mesh cannot be animated, but surf can
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 316
- Avg merge
- 7h 44m
- Merged PRs (30d)
- 5
Description
When using p = mlab.mesh(x, y, prob_2d), just the colormap is animated, but when using surf the gauss package is moving (like expected)
`
import numpy as np
import time
from mayavi import mlab
def psi_gauss_2d(x, y, a=1.0, x_0=0.0, y_0=0.0, k_0=0.0):
return ((a * np.sqrt(np.pi)) ** (-0.5) * np.exp(-0.5 * (((x - x_0) * 1.0) ** 2
+ ((y - y_0) * 1.0) ** 2) / (a ** 2) + 1j * x * k_0))
fig = mlab.figure()
L = 5
x, y = np.mgrid[-L:L:100j, -L:L:100j]
prob_2d = np.abs(psi_gauss_2d(x, y)) ** 2
p = mlab.mesh(x, y, prob_2d)
for i in range(0, 10, 1):
sc = 1.1 ** i * np.abs(psi_gauss_2d(x, y, x_0=0.5 * i)) ** 2
p.mlab_source.trait_set(scalars=sc)
mlab.savefig("anim_%02d.png" % i)
time.sleep(0.05)
`
mesh:


surf:

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.