Hi,
I want to share code for doing smooth animations in Plotly for Python (using a Jupyter Notebook)
import plotly.graph_objects as go
import numpy as np
ts = np.linspace(0,2*np.pi,100)
frames = [
go.Frame(
data=[go.Scatter(
x=[np.cos(t),2*np.cos(2*t)],
y=[np.sin(t),2*np.sin(2*t)])
]
)
for t in ts
]
fig = go.Figure(
data=[go.Scatter(x=[0, 1], y=[0, 1])],
layout=go.Layout(
xaxis=dict(range=[-3, 3], autorange=False),
yaxis=dict(range=[-3, 3], autorange=False),
width=800,
height=800,
title="Start Title",
updatemenus=[dict(
type="buttons",
buttons=[dict(label="Play",
method="animate",
args=[None,{"frame": {"duration": 5}}])])]
),
frames=frames
)
fig.show()