Learn R Programming

ggtern (version 1.0.6.1)

ternary_transformations: Ternary Transformations

Description

Functions relating to the transformation from the ternary coordinate systems, to the cartesian coordinate system.

Usage

transform_tern_to_cart(T, L, R, data = data.frame(T = T, L = L, R = R), ...,
  Tlim = c(0, 1), Llim = c(0, 1), Rlim = c(0, 1), scale = TRUE)

trytransform(data, coord)

Arguments

T
the concentrations of the Top species on the ternary diagram
L
the concentrations of the Left species on the ternary diagram
R
the concentrations of the Right species on the ternary diagram
data
object of type data.frame containing columns T, L and R. If not specified (Default), it will be produced from the T, L and R parameters for use in the function.
...
not used
Tlim
the limits of the top axis
Llim
the limits of the left axis
Rlim
the limits of the right axis
scale
logical indicating whether the concentrations should be scaled to sum to unity.
coord
the coordinates
data
the dataset

Value

  • transform_tern_to_cart returns a data.frame object with columns x and y representing the transformed coordinates, and, number of rows equal to that of the data argument. In other words, a '1 to 1' transformation from the ternary to the cartesian space.

    trytransform returns a data.frame object regardless of the success of the function operation.

Transform Ternary Coordinates to Cartesian Coordinates

transform_tern_to_cart(...) is a function that takes input numeric vectors for the T, L and R species, or, alternatively, a data.frame with columns T, L and R (Mandatory Column Names), and, transforms the data from the ternary space, to the cartesian space where x and y are in the range [0,1] and [0,$sin(\pi/3)$] respectively. The limits for T, L and R MAY NOT NECESSARILY be in the range [0,1], however, this is the default range.

Since the constituents of each ternary points must sum to 1.0, the user has the option to scale the data so that this is satisfied. Negative values may be of interest when trying to determine the coordinates of a point 'outside' of the ternary plot surface, however, they must still sum to unity.

Custom Limits can be applied for T, L and R species (by the parameters Tlim, Llim and Rlim, respectively), however, if they are non-standard (ie [0,1]), then checks are made so that non-sensical results are not implied and, an error will be thrown if such non-sensical results exist, IE, All points MUST sum to unity given that the axis extremes should meet at the vertices of the plot area.

By the above statement, the following constraints must hold TRUE:

  1. max(Tlim)+min(Llim) + min(Rlim) = 1AND
min(Tlim) + max(Llim) + min(Rlim) = 1 AND min(Tlim) + min(Llim) + max(Rlim) = 1

Attempt Transformation from Ternary to Cartesian Coordinates

trytransform is an internal function which attempts to make ternary transformation. If fails, the original data is returned.