graph manual finished for 0.6 and small cleanups
[PyX/mjg.git] / examples / axis / log.py
blob64aec419d752c0bb7dd372985773c337b6d09a98
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 *
9 from pyx.graph import axis
11 p = path.curve(0, 0, 3, 0, 1, 4, 4, 4)
13 log2parter = axis.parter.log([axis.parter.preexp([axis.tick.rational(1)], 4),
14 axis.parter.preexp([axis.tick.rational(1)], 2)])
15 log2texter = axis.texter.exponential(nomantissaexp=r"{2^{%s}}",
16 mantissamax=axis.tick.rational(2))
18 c = canvas.canvas()
19 c.insert(axis.pathaxis(p, axis.log(min=1, max=1024)))
20 c.insert(axis.pathaxis(p.transformed(trafo.translate(4, 0)),
21 axis.log(min=1, max=1024, parter=log2parter)))
22 c.insert(axis.pathaxis(p.transformed(trafo.translate(8, 0)),
23 axis.log(min=1, max=1024, parter=log2parter,
24 texter=log2texter)))
25 c.writeEPSfile("log")