-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
27 lines (22 loc) · 716 Bytes
/
plot.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
import operator
import matplotlib.pyplot as plt
def plot(points, path: list):
x = []
y = []
for point in points:
x.append(point[0])
y.append(point[1])
# noinspection PyUnusedLocal
y = list(map(operator.sub, [max(y) for i in range(len(points))], y))
plt.plot(x, y, 'co')
print('length of path - ', len(path))
for _ in range(1, len(path)):
i = path[_ - 1]
j = path[_]
# noinspection PyUnresolvedReferences
plt.arrow(x[i], y[i], x[j] - x[i], y[j] - y[i], color='r', length_includes_head=True)
# noinspection PyTypeChecker
plt.xlim(0, max(x) * 1.1)
# noinspection PyTypeChecker
plt.ylim(0, max(y) * 1.1)
plt.show()