This article introduces the graph structure and various artists in matplotlib.
I used to know how to use pyplot to draw a graph. I didn't understand pyplot. Now I want to understand it.
In pyplot (or a more comprehensive matplotlib), there are two types of artists. One is primitives, an element that indicates the standard image object we want to draw, like line2d (2D curves), rectangle, text, axesimage, etc. The other is containers, which is used to store elements such as axis, axes, and figure.
Each artist has many attributes that can be set, as shown in,
Here there are content related to boudningbox, which may be used later.
Since each artist has these attributes, you can set them. The container can be set directly. What about primitives? Since the container contains primitives, you can get the primitives from the container and set them. The following describes the container.
The top layer is figure, which contains all the content in the drawn image. The content is
Then there is the most important axes, because it is the drawing area in most cases, through the plot (), text (), hist (), imshow () and so on, to create image elements, the previously used subplot is a special type of axes.
The primitives added in axes are implemented by the following method,
Like figure, axes acts as containers and includes the following attributes,
The axis is located at the bottom of the axes. You can set the attributes of the axis,
There is also the last layer under Axis. Tick is the scale, annotation, and so on above the axis. Therefore, it is related to the image to have two coordinate axes, or to switch the coordinate axes from the left to the right.
This part is actually the ninth chapter of the matplotlib manual. For more information, see the manual.