Create or add to a Trilinear Plot
triplot.RdCreate (or add to) a trilinear plot of 3 proportions that sum to 1.
Arguments
- x
Vector or matrix of up to 3 columns.
- y
Vector (if
xis a vector).- z
Vector (if
xis 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
pointsortext.
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
Greg Snow 538280@gmail.com
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))