Skip to content

Heatmap gradient color in folium.plugins.HeatMap is not documented. #2051

@defending1

Description

@defending1

Describe the bug

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):

defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"}

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.js function (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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions