#範例11-9:畫圖股票線圖(讀取AAPL.xlsx股票檔案) #使用Matplotlib模組 #結合pandas 與 matplotlib = df.plot(x='..',y='..',color='red') import pandas as pd import matplotlib.pyplot as plt #畫圖-line:Date vs Close (預設 kind= line) df = pd.read_excel('AAPL.xlsx','AAPL') #plt.plot([1,2,3,4,5,6]) df.plot(x='Date', y='Close',grid=True, color='red',label='Close') #df.plot(x=df['Date'], y=df['Close'],grid=True, color='red') plt.show() #畫圖-bar:Date vs Close (kind= scatter) #line線圖,bar柱狀圖,scatter散佈圖,bar水平柱狀圖,hist直方圖,box盒鬚圖 df.plot(x='Date', y='Close',grid=True, color='red',label='Close',kind='scatter') plt.show() #在同一圖fig,同一個軸ax,畫出三條線(Open,Close,High) labels = ['Open','Close','High'] fig,ax = plt.subplots() for name in labels: df.plot(x='Date',y=name, ax=ax, label=name) plt.show()