matplotlib.pyplot.plot()

matplotlib.pyplot.plot()是matplotlib库中的一个函数,plot有绘图之意,py是python的简写。

matplotlib.pyplot.plot(*args, **kwargs)
    下面是plot函数得两种形式,plot把x与y画成线,或者标记(Plot y versus x as lines and/or markers),第二种形式在一个图中要画出多条线的话可以用,同样也可以重复使用形式一达到目的
plot([x], y, [fmt], data=None, **kwargs)
plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)其中可以缺少x的数据,会自动以自然数的形式补齐(0,1......n)

1.输入数据类型

    (1)x 和 y 都是一维列表或数组;

    (2)x 是n*1数组或列表,y是一维长度为n的数组或列表;

    (3)x是m*n数组或列表,y是m*1列表或数组。如下例子,画出的图如下。

会产生20个点,十对。

x = [[-0.07816532  0.05068012  0.07786339  0.05285819  0.07823631  0.0644473
   0.02655027 -0.00259226  0.04067226 -0.00936191]
 [ 0.0090156   0.05068012 -0.03961813  0.0287581   0.03833367  0.0735286

  -0.07285395  0.1081111   0.01556684 -0.04664087]]

y = [ 201.12401963  150.05917612]

matplotlib.pyplot.plot(x,y)


2.fmt是shortcut string notation ,其形式为 

    fmt = '[color][marker][line]',颜色,点标记类型,画线类型。

    (1)颜色表:

charactercolor
'b'blue
'g'green
'r'red
'c'cyan
'm'magenta
'y'yellow
'k'black
'w'white

    (2)点类型

characterdescription
'.'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

    (3)线条类型

characterdescription
'-'solid line style
'--'dashed line style
'-.'dash-dot line style
':'dotted line style

3.**kwargs包含fmt,如果即在fmt中定义了,然后又重复在**kwargs中定义,那么以**kwargs为准

PropertyDescription
agg_filtera filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alphafloat (0.0 transparent through 1.0 opaque)
animatedbool
antialiased or aabool
clip_boxBbox instance
clip_onbool
clip_path[(PathTransform) | Patch | None]
color or cany matplotlib color
containsa callable function
dash_capstyle[‘butt’ | ‘round’ | ‘projecting’]
dash_joinstyle[‘miter’ | ‘round’ | ‘bevel’]
dashessequence of on/off ink in points
drawstyle[‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’]
figureFigure instance
fillstyle[‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’]
gidan id string
labelobject
linestyle or ls[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
linewidth or lwfloat value in points
markerA valid marker style
markeredgecolor or mecany matplotlib color
markeredgewidth or mewfloat value in points
markerfacecolor or mfcany matplotlib color
markerfacecoloralt or mfcaltany matplotlib color
markersize or msfloat
markevery[None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]
path_effectsAbstractPathEffect
pickerfloat distance in points or callable pick function fn(artist,event)
pickradiusfloat distance in points
rasterizedbool or None
sketch_params(scale: float, length: float, randomness: float)
snapbool or None
solid_capstyle[‘butt’ | ‘round’ | ‘projecting’]
solid_joinstyle[‘miter’ | ‘round’ | ‘bevel’]
transformmatplotlib.transforms.Transform instance
urla url string
visiblebool
xdata1D array
ydata1D array
zorderfloat



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章