I have several points (about 3000) and edges (about 6000) in this format:
points = numpy.array([1,2],[4,5],[2,7],[3,9],[9,2]) edges = numpy.array([0,1],[3,4],[3,2],[2,4])
where the edges are indices into points, so that the initial and final coordinates of each edge are specified:
points[edges]
I am looking for a faster / better way to build them. I currently have:
from matplotlib import pyplot as plt x = points[:,0].flatten() y = points[:,1].flatten() plt.plot(x[edges.T], y[edges.T], 'y-')
I read about lineCollections but don't know how to use them. Is there a way to use my data more directly? What is the bottleneck here?
Some more realistic test data, the time to build is about 132 seconds:
points = numpy.random.randint(0, 100, (3000, 2)) edges = numpy.random.randint(0, 3000, (6000, 2))