7

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()

Community
  • 1
  • 1
NGXII
  • 407
  • 2
  • 9
  • 18
  • If you are on Windows, are you using the latest matplotlib version? There was some kind of a bug that made the rendering slow under Windows (https://github.com/matplotlib/matplotlib/issues/2559/). – Jean-Sébastien Aug 15 '15 at 04:25
  • Unfortunately I am using MacOSX at the moment – NGXII Aug 15 '15 at 04:28
  • I'd recommend using PyQtGraph instead. It uses C++ as its backend, so it's a lot faster than Matplotlib: https://nrecursions.blogspot.com/2019/09/realtime-plotting-in-python.html – Nav Dec 08 '19 at 12:25

0 Answers0