PyX - Example: axis/manualticks.py

0.5 KB
17.1 KB
10.5 KB

Manually place ticks at certain positions

manualticks.png
import math
from pyx import *

p = path.curve(0, 0, 3, 0, 1, 4, 4, 4)

myticks = [graph.axis.tick.tick(math.pi, label="\pi", labelattrs=[text.mathmode]),
           graph.axis.tick.tick(2*math.pi, label="2\pi", labelattrs=[text.mathmode])]

c = canvas.canvas()
c.insert(graph.axis.pathaxis(p, graph.axis.linear(min=0, max=10)))
c.insert(graph.axis.pathaxis(p.transformed(trafo.translate(4, 0)),
                             graph.axis.linear(min=0, max=10, manualticks=myticks)))
c.writeEPSfile("manualticks")
c.writePDFfile("manualticks")

Description

Ticks can be set manually by passing tick instances to the manualticks argument of the axis instance as shown at the right axis in this example.

As you can see the manual ticks are combined with tick created automatically. You could disable any automatic tick creation by setting the parter argument to None. But what's much more interesting is, that the manually and automatically created ticks are not just merged, but the combination together is used when rating the resulting partion. Hence the manual ticks lead to a different set of automatically created ticks for this example.