Filter löschen
Filter löschen

How can the set Figure properties for the whole script?

5 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Tim Berk
Tim Berk am 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 Kommentare
Friedrich Maack
Friedrich Maack am 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 am 18 Aug. 2020
Hi Friedrich,
It woud be great if you could post an example for the function you created for the figure properties?
Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by