I'm trying to control the properties for subplot's title in a way that is independent of other font properties while using latex as interpreter (I don't think this last part is relevant, but just in case). Here is a sample code:
% Figure handle
fig1 = figure;
% Subplot 1
subplot(2,1,1)
plot(rand(100,1))
xlabel('$x$ label')
ylabel('$y$ label')
title('First subplot')
% Subplot 2
subplot(2,1,2)
plot(rand(100,1))
xlabel('$x$ label')
ylabel('$y$ label')
title('Second subplot')
% Setting global properties
set(findall(fig1,'-property','FontSize'),'FontSize',14)
set(findall(fig1,'-property','Interpreter'),'Interpreter','Latex')
set(findall(fig1,'-property','TickLabelInterpreter'),'TickLabelInterpreter','Latex')
When I do this, I can set the size and interpreter for axis labels, tick labels, and subplot titles. This makes the title to have the same style as those other objects.
Is there a way to control the titles properties independently to make them slightly bigger and bolder, for example, so they are easily distinguishable from axis labels?
The set
instruction can be applied to an array of graphic handle, so if you want to modify properties of all your titles, just gather their handles in an array first, then use the set
command on the handle array.
So in your example, replace your
% ...
title('First subplot')
% ...
title('Second subplot')
% ...
by:
% ...
ht(1) = title('First subplot')
% ...
ht(2) = title('Second subplot')
% ...
You now have an array of handles ht
to your titles. Now to modify them all in one batch, without modifying anything else:
set( ht , 'FontSize',18, 'FontWeight','bold')
Similarly, you could regroup handles of other objects to assign their properties in one go:
% build a collection of xlabel array
hxlabel = [hax(1).XLabel hax(2).XLabel] ;
% Set their label and interpreter all at once
set( hxlabel , 'String' , '$x$ label' , 'Interpreter','Latex' )
This will apply the same xlabel
to all the subplot, and set their interpreter to latex at the same time.
The same reasonning can be applied for the ylabel
, or any other common property accross many objects.