Here is an example using matplotlib.delaunay, which automatically 
returns the edges and triangules:



import matplotlib.delaunay as delaunay
import matplotlib.pyplot as pp

#generate points
npts=41
xpt=sp.random.random_sample(npts)
ypt=sp.random.random_sample(npts)
#create triangulation
circumcenters,edges,tri_points,tri_neighbors=delaunay.delaunay(xpt, ypt)
#plot using edges
pp.plot(xpt[edges.T],ypt[edges.T],'b-')

#following extracts same edges from triangles
#  but does not worry about repeating edges
from numpy import vstack
my_edges=vstack( (tri_points[:,0:2],
                  tri_points[:,1:],
                  tri_points[:,2::-2]) )
#plot the edges extracted (possibly multiple times) from triangles
pp.plot(xpt[my_edges.T],ypt[my_edges.T],'r--')


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to