added voronoi anim pyscript and integrated Jacopo comments on readme

This commit is contained in:
dave 2018-11-10 13:13:01 -05:00
parent 8f7b8fa4e6
commit 4ad8ecf443
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
#!/usr/bin/python
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
import matplotlib.animation as animation
import numpy as np
import csv
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
axes = plt.gca()
axes.set_xlim([-70,70])
axes.set_ylim([-70,70])
datafile = open('src/rosbuzz/buzz_scripts/log/voronoi_4.csv', 'r')
Vorreader = csv.reader(datafile, delimiter=',')
def animate(i):
for row in Vorreader:
ax.clear()
# ax.plot([-50, -50, 50, 50, -50],[-50, 50, 50, -50, -50],'b--')
j = 1
while j < len(row)-2:
ax.plot([float(row[j]), float(row[j+2])], [float(row[j+1]), float(row[j+3])])
j += 6
ax.plot(float(row[len(row)-2]),float(row[len(row)-1]),'x')
return
ani = animation.FuncAnimation(fig, animate, interval=250)
plt.show()