Why is saveas() changing my image aspect ratio?

조회 수: 3 (최근 30일)
Asser Abdelgawad
Asser Abdelgawad 2022년 6월 17일
댓글: Asser Abdelgawad 2022년 6월 17일
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.
  댓글 수: 1
Asser Abdelgawad
Asser Abdelgawad 2022년 6월 17일
This doesn't change size though, only resolution.

댓글을 달려면 로그인하십시오.

카테고리

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