By the way, the animated gif at the head of this post was created using the following script. It's similar to above, except we add some extra frames to create the patrol-loop and the pause at each end.

Note that saving the animation as an animated gif requires both matplotlib version 1.3+ and the imagemagick command.