python-visualization / branca

This library is a spinoff from folium, that would host the non-map-specific features.
https://python-visualization.github.io/branca/
MIT License
111 stars 63 forks source link

Colormap banding #89

Closed Chrismarsh closed 1 year ago

Chrismarsh commented 3 years ago

When attaching a LinearColormap to a folium.raster_layers.TileLayer map, I'm getting banding in the fill

image This appears to persist across various OS and browser combinations

I'm creating the colour map as

import branca.colormap as cm
import seaborn as sns

#[...]

cmap = sns.color_palette("YlGnBu", 12)
colormap = cm.LinearColormap(colors=cmap, vmin=vmin, vmax=vmax)
m.add_child(colormap)

#[...]

I've isolated the problem with the rect width being set here https://github.com/python-visualization/branca/blob/master/branca/templates/color_scale.js#L48

For my case, this function is returning a width of ~0.8 (although each rect is slightly different widths).

If I set width=1.5 the problem is resolved image

I'm wondering if this is intended behaviour, if it's a bug, and/or if there are any unintended consequences to changing the width.

Conengmo commented 1 year ago

I'm not sure how this code came about and I would have to guess what is causing the banding.

For me, I don't see banding with the current code. Setting a particular width doesn't change that. If I zoom the page in I do get banding at some zoom levels, but not all.

I'm going to say this is not something we have to strive to resolve. But if somebody can provide more insight on this that is welcome!