Why is saveas() changing my image aspect ratio?

6 visualizaciones (últimos 30 días)
Asser Abdelgawad
Asser Abdelgawad el 17 de Jun. de 2022
Comentada: Asser Abdelgawad el 17 de Jun. de 2022
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");

Respuestas (2)

Jan
Jan el 17 de Jun. de 2022
Try to set the 'PaperSize' property of the figure.

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

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by