FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

plt.ioff() not suppressing figure generation · Issue #14950 · matplotlib/matplotlib · GitHub

Repository navigation

plt.ioff() not suppressing figure generation #14950

Closed

Description

Bug report

Bug summary
Usual behaviour for supressing plots (by enabling plt.ioff()) no longer working since update to latest version of conda.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

x = np.random.rand(10)
y = np.random.rand(10)

plt.ioff()
plt.plot(x, y)

Actual outcome
In Spyder IDE, still generates figure window.

Expected outcome
Figure window should not appear. plt.ioff() should disable interactive mode, and require a plt.show() call to generate figure window.

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 3.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.7.3
  • Jupyter version (if applicable):
  • Other libraries: numpy 1.16.4

conda

Default channel (via https://www.anaconda.com/distribution/ )

Activity

  1. WeatherGod commented on Aug 1, 2019

    Member
  2. ImportanceOfBeingErnest commented on Aug 1, 2019

    Member

    Spyder does not have its own backend (PyCharm has, though).
    However, spyder has a "Support for grahics (Matplotlib)" mode, which is probably turned on by default.

    Many people like this mode, because it allows to choose a backend on a by-file- or by-project basis etc., but support for consequences of using this should probably directed towards Spyder.

  3. Yoshi2112 commented on Aug 2, 2019

    Author

    @ImportanceOfBeingErnest

    If I force inline plots by disabling Matplotlib support in Spyder, the interactive mode works correctly. Inline also works correctly when manually selected as the graphics backend.

    The other modes don't work as I'd expect. I'd always used the "Automatic" setting, which would probably be Qt5. Manually selecting Qt5 had the behaviour described in the OP - plt.ioff() failed to suppress the generation of a figure window.

    Of the other two modes, Qt4 failed to run because Qt5 was running (?), and Tkinter was successfully suppressed, but failed to display a plot when interactive mode was selected. A figure window was generated, but frozen. This might be an issue with missing modules or something though? I'm not exactly a dev.

    Is this a problem with matplotlib? Or perhaps an issue with the Spyder IDE failing to adhere to the interactive mode settings?

  4. ccordoba12 commented on Aug 2, 2019

    Chiming in in behalf of Spyder. We set the Matplotlib backend using the %matplotlib IPython magic, so if there's a problem it's with that magic.

  5. ImportanceOfBeingErnest commented on Aug 2, 2019

    Member

    Indeed it doesn't look like a Spyder issue. I was able to reproduce solemnly on the Ipython QtConsole, running

    Now it turns out this is indeed a matplotlib issue.
    It bisects to #13664 ("Backport PR #12637 on branch v3.1.x (Tell IPython the correct GUI event loop to use for all backends.)"), and hence originates from

    #12637 ("Tell IPython the correct GUI event loop to use for all backends.")

  6. added this to the v3.1.2 milestone on Aug 2, 2019
  7. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Aug 2, 2019
  8. tacaswell commented on Aug 2, 2019

    Member

    Suspect that ipython/ipython#11837 is also related.

  9. tacaswell commented on Aug 2, 2019

    Member

    I suspect that if you call plt.ioff() after you have created the first figure it will work as expected.

  10. ImportanceOfBeingErnest commented on Aug 2, 2019

    Member

    Yes, but that's not really an option if you want to run your whole code in one cell, like e.g. spyder does.

  11. Carreau commented on Aug 5, 2019

    Contributor

    See #14979 for the fix of the IPython side issue; and thomas is right that the piece of code that is responsible for the IPython-side-issue seem to also enable matplotlib gui integration and switch back to interactive.

    It seem to be triggered as a side effect of import matplotlib.pyplot as plt So we should likely detect that the %matplotlib magic has been called and not trigger the ip.enable_maplotlib()

  12. added a commit that references this issue on Aug 5, 2019
    d66a760
  13. changed the title [-]plt.ioff() not supressing figure generation[/-] [+]plt.ioff() not suppressing figure generation[/+] on Jun 23, 2025
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

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL