When plotting millions of points, counting the number of neighbors of each point is extremely slow. The current algorithm calculates the pairwise distance for all points. This could be optimized, for instance with this approach. Other ideas are welcome.