|
| 1 | +% Generated by roxygen2 (4.0.0): do not edit by hand |
1 | 2 | \name{geom_boxplot}
|
2 | 3 | \alias{geom_boxplot}
|
3 | 4 | \title{Box and whiskers plot.}
|
4 | 5 | \usage{
|
5 |
| - geom_boxplot(mapping = NULL, data = NULL, |
6 |
| - stat = "boxplot", position = "dodge", |
7 |
| - outlier.colour = "black", outlier.shape = 16, |
8 |
| - outlier.size = 2, notch = FALSE, notchwidth = 0.5, ...) |
| 6 | +geom_boxplot(mapping = NULL, data = NULL, stat = "boxplot", |
| 7 | + position = "dodge", outlier.colour = NULL, outlier.shape = NULL, |
| 8 | + outlier.size = NULL, notch = FALSE, notchwidth = 0.5, ...) |
9 | 9 | }
|
10 | 10 | \arguments{
|
11 |
| - \item{outlier.colour}{colour for outlying points} |
| 11 | +\item{outlier.colour}{colour for outlying points. Uses the default from geom_point().} |
12 | 12 |
|
13 |
| - \item{outlier.shape}{shape of outlying points} |
| 13 | +\item{outlier.shape}{shape of outlying points. Uses the default from geom_point().} |
14 | 14 |
|
15 |
| - \item{outlier.size}{size of outlying points} |
| 15 | +\item{outlier.size}{size of outlying points. Uses the default from geom_point().} |
16 | 16 |
|
17 |
| - \item{notch}{if \code{FALSE} (default) make a standard |
18 |
| - box plot. If \code{TRUE}, make a notched box plot. |
19 |
| - Notches are used to compare groups; if the notches of two |
20 |
| - boxes do not overlap, this is strong evidence that the |
21 |
| - medians differ.} |
| 17 | +\item{notch}{if \code{FALSE} (default) make a standard box plot. If |
| 18 | +\code{TRUE}, make a notched box plot. Notches are used to compare groups; |
| 19 | +if the notches of two boxes do not overlap, this is strong evidence that |
| 20 | +the medians differ.} |
22 | 21 |
|
23 |
| - \item{notchwidth}{for a notched box plot, width of the |
24 |
| - notch relative to the body (default 0.5)} |
| 22 | +\item{notchwidth}{for a notched box plot, width of the notch relative to |
| 23 | +the body (default 0.5)} |
25 | 24 |
|
26 |
| - \item{mapping}{The aesthetic mapping, usually constructed |
27 |
| - with \code{\link{aes}} or \code{\link{aes_string}}. Only |
28 |
| - needs to be set at the layer level if you are overriding |
29 |
| - the plot defaults.} |
| 25 | +\item{mapping}{The aesthetic mapping, usually constructed with |
| 26 | +\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set |
| 27 | +at the layer level if you are overriding the plot defaults.} |
30 | 28 |
|
31 |
| - \item{data}{A layer specific dataset - only needed if you |
32 |
| - want to override the plot defaults.} |
| 29 | +\item{data}{A layer specific dataset - only needed if you want to override |
| 30 | +the plot defaults.} |
33 | 31 |
|
34 |
| - \item{stat}{The statistical transformation to use on the |
35 |
| - data for this layer.} |
| 32 | +\item{stat}{The statistical transformation to use on the data for this |
| 33 | +layer.} |
36 | 34 |
|
37 |
| - \item{position}{The position adjustment to use for |
38 |
| - overlappling points on this layer} |
| 35 | +\item{position}{The position adjustment to use for overlapping points |
| 36 | +on this layer} |
39 | 37 |
|
40 |
| - \item{...}{other arguments passed on to |
41 |
| - \code{\link{layer}}. This can include aesthetics whose |
42 |
| - values you want to set, not map. See \code{\link{layer}} |
43 |
| - for more details.} |
| 38 | +\item{...}{other arguments passed on to \code{\link{layer}}. This can |
| 39 | +include aesthetics whose values you want to set, not map. See |
| 40 | +\code{\link{layer}} for more details.} |
44 | 41 | }
|
45 | 42 | \description{
|
46 |
| - The upper and lower "hinges" correspond to the first and |
47 |
| - third quartiles (the 25th and 75th percentiles). This |
48 |
| - differs slightly from the method used by the |
49 |
| - \code{boxplot} function, and may be apparent with small |
50 |
| - samples. See \code{\link{boxplot.stats}} for for more |
51 |
| - information on how hinge positions are calculated for |
52 |
| - \code{boxplot}. |
| 43 | +The upper and lower "hinges" correspond to the first and third quartiles |
| 44 | +(the 25th and 75th percentiles). This differs slightly from the method used |
| 45 | +by the \code{boxplot} function, and may be apparent with small samples. |
| 46 | +See \code{\link{boxplot.stats}} for for more information on how hinge |
| 47 | +positions are calculated for \code{boxplot}. |
53 | 48 | }
|
54 | 49 | \details{
|
55 |
| - The upper whisker extends from the hinge to the highest |
56 |
| - value that is within 1.5 * IQR of the hinge, where IQR is |
57 |
| - the inter-quartile range, or distance between the first |
58 |
| - and third quartiles. The lower whisker extends from the |
59 |
| - hinge to the lowest value within 1.5 * IQR of the hinge. |
60 |
| - Data beyond the end of the whiskers are outliers and |
61 |
| - plotted as points (as specified by Tukey). |
62 |
| - |
63 |
| - In a notched box plot, the notches extend \code{1.58 * |
64 |
| - IQR / sqrt(n)}. This gives a roughly 95% confidence |
65 |
| - interval for comparing medians. See McGill et al. (1978) |
66 |
| - for more details. |
| 50 | +The upper whisker extends from the hinge to the highest value that is within |
| 51 | +1.5 * IQR of the hinge, where IQR is the inter-quartile range, or distance |
| 52 | +between the first and third quartiles. The lower whisker extends from the |
| 53 | +hinge to the lowest value within 1.5 * IQR of the hinge. Data beyond the |
| 54 | +end of the whiskers are outliers and plotted as points (as specified by Tukey). |
| 55 | + |
| 56 | +In a notched box plot, the notches extend \code{1.58 * IQR / sqrt(n)}. |
| 57 | +This gives a roughly 95% confidence interval for comparing medians. |
| 58 | +See McGill et al. (1978) for more details. |
67 | 59 | }
|
68 | 60 | \section{Aesthetics}{
|
69 |
| - \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", |
70 |
| - "boxplot")} |
| 61 | + |
| 62 | +\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "boxplot")} |
71 | 63 | }
|
72 | 64 | \examples{
|
73 | 65 | \donttest{
|
@@ -124,16 +116,23 @@ b <- ggplot(abc, aes(x = X1, ymin = `0\%`, lower = `25\%`, middle = `50\%`, uppe
|
124 | 116 | b + geom_boxplot(stat = "identity")
|
125 | 117 | b + geom_boxplot(stat = "identity") + coord_flip()
|
126 | 118 | b + geom_boxplot(aes(fill = X1), stat = "identity")
|
| 119 | + |
| 120 | +# Update the defaults for the outliers by changing the defaults for geom_point |
| 121 | + |
| 122 | +p <- ggplot(mtcars, aes(factor(cyl), mpg)) |
| 123 | +p + geom_boxplot() |
| 124 | + |
| 125 | +update_geom_defaults("point", list(shape = 1, colour = "red", size = 5)) |
| 126 | +p + geom_boxplot() |
127 | 127 | }
|
128 | 128 | }
|
129 | 129 | \references{
|
130 |
| - McGill, R., Tukey, J. W. and Larsen, W. A. (1978) |
131 |
| - Variations of box plots. The American Statistician 32, |
132 |
| - 12-16. |
| 130 | +McGill, R., Tukey, J. W. and Larsen, W. A. (1978) Variations of |
| 131 | + box plots. The American Statistician 32, 12-16. |
133 | 132 | }
|
134 | 133 | \seealso{
|
135 |
| - \code{\link{stat_quantile}} to view quantiles conditioned |
136 |
| - on a continuous variable, \code{\link{geom_jitter}} for |
137 |
| - another way to look at conditional distributions" |
| 134 | +\code{\link{stat_quantile}} to view quantiles conditioned on a |
| 135 | + continuous variable, \code{\link{geom_jitter}} for another way to look |
| 136 | + at conditional distributions" |
138 | 137 | }
|
139 | 138 |
|
0 commit comments