我正在尝试使用以下内容创建一个 2x2 子图:
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()
出现的问题是子图中的底图范围仅限于叠加点数据。如何更改它,以便每个子图都有一个覆盖整个子图的底图。