Closed jvrs91 closed 4 months ago
I couldn't reproduce your bug., because the link you posted is empty. The slider definition used in your code has often been reported on the plotly forum as not working. An explicit slider definition is as follows:
sliders = [dict(steps= [dict(method= 'animate',
args= [[f'{k}'], #frame name
dict(mode= 'immediate',
frame= dict(duration=100, redraw= True ),
transition_duration= 0)],
label=f'frame{k+1}' #OPTIONAL
) for k in range(0, len(frames))],
transition_duration= 0,
x=0,
y=0,
currentvalue=dict(font=dict(size=12), visible=True, xanchor= 'center'),
len=1.0)
]
To increase the frame rate set frame['duration']=10
(0r 20, 30, by trial and error), and transition_duration=0
. The relationship between the two durations is as follows: The transition duration defines the amount of time spent interpolating a trace from one state to another(this is valid for scatter animation), while the frame duration defines the total time spent in that state, including time spent transitioning. Only scatter traces may be smoothly transitioned from one state to the next. Other trace types are updated instantaneously.
I couldn't reproduce your bug., because the link you posted is empty. The slider definition used in your code has often been reported on the plotly forum as not working. An explicit slider definition is as follows:
sliders = [dict(steps= [dict(method= 'animate', args= [[f'{k}'], #frame name dict(mode= 'immediate', frame= dict(duration=100, redraw= True ), transition_duration= 0)], label=f'frame{k+1}' #OPTIONAL ) for k in range(0, len(frames))], transition_duration= 0, x=0, y=0, currentvalue=dict(font=dict(size=12), visible=True, xanchor= 'center'), len=1.0) ]
To increase the frame rate set
frame['duration']=10
(0r 20, 30, by trial and error), andtransition_duration=0
. The relationship between the two durations is as follows: The transition duration defines the amount of time spent interpolating a trace from one state to another(this is valid for scatter animation), while the frame duration defines the total time spent in that state, including time spent transitioning. Only scatter traces may be smoothly transitioned from one state to the next. Other trace types are updated instantaneously.
Hi, thank you very much for your suggestion. I tried it but still nothing happens to the slider. It isn't updated with the play button and if I manually move the slider the frames aren't updated. Here is the link for the code (I already implemented your suggestion and my previous slider definition is commented). The mesh is quite big. Can the mesh size be related to the slow rendering when the play button is pressed? https://1drv.ms/u/s!AnfrICxwHeIiiehQ9i5wZ4LbSeKpsQ?e=oVsqFs
The slider definition I posted in the initial answer is a right one. I used it in tens animations.
args
definition in your updatemenus
is incomplete. It lacks the frame duration and transition duration, and plotly.js uses the default value of 500 for frame['duration']
. This makes your animation very slow,
updatemenus=[dict(type='buttons',
showactive=False,
buttons=[dict(
label='Play',
method='animate',
args=[None, dict(frame=dict(duration=150, redraw=True),
transition=dict(duration=0),
fromcurrent=True,
mode='immediate')])])]
frame['duration']
and transition['duration']
must have the same values as those in the sliders definition.
Your code contains many unnecessary settings, that are default settings in fig.layout
definition,
In zaxis
definition I commented out unnecessary attributes:
zaxis = dict(
#type = 'linear',
dtick = 100,
range = [332, 2134],
tick0 = 0,
title = dict(text = 'z_[m]'),
#showgrid = True,
#showline = True,
#tickmode = 'linear',
#zeroline = True,
autorange = False,
gridwidth = 5,
#tickangle = 0,
#tickprefix = '',
#ticksuffix = '',
#showticklabels = True,
backgroundcolor = '#eefbff')
Then camera
properties, up
, eye
, center
, projection
can be ommited, because you set the default dict for each one.
On Plotly forum you can find many answered questions and examples of animations, as models: https://community.plotly.com/search?q=animation%20category%3A10.
Hi @empet . Even with the full definition of updatemenus the slider doesn't work and the animation is still slow no matter what frame and transition duration I choose. In order to make the animation faster I had to change the plot from Mesh3d to Surface.
Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson
Hi I am struggling on trying to get the animation slider to work. Basically, my goal is to develop an animation of two UAVs (with given x,y,z coordinates over time) over a fixed mesh. The animation runs if I press the play button, but the slider isn't updated. The animation also takes to much time to run. Is there a way to reduce the rendering time? The full mesh data can be found on this link -> https://github.com/jvrs91/plotly.git