Skip to content

Commit 8eac69e

Browse files
authored
Create rand_line.py
随机数组成的折线
1 parent 8d40941 commit 8eac69e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

animation/rand_line.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#Author: Listen
2+
#!/usr/bin/env python3
3+
#-*- coding:utf-8 -*-
4+
5+
import numpy as np
6+
import matplotlib.pyplot as plt
7+
import matplotlib.animation as animation
8+
fig = plt.figure()
9+
axes1 = fig.add_subplot(1,1,1)
10+
line, =axes1.plot(np.random.rand(10))
11+
12+
def update(data):
13+
line.set_ydata(data)
14+
return line,
15+
def data_gen():
16+
while True:
17+
# line, = axes1.plot(np.random.rand(10))
18+
# return line,
19+
yield np.random.rand(10)
20+
21+
ani = animation.FuncAnimation(fig, update, data_gen(),interval=2*1000)
22+
plt.show()

0 commit comments

Comments
 (0)