Right now im struggling with plotting the graph that should be showing the peaks of my dataset, but it looks like the find_peaks function is cutting off every datapoint that doesnt fit into to the peak detection. Does anybody know how i can still plot the graphs by maybe replacing the datapoints that dont fit with zeros or is there any other possibility?
I am getting the following Error Message: "ValueError: x and y must have same first dimension, but have shapes (800,) and (105,)"
def plot():
i = 1
d_time, d_x, d_y, d_z = [], [], [], []
columns = ["Time", "y", "x", "z"]
df = pd.read_csv("mydata.csv", usecols=columns)
for zeile in df.Time:
if i % 30 == 0:
d_time.append(df.Time[i])
d_x.append(df.x[i])
d_y.append(df.y[i])
d_z.append(df.z[i])
i = 1
elif i > 24000:
break
else:
i = 1
fig = plt.figure(dpi=64, figsize=(100, 60))
p_z, _ = scipy.signal.find_peaks(d_z, 0, distance=5)
plt.plot(d_time, d_z, c='red', label="Z-Achse")
plt.plot(d_time, p_z, "x", c='blue', label="Peaks Z-Achse")
plt.title("Peak Detection", fontsize=16)
plt.xlabel('t(s)', fontsize=16)
fig.autofmt_xdate()
plt.ylabel("a(m/s²)", fontsize=16)
plt.tick_params(axis='both', which='major')
plt.legend()
plt.show()
plot()