Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6584.

It includes the preserve logic analogous to position_dodge(), as well as the order aesthetic.
Reprex from issue:

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

ggplot(penguins, aes(species, bill_len, fill = island)) +
  stat_summary(
    geom = "bar",
    fun = "mean",
    show.legend = T,
    position = position_dodge(preserve = "single")
  ) +
  stat_summary(
    geom = "errorbar",
    fun.data = "mean_sdl",
    fun.args = list(mult = 1),
    width = 0.3,
    position = position_dodge(width = 0.9, preserve = "single")
  ) +
  geom_point(
    show.legend = F,
    position = position_jitterdodge(
      jitter.width = 0.3, dodge.width = 0.9, preserve = "single"
    )
  )
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_summary()`).
#> Removed 2 rows containing non-finite outside the scale range
#> (`stat_summary()`).
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).

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

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.

Add preserve argument to position_jitterdodge()
1 participant