Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions doc/python/animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ fig.show()

```python
import plotly.graph_objects as go

import numpy as np

# Generate curve data
t = np.linspace(-1, 1, 100)
x = t + t ** 2
Expand All @@ -156,7 +154,7 @@ 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
N = 25
s = np.linspace(-1, 1, N)
xx = s + s ** 2
yy = s - s ** 2
Expand All @@ -167,26 +165,29 @@ fig = go.Figure(
data=[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"))],
layout=go.Layout(
go.Scatter(x=[xx[0]], y=[yy[0]],
mode="markers",
marker=dict(color="red", size=10))])
fig.update_layout(width=600, height=450,
xaxis=dict(range=[xm, xM], autorange=False, zeroline=False),
yaxis=dict(range=[ym, yM], autorange=False, zeroline=False),
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))])

for k in range(N)]
)
title_text="Kinematic Generation of a Planar Curve", title_x=0.5,
updatemenus = [dict(type = "buttons",
buttons = [
dict(
args = [None, {"frame": {"duration": 10, "redraw": False},
"fromcurrent": True, "transition": {"duration": 10}}],
label = "Play",
method = "animate",

)])])

fig.update(frames=[go.Frame(
data=[go.Scatter(
x=[xx[k]],
y=[yy[k]])],
traces=[1]) # fig.data[1] is updated by each frame
for k in range(N)])

fig.show()
```
Expand Down