File: geom_boxplot.rd

package info (click to toggle)
r-cran-ggplot2 0.8.9-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,084 kB
  • sloc: makefile: 3
file content (89 lines) | stat: -rw-r--r-- 3,453 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
\name{geom_boxplot}
\alias{geom_boxplot}
\alias{GeomBoxplot}
\title{geom\_boxplot}
\description{Box and whiskers plot}
\details{
This page describes geom\_boxplot, 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 geom\_boxplot.  Aesthetics are mapped to variables in the data with the aes function: \code{geom\_boxplot(aes(x = var))}
\itemize{
  \item \code{x}: x position (\strong{required}) 
  \item \code{lower}: NULL (\strong{required}) 
  \item \code{upper}: NULL (\strong{required}) 
  \item \code{middle}: NULL (\strong{required}) 
  \item \code{ymin}: bottom (vertical minimum) (\strong{required}) 
  \item \code{ymax}: top (vertical maximum) (\strong{required}) 
  \item \code{weight}: observation weight used in statistical transformation 
  \item \code{colour}: border colour 
  \item \code{fill}: internal colour 
  \item \code{size}: size 
  \item \code{alpha}: transparency 
}
}
\usage{geom_boxplot(mapping = NULL, data = NULL, stat = "boxplot", position = "dodge", 
    outlier.colour = "black", outlier.shape = 16, outlier.size = 2, 
    ...)}
\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{stat}{statistic used by this layer}
 \item{position}{position adjustment used by this layer}
 \item{outlier.colour}{colour for outlying points}
 \item{outlier.shape}{shape of outlying points}
 \item{outlier.size}{size of outlying points}
 \item{...}{other arguments}
}
\seealso{\itemize{
  \item \code{\link{stat_quantile}}: View quantiles conditioned on a continuous variable
  \item \code{\link{geom_jitter}}: Another way to look at conditional distributions
  \item \url{http://had.co.nz/ggplot2/geom_boxplot.html}
}}
\value{A \code{\link{layer}}}
\examples{\dontrun{
p <- ggplot(mtcars, aes(factor(cyl), mpg))

p + geom_boxplot()
qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot")

p + geom_boxplot() + geom_jitter()
p + geom_boxplot() + coord_flip()
qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot") +
  coord_flip()

p + geom_boxplot(outlier.colour = "green", outlier.size = 3)

# Add aesthetic mappings
# Note that boxplots are automatically dodged when any aesthetic is 
# a factor
p + geom_boxplot(aes(fill = cyl))
p + geom_boxplot(aes(fill = factor(cyl)))
p + geom_boxplot(aes(fill = factor(vs)))
p + geom_boxplot(aes(fill = factor(am)))

# Set aesthetics to fixed value
p + geom_boxplot(fill="grey80", colour="#3366FF")
qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot", 
  colour = I("#3366FF"))

# Scales vs. coordinate transforms -------
# Scale transformations occur before the boxplot statistics are computed.
# Coordinate transformations occur afterwards.  Observe the effect on the
# number of outliers.
m <- ggplot(movies, aes(y = votes, x = rating,
   group = round_any(rating, 0.5)))
m + geom_boxplot()
m + geom_boxplot() + scale_y_log10()
m + geom_boxplot() + coord_trans(y = "log10")
m + geom_boxplot() + scale_y_log10() + coord_trans(y = "log10")

# Boxplots with continuous x:
# Use the group aesthetic to group observations in boxplots
qplot(year, budget, data = movies, geom = "boxplot")
qplot(year, budget, data = movies, geom = "boxplot", 
  group = round_any(year, 10, floor))

}}
\author{Hadley Wickham, \url{http://had.co.nz/}}
\keyword{hplot}