# Avoid string translated as date when plot scatter

**URL:** <https://community.plotly.com/t/avoid-string-translated-as-date-when-plot-scatter/31273>\
**Category:** 📊 Plotly Python\
**Created:** [November 13, 2019, 6:47pm UTC](https://community.plotly.com/t/avoid-string-translated-as-date-when-plot-scatter/31273 "2019-11-13T18:47:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hedmah](https://avatars.discourse-cdn.com/v4/letter/h/5f9b8f/32.png) [@hedmah](https://community.plotly.com/u/hedmah)\
**Post date:** [November 13, 2019, 6:47pm UTC](https://community.plotly.com/t/avoid-string-translated-as-date-when-plot-scatter/31273/1 "2019-11-13T18:47:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Emmanuelle](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emmanuelle/32/7853_2.png) [@Emmanuelle](https://community.plotly.com/u/Emmanuelle)\
**Post date:** [November 13, 2019, 7:09pm UTC](https://community.plotly.com/t/avoid-string-translated-as-date-when-plot-scatter/31273/2 "2019-11-13T19:09:33Z")

</div>

Hi, you can force the axis type to be ‘category’ as follows

```auto
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)

---

<div class="post-metadata">

**Author:** ![hedmah](https://avatars.discourse-cdn.com/v4/letter/h/5f9b8f/32.png) [@hedmah](https://community.plotly.com/u/hedmah)\
**Post date:** [November 14, 2019, 10:28am UTC](https://community.plotly.com/t/avoid-string-translated-as-date-when-plot-scatter/31273/3 "2019-11-14T10:28:55Z")

</div>

Thank you Emmanuelle for your fast answer 🙂

---

<div class="post-metadata">

**Author:** ![mail8](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/mail8/32/31560_2.png) [@mail8](https://community.plotly.com/u/mail8)\
**Post date:** [March 21, 2023, 9:30pm UTC](https://community.plotly.com/t/avoid-string-translated-as-date-when-plot-scatter/31273/4 "2023-03-21T21:30:19Z")

</div>

How to avoid that in the legend?

---

<div class="post-metadata">

**Author:** ![mail8](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/mail8/32/31560_2.png) [@mail8](https://community.plotly.com/u/mail8)\
**Post date:** [August 2, 2023, 10:57pm UTC](https://community.plotly.com/t/avoid-string-translated-as-date-when-plot-scatter/31273/5 "2023-08-02T22:57:48Z")

</div>

> [@Emmanuelle](#):
>
> ```auto
> fig.update_layout(xaxis_type='category')
> 
> ```

Does not work for plots that use `facet_col` or `facet_row`. It is only applied to the last facet.

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [August 3, 2023, 7:09am UTC](https://community.plotly.com/t/avoid-string-translated-as-date-when-plot-scatter/31273/6 "2023-08-03T07:09:15Z")

</div>

Thats becasue you have more than just one xaxis. You’ll have to use `fig.for_each_xaxis()`
