1

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

1 Answer 1

0

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

1
  • Thanks a lot! Solved the issue Mar 27, 2021 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.