-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraph.py
73 lines (57 loc) · 2.01 KB
/
graph.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from matplotlib import pyplot as plot
from mpl_toolkits.mplot3d import Axes3D
def plot_swings(detected_events,gyro_data):
plot.figure()
ox = back_gyro(gyro_data)
swing_stats = [y['swing'] for y in detected_events]
swing_dots = [2500 if state else 0 for state in swing_stats]
plot.plot(ox, swing_dots, 'black', label='swingsers', )
plot.xlabel('ms')
plot.ylabel('acc_data')
plot.legend()
pass
def back_acc(acc_data):
ox = [x for x in range(0, len(acc_data))]
for label in ['acc_x', 'acc_y', 'acc_z']:
index = ['acc_x', 'acc_y', 'acc_z'].index(label)
dots = [y[index] for y in acc_data]
plot.plot(ox, dots, label=label)
return ox
def back_gyro(gyro_data):
ox = [x for x in range(0, len(gyro_data))]
for label in ['gyro_x', 'gyro_y', 'gyro_z']:
index = ['gyro_x', 'gyro_y', 'gyro_z'].index(label)
dots = [y[index] for y in gyro_data]
plot.plot(ox, dots, label=label)
return ox
def plot_quatern_wx(quatertn_data, gyro_data):
plot.figure()
ox = back_gyro(gyro_data) # swings:
q_w = [(y[0] * 10000) - 10000 for y in quatertn_data]
plot.plot(ox, q_w, 'black', label='q_w')
q_x = [y[1] * 10000 for y in quatertn_data]
plot.plot(ox, q_x, 'cyan', label='q_x')
plot.legend()
return None
def plot_quatern_yz(quatertn_data, gyro_data):
plot.figure()
ox = back_gyro(gyro_data) # swings:
q_y = [y[2] * 10000 for y in quatertn_data]
plot.plot(ox, q_y, 'black', label='q_y')
q_z = [y[3] * 10000 for y in quatertn_data]
plot.plot(ox, q_z, 'cyan', label='q_z')
plot.legend()
return None
def plot_vector3(listx, listy, listz):
fig=plot.figure()
ax=fig.add_subplot(111, projection='3d')
ax.plot(xs=listx, ys=listy, zs=listz)
pass
def plot_quaternion_evo(qlist):
listw, listx, listy, listz = zip (*qlist)
plot_vector3(listx, listy, listz)
pass
def plot_vector_evo(vlist):
listx, listy, listz = zip(*vlist)
plot_vector3(listx, listy, listz)
return None