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
plot window hangs and/or is generally unresponsive #8505
To help us understand and resolve your issue, please fill out the form to the best of your ability. You can feel free to delete the sections that do not apply.
Bug report
Bug summary
Interactive code example from documentation produces hanging/unresponsive window, frequently stuck behind other windows.
Code for reproduction
from matplotlib documentation here
#backend set to TkAgg, others also error...importmatplotlib.pyplotaspltplt.ion()
plt.plot([1.6, 2.7])
Actual outcome
Figure window appears, is unresponsive and no plot is shown. Figure cannot be moved, will go to background (cmd tab will not bring window to top). Within seconds the cursor becomes unresponsive "beachball" when over the figure window.
Expected outcome
A (non hanging, cmd-tabbable) plot window with something plotted. This error has persisted for some time.
Similar behavior has been reported long ago, without resolution: spyder-ide/spyder#2022. I have tried every available backend without satisfactory results. Any workarounds welcome...
#4779 (which I really need to finish and get merged) has some of the gory details. In short:
get get a responsive GUI + a prompt you have get two infinite loops to play nice (the one waiting for you to type and the GUI event loop waiting for you to interact with the figure (well, waiting for the window system to tell it you interacted with the figure))
Some semi-subtle jiggery-pokery needs to happen to set it up so they do play nice, and that is done by %matplotlib.
This is exasperated by IPython changing from using readline (which tk actually properly register's it's self with automatically on import) to prompt toolkit (which has a different registration method). Your example should work older versions of IPython or the vanilla python prompt.
Closing this as it is not a bug in matplotlib (but with integrating your GUI with IPython).
thanks @tacaswell. I have been futzing with this for way too long. Does anyone compile up-to-date recommended matplotlib setups? I have a very standard computing configuration, yet there is a swirling mass of out-of-date solutions floating around Stack Overflow, Github, blogs etc (e.g., %pyplot) making it difficult to find an "orthodox" setup that functions well.
Activity
bitworm commentedon Apr 17, 2017
Similar behavior has been reported long ago, without resolution: spyder-ide/spyder#2022. I have tried every available backend without satisfactory results. Any workarounds welcome...
bitworm commentedon Apr 17, 2017
After further investigation, this appears to be from the
plt.ion()call.bitworm commentedon Apr 17, 2017
And somehow,
%matplotlibsolves this. What does this do exactly?tacaswell commentedon Apr 18, 2017
#4779 (which I really need to finish and get merged) has some of the gory details. In short:
%matplotlib.This is exasperated by IPython changing from using readline (which tk actually properly register's it's self with automatically on import) to prompt toolkit (which has a different registration method). Your example should work older versions of IPython or the vanilla python prompt.
Closing this as it is not a bug in matplotlib (but with integrating your GUI with IPython).
bitworm commentedon Apr 18, 2017
thanks @tacaswell. I have been futzing with this for way too long. Does anyone compile up-to-date recommended matplotlib setups? I have a very standard computing configuration, yet there is a swirling mass of out-of-date solutions floating around Stack Overflow, Github, blogs etc (e.g.,
%pyplot) making it difficult to find an "orthodox" setup that functions well.tacaswell commentedon Apr 18, 2017
Running
%matplotlibin IPython will work correctly on all reasonably modern ipython/matplotlib version combinations, see http://ipython.org/ipython-doc/stable/interactive/reference.html#plotting-with-matplotlib