【问题标题】:How to format numbers in plotly and avoid conversion to millions如何在情节中格式化数字并避免转换为数百万
【发布时间】:2020-03-26 19:36:03
【问题描述】:

我的数据框如下所示

    S2PName-Category    totSale
0   Food                6692735.90
1   Beverages           764768.33
2   Others              127971.91
3   Juice               261923.59
4   Snacks              382461.55

绘制我的图表时看起来像这样

当我悬停时,我得到的值为 6.692736M ,而不是我希望它是 6692735.90,如我的 df 中给出的那样。如果可能的话 66,92,735.90 卢比 我怎样才能做到这一点?

【问题讨论】:

    标签: python python-3.x pandas formatting plotly


    【解决方案1】:

    你可以使用tickformat:

    import plotly.graph_objs as go
    
    data = [go.Bar(x=['Food', 'Beverages', 'Others', 'Juice', 'Snacks'],
                   y=[6692735.90, 764768.33, 127971.91, 261923.59, 382461.55],
                   name='name',)]
    
    layout = go.Layout(yaxis=dict(tickformat=".2f"))
    
    fig = go.Figure(data=data, layout=layout)
    fig.show()
    

    你会得到:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-12
      相关资源
      最近更新 更多