Skip to content

Commit ec5b4d7

Browse files
committed
Support US spelling: outlier.color.
Fixes #1455
1 parent 271a3e2 commit ec5b4d7

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggplot2 2.0.0.9000
22

3+
* `geom_boxplot()` now understands `outlier.color` (#1455).
4+
35
* `geom_histgram(bins = n)` now gives a histogram with `n` bins, not `n + 1`
46
(#1487).
57

R/geom-boxplot.r

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@
2525
#' @inheritParams geom_point
2626
#' @param geom,stat Use to override the default connection between
2727
#' \code{geom_boxplot} and \code{stat_boxplot}.
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.
28+
#' @param outlier.colour,outlier.color,outlier.shape,outlier.size,outlier.stroke
29+
#' Default aesthetics for outliers. Set to \code{NULL} to inherit from the
30+
#' aesthetics used for the box.
31+
#'
32+
#' In the unlikely event you specify both US and UK spellings of colour, the
33+
#' US spelling will take precedence.
3134
#' @param notch if \code{FALSE} (default) make a standard box plot. If
3235
#' \code{TRUE}, make a notched box plot. Notches are used to compare groups;
3336
#' if the notches of two boxes do not overlap, this suggests that the medians
@@ -87,7 +90,8 @@ geom_boxplot <- function(mapping = NULL, data = NULL, stat = "boxplot",
8790
outlier.shape = 19, outlier.size = 1.5,
8891
outlier.stroke = 0.5, notch = FALSE, notchwidth = 0.5,
8992
varwidth = FALSE, na.rm = FALSE,
90-
show.legend = NA, inherit.aes = TRUE, ...) {
93+
show.legend = NA, inherit.aes = TRUE, ...,
94+
outlier.color = NULL) {
9195
layer(
9296
data = data,
9397
mapping = mapping,
@@ -97,7 +101,7 @@ geom_boxplot <- function(mapping = NULL, data = NULL, stat = "boxplot",
97101
show.legend = show.legend,
98102
inherit.aes = inherit.aes,
99103
params = list(
100-
outlier.colour = outlier.colour,
104+
outlier.colour = outlier.color %||% outlier.colour,
101105
outlier.shape = outlier.shape,
102106
outlier.size = outlier.size,
103107
outlier.stroke = outlier.stroke,

man/geom_boxplot.Rd

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-geom-boxplot.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
context("geom_boxplot")
2+
3+
test_that("can use US spelling of colour", {
4+
df <- data.frame(x = 1, y = c(1:5, 100))
5+
plot <- ggplot(df, aes(x, y)) + geom_boxplot(outlier.color = "red")
6+
7+
gpar <- layer_grob(plot)[[1]]$children[[1]]$children[[1]]$gp
8+
expect_equal(gpar$col, "#FF0000FF")
9+
})

0 commit comments

Comments
 (0)