dynamic_image_gtkagg.py
来自「非原创。很好的python例子」· Python 代码 · 共 44 行
PY
44 行
#!/usr/bin/env python"""An animated image"""import sys, time, os, gcimport matplotlibmatplotlib.use('GTKAgg')from matplotlib import rcParamsfrom pylab import *import gobject, gtkfig = figure(1)a = subplot(111)x = arange(120.0)*2*pi/120.0x = resize(x, (100,120))y = arange(100.0)*2*pi/100.0y = resize(y, (120,100))y = transpose(y)z = sin(x) + cos(y)im = a.imshow( z, cmap=cm.jet)#, interpolation='nearest')manager = get_current_fig_manager()cnt = 0tstart = time.time()def updatefig(*args): global x, y, cnt, start x += pi/15 y += pi/20 z = sin(x) + cos(y) im.set_array(z) manager.canvas.draw() cnt += 1 if cnt==50: print 'FPS', cnt/(time.time() - tstart) return gtk.FALSE return Truecnt = 0gobject.idle_add(updatefig)show()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?