Ragesh Kr
Ragesh Kr

Reputation: 1733

How to format numbers in plotly and avoid conversion to millions

My dataframe looks like below

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

While plotting my graph looks like this

enter image description here

When I hover I get the value as 6.692736M , instead i would like it to be 6692735.90, as given in my df. If possible Rs 66,92,735.90 How can I achieve this ?

Upvotes: 2

Views: 7673

Answers (1)

sentence
sentence

Reputation: 8933

You can use 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()

and you get:

enter image description here

Upvotes: 2

Related Questions