Home » Remove the Legend in a Folium Choropleth Map

# Remove the Legend in a Folium Choropleth Map

Sometimes, just sometimes, you really want to get rid of the legend(s) in your Folium Choropleth map. However, there is no method within the Choropleth object to achieve that.

Currently, the most straightforward way of removing the legend from your map is by looping over all the layers in the Choropleth object and removing the ones that can be identified as a legend.

First, let’s create our map and choropleth layer.

import folium

m = folium.Map()
c = folium.Choropleth(
...
)

Let’s take a look at the _children of the Choropleth object stored in c.

c._children

In the ordered dictionary, you can see a GeoJSON and a StepColormap.

By removing the StepColormap, you will be able to remove the legend from your choropleth visualization.

for key in c._children:
if key.startswith('color_map'):
del(c._children[key])

c.add_to(m)

Congratulations, you removed the legend from your choropleth map.

### Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.