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, surface):
- ax.view_init(elev=30, azim=frame)
- return surface,
- fig = plt.figure()
- ax = fig.add_subplot(111, projection='3d')
- u, v = np.linspace(0, 2 * np.pi, 10), np.linspace(0, np.pi, 10)
- 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)
- surface = ax.plot_surface(x, y, z, color='pink')
- ax.set_xlim([-3,3])
- ax.set_ylim([-3,3])
- ax.set_zlim([-3,3])
- ani = FuncAnimation(fig, update, frames=360, fargs=(surface,), interval=20, blit=False,
- repeat=False, save_count=50)
- plt.show(block=False)
- # Switch to 'gloo' or 'agg' renderer for faster rendering
- plt.switch_backend('gloo')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement