Already been 2 hours that I am having issues to join different unique figures in a subplot.
Any idea why the following insn't working:
# MAIN FIGURE
fig = make_subplots(rows=4, cols=1,
specs=[[{"rowspan": 3}],
[None],
[None],
[{}]])
# sub-FIGURE 1
candlestick = go.Candlestick(x = df.index,
open = df.open_BTC,
high = df.high_BTC,
low = df.low_BTC,
close = df.close_BTC)
# sub-FIGURE 2
# Filter data for conditional above/below 0 fillings
pos = df[i] >= 0
above = np.where(pos, df[i], np.nan)
below = np.where(pos, np.nan, df[i])
scatter1 = go.Scatter(x=df.index, y=below, fill='tozeroy')
scatter2 = go.Scatter(x=df.index, y=above, fill='tozeroy')
#... and other cool shit (but must be in fig2 only !)
fig2 = go.Figure(data=[scatter1, scatter2]) # <-- THIS PLOTS WELL !
# ADDING fig1 and fig2 IN SUBPLOT
fig.add_trace(candlestick, row=1, col=1)
fig.add_trace(fig2, row=4, col=1) # <-- THIS DOESN'T WORK... WHY ?
Apparently, I am not understanding how to initialise figures correctly. Thanks in advance for your help.
Missunderstanding here as there are no such things.
I could make it the following way:
fig = make_subplots(rows=4, cols=1,
specs=[[{"rowspan": 3}],
[None],
[None],
[{}]])
candlestick = go.Candlestick(x = df.index,
open = df.open_BTC,
high = df.high_BTC,
low = df.low_BTC,
close = df.close_BTC)
# Filter data
pos = df[i] >= 0
above = np.where(pos, df[i], np.nan)
below = np.where(pos, np.nan, df[i])
scatter1 = go.Scatter(x=df.index, y=below, fill='tozeroy')
scatter2 = go.Scatter(x=df.index, y=above, fill='tozeroy')
#fig2 = go.Figure(data=[scatter1, scatter2])
fig.add_trace(candlestick, row=1, col=1)
fig.add_trace(scatter1, row=4, col=1) # <-- just add the elements at the correct place
fig.add_trace(scatter2, row=4, col=1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.