Matplotlib in PyQt GUI - Need more FPS

If you can provide a few pointers to the relevant files in

    > the matplotlib source, I'll have a look and see what I can
    > do.

You will only need to modify one file
lib/matplotlib/backends/backend_qtagg and add the following three

    * background = canvas.copy_from_bbox(ax.bbox) - copy the region in
      ax.bbox into a pixel buffer and return it in an object type of
      your choosing. bbox is a matplotlib BBox instance from the [WWW]
      transforms module. background is not used by the matplotlib
      frontend, but it stores it and passes it back to the backend in
      the restore_region method. You will probably want to store not
      only the pixel buffer but the rectangular region of the canvas
      from whence it came in the background object.

    * canvas.restore_region(background) - restore the region copied
      above to the canvas.

    * canvas.blit(bbox) - transfer the pixel buffer in region bounded
      by bbox to the canvas.

The pixel buffer is provided by backend_agg's RendererAgg. QtAggg
inherits from Agg, so has access to these methods. GTKAgg, WXAgg and
TkAgg currently do the pixel transfer in extension code (see
src/_gtkagg.cpp, src/_tkagg.cpp and src/_wxagg.cpp) but this is not
necessary. For example, one can use the pygtk pixel buffer methods to
do the transfer and it would probably be as efficient, but this has
not been implemented yet. The hard part is to get all the vertical
offsets right, with the origin at the top versus bottom stuff worked

Take a look at the paintEvent method in FigureCanvasQtAgg which does
the pixel buffer of the entire agg buffer to the qt canvas. For
the "blit" method, you'll want to emulate this but transfer only the
region in the bbox. The bbox is a matplotlib.transforms.BBox
instance. See the docs at

Good luck, and feel free to ask questions!