开始使用免费开始使用

颜色映射(Colormaps)

当您想区分不同区域,但不想暗示区域之间存在任何数值关系时,最好使用定性(qualitative)颜色映射。 在本练习中,您将使用提供给您的 school_districts(学区)GeoDataFrame,对比定性颜色映射与顺序(定量)颜色映射的效果。

本练习是课程的一部分

在 Python 中可视化地理空间数据

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Set legend style
lgnd_kwds = {'title': 'School Districts',
               'loc': 'upper left', 'bbox_to_anchor': (1, 1.03), 'ncol': 1}

# Plot the school districts using the tab20 colormap (qualitative)
school_districts.plot(column = ____, ____ = 'tab20', ____ = True, ____ = lgnd_kwds)
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.title('Nashville School Districts')
plt.show();
编辑并运行代码