PDA

查看完整版本 : [求助]两个坐标轴怎么重合了?


豌豆花
2009-03-11, 10:47
下面的一段程序是要画两个坐标轴,可是为什么运行后第二个坐标轴还是和第一个坐标轴重合,而不是在top和right呢?哪里出错了呢?
X=1:5:50;
Y1=sin(X);
Y2=cos(X);
h1=plot(X,Y1,'r');
ax1=gca;
set(ax1,'XColor','r','YColor','r')
ax2=axes('Position',get(ax1,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k','YColor','k');
h2=plot(X,Y2,'Color','k','parent',ax2);

zhyanchao
2009-03-11, 22:25
在h2前面加hold on应该就可以了

豌豆花
2009-03-12, 09:10
谢谢你的解答!:lol: