Identify Points on Plot - Generic Function

DESCRIPTION:
Interactively identifies points in a plot if a suitable graphics device is being used.

This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include: tree.


USAGE:
identify(x, ...)
identify.default(x, y, labels = seq(along = x), n = length(x),
                 plot = T, atpen = T, offset = 0.5, pts,
                 tolerence = 0.5, ...)

REQUIRED ARGUMENTS:
x,y:
coordinates of points. The coordinates can be given by two arguments that are vectors or by a single argument x which is a univariate time series, a complex vector, a matrix with 2 columns, or a list containing components named x and y.
Missing values (NA) are allowed.

OPTIONAL ARGUMENTS:
labels:
vector giving labels for each of the points. If supplied, this must have the same length as x and y.
n:
maximum number of points to identify.
plot:
if TRUE, identify plots the labels of the points identified. In any case, the subscripts are returned.
atpen:
if TRUE, plotted identification is relative to locator position when the point is identified; otherwise, plotting is relative to the identified x,y value. This is useful for controlling the position of labels when points are crowded.
offset:
identification is plotted as a text string, moved offset character widths from the point. If the locator was left (right) of the nearest point, the label will be offset to the left (right) of the point.
pts:
locations to identify. If this argument is supplied, the locations given by pts$x and pts$y (or pts[,1] and pts[,2] if pts is a matrix) will be identified automatically, you will not need to click on them.
tolerence:
maximum distance in inches which a point can be from the cursor in order to be identified. Default value is 0.5.

Graphical parameters may also be supplied as arguments to this function (see par).


VALUE:
indices (in x and y) corresponding to identified points.

SIDE EFFECTS:
labels are placed on the current plot if plot is TRUE.

DETAILS:
Observations that have missing values in either x or y are treated as if they were not given.

When using the X11 driver under the X Window System, a point is identified by positioning the cursor over the point and pressing the left button. To exit identify press the middle button (both buttons on a two button mouse) while the cursor is in the graphics window. The same procedure is used under the suntools driver. This function may also be used with the "tek" drivers.

Some devices that do not allow interaction prompt you for an x,y pair.

The nearest point to the locator position is identified. In case of ties, the earliest point is identified.


SEE ALSO:
locator , par , text .

EXAMPLES:
identify(x, y, z)   # plot z values when x,y points identified
bad <- identify(x, y, plot = FALSE)
xgood <- x[-bad]       # eliminate identified "bad" points
ygood <- y[-bad]       # from x and y
# use the pts argument and locator to identify all points at once
x <- c(1, 2, 3)
y <- c(3, 4, 5)
plot(x, y)
pts <- locator() # click once on each of the three points
identify(x, y, pts = pts) # all the points on the plot are labelled
                          # at once