jupyterlab interactive plot

2019-02-06 11:24发布

I'm getting into using Jupyterlab from Jupyter notebooks. In notebooks I used to use:

import matplotlib.pyplot as plt
%matplotlib notebook
plt.figure()
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)

for interactive plots. Which now gives me (in jupyterlab):

JavaScript output is disabled in JupyterLab

I have also tried the magic (with jupyter-matplotlib installed):

%matplotlib ipympl

But that just returns:

FigureCanvasNbAgg()

Inline plots:

%matplotlib inline

work just fine, but I want interactive plots.

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-06 12:01

As per Georgy's suggestion, this was caused by Node.js not being installed.

查看更多
够拽才男人
3楼-- · 2019-02-06 12:18

To enable the jupyter-matplotlib backend, use the matplotlib Jupyter magic:

%matplotlib widget
import matplotlib.pyplot as plt
plt.figure()
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)

More info here jupyter-matplotlib on GitHub

Screenshot Jupyter Lab

查看更多
登录 后发表回答