ggsave: Save a ggplot (or other grid object) with sensible defaults...

Description Usage Arguments Author(s) Examples

View source: R/save.R

Description

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.

Usage

1
2
3
ggsave(filename, plot = last_plot(), device = NULL, path = NULL,
  scale = 1, width = NA, height = NA, units = c("in", "cm", "mm"),
  dpi = 300, limitsize = TRUE, ...)

Arguments

filename

File name to create on disk.

plot

Plot to save, defaults to last plot displayed.

device

Device to use (function or any of the recognized extensions, e.g. "pdf"). By default, extracted from filename extension. ggsave currently recognises eps/ps, tex (pictex), pdf, jpeg, tiff, png, bmp, svg and wmf (windows only).

path

Path to save plot to (combined with filename).

scale

Multiplicative scaling factor.

width, height

Plot dimensions, defaults to size of current graphics device.

units

Units for width and height when specified explicitly (in, cm, or mm)

dpi

Resolution used for raster outputs.

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

Author(s)

Nicholas Hamilton

Examples

1
2
3
4
5
6
## Not run: 
data(Feldspar)
base = ggtern(Feldspar,aes(Ab,An,Or)) + geom_point()
ggsave("./output.pdf",base,width=10,height=10)

## End(Not run)

Example output

Loading required package: ggplot2
--
Consider donating at: http://ggtern.com
Even small amounts (say $10-50) are very much appreciated!
Remember to cite, run citation(package = 'ggtern') for further info.
--

Attaching package: 'ggtern'

The following objects are masked from 'package:ggplot2':

    %+%, aes, annotate, calc_element, ggplot, ggplotGrob, ggplot_build,
    ggplot_gtable, ggsave, layer_data, theme, theme_bw, theme_classic,
    theme_dark, theme_gray, theme_light, theme_linedraw, theme_minimal,
    theme_void

ggtern documentation built on Nov. 6, 2018, 5:07 p.m.