code: def demo_locatable_axes_hard(fig):
      from mpl_toolkits.axes_grid1 import Size, SubplotDivider
  
      divider = SubplotDivider(fig, 2, 2, 2, aspect=True)
  
      # Axes for image
      ax = fig.add_subplot(axes_locator=divider.new_locator(nx=0, ny=0))
      # Axes for colorbar
      ax_cb = fig.add_subplot(
          axes_locator=divider.new_locator(nx=2, ny=0)
      )
  
      divider.set_horizontal(
          [
              Size.AxesX(ax),  # main Axes
              Size.Fixed(0.05),  # padding, 0.1 inch
              Size.Fixed(0.2),  # colorbar, 0.3 inch
          ]
      )
      divider.set_vertical([Size.AxesY(ax)])
  
      Z, extent = get_demo_image()
  
      im = ax.imshow(Z, extent=extent)
      plt.colorbar(im, cax=ax_cb)
      ax_cb.yaxis.set_tick_params(labelright=False)
  
file_path: matplotlib/galleries/examples/axes_grid1/demo_axes_divider.py
imports: import matplotlib.pyplot
  from matplotlib import cbook
label_desc: Use image node_id 3 for calling a global function with example usage: demo_locatable_axes_hard(fig) without return types