How to have a clear separation between processes of Gantt graph Plotly

Viewed 29

In my Gantt graph, I have two same resource that are touching each other for one task. Since it is the same resource, Gantt graph uses the same color, but visually, it looks like one long process and not two separate ones.

I am trying to produce something as shown below, to add a line to demarcate two processes or maybe have a better way to clearly dissociate the two:

enter image description here

Here below is a short test code:

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()
1 Answers

please see if this satisfies your need. You can easily add trace to provide edge color to each of the boxes. If you add this line right after create_gantt()

fig.update_traces(mode='lines', line_color='black', selector=dict(fill='toself'))

...you will get this plot

enter image description here

Related