Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Specify alpha for outlier points in geom_boxplot. #1644

Merged
merged 10 commits into from Sep 15, 2016
View
1 NEWS
@@ -1,4 +1,3 @@
-
ggplot2 1.0.1
----------------------------------------------------------------
View
13 NEWS.md
@@ -1,5 +1,10 @@
# ggplot2 2.1.0.9000
+* `geom_boxplot` gain new `outlier.alpha` argument for controlling the alpha of
+ outlier points independently of the alpha of the boxes.
+ Analogous to outlier.colour, outlier.shape, etc.
+ (@jonathan-g).
+
* FP adjustment for histogram bins is now actually used - it was previously
inadvertently ignored (#1651).
@@ -57,7 +62,7 @@
* Minor code formatting and grammar issues in examples and function
parameters were fixed. (@hrbrmstr)
-
+
* `geom_col()` was added to complement `geom_bar()`. It uses `stat="identity"`
by default, making the `y` aesthetic mandatory. It does not support any
other `stat_()` and does not provide fallback support for the `binwidth`
@@ -66,7 +71,7 @@
* Fix error message of Stats ggprotos when required aesthetics are
missing.
-
+
* Fix bug that resulted in several annotation_x function not getting drawn when
global data was lacking (#1655)
@@ -136,9 +141,9 @@
* `bins = n` now gives a histogram with `n` bins, not `n + 1` (#1487).
-## Bug fixes
+## Bug fixes
-* All `\donttest{}` examples run.
+* All `\donttest{}` examples run.
* All `geom_()` and `stat_()` functions now have consistent argument order:
data + mapping, then geom/stat/position, then `...`, then specific arguments,
View
@@ -26,7 +26,7 @@
#' @inheritParams geom_point
#' @param geom,stat Use to override the default connection between
#' \code{geom_boxplot} and \code{stat_boxplot}.
-#' @param outlier.colour,outlier.color,outlier.shape,outlier.size,outlier.stroke
+#' @param outlier.colour,outlier.color,outlier.shape,outlier.size,outlier.stroke,outlier.alpha
#' Default aesthetics for outliers. Set to \code{NULL} to inherit from the
#' aesthetics used for the box.
#'
@@ -67,6 +67,8 @@
#' geom_boxplot()
#' ggplot(diamonds, aes(carat, price)) +
#' geom_boxplot(aes(group = cut_width(carat, 0.25)))
+#' ggplot(diamonds, aes(carat, price)) +
+#' geom_boxplot(aes(group = cut_width(carat, 0.25)), outlier.alpha = 0.1)
#'
#' \donttest{
#' # It's possible to draw a boxplot with your own computations if you
@@ -94,6 +96,7 @@ geom_boxplot <- function(mapping = NULL, data = NULL,
outlier.shape = 19,
outlier.size = 1.5,
outlier.stroke = 0.5,
+ outlier.alpha = NULL,
notch = FALSE,
notchwidth = 0.5,
varwidth = FALSE,
@@ -113,6 +116,7 @@ geom_boxplot <- function(mapping = NULL, data = NULL,
outlier.shape = outlier.shape,
outlier.size = outlier.size,
outlier.stroke = outlier.stroke,
+ outlier.alpha = outlier.alpha,
notch = notch,
notchwidth = notchwidth,
varwidth = varwidth,
@@ -160,6 +164,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom,
draw_group = function(data, panel_scales, coord, fatten = 2,
outlier.colour = NULL, outlier.shape = 19,
outlier.size = 1.5, outlier.stroke = 0.5,
+ outlier.alpha = NULL,
notch = FALSE, notchwidth = 0.5, varwidth = FALSE) {
common <- data.frame(
@@ -204,7 +209,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom,
size = outlier.size %||% data$size[1],
stroke = outlier.stroke %||% data$stroke[1],
fill = NA,
- alpha = NA,
+ alpha = outlier.alpha %||% data$alpha[1],
@hadley

hadley Jul 28, 2016

Owner

%||% works with NULL not NA. I think that just means the default function param above should be NULL.

@jonathan-g

jonathan-g Jul 29, 2016

Contributor

Thanks for catching that. I changed the default NULL and tested and it seems to work fine that way.

stringsAsFactors = FALSE
)
outliers_grob <- GeomPoint$draw_panel(outliers, panel_scales, coord)
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.