Best shown with this simple example, the top subplot does not clear
with the call to restore_region. Any clues???
···
-------------------------------------------------------------
import matplotlib
matplotlib.use('TkAgg')
from pylab import *
ion()
ax1 = subplot(211, xlim=(0,1), ylim=(0,1))
ax2 = subplot(212, xlim=(0,1), ylim=(0,1))
canvas = ax1.figure.canvas
draw()
ax1bg = canvas.copy_from_bbox(ax1.bbox)
ax2bg = canvas.copy_from_bbox(ax2.bbox)
scat1 = None
scat2 = None
def animate(event):
global ax1bg, ax2bg, scat1, scat2, canvas
for i in xrange(150):
print i
x, y = rand(2,1)
if scat1 in ax1.collections: ax1.collections.remove(scat1)
if scat2 in ax2.collections: ax2.collections.remove(scat2)
scat1 = ax1.scatter(x, y, animated=True)
scat2 = ax2.scatter(x, y, animated=True)
canvas.restore_region(ax1bg)
canvas.restore_region(ax2bg)
ax1.draw_artist(scat1)
ax2.draw_artist(scat2)
canvas.blit(ax1.bbox)
canvas.blit(ax2.bbox)
ax1.figure.canvas.mpl_connect('draw_event', animate)
show()
-------------------------------------------------------------