new style bars become are stackable now
[PyX.git] / test / functional / test_bargraph.py
blobea85c4bcad957913370bfffb7bf6670eeb203fcc
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),
28 graph.data.file("data/testdata2", xname=0, y=3)], [graph.style.bar(barattrs=[attr.changelist([attr.changelist([color.rgb.red, color.rgb.green]), color.rgb.blue, color.cmyk.Cyan])])])
30 def test_barnew(c, x, y):
31 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)]))))
32 g.plot(graph.data.file("data/testdata2", xname=1, y=2, text=2), [graph.style.barpos_new(fromvalue=0), graph.style.bar_new(), graph.style.text()])
34 def test_barnew2(c, x, y):
35 g = c.insert(graph.graphxy(x, y, height=5, width=5, y=graph.axis.bar(title="Month")))
36 g.plot(graph.data.file("data/testdata2", x=2, dx="1", yname=1), [graph.style.bar_new(), graph.style.errorbar()])
38 def test_barnew3(c, x, y):
39 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))))
40 g.plot([graph.data.file("data/testdata2", xname=1, y=2),
41 graph.data.file("data/testdata2", xname=1, y=3),
42 graph.data.file("data/testdata2", xname=1, y=3)], [graph.style.bar_new()])
44 def test_barnew4(c, x, y):
45 g = c.insert(graph.graphxy(x, y, height=5, width=12, x=graph.axis.bar(graph.axis.bar(dist=0)), key=graph.key.key()))
46 g.plot([graph.data.file("data/testdata2", xname=0, y=2, ystack1=3),
47 graph.data.file("data/testdata2", xname=0, y="$2-1", ystack1=3, title="test")],
48 [graph.style.bar_new(), graph.style.barpos_new(stackname="ystack1"), graph.style.bar_new([color.palette.ReverseRainbow])])
49 #g.plot([graph.data.file("data/testdata2", xname=0, y=2, ystack1=3),
50 # graph.data.file("data/testdata2", xname=0, y=2),
51 # graph.data.file("data/testdata2", xname=0, y=3)], [graph.style.bar(barattrs=[attr.changelist([attr.changelist([color.rgb.red, color.rgb.green]), color.rgb.blue, color.cmyk.Cyan])])])
53 c = canvas.canvas()
54 # test_bar(c, 0, 0)
55 # test_bar2(c, 7, 0)
56 # test_bar3(c, 0, -7)
57 # test_bar4(c, 0, -14)
58 test_barnew(c, 0, 0)
59 test_barnew2(c, 7, 0)
60 test_barnew3(c, 0, -7)
61 test_barnew4(c, 0, -14)
62 c.writeEPSfile("test_bargraph", paperformat="a4")