Skip to content

plot window hangs and/or is generally unresponsive #8505

Closed

Description

@bitworm

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

Activity

  1. bitworm commented on Apr 17, 2017

    @bitworm
    Author

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

  2. bitworm commented on Apr 17, 2017

    @bitworm
    Author

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

  3. bitworm commented on Apr 17, 2017

    @bitworm
    Author

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

  4. tacaswell commented on Apr 18, 2017

    @tacaswell
    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).

  5. bitworm commented on Apr 18, 2017

    @bitworm
    Author

    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.

  6. tacaswell commented on Apr 18, 2017

    @tacaswell
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions