Skip to main content
5 of 15
deleted 134 characters in body
Antoni Parellada
  • 26.9k
  • 18
  • 122
  • 230

Two-variable ternary diagrams in scatter plot matrix of R compositions package

In the documentation for the R compositions package, and in reference to ternary diagrams, it is stated that:

However the ternary diagram can only display compositions of three parts. In case of more parts a scatter plot matrix like matrix of ternary diagrams is displayed which selects two components against some sort of margin of the rest:

plot(acomp(sa.lognormals5))
plot(acomp(sa.lognormals5), margin = "rcomp")
plot(acomp(sa.lognormals5), margin = "Cu")

In here the author presents this (tantalizingly beautiful) plot:

enter image description here

... without the code!

So I've been trying to reproduce this matrix scatter plots, and understand them. For instance I am having trouble calling the multiple plots with the ellipses around points of the same variable. Here is my code and the output:

library(compositions)
data(SimulatedAmounts)
colors = c(rgb(red=0, green=0, blue=.9, alpha=0.7),
           rgb(red=0, green=.9, blue=0, alpha=0.7),
           rgb(red=0.9, green=0, blue=0, alpha=0.7))
tt = acomp(sa.groups5)
plot(tt, col = rgb(0,0,0,0), bg = colors, pch = 21, cex = .9)
ellipses(mean(tt), var(tt), r = 2)

enter image description here

yielding only one lasso (or three lines) per ternary diagram.


In Analyzing Compositional Data with R By K. Gerald van den Boogaart, Raimon Tolosana-Delgado the following plot can be found with a telling caption:

enter image description here

in which the radius of the lines contain 95% of the probability assuming a normal model for the composition and a known variance.

The code of this latter plot likely includes the lines:

r = sqrt(qchisq(p = .095, df = 2))
mm = mean(tt)
vr = var(tt)
ellipses(mean = mm, var = vr, r = r)

and there is a clarifying comment as to the meaning of $*$:

margin = "acomp" (or nothing, the default) computes the third part as the geometric of all components except those two from row and colum (symbolized with "*").


The remaining question is:

What are the color-coded (black, red and green) lines on the (first) plot? And, if at all possible (I understand this second part is code-specific), how can they be generated?

Antoni Parellada
  • 26.9k
  • 18
  • 122
  • 230