Boxplot how to make the box widths proportional to sample size

6 vues (au cours des 30 derniers jours)
paloma paleo
paloma paleo le 21 Fév 2022
Réponse apportée : Rik le 21 Fév 2022
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

Réponses (1)

Rik
Rik le 21 Fév 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