Re: Legend on xy plots with multiple lines

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 03 2013 - 11:30:35 MDT


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:

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.


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:

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Tue Sep 3 11:30:44 2013

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