[ncl-talk] Make zero white in colour bar
Barry Lynn
barry.h.lynn at gmail.com
Wed Aug 2 07:02:49 MDT 2017
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","HotPink3","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 <(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/94167d05/attachment.html
-------------- 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/94167d05/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/94167d05/attachment-0001.jpe
-------------- 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/94167d05/attachment.jpg
More information about the ncl-talk
mailing list