Re: legend v. PlotManager v. writing legend over plot?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue, 8 Feb 2005 09:40:31 -0700 (MST)

On Mon, 7 Feb 2005, Matt Stumbaugh wrote:

> Does anyone know if there's a legend function in PyNGL similar to
> gsn_legend_ndc() in NCL?

Hi Matt,

I haven't added such a function yet, but eventually will get to this one.
I could probably whip it up if I can get a free moment!

> In example 8, plotManager is used to produce a legend for data in neat 2d
> arrays.
>
> In my case, I want to plot some data using Ngl.XY() and some data using
> Ngl.polyline() and then have a corresponding legend.
>
> In the past using NCL, I found it practical to keep visual information
> corresponding to particular lines (often unique polylines with different
> colors, dash indices, etc.) in arrays and then pass these arrays into the
> resources for gsn_legend_ndc(). But in using PyNGL, I've almost reached the
> conclusion that making up an ad hoc legend and writing it directly to the
> plot gives good flexibility without having to force my data into uniform
> arrays for plotting solely with Ngl.XY(). Of course this isn't very neat.
> So unless some kind soul out there can help me, I know there are many, I
> guess I'm going to have to get my data in one array.
>
> FYI, below I've included snippits of my code in both NCL and PyNGL and have
> also attached the plot I'm developing.
> Thanks!
> M
>

I'll take a look at your script, and also see what it would take to
get a legend in PyNGL. While I'm at it, I'll also do "labelbar_ndc"
since it's a similar function.

Cheers,

--Mary

> ;--NCL-------------------------------------------------------------;
> ; legend resources
>
> lgres = True
> lgres_at_lgMonoItemType = False
> lgres_at_lgItemTypes = data_types
> lgres_at_lgMonoDashIndex = False
> lgres_at_lgDashIndex = index_gnome
> lgres_at_lgMonoLineColor = False
> lgres_at_lgLineColors = color_index ; colors for legend lines
> lgres_at_lgLineThicknessF = 3
> lgres_at_lgMonoMarkerColor= True
> lgres_at_lgMarkerSizeF = .01
> lgres_at_lgMarkerColor = "red"
>
> lgres_at_lgMonoMarkerIndex= True
> lgres_at_lgMarkerIndex = 16
> ;lgres_at_vpKeepAspect = True
> lgres_at_vpWidthF = 0.4 ; width of legend (NDC)
> lgres_at_vpHeightF = 0.2 ; height of legend (NDC)
> lgres_at_lgPerimOn = True ; turn off perimeter
> lgres_at_lgLabelFontHeightF = 0.015
> gsn_legend_ndc(wks,tComp,data_names,0.25,0.4,lgres)
>
>
> #PyNGL########################################
> lgXposL = (max(ndt) - min(ndt))/10
> lgXposR = lgXposL * 2
> lgYrange= max(nalongDistC) - min(nalongDistC)
> lgYdelta= lgYrange/(2.*float(count))
> lgYtop = max(nalongDistC) - lgYdelta lgYpos = []
> for val in leg_count:
> lgYval = lgYtop - lgYdelta * val
> lgYpos.append(lgYval)
>
> lgres = Ngl.Resources()
> lgres.gsLineThicknessF = 2.0
> lgXLR = [lgXposL, lgXposR]
> print lgXLR
> print lgYpos
> txres = Ngl.Resources()
> txres.txJust = "topLeft"
> txres.txFontHeightF = .02
> for index in leg_count:
> lgY = [lgYpos[index], lgYpos[index]]
> lgres.gsLineColor = leg_colors[index] Ngl.polyline(wks,
> plot, lgXLR, lgY, lgres)
> Ngl.text(wks, plot, str(leg_text[index]), lgXLR[1], lgY[1], txres)
>
_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Tue Feb 08 2005 - 09:40:31 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 19 2006 - 21:31:52 MST