triplot: Create or add to a Trilinear Plot

triplotR Documentation

Create or add to a Trilinear Plot

Description

Create (or add to) a trilinear plot of 3 proportions that sum to 1.

Usage

triplot(x, y = NULL, z = NULL, labels = dimnames(x)[[2]],
  txt = dimnames(x)[[1]], legend = NULL, legend.split = NULL,
  inner = TRUE, inner.col = c("lightblue", "pink"), inner.lty = c(2, 3),
  add = FALSE, main = "", ...)

Arguments

x

Vector or matrix of up to 3 columns.

y

Vector (if x is a vector).

z

Vector (if x is a vector).

labels

Labels for the 3 components (printed at corners).

txt

Vector of text strings to be plotted instead of points.

legend

Labels for the data points

legend.split

What proportion of the labels will go on the left.

inner

Logical, should the inner reference lines be plotted.

inner.col

Colors for the 2 inner triangles.

inner.lty

Line types for the 2 inner triangles.

add

Add points to existing plot (TRUE), or create a new plot (FALSE).

main

Main title for the plot.

...

Additional arguments passed on to points or text.

Details

Trilinear plots are useful for visualizing membership in 3 groups by plotting sets of 3 proportions that sum to 1 within each set.

The data can be passed to the function as a matrix with either 2 or 3 columns, or as seperate vectors to x, y, and optionaly z. If 2 columns are passed in, then they must be between 0 and 1 and the 3rd column will be created by subtracting both from 1. If 3 columns of data are given to the function then each will be divided by the sum of the 3 columns (they don't need to sum to 1 before being passed in).

Value

An invisible matrix with 2 columns and the same number of rows as x corresponding to the points plotted (after transforming to 2 dimensions).

The return matrix can be passed to identify for labeling of individual points.

Using type='n' and add=FALSE will return the transformed points without doing any plotting.

Author(s)

Greg Snow 538280@gmail.com

References

Allen, Terry. Using and Interpreting the Trilinear Plot. Chance. 15 (Summer 2002).

See Also

triangle.plot in package ade4, ternaryplot in package vcd, tri in package cwhtool, soil.texture and triax.plot in package plotrix.

Examples

triplot(USArrests[c(1,4,2)])
tmp <- triplot(USArrests[c(1,4,2)],txt=NULL)
if(interactive()){ identify(tmp, lab=rownames(USArrests) ) }

tmp <- rbind( HairEyeColor[,,'Male'], HairEyeColor[,,'Female'])
tmp[,3] <- tmp[,3] + tmp[,4]
tmp <- tmp[,1:3]
triplot(tmp, legend=rep(c('Male','Femal'),each=4),
 col=rep(c('black','brown','red','yellow'),2))

TeachingDemos documentation built on May 29, 2024, 5:59 a.m.