plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Animations: let 'Play' button support different durations for different frames

Open sducouedic opened this issue 3 months ago • 1 comments

So far the button Play only support a single frame duration and a single transition duration for all the steps of the animation. It would be very useful to support different duration values at different frame step. Note that I haven't any way to define specific duration per frame, I am open to suggestions.

Current:

fig.update_layout(
    updatemenus=[{
        'type': 'buttons',
        'buttons': [
            {
                'label': 'Play',
                'method': 'animate',
                'args': [None, {
                    'fromcurrent': True,
                    'frame': {'duration': 100, 'redraw': False},
                    'transition': {'duration': 100}
                }]
            }
        ]
    }]
)

Possible alternative way to pass information:

fig.update_layout(
    updatemenus=[{
        'type': 'buttons',
        'buttons': [
            {
                'label': 'Play',
                'method': 'animate',
                'args': [None, {
                    'fromcurrent': True,
                    'frame': [(str(i), {'duration': 100 if i%2 == 0 else 1000, 'redraw': False}) for i in range(len(frames))],
                    'transition': [(str(i), {'duration': 100 if i%2 == 0 else 1000}) for i in range(len(frames))]
                }]
            }
        ]
    }]
)

sducouedic avatar Oct 02 '25 13:10 sducouedic

Thanks for the suggestion @sducouedic - it's a good idea, but we're not going to be able to address it any time soon. That said, I'd be happy to prioritize review of a PR from the community. Thanks - @gvwilson

gvwilson avatar Oct 07 '25 13:10 gvwilson