environment:win10 + eclipse + pydev + python2.7.11 + wxpython3.0.2
code sample:
1 #!/usr/bin/env python 2 # -*- coding: UTF-8 -*- 3 4 import wx 5 import wx.lib.plot as plot 6 7 class MyFrame(wx.Frame): 8 def __init__(self): 9 self.frame1 = wx.Frame(None, title="test", id=-1, size=(500, 300)) 10 self.panel1 = wx.Panel(self.frame1) 11 self.panel1.SetBackgroundColour("white") 12 13 Button1 = wx.Button(self.panel1, -1, "Update", (200,220)) 14 Button1.Bind(wx.EVT_BUTTON, self.redraw) 15 16 plotter = plot.PlotCanvas(self.panel1) 17 plotter.SetInitialSize(size=(500, 200)) 18 19 data= [[1, 10], [2, 5], [3,10], [4, 5]] 20 line= plot.PolyLine(data, colour='red', width=1) 21 22 gc= plot.PlotGraphics([line], 'Test', 'x', 'y') 23 plotter.Draw(gc) 24 25 self.frame1.Show(True) 26 27 28 def redraw(self, event): 29 plotter = plot.PlotCanvas(self.panel1) 30 plotter.SetInitialSize(size=(500, 200)) 31 32 data2= [[1, 20], [2, 15], [3,20], [4, -10]] 33 line= plot.PolyLine(data2, colour='red', width=1) 34 35 gc= plot.PlotGraphics([line], 'Test', 'x', 'y') 36 plotter.Draw(gc) 37 38 app = wx.PySimpleApp() 39 f = MyFrame() 40 app.MainLoop()