1、plt.legend
plt.legend(loc=0)#顯示圖例的位置,自適應方式
說明:'best' : 0, (only implemented for axes legends)(自適應方式)'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)#設置繪圖區域的大小和像素
3、plt.xticks
plt.xticks(new_year)#設置x軸的刻度線為new_year,new_year可以為數組
4、plt.xlabel
plt.xlabel('year')#x軸標簽
5、plt.plot
plt.plot(number, color='blue', label="actual value")#將實際值的折線設置為藍色
6、兩個圖分開
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, linestyle="dotted", linewidth=4, color='r')#99表示橫坐標
8、圖片保存
plt.savefig('timeseries_y.jpg')
以上這篇對Python中plt的畫圖函數詳解就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林站長站。
新聞熱點
疑難解答