【发布时间】:2020-09-02 23:14:34
【问题描述】:
我正在尝试使用 plotly 绘制甘特图。重要的是水平泳道可以有多个在时间上分开的条。
我找到了一个使用日历日期 (YYYY-MM-DD) 的示例,并尝试使用时间 (HH:MM:SS) 进行转换。但是当我使用时间戳时,所有内容都会聚集在一起,没有间隙。
import plotly.express as px
import pandas as pd
df = pd.DataFrame([
dict(Start='00:01:12', Finish='00:01:59', Resource="Alex"),
dict(Start='00:04:51', Finish='00:05:28', Resource="Alex"),
dict(Start='00:02:12', Finish='00:04:34', Resource="Max")
])
fig = px.timeline(df, x_start="Start", x_end="Finish", y="Resource", color="Resource"
)
fig.update_layout(xaxis=dict(
title='Timestamp',
tickformat = '%H:%M:%S',
))
fig.show()
【问题讨论】:
标签: python timestamp plotly data-visualization