【網易雲課堂】之Matplotlib(二)折線圖

一、畫數據

1.1 plt.plot(x, y)

在這裏插入圖片描述

1.2 plt.plot(y)

當只有y而x缺省時,x默認爲range(len(y))
在這裏插入圖片描述

二、線條

2.1 線條類型

在這裏插入圖片描述

2.2 plt.plot(color=)線條顏色

在這裏插入圖片描述

2.3 plt.plot(linewidth=)線條寬度

np.linspace線性構造數據,參考博文:https://blog.csdn.net/u010916338/article/details/105325982
在這裏插入圖片描述

2.4 關鍵點設置(實際數據點)

2.4.1 plt.plot(marker=)關鍵點類型

在這裏插入圖片描述

2.4.3 plt.plot(markersize=)關鍵點顏色

在這裏插入圖片描述

2.4.2 plt.plot(markerfacecolor=)關鍵點大小

在這裏插入圖片描述

三、設置x軸和y軸

3.1 plt.xlabel()設置x軸標籤名

在這裏插入圖片描述

3.2 plt.ylabel()設置y軸標籤名

在這裏插入圖片描述

3.3 plt.xlabel(fontsize=)設置x軸y軸標籤名字體大小

在這裏插入圖片描述

四、plt.title()設置圖title主題

在這裏插入圖片描述

五、plt.grid()設置網格線

在這裏插入圖片描述

六、多圖重疊

np.arange等距離構造數據,參考博文:https://blog.csdn.net/u010916338/article/details/105325982
在這裏插入圖片描述

七、plt.subplot()子圖

在這裏插入圖片描述

八、plt.annotate()添加註釋

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