import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = np.linspace(-np.pi,np.pi,50)
y = np.linspace(-np.pi,np.pi,50)
x, y = np.meshgrid(x, y)
ax.set_zlim(-1, 1)
axes=None
for phi in np.linspace(-np.pi,np.pi,50):
    if axes:
        ax.collections.remove(axes)
    z=np.cos(x+phi)*np.sin(y)
    axes=ax.plot_surface(x, y, z, rstride=2, cstride=2,cmap=plt.cm.rainbow)
    plt.pause(0.01)