Thanks to visit codestin.com
Credit goes to github.com

Skip to content

plot window hangs and/or is generally unresponsive #8505

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
bitworm opened this issue Apr 17, 2017 · 6 comments
Closed

plot window hangs and/or is generally unresponsive #8505

bitworm opened this issue Apr 17, 2017 · 6 comments

Comments

@bitworm
Copy link

bitworm commented Apr 17, 2017

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...
import matplotlib.pyplot as plt
plt.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.

Matplotlib version

  • Matplotlib 1.5.1 (latest with conda update matplotlib), python 2.7.11 (anaconda distr.), macos 10.12.4
@bitworm
Copy link
Author

bitworm commented 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
Copy link
Author

bitworm commented Apr 17, 2017

After further investigation, this appears to be from the plt.ion() call.

@bitworm
Copy link
Author

bitworm commented Apr 17, 2017

And somehow, %matplotlib solves this. What does this do exactly?

@tacaswell
Copy link
Member

#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).

@bitworm
Copy link
Author

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

Running %matplotlib in 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

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

2 participants