File: plot.py

package info (click to toggle)
python-peakutils 1.3.4%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 380 kB
  • sloc: python: 423; makefile: 150; sh: 6
file content (23 lines) | stat: -rw-r--r-- 572 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import matplotlib.pyplot as plt


def plot(x, y, ind):
    """
    Plots the original data with the peaks that were identified

    Parameters
    ----------
    x : array-like
        Data on the x-axis
    y : array-like
        Data on the y-axis
    ind : array-like
        Indexes of the identified peaks
    """
    plt.plot(x, y, "--")

    marker_x = x.iloc[ind] if hasattr(x, "iloc") else x[ind]
    marker_y = y.iloc[ind] if hasattr(y, "iloc") else y[ind]

    plt.plot(marker_x, marker_y, "r+", ms=5, mew=2, label="{} peaks".format(len(ind)))
    plt.legend()