1

I got this plot out of a matplotlib plot. enter image description here

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?

0

1 Answer 1

1

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 = '')

Complete Code

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()

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.