folium.Choropleth:控制fill_opacity仅用于空值

问题描述 投票:0回答:1

我画了一张漂亮的美国地图。我已经使用Choropleth

创建了Folium
folium.Choropleth(
 geo_data=boundaries,
 name='choropleth',
 data=df,
 columns=['state','NR'],
 key_on='feature.id',
 fill_color='Blues',
 threshold_scale=a_non_unform_log_scale,
fill_opacity=0.7
).add_to(m)

enter image description here

这是我想要的,但是我想给值0一种特殊的透明颜色。例如。在图像中,许多状态为黑色,因为它们在df中有一个null / nan条目。我可以使缺失状态透明吗?

python dictionary plot alpha folium
1个回答
0
投票

是,可以。您可以执行以下操作:

© www.soinside.com 2019 - 2024. All rights reserved.