add PDF output
[PyX/mjg.git] / test / functional / test_axis.py
blobec3f41593daf401d40e4217ed2e3eea4b2351537
1 #!/usr/bin/env python
2 import sys; sys.path[:0] = ["../.."]
4 import math
5 from pyx import *
6 from pyx.graph.axis.parter import linear as linparter
7 from pyx.graph.axis.painter import regular, ticklength, rotatetext
8 from pyx.graph.axis.texter import rational, exponential
9 from pyx.graph.axis.axis import lin, pathaxis
11 c = canvas.canvas()
12 lintest = {"title": "axis title", "min": 0, "max": 1, "parter": linparter(["0.25", "0.1/0.8"])}
13 c.insert(pathaxis(path.path(path.moveto(0, 0), path.lineto(0, 8)),
14 lin(**lintest),
15 direction=-1))
16 c.insert(pathaxis(path.path(path.moveto(1, 0), path.lineto(1, 8)),
17 lin(**lintest)))
18 c.insert(pathaxis(path.path(path.moveto(5, 0), path.lineto(5, 8)),
19 lin(painter=regular(labelattrs=[trafo.rotate(45)], titleattrs=[trafo.rotate(45)]), **lintest),
20 direction=-1))
21 c.insert(pathaxis(path.path(path.moveto(8, 0), path.lineto(8, 8)),
22 lin(painter=regular(labelattrs=[trafo.rotate(45), text.halign.right], titleattrs=[trafo.rotate(-45)]), **lintest),
23 direction=-1))
24 c.insert(pathaxis(path.path(path.moveto(11, 0), path.lineto(11, 8)),
25 lin(painter=regular(tickattrs=[color.rgb.red], innerticklength=0, outerticklength=ticklength.normal), **lintest),
26 direction=-1))
27 c.insert(pathaxis(path.path(path.moveto(12, 0), path.lineto(12, 8)),
28 lin(painter=regular(tickattrs=[attr.changelist([None, color.rgb.green])]), **lintest)))
29 c.insert(pathaxis(path.path(path.moveto(16, 0), path.lineto(16, 8)),
30 lin(texter=exponential(), **lintest),
31 direction=-1))
32 c.insert(pathaxis(path.path(path.moveto(18, 0), path.lineto(18, 8)),
33 lin(texter=rational(), **lintest),
34 direction=-1))
35 lintest = {"title": "axis title", "min": -2*math.pi, "max": 0, "divisor": math.pi, "parter": linparter("0.25")}
36 c.insert(pathaxis(path.path(path.moveto(0, 11), path.lineto(8, 11)),
37 lin(texter=rational(suffix="\pi"), **lintest)))
38 lintest = {"title": "axis title", "min": 0, "max": 2*math.pi, "divisor": math.pi, "parter": linparter("0.5")}
39 c.insert(pathaxis(path.path(path.moveto(10, 11), path.lineto(18, 11)),
40 lin(texter=rational(enumsuffix="\pi", over="%s/%s"), **lintest)))
41 lintest = {"min": 0, "max": 2*math.pi, "divisor": math.pi, "parter": linparter("0.125")}
42 c.insert(pathaxis(path.circle(4, 17, 4),
43 lin(texter=rational(suffix="\pi"), **lintest)))
44 lintest = {"min": 0, "max": 2*math.pi, "divisor": math.pi/180, "parter": linparter("30")}
45 c.insert(pathaxis(path.circle(14, 17, 4),
46 lin(painter=regular(labeldirection=rotatetext.parallel), **lintest)))
47 c.writeEPSfile("test_axis", paperformat="a4")
48 c.writePDFfile("test_axis", paperformat="a4")