Skip to content
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

Compute jitter width by panel #6330

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #3722.

It ensures that the default, resolution-based jitter width is computed per panel instead of per layer.

Reprex from the issue, notice that the jitter has about equal visual spread across panels:

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

set.seed(123)
df <- data.frame(
  y = rnorm(100, 50, 10),
  x = c(rep(1:5, 10), rep(seq(0, 100, length.out = 5), 10)),
  group = c(rep("a", times = 50), rep("b", times = 50))
)

ggplot(df, aes(x = x, y = y)) +
  geom_point(color = "orange", alpha = 0.7) +
  geom_point(position = "jitter", color = "blue", alpha = 0.7) +
  facet_wrap( ~ group, scales = "free")

Created on 2025-02-12 with reprex v2.1.1

An open question is whether we should do this for position_jitterdodge() too.

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.

Misleading noise when using geom_jitter in combination with facet_wrap
1 participant