- adjustments to the new path + graph data and style handling
[PyX/mjg.git] / examples / graphs / bar.py
blobab6ed039dbe4328bb32dd78507f6442ff25e2c9c
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
6 # we prepare some stuff first
7 bap = axis.painter.bar # just an abbreviation
8 a1 = axis.bar(painter=bap(nameattrs=None)) # for single bars
9 a2 = axis.bar(painter=bap(nameattrs=[trafo.rotate(45),
10 text.halign.right],
11 innerticklength=0.2),
12 subaxis=axis.bar(dist=0)) # for several bars
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, stack=3),
17 [graph.style.stackedbarpos("stack"),
18 graph.style.bar(barattrs=[color.rgb.green])])
19 g2 = c.insert(graph.graphxy(width=8, x=a2, height=4))
20 g2.plot([graph.data.file("bar.dat", xname=1, y=2),
21 graph.data.file("bar.dat", xname=1, y=3)],
22 [graph.style.bar()])
23 c.writeEPSfile("bar")