addAnnotation: Add Text to a Graph

View source: R/addAnnotation.R

addAnnotationR Documentation

Add Text to a Graph

Description

Adds text to a plot to annotate a feature.

Usage

addAnnotation(x, y, annotation, leaderx = NULL, leadery = NULL,
  leadercol = "black", angle = 0, justification = "left", size = 60
  * par("csi"), position = "above", current = list(yaxis.log = FALSE,
  yaxis.rev = FALSE, xaxis.log = FALSE))

Arguments

x

the x-axis placement of annotation.

y

the y-axis placement of annotation.

annotation

the text. Can be either a character string or an "expression" object.

leaderx

draw leader from x to leaderx.

leadery

draw leader from y to leadery.

leadercol

the color of the leader.

angle

the angle to rotate the text.

justification

the justification of the text relative to x, y. Must be one of "left," "center," or "right."

size

size of the text in points, the default is the current point size.

position

the vertical location of the text. Must be one of "above," "below," or "center."

current

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

Details

This function places only a single annotation string on the graph for each call.
A leader from x, y to leaderx, leadery if leaderx is not NULL.

Value

The current plot information is returned invisibly.

See Also

labelPoints, addTable, xyPlot

Examples

## Not run: 
set.seed(12)
X <- rnorm(12)
Y <- X + rnorm(12)
# make an outlier
X[1L] <- 1.5
setGD()
AA.pl <- xyPlot(X, Y)
# label the outlier
addAnnotation(X[1L], Y[1L], "Outlier", current=AA.pl)
# For more details of addAnnotation see
vignette(topic="GraphAdditions", package="smwrGraphs")
demo(topic="TopAxisExample", package="smwrGraphs")

## End(Not run)

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