Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import scipy.stats
import scipy.spatial
from numpy.random import RandomState
import matplotlib.pyplot as plt
rv=RandomState(123456789)
locations=rv.randint(0,511,size=(2,128))
#voronoiSet
voronoiSet=scipy.spatial.Voronoi(locations.T)
scipy.spatial.voronoi_plot_2d(voronoiSet,show_points=True,show_vertices=False)
plt.savefig('voronoi.png')
plt.show()
#triangulation
triangulation=scipy.spatial.Delaunay(locations.T)
assim_vertex=lambda index: triangulation.points[index]
triangle_set=map(assim_vertex,triangulation.vertices)
plt.triplot(locations[1],locations[0],triangles=triangle_set,color='r')
plt.scatter(locations[1],locations[0])
plt.savefig('triangular.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment