-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_path.py
45 lines (38 loc) · 967 Bytes
/
plot_path.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
import matplotlib.pyplot as plt
import numpy as np
def get_data(f):
data = f.readlines()
f.close()
x = []
y = []
for line in data[1:]:
line = line.strip().split(',')
x.append(float(line[0]))
y.append(float(line[1]))
return x, y
def get_obstacles(f):
data = f.readlines()
f.close()
obstacles = []
x = []
y = []
for line in data[1:]:
if line == '\n':
obstacles.append([x, y])
x = []
y = []
continue
line = line.strip().split(',')
x.append(float(line[0]))
y.append(float(line[1]))
return obstacles
plt.figure(figsize=(10, 10))
x, y = get_data(open('path.csv', 'r'))
t_x, t_y = get_data(open('tree.csv', 'r'))
obstacles = get_obstacles(open('obstacles.csv', 'r'))
plt.plot(t_x, t_y, '.g')
plt.plot(x, y, 'r')
for obstacle in obstacles:
plt.plot(obstacle[0], obstacle[1], 'k')
plt.axis('equal')
plt.show()