hyperbolaPlot: Plot a hyperbola

View source: R/hyperbola.R

hyperbolaPlotR Documentation

Plot a hyperbola

Description

Plot a hyperbola

Usage

hyperbolaPlot(
  hyp,
  x = NULL,
  add = TRUE,
  ann = FALSE,
  ann.pos = 3,
  ann.offset = 0.5,
  ann.col = "green",
  ann.font = 2,
  n = 100,
  ...
)

Arguments

hyp

[list|class hyperbola] Either a list with elements x0, t0, and vrms corresponding to the coordinates of the hyperbola vertex and the root-mean-square velocity, or a list of class hyperbola (i.e., the output of the function hyperbolaFit). y = NULL)

x

[numeric] The horitzontal positions at which to plot the hyperbola (optional, see details).

add

[logical(1)] If TRUE (defaults), add the hyperbola to current plot. If FALSE, display the hyperbola in a new plot. In this case you must specify x.

ann

[logical(1)] If TRUE, add the following annotation above the hyperbola vertex: root-mean-square velocity and vertex depth.

ann.pos

[numeric(1)] A position specifier for the annotation text. See argument pos of the function text.

ann.offset

[numeric(1)] when pos is specified, this value controls the distance ('offset') of the annotation text label from the specified coordinate in fractions of a character width. See argument offset of the function text.

ann.col

[character(1)] Color of the annotation text. See argument col of the function text.

ann.font

[integer(1)] Number of points used to plot the hyperbola when x is not specified.

...

Additional arguments passed to lines (if add = TRUE) or to plot (if add = FALSE) .

Details

If x = NULL and add = TRUE, the hyperbola is per default displayed over the entire plot. You can define the extent of the hyperbola by setting xlim as in the function plot. If add = FALSE x must be defined otherwise an error is raised.

See Also

hyperbolaFit, hyperbolaSim

Examples

data("frenkeLine00")
x <- frenkeLine00
x <- estimateTime0(x, w = 5, method = "MER", FUN = mean)
x <- time0Cor(x, method = "pchip")
x <- gainAGC(fFilter(x, f = c(180, 250), type = "low"), w = 20)
plot(x)

# xy <- locator(type = "l")
xy <- list( x = c( 11.8,  15.0,  17.7, 20.3, 24.4,  27.4,  30.9,  35.2),
            y = c(142.2, 119.8, 107.7, 99.5, 97.5, 105.6, 120.9, 138.1))
hyp <- hyperbolaFit(xy)
hyperbolaPlot(hyp, x = seq(5, 50, by = 0.01), col = "green", 
              lwd = 4, ann = TRUE)
points(xy, pch = 20, col = "blue")

plot(x)
hyp2 <- list(x0 = hyp$x0, t0 = hyp$t0, vrms = hyp$vrms)
hyperbolaPlot(hyp2, col = "blue", lwd = 2, ann = TRUE, xlim = c(10, 40))
points(hyp$x0, hyp$t0, pch = 20, col = "red", cex = 1.3)

# with 'add = FALSE'
plot(x)
hyperbolaPlot(hyp, x = seq(10, 40, by = 0.1), col = "red", 
lwd = 2,  add = FALSE, type = "l")
hyperbolaPlot(hyp, x = seq(10, 40, by = 0.1), col = "red", 
             lwd = 2,  add = FALSE, type = "l", ylim = c(175, 95))


emanuelhuber/RGPR documentation built on May 13, 2024, 9:31 p.m.