# Rescaling the x-axis of FFT transformed histogram

**URL:** <https://root-forum.cern.ch/t/rescaling-the-x-axis-of-fft-transformed-histogram/17761>\
**Category:** ROOT\
**Created:** [June 13, 2014, 2:47pm UTC](https://root-forum.cern.ch/t/rescaling-the-x-axis-of-fft-transformed-histogram/17761 "2014-06-13T14:47:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![eberry](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/45deac/32.png) [@eberry](https://root-forum.cern.ch/u/eberry)\
**Post date:** [June 17, 2014, 4:23pm UTC](https://root-forum.cern.ch/t/rescaling-the-x-axis-of-fft-transformed-histogram/17761/2 "2014-06-17T16:23:52Z")

</div>

The answer can be found in the fftw documentation:  
[fftw.org/doc/The-1d-Discrete … \_0029.html](http://www.fftw.org/doc/The-1d-Discrete-Fourier-Transform-_0028DFT_0029.html)

Here is what I believe the answer is:

- Say your input histogram has a sampling frequency of “f”, where f = 1 / (input histogram bin width)
- Say your output histogram has “nFFT” bins
- Then for k \<= (nFFT / 2), the kth bin of your output histogram corresponds to the frequency k \* f / nFFT
- If you only want to plot positive frequencies, then you’re done. Just plot the first nFFT / 2 bins and ignore the following bins of the FFT output.
- If you do want to plot negative frequencies, the values corresponding to the negative frequencies are stored in backwards order in the second half of the output [k \> (nFFT / 2)].

As an aside: in addition to my question on this topic, I noticed a few very similar questions on this forum that had not been answered. Here are just two examples:

> [@Axis rescale in FFT.C](https://root-forum.cern.ch/t/axis-rescale-in-fft-c/15814/1):
>
> Hello, I was playing with the FFT.C and tried to extract the frequency of the input fuction. The totorial says: Unfortunatelly I couldn’t figure out how this is done. Any advice? Regards, Christian

> [@FFT Help](https://root-forum.cern.ch/t/fft-help/17302/1):
>
> Hi, I am new to root and having problems with FFT. I want to perform the FFT on captured time domain signals captured in the lab. I have for example a 4 MHz square wave with 37,500 sample points. The code I am using is below. I would really appreciate if someone with more experience could help me answer these questions. Should I use the same amount of time-domain points for the FFT? On my output FFT graph , I am getting negative amplitudes? How is that possible if I am only getting the re…

Is this feature simply no longer supported? That would be a shame.

Best,  
Edmund

---

_[View the full topic](https://root-forum.cern.ch/t/rescaling-the-x-axis-of-fft-transformed-histogram/17761)._
