Save figure with minimal white space

4 vues (au cours des 30 derniers jours)
Roderick
Roderick le 28 Août 2017
Réponse apportée : OCDER le 31 Août 2017
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 commentaire
Jan
Jan le 28 Août 2017
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.

Connectez-vous pour commenter.

Réponses (1)

OCDER
OCDER le 31 Août 2017
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).

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by