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。怎样做才能让它们共存?
我认为您正在寻找这个电话:
figure(1)
image(pixels)
colormap(clr)
axis image % <-- this call
Run Code Online (Sandbox Code Playgroud)


您还可以使用该imshow函数执行类似的操作,该函数充当image/的更高级别包装器imagesc:
figure(2)
imshow(pixels, clr, 'InitialMag','fit', 'Border','loose')
axis on
Run Code Online (Sandbox Code Playgroud)