[ncl-talk] ExcludeOuterBoxes in gsn_create_labelbar

Giorgio Graffino g.graffino at tim.it
Wed Sep 28 13:22:27 MDT 2022


Dear NCL Community,

I'm trying to set the resource cnLabelBarEndStyle to "ExcludeOuterBoxes" 
while calling gsn_create_labelbar, to get ride of the labelbar boxes 
bigger than 1 and smaller than -1 in the attached plot. However, since 
I'm not drawing a contour plot, the resource doesn't do anything. I'm 
adapting this example 
(https://www.ncl.ucar.edu/Applications/Scripts/table_8.ncl). The 
procedure drawing the labelbar is shown below.

How can I solve the issue? I tried to look for a solution in the quick 
search bar in https://www.ncl.ucar.edu/Support/posting_guidelines.shtml, 
but it's always giving me the following error "The requested page could 
not be found."

Cheers,
Giorgio

undef("add_labelbar")
procedure add_labelbar(wks,plot,cmap,labels,stride,title,location)
local nboxes, vph, vpw, nboxes, lbres, lbid, amres, annoid
begin
   nboxes = dimsizes(labels)+1
   colors = span_color_rgba(cmap,nboxes)
   getvalues plot                      ; Get plot size for use in
     "vpHeightF" : vph                 ; creating labelbar.
     "vpWidthF"  : vpw
   end getvalues
;
; Set some resources for a vertical or horizontal labelbar on the
; bottom or right axis.
;
; am_para/am_orth
;    0.0/ 0.0  -  annotation in dead center of plot
;    0.5/ 0.5  -  annotation at bottom right of plot
;    0.5/-0.5  -  annotation at top right of plot
;   -0.5/-0.5  -  annotation at top left of plot
;   -0.5/ 0.5  -  annotation at bottom left of plot
;
; You will likely need to modify the am_para/am_orth
; values depending on your X and Y axis labels, the size
; of your plot, the number of rows and columns you have, et.
;
   if(any(location.eq.(/"bot1","bot2"/))) then
     orient  = "horizontal"
     width   = vpw * 0.95   ; slightly shorter than width of plot
     height  = vph * 0.15
     am_just = "BottomCenter"
     am_para = 0.0         ; Centered about X axis
     title_pos = "Top"
     if(location.eq."bot1")
       am_orth = 0.85       ; Move labelbar down
     else
       am_orth = 1.04       ; move further down
     end if
   else
     orient  = "vertical"
     width   = vpw * 0.15
     height  = vph * 0.95    ; slightly shorter than height of plot
     am_just = "TopLeft"
     am_orth = -0.5          ; Move labelbar up
     title_pos = "Left"
     if(location.eq."rgt2")
       am_para = 0.55        ; Move labelbar right
     else
       am_para = 0.78        ; move further right
     end if
   end if
; labelbar resources
   lbres                    = True
   lbres at lbAutoManage       = False         ; Necessary to control sizes
   lbres at vpWidthF           = width
   lbres at vpHeightF          = height
   lbres at cnLabelBarEndStyle = "ExcludeOuterBoxes"
   lbres at lbFillColors       = colors        ; labelbar colors
   lbres at lbMonoFillPattern  = True          ; Solid fill pattern
   lbres at lbLabelFontHeightF = 0.015          ; font height. Default is 
small
   lbres at lbLabelAlignment   = "InteriorEdges"
   lbres at lbOrientation      = orient
   lbres at lbTitleString      = title
   lbres at lbPerimOn          = False
   lbres at lbTitlePosition    = title_pos
   lbres at lbLabelStride      = stride
   lbid = gsn_create_labelbar(wks,nboxes,labels,lbres)
; annotation resources
   amres                  = True
   amres at amJust           = am_just
   amres at amOrthogonalPosF = am_orth
   amres at amParallelPosF   = am_para
; attach the labelbar to the plot
   plot at annoid = gsn_add_annotation(plot,lbid,amres)
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220928/788a5b81/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HadCM3_plot_maps_cor_10a.png
Type: image/png
Size: 19971 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220928/788a5b81/attachment.png>


More information about the ncl-talk mailing list