【问题标题】:Extending subplot function in matlab在matlab中扩展子图函数
【发布时间】:2013-09-08 16:41:56
【问题描述】:

大家好,我在matlab中遇到了一些问题:

假设我有 5 张图像,我想在 matlab 图形窗口中绘制所有图像。我该怎么做?意思是我想在第一行放两张图片,在第二行放三张图片。我实际上想要这个输出。

或者是这样的:

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

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

我使用的代码是这样的:

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。

如需进一步澄清,请回复我!

提前致谢!!

【问题讨论】:

  • 老实说,您计划做的事情相当复杂,甚至可能是不可能的。您可以尝试文件交换的subaxis 包。但我强烈建议您节省时间并在 illustrator 或 Latex 中进行图像合成。还是有什么特殊原因要在 matlab 中执行此操作?
  • 感谢您的回复。其实我对乳胶并不熟悉。我的代码是用 matlab 编写的。在 matlab 命令提示符下生成逻辑数组。我怎样才能将它们转移到乳胶?
  • 乳胶只是一个例子,您也可以使用任何其他软件。显然matlab也有解决方案。

标签: matlab image-processing plot figure


【解决方案1】:

如果您想使用subplot,而不是直接指定坐标轴位置,您必须在脑海中将图形分割成最小的均匀区域,然后将它们组合成图。例如,要拥有三个大小相同的地块,一个在顶部,两个在底部,您可以:

firstAxes =  subplot(2,4,2:3);
secondAxes = subplot(2,4,5:6);
thirdAxes =  subplot(2,4,7:8);

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

   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】:

你也可以试试

figure
subplot(2,3,1.5)
subplot(2,3,2.5)
subplot(2,3,4)
subplot(2,3,5)
subplot(2,3,6)

subplot(2,2,1.5)
subplot(2,2,3)
subplot(2,2,4)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-20
    • 2013-02-24
    • 2014-07-14
    • 2012-07-02
    • 1970-01-01
    • 2021-11-21
    • 2021-09-14
    相关资源
    最近更新 更多