python - 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”
任何人都可以帮忙吗?
解决方案
如果同时安装多个版本的 Plotly(例如通过 pip 和 conda),则可能会发生这种情况。如果您尝试使用这两种方法进行卸载,然后仅使用一种方法重新安装,这应该可以解决问题。
推荐阅读
- python - 如何按python中两个轴的最大值对列表进行排序?
- java - Java if 循环条件返回错误结果
- excel - 从网页中选择复选框和输入框以下载数据
- python - Python:如何从没有标题的csv中提取数据
- javascript - 带有jquery的Javascript高亮功能不起作用
- python - 有没有办法使用 cv2.approxPolyDP 来近似开放曲线?
- c - 在主循环外重复输入
- c++ - NS3 Socket混淆(需要帮助理解)
- excel - 如果语句部分未使用 UserForm 执行
- python - 无法将关键字“已创建”解析为字段。选项有:日期、id、post、user、user_id?