File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Python_Begginer_Projects/Amazing Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments