[ncl-talk] Make zero white in colour bar

Michael Weston mjweston at masdar.ac.ae
Wed Aug 2 05:51:13 MDT 2017


Dear NCL users,

This question has been asked many times. However, I wonder if a more 
elegant solution has been found in the mean time.
E.g subjects in this group, but these do not answer my question

Making zero value white in contour plot (Jake Huff)
Re: Making zero value white in contour plot (Mary Haley)
Re: Making zero value white in contour plot (Dennis Shea)

I have also tried:
Getting the colour index (/get_color_index/), setting the colour index 
to another colour using /NhlSetColor//
/
I have tried these links
"How to coincide zero with the white color of the colo bar with uneven 
numbering"
http://mailman.ucar.edu/pipermail/ncl-talk/2014-November/001361.html
This involves indexing a 256 color palette to the colours you want in 
your 16 level map/color bar.

combined with

http://www.ncl.ucar.edu/Document/Functions/Built-in/get_color_index.shtml

However, none have really hit the nail on the head despite my efforts. 
And I imagine this must be much simpler than indexing a 256 color scheme.

What I want:
1. I want to make a map using filled contours, but I want zero to be 
represented by white.
     I can achieve this by making all zero values missing values.
2. I want to have a color bar next to my map, with zero represented by 
white.
     I can not achieve this.

My map is attached.
As you can see it is beautiful, except, I would like to get rid of the 
delightful purple and dark blue in the color bar. (i.e. first two classes.)

Is this possible?

Thanks and regards
Michael


general overview of code below

     sfile = addfile(srcFileName,"r")
     TMP       = sfile->var_index
     TMP = where(TMP.ne.0,TMP,TMP at _FillValue) ;MAKE ZERO MISSING

     res at cnFillOn          = True
     res at cnFillMode       = "RasterFill"       ; Raster Mode
     res at cnConstFEnableFill = True
     res at cnLinesOn         = False
     res at cnLineLabelsOn    = False

     res at cnLevelSelectionMode = "ExplicitLevels"
     res at cnLevels             = fspan(0,1,10)
     cmap = read_colormap_file("BlueYellowRed")
     res at lbLabelBarOn          = True
     res at lbLabelStrings        = 
(/"0","0.1","0.2","0.3","0.4","0.5","0.6","0.7","0.8","0.9","1"/)
     res at lbOrientation         = "Vertical"
     wks = gsn_open_wks("png","ncl_map")
     plot = gsn_csm_contour_map(wks,TMP,res)
     draw(plot)
     frame(wks)
     delete(wks)

-- 

*Michael****Weston**
*Research Engineer


*A Part of Khalifa University of Science and Technology*

PO Box 54224, Abu Dhabi,
United Arab Emirates
Office   +971 2 810 9510

Email mjweston at masdar.ac.ae <mailto:mjweston at masdar.ac.ae>
http://www.masdar.ac.ae <http://www.masdar.ac.ae/>
**
/Please consider the environment before printing this email//
/
This transmission is confidential and intended solely for the person or 
organization to whom it is addressed. It may contain privileged and 
confidential information. If you are not the intended recipient, you 
should not copy, distribute or take any action in reliance on it. If you 
have received this transmission in error, please notify us immediately 
by e-mail at *info at masdar.ae**.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170802/8e287df8/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: masdarlogo.jpg
Type: image/jpeg
Size: 5411 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170802/8e287df8/attachment.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ncl_map.png
Type: image/png
Size: 82537 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170802/8e287df8/attachment.png 


More information about the ncl-talk mailing list