You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Heatmap gradient color in folium.plugins.HeatMap is not documented. #2051
The documentation for folium.plugins.HeatMap mentions that default gradient is None, but I found that Folium seems using the standard gradient color from leaflet, which from the source code is defined as (see leaflet_heat.min.js, or the dependency simpleheat.js):
To me is also not clear from the js code which colors the gradient uses before 0.4. I tried to understand it looking at simpleheat.jsfunction (grad), since the minified version should come from here. One comment in this function says "create a 256x1 gradient that we'll use to turn a grayscale heatmap into a colored one". So should I assume that the gradient in 0 starts from black?
Additional context
Like user from issue #1579, I was trying to replicate the default gradient to build a colormap for the heatmap plot, and it was not obvious to figure out that the gradient color used could be defined in the leaflet.js file.
Possible solutions
Passing defaultGradient as object for folium.plugins.HeatMap, even if it will do nothing because the default is still defined in the leaflet.js code, it could be useful for future users.
Thanks for reporting this missing information! I understand you would like to be able to know the default gradient without having to dive into the underlying Javascript code.
The simplest thing would be to just add that default gradient to the docstring. We already have an example there, we can replace it with the default gradient.
I wouldn't want to do it as a default argument to the class, because mutable types are not recommended as default arguments.
Activity
Conengmo commentedon Dec 14, 2024
Thanks for reporting this missing information! I understand you would like to be able to know the default gradient without having to dive into the underlying Javascript code.
The simplest thing would be to just add that default gradient to the docstring. We already have an example there, we can replace it with the default gradient.
I wouldn't want to do it as a default argument to the class, because mutable types are not recommended as default arguments.
Conengmo commentedon Dec 14, 2024
@defending1 maybe you can check out https://github.com/python-visualization/folium/pull/2052/files see if this addresses your issue?
defending1 commentedon Dec 14, 2024
Yes good idea. This solves, thanks.
Conengmo commentedon Dec 14, 2024
Great, thanks!