Hold on command does not work for boxplot and additional plot

11 views (last 30 days)
Hello all,
I've got a boxplot (with horizontal orientation) with data:
a= [x1;x2;x3;x4;x5;x6;x7;x8;x9;x10;x11;x12;x13;x14;x15]
and the boxplot groups are defined by vector b, where b is:
b = [0*ones(size(x1)); 0.1*ones(size(x2)); 0.2*ones(size(x3)); 0.3*ones(size(x4)); 0.4*ones(size(x5)); 0.5*ones(size(x6)); 0.6*ones(size(x7)); 0.7*ones(size(x8)); 0.8*ones(size(x9)); 0.9*ones(size(x10)); 1.0*ones(size(x11)); 1.1*ones(size(x12)); 1.2*ones(size(x13)); 1.5*ones(size(x14)); 1.6*ones(size(x15))];
where, the positions 0, 0.1, 0.2, 0.3, 0.4......., 1.6 are the positions that my horizontal boxplots are taking on the y axis.
----------
I want to overlap a plot with 5 points say c=[0.3, 0.4, 0.5, 0.6, 0.7] at y=2.
------------
So, when I'm typing
figure
boxplot(a,b,'orientation','horizontal')
hold on
plot(c,2*ones(size(c)),'g.')
it does not work and only the boxplots are shown, but not my 5 points (that are above the highest y value of the boxplots, which is 1.6).
Any ideas of how I could resolve this?

Answers (1)

Walter Roberson
Walter Roberson on 25 May 2015
"hold on" affects the xlim and ylim.
  3 Comments
Christina
Christina on 26 May 2015
Hi Walter,
Thank you for your reply.
I think I resolved the first part with plotting boxplots correctly.
-------------
So, when I've got
Xpos = [0 0.1 0.2] (just for three boxplots and not for 15)
group = [repmat(Xpos(1),[size(x1),1]); repmat(Xpos(2),[size(x2)],1); repmat(Xpos(3),[size(x3)],1)]
dataset3 = [x1;x2;x3];
---------
figure
boxplot(dataset3, group,'positions', Xpos,'orientation','horizontal')
hold on
scatter(0.5,2,'g.') (just for one additional point and not for 5 that I want)
------------
my point is still not visible.
I do understand that hold on is restraining the ylimits, but what can I use instead?
Many thanks

Sign in to comment.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!