[ncl-talk] White for zero in a map
Mary Haley
haley at ucar.edu
Tue Mar 3 14:29:45 MST 2015
There are many ways you can do this.
I've attached a script that does this by using the cnFillColors resource to
specify a list of color indexes into the "rainbow" color map, but then I
changed the color index that represents level 0.0 to be 0 (the background
color, and therefore white).
--Mary
On Sun, Mar 1, 2015 at 3:01 PM, Jiang, Lifen <lfjiang at ou.edu> wrote:
> Hello,
>
> I was trying to create a map of the attached variable. The min and and
> max are -14 and 18, respectively.
>
> I would like to set white for zero, but could not work out how to make
> it. Script is at the end of this email.
>
> Could anybody help with my issue?
>
> I appreciate your time and help!
>
> Thanks,
>
> Lifen
>
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> in = addfile("Diff.nc","r")
> t = in->Diff
> t at _FillValue = -999
> t at missing_value = t at _FillValue
>
> printVarSummary(t)
>
> wks = gsn_open_wks("png" ,"Plot_Diff") ;
> gsn_define_colormap(wks,"rainbow") ; choose colormap
>
> res = True ; plot mods desired
>
> res at cnFillOn = True ; turn on color fill
> res at cnLinesOn = False ; turn off contour lines
> res at cnLevelSpacingF = 3 ; contour spacing
>
> ;---This resource not needed in NCL V6.1.0
> res at gsnSpreadColors = True ; use full range of color map
>
> res at lbLabelStride = 1
>
> res at pmTickMarkDisplayMode = "Always"; use NCL default lat/lon labels
>
> res at gsnAddCyclic = False ; data already has cyclic point
> ; this must also be set for any zoom
>
> ; note that the gsn_csm_*map_ce templates automatically set
> ; res at mpLimitMode="LatLon" for you. If you are plotting a different
> projection,
> ; you may have to set this resource.
>
> res at mpMinLatF = -90 ; range to zoom in on
> res at mpMaxLatF = 90
> res at mpMinLonF = -180
> res at mpMaxLonF = 180
>
> res at cnLevelSelectionMode = "ManualLevels"
> res at cnMinLevelValF = -15
> res at cnMaxLevelValF = 20
>
> plot = gsn_csm_contour_map_ce(wks,t({-90:90},{-180:180}), res)
>
> end
>
> _______________________________________________
> 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/20150303/b7328214/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff.ncl
Type: application/octet-stream
Size: 1219 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150303/b7328214/attachment.obj
More information about the ncl-talk
mailing list