@empet I am following the charts side by side @ the following link, and trying to animate two charts at the same time.
https://plotly.com/python/subplots/#side-by-side-subplot-lowlevel-api
My code is the following, I think I have got the data and layout part, but did not get the frame configured correctly. I got the ValueError at the end, can you let me know how to configure to assign frame to trace1 and trace2 specifically? Thanks very much for your help.
import plotly.graph_objects as go
import numpy as np
# Generate curve data
t = np.linspace(-1, 1, 100)
x = t + t ** 2
y = t - t ** 2
xm = np.min(x) - 1.5
xM = np.max(x) + 1.5
ym = np.min(y) - 1.5
yM = np.max(y) + 1.5
N = 50
s = np.linspace(-1, 1, N)
xx = s + s ** 2
yy = s - s ** 2
# Create figure
trace1 = [go.Scatter(x=x, y=y,
mode="lines",
line=dict(width=2, color="blue")),
go.Scatter(x=x, y=y,
mode="lines",
line=dict(width=2, color="blue"))]
trace2 = [go.Scatter(x=x, y=y,
mode="lines",
line=dict(width=2, color="blue")),
go.Scatter(x=x, y=y,
mode="lines",
line=dict(width=2, color="blue"))]
fig = go.Figure(
data=[trace1, trace2],
layout=go.Layout(
xaxis=dict(range=[xm, xM], autorange=False, zeroline=False, domain=[0, 0.6]),
yaxis=dict(range=[ym, yM], autorange=False, zeroline=False),
xaxis2=dict(range=[xm, xM], autorange=False, zeroline=False, domain=[0.7, 1]),
yaxis2=dict(range=[ym, yM], autorange=False, zeroline=False, anchor="x2"),
title_text="Kinematic Generation of a Planar Curve", hovermode="closest",
updatemenus=[dict(type="buttons",
buttons=[dict(label="Play", method="animate", args=[None])])]),
frames=[
go.Frame(
data=[go.Scatter(
x=[xx[k]],
y=[yy[k]],
mode="markers",
marker=dict(color="red", size=10)),
go.Scatter(
x=[xx[k]],
y=[yy[k]],
mode="markers",
marker=dict(color="red", size=10))
]
)
for k in range(N)
]
)
fig.show()
print('two chart is animated.')
My error message is at line 58, which is
for k in range(N)
ValueError:
Invalid element(s) received for the 'data' property of ...