Ich schau mir gerade die library wx.lib.plot an und bin erfreut, wie schnell und einfach ich repräsentable Grafiken hinbekomme.
Allerdings habe ich im Netz noch kein Bespiel für ein bar chart gefunden. Kann mir da jemand helfen ?
Vielen Dank !
bar chart mit wx.lib.plot
@mikanoca: In der Demo unter `More Windows/Controls » PyPlot` ist `Draw6` im `Plot`-Menü ein Balkendiagramm.
Im Democode steht bei mir:
Und in der angegebenen Datei ist's dann die Funktion `_draw6Objects()`. Die Balken sind einfach breite `PolyLine`-Exemplare.
Code: Alles auswählen
################################################################\
# Where's the code??? |
# |
# wx.lib.plot.py came with its own excellent demo built in, |
# for testing purposes, but it serves quite well to demonstrate |
# the code and classes within, so we are simply borrowing that |
# code for the demo. Please load up wx.lib.plot.py for a review |
# of the code itself. The demo/test is at the bottom of |
# the file, as expected. |
################################################################/
Code: Alles auswählen
def _draw6Objects():
# Bar graph
points1=[(1,0), (1,10)]
line1 = PolyLine(points1, colour='green', legend='Feb.', width=10)
points1g=[(2,0), (2,4)]
line1g = PolyLine(points1g, colour='red', legend='Mar.', width=10)
points1b=[(3,0), (3,6)]
line1b = PolyLine(points1b, colour='blue', legend='Apr.', width=10)
points2=[(4,0), (4,12)]
line2 = PolyLine(points2, colour='Yellow', legend='May', width=10)
points2g=[(5,0), (5,8)]
line2g = PolyLine(points2g, colour='orange', legend='June', width=10)
points2b=[(6,0), (6,4)]
line2b = PolyLine(points2b, colour='brown', legend='July', width=10)
return PlotGraphics([line1, line1g, line1b, line2, line2g, line2b],
"Bar Graph - (Turn on Grid, Legend)", "Months", "Number of Students")