Draws the panel area of a ggplot to a png file, and then re-draws it as raster to the current device. There is also an option to save the result to a file (if filename
is not NULL).
Plot to save, defaults to last plot displayed.
File name to create on disk.
Device to use. Can either be a device function (e.g. png), or one of "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf" (windows only).
Path of the directory to save plot to: path
and filename
are combined to create the fully qualified file name. Defaults to the
working directory.
Multiplicative scaling factor.
Plot size in units
("in", "cm", "mm", or "px").
If not supplied, uses the size of current graphics device.
Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types.
When TRUE
(the default), ggsave()
will not
save images larger than 50x50 inches, to prevent the common error of
specifying dimensions in pixels.
Other arguments passed on to the graphics device function,
as specified by device
.
if (FALSE) {
library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point()
ggrasterize(p)
# save to a pdf file
ggrasterize(p, "myfile.pdf")
}