From 8e285dcfbfc80e5cd7b4e94327cdffe852424ed4 Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Sun, 1 Oct 2023 08:06:55 -0400 Subject: [PATCH] Fix the pixels/bin calculation --- src/qtgui/plotter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qtgui/plotter.cpp b/src/qtgui/plotter.cpp index 63c7a65b7..1dba888d1 100644 --- a/src/qtgui/plotter.cpp +++ b/src/qtgui/plotter.cpp @@ -1154,9 +1154,8 @@ void CPlotter::draw(bool newData) const double startFreq = fftCenter - span / 2.0; const double binsPerHz = fftSize / sampleFreq; - // Scale factor for x -> fft bin. Note that it takes 2 pixels to have a - // span of 1 pixel. - double xScale = sampleFreq * (w - 1) / fftSize / span; + // Scale factor for x -> fft bin (pixels per bin). + double xScale = sampleFreq * w / fftSize / span; // Center of fft is the center of the DC bin. The Nyquist bin (index 0 // after shift) is not used.