Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d43b3b

Browse files
committed
replaced gtk timeout example
svn path=/trunk/matplotlib/; revision=5598
1 parent b72fd23 commit 5d43b3b

2 files changed

Lines changed: 19 additions & 27 deletions

File tree

examples/animation/dynamic_demo.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

examples/animation/gtk_timeout.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import gobject
2+
import numpy as np
3+
import matplotlib
4+
matplotlib.use('GTKAgg')
5+
6+
import matplotlib.pyplot as plt
7+
8+
fig = plt.figure()
9+
ax = fig.add_subplot(111)
10+
line, = ax.plot(np.random.rand(10))
11+
ax.set_ylim(0, 1)
12+
13+
def update():
14+
line.set_ydata(np.random.rand(10))
15+
fig.canvas.draw_idle()
16+
return True # return False to terminate the updates
17+
18+
gobject.timeout_add(100, update) # you can also use idle_add to update when gtk is idle
19+
plt.show()

0 commit comments

Comments
 (0)