✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Gantt Chart: Resolve overlap in grouped tasks

I need to display Subtasks within a Gantt chart that can overlap. Is there a way to change the bar width of the subtasks, so that the overlap becomes visible?

import plotly.figure_factory as ff

df = [dict(Task="Job A", Subtask="Subtask 1", Start='2020-02-01', Finish='2020-05-02'),
      dict(Task="Job A", Subtask="Subtask 2", Start='2020-03-01', Finish='2020-07-02'),
      dict(Task="Job A", Subtask="Subtask 3", Start='2020-04-01', Finish='2020-10-02'),
      dict(Task="Job B", Subtask="Subtask 1", Start='2020-03-01', Finish='2020-06-02'),
      dict(Task="Job B", Subtask="Subtask 2", Start='2020-05-01', Finish='2020-08-02'),
      dict(Task="Job B", Subtask="Subtask 3", Start='2020-06-01', Finish='2020-09-02'),
      dict(Task="Job C", Subtask="Subtask 1", Start='2020-01-01', Finish='2020-04-02'),
      dict(Task="Job C", Subtask="Subtask 2", Start='2020-05-01', Finish='2020-08-02'),
      dict(Task="Job C", Subtask="Subtask 3", Start='2020-06-01', Finish='2020-09-02')]

fig = ff.create_gantt(df, colors=['#333F44', '#93e4c1', '#FF4040'], index_col='Subtask',
                      show_colorbar=True, bar_width=0.2, showgrid_x=True, showgrid_y=True, group_tasks=True)

fig.show()

The chart currently looks like this:

Hi!

You can try

for shape in fig['data']:
    shape['opacity'] = 0.5

after to show plot.

import plotly.figure_factory as ff

df = [dict(Task="Job A", Subtask="Subtask 1", Start='2020-02-01', Finish='2020-05-02'),
      dict(Task="Job A", Subtask="Subtask 2", Start='2020-03-01', Finish='2020-07-02'),
      dict(Task="Job A", Subtask="Subtask 3", Start='2020-04-01', Finish='2020-10-02'),
      dict(Task="Job B", Subtask="Subtask 1", Start='2020-03-01', Finish='2020-06-02'),
      dict(Task="Job B", Subtask="Subtask 2", Start='2020-05-01', Finish='2020-08-02'),
      dict(Task="Job B", Subtask="Subtask 3", Start='2020-06-01', Finish='2020-09-02'),
      dict(Task="Job C", Subtask="Subtask 1", Start='2020-01-01', Finish='2020-04-02'),
      dict(Task="Job C", Subtask="Subtask 2", Start='2020-05-01', Finish='2020-08-02'),
      dict(Task="Job C", Subtask="Subtask 3", Start='2020-06-01', Finish='2020-09-02')]

fig = ff.create_gantt(df, colors=['#333F44', '#93e4c1', '#FF4040'], index_col='Subtask',
                      show_colorbar=True, bar_width=0.2, showgrid_x=True, showgrid_y=True, group_tasks=True)

print(fig['data'])

for shape in fig['data']:
    shape['opacity'] = 0.5

fig.show()

reference post

Wow, thank you. I haven’t thought about opacity.
:grinning: