Boxplot Label Numberical Organization

3 次查看(过去 30 天)
I am trying to graph multiple boxplots on a figure that have varying x values. I am inserting these labels into the boxplot function like so:
b = boxplot(ErrorPlot, 'Labels', weight);
However, I face an issue when the labels vary in distance. When graphing a set of labels, like seen in the image, the boxplots are equidistant regardless of what their labels say. Is it possible to ensure that these boxplots are graphed with a distance matching their label value (i.e. 10 and 20 are only 1/10th as far from each other as 100 and 200 are)?

采纳的回答

Aaditya Pore
Aaditya Pore 2022-7-12
Found answer in this forum.

更多回答(1 个)

dpb
dpb 2022-7-11
Not an option w/ builtin boxplot, sorry.
You can make it work with the alternate boxchart function, but the large scale factor will probably end up with the boxes only being vertical lines as the spacing between the axis values is almost all white space.
I tried
x=randi(20,[20,4]);
g=[10 20 100 200].*ones(size(x));
hBC=boxchart(g(:),x(:));
with just a subset of your x values above -- it was less than satisfactory, methinks --
There is not an optional input to let one set the width of the boxes independently; whether one could go "handle-diving" and uncover the pieces and modify them or not I didn't explore.
  1 个评论
Aaditya Pore
Aaditya Pore 2022-7-12
Thanks for the response! I spent some more time looking and found that the boxplot function has a 'Positions' modifier (not in the documentation for some reason?). Anyway, running this code
boxplot(ErrorPlot, 'Positions', weight, 'Labels', weight);
got the results I was looking for. An image of a sample boxplot is attached. Thanks again!

请先登录,再进行评论。

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by