我正在尝试在geopandas
中制作一个choropleth图。由于对象数量众多,并且分布高度偏斜,因此我将使用内置的mapclassify
支持将分档为分位数。效果很好,除了生成的图例的标签很糟糕。
作为测试用例,我产生了以下内容:
使用以下代码:
import geopandas as gp
import matplotlib.pyplot as plt
world = gp.read_file(gp.datasets.get_path('naturalearth_lowres'))
fig,ax = plt.subplots()
world.plot(ax=ax,column='pop_est',cmap='OrRd',scheme='quantiles',legend=True,legend_kwds=dict(loc='upper right',bbox_to_anchor=(1.5,.9),fontsize='small',title="Legend",frameon=False)
)
ax.axis('off')
我至少希望能够为图例具有完全自定义的标签,例如:
- 236万
- ...
- > 3,800万
但是,理想的情况是使带有自定义标签的色块连续出现,例如下面的美国地图(我未制作):