Skip to content

Commit f1dd8dd

Browse files
authored
Add files via upload
1 parent a0d9df3 commit f1dd8dd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
from mpl_toolkits.mplot3d import Axes3D
4+
5+
# Define the range of x and y values
6+
x = np.linspace(-5, 5, 50) # Extending the range for more variation
7+
y = np.linspace(-5, 5, 50)
8+
9+
# Create meshgrid for X and Y
10+
X, Y = np.meshgrid(x, y)
11+
12+
# Calculate Z values for each combination of X and Y
13+
Z = np.sin(np.sqrt(X**2 + Y**2))
14+
15+
# Create the plot
16+
fig = plt.figure()
17+
ax = fig.add_subplot(111, projection='3d')
18+
19+
# Plot the surface with color map
20+
surface = ax.plot_surface(X, Y, Z, cmap='viridis')
21+
22+
# Add a colorbar with correct normalization
23+
fig.colorbar(surface, ax=ax, shrink=0.5, aspect=5)
24+
25+
# Set axis labels
26+
ax.set_xlabel('X axis')
27+
ax.set_ylabel('Y axis')
28+
ax.set_zlabel('Z axis')
29+
30+
# Display the plot
31+
plt.show()

0 commit comments

Comments
 (0)