class_docstr: A base class of GridSpec that specifies the geometry of the grid
  that a subplot will be placed.
class_docstr_tok: ["A","base","class","of","GridSpec","that","specifies","the","geometry","of","the","grid","that","a","subplot","will","be","placed","."]
docstr: Add all subplots specified by this `GridSpec` to its parent figure.
  
  See `.Figure.subplots` for detailed documentation.
code: def subplots(
      self, *, sharex=False, sharey=False, squeeze=True, subplot_kw=None
  ):
      """
      Add all subplots specified by this `GridSpec` to its parent figure.
  
      See `.Figure.subplots` for detailed documentation.
      """
  
      figure = self.figure
  
      if figure is None:
          raise ValueError(
              "GridSpec.subplots() only works for GridSpecs "
              "created with a parent figure"
          )
  
      if not isinstance(sharex, str):
          sharex = "all" if sharex else "none"
      if not isinstance(sharey, str):
          sharey = "all" if sharey else "none"
  
      _api.check_in_list(
          ["all", "row", "col", "none", False, True],
          sharex=sharex,
          sharey=sharey,
      )
      if subplot_kw is None:
          subplot_kw = {}
      # don't mutate kwargs passed by user...
      subplot_kw = subplot_kw.copy()
  
      # Create array to hold all Axes.
      axarr = np.empty((self._nrows, self._ncols), dtype=object)
      for row in range(self._nrows):
          for col in range(self._ncols):
              shared_with = {
                  "none": None,
                  "all": axarr[0, 0],
                  "row": axarr[row, 0],
                  "col": axarr[0, col],
              }
              subplot_kw["sharex"] = shared_with[sharex]
              subplot_kw["sharey"] = shared_with[sharey]
              axarr[row, col] = figure.add_subplot(
                  self[row, col], **subplot_kw
              )
  
      # turn off redundant tick labeling
      if sharex in ["col", "all"]:
          for ax in axarr.flat:
              ax._label_outer_xaxis(skip_non_rectangular_axes=True)
      if sharey in ["row", "all"]:
          for ax in axarr.flat:
              ax._label_outer_yaxis(skip_non_rectangular_axes=True)
  
      if squeeze:
          # Discarding unneeded dimensions that equal 1.  If we only have one
          # subplot, just return it instead of a 1-element array.
          return axarr.item() if axarr.size == 1 else axarr.squeeze()
      else:
          # Returned axis array will be always 2-d, even if nrows=ncols=1.
          return axarr
  
imports: import copy
  import logging
  from numbers import Integral
  import numpy
  import matplotlib
  from matplotlib import _api, _pylab_helpers, _tight_layout
  from matplotlib.transforms import Bbox
label_desc: Use image node_id 13 for calling the GridSpecBase obj's underlying member method code with example usage: obj.subplots() and returns: unknown, axarr