Bird
0
0

What output will this code produce?

medium📝 Predict Output Q5 of 15
Matplotlib - 3D Plotting
What output will this code produce?
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot([0,1],[0,1],[0,1])
plt.show()
AAn error because plot does not support 3D
BA 2D line ignoring the z-axis
CA scatter plot of points (0,0,0) and (1,1,1)
DA 3D line from (0,0,0) to (1,1,1)
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the plot method on 3D axes

    The ax.plot method on 3D axes draws a line connecting the given 3D points.
  2. Step 2: Identify the points connected

    The points are (0,0,0) and (1,1,1), so a 3D line is drawn between them.
  3. Final Answer:

    A 3D line from (0,0,0) to (1,1,1) -> Option D
  4. Quick Check:

    3D plot line = A 3D line from (0,0,0) to (1,1,1) [OK]
Quick Trick: ax.plot with 3 lists draws 3D lines [OK]
Common Mistakes:
  • Assuming plot only works in 2D
  • Confusing plot with scatter
  • Expecting an error due to 3D data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes