Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. %matplotlib notebook
  2. from matplotlib import cm
  3. from mpl_toolkits.mplot3d import Axes3D
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6.  
  7. fig = plt.figure()
  8. ax = fig.add_subplot(111, projection='3d')
  9.  
  10. u=np.linspace(0,2*np.pi,100)
  11. v=np.linspace(0,2*np.pi,100)
  12. u,v=np.meshgrid(u,v)
  13.  
  14. #body
  15. a = 3.8
  16. b = 4
  17. X = (b + a*np.cos(u)) * np.cos(v)
  18. Y = (b + a*np.cos(u)) * np.sin(v)
  19. Z = 5 * np.sin(u) +2*np.cos(u)
  20.  
  21. #shin
  22. zz = np.linspace(2.5, 8, 100)
  23. Theta, z =np.meshgrid(v, zz)
  24. x = 1*np.cos(Theta)
  25. y = 1*np.sin(Theta)
  26.  
  27. ax.set_xlabel('x axis')
  28. ax.set_ylabel('y axis')
  29. ax.set_zlabel('z axis')
  30. ax.set_xlim(-10,10)
  31. ax.set_ylim(-10,10)
  32. ax.set_zlim(-10,10)
  33. ax.set_aspect('equal')
  34.  
  35. ax.plot_surface(X, Y, Z,alpha=0.8, cmap=cm.Reds)
  36. ax.plot_surface(x, y, z, color='k')
  37. ax.view_init(elev=20., azim=60)
  38. #fig.savefig("apple.png", dpi=150,transparent = False)
  39.  
  40. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement