Plot function properties (from Matplotlib) __ function

Source: Internet
Author: User
Tags dashed line
Matplotlib.pyplot. Plot (*args, **kwargs)

Plot lines and/or markers to the Axes. Args is a variable length argument, allowing to multiple x, y pairs with a optional format string. For example, each of the following is legal:

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 x and/or Y is 2-dimensional, then the corresponding columns would be plotted.

An arbitrary number of x, Y, FMT groups can is specified, as in:

A.plot (x1, y1, ' g^ ', x2, y2, ' G ')

Return value are a list of lines that were added.

By default, the assigned a different color specified by a ' color cycle '. To change this behavior, you can edit the Axes.color_cycle rcparam. Alternatively, can use Set_default_color_cycle ().

The following format string characters are accepted to control the line style or marker:

character Description
'-' 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

The following color abbreviations are supported:

character Color
' B ' Blue
' G ' Green
' R ' Red
C Cyan
' m ' Magenta
' Y ' Yellow
K Black
' W ' White

In addition, your can specify colors in many weird and wonderful ways, including full names (' green '), Hex strings (' #00800 0 '), RGB or RGBA tuples ((0,1,0,1)) or grayscale intensities as a string (' 0.8 '). Of these, the string specifications can is used in place of a FMT group, but the tuple forms can is used only as Kwargs.

Line styles and colors are combined into a single format string, as in ' Bo ' for blue circles.

The Kwargs can is used to set line properties (any property that is has a set_* method). You can use this to set a line label (for Auto Legends), LineWidth, anitialising, marker face color, etc. This is example:

Plot ([1,2,3], [1,2,3], ' go-', label= ' line 1 ', linewidth=2)
plot ([1,2,3], [1,4,9], ' rs ',  label= ' Line 2 ')
Axis ([0, 4, 0, ten])
legend ()

If you do multiple lines with one plot command, the Kwargs apply to all those lines, e.g.:

Plot (x1, y1, x2, y2, Antialised=false)

Neither line would be antialiased.

You don't need to use format strings, which are just abbreviations. All of the line properties can is controlled by keyword arguments. For example, your can set the color, marker, LineStyle, and Markercolor with:

Plot (x, y, color= ' green ', linestyle= ' dashed ', marker= ' o ',
     markerfacecolor= ' Blue ', markersize=12).

Line2D for details.

The Kwargs are line2d properties:

property description
agg_filter unknown
Alpha Flo At (0.0 transparent through 1.0 opaque)
animated [True | False]
antialiased or aa [True | False]
axes an axes instance

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.