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

2024-09-28 19:03:38 发布

您现在位置:Python中文网/ 问答频道 /正文

如果我在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 lab上运行相同的代码

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

我该如何解决这个问题


Tags: 代码fromimportnumpyasnpjupyterplt
2条回答

嗨,只要在一个单元格中输入这个,然后运行它,它就会工作了

%matplotlib inline

首先,运行这个

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

在Jupyter笔记本中

import bqplot

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

相关问题 更多 >