Animated matplotlib in wxPython, sizing / redrawing quirk

Hi, folks,

I will be posting this question to both matplotlib-users and
wxpython-users. Apologies to those of you who have to endure my
ramblings two times in a row!

Using this example by John Bender,

I recently constructed a working, animated matplotlib graph in a
wxPython frame. A sample output is here:

In that example, the text block is in wxPython, and the color bar for
the graph's Z scale is a bitmap object which is again handled by wx.
Only the live graph is rendered by matplotlib.
Once I accomplished this, I attempted a more complicated,
multiple-subplot display, this time with the text boxes handled my
matplotlib rather than wx. I also tried removing parts of Mr. Bender's
code that I thought that I would not need. Specifically, I've disabled
resizing of my matplotlib panel. But when I removed the code associated
with sizing, I discovered that my animation disappeared. The first
frame would draw, then nothing.

Digging deeper, I learned that redrawing is SOMEHOW accomplished in the
PlotPanel._SetSize method. _SetSize is called when there's a wx.IDLE
message. In _SetSize, you have to call PlotPanel.SetSize (note, no
underscore this time) and FigureCanvasWxAgg.SetSize on EVERY cycle to
make animation work. The matplotlib figure.set_size method needs only
to be called the first time -- at least, in my case, where I've disabled
resizing. I haven't tested a resizable window.

Here are my questions.

1) I do not recall seeing this kind of behavior in wxPython before. Why
does wxPython treat matplotlib objects differently?

2) How exactly is sizing making the redrawing happen? Is this a good
method to use? The indirect nature of this redrawing-by-sizing approach
sent me on a long and pointless hunt for bugs in my own code. Finally,
how can I determine how MUCH redrawing is taking place on my matplotlib
canvas? I am trying to implement eight image plots simultaneously, with
some overlaid contours, and some live text, too. But sometimes I only
have to update four of the eight plots, or just the text. Does
matplotlib know which parts of its image are "dirty" and confine its
updates appropriately?

Many thanks for your insights!

Following up to my own post:

First, Sourceforge's listserv did not like the link to my animation.
Let my try again, with a shortened link:


The indirect nature of this redrawing-by-sizing approach
sent me on a long and pointless hunt for bugs in my own code.

Putting this another way -- explicit is better than implicit!