【发布时间】:2021-06-14 03:41:16
【问题描述】:
我是 plotly 新手,我正在使用 px.timeline 创建甘特图。我的数据集中有 3 类数据,一个有开始和结束时间的普通任务,还有两种开始和结束时间相同的任务。我希望正常任务是一个矩形(这就是它的绘制方式),而其他两个任务有一个沙漏标记和一个三角形标记,而不是一条非常细的线?
这就是我的数据的样子:
data = [dict(Task=’’, start=’’, end=’’, shape=’<rect, hour, tri>’)]
样本数据:
df = [dict(Task="Job A", Start='2009-01-01', Finish='2009-01-01', shape='hourglass'),
dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15', shape='rectangle'),
dict(Task="Job C", Start='2009-05-30', Finish='2009-05-30', shape='triangle')]
代码:
fig = px.timeline(data, x_start="Start", x_end="Finish", y="Task")
fig.update_yaxes(autorange="reversed", ticklabelposition="outside left")
fig.update_layout(showlegend=False, height=2000, width=1255, margin_pad=10)
fig.show()
例子:
有什么方法可以实现吗?
谢谢!
【问题讨论】:
标签: python-3.x plot plotly plotly-python gantt-chart