docs: def plot_data(
      input_data,
      xlabel=None,
      ylabel=None,
      sed=True,
      figure=None,
      e_unit=None,
      ulim_opts={},
      errorbar_opts={},
  ):
      """
      Plot spectral data.
  
      Parameters
      ----------
      input_data : `emcee.EnsembleSampler`, `astropy.table.Table`, or `dict`
          Spectral data to plot. Can be given as a data table, a dict generated
          with `validate_data_table` or a `emcee.EnsembleSampler` with a data
          property.
      xlabel : str, optional
          Label for the ``x`` axis of the plot.
      ylabel : str, optional
          Label for the ``y`` axis of the plot.
      sed : bool, optional
          Whether to plot SED or differential spectrum.
      figure : `matplotlib.figure.Figure`, optional
          `matplotlib` figure to plot on. If omitted a new one will be generated.
      e_unit : `astropy.unit.Unit`, optional
          Units for energy axis. Defaults to those of the data.
      ulim_opts : dict
          Options for upper-limit plotting. Available options are capsize (arrow
          width) and height_fraction (arrow length in fraction of flux value).
      errorbar_opts : dict
          Addtional options to pass to `matplotlib.plt.errorbar` for plotting the
          spectral flux points.
      """
  
      import matplotlib.pyplot as plt
  
      try:
          data = validate_data_table(input_data)
      except TypeError as exc:
          if hasattr(input_data, "data"):
              data = input_data.data
          elif isinstance(input_data, dict) and "energy" in input_data.keys():
              data = input_data
          else:
              log.warning(
                  "input_data format unknown, no plotting data! "
                  "Data loading exception: {}".format(exc)
              )
              raise
  
      if figure is None:
          f = plt.figure()
      else:
          f = figure
  
      if len(f.axes) > 0:
          ax1 = f.axes[0]
      else:
          ax1 = f.add_subplot(111)
  
      # try to get units from previous plot in figure
      try:
          old_e_unit = u.Unit(ax1.get_xlabel().split("[")[-1].split("]")[0])
      except ValueError:
          old_e_unit = u.Unit("")
  
      if e_unit is None and old_e_unit.physical_type == "energy":
          e_unit = old_e_unit
      elif e_unit is None:
          e_unit = data["energy"].unit
  
      _plot_data_to_ax(
          data,
          ax1,
          e_unit=e_unit,
          sed=sed,
          ylabel=ylabel,
          ulim_opts=ulim_opts,
          errorbar_opts=errorbar_opts,
      )
  
      if xlabel is not None:
          ax1.set_xlabel(xlabel)
      elif xlabel is None and ax1.get_xlabel() == "":
          ax1.set_xlabel(
              r"$\mathrm{Energy}$"
              + " [{0}]".format(e_unit.to_string("latex_inline"))
          )
  
      ax1.autoscale()
  
      return f