phase.plot: Plot phases with arrows

View source: R/phase.plot.R

phase.plotR Documentation

Plot phases with arrows

Description

Plot phases with arrows

Usage

phase.plot(
  x,
  y,
  phases,
  arrow.len = min(par()$pin[2]/30, par()$pin[1]/40),
  arrow.col = "black",
  arrow.lwd = arrow.len * 0.3
)

Arguments

x

X-coordinates

y

Y-coordinates

phases

Phases

arrow.len

Size of the arrows. Default is based on plotting region.

arrow.col

Arrow line color.

arrow.lwd

Width/thickness of arrows.

Note

Arrows pointing to the right mean that x and y are in phase.

Arrows pointing to the left mean that x and y are in anti-phase.

Arrows pointing up mean that x leads y by \pi/2.

Arrows pointing down mean that y leads x by \pi/2.

Author(s)

Tarik C. Gouhier (tarik.gouhier@gmail.com)

Huidong Tian provided a much better implementation of the phase.plot function that allows for more accurate phase arrows.

Original code based on WTC MATLAB package written by Aslak Grinsted.

Examples

# Code to help interpret arrow direction
a <- 0.5 * pi # phase difference
f <- 10
t <- 1:200
# x leads y by a = 0.5 * pi
x <- sin(t / max(t) * f * 2 * pi)
y <- sin(t / max(t) * f * 2 * pi - a)
par(mfrow = c(2, 1))
plot(t, x, t = "l")
lines(t, y, col = "red")
my_xwt <- xwt(cbind(t, x), cbind(t, y))
plot(my_xwt, plot.phase = TRUE)
# arrows pointing up indicating x leads y

biwavelet documentation built on Sept. 11, 2024, 8:23 p.m.