首页 > 解决方案 > Plotly AttributeError:“Figure”对象没有属性“update_traces”

问题描述

import plotly.graph_objects as go
colors = ['gold', 'mediumturquoise', 'darkorange', 'lightgreen']
fig = go.Figure(data=[go.Pie(labels= 
['ASIA','AFRICA','EUROPE','AMERICA'], 
values=[9000,20,12,5000])])
fig.update_traces(hoverinfo='label+percent', textinfo='value', 
textfont_size=20,
marker=dict(colors=colors, line=dict(color='#000000', width=2)))
fig.show()

我用 plotly 来制作图表。我需要从上面的代码制作一个图表,但它给出了错误

AttributeError:“Figure”对象没有属性“update_traces”

任何人都可以帮忙吗?

标签: pythonpython-2.7matplotlibplotly

解决方案


如果同时安装多个版本的 Plotly(例如通过 pip 和 conda),则可能会发生这种情况。如果您尝试使用这两种方法进行卸载,然后仅使用一种方法重新安装,这应该可以解决问题。


推荐阅读