Why is saveas() changing my image aspect ratio?

8 views (last 30 days)
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;
g.WindowState = 'maximized'; % this didn't work
saveas(g, name, "png");

Answers (2)

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

Eamon Gekakis
Eamon Gekakis on 17 Jun 2022
The exportgraphics function may be useful here, 'Resolution' is available as a name-value pair input argument.
  1 Comment
Asser Abdelgawad
Asser Abdelgawad on 17 Jun 2022
This doesn't change size though, only resolution.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!