Skip to content

preserve = "single" breaks violin plots #2801

Closed
@willgearty

Description

@willgearty

I'm trying to use preserve = "single" as you would with boxplots to maintain the sizes of the boxes when there are unused factors. While I figured it would work just the same way for violin plots, it appears to completely break them.

p <- ggplot(mtcars, aes(factor(cyl), mpg))
#works fine
p + geom_violin(aes(fill = factor(vs)))
#works fine
p + geom_violin(aes(fill = factor(vs)), position = "dodge")
#this doesn't work
p + geom_violin(aes(fill = factor(vs)), position = position_dodge(preserve = "single"))

The latter attempt above produces this:

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