configuration of subplots - editing titles, fonts and so on

2 views (last 30 days)
Hey everyone,
I currently have to create a lot of subplots, and for each I want to set:
colormap gray; axis image; title('title of spesific subplot','fontname','times','fontsize',16);
Is there any way for me to configure this line only once for all of my subplots instead of adding it for each line I write?
maybe entering the 'title of specific subplot' itself as an array?
thanks,

Answers (1)

dpb
dpb on 21 Dec 2019
That would be the obvious solution, yes. If the specific title is more or less random text, that's about the only way other than to have saved in an external text file that you read. If it's a generic title that only changes owing to some parameter, then it could be generated programmatically.
From the above limited description, structure the code as a loop over the number of subplots desired something like
nr=3; nc=2; % number rows, columns in subplot figure
nt=nr*nc; % total number subplots
for i=1:nt % for each subplot in order
hAx(i)=subplot(nr,nc,i); % create each subplot; save the axes handles
% do whatever for each subplot here
...
end

Community Treasure Hunt

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

Start Hunting!