jupyter lab 上未显示绘图和小部件

Plots and widgets not showing on jupyter lab

如果我运行这个代码在jupyter notebook

from bqplot import pyplot as plt
import numpy as np

plt.figure(1, title='Line Chart')
np.random.seed(0)
n = 200
x = np.linspace(0.0, 10.0, n)
y = np.cumsum(np.random.randn(n))
plt.plot(x, y)
plt.show()

绘图显示,但如果我 运行 在 Jupyter 实验室上使用相同的代码,我会得到

VBox(children=(Figure(axes=[Axis(scale=LinearScale()), Axis(orientation='vertical', scale=LinearScale())], fig…

我该如何解决这个问题?

您好,只需在单元格中键入此内容,然后 运行 它,它应该可以工作!

%matplotlib inline

首先,运行这个。

$ pip install bqplot
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager 
$ jupyter labextension install bqplot

在 Jupyter 笔记本中

import bqplot

然后重启jupyter lab。你准备好了!