grobsave: Save a ggplot with sensible defaults

Description Usage Arguments Details Examples

Description

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.

Usage

1
2
3
4
grobsave(filename = default_name(plot), plot = NULL,
  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, ...)

Arguments

filename

file name/filename of plot

plot

plot to save. This needs to be specified, otherwise the function will fail.

device

device to use, automatically extract from file name extension

path

path to save plot to (if you just want to set path and not filename)

scale

scaling factor

width

width (defaults to the width of current plotting window)

height

height (defaults to the height of current plotting window)

units

units for width and height when either one is explicitly specified (in, cm, or mm)

dpi

dpi to use for raster graphics

limitsize

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 to graphics device

Details

grobsave currently recognises the extensions eps/ps, tex (pictex), pdf, jpeg, tiff, png, bmp, svg and wmf (windows only).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
ratings <- qplot(rating, data=movies, geom="histogram")
qplot(length, data=movies, geom="histogram")
ggsave("length-hist.pdf")
ggsave("length-hist.png")
ggsave("ratings.pdf", ratings)
ggsave("ratings.pdf", ratings, width=4, height=4)
# make twice as big as on screen
ggsave("ratings.pdf", ratings, scale=2)

## End(Not run)

johnDorian/ggsnippets documentation built on May 19, 2019, 3:02 p.m.