importmatplotlib.pyplotaspltimportnumpyasnpfig,ax=plt.subplots()# Create a figure containing a single Axes.ax.plot([1,2,3,4],[1,4,2,3])# Plot some data on the Axes.plt.show()
Figure
The whole figure. The Figure keeps track of all the child Axes, a group of 'special' Artists (titles, figure legends, colorbars, etc.), and even nested subfigures.
Axes
An Axes is an Artist attached to a Figure that contains a region for plotting data, and usually includes two (or three in the case of 3D) Axis objects
importmatplotlib.pyplotaspltimportnumpyasnpfig,axs=plt.subplots(2,2,figsize=(4,3),layout='constrained')forrowinrange(2):forcolinrange(2):axs[row,col].annotate(f'axs[{row}, {col}]',(0.5,0.5),transform=axs[row,col].transAxes,ha='center',va='center',fontsize=18,color='darkgrey')# ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # Plot some data on the Axes.plt.show()