'Column color based when ploting a GeoDataFrame with 'explore' method
I'd like to color the cities that belongs to one hemisphere or another with the color specified at 'Color' column. All the cities of each hemisphere (each category) have the same value for that column. I'd like the legend to show the same colors too.
I'm not being able of getting it. Could anyone help me? Thank you very much in advance.
Note: This is a reproducible example of what I'm dealing with -based on geopandas examples.
import geopandas as gpd
gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))
gdf['Hemisphere'] = gdf['geometry'].apply(lambda x: 'Norte'if x.y > 0 else 'Sur')
gdf['Color'] = gdf['Hemisphere'].apply(lambda x: '#D94325' if x=='Norte' else '#5CD925')
gdf.explore(column='Hemisferio', color='Color')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

