graph style rework continues
[PyX/mjg.git] / examples / graphs / bar.py
blobe8bf9b22418b2a7d4335f47e9603c4fa6ed62ab1
1 from pyx import * # bar.dat looks like:
2 from pyx.graph import axis # #month min max
3 # January -5 1
4 # Feburary -4 3
5 # we prepare some stuff first ...
6 bap = axis.painter.bar # just an abbreviation
7 a1 = axis.bar(painter=bap(nameattrs=None)) # for single bars
8 a2 = axis.bar(painter=bap(nameattrs=[trafo.rotate(45),
9 text.halign.right],
10 innerticklength=0.2),
11 subaxis=axis.bar(dist=0)) # for several bars
12 nofirst = [attr.changelist([None, color.rgb.green])] # special draw attrs
14 c = canvas.canvas() # we draw several plots, thus we create a main canvas
15 g = c.insert(graph.graphxy(ypos=4.5, width=8, height=4, x=a1))
16 g.plot(graph.data.file("bar.dat", xname=1, y=2, ystack1=3),
17 graph.style.bar(barattrs=nofirst))
18 g2 = c.insert(graph.graphxy(width=8, x=a2, height=4))
19 g2.plot([graph.data.file("bar.dat", xname=1, y=2),
20 graph.data.file("bar.dat", xname=1, y=3)],
21 graph.style.bar())
22 c.writeEPSfile("bar")