图和小部件未在jupyter实验室上显示

时间:2020-06-16 13:39:51

标签: python 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…

我该如何解决?

2 个答案:

答案 0 :(得分:1)

首先,运行它。

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

在Jupyter笔记本中

import bqplot

然后重新启动jupyter实验室。你准备好了!

答案 1 :(得分:0)

您好,只需在单元格中键入此代码,然后运行它,它就可以正常工作!

%matplotlib inline