forked from Willyou2/RealtimeViewer2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncAnimationtest.py
48 lines (38 loc) · 981 Bytes
/
funcAnimationtest.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
47
48
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
x = [1]
y = [1]
fig, ax = plt.subplots()
line, = ax.plot(x, y, color='k')
def update(num, line):
global x, y
x[0] += 0.05
y[0] += 0.05
line.set_data(x, y)
#line.axes.axis([0, 10, 0, 1])
return line,
ani = animation.FuncAnimation(fig, update, fargs=[line],
interval=1000, blit=True)
#ani.save('test.gif')
plt.show()
'''
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
xdata, ydata = [], []
ln, = plt.plot(xdata, ydata, 'k*', animated=True)
def init():
ax.set_xlim(0, 2*np.pi)
ax.set_ylim(-1, 1)
return ln,
def update(frame):
xdata.append(frame)
ydata.append(np.sin(frame))
ln.set_data(xdata, ydata)
return ln,
ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128),
init_func=init, blit=True)
plt.show()
'''