Custom legend color and interval on geopandas explore

141 Views Asked by At

I have a geodataframe called gdf_isochrone that consists of 3 polygons:

    isochrone_id    travel_time_mins    geometry    furthest_distance   speed   category
0   is15    15  POLYGON ((106.77372 -6.23474, 106.77612 -6.234...   8901    35.604  0
1   is30    30  POLYGON ((106.74866 -6.21551, 106.75072 -6.214...   19130   38.260  1
2   is60    60  POLYGON ((106.67107 -6.21208, 106.67244 -6.207...   33835   33.835  2

I use geopandas.explore to map it using:

gdf_isochrone.explore(
    column = 'travel_time_mins',
    vmin = 0,
    vmax = 60,
    legend = True,
    tooltip = True
)

How do I make the color to be:

travel_time_mins = 15, then green
travel_time_mins = 30, then yellow
travel_time_mins = 60, then red

I've attached existing map enter image description here

1

There are 1 best solutions below

0
On

Adjust the cmap parameter: https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.explore.html

It takes more time to type that whole question than to read the docs.