MATLAB: Is errorbar whisker length dependent on X

bugerrorbarplot

I am running a simulation in Matlab 2015 which creates data each round, so I am plotting a number of single errorbar series individually. Here's a sample code and the output plot:
figure
xlim([0 30])
hold on
errorbar(1,2.0,1.9,16.5,'x')
errorbar(15,2.0,1.9,16.5,'x')
errorbar(25,2.0,1.9,16.5,'x')
errorbar(10,2.0,1.9,16.5,'x')
errorbar(30,2.0,1.9,16.5,'x')
errorbar(5,2.0,1.9,16.5,'x')
errorbar(20,2.0,1.9,16.5,'x')
The weirdness is that the whisker length appears to be dependent on my X value. As you can see it increases from left to right, even though I did not plot them from left to right. The single-side width of each whisker is 0.01*x.
What on earth is happening, and how can I fix it? Ideally I would just manually set the width of each whisker, but I can't find a way to do that. There was a function posted on the MFX a while back, but that was made for R2007b and no longer works. The errorbar series properties do not give any indication that the whiskers can even be affected at all. Any help here would be greatly appreciated!

Best Answer

You could make the bars manually like this:
% define data:
x = [1 15 25 10 30 5 20];
shw = 0.3; % half-width of stem in x units
y = 2+zeros(size(x));
le = 0.9+zeros(size(x)); % lower error
ue = 16.5+zeros(size(x)); % upper error
figure
xlim([0 31])
hold on
% definte bar colors:
colors = jet(length(x));
for k = 1:length(x)
% x-shaped data marker:
plot(x(k),y(k),'x','color',colors(k,:),'markersize',12)
% vertical bar:
plot([x(k) x(k)],y(k)+[-le(k) ue(k)],'-',...
'color',colors(k,:),'linewidth',1)
% horizontal stems:
plot(x(k)+shw*[-1 -1;1 1],...
y(k)+[-le(k) ue(k);-le(k) ue(k)],...
'-','color',colors(k,:),'linewidth',1)
end
set(gcf,'color',.2*[1 1 1])
set(gca,'color','none')