軸標籤!
在上一個練習中,你已經畫出 Iris versicolor 花瓣長度的不錯的長條圖,但你沒有標示座標軸! 沒關係;這不是你的錯,因為我們當時沒有要求你這麼做。現在,請使用 plt.xlabel() 與 plt.ylabel() 為圖形加上軸標籤。別忘了加上單位,並把這兩行指定給 _。matplotlib.pyplot 與 seaborn 已經用預設別名匯入。之後也會維持這個設定,除非特別說明。
本練習屬於課程
Statistical Thinking in Python (Part 1)
練習說明
- 加上座標軸標籤。記住,軸標籤應該一律包含單位。你的 \(y\) 軸標籤是
'count'。你的 \(x\) 軸標籤是'petal length (cm)'。單位非常關鍵! - 使用
plt.show()顯示依上述步驟建立的圖形。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot histogram of versicolor petal lengths
_ = plt.hist(versicolor_petal_length)
# Label axes
# Show histogram