If I remember correctly, Spyder has its own backend, right? I wonder if
they aren't properly recognizing `ioff()`? Does the same issue happen when
running the code from a vanilla python interface?
On Thu, Aug 1, 2019 at 12:04 AM Yoshi2112 ***@***.***> wrote:
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 npimport 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. Disabling
*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/ )
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#14950?email_source=notifications&email_token=AACHF6AKPBEVDATEUY22WHTQCJOGJA5CNFSM4IIMQMPKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HCW6HVQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACHF6GWJQR3GZ3PB7K6NWLQCJOGJANCNFSM4IIMQMPA>
.
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.
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?
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.")
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()
Activity
WeatherGod commented on Aug 1, 2019
ImportanceOfBeingErnest commented on Aug 1, 2019
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.
Yoshi2112 commented on Aug 2, 2019
@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?
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.
ImportanceOfBeingErnest commented on Aug 2, 2019
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.")
tacaswell commented on Aug 2, 2019
Suspect that ipython/ipython#11837 is also related.
tacaswell commented on Aug 2, 2019
I suspect that if you call plt.ioff() after you have created the first figure it will work as expected.
ImportanceOfBeingErnest commented on Aug 2, 2019
Yes, but that's not really an option if you want to run your whole code in one cell, like e.g. spyder does.
Carreau commented on Aug 5, 2019
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()
FIX: preserve interactive state around ip.enable_matplotlib()