溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Python中plt畫圖函數(shù)怎么用

發(fā)布時(shí)間:2021-08-25 14:39:48 來(lái)源:億速云 閱讀:172 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要為大家展示了“Python中plt畫圖函數(shù)怎么用”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“Python中plt畫圖函數(shù)怎么用”這篇文章吧。

1、plt.legend

plt.legend(loc=0)#顯示圖例的位置,自適應(yīng)方式
說(shuō)明:

'best'   : 0, (only implemented for axes legends)(自適應(yīng)方式)
'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4,
'right'  : 5,
'center left' : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center'  : 10,

2、plt.figure

plt.figure(figsize=(14, 6), dpi=80)#設(shè)置繪圖區(qū)域的大小和像素

3、plt.xticks

plt.xticks(new_year)#設(shè)置x軸的刻度線為new_year,new_year可以為數(shù)組

4、plt.xlabel

plt.xlabel('year')#x軸標(biāo)簽

5、plt.plot

plt.plot(number, color='blue', label="actual value")#將實(shí)際值的折線設(shè)置為藍(lán)色

6、兩個(gè)圖分開

fig, axes = plt.subplots(2, 1, sharex=True,figsize=(10,10))
axes[0].plot(range (len(data20)),data20,'r')
axes[1].plot(range (len(data40)),data40,'b')

7、畫豎直線

plt.axvline(99, line, linewidth=4, color='r')#99表示橫坐標(biāo)

8、圖片保存

plt.savefig('timeseries_y.jpg')

以上是“Python中plt畫圖函數(shù)怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI