1 from pyx
import * # bar.dat looks like:
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),
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())