Skip to content

Use default aesthetics from geom_point as defaults for goem_boxplot outliers #757

New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nfdisco opened this issue Jan 21, 2013 · 2 comments
Closed

Comments

@nfdisco
Copy link

nfdisco commented Jan 21, 2013

Currently, the default values for the outlier arguments to geom_boxplot, that control the shape, colour and size of outliers, cannot be changed with update_geom_defaults. It makes sense because technically these parameters are not aesthetics. On the other hand, if the user changes, say, the default shape of geom_point, the result will be that geom_point and geom_boxplot will produce points with different shapes, which probably is not desirable or entirely expected.

One solution is to use the default values from geom_point as defaults for the outlier arguments in geom_boxplot, so that

update_geom_defaults("point", list(shape = 1, colour='blue',size=4))

also affects the shape, colour and size of the outlier points produced by geom_boxplot. Find patch attached.

@nfdisco
Copy link
Author

nfdisco commented Jan 21, 2013

I don't seem to be able to attach files so I will just paste the diff output below.

--- R/geom-boxplot.r.old    2013-01-21 00:41:53.950280570 +0100
+++ R/geom-boxplot.r    2013-01-21 00:56:16.922267982 +0100
@@ -94,8 +94,12 @@
 #' b + geom_boxplot(aes(fill = X1), stat = "identity")
 #' }
 geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot", position = "dodge", 
-outlier.colour = "black", outlier.shape = 16, outlier.size = 2,
+outlier.colour = NULL, outlier.shape = NULL, outlier.size = NULL,
 notch = FALSE, notchwidth = .5, ...) {
+  outlier_defaults <- Geom$find('point')$default_aes()
+  outlier.colour <- outlier.colour %||% outlier_defaults$colour
+  outlier.shape <- outlier.shape %||% outlier_defaults$shape
+  outlier.size <- outlier.size %||% outlier_defaults$size
   GeomBoxplot$new(mapping = mapping, data = data, stat = stat, 
   position = position, outlier.colour = outlier.colour, outlier.shape = outlier.shape, 
   outlier.size = outlier.size, notch = notch, notchwidth = notchwidth, ...)

@hadley
Copy link
Member

hadley commented Feb 24, 2014

This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette.

@hadley hadley closed this as completed Feb 24, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants