How can I get the data updated for each frame in the plotly animation?!

Hi Guys, I’m trying to access the data of the animation, someone can help me?

fig = px.bar(df_new, x="variable", y="value", color="new", 
             animation_frame="order", animation_group="variable", 
             barmode="group" )

fig.layout['updatemenus'] = [
    {
        'buttons': [
            {
                'args': [None, {'frame': {'duration': 5000, 'redraw': False},
                         'fromcurrent': True, 'transition': {'duration': 1500, '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': 'right',
        'pad': {'r': 10, 't': 87},
        'showactive': True,
        'type': 'buttons',
        'x': 0.1,
        'xanchor': 'right',
        'y': 0,
        'yanchor': 'top'
    }
]

fig

I read on GitHub that I need to use fig.frames… but how can I have these values outputted every time that the frames be changed, for each state in my animation automatically?

Did you ever figure this out? I am doing something similar

Hi buddy,

I used the fig.frames to get the data for each frame.

1 Like