Skip to content

Fix geom_violin(position = "dodge2") #6663

@teunbrand

Description

@teunbrand

Absolutely horrifying, perhaps even more so after the quantiles were reworked:

library(ggplot2)

ggplot(mpg, aes(drv, displ, fill = factor(year))) +
  geom_violin(position = position_dodge2())

Created on 2025-09-29 with reprex v2.1.1

@karawoo had described this many moons ago https://youtu.be/UGAuXyxdrvA?si=q9GH8ety6Xj1ak5t&t=986, but I couldn't find a related issue that kept this on the radar. This issue is that blip.

I think fundamentally position_dodge2() doesn't know the relation between rows and groups. For many geoms, 1 row is one group, like geom_boxplot(), but in others there is a many-to-one relationship, like geom_violin() or perhaps geom_dotplot(). I think the meat of the issue is how we can communicate this information between geom and position. The implementation at the position level worries me less.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions