Bird
0
0

Why does this code produce a blurry saved image?

medium📝 Debug Q7 of 15
Matplotlib - Export and Publication Quality
Why does this code produce a blurry saved image?
fig = plt.figure(figsize=(8,6))
plt.plot([1,2,3])
fig.savefig('plot.png')

Assuming default DPI is 100.
ABecause figsize is too small
BBecause the DPI is too low for the large figure size
CBecause plt.plot() needs more data points
DBecause savefig() was called without a filename
Step-by-Step Solution
Solution:
  1. Step 1: Understand default DPI effect

    Default DPI is 100, so large figure size (8x6 inches) results in 800x600 pixels.
  2. Step 2: Relate DPI to image sharpness

    800x600 pixels may be low resolution for large images, causing blurriness.
  3. Final Answer:

    Because the DPI is too low for the large figure size -> Option B
  4. Quick Check:

    Low DPI + large size = blurry image [OK]
Quick Trick: Increase dpi for large figures to avoid blur [OK]
Common Mistakes:
  • Blaming figsize size alone
  • Thinking plot data affects sharpness
  • Ignoring dpi in savefig

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes