I hope that this package proves simple to use.

Install the package with:

install.packages('Ternary')

Or if you want the latest development version of the package:

if (!require('devtools')) install.packages('devtools')
install_github('ms609/Ternary')

Once the package is installed, load it into the current R session with

library('Ternary')

There are two stages to creating a ternary plot: first, rendering the plot, styled as you like it and pointing in any of the four compass directions; secondly, adding data.

Create a blank plot

At its simplest, all you need to do is type

TernaryPlot()

The following charts show which corners are which, under different orientations:

par(mfrow=c(2, 2), mar=rep(0.5, 4))
for (dir in c('up', 'right', 'down', 'le')) {
  TernaryPlot(point=dir, atip='A', btip='B', ctip='C', alab='Aness', blab='Bness', clab='Cness')
  TernaryText(list(A=c(10, 01, 01), B=c(01, 10, 01), C=c(01, 01, 10)), col=cbPalette8[4], font=2)
}

Plot two stylised plots side by side, and plot data

par(mfrow=c(1, 2), mar=rep(0.3, 4))
TernaryPlot(alab="Redder \u2192", blab="\u2190 Greener", clab="Bluer \u2192",
            point='right', lab.cex=0.8, grid.minor.lines=0,
            grid.lty='solid', col=rgb(0.9, 0.9, 0.9), grid.col='white', 
            axis.col=rgb(0.6, 0.6, 0.6), ticks.col=rgb(0.6, 0.6, 0.6),
            padding=0.08)
data_points <- list(
  R = c(255, 0, 0), 
  O = c(240, 180, 52),
  Y = c(210, 222, 102),
  G = c(111, 222, 16),
  B = c(25, 160, 243),
  I = c(92, 12, 243),
  V = c(225, 24, 208)
)
AddToTernary(points, data_points, pch=21, cex=2.8, 
             bg=vapply(data_points, 
                       function (x) rgb(x[1], x[2], x[3], 128, maxColorValue=255),
                       character(1))
             )
AddToTernary(text, data_points, names(data_points), cex=0.8, font=2)
legend('bottomright', 
       legend=c('Red', 'Orange', 'Yellow', 'Green'),
       cex=0.8, bty='n', pch=21, pt.cex=1.8,
       pt.bg=c(rgb(255,   0,   0, 128, NULL, 255), 
               rgb(240, 180,  52, 128, NULL, 255),
               rgb(210, 222, 102, 128, NULL, 255),
               rgb(111, 222,  16, 128, NULL, 255)),
       )

###
# Next plot:
###
TernaryPlot('Steam', 'Ice', 'Water', 
            grid.lines=5, grid.lty='dotted',
            grid.minor.lines=1, grid.minor.lty='dotted',
            point='West')
HorizontalGrid()
middle_triangle <- matrix(c(
  30, 40, 30,
  30, 30, 40,
  55, 20, 25
), ncol=3, byrow=TRUE)
TernaryPolygon(middle_triangle, col='#aaddfa', border='grey')
TernaryLines(list(c(0, 100, 0), middle_triangle[1, ]), col='grey')
TernaryLines(list(c(0, 0, 100), middle_triangle[2, ]), col='grey')
TernaryLines(list(c(100, 0, 0), middle_triangle[3, ]), col='grey')
TernaryArrows(c(20, 20, 60), c(30, 30, 40), length=0.2, col='darkblue')

It is also possible to use cartesian coordinates to plot onto the graph.

By default, the plotting area is a 1x1 square.

TernaryPlot(point='right')
cat("X range in this orientation:", TernaryXRange())
## X range in this orientation: -0.0669873 0.9330127
cat("Y range in this orientation:", TernaryYRange())
## Y range in this orientation: -0.5 0.5
arrows(x0=0.5, y0=0.4, x1=sqrt(3)/2, y1=0.4, length=0.1, col=cbPalette8[2])
text(x=mean(c(0.5, sqrt(3)/2)), y=0.4, "Increasing X", pos=3, col=cbPalette8[2])
text(x=0.5, y=0, "(0.5, 0)", col=cbPalette8[3])
text(x=0.8, y=-0.5, "(0.8, -0.5)", col=cbPalette8[3])

Contours

A plot can be coloured and contoured according to the output of a mathematical expression:

par(mar=rep(0.2, 4))
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)
TernaryContour(FunctionToContour, resolution=36L)