MATLAB画图 |
您所在的位置:网站首页 › MATLAB多子图如何命名 › MATLAB画图 |
MATLAB的subplot函数,让我们可以在一个图中画多张图,大多数情况下,系统自动平均分配的大小非常合适。但有时候,我们需要几个子图有不同的大小,或者是需要不均匀的位置,例如: 函数图的三个视角立体频谱图和声波图那么这种情况怎么做呢? 很简单。 命令subplot(m,n,i),会均匀地将图窗分为m行×n列的网格,并在第i个位置生成图片。 请看: subplot(3,2,1)subplot(3,2,2)subplot(3,2,2)subplot(3,2,3)可见子窗的编号是一行一行顺序数下来的。subplot支持这样一种写法 subplot(m,n,[i,j,k,l]); 也就是说把第i、j、k、l个子窗合成一个图窗来画图。给个例子: subplot(3,2,[1 2 3 4]);subplot(3,2,[5,6])如果你想画不均匀子图,只要自己定义位置就好了! 给个模板: figure%生成图窗 set(gcf,'unit','normalized','position',[0,0,1,1]);%设定图窗为宽屏全屏 x1=load("C:\Users\16000\Desktop\GlobalSeis_notitle\0000000_rad_2_0.asc"); suptitle("Spheroidal n=2,l=0");%总标题 subplot(4,2,[1 3]);%在[1,3]位置画第一个子图 T1=x1(:,1)/1000;U1=x1(:,2); plot(U1,T1,'LineWidth',1);grid on;grid minor;%画图,开坐标网格 title('U(r)');%每个子图都可以加标题 subplot(4,2,[2 4]);%在[2,4]位置画第二个子图 T1=x1(:,1)/1000;U1=x1(:,3); plot(U1,T1,'LineWidth',1);grid on;grid minor;title('dU(r)/dr'); subplot(4,2,[5 7]);%在[5,7]位置画第三个子图 T1=x1(:,1)/1000;U1=T1.*0; plot(U1,T1,'LineWidth',1);grid on;grid minor;title('V(r)'); subplot(4,2,[6 8]);%在[6,8]位置画第四个子图 T1=x1(:,1)/1000;U1=T1.*0; plot(U1,T1,'LineWidth',1);grid on;grid minor;title('dV(r)/dr'); I=getframe(gcf); imwrite(I.cdata,'0000000_rad_2_0.jpg'); 经过调整生成的图片谢谢收看,欢迎收藏~ |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |