[ncl-talk] Make zero white in colour bar

Barry Lynn barry.h.lynn at gmail.com
Wed Aug 2 06:21:35 MDT 2017


Hi:

Do you really want to include the < 0 part of your color bar?

On Wed, Aug 2, 2017 at 2:51 PM, Michael Weston <mjweston at masdar.ac.ae>
wrote:

> 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 <+971%202%20810%209510>
>
> Email   mjweston at 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 <info at masdar.ae>**.*
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Barry H. Lynn, Ph.D
Senior Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
US 914 432 3108
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170802/2fd6d660/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/2fd6d660/attachment.jpg 


More information about the ncl-talk mailing list