Add labels to a plot.

Description

Adds label to points in a a plot, unsing an index.

Usage

1
2
text_id(x, y, ind, labels.id = rownames(x), adj.x = TRUE, 
cex.id = 0.75, label.pos = c(4, 2), ...)

Arguments

x, y

numeric vectors of coordinates where the text labels should be written.

ind

vector of the indices of data points to be marked with a label.

labels.id

vector of the identtification strings of data points to be marked with a label.

adj.x

used to calculate pos.

cex.id

numeric character expansion factor; passed to text.

label.pos

used to calculate pos.

...

further graphical parameters (from par), such as srt, family and xpd.

Author(s)

This is code extracted from function locator.

See Also

locator,identify

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x, y, ind, labels.id = rownames(x), adj.x = TRUE, cex.id = 0.75, 
    label.pos = c(4, 2), ...) 
{
    x <- x[ind]
    y <- y[ind]
    labels.id <- labels.id[ind]
    labpos <- if (adj.x) 
        label.pos[1 + as.numeric(x > mean(range(x)))]
    else 3
    text(x, y, labels.id, cex = cex.id, xpd = TRUE, pos = labpos, 
        offset = 0.25, ...)
  }