[matplotlib-devel] Unnecessary rerendering in wx/wxagg backends

Gregor Thalhammer wrote:

for repainting a matplotlib figure, every time a repaint is done also the bitmap is rerendered:

# Render to the bitmap

You're quite right -- the paint handler should only blit to the PaintDC, which, in this case, is:


However, if I comment out that call to self.draw, I get a blank screen in a wxmpl app of mine. If I re-size the Window, then it gets draw ('cause the OnSize handler is re-drawing).

Also, in the same app, even when I call Figure.draw(), I'm notgetting it updated.

So it looks like there is code counting on this extra draw call.

I'll poke into it a bit more, it may be somethign we can fix in wxmpl, if there aren't issues elsewhere.


This also affects the behaviour of the wxagg backend.

yes, it looks like _onPaint is inherited from FigureCanvasWx, so it's the same issue.

  Rerendering and


therefore also repainting gets quite slow if, e.g., images are included in the figure. I can see this by simply dragging another window across the matplotlibfigure. Commenting out the rerendering I get a much smoother behaviour. I could not observe problems except that sometimes some parts of the figure are not properly repainted if the matplotlib figure is in the background (I only tested the wxagg backend). Therefore it seems that this rerendering every time a repaint is performed is not really necessary and should be avoided.

I tested this on matplotlib 0.91.2 on WinXP, Python 2.5, wx 2.8.7. I checked that in the current svn version the _onPaint() function is unchanged.


Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
Matplotlib-devel mailing list
matplotlib-devel List Signup and Options

Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception