Can't get Gantt chart examples to work


Can anyone help please. I am using version 3.10 of Plotly with Python 3.7.

The example code on the plotly site is:

import plotly.plotly as py
import plotly.figure_factory as ff

df = [dict(Task=“Job A”, Start=‘2009-01-01’, Finish=‘2009-02-28’),
dict(Task=“Job B”, Start=‘2009-03-05’, Finish=‘2009-04-15’),
dict(Task=“Job C”, Start=‘2009-02-20’, Finish=‘2009-05-30’)]

fig = ff.create_gantt(df)
py.iplot(fig, filename=‘gantt-simple-gantt-chart’, world_readable=True)

This initially says that Numpy is missing so I have imported this libary. However, it then tells me that is deprecated. Use plotly.figure_factory.create_gantt

I altered the code around this, but it still generates other errors. I can’t find the reference for plotly.figure_factory.create_gantt to see what attributes, etc are available.

Can anyone help with this please as I am fairly new to this, but this will help me to develop a really useful utility I have been working on.

Thanks for your help.


Hi @stevebutler99,

Here’s a full offline gantt chart example that I’m running with 3.10.0.

import plotly.figure_factory as ff
from plotly.offline import init_notebook_mode, iplot

df = [dict(Task="Job A", Start='2009-01-01', Finish='2009-02-28'),
      dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
      dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')]

fig = ff.create_gantt(df)

You can use the built-in python help function to view the documentation of the arguments to create_gantt.

Help on function create_gantt in module plotly.figure_factory._gantt:

create_gantt(df, colors=None, index_col=None, show_colorbar=False, reverse_colors=False, title='Gantt Chart', bar_width=0.2, showgrid_x=False, showgrid_y=False, height=600, width=900, tasks=None, task_names=None, data=None, group_tasks=False)
    Returns figure for a gantt chart
    :param (array|list) df: input data for gantt chart. Must be either a
        a dataframe or a list. If dataframe, the columns must include
        'Task', 'Start' and 'Finish'. Other columns can be included and
        used for indexing. If a list, its elements must be dictionaries
        with the same required column headers: 'Task', 'Start' and

Hope that helps!

Thanks Jon, just trying this out.