Black Lives Matter. Please consider donating to Campaign Zero's mission of ending police violence in America.
https://www.joincampaignzero.org

Scatter animation doesn't work

I am relentlessly trying to animate scatter plot. It does work, if i will add button control with default args=[None]

                  updatemenus=[dict(type="buttons",
                                    buttons=[dict(label="Play",
                                                  method="animate",
                                                  args=[None
                                                        # {"frame": {"duration": 0.5, "redraw": True},
                                                        #  "fromcurrent": True,
                                                        #  "mode": "immediate",
                                                        #  "transition": {"duration": 0.5}
                                                        # }
                                                        ],
                                                  )]

But I need to make it play faster. Its too slow. I have played with args like frame duration and transition duration, but it looks like with them set there is no animation at all. Any help would be greatly appreciated.

Hi @mcstarioni, the frame_duration is in ms, so I guess you don’t see anything indeed with only 0.5ms! Here is an example adapted from our documentation https://plot.ly/python/animations/, which we should update to show how to changed the animation speed.

import plotly.graph_objects as go

fig = go.Figure(
    data=[go.Scatter(x=[0, 1], y=[0, 1])],
    layout=go.Layout(
        xaxis=dict(range=[0, 5], autorange=False),
        yaxis=dict(range=[0, 5], autorange=False),
        title="Start Title",
        updatemenus=[dict(
            type="buttons",
            buttons=[dict(label="Play",
                          method="animate",
                          args=[None, {"frame": {"duration": 200, "redraw": False}} ])])]
    ),
    frames=[go.Frame(data=[go.Scatter(x=[1, 2], y=[1, 2])]),
            go.Frame(data=[go.Scatter(x=[1, 4], y=[1, 4])]),
            go.Frame(data=[go.Scatter(x=[3, 4], y=[3, 4])],
                     layout=go.Layout(title_text="End Title"))]
)

fig.show()
2 Likes

Thanks, that worked! :+1::grinning:

1 Like