Complete the code to create a figure with size 8 by 6 inches.
import matplotlib.pyplot as plt fig = plt.figure(figsize=[1]) plt.show()
The figsize parameter expects a tuple with width and height in inches, so (8, 6) is correct.
Complete the code to set the DPI (dots per inch) of the figure to 150.
import matplotlib.pyplot as plt fig = plt.figure(dpi=[1]) plt.show()
The dpi parameter controls the resolution of the figure. Setting it to 150 increases the detail.
Fix the error in the code to create a figure with size 10 by 4 inches and DPI 120.
import matplotlib.pyplot as plt fig = plt.figure(figsize=[1], dpi=120) plt.show()
The figsize must be a tuple, so (10, 4) is correct. Lists or sets cause errors.
Fill both blanks to create a figure with size 12 by 8 inches and DPI 100.
import matplotlib.pyplot as plt fig = plt.figure(figsize=[1], dpi=[2]) plt.show()
Use a tuple (12, 8) for figsize and set dpi to 100 for the desired resolution.
Fill all three blanks to create a figure with size 5 by 5 inches, DPI 200, and save it as 'output.png'.
import matplotlib.pyplot as plt fig = plt.figure(figsize=[1], dpi=[2]) fig.savefig([3]) plt.show()
Use (5, 5) for size, 200 for dpi, and save the figure as 'output.png'.