Skip to content

Aligning geoms with preserve = "single": appears not to work with several factors  #3647

@adrowe1

Description

@adrowe1

Hi,

I discovered issue #2712 when looking for a solution to the misalignment of boxplots with overlaid points. While the solution shown works in the example, it does not seem to generalise to cases with a greater number of factors.

Ideally it would be possible to achieve the same thing with position_jitterdodge(), but I guess that is beyond the scope of this issue.

library(ggplot2)

ggplot(mtcars, aes(factor(am), mpg, fill = factor(carb))) + 
  geom_boxplot(position = position_dodge2(0.75, preserve = 'single')) +
  geom_point(position = position_dodge(0.75, preserve = 'total'))

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorpositions 🥇

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions