can we set beside each one bar graph another comparative?

1 vue (au cours des 30 derniers jours)
Tony Castillo
Tony Castillo le 28 Mar 2017
Commenté : KSSV le 28 Mar 2017
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);

Réponse acceptée

KSSV
KSSV le 28 Mar 2017
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 commentaires
Tony Castillo
Tony Castillo le 28 Mar 2017
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.
KSSV
KSSV le 28 Mar 2017
Take data1 as Pmax and data2 as CMUD1.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by