|
1 | | -""" pyplots.ai |
| 1 | +"""pyplots.ai |
2 | 2 | gantt-dependencies: Gantt Chart with Dependencies |
3 | | -Library: seaborn 0.13.2 | Python 3.13.11 |
4 | | -Quality: 91/100 | Created: 2026-01-15 |
| 3 | +Library: seaborn 0.13.2 | Python 3.14 |
| 4 | +Quality: /100 | Updated: 2026-02-25 |
5 | 5 | """ |
6 | 6 |
|
7 | 7 | import matplotlib.patches as mpatches |
|
16 | 16 | sns.set_theme(style="whitegrid") |
17 | 17 |
|
18 | 18 | # Data: Software Development Project with Dependencies |
| 19 | +# All dependent tasks start at or after their predecessors end |
19 | 20 | tasks_data = [ |
20 | 21 | # Requirements Phase |
21 | 22 | { |
|
49 | 50 | }, |
50 | 51 | { |
51 | 52 | "task": "Database Design", |
52 | | - "start": "2024-02-01", |
53 | | - "end": "2024-02-12", |
| 53 | + "start": "2024-02-09", |
| 54 | + "end": "2024-02-20", |
54 | 55 | "group": "Design", |
55 | 56 | "depends_on": ["System Architecture"], |
56 | 57 | }, |
57 | 58 | { |
58 | 59 | "task": "UI/UX Design", |
59 | | - "start": "2024-02-05", |
60 | | - "end": "2024-02-18", |
| 60 | + "start": "2024-02-09", |
| 61 | + "end": "2024-02-22", |
61 | 62 | "group": "Design", |
62 | 63 | "depends_on": ["System Architecture"], |
63 | 64 | }, |
64 | 65 | { |
65 | 66 | "task": "Design Review", |
66 | | - "start": "2024-02-19", |
67 | | - "end": "2024-02-23", |
| 67 | + "start": "2024-02-23", |
| 68 | + "end": "2024-02-28", |
68 | 69 | "group": "Design", |
69 | 70 | "depends_on": ["Database Design", "UI/UX Design"], |
70 | 71 | }, |
71 | 72 | # Development Phase |
72 | 73 | { |
73 | 74 | "task": "Backend Core", |
74 | | - "start": "2024-02-26", |
| 75 | + "start": "2024-02-29", |
75 | 76 | "end": "2024-03-18", |
76 | 77 | "group": "Development", |
77 | 78 | "depends_on": ["Design Review"], |
78 | 79 | }, |
79 | 80 | { |
80 | 81 | "task": "API Development", |
81 | | - "start": "2024-03-04", |
82 | | - "end": "2024-03-22", |
| 82 | + "start": "2024-03-19", |
| 83 | + "end": "2024-04-05", |
83 | 84 | "group": "Development", |
84 | 85 | "depends_on": ["Backend Core"], |
85 | 86 | }, |
86 | 87 | { |
87 | 88 | "task": "Frontend Components", |
88 | | - "start": "2024-03-11", |
89 | | - "end": "2024-03-29", |
| 89 | + "start": "2024-04-06", |
| 90 | + "end": "2024-04-22", |
90 | 91 | "group": "Development", |
91 | 92 | "depends_on": ["UI/UX Design", "API Development"], |
92 | 93 | }, |
93 | 94 | { |
94 | 95 | "task": "Integration", |
95 | | - "start": "2024-04-01", |
96 | | - "end": "2024-04-12", |
| 96 | + "start": "2024-04-23", |
| 97 | + "end": "2024-05-06", |
97 | 98 | "group": "Development", |
98 | 99 | "depends_on": ["API Development", "Frontend Components"], |
99 | 100 | }, |
|
107 | 108 | }, |
108 | 109 | { |
109 | 110 | "task": "Integration Testing", |
110 | | - "start": "2024-04-08", |
111 | | - "end": "2024-04-19", |
| 111 | + "start": "2024-05-07", |
| 112 | + "end": "2024-05-17", |
112 | 113 | "group": "Testing", |
113 | 114 | "depends_on": ["Integration", "Unit Testing"], |
114 | 115 | }, |
115 | 116 | { |
116 | 117 | "task": "UAT", |
117 | | - "start": "2024-04-22", |
118 | | - "end": "2024-05-03", |
| 118 | + "start": "2024-05-20", |
| 119 | + "end": "2024-05-31", |
119 | 120 | "group": "Testing", |
120 | 121 | "depends_on": ["Integration Testing"], |
121 | 122 | }, |
122 | | - {"task": "Bug Fixes", "start": "2024-05-06", "end": "2024-05-17", "group": "Testing", "depends_on": ["UAT"]}, |
| 123 | + {"task": "Bug Fixes", "start": "2024-06-03", "end": "2024-06-14", "group": "Testing", "depends_on": ["UAT"]}, |
123 | 124 | ] |
124 | 125 |
|
125 | 126 | df = pd.DataFrame(tasks_data) |
|
155 | 156 | fig, ax = plt.subplots(figsize=(16, 9)) |
156 | 157 |
|
157 | 158 | # Create data for seaborn lineplot (bars as thick lines) |
158 | | -# This uses seaborn's lineplot to draw horizontal bars as line segments |
159 | 159 | line_data = [] |
160 | 160 | for _, row in df.iterrows(): |
161 | | - # Create start and end points for each task bar |
162 | 161 | line_data.append( |
163 | 162 | {"x": row["start_num"], "y": row["y_pos"], "task": row["task"], "group": row["group"], "point": "start"} |
164 | 163 | ) |
|
193 | 192 |
|
194 | 193 | ax.plot([group_start, group_end], [y, y], color=color, linewidth=10, alpha=0.4, solid_capstyle="round") |
195 | 194 |
|
196 | | -# Draw dependency arrows |
| 195 | +# Draw dependency arrows from right edge of predecessor to left edge of successor |
197 | 196 | for _, row in df.iterrows(): |
198 | 197 | if row["depends_on"]: |
199 | 198 | end_y = task_to_y[row["task"]] |
|
230 | 229 | all_y.append(task_to_y[task]) |
231 | 230 |
|
232 | 231 | ax.set_yticks(all_y) |
233 | | -ax.set_yticklabels(all_labels, fontsize=12) |
| 232 | +ax.set_yticklabels(all_labels, fontsize=13) |
234 | 233 | ax.invert_yaxis() |
235 | 234 |
|
| 235 | +# Bold group labels for hierarchy emphasis |
| 236 | +for label in ax.get_yticklabels(): |
| 237 | + if label.get_text().startswith("▪"): |
| 238 | + label.set_fontweight("bold") |
| 239 | + label.set_fontsize(14) |
| 240 | + |
236 | 241 | # X-axis formatting (dates) |
237 | 242 | max_day = int(df["end_num"].max()) + 7 |
238 | 243 | date_ticks = np.arange(0, max_day, 14) |
|
0 commit comments