Complete the code to create a new figure using matplotlib.
import matplotlib.pyplot as plt fig = plt.[1]()
The plt.figure() function creates a new figure in matplotlib.
Complete the code to create a figure with a specific size of 8 by 6 inches.
import matplotlib.pyplot as plt fig = plt.figure(figsize=[1])
The figsize parameter takes a tuple with width and height in inches. So (8, 6) sets width 8 and height 6.
Fix the error in the code to create a figure with a title 'My Plot'.
import matplotlib.pyplot as plt fig = plt.figure() fig.[1]('My Plot')
The suptitle method sets the title for the whole figure, unlike set_title which is for axes.
Fill both blanks to create a figure with a size of 10 by 4 inches and a blue background color.
import matplotlib.pyplot as plt fig = plt.figure(figsize=[1], facecolor=[2])
The figsize parameter sets the figure size as a tuple, and facecolor sets the background color as a string.
Fill all three blanks to create a figure with a size of 12 by 5 inches, a green background, and a tight layout.
import matplotlib.pyplot as plt fig = plt.figure(figsize=[1], facecolor=[2]) fig.[3]()
The figsize should be a tuple with width then height, facecolor is a string for background color, and tight_layout() adjusts spacing automatically.