canvas.draw() is slow in animation, I have succeed in replacing it with canvas.restore_region(). And it is wonderful. However, in the following, I fail to make it work the same as canvas.draw().The following code can work. And creat a dynamic line. When I work with the statement "#self.canvas.draw()" .The result is exactly what I want.
However, canvas.restore_region() fail to do as canvas.draw() here. The problem is when I refresh the line, the previous line is not clear as I want to.Could anyone help me? Thanks. import wx from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg from matplotlib.figure import Figure class Temp: def __init__(self): app = wx.PySimpleApp() frame=wx.Frame(None,size=(700,500)) frame.Show(True) ##Creat figure , canvas , axe. fig = Figure((8.8,6),facecolor='w') self.canvas = FigureCanvasWxAgg(frame, -1, fig) self.ax=fig.add_axes([0.1,0.15,0.7,0.7],axisbg='#dedff7') ##Get background for OnTimer function. self.background=self.canvas.copy_from_bbox(self.ax.bbox) ##Create line on axe. self.y=[1,1] self.x=[0,10] self.line,=self.ax.plot(self.x,self.y) ##Bind timer to refresh line timer=wx.Timer() timer.Bind(wx.EVT_TIMER, self.OnTimer, timer) timer.Start(1000) app.MainLoop() def OnTimer(self,event): self.y=[self.y[0]+0.005,self.y[1]+0.005] self.line.set_data(self.x,self.y) self.canvas.restore_region(self.background) self.ax.draw_artist(self.line) self.canvas.blit(self.ax.bbox) self.canvas.gui_repaint() #self.canvas.draw() Temp() -- View this message in context: http://www.nabble.com/Different-between-canvas.draw%28%29-and-canvas.restore_region%28%29---tp16790656p16790656.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users