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 it as 'plot.png'.
Complete the code to save the figure with a resolution of 300 dots per inch (DPI).
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.savefig('plot.png', [1]=300)
The dpi parameter sets the resolution of the saved figure in dots per inch.
Fix the error in the code to save the figure as a PDF file named 'figure.pdf'.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]('figure.pdf')
The correct function to save figures in matplotlib is savefig. Other options like save or export do not exist.
Fill both blanks to save the figure as a JPEG file with a transparent background.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.savefig('image.jpg', [1]=[2])
The transparent parameter set to True saves the figure background as transparent.
Fill all three blanks to save the figure as a high-quality SVG file with a tight bounding box.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.savefig('diagram.svg', [1]=300, [2]='[3]')
Use dpi for resolution, bbox_inches set to 'tight' to reduce extra whitespace around the figure.