【问题标题】:Matlab - Creating a figure of different sized subplotsMatlab - 创建不同大小子图的图形
【发布时间】:2019-11-09 06:48:57
【问题描述】:

我有一组图像,我需要将它们并排绘制,每个图像都有不同的大小。虽然实际图像尺寸很大,但我想做一些类似 imresize 的操作来绘制我想要的尺寸。

我尝试过像这样的子情节策略

subplot(1, 4, 1);
imshow(...);
subplot(1, 4, 2);
imshow(...);
subplot(1, 4, 3);
imshow(...);
subplot(1, 4, 4);
imshow(...);

但所有图像都显示为相同大小。我想要这样的东西

出于某种原因,这似乎很重要。非常感谢一些帮助。

【问题讨论】:

  • 您可以手动设置每个轴的位置和大小(参见其“Position”属性)。

标签: image matlab image-processing plot charts


【解决方案1】:

可以通过在语法subplot(m,n,p) 中为网格位置参数p 指定多元素向量来生成subplots of different sizes

您的示例可以使用以下内容构建:

subplot(4,10,[1:4 11:14 21:24 31:34]);
subplot(4,10,[5:7 15:17 25:27]);
subplot(4,10,[8:9 18:19]);
subplot(4,10,[10]);

【讨论】:

    【解决方案2】:

    可以在图中添加4个轴,并设置每个轴的位置:

    I = imread('cameraman.tif');
    
    scrsz = get(groot, 'ScreenSize'); %Get screen size
    f = figure('Position', [scrsz(3)/10, scrsz(4)/5, scrsz(4)/2*2.4, scrsz(4)/2]); %Set figure position by screen size.
    positionVector1 = [-0.25, 0.95-0.9, 0.9, 0.9]; %position vector for largest image.
    positionVector2 = [0.23, 0.95-0.6, 0.6, 0.6];
    positionVector3 = [0.555, 0.95-0.4, 0.4, 0.4];
    positionVector4 = [0.775, 0.95-0.267, 0.267, 0.267]; %position vector for smallest image.
    axes(f, 'Position', positionVector1);
    imshow(I, 'border', 'tight');
    axes(f, 'Position', positionVector2);
    imshow(I, 'border', 'tight');
    axes(f, 'Position', positionVector3);
    imshow(I, 'border', 'tight');
    axes(f, 'Position', positionVector4);
    imshow(I, 'border', 'tight');
    

    手动设置位置不是最佳解决方案。
    必须有一种方法来计算每个轴的位置。

    结果:

    【讨论】:

      猜你喜欢
      • 2012-10-22
      • 2012-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-27
      • 1970-01-01
      • 2017-04-01
      相关资源
      最近更新 更多