[英]find_peaks() put the peaks correct, but squeezed the plot left benear
我想通過 scipy 庫檢測曲線中的峰值,它是 function find_peaks()。
如果我 plot 在我的腳本中沒有 find_peaks() 函數的曲線,它將按預期繪制。
但是如果我在我的腳本中使用 find_peaks() function plot 會顯示這種意外行為。
任何想法這里出了什么問題都值得贊賞。
多謝。
如果我 plot 沒有 find_peaks() 函數的曲線,它按預期繪制:
但是,如果我使用 find_peaks() function plot 會顯示這種意外行為:
我使用此源代碼作為壓縮的 plot 顯示:
import pandas as pd
import numpy as np
from scipy.signal import find_peaks
"""Read the file
"""
path = '../data/accelerometer/Wrist-Accelerometer-X-Axis-UpDown.csv'
"""Define the variables
"""
w = data['elapsed (s)']
x = data['x-axis (g)']
"""Plot the data
"""
fig, ax1 = plt.subplots(nrows=1, ncols=1, figsize=(8, 4))
ax1.plot(w, x, marker='.')
ax1.set_title('UpDown movement: Behaviour of x-axis')
ax1.set_xlabel('$Datapoints$')
ax1.xaxis.set_major_locator(plt.MultipleLocator(0.5))
ax1.set_ylabel('$Acceleration \n on x-axis (g)$')
ax1.yaxis.set_major_locator(plt.AutoLocator())
peaks, _ = find_peaks(x, -2, 0, prominence=1, distance=1)
ax1.plot(peaks, x[peaks], 'x', markersize=8)
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.