等距分級色階地圖
在上一個練習中,我們建立了樹木密度的地圖。現在你更了解色階地圖了,我們要更深入地探索這個視覺化。
首先,來比較直接使用樹木數量,與以行政區面積正規化後的樹木數量(也就是樹木密度)之差異。 其次,我們會改用等距分級,而不是連續色帶,來建立這個地圖。這個分級演算法會把數值範圍切成等寬的區間,並為每個區間指定一個顏色。
district_trees 這個 GeoDataFrame(上一個練習完成後的結果)已經載入。它包含 n_trees_per_area 變數,用來衡量各行政區的樹木密度(注意:此變數已乘以 10,000)。
本練習屬於課程
在 Python 中處理地理空間資料
練習說明
- 以
'n_trees'變數為多邊形著色繪圖,並使用legend參數顯示圖例。 - 以同樣的方式改用
'n_trees_per_area'變數。你看出差異了嗎? - 使用
'n_trees_per_area'變數,採用等距分級法產生色階地圖。同樣要加入圖例。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print the first rows of the tree density dataset
print(districts_trees.head())
# Make a choropleth of the number of trees
districts_trees.plot(____, ____)
plt.show()
# Make a choropleth of the number of trees per area
districts_trees.plot(____, ____)
plt.show()
# Make a choropleth of the number of trees
districts_trees.plot(____, ____, ____)
plt.show()