|
25 | 25 | #' @inheritParams geom_point
|
26 | 26 | #' @param geom,stat Use to override the default connection between
|
27 | 27 | #' \code{geom_boxplot} and \code{stat_boxplot}.
|
28 |
| -#' @param outlier.colour Override aesthetics used for the outliers. Defaults |
29 |
| -#' come from \code{geom_point()}. |
30 |
| -#' @param outlier.shape Override aesthetics used for the outliers. Defaults |
31 |
| -#' come from \code{geom_point()}. |
32 |
| -#' @param outlier.size Override aesthetics used for the outliers. Defaults |
33 |
| -#' come from \code{geom_point()}. |
34 |
| -#' @param outlier.stroke Override aesthetics used for the outliers. Defaults |
35 |
| -#' come from \code{geom_point()}. |
| 28 | +#' @param outlier.colour,outlier.shape,outlier.size,outlier.stroke Default |
| 29 | +#' aesthetics for outliers. Set to \code{NULL} to inherit from the aesthetics |
| 30 | +#' used for the box. |
36 | 31 | #' @param notch if \code{FALSE} (default) make a standard box plot. If
|
37 | 32 | #' \code{TRUE}, make a notched box plot. Notches are used to compare groups;
|
38 | 33 | #' if the notches of two boxes do not overlap, this suggests that the medians
|
|
55 | 50 | #' p + geom_boxplot(notch = TRUE)
|
56 | 51 | #' p + geom_boxplot(varwidth = TRUE)
|
57 | 52 | #' p + geom_boxplot(fill = "white", colour = "#3366FF")
|
| 53 | +#' # By default, outlier points match the colour of the box. Use |
| 54 | +#' # outlier.colour to override |
58 | 55 | #' p + geom_boxplot(outlier.colour = "red", outlier.shape = 1)
|
59 | 56 | #'
|
60 | 57 | #' # Boxplots are automatically dodged when any aesthetic is a factor
|
61 |
| -#' p + geom_boxplot(aes(fill = drv)) |
| 58 | +#' p + geom_boxplot(aes(colour = drv)) |
62 | 59 | #'
|
63 | 60 | #' # You can also use boxplots with continuous x, as long as you supply
|
64 | 61 | #' # a grouping variable. cut_width is particularly useful
|
|
86 | 83 | #' )
|
87 | 84 | #' }
|
88 | 85 | geom_boxplot <- function(mapping = NULL, data = NULL, stat = "boxplot",
|
89 |
| - position = "dodge", outlier.colour = "black", |
| 86 | + position = "dodge", outlier.colour = NULL, |
90 | 87 | outlier.shape = 19, outlier.size = 1.5,
|
91 | 88 | outlier.stroke = 0.5, notch = FALSE, notchwidth = 0.5,
|
92 | 89 | varwidth = FALSE, na.rm = FALSE,
|
@@ -152,6 +149,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom,
|
152 | 149 | outlier.colour = "black", outlier.shape = 19,
|
153 | 150 | outlier.size = 1.5, outlier.stroke = 0.5,
|
154 | 151 | notch = FALSE, notchwidth = 0.5, varwidth = FALSE) {
|
| 152 | + |
155 | 153 | common <- data.frame(
|
156 | 154 | colour = data$colour,
|
157 | 155 | size = data$size,
|
@@ -212,8 +210,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom,
|
212 | 210 | draw_key = draw_key_boxplot,
|
213 | 211 |
|
214 | 212 | default_aes = aes(weight = 1, colour = "grey20", fill = "white", size = 0.5,
|
215 |
| - alpha = NA, shape = 19, linetype = "solid", outlier.colour = "black", |
216 |
| - outlier.shape = 19, outlier.size = 1.5, outlier.stroke = 0.5), |
| 213 | + alpha = NA, shape = 19, linetype = "solid"), |
217 | 214 |
|
218 | 215 | required_aes = c("x", "lower", "upper", "middle", "ymin", "ymax")
|
219 | 216 | )
|
0 commit comments