Plotly 指标数字四舍五入

Jul*_*nos 2 python dashboard plotly plotly-python

当将 Plotly(在 Python 中)与指示器一起使用时,如果数字相对较大,则数字会四舍五入。如何避免这种情况(或至少控制它)?

fig_ind_abs = go.Figure(go.Indicator(
        mode="number+delta",
        value=5222,
        delta={'position': "top", 'reference': 5218}))
Run Code Online (Sandbox Code Playgroud)

将显示以下指示器 结果

有任何想法吗?

ven*_*y__ 7

您需要格式化指示器编号。您应该{'valueformat':'f'}在需要浮点值的地方添加到代码中。Reference

可用定制的完整列表d3 format api

import plotly.graph_objects as go
go.Figure(go.Indicator(
        mode="number+delta",
        value=5222,
        delta={'position': "top", 'reference': 5218, 'valueformat':'f'},
        number = {'valueformat':'f'}
))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述