news item: tutorial by Titus Winter
[PyX/mjg.git] / examples / bargraphs / compare.py
blob1bc51021464da4abbf3821d4f44fed3c0af570fe
1 # When plotting several bars with the same style in a bar graph,
2 # they are plotted side by side. You have to create a nested bar
3 # axis to make each position in the bar graph to contain another
4 # bar axis. Additionally you can see, how you can explicitly add
5 # the parpos style in front of the bar style to set the fromvalue
6 # parameter, which allows to start bars at a certain value instead
7 # of starting them at the baseline.
9 from pyx import *
11 bap = graph.axis.painter.bar
12 a = graph.axis.nestedbar(painter=bap(nameattrs=[trafo.rotate(45),
13 text.halign.right],
14 innerticklength=0.1))
16 g = graph.graphxy(width=8, x=a)
17 g.plot([graph.data.file("bar.dat", xname="$1, 0", y=2),
18 graph.data.file("bar.dat", xname="$1, 1", y=3)],
19 [graph.style.barpos(fromvalue=0), graph.style.bar()])
20 g.writeEPSfile("compare")
21 g.writePDFfile("compare")