Complete the code to set the Agg backend in matplotlib for faster rendering.
import matplotlib matplotlib.use('[1]')
The Agg backend in matplotlib is a non-interactive backend that renders images quickly and is suitable for scripts and batch jobs.
Complete the code to save a plot as a PNG file using the Agg backend.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.savefig('[1]')
Saving the plot as a PNG file uses the Agg backend for fast raster image output.
Fix the error in the code to correctly set the Agg backend before importing pyplot.
import matplotlib matplotlib.use('[1]') import matplotlib.pyplot as plt plt.plot([1, 2], [3, 4])
The backend must be set before importing pyplot. The correct order is to import matplotlib, set the backend to Agg, then import pyplot.
Fill both blanks to create a figure and save it using the Agg backend.
import matplotlib matplotlib.use('[1]') import matplotlib.pyplot as plt fig = plt.[2]() fig.savefig('output.png')
Set the backend to Agg before importing pyplot. Use plt.figure() to create a figure object.
Fill all three blanks to set the Agg backend, create a plot, and save it as a PNG file.
import matplotlib matplotlib.use('[1]') import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[2]('[3]')
Set the backend to Agg before importing pyplot. Use savefig to save the plot as plot.png.