Description Usage Arguments Examples
ggsave()
is a convenient function for saving a plot. It defaults to
saving the last plot that you displayed, using the size of the current
graphics device. It also guesses the type of graphics device from the
extension.
1 2 3 |
filename |
File name to create on disk. |
plot |
Plot to save, defaults to last plot displayed. |
device |
Device to use. Can be either be a device function
(e.g. |
path |
Path to save plot to (combined with filename). |
scale |
Multiplicative scaling factor. |
width, height, units |
Plot size in |
dpi |
Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types. |
limitsize |
When |
... |
Other arguments passed on to the graphics device function,
as specified by |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
ggplot(mtcars, aes(mpg, wt)) + geom_point()
ggsave("mtcars.pdf")
ggsave("mtcars.png")
ggsave("mtcars.pdf", width = 4, height = 4)
ggsave("mtcars.pdf", width = 20, height = 20, units = "cm")
# delete files with base::unlink()
unlink("mtcars.pdf")
unlink("mtcars.png")
# specify device when saving to a file with unknown extension
# (for example a server supplied temporary file)
file <- tempfile()
ggsave(file, device = "pdf")
unlink(file)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.