highlight {NCStats}R Documentation

Labels a list of points on a two-dimensional plot.

Description

Labels a list of points on a two-dimensional plot.

Usage

highlight(x, ...)

## Default S3 method:
highlight(x, y, lbls = NULL, pts = NULL, col = "red",
  cex = 1.25, pos = NULL, ...)

## S3 method for class 'formula'
highlight(x, data = NULL, lbls = NULL, pts = NULL,
  col = "red", cex = 1.25, pos = NULL, ...)

Arguments

x

The vector of x coordinates or a formula of the form y~x.

...

Other arguments to be passed to text().

y

The vector of y coordinates.

lbls

The name of the variable in data or the parent environment that contains the labels for the points. If left as NULL then the points will be labelled with the row number in pts.

pts

The vector of row numbers corresponding to the points to highlight. If left as NULL then every point will be labelled.

col

A numeric or string indicating the color to use when labeling the points.

cex

A numeric characther expansion number for the point labels.

pos

A numeric indicating where to place the labels (see text. If left as NULL then the labels will be placed to minimize label overlap as determined with thigmophobe() from plotrix.

data

The data frame from which the formula should be evaluated.

Details

A two dimensional plot must be active and the x and y vectors must correspond to the x- and y-axes of the plot or x must correspond to the formula used to produce the plot.

Value

None, but an active graphic is modified.

Examples

df <- data.frame(x=runif(10),y=runif(10),grp=factor(rep(c("Yes","No"),each=5)))
plot(y~x,data=df)

# highlight the first and second points with default positioning using the formula notation
highlight(y~x,data=df,lbls=grp,pts=c(1,2))
# highlight the third and fourth points with user-chosen positioning
highlight(y~x,data=df,lbls=grp,pts=c(3,4),pos=c(1,2),col="blue")
# highlight the fifth and sixth points illustrating lack of data= argument
with(df,highlight(y~x,lbls=grp,pts=c(5,6),col="orange"))
# highlight the seventh and eighth points illustrating no use of formula
with(df,highlight(x,y,lbls=grp,pts=c(7,8),col="yellow"))
# highlight the ninth and tenth points with numeric labeling
highlight(y~x,data=df,pts=c(9,10),col="green")

# label all points with their row numbers
plot(y~x,data=df)
highlight(y~x,data=df)


[Package NCStats version 0.4.7 Index]