I am having a problem, because I do not fully follow the documentation, and pyCharm does not fully traverse the objects in pyQtGraph.
Here's my code, to date.
class FFT_Plot():
def __init__(self,
win,
nSamples,
aData,
sRate,
wFunction,
zStart = 0):
self.nSamples = nSamples # Number of Sample must be a 2^n power
self.aData = aData # Amplitude data array
self.sRate = sRate # Sample Rate
self.wFunction = wFunction # Windowing Function
self.zStart = zStart # Start of Zoom Window if Used
self.zStop = nSamples/2 # End of Zoom Window if Used
# Instantiate a plot window within an existing pyQtGraph window.
self.plot = win.addPlot(title="FFT")
self.update(aData)
self.grid_state()
self.plot.setLabel('left', 'Amplitude', 'Volts')
self.plot.setLabel('bottom', 'Frequency', 'Hz')
def update(self, aData):
x = np.fft.fft(aData,)
amplitude = np.absolute(x)
fScale = np.linspace(0 , 50000, self.nSamples)
self.plot.plot(amplitude)
# Calculate and set-up X axis
self.plot.setXRange(SampleSize/2, 0)
def grid_state(self, x = True, y = True):
self.plot.showGrid(x, y)
I am not showing how I create a sine wave and test this Class.
How do I scale the axis values so that, ex. 2048 samples, instead of the axis displaying 0 to 1 it displays the frequency values?
Mike Sr.