久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Python matplotlib Line2D對象怎么用

176次閱讀
沒有評論

共計 2915 個字符,預計需要花費 8 分鐘才能閱讀完成。

這篇文章主要介紹 Python matplotlib Line2D 對象怎么用,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

總括

matplotlib.pyplot 很像 MATLAB。它的每一個函數都會對現有的圖形進行更改:比如建立一個圖形(figure),創建畫圖區域,在畫圖區域做出線條,使用標簽裝飾。
如果你傳入了一個簡單的 list 或者 array,matplotlib 會把它當成 y 值,并自動生成 x 值。事實上所有序列都會被轉換為 numpy arrays。

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel(some numbers)
plt.show()

當你傳入兩個 list 或者 array 時,第一個會被當成 x 值,第二個會被當成 y 值,而且你可以通過第三個參數設置顯示的形狀和顏色(這是一個組合),當然你也可以分別設置形狀和顏色。通過 plt.axis(xmin, xmax, ymin, ymax)函數你可以設置 x 軸,y 軸的最大值和最小值:

import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16],  ro )
plt.axis([0, 6, 0, 20])
plt.show()

Line2D 對象 Line2D

Bases: matplotlib.artist.Artistclass matplotlib.lines.Line2D(xdata, ydata, linewidth=None, line > 屬性控制 

有三種方式設置線的屬性
1)直接在 plot()函數中設置

plt.plot(x, y, linewidth=2.0)

2)通過獲得線對象,對線對象進行設置

line, = plt.plot(x, y,  -)line.set_antialiased(False) # turn off antialising

3)獲得線屬性,使用 setp()函數設置

lines = plt.plot(x1, y1, x2, y2)# use keyword argsplt.setp(lines, color= r , linewidth=2.0)

PropertyValue Typealphafloatanimated[True False]antialiased or aa[True False]clip_boxa matplotlib.transform.Bbox instanceclip_on[True False]clip_patha Path instance and a Transform instance, a Patchcolor or cany matplotlib colorcontainsthe hit testing functiondash_capstyle[‘butt’‘round’‘projecting’]dash_joinstyle[‘miter’‘round’‘bevel’]dashessequence of on/off ink in pointsdata(np.array xdata, np.array ydata)figurea matplotlib.figure.Figure instancelabelany stringlinestyle or ls[‘-’‘–’‘-.’‘:’‘steps’…]linewidth or lwfloat value in pointslod[True False]marker[‘+’‘,’‘.’‘1’‘2’‘3’‘4’]markeredgecolor or mecany matplotlib colormarkeredgewidth or mewfloat value in pointsmarkerfacecolor or mfcany matplotlib colormarkersize or msfloatmarkevery[None integer (startind, stride) ]pickerused in interactive line selectionpickradiusthe line pick selection radiussolid_capstyle[‘butt’‘round’‘projecting’]solid_joinstyle[‘miter’‘round’‘bevel’]transforma matplotlib.transforms.Transform instancevisible[True False]xdatanp.arrayydatanp.arrayzorderany numberlinestyledescription‘-‘?or?’solid’solid line‘–’?or?’dashed’dashed line‘-.’?or?’dashdot’dash-dotted line‘:’?or?’dotted’dotted line‘None’draw nothing‘?’draw nothing”draw nothingmarkerdescription“.”point“,”pixel“o”circle“v”triangle_down“^”triangle_up“”triangle_left“”triangle_right“1”tri_down“2”tri_up“3”tri_left“4”tri_right“8”octagon“s”square“p”pentagon“P”plus (filled)“*”star“h”hexagon1“H”hexagon2“+”plus“x”x“X”x (filled)“D”diamond“d”thin_diamond“““_”hlineTICKLEFTtickleftTICKRIGHTtickrightTICKUPtickupTICKDOWNtickdownCARETLEFTcaretleft (centered at tip)CARETRIGHTcaretright (centered at tip)CARETUPcaretup (centered at tip)CARETDOWNcaretdown (centered at tip)CARETLEFTBASEcaretleft (centered at base)CARETRIGHTBASEcaretright (centered at base)CARETUPBASEcaretup (centered at base)“None”,?”?”?or?”“nothing‘...’render the string using mathtext.vertsa list of (x, y) pairs used for Path vertices. The center of the marker is located at (0,0) and the size is normalized.patha?Path?instance.

以上是“Python matplotlib Line2D 對象怎么用”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注丸趣 TV 行業資訊頻道!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-17發表,共計2915字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 宜昌市| 桓仁| 冕宁县| 连州市| 新宁县| 孙吴县| 石屏县| 黑河市| 敦化市| 仪陇县| 五家渠市| 墨竹工卡县| 雷山县| 大悟县| 即墨市| 高阳县| 耒阳市| 高雄县| 九寨沟县| 贺兰县| 阜宁县| 麻江县| 阿尔山市| 中山市| 伊川县| 兴海县| 馆陶县| 宿松县| 郯城县| 曲阜市| 余庆县| 静宁县| 金塔县| 应城市| 西吉县| 洞头县| 阜新| 章丘市| 灵寿县| 康马县| 东平县|