Changed code from Intro to animations in Python to animate a single 3d point in time.
But neither the animation or slider bar work.
t goes from 0 to 9, and the point should be at [t,t,t] at t.
Please help!
import plotly.graph_objects as go
import pandas as pd
make figure
fig_dict = {
"data": [], "layout": {}, "frames": []}
fill in most of layout
fig_dict[“layout”][“sliders”] = {
"args": [ "transition", { "duration": 400, "easing": "cubic-in-out" } ], "initialValue": "1952", "plotlycommand": "animate", "values": [x for x in range(10)], "visible": True,}
fig_dict[“layout”][“updatemenus”] = [
{ "buttons": [ { "args": [None, {"frame": {"duration": 500, "redraw": False}, "fromcurrent": True, "transition": {"duration": 300, "easing": "quadratic-in-out"}}], "label": "Play", "method": "animate" }, { "args": [[None], {"frame": {"duration": 0, "redraw": False}, "mode": "immediate", "transition": {"duration": 0}}], "label": "Pause", "method": "animate" } ], "direction": "left", "pad": {"r": 10, "t": 87}, "showactive": False, "type": "buttons", "x": 0.1, "xanchor": "right", "y": 0, "yanchor": "top" }]
sliders_dict = {
"active": 0, "yanchor": "top", "xanchor": "left", "currentvalue": { "font": {"size": 20}, "prefix": "Year:", "visible": True, "xanchor": "right" }, "transition": {"duration": 300, "easing": "cubic-in-out"}, "pad": {"b": 10, "t": 50}, "len": 0.9, "x": 0.1, "y": 0, "steps": []}
make data
fig_dict[“data”].append(go.Scatter3d(x=[0], y=[0], z=[0]))
make frames
for i in range(10):
fig_dict["frames"].append(go.Frame( data=[go.Scatter3d(x=[i], y=[i], z=[i])], name=str(i) )) slider_step = {"args": [ [i], {"frame": {"duration": 300, "redraw": False}, "mode": "immediate", "transition": {"duration": 300}} ], "label": i, "method": "animate"} sliders_dict["steps"].append(slider_step)fig_dict[“layout”][“sliders”] = [sliders_dict]
fig = go.Figure(fig_dict)
fig.show()