创建 point plot
要做出有用的可视化,有时需要多次尝试。现在请您创建一个可视化,展示评论数 "Nr. reviews"(某位评论者此前写过的评论数量)在不同酒店星级 "Hotel stars" 下的表现。由于评论数是数值型,您决定使用 point plot 来展示各类别中的均值。
本练习是课程的一部分
在 Python 中处理分类数据
练习说明
- 使用
catplot()函数创建一个 point plot。 - 使用
"Hotel stars"在 x 轴上拆分数据。 - 将要可视化的数值变量设为
"Nr. reviews"。 - 调整参数以确保可能出现的连线不会重叠。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create a point plot with catplot using "Hotel stars" and "Nr. reviews"
sns.catplot(
# Split the data across Hotel stars and summarize Nr. reviews
____,
____,
data=reviews,
# Specify a point plot
____,
hue="Pool",
# Make sure the lines and points don't overlap
____
)
plt.show()