Skip to content

Make sure boxplot check doesn't polute other stats/geoms #3800

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

Merged
merged 2 commits into from
Feb 6, 2020

Conversation

thomasp85
Copy link
Member

Superseedes #3764

This PR introduces a new switch in has_flipped_aes() which confines the single value check to those requesting it (currently only boxplot)

@thomasp85 thomasp85 added this to the ggplot2 3.3.0 milestone Feb 6, 2020
@yutannihilation
Copy link
Member

Ah, now I understand your comment on #3764. The example I used was the one that should not be flipped, and I confirmed this PR handles them correctly. Thanks.

df <- data.frame(value = 1:3, group = c("a", "a", "b"))

devtools::load_all("~/Documents/repo/ggplot2/")
#> Loading ggplot2

l <-  stat_summary(fun = "mean", geom = "bar", position = "dodge")
p1 <- ggplot(df, aes(value, 1, fill = group)) + l
p2 <- ggplot(df, aes(value, 0, fill = group)) + l

patchwork::wrap_plots(p1, p2, ncol = 1)

Created on 2020-02-06 by the reprex package (v0.3.0)

Copy link
Member

@yutannihilation yutannihilation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StatBoxplot fills 0 here, so this PR looks the right fix to me (though I still don't understand where all(x = 1) came from...).

data$x <- data$x %||% 0

Can we add a simple test for this? If you think it's not worth adding, I'm fine since this seems very corner case anyway.

@thomasp85
Copy link
Member Author

I have no idea how I convinced myself it defaulted to 1 🤷‍♂️

@thomasp85 thomasp85 merged commit fbebbaa into v3.3.0-rc Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants