Я хочу добавить легенду, объясняющую различные сгенерированные цвета (красный, оранжевый, светло-зеленый и светло-голубой).
код выглядит так
def plot_station_counts(trip_counts):
# generate a new map
folium_map = folium.Map(location=[22, 75],
zoom_start=7.4,
tiles='Stamen Terrain',
width='100%',
height='100%')
for index, row in Anemic.iterrows():
popup_text = "<br><b>EDD: </b>{} <br><b>Haemoglobin: </b>{}"
popup_text = popup_text.format(row["EDD"],row["Haemoglobin"])
radius = row['Haemoglobin']
if radius <= 7:
color="red" # tangerine
else:
color="orange" # teal
folium.CircleMarker(location=(row["latitude"],row["longitude"]),radius=10,color=color,popup=popup_text,fill=True).add_to(folium_map)
latmean=22
lonmean=75
map5 = folium.Map(location=[latmean,lonmean],
zoom_start=7.4,tiles = 'Mapbox bright')
folium.Marker(location=(row['phcs_latitude'],row['phcs_longitude']),popup = row['phcs_name'], max_width=10,min_width=10,
icon= folium.Icon(color='lightgreen',
icon_color='lightgreen', icon='info-sign', icon_size=(2.5, 2.5))).add_to(folium_map)
folium.Marker(location=(row['sub_center_latitude'],row['sub_center_longitude']),popup = row['Subcenter'], max_width=10,min_width=10,
icon= folium.Icon(color='lightblue',
icon_color='lightblue', icon='info-sign', icon_size=(2.5, 2.5))).add_to(folium_map)
return folium_map
plot_station_counts(Anemic)
folium.LayerControl().add_to(plot_station_counts(Anemic))
print(plot_station_counts(Anemic).save("/home/sarfraaz/Documents/geofencing/Anemic.html"))