Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
import wx
import wx.lib.plot as plot
wx.SetDefaultPyEncoding("iso-8859-15")
class MyFrame(wx.Frame):
def __init__(
self, parent = None, id = -1, title = "Example", size = wx.Size(500, 500)
):
wx.Frame.__init__(self, parent, id, title, size = size)
panel = wx.Panel(self)
vbox_main = wx.BoxSizer(wx.VERTICAL)
panel.SetSizer(vbox_main)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox_main.Add(vbox, 1, wx.ALL | wx.EXPAND, 5)
canvas = plot.PlotCanvas(panel)
vbox.Add(canvas, 1, wx.EXPAND | wx.ALL, 5)
coordinates1 = (
(1, 50), (2, 60), (3, 45), (4, 60), (5, 33), (6, 79),
)
coordinates2 = (
(1, 40), (2, 30), (3, 65), (4, 80), (5, 23), (6, 19),
)
lines = (
plot.PolyLine(
coordinates1, colour = "green", legend = u" Jänner", width = 1
),
plot.PolyLine(
coordinates2, colour = "blue", legend = u" Februar", width = 1
),
)
graphics = plot.PlotGraphics(
objects = lines, title = u"Monatsübersicht", xLabel = u"Monate",
yLabel = u"Anzahl Verkäufe"
)
canvas.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
canvas.SetFontSizeAxis(10)
canvas.SetFontSizeLegend(7)
canvas.SetEnableLegend(True)
canvas.SetXSpec('auto')
canvas.SetYSpec('auto')
canvas.SetEnableGrid(True)
canvas.Draw(graphics, xAxis = (0, 12), yAxis = (0, 100))
#canvas.Draw(graphics)
def main():
"""Testing"""
app = wx.PySimpleApp()
f = MyFrame()
f.Center()
f.Show()
app.MainLoop()
if __name__ == "__main__":
main()
Gerold
Stichworte: Diagramm Graph Linie Liniendiagramm