Folium – How to Change Circle Opacity

choroplethfoliumleafletpython

I made my first choropleth map using Folium which worked quite well! However I would like to change the opacity of my circles to be a bit more opaque. How does one do this? There does not seem to be an option.

m = folium.Map(location=[48, -102], zoom_start=3)
for geoid, (long, lat) in geoids.items():
    city_name = df_metro.loc[df_metro['geoid']==geoid, 'Geographic Area Name'].iloc[0]
    city_ratio = df_metro.loc[df_metro['geoid']==geoid, 'Ratio'].iloc[0]
    city_pop = df_metro.loc[df_metro['geoid']==geoid, 'Total'].iloc[0]
    folium.Circle(
        location=[lat, long],
        color=colormap(city_ratio),
        radius=50*math.sqrt(city_pop),
        fill=True,
        opacity=0.8,
        tooltip='{}: {}'.format(city_name, city_ratio)
    ).add_to(m)

default circles are too transparent

Best Answer

The parameter to control that is called fill_opacity.

folium.Circle(
    location=[lat, long],
    color=colormap(city_ratio),
    radius=50*math.sqrt(city_pop),
    fill=True,
    opacity=0.8,
    fill_opacity=1,
    tooltip='{}: {}'.format(city_name, city_ratio)
).add_to(m)