code: def generate_imshow_demo_grid(extents, xlim=None, ylim=None):
      N = len(extents)
      fig = plt.figure(tight_layout=True)
      fig.set_size_inches(6, N * (11.25) / 5)
      gs = GridSpec(N, 5, figure=fig)
  
      columns = {
          "label": [fig.add_subplot(gs[j, 0]) for j in range(N)],
          "upper": [fig.add_subplot(gs[j, 1:3]) for j in range(N)],
          "lower": [fig.add_subplot(gs[j, 3:5]) for j in range(N)],
      }
      x, y = np.ogrid[0:6, 0:7]
      data = x + y
  
      for origin in ["upper", "lower"]:
          for ax, extent in zip(columns[origin], extents):
              plot_imshow_with_labels(
                  ax, data, extent, origin, xlim, ylim
              )
  
      columns["label"][0].set_title("extent=")
      for ax, extent in zip(columns["label"], extents):
          if extent is None:
              text = "None"
          else:
              left, right, bottom, top = extent
              text = (
                  f"left: {left:0.1f}\nright: {right:0.1f}\n"
                  f"bottom: {bottom:0.1f}\ntop: {top:0.1f}\n"
              )
          ax.text(
              1.0,
              0.5,
              text,
              transform=ax.transAxes,
              ha="right",
              va="center",
          )
          ax.axis("off")
      return columns
  
file_path: matplotlib/galleries/users_explain/artists/imshow_extent.py
imports: import matplotlib.pyplot
  import numpy
  from matplotlib.gridspec import GridSpec
label_desc: Use image node_id 7 for calling a global function with example usage: generate_imshow_demo_grid(extents, xlim, ylim) and returns: columns