Briefly, instead of counting the number of rows per PANEL/xmin interaction, we are counting the number of unique groups per PANEL/xmin interaction. Argueably, this is the metric that should be counted.
The reprex from the issue now shows violin plots of appropriate widths:
devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(vs))) +
geom_violin(position = position_dodge(preserve = "single"))
#> Warning: Groups with fewer than two datapoints have been dropped.
#> ℹ Set `drop = FALSE` to consider such groups for position adjustment purposes.
This PR aims to fix #2801 and revives #2813.
Briefly, instead of counting the number of rows per
PANEL
/xmin
interaction, we are counting the number of unique groups perPANEL
/xmin
interaction. Argueably, this is the metric that should be counted.The reprex from the issue now shows violin plots of appropriate widths:
Created on 2024-06-03 with reprex v2.1.0
One concern raised in https://github.com/tidyverse/ggplot2/pull/2813#issuecomment-420779013 was performance. This PR uses {vctrs} and is faster than the current implementation.