Adding dots to a box-plot

12 Ansichten (letzte 30 Tage)
Rotem Ben-Hamo
Rotem Ben-Hamo am 22 Nov. 2017
Beantwortet: Akira Agata am 27 Nov. 2017
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!

Antworten (1)

Akira Agata
Akira Agata am 27 Nov. 2017
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)

Community Treasure Hunt

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

Start Hunting!

Translated by