Learn R Programming

broman (version 0.84)

tritext: Plot text within a Holmans triangle

Description

Plot text within a Holmans triangle (an equilateral triangle used to depict trinomial distributions).

Usage

tritext(x, labels, ...)

Value

Text is plotted at the (x,y) coordinates of the points.

Arguments

x

A matrix with three rows, each column being a trinomial distribution.

labels

A vector of character strings, with length equal to the number of columns of x.

...

Passed to graphics::text().

Details

Plot of an equilateral triangle, in order to depict trinomial distributions. A trinomial distribution (that is, a trio of non-negative numbers that add to 1) is equated to a point in the triangle through the distances to the three sides. This makes use of the fact that for any point in an equilateral triangle, the sum of the distances to the three sides is constant. First use triplot() to first plot the equilateral triangle.

See Also

triplot(), trilines(), triarrow(), tripoints()

Examples

Run this code
triplot()
x <- cbind(c(0.25, 0.5, 0.25), c(1/3, 1/3, 1/3))
tripoints(x, lwd=2, pch=21, bg="lightblue")
xp <- x + c(0.02, 0, -0.02)
tritext(xp, c("(1/4,1/2,1/4)", "(1/3,1/3,1/3)"), adj=c(0, 0.5))

Run the code above in your browser using DataLab