[ncl-talk] uneven colorbar

Mary Haley haley at ucar.edu
Wed Nov 12 08:39:16 MST 2014


This is a good suggestion, to use named colors.

For the record, we recommend using "cnFillPalette" in place of
"gsn_define_colormap". This allows you to associated the colors directly
with the contours (and hence enables you have other contour plots with
their own colormaps).

Here's an example that you should be able to run as-is:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin
  a = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r")
  u = a->U(1,:,:)                       ; read July zonal winds

  wks = gsn_open_wks("x11","ce")

  res = True
  res at cnFillPalette = (/"white","black","Snow"     \
               ,"PaleTurquoise","PaleGreen","SeaGreen3" ,"Yellow"  \
               ,"Orange","HotPink","Red","Violet", "Purple", "Brown",
"Black"/)

  res at cnFillOn             = True
  res at cnLevelSelectionMode = "ExplicitLevels"
  res at cnLevels             = (/-12,-8,-4,0,4,6,8,10,15,20,25,30,40/)

  plot = gsn_csm_contour_map(wks,u,res)

end



On Wed, Nov 12, 2014 at 8:30 AM, Dennis Shea <shea at ucar.edu> wrote:

> Also:
>
>        wks    = gsn_open_wks(...)
>        colors = (/"white","black","Snow"     \
>                ,"PaleTurquoise","PaleGreen","SeaGreen3" ,"Yellow"  \
>                ,"Orange","HotPink","Red","Violet", "Purple", "Brown", "Black"/)
>        gsn_define_colormap(wks, colors)               ; generate new color map
>
>
>        res at cnLevelSelectionMode = "ExplicitLevels"
>        res at cnLevels             = (/0.1,1,5,10,20,30,50,75,100,150/) ; "mm/day"
>
>
>
>
> On Wed, Nov 12, 2014 at 8:10 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> You can set:
>>
>> res at cnLevelSelectionMode = "ExplicitLevels"
>> res at cnLevels = (/-10,-8,-6,-4,-2,0,2,4/)
>>
>> "cnLevels" can be any spacing of values that you want. They don't have to
>> be equally spaced, but they do have to be increasing.
>>
>> If you need to match certain levels to certain colors in a color map,
>> then you may want to see example "conLev_4.ncl" at:
>>
>> http://www.ncl.ucar.edu/Applications/contourLev.shtml
>>
>> --Mary
>>
>>
>> On Mon, Nov 10, 2014 at 8:03 AM, Xi Chang <xi.chang01 at gmail.com> wrote:
>>
>>> Hallo, Is there any way to create uneven color bar? for instence my
>>> plotting values ranging from -10 to +4, and I want to always plot 0 values
>>> as white. Thank you.
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141112/d38b7b0b/attachment.html 


More information about the ncl-talk mailing list