Plot values of a boxplot next to it?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lorenz
el 14 de Jul. de 2022
Comentada: Lorenz
el 14 de Jul. de 2022
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 comentarios
Respuesta aceptada
Chunru
el 14 de Jul. de 2022
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');
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!