• API
• FAQ
• Tools
• Archive
daily pastebin goal
28%
SHARE
TWEET

# Untitled

a guest Jan 12th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import numpy as np
2.
3. import matplotlib.pyplot as plt
4. from matplotlib import rcParams
5. from matplotlib.ticker import LinearLocator
6.
7. # use default Latex font for math even with matplotlib 2.0
8. rcParams['mathtext.fontset'] = 'cm'
9.
10. fig = plt.figure()
11. ax = fig.gca(projection='3d')
12.
13. # set the limits
14. xlim = (-2, 2)
15. ylim = (0, 2)
16. zlim = (0, 2)
17.
18. # Make data.
19. Y = np.linspace(ylim[0], ylim[1], 30)
20. Z = np.linspace(zlim[0], zlim[1], 30)
21. Z, Y = np.meshgrid(Z, Y)
22.
23. X = np.sqrt(Z * Y)
24.
25. # Plot the surface.
26. for x in [X, -X]:
27.     surf = ax.plot_surface(x, Y, Z, rstride=1, cstride=1,
29.                            linewidth=0.5, antialiased=True)
30.
31. ax.set_xlim(xlim)
32. ax.set_ylim(ylim)
33. ax.set_zlim(zlim)
34. ax.xaxis.set_major_locator(LinearLocator(3))
35. ax.yaxis.set_major_locator(LinearLocator(3))
36. ax.zaxis.set_major_locator(LinearLocator(3))
37.
38. # rotate view
39. ax.azim, ax.elev = -135, 20
40.
41. ax.set(xlabel=r'\$x\$', ylabel=r'\$y\$', zlabel=r'\$f(x,y)\$')
42. ax.set(title=r'Figure 3.3 - Graph of \$f(x,y)=x^2/y\$')
43. ax.grid('off')
44.
45. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top