Complete the code to save the figure as a PNG file named 'plot.png'.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]('plot.png')
The savefig function saves the current figure to a file. Here, it saves as 'plot.png'.
Complete the code to save the figure as a PDF file named 'chart.pdf'.
import matplotlib.pyplot as plt plt.plot([10, 20, 30], [1, 4, 9]) plt.[1]('chart.pdf')
Use savefig to save the figure to a file. The file extension '.pdf' saves it as a PDF.
Fix the error in the code to save the figure as 'output.jpg'.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [3, 2, 1]) plt.[1]('output.jpg')
The correct function to save a figure is savefig, not save.
Fill both blanks to save the figure as a high-resolution PNG file named 'highres.png' with 300 dpi.
import matplotlib.pyplot as plt plt.plot([5, 10, 15], [2, 4, 6]) plt.[1]('highres.png', [2]=300)
Use savefig to save the figure. The dpi parameter sets the resolution in dots per inch.
Fill all three blanks to save the figure as 'custom.svg' with transparent background and tight bounding box.
import matplotlib.pyplot as plt plt.plot([7, 8, 9], [1, 3, 5]) plt.[1]('custom.svg', [2]=True, [3]='tight')
Use savefig to save the figure. The transparent=True makes the background transparent. The bbox_inches='tight' trims extra whitespace.