Multiple gantt chart in a plot

Is there a way to plot multiple gantt charts in one plot. I have tried to use the subplot method and it is not working.

from plotly.offline import   plot
import plotly.figure_factory as ff


fig = tools.make_subplots(rows=1, cols=2) 
fig1 = ff.create_gantt(data1, title=title1, group_tasks=True, show_colorbar=False)
fig2 = ff.create_gantt(data1, title=title2, group_tasks=True, show_colorbar=False)

fig.append_trace(fig1, 1, 1)    
fig.append_trace(fig2, 1, 2)    

I get an error with huge message which ends this way–

The ‘data’ property is a tuple of trace instances
that may be specified as:
- A list or tuple of trace instances
(e.g. [Scatter(…), Bar(…)])
- A list or tuple of dicts of string/value properties where:
- The ‘type’ property specifies the trace type
One of: [‘area’, ‘bar’, ‘barpolar’, ‘box’,
‘candlestick’, ‘carpet’, ‘choropleth’, ‘cone’,
‘contour’, ‘contourcarpet’, ‘heatmap’,
‘heatmapgl’, ‘histogram’, ‘histogram2d’,
‘histogram2dcontour’, ‘mesh3d’, ‘ohlc’,
‘parcats’, ‘parcoords’, ‘pie’, ‘pointcloud’,
‘sankey’, ‘scatter’, ‘scatter3d’,
‘scattercarpet’, ‘scattergeo’, ‘scattergl’,
‘scattermapbox’, ‘scatterpolar’,
‘scatterpolargl’, ‘scatterternary’, ‘splom’,
‘streamtube’, ‘surface’, ‘table’, ‘violin’]

  - All remaining properties are passed to the constructor of
     the specified trace type

    (e.g. [{'type': 'scatter', ...}, {'type': 'bar, ...}])

Hi @almasudme,

Welcome to the forums! The reason that fig.append_trace isn’t working in this case is because the output of create_gantt is a figure (that itself contains traces and shapes), and append_trace requires a trace as input.

There’s nothing built in to plotly.py right now for merging multiple figures together, so there isn’t an easy way to do this unfortunately. Are you working in the Jupyter Notebook? If so, one approach would be to create a FigureWidget for each figure and then place them side by side with an ipywidgets HBox.

Happy to go into more detail if that approach sounds useful :slightly_smiling_face:

-Jon

@almasudme were you able to create multiple gantt charts? if so can you please help shed some light on how I’ve been stuck for days trying to figure it out.

@jmmease are there any updates to the library that allow for multiple figure_factory gantt charts using a plotly.graph_objects drop down menu? and if not do you have an example of the approach you suggested?

thanks in advance for any reply

1 Like

@hadi You can define subplots of Gantt charts as it is explained here: https://plot.ly/~empet/15256.

1 Like

@empet thank you very very very very very much

1 Like