1. 程式人生 > 其它 >資料分析,先通過畫圖來掌握資料大概是什麼樣子(以預測溫度為例)

資料分析,先通過畫圖來掌握資料大概是什麼樣子(以預測溫度為例)

``` 資料格式

針對測溫的資料集進行畫圖,包括四個子圖,分別展示最高溫度圖,前一天的溫度,前兩天的溫度,效果如圖所示。

程式碼如下:

#指定預設風格
plt.style.use(‘fivethirtyeight’)
#設定佈局
fig, ((ax1,ax2),(ax3,ax4))=plt.subplots(nrows=2, ncols=2,figsize=(10,10))
fig.autofmt_xdate(rotation=45)
#標籤值
ax1.plot(dates, features[‘actual’])
ax1.set_xlabel(''); ax1.set_ylabel('Temperature'); ax1.set_title(‘Max Temp’)

#昨天
ax2.plot(dates, features[‘temp_1’])
ax2.set_xlabel(''); ax2.set_ylabel('Temperature'); ax2.set_title(‘Previous Max Temp’)

#前天
ax3.plot(dates, features[‘temp_2’])
ax3.set_xlabel('Date'); ax3.set_ylabel('Temperature'); ax3.set_title(‘Two Days Prior Max Temp’)

#朋友
ax4.plot(dates, features[‘friend’])
ax4.set_xlabel('Date'); ax4.set_ylabel('Temperature'); ax4.set_title(‘Friend Estimate’)


plt.tight_layout(pad=2)