class_docstr: The location of a subplot in a `GridSpec`.
  
  .. note::
  
      Likely, you will never instantiate a `SubplotSpec` yourself. Instead,
      you will typically obtain one from a `GridSpec` using item-access.
  
  Parameters
  ----------
  gridspec : `~matplotlib.gridspec.GridSpec`
      The GridSpec, which the subplot is referencing.
  num1, num2 : int
      The subplot will occupy the *num1*-th cell of the given
      *gridspec*.  If *num2* is provided, the subplot will span between
      *num1*-th cell and *num2*-th cell **inclusive**.
  
      The index starts from 0.
class_docstr_tok: ["The","location","of","a","subplot","in","a","`","GridSpec","`",".","..","note",":",":","Likely",",","you","will","never","instantiate","a","`","SubplotSpec","`","yourself",".","Instead",",","you","will","typically","obtain","one","from","a","`","GridSpec","`","using","item-access",".","Parameters","--","--","--","--","--","gridspec",":","`","~matplotlib.gridspec.GridSpec","`","The","GridSpec",",","which","the","subplot","is","referencing",".","num1",",","num2",":","int","The","subplot","will","occupy","the","*","num1","*","-th","cell","of","the","given","*","gridspec","*",".","If","*","num2","*","is","provided",",","the","subplot","will","span","between","*","num1","*","-th","cell","and","*","num2","*","-th","cell","*","*","inclusive","*","*",".","The","index","starts","from","0","."]
docstr: Construct a `.SubplotSpec` from a parent `.Figure` and either
  
  - a `.SubplotSpec` -- returned as is;
  - one or three numbers -- a MATLAB-style subplot specifier.
code: def _from_subplot_args(figure, args):
      """
      Construct a `.SubplotSpec` from a parent `.Figure` and either
  
      - a `.SubplotSpec` -- returned as is;
      - one or three numbers -- a MATLAB-style subplot specifier.
      """
      if len(args) == 1:
          (arg,) = args
          if isinstance(arg, SubplotSpec):
              return arg
          elif not isinstance(arg, Integral):
              raise ValueError(
                  f"Single argument to subplot must be a three-digit "
                  f"integer, not {arg!r}"
              )
          try:
              rows, cols, num = map(int, str(arg))
          except ValueError:
              raise ValueError(
                  f"Single argument to subplot must be a three-digit "
                  f"integer, not {arg!r}"
              ) from None
      elif len(args) == 3:
          rows, cols, num = args
      else:
          raise _api.nargs_error(
              "subplot", takes="1 or 3", given=len(args)
          )
  
      gs = GridSpec._check_gridspec_exists(figure, rows, cols)
      if gs is None:
          gs = GridSpec(rows, cols, figure=figure)
      if isinstance(num, tuple) and len(num) == 2:
          if not all(isinstance(n, Integral) for n in num):
              raise ValueError(
                  f"Subplot specifier tuple must contain integers, not {num}"
              )
          i, j = num
      else:
          if (
              not isinstance(num, Integral)
              or num < 1
              or num > rows * cols
          ):
              raise ValueError(
                  f"num must be an integer with 1 <= num <= {rows*cols}, "
                  f"not {num!r}"
              )
          i = j = num
      return gs[i - 1 : j]
  
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 3 for calling the SubplotSpec obj's underlying member method code with example usage: obj._from_subplot_args(figure, args) and returns: gs, arg