【问题标题】:How to show Plotly figures in JupyterLab 3+?如何在 JupyterLab 3+ 中显示 Plotly 数字?
【发布时间】:2021-06-04 17:50:24
【问题描述】:

我正在运行 JupyterLab 3.0.6 和 Plotly 4.14.1。似乎所有的情节破折号插件都过时了?是否有任何适用于 JupyterLab 3 的扩展?

例如

import plotly.express as px
px.line([1,2,3,2])

只显示空输出。

【问题讨论】:

    标签: plotly jupyter-lab


    【解决方案1】:

    这个问题已经被一位情节开发者回答了。

    Plotly express is not rendered in jupyter lab

    编辑:该链接是旧的对不起。经过更多研究,看来 jupyter lab 3 目前与 plotly 不兼容。他们目前正在努力。

    https://community.plotly.com/t/jupyterlab-plotly-not-compatible-with-jupyterlab-3-0/48777

    【讨论】:

    • 当然,绘图是在 JupyterLab 中渲染的。例如。 Jupyter Lab 2.2.6 左右。我的问题是解决最新版本的 JupyterLab (3+)
    • 哦,对不起,我没有意识到那个帖子是 jupyter lab 2。我更新了我的答案。
    • JupyterLab 3 一直受到支持,从 plotly v5 开始得到更好的支持,并带有联合扩展 :)
    【解决方案2】:

    它现在正在工作。

    conda install -c plotly plotly=4.14.3
    conda install "notebook>=5.3" "ipywidgets>=7.5"
    jupyter labextension install jupyterlab-plotly@4.14.3
    # OPTIONAL: Jupyter widgets extension
    jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.14.3
    

    https://plotly.com/python/getting-started/

    【讨论】:

    • 如果 JupyterLab 3 确实需要这样做,则应该更新链接的指南。 The JupyterLab section 当前说 “jupyterlab>=3 和 ipywidgets>=7.6 包含运行 JupyterLab 所需的一切。” 然后它给出 labextension 命令“用于 JupyterLab 2 或更早版本。”
    【解决方案3】:

    要在 ubuntu 上的 JupyterLab 3 上安装 Plotly 需要安装 nodejs、npm 和 jupyterlab plotly 扩展

    instructions on the plotly 网站对我不起作用。该图被渲染为一个白色方块。我发现 jupyterlab plotly 扩展正在工作,但在 Ubuntu 上它依赖于 nodejs 和 npm。

    apt install nodejs npm
    jupyter labextension install jupyterlab-plotly 
    

    重新启动 jupyter,它应该像下面的示例一样工作。

    【讨论】:

    • 这在 plotly 的 5.x 版本中已经过时了
    【解决方案4】:

    正如评论中提到的 How to show Plotly figures in JupyterLab 3+? 使用 JupyterLab 3.x 和 Plotly 5.x labextension 安装 plotly 已过时。

    安装: https://plotly.com/python/getting-started/#installation

    【讨论】:

      猜你喜欢
      • 2020-07-27
      • 2020-05-15
      • 2020-10-17
      • 2021-02-13
      • 2016-05-20
      • 2018-09-07
      • 1970-01-01
      • 2021-01-09
      • 2018-10-31
      相关资源
      最近更新 更多