stackedbarpos separated from barpos
[PyX/mjg.git] / test / functional / test_bargraph.py
bloba00c62b756a8b1e8e610e41869156e12f148a9e3
1 #!/usr/bin/env python
2 import sys; sys.path[:0] = ["../.."]
4 import math
5 from pyx import *
6 from pyx import mathtree, attr
8 text.set(mode="latex")
10 def test_bar(c, x, y):
11 g = c.insert(graph.graphxy(x, y, height=5, width=5, x=graph.axis.bar(title="Month", painter=graph.axis.painter.bar(nameattrs=[text.halign.right, trafo.rotate(90)]))))
12 g.plot(graph.data.file("data/testdata2", xname=1, y=2, text=2), [graph.style.barpos(fromvalue=0), graph.style.bar(), graph.style.text()])
14 def test_bar2(c, x, y):
15 g = c.insert(graph.graphxy(x, y, height=5, width=5, y=graph.axis.bar(title="Month")))
16 g.plot(graph.data.file("data/testdata2", x=2, dx="1", yname=1), [graph.style.bar(), graph.style.errorbar()])
18 def test_bar3(c, x, y):
19 g = c.insert(graph.graphxy(x, y, height=5, width=12, x=graph.axis.bar(multisubaxis=graph.axis.bar(dist=0), painter=graph.axis.painter.bar(innerticklength=0.2))))
20 g.plot([graph.data.file("data/testdata2", xname=1, y=2),
21 graph.data.file("data/testdata2", xname=1, y=3),
22 graph.data.file("data/testdata2", xname=1, y=3)], [graph.style.bar()])
24 def test_bar4(c, x, y):
25 g = c.insert(graph.graphxy(x, y, height=5, width=12, x=graph.axis.bar(graph.axis.bar(dist=0)), key=graph.key.key()))
26 g.plot([graph.data.file("data/testdata2", xname=0, y=2, ystack1=3),
27 graph.data.file("data/testdata2", xname=0, y="$2-1", ystack1=3, title="test")],
28 [graph.style.bar(), graph.style.stackedbarpos("ystack1"), graph.style.bar([color.palette.ReverseRainbow]), graph.style.symbol()])
30 c = canvas.canvas()
31 test_bar(c, 0, 0)
32 test_bar2(c, 7, 0)
33 test_bar3(c, 0, -7)
34 test_bar4(c, 0, -14)
35 c.writeEPSfile("test_bargraph", paperformat="a4")