設定預設樣式
在這些練習中,我們會查看由美國住房與都市發展部(US Housing and Urban Development Department)計算的公允市場租金(fair market rent)。 這些資料用來制定多項聯邦計畫的指引。實際租金金額在美國各地差異很大。 我們可以用這些資料來練習設定 Seaborn 圖表。
所需的 seaborn、pandas 和 matplotlib 匯入都已完成。
資料存放在 pandas 的 DataFrame df 中。
順帶一提,如果你還沒下載,建議看看這份 Seaborn Cheat Sheet。它整理了最重要的觀念、函式與方法,當你需要快速複習時會很實用!
本練習屬於課程
Seaborn 資料視覺化中級
練習說明
- 先不調整樣式,繪製一個
pandas的長條圖。 - 設定 Seaborn 的預設樣式。
- 針對
fmr_2欄位(代表 2 房公寓的公允市場租金)再建立一個pandas的長條圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot the pandas histogram
df['fmr_2'].plot.____()
plt.show()
plt.clf()
# Set the default seaborn style
sns.____()
# Plot the pandas histogram again
df['fmr_2'].plot.____()
plt.show()
plt.clf()