Skip to content

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

Merged
thomasp85 merged 2 commits into
v3.3.0-rcfrom
better-direction-detect
Feb 6, 2020
Merged

thomasp85 merged 2 commits into
v3.3.0-rcfrom
better-direction-detect

Conversation

@thomasp85

Copy link
Copy Markdown
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
Copy Markdown
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)

@yutannihilation yutannihilation left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
@thomasp85
thomasp85 deleted the better-direction-detect branch October 6, 2025 11:58
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