R/circplot.R

Defines functions circplot

Documented in circplot

circplot <- function(u, mu  = NULL, rads = TRUE, col = 3, lwd = 2) {
  if ( !rads )  u <- u * pi / 180
  dat <- circular::circular(u)
  plot(dat, stack = TRUE)
  if ( is.null(mu) ) {
    cx <- mean( cos(u) )  ;  cy <- mean( sin(u) )
    mu <- ( atan(cy/cx) + pi * I(cx < 0) ) %% (2 * pi)
    cx <- cos(mu)  ;  cy <- sin(mu)
  } else {
    cx <- cos(mu)
    cy <- sin(mu)
  }
  arrows(x0 = 0, y0 = 0, x1 = cx, y1 = cy, length = 0.10, lwd = lwd, col = col)
}

Try the circda package in your browser

Any scripts or data that you put into this service are public.

circda documentation built on Sept. 15, 2026, 5:09 p.m.