|
23 | 23 | #' continuous variable, \code{\link{geom_jitter}} for another way to look
|
24 | 24 | #' at conditional distributions"
|
25 | 25 | #' @inheritParams geom_point
|
26 |
| -#' @param outlier.colour colour for outlying points |
27 |
| -#' @param outlier.shape shape of outlying points |
28 |
| -#' @param outlier.size size of outlying points |
| 26 | +#' @param outlier.colour colour for outlying points. Uses the default from geom_point(). |
| 27 | +#' @param outlier.shape shape of outlying points. Uses the default from geom_point(). |
| 28 | +#' @param outlier.size size of outlying points. Uses the default from geom_point(). |
29 | 29 | #' @param notch if \code{FALSE} (default) make a standard box plot. If
|
30 | 30 | #' \code{TRUE}, make a notched box plot. Notches are used to compare groups;
|
31 | 31 | #' if the notches of two boxes do not overlap, this is strong evidence that
|
|
100 | 100 | #' # Using varwidth
|
101 | 101 | #' p + geom_boxplot(varwidth = TRUE)
|
102 | 102 | #' qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot", varwidth = TRUE)
|
| 103 | +#' |
| 104 | +#' # Update the defaults for the outliers by changing the defaults for geom_point |
| 105 | +#' |
| 106 | +#' p <- ggplot(mtcars, aes(factor(cyl), mpg)) |
| 107 | +#' p + geom_boxplot() |
| 108 | +#' |
| 109 | +#' update_geom_defaults("point", list(shape = 1, colour = "red", size = 5)) |
| 110 | +#' p + geom_boxplot() |
103 | 111 | #' }
|
104 |
| -geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot", position = "dodge", |
105 |
| -outlier.colour = "black", outlier.shape = 16, outlier.size = 2, |
106 |
| -notch = FALSE, notchwidth = .5, varwidth = FALSE, ...) { |
| 112 | +geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot", |
| 113 | + position = "dodge", outlier.colour = NULL, |
| 114 | + outlier.shape = NULL, outlier.size = NULL, |
| 115 | + notch = FALSE, notchwidth = .5, ...) { |
| 116 | + |
| 117 | + outlier_defaults <- Geom$find('point')$default_aes() |
| 118 | + |
| 119 | + outlier.colour <- outlier.colour %||% outlier_defaults$colour |
| 120 | + outlier.shape <- outlier.shape %||% outlier_defaults$shape |
| 121 | + outlier.size <- outlier.size %||% outlier_defaults$size |
| 122 | + |
107 | 123 | GeomBoxplot$new(mapping = mapping, data = data, stat = stat,
|
108 |
| - position = position, outlier.colour = outlier.colour, outlier.shape = outlier.shape, |
109 |
| - outlier.size = outlier.size, notch = notch, notchwidth = notchwidth, varwidth = varwidth, ...) |
| 124 | + position = position, outlier.colour = outlier.colour, |
| 125 | + outlier.shape = outlier.shape, outlier.size = outlier.size, notch = notch, |
| 126 | + notchwidth = notchwidth, ...) |
110 | 127 | }
|
111 | 128 |
|
112 | 129 | GeomBoxplot <- proto(Geom, {
|
|
0 commit comments