Bird
0
0

Which of the following is the correct way to save a matplotlib plot with 300 DPI resolution?

easy📝 Syntax Q12 of 15
Matplotlib - Export and Publication Quality
Which of the following is the correct way to save a matplotlib plot with 300 DPI resolution?
Aplt.savefig('plot.png', dpi='300')
Bplt.save('plot.png', dpi=300)
Cplt.savefig('plot.png', resolution=300)
Dplt.savefig('plot.png', dpi=300)
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct function to save plots

    The correct function to save a plot in matplotlib is plt.savefig().
  2. Step 2: Check the parameter for resolution

    The parameter to set resolution is dpi, so the correct syntax is plt.savefig('filename', dpi=300).
  3. Final Answer:

    plt.savefig('plot.png', dpi=300) -> Option D
  4. Quick Check:

    Use plt.savefig with dpi=300 = A [OK]
Quick Trick: Use plt.savefig(filename, dpi=number) to set resolution [OK]
Common Mistakes:
  • Using plt.save instead of plt.savefig
  • Using 'resolution' instead of 'dpi'
  • Passing dpi as a string '300'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes