Making complex(ish) bar graphs?

1 view (last 30 days)
Croy Carlin
Croy Carlin on 20 Sep 2011
Second question of the day, I have a single set of values on the y axis (in this case lengths from 10-20 "units), and then I have 4 different items I want on the x axis (preferably in different colors), and I want them to be grouped in pairs (for easy comparison). How would I go about doing this?

Answers (1)

Grzegorz Knor
Grzegorz Knor on 20 Sep 2011
Something like this:
y = rand(4,1)*10+10;
bar([1,2],y(1:2),'r')
hold on
bar([3.5,4.5],y(3:4),'g')
set(gca,'xtick',[1 2 3.5 4.5],'xticklabel',{'A','B','C','D'})
ylabel('length [a.u.]')
?
See also:

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!