跟踪犯罪统计
Laura 警佐希望做一些背景研究,以便更好地理解 Bayes 被绑架的文化背景。她使用 Uniform Crime Reporting Statistics 的数据,绘制了 3 座美国城市的入室盗窃率。
她想把这些数据展示给同事,并希望图像尽可能美观,以便更有效地讲述数据故事。
回顾:
- 您可以将
linestyle更改为点状(':')、虚线('--')或无连线('')。 - 您可以将
marker更改为圆形('o')、菱形('d')或方形('s')。
本练习是课程的一部分
Python 数据科学入门
练习说明
- 将 Phoenix 的颜色改为
"DarkCyan"。 - 将 Los Angeles 的线条改为点状。
- 为 Philadelphia 添加方形标记。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Change the color of Phoenix to `"DarkCyan"`
plt.plot(data["Year"], data["Phoenix Police Dept"], label="Phoenix", ____)
# Make the Los Angeles line dotted
plt.plot(data["Year"], data["Los Angeles Police Dept"], label="Los Angeles", ____)
# Add square markers to Philedelphia
plt.plot(data["Year"], data["Philadelphia Police Dept"], label="Philadelphia", ____)
# Add a legend
plt.legend()
# Display the plot
plt.show()