Why does exportgraphics change the figure when exporting an area plot to png?

25 ビュー (過去 30 日間)
Johannes Schorr
Johannes Schorr 2023 年 12 月 11 日
移動済み: Dyuman Joshi 2024 年 1 月 24 日
Hey everyone,
when I export my area-plot with exportgraphics at high resolutions (e.g. >300 dpi), it changes the plotted area like follows:
<-How it should look
<- How it actually looks
the export-command I am using is as follows:
exportgraphics(gcf,'figure.png','Resolution',300)
I am also plotting using yyaxis and tiled layout.
Does someone know a quick work-around or the reason why matlab does this? When manually exporting the figure the same issue ocurrs...
Best,
Johannes
  2 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 12 月 11 日
移動済み: Dyuman Joshi 2024 年 1 月 24 日
From the documentation - "exportgraphics(obj,filename) saves the contents of the graphics object specified by obj to a file. The graphics object can be any type of axes, a figure, a standalone visualization, a tiled chart layout, or a container within the figure. The resulting graphic is tightly cropped to a thin margin surrounding your content."
Note the underlined part.
Try using print or saveas instead.
Options from FEX include export_fig
Johannes Schorr
Johannes Schorr 2023 年 12 月 11 日
移動済み: Dyuman Joshi 2024 年 1 月 24 日
Thanks for the suggestions, however, neither of these seem to resolve the issue.

サインインしてコメントする。

回答 (1 件)

Johannes Schorr
Johannes Schorr 2023 年 12 月 11 日
移動済み: Dyuman Joshi 2024 年 1 月 24 日
My work-around is now to go to:
  • File > Export Setup > Rendering > Resolution: 300/600 > Apply to Figure > OK
  • File > Save as --> save figure in desired format
This solves the issue, but is rather tedious if you have many figures to export...

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by