The below code uses Python lists to create a Plotly graph.
The timestamps are Epoch milliseconds. How do I format the x-axis to readable datetime?
I tried fig.layout['xaxis_tickformat'] = '%HH-%MM-%SS'
but it didn’t work.
import plotly.graph_objects as go
time_series = [1716693661000, 1716693662000, 1716693663000, 1716693664000]
prices = [20, 45, 32, 19]
fig = go.Figure()
fig.add_trace(go.Scatter(x=time_series, y=prices, yaxis='y'))
fig.update_layout(xaxis=dict(rangeslider=dict(visible=True),type="linear"))
fig.layout['xaxis_tickformat'] = '%Y-%m-%d'
fig.show()