使用旧的木星笔记本,我可以通过以下方式创建交互式情节:
import matplotlib.pyplot as plt
%matplotlib notebook
x = [1,2,3]
y = [4,5,6]
plt.figure()
plt.plot(x,y)但是,在JupyterLab中,这会产生一个错误:
JavaScript output is disabled in JupyterLab我也尝试过这种魔力(安装了jupyter-matplotlib ):
%matplotlib ipympl但这只是回报:
FigureCanvasNbAgg()内联绘图工作,但它们不是交互式情节:
%matplotlib inline发布于 2018-05-09 06:55:27
根据乔治的建议,这是由于没有安装Node.js造成的。
发布于 2019-04-25 11:41:50
JupyterLab 3.0+
jupyterlab和ipympl。
对于pip用户:
pip安装-升级jupyterlab ipympl
对于conda用户:
conda更新-c conda-伪造jupyterlab ipymplJupyterLab 2.0
nodejs,例如conda install -c conda-forge nodejs。ipympl,例如conda install -c conda-forge ipympl。conda update -c conda-forge jupyterlab==2.2.9==py_0。export JUPYTERLAB_DIR="$HOME/.local/share/jupyter/lab"。jupyter nbextension enable --py widgetsnbextension。%matplotlib widget装饰。发布于 2018-09-24 20:42:45
要启用jupyter-matplotlib后端,请使用matplotlib木星魔术:
%matplotlib widget
import matplotlib.pyplot as plt
plt.figure()
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)更多信息请访问GitHub上的jupyter-matplotlib

https://stackoverflow.com/questions/50149562
复制相似问题