class_docstr: A class that creates a grid of Axes. In matplotlib, the axes
  location (and size) is specified in the normalized figure
  coordinates. This may not be ideal for images that needs to be
  displayed with a given aspect ratio.  For example, displaying
  images of a same size with some fixed padding between them cannot
  be easily done in matplotlib. ImageGrid is used in such case.
docstr: Build an :class:`ImageGrid` instance with a grid nrows*ncols
  :class:`~matplotlib.axes.Axes` in
  :class:`~matplotlib.figure.Figure` *fig* with
  *rect=[left, bottom, width, height]* (in
  :class:`~matplotlib.figure.Figure` coordinates) or
  the subplot position code (e.g., "121").
  
  Optional keyword arguments:
  
    ================  ========  =========================================
    Keyword           Default   Description
    ================  ========  =========================================
    direction         "row"     [ "row" | "column" ]
    axes_pad          0.02      float| pad between axes given in inches
                                or tuple-like of floats,
                                (horizontal padding, vertical padding)
    add_all           True      bool
    share_all         False     bool
    aspect            True      bool
    label_mode        "L"       [ "L" | "1" | "all" ]
    cbar_mode         None      [ "each" | "single" | "edge" ]
    cbar_location     "right"   [ "left" | "right" | "bottom" | "top" ]
    cbar_pad          None
    cbar_size         "5%"
    cbar_set_cax      True      bool
    axes_class        None      a type object which must be a subclass
                                of axes_grid's subclass of
                                :class:`~matplotlib.axes.Axes`
    ================  ========  =========================================
  
  *cbar_set_cax* : if True, each axes in the grid has a cax
    attribute that is bind to associated cbar_axes.
docstr_tok: ["Build","an",":","class",":","`","ImageGrid","`","instance","with","a","grid","nrows","*","ncols",":","class",":","`","~matplotlib.axes.Axes","`","in",":","class",":","`","~matplotlib.figure.Figure","`","*","fig","*","with","*","rect=","[","left",",","bottom",",","width",",","height","]","*","(","in",":","class",":","`","~matplotlib.figure.Figure","`","coordinates",")","or","the","subplot","position","code","(","e.g.",",","``","121","''",")",".","Optional","keyword","arguments",":","================","========","=========================================","Keyword","Default","Description","================","========","=========================================","direction","``","row","''","[","``","row","''","|","``","column","''","]","axes_pad","0.02","float|","pad","between","axes","given","in","inches","or","tuple-like","of","floats",",","(","horizontal","padding",",","vertical","padding",")","add_all","True","bool","share_all","False","bool","aspect","True","bool","label_mode","``","L","''","[","``","L","''","|","``","1","''","|","``","all","''","]","cbar_mode","None","[","``","each","''","|","``","single","''","|","``","edge","''","]","cbar_location","``","right","''","[","``","left","''","|","``","right","''","|","``","bottom","''","|","``","top","''","]","cbar_pad","None","cbar_size","``","5","%","''","cbar_set_cax","True","bool","axes_class","None","a","type","object","which","must","be","a","subclass","of","axes_grid","'s","subclass","of",":","class",":","`","~matplotlib.axes.Axes","`","================","========","=========================================","*","cbar_set_cax","*",":","if","True",",","each","axes","in","the","grid","has","a","cax","attribute","that","is","bind","to","associated","cbar_axes","."]
code: def __init__(
      self,
      fig,
      rect,
      nrows_ncols,
      ngrids=None,
      direction="row",
      axes_pad=0.02,
      add_all=True,
      share_all=False,
      aspect=True,
      label_mode="L",
      cbar_mode=None,
      cbar_location="right",
      cbar_pad=None,
      cbar_size="5%",
      cbar_set_cax=True,
      axes_class=None,
  ):
      """
      Build an :class:`ImageGrid` instance with a grid nrows*ncols
      :class:`~matplotlib.axes.Axes` in
      :class:`~matplotlib.figure.Figure` *fig* with
      *rect=[left, bottom, width, height]* (in
      :class:`~matplotlib.figure.Figure` coordinates) or
      the subplot position code (e.g., "121").
  
      Optional keyword arguments:
  
        ================  ========  =========================================
        Keyword           Default   Description
        ================  ========  =========================================
        direction         "row"     [ "row" | "column" ]
        axes_pad          0.02      float| pad between axes given in inches
                                    or tuple-like of floats,
                                    (horizontal padding, vertical padding)
        add_all           True      bool
        share_all         False     bool
        aspect            True      bool
        label_mode        "L"       [ "L" | "1" | "all" ]
        cbar_mode         None      [ "each" | "single" | "edge" ]
        cbar_location     "right"   [ "left" | "right" | "bottom" | "top" ]
        cbar_pad          None
        cbar_size         "5%"
        cbar_set_cax      True      bool
        axes_class        None      a type object which must be a subclass
                                    of axes_grid's subclass of
                                    :class:`~matplotlib.axes.Axes`
        ================  ========  =========================================
  
      *cbar_set_cax* : if True, each axes in the grid has a cax
        attribute that is bind to associated cbar_axes.
      """
      self._nrows, self._ncols = nrows_ncols
  
      if ngrids is None:
          ngrids = self._nrows * self._ncols
      else:
          if not 0 < ngrids <= self._nrows * self._ncols:
              raise Exception
  
      self.ngrids = ngrids
  
      axes_pad = _extend_axes_pad(axes_pad)
      self._axes_pad = axes_pad
  
      self._colorbar_mode = cbar_mode
      self._colorbar_location = cbar_location
      if cbar_pad is None:
          # horizontal or vertical arrangement?
          if cbar_location in ("left", "right"):
              self._colorbar_pad = axes_pad[0]
          else:
              self._colorbar_pad = axes_pad[1]
      else:
          self._colorbar_pad = cbar_pad
  
      self._colorbar_size = cbar_size
  
      self._init_axes_pad(axes_pad)
  
      if direction not in ["column", "row"]:
          raise Exception("")
  
      self._direction = direction
  
      if axes_class is None:
          axes_class = self._defaultLocatableAxesClass
          axes_class_args = {}
      else:
          if isinstance(axes_class, maxes.Axes):
              axes_class_args = {}
          else:
              axes_class, axes_class_args = axes_class
  
      self.axes_all = []
      self.axes_column = [[] for _ in range(self._ncols)]
      self.axes_row = [[] for _ in range(self._nrows)]
  
      self.cbar_axes = []
  
      h = []
      v = []
      if isinstance(rect, six.string_types) or cbook.is_numlike(rect):
          self._divider = SubplotDivider(
              fig, rect, horizontal=h, vertical=v, aspect=aspect
          )
      elif isinstance(rect, SubplotSpec):
          self._divider = SubplotDivider(
              fig, rect, horizontal=h, vertical=v, aspect=aspect
          )
      elif len(rect) == 3:
          kw = dict(horizontal=h, vertical=v, aspect=aspect)
          self._divider = SubplotDivider(fig, *rect, **kw)
      elif len(rect) == 4:
          self._divider = Divider(
              fig, rect, horizontal=h, vertical=v, aspect=aspect
          )
      else:
          raise Exception("")
  
      rect = self._divider.get_position()
  
      # reference axes
      self._column_refax = [None for _ in range(self._ncols)]
      self._row_refax = [None for _ in range(self._nrows)]
      self._refax = None
  
      for i in range(self.ngrids):
          col, row = self._get_col_row(i)
  
          if share_all:
              if self.axes_all:
                  sharex = self.axes_all[0]
                  sharey = self.axes_all[0]
              else:
                  sharex = None
                  sharey = None
          else:
              sharex = self._column_refax[col]
              sharey = self._row_refax[row]
  
          ax = axes_class(
              fig, rect, sharex=sharex, sharey=sharey, **axes_class_args
          )
  
          self.axes_all.append(ax)
          self.axes_column[col].append(ax)
          self.axes_row[row].append(ax)
  
          if share_all:
              if self._refax is None:
                  self._refax = ax
          if sharex is None:
              self._column_refax[col] = ax
          if sharey is None:
              self._row_refax[row] = ax
  
          cax = self._defaultCbarAxesClass(
              fig, rect, orientation=self._colorbar_location
          )
          self.cbar_axes.append(cax)
  
      self.axes_llc = self.axes_column[0][-1]
  
      self._update_locators()
  
      if add_all:
          for ax in self.axes_all + self.cbar_axes:
              fig.add_axes(ax)
  
      if cbar_set_cax:
          if self._colorbar_mode == "single":
              for ax in self.axes_all:
                  ax.cax = self.cbar_axes[0]
          elif self._colorbar_mode == "edge":
              for index, ax in enumerate(self.axes_all):
                  col, row = self._get_col_row(index)
                  if self._colorbar_location in ("left", "right"):
                      ax.cax = self.cbar_axes[row]
                  else:
                      ax.cax = self.cbar_axes[col]
          else:
              for ax, cax in zip(self.axes_all, self.cbar_axes):
                  ax.cax = cax
  
      self.set_label_mode(label_mode)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  import matplotlib.axes
  import matplotlib.cbook
  import matplotlib.ticker
  from matplotlib.gridspec import SubplotSpec
  from .axes_divider import Size, SubplotDivider, LocatableAxes, Divider
  from .colorbar import Colorbar
label_desc: Use image node_id 1 to create a new ImageGrid object from inherited base classes: Grid with example: obj = ImageGrid(fig, rect, nrows_ncols, ngrids, direction, axes_pad, add_all, share_all, aspect, label_mode, cbar_mode, cbar_location, cbar_pad, cbar_size, cbar_set_cax, axes_class)