How can I repeat my setting for multiple figures (in different figure )?

90 views (last 30 days)
work wolf
work wolf on 21 Nov 2017
Answered: Nimrod on 3 Jan 2019
I want to apply this changes to all of my figures:
figure('PaperUnits', 'inches','Units', 'inches',...
'PaperPosition', Possave,...
'PaperSize', sizesave,...
'Position', Poscreen,...
'PaperPositionMode', 'auto'); %'PaperType','A4');
axis auto;
set(gca,...
'Units','normalized',...
'FontUnits','points',...
'FontWeight','normal',... 'fontWeight','bold',...
'FontSize',14,...
'FontName','Times',...
'LineWidth',2,...
'box', 'off'); % default is off
set(legend,'FontSize',14,...
'linewidth', 0.3,...
'interpreter','latex',...
'TextColor',[0,0,0]);
and so on
How do I do that without the need of repeating my setting like this:
figure;
p=[plot(t,XEe,'-black'),plot(t,X,'or'),plot(t,XF,'+b'),...
plot(t,YEe,'-black'),plot(t,Y,'or'),plot(t,YF,'+b')];
set(p,'MarkerSize',10,'LineWidth',2);
figure;
p=[plot(t,XEe,'-black'),plot(t,X,'or'),...
plot(t,YEe,'-black'),plot(t,Y,'or'),];
set(p,'MarkerSize',10,'LineWidth',2);
figure;
p=[plot(t,XEe,'-black'),plot(t,XF,'+b'),...
plot(t,YEe,'-black'),plot(t,YF,'+b')];
set(p,'MarkerSize',10,'LineWidth',2);

Accepted Answer

Stephen23
Stephen23 on 21 Nov 2017
Edited: Stephen23 on 22 Nov 2017
Two simple options:
  1. Set those value as defaults in the graphics root, then they will be used for all figures/axes/...
  2. Put the key-value pairs into a cell array, and then use a comma-separated list to input the values to the command:
figOpt = {'Position',[...], 'Papersize',[...],...};
axeOpt = {...};
...
figHnd = figure(...,figOpt{:});
axeHnd = axes(figHnd,...,axeOpt{:});
etc
  3 Comments
work wolf
work wolf on 21 Nov 2017
Thanks again. Really, your answer is so clear and useful. Best Regards.

Sign in to comment.

More Answers (1)

Nimrod
Nimrod on 3 Jan 2019
help linkprop

Community Treasure Hunt

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

Start Hunting!