Stacked area graphs, Subplots

I am using Live-Graphs for dynamic updates, as I wanted to display many live-graphs, intervals are handled in a proper planned way.

The Graphs are Filled Area Graph(without sharing axis). I am trying to plot 2 Filled/Stacked Area Graphs but unable to do it. Can anyone provide solutions to this.
My code looks something like below(data irrelevant):

trace1 = go.Scatter(
x=[0, 1, 2],
y=[10, 11, 12]
)
trace2 = go.Scatter(
x=[2, 3, 4],
y=[100, 110, 120],
)
trace3 = go.Scatter(
x=[3, 4, 5],
y=[1000, 1100, 1200],
)

trace3 = go.Scatter(
x=[0, 1, 2],
y=[10, 11, 12]
)
trace4 = go.Scatter(
x=[2, 3, 4],
y=[100, 110, 120],
)
trace5 = go.Scatter(
x=[3, 4, 5],
y=[1000, 1100, 1200],
)

fig = tools.make_subplots(rows=2, cols=1,vertical_spacing=0.1)

data1 = [trace1,trace2,trace3]
data2 = [trace3,trace4,trace5]
fig.append_trace(data1, 1, 1)
fig.append_trace(data2, 2, 1)

Can anyone please help on this?

Hey praveen,

I simply looked at the plotly doc: https://plot.ly/python/subplots/#Multiple%20Subplots
and there were no examples of adding trace as list of Scatters (just Scatter).

it should fix your error:

trace1 = go.Scatter(
x=[0, 1, 2],
y=[10, 11, 12],
)
trace2 = go.Scatter(
x=[2, 3, 4],
y=[100, 110, 120],
)
trace3_0 = go.Scatter(
x=[3, 4, 5],
y=[1000, 1100, 1200],
)

trace3_1 = go.Scatter(
x=[0, 1, 2],
y=[10, 11, 12],
)
trace4 = go.Scatter(
x=[2, 3, 4],
y=[100, 110, 120],
)
trace5 = go.Scatter(
x=[3, 4, 5],
y=[1000, 1100, 1200],
)

fig = tools.make_subplots(rows=2, cols=3,vertical_spacing=0.1)

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 2)
fig.append_trace(trace3_0, 1, 3)
fig.append_trace(trace3_1, 2, 1)
fig.append_trace(trace4, 2, 2)
fig.append_trace(trace5, 2, 3)

Thank you for your reply on this!
But I think you have missed a requirement.

The provided solutions definitely works for 6 different graphs, I have Stacked/Filled area graphs.

trace1, trace2,trace3_0 should come on one x-y axis
trace3_1, trace4, trace5 should come on second x-y axis

Filled Area Plots

My bad,

I’m still not 100% sure of what you want to do, does this fit your needs ?

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 1)
fig.append_trace(trace3_0, 1, 1)
fig.append_trace(trace3_1, 2, 1)
fig.append_trace(trace4, 2, 1)
fig.append_trace(trace5, 2, 1)

I found the inspiration on this β€œβ€"β€œrelated”"" topic: Subplot with multiple y axis

1 Like

Thanks alot. I would try this and check