Hi Patrik,
> I'm trying to get started making some more advanced plots with PyX. What I
> want to do is create a plot with some lines on it, where each line is
> surrounded by a half-transparent filled area (the 1-sigma deviation around
> the line). (For an example see
> http://governator.ucsc.edu/filer/p04tau100variance.png, which was made with
> matplotlib.)
> 
> The strategy I'm using is based on the "integral" example, ie:
> 
> plot lines
> retrieve paths from plotitems
> create closed paths and fill them

I'm not convinced that my strategy is the "best" or "official" - but at
least it seems to work;-)

from pyx import *
g = graph.graphxy(width=8,
                  x=graph.axis.linear(min=0, max=2),
                  y=graph.axis.linear(min=0, max=2),
                  key=graph.key.key(pos="br", dist=0.1))
g.plot([graph.data.function("x(y)=y**4", title=r"$x = y^4$"),
        graph.data.function("x(y)=y**2", title=r"$x = y^2$"),
        graph.data.function("x(y)=y", title=r"$x = y$"),
        graph.data.function("y(x)=x**2", title=r"$y = x^2$"),
        graph.data.function("y(x)=x**4", title=r"$y = x^4$")],
       [graph.style.line([color.gradient.Rainbow])])
g.finish()
# Now, we search the properties of plotimes until we find the colours..
colors = {}
for i in g.plotitems:
  for s in i.privatedatalist:
    if s.__dict__.has_key('lineattrs'):
      for c in s.__dict__['lineattrs']:
        if isinstance(c,pyx.color.color):
          colors[i.title] =  c
This wil create a dictionary, containg all title->color relations.
Then there are 2 possibilites:
a) you create the closed paths from parallel shifts of the original
path. Then you can just use the graph as a canvas an continue plotting
there (using the canvas-methods, no longer the plot-routines)
b) you create the closed paths also by g.plot-Routines. Then, the
easiest way is probably to create a new graphxy-Object, and plot
everything there, as now you know already the colors


But I'm sure, there are better ways to achive this result;-)

Good Luck

Axel

------------------------------------------------------------------------------
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

Reply via email to