Pyplot matplotlib plot, pyplotmatplotlib

Source: Internet
Author: User

Pyplot matplotlib plot, pyplotmatplotlib

Matplotlib is actually a set of object-oriented drawing libraries. Each Drawing Element in the chart it draws, such as Line2D, Text, and scale, has an object corresponding to it in memory.
To facilitate rapid plotting, matplotlib provides a set of plotting APIs similar to MATLAB through the pyplot module, hiding the complex structures composed of many drawing objects in this set of APIs. You only need to call the functions provided by the pyplot module to quickly plot and set various chart details. Although the pyplot module is easy to use, it is not suitable for large applications.
To wrap the object-oriented drawing library into a function-only calling interface, the pyplot module stores information such as the current chart and the current subgraph. The Current chart and subgraph can be obtained using plt. gcf () and plt. gca (), indicating "Get Current Figure" and "Get Current Axes" respectively ". In the pyplot module, many functions process the current Figure or Axes object, for example:
Plt. plot () actually obtains the current Axes object ax through plt. gca (), and then calls the ax. plot () method to implement the real drawing.
You can enter "plt. plot?" In Ipython ?? "Command to view how the functions of the pyplot module wrap various drawing objects.

1. pyplot. plot (* args, ** kwargs)

This function has two parameters: a variable parameter and a named parameter. Variable parameters can be specified with three parameters, x, y, and line format strings. The following example shows some common combinations.

Plot (x, y) # plot x and y using default line style and color plot (x, y, 'bo') # plot x and y using blue circle markers plot (y) # plot y using x as index array 0 .. n-1 plot (y, 'r + ') # ditto, but with red plusses
If the name parameter is not used, you can set the x, y, Format String of any group, for example:
A. plot (x1, y1, 'G ^ ', x2, y2, 'g -')

The returned value type of plot is matplotlib. lines. Line2D object.
If you do not specify the plot, the default line and color will be used. The following shows the configurable values of the line and color.
Line Value
========================================================== ======= Character description ========================================== ======================='''-''' solid line ''' -- ''' dashed line style'' '-. '''dash-dot line style dotted line ''': ''' dotted line style dotted line '''. '''point marker Dots as dots ''', '''pixel marker ''' o '''circle marker as a point in the Blue circle '''v''' triangle_down marker lower triangle ''' ^ ''' triangle_up marker upper triangle points ''' <''' triangle_left marker '''> ''' triangle_right marker ''' 1' 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 ==== ========================================================== ===================================== character color ====================== ==== 'B' blue 'G' r'red' C' cyan 'M' magenta 'y' yellow 'K' black' w'white ==== ==================

The named parameter can be used to set the line attributes. Each attribute has a set _... method, which can be used to set the line label, line width, and so on.

The specified string format is just an abbreviation. You can set the line format in the form of naming parameters without the abbreviation. The example is as follows:

The attributes of the named parameter are the attributes of matplotlib. lines. Line2D.

 

 

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.