I used to make animated figures generated with scripts similar to the following one:
import numpy as N
matplotlib.use("Qt4Agg") # Not working
#matplotlib.use("WXAgg") # Buggy
#matplotlib.use("GTKAgg") # OK
import matplotlib.pyplot as P
fig,ax = P.subplots()
x = N.linspace(0,20)
line, = ax.plot(x, N.sin(x))
for i in range(25):
It works fine with GTKAgg backend, but does not work with QT4Agg one: the figure just flashes at the end of the animation!
Is it a bug in Qt4Agg, or an unimplemented feature? Is there any way other than switching back to GTKAgg specifically?
PS: I know about the recent Animation module, but I don't want to update all my scripts to this new framework.
Try using plt.pause instead of time.sleep (ref: http://stackoverflow.com/questions/12822762/pylab-ion-in-python-2-matplotlib-1-1-1-and-updating-of-the-plot-while-the-pro/12826273#12826273 )
I believe this is the same issue as #1451 and I can confirm that using plt.pause rather than plt.draw and time.sleep resolved the issue in the QT4 backend. Both work fine in the GTK backend.
Indeed it does work with pyplot.pause in place of pyplot.draw, even though it generates a DeprecationWarning:
backend_bases.py:2277: DeprecationWarning: Using default event loop until function specific to this GUI is implemented
But is it a workaround of a true Qt4Agg backend bug, and a deeper change in the matplotlib API? In the later case, what is the utility of draw in interactive mode?
From https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_qt4.py#L363 and the documentation at https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backend_bases.py#L2289 I would say that warning is more of a issue with the qt4 backend not being complete and would not worry about it too much (but maybe fixing this should get it's own issue)
@ycopin I am going to close this as I think it is resolved. Ping me if you disagree.