豌豆花
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);
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);