Advertisement
ikizid

3D ääriviiva

Jul 3rd, 2025
140
0
25 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. # FaceBook https://www.facebook.com/photo/?fbid=1179971490823734&set=a.456019453218945
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. from mpl_toolkits.mplot3d import Axes3D
  5.  
  6. x = np.linspace(-5, 5, 100)
  7. y = np.linspace(-5, 5, 100)
  8. X, Y = np.meshgrid(x, y)
  9.  
  10. def f(x, y):
  11.     return np.sin(np.sqrt(x**2 + y**2))
  12.  
  13. Z = f(X, Y)
  14.  
  15. fig = plt.figure(figsize=(8, 6))
  16. ax = fig.add_subplot(111, projection='3d')
  17. contour = ax.contour3D(X, Y, Z, 50, cmap='viridis')
  18.  
  19. # Add labels and colorbar
  20. ax.set_xlabel('X-axis')
  21. ax.set_ylabel('Y-axis')
  22. ax.set_zlabel('Z-axis')
  23. fig.colorbar(contour, ax=ax, label='Z values')
  24. plt.show()
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement