docs: def plot_spectrum(cube, xtick, ytick, aperture, ax=None, **kwargs):
      """Plot a spectrum.
  
      Args:
          cube (xarray.DataArray): Cube which the spectrum information is included.
          xtick (str): Type of x axis.
              'freq': Frequency [GHz].
              'id': Kid id.
          ytick (str): Type of y axis.
              'max': Maximum.
              'sum': Summation.
              'mean': Mean.
          aperture (str): The shape of aperture.
              'box': Box.
              'circle': Circle.
          ax (matplotlib.axes): Axis you want to plot on.
          kwargs (optional):
              When 'box' is specified as shape,
                  xc: Center of x.
                  yc: Center of y.
                  width: Width.
                  height: Height.
                  xmin: Minimum of x.
                  xmax: Maximum of x.
                  ymin: Minimum of y.
                  ymax: Maximum of y.
              When 'circle' is specified as shape,
                  xc: Center of x.
                  yc: Center of y.
                  radius: Radius.
              Remaining kwargs are passed to ax.step().
  
      Notes:
          All kwargs should be specified as pixel coordinates.
      """
      if ax is None:
          ax = plt.gca()
  
      ### pick up kwargs
      xc     = kwargs.pop('xc', None)
      yc     = kwargs.pop('yc', None)
      width  = kwargs.pop('width', None)
      height = kwargs.pop('height', None)
      xmin   = kwargs.pop('xmin', None)
      xmax   = kwargs.pop('xmax', None)
      ymin   = kwargs.pop('ymin', None)
      ymax   = kwargs.pop('ymax', None)
      radius = kwargs.pop('radius', None)
      exchs  = kwargs.pop('exchs', None)
  
      ### labels
      xlabeldict = {'freq': 'frequency [GHz]', 'id': 'kidid'}
  
      cube     = cube.copy()
      datatype = cube.datatype
      if aperture == 'box':
          if None not in [xc, yc, width, height]:
              xmin, xmax = int(xc - width / 2), int(xc + width / 2)
              ymin, ymax = int(yc - width / 2), int(yc + width / 2)
          elif None not in [xmin, xmax, ymin, ymax]:
              pass
          else:
              raise KeyError('Invalid arguments.')
          value = getattr(cube[xmin:xmax, ymin:ymax, :], ytick)(dim=('x', 'y'))
      elif aperture == 'circle':
          if None not in [xc, yc, radius]:
              pass
          else:
              raise KeyError('Invalid arguments.')
          x, y   = np.ogrid[0:len(cube.x), 0:len(cube.y)]
          mask   = ((x - xc)**2 + (y - yc)**2 < radius**2)
          mask   = np.broadcast_to(mask[:, :, np.newaxis], cube.shape)
          masked = np.ma.array(cube.values, mask=~mask)
          value  = getattr(np, 'nan'+ytick)(masked, axis=(0, 1))
      else:
          raise KeyError(aperture)
  
      if xtick == 'freq':
          kidfq     = cube.kidfq.values
          freqrange = ~np.isnan(kidfq)
          if exchs is not None:
              freqrange[exchs] = False
          x = kidfq[freqrange]
          y = value[freqrange]
          ax.step(x[np.argsort(x)], y[np.argsort(x)], where='mid', **kwargs)
      elif xtick == 'id':
          ax.step(cube.kidid.values, value, where='mid', **kwargs)
      else:
          raise KeyError(xtick)
      ax.set_xlabel('{}'.format(xlabeldict[xtick]))
      ax.set_ylabel('{} ({})'.format(datatype.values, ytick))
      ax.set_title('spectrum')