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



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