See animating matplotlib axes / ticks and python matplotlib blit for axes or sides of a shape?
So the problem is that in the guts of the animation , where blit backgrounds are actually stored (line 792 animation.py ), it captures what's in the bounding box of the axes. This makes sense when you have several axes that are independently animated. In your case, you only have one axes to worry about, and we want to animate the material outside the bounding box of the axes. With a small number of monkey fixes, a level of tolerance for achieving mpl courage and a little gouging, and making the quickest and most dirty decision, we can solve your problem as such:
import matplotlib import matplotlib.pyplot as plt import matplotlib.animation as animation import numpy as np def _blit_draw(self, artists, bg_cache):
Note that this may not work as expected if your figure has several axes. A much better solution is to extend axes.bbox to capture header + axis labels. I suspect there is code somewhere in mpl, but I don't know where it is on my head.
source share