How to do simple 3D scatter animation?

I got code of Scatter line animation on Intro to animations with Python and its animating perfectly,

Untitled (2)

but, when i tried to write same code for Scatter3d it is not animating

import plotly.graph_objects as go

fig = go.Figure(
    data=[go.Scatter3d(x=[0, 1], y=[0, 1], z=[0,1])],
    layout=go.Layout(
        scene=dict(
            xaxis=dict(range=[0, 5], autorange=False),
            yaxis=dict(range=[0, 5], autorange=False),
            zaxis=dict(range=[0, 5], autorange=False),
        ),
        width=500,
        height=500,
        updatemenus=[dict(
            type="buttons",
            buttons=[dict(label="Play",
                          method="animate",
                          args=[None])])]
        
    ),
    frames=[go.Frame(data=[go.Scatter3d(x=[1, 2], y=[1, 2], z=[1, 2])]),
            go.Frame(data=[go.Scatter3d(x=[1, 4], y=[1, 4], z=[1, 4])]),
            go.Frame(data=[go.Scatter3d(x=[3, 4], y=[3, 4], z=[3, 4])]),
    ]
)

fig.show()

Untitled (1)

Although Plotly Express supports animation for many chart and map types, smooth inter-frame transitions are today only possible for scatter and bar.

I found this on that Intro.

ohhhh !!! :smiling_face_with_tear:

the statement you cite was in the context of Plotly Express.
Hopefully it is still possible to get smooth 3D animations on the low level of Graphical Objects. Hopefully…

1 Like