Skip to content

Reverse dodging #5923

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 8 commits into from
Jul 11, 2024
Merged

Reverse dodging #5923

merged 8 commits into from
Jul 11, 2024

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented May 31, 2024

This PR aims to fix #3610.

Briefly, it adds a reverse argument to position_dodge() and position_jitterdodge() that reverses the groups within a position in terms of dodge order.

As a detail, for consistency with position_dodge2(), we actually pass !reverse to collide().

Adapted reprex from issue:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

p <- ggplot(mtcars) +
  aes(
    as.factor(cyl), mpg, 
    fill = as.factor(vs), 
    group = interaction(cyl, vs)
  )

p + 
  geom_boxplot(position = position_dodge(reverse = FALSE)) +
  geom_point(position = position_jitterdodge(reverse = FALSE), shape = 21)

p + 
  geom_boxplot(position = position_dodge(reverse = TRUE)) +
  geom_point(position = position_jitterdodge(reverse = TRUE), shape = 21)

Created on 2024-05-31 with reprex v2.1.0

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

LGTM

@teunbrand teunbrand merged commit 1c1cdc3 into tidyverse:main Jul 11, 2024
11 checks passed
@teunbrand teunbrand deleted the reverse_dodge branch July 11, 2024 18:17
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.

reverse dodge order works differently in position_jitterdodge() vs., for example position_dodge2()
2 participants