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
118 stars 66 forks source link

ENH: expose max_labels in ColorMap #90

Closed martinfleis closed 3 years ago

martinfleis commented 3 years ago

Closes #88

This PR introduces 2 changes to the ColorMap labels.

  1. It exposes max_labels keyword to control how many labels should be shown. At the moment there is a hard-coded value of 10, which often causes overlaps.
  2. It changes which labels are used to always have the minimum and the maximum. Current behaviour shows min, 8 in between and the second to last, not the last (max). This issue is not so apparent with 10 labels but if you use 2 you get (without this change) one in the beginning and one in the middle of the color bar which is probably not intended.

We are currently working on folium-based plotting to be included in GeoPandas and this is one of the things which would be great to fix to make a smoother user experience.

One question - how do you want to test it? I see that branca tests are essentially written as a check that it the code does not fail.

martinfleis commented 3 years ago

CI failures are not related to this PR.

martinfleis commented 3 years ago

I've added basic tests for LinearColormap and StepColormap, fixed docstrings and reverted the addition of the last value to the legend. Should be ready for another round of review/merge.