Hi Bing,
> I am new to PyX and would like to know how to specify the location of
> legend for multiple plots
>
> For example, the code below is taken from Titus' PyX tutorial:
>
> data = [graph.data.file("data.dat", x=1, y=2, title="Data 1"),
> graph.data.file("data2.dat", x=1, y=2, title ="Data 2")]
>
> # Plot it
> g.plot(data,
> styles=[graph.style.symbol(symbolattrs=[color.gradient.Rainbow])])
>
> The legend containing the title "Data 1 " and "Data 2" is always in
> the upper-right corner of the graph.
> Is there any way to specify where to place the legend, like the pos
> keyword in MATLAB's legend function?
Yes there ist:
When creating the plot, you can directly add a legend (called "key"):
g = graph.graphxy(
...
key = graph.key.key()
)
this "graph.key.key" takes many keywords (see
http://pyx.sourceforge.net/manual.pdf, page 45: 4.6. Module graph.key:
Keys)
You are probably looking for "pos":
pos = "tl" will place the key in the "Top Left" corner,
pos = "bc" will place the key in the "Bottom Center" - position
As alternative, you can give the exact position by using
hpos = 0.8
vpos = 0.4
which take arbitrary values between 0 and 1, positioning the key:
The example
http://pyx.sourceforge.net/examples/graphs/change.html
uses the "key"-keyword in order to place the legend in the bottom-right
corner.
HTH,
Axel
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user