You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Plotly甘特图中清晰区分同资源的连续任务

问题:Plotly甘特图同一资源连续任务的区分方法

我在Plotly甘特图中配置了同一资源(Resource A)的两个连续任务,由于资源相同,甘特图使用同一颜色渲染,导致视觉上二者看似一个长流程,而非两个独立任务。我希望添加分隔线或通过其他方式明确区分这两个任务,预期效果见附图。

测试代码如下:

import pandas as pd
import plotly.figure_factory as ff


values = []
values.append(dict(Task="John",Start=0,Finish=10,Resource="A"))
values.append(dict(Task="John",Start=10,Finish=20,Resource="A"))

df = pd.DataFrame(values)

fig = ff.create_gantt(df, index_col='Resource', bar_width=0.4, show_colorbar=True,
                      group_tasks=True, title="Simulation")
fig.update_layout(xaxis_type='linear', autosize=False, width=800, height=400)

fig.show()

内容的提问来源于stack exchange,提问作者GuiGui

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 15:27:21