Last active
December 5, 2024 22:56
-
-
Save summerofgeorge/4ed322319dffaf61118b81e79ec82acf to your computer and use it in GitHub Desktop.
Gantt chart Excel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib.dates import date2num | |
gantt_df = xl("tasks[#All]", headers=True) | |
# Plot Gantt chart | |
fig, ax = plt.subplots(figsize=(10, 6)) | |
# Define positions for the tasks on the y-axis | |
y_positions = range(len(gantt_df)) | |
# Create bars for each task | |
for i, task in enumerate(gantt_df.itertuples()): | |
ax.barh(y=i, width=(task.End - task.Start).days, left=date2num(task.Start), height=0.5, align='center', color='skyblue') | |
# Customize the plot | |
ax.set_yticks(y_positions) | |
ax.set_yticklabels(gantt_df['Task']) | |
ax.xaxis_date() # Format x-axis as dates | |
ax.set_xlabel("Date") | |
ax.set_ylabel("Tasks") | |
ax.set_title("Gantt Chart") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment