Idea 1: put all shared name-value properties into a cell array
For sets of name-value pairs that will be assigned to several objects, you can group them into 1 variable and assign them like this.
extraInputs = {'interpreter','latex','fontsize',14};
xlabel('$k$',extraInputs{:})
ylabel('$h_1$',extraInputs{:})
legend({'closed loop','setpoint'},extraInputs{:})
Idea 2: set the axis properties when possible
Axes do not have an interpreter property but you could avoid assigning font size (and other properties) to each axis label and legend by assigning those properties to the axes.
set(gca,'fontsize',14)
xlabel('$k$','interpreter','latex')
ylabel('$h_1$','interpreter','latex')
legend({'closed loop','setpoint'},'interpreter','latex')
Idea 3: create a local function designed to produce formatted axes and labels
Lastly, if you're creating a bunch of subplots that all have the same set of properties, create a local function that creates subplots and assigns the formatted axis labels.
figure('DefaultAxesFontSize',14)
clf
ax = newsubplot(221,'k','h_1');
plot(1:5,'LineWidth',2)
line([0,1], [1,2],'color','red','linestyle','--','LineWidth',2)
legend({'closed loop','setpoint'},'interpreter','latex')
function ax = newsubplot(position, xlab, ylab)
ax = subplot(position);
hold on
set(ax,'FontSize',14)
xlabel(['$',xlab,'$'],'interpreter','latex')
ylabel(['$',ylab,'$'],'interpreter','latex')
grid on
end
Best Answer
This is a complete title() object that gets set.
Each time you create a new axes, it will set the axes Title object to the object that was created. This will set the Parent of the Title object to be the appropriate axes, which will stop it from displaying where it was and start displaying it in the new axes. Any change in the new axes (such as to the string) will affect the properties for all of the other axes it is set to, because all of those axes will have handles to the same Title object. delete() of any one of the references will delete it for all of the references.
You will probably find this highly unsatisfactory... but you asked ;-)
There does not appear to be any way to set just the Interpreter property by the groot/default mechanism. This is unfortunate.