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 65 66 67 68 69 70 71 72 73 74
|
\name{stat_contour}
\alias{stat_contour}
\alias{StatContour}
\title{stat\_contour}
\description{Contours of 3d data}
\details{
This page describes stat\_contour, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\section{Aesthetics}{
The following aesthetics can be used with stat\_contour. Aesthetics are mapped to variables in the data with the aes function: \code{stat\_contour(aes(x = var))}
\itemize{
\item \code{x}: x position (\strong{required})
\item \code{y}: y position (\strong{required})
\item \code{z}: NULL (\strong{required})
\item \code{order}: NULL
}
}
\usage{stat_contour(mapping = NULL, data = NULL, geom = "path", position = "identity",
na.rm = FALSE, ...)}
\arguments{
\item{mapping}{mapping between variables and aesthetics generated by aes}
\item{data}{dataset used in this layer, if not specified uses plot dataset}
\item{geom}{geometric used by this layer}
\item{position}{position adjustment used by this layer}
\item{na.rm}{NULL}
\item{...}{ignored }
}
\seealso{\itemize{
\item \url{http://had.co.nz/ggplot2/stat_contour.html}
}}
\value{A \code{\link{layer}}}
\examples{\dontrun{
# Generate data
volcano3d <- melt(volcano)
names(volcano3d) <- c("x", "y", "z")
# Basic plot
v <- ggplot(volcano3d, aes(x, y, z = z))
v + stat_contour()
# Setting bins creates evenly spaced contours in the range of the data
v + stat_contour(bins = 2)
v + stat_contour(bins = 10)
# Setting binwidth does the same thing, parameterised by the distance
# between contours
v + stat_contour(binwidth = 2)
v + stat_contour(binwidth = 5)
v + stat_contour(binwidth = 10)
v + stat_contour(binwidth = 2, size = 0.5, colour = "grey50") +
stat_contour(binwidth = 10, size = 1)
# Add aesthetic mappings
v + stat_contour(aes(size = ..level..))
v + stat_contour(aes(colour = ..level..))
# Change scale
v + stat_contour(aes(colour = ..level..), size = 2) +
scale_colour_gradient(low = "brown", high = "white")
# Set aesthetics to fixed value
v + stat_contour(colour = "red")
v + stat_contour(size = 2, linetype = 4)
# Try different geoms
v + stat_contour(geom="polygon", aes(fill=..level..))
v + geom_tile(aes(fill = z)) + stat_contour()
# Use qplot instead
qplot(x, y, z, data = volcano3d, geom = "contour")
qplot(x, y, z, data = volcano3d, stat = "contour", geom = "path")
}}
\author{Hadley Wickham, \url{http://had.co.nz/}}
\keyword{hplot}
|