ggsave {ggplot2} | R Documentation |
Save a ggplot with sensible defaults
ggsave(plot = last_plot(), filename=default_name(plot), device=default_device(filename), scale=1, width=par("din")[1], height=par("din")[2], dpi=72, path="", keep = plot$options$keep, drop = plot$options$drop, ...)
plot |
plot to save, defaults to last plot displayed |
filename |
file name/path of plot |
device |
device to use, automatically extract from file name extension |
scale |
scaling factor |
width |
width (in inches) |
height |
height (in inches) |
dpi |
dpi to use for raster graphics |
path |
path where file should be saved (if filename unspecified) |
keep |
other arguments passed to graphics device |
drop |
|
... |
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 guess the type of graphics device from the extension. This means the only argument you need to supply is the path.
ggsave
currently recognises the extensions ps, tex (pictex), pdf,
tiff, png, bmp and wmf (windows only).
Hadley Wickham <h.wickham@gmail.com>
## Not run: ratings <- qplot(rating, data=movies, geom="histogram") qplot(length, data=movies, geom="histogram") ggsave(file="length-hist.pdf") ggsave(file="length-hist.png") ggsave(ratings, file="ratings.pdf") ggsave(ratings, file="ratings.pdf", width=4, height=4) # make twice as big as on screen ggsave(ratings, file="ratings.pdf", scale=2) ## End(Not run)