Re: Legend on xy plots with multiple lines

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 03 2013 - 11:49:50 MDT

On Sep 3, 2013, at 11:41 AM, Xin Xi wrote:

> Mary,
> I used NhlAddData approach to deal with multiple lines with two y axes. I use xyDashPattern, not xyDashPatterns.

You will still need to set lgDashIndexes as described below, but be sure to use the same index values that
you used with each xyDashPattern setting and be sure to use them in the right order.

>
>
> On Tue, Sep 3, 2013 at 1:30 PM, Mary Haley <haley@ucar.edu> wrote:
> Xin,
>
> You can set the line patterns yourself using
> the "xyDashPatterns" resource, and that
> way know exactly which line patterns to
> use in the legend:
>
> res@xyDashPatterns = (/2,3,4/) ; just an example
> . . .
> plot = gsn_csm_xy(wks,x,y,res)
>
> lgres = True
> . . .
> lgres@lgDashIndexes = (/2,3,4/) ; or you can use lgres@lgDashIndexes = res@xyDashPatterns
> lgres@lgMonoDashIndex = False
>
> Or, you can retrieve the value of "xyDashPatterns" from
> the XY plot, and use this in your legend:
>
> plot = gsn_csm_xy(wks,x,y,res)
>
> getvalues plot@dataspec
> "xyDashPatterns" : dash_patterns
> end getvalues
>
> . . .
>
> lgres@lgDashIndexes = dash_patterns
> lgres@lgMonoDashIndex = False
>
>
> See example "leg_13.ncl" at:
>
> http://www.ncl.ucar.edu/Applications/legend.shtml
>
>
> This example is a bit lengthy, but it shows how to get information
> from an XY plot so you can reconstruct a legend from scratch.
>
> --Mary
>
> On Sep 3, 2013, at 9:43 AM, Xin Xi wrote:
>
> > Hello,
> > I am plotting multiple lines on a xy plot with two y axes, and use gsn_create_legend to attach a legend to the plot. I donot know how to make the line patterns in the legend consistent with the line plot. See attached script and figure. Any help is much appreciated.
> > Thanks.
> > Xin
> >
> > <zz.ncl><z0_usth_ust.png>_______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Xin Xi
> School of Earth and Atmospheric Sciences
> Georgia Institute of Technology
> 311 Ferst Drive, Atlanta, GA 30332-0340
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 3 11:50:00 2013

This archive was generated by hypermail 2.1.8 : Wed Sep 04 2013 - 10:27:56 MDT