Adding dots to a box-plot

11 次查看(过去 30 天)
Rotem Ben-Hamo
Rotem Ben-Hamo 2017-11-22
回答: Akira Agata 2017-11-27
Hello I have a figure with 8 boxplots and I would like to add the actual data to the figure by adding dots.
Since there isn't a straight foreword way of doing so I am trying to add the dots one by one to the figure. Unfortunately, I cant seem to figure it out. this is what I am doing:
boxplot(A,B); % A is a numerical vector and B is Char array.
hold on
scatter(0.3,1)
But the dot does not appear.
Can anyone help out with this?
Thanks so much!

回答(1 个)

Akira Agata
Akira Agata 2017-11-27
Since the XTick of the 1st, 2nd... box plots are 1, 2..., x = 0.3 might be too small to display on the graph. If you adjust (x,y) value of the dot properly, you can add the dot on the plot, like:
x = rand(1000,1);
group = mat2cell('a':'h',1,ones(8,1));
g = group(randi([1,8],1000,1));
boxplot(x,g)
hold on
scatter(1.5, 0.5)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by