擅长:python、mysql、java
<p>尝试:</p>
<p><code>%matplotlib notebook</code></p>
<p>见<a href="https://stackoverflow.com/users/2937831/jakevdp">jakevdp</a>回复
<a href="https://stackoverflow.com/a/33440743/1204331">here</a></p>
<p><strong>为JupyterLab用户编辑:</strong></p>
<p>按照<a href="https://github.com/matplotlib/jupyter-matplotlib#installation" rel="noreferrer">instructions</a>安装<a href="https://github.com/matplotlib/jupyter-matplotlib" rel="noreferrer">jupyter-matplotlib</a></p>
<p>然后不再需要上面的magic命令,如示例所示:</p>
<pre><code># Enabling the `widget` backend.
# This requires jupyter-matplotlib a.k.a. ipympl.
# ipympl can be install via pip or conda.
%matplotlib widget
# aka import ipympl
import matplotlib.pyplot as plt
plt.plot([0, 1, 2, 2])
plt.show()
</code></pre>
<p>最后,请注意Maarten Breddels'<a href="https://stackoverflow.com/a/44165156/1204331">reply</a>;IMHO<a href="https://github.com/maartenbreddels/ipyvolume" rel="noreferrer">ipyvolume</a>确实非常令人印象深刻(而且非常有用!)。</p>