循环绘制带有 geopandas 的多张地图并删除轴

Looping to plot multiple map with geopandas and removing axis

我想创建一个 png,它结合了英国在不同时期的类似叶绿素地图。我的输入数据框 (df) 具有以下结构:

decade nb_patentees area
1910 25 zone1
1910 15 zone2
1920 34 zone1
1920 35 zone2

我是这样做的:

fig, axes = plt.subplots(ncols=4, nrows=(len(list_decade)//4+1), figsize=(10,15))
i = 0
for dec in sorted(list_decade): #list_decade is a lost of decades [1900, 1910, 1920...]
  j = i%4 # column
  ax = axes[i//4, j]
  ax.title.set_text(f"{dec}'s")
  ax.axis("off")
  df_dec = df.query("decade == @dec") # df is a dataframe containing all data, I keep only the relevant decade

  df_dec.plot(column='nb_patentees', legend=True, edgecolor="black", figsize = (10,15), linewidth = 0.01, legend_kwds={'label': "Number of patentess (log)",
                          'orientation': "horizontal", 'shrink': 0.8}, ax = ax)
  i = i+1

它工作正常,除非子图的数量与 cols x 行的平方不匹配,在这种情况下我得到一个带轴的空地图。你知道我怎样才能摆脱它吗?

这应该删除空白子图上的轴:

axes[-1, -2].axis('off')