8000 after plotting using Qt4Agg backend in Mac OS, terminal gets slow, CPU increases · Issue #6038 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

after plotting using Qt4Agg backend in Mac OS, terminal gets slow, CPU increases #6038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
js54434 opened this issue Feb 21, 2016 · 6 comments

Comments

@js54434
Copy link
js54434 commented Feb 21, 2016

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

@efiring
Copy link
Member
efiring commented Feb 21, 2016

This is with the plain python shell? If so, does it also occur with the ipython shell?

@js54434
Copy link
Author
js54434 commented Feb 21, 2016

I've just checked, and yes, it does happen with ipython.

@tacaswell
Copy link
Member

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
Copy link
Member
efiring commented 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
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0