Convert Plotly y axis from numeric to string

Question:

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?

Asked By: nilsinelabore

||

Answers:

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

Answered By: bartolo-otrit

An alternative to @bartolo-otrit’s solution:

fig.update_yaxes(type='category', title = 'Title')

also worked by converting data type to categorical.

Answered By: nilsinelabore
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.