multiple axes with Matlab_SE5.3
multiple axes with Matlab_SE5.3
(OP)
Hello out there,
I am trying to plot two curves in one figure - one scaled on the left y-axes, the 2nd on the right y-axes. I found something about it in the help-desk - but for some reason it does not work. The "YAxisLocation" semes to be ignored...
Belwo I print the part from my script. I appreciate any helpful comment on it! Thanks!
hl1 = plot(x,y1,'k-','LineWidth',1.5);
ax1 = gca;
set(ax1,'TickDir','out','YTick',[0 1 2 3 4 5 6 7],'YTickLabel',[' 0';' ';' 2';' ';' 4';' ';' 6';' '],'XTick',[0 3 6 9 12 15 18 21 24],'XTickLabel',[' ';' ';' ';' ';' ';' ';' ';' ';' '],'FontSize',11,'FontName','Arial','FontWeight','bold');
axis([0 24 0 7]);grid on;
title('Januar','FontSize',12,'FontName','Arial','FontWeight','bold');
ylabel('T_{a} (^{\circ}C)','FontSize',11,'FontName','Arial','FontWeight','bold');
ax2 = axes('Position',get(ax1,'Position'),'YAxisLocation','right');
plot(x,z1,'k--','LineWidth',1.5,'Parent',ax2); %,'Parent',ax2
ylabel('\Delta T_{a} (K)','FontSize',11,'FontName','Arial','FontWeight','bold');
set(ax2,'TickDir','out','YTick',[-0.4 -0.2 0 0.2 0.4 0.6 0.8 1],'YTickLabel',['-0.4';' ';' 0 ';' ';' 0.4';' ';' 0.8';' '],'XTick',[0 3 6 9 12 15 18 21 24],'XTickLabel',[' ';' ';' ';' ';' ';' ';' ';' ';' '],'FontSize',11,'FontName','Arial','FontWeight','bold');
axis([0 24 -0.4 1]);
I am trying to plot two curves in one figure - one scaled on the left y-axes, the 2nd on the right y-axes. I found something about it in the help-desk - but for some reason it does not work. The "YAxisLocation" semes to be ignored...
Belwo I print the part from my script. I appreciate any helpful comment on it! Thanks!
hl1 = plot(x,y1,'k-','LineWidth',1.5);
ax1 = gca;
set(ax1,'TickDir','out','YTick',[0 1 2 3 4 5 6 7],'YTickLabel',[' 0';' ';' 2';' ';' 4';' ';' 6';' '],'XTick',[0 3 6 9 12 15 18 21 24],'XTickLabel',[' ';' ';' ';' ';' ';' ';' ';' ';' '],'FontSize',11,'FontName','Arial','FontWeight','bold');
axis([0 24 0 7]);grid on;
title('Januar','FontSize',12,'FontName','Arial','FontWeight','bold');
ylabel('T_{a} (^{\circ}C)','FontSize',11,'FontName','Arial','FontWeight','bold');
ax2 = axes('Position',get(ax1,'Position'),'YAxisLocation','right');
plot(x,z1,'k--','LineWidth',1.5,'Parent',ax2); %,'Parent',ax2
ylabel('\Delta T_{a} (K)','FontSize',11,'FontName','Arial','FontWeight','bold');
set(ax2,'TickDir','out','YTick',[-0.4 -0.2 0 0.2 0.4 0.6 0.8 1],'YTickLabel',['-0.4';' ';' 0 ';' ';' 0.4';' ';' 0.8';' '],'XTick',[0 3 6 9 12 15 18 21 24],'XTickLabel',[' ';' ';' ';' ';' ';' ';' ';' ';' '],'FontSize',11,'FontName','Arial','FontWeight','bold');
axis([0 24 -0.4 1]);





RE: multiple axes with Matlab_SE5.3
Anytime you want to plot more than one plot in a figure window, you must issue the "hold on" command immediately after you issue the "figure" command. Otherwise, your figure will only contain the last plot. No matter, what else is wrong.
RE: multiple axes with Matlab_SE5.3
I've tried it with the "hold on" but it doesn't help. It still shows both axis labels on the left side and the figure itself contains only one line....
RE: multiple axes with Matlab_SE5.3