首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >matlab中subplot函数的扩展

matlab中subplot函数的扩展
EN

Stack Overflow用户
提问于 2013-09-09 00:41:56
回答 2查看 2.4K关注 0票数 2

大家好,我在matlab中有几个问题:

假设我有5幅图像,我想在matlab图形窗口中绘制所有这些图像。我如何做到这一点呢?这意味着我想把两个图像放在第一行,3个图像放在第二行。我实际上想要这个输出。

或者类似这样的东西:

请记住,我想在两个图形窗口的顶行居中对齐图像。简而言之,我想知道如何在matlab图形窗口中具体设置子图的位置?

另外,有没有什么方法可以给我的图形窗口一个主标题?我不想使用函数SUPLABEL

我使用的代码是:

代码语言:javascript
复制
h1=figure;
subplot(2,3,1);imshow(I_orignial);title('The original Image','FontWeight','bold','FontSize', 12);
subplot(2,2,2);imshow(aa1); title('1st segment','FontWeight','bold','FontSize', 12);
subplot(2,2,3);imshow(aa2); title('2nd segment','FontWeight','bold','FontSize', 12);
subplot(2,2,4);imshow(aa3); title('3rd segment','FontWeight','bold','FontSize', 12);

%//Please note that aa1,aa2 & aa3 are logical arrays and I_orignial is an uint8 image.
%//The size of the logical arrays is 64X64.
%//The size of the image is 160X221.

另外,在图形上显示之前,有没有办法将我的子图图像调整到特定的大小?我的意思是,如何在matlab图形上将不同大小的图像强制为相同的子图大小?请注意:我不是在谈论imresize。

如果需要进一步的澄清,请给我回复!

提前感谢!!

EN

回答 2

Stack Overflow用户

发布于 2013-09-09 01:40:23

如果你想使用subplot,而不是直接指定轴的位置,你必须在你的脑海中将图形分割成最小的均匀区域,然后将它们组合成图。例如,要有三个大小相等的图,一个在顶部,两个在底部,您应该这样做:

代码语言:javascript
复制
firstAxes =  subplot(2,4,2:3);
secondAxes = subplot(2,4,5:6);
thirdAxes =  subplot(2,4,7:8);

如果要执行更复杂的操作,例如将文本放在特定位置,最好直接创建显示对象。例如:

代码语言:javascript
复制
   fh = figure;
   hiddenAxes = axes('parent',fh,'units','normalized','position',[0 0 1 1],'color','w','xcolor','w','ycolor','w','xlim',[0 1],'ylim',[0 1]);
   text('parent',hiddenAxes','position',[0.25 0.9 0.5 0.1],'horizontalAlignment','center','string','this is a centered title','fontWeight','bold')
   firstAxes =  axes('parent',fh,'units','normalized','position',[0.25 0.5 0.5 0.45]);
   secondAxes = axes('parent',fh,'units','normalized','position',[0 0 0.5 0.45]);
   thirdAxes =  axes('parent',fh,'units','normalized','position',[0.5 0 0.5 0.45]);

要控制图像大小,您需要更改轴限制。

票数 2
EN

Stack Overflow用户

发布于 2017-09-27 03:30:16

您也可以尝试

代码语言:javascript
复制
figure
subplot(2,3,1.5)
subplot(2,3,2.5)
subplot(2,3,4)
subplot(2,3,5)
subplot(2,3,6)

代码语言:javascript
复制
subplot(2,2,1.5)
subplot(2,2,3)
subplot(2,2,4)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18686122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档