Hi Patrik,
Am 06.02.2009 um 01:40 schrieb Patrik Jonsson:
> The first is setting the color of the lines: I want the "main" lines
> to use a color gradient, and then I want to retrieve that color and
> use it again for the lines bounding the filled area. However, I
> can't figure out how to do this. The manual talks about various ways
> of setting the styles used for stroking the paths, but not how to
> retrieve them. I'm not even sure that this is part of the path
> derived from the plotitem, because it seems that the stroke style is
> set when passing the path to the canvas.stroke function and is not a
> property of the path itself?
Indeed, the stroke (and/or fill) attributes are not related to a path
itself. (The decorated path is the combination of a path and its
styles and other stuff (ornaments), but this is some internal detail.)
To answer your question, the following code will return the color of
the line in a graph:
from pyx import *
from pyx import attr
g = graph.graphxy(width=10)
pi = g.plot(graph.data.points([(0, 0), (1, 1)], x=1, y=2),
[graph.style.line([color.rgb.red])])
g.dodata()
c, = attr.getattrs(pi.lineattrs, [color.color])
g.writePDFfile("jonsson")
Note that attr module is (currently) not imported by from pyx import *
> The second problem is that it's my understanding that to get the
> paths out of the plot, you need to finish it. But then you can't
> plot to it again, so at that point it's too late to add the shaded
> region?
Indeed. IIRC this has changed in the current SVN head, but you would
still have the problem, that the axes are not scaled including the
additional stuff you want to draw. You could add the data for the
shaded region within the graph too without stroking it immediately:
pi2 = g.plot(graph.data.points([(0, 0.1), (1, 1.1)], x=1, y=2),
[graph.style.line(None)])
Then you can just use pi2.path and stroke and fill it yourself.
Beside that I would ask myself whether this plot style you want to
create could not be realized similar to errorbars. I think this would
lead to a very nice way of creating such plots.
Best,
André
--
by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
/ \ \ / ) [email protected], http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user