Another observation/example. Depending on the order of the axes, the
last one is the only one that acts correctly. So I don't think it is
a coord issue.
-------------------------------------------------------------
import matplotlib
from pylab import *
ion()
axs =3D [subplot(221+i, xlim=3D(0,1), ylim=3D(0,1)) for i in xrange(4)]
canvas =3D gcf().canvas
draw()
bgs =3D [canvas.copy_from_bbox(ax.bbox) for ax in axs]
scats =3D [None for ax in axs]
def animate(event):
global canvas, axs, bgs, scats
order =3D [3,0,2,1]
for i in xrange(150):
print i
x, y =3D rand(2,1)
for i in order:
if scats[i] in axs[i].collections: axs[i].collections.remove(scat=
s[i])
for i in order:
scats[i] =3D axs[i].scatter(x, y, animated=3DTrue)
for i in order:
canvas.restore_region(bgs[i])
for i in order:
axs[i].draw_artist(scats[i])
for i in order:
canvas.blit(axs[i].bbox)
canvas.mpl_connect('draw_event', animate)
show()
-------------------------------------------------------------
On 12/14/05, Charlie Moad <cwmoad@...> wrote:
> Correction, this is Agg specific. Not limited to Tk.
>
> On 12/14/05, Charlie Moad <cwmoad@...> wrote:
> > 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 =3D subplot(211, xlim=3D(0,1), ylim=3D(0,1))
> > ax2 =3D subplot(212, xlim=3D(0,1), ylim=3D(0,1))
> > canvas =3D ax1.figure.canvas
> >
> > draw()
> > ax1bg =3D canvas.copy_from_bbox(ax1.bbox)
> > ax2bg =3D canvas.copy_from_bbox(ax2.bbox)
> > scat1 =3D None
> > scat2 =3D None
> >
> > def animate(event):
> > global ax1bg, ax2bg, scat1, scat2, canvas
> >
> > for i in xrange(150):
> > print i
> > x, y =3D rand(2,1)
> > if scat1 in ax1.collections: ax1.collections.remove(scat1)
> > if scat2 in ax2.collections: ax2.collections.remove(scat2)
> > scat1 =3D ax1.scatter(x, y, animated=3DTrue)
> > scat2 =3D ax2.scatter(x, y, animated=3DTrue)
> >
> > 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()
> > -------------------------------------------------------------
> >
>
|