Hi Dave,
There is not an automatic way to set the colormap such that the
transition from blue->red occurs around the zero line for asymetric
colorbars in ncl. There are three different ways you can do it, by
setting cnLevelSelectionMode = "ManualLevels", by setting
cnLevelSelectionMode = "ExplicitLevels", or by using gsnSpreadColors and
gsnSpreadColorStart and gsnSpreadColorEnd. The latter option requires
some trial and error, but shouldn't take you long... I have attached a
script along with the resulting .gif image that shows all three ways to
do it..
Good luck,
Adam
David B.Reusch wrote:
> I would like to be able to use asymmetric colorbars but still have the
> zero point anchored to the switch between, for example, blue and red in
> the BlueRed colormap. I am contouring (filled) data that has both
> positive and negative values (e.g., anomalies or zonal wind speeds) and
> am trying to get positives in one color (red) and negatives in the
> other (blue) but this does not always work when using an asymmetric
> contours range. Sometimes the zero value is two or more levels into
> the blue (or red). Symmetric values work (i.e., the blue/red
> transition is reliably anchored to zero) but this often results in one
> side of zero having an awkward number of contours (e.g., the data are
> in the range -5 to +30, so a symmetric range would be +/-30, which does
> a bad job for the negative values).
>
> I've looked at the online info about cnLevels, cnFillColors and
> colormaps and could *probably* come up with code (eventually) to do
> this for specific cases, but was hoping someone could provide a generic
> approach.
>
> I've attached an example figure that shows the problem I'd like to
> resolve. I can also provide data/code as needed for testing.
>
> thanks,
> dave
> dbr@geosc.psu.edu
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk@ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-- -------------------------------------------------------------- Adam Phillips asphilli@ucar.edu National Center for Atmospheric Research tel: (303) 497-1726 ESSL/CGD/CAS fax: (303) 497-1333 P.O. Box 3000 Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
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 a = addfile("slp.mon.mean.73x144.nc","r") slp = a->slp slp = rmMonAnnCycTLL(slp) finarr = slp(0,:,:) ;======================================================================== wks = gsn_open_wks("ps","example") gsn_define_colormap(wks,"BlueRed") res = True res@gsnDraw = False res@gsnFrame = False res@cnFillOn = True res@cnLinesOn = False res@cnMonoFillColor = False map = new(4,graphic) res@cnLevelSelectionMode = "ManualLevels" res@cnMinLevelValF = -3. res@cnMaxLevelValF = 7. res@cnLevelSpacingF = 1. res@cnFillColors = (/92,102,112,122,132,142,152,162,172,182,192,202/) res@gsnCenterString = "Manual" map(0) = gsn_csm_contour_map_ce(wks,finarr,res) res@cnLevelSelectionMode = "ExplicitLevels" res@cnLevels = (/-3,-2,-1,-.5,0,.5,1,2,3,4,5/) res@cnFillColors = (/82,92,102,112,122,132,142,152,162,172,182,192/) res@gsnCenterString = "Explicit" map(1) = gsn_csm_contour_map_ce(wks,finarr,res) res@gsnSpreadColors=True res@gsnSpreadColorStart = 85 res@gsnSpreadColorEnd = 192 res@gsnCenterString = "SpreadColors #1" map(2) = gsn_csm_contour_map_ce(wks,finarr,res) res@gsnSpreadColorStart = 61 res@gsnSpreadColorEnd = 232 res@gsnCenterString = "SpreadColors #2" map(3) = gsn_csm_contour_map_ce(wks,finarr,res)
yres = True yres@gsnMaximize = True yres@gsnPaperOrientation = "portrait" gsn_panel(wks,map,(/2,2/),yres) end
_______________________________________________ ncl-talk mailing list ncl-talk@ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2b29 : Thu Nov 03 2005 - 11:45:53 MST