【问题标题】:Issue with Plotly情节问题
【发布时间】:2020-11-11 20:34:39
【问题描述】:

我使用以下代码在 python 中绘制了一个图形,但它确实返回了任何东西。有谁知道为什么会这样?我该如何解决?谢谢。

import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
fig.show() 

【问题讨论】:

  • 它会抛出什么错误?
  • 它确实返回任何错误。

标签: plotly


【解决方案1】:

如果您在 Jupyter Notebook 中运行它,那么您需要安装扩展。

请参阅 repo 的自述文件中的以下内容:

Jupyter 笔记本支持

要在 Jupyter Notebook 中使用,请安装 notebookipywidgets 使用 pip 的包...

pip install "notebook>=5.3" "ipywidgets==7.5"

或康达。

conda install "notebook>=5.3" "ipywidgets=7.5"

JupyterLab 支持(Python 3.5+)

要在 JupyterLab 中使用,请安装 jupyterlabipywidgets 使用 pip 的包...

pip install jupyterlab "ipywidgets==7.5"

或康达。

conda install jupyterlab "ipywidgets=7.5"

然后运行以下命令安装所需的 JupyterLab 扩展(注意这将需要安装 node):

# Basic JupyterLab renderer support
jupyter labextension install jupyterlab-plotly@4.9.0

# OPTIONAL: Jupyter widgets extension for FigureWidget support
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.9.0

如果您在使用 JupyterLab 时遇到任何问题,请查看我们的 Troubleshooting guide

【讨论】:

  • 非常感谢您的回答!它运作良好。非常感谢您的帮助。
  • 很高兴为您提供帮助,艾米 - 请记住,如果您觉得有用,您可以接受答案
猜你喜欢
  • 2021-02-20
  • 1970-01-01
  • 2016-08-25
  • 2014-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多