Search code examples
pythonpandasplotly

Convert Plotly y axis from numeric to string


How can I format the y axis in Plotly as string instead of numeric?

I tried to convert the numeric into string with:

df.id= df.id.astype('str')
fig = px.scatter(x = df.Datetime, y = df.id, color =df.Category
                                      )

fig.show()

but the plot displayed the numeric in million, as below:

enter image description here

How can I get the y axis showing the complete digits as string?


Solution

  • fig.update_yaxes(tickformat='d') might be used to change the formatting rules to show decimal numbers