Python Matplotlib.pyplot Learning Record

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.