將各時間序列畫在各自的圖上
把各個時間序列分別畫在不同的圖上,常能提高清晰度,並為 DataFrame 中的每條時間序列提供更多脈絡。
你可以透過將 subplots 參數設為 True,把每條時間序列「分面」成獨立圖,再排成一個「格狀」配置。此外,還可以搭配以下參數:
layout:指定要使用的「列 x 行」數量。sharex與sharey:指定各子圖是否共用 x 軸與 y 軸的刻度值。
本練習屬於課程
使用 Python 視覺化時間序列資料
練習說明
- 以 2 列 4 行的版面配置,為
meatDataFrame 建立分面圖。 - 確保各子圖之間不共用 x 軸與 y 軸的刻度值。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a facetted graph with 2 rows and 4 columns
meat.plot(subplots=____,
layout=____,
sharex=____,
sharey=____,
colormap='viridis',
fontsize=2,
legend=False,
linewidth=0.2)
plt.show()