TernaryPointValues {Ternary} | R Documentation |
Intended to facilitate coloured contour plots with ColourTernary()
,
TernaryPointValue()
evaluates a function at points on a triangular grid;
TernaryDensity()
calculates the density of points in each grid cell.
TernaryPointValues( Func, resolution = 48L, direction = getOption("ternDirection", 1L), ... ) TernaryDensity( coordinates, resolution = 48L, direction = getOption("ternDirection", 1L) )
Func |
Function taking vectors of coordinates |
resolution |
The number of triangles whose base should lie on the longest axis of the triangle. Higher numbers will result in smaller subdivisions and smoother colour gradients, but at a computational cost. |
direction |
(optional) Integer specifying the direction that the current ternary plot should point: 1, up; 2, right; 3, down; 4, left. |
... |
Additional parameters to |
coordinates |
A list, matrix, data.frame or vector in which each element (or row) specifies the three coordinates of a point in ternary space. |
TernaryPointValues()
returns a matrix whose rows correspond to:
x, y: co-ordinates of the centres of smaller triangles
z: The value of Func(a, b, c)
, where a
, b
and c
are the
ternary coordinates of x
and y
.
down: 0
if the triangle concerned points upwards (or right),
1
otherwise
Martin R. Smith (martin.smith@durham.ac.uk)
Other contour plotting functions:
ColourTernary()
,
TernaryContour()
,
TernaryDensityContour()
TernaryPointValues(function (a, b, c) a * b * c, resolution = 2) TernaryPlot(grid.lines = 4) cols <- TernaryPointValues(rgb, resolution = 4) text(as.numeric(cols["x", ]), as.numeric(cols["y", ]), labels = ifelse(cols["down", ] == "1", "v", "^"), col = cols["z", ]) TernaryPlot(axis.labels = seq(0, 10, by = 1)) nPoints <- 4000L coordinates <- cbind(abs(rnorm(nPoints, 2, 3)), abs(rnorm(nPoints, 1, 1.5)), abs(rnorm(nPoints, 1, 0.5))) density <- TernaryDensity(coordinates, resolution = 10L) ColourTernary(density) TernaryPoints(coordinates, col = "red", pch = ".")