labelPoints: Label Points

View source: R/labelPoints.R

labelPointsR Documentation

Label Points

Description

Labels points on a graph.

Usage

labelPoints(x, y, labels, dir = "E", offset = 0.75, size = 8,
  color = "black", current = list(yaxis.log = FALSE, yaxis.rev = FALSE,
  xaxis.log = FALSE))

Arguments

x

the x-axis data. Missing values are permitted, but ignored.

y

the y-axis data. Missing values are permitted, but ignored.

labels

the text labels, must be the same length as x and y. Missing values are permitted, but ignored.

dir

the direction relative to the point to place the label. See Details.

offset

the relative offset from the point. See Details.

size

character size in points.

color

the color of the labels.

current

the current plot controls. Typically, this would be the output from one of the graph creation functions like xyPlot.

Details

The value for dir can be of length one or the length of x, in which case, dir applies to the corresponding point. The value must be "N," "NE," "E," "SE," "S," "SW," "W," or "NW" cooresponding to the compass direction or "C" to center the label.

The value for offset can be of length one or the length of x, in in which case, offset applies to the corresponding point. The value is relative to the size of the test. The default value of offset is correct for creating a text plot, where the text is centered on the value.

Value

A list containing x, y, and labels.

Note

The current version does not have any method to automatically eliminate overlapping labels. Several iterations may be required trying various values for dir and possibly offset to produce non overlapping labels.

See Also

addAnnotation,, xyPlot

Examples

## Not run: 
set.seed(1)
X <- rnorm(32)
Y <- X + rnorm(32)
setGD()
xyPlot(X, Y)
# Label the first point
labelPoints(X[1], Y[1], "First")
# For more details of labelPoints see
vignette(topic="GraphAdditions", package="smwrGraphs")

## End(Not run)

USGS-R/smwrGraphs documentation built on Oct. 11, 2022, 6:11 a.m.