Get Coordinates from Plot

DESCRIPTION:
Returns the coordinates specified interactively on a plot under certain graphics device drivers. Points and/or lines may be added to the plot.

USAGE:
locator(n=500, type="n", noclick=F)

OPTIONAL ARGUMENTS:
n:
the maximum number of points to locate.
type:
character describing interactive drawing option. If type is "n", nothing is drawn. Values of "p", "l", "b", and "o" plot points at the digitized coordinates, lines connecting them, both points and lines, or overplotted points and lines.
noclick:
logical flag: should the function return a single locator position immediately, without waiting for user interaction? This can only be done on certain devices.

VALUE:
list containing vector components x and y which give coordinates for each point. The length of these vectors is at most n, but can be shorter if the user terminates graphic input after fewer than n points are given.

If noclick=TRUE is specified, an additional component, n, gives the status of the locator device (typically a numeric encoding of the states of the mouse buttons).


SIDE EFFECTS:
if type does not equal "n", then points and/or lines are added to the current plot.

DETAILS:
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 mouse button. To exit locator, 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 don't allow real interaction will prompt you for an x,y pair.


WARNING:
Remember that you must locate n points or exit locator in order to be able to get back to the S-PLUS prompt.

SEE ALSO:
identify , text .

EXAMPLES:
amp;# user points at an outlier which is then labelled
text(locator(1), "outlier")
amp;# position a legend
legend(locator(1), legend=c("IBM", "AT&T", "GM"), fill=2:4)
lines(locator())    # input a number of points, connect with line
locator(type="l")    # alternative