# How to Create a Gantt Chart in Plotly Python

## 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([
])

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()

Rating: 1 out of 5.