MATLAB: Plotting multiple bar graphs

barplotting

Hi everyone, I am plotting 3 different bar graphs on a same figure window. I have managed up to this point, shown in the figure. I want them to be side by side not overlapping. Any help guys ?
figure(5);
hold on;
bar(xdata,bpcombine3,0.125,'FaceColor',[0,0,1],...
'EdgeColor',[0,0,1]);
bar(xdata,bpcombine2,0.25,'FaceColor',[0,1,0],...
'EdgeColor',[0,1,0]);
bar(xdata,bpcombine1,0.4,'FaceColor',[1,0,0]);
set(gca, 'XTick', 1:6, 'XTickLabel', labels);
title('Blocking Probability vs Routing Level');

Best Answer

Guessing here because I don’t have all your data, but I would do something like this:
bpcombined = [bpcombine1(:), bpcombine2(:), bpcombine3(:)];
hb = bar(xdata, bpcombined, 'grouped')
You can then change the colours by referring to the individual bar series using the ‘hb’ handle. (The (:) creates each vector as a column vector so the concatenation works correctly.)
Related Question