<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Using the nbagg backend with matplotlib in a jupyter notebook and plotting the figure inside a <code class="notranslate">ipywidgets.Output()</code> widget breaks the functionality of the "Stop Interaction" button. If pressed, nothing happens.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<p dir="auto">Use inside a jupyter notebook.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import ipywidgets as widgets
import matplotlib.pyplot as plt

%matplotlib notebook
# or %matplotlib nbagg

o = widgets.Output()
display(o)
with o:
    plt.plot(range(10), range(10))
    plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">ipywidgets</span> <span class="pl-k">as</span> <span class="pl-s1">widgets</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">notebook</span>
<span class="pl-c"># or %matplotlib nbagg</span>

<span class="pl-s1">o</span> <span class="pl-c1">=</span> <span class="pl-s1">widgets</span>.<span class="pl-v">Output</span>()
<span class="pl-en">display</span>(<span class="pl-s1">o</span>)
<span class="pl-k">with</span> <span class="pl-s1">o</span>:
    <span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-en">range</span>(<span class="pl-c1">10</span>), <span class="pl-en">range</span>(<span class="pl-c1">10</span>))
    <span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong><br>
Red circle added on the button for emphasis.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/59456929/106790033-4b810f00-6653-11eb-9f24-09be76ea250b.png"><img src="https://user-images.githubusercontent.com/59456929/106790033-4b810f00-6653-11eb-9f24-09be76ea250b.png" alt="Untitled" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/59456929/106790116-63589300-6653-11eb-97b1-e81bce1958d6.png"><img src="https://user-images.githubusercontent.com/59456929/106790116-63589300-6653-11eb-97b1-e81bce1958d6.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating system:  Linux 5.10.11-arch1-1</li>
<li>Matplotlib version: 3.3.4</li>
<li>Matplotlib backend: nbagg</li>
<li>Python version: 3.9.1</li>
<li>Jupyter version:
<ul dir="auto">
<li>jupyter core     : 4.6.3</li>
<li>jupyter-notebook : 6.2.0</li>
<li>qtconsole        : not installed</li>
<li>ipython          : 7.19.0</li>
<li>ipykernel        : 5.4.2</li>
<li>jupyter client   : 6.1.7</li>
<li>jupyter lab      : not installed</li>
<li>nbconvert        : 6.0.7</li>
<li>ipywidgets       : 7.6.2</li>
<li>nbformat         : 5.0.8</li>
<li>traitlets        : 5.0.5</li>
</ul>
</li>
</ul>
<p dir="auto">All Python related packages installed via pip.</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Plot not being displayed using notebook toolkit on the output widget depending on order of output.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>

<p dir="auto">cell 1:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="%matplotlib notebook
from matplotlib import pyplot as plt
import ipywidgets as wg"><pre class="notranslate"><span class="pl-c1">%</span><span class="pl-s1">matplotlib</span> <span class="pl-s1">notebook</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">import</span> <span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">ipywidgets</span> <span class="pl-k">as</span> <span class="pl-s1">wg</span></pre></div>
<p dir="auto">cell 2:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="test_out = wg.Output()
display(test_out)
with test_out:
    plt.figure()
    plt.plot([1,2,3])"><pre class="notranslate"><span class="pl-s1">test_out</span> <span class="pl-c1">=</span> <span class="pl-s1">wg</span>.<span class="pl-v">Output</span>()
<span class="pl-en">display</span>(<span class="pl-s1">test_out</span>)
<span class="pl-k">with</span> <span class="pl-s1">test_out</span>:
    <span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
    <span class="pl-s1">plt</span>.<span class="pl-en">plot</span>([<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>])</pre></div>
<p dir="auto">cell 3:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="test_out = wg.Output()
with test_out:
    plt.figure()
    plt.plot([1,2,3])
display(test_out)
"><pre class="notranslate"><span class="pl-s1">test_out</span> <span class="pl-c1">=</span> <span class="pl-s1">wg</span>.<span class="pl-v">Output</span>()
<span class="pl-k">with</span> <span class="pl-s1">test_out</span>:
    <span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
    <span class="pl-s1">plt</span>.<span class="pl-en">plot</span>([<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>])
<span class="pl-en">display</span>(<span class="pl-s1">test_out</span>)</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/33698726/83866191-1de46e80-a730-11ea-8bf3-5d6bf3926b04.png"><img src="https://user-images.githubusercontent.com/33698726/83866191-1de46e80-a730-11ea-8bf3-5d6bf3926b04.png" alt="mpl_bug" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">same output for cell 3  as cell 2:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/33698726/83866398-6bf97200-a730-11ea-859d-9d1e805c317b.png"><img src="https://user-images.githubusercontent.com/33698726/83866398-6bf97200-a730-11ea-859d-9d1e805c317b.png" alt="mpl_bug" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: win</li>
<li>Matplotlib version:  3.0.2</li>
<li>Matplotlib backend : nbAgg</li>
<li>Python version: Python 3.7.1</li>
<li>Jupyter version (if applicable): 5.7.4</li>
<li>Other libraries: ipywidgets 7.5.1</li>
</ul>