-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Whiskers and outliers for geom_boxplot with transformed scale #3336
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
Comments
You're right, boxplots are calculated based on the transformed values, which affects the calculation of outliers. However, https://github.com/tidyverse/ggplot2/blob/master/R/stat-boxplot.r#L82-L85 |
The only other place I can find a |
It's worth noting that this (surprise at |
Ah, sorry I missed those issues—I only searched for boxplot related ones. Computing stats on the transformed values is potentially quite reasonable from a statistical perspective. If that's the way this goes, I would then just suggest a documentation update to note the behaviour since it's a bit surprising. |
This topic came up at Lee Wilkinson's talk yesterday at SDSS 2019: Stats are computed on the transformed values. If you want the stats to be calculated on the original values then you need to work with a transformed coordinate system: https://ggplot2.tidyverse.org/reference/coord_trans.html This is common confusion in ggplot2: Many people try to use scales for things that should be done in coords. Setting axis limits without dropping data points is another common issue. |
If that's true, it should be much easier to make a pretty looking plot with library(ggplot2)
p <- ggplot(diamonds, aes(cut, price)) +
geom_boxplot()
p + aes(y = log10(price)) p + scale_y_log10() p + coord_trans(y = "log10") p + coord_trans(y = "log10") + scale_y_continuous(breaks = scales::log_breaks()) Created on 2019-06-02 by the reprex package (v0.2.1) |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Boxplot whiskers and outliers seem to be incorrect when using geom_boxplot with a transformed scale. It probably affects notches too, but I haven't checked.
The hinges are fine, which makes sense—monotonic transformations preserve quantiles.
Created on 2019-05-20 by the reprex package (v0.3.0)
I'm using ggplot2 3.1.1.
The text was updated successfully, but these errors were encountered: