构建 FacetGrid
Seaborn 的 FacetGrid 是构建"数据感知"网格的基础。数据感知网格可以创建一系列小图,有助于理解复杂的数据关系。
在这些练习中,我们将继续使用美国教育部的 College Scorecard 数据。这是一个信息丰富的数据集,包含许多可以用 Seaborn 可视化的有趣数据元素。
构建 FacetGrid 时通常包括两个步骤:
- 使用列、行或色相(hue)创建一个
FacetGrid对象; - 将各个图表映射到该网格上。
本练习是课程的一部分
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()