prevent double call of _cleanup, which harms usefiles (and is a bad idea in general)
[PyX.git] / examples / axis / texter.py
blob006ac27dec20245bc1113b055d11ecd2eef85aa8
1 import math
2 from pyx import *
3 from pyx.graph import axis
5 texter1 = axis.texter.decimal(plus="+", minus="-", equalprecision=1)
6 texter2 = axis.texter.rational()
8 class piaxis(axis.linear):
10 def __init__(self, divisor=math.pi,
11 texter=axis.texter.rational(suffix="\pi"), **kwargs):
12 axis.linear.__init__(self, divisor=divisor, texter=texter, **kwargs)
14 p1 = path.path(path.moveto(0, 0), path.curveto(3, 0, 1, 4, 4, 4))
15 p2 = p1.transformed(trafo.translate(4, 0))
16 p3 = p2.transformed(trafo.translate(4, 0))
17 p4 = p3.transformed(trafo.translate(4, 0))
19 c = canvas.canvas()
20 c.insert(axis.pathaxis(p1, axis.linear(min=0, max=1e2)))
21 c.insert(axis.pathaxis(p2, axis.linear(min=-0.7, max=0.4, texter=texter1)))
22 c.insert(axis.pathaxis(p3, axis.linear(min=-0.7, max=0.4, texter=texter2)))
23 c.insert(axis.pathaxis(p4, piaxis(min=0, max=2*math.pi)))
24 c.writeEPSfile("texter")
25 c.writePDFfile("texter")
26 c.writeSVGfile("texter")