首页 > 解决方案 > 使用 plotly 时出现以下错误。AttributeError:模块'plotly.graph_objects'没有属性'figure'

问题描述

下面是我来自 Jupyter Notebook 的代码。

import chart_studio.plotly as py
import plotly.graph_objects as go
init_notebook_mode(connected=True)
data = dict(type='choropleth',
            locations=['CA', 'NY', 'AZ'],
            locationmode='USA-states',
           colorscale='ylorbr',
           text=['text1','text2','text3'],
           z=[1.0, 2.0, 3.0],
           colorbar={'title':'ColorbarTitle'})
#text- which hovers over all the locations
layout=dict(geo={'scope':'usa'})
choromap = go.figure(data=[data], layout=layout)

我已经完成了以下步骤: pip install chart-studio pip install ipywidgets

使用的绘图版本:4.7.1

以下是错误跟踪: AttributeError:模块'plotly.graph_objects'没有属性'figure'

我发现最近的是以下链接: https ://community.plotly.com/t/attributeerror-module-plotly-graph-objs-has-no-attribute-figurewidget-after-upgrading-to-plotly-4- 7/39034

还尝试了以下方法: from plotly import graph_objects as go

提前致谢..

标签: pythonplotly

解决方案


推荐阅读