只要我不尝试更改其图例的位置,我的情节就可以正常工作。(我正在绘制一个 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 添加的。)
非常感谢您的建议。