最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

matplotlib.pyplot.plot()參數(shù)使用詳解

 更新時(shí)間:2020年07月28日 11:14:25   作者:ims-  
這篇文章主要介紹了matplotlib.pyplot.plot()參數(shù)詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

在交互環(huán)境中查看幫助文檔:

import matplotlib.pyplot as plt
help(plt.plot)

以下是對(duì)幫助文檔重要部分的翻譯:

plot函數(shù)的一般的調(diào)用形式:

#單條線:
plot([x], y, [fmt], data=None, **kwargs)
#多條線一起畫
plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

可選參數(shù)[fmt] 是一個(gè)字符串來定義圖的基本屬性如:顏色(color),點(diǎn)型(marker),線型(linestyle),

具體形式  fmt = '[color][marker][line]'

fmt接收的是每個(gè)屬性的單個(gè)字母縮寫,例如:

plot(x, y, 'bo-') # 藍(lán)色圓點(diǎn)實(shí)線

若屬性用的是全名則不能用*fmt*參數(shù)來組合賦值,應(yīng)該用關(guān)鍵字參數(shù)對(duì)單個(gè)屬性賦值如:

plot(x,y2,color='green', marker='o', linestyle='dashed', linewidth=1, markersize=6)

plot(x,y3,color='#900302',marker='+',linestyle='-')

常見的顏色參數(shù):**Colors**

也可以對(duì)關(guān)鍵字參數(shù)color賦十六進(jìn)制的RGB字符串如 color='#900302'

 ============= ===============================
 character  color
 ============= ===============================
 ``'b'``   blue 藍(lán)
 ``'g'``   green 綠
 ``'r'``   red 紅
 ``'c'``   cyan 藍(lán)綠
 ``'m'``   magenta 洋紅
 ``'y'``   yellow 黃
 ``'k'``   black 黑
 ``'w'``   white 白
 ============= ===============================

點(diǎn)型參數(shù)**Markers**,如:marker='+' 這個(gè)只有簡(jiǎn)寫,英文描述不被識(shí)別

============= ===============================
 character  description
 ============= ===============================
 ``'.'``   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
 ============= ===============================

線型參數(shù)**Line Styles**,linestyle='-'

 ============= ===============================
 character  description
 ============= ===============================
 ``'-'``   solid line style 實(shí)線
 ``'--'``   dashed line style 虛線
 ``'-.'``   dash-dot line style 點(diǎn)畫線
 ``':'``   dotted line style 點(diǎn)線
 ============= ===============================

樣例1

函數(shù)原型:matplotlib.pyplot.plot(*args, scalex=True, scaley=True, data=None, **kwargs)

>>> plot('xlabel', 'ylabel', data=obj)

解釋:All indexable objects are supported. This could e.g. be a dict, a pandas.DataFame or a structured numpy array.

data 參數(shù)接受一個(gè)對(duì)象數(shù)據(jù)類型,所有可被索引的對(duì)象都支持,如 dict 等

import matplotlib.pyplot as plt 
import numpy as np
'''read file 
fin=open("para.txt")
a=[]
for i in fin:
 a.append(float(i.strip()))
a=np.array(a)
a=a.reshape(9,3)
'''
a=np.random.random((9,3))*2 #隨機(jī)生成y
 
y1=a[0:,0]
y2=a[0:,1]
y3=a[0:,2]
 
x=np.arange(1,10)
 
ax = plt.subplot(111)
width=10
hight=3
ax.arrow(0,0,0,hight,width=0.01,head_width=0.1, head_length=0.3,length_includes_head=True,fc='k',ec='k')
ax.arrow(0,0,width,0,width=0.01,head_width=0.1, head_length=0.3,length_includes_head=True,fc='k',ec='k')
 
ax.axes.set_xlim(-0.5,width+0.2)
ax.axes.set_ylim(-0.5,hight+0.2)
 
plotdict = { 'dx': x, 'dy': y1 }
ax.plot('dx','dy','bD-',data=plotdict)
 
ax.plot(x,y2,'r^-')
ax.plot(x,y3,color='#900302',marker='*',linestyle='-')
 
plt.show()

樣例2,

import matplotlib.pyplot as plt 
import numpy as np 
 
x = np.arange(0, 2*np.pi, 0.02) 
y = np.sin(x) 
y1 = np.sin(2*x) 
y2 = np.sin(3*x) 
ym1 = np.ma.masked_where(y1 > 0.5, y1) 
ym2 = np.ma.masked_where(y2 < -0.5, y2) 
 
lines = plt.plot(x, y, x, ym1, x, ym2, 'o') 
#設(shè)置線的屬性
plt.setp(lines[0], linewidth=1) 
plt.setp(lines[1], linewidth=2) 
plt.setp(lines[2], linestyle='-',marker='^',markersize=4) 
#線的標(biāo)簽
plt.legend(('No mask', 'Masked if > 0.5', 'Masked if < -0.5'), loc='upper right') 
plt.title('Masked line demo') 
plt.show()

例3 :圓

import numpy as np
import matplotlib.pyplot as plt
 
theta = np.arange(0, 2*np.pi, 0.01)
xx = [1,2,3,10,15,8]
yy = [1,-1,0,0,7,0]
rr = [7,7,3,6,9,9]
 
fig = plt.figure()
axes = flg.add_subplot(111)
 
i = 0
while i < len(xx):
 x = xx[i] + rr[i] *np.cos(theta)
 x = xx[i] + rr[i] *np.cos(theta)
 axes.plot(x,y)
 axes.plot(xx[i], yy[i], color='#900302', marker='*')
  i = i+1
width = 20
hight = 20
axes.arrow(0,0,0,hight,width=0.01,head_width=0.1,head_length=0.3,fc='k',ec='k')
axes.arrow(0,0,width,0,width=0.01,head_width=0.1,head_length=0.3,fc='k',ec='k')
plt.show()

 到此這篇關(guān)于matplotlib.pyplot.plot()參數(shù)詳解的文章就介紹到這了,更多相關(guān)matplotlib.pyplot.plot()內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • python實(shí)現(xiàn)逐個(gè)讀取txt字符并修改

    python實(shí)現(xiàn)逐個(gè)讀取txt字符并修改

    今天小編就為大家分享一篇python實(shí)現(xiàn)逐個(gè)讀取txt字符并修改,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-12-12
  • Linux下python與C++使用dlib實(shí)現(xiàn)人臉檢測(cè)

    Linux下python與C++使用dlib實(shí)現(xiàn)人臉檢測(cè)

    這篇文章主要為大家詳細(xì)介紹了Linux下python與C++使用dlib實(shí)現(xiàn)人臉檢測(cè),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • 簡(jiǎn)單介紹Python中的struct模塊

    簡(jiǎn)單介紹Python中的struct模塊

    這篇文章主要介紹了Python中的struct模塊,代碼基于Python2.x版本,需要的朋友可以參考下
    2015-04-04
  • Python中使用Selenium環(huán)境安裝的方法步驟

    Python中使用Selenium環(huán)境安裝的方法步驟

    這篇文章主要介紹了Python中使用Selenium環(huán)境安裝的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • python實(shí)現(xiàn)自冪數(shù)的示例代碼

    python實(shí)現(xiàn)自冪數(shù)的示例代碼

    這篇文章主要介紹了python實(shí)現(xiàn)自冪數(shù)的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • Python實(shí)現(xiàn)解析路徑字符串并獲取每個(gè)文件夾名稱

    Python實(shí)現(xiàn)解析路徑字符串并獲取每個(gè)文件夾名稱

    在?Python?中,解析路徑字符串并獲取每個(gè)文件夾的名稱是一項(xiàng)常見的任務(wù),這篇文章主要為大家詳細(xì)介紹了Python解析路徑字符串的具體方法,希望對(duì)大家有所幫助
    2024-04-04
  • Python機(jī)器學(xué)習(xí)之決策樹和隨機(jī)森林

    Python機(jī)器學(xué)習(xí)之決策樹和隨機(jī)森林

    本文主要介紹了機(jī)器學(xué)習(xí)之決策樹和隨機(jī)森林,詳細(xì)的介紹了實(shí)現(xiàn) 原理機(jī)器實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-07-07
  • pycharm中加了斷點(diǎn)卻無法調(diào)試,直接執(zhí)行到程序結(jié)束如何解決

    pycharm中加了斷點(diǎn)卻無法調(diào)試,直接執(zhí)行到程序結(jié)束如何解決

    這篇文章主要介紹了pycharm中加了斷點(diǎn)卻無法調(diào)試,直接執(zhí)行到程序結(jié)束如何解決問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • Python?如何引用不確定的函數(shù)

    Python?如何引用不確定的函數(shù)

    在Python中,引用不確定的函數(shù)通常意味著我們可能在運(yùn)行時(shí)才知道要調(diào)用哪個(gè)函數(shù),或者我們可能想根據(jù)某些條件動(dòng)態(tài)地選擇不同的函數(shù)來執(zhí)行,下面給大家分享Python?如何引用不確定的函數(shù),感興趣的朋友跟隨小編一起看看吧
    2024-07-07
  • Python基礎(chǔ)知識(shí)快速上手入門學(xué)習(xí)

    Python基礎(chǔ)知識(shí)快速上手入門學(xué)習(xí)

    本篇文章使用代碼示例,一看就會(huì),從基礎(chǔ)語法、變量類型、運(yùn)算符和條件語句多個(gè)方面詳細(xì)闡述了Python基礎(chǔ)知識(shí)快速上手入門學(xué)習(xí)的內(nèi)容,希望本文能對(duì)Python初學(xué)者有所幫助
    2023-08-08

最新評(píng)論

武平县| 中卫市| 龙海市| 三河市| 瑞丽市| 江永县| 阳城县| 册亨县| 德阳市| 丰城市| 鲁山县| 来安县| 体育| 紫阳县| 皋兰县| 高青县| 安吉县| 肃北| 贵德县| 大新县| 林芝县| 鸡东县| 海伦市| 沛县| 类乌齐县| 大冶市| 荥阳市| 虹口区| 宁南县| 沙雅县| 阜平县| 蓝山县| 延安市| 南雄市| 渝北区| 南通市| 桦川县| 珠海市| 稻城县| 博兴县| 丹凤县|