can we set beside each one bar graph another comparative?

1 visualización (últimos 30 días)
Tony Castillo
Tony Castillo el 28 de Mzo. de 2017
Comentada: KSSV el 28 de Mzo. de 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);

Respuesta aceptada

KSSV
KSSV el 28 de Mzo. de 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 comentarios
Tony Castillo
Tony Castillo el 28 de Mzo. de 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 el 28 de Mzo. de 2017
Take data1 as Pmax and data2 as CMUD1.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by