Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Matplotlib - Export and Publication Quality
Identify the error in this code snippet:
plt.figure(figsize=6,4, dpi=150)
plt.plot([1,2,3])
plt.savefig('image.png')
Aplt.plot() requires two arguments
Bdpi cannot be set in plt.figure()
Cfigsize should be a tuple, not separate arguments
Dplt.savefig() must be called before plt.plot()
Step-by-Step Solution
Solution:
  1. Step 1: Check figsize parameter format

    figsize must be a tuple like (6,4), not two separate numbers.
  2. Step 2: Confirm dpi usage and plot syntax

    dpi is valid in plt.figure(), plt.plot() can take one argument, and plt.savefig() can be called after plotting.
  3. Final Answer:

    figsize should be a tuple, not separate arguments -> Option C
  4. Quick Check:

    figsize needs tuple (width,height) [OK]
Quick Trick: Pass figsize as a tuple: figsize=(width,height) [OK]
Common Mistakes:
  • Passing figsize as separate numbers
  • Misplacing dpi parameter
  • Wrong order of savefig and plot

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes