本帖最后由 ljelly 于 2011-1-12 21:15 编辑
首先感谢big boss的回复啊:lol
代码如下附件。
一方面,坐标标识被盖住
另一方面,如何设置两个的Y坐标数值的比例为1:1,即下图中的sin应该比2×cos小些。
谢谢big boss了。
clc;
clear all;
x=[0:0. ...
jacobi 发表于 2011-1-12 16:57
问题1,坐标标识被盖住,是因为你的图设置的太小,设置大一点就ok了
问题2,通过调整轴属性是可以改变的
调整后的代码如下,图如下所示- clc;
- clear all;
- x=0:0.1:12;
- y1=sin(x);
- y2=2*cos(x);
- figbar=figure(1);
- tmp=transpose(x);
- [ax,h1,h2]=plotyy(x,y1,tmp,y2,'plot');
- set(get(ax(1),'Ylabel'),'string','y1','color','k','fontsize',14)
- set(get(ax(2),'Ylabel'),'string','y2','color','k','fontsize',14)
- xlabel('Distance','fontsize',14)
- set(h1,'linestyle','-','color','b','LineWidth',2);
- set(h2,'linestyle','--','color','r','LineWidth',2);
- legend([h1 h2],'sin(x)','2*cos(x)','fontsize',14) %标注两条线
- legend('boxoff')
- set(figbar,'Position',[200,200,600,500]);
- set(ax,'fontsize',14) ;
- set(ax(1),'ylim',[-2 2],'ytick',[-2 -1 0 1 2])
- set(ax(1),'ylim',[-2 2],'ytick',-2:0.5:2)
复制代码 |