What is the syntax to create a 3D animation with Plotly in Python?

Hi,

I created an animation of N particles coordinates (x,y) moving as time goes. I used the grid and plotly.icreate_animations features.

I now would like to add f(x,y) (a real positive number) on the z-axis for each particle and keep the animated motion over time.
Thanks for any help, I can join the code if you’d like.

Hi @barnabe_corni,

You should be able to define animation frames in the same way that you are for the 2D case. But the smooth animated transitions are only supported for the scatter trace type right now. For other trace types the change between frames will be instantaneous.

-Jon

Hi @jmmease,
Thank you for your answer !
I tried as you said, by adding the line :

'zsrc': grid.get_column_reference('f3(x,y) à t = ' + str(j)),

below the lines concerning x and y, in the data section and in frame ones. I also changed the z-axis range but the plot created is still a 2D plot.

I have another request : is it possible to plot a 3D surface in the first place, instead of a few points ? I tried to mix the examples I find in Plotly’s website but the functions used are different (iplot and icreate_animations) but it didn’t work.

Thanks for your help

Hi @barnabe_corni,

To get a 3D scatter plot you need to specify the trace as a plotly.graph_objs.Scatter3d object or as a dict with a type: 'scatter3d' key.

Feel free to share a full reproducible example if you’d like to work through more of the details.

-Jon