Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple axes with Matlab_SE5.3

Status
Not open for further replies.

seabreeze

Marine/Ocean
Joined
Oct 17, 2002
Messages
5
Location
DE
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]);
 
Well, beyond the fact I can't make sense of what you are trying to do, and ignoring the fact that Matlab 5.3 is about 5 years out of date, I will offer one point.

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.
 
thanks for your answer - to give a reason for this figure: I want the temperature of one measuring height scaled on the left axis and the deviation of another measuring height from this one on the other axis. That's a quite common type of figure, isn't it?

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....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top