绘制鸡群位置
现在,您将创建一个散点图,用来展示纳什维尔的鸡群分布位置。
本练习是课程的一部分
在 Python 中可视化地理空间数据
练习说明
- 鸡群数据集的路径保存在变量
chickens_path中。使用 pandas 的read_csv函数将其加载为名为chickens的数据框。 - 使用
.head()函数查看前几行。 - 接着,在
plt.scatter()中添加 x 和 y 参数,绘制纳什维尔鸡群的位置。使用默认的标记与颜色选项。 - 使用
plt.show()显示图形。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Import pandas and matplotlib.pyplot using their customary aliases
import pandas as pd
import matplotlib.pyplot as plt
# Load the dataset
chickens = pd.____(chickens_path)
# Look at the first few rows of the chickens DataFrame
print(chickens.____())
# Plot the locations of all Nashville chicken permits
plt.scatter(x = chickens.____, y = chickens.____)
# Show the plot
plt.show()