-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlive_plot_sample.py
More file actions
50 lines (37 loc) · 1.13 KB
/
Copy pathlive_plot_sample.py
File metadata and controls
50 lines (37 loc) · 1.13 KB
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
49
50
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from time import sleep
# Define the number of data points to keep track of
NUM_POINTS = 200
data_points = np.zeros((NUM_POINTS, 3))
# Initialize the plot
fig = plt.figure()
ax1 = plt.subplot2grid((2,2),(0,0))
#ax1.set_aspect('equal')
ax2 = plt.subplot2grid((2,2),(1,0))
ax3 = plt.subplot2grid((2, 2), (0, 1))
ax4 = plt.subplot2grid((2,2), (1,1))
def data_gen():
global data_points
data = [1,2,3]
data_points = np.roll(data_points, -1, axis=0)
data_points[-1, :] = data
yield data_points
def init():
ax1.cla()
limits=200
ax1.set_xlim(-5,5)
ax1.set_ylim(-5,5)
def run(data):
print(data)
# update the data
# Draw the line connecting the data points
ax1.plot(data_points[:, 0], data_points[:, 2])
ax2.scatter(data_points[:, 0], data_points[:, 1])
ax1.set_title("példa ábra")
#ax1.grid()
#ax1.figure.canvas.draw()
# Only save last 100 frames, but run forever
ani = animation.FuncAnimation(fig, run, data_gen, interval=500, init_func=init,cache_frame_data=False)
plt.show()