can we set beside each one bar graph another comparative?

1 Ansicht (letzte 30 Tage)
Tony Castillo
Tony Castillo am 28 Mär. 2017
Kommentiert: KSSV am 28 Mär. 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);

Akzeptierte Antwort

KSSV
KSSV am 28 Mär. 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 Kommentare
Tony Castillo
Tony Castillo am 28 Mär. 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 am 28 Mär. 2017
Take data1 as Pmax and data2 as CMUD1.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by