Adding dots to a box-plot

11 views (last 30 days)
Rotem Ben-Hamo
Rotem Ben-Hamo on 22 Nov 2017
Answered: Akira Agata on 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!

Answers (1)

Akira Agata
Akira Agata on 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!