docs: def _plot(x, mph, mpd, threshold, edge, valley, ax, ind):
      """Plot results of the detect_peaks function, see its help."""
      try:
          import matplotlib.pyplot as plt
      except ImportError:
          print('matplotlib is not available.')
      else:
          if ax is None:
              _, ax = plt.subplots(1, 1, figsize=(8, 4))
  
          ax.plot(x, 'b', lw=1)
          if ind.size:
              label = 'valley' if valley else 'peak'
              label = label + 's' if ind.size > 1 else label
              ax.plot(ind, x[ind], '+', mfc=None, mec='r', mew=2, ms=8,
                      label='%d %s' % (ind.size, label))
              ax.legend(loc='best', framealpha=.5, numpoints=1)
          ax.set_xlim(-.02*x.size, x.size*1.02-1)
          ymin, ymax = x[np.isfinite(x)].min(), x[np.isfinite(x)].max()
          yrange = ymax - ymin if ymax > ymin else 1
          ax.set_ylim(ymin - 0.1*yrange, ymax + 0.1*yrange)
          ax.set_xlabel('Data #', fontsize=14)
          ax.set_ylabel('Amplitude', fontsize=14)
          mode = 'Valley detection' if valley else 'Peak detection'
          ax.set_title("%s (mph=%s, mpd=%d, threshold=%s, edge='%s')"
                       % (mode, str(mph), mpd, str(threshold), edge))