ptlocator: Point locator

View source: R/plot_extra.R

ptlocatorR Documentation

Point locator

Description

Interactively select points on an existing figure and annotated with new plotting characters.

Usage

ptlocator(
  n = 512L,
  x,
  y,
  col = adjustcolor("red", alpha.f = 0.5),
  pch = 16L,
  ...
)

Arguments

n

the maximum number of points to locate

x, y

x- and y-coordinates

col

color for points

pch

plotting character

...

additional graphical arguments passed to points

Value

Returns (invisibly) the indices of selected points.

References

http://www.r-bloggers.com/data-point-locator-function/

Examples

## Not run: 
set.seed(1)
n <- 200
x <- sort(runif(n, 0, 10 * pi))
y <- sin(x) + rnorm(n, 0, .2)

plot(x, y, cex = 2)
p <- ptlocator(10, x, y, cex = 2)
cbind(x = x[p], y = y[p])

## End(Not run)


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.