pac
pac

Reputation: 291

Draw two bar graph on top each other

I have two information and want them to be displayed at the same time.

 f=     1.4000    0.8000


 d=    8.0000    8.2000

I used several codes here is one example:

 bar([d, f], 'stacked'); 
 legend(' ', ' '); 
 xlabel('every 5 Run of runs'); 
 ylabel(' ')
 axis([0 T  0 N])
 hold on;

What I am getting :

1:the two legends and graph are of the same color

2:they are displayed one after the other.

3:the two info are read at same run 1 and 2 what I have here 4 runs

Result

how to solve? I want both to be displayed at run 1 and 2 on top of each other with different colors of course. thanks

Upvotes: 0

Views: 1426

Answers (1)

Webfoot Witch Hat
Webfoot Witch Hat

Reputation: 81

If d and f are defined as

f= [1.4000,0.8000];
d= [8.0000,8.2000];

and you do this

bar([d', f'], 1.5);   %Where 1.5 is the width of the bars.

You will get them on top of each other. The difference being that [d, f] is now a 2x2 matrix instead of a 1x4 row vector.

Upvotes: 0

Related Questions