Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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.
- import matplotlib
- import matplotlib.pyplot as plt
- import numpy as np
- %matplotlib inline
- from mpl_toolkits.mplot3d.axes3d import Axes3D
- %matplotlib notebook
- (-1 * (2**-1)/2, -1 * (2**-1)/2, 1 + 2**-1)
- '''Prepare the figure container'''
- fig = plt.figure()
- ax = fig.add_subplot(111, projection='3d')
- '''Prepare the 2D domain: x from -1 to 1 and y from -1 to 1'''
- x,y = np.meshgrid(np.linspace(-2,2,41),np.linspace(-2,2,41))
- t = np.linspace(0, 2*np.pi)
- X = np.cos(t)
- Y = np.sin(t)
- z1 = 1 - x - y
- x2=np.linspace(-1,1,40)
- z2=np.linspace(-2,2,40)
- X2, Z2=np.meshgrid(x2,z2)
- Y2=np.sqrt(1-X2**2)
- ax.plot_wireframe(X2,Y2,Z2)
- ax.plot_wireframe(X2,-Y2,Z2)
- '''Plot the surface'''
- ax.plot_wireframe(x,y,z1,color="red")
- '''Set all labels, view, and then plot'''
- ax.set_xlabel('x')
- ax.set_ylabel('y')
- ax.set_zlabel('f(x,y)')
- #ax.set_xticks([-1,-0.5,0,0.5,1])
- #ax.set_yticks([-1,-0.5,0,0.5,1])
- #ax.set_zticks([-1,-0.5,0,0.5,1])
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement