I have a list of data frames A[i]
where i
goes from 0 to 50. If I want to draw traces manually, it works:
import plotly.graph_objects as go
fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(go.Scatter(x=A[1].index,y=A[1]['diff'], mode='markers',name='Line 3'),secondary_y=False,)
fig.add_trace(go.Scatter(x=A[2].index,y=A[2]['diff'], mode='markers',name='Line 4'),secondary_y=False,)
However, I would like to draw the column diff
from each data frame of the list and I would like to do that in a loop, I tried the following:
fig = make_subplots(specs=[[{"secondary_y": True}]])
for i in range(0,50):
fig.add_trace(go.Scatter(x=A[i].index,y=A[i]['diff'], mode='markers',name='Line 3'),secondary_y=False,)
This did not work, any ideas on what I'm doing wrong?
fig.show()
Kindly add this within the for
loop.
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.