\HeaderA{ggsave}{ggsave}{ggsave}
\keyword{file}{ggsave}
\begin{Description}\relax
Save a ggplot with sensible defaults
\end{Description}
\begin{Usage}
\begin{verbatim}ggsave(plot = .last_plot, filename=default_name(plot), device=default_device(filename), scale=1, width=par("din")[1], height=par("din")[2], dpi=96, ...)\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{plot}] plot to save, defaults to last plot displayed
\item[\code{filename}] file name/path of plot
\item[\code{device}] device to use, automatically extract from file name extension
\item[\code{scale}] scaling factor
\item[\code{width}] width (in inches)
\item[\code{height}] height (in inches)
\item[\code{dpi}] dpi to use for raster graphics
\item[\code{...}] other arguments passed to graphics device
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
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.
\end{Details}
\begin{Author}\relax
Hadley Wickham <h.wickham@gmail.com>
\end{Author}
\begin{Examples}
\begin{ExampleCode}## 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)\end{ExampleCode}
\end{Examples}

