Animating moving sphere

I want to create an animation of a moving sphere in matplotlib. This is what I've wrote so far

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
from matplotlib import cm
from matplotlib import animation
import pandas as pd


fig = plt.figure(facecolor='black')
ax = plt.axes(projection = "3d")

u = np.linspace(0, 2*np.pi, 100)
v = np.linspace(0, np.pi, 100)
r = 4

ax.set_xlim(0, 60)
ax.set_ylim(0, 60)
ax.set_zlim(0, 60)

x0 = r * np.outer(np.cos(u), np.sin(v)) + 10
y0 = r * np.outer(np.sin(u), np.sin(v)) + 10
z0 = r * np.outer(np.ones(np.size(u)), np.cos(v)) + 50

def init():
    ax.plot_surface(x0,y0,z0)
    return fig,

def animate(i):
    ax.plot_surface(x0 + 1, y0 + 1, z0 + 10)
    return fig,

ani = animation. FuncAnimation(fig, animate, init_func = init, frames = 90, interval = 300)


plt.show()

Here, I have attempted to move the sphere by (1,1,1) in each new iteration, but it fails to do so.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum