From 0a8d5b253aa70f9f03259604b53d51bf77791db8 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Wed, 18 Jan 2017 09:02:53 +0800 Subject: [PATCH] fix: freq coords need to take into account x-coords spacing --- pyqtgraph/graphicsItems/PlotDataItem.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index 11184ae6..485576f6 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -679,8 +679,10 @@ class PlotDataItem(GraphicsObject): x2 = np.linspace(x[0], x[-1], len(x)) y = np.interp(x2, x, y) x = x2 - f = np.fft.rfft(y) / y.size - x = np.fft.rfftfreq(y.size) + n = y.size + f = np.fft.rfft(y) / n + d = (x[-1] - x[0]) / (n - 1) + x = np.fft.rfftfreq(n, d) y = np.abs(f) return x, y