<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Adam,<div><br></div><div>thanks for taking the time to respond to me, and thanks for your suggestion! In fact I've found a work-around in the meantime that seems to work quite efficient with what I wanted to achieve, and that is also similar to your suggestion:</div><div><br></div><div>1) I work out my value range and associated number of contour intervals, depending on how fine I want my contours, using <i>fspan</i>:</div><div>  ->  e.g.    res@cnLevels               =  fspan(-7, 7, 56) ,     in this case I decided for a contour spacing of 0.25</div><div><br></div><div>2) I use 'span_color_indexes'  and decide on a color palette to retrieve the desired amount of colours. Here I need to add 2 to the number in contour levels above:</div><div>   -> icol = span_color_indexes("BlWhRe", 58)         so I have 58 color indexes here (56 contour levels)<br></div><div><br></div><div>3) I insert as many white intervals as I want around the center of my color range determined by 'icol', here in this example I chose 4 white intervals that appear in the middle of the color bar:</div><div>  ->          icol(27:30)          =  -1</div><div><br></div><div>In this way I achieved more or less what I wanted, the only problem I encountered was that there seemed to be no control over the labal bar labels anymore, in some plots they appeared rather random, or at least with a lot of decimal places..</div><div><br></div><div>I attach one example of a 2m-temperature plot.</div><div><br></div><div>cheers</div><div>Anne</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Jan 12, 2019 at 1:06 AM Adam Phillips <<a href="mailto:asphilli@ucar.edu" target="_blank">asphilli@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">HI Anne,<div>If you want a symmetric colorbar with white in the middle, you want to use (the default) gsnSpreadColors, you do not want to always set cnLevels, and you do not want to specify what colors you use by setting cnFillColors (for every color), then I think the best thing to do would be to use getvalues to retrieve the colors after the plot has been created, modify them, and then use setvalues to set them. The following should get you started. Note that the label bar has to be created after gsn_csm_contour_map is called as you are modifying the colors after the plot is drawn.</div><div><br></div><div>If you have any further questions let ncl-talk know.</div><div>Adam</div><div><br></div><div><div>begin</div><div>;************************************************</div><div>; read in netCDF file</div><div>;************************************************</div><div>  a = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/<a href="http://uv300.nc" target="_blank">uv300.nc</a>","r")</div><div>  u = a->U(1,:,:)                                ; read July zonal winds</div><div>;************************************************</div><div>; create plot</div><div>;************************************************</div><div>  wks = gsn_open_wks("png","color")             ; send graphics to PNG file</div><div>  gsn_define_colormap(wks,"ncl_default")</div><div>  cmap = read_colormap_file("ncl_default")</div><div><br></div><div>  res                      = True               ; plot mods desired</div><div>  res@tiMainString         = "Default Color"    ; main title</div><div>  res@cnFillOn             = True               ; turn on color fill</div><div>  res@gsnDraw = False</div><div>  res@gsnFrame = False</div><div>  res@lbLabelBarOn = False   </div><div><br></div><div>  plot = gsn_csm_contour_map(wks,u, res)     ; create plot</div><div><br></div><div>  getvalues plot@contour    ; retrieve colors/levels from plot</div><div>    "cnFillColors" : colors</div><div>    "cnLevels"     : levels</div><div>  end getvalues</div><div><br></div><div>  ncolors = dimsizes(colors)</div><div>  colors(ncolors/2-1) = 0    ; set two middle colors to white</div><div>  colors(ncolors/2) = 0       ; if you have odd number of colors this should be modified</div><div><br></div><div>  print(colors)</div><div><br></div><div>  setvalues plot@contour</div><div>     "cnFillColors" : colors       ; reset the colors</div><div>  end setvalues</div><div><br></div><div>  lbres                    = True</div><div>  lbres@vpWidthF           = 0.55</div><div>  lbres@vpHeightF          = 0.075</div><div><br></div><div>  lbres@lbPerimOn          = False            ; Turn off perimeter.</div><div>  lbres@lbOrientation      = "Horizontal"     ; Default is vertical.</div><div>  lbres@lbFillColors       = colors</div><div>  lbres@lbMonoFillPattern  = True             ; Fill them all solid.</div><div>  lbres@lbLabelFontHeightF = 0.020            ; Label font height</div><div>  lbres@lbLabelAlignment   = "InteriorEdges"</div><div>  lbid = gsn_create_labelbar(wks,dimsizes(levels),levels,lbres)       ; create the labelbar</div><div><br></div><div><br></div><div>  amres                  = True</div><div>  amres@amJust           = "BottomCenter"</div><div>  amres@amParallelPosF   =  0.0</div><div>  amres@amOrthogonalPosF = 0.75</div><div>  annoid = gsn_add_annotation(plot,lbid,amres)    ; attach the labelbar to the plot</div><div>  draw(plot)</div><div>  frame(wks)</div></div><div>end</div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 11, 2019 at 4:36 AM Anne SEIDENGLANZ <<a href="mailto:anne.seidenglanz@unive.it" target="_blank">anne.seidenglanz@unive.it</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>Hello,</div><div><br></div><div>I am trying to combine the possibilities in NCL to </div><div><br></div><div>1) use the a symmetric colorbar using the gsnSpreadColorStart / End resources (and res@cnLevelSelectionMode = “ManualLevels”)</div><div><br></div><div>and</div><div><br></div><div>2) forcing white for 1-2 contours in the middle for things like anomaly fields. </div><div><br></div><div>Since I need a very fine scale, and therefore a lot of contours, setting them explicitely using res@cnExplicitLevels is not very feasible for me, and I’m trying to avoid to set these levels each single time.</div><div><br></div><div>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?</div><div>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. </div><div><br></div><div>Here’s an example of I have been trying to attempt:</div><div><br></div><div><div> res@cnLevelSelectionMode      = "ManualLevels"</div><div> res@cnMinLevelValF         =  -5</div><div> res@cnMaxLevelValF         =  5</div><div> res@cnLevelSpacingF        =  0.25</div><div><br></div><div> res@gsnSpreadColors   =  True</div><div> res@gsnSpreadColorStart   =  2</div><div> res@gsnSpreadColorEnd     =  255</div><div><br></div><div> res@cnLevelSelectionMode    := "ExplicitLevels"</div><div> res@cnLevels                =  fspan(-5, 5, 0.25)</div><div> res@cnFillColors(20:22)        =  1</div></div><div><br></div><div><br></div><div>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. </div><div><br></div><div>I remember there is some function that does exactly take care of this but I do not remember which one it was.</div><div><br></div><div><br></div><div>Any help is appreciated!</div><div>Thanks,</div><div>Anne</div><div><br></div><div><br></div><div><br></div><br><div><blockquote type="cite"><div>On 3 Jan 2019, at 18:55, Adam Phillips <<a href="mailto:asphilli@ucar.edu" target="_blank">asphilli@ucar.edu</a>> wrote:</div><br class="gmail-m_-6490611580294256170gmail-m_-5302341073864890499gmail-m_-2314912229231948107gmail-m_2452906710536202663gmail-m_6980392933698291299Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr">Hi David,<div>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: <a href="http://www.ncl.ucar.edu/Applications/mptick.shtml#ex9" target="_blank">http://www.ncl.ucar.edu/Applications/mptick.shtml#ex9</a></div><div>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. </div><div>Hope that helps!</div><div>Adam</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 2, 2019 at 3:08 PM David Hebert, Code 7322 <<a href="mailto:david.hebert@nrlssc.navy.mil" target="_blank">david.hebert@nrlssc.navy.mil</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-6490611580294256170gmail-m_-5302341073864890499gmail-m_-2314912229231948107gmail-m_2452906710536202663gmail-m_6980392933698291299gmail-m_-4169463851194194246WordSection1"><p class="MsoNormal"><span style="font-family:"Courier New"">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. <u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">The relevant settings I am using in my script are:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@mpProjection          = "Stereographic"<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@gsnAddCyclic          = False<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@mpGridAndLimbOn       = True              ; turn on lat/lon lines<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@mpPerimOn             = False             ; turn off box around plot<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@pmTickMarkDisplayMode = "Always"      ; turn on ticks<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@tmYROn = False<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@tmXTOn = False<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@mpGridLonSpacingF = 15.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  res@mpGridLatSpacingF = 2.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">  ; set map limits based on tlat,tlon<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpLimitMode        = "Corners"<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpLeftCornerLatF   = tlat(0,0)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpLeftCornerLonF   = tlon(0,0)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpRightCornerLatF  = tlat(nj2-1,ni2-1)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpRightCornerLonF  = tlon(nj2-1,ni2-1)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpRelativeCenterLon         = True      ; set a center lon<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpCenterLonF                = 180.0<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpRelativeCenterLat         = True       ; set a center lat<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">    res@mpCenterLatF                = -90.0           ; center lat<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New"">Any suggestions on how to get the latitude labels on the left axis? Thank you for your help!<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-family:"Courier New";color:rgb(31,73,125)">David A. Hebert<u></u><u></u></span></b></p><p class="MsoNormal"><span style="font-family:"Courier New"">Oceanography Division, </span><span style="font-family:"Courier New"">Code 7322 <br>Naval Research Laboratory <br>Stennis Space Center, MS 39529<br>(228)688-5846; DSN 828-5846 <br></span><span style="font-family:"Courier New""><a href="http://www.nrl.navy.mil/" target="_blank"><span style="color:blue">http://www.nrl.navy.mil</span></a><u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New""><u></u> <u></u></span></p></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-6490611580294256170gmail-m_-5302341073864890499gmail-m_-2314912229231948107gmail-m_2452906710536202663gmail-m_6980392933698291299gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
<span id="gmail-m_-6490611580294256170gmail-m_-5302341073864890499gmail-m_-2314912229231948107gmail-m_2452906710536202663gmail-m_6980392933698291299cid:f_jqgwuoom0"><tickmarks.ncl></span><span id="gmail-m_-6490611580294256170gmail-m_-5302341073864890499gmail-m_-2314912229231948107gmail-m_2452906710536202663gmail-m_6980392933698291299cid:f_jqgwuop21"><mptick.png></span>_______________________________________________<br>ncl-talk mailing list<br><a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br></div></blockquote></div><br></div>
<br>
<div><font style="font-family:Arial,Helvetica,sans-serif" size="2">Nota automatica aggiunta dal sistema di posta.</font></div><div><img src="https://www.unive.it/media/banner_150.jpg"></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-6490611580294256170gmail-m_-5302341073864890499gmail-m_-2314912229231948107gmail-m_2452906710536202663gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div>

<br>
<div><font style="font-family:Arial,Helvetica,sans-serif" size="2">Nota automatica aggiunta dal sistema di posta.</font></div><div><img src="https://www.unive.it/media/banner_150.jpg"></div>