-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
matplotlib plots not showing when using "ipython --pylab" #14401
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
Comments
This might be due to #14330. I will investigate. |
@alaniwi Thanks for reporting this, it is definitely a bug that I introduced in #14330. The problem occurs using I have a fix, which will be in the next release. |
Fixes #14401 which has been a bug in the 8.22.x and 8.23.x releases. When I removed the multiple initialisation of Matplotlib backends in #14330 it broke use of the following: ```bash ipython --matplotlib ipython --matplotlib=auto ipython --pylab ipython --pylab=auto ``` by failing to display Matplotlib plot. If you specify a particular GUI event loop such as using ```bash ipython --pylab=qt ``` then it was and is fine. So for anyone finding this, the workaround until the next release is to specify a GUI loop rather than relying on the auto selection. I didn't notice this as I've been concentrating on moving the Matplotlib backend logic from IPython to Matplotlib, and with those changes (matplotlib/matplotlib#27948) the above use cases all work OK. The fix is to reintroduce the early import of `matplotlib-inline` but only if both the gui loop is not specified and the Matplotlib version is before the movement of the backend logic across to it. There are no explicit tests for this. In the future I will try to think of some tests for some of this IPython-Matplotlib functionality that don't involve installing complicated backend dependencies or adding image comparison tests.
Great, thank you for the quick response. |
In versions of ipython up to 8.21.0, when invoked with
ipython --pylab
, matplotlib plots are displayed to the screen automatically, and without blocking. In later versions (8.22.* and 8.23.0), they are not, and can only be displayed usingplt.show(block=True)
.Here are steps to reproduce. This uses
pip
installation on Ubuntu for a simple example (where/usr/bin/python3
is python 3.10.12), although I have also observed the issue in conda environments on both Ubuntu and CentOS, based on python 3.11 and 3.12.1) Working example -- with ipython 8.21.0:
A plot appears on the screen automatically (without needing to call
plt.show
explicitly) -- and in non-blocking mode, so you can continue to type at the ipythonIn [2]:
prompt.Screenshot of plot window
2) Broken example with ipython 8.23.0:
ipython==8.23.0
In this case, a matplotlib window is opened, but it is black (with no plot).
Screenshot of plot window
If
plt.show()
orplt.show(block=False)
is typed, neither of these succeed in displaying the plot -- and ifplt.show(block=False)
is typed then not long afterwards a message from GNOME appears saying "matplotlib is not responding". The plot is only shown ifplt.show(block=True)
is typed, in which case, it blocks as requested (so no futher prompt is issued until the plot is closed).In these examples, matplotlib was version 3.8.4, although further experimentation shows that it does not seem to depend on the matplotlib version.
Please can you restore the behaviour that is obtained in earlier versions.
The text was updated successfully, but these errors were encountered: