Why is the PNG of my figure rotated 90 degrees?
2 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2017-4-10
编辑: MathWorks Support Team
2025-11-10,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);
采纳的回答
MathWorks Support Team
2025-11-10
编辑:MathWorks Support Team
2025-11-10,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:
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!