📄 animation_blit.py
字号:
#!/usr/bin/env python# For detailed comments on animation and the techniques used here, see# the wiki entry# http://www.scipy.org/wikis/topical_software/MatplotlibAnimationimport sysimport timeimport gtk, gobjectimport matplotlibmatplotlib.use('GTKAgg')import matplotlib.numerix as nximport pylab as pax = p.subplot(111)canvas = ax.figure.canvas# create the initial linex = nx.arange(0,2*nx.pi,0.01)line, = p.plot(x, nx.sin(x), animated=True, lw=2)# for profilingtstart = time.time()def update_line(*args): if update_line.background is None: update_line.background = canvas.copy_from_bbox(ax.bbox) # restore the clean slate background canvas.restore_region(update_line.background) # update the data line.set_ydata(nx.sin(x+update_line.cnt/10.0)) # just draw the animated artist ax.draw_artist(line) # just redraw the axes rectangle canvas.blit(ax.bbox) if update_line.cnt==200: # print the timing info and quit print 'FPS:' , 200/(time.time()-tstart) sys.exit() update_line.cnt += 1 return Trueupdate_line.cnt = 0update_line.background = Nonegobject.idle_add(update_line)p.show()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -