【轉(zhuǎn)】Python應(yīng)用matplotlib.pyplot畫圖總結(jié)

部分一:

import numpy as np
import matplotlib.pyplot as plt

a = plt.subplot(1,1,1)
x = np.arange(0.,3.,0.1)

#這里b表示blue,g表示green,r表示red,-表示連接線,--表示虛線鏈接
a1 = a.plot(x, x, 'bx-', label = 'line 1')
a2 = a.plot(x, x**2, 'g^-', label = 'line2')
a3 = a.plot(x, x**3, 'gv-', label = 'line3')
a4 = a.plot(x, 3*x, 'ro-', label = 'line4')
a4 = a.plot(x, 2*x, 'r*-', label = 'line5')
a4 = a.plot(x, 2*x+1, 'ro--', label = 'line6')

#標(biāo)記圖的題目,x和y軸
plt.title("My matplotlib learning")
plt.xlabel("X")
plt.ylabel("Y")


#顯示圖例
handles, labels = a.get_legend_handles_labels()
a.legend(handles[::-1], labels[::-1])
plt.show()
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容