MATLAB - 轴相等并且同时拉伸填充?

Sib*_*ing 2 matlab plot image aspect-ratio matlab-figure

默认情况下,stretch-to-fill处于打开状态。所以

pixels = ones(100,100)
image(pixels);
colormap([0 0 0; 1 1 1]);
Run Code Online (Sandbox Code Playgroud)

产生

在此输入图像描述

强制轴具有相同的比例,这

pixels = ones(100,100)
image(pixels);
colormap([0 0 0; 1 1 1]);
axis equal;
Run Code Online (Sandbox Code Playgroud)

产生

在此输入图像描述

显然,stretch-to-fill被 覆盖axis equal。怎样做才能让它们共存?

Amr*_*mro 5

我认为您正在寻找这个电话:

figure(1)
image(pixels)
colormap(clr)
axis image        % <-- this call
Run Code Online (Sandbox Code Playgroud)

图像

下面是各种模式操作的轴属性表:axis

axis_modes_axes_props


您还可以使用该imshow函数执行类似的操作,该函数充当image/的更高级别包装器imagesc

figure(2)
imshow(pixels, clr, 'InitialMag','fit', 'Border','loose')
axis on
Run Code Online (Sandbox Code Playgroud)