English 中文(简体)
如何在 wxpython 面板上重新绘制数学图象?
原标题:How to redraw a mathplotlib figure in a wxpython panel?

我想在每个 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()
问题回答

@acatal在他的评论中建议, 你要做的就是在您的绘图子例程中添加这些线条,

 self.canvas.draw()
 self.canvas.Refresh()




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签