The code in the guide can be used to acheive this.
http://docs.scipy.org/doc/scipy/reference/tutorial/spatial.html
I haven't yet had time to read through and understand all the code, but it "manually" does what I want and it works.
Instead of using
voronoi_plot_2d(vor)
It step by step uses the different parts of vor to plot the voronoi plot, and this can be repeated in the loop. Full code example below:
#!/usr/bin/env python
import numpy as np
import time
from scipy.spatial import Voronoi, voronoi_plot_2d
import matplotlib.pyplot as plt
plt.ion()
(x,y) = (1,2)
plt.draw()
while True:
print "loop "
x += 0.1
y += 0.1
points = np.array([[0, 0], [1, 3], [0, 2.5], [x,y], [4, 1], [6, 4]])
plt.clf()
vor = Voronoi(points)
####MANUAL PLOTTING
plt.plot(points[:,0], points[:,1], 'o')
plt.plot(vor.vertices[:,0], vor.vertices[:,1], '*')
plt.xlim(-1, 3); plt.ylim(-1, 3)
for simplex in vor.ridge_vertices:
simplex = np.asarray(simplex)
if np.all(simplex >= 0):
plt.plot(vor.vertices[simplex,0], vor.vertices[simplex,1], 'k-')
center = points.mean(axis=0)
for pointidx, simplex in zip(vor.ridge_points, vor.ridge_vertices):
simplex = np.asarray(simplex)
if np.any(simplex < 0):
i = simplex[simplex >= 0][0] # finite end Voronoi vertex
t = points[pointidx[1]] - points[pointidx[0]] # tangent
t /= np.linalg.norm(t)
n = np.array([-t[1], t[0]]) # normal
midpoint = points[pointidx].mean(axis=0)
far_point = vor.vertices[i] + np.sign(np.dot(midpoint - center, n)) * n * 100
plt.plot([vor.vertices[i,0], far_point[0]], [vor.vertices[i,1], far_point[1]], 'k--')
plt.draw()
time.sleep(0.5)