我想在每个 draw ()
操作上绘制一个新图。 我拼凑到 < a href=> https://stackoverflow.com/ questions/10737459/embedding- a-matplotlib- imput- inside- a- wxpython-panel > > > 代码 , 用于绘制在天体创建后 < 坚固 > 从未更新过 的静态图。 但我想要在显示新数据时能够 < 坚固 > redraw 。
我如何构建我的代码 来做可重新绘制的数字?
这是这里的代码, 它精确地画了一次:
from numpy import arange, sin, pi
import matplotlib
matplotlib.use( WXAgg )
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
class CanvasPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
#self.size = (800, 50)
self.figure = Figure()
self.figure.set_size_inches( (8,1) )
self.figure.set_dpi(80)
#self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self, -1, self.figure )
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.Fit()
def draw(self):
self.axes = self.figure.add_subplot(111)
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * t)
self.axes.plot(t, s)
#time.sleep(5)
#self.figure.clear()