Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from mpl_toolkits.mplot3d import Axes3D
- from matplotlib.animation import FuncAnimation
- def update(frame):
- ax.clear()
- ax.set_xlim([-3,3])
- ax.set_ylim([-3,3])
- ax.set_zlim([-3,3])
- u, v = np.linspace(0, 2 * np.pi, 50), np.linspace(0, np.pi, 50)
- u, v = np.meshgrid(u, v)
- x = np.cos(u) * (1 + np.cos(v))
- y = np.sin(u) * (1 + np.cos(v))
- z = np.sin(v)
- ax.plot_surface(x, y, z, color='pink')
- ax.view_init(elev=30, azim=frame)
- fig = plt.figure()
- ax = fig.add_subplot(111, projection='3d')
- ani = FuncAnimation(fig, update, frames=360, interval=100)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement