.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 frame
or 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, alist
of colors, adictionary
mapping values to colors, or atuple
defining 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
: Aboolean
parameter determining the visibility of the color bar in the Gantt chart.reverse_colors
: Aboolean
parameter 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.