-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_animate.py
46 lines (36 loc) · 1.03 KB
/
test_animate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
def xrange(x):
n = 0
while n < x:
yield n
n += 1
def main():
numframes = 10
numpoints = 10
color_data = np.ones((numframes, numpoints))
x, y, c = np.random.random((3, numpoints))
area_x = np.arange(0, 1, 0.2)
area_y = np.arange(0, 1, 0.2)
area = []
for i in range(5):
for j in range(5):
temp_x = []
temp_x.append(area_x[i])
temp_x.append(area_y[j])
temp_x = np.array(temp_x)
area.append(temp_x)
area = np.array(area)
x1 = area[..., :1]
y1 = area[..., 1:]
fig = plt.figure()
scat = plt.scatter(x, y, c=c, s=100)
plt.scatter(x1, y1, c='r', s=100)
ani = animation.FuncAnimation(fig, update_plot, frames=xrange(numframes),
fargs=(color_data, scat))
plt.show()
def update_plot(i, data, scat):
scat.set_offsets(np.random.random((10, 2)))
return scat,
main()