指定繪圖樣式
matplotlib 函式庫也提供多種內建樣式表,讓你自訂圖表的外觀。若要在繪圖時套用特定樣式表,可以使用指令 plt.style.use(your_stylesheet),其中 your_stylesheet 是樣式表的名稱。
若要查看可用的樣式表清單,可以使用 print(plt.style.available)。在本課程的其餘內容中,我們會使用很受歡迎的 fivethirtyeight 樣式表。
本練習屬於課程
使用 Python 視覺化時間序列資料
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import the matplotlib.pyplot sub-module
____
# Use the fivethirtyeight style
plt.____('fivethirtyeight')
# Plot the time series
ax1 = discoveries.plot()
ax1.set_title('FiveThirtyEight Style')
plt.show()