code: def _plot_alignment(
      x, y, metric, dist_kwargs: dict = None, title: str = ""
  ):
      _check_soft_dependencies("matplotlib")
  
      import matplotlib as plt
  
      if dist_kwargs is None:
          dist_kwargs = {}
      try:
          path, dist, cost_matrix = distance_alignment_path(
              x,
              y,
              metric=metric,
              return_cost_matrix=True,
              **dist_kwargs,
          )
      except NotImplementedError:
          path, dist, cost_matrix = _pairwise_path(x, y, metric)
  
      plt.figure(1, figsize=(8, 8))
  
      plt.plot(x, "b-", color="black")
      plt.plot(y, "g-", color="black")
  
      for positions in path:
          try:
              plt.plot(
                  [positions[0], positions[1]],
                  [x[positions[0]], y[positions[1]]],
                  "--",
                  color="#818587",
              )
          except:
              continue
      plt.legend()
      plt.title(title)
  
      plt.tight_layout()
      return plt
  
imports: import numpy
  from sktime.distances._distance import distance_alignment_path, pairwise_distance
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 4 for calling a global function with example usage: _plot_alignment(x, y, metric, dist_kwargs, title) and returns: plt