Advertisement
UF6

Group Project 2, Problem 18

UF6
May 4th, 2016
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. #I have the problem done out if you need it. Plotting In 3D has the code you need for the line. I'm also going to add some notes to these later.
  2.  
  3. import matplotlib
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. %matplotlib inline
  7. from mpl_toolkits.mplot3d.axes3d import Axes3D
  8. %matplotlib notebook
  9.  
  10. (-1 * (2**-1)/2, -1 * (2**-1)/2, 1 + 2**-1)
  11.  
  12. '''Prepare the figure container'''
  13. fig = plt.figure()
  14. ax = fig.add_subplot(111, projection='3d')
  15.  
  16. '''Prepare the 2D domain: x from -1 to 1 and y from -1 to 1'''
  17. x,y = np.meshgrid(np.linspace(-2,2,41),np.linspace(-2,2,41))
  18. t = np.linspace(0, 2*np.pi)
  19. X = np.cos(t)
  20. Y = np.sin(t)
  21. z1 = 1 - x - y
  22.  
  23. x2=np.linspace(-1,1,40)
  24. z2=np.linspace(-2,2,40)
  25.  
  26. X2, Z2=np.meshgrid(x2,z2)
  27. Y2=np.sqrt(1-X2**2)
  28.  
  29. ax.plot_wireframe(X2,Y2,Z2)
  30. ax.plot_wireframe(X2,-Y2,Z2)
  31.  
  32.  
  33. '''Plot the surface'''
  34. ax.plot_wireframe(x,y,z1,color="red")
  35.  
  36.  
  37.                
  38. '''Set all labels, view, and then plot'''
  39. ax.set_xlabel('x')
  40. ax.set_ylabel('y')
  41. ax.set_zlabel('f(x,y)')
  42. #ax.set_xticks([-1,-0.5,0,0.5,1])
  43. #ax.set_yticks([-1,-0.5,0,0.5,1])
  44. #ax.set_zticks([-1,-0.5,0,0.5,1])
  45. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement