Adding a Max Value to a Gantt Chart

Viewed 37

There is the following chart (this is an instance of several charts of the same type)

How can I add to it the output of the maximum value (in the form of a dot or a strip with the value itself) for each strip:

Expected Result: enter image description here

Dataset: https://docs.google.com/spreadsheets/d/1pED4oFOuCcbZyoSuh_F-uUM7yuT6Ff0n/edit?usp=sharing&ouid=100335429201323787767&rtpof=true&sd=true

My code:

df2

fig, ax = plt.subplots(1, figsize=(15,8))
operation_lenght = df2.Duration

bars = ax.barh(df2.Operation, df2.Duration, left=df2.Start, color=df2.Color)
ax.bar_label(bars, label_type='edge', padding = 5.0, labels = df2["Duration"], fontsize= 15)
ax.set_xlabel('Duration')
ax.set_ylabel('Operations')
plt.show()
1 Answers

Maybe not exactly like you intended it, but you might simply use axvline to draw the max value, i.e.:

ax.axvline(df2.Duration.sum(), ls='--', dashes=(5, 15))  # first argument is your max value
Related