💸 Reduce costs by consolidating proprietary analytics & reporting software to open-source & Dash.
Challenge us to replace your analytics with Dash and reduce costs.

How to change x axis labels in python?

I am plotting a horizontal stacked bar chart, and I want each item on the x axis to reflect a datetime value instead of an integer. I am plotting the values in terms of seconds. How can I change the x axis tick labels to reflect a datetime? Thanks!

import plotly.plotly as plt
import plotly.graph_objs as gph

data = [
    ('task 1', 300),
    ('task 2', 1200),
    ('task 3', 500)
]
traces = []
for (key, val) in data:
    traces += [gph.Bar(
        x=val,
        y=1,
        name=key,
        orientation='h',
        )]

layout = gph.Layout(barmode='stack')
fig = gph.Figure(data=traces, layout=layout)
plt.iplot(fig)

should help you get started.