Figures and backends#

When looking at Matplotlib visualization, you are almost always looking atArtists placed on aFigure. In the example below, the figure is theblue region andadd_subplot has added anAxes artist to theFigure (seeParts of a Figure). A more complicated visualization can addmultiple Axes to the Figure, colorbars, legends, annotations, and the Axesthemselves can have multiple Artists added to them(e.g.ax.plot orax.imshow).

fig=plt.figure(figsize=(4,2),facecolor='lightskyblue',layout='constrained')fig.suptitle('A nice Matplotlib Figure')ax=fig.add_subplot()ax.set_title('Axes',loc='left',fontstyle='oblique',fontsize='medium')

(Sourcecode,2x.png,png)