Why is the PNG of my figure rotated 90 degrees?

1 visualización (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 10 de Abr. de 2017
Editada: MathWorks Support Team el 10 de Nov. de 2025 a las 11:55
In MATLAB, my figure looks exactly how I want it to look in the figure window. However, when I save the figure as a PNG file, the resulting PNG inage is rotated 90 degrees. How can I make sure that the PNG looks exactly like the figure?
I use the following command to save my figure, "fig", as a PNG:
>> print(fig,'-dpng',pngName);

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 10 de Nov. de 2025 a las 0:00
Editada: MathWorks Support Team el 10 de Nov. de 2025 a las 11:55
When the 'PaperOrientation' property of the figure is set to 'landscape' instead of 'portrait', the subsequent call to "print" saves the figure as a PNG image using this orientation specification. This could result in an image that is rotated 90 degrees from the orientation of the original figure.
This can be verified with the following command (while the figure "fig" is open):
>> get(fig,'PaperOrientation')
In order to resolve this issue, you can insert the following line before the call to "print":
>> set(fig,'PaperOrientation','portrait');
For the latest release documentation on figure properties, please refer to:

Más respuestas (0)

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by