Change single patch color in geopandas

风流意气都作罢 提交于 2019-12-06 08:42:01

A possible solution is using geopandas.plotting.plot_multipolygon to specifically add only one geometry object with blue colors to the existing figure:

from geopandas.plotting import plot_multipolygon
manhattan = nybb[nybb.BoroName == "Manhattan"]
plot_multipolygon(nybb_plot, manhattan.geometry.iloc[0], facecolor="#33ccff", edgecolor='none')

This gives me:

The reason your above approach does not work, is because geopandas adds the second plot to the same axes as the first plot (and this axes is returned from plot()). So nybb_plot and man_plot are referring to the same object, and so you do update all patches the second time.


Note that in the development version, the second plot will not automatically added anymore to the first, but a new figure will be created.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!