PyX - Example: axis/minimal.py

0.2 KB
15.1 KB
10.0 KB

Minimal example drawing an axis along a path

minimal.png
from pyx import *

c = graph.axis.pathaxis(path.curve(0, 0, 3, 0, 1, 4, 4, 4),
                        graph.axis.linear(min=0, max=10))
c.writeEPSfile("minimal")
c.writePDFfile("minimal")

Description

This is the basic example how to draw an axis along an arbitrary path. The function pathaxis from the graph.axis module takes a path and returns a canvas. As opposed to the typical usecase in graphs, we must fix the axis range by appropriate min and max arguments, because no data is provided to the axis instance where a data range could be extracted from. In graphs the range of an axis gets adjusted automatically although you can still set minimal and/or maximal values to force a certain axis range.

The axis instance is passed as the second argument to the pathaxis function. To use the axis at a graph all you need to do is to path the instance to the axis constructor using an appropriate keyword specifying the axis name.