使用这张纽约市地图,我想将曼哈顿更改为亮蓝色。但是当我改变曼哈顿的个别补丁颜色时,所有其他补丁颜色也会改变。这出乎我的意料。
你如何改变一个单独的补丁的颜色?
from matplotlib import pyplot as plt
import geopandas as gpd
nybb = gpd.GeoDataFrame.from_file('nybb.shp')
nybb_plot = nybb.plot()
for p_ny in nybb_plot.patches:
p_ny.set_color("#111111")
p_ny.set_alpha(0.6)
for line in nybb_plot.lines:
line.set_linewidth(0.25)
line.set_alpha(0.9)
line.set_color("#d3d3d3")
manhattan = nybb.loc[nybb.BoroName == "Manhattan"]
man_plot = manhattan.plot()
for p_mh in man_plot.patches:
p_mh.set_color("#33ccff")
plt.show()