[ncl-talk] Make zero white in colour bar

Barry Lynn barry.h.lynn at gmail.com
Wed Aug 2 07:32:38 MDT 2017


Hi:

You need to define things, so I guess you're/we're stuck.

I am not sure about the "Span" index line -- someone else will have to
answer.

Barry

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

> Hi Barry
>
> Thanks for this. Yes, while is does achieve white in the first block (see
> attached), I was actually trying to avoid defining each colour of each
> block individually.
>
> If I adapt this approach, I could use  *get_color_index  *and loop
> through my levels. Get the named colour of each level. And then recreate
>
> icol = get_color_index(cmap,levels,0)
>
> res1 at cnFillColors         = (/"White", cmap[icol_1],cmap[icol_2],etc,
> ...,cmap[icol_10]/)
>
> I was hoping to there was a cleaner approach something like:
>
> res at cnFillColors = (/"White",*span_color_indexes*("BlueYellowRed",10)[1:9]/)
> ; I know syntax is not ncl correct here but hope you get my drift
>
> Is this possible?
>
> Mike
>
>
>
> On 02/08/2017 17:03, Barry Lynn wrote:
>
> You can remove one interval and one "whilte."
>
> On Wed, Aug 2, 2017 at 4:02 PM, Barry Lynn <barry.h.lynn at gmail.com> wrote:
>
>> Hi:
>>
>> You need to set your classes.
>>
>>     res1 at cnLevelSelectionMode = "ExplicitLevels"    ; set explicit
>> contour levels
>>
>>   res1 at cnLevels             = (/ 000, 1,5, 10., 15., \
>>
>>                                      20, 30,40,50,75,100/)
>>
>>     res1 at cnFillColors         = (/"White","White","AntiqueWhite","AntiqueWhite3",
>> \
>>
>>                                     "chartreuse", \
>>
>>                                     "chartreuse3","ForestGreen", \
>>
>>                                     "Yellow","Orange","Red","HotPi
>> nk3","HotPink1","HotPink","Violet"/)
>>
>> On Wed, Aug 2, 2017 at 3:59 PM, Michael Weston <mjweston at masdar.ac.ae>
>> wrote:
>>
>>> Hi Barry
>>>
>>> So I can define the classes manually as below (although this is a
>>> tradeoff):
>>>
>>>     res at cnLevelSelectionMode = "ManualLevels"
>>>     res at cnMinLevelValF   =  0.1               ; set min contour level
>>>     res at cnMaxLevelValF   =  1               ; set max contour level
>>>     res at cnLevelSpacingF  =  0.1               ; set contour spacing
>>>
>>>     res at lbLabelStrings        = (/"0.1","0.2","0.3","0.4","0.5
>>> ","0.6","0.7","0.8","0.9","1"/)
>>> But it still creates a purple box in the color bar.
>>> Is this what you had in mind?
>>>
>>> Thanks
>>> Mike
>>>
>>>
>>> On 02/08/2017 16:41, Barry Lynn wrote:
>>>
>>> Hi:
>>>
>>> The easiest thing to do is just define your color bar manually, and your
>>> intervals not to include 0.  You then set the leftward most color to white.
>>>
>>> I am not sure if there is an easier way.
>>>
>>> Do you need help with this?
>>>
>>> Barry
>>>
>>> On Wed, Aug 2, 2017 at 3:31 PM, Michael Weston <mjweston at masdar.ac.ae>
>>> wrote:
>>>
>>>> Hi
>>>> No not really. What line in the code is causing it to be included?
>>>> My understanding from both these lines is that it starts at zero.
>>>>
>>>> res at cnLevels             = fspan(0,1,10)
>>>> ...
>>>> res at lbLabelStrings        = (/"0","0.1","0.2","0.3","0.4",
>>>> "0.5","0.6","0.7","0.8","0.9","1"/)
>>>>
>>>> Mike
>>>>
>>>>
>>>> On 02/08/2017 16:21, Barry Lynn wrote:
>>>>
>>>> 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_colo
>>>>> r_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 <%28914%29%20432-3108>
>>>>
>>>>
>>>> --
>>>>
>>>> *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>**.*
>>>>
>>>
>>>
>>>
>>> --
>>> 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 <%28914%29%20432-3108>
>>>
>>>
>>> --
>>>
>>> *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>**.*
>>>
>>
>>
>>
>> --
>> 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 <%28914%29%20432-3108>
>>
>
>
>
> --
> 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 <(914)%20432-3108>
>
>
> --
>
> *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>**.*
>



-- 
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/8d60adff/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/8d60adff/attachment.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 5411 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170802/8d60adff/attachment.jpe 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 5411 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170802/8d60adff/attachment-0001.jpe 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 5411 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170802/8d60adff/attachment-0002.jpe 


More information about the ncl-talk mailing list