爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 13936|回复: 10

[程序设计] matlab用subplot作图显示不全

[复制链接]

新浪微博达人勋

发表于 2020-8-24 09:44:11 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
各位大神,你们在画图的时候有没有遇到过,用subplot在一张Figure里画多张图时,显示不全的情况,比如,我需要画8张图,但是在Figure里只显示出6张。程序没有报错,也检查不出问题,好疑惑,求大大解答!!!
附上画图程序,以供参考。
H = figure
set(gcf,'unit','centimeters','position',[0,1,25,25])
H1 = subplot(4,2,1)
set(H1,'pos',[0.07  0.78 0.21  0.21])
m_proj('Equidistant Cylindrical','lon',[100 130],'lat',[15 45]);%¸ü¸Ä·¶Î§
m_pcolor(Lon_T,Lat_T,PP1')
shading interp
colormap(mycols(0));
caxis([-1.1 1.1])
set(gca, 'FontSize', 10);
hold on
m_coast('color',[0.3 0.3 0.5]);
hold on
m_contour(Lon_SH,Lat_SH,SH',[300,300],'LineColor','g','LineWidth',2.5);
hold on
m_plot(GJ_X,GJ_Y,'-k','LineWidth',2.5)%»æ1ú½ç
hold on
m_plot(yangtze_x,yangtze_y,'-g','LineWidth',1)%»æ3¤½-
hold on
m_plot(yellow_x,yellow_y,'-g','LineWidth',1)%»æ»Æoó
m_grid('ytick',[20 30 40],'xtick',[])
hold on
m_rectangle(125,15,5,5,0,'LineWidth',1,'Curvature', [0 0], 'FaceColor','w')
hold on
m_text(125.5,17.5,'P1','fontname','Times New Roman','FontSize',17);  

H2 = subplot(4,2,2)
set(H2,'pos',[0.07  0.56 0.21  0.21])
m_proj('Equidistant Cylindrical','lon',[100 130],'lat',[15 45]);%¸ü¸Ä·¶Î§
m_pcolor(Lon_T,Lat_T,PP2')
shading interp
colormap(mycols(0));
caxis([-1.1 1.1])
set(gca, 'FontSize', 10);
hold on
m_coast('color',[0.3 0.3 0.5]);
hold on
m_contour(Lon_SH,Lat_SH,SH',[300,300],'LineColor','g','LineWidth',2.5);
hold on
m_plot(GJ_X,GJ_Y,'-k','LineWidth',2.5)%»æ1ú½ç
hold on
m_plot(yangtze_x,yangtze_y,'-g','LineWidth',1)%»æ3¤½-
hold on
m_plot(yellow_x,yellow_y,'-g','LineWidth',1)%»æ»Æoó
m_grid('ytick',[20 30 40],'xtick',[])
hold on
m_rectangle(125,15,5,5,0,'LineWidth',1,'Curvature', [0 0], 'FaceColor','w')
hold on
m_text(125.5,17.5,'P2','fontname','Times New Roman','FontSize',17);  

H3 = subplot(4,2,3)
set(H3,'pos',[0.07  0.34 0.21  0.21])
m_proj('Equidistant Cylindrical','lon',[100 130],'lat',[15 45]);%¸ü¸Ä·¶Î§
m_pcolor(Lon_T,Lat_T,PP3')
shading interp
colormap(mycols(0));
caxis([-1.1 1.1])
set(gca, 'FontSize', 10);
hold on
m_coast('color',[0.3 0.3 0.5]);
hold on
m_contour(Lon_SH,Lat_SH,SH',[300,300],'LineColor','g','LineWidth',2.5);
hold on
m_plot(GJ_X,GJ_Y,'-k','LineWidth',2.5)%»æ1ú½ç
hold on
m_plot(yangtze_x,yangtze_y,'-g','LineWidth',1)%»æ3¤½-
hold on
m_plot(yellow_x,yellow_y,'-g','LineWidth',1)%»æ»Æoó
m_grid('ytick',[20 30 40],'xtick',[])
hold on
m_rectangle(125,15,5,5,0,'LineWidth',1,'Curvature', [0 0], 'FaceColor','w')
hold on
m_text(125.5,17.5,'P3','fontname','Times New Roman','FontSize',17);  

H4 = subplot(4,2,4)
set(H4,'pos',[0.07  0.12 0.21  0.21])
m_proj('Equidistant Cylindrical','lon',[100 130],'lat',[15 45]);%¸ü¸Ä·¶Î§
m_pcolor(Lon_T,Lat_T,PP4')
shading interp
colormap(mycols(0));
caxis([-1.1 1.1])
set(gca, 'FontSize', 10);
hold on
m_coast('color',[0.3 0.3 0.5]);
hold on
m_contour(Lon_SH,Lat_SH,SH',[300,300],'LineColor','g','LineWidth',2.5);
hold on
m_plot(GJ_X,GJ_Y,'-k','LineWidth',2.5)%»æ1ú½ç
hold on
m_plot(yangtze_x,yangtze_y,'-g','LineWidth',1)%»æ3¤½-
hold on
m_plot(yellow_x,yellow_y,'-g','LineWidth',1)%»æ»Æoó
m_grid('ytick',[20 30 40],'xtick',[])
hold on
m_rectangle(125,15,5,5,0,'LineWidth',1,'Curvature', [0 0], 'FaceColor','w')
hold on
m_text(125.5,17.5,'P4','fontname','Times New Roman','FontSize',17);  

H5 = subplot(4,2,5)
set(H5,'pos',[0.26 0.78 0.21  0.21])
m_proj('Equidistant Cylindrical','lon',[100 130],'lat',[15 45]);%¸ü¸Ä·¶Î§
m_pcolor(Lon_T,Lat_T,PP5')
shading interp
colormap(mycols(0));
caxis([-1.1 1.1])
set(gca, 'FontSize', 10);
hold on
m_coast('color',[0.3 0.3 0.5]);
hold on
m_contour(Lon_SH,Lat_SH,SH',[300,300],'LineColor','g','LineWidth',2.5);
hold on
m_plot(GJ_X,GJ_Y,'-k','LineWidth',2.5)%»æ1ú½ç
hold on
m_plot(yangtze_x,yangtze_y,'-g','LineWidth',1)%»æ3¤½-
hold on
m_plot(yellow_x,yellow_y,'-g','LineWidth',1)%»æ»Æoó
m_grid('ytick',[20 30 40],'xtick',[])
hold on
m_rectangle(125,15,5,5,0,'LineWidth',1,'Curvature', [0 0], 'FaceColor','w')
hold on
m_text(125.5,17.5,'P5','fontname','Times New Roman','FontSize',17);  

H6 = subplot(4,2,6)
set(H6,'pos',[0.26  0.56 0.21  0.21])
m_proj('Equidistant Cylindrical','lon',[100 130],'lat',[15 45]);%¸ü¸Ä·¶Î§
m_pcolor(Lon_T,Lat_T,PP6')
shading interp
colormap(mycols(0));
caxis([-1.1 1.1])
set(gca, 'FontSize', 10);
hold on
m_coast('color',[0.3 0.3 0.5]);
hold on
m_contour(Lon_SH,Lat_SH,SH',[300,300],'LineColor','g','LineWidth',2.5);
hold on
m_plot(GJ_X,GJ_Y,'-k','LineWidth',2.5)%»æ1ú½ç
hold on
m_plot(yangtze_x,yangtze_y,'-g','LineWidth',1)%»æ3¤½-
hold on
m_plot(yellow_x,yellow_y,'-g','LineWidth',1)%»æ»Æoó
m_grid('ytick',[20 30 40],'xtick',[])
hold on
m_rectangle(125,15,5,5,0,'LineWidth',1,'Curvature', [0 0], 'FaceColor','w')
hold on
m_text(125.5,17.5,'P6','fontname','Times New Roman','FontSize',17);  

H7 = subplot(4,2,7)
set(H7,'pos',[0.26  0.34 0.21  0.21])
m_proj('Equidistant Cylindrical','lon',[100 130],'lat',[15 45]);%¸ü¸Ä·¶Î§
m_pcolor(Lon_T,Lat_T,PP7')
shading interp
colormap(mycols(0));
caxis([-1.1 1.1])
set(gca, 'FontSize', 10);
hold on
m_coast('color',[0.3 0.3 0.5]);
hold on
m_contour(Lon_SH,Lat_SH,SH',[300,300],'LineColor','g','LineWidth',2.5);
hold on
m_plot(GJ_X,GJ_Y,'-k','LineWidth',2.5)%»æ1ú½ç
hold on
m_plot(yangtze_x,yangtze_y,'-g','LineWidth',1)%»æ3¤½-
hold on
m_plot(yellow_x,yellow_y,'-g','LineWidth',1)%»æ»Æoó
m_grid('ytick',[20 30 40],'xtick',[])
hold on
m_rectangle(125,15,5,5,0,'LineWidth',1,'Curvature', [0 0], 'FaceColor','w')
hold on
m_text(125.5,17.5,'P7','fontname','Times New Roman','FontSize',17);  

H8 = subplot(4,2,8)
set(H8,'pos',[0.26  0.12 0.21  0.21])
m_proj('Equidistant Cylindrical','lon',[100 130],'lat',[15 45]);%¸ü¸Ä·¶Î§
m_pcolor(Lon_T,Lat_T,PP8')
shading interp
colormap(mycols(0));
caxis([-1.1 1.1])
set(gca, 'FontSize', 10);
hold on
m_coast('color',[0.3 0.3 0.5]);
hold on
m_contour(Lon_SH,Lat_SH,SH',[300,300],'LineColor','g','LineWidth',2.5);
hold on
m_plot(GJ_X,GJ_Y,'-k','LineWidth',2.5)%»æ1ú½ç
hold on
m_plot(yangtze_x,yangtze_y,'-g','LineWidth',1)%»æ3¤½-
hold on
m_plot(yellow_x,yellow_y,'-g','LineWidth',1)%»æ»Æoó
m_grid('ytick',[20 30 40],'xtick',[])
hold on
m_rectangle(125,15,5,5,0,'LineWidth',1,'Curvature', [0 0], 'FaceColor','w')
hold on
m_text(125.5,17.5,'P8','fontname','Times New Roman','FontSize',17);  





密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2020-8-24 11:22:46 | 显示全部楼层

回帖奖励 +5 金钱

subplot 如果两个坐标有重叠区域,前一个会被覆盖。
以及subplot(m,n,p) 和设置位置最好不要互相串用吧。
你可以用 axes,感觉更符合你的需要
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-8-24 11:44:49 | 显示全部楼层

回帖奖励 +5 金钱

写八个subplot  为什么不用个循环呢。。。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-8-24 12:33:04 | 显示全部楼层

回帖奖励 +5 金钱

如果不用set(H7,'pos',[0.26  0.34 0.21  0.21])这种控制具体位置的命令,会不会还有显示不全的状况?用subplot自带的位置设定按顺序下来试试。另外赞同楼上看法,建议使用循环画图。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-8-24 14:08:37 | 显示全部楼层

回帖奖励 +5 金钱

subplot重叠的话就可能画不出来,用axes就好了。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-8-24 23:04:57 | 显示全部楼层
学习渣渣 发表于 2020-8-24 11:22
subplot 如果两个坐标有重叠区域,前一个会被覆盖。
以及subplot(m,n,p) 和设置位置最好不要互相串用吧。
...

嗯嗯,确实是,谢谢你!
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-8-24 23:09:12 | 显示全部楼层
wjy_ecnu 发表于 2020-8-24 11:44
写八个subplot  为什么不用个循环呢。。。

哈哈哈,这样看起来更直观
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-8-24 23:12:59 | 显示全部楼层

回帖奖励 +5 金钱

{:eb513:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-8-24 23:19:27 | 显示全部楼层
伽蓝鸟 发表于 2020-8-24 14:08
subplot重叠的话就可能画不出来,用axes就好了。

已经解决,谢谢!
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-12-23 10:20:54 | 显示全部楼层
楼主,请问怎么解决的?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表