This is what I want to do (higher quality image as attachment):
A grouped barplot with errorbars. There are two "groups of groups" which should have different colors. Since I did not find a way to change the colors of individual bars but only groups of bars, I put two separate plots with different x values into one figure using "hold on". However, as you can see from the graph, the second plot has a problem with the location of the errorbars. If I remove the "hold on" before the second plot and generate a new figure, the problem disappears, without changing anything else in the code.
figure() barwitherr(errors(1:a,:),[1:a],data(1:a,:),'BarWidth',0.8); colormap('summer');
hold on second = barwitherr(errors(a+1:end,:),[a+1:size(errors,2)],data(a+1:end,:),'BarWidth',0.8); set(gca,'XTick',[1:length(lines)],'XTickLabel',lines(order)); set(second(1),'facecolor',Colors2(1,:)); set(second(2),'facecolor',Colors2(3,:)); set(second(3),'facecolor',Colors2(5,:)); set(second(4),'facecolor',Colors2(7,:));
It would be truly great if you could help me out here.
With best regards, Gero
The graphics need to be updated immediately, e.g. via drawnow or putting in a pause. In this case the figure gets updated properly and the errorbars are put in the right place. I've updated the file in File Exchange.