1 # Texters create the label strings written to the ticks. There are
2 # texters available for decimal numbers without and with an
3 # exponential part as well as fractions. Internally, the partitioning
4 # is based on fractions to avoid any rounding problems.
6 # Although we could modify axis.linear into a piaxis "inplace", we
7 # define a special piaxis below to give an impression, how easy
8 # alternative default settings can be implemented. A more advanced
9 # task would be to add an appropriate special partitioner for a
14 from pyx
.graph
import axis
16 class piaxis(axis
.linear
):
18 def __init__(self
, divisor
=math
.pi
,
19 texter
=axis
.texter
.rational(suffix
="\pi"), **kwargs
):
20 axis
.linear
.__init
__(self
, divisor
=divisor
, texter
=texter
, **kwargs
)
23 p
= path
.path(path
.moveto(0, 0), path
.curveto(3, 0, 1, 4, 4, 4))
26 c
.insert(axis
.pathaxis(p
, axis
.linear(min=0, max=10)))
27 c
.insert(axis
.pathaxis(p
.transformed(trafo
.translate(4, 0)),
28 axis
.linear(min=0, max=1e5
)))
29 c
.insert(axis
.pathaxis(p
.transformed(trafo
.translate(8, 0)),
30 piaxis(min=0, max=2*math
.pi
)))
31 c
.writeEPSfile("texter")
32 c
.writePDFfile("texter")