You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
matplotlib plots not showing when using "ipython --pylab" #14401
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.
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.
Screenshot of plot window
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).
Screenshot of plot window
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.
@alaniwi Thanks for reporting this, it is definitely a bug that I introduced in #14330.
The problem occurs using ipython --pylab or ipython --pylab=auto (the former is shorthand for the latter). But if you specify a GUI event loop then it works, so the workaround in your situation is to use ipython --pylab=qt.
Activity
ianthomas23 commentedon Apr 13, 2024
This might be due to #14330. I will investigate.
ianthomas23 commentedon Apr 13, 2024
@alaniwi Thanks for reporting this, it is definitely a bug that I introduced in #14330.
The problem occurs using
ipython --pylaboripython --pylab=auto(the former is shorthand for the latter). But if you specify a GUI event loop then it works, so the workaround in your situation is to useipython --pylab=qt.I have a fix, which will be in the next release.
Fix use of --pylab=auto and --matplotlib=auto (#14403)
alaniwi commentedon Apr 15, 2024
Great, thank you for the quick response.