-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaze_plot.py
More file actions
46 lines (40 loc) · 1.2 KB
/
maze_plot.py
File metadata and controls
46 lines (40 loc) · 1.2 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
#!/usr/bin/python -w
import matplotlib.pyplot as plt
def plot_points(points, bg="maze_hard.pbm", title=None):
x,y = zip(*points)
fig1, ax1 = plt.subplots()
ax1.set_xlim(0,600)
ax1.set_ylim(600,0) # Decreasing
ax1.set_aspect('equal')
if(bg):
img = plt.imread(bg)
ax1.imshow(img, extent=[0, 600, 600, 0])
if(title):
ax1.set_title(title)
ax1.scatter(x, y, s=2)
plt.show()
def plot_points_lists(lpoints, bg="maze_hard.pbm", title=None):
fig1, ax1 = plt.subplots()
ax1.set_xlim(0,600)
ax1.set_ylim(600,0) # Decreasing
ax1.set_aspect('equal')
if(bg):
img = plt.imread(bg)
ax1.imshow(img, extent=[0, 600, 600, 0])
if(title):
ax1.set_title(title)
for points in lpoints:
x,y = zip(*points)
ax1.scatter(x, y, s=2)
plt.show()
def plot_traj_file(filename, bg="maze_hard.pbm", title=None):
try:
with open(filename) as f:
points=[]
for l in f.readlines():
pos=list(map(float, l.split(" ")))
points.append(pos)
f.close()
plot_points(points, bg, title)
except IOError:
print("Could not read file: "+f)