further docu for upcoming PyX 0.3 release
[PyX/mjg.git] / examples / graphs / step.py
blobbbd967397083ae58fa149abc7305578e8a378d24
1 from pyx import *
3 def step(x, a):
4 if a > 0:
5 return x
7 c = canvas.canvas()
8 g = c.insert(graph.graphxy(width = 10))
9 df = data.datafile("step.dat")
10 df.addcolumn("y1a=step(y1, y1-0.02)", context=locals())
11 df.addcolumn("y1b=step(y1, 0.02-y1)", context=locals())
12 df.addcolumn("y2a=step(y2, x-1)", context=locals())
13 df.addcolumn("y2b=step(y2, 1-x)", context=locals())
14 g.plot(graph.data(df, x=1, y="y1a"), graph.line(color.rgb.red))
15 g.plot(graph.data(df, x=1, y="y1b"), graph.line(color.rgb.blue))
16 g.plot(graph.data(df, x=1, y="y2a"), graph.line(color.rgb.red))
17 g.plot(graph.data(df, x=1, y="y2b"), graph.line(color.rgb.blue))
18 c.writetofile("step")