但是,subplot中子绘图窗口只能实现m*n矩阵排列。如果我想在一个figure中绘制3个axes,怎么办呢? 一般matlab书上很少介绍。其实很简单。
请看下面的代码。- t=0:.01:1;
- y1=sin(6*pi*t);
- y2=sin(6*pi*t)./t;
- y3=t.^2-t;
- figure; %新建一个figure
- a1=axes('position',[0.1 0.6 0.8 0.3]); %%新建一个坐标轴,并设定它的位置。相对于figure的左下角
- plot(t,y1);
- title('y1','fontsize',14);
- a2=axes('position',[0.1 0.1 0.35 0.3]); %%再新建一个坐标轴
- plot(t,y2);
- title('y2','fontsize',14);
- a3=axes('position',[0.55 0.1 0.35 0.3]);%%再新建一个坐标轴
- plot(t,y3);
- title('y3','fontsize',14);
复制代码 效果如下:
**************任意排布******************- ax1=axes; %%默认坐标轴位置
- ezplot('exp(-x^2)',[-3 3]);
- ax2=axes('position',[0.6 0.6 0.2 0.2]); %%自定义坐标轴位置
- ezplot('sin(x)');
复制代码 效果:
****************************- subplot(2,2,1);
- %your code
- subplot(2,2,2);
- %your code
- subplot(2,2,3);
- % your code
- subplot(2,2,4);
- %your code
- hax=axes('position',[.3 .3 .4 .3]);box on
- %your code
复制代码
相关帖子
|