Reputation: 891
The code snippet below applies the large font size only to the bottom plot, not the top plot.
subplot(2,1,1)
pcolor(lon(Lon2Use),-dep,v(Lon2Use,:)'); shading('flat'); colorbar
subplot(2,1,2)
pcolor(lon(Lon2Use),-dep,PressureGeo(Lon2Use,:)'); shading('flat'); colorbar
set(gca,'FontSize',20)
title('v along constant latitude line')
xlabel('longitude')
ylabel('depth')
How can I do it for the top plot too, preferably with as few extra steps as possible?
Upvotes: 1
Views: 2889
Reputation: 125854
You have a couple options. Since the function gca
always returns the handle of the axis that has the current focus, the easiest solution is simply to repeat the command after making each plot:
subplot(2,1,1)
pcolor(lon(Lon2Use),-dep,v(Lon2Use,:)');shading('flat');colorbar
set(gca,'FontSize',20) %<----First axis has focus at this point
subplot(2,1,2)
pcolor(lon(Lon2Use),-dep,PressureGeo(Lon2Use,:)');shading('flat');colorbar
set(gca,'FontSize',20) %<----Second axis has focus at this point
Alternatively, if you want all your axes to always have that font size by default, you can set the default size on the root object like so before running any of the above code:
set(0, 'DefaultAxesFontSize', 20);
And your axes will automatically have that font size.
Upvotes: 2
Reputation: 4551
You have a couple of options here. You could either just repeat the call before you create the second axes, i.e.,
subplot(2,1,1)
pcolor(lon(Lon2Use),-dep,v(Lon2Use,:)');shading('flat');colorbar
set(gca,'FontSize',20)
subplot(2,1,2)
pcolor(lon(Lon2Use),-dep,PressureGeo(Lon2Use,:)');shading('flat');colorbar
set(gca,'FontSize',20)
OR, you could store the return values from subplot
(axes handles) and set the properties of these, i.e.,
ax = [];
ax = [ax; subplot(2,1,1)];
pcolor(lon(Lon2Use),-dep,v(Lon2Use,:)');shading('flat');colorbar
ax = [ax; subplot(2,1,2)];
pcolor(lon(Lon2Use),-dep,PressureGeo(Lon2Use,:)');shading('flat');colorbar
set(ax,'FontSize',20);
I personally favour the latter solution, because the code doesn't change if you change the number of subplots.
Upvotes: 1