new attribute handling in text module completed
[PyX/mjg.git] / examples / graphs / bar.py
blob038cffae9dd2d30b7cdf296e548cad9e9684d09b
1 from pyx import * # bar.dat looks like:
2 # #month min max
3 # January -5 1
4 # Feburary -4 3
5 # we prepare some stuff first ...
6 bap = graph.baraxispainter # just an abbreviation
7 a1 = graph.baraxis(painter=bap(nameattrs=None)) # for single bars
8 a2 = graph.baraxis(painter=bap(nameattrs=(trafo.rotate(45),
9 text.halign.right),
10 innerticklength=0.2),
11 subaxis=graph.baraxis(dist=0)) # for several bars
12 df = data.datafile("bar.dat") # read the datafile just once
13 d = [graph.data(df, x="month", y="min"), graph.data(df, x=1, y=3)]
14 nofirst = (graph.changesequence(None, [deco.stroked([color.gray.black])]),
15 graph.changesequence(None, [color.rgb.green])) # special draw attrs
17 c = canvas.canvas() # we draw several plots, thus we create a main canvas
18 g = c.insert(graph.graphxy(ypos=4.5, width=8, height=4, x=a1))
19 g.plot(d, graph.bar(stacked=1, barattrs=nofirst))
20 g.finish() # we explicitly finish the plot allow for a reuse of "d"
21 g2 = c.insert(graph.graphxy(width=8, x=a2, height=4))
22 g2.plot(d, graph.bar())
23 c.writetofile("bar")