小编Bob*_*byF的帖子

尝试重新定位 geopandas 图例时出现“无标签句柄”错误

只要我不尝试更改其图例的位置,我的情节就可以正常工作。(我正在绘制一个 GeoDataFrame。)

# %%
ax = NE_shp.plot(column=NE_shp.iloc[:,4], figsize=(10,3), scheme='quantiles', edgecolor='k', k=10, legend=True)

#ax.legend(loc='upper left', bbox_to_anchor=(1, 1)) #This is the line for relocating legend

ax.set_title('The Map', fontsize=16)
ax.axis('off')
Run Code Online (Sandbox Code Playgroud)

结果图: 没有图例位置设置

但是当我使用现在被屏蔽的行作为注释来更改图例位置时,会出现以下错误并且图例未显示如下图

No handles with labels found to put in legend.

为图例设置位置后

(我怀疑它是否与scheme='quantiles'原因有关,它不是 matplotlib 固有的,而是由 pySAL 添加的。)

非常感谢您的建议。

python matplotlib legend geopandas

2
推荐指数
1
解决办法
1072
查看次数

标签 统计

geopandas ×1

legend ×1

matplotlib ×1

python ×1