ggsave(filename = default_name(plot), plot = last_plot(), device = default_device(filename),
path = NULL, scale = 1, width = par("din")[1], height = par("din")[2], units = c("in",
"cm", "mm"), dpi = 300, limitsize = TRUE, ...)
TRUE (the default),
ggsave will not save images larger than 50x50
inches, to prevent the common error of specifying
dimensions in pixels.ggsave is a convenient function for saving a plot. It defaults to saving the last plot that you displayed, and for a default size uses the size of the current graphics device. It also guesses the type of graphics device from the extension. This means the only argument you need to supply is the filename.
ggsave currently recognises the extensions eps/ps,
tex (pictex), pdf, jpeg, tiff, png, bmp, svg and wmf
(windows only).
ratings <- qplot(rating, data=movies, geom="histogram") qplot(length, data=movies, geom="histogram")stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
ggsave(file="length-hist.pdf")Saving 5 x 5 in image stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.ggsave(file="length-hist.png")Saving 5 x 5 in image stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.ggsave(ratings, file="ratings.pdf")Saving 5 x 5 in image stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.ggsave(ratings, file="ratings.pdf", width=4, height=4)stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.# make twice as big as on screen ggsave(ratings, file="ratings.pdf", scale=2)Saving 10 x 10 in image stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.