matplotlib principle drawing


1. Principle drawing

Here Insert Picture Description

2. The drawing area setting

When we need to draw a number of different patterns on a canvas figure, different graphs can be plotted in several different areas among the axes. There are three ways:

  • Call auto_subplot () object method by Figure
  • By subplot plt () method
  • By subplots plt () method

2.1 add_subplot method

  1. Creating a target figure, if not manually created, automatically created implicitly.
  2. Figure calling object auto_subplot () method number of rows, designated subregion and subregion to specify the current to be drawn which returns a child drawing object (axis object).
  3. By graphing child drawing object.
    Here Insert Picture Description

2.2 subplot method

  1. By calling subplot plt () method to create a sub-region of the drawing, the child returned drawing object.
  2. Figure implicitly created objects.
    Here Insert Picture Description

2.3 subplots method

  1. Created by invoking the subplots plt () method of the sub-drawing region, the method returns a tuple (Figure a drawing object and all child objects, if a plurality of drawing objects child, it returns an array ndarray).
  2. You can set whether or shared x-axis and y-axis by sharex shareyss.
    Here Insert Picture Description

3. scale settings

Or the setting information acquired by the related method plt scale objects.

  • plt.xlim Gets or sets the x-axis scale range
  • plt.ylim Gets or sets the y-axis scale range
  • plt.xticks Gets or sets the x-axis scale shows the numeric / text
  • plt.yticks Gets or sets the y-axis scale shows the numeric / text

plt.xlim plt.ylim and get or set the scale range
Here Insert Picture Description
plt.xticks plt.yticks and get or set the scale information
Here Insert Picture Description
may be provided through the sub-scale drawing object information.

  • The x-axis scale range set ax.set_xlim
  • acquiring the x-axis scale range ax.get_xlim
  • ax.set_xticks disposed in the x-axis scale
  • Get ax.get_xticks scale of the x-axis
  • Similarly as the y-axis

Example:
Here Insert Picture Description

Published 56 original articles · won praise 34 · views 3638

Guess you like

Origin blog.csdn.net/MicoOu/article/details/103991682