<h3 dir="auto">Bug summary</h3>
<p dir="auto">In jupyter lab, the code snippet below sets the title of the axis to the x,y coords of a mouse click, however in matplotlib 3.5.2 specifically, the clicks aren't registered unless I'm clicking around using the pan or zoom controls of the interactive widget. Downgrading to matplotlib 3.5.1, the clicks are registered with just the cursor as expected with the same ipympl version 0.9.1.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import matplotlib.pyplot as plt
%matplotlib widget

fig, ax = plt.subplots(figsize=(5,5))
plt.plot(np.random.randint(0, 5, 5))
plt.show()

def onclick(event):
    ax.set_title(f'x={event.x}, y={event.y}')
    print(f'x={event.x}, y={event.y}')

fig.canvas.mpl_connect('button_press_event', onclick)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-c1">%</span><span class="pl-s1">matplotlib</span> <span class="pl-s1">widget</span>

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">5</span>,<span class="pl-c1">5</span>))
<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randint</span>(<span class="pl-c1">0</span>, <span class="pl-c1">5</span>, <span class="pl-c1">5</span>))
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()

<span class="pl-k">def</span> <span class="pl-en">onclick</span>(<span class="pl-s1">event</span>):
    <span class="pl-s1">ax</span>.<span class="pl-en">set_title</span>(<span class="pl-s">f'x=<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">event</span>.<span class="pl-s1">x</span><span class="pl-kos">}</span></span>, y=<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">event</span>.<span class="pl-s1">y</span><span class="pl-kos">}</span></span>'</span>)
    <span class="pl-en">print</span>(<span class="pl-s">f'x=<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">event</span>.<span class="pl-s1">x</span><span class="pl-kos">}</span></span>, y=<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">event</span>.<span class="pl-s1">y</span><span class="pl-kos">}</span></span>'</span>)

<span class="pl-s1">fig</span>.<span class="pl-s1">canvas</span>.<span class="pl-en">mpl_connect</span>(<span class="pl-s">'button_press_event'</span>, <span class="pl-s1">onclick</span>)</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">No axis title after clicking inside the plot with just a regular cursor<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/26208374/180457943-08bf7053-0870-45bc-88c7-f22791d8d26a.png"><img width="514" alt="Screen Shot 2022-07-22 at 9 13 29 AM" src="https://user-images.githubusercontent.com/26208374/180457943-08bf7053-0870-45bc-88c7-f22791d8d26a.png" style="max-width: 100%;"></a></p>
<p dir="auto">Axis title set after clicking inside the plot with the pan tool of the interactive widget (same if using the zoom tool)<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/26208374/180457956-538d1a22-c741-483f-881e-94f710761529.png"><img width="518" alt="Screen Shot 2022-07-22 at 9 12 03 AM" src="https://user-images.githubusercontent.com/26208374/180457956-538d1a22-c741-483f-881e-94f710761529.png" style="max-width: 100%;"></a></p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">This screenshot was taken with mpl version 3.5.1 where the regular cursor click was registered and the axis title was changed<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/26208374/180458756-8db913fe-addc-428f-911b-d8232fa05133.png"><img width="519" alt="Screen Shot 2022-07-22 at 9 17 51 AM" src="https://user-images.githubusercontent.com/26208374/180458756-8db913fe-addc-428f-911b-d8232fa05133.png" style="max-width: 100%;"></a></p>
<h3 dir="auto">Additional information</h3>
<p dir="auto">It's also interesting that under mpl 3.5.2, the cursor remains as the finger cursor icon after clicking while in mpl 3.5.1, the cursor icon changes back to the regular pointer - I'm not sure what that means but it is a difference in behavior...</p>
<p dir="auto">Some relevant package versions:<br>
matplotlib 3.5.2<br>
ipympl 0.9.1<br>
jupyterlab 3.4.3</p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">reproduced on both Ubuntu and macOS</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.5.2</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">module://ipympl.backend_nbagg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.8.13</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto">3.4.3</p>
<h3 dir="auto">Installation</h3>
<p dir="auto">pip</p>
<h3 dir="auto">Bug summary</h3>
<p dir="auto">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 <code class="notranslate">pyplot</code> interface in an interactive IPython session. This has been observed with both <code class="notranslate">pyplot.plot</code> and <code class="notranslate">pyplot.tripcolor</code>. The figure will show the first plot drawn, but subsequent calls to <code class="notranslate">pyplot.plot</code> and <code class="notranslate">pyplot.tripcolor</code> fail to update an on-screen figure until <code class="notranslate">pyplot.draw</code> is invoked. This has been observed with IPython versions 8.3.0 (current) and 8.2.0.</p>
<p dir="auto">Both the Qt5 and Tk backends exhibit the same issues.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# 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()"><pre class="notranslate"><span class="pl-c"># Install matplotlib and ipython in a virtualenv</span>
<span class="pl-s1">python3</span> <span class="pl-c1">-</span><span class="pl-s1">m</span> <span class="pl-s1">venv</span> <span class="pl-c1">~</span><span class="pl-c1">/</span><span class="pl-s1">mpl</span>.<span class="pl-s1">venv</span>
. <span class="pl-c1">~</span><span class="pl-c1">/</span><span class="pl-s1">mpl</span>.<span class="pl-s1">venv</span><span class="pl-c1">/</span><span class="pl-s1">bin</span><span class="pl-c1">/</span><span class="pl-s1">activate</span>
<span class="pl-s1">pip</span> <span class="pl-s1">install</span> <span class="pl-s1">matplotlib</span> <span class="pl-s1">ipython</span>

<span class="pl-c"># Make sure to start with a clean config</span>
<span class="pl-s1">mv</span> <span class="pl-c1">~</span><span class="pl-c1">/</span>.<span class="pl-s1">ipython</span> <span class="pl-c1">~</span><span class="pl-c1">/</span>.<span class="pl-s1">ipython</span>.<span class="pl-s1">backup</span>
<span class="pl-s1">mv</span> <span class="pl-c1">~</span><span class="pl-c1">/</span>.<span class="pl-s1">config</span><span class="pl-c1">/</span><span class="pl-s1">matplotlib</span> .<span class="pl-s1">config</span><span class="pl-c1">/</span><span class="pl-s1">matplotlib</span>.<span class="pl-s1">backup</span>

<span class="pl-c"># Run `pylab`</span>
<span class="pl-s1">ipython</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">pylab</span><span class="pl-c1">=</span><span class="pl-s1">tk</span>

<span class="pl-c"># ... the following are commands issues in the ipython prompt</span>
<span class="pl-en">plot</span>(<span class="pl-en">arange</span>(<span class="pl-c1">10</span>))
<span class="pl-en">plot</span>(<span class="pl-c1">-</span><span class="pl-en">arange</span>(<span class="pl-c1">10</span>))
<span class="pl-en">draw</span>()</pre></div>
<h3 dir="auto">Actual outcome</h3>
<ol dir="auto">
<li>After the first <code class="notranslate">plot</code> command, a figure appears with a <code class="notranslate">y = x</code> line shown.</li>
<li>After the second <code class="notranslate">plot</code> command, the figure does not update.</li>
<li>After the <code class="notranslate">draw</code> command, the figure updates to show both the <code class="notranslate">y = x</code> and <code class="notranslate">y = -x</code> lines.</li>
</ol>
<h3 dir="auto">Expected outcome</h3>
<ol dir="auto">
<li>After the first <code class="notranslate">plot</code> command, a figure appears with a <code class="notranslate">y = x</code> line shown. (This is as expected.)</li>
<li>After the second <code class="notranslate">plot</code> command, the figure updates with the addition of a <code class="notranslate">y = -x</code> line. (This is the deviation.)</li>
<li>The <code class="notranslate">draw</code> command should produce no visible change in the figure.</li>
</ol>
<h3 dir="auto">Additional information</h3>
<p dir="auto">This regression has been bisected to commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/matplotlib/matplotlib/commit/f937b0ab5ef9d5ffe9f2f58f6391357783cc4afa/hovercard" href="https://github.com/matplotlib/matplotlib/commit/f937b0ab5ef9d5ffe9f2f58f6391357783cc4afa"><tt>f937b0a</tt></a>.</p>
<p dir="auto">The testbed is a current Void Linux system running Python 3.10.4, including the system <code class="notranslate">python3-tkinter</code> 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 <code class="notranslate">pip freeze</code> is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>
<p dir="auto">(Note that the funny <code class="notranslate">matplotlib</code> version comes from a local git repo checked out to the problematic commit.)</p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Void Linux x86_64</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.5.2</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">TkAgg, Qt5Agg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.10.4</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto">None</p>
<h3 dir="auto">Installation</h3>
<p dir="auto">pip</p>