2013-04-13 2 views
0

안녕하세요, matlab에 스택 막대 차트를 만들려고하지만 출력 그래프가 첫 번째 데이터 세트 (AD_monthly_generation_250)를 두 번째 (CC_monthly_demand_2012)에 추가하는 것으로 보입니다. 어떻게 이것을 피할 수 있습니까?matlab에 스택 막대 차트를 만들

내 코드

%% 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'); 


% Add title and axis labels 
title('Seasonal Anaerobic Digestion (250kWe) Supply to Demand - 2012','FontSize',22); 
set(gca,'XTickLabel',{'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',' Sep',  'Oct', 'Nov',' Dec'},'FontSize',18) 
ylabel('Energy (MWh)'); 

답변

1

내가 'stack' 옵션 ...이 코드를 시도하도록되어로 작동 생각이다, 어쩌면 당신이 원하는 무엇 : 그 보이지 않지만

%% 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'); 
bar(1:12, AD_monthly_generation_250, 0.5, 'b'); 
hold on; 
bar(1:12, CC_monthly_demand_2012, 0.5, 'r'); 
hold off; 

% Add title and axis labels 
title('Seasonal Anaerobic Digestion (250kWe) Supply to Demand - 2012','FontSize',22); 
set(gca,'XTickLabel',{'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',' Sep',  'Oct', 'Nov',' Dec'},'FontSize',18) 
ylabel('Energy (MWh)'); 
+0

감사 일하다. 내가 얻을 수있는 것은 동일한 y 축 값 AD_monthly_generation_250을 가진 막 대형 차트입니다. – user643469

+0

@ user643469 : 실수로 한 줄 주석 처리했습니다. 위의 대답에서 코드를 업데이트했습니다. 다시 시도해 주시겠습니까? –

+0

완벽한, 감사합니다. – user643469

관련 문제