can we set beside each one bar graph another comparative?

1 次查看(过去 30 天)
Hi dear mathfriends, i need some help in order to set one bar graph, next to another one for make possible the comparisson between generation and comsumption, can you check it my code and give me some help to improve the attached graph? This is the code:
% % Salidas de datos mes={'Ene' 'Feb' 'Mar' 'Abr' 'May' 'Jun' 'Jul' 'Ago' 'Sep' 'Oct' 'Nov' 'Dic'};
%SALIDAS GRAFICAS
figure(1)
grid on
hold on
% title('Maximum Photovoltaic Power Harvesting');
xlabel('Meses [2015]');
ylabel('Energía [W·h]');
xlim([1 365]);
ax = gca;
ax.XTick = [1:30.4:365];
set(gca,'XTickLabel',mes);
ylim([0 Inf]);
% legend('Potencia Generable', 'Consumo');
% Y=[Pmax, CMUD1];
bar (Pmax, 'green');
hold on
bar (CMUD1, 'white');
% bar(Y);

采纳的回答

KSSV
KSSV 2017-3-28
d1 = rand(5,1) ;
d2 = rand(5,1) ;
y = zeros(2*5,1) ;
y(1:2:end) = d1 ;
y(2:2:end) = d2 ;
figure
hold on
for i = 1:numel(y)
if mod(i,2)==0
bar(i, y(i),'facecolor', 'r');
else
bar(i, y(i),'facecolor', 'b');
end
end
  2 个评论
Tony Castillo
Tony Castillo 2017-3-28
Hi, thanks for your fast answer, but i have a doubt now if my variables to graph are Pmax and CMUD1, in the code above, wich is each one?, i mean for substitute, and graph with my values.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by