Interactive mode broken in Qt4Agg backend? #1646

Closed
ycopin opened this Issue Jan 9, 2013 · 5 comments

Projects

None yet

3 participants

@ycopin
ycopin commented Jan 9, 2013

I used to make animated figures generated with scripts similar to the following one:

#!/usr/bin/env python

import numpy as N
import time

import matplotlib
matplotlib.use("Qt4Agg") # Not working
#matplotlib.use("WXAgg") # Buggy
#matplotlib.use("GTKAgg") # OK

import matplotlib.pyplot as P

P.ion()

fig,ax = P.subplots()

x = N.linspace(0,20)
line, = ax.plot(x, N.sin(x))

for i in range(25):
    print i
    time.sleep(.04)
    line.set_data(x, N.sin(x+i))
    P.draw()

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.

@jenshnielsen
Member

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.

@ycopin
ycopin commented Jan 9, 2013

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?

@tacaswell
Member

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)

@tacaswell
Member

@ycopin I am going to close this as I think it is resolved. Ping me if you disagree.

@tacaswell tacaswell closed this Nov 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment