Skip to main contentSkip to solution

A figure can also be saved by using __________ function in Python.

Solution

✅ Correct Option: 2

In Matplotlib, the savefig() function from pyplot saves the current figure to a file, for example plt.savefig("chart.png"). The file format (png, pdf, jpg, etc.) is taken from the file extension.

Call savefig() before show(), because show() can clear the figure and leave a blank saved file.


Option 1: plot() only draws the line graph and does not save anything.

Options 3 and 4: graph() and savegraph() do not exist in Matplotlib.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question