Timeseries plot with timedelta axis


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.


import pandas as pd
import plotly.graph_objs as go

from plotly.offline import init_notebook_mode
from plotly.offline import iplot 

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)

Hi @Shahab_ai,

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


1 Like

Bummer! Basic python data type support would be great