Create a stacked bar chart in matlab

1 view (last 30 days)
Andrew Alkiviades
Andrew Alkiviades on 13 Apr 2013
Hi, I am trying to create a stacked bar chart in matlab. All I am trying to do is have the two data sets I am plotting on the same bar in different colours.
What seems to be happening with my code below is that the data sets are adding up thus even though the difference is the correct value, the absolute number is not. can this be avoided?
my code is
%%AD STACKED CC %%
AD_monthly_generation_250 = [186 186 186 186 186 186 186 186 186 186 186 186]';
CC_monthly_demand_2012 = [199.575 206.701 145.284 135.944 127.689 93.281 80.311 78.859 98.145 168.572 206.365 113.030]';
% Create a stacked bar chart using the bar function
figure;
bar(1:12, [ AD_monthly_generation_250 CC_monthly_demand_2012 ], 0.5, 'stack');

Answers (0)

Community Treasure Hunt

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

Start Hunting!