Violinplot-Matlab
Violinplot-Matlab copied to clipboard
Normalize the violins
Is there a way to normalize the violins so that the total area of them are the same? I know it can be done by using distributionPlot but their graphics do not look as pretty as yours.
Thanks
This shouldn't be very hard. Do you want to take a stab at it and submit a pull request?
I'm not sure which part of your codes need modification. Could you add some comments into the codes to make sure I understand how they work? I then can integrate the feature. Does that make sense?
Currently, the all violins are scaled to a specific width. If you want a different normalization, you'd have to change this line to something different.
And then you would probably need to modify the "width" parameter, or add a new "normalized" parameter, or something like that.
I find it hard to think of a "correct" way of normalizing violins to a fixed area, though, without sometimes intersecting with neighbouring violins. But maybe I am missing something.
I would encourage you to play with the code a bit, and figure out exactly how normalized violins would work in practice. I'll try to help you as best I can if you have questions.
In general, all the plotting is done in Violin constructor. The rest of the Violin class only defines getters and setters for the Violin class, and input parameter validation for the Violin constructor.