mohass98 / pyqtgraph

Fast data visualization and GUI tools for scientific / engineering applications
https://www.pyqtgraph.org
Other
0 stars 2 forks source link

Error when using FFT on data with one point #3018 #6

Closed Silas-K closed 2 months ago

Silas-K commented 2 months ago

See issue: pyqtgraph/pyqtgraph#3018

"""
Simple example to reproduce the fft error
"""

import numpy as np
import pyqtgraph as pg

win = pg.plot()
win.setWindowTitle('pyqtgraph example: FFT')

# Add a plot
x = np.array([1])
y = np.array([1])
win.plot(x, y, pen=None, symbol='o')  # Plot a single data point

# After plotting apply the fft transform in the context menu
# --> Plot Options
#     --> Transforms
#         --> Power Spectrum (FFT)

if __name__ == '__main__':
    pg.exec()
Silas-K commented 2 months ago

Fixed with 1731e714f098496f731b89bc825f25b76c716ea4

Local tests produced the same results as the master branch:

image

image

[!NOTE]
TODO: Pull Request to main repo

Silas-K commented 2 months ago

Merged into main pyqtgraph repo with this pull request https://github.com/pyqtgraph/pyqtgraph/pull/3070