How can the set Figure properties for the whole script?

5 次查看(过去 30 天)
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!

采纳的回答

Tim Berk
Tim Berk 2017-9-20
You can set almost all Figure values as default. For example:
set(0,'DefaultFigurePaperPositionMode','auto')
Or
set(0,'DefaultAxesPosition',[0 0 1 1])
  2 个评论
Friedrich Maack
Friedrich Maack 2017-9-20
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
Hi Friedrich,
It woud be great if you could post an example for the function you created for the figure properties?
Thanks

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by