I have checked the parameters for the choropleth() function. However can't figure out how to disable the legend. Is there any way to do that?
Many thanks!
m.choropleth(
geo_data, data=None, columns=None, key_on=None, threshold_scale=None, fill_color='blue',
fill_opacity=0.6, line_color='black', line_weight=1, line_opacity=1, name=None, legend_name='',
topojson=None, reset=False, smooth_factor=None, highlight=None)
It's a bit of a hack, but you can delete the color scale after it was created:
m = folium.Map()
m.choropleth()
for key in m._children:
if key.startswith('color_map'):
del(m._children[key])
Why do you want to hide the legend? We should decide if this should be added as an argument.
BTW, you can probably use the GeoJson class to achieve that.
Closing b/c having a choropleth with the legend is not the goal of the .choropleth() method. What we can do is to add some example on how to use the GeoJson for that though.
There are a couple of reasons why I do not want the scale bars:
@Conengmo you might know how this works for newer folium versions? Using your approach seem not to work with newest version.
I didn't test it but does this work?
m = folium.Map()
choropleth = folium.Choropleth().add_to(m)
for key in choropleth._children:
if key.startswith('color_map'):
del(m._children[key])
@Conengmo no unfortunately not. it ends in a key error. I am trying to create a bunch of choropleth maps and by hide the layer in the layer control I would like to hide the legend as well.
Do you have any other suggestion? I would really appreciate it. I think the whole legend thing generally is an issue at Folium.
@renelikestacos In combination with this comment and this notebook I was able to delete the choropleth's legend and create a legend for each layer.
I found a slight variation of Conengmo comment works. Delete key in choropleth._children before adding to m:
m = folium.Map()
choropleth = folium.Choropleth()
for key in choropleth._children:
if key.startswith('color_map'):
del(choropleth._children[key])
choropleth.add_to(m)
Most helpful comment
It's a bit of a hack, but you can delete the color scale after it was created:
Why do you want to hide the legend? We should decide if this should be added as an argument.