0
0
Matplotlibdata~10 mins

3D surface plots in Matplotlib - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the 3D plotting toolkit from matplotlib.

Matplotlib
from mpl_toolkits.mplot3d import [1]
Drag options to blanks, or click blank then click option'
Aplot3d
Bplot_surface
Csurface3d
DAxes3D
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'plot3d' which does not exist.
Trying to import 'surface3d' or 'plot_surface' which are not importable classes.
2fill in blank
medium

Complete the code to create a 3D subplot in matplotlib.

Matplotlib
fig = plt.figure()
ax = fig.add_subplot(111, projection=[1])
Drag options to blanks, or click blank then click option'
A'3d'
B'3D'
C'2d'
D'surface'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase '3D' which causes an error.
Using '2d' which creates a 2D plot.
Using 'surface' which is not a valid projection.
3fill in blank
hard

Fix the error in the code to generate X, Y meshgrid for surface plotting.

Matplotlib
x = np.linspace(-5, 5, 50)
y = np.linspace(-5, 5, 50)
X, Y = np.[1](x, y)
Drag options to blanks, or click blank then click option'
Ameshgrid
Bmgrid
Clinspace
Darange
Attempts:
3 left
💡 Hint
Common Mistakes
Using mgrid which is an object, not a function.
Using linspace or arange which generate 1D arrays only.
4fill in blank
hard

Fill both blanks to complete the code that computes Z values for the surface plot.

Matplotlib
Z = np.sin(np.sqrt(X[1] + Y[2]))
Drag options to blanks, or click blank then click option'
A**2
B+
C*2
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or multiplication instead of squaring.
Using different operators for X and Y.
5fill in blank
hard

Fill all three blanks to create a 3D surface plot with labels.

Matplotlib
fig = plt.figure()
ax = fig.add_subplot(111, projection=[1])
ax.plot_surface(X, Y, Z, cmap=[2])
ax.set_xlabel([3])
Drag options to blanks, or click blank then click option'
A'3d'
B'viridis'
C'X axis'
D'2d'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '2d' as projection causing errors.
Using invalid colormap names.
Not using quotes around axis label.