首页 > 解决方案 > 更改图例的 edgecolor 和 textcolor

问题描述

我正在尝试更改图例的边缘颜色和文本颜色(请参见下面的输出)。

我正在使用 geopandas 来创建地理图。

fig, ax = plt.subplots(1, 1, figsize=(10,5))

divider = make_axes_locatable(ax)

cax = divider.append_axes("bottom", size="5%", pad=0.2)


merge.plot(ax=ax, column='Interest', cmap="Blues", legend=True, cax=cax, 
           legend_kwds={'label': "Interest by Country", "orientation": "horizontal"})



merge.boundary.plot(ax=ax, color="darkgray", linewidth=0.25)

ax.grid(False)
ax.axes.yaxis.set_visible(False)
ax.axes.xaxis.set_visible(False)
      
plt.show()

输出:

在此处输入图像描述

标签: pythonmatplotlibgeopandas

解决方案


推荐阅读