進一步自訂繪圖
matplotlib API 支援許多常見的自訂,例如座標軸標籤、加入標題,以及設定範圍。讓我們再完成一個自訂化的練習。
本練習屬於課程
Seaborn 資料視覺化中級
練習說明
- 建立
fmr_1欄位的histplot。 - 將 x 軸標籤改為「1 Bedroom Fair Market Rent」。
- 將 x 軸範圍設定在 100 到 1500 之間。
- 在圖上加入描述性標題
"US Rent"。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a figure and axes
fig, ____ = plt.subplots()
# Plot the distribution of 1 bedroom rents
sns.____(df['fmr_1'], ax=____)
# Modify the properties of the plot
ax.set(xlabel="1 Bedroom Fair Market Rent",
xlim=(____,____),
____="US Rent")
# Display the plot
plt.show()