Quantiles choropleth
In this exercise we will create a quantile version of the tree density map. Remember that the quantile algorithm will rank and split the values into groups with the same number of elements to assign a color to each.
This time, we will create seven groups that allocate the colors of the YlGn
colormap across the entire set of values.
The district_trees
GeoDataFrame is again already loaded. It includes the variable n_trees_per_area
, measuring tree density by district (note the variable has been multiplied by 10,000).
This exercise is part of the course
Working with Geospatial Data in Python
Exercise instructions
- Generate a choropleth using the
'n_trees_per_area'
variable, a quantile classification scheme with 7 classes and theYlGn
color map. Assign the result to a variable namedax
. - Remove the frames, ticks and tick labels from the plot for a cleaner map using the
set_axis_off()
method.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Generate the choropleth and store the axis
____ = districts_trees.plot(column='n_trees_per_area', scheme='____',
k=____, cmap='____', legend=True)
# Remove frames, ticks and tick labels from the axis
____.set_axis_off()
plt.show()