【问题标题】:Colorbar resizes the subplots颜色栏调整子图的大小
【发布时间】:2018-02-24 17:45:09
【问题描述】:

我正在尝试使用subplot 在 MATLAB 中并排绘制 3 张图像:

maxValue =  9;
minValue =  5;

figure(1)
subplot(1,3,1);
imshow(im1);
axis equal;

subplot(1,3,2);
imagesc(im2);colorbar;
caxis([minValue maxValue]) 
axis equal;

subplot(1,3,3);
imagesc(im3);colorbar;
caxis([minValue maxValue]) 
axis equal;

但结果看起来像这样:

显然颜色条正在调整图像的大小。如何使所有 3 张图片大小相同,并且颜色条适合图片大小?

【问题讨论】:

    标签: image matlab matlab-figure subplot


    【解决方案1】:

    这是我最终做的:

    fig = figure(1);
    set(fig, 'Position', [52 529 1869 445]); % Resize the image
    subplot(1,3,1); % Add a subplot
    subaxis(1,3,1, 'Spacing', 0.03, 'Padding', 0, 'Margin', 0); % Remove whitespace from subplot
    imshow(im);
    axis equal; % Use undistorted images
    
    
    subplot(1,3,2);
    subaxis(1,3,2, 'Spacing', 0.03, 'Padding', 0, 'Margin', 0);
    imagesc(depth_gt);colorbar;
    caxis([minValue maxValue]) 
    axis equal;
    
    
    subplot(1,3,3);
    subaxis(1,3,3, 'Spacing', 0.03, 'Padding', 0, 'Margin', 0);
    imagesc(depth_pred);colorbar;
    caxis([minValue maxValue]) 
    axis equal;
    

    您可以通过手动调整图像大小来获得这个“位置”,然后在 Matlab 命令终端中打印fig 的输出

    【讨论】:

      【解决方案2】:

      您的图片会根据可用空间调整大小以保持其纵横比。
      axis normal; 用于subplot(1,3,1) 而不是axis equal
      您可能还需要最大化图形窗口。


      对于im1 = imread('peppers.png');,结果是:

      【讨论】:

        猜你喜欢
        • 2013-06-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-09-15
        • 2021-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多