Effacer les filtres
Effacer les filtres

How can the set Figure properties for the whole script?

5 vues (au cours des 30 derniers jours)
Friedrich Maack
Friedrich Maack le 20 Sep 2017
Hi,
I would like to have all my plots in the script to have the same appearance and to be saved as pdf with minimal whitespace, so I can insert them in a Latex document. I took the commands from https://de.mathworks.com/help/matlab/creating_plots/save-figure-with-minimal-white-space.html :
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];
fig = gcf;
fig.PaperPositionMode = 'auto';
fig_pos = fig.PaperPosition;
fig.PaperSize = [fig_pos(3) fig_pos(4)];
They do exactly what I want but the settings always apply to gca and gcf so I would have to copy/paste these commands below every plot. I would like to know how to save them as default. For example it works with
set(0,'defaulttextinterpreter','latex');
and other similar commands.
Thank you!

Réponse acceptée

Tim Berk
Tim Berk le 20 Sep 2017
You can set almost all Figure values as default. For example:
set(0,'DefaultFigurePaperPositionMode','auto')
Or
set(0,'DefaultAxesPosition',[0 0 1 1])
  2 commentaires
Friedrich Maack
Friedrich Maack le 20 Sep 2017
I kind of answered myself in the meantime. The only solution I found was to create a function that contains all the settings and apply it to gcf below every figure. That way the properties are still set every time, but at least in a condensed form.
Thank you for your Answer!
Shoaib Ayjaz Mohammed
Shoaib Ayjaz Mohammed le 18 Août 2020
Hi Friedrich,
It woud be great if you could post an example for the function you created for the figure properties?
Thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by