Plot values of a boxplot next to it?
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
i'm currently working with the matlab function boxplot and need a representation of the corresponding values next to the boxplots (see figure) for better clarity. Is there any possibility to implement this with boxplot? In my use case the number of boxplots changes depending on the user input, so a static positioning of the numbers is not possible.
Thanks in advance!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1065160/image.png)
0 件のコメント
採用された回答
Chunru
2022 年 7 月 14 日
x1 = rand(5,1);
x2 = rand(10,1);
x3 = rand(15,1);
x = [x1; x2; x3];
g1 = repmat({'First'},5,1);
g2 = repmat({'Second'},10,1);
g3 = repmat({'Third'},15,1);
g = [g1; g2; g3];
boxplot(x,g)
qx1 = quantile(x1, [.25 .5 .75]);
qx2 = quantile(x2, [.25 .5 .75]);
qx3 = quantile(x3, [.25 .5 .75]);
hold on
text(1+.25+zeros(1,3), qx1, string(qx1), 'HorizontalAlignment', 'left');
text(2+.25+zeros(1,3), qx2, string(qx2), 'HorizontalAlignment', 'left');
text(3+.25+zeros(1,3), qx3, string(qx3), 'HorizontalAlignment', 'left');
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!