# Timeseries plot with timedelta axis

**URL:** <https://community.plotly.com/t/timeseries-plot-with-timedelta-axis/23560>\
**Category:** 📊 Plotly Python\
**Created:** [May 16, 2019, 11:29pm UTC](https://community.plotly.com/t/timeseries-plot-with-timedelta-axis/23560 "2019-05-16T23:29:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shahab\_ai](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Shahab\_ai](https://community.plotly.com/u/Shahab_ai)\
**Post date:** [May 16, 2019, 11:29pm UTC](https://community.plotly.com/t/timeseries-plot-with-timedelta-axis/23560/1 "2019-05-16T23:29:39Z")

</div>

Hello,

Is there anyway to show timedelta data in ‘%H:%M:%S’ format on the plot? Below is my simple code. I want the x axis ticks to be in %M:%S format.

Thanks

```
import pandas as pd
import plotly.graph_objs as go

from plotly.offline import init_notebook_mode
from plotly.offline import iplot 
init_notebook_mode(connected=True)

df = pd.DataFrame({'x': range(1000), 'y':np.sin(np.arange(1000)/100)})
df.x = pd.to_timedelta(df.x, unit='s')
trace = go.Scatter(x=df.x, y=df.y)
data = [trace]
fig = go.Figure(data)
iplot(fig)

```

 ![newplot](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/8/83ad31d45d0bad15db12854cf491d32947b9c220.png)

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [May 17, 2019, 10:32am UTC](https://community.plotly.com/t/timeseries-plot-with-timedelta-axis/23560/2 "2019-05-17T10:32:52Z")

</div>

Hi @Shahab_ai,

No, this isn’t directly supported right now. See [https://github.com/plotly/plotly.py/issues/799](https://github.com/plotly/plotly.py/issues/799) and [https://github.com/plotly/plotly.py/issues/801](https://github.com/plotly/plotly.py/issues/801). Perhaps the workaround in [https://github.com/plotly/plotly.py/issues/801#issuecomment-317174985](https://github.com/plotly/plotly.py/issues/801#issuecomment-317174985) would be helpful.

-Jon

---

<div class="post-metadata">

**Author:** ![randerson5726](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@randerson5726](https://community.plotly.com/u/randerson5726)\
**Post date:** [May 14, 2021, 7:38pm UTC](https://community.plotly.com/t/timeseries-plot-with-timedelta-axis/23560/3 "2021-05-14T19:38:50Z")

</div>

Bummer! Basic python data type support would be great

---

<div class="post-metadata">

**Author:** ![farispriadi](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/farispriadi/32/26759_2.png) [@farispriadi](https://community.plotly.com/u/farispriadi)\
**Post date:** [October 7, 2023, 12:52am UTC](https://community.plotly.com/t/timeseries-plot-with-timedelta-axis/23560/4 "2023-10-07T00:52:11Z")

</div>

Hi @Shahab_ai ,

Instead using **to\_timedelta** try to use **to\_datetime** to convert _x_ column.  
Also you need to format the xaxis ticks using '%M-%S format and update the layout.

Hope this help.

```auto
import numpy as np
import pandas as pd
import plotly.graph_objs as go

df = pd.DataFrame({'x': range(1000), 'y':np.sin(np.arange(1000)/100)})
df.x = pd.to_datetime(df.x, unit='s')
trace = go.Scatter(x=df.x, y=df.y)
data = [trace]
fig = go.Figure(data)

fig.update_layout(xaxis_tickformat='%M-%S')
fig.show()

```
