Why is saveas() changing my image aspect ratio?

3 次查看(过去 30 天)
I'm trying to save a figure as a PNG but the aspect ratio changes for some reason.
This is how it looks in MATLAB:
This is how it looks when I save it (slightly elongated as you can see):
How can I fix this?
g = figure;
subplot(1,2,1)
imagesc(im1);
subplot(1,2,2)
imagesc(im2);
g.WindowState = 'maximized'; % this didn't work
saveas(g, name, "png");

回答(2 个)

Jan
Jan 2022-6-17
Try to set the 'PaperSize' property of the figure.

Eamon Gekakis
Eamon Gekakis 2022-6-17
The exportgraphics function may be useful here, 'Resolution' is available as a name-value pair input argument.

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by