# Center / normalize choropleth colors in GeoPandas

I'm looking to plot a choropleth with a divergent colormap. I need to center the colormap in such a way that the middle color is displayed for a specific value (e.g. 0). How could I do this in GeoPandas/Geoplot?

I tried using a normalizer with `geopandas.plot()` but it's values are reset to data min and max once I plot:

``````import geopandas as gpd
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

world.loc[:,'random'] = np.random.normal(size=len(world))+2

norm = mpl.colors.Normalize(-4,4,clip=True)

fig, ax = plt.subplots()
world.plot('random', cmap=cmap, legend=True, norm=norm, ax=ax)
``````

And here is the figure: You could normalize the color by using the `DivergingNorm` function in matplotlib.

``````import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import geopandas as gpd
plt.style.use('seaborn-white')

# generate data
gdf = gdf[gdf.continent == 'Africa']
gdf['random'] = np.random.gamma(2, 2, len(gdf)) - 2

# normalize color
vmin, vmax, vcenter = gdf.random.min(), gdf.random.max(), 0
divnorm = colors.DivergingNorm(vmin=vmin, vcenter=vcenter, vmax=vmax)
# create a normalized colorbar
cbar = plt.cm.ScalarMappable(norm=divnorm, cmap='RdBu')

# plot
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 7))
# with no normalization
gdf.plot(column='random', cmap='RdBu', legend=True, ax=ax1)
# with normalization
gdf.plot(column='random', cmap='RdBu', legend=False, norm=divnorm, ax=ax2) 1. You could change `vcenter` to other desired values.
3. Set `legend=False` for the normalized map so that the unnormalized colorbar won't be plotted.