Skip to content

Use group to dodge in position_jitterdodge() #5922

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 5 commits into from
Jun 4, 2024

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #3656.

Briefly, instead of dodging by a set of aesthetics, it uses the innate group to dodge.
Also using position = "jitterdodge" no longer fails due to missing parameters.

Some examples:

If there is no group it just jitters:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
p <- ggplot(mpg, aes("x", displ)) +
  geom_point(position = "jitterdodge")

p

If there is an explicit group, that is used to dodge:

p + aes(group = drv)

If there is an implicit automatic group, it dodges by that:

p + aes(colour = drv)

Explicit groups can be used to override implicit ones:

p + aes(group = drv, colour = factor(cyl))

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 79b6e1c into tidyverse:main Jun 4, 2024
11 checks passed
@teunbrand teunbrand deleted the jitterdodge_group branch June 4, 2024 10:52
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.

position_jitterdodge() failed when attribute fill is not specified
2 participants