jupyter-lab 中未显示动画 plotly-express 图

Animated plotly-express graph not showing up in jupyter-lab

以下示例生成一个可以用 jupyter notebook 显示的动画图形,但在 jupyter-lab 中该图形不会显示。

%pylab inline
import plotly.express as px
gapminder = px.data.gapminder()
px.scatter(gapminder, x="gdpPercap", y="lifeExp", animation_frame="year", animation_group="country",
           size="pop", color="continent", hover_name="country",
           log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90])

使用 plotly 4.0.0 和 plotly_express 0.4.0.

知道可能出了什么问题吗?

对于 JupyterLab 支持,有几个额外的安装步骤:https://plot.ly/python/getting-started/#jupyterlab-support-python-35

编辑:我们已将故障排除步骤整合到一份方便的指南中,网址为 https://plotly.com/python/troubleshooting/

按照以下步骤在 jupyter notebook 中显示绘图,请按照以下 link 查找有关以下命令及其用法的更多详细信息: JupyterLab Support for plotely

  1. pip install jupyterlab "ipywidgets>=7.5"
  2. jupyter labextension install jupyterlab-plotly@4.14.3
  3. jupyter labextension install @jupyter-widgets/jupyterlab-manager
  4. jupyter lab

这是因为Nbextension。在可配置的 nbextensions 中。您必须禁用 jupyterlab-plotly/extensionplotlywidget/extension。之后重启笔记本。希望有用。here is image of disable