Violinplot-Matlab icon indicating copy to clipboard operation
Violinplot-Matlab copied to clipboard

Normalize the violins

Open brianpenghe opened this issue 6 years ago • 4 comments

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

brianpenghe avatar Jul 11 '18 07:07 brianpenghe

This shouldn't be very hard. Do you want to take a stab at it and submit a pull request?

bastibe avatar Jul 11 '18 11:07 bastibe

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?

brianpenghe avatar Jul 11 '18 17:07 brianpenghe

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.

bastibe avatar Jul 12 '18 12:07 bastibe

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.

bastibe avatar Jul 12 '18 12:07 bastibe