I have some points (about 3000) and edges (about 6000) in this type of 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 start and end coordinates of each edges is given by:
points[edges]
I am looking for a faster / better way to plot them. Currently I have:
from matplotlib import pyplot as plt
x = points[:,0].flatten()
y = points[:,1].flatten()
plt.plot(x[edges.T], y[edges.T], 'y-') # Edges
plt.plot(x, y, 'ro') # Points
plt.savefig('figure.png')
I read about lineCollections, but am unsure how to use them. Is there a way to use my data more directly? What is the bottleneck here?
Some more realistic test data, time to plot is about 132 seconds:
points = numpy.random.randint(0, 100, (3000, 2))
edges = numpy.random.randint(0, 3000, (6000, 2))