New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Choropleth legends being part of the layer #1052
Comments
Even in maps with a single choropleth, being able to toggle the legend's visibility along with the choropleth helps reduce visual clutter. |
Hi, any chance if this has been fixed or if there's a workaround that anyone's aware of, I would be most grateful. Thanks. |
Much appreciate if this problem is solved as well! Thanks!!! |
You can do a hacky workaround by saving your map to html and adding the following lines:
This will only work in specific cases though (one choropleth as your only overlay and only 1 legend object) |
@julianaddison The Python method @kylenguyen245 mentioned does work in principle. Delete color_map children outside of the loop. Hope this helps. @kylenguyen245 I sometimes delete the legend (color maps) because the numerical labels overlap one another. I often don't use linear spacing for the bins. Do you know whether there's a way to use fewer labels than there are bins to avoid overlapping labels (see picture)?
|
does anyone have a fixed for this instead of hiding the legend? I have a choropleth with a lot of layers and actually need the colormap to be displayed for each of my layer being selected :(. would really appreciate help! . Currenlty, when I create a loop, all the legends for each layers get pasted on top of everything without the layers being selected. |
I could also use a solution for this. I have maps with 40 layers. |
Same |
Hi, |
Looking for a solution here. I've got multiple choropleth layers and would like for each choropleth's legend to be part of the layer, such that selecting Choropleth 1 would show its corresponding legend, but then selecting Choropleth 2 would remove the first legend and show the legend corresponding to this second layer. It doesn't make much sense to continue showing the legend for Choropleth 1 layer even when it's turned off. |
Turns out this is actually a duplicate of #450 |
Please add a code sample or a nbviewer link, copy-pastable if possible
This is how I created and added the folium.Choropleth layers to the folium.Map object (self.map is a default folium.Map object)
This is how I added folium.LayerControl and saved the file
Problem description
I created a folium.Map with two folium.Choropleth objects added to it as overlays, so that someone viewing the .html file could choose which choropleth map they would like to see using the LayerControl. When the layers were deselected the choropleth layers were removed from the screen but the legend stayed.
I found this behaviour confusing as, when a choropleth layer was deselected the legend remained on the screen, I would expect the legends to belong to the layers on the map and appear and disappear as layers were selected/deselected.
Expected Output
The legends for a folium.Choropleth object should disappear when the folium.Choropleth layer is deselected from the layer control box.
Output of
folium.__version__
0.7.0
The text was updated successfully, but these errors were encountered: