【发布时间】:2022-07-22 22:39:37
【问题描述】:
我在将饼图的标签(全局对象)设置为仅保留 1 个小数位的百分比时遇到问题。
When I set texttemplate = "%{percent}"
with texttemplate = "%{percent:.1f}"
我现在的代码:
fig = go.Figure(data=[go.Pie(labels=X,
values=Y,
textfont = {'family': "Montserrat"},
texttemplate = "%{percent:.1f}",
marker = {'colors': paleta, 'line':{'color': 'white', 'width':2}}
)])
fig.update_traces(hoverinfo='label+percent', textinfo='value', textfont_size=10, sort=True,
direction='clockwise', rotation = 0)
fig.show()
【问题讨论】:
-
不要将相关信息作为图片链接发布。
标签: python plotly percentage