Clear Filters
Clear Filters

using errorbar I get the error bars' caps on top of (in front) of the symbol

5 views (last 30 days)
I am using the errorbar function that is able to show both error bars on X and Y. when the errors are smaller than the symbol I expect the error bar would not show (hidden behind the symbol), but instead the error bar caps show ON TOP of the symbol. I overcome this by using the plot function after errorbar, but that is surely not the elegant way.
Am I missing something? or is that a bug?
here's a code to generate the same phenomenon:
% generate data
x=1:10;
y(:,1)=2*x+rand(1,10);
ex(:,1)=rand(1,10);
ey(:,1)=rand(1,10);
y(:,2)=2*x+rand(1,10)+5;
ex(:,2)=rand(1,10)*2;
ey(:,2)=rand(1,10)*2;
% plot
for i=1:2
errorbar(x',y(:,i),ex(:,i),ex(:,i),ey(:,i),ey(:,i),...
'sk','MarkerFaceColor','r',...
'MarkerSize',20,...
'LineWidth',2);
hold on
end
  2 Comments
dpb
dpb on 19 Jul 2017
I would presume the code was written with the assumption by the author that if one were using errorbar that the prime impetus would be to see the error ranges; hence I'm not at all surprised it places them in the foreground plane rather than occluded by the marker symbol. After all, when they're smaller, all that is known is that they're not big-enough to show up but that could be anywhere from that size to essentially (or even identically) zero. In short, seems to me a reasonable expectation for most users.
Given the above rationale, if that's not what's wanted in a particular instance I'd say your workaround is the likely solution...
I'll add the usual caveats $0.02, imo, ymmv, etc., etc., etc., ... on this one.
the cyclist
the cyclist on 19 Jul 2017
Edited: the cyclist on 19 Jul 2017
Imagine the scenario where the very small error bars simply do not display by default. I would expect most people would be very confused by the "bug" that their error bars aren't being plotted. :-)
I think the current default behavior makes a lot of sense.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!