FTGramImage: Display Fourier spectrogram

View source: R/rendering_and_plotting.R

FTGramImageR Documentation

Display Fourier spectrogram


This function displays a Fourier spectrogram using the same plot structure and options as HHGramImage. It uses the function EvolutiveFFT to generate a spectrogram, then wraps it in the same plotting format as HHGramImage.


FTGramImage(sig, dt, ft, time.span = NULL, freq.span = NULL, 
     amp.span = NULL, blur = NULL, taper=0.05, scaling = "none", grid=TRUE, 
    colorbar=TRUE, backcol=c(0, 0, 0), colormap=NULL, pretty=FALSE, ...)



The signal to process


sample rate


Fourier spectrogram options

  • ft$nfft is the fft length

  • ft$ns is the number of samples in a window

  • ft$nov is the number of samples to overlap


Time span to render spectrogram over. NULL will draw the spectrogram over the entire signal.


Frequency span to render spectrogram over. NULL plots everything up to the Nyquist frequency.


Amplitude range to plot. NULL plots everything.


Apply a Gaussian smoother. Default NULL - no smoothing


  • blur$sigma is a scalar or two-element vector giving the standard deviation of the Gaussian kernel.

  • blur$bleed determines whether to allow values to bleed out of the domain of the image. Default TRUE


Taper value to use for spectrogram (default is 0.05), see spec.taper in the base package.


determines whether to apply logarithmic (log), or square root (sqrt) scaling to the amplitude data


Boolean - whether to display grid lines or not


Boolean - whether to display amplitude colorbar or not


What background color to use behind the spectrogram, in a 3 element vector: c(red, green, blue)


What palette object to use for the spectrogram, defaults to rainbow


Boolean - choose nice axes values, some adjustment may result


This function supports some optional parameters as well:

  • trace.format - the format of the trace minima and maxima in sprintf format

  • img.x.format - the format of the X axis labels of the image in sprintf format

  • img.y.format - the format of the Y axis labels of the image in sprintf format

  • colorbar.format - the format of the colorbar labels in sprintf format

  • cex.lab - the font size of the image axis labels

  • cex.colorbar - the font size of the colorbar

  • cex.trace - the font size of the trace axis labels

  • img.x.lab - the X - axis label of the image, it defaults to "time"

  • img.y.lab- the Y - axis label of the image, it defaults to "frequency"

  • main - figure title


This function is a simple Fourier spectrogram plotter. It's useful to compare this image with images generated by HHGramImage to see how the Fourier and Hilbert spectrograms differ.



The spectrogram image, suitable for plotting with the generic image function


Daniel Bowman danny.c.bowman@gmail.com


Jonathan M. Lees (2012). RSEIS: Seismic Time Series Analysis Tools. R package version 3.0-6. http://CRAN.R-project.org/package=RSEIS

See Also

HHGramImage, EvolutiveFFT



dt <- mean(diff(tt))

ft <- list()
ft$nfft <- 4096
ft$ns <- 30
ft$nov <- 29

time.span <- c(5, 10)
freq.span <- c(0, 25)
amp.span <- c(1e-5, 0.0003)
FTGramImage(sig, dt, ft, time.span = time.span, freq.span = freq.span, 
    amp.span = amp.span, pretty = TRUE, img.x.format = "%.1f",
    img.y.format = "%.0f",
    main = "Port Foster Event - Fourier Spectrogram")

hht documentation built on Dec. 1, 2022, 1:14 a.m.

Related to FTGramImage in hht...