ColourTernary | R Documentation |
Colour a ternary plot according to the output of a function
ColourTernary(
values,
spectrum = hcl.colors(256L, palette = "viridis", alpha = 0.6),
resolution = sqrt(ncol(values)),
direction = getOption("ternDirection", 1L),
legend,
...
)
ColorTernary(
values,
spectrum = hcl.colors(256L, palette = "viridis", alpha = 0.6),
resolution = sqrt(ncol(values)),
direction = getOption("ternDirection", 1L),
legend,
...
)
values |
Numeric matrix, possibly created using
|
spectrum |
Vector of colours to use as a spectrum, or |
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. |
legend |
Character vector specifying annotations for colour scale.
If not provided, no colour legend is displayed.
Specify |
... |
Further arguments to
|
Martin R. Smith (martin.smith@durham.ac.uk)
Fine control over continuous legends:
PlotTools::SpectrumLegend()
Other contour plotting functions:
TernaryContour()
,
TernaryDensityContour()
,
TernaryPointValues()
Other functions for colouring and shading:
TernaryTiles()
TernaryPlot(alab = "a", blab = "b", clab = "c")
FunctionToContour <- function (a, b, c) {
a - c + (4 * a * b) + (27 * a * b * c)
}
values <- TernaryPointValues(FunctionToContour, resolution = 24L)
ColourTernary(
values,
x = "topleft",
bty = "n", # No box
legend = signif(seq(max(values), min(values), length.out = 4), 3)
)
TernaryContour(FunctionToContour, resolution = 36L)
TernaryPlot()
values <- TernaryPointValues(rgb, resolution = 20)
ColourTernary(values, spectrum = NULL)
# Create a helper function to place white centrally:
rgbWhite <- function (r, g, b) {
highest <- apply(rbind(r, g, b), 2L, max)
rgb(r/highest, g/highest, b/highest)
}
TernaryPlot()
values <- TernaryPointValues(rgbWhite, resolution = 20)
ColourTernary(values, spectrum = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.