Plotly Indicator如何显示完整数字?技术咨询
Plotly Indicator组件显示完整数字的解决方案
你的代码运行正常,但Indicator组件默认会对较大数值进行缩略显示(比如将32000显示为32k)。要强制显示完整数字,只需在number参数中添加valueformat字段,指定数值的显示格式即可。
修改后的代码示例
import plotly.graph_objects as go fig = go.Figure(go.Indicator( mode = "number+delta", value = 32000, number = {'prefix': "zł", 'valueformat': 'd'}, # 添加valueformat指定整数格式 delta = {'position': "top", 'reference': 32000, "valueformat": "f"}, domain = {'x': [0, 1], 'y': [0, 1]} )) fig.update_layout(paper_bgcolor = "lightgray") fig.show()
常用格式选项说明
'd':显示纯整数格式(无小数部分),示例:32000',d':带千分位分隔符的整数,示例:32,000'f':固定小数位数显示(默认保留两位,可通过'%.0f'指定无小数),示例:32000.00
内容的提问来源于stack exchange,提问作者MatJablo
相关产品推荐
相关产品推荐

