Search code examples
pythonplotly

How can i slow animation speed and shouldn't delete last value in plotly


i am complete beginner in plotly. I want to reduce the animation speed and for example a value is shown and the next value comes without deleting this value. I searched a lot on google but couldn't find it. This is my code

fig = px.scatter(x=dbdeads, y=dbyear, color=dbdeads,text=dbnamedate,animation_frame=dbyear,
                range_x=[0,200000000], range_y=[-500,2050],size=dbdeads,
)
fig.update_traces(textposition="bottom right")

Solution

  • One way to set the animation speed is through:

    fig.layout.updatemenus[0].buttons[0].args[1]["frame"]["duration"] = 2000
    

    where 2000 is milliseconds. Try it out and see how it works for you.

    Without a sample of your data and a fully reproducible code snippet, it's hard to know exactly what you mean by:

    and for example a value is shown and the next value comes without deleting this value.

    I can't imagine any other use case for this than a line plot. If that's what you're looking for, I'd be happy to write up a suggestion. If it's not, then I would suggest that you edit your question to only handle the animation speed, and then write up a new question with further descriptions of the latter challenge.