How to change the NaN color
40 views (last 30 days)
Show older comments
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
Eric Muhlbach
on 2 Nov 2020
Using m_map you can set the background color property using m_grid()
m_grid('BackgroundColor', [0.7 0.7 0.7]);
Accepted Answer
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
Walter Roberson
on 3 Nov 2020
Edited: Walter Roberson
on 8 Apr 2022
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')
More Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!