我正在绘制一张choropleth地图,每个区域的名称都在多边形上。当我移除投影线时,效果很好,但贴图是水平拉伸的。当我使用projection=gcrs.albersqualarea()时,我消除了拉伸,但这次所有标签在中心重叠。有人知道是什么导致了这个问题吗?如何使标签显示在具有未拉伸投影的多边形上
ax = gplt.choropleth(df=map_data,
projection=gcrs.AlbersEqualArea(),
hue='population',
figsize=(16,8),
legend=True,
cmap='BuGn',
scheme=scheme_2,
legend_kwargs={'loc': 'lower right'},
edgecolor='black', linewidth=0.5,
)
map_data.apply(lambda x: ax.annotate(s=x.population_abb, xy=x.geometry.centroid.coords[0],fontsize='x-small',fontstretch='ultra-expanded', ha='center',bbox={'facecolor': 'white', 'alpha':0.3, 'pad': 2, 'edgecolor':'none'}),axis=1,);
地图:
目前没有回答
相关问题 更多 >
编程相关推荐