Complete the code to import the 3D plotting toolkit from matplotlib.
from mpl_toolkits.mplot3d import [1]
The 3D plotting toolkit in matplotlib is imported using Axes3D from mpl_toolkits.mplot3d.
Complete the code to create a 3D subplot in matplotlib.
fig = plt.figure() ax = fig.add_subplot(111, projection=[1])
To create a 3D subplot, the projection parameter must be set to the string '3d' (all lowercase).
Fix the error in the code to generate X, Y meshgrid for surface plotting.
x = np.linspace(-5, 5, 50) y = np.linspace(-5, 5, 50) X, Y = np.[1](x, y)
mgrid which is an object, not a function.linspace or arange which generate 1D arrays only.The function np.meshgrid creates coordinate matrices from coordinate vectors, which is needed for 3D surface plots.
Fill both blanks to complete the code that computes Z values for the surface plot.
Z = np.sin(np.sqrt(X[1] + Y[2]))
To compute Z, we square X and Y, then add them inside the square root. So both blanks should be **2.
Fill all three blanks to create a 3D surface plot with labels.
fig = plt.figure() ax = fig.add_subplot(111, projection=[1]) ax.plot_surface(X, Y, Z, cmap=[2]) ax.set_xlabel([3])
The projection must be '3d' for 3D plotting. The colormap 'viridis' is a common choice. The x-axis label should be a string like 'X axis'.