
Gantt Chart –
A Gantt chart is a type of bar chart that illustrates a project schedule. The chart lists the tasks to be performed on the vertical axis, and time intervals on the horizontal axis. The width of the horizontal bars in the graph shows the duration of each activity.
Let’s create a dataframe to work with.
import pandas as pd
df = pd.DataFrame([
dict(Task="Planning", Start='2022-01-01', Finish='2022-01-20', Resource='Steve'),
dict(Task="Research", Start='2022-02-01', Finish='2022-04-30', Resource='Steve'),
dict(Task="Design", Start='2022-05-01', Finish='2022-05-30', Resource='Max'),
dict(Task="Implementation", Start='2022-06-01', Finish='2022-09-30', Resource='Eleven'),
dict(Task="Follow Up", Start='2022-10-01', Finish='2022-10-10', Resource='Eleven')
])
df

To create a Gantt Chart we will us the px.timeline function from plotly express. The px.timeline
function by default sets the X-axis to be of type=date
, so it can be configured like any time-series chart.
import plotly.express as px
fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task")
fig.update_yaxes(autorange="reversed")
fig.show()

We can also specify which person is doing which task using the color parameter.
fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", color="Resource")
fig.update_yaxes(autorange="reversed")
fig.show()
