Complete the code to create a figure and a single axes using matplotlib.
import matplotlib.pyplot as plt fig, ax = plt.[1]()
The plt.subplots() function creates a figure and axes together.
Complete the code to set the title of the axes to 'My Plot'.
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.[1]('My Plot')
title() which is a pyplot function, not an axes method.show() which displays the plot.The set_title() method sets the title of the axes.
Fix the error in the code to plot a line on the axes.
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.[1]([1, 2, 3], [4, 5, 6]) plt.show()
show() as a method on axes which causes error.figure() which creates a new figure, not plotting.The plot() method draws a line plot on the axes.
Fill both blanks to create a figure with 2 rows and 1 column of axes.
import matplotlib.pyplot as plt fig, ax = plt.subplots([1], [2])
The arguments to plt.subplots() specify rows and columns of axes.
Fill both blanks to create a dictionary comprehension that maps each axes to its index if the index is greater than 0.
axes_dict = {ax:: i[1] i in range(3) if i [2] 0}This dictionary comprehension uses ax: i for i in range(3) if i > 0 syntax.
