Skip to content

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
@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