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:
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.savefig('figure.jpg', rasterized=True)
Arasterized parameter is invalid for savefig
BJPEG does not support vector output
Cplot function cannot save images
DFile extension must be .png
Step-by-Step Solution
Solution:
  1. Step 1: Understand JPEG format

    JPEG is a raster format and does not support vector graphics.
  2. Step 2: Check rasterized parameter effect

    rasterized=True is ignored for JPEG since it's always raster.
  3. Final Answer:

    JPEG does not support vector output -> Option B
  4. Quick Check:

    JPEG format = Raster only [OK]
Quick Trick: JPEG is always raster, vector options ignored [OK]
Common Mistakes:
  • Thinking rasterized invalid
  • Confusing file extensions
  • Assuming plot can't save

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes