I made a little video player using matplotlib. I need it to allow very good control over the playback speed (e.g. direction, frame-by-frame stepping and fast and slow).
However, it’s not very fast. Max frame rate I can achieve is 10-20 fps.
I followed Basti’s advice on speeding up plotting (http://bastibe.de/2013-05-30-speeding-up-matplotlib.html).
This resulted in a more than 2x improvement (from <5 to 10-20 fps), but I would like to reach 40-50 fps.
The core code is something like this:
self.ax.draw_artist([self.im](http://self.im)) self.ax.draw_artist(self.text) self.im.figure.canvas.update() self.im.figure.canvas.flush_events()
video_frame is a 200 x 250 array. I tried lowering dpi from 100 to 50, but the improvement is marginal.
I saw that Harden (http://www.swharden.com/wp/2013-04-15-fixing-slow-matplotlib-in-pythonxy/) recommended using TkAgg over Qt4Agg since TkAgg is supposed to be faster.
But, TkAgg doesn’t play nicely with figure.canvas.update(). I get the following error:
AttributeError: ‘FigureCanvasTkAgg’ object has no attribute ‘update’
It works with Qt4Agg though.
Does anyone have a fix for this? Or some general advice on how to speed up playback speed?
I tried with both matplotlib 1.5.1 and the current version from github 2.0.0b4+2373.gb34c55d