yy = randrange(n, 0, 100)
zz = randrange(n, -50, -25)
fig = plt.figure()
ax = Axes3D(fig)

def init():
    x = np.linspace(0, 100, 100)
y = np.linspace(0, 100, 100)
ax.scatter(xx, yy, zz, marker='o', s=20, c='goldenrod', alpha=0.6)

def animate(i):
    ax.view_init(elev=10.0, azim=i)
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=360,
    interval=20, blit=True)
anim.save('basic_animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])
Animate a rotating 3D graph in matplotlib