Folium – Not Getting Different Colors in Folium Package

foliumplottingpython

I am trying to plot some points on the map, where the points are marked based on geo-coordinates and each point belongs to a category.

I am trying to set the color of the categories from the color array, and even converted that into a function, yet it is displaying all the categories in one color, as in the image:
Plot of the points

Here's the code mentioned below. I am not exactly sure where am I going wrong, since this is from the documentation of Folium.

The variable 'c' here, is actually coming from the column C in dataframe, which has the number of the segment.

mapPlot = folium.Map(location=[latitude, longitude], zoom_start=2)
 
colors = [
    'red',
    'blue',
    'gray',
    'orange',
    'beige',
    'green',
    'purple',
    'cadetblue',
    'black',
    'pink'
]
 
def colorCall(val):
  val = int(val)
  return colors[val]
 
for lon, lat, c in zip(df1['long'], df1['lat'], df1['C']):
    folium.CircleMarker(
        [lat, lon],
        radius=2,
 
 
        #fill_color=colors[int(c)],
        fill_color = colorCall(c),
        fill=True,
        fill_opacity=0.7
        ).add_to(mapPlot)
 
 
mapPlot

Best Answer

What you are seeing as blue is the outline of the circle. Set color=False:

        ...
        fill_color = colorCall(c),
        fill=True,
        color=False,  # outline color
        ...

color=True:

folium circlemarkers with outline

color=False:

folium circlemarkers without outline