【发布时间】:2018-11-05 16:11:44
【问题描述】:
我想在我正在创建的 geopandas 世界 choropleth 中使用颜色条编辑多个内容。即大小(使其与地图本身大致匹配),文本大小(当前显示得太小),我还想为其添加一个标签。从阅读来看,似乎没有简单的方法可以在 geopandas 中明确地做到这一点,所以我想知道是否有人可以提供任何解决方法?任何帮助将不胜感激。
这是我目前正在使用的一段代码(在某些情况下,中间部分只是将列表与国家/地区的数字合并到框架中,我将其用作着色的基础)
fig, ax = plt.subplots(figsize=(40,29.171))
world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
world=pd.DataFrame(world)
world['LEADS']=0.1
world = world.set_index('name')
world['name']=world.index
for x, y in zip(Countries, country_counts):
world.loc[x, 'LEADS'] = y
world=geopandas.GeoDataFrame(world)
world = world[(world.index != "Antarctica")]
ax.set_axis_off()
#ax.legend(title="Leads")
world.plot(ax=ax, column='LEADS', cmap='Oranges', legend=True,linewidth = 1.5)
plt.tight_layout()
plt.savefig('plot_image.png', bbox_inches='tight', transparent=True)
这里的理想解决方案是保持图例选项具有的颜色、指定大小和文本大小并在栏顶部启用标签。不幸的是,我正在努力弄清楚这一切是如何完成的。
【问题讨论】:
标签: python pandas visualization geopandas choropleth