awips2/pythonPackages/matplotlib/lib/mpl_examples/animation/dynamic_image_gtkagg.py
root 3360eb6c5f Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: 9f19e3f712 [formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]
Former-commit-id: 06a8b51d6d
2012-01-06 08:55:05 -06:00

45 lines
796 B
Python
Executable file

#!/usr/bin/env python
"""
An animated image
"""
import time
import gobject
import gtk
import matplotlib
matplotlib.use('GTKAgg')
from matplotlib import rcParams
from pylab import *
fig = figure(1)
a = subplot(111)
x = arange(120.0)*2*pi/120.0
x = resize(x, (100,120))
y = arange(100.0)*2*pi/100.0
y = 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 = 0
tstart = 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 False
return True
cnt = 0
gobject.idle_add(updatefig)
show()