You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
after plotting using Qt4Agg backend in Mac OS, terminal gets slow, CPU increases #6038
Frequently, when I make plots in matplotlib using the Qt4Agg backend in the python shell in a default Mac OS terminal window, the CPU percentage gets high (as seen by Activity Monitor) and the terminal becomes laggy as I'm typing into it. The problem doesn't always occur (I can reproduce it maybe 50% of the time), but I've seen it after simply entering the following into the python shell
import matplotlib.pyplot as plt plt.figure()
and then, say, holding down "a" on the keyboard and seeing if the CPU jumps up to 30% or so. Generally, the problem seems to start only after I've created the first figure with plt.figure() (after importing matplotlib.pyplot as plt). (The plot isn't displayed in this case, but I've also had the problem in interactive mode after the plot is displayed.) The lagginess continues after the figure's closed and seems to get worse over time, basically making it difficult to continue until I restart the python shell. The CPU gets high (say, 30-120% rather than the usual 0-2%), but only when I'm typing or when it's processing the last thing I typed.
I do not have the problem with the TkAgg backend, though for the macosx backend I do have the different issue shown here: #5964. backend.qt4 was set to PyQt4 in the matplotlibrc file.
matplotlib version: 1.5.1
python 3.5.1, Anaconda 2.5.0 (x86_64)
(I just reinstalled Anaconda with python 3.5, but I've also had the issue with a previous Anaconda version for python 2.7.)
Mac OS X 10.11.3
I can reproduce the high CPU usage (15-30%) while holding down a key, after plt.figure(), and with qt4agg but not with tkagg. This is on Mavericks, in ipython.
It does not occur with %matplotlib, so the figure is displayed, however.
It does occur if I leave out the magic and use plt.ion() to display the figure.
Closing the figure doesn't help; the cpu usage remains high when holding a key down.
And now I am baffled, because when I try to reproduce the phenomenon in ipython, it is not happening.
Then I switch to the plain python console, and the CPU usage can go as high as 50%.
And there also, it doesn't always happen.
I wonder whether this is related to the rather long delay (many seconds, unless I get impatient and hit control-C) I sometimes encounter when exiting ipython after plotting.
Activity
efiring commentedon Feb 21, 2016
This is with the plain python shell? If so, does it also occur with the ipython shell?
js54434 commentedon Feb 21, 2016
I've just checked, and yes, it does happen with ipython.
tacaswell commentedon Feb 21, 2016
I wonder if it is related to readline being installed or not? The integration of the repl with an GUI event loop can be complex.
efiring commentedon Feb 22, 2016
I can reproduce the high CPU usage (15-30%) while holding down a key, after
plt.figure(), and with qt4agg but not with tkagg. This is on Mavericks, in ipython.It does not occur with
%matplotlib, so the figure is displayed, however.It does occur if I leave out the magic and use
plt.ion()to display the figure.Closing the figure doesn't help; the cpu usage remains high when holding a key down.
And now I am baffled, because when I try to reproduce the phenomenon in ipython, it is not happening.
Then I switch to the plain python console, and the CPU usage can go as high as 50%.
And there also, it doesn't always happen.
I wonder whether this is related to the rather long delay (many seconds, unless I get impatient and hit control-C) I sometimes encounter when exiting ipython after plotting.
tacaswell commentedon Feb 22, 2016
IPython does the event loop integration differently that pyqt4 does 'stock' (and that handling is installed via
%matplotlib).Can you reproduce this if you just make a qapp and create a window?
timhoffm commentedon Jul 14, 2020
Closing due to lack of response. Note that Qt4 was deprecated with Matplotlib 3.3.
Feel free to reopen if there is still an issue with Qt5.