fork download
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from mpl_toolkits.mplot3d import Axes3D
  4.  
  5. # Create a grid of x and y values
  6. x = np.linspace(-10, 10, 100)
  7. y = np.linspace(-10, 10, 100)
  8. X, Y = np.meshgrid(x, y)
  9.  
  10. # Compute the corresponding z values
  11. Z = np.sin(X) + np.cos(Y)
  12.  
  13. # Create a 3D plot
  14. fig = plt.figure()
  15. ax = fig.add_subplot(111, projection='3d')
  16. ax.plot_surface(X, Y, Z, cmap='viridis')
  17.  
  18. # Set labels and title
  19. ax.set_xlabel('X')
  20. ax.set_ylabel('Y')
  21. ax.set_zlabel('Z')
  22. ax.set_title('3D Plot of z = sin(x) + cos(y)')
  23.  
  24. # Display the plot
  25. plt.show()
  26.  
  27.  
Success #stdin #stdout 2.42s 59920KB
stdin
Standard input is empty
stdout
Standard output is empty