下面的内容都是多年前的方法了。现在matlab推荐使用yyaxis来完成,取代了plotyy
hold on
yyaxis left
plot(tt1,u(:,1))
ylabel('Mean Temperature')
yyaxis right
plot(tt1,sigma(:,[1,7]))
ylabel('Sigma')
title(tag)
set(gca,'xtick',tt1(1:5:end),'xticklabel',yytick2(1:5:end),'xlim',[tt1(1),tt1(end)])
legend({'mean temp','\sigma','\sigma IMF6'},'location','best','box','off')
数据就不贴上来了,请参考
=============================
x=0:0.1:7;
h1=subplot(3,1,1);
plot(x,sin(x),'k');
h2=subplot(3,1,2);
plot(x,cos(x),'k');
set([h1,h2],'Xcolor','w','XTick',[]) %将前两个x坐标设为白色,且不显示xtick
% 利用plotyy双轴显示同一个图像,一副显示左y,下x,另一幅显示右y,下x
h3=subplot(3,1,3);
[ax,h4,h5]=plotyy(x,sec(x),x,sec(x));
box off
set(ax(1),'YColor','k')
set(ax(2),'Xaxislocation','bottom','YColor','k')
set(h5,'color','k')
set(gcf,'color','w') % 背景色设为白色,间接隐藏所有白色轴线