Learn R Programming

heplots (version 1.0-8)

label.ellipse: 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
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, y
...
Other arguments passed to text, such as offset, srt, font, family, etc.

Value

  • None.

Details

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

See Also

text, par for other graphics parameters

Examples

Run this code
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)

Run the code above in your browser using DataLab