-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
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 using plt.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:
$ python3 -m venv /tmp/myenv
$ . /tmp/myenv/bin/activate
(myenv) $ pip install pyqt5 numpy matplotlib ipython==8.21.0
(myenv) $ ipython --pylab
In [1]: plt.plot(np.arange(10)**2)
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 ipython In [2]: prompt.
2) Broken example with ipython 8.23.0:
- use the same commands as above, except
ipython==8.23.0
In this case, a matplotlib window is opened, but it is black (with no plot).
If plt.show() or plt.show(block=False) is typed, neither of these succeed in displaying the plot -- and if plt.show(block=False) is typed then not long afterwards a message from GNOME appears saying "matplotlib is not responding". The plot is only shown if plt.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.

