Amarjit Dhillon
Amarjit Dhillon

Reputation: 2816

Plot the stacked bar graph in MATLAB with original values instead of a cumulative summation

By original values, I mean that when I create the stacked bar graph, MATLAB automatically appends values to its previous ones to create a cumulative summation. This is illustrated by taking an example from MATLAB official site, whose screenshot is shown below

enter image description here Here first the value 2 is plotted, then 2+2 and then 2+2+3. What if we have to plot the values as they are, which means plotting [2 2 3] instead of [2 4 7]. Also, I want to plot the values given in variable y as a stacked bar graph in above screenshot as if those are real values.

Help, please!

Upvotes: 0

Views: 1052

Answers (1)

Juancheeto
Juancheeto

Reputation: 586

Perhaps you can use a 3D graph and then change the view angle.

y=[2 2 3; 2 5 6; 2 8 9; 2 11 12];
bar3(y)
view(-90,0)

The above code was used to generate this graph. enter image description here

Upvotes: 2

Related Questions