Employee utilization on a project

import matplotlib.pyplot as plt # 2-week project outlook task_times = ( ('design team', [ ('Hugo', [(0, 3), (5,7), (7,9), (11,13), (15,16), (18, 20)]), ('Costa', [(1,4), (6,7), (7,8), (10,11), (13,14), (14, 15), (17, 19)]), ('Claire', [(0,3), (4,6), (8,10), (12, 14), (16, 17), (18, 20)]), ('Benoit', [(4,7), (7,9), (13,16), (17,18), (19,20)]), ('Anette', [(2,4), (5,6), (7,10), (12,14), (16,20)]) ]), ('programming team', [ ('Nathan', [(2,5), (7,9), (10,12), (13,14), (16,19)]), ('Lora', [(1,3), (4,6), (7,10), (11,13), (15,16), (18,20)]), ('Chris', [(2,3), (5,7), (7,10), (12,14), (16,19)]) , ('Manuel', [(3,6), (8,11), (12, 14), (15, 17), (18, 20)]), ('Clara', [(2,7), (8,11), (14,16), (17,19)]) ]) ) colors = ['f5e29e', 'f1db8c', 'f9dc88', 'ffe68b', 'fcd37a'] weeks, workdays_in_week, day_subdivisions = 2, 5, 2 time_units = weeks * workdays_in_week * day_subdivisions milestone_times = [7, 14] fig, ax = plt.subplots(2, 1, sharex=True, figsize=(8,5)) ax[0].set_title('Employee utilization on different teams on the same project for the next two weeks (half-day granularity)') for i, (team, people) in enumerate(task_times): names = [] for j, (name, task_times) in enumerate(people): color = colors[j] y_offset = j + 1 for start, end in task_times: ax[i].plot([start, end], [y_offset]*2, '-', lw=14, alpha=1, color='#'+color, solid_capstyle="butt") names.append(name) ax[i].set_yticks(range(len(names)+2)) ax[i].set_yticklabels([''] + names+['']) ax[i].set_ylabel(team) ax[i].set_ylim(0, len(names)+2-1) # Draw vertical milestone lines for mt in milestone_times: ax[i].axvline(x=mt, color='grey', alpha=0.5, linestyle='dashed', lw=0.7) r = range(0, time_units+1) ax[1].set_xticks(r) ax[1].set_xticklabels(r) ax[1].set_xlabel('Time units') plt.xlim(0, time_units) plt.tight_layout() plt.show()