折線圖
也稱為趨勢圖,它使用直線線段將個數據點連接起來而組成的圖形,以折線方式顯示數據的變化趨勢。
折線圖繪制函數:
plot(x,y,style,color,linewidth)
title(“圖的標題”)
參數說明:
√ style,畫線的樣式
√ color,畫線的顏色
√ linewidth,線的寬度

1 import pandas 2 import matplotlib 3 from matplotlib import pyplot as plt 4 5 data=pandas.read_csv( 6 "D://Python//6.2//data.csv") 7 8 #對日期格式進行轉換 9 data["購買日期"]=pandas.to_datetime( 10 data["日期"]) 11 12 mainColor=(42/256, 87/256, 141/256, 1) 13 14 font={ 15 "size":20, 16 "family":"SimHei"} 17 18 matplotlib.rc("font",**font) 19 20 21 22 #%matplotlib qt 23 plt.xlabel( 24 "購買日期", 25 color=mainColor) 26 plt.ylabel( 27 "購買用戶數", 28 color=mainColor) 29 30 plt.tick_params( 31 axis="x", 32 colors=mainColor) 33 plt.tick_params( 34 axis="y", 35 colors=mainColor) 36 37 #"-" 順滑的曲線 38 plt.plot( 39 data["購買日期"], 40 data["購買用戶數"], 41 "-",color=mainColor) 42 43 plt.title("用戶天數") 44 plt.show() 45 46 47 #設置線條粗細 48 plt.plot( 49 data["購買日期"], 50 data["購買用戶數"], 51 "-",color=mainColor, 52 linewidth=10)