首页 > 解决方案 > Plotly 地图未显示在 VS Code 中的 Jupyter Notebook 中

问题描述

堆栈!我正在尝试在 Python 中使用 plotly 绘制图形。具体来说:情节:地图,气泡图,Choropleth.. Python:3.9.6 情节:4.01 Jupyter Notebook:7.26 环境管理器:miniconda3 IDE:Ms. Visual Studio Code

我试图运行这样的代码:

import plotly
import plotly.offline as pyo
pyo.init_notebook_mode()
import plotly.graph_objs as go
import plotly.express as ex
df = ex.data.gapminder().query("year==2007")
fig = ex.choropleth(df, locations="iso_alpha",
                    color="lifeExp", # lifeExp is a column of gapminder
                    hover_name="country", # column to add to hover information
                    color_continuous_scale=ex.colors.sequential.Plasma)

这不是我的项目代码,只是我在 Plotly 网站 ( https://plotly.com/python/choropleth-maps/ ) 上找到的 Plotly Map 的示例代码,但它没有显示任何内容。

PS:我尝试从 conda 安装 plotly Jupyterlab 依赖项,我也尝试使用离线 plotly 但仍然没有出现。(只有绘图画布和图例,缺少地图)。虽然,当我尝试制作条形图时,它可以工作。高手帮帮我!!!!!!

标签: pythonvisual-studio-codeplotjupyter-notebookplotly

解决方案


推荐阅读