Boxplot how to make the box widths proportional to sample size

5 visualizzazioni (ultimi 30 giorni)
I would like to modify the box widths proportional to the sample size. Similar to the attached figure.
Can I do this with Matalb?
thanks

Risposte (1)

Rik
Rik il 21 Feb 2022
There is no function in Matlab that does this natively, but you can write it from scratch.
If it is important to you that your code works on older Matlab releases you will have to make something with patch and line objects (see their documentation for help). For newer releases you can use the boxchart function. The boxplot function is in a toolbox, so that also has limited compatibility (although it is supported by older releases than those supporting boxchart).
The main idea would be to plot your boxes in a loop, 1 per iteration, in which you set the width yourself.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by