Plot the function $ z = e ^ {-(x ^ 2 + y ^ 2)} $ that can be represented by a 3D curved surface using matplotlib. Use plot_surface and plot_wireframe.
(1) surface plot
"""
Plot example of 3D curved surface
z=exp(-(x^2+y^2))
"""
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure() #Creating a plot area
ax = fig.gca(projection='3d') #Get the axes in the plot. gca is"Get Current Axes"Abbreviation for.
x = np.arange(-2, 2, 0.05) #As x points[-2, 2]Up to 0.Sample in 05 increments
y = np.arange(-2, 2, 0.05) #As y point[-2, 2]Up to 0.Sample in 05 increments
x, y = np.meshgrid(x, y) #Sampling points mentioned above(x,y)Mesh generation using
z = np.exp(-(x**2 + y**2)) #exp(-(x^2+y^2))Is calculated and stored in the zz coordinates.
ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='hsv', linewidth=0.3) #Surface plot. rstride and cstride represent the step size, cmap represents coloring, and linewidth represents the line thickness of the curved mesh.
plt.show() #Picture output.
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure() #Creating a plot area
ax = fig.gca(projection='3d') #Get the axes in the plot. gca is"Get Current Axes"Abbreviation for.
x = np.arange(-2, 2, 0.05) #As x points[-2, 2]Up to 0.Sample in 05 increments
y = np.arange(-2, 2, 0.05) #As y point[-2, 2]Up to 0.Sample in 05 increments
x, y = np.meshgrid(x, y) #Sampling points mentioned above(x,y)Mesh generation using
z = np.exp(-(x**2 + y**2)) #exp(-(x^2+y^2))Is calculated and stored in the zz coordinates.
ax.set_zlim(0.0,1.0)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.plot_wireframe(x, y, z, color='blue',linewidth=0.3) #Wireframe plot. linewidth represents the line thickness of the curved mesh.
plt.show() #Picture output.