使用 matplotlib.pyplot 介面
使用 Matplotlib 有很多種方式。本課程會專注在 pyplot 介面,因為它在建立與自訂資料視覺化時最具彈性。
一開始,會先用 pyplot 介面建立兩種物件:Figure 物件與 Axes 物件。
本課程會介紹許多新概念。若你需要快速複習,請下載並隨身參考 Matplotlib Cheat Sheet!
本練習屬於課程
Matplotlib 資料視覺化入門
練習說明
- 以慣用名稱
plt匯入matplotlib.pyplotAPI。 - 使用
plt.subplots函式建立Figure與Axes物件。 - 使用
plt.show函式顯示結果(空白的座標軸)。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import the matplotlib.pyplot submodule and name it plt
import ____ as ____
# Create a Figure and an Axes with plt.subplots
fig, ax = ____
# Call the show function to show the result
____