From 2c5c651e995f9684833f2c41ab051708b0f4ed5f Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 21 Feb 2018 13:13:24 -0800 Subject: [PATCH] Gives fourier graphs created with FFT and underlying function attribute --- active_projects/fourier.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/active_projects/fourier.py b/active_projects/fourier.py index 1c7fd54c..c725d148 100644 --- a/active_projects/fourier.py +++ b/active_projects/fourier.py @@ -59,6 +59,13 @@ def get_fourier_graph( for x, y in zip(frequencies, fft_output[:n_samples//2]) ]) graph.highlight(color) + f_min, f_max = [ + axes.x_axis.point_to_number(graph.points[i]) + for i in 0, -1 + ] + graph.underlying_function = lambda f : axes.y_axis.point_to_number( + graph.point_from_proportion((f - f_min)/(f_max - f_min)) + ) return graph def get_fourier_transform(