Bird
0
0

Which of the following code snippets correctly initializes a 3D wireframe plot in matplotlib?

easy📝 Conceptual Q3 of 15
Matplotlib - 3D Plotting
Which of the following code snippets correctly initializes a 3D wireframe plot in matplotlib?
Afig = plt.figure() ax = fig.add_subplot(111) ax.plot_wireframe(X, Y, Z)
Bfig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_wireframe(X, Y, Z)
Cfig = plt.figure() ax = fig.add_subplot(111, projection='2d') ax.plot_wireframe(X, Y, Z)
Dfig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_surface(X, Y, Z)
Step-by-Step Solution
Solution:
  1. Step 1: Check subplot projection

    3D wireframe plots require 'projection="3d"' in add_subplot.
  2. Step 2: Check plotting method

    Use ax.plot_wireframe for wireframe plots, not plot_surface.
  3. Final Answer:

    fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_wireframe(X, Y, Z) -> Option B
  4. Quick Check:

    3D projection + plot_wireframe needed [OK]
Quick Trick: Use projection='3d' and plot_wireframe for 3D wireframes [OK]
Common Mistakes:
  • Omitting projection='3d' in add_subplot
  • Using plot_surface instead of plot_wireframe
  • Using 2D projection for 3D plots

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes