Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- from scipy.spatial import Voronoi
- import numpy
- import pylab
- numpy.random.seed(1)
- vor = Voronoi(numpy.random.random((20,2)))
- print(vor.ridge_points.T)
- print(vor.ridge_vertices)
- pylab.plot(vor.points.T[0],
- vor.points.T[1],'.')
- pylab.plot(vor.vertices.T[0],
- vor.vertices.T[1],'.')
- for pair in vor.ridge_points:
- if pair[0]>=0 and pair[1]>=0:
- pylab.plot([vor.points.T[0][pair[0]],vor.points.T[0][pair[1]]],
- [vor.points.T[1][pair[0]],vor.points.T[1][pair[1]]],'k')
- for pair in vor.ridge_vertices:
- if pair[0]>=0 and pair[1]>=0:
- pylab.plot([vor.vertices.T[0][pair[0]],vor.vertices.T[0][pair[1]]],
- [vor.vertices.T[1][pair[0]],vor.vertices.T[1][pair[1]]],'r')
- pylab.xlim((0,1))
- pylab.ylim((0,1))
- pylab.show()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement