[ncl-talk] Hown to turn on color fill of map with add labelbar

juki juki juky_emc2 at yahoo.com
Sat Nov 16 08:09:59 MST 2019


Hi Rick;
Thank you for help. Nice, it works, but suppose that I want to make a panel plot (subplot) with diffent level of colorbar (diffent data). Should we define the level for each plot, if so, it seems using add_labelbar is not so simple for panel plot. 
Juky
    On Friday, November 15, 2019, 06:29:56 AM GMT+7, Rick Brownrigg <brownrig at ucar.edu> wrote:  
 
 I spoke too soon -- I *do* know the reason this occurs:   add_labelbar is an internal function is gsn_csm.ncl!  But its being redefined at the top of your script after gsn_csm.ncl is loaded. Thus internal code within gsn_csm.ncl ends up trying to call your version, which expects different parameters, and things go downhill from there quickly.  

So (much to my relief), if you merely rename your version of add_labelbar, the setting of gsnOldLabelBar is not necessary (you'll probably still want lbLabelBarOn=False or you'll still end up with 2 overlapping labelbars).
Rick

On Thu, Nov 14, 2019 at 4:22 PM Rick Brownrigg <brownrig at ucar.edu> wrote:

Hi,
Try adding these resources to your mpres variable:
  mpres at gsnOldLabelBar = False
  mpres at lbLabelBarOn = False
This works for me. I do not have a good explanation for why this is needed. The gsnOldLabelBar is an undocumented, "internal", resource; its set to True by default.  I traced into the code far enough to see that there is an interaction with that resource=True and cnFillOn=True. But there must be more to it than that, or otherwise we would see this issue all the time. There's evidently a bug in there somewhere, but I am not in a position to go track it down. 

Setting lbLabelBarOn = False is not strictly necessary, but if you don't you'll get a second labelbar that is for the terrain. In the current setup, it partially overlaps the labelbar you are explicitly adding.
I hope that helps...Rick

On Thu, Nov 14, 2019 at 3:23 PM juki juki <juky_emc2 at yahoo.com> wrote:

line 216 is 
map = gsn_csm_contour_map(wks,data1T,mpres)

This appears when I set:
mpres at cnFillOn              = True     ; turn on color fill

If I set
mpres at cnFillOn              = False     ; turn on color fill

there is no error but I want to have topography background ins the map.
Juki


    On Friday, November 15, 2019, 05:16:20 AM GMT+7, Rick Brownrigg <brownrig at ucar.edu> wrote:  
 
 What is line 216 in your script?  Is that the only error/warning messages?




On Thu, Nov 14, 2019 at 2:57 PM juki juki via ncl-talk <ncl-talk at ucar.edu> wrote:

Sorry I re-send my previous question and hope some helps.
Juky 

    On Wednesday, November 13, 2019, 09:43:00 PM GMT+7, juki juki via ncl-talk <ncl-talk at ucar.edu> wrote:  
 
 Hi all !
I am using the following add labelbar for my contour plot: http://www.ncl.ucar.edu/Applications/Scripts/polyg_8_lbar.ncl
I am plotting the topography as the background instead of map = gsn_csm_map(wks,mpres)The following is my simple ncl: wks = gsn_open_wks("png","polyg")              ; send graphics to PNG file
;---Set up some map resources.  mpres                       = True  mpres at gsnMaximize           = False             ; Maximize plot in frame.  mpres at gsnDraw               = False            ; Will draw later  mpres at gsnFrame              = False            ; Don't advance the frame ; mpres at pmTickMarkDisplayMode = "Always"  mpres at gsnAddCyclic          = False    ; data already has cyclic point  mpres at mpGeophysicalLineThicknessF = 1.5          ; thickness of outlines  mpres at mpDataBaseVersion     = "MediumRes"  ; Medium resolution database  mpres at cnFillOn              = True     ; turn on color fill  mpres at cnLinesOn             = False    ; turn of contour lines    mpres at cnLineLabelsOn = False ;-- turns off contour line labels  mpres at cnInfoLabelOn = False ;-- turns off contour info label   mpres at cnLevelSelectionMode = "ManualLevels"    ; Set contour levels  mpres at cnMinLevelValF       = 200               ; the same for each plot.  mpres at cnMaxLevelValF       =  3000  mpres at cnLevelSpacingF      =   200

  mpres at mpMinLatF             = -7.  mpres at mpMaxLatF             = 7.  mpres at mpMinLonF             = 94.  mpres at mpMaxLonF             = 108.  mpres at mpShapeMode  = "FreeAspect"  mpres at vpWidthF      = 0.35  mpres at vpHeightF     = 0.25    mpres at tmXBLabelFontHeightF = 0.01                 ; resize tick labels  mpres at tmYLLabelFontHeightF = 0.01  mpres at gsnMajorLatSpacing = 2  mpres at gsnMajorLonSpacing = 2  mpres at gsnStringFontHeightF = 0.01    
    map = gsn_csm_contour_map(wks,data1T,mpres)
;data1T is topography data
;--Create logical variables to hold the marker resources.  gsres               = True  gsres at gsMarkerIndex = 16          ; Use filled dots for markers.;; Loop through each grouping of markers, and draw them one set at; a time, assigning the proper color and size with gsn_marker.;  base_size = 0.005  pmid = new(num_distinct_markers,graphic)  do i = 0, num_distinct_markers-1    if (.not.ismissing(lat_new(i,0)))      gsres at gsMarkerColor      = colors(i,:)      ;gsres at gsMarkerSizeF      = base_size * (i+1)/3.      gsres at gsMarkerSizeF      = base_size       gsres at gsMarkerThicknessF = 0.7*(i+1)      pmid(i) = gsn_add_polymarker(wks,map,lon_new(i,:),lat_new(i,:),gsres)    end if  end do
;---Draw labelbar and advance frame.  add_labelbar(wks,map,levels,colors)  draw(map)  frame(wks)
Question: How to turn on the color fill? When I set  mpres at cnFillOn              = True     ; turn on color fill, I got the following error:
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 7901 in file /usr/local/lib/ncarg/nclscripts/csm/gsn_csm.ncl
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 11301 in file /usr/local/lib/ncarg/nclscripts/csm/gsn_csm.ncl
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 216 in file rata.ncl
Thank you for help
Juky





_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk  _______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu
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/20191116/dfc4edb6/attachment.html>


More information about the ncl-talk mailing list