Re: Assigning specific color to contour level

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Fri Sep 23 2011 - 11:20:53 MDT

Hi Nisha,
The short answer is no, a function that colors the contour lines in a
similar fashion to what gsnSpreadColors does for color shading does not
exist. The closest one is ColorNegDashZeroPosContour, but that colors
all the negative contours the same color.

That being said, the following should work: (untested)

res@cnLevelSelectionMode = "ExplicitLevels"
res@cnLevels = ispan(-5,5,11) ; set contour levels

nlev = dimsizes(res@cnLevels) ; retrieve # of contour levels
colors = gsn_retrieve_colormap(wks) ; retrieve colormap
tt = dimsizes(colors)
ncolors = tt(0) ; # of colors in colormap
res@cnMonoLineColor = False ; allow contours to have different colors
res@cnLineColors = floattoint(fspan(2,ncolors+1,nlev))
if (res@cnLevels(nlev/2).eq.0) then
    res@cnLineColors(nlev/2) = 0 ; set middle contour to 0th
end if ; color index (usually white)

Note that that above approach assumes that your colormap has an even
number of positive / negative colors, and that your contours are evenly
split between positive/negative contours.

Regardless, you should be able to modify the above for your specific
needs... Hope that helps!

On 09/23/2011 10:50 AM, Manisha Ganeshan wrote:
> Hi,
> I am using the "GreenYellow" color table for plotting a field on a map
> with contours ranging from negative to positive values.
> I wish to have the greens represent negative values, and the yellows
> represent positive values. Is there a quick and easy way to assign a
> specific color from the color table to correspond to a contour value
> (eg. white color to represent 0)?
> I need to plot several maps, so if there is a function that can help me
> do this quickly, it would be great!
> Nisha
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:

Adam Phillips                      
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Fri Sep 23 11:20:58 2011

This archive was generated by hypermail 2.1.8 : Mon Sep 26 2011 - 14:45:50 MDT