I wrote once before
(http://sourceforge.net/mailarchive/message.php?msg_id=12093643) about
some new methods for animation that can enable fast animations in
matplotlib, which can support everything from dynamically updating
your data to strip charts to real time cursoring to a widget like
canvas.
So far, only GTKAgg has complete support for the required methods. I
think it would be nice to have these in the major mpl GUI backends,
since it would make the animation interface much simpler and cleaner
if we could rely on them in the frontend, eg in the Axes class.
I just posted an entry on the wiki about matplotlib animations. It
starts with regular "pylab" animations, and then discusses GUI
animations using timers and event handlers, and finally the newfangled
methods to support per-artist animations.
As it turns out, for the *Agg backends, only one new method needs to
be added, which is
canvas.blit(bbox)
This method transfers the agg canvas within the bounding box onto the
GUI canvas. I realize that I need to add something like
aggcanvas.as_rgba_str(bbox)
to support this for Qt and WX which are currently using string methods
to blit to canvas. I'm happy to do this in the next couple of days if
I know that someone is interested in actually implementing
canvas.blit(bbox) for their respective backend.
To see the utility of the new methods, run examples/widgets/cursor.py
and examples/widgets/span_selector.py modified to set useblit=True,
and compare the performance of anim.py with examples/animation_blit.py
which animate the same data. All of the above should be run done with
the GTKAgg backend.
As noted on the wiki entry, with these methods in place, users who
want to do per artist animation could write code like
line, = ax.plot(something, animated=True)
canvas.draw()
def callback(*args):
line.set_ydata(somedata)
ax.draw_animated()
This *doesn't* work now, because I am hesitant to put methods into
Axes which would break most backends. The equivalent in
animation_blit.py is considerably more complicated.
Perhaps someone at STScI could sign up for implementing
canvas.blit(bbox) for TkAgg, and someone at JPL for the Qt backend? I
might take a crack at WX, if noone else wants it Steve, Gregory
and Charles, if you are interested in animation for your respective
backends, I encourage you to take a look at this too. Those of you
using the agg buffer in extension code (eg tkagg) may want to look at
src/_gtkagg.cpp to see how the bbox and the agg buffer are used to
implement blit, which defaults to blitting the entire canvas if
blit=None.
All of this is discussed in more depth at
http://www.scipy.org/wikis/topical_software/Animations
Thanks!
JDH