[ncl-talk] ExcludeOuterBoxes in gsn_create_labelbar

Adam Phillips asphilli at ucar.edu
Tue Oct 4 09:53:41 MDT 2022


Hi Giorgio,
You can try setting lbLabelAlignment to "ExternalEdges" which I believe
will produce the same results as cnLabelBarEndStyle. See example #14 here:
https://www.ncl.ucar.edu/Applications/labelbar.shtml#ex14
Or see many other examples where this resource is set:
https://www.ncl.ucar.edu/Applications/res_list.shtml#lbLabelAlignment

Hope that helps!
Adam

On Wed, Sep 28, 2022 at 1:22 PM Giorgio Graffino via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

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


-- 
Adam Phillips
Associate Scientist IV, Climate Analysis Section
Climate and Global Dynamics Laboratory
National Center for Atmospheric Research
www.cgd.ucar.edu/staff/asphilli/

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221004/6bc3f9ec/attachment.htm>


More information about the ncl-talk mailing list