Black Lives Matter. Please consider donating to Black Girls Code today.

Subplots :: The 'data' property is a tuple of trace instances


i am trying to create a line stacked subplots… some thing like below

multiple of these types of graphs as a subplot.

below is my code:

import plotly.offline as pyo
import plotly.graph_objs as go
import pandas as pd
from import make_subplots

NE = pd.read_csv(“C:\py\programs\plotly\final\NE.csv”)
week_days = NE[‘date’].unique()
data1 = []
data2 = []

for day in week_days:
trace_volte_traffic = dict(type=“scatter”, x=NE[“time”], y=NE[NE[“date”] == day]
[“L.Traffic.User.VoIP.Avg”], mode=“lines+markers”, name=“volte_traffic”)

for day in week_days:
trace_PS_Traffic = dict(type=“scatter”, x=NE[“time”], y=NE[NE[“date”] == day]
[“LTE Traffic (DL+UL) - GB”], mode=“lines+markers”, name=“PS_traffic”)

fig = make_subplots(rows=2, cols=2,
subplot_titles=[‘Volte Traffic’, ‘PS Traffic’], shared_yaxes=True)

fig.append_trace(data1, 1, 1)
fig.append_trace(data2, 1, 2)

fig[‘layout’].update(height=1000, width=1600, title=‘CS Traffic’)


but i am getting below error

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’,
‘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, ...}])

i am new to programming, so really thankful for your patience :slight_smile: .

Best Regards

Hi @Riz_K,

I think the problem is that the data1/data2 values that you’re passing to append_trace are lists of a single trace, but append_trace expects a single trace. You can either call append_trace for each trace individually, or you can use add_traces which accepts a list of traces and lists of rows and cols. In your case, I think you could do something like

fig.add_traces(data1, rows=[1]*len(data1), cols=[1]*len(data1))
fig.add_traces(data2, rows=[1]*len(data2), cols=[2]*len(data2))

In the future, please place your code in a fenced code block ( This keeps the markdown renderer from messing up the formatting.

Hope that helps!


I am really thankful for your time. it actually worked. :smiley:

Thanks again and Best Regards

1 Like