I am using Plotly graph objects with 3 traces in Data (2 scatter and 1 Bar) and 3 traces(2 scatter and 1 Bar) in Frame.
- Always the first trace in Data is not displaying…
- What would be the relation between the traces defined in Data versus traces defined in Frame.
How many frames should i need to create in correspondence with the data. Please look at the code below and let me know the changes I need to perform on the traces in Frame, If I need to animate all traces in data one by one but at the end displaying all of them(2 scatters and 1 Bar)
import plotly.graph_objects as go
fig=go.Figure(
data=[go.Scatter(x=[1,2,4,5],y=[1,2,4,5],mode=“lines+text”,text=“Scatter1 in Data”,visible=True,name=“Scatter1 in Data”),
go.Scatter(x=[5,6,7,8,9],y=[1,4,3,6,7],mode=“lines+text”,text=“Scatter2 in Data”,visible=True,name=“Scatter2 in Data”),
go.Bar(x=[-1,4],y=[2,3],visible=True,width=0.5,name=“Bar in Data”)
],
layout=go.Layout(
xaxis=dict(range=(-2,10),autorange=False),
yaxis=dict(range=(-1,10),autorange=False),
title=“Start Title”,
updatemenus=[dict(
type=“buttons”,
buttons=[dict(label=“Play This”,
method=“animate”,
args=[None, {“frame”: {“duration”: 4000, “redraw”: True},}])])]
),
frames=[go.Frame(data=[go.Scatter(visible=True,name=“Scatter1 in Frame”)]),
go.Frame(data=[go.Scatter(visible=True,name=“Scatter2 in Frame”)]),
go.Frame(data=[go.Bar(visible=True,name=“Bar in Frame”)]),
]
)
fig.update_layout(transition_duration=3000)
fig.write_html(“GOOOOO.HTML”,auto_open=True)