Python:Plotly .create_gantt()
The .create_gantt method in the plotly.figure_factory module is a function used in Plotly to generate Gantt charts. Gantt charts are graphical representations of project schedules that illustrate tasks, their durations, and dependencies. This method allows users to create interactive Gantt charts within their Plotly figures, providing a visual overview of project timelines and progress.
Syntax
The syntax for the .create_gantt() method in Plotly is customizable. Below is a general structure of it:
plotly.figure_factory.create_gantt(df, colors=None, index_col=None, show_colorbar=False, reverse_colors=False, title=’Gantt Chart’, ....)
The .create_gantt method takes the following arguments:
df: Required input data, either adata frameor a list, serving as the foundation for the Gantt chart’s content.colors: Specifies the color scheme used in the chart, allowing customization through options like a Plotly scale name, alistof colors, adictionarymapping values to colors, or atupledefining the color range.index_col: Identifies the column header to be used as the indexing column in the Gantt chart, aiding in the organization of tasks or data points along they-axis.show_colorbar: Abooleanparameter determining the visibility of the color bar in the Gantt chart.reverse_colors: Abooleanparameter enabling the reversal of selected colors in the chart.title: Sets a descriptive title for the Gantt chart.
Note: The ellipsis (…) indicates that there can be additional optional arguments beyond those listed here.
Example
The example below demonstrates the use of .create_gantt() to plot a Gantt chart for a simple project with three tasks (A, B and C) that take place in the same year:
import plotly.figure_factory as ffdf = [dict(Task="Task A", Start='2024-01-01', Finish='2024-02-02'),dict(Task="Task B", Start='2024-03-01', Finish='2024-11-11'),dict(Task="Task C", Start='2024-08-06', Finish='2024-09-21')]fig = ff.create_gantt(df)fig.show()
Output:
The code depicted above produces the following output:

All contributors
- Anonymous contributor
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python:Plotly on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
- With Certificate
- Beginner Friendly.24 hours