[ncl-talk] NCL legend formatting question using gsn_legend_ndc

Rick Brownrigg brownrig at ucar.edu
Wed Aug 10 14:26:11 MDT 2016


I agree with you -- I don't think there's a way to it directly.  But you
could make two calls to gsn_legend_ndc() to get the same effect (I know its
a bit more painful).  I had initially thought you might get the desired
effect by using the graphical-table functions (
http://ncl.ucar.edu/Applications/table.shtml), which would certainly handle
the layout problem, but I'm not sure how/if it would be possible to include
the color line segments.

Hope that helps...
Rick

On Wed, Aug 10, 2016 at 1:19 PM, Alan Rhoades <alan.m.rhoades at gmail.com>
wrote:

> Hello,
>
> I have a question in regards to using the gsn_legend_ndc legend generator.
>
>
> [image: Inline image 1]
>
> I'd like to make plot A) (generated using the resources highlighted below)
> look more like plot B) (modified manually) without generating two legends
> with the gsn_legend_ndc and overlaying the plots.
>
> The functionality I have in mind would be setting gsn_legend_ndc from...
>
> gsn_legend_ndc(wks,17,labels,0.80,0.99,lgres)
>
> ...to...
>
> gsn_legend_ndc(wks,(/8,9/),labels,0.80,0.99,lgres)
>
> ...to allow for a return on the legend labels where the new labels would
> be placed to the right of the first set of labels.  After reviewing all of
> the NCL legend/xy examples, I don't think this is currently possible though.
>
> Here are the resources that I used to generate the "dummy" plot (i.e., A)
> ) above...
>
> ***********************************************
> ; legend resources
> ;***********************************************
>  labels = (/"VR-CESM28 - 1980-2005","VR-CESM28 - 2025-2050","VR-CESM28 -
> 2075-2100","PRISM","BCSD-CMIP5","NLDAS14 MOSAIC","NLDAS14 NOAH","NLDAS14
> VIC","NARCCAP - CRCM-CCSM","NARCCAP - CRCM-CGCM3","NARCCAP -
> ECP2-GFDL","NARCCAP - HRM3-HADCM3","NARCCAP - MM5-CCSM","NARCCAP -
> MM5-HADCM3","NARCCAP - RCM3-CGCM3","NARCCAP - RCM3-CGCM3","NARCCAP -
> RCM3-GFDL","NARCCAP - WRFG-CCSM"/)
>
>  lgres                    = True
> ; LEGEND LABELS AND COLORS
>  lgres at lgMonoLineColor    = False
>  lgres at lgBoxMinorExtentF  = 0.1 ; default 0.6 - controls how long a line
> segment
>  lgres at lgLineLabelStrings = labels
>  lgres at lgLineColors     = (/"Black","Red3","Red4","Cyan"
> ,"Green","royalblue3","royalblue2","royalblue1","
> gray40","gray45","gray50","gray55","gray60","gray65","
> gray70","gray75","gray80"/)
>  lgres at lgDashIndexes       = (/0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1/)    ;
> dash indexes
>  lgres at lgItemOrder  = (/ 16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 /)   ;
> Reorder the legends
>
> ; LEGEND HEIGHT AND WIDTH
>  lgres at vpWidthF           = 0.15                   ; width of legend (NDC)
>  lgres at vpHeightF          = 0.175                   ; height of legend
> (NDC)
>
> ; LEGEND FONT HEIGHT (AVOID IF POSSIBLE)
> ; lgres at lgAutoManage           = False                 ; Necessary to set
> font hgt
> ; lgres at lgLabelFontHeightF     = 0.025                ; label font height
>
> ; LEGEND BORDER AND COLORFILL
>  lgres at lgPerimOn              = False                ; turn off/on box
> around
>  lgres at lgPerimFill            = "SolidFill"      ; Fill legend box w/white
>  lgres at lgPerimFillColor       = "white"          ; so it masks XY curves
>
> ;
> ; Draw the legend, indicating the number of items, a label for each
> ; item, and the X, Y position of the legend in NDC coordinates.
> ;
>  gsn_legend_ndc(wks,17,labels,0.80,0.99,lgres)
>
> Thanks in advance!
>
> AR
>
> --
>
> *Alan Rhoades | **PhD Candidate | **University of California, Davis*
> *Atmospheric Science Graduate Group | **Climate Change Water and Society
> (CCWAS) NSF IGERT Trainee*
> *alan.m.rhoades at gmail.com
> <alan.m.rhoades at gmail.com> | amrhoades at ucdavis.edu <amrhoades at ucdavis.edu>*
> *Website <http://alanrhoades.weebly.com/> | Research Gate
> <https://www.researchgate.net/profile/Alan_Rhoades> | LinkedIn
> <https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a>** | **Google
> Scholar <https://scholar.google.gr/citations?user=AVFLiFsAAAAJ&hl=en>*
>
> _______________________________________________
> 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/20160810/25f92c43/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NCL_Legend_Format_Question.png
Type: image/png
Size: 582881 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160810/25f92c43/attachment-0001.png 


More information about the ncl-talk mailing list