question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I hide the legend for choropleth chart?

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
nhpackardcommented, Oct 13, 2020

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)
6reactions
Conengmocommented, Sep 17, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to hide the legend on Choropleth Maps?
I think charting.legend.placement is not the right option to use for a choropleth map. Using simpleXML in Splunk UI, I successfully used <option...
Read more >
how to hide python folium choropleth legend - Stack Overflow
Explaining the solution briefly, the branca color map is first removed to then be re-added to the map binded to the choropleth layer...
Read more >
Show or hide a chart legend or data table - Microsoft Support
Show or hide a legend · Click the chart in which you want to show or hide a legend. This displays the Chart...
Read more >
How to hide the colorbar and legend in Plotly Express?
In this article, we will learn how to hide the colorbar and legend in plotly express. Here we will discuss two different method...
Read more >
Legends in Python - Plotly
Users may show or hide traces by clicking or double-clicking on their associated legend item. Traces that support legend items also support the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found