title: How to visualize FFT of a signal in Julia?
body: <p>I'm trying to visualize a signal and its frequency spectrum in Julia.</p>
  
  <p>I found the <a href="https://github.com/JuliaMath/FFTW.jl" rel="noreferrer">FFTW</a> package that provides the FFT and <a href="https://github.com/JuliaDSP/DSP.jl" rel="noreferrer">DSP</a> for the frequencies.</p>
  
  <p>Here is what I'm trying, with a sinusoidal signal:</p>
  
  <pre><code>using Plots
  using FFTW
  using DSP
  
  # Number of points
  N = 2^14 - 1
  # Sample rate
  fs = 1 / (1.1 * N)
  # Start time
  t0 = 0
  tmax = t0 + N * fs
  
  # time coordinate
  t = [t0:fs:tmax;]
  
  # signal
  signal = sin.(2π * 60 * t)  # sin (2π f t)
  
  # Fourier Transform of it
  F = fft(signal)
  freqs = fftfreq(length(t), fs)
  freqs = fftshift(freqs)
  
  # plots
  time_domain = plot(t, signal, title = "Signal")
  freq_domain = plot(freqs, abs.(F), title = "Spectrum")
  plot(time_domain, freq_domain, layout = 2)
  savefig("Wave.pdf")
  </code></pre>
  
  <p>I expected to see a nice plot with a peak in the 60 Hz, but all I got was a weird result:</p>
  
  <p><img src="https://i.imgur.com/5aZchIX.png" alt="Imgur"></p>
  
  <p>I'm ignoring the negative frequencies for now.</p>
  
  <p>How should I do that in Julia?</p>