I want to make a double slit wave animation with plotly. The project below makes only one image. I have googled a lot but I cannot find the exact format of the few lines that I guess are necessary to make it an animation (tried something with frames…).

Any advice?

Poul Riis

Denmark

import plotly.graph_objs as go

import numpy as np

xp = np.linspace(0, 200, 401,endpoint=True)

yp = np.linspace(-100, 100, 401,endpoint=True)

tarray = np.linspace(0, 1, 11,endpoint=True)

xGrid, yGrid = np.meshgrid(xp, yp)

d=80

lambd=10

T=1

A=0.02

twopi=2*np.pi

k=twopi/lambd

dh=d/2

omega=twopi/T

x =yGrid # x = r*cos(s)*sin(t)
y = xGrid # y = r*sin(s)*sin(t)

def zz(t):

return A*(np.sin(np.sqrt(yGrid**2+(xGrid-dh)**2) k-omegat)+np.sin(np.sqrt(yGrid**2+(xGrid+dh)**2)

*k-omega*t))

z=zz(0.1)

surface = go.Surface(x=x, y=y, z=z)

data = [surface]

layout = go.Layout(

title=‘Parametric Plot’,

scene=dict(

xaxis=dict(

gridcolor=‘rgb(255, 255, 255)’,

zerolinecolor=‘rgb(255, 255, 255)’,

showbackground=True,

backgroundcolor=‘rgb(230, 230,230)’

),

yaxis=dict(

gridcolor=‘rgb(255, 255, 255)’,

zerolinecolor=‘rgb(255, 255, 255)’,

showbackground=True,

backgroundcolor=‘rgb(230, 230,230)’

),

zaxis=dict(

gridcolor=‘rgb(255, 255, 255)’,

zerolinecolor=‘rgb(255, 255, 255)’,

showbackground=True,

backgroundcolor=‘rgb(230, 230,230)’,

range = [-1,1]

),

)

)

#frames=[dict(data=[dict(x=x,y=y,z=zz(t))]) for t in tarray]

fig = go.Figure(data=data, layout=layout)

py.iplot(fig, filename=‘3d surface’)