some more comments on changelists
[PyX/mjg.git] / examples / graphs / washboard.py
blob2002d77ea1e15d89f25f622e60e57a4baa3f6fa9
1 # contributed by Sigmund Kohler
3 from math import pi, cos
4 from pyx import *
5 from pyx.deco import barrow, earrow
6 from pyx.style import linewidth, linestyle
7 from pyx.graph import graphxy
8 from pyx.graph.axis import linear
9 from pyx.graph.axis.painter import regular
10 from pyx.graph.style import line
11 from pyx.graph.data import function
13 mypainter = regular(basepathattrs=[earrow.normal], titlepos=1)
14 def mycos(x): return -cos(x)+.10*x
16 g = graphxy(height=5, x2=None, y2=None,
17 x=linear(min=-2.5*pi, max=3.3*pi, parter=None,
18 painter=mypainter, title=r"$\delta\phi$"),
19 y=linear(min=-2.3, max=2, painter=None))
20 g.plot(function("y(x)=mycos(x)", context=locals()),
21 [line(lineattrs=[linewidth.Thick])])
22 g.finish()
24 x1, y1 = g.pos(-pi+.1, mycos(-pi+.1))
25 x2, y2 = g.pos(-.1, mycos(-.1))
26 x3, y3 = g.pos(pi+.1, mycos(pi+.1))
28 g.stroke(path.line(x1-.5, y1, x1+.5, y1), [linestyle.dashed])
29 g.stroke(path.line(x1-.5, y3, x3+.5, y3), [linestyle.dashed])
30 g.stroke(path.line(x2-.5, y2, x3+.5, y2), [linestyle.dashed])
31 g.stroke(path.line(x1, y1, x1, y3), [barrow.normal, earrow.normal])
32 g.stroke(path.line(x3, y2, x3, y3), [barrow.normal, earrow.normal])
33 g.text(x1+.2, 0.5*(y1+y3), r"$2\pi\gamma k\Omega$", [text.vshift.middlezero])
34 g.text(x1-.6, y1-.1, r"$E_{\rm b}$", [text.halign.right])
35 g.text(x3+.15, y2+.20, r"$2J_k(\varepsilon/\Omega)+\pi\gamma k\Omega$")
37 g.writeEPSfile("washboard")
38 g.writePDFfile("washboard")