I'm trying to create a 2x2 subplot using the following:
import geopandas as gpd
import matplotlib.pyplot as plt
import contextily as ctx
site = gdf.groupby('Site_name')
plt.figure(figsize =(20,20))
# Iterate through sites
for i, (Site_name, site_gdf) in enumerate(site):
# create subplot axes in a 2x2 grid
ax = plt.subplot(2, 2, i + 1) # nrows, ncols, axes position
# plot the site on these axes
site_gdf.plot(ax=ax)
ctx.add_basemap(ax, source=ctx.providers.Esri.WorldImagery)
# set the title
ax.set_title(Site_name)
# set the aspect
# adjustable datalim ensure that the plots have the same axes size
ax.set_aspect('equal', adjustable='datalim')
plt.tight_layout()
plt.show()
The problem occurs that the extent of the basemaps within the subplots are restricted to the overlaid point data. How do I change it so that each subplot has a basemap that covers the whole subplot.
