Reputation: 173
I got this plot out of a matplotlib plot.
My code is shown here:
from os import sep
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path
from numpy.fft import rfft, rfftfreq
dt=1/10000
g=pd.read_csv('20210803-0002.csv', sep = ';', skiprows=[1,2],usecols = [4],dtype=float, decimal=',')
n=len(g)
acc=g.values.flatten() #to convert DataFrame to 1D array
#acc value must be in numpy array format for half way mirror calculation
fft=rfft(acc)*dt
freq=rfftfreq(n,d=dt)
FFT=abs(fft)
plt.plot(freq,FFT,label = 'neuer Motor')
plt.legend()
plt.show()
plt.close()
I would like to add a marker for every y value > 10.
Does any of you know how to plot these values on the graph?
Upvotes: 1
Views: 1692
Reputation: 12514
You can set your treshold and use it to create a filter:
threshold = 40
filt = y > threshold
Then you can filter x
and y
values:
ax.plot(x, y)
ax.plot(x[filt], y[filt], marker = 'o', linestyle = '')
import numpy as np
import matplotlib.pyplot as plt
N = 1000
x = np.linspace(0, 3000, N)
y = 50*np.random.rand(N)
threshold = 40
filt = y > threshold
fig, ax = plt.subplots()
ax.plot(x, y)
ax.plot(x[filt], y[filt], marker = 'o', linestyle = '')
plt.show()
Upvotes: 1