Former-commit-id:2b462d8665
[formerly133dc97f67
] [formerlya02aeb236c
] [formerlya02aeb236c
[formerly9f19e3f712
]] [formerly2b462d8665
[formerly133dc97f67
] [formerlya02aeb236c
] [formerlya02aeb236c
[formerly9f19e3f712
]] [formerly06a8b51d6d
[formerlya02aeb236c
[formerly9f19e3f712
] [formerly06a8b51d6d
[formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]]]] Former-commit-id:06a8b51d6d
Former-commit-id:2c3569dd39
[formerly9bb8decbcf
] [formerly8e80217e59
] [formerlye2ecdcfe33
[formerly377dcd10b9
] [formerly8e80217e59
[formerly3360eb6c5f
]]] Former-commit-id:e2ecdcfe33
[formerly377dcd10b9
] Former-commit-id:e2ecdcfe33
Former-commit-id:7dbd17a5aa
52 lines
1.2 KiB
Python
Executable file
52 lines
1.2 KiB
Python
Executable file
# For detailed comments on animation and the techniqes used here, see
|
|
# the wiki entry http://www.scipy.org/Cookbook/Matplotlib/Animations
|
|
|
|
import matplotlib
|
|
matplotlib.use('TkAgg')
|
|
|
|
import sys
|
|
import pylab as p
|
|
import numpy as npy
|
|
import time
|
|
|
|
ax = p.subplot(111)
|
|
canvas = ax.figure.canvas
|
|
|
|
|
|
# create the initial line
|
|
x = npy.arange(0,2*npy.pi,0.01)
|
|
line, = p.plot(x, npy.sin(x), animated=True, lw=2)
|
|
|
|
def run(*args):
|
|
background = canvas.copy_from_bbox(ax.bbox)
|
|
# for profiling
|
|
tstart = time.time()
|
|
|
|
while 1:
|
|
# restore the clean slate background
|
|
canvas.restore_region(background)
|
|
# update the data
|
|
line.set_ydata(npy.sin(x+run.cnt/10.0))
|
|
# just draw the animated artist
|
|
ax.draw_artist(line)
|
|
# just redraw the axes rectangle
|
|
canvas.blit(ax.bbox)
|
|
|
|
if run.cnt==1000:
|
|
# print the timing info and quit
|
|
print 'FPS:' , 1000/(time.time()-tstart)
|
|
sys.exit()
|
|
|
|
run.cnt += 1
|
|
run.cnt = 0
|
|
|
|
|
|
p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
|
|
p.grid() # to ensure proper background restore
|
|
manager = p.get_current_fig_manager()
|
|
manager.window.after(100, run)
|
|
|
|
p.show()
|
|
|
|
|
|
|