使用 lmplot
lmplot 用在 FacetGrid 物件上繪製帶有迴歸線的散佈圖。
它的 API 與 catplot 類似,但 lmplot 的預設行為是繪出迴歸線。
在第一組練習中,你會查看大學部學生人數(UG),並與獲得 Pell Grants 的學生百分比(PCTPELL)進行比較。
在第二個 lmplot 練習中,你會比較不同學位型別,以及公立與非營利學校之間的平均 SAT 分數與學費(Tuition)之關係。
本練習屬於課程
Seaborn 資料視覺化中級
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a FacetGrid varying by column and columns ordered with the degree_order variable
g = sns.FacetGrid(df, ___="Degree_Type", ____order=degree_ord)
# Map a scatter plot of Undergrad Population compared to PCTPELL
g.map(plt.___, 'UG', 'PCTPELL')
plt.show()
plt.clf()