Alb*_*oss 26 python matplotlib jupyter-lab
我正在使用Jupyter笔记本中的Jupyterlab.在我曾经使用的笔记本中:
import matplotlib.pyplot as plt
%matplotlib notebook
plt.figure()
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)
Run Code Online (Sandbox Code Playgroud)
用于交互式情节.现在给了我(在jupyterlab中):
JavaScript output is disabled in JupyterLab
Run Code Online (Sandbox Code Playgroud)
我也尝试了魔术(安装了jupyter-matplotlib):
%matplotlib ipympl
Run Code Online (Sandbox Code Playgroud)
但那只是回归:
FigureCanvasNbAgg()
Run Code Online (Sandbox Code Playgroud)
内联图:
%matplotlib inline
Run Code Online (Sandbox Code Playgroud)
工作得很好,但我想要互动情节.
Mat*_*haq 14
nodejs,例如conda install nodejs。ipympl,例如pip install ipympl。pip install --upgrade jupyterlab。export JUPYTERLAB_DIR="$HOME/.local/share/jupyter/lab"。安装扩展程序:
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
Run Code Online (Sandbox Code Playgroud)启用小部件:jupyter nbextension enable --py widgetsnbextension。
%matplotlib widget。不推荐使用,但是要盲目地在Anaconda中使用小部件扩展,可以在终端窗口中运行以下命令:
conda install -y nodejs
pip install ipympl
pip install --upgrade jupyterlab
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
jupyter nbextension enable --py widgetsnbextension
Run Code Online (Sandbox Code Playgroud)
要启用jupyter-matplotlib后端,请使用matplotlib Jupyter魔术:
%matplotlib widget
import matplotlib.pyplot as plt
plt.figure()
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)
Run Code Online (Sandbox Code Playgroud)
更多信息在这里GitHub上的jupyter-matplotlib
我以前曾多次使用Mateen的答案,但是当我使用 JupyterLab 3.0.7 尝试它们时,我发现jupyter labextension install @jupyter-widgets/jupyterlab-manager返回了一个错误并且我损坏了小部件。
经过很多头痛和谷歌搜索之后,我想我会为发现自己在这里的任何其他人发布解决方案。
现在简化了步骤,我能够使用以下内容重新开始工作交互式绘图:
pip install jupyterlabpip install ipympl%matplotlib widget第 2 步将自动处理其余的依赖项,包括(现在折旧?) @jupyter-widgets/jupyterlab-manager
希望这可以为其他人节省一些时间!
| 归档时间: |
|
| 查看次数: |
25067 次 |
| 最近记录: |