forked from tidyverse/ggplot2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathggsave.Rd
65 lines (51 loc) · 1.93 KB
/
ggsave.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/save.r
\name{ggsave}
\alias{ggsave}
\title{Save a ggplot (or other grid object) with sensible defaults}
\usage{
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{
\item{filename}{File name to create on disk.}
\item{plot}{Plot to save, defaults to last plot displayed.}
\item{device}{Device to use (function or any of the recognized extensions,
e.g. \code{"pdf"}). By default, extracted from filename extension.
\code{ggsave} currently recognises eps/ps, tex (pictex), pdf, jpeg, tiff,
png, bmp, svg and wmf (windows only).}
\item{path}{Path to save plot to (combined with filename).}
\item{scale}{Multiplicative scaling factor.}
\item{width,height}{Plot dimensions, defaults to size of current graphics
device.}
\item{units}{Units for width and height when specified explicitly (in, cm,
or mm)}
\item{dpi}{Resolution used for raster outputs.}
\item{limitsize}{When \code{TRUE} (the default), \code{ggsave} will not
save images larger than 50x50 inches, to prevent the common error of
specifying dimensions in pixels.}
\item{...}{Other arguments passed on to graphics device}
}
\description{
\code{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.
}
\examples{
\dontrun{
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")
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)
}
}