piermorel / gramm

Gramm is a complete data visualization toolbox for Matlab. It provides an easy to use and high-level interface to produce publication-quality plots of complex data with varied statistical visualizations. Gramm is inspired by R's ggplot2 library.
MIT License
780 stars 221 forks source link

Median & quartile lines to extend all the way to the edges of violin plot? #109

Open wildetudor opened 3 years ago

wildetudor commented 3 years ago

I'm trying to create mixed violin&box plots where, rather than be of fixed width (as gramm's stat_boxplot makes them), both the median line and the quartile lines above/below it extend all the way to the edge of the violin plot. Just like in the image below: mehr 2018 currbio (made with R)

I know that in ggplot2, this is done easily straight from geom_violin (cf documentation; search "# Show quartiles").

In gramm, I think rather than tweak stat_violin.m, it's easier to achieve this by playing around with the width of the bars that stat_boxplot adds. However, I've not been able to achieve the desired effect. ANy suggestions? Thanks!

piermorel commented 8 months ago

Hi @wildetudor, Thanks for the idea. I don't know if you are still looking into this (as you can see after a long hiatus I have the opportunity to make the repository more alive !), but I suspect that it might be easier to do this by tweaking stat_violin(). Since graphic elements work quite independently from each other it would be quite hard to get stat_boxplot to know about the width of violins. It's much easier to recalculate medians and quartiles within stat_violin and plot them there. Hoping to see a pull request on this 😉