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
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.r
\name{print.ggplot}
\alias{print.ggplot}
\alias{plot.ggplot}
\title{Explicitly draw plot}
\usage{
\method{print}{ggplot}(x, newpage = is.null(vp), vp = NULL, ...)
\method{plot}{ggplot}(x, newpage = is.null(vp), vp = NULL, ...)
}
\arguments{
\item{x}{plot to display}
\item{newpage}{draw new (empty) page first?}
\item{vp}{viewport to draw plot in}
\item{...}{other arguments not used by this method}
}
\value{
Invisibly returns the original plot.
}
\description{
Generally, you do not need to print or plot a ggplot2 plot explicitly: the
default top-level print method will do it for you. You will, however, need
to call \code{print()} explicitly if you want to draw a plot inside a
function or for loop.
}
\examples{
colours <- list(~class, ~drv, ~fl)
# Doesn't seem to do anything!
for (colour in colours) {
ggplot(mpg, aes_(~ displ, ~ hwy, colour = colour)) +
geom_point()
}
# Works when we explicitly print the plots
for (colour in colours) {
print(ggplot(mpg, aes_(~ displ, ~ hwy, colour = colour)) +
geom_point())
}
}
\keyword{hplot}
|