In your layout you need to specify the type that will be the category, as well as specify the values of the category and array. Also, in order for your graphic diagrams to display correctly, they must be arrays. The code below does what you would like to do, given the fact that your datetime is a value.
import plotly.plotly as plt
import plotly.graph_objs as gph
data = [
('task 1', 300),
('task 2', 1200),
('task 3', 500)
]
vals = []
traces = []
for (key, val) in data:
vals.append(val)
traces.append(gph.Bar(
x=[val],
y=[1],
name=key,
))
layout = gph.Layout(xaxis=dict(categoryorder='array', categoryarray=vals, type="category"))
fig = gph.Figure(data=traces, layout=layout)
plt.iplot(fig)
source
share