Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %matplotlib notebook
- from matplotlib import cm
- from mpl_toolkits.mplot3d import Axes3D
- import matplotlib.pyplot as plt
- import numpy as np
- fig = plt.figure()
- ax = fig.add_subplot(111, projection='3d')
- u=np.linspace(0,2*np.pi,100)
- v=np.linspace(0,2*np.pi,100)
- u,v=np.meshgrid(u,v)
- #body
- a = 3.8
- b = 4
- X = (b + a*np.cos(u)) * np.cos(v)
- Y = (b + a*np.cos(u)) * np.sin(v)
- Z = 5 * np.sin(u) +2*np.cos(u)
- #shin
- zz = np.linspace(2.5, 8, 100)
- Theta, z =np.meshgrid(v, zz)
- x = 1*np.cos(Theta)
- y = 1*np.sin(Theta)
- ax.set_xlabel('x axis')
- ax.set_ylabel('y axis')
- ax.set_zlabel('z axis')
- ax.set_xlim(-10,10)
- ax.set_ylim(-10,10)
- ax.set_zlim(-10,10)
- ax.set_aspect('equal')
- ax.plot_surface(X, Y, Z,alpha=0.8, cmap=cm.Reds)
- ax.plot_surface(x, y, z, color='k')
- ax.view_init(elev=20., azim=60)
- #fig.savefig("apple.png", dpi=150,transparent = False)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement