Open teunbrand opened 4 months ago
I'm considering whether draw_quantiles
should still be a parameter of the geom. It seems wrong that drawing is controlled by a stat.
Would it make sense to have the stat always compute the quantile, and the geom drawing it depending on the value of draw_quantile
?
In principle I agree with you, though there are some practicalities that may get in the way.
The issue is that draw_quantiles
currently is not a boolean and carries the numeric values for which quantiles the stat should know about, but the geom doesn't need to know about.
Another issue is what the default quantiles that are computed should be, but it'd probably should be c(0.25, 0.5, 0.75)
.
This PR aims to fix #4120.
Briefly, instead of GeomViolin estimating quantiles based on the density, StatYdensity includes
quantile
as a computed variable. GeomViolin is then able to draw the quantiles based on that computed variable.I consider this a breaking change as StatYdensity how 'owns' the
draw_quantiles
parameter, rather than GeomViolin. For users, this should only matter when they are breaking the link betweengeom_violin()
andstat_ydensity()
. It is also a visual change, as the quantiles are now correct.Reprex from the issue, notice how the red quantiles of the violin now aligns with the boxplot quantiles.
Created on 2024-05-28 with reprex v2.1.0