필터 지우기
필터 지우기

How can the set Figure properties for the whole script?

조회 수: 5 (최근 30일)
Friedrich Maack
Friedrich Maack 2017년 9월 20일
댓글: Shoaib Ayjaz Mohammed 2020년 8월 18일
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
Shoaib Ayjaz Mohammed 2020년 8월 18일
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