Folium: Custom color scheme for choropleth

Created on 28 Mar 2016  路  7Comments  路  Source: python-visualization/folium

Hi guys,
Thanks for the nice work here!

I'm new here so I'm sorry if I'm missing something. Do we have, in the current version, any way to define specific color schemes for the choropleth, beyond those defined in the docsting of the function (BuGn, BuPu, GnBu, OrRd, PuBu, PuBuGn, PuRd, RdPu, YlGn, YlGnBu, YlOrBr, and YlOrRd)?

Most helpful comment

Assuming you're using v0.2.0 and the choropleth convenience method, you are indeed limited to the color_brewer schemes defined in https://github.com/python-visualization/folium/blob/v0.2.0/folium/utilities.py#L104

On the other hand, for maximum flexibility, if you create your choropleth via either the GeoJson or TopoJson classes, you can pass in your own instance of colormap.

For examples, have a look at the StepColormap and LinearColormap sections in http://nbviewer.jupyter.org/github/python-visualization/folium/blob/v0.2.0/examples/Colormaps.ipynb

All 7 comments

Assuming you're using v0.2.0 and the choropleth convenience method, you are indeed limited to the color_brewer schemes defined in https://github.com/python-visualization/folium/blob/v0.2.0/folium/utilities.py#L104

On the other hand, for maximum flexibility, if you create your choropleth via either the GeoJson or TopoJson classes, you can pass in your own instance of colormap.

For examples, have a look at the StepColormap and LinearColormap sections in http://nbviewer.jupyter.org/github/python-visualization/folium/blob/v0.2.0/examples/Colormaps.ipynb

Thanks @eddies!

Nice! Thanks @eddies!

It says that there is no module named colormap in folium.

Please see the updated notebook: https://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/Colormaps.ipynb

There are two ways to import the colormap classes:

  • From their source module: branca.colormap import ColorMap, LinearColormap, StepColormap
  • From a shortcut: from folium import ColorMap, LinearColormap, StepColormap

Thank you!

I have another question: I have a folium.Choropleth and I want to pass a customised map with 10 different colors into the fill_color parameter. I am using a df that has values between 1 and 10 in one column and if there is for example a 2 it should be shown blue, for a 7 yellow and so on...

Hi!

I'd like to do the same thing, did you find a way?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

achourasia picture achourasia  路  19Comments

themiurgo picture themiurgo  路  19Comments

xhx509 picture xhx509  路  15Comments

olibchr picture olibchr  路  19Comments

Demetrio92 picture Demetrio92  路  18Comments