下面的代码片段仅将大字体大小应用于底部图,而不是顶部图。
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')
我怎样才能为顶部情节做到这一点,最好是尽可能少的额外步骤?
答案 0 :(得分:2)
你有几个选择。由于函数gca
总是返回具有当前焦点的轴的句柄,因此最简单的解决方案就是在完成每个绘图后重复命令:
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
或者,如果您希望所有轴在默认情况下始终具有该字体大小,则可以在set the default size上root object之前使用{{3}},然后再运行上述任何代码:
set(0, 'DefaultAxesFontSize', 20);
您的轴将自动具有该字体大小。
答案 1 :(得分:1)
你有几个选择。您可以在创建第二个轴之前重复调用,即
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)
或者,你可以存储subplot
(轴句柄)的返回值并设置它们的属性,即
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);
我个人赞成后一种解决方案,因为如果更改子图的数量,代码不会改变。