simplify path generation
[PyX/mjg.git] / examples / axis / log.py
blobb66c7f79ad8f468e44212a864f6feced99ec4788
1 # Certainly logarithmic axes are supported in PyX. By playing with
2 # partitioners and texters, you can easily change the base.
4 # It is left as an exercise to the reader to create a automatic
5 # partitioner for logarithmic axes with base 2.
7 import math
8 from pyx import *
10 p = path.curve(0, 0, 3, 0, 1, 4, 4, 4)
12 log2parter = graph.logparter([graph.preexp(graph.frac(1), 4),
13 graph.preexp(graph.frac(1), 2)])
14 log2texter = graph.exponentialtexter(nomantissaexp=r"{2^{%s}}",
15 mantissamax=graph.frac(2))
17 c = canvas.canvas()
18 c.insert(graph.pathaxis(p,
19 graph.logaxis(min=1, max=1024)))
20 c.insert(graph.pathaxis(p.transformed(trafo.translate(4, 0)),
21 graph.logaxis(min=1, max=1024, parter=log2parter)))
22 c.insert(graph.pathaxis(p.transformed(trafo.translate(8, 0)),
23 graph.logaxis(min=1, max=1024, parter=log2parter,
24 texter=log2texter)))
25 c.writetofile("log")