I\'m trying to get: a nice bar graph of groups. I\'d like error bars on each bar like this (or similar at your discretion):
It's really not that crazy!
You can just use errorbar
with the data that you have readily available.
This code computes the correct locations, by adding 1 for every group and 1/7 for each bar within a group.
for i = 1:5
j = 1:6;
x = -0.5 + i + 1/7 * j;
errorbar(x, ff(j,i), ee(j,i), '.');
end
Results in:
(Leaving out the labels, but otherwise this seems pretty similar to what you were looking for)
the centre of each bar can be obtained by
x = get(get(h(i),'children'),'xdata');
barsx=mean(x,1);
barsx gives the center for every ith element of every bar subset.
h=bar(bars)
for i=1:6
x = get(get(h(i),'children'),'xdata');
barsx(1:6,i)=mean(x,1)
end
hold all
h=errorbar(barsx,bars,barsvar)
to have the errors having the same colors as bar:
figure()
h=bar(bars)
col=[0 0 1;0 1 0;1 1 0; 1 1 1; 0 0 0; 0 1 1];
colormap([0 0 1;0 1 0;1 1 0; 1 1 1; 0 0 0; 0 1 1])
hold all
for i=1:6
x = get(get(h(i),'children'),'xdata')
barsx=mean(x,1)
h1=errorbar(barsx',bars(1:6,i),barsvar(1:6,i),'color',col(i,:))
set(h1,'linestyle','none')
end