Skip to contents

Displays the coherence as a function of frequency from the result of coherence. Optionally draws the 95\ a horizontal dashed line.

Usage

plotCoherenceSpectrum(
  result,
  show_threshold = TRUE,
  title = "Coherence Spectrum",
  ...
)

Arguments

result

A list returned by coherence, containing at least $coherence and $frequencies. If $confidence_limit is present it is drawn as a threshold line.

show_threshold

Logical; if TRUE (default) and a confidence limit is available, draw it on the plot.

title

Character string for the plot title (default "Coherence Spectrum").

...

Additional arguments (currently unused).

Value

A ggplot object.

References

Wickham, H. (2016). ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. doi:10.1007/978-3-319-24277-4

Examples

sr <- 500
t <- seq(0, 10, length.out = sr * 10)
x <- sin(2 * pi * 20 * t) + 0.2 * rnorm(length(t))
y <- 0.8 * sin(2 * pi * 20 * t) + 0.2 * rnorm(length(t))
res <- coherence(x, y, sr = sr)
if (requireNamespace("ggplot2", quietly = TRUE)) {
  plotCoherenceSpectrum(res)
}