axes
in the same figure?The following should be a wholly reproducible example to run the code and get
From geopandas 0.5 onwards you can use a custom scheme defined as scheme="User_Defined"
and supply the binning via classification_kwds
.
import geopandas as gpd
print(gpd.__version__) ## 0.5
import numpy as np; np.random.seed(42)
import matplotlib.pyplot as plt
gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
gdf['quant']=np.random.rand(len(gdf))*100-20
fig, ax = plt.subplots()
gdf.plot(column='quant', cmap='RdBu', scheme="User_Defined",
legend=True, classification_kwds=dict(bins=[-10,20,30,50,70]),
ax=ax)
plt.show()
So the remaining task is to get a list of bins from the quantiles of one of the columns. This should be easily done, e.g. via
import mapclassify
bins = mapclassify.Quantiles(gdf['quant'], k=5).bins
then setting classification_kwds=dict(bins=bins)
in the above code.