hedmah
November 13, 2019, 6:47pm
1
Hi,
I have a problem where a string is translated into dates, without my intent. For example if I run on Python:
import plotly.express as px
fig = px.scatter(x=[β00-01β, β01-02β, β02-03β], y=[0, 1, 4,])
fig.show()
The β00-01β is translated into βJan 2000β on the x-axis when visualized. I just want it to show 00-01 on the x-axis. While when running with βx=[β12-13β, β13-14β, β14-15β]β this is not a problem.
How can I avoid that it interpret it as dates?
Regards
Eddie
Hi, you can force the axis type to be βcategoryβ as follows
import plotly.express as px
fig = px.scatter(x=['00-01', '01-02', '02-03'], y=[0, 1, 4,])
fig.update_layout(xaxis_type='category')
fig.show()
(plotly is interpreting strings formatted like dates as dates, but you can override this behaviour)
1 Like
hedmah
November 14, 2019, 10:28am
3
Thank you Emmanuelle for your fast answer
mail8
March 21, 2023, 9:30pm
4
How to avoid that in the legend?
mail8
August 2, 2023, 10:57pm
5
Does not work for plots that use facet_col
or facet_row
. It is only applied to the last facet.
AIMPED
August 3, 2023, 7:09am
6
Thats becasue you have more than just one xaxis. Youβll have to use fig.for_each_xaxis()