Skip to content

Changes in jitter.width of geom_point() since v3.5.1.9000 #6300

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

Closed
jbengler opened this issue Jan 22, 2025 · 5 comments
Closed

Changes in jitter.width of geom_point() since v3.5.1.9000 #6300

jbengler opened this issue Jan 22, 2025 · 5 comments

Comments

@jbengler
Copy link

Part 1

In this example the jitter is wider since v3.5.1.9000

ggplot(mtcars, aes(x = factor(cyl), y = disp, color = factor(cyl))) +
  geom_point(
    position = position_jitterdodge(
      jitter.width = 0.4, jitter.height = 0, dodge.width = 0, seed = 42
      )
    )

Output of ggplot2 v3.5.1

Image

Output of ggplot2 v3.5.1.9000

Image

Part 2

Now, it gets even more interesting. If the grouping viable is discrete, but not a factor, the jitter is more narrow since v3.5.1.9000

mtcars %>%
  mutate(new_var = c(rep("A", 11), rep("B", 11), rep("C", 10))) %>%
  ggplot(aes(x = new_var, y = disp, color = new_var)) +
  geom_point(
    position = position_jitterdodge(
      jitter.width = 0.4, jitter.height = 0, dodge.width = 0, seed = 42
    )
  )

Output of ggplot2 v3.5.1

Image

Output of ggplot2 v3.5.1.9000

Image

Conclusion

I am not sure what to make of this. I guess this might probably not hurt too much. However, in tidyplots it triggers a lot of vdiffr failures.

@teunbrand
Copy link
Collaborator

Thanks for the report Jan!

The relevant PR that affected this behaviour is #5922.
In the dev version, the jitter is equally wide regardless of whether the grouping is a factor or character.
The behaviour in 3.5.1, where you get unequal jitter widths based on factor/character, is undesirable.

it triggers a lot of vdiffr failures

I'm sure there will be other changes that will trigger small changes as well. vdiffr snapshots aren't checked on CRAN, so it won't be an immediate problem.

@teunbrand
Copy link
Collaborator

I'm going to close this issue as the new jittering has preferred properties over the old jittering and we therefore shouldn't move backwards.

@jbengler
Copy link
Author

@teunbrand

Do you have a rough estimate, when the next ggplot2 release is going to hit CRAN? I should probably submit the fixed version of tidyplots before that. However, I just submitted to CRAN 9 days ago and I would like to collect some more commits before submitting again.

Thanks a lot!

@teunbrand
Copy link
Collaborator

I do indeed and that estimate is before summer, so May-ish.

@jbengler
Copy link
Author

That's great! Thanks!

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

No branches or pull requests

2 participants