Up to this point, we have used Matplotlib's high-level functions, such as plot(), to create graphs. In this section, we will show how to use objects of type Artist to draw arbitrary shapes in a plot.
In Matplotlib, every plot element is an object from the Artist class. There are two kinds of Artist objects:
- Containers are objects designed to contain other graphic elements. The most important types of container are Figure and Axes objects.
- Primitives represent elements that can be directly drawn in a container. These include objects of type Line2D, Patch, and Text, for example.
In the next recipe, we will see how to use Matplotilib's Artist interface to draw general shapes in a figure.