Animation with many moving parts

I'm trying to do an animation which plots a large number of items on two dimensions, and then animates their positions over time. I have set up the plot with my dimensions on the axes and am using canvas.blit (as shown in one of the examples) to update my plot. I'm using text as the markers --- that is, I use the text function to display the label of each item (not just a point) at its location on the graph.

  The problem is that I have a large amount of data. There are over 100,000 "steps" in my time sequence (i.e., places where I might need to update the display because some item moved), and even though not all of those actually result in a change in the positions, there are still several thousand distinct items that need to be plotted and moved around. I'm currently buffering this a bit so that I only update on every Nth data point, but it's still rather slow.

  I can see one obvious, issue, but I'm not sure how to work around it. The thing is that a large number of the items don't actually move around very much over time, and even if one does move around relatively frequently, there may be long stretches where it doesn't. Yet, on every display update, I am redrawing all 1000+ artists. I feel like there should be some way to move only the points that need to be moved, but I'm not sure how to do it. My idea for how to improve it is that, for each display update, I would look at which bits of text actually do need to move, look at where they currently are, calculate which other texts overlap with those moving, then blit a blank rectangle onto the "old" positions of the moving items, and redraw only the moving items and those that were partially erased by the blank. This way items that were nowhere near any change wouldn't need to be redrawn.

  Is this feasible? Is there a standard way to go about this? Is there any way to figure out which artists overlap without looping over the list of all artists and checking the bbox bounds? Any other suggestions on how to do it?



Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail."
    --author unknown