MATLAB: How to change the NaN color

colornanpcolor

I used a m_map tool
%%%%%%%
figure(1)
set(gcf,'color','w');
m_proj('UTM','lon',[128.3239 128.85],'lat',[34.0496 34.2721]);
hold on;
m_pcolor(lon,lat,TSS); shading flat;
caxis([0 5]);
hc = colorbar('v','YTick',[0 : 5], 'box', 'on');
Pos = get(hc, 'position'); Pos(1) = 0.915; Pos(3) = 0.02; % colorer position [left bottom width height]
set(hc,'position',Pos);
m_grid('box', 'fancy', 'linewidth', 1, 'tickdir', 'in', 'fontsize', 30, 'fontname', 'Arial', 'fontweight', 'bold', 'linestyle', 'none');
xlabel('Longitude', 'fontsize' ,30); ylabel('Latitude', 'fontsize', 30);
%%%%%%
In here, currently, NaN is white but I want to change from white to gray [.7 .7 .7].
I will be looking forward your reply.
Thank you.

Best Answer

NaN has no color: whatever color is underneath is shown. You could set the axes color to that gray. Another way would be to put a solid-gray image or rectangle or patch "under" what you want to display, so that when NaN allows the color beneath to be seen, it will see the color of that area.