開始使用免費開始

建立 FacetGrid

Seaborn 的 FacetGrid 是建立資料感知網格的基礎。資料感知網格可以讓你建立一系列小型圖表,有助於理解複雜的資料關係。

在這些練習中,我們會繼續使用美國教育部的 College Scorecard 資料。這個豐富的資料集包含許多有趣的欄位,可以用 Seaborn 來視覺化。

建立 FacetGrid 有兩個步驟:

  • 使用欄(columns)、列(rows)或色相(hue)建立 FacetGrid 物件。
  • 將各個圖形對應(map)到網格上。

本練習屬於課程

Seaborn 資料視覺化中級

檢視課程

練習說明

  • 建立一個 FacetGrid,顯示平均 SAT 分數 SAT_AVG_ALL 的點狀圖。
  • 使用 row_order 來控制學位類型的顯示順序。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Create FacetGrid with Degree_Type and specify the order of the rows using row_order
g2 = sns.____(df, 
             ____="Degree_Type",
             row_order=['Graduate', 'Bachelors', 'Associates', 'Certificate'])

# Map a pointplot of SAT_AVG_ALL onto the grid
g2.____(sns.____, 'SAT_AVG_ALL')

# Show the plot
plt.show()
plt.clf()
編輯並執行程式碼