Skip to content

Commit 71b4a97

Browse files
committed
Add another set of basic examples.
svn path=/trunk/matplotlib/; revision=8662
1 parent ae474ac commit 71b4a97

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
import matplotlib.animation as animation
4+
5+
def update_line(num, data, line):
6+
line.set_data(data[...,:num])
7+
return line,
8+
9+
fig1 = plt.figure()
10+
11+
data = np.random.rand(2, 25)
12+
l, = plt.plot([], [], 'r-')
13+
plt.xlim(0, 1)
14+
plt.ylim(0, 1)
15+
plt.xlabel('x')
16+
plt.title('test')
17+
line_ani = animation.FuncAnimation(fig1, update_line, 25, fargs=(data, l),
18+
interval=50, blit=True)
19+
#line_ani.save('lines.mp4')
20+
21+
fig2 = plt.figure()
22+
23+
x = np.arange(-9, 10)
24+
y = np.arange(-9, 10).reshape(-1, 1)
25+
base = np.hypot(x, y)
26+
ims = []
27+
for add in np.arange(15):
28+
ims.append((plt.pcolor(x, y, base + add, norm=plt.Normalize(0, 30)),))
29+
30+
im_ani = animation.ArtistAnimation(fig2, ims, interval=50, repeat_delay=3000,
31+
blit=True)
32+
#im_ani.save('im.mp4')
33+
34+
plt.show()

0 commit comments

Comments
 (0)