Save figure with minimal white space

4 ビュー (過去 30 日間)
Roderick
Roderick 2017 年 8 月 28 日
回答済み: OCDER 2017 年 8 月 31 日
Dear all,
In the following page, Mathworks explains how to save a figure with minimal white space.
ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];
I have a figure containing multiple subplots and can't figure out how to make it work. Anyone tips on modifying the commands suggested by Mathworks?
Thank you in advance.
Regards
  1 件のコメント
Jan
Jan 2017 年 8 月 28 日
Today I have selected your code with the mouse and hit the "{} Code" button for a readable formatting. Please do this by your own in the next questions. Thanks.

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

回答 (1 件)

OCDER
OCDER 2017 年 8 月 31 日
I had a similar issue and so had to create a series of codes to make this work. Essentially, you'll have to determine the location of the subplots and then manually set the axes. I use the "TightInset" property of each subplot axes handle to determine how much border to leave around each figure, and then adjust the "Position" property of each axes to the right location in the figure.
OR, you can take a look at the codes in this folder:
The codes in the PlotTools folder can be used for matlab plotting jobs. Download and test these files by running testPlotTools.m on your matlab, which shows what each function does. resizeSubplots.m is the function you probably want to use, which resizes all subplots to fill the white space. You can add spacers between the subplots too (see the resizeSubplots help info).

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by