From: Steffie Tomson on
Hi all,

I'm having a problem plotting multiple errorbar plots onto the same subplot. If I comment one out, the other will plot and visa versa, but they seem to be overwriting each other such that the two plots never appear at the same time. I'm having the same problem with scatter, so clearly the error is on my end somewhere. Note that the code below works great if I remove subplot and put it all into one figure. I've seen people post this problem before but I've never seen a solution posted, so naturally I thought I'd try again.

Any input much appreciated!

Thanks,
Steffie

subplot(2,1,1), errorbar(Averages(:,1), Averages(:,2), 'b-', 'LineWidth', 1); subplot(2,1,1),errorbar(Averages(:,3), Averages(:,4), 'c-', 'LineWidth', 1);
From: Steven Lord on

"Steffie Tomson" <snelsonian(a)gmail.com> wrote in message
news:hrhto6$q20$1(a)fred.mathworks.com...
> Hi all,
>
> I'm having a problem plotting multiple errorbar plots onto the same
> subplot. If I comment one out, the other will plot and visa versa, but
> they seem to be overwriting each other such that the two plots never
> appear at the same time. I'm having the same problem with scatter, so
> clearly the error is on my end somewhere. Note that the code below works
> great if I remove subplot and put it all into one figure. I've seen
> people post this problem before but I've never seen a solution posted, so
> naturally I thought I'd try again.

Use HOLD to tell MATLAB you want to display multiple plots on the same axes.

x = 1:10;
y = sin(x);
e = std(y)*ones(size(x));
errorbar(x,y,e)
hold on
errorbar(x, cos(x), e, 'r')

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ