I'm trying to make an interactive GUI using MatPlotLib, and the thing users notice most is the latency between, say, changing a slider, and the GUI responding.
Currently, I am using plt.draw()
at the end of every event, which works well, except for the fact that it causes 256ms
of the function's 259ms
runtime.
In researching alternatives to plt.draw()
, I came across this post: why is plotting with Matplotlib so slow? , in which it was recommended to use fig.canvas.blit(ax1.bbox)
as an alternative which reloads just the graph, and not the entire figure.
When I use this, the event handler runs in 3ms
, however the GUI updates during the following event, rather than at the end of the current event as if the event was caught in a buffer: User input 1
>pause
>User input 2
>GUI responds to input 1
>pause
>User input 3
>GUI responds to input 2
, making the program unusable.
So what alternatives do I have? Fixing either one of these problems would allow me to run a very fast GUI. I'll post code if you need it.
Note 1: When using fig.canvas.blit(ax1.bbox)
, the sliders, buttons, etc will change immediately, and only the subplots will behave as described above.
Note 2: fig.canvas.draw_idle()
, as used in the widgets example here http://matplotlib.org/examples/widgets/slider_demo.html, and fig.canvas.draw()
, perform identically to plt.draw()