label.ellipse {heplots}R Documentation

Draw a Label on an Ellipse-like Object

Description

Draws a label on an ellipse (or similar closed ploygon object) allowing a label.pos argument to specify the position of the label as center, bottom, left, top, or right relative to the object.

Usage

label.ellipse(ellipse, label, col = "black", label.pos = NULL, 
      xpd = TRUE, tweak = 0.5 * c(strwidth("M"), strheight("M")), ...)

Arguments

ellipse

A two-column matrix, or an object that can be coerced to one.

label

Label text, a character string, or expression (or coercible to such a type).

col

Label color

label.pos

Label position, an integer (in 0:4) or character string (in c("center", "bottom", "left", "top", "right")). Values of 1, 2, 3 and 4, respectively indicate positions below, to the left of, above and to the right of the max/min coordinates of the ellipse; the value 0 specifies the centroid of the ellipse object. The default, label.pos=NULL uses the correlation of the ellipse to determine "top" (r>=0) or "bottom" (r<0).

xpd

logical. Whether to allow the label to go beyond the plot area.

tweak

A two element vector specifying minor adjustments applied to the x or y coordinate of the label, depending on label.pos. The defaults are one-half the width and height of an uppercase "M" on the current graphics device.

Alternatively, you can set tweak=c(0,0) and use offset to achieve more general adjustments.

...

Other arguments passed to text, such as offset, srt, font, family, etc.

Details

Like text, this function simply adds to an existing base graphics plot.

Value

None.

Author(s)

Michael Friendly

See Also

text, par for other graphics parameters

Examples

op <- par(mfrow=c(1,2))
plot(c(-2,2), c(-3,3), type="n", xlab="x", ylab="y")
E <- ellipse(c(0,0), matrix(c(1,2,2,5), 2, 2), 1, add=TRUE)

label.ellipse(E, "default", col="red", cex=2)
label.ellipse(E, "center", label.pos=0)
label.ellipse(E, "bottom", label.pos=1)
label.ellipse(E, "top", label.pos=3)
label.ellipse(E, "left", label.pos=2)
label.ellipse(E, "right", label.pos=4)

plot(c(-2,2), c(-3,3), type="n", xlab="x", ylab="y")
E <- ellipse(c(0,0), matrix(c(1,-2,-2,5), 2, 2), 1, add=TRUE)

label.ellipse(E, "default", col="red", cex=2)
label.ellipse(E, "center", label.pos="center")
label.ellipse(E, "bottom", label.pos=1, cex=1.5)
label.ellipse(E, "top", label.pos=3, cex=1.5)
label.ellipse(E, "left", label.pos=2, cex=1.5)
label.ellipse(E, "right", label.pos=4, cex=1.5)
par(op)


[Package heplots version 1.0-15 Index]