Matplotlib is a powerful drawing tool in Python and is often used in machine learning.
The first is the import
Import Matplotlib.pyplot as Plt
There are many ways to document the common methods in the PLT.
Plt.plot () This method is used to draw, the first parameter is the Y value, the second parameter is the X value, the third parameter is a string of two values, the first value is the color, the second value is the type of the line
The optional values for the color are
| ' B ' |
Blue |
| ' G ' |
Green |
| ' R ' |
Red |
| C |
Cyan |
| ' m ' |
Magenta |
| ' Y ' |
Yellow |
| K |
Black |
| ' W ' |
White |
The type of line has
‘-‘ |
Solid line Style |
‘--‘ |
Dashed line Style |
‘-.‘ |
Dash-dot Line Style |
‘:‘ |
Dotted line Style |
‘.‘ |
Point marker |
‘,‘ |
Pixel marker |
‘o‘ |
Circle Marker |
‘v‘ |
Triangle_down Marker |
‘^‘ |
TRIANGLE_UP Marker |
‘<‘ |
Triangle_left Marker |
‘>‘ |
Triangle_right Marker |
‘1‘ |
Tri_down Marker |
‘2‘ |
TRI_UP Marker |
‘3‘ |
Tri_left Marker |
‘4‘ |
Tri_right Marker |
‘s‘ |
Square Marker |
‘p‘ |
Pentagon marker |
‘*‘ |
Star Marker |
‘h‘ |
Hexagon1 Marker |
‘H‘ |
Hexagon2 Marker |
‘+‘ |
Plus marker |
‘x‘ |
X marker |
‘D‘ |
Diamond Marker |
‘d‘ |
Thin_diamond Marker |
‘|‘ |
VLine Marker |
‘_‘ |
Hline Marker |
such as ' R ' is the red dot
Multiple points can be drawn at once
Plt.plot ([1,2,3,4]) will draw a line through (0,1), (2,3), (3,4)
If no x value is specified, the default is 0, starting with a step of 1
Plt.axis ([xmin, xmax, ymin, ymax]) specify the starting and ending points of the X and Y axes
Plt.xlabel (' x ')
Plt.ylabel (' y ')
Specify a name for the x, Y axis, respectively
Plt.figure () draw multiple graphs, passing in an incrementing number
Plt.subplot (numrows, numcols, fignum) divides the diagram into numrows rows, numcols columns
PLT.CLF () Clear the points drawn before
PLT.CLA () clear the current axis
Plt.text (x1,x2,text) Add text at a point
Plt.title (title) take a title to the picture
Plt.show () shows the graph.
Official Document Http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot
Python Matplotlib.pyplot Learning Record