[ncl-talk] Forcing white in the middle of a symmetric colorbar

Anne SEIDENGLANZ anne.seidenglanz at unive.it
Fri Jan 11 04:36:20 MST 2019


Hello,

I am trying to combine the possibilities in NCL to 

1) use the a symmetric colorbar using the gsnSpreadColorStart / End resources (and res at cnLevelSelectionMode = “ManualLevels”)

and

2) forcing white for 1-2 contours in the middle for things like anomaly fields. 

Since I need a very fine scale, and therefore a lot of contours, setting them explicitely using res at cnExplicitLevels is not very feasible for me, and I’m trying to avoid to set these levels each single time.

So my question is:  Is there a way to use gsnSpreadColorStart and gsnSpreadColorEnd so as to have a symmetric color bar  AND  having 1-2 contours of white in the middle?
I know there are some white-in-the-middle pre-defined color maps in NCL but some of them don’t have a fine enough color scale. 

Here’s an example of I have been trying to attempt:

 res at cnLevelSelectionMode      = "ManualLevels"
 res at cnMinLevelValF         =  -5
 res at cnMaxLevelValF         =  5
 res at cnLevelSpacingF        =  0.25

 res at gsnSpreadColors   =  True
 res at gsnSpreadColorStart   =  2
 res at gsnSpreadColorEnd     =  255

 res at cnLevelSelectionMode    := "ExplicitLevels"
 res at cnLevels                =  fspan(-5, 5, 0.25)
 res at cnFillColors(20:22)        =  1


so I tried to overwrite the SelectionMode resource to ‘Explicit’  and then picking trying to pick only the center conoturs for white.. but obviously it didn’t work in this way. 

I remember there is some function that does exactly take care of this but I do not remember which one it was.


Any help is appreciated!
Thanks,
Anne




> On 3 Jan 2019, at 18:55, Adam Phillips <asphilli at ucar.edu> wrote:
> 
> Hi David,
> There's a function (add_map_tickmarks2) that you can use embedded in some of the NCL examples that will add tick mark labels to rectangular projections. I took mptick example #9 here: http://www.ncl.ucar.edu/Applications/mptick.shtml#ex9 <http://www.ncl.ucar.edu/Applications/mptick.shtml#ex9>
> and modified it to (mostly) match your projection. The script can be run on its' own and runs quickly, making trial and error less painful. I have attached the modified script and the resulting graphic. 
> Hope that helps!
> Adam
> 
> On Wed, Jan 2, 2019 at 3:08 PM David Hebert, Code 7322 <david.hebert at nrlssc.navy.mil <mailto:david.hebert at nrlssc.navy.mil>> wrote:
> I am attempting to make a regional plot using stereographic projection, and limit the projection using ‘corners’. I am getting only  longitude labels along the bottom and left plot boundary. See attached plot.
> 
>  
> 
> The relevant settings I am using in my script are:
> 
>  
> 
>   res at mpProjection          = "Stereographic"
> 
>   res at gsnAddCyclic          = False
> 
>   res at mpGridAndLimbOn       = True              ; turn on lat/lon lines
> 
>   res at mpPerimOn             = False             ; turn off box around plot
> 
>   res at pmTickMarkDisplayMode = "Always"      ; turn on ticks
> 
>  
> 
>   res at tmYROn = False
> 
>   res at tmXTOn = False
> 
>  
> 
>   res at mpGridLonSpacingF = 15.
> 
>   res at mpGridLatSpacingF = 2.
> 
>  
> 
>   ; set map limits based on tlat,tlon
> 
>     res at mpLimitMode        = "Corners"
> 
>     res at mpLeftCornerLatF   = tlat(0,0)
> 
>     res at mpLeftCornerLonF   = tlon(0,0)
> 
>     res at mpRightCornerLatF  = tlat(nj2-1,ni2-1)
> 
>     res at mpRightCornerLonF  = tlon(nj2-1,ni2-1)
> 
>     res at mpRelativeCenterLon         = True      ; set a center lon
> 
>     res at mpCenterLonF                = 180.0
> 
>     res at mpRelativeCenterLat         = True       ; set a center lat
> 
>     res at mpCenterLatF                = -90.0           ; center lat
> 
>  
> 
> Any suggestions on how to get the latitude labels on the left axis? Thank you for your help!
> 
>  
> 
>  
> 
> David A. Hebert
> 
> Oceanography Division, Code 7322 
> Naval Research Laboratory 
> Stennis Space Center, MS 39529
> (228)688-5846; DSN 828-5846 
> http://www.nrl.navy.mil <http://www.nrl.navy.mil/>
>  
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
> 
> 
> -- 
> Adam Phillips 
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/ <http://www.cgd.ucar.edu/staff/asphilli/>   303-497-1726
> 
>  <http://www.cgd.ucar.edu/staff/asphilli><tickmarks.ncl><mptick.png>_______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk


-- 
Nota automatica aggiunta dal sistema di posta.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190111/abd90cc9/attachment.html>


More information about the ncl-talk mailing list