Drop unused data in the plot
Usage
drop_data(p)
# S3 method for class 'ggplot'
drop_data(p)
# S3 method for class 'patchwork'
drop_data(p)
# Default S3 method
drop_data(p)
Examples
library(ggplot2)
p <- ggplot(data = mtcars, aes(x = mpg, y = wt, colour = cyl)) +
geom_point() +
scale_x_continuous(limits = c(10, 30)) +
scale_y_continuous(limits = c(1, 6)) +
theme_scop()
object.size(p)
#> 6144696 bytes
p_drop <- drop_data(p)
object.size(p_drop)
#> 6139648 bytes
p / p_drop
#> Warning: Removed 4 rows containing missing values or values outside the scale range
#> (`geom_point()`).