Description
Bug summary
A regression between release versions 3.5.1 and 3.5.2 causes figures to fail to redraw after an initial plot is added using the pyplot
interface in an interactive IPython session. This has been observed with both pyplot.plot
and pyplot.tripcolor
. The figure will show the first plot drawn, but subsequent calls to pyplot.plot
and pyplot.tripcolor
fail to update an on-screen figure until pyplot.draw
is invoked. This has been observed with IPython versions 8.3.0 (current) and 8.2.0.
Both the Qt5 and Tk backends exhibit the same issues.
Code for reproduction
# Install matplotlib and ipython in a virtualenv
python3 -m venv ~/mpl.venv
. ~/mpl.venv/bin/activate
pip install matplotlib ipython
# Make sure to start with a clean config
mv ~/.ipython ~/.ipython.backup
mv ~/.config/matplotlib .config/matplotlib.backup
# Run `pylab`
ipython --pylab=tk
# ... the following are commands issues in the ipython prompt
plot(arange(10))
plot(-arange(10))
draw()
Actual outcome
- After the first
plot
command, a figure appears with ay = x
line shown. - After the second
plot
command, the figure does not update. - After the
draw
command, the figure updates to show both they = x
andy = -x
lines.
Expected outcome
- After the first
plot
command, a figure appears with ay = x
line shown. (This is as expected.) - After the second
plot
command, the figure updates with the addition of ay = -x
line. (This is the deviation.) - The
draw
command should produce no visible change in the figure.
Additional information
This regression has been bisected to commit f937b0a.
The testbed is a current Void Linux system running Python 3.10.4, including the system python3-tkinter
package for a GUI. (As noted above, this bug is also present with the Qt5 backend.) All packages were installed in a virtual environment. The output of pip freeze
is:
asttokens==2.0.5
backcall==0.2.0
cycler==0.11.0
decorator==5.1.1
executing==0.8.3
fonttools==4.33.3
ipython==8.3.0
jedi==0.18.1
kiwisolver==1.4.2
matplotlib==3.6.0.dev155+gf937b0ab5e
matplotlib-inline==0.1.3
numpy==1.22.3
packaging==21.3
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.1.0
prompt-toolkit==3.0.29
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.12.0
pyparsing==3.0.9
python-dateutil==2.8.2
setuptools-scm==6.4.2
six==1.16.0
stack-data==0.2.0
tk==0.1.0
tomli==2.0.1
traitlets==5.2.0
wcwidth==0.2.5
(Note that the funny matplotlib
version comes from a local git repo checked out to the problematic commit.)
Operating system
Void Linux x86_64
Matplotlib Version
3.5.2
Matplotlib Backend
TkAgg, Qt5Agg
Python version
3.10.4
Jupyter version
None
Installation
pip