Bird
0
0

Which of the following is the correct syntax to save a plot as a PDF file named 'chart.pdf'?

easy📝 Syntax Q12 of 15
Matplotlib - Export and Publication Quality
Which of the following is the correct syntax to save a plot as a PDF file named 'chart.pdf'?
Aplt.savefig('chart.pdf')
Bplt.save('chart.pdf')
Cplt.savefig('chart.pdf', format='png')
Dplt.savefig(chart.pdf)
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct function name

    The correct function to save a plot is plt.savefig().
  2. Step 2: Use correct string syntax for filename

    The filename must be a string, so it should be enclosed in quotes: 'chart.pdf'.
  3. Final Answer:

    plt.savefig('chart.pdf') -> Option A
  4. Quick Check:

    Correct function and string filename = plt.savefig('chart.pdf') [OK]
Quick Trick: Use plt.savefig('filename.ext') with quotes [OK]
Common Mistakes:
  • Omitting quotes around filename
  • Using plt.save() instead of plt.savefig()
  • Passing filename without quotes causing syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes