Complete the code to create a figure and 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 plot data using the axes-level method.
fig, ax = plt.subplots() ax.[1]([1, 2, 3], [4, 5, 6]) plt.show()
The ax.plot() method plots data on the specific axes.
Fix the error in the code by choosing the correct figure-level method to set the title.
fig, ax = plt.subplots() ax.plot([1, 2, 3], [4, 5, 6]) fig.[1]('My Plot Title') plt.show()
The figure-level method to set a title for the whole figure is fig.suptitle().
Fill both blanks to set the x and y labels using axes-level methods.
fig, ax = plt.subplots() ax.plot([1, 2, 3], [4, 5, 6]) ax.[1]('X Label') ax.[2]('Y Label') plt.show()
plt.xlabel() and plt.ylabel(), which are pyplot functions.ax.xlabel(), which does not exist.The axes-level methods are ax.set_xlabel() and ax.set_ylabel().
Fill all three blanks to set titles on two subplots using axes-level methods and a main title using figure-level method.
fig, (ax1, ax2) = plt.subplots(1, 2) ax1.plot([1,2,3], [1,2,3]) ax1.[1]('Left Plot') ax2.plot([3,2,1], [1,2,3]) ax2.[2]('Right Plot') fig.[3]('Comparison') plt.show()
title() without set_ on axes.suptitle() on individual axes instead of figure.Use set_title() on each ax for subplot titles and suptitle() on fig for the main title.
