Save Plot with Minimal White Space (Crop Padding)

50 ビュー (過去 30 日間)
z8080
z8080 2019 年 7 月 11 日
コメント済み: ZAHID RAZZAQ 2021 年 3 月 1 日
I'd like to save my figures without the rather large white padding space that Matlab includes by default, and such that they are as tightly cropped as possible.
This page seems to include both a script/programatic way to do it as well as a GUI-based one; unfortunately, it seems to not work in my version (R2016a).
Is there any workaround that can help me achieve the same goal?
Thanks!
  2 件のコメント
Adam Danz
Adam Danz 2019 年 7 月 11 日
Also see the solutions to these similar questions
z8080
z8080 2019 年 7 月 11 日
Thanks for your answer Adam!
What isn't working: there is no export button as explained on that page, since this feature I believe was only introduced in a later version. Also if I run the proposed sections of code, it does not have the desired effect on the figure.
As to the links you included:
1) Those 2 lines of code did not work for me
2) Haven't tried that long section of code - am hoping for a simpler solution..
3) "axis tight" doesn't do it in this case, if there is for instance a legend, as what I want to remove is the padding between the legend and the figure's (canvas') edge.

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

採用された回答

Adam Danz
Adam Danz 2019 年 7 月 11 日
編集済み: Adam Danz 2019 年 7 月 11 日
"What isn't working: there is no export button as explained on that page..."
The demo in the link you provided works well in r2019a and r2016b (those are the releases I tested).
r2019a
Hover your mouse over the axes and a row of icons should appear in the upper, right corner, one of which is the export button.
If that's not working in r2019a, make sure toolbar visibility is on.
axh = gca();
axh.Toolbar.Visible = 'on';
r2016b
From the menu bar, select File > Export Setup.
Turn on the menu bar if it's not visible.
fh = gcf();
fh.MenuBar = 'Figure';
Alternatively, do it programmatically.
Follow the steps in the link you proivded to do it without the export button.
"1) Those 2 lines of code did not work for me..."
Again, what didn't work? I'm sure it didn't result in an error.
  2 件のコメント
z8080
z8080 2019 年 7 月 11 日
Many thanks for this , I will give it a try!
ZAHID RAZZAQ
ZAHID RAZZAQ 2021 年 3 月 1 日
Thanks so much it worked for me. I am using Matlab R2020b, this was exactly I was looking for , it also doesn't distort the quality of plot. Thanks once again.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by