Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Feature request: colormap with background

Open
#124 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start by inspecting the branca.colormap classes and the generated colormap HTML used by the example. Trace how the colormap is rendered and determine where an optional background rectangle can be represented; done means the existing example supports a selectable background color without changing the color mapping.

Written by the indexing model from the issue text.

Description

enhancement
Code Sample
import folium
import pandas as pd
import folium.plugins

import branca
import branca.colormap as cm

data = [
    [33.823400, -118.12194, 99.23],
    [33.823500, -118.12294, 95.23],
    [33.823600, -118.12394, 91.23],
    [33.823700, -118.12494, 90.00]
]

df = pd.DataFrame(data, columns=['latitude','longitude','data'])

x_start = (df['latitude'].max() + df['latitude'].min()) / 2
y_start = (df['longitude'].max() + df['longitude'].min()) / 2
start_coord = (x_start, y_start)


colormap = cm.LinearColormap(colors=['red','lightblue'],
                             index=[df['data'].min(),df['data'].max()],
                             vmin=df['data'].min(),vmax=df['data'].max())

colormap.caption = 'Data [units]'

map = folium.Map(location=start_coord, zoom_start=12)


lat = list(df.latitude)
lon = list(df.longitude)
dat = list(df.data)


for loc, p in zip(zip(lat, lon), dat):
    folium.Circle(
        location=loc,
        radius=10,
        fill=True,
        color=colormap(p),
        fill_opacity=0.7
    ).add_to(map)

map.add_child(colormap)
map.save('index.html')

Problem description

Code above creates colored points, and displays a colormap to show what data value each color corresponds to. This is great but it would be even better if a background colour could be selected. This slightly hacky work-around does exactly what I want:
https://stackoverflow.com/a/50427006/4988601

I'd be happy to try and plumb this into folium itself if a few people show some interest in this feature (I'm fairly new to folium so any pointers on what methods/classes I'd need to poke around in would be appreciated).

Expected Output

Colormap with an optional background color rectangle to help it stand out.

Output of folium.__version__

0.10.0

Dominant language
Python
Stars
134
Forks
69
Avg merge
1h 10m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-visualization/branca

All issues in python-visualization/branca

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.