How to change the NaN color

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.

2 Comments

Using m_map you can set the background color property using m_grid()
m_grid('BackgroundColor', [0.7 0.7 0.7]);
Comment posted as flag by Ce Bian:
perfect suggestion!

Sign in to comment.

 Accepted Answer

Walter Roberson
Walter Roberson on 16 Apr 2016
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.

2 Comments

axin = gca;
P = axin.Position;
Px = [P(1), P(1)+P(3), P(1)+P(3), P(1), P(1)];
Py = [P(2), P(2), P(2)+P(4), P(2)+P(4), P(2)];
hold(axin, 'on');
Pp = fill(Px, Py, [.7 .7 .7]);
uistack(Pp, 'bottom');
hold(axin, 'off')

Sign in to comment.

More Answers (0)

Categories

Asked:

on 16 Apr 2016

Commented:

Rik
on 11 Apr 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!