MATLAB: Different colormaps for subplots

subplot colormap bluewhitered pcolor

I am having a frustrating problem that I think is related to how I am using handles to format the colormaps in my plots. I am trying to plot the first two subplots with the bluewhitered colormap to emphasize the positive versus negative values. But I want the third subplot (temperature) to use the jet colormap. When I run the full script for my figure I get jet coloring for all three. But if I only run the first subplots I get the coloring I want. Is there something in my code for the third subplot that is changing the first two? Please see figures for clarification. Thank you so much!
Here's my code:
f1=figure(1)
%PK alongshore
ax(1) = subplot(3,1,1)
hold on
pcolor(PK1.time,PK1.zbin,PK1.pE'); %Plot velocity
pcolor(PK2.time,PK2.zbin,PK2.pE');
plot(PK1.time,PK1.depth,'k'); %Plot depth
plot(PK2.time,PK2.depth,'k');
shading('flat'); caxis([-0.05 0.05]);
a=colorbar; colormap(bluewhitered);
set(a, 'Position', [0.93 .72 .015 .2])
set(get(a,'label'),'string','Alongshore','fontsize',14);
%legend('Current Alongshore (m/s)','Depth (m)');
%legend('Alongshore Velocity (m/s)')
set(gca,'fontsize',16)
ylabel('Depth (m)');
ylim([0 11]);
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
%PK cross-shore
ax(2) = subplot(3,1,2)
hold on
pcolor(PK1.time,PK1.zbin,PK1.pN'); %Plot velocity
pcolor(PK2.time,PK2.zbin,PK2.pN');
plot(PK1.time,PK1.depth,'k'); %Plot depth
plot(PK2.time,PK2.depth,'k');
shading('flat'); caxis([-0.05 0.05]);
b=colorbar; colormap(bluewhitered);
set(b, 'Position', [0.93 .42 .015 .2])
set(get(b,'label'),'string','Cross-shore','fontsize',14);
set(gca,'fontsize',16)
ylabel('Depth (m)');
ylim([0 11]);
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
%PK Temperature
ax(3) = subplot(3,1,3)
h=plot(MX,PK.PRESS(9,:),'k')
hold on
pcolor(MX,PK.mab,PK.TEMP); %Plot temperature
shading('interp');
ylabel('Depth (mab)');
c=colorbar; colormap(jet);
set(c, 'Position', [0.93 .11 .015 .2])
caxis([9 19.2]);
title(c,'\circC','fontsize',18);
set(gca,'fontsize',16);
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks');
linkaxes(ax,'x')

Best Answer

Hi,
please try
colormap(ax(1),bluewhitered)
colormap(ax(2),spring)
colormap(ax(3),jet)