Drop unused data from the plot to reduce the object size
Usage
slim_data(p)
# S3 method for class 'ggplot'
slim_data(p)
# S3 method for class 'patchwork'
slim_data(p)Examples
library(ggplot2)
p <- ggplot(data = mtcars, aes(x = mpg, y = wt, colour = cyl)) +
  geom_point()
object.size(p)
#> 14928 bytes
colnames(p$data)
#>  [1] "mpg"  "cyl"  "disp" "hp"   "drat" "wt"   "qsec" "vs"   "am"   "gear" "carb"
p_slim <- slim_data(p)
object.size(p_slim)
#> 11856 bytes
colnames(p_slim$data)
#> [1] "mpg" "cyl" "wt"