Thanks for your help. I get it work. However, an interesting thing appears. The following two codes(code 1 and code 2) makes different result??? Only set background in different place. Anyone can tell me why? I am eager to know it.
##code 1 import wx from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg from matplotlib.figure import Figure class Temp: def __init__(self): self.step=0 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') ##Create line on axe. self.y=[1,1] self.x=[0,10] self.line,=self.ax.plot(self.x,self.y,animated=True) ##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.step=self.step+1 if self.step==1: self.background=self.canvas.copy_from_bbox(self.ax.bbox) self.y=[self.y[0]+0.005,self.y[1]+0.005] self.canvas.restore_region(self.background) self.line.set_data(self.x,self.y) self.ax.draw_artist(self.line) self.canvas.blit(self.ax.bbox) Temp() ##Code 2 import wx from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg from matplotlib.figure import Figure class Temp: def __init__(self): self.step=0 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') ##Create line on axe. self.y=[1,1] self.x=[0,10] self.line,=self.ax.plot(self.x,self.y,animated=True) self.background=self.canvas.copy_from_bbox(self.ax.bbox) ##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.step=self.step+1 self.y=[self.y[0]+0.005,self.y[1]+0.005] self.canvas.restore_region(self.background) self.line.set_data(self.x,self.y) self.ax.draw_artist(self.line) self.canvas.blit(self.ax.bbox) Temp() -- View this message in context: http://www.nabble.com/Different-between-canvas.draw%28%29-and-canvas.restore_region%28%29---tp16790656p16801603.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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users