ggrasterize | R Documentation |
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).
ggrasterize(
plot = ggplot2::last_plot(),
filename = NULL,
device = NULL,
path = NULL,
scale = 1,
width = NA,
height = NA,
dpi = 300,
units = c("in", "cm", "mm"),
limitsize = TRUE,
...
)
plot |
Plot to save, defaults to last plot displayed. |
filename |
File name to create on disk. |
device |
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). If
|
path |
Path of the directory to save plot to: |
scale |
Multiplicative scaling factor. |
width , height |
Plot size in units expressed by the |
dpi |
Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types. |
units |
One of the following units in which the |
limitsize |
When |
... |
Other arguments passed on to the graphics device function,
as specified by |
ggsave
## Not run:
library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point()
ggrasterize(p)
# save to a pdf file
ggrasterize(p, "myfile.pdf")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.