更多图形自定义
matplotlib API 支持许多常见的自定义操作,例如设置轴标签、添加标题以及设定取值范围。让我们再完成一个自定义练习。
本练习是课程的一部分
Seaborn 数据可视化进阶
练习说明
- 绘制
fmr_1列的histplot。 - 将 x 轴标签修改为 "1 Bedroom Fair Market Rent"。
- 将 x 轴范围设为 100 到 1500 之间。
- 为图形添加描述性标题
"US Rent"。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create a figure and axes
fig, ____ = plt.subplots()
# Plot the distribution of 1 bedroom rents
sns.____(df['fmr_1'], ax=____)
# Modify the properties of the plot
ax.set(xlabel="1 Bedroom Fair Market Rent",
xlim=(____,____),
____="US Rent")
# Display the plot
plt.show()