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)
1 Like
Bummer! Basic python data type support would be great
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.
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()