plotly.py
plotly.py copied to clipboard
Animations: let 'Play' button support different durations for different frames
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))]
}]
}
]
}]
)
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