title: Plot scipy.signal.find_peaks graph with datetime data
body: <p>I would like to use <code>scipy.signal.find_peaks</code> to find peaks for <code>Value</code> in <code>df</code> as shown below.</p>
  <p>df:</p>
  <pre><code>  index Timestamp               Value   Id
  0   36  2020-11-08 23:30:40.370 45.5    15
  1   47  2020-11-13 04:52:29.410 44.5    15
  2   67  2020-12-01 22:17:50.300 42.5    20
  3   129 2020-11-24 00:57:11.950 43.0    103
  4   176 2020-12-03 01:40:16.250 42.0    87
  5   246 2020-11-12 07:32:54.000 43.5    103
  6   281 2020-11-30 21:13:07.630 45.5    15
  7   335 2020-11-30 20:43:11.050 43.5    15
  8   370 2020-11-09 06:04:19.630 45.0    15
  9   375 2020-11-22 21:21:33.150 44.0    115
  10  384 2020-11-23 22:04:44.580 40.5    20
  11  408 2020-11-16 03:26:10.150 46.0    15
  12  428 2020-12-07 02:04:42.890 46.5    15
  13  437 2020-11-26 00:10:34.660 47.0    15
  14  482 2020-11-26 04:14:23.180 46.0    15
  15  500 2020-12-06 19:40:30.580 46.0    15
  16  528 2020-11-26 02:17:27.110 47.5    15
  17  585 2020-11-25 18:13:17.450 43.0    15
  18  641 2020-11-26 20:02:13.170 46.0    15
  19  647 2020-11-11 21:36:09.530 41.0    112
  </code></pre>
  <p>reproducible example:</p>
  <pre><code>from pandas import Timestamp
  df = pd.DataFrame({'index': {0: 36,
    1: 47,
    2: 67,
    3: 129,
    4: 176,
    5: 246,
    6: 281,
    7: 335,
    8: 370,
    9: 375,
    10: 384,
    11: 408,
    12: 428,
    13: 437,
    14: 482,
    15: 500,
    16: 528,
    17: 585,
    18: 641,
    19: 647},
   'Timestamp': {0: Timestamp('2020-11-08 23:30:40.370000'),
    1: Timestamp('2020-11-13 04:52:29.410000'),
    2: Timestamp('2020-12-01 22:17:50.300000'),
    3: Timestamp('2020-11-24 00:57:11.950000'),
    4: Timestamp('2020-12-03 01:40:16.250000'),
    5: Timestamp('2020-11-12 07:32:54'),
    6: Timestamp('2020-11-30 21:13:07.630000'),
    7: Timestamp('2020-11-30 20:43:11.050000'),
    8: Timestamp('2020-11-09 06:04:19.630000'),
    9: Timestamp('2020-11-22 21:21:33.150000'),
    10: Timestamp('2020-11-23 22:04:44.580000'),
    11: Timestamp('2020-11-16 03:26:10.150000'),
    12: Timestamp('2020-11-07 02:04:42.890000'),
    13: Timestamp('2020-11-26 00:10:34.660000'),
    14: Timestamp('2020-11-26 04:14:23.180000'),
    15: Timestamp('2020-12-06 19:40:30.580000'),
    16: Timestamp('2020-12-26 02:17:27.110000'),
    17: Timestamp('2020-11-25 18:13:17.450000'),
    18: Timestamp('2020-11-26 20:02:13.170000'),
    19: Timestamp('2020-11-11 21:36:09.530000')},
   'Value': {0: 45.5,
    1: 44.5,
    2: 42.5,
    3: 43.0,
    4: 42.0,
    5: 43.5,
    6: 45.5,
    7: 43.5,
    8: 45.0,
    9: 44.0,
    10: 40.5,
    11: 46.0,
    12: 46.5,
    13: 47.0,
    14: 46.0,
    15: 46.0,
    16: 47.5,
    17: 43.0,
    18: 46.0,
    19: 41.0},
   'Id': {0: 15,
    1: 15,
    2: 20,
    3: 103,
    4: 87,
    5: 103,
    6: 15,
    7: 15,
    8: 15,
    9: 115,
    10: 20,
    11: 15,
    12: 15,
    13: 15,
    14: 15,
    15: 15,
    16: 15,
    17: 15,
    18: 15,
    19: 112}})
  </code></pre>
  <p>Using the code below:</p>
  <pre><code>import matplotlib.pyplot as plt
  from scipy.misc import electrocardiogram
  from scipy.signal import find_peaks
  
  x = df['Value'].values
  peaks, properties = find_peaks(x, prominence=0.1, width=1)
  properties[&quot;prominences&quot;], properties[&quot;widths&quot;]
  
  plt.figure(figsize=(15,12))
  plt.plot(x)
  plt.plot(peaks, x[peaks], &quot;x&quot;)
  plt.vlines(x=peaks, ymin=x[peaks] - properties[&quot;prominences&quot;],
             ymax = x[peaks], color = &quot;C1&quot;)
  plt.hlines(y=properties[&quot;width_heights&quot;], xmin=properties[&quot;left_ips&quot;],
             xmax=properties[&quot;right_ips&quot;], color = &quot;C1&quot;)
  plt.show()
  </code></pre>
  <p>and the output is below, which only considered the <code>Value</code> column.
  <a href="https://i.stack.imgur.com/MMiAu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MMiAu.png" alt="enter image description here" /></a></p>
  <p>How can I make <code>Timestamp</code> the horizontal axis?</p>
  <hr />
  <p>Edit:</p>
  <p>I tried to make <code>Timestamp</code> the index and changed the x- and y- axis accordingly:</p>
  <pre><code>
  import matplotlib.pyplot as plt
  from scipy.misc import electrocardiogram
  from scipy.signal import find_peaks
  
  z = df
  z.set_index('Timestamp', inplace=True)
  z.index.to_pydatetime()
  peaks, properties = find_peaks(z.Value, prominence=0.1, width=1)
  properties[&quot;prominences&quot;], properties[&quot;widths&quot;]
  
  plt.figure(figsize=(15,12))
  plt.plot_date(z.index, z.Value)
  plt.plot_date(z.index[peaks], z.Value[peaks], &quot;x&quot;)
  plt.vlines(x=z.index[peaks], ymin=z.Value[peaks] - properties[&quot;prominences&quot;],
             ymax = z.index[peaks], color = &quot;C1&quot;)
  plt.hlines(y=properties[&quot;width_heights&quot;], xmin=properties[&quot;left_ips&quot;],
             xmax=properties[&quot;right_ips&quot;], color = &quot;C1&quot;)
  plt.show()
  </code></pre>
  <p>which returned:
  <a href="https://i.stack.imgur.com/YNypu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YNypu.png" alt="enter image description here" /></a></p>
  <p>What could have gone wrong?</p>
  <hr />
  <p>Edit 2:
  Using @Asmus's solution on a larger dataset, I noticed that the graph changed completely when I changed the <code>prominence</code> and <code>width</code>. For instance, in the graph below I used <code>prominence== 5</code> and <code>width==0.0001157</code>, for <code>Value &gt; 30</code> because I'm interested in peaks above 30 for <code>Value</code>, and have a prominence of around 5 and width of 0.0001157, which is 10 seconds as a fraction of a day.</p>
  <p><a href="https://i.stack.imgur.com/klSmc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/klSmc.png" alt="enter image description here" /></a></p>
  <p>Then if I changed <code>prominence</code> to 10, it looks like this:
  <a href="https://i.stack.imgur.com/Rm4Ow.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rm4Ow.png" alt="enter image description here" /></a></p>
  <p>Both look very differently from the original data, as below:
  <a href="https://i.stack.imgur.com/rklQT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rklQT.png" alt="enter image description here" /></a></p>
  <p>Why is this happening?</p>