Skip to contents

Drop unused data from the plot to reduce the object size

Usage

slim_data(p)

# S3 method for ggplot
slim_data(p)

# S3 method for patchwork
slim_data(p)

Arguments

p

A patchwork object.

Examples

library(ggplot2)
p <- ggplot(data = mtcars, aes(x = mpg, y = wt, colour = cyl)) +
  geom_point()
object.size(p)
#> 13984 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)
#> 10912 bytes
colnames(p_slim$data)
#> [1] "mpg" "cyl" "wt"