Plotting · compositions
Ternary Plots: Plotting Three-Component Compositions
A ternary plot displays mixtures of three components on a single flat diagram. Each point is a composition (a, b, c) with a + b + c = 1, and the diagram is an equilateral triangle whose corners stand for the pure components. Soil texture, alloys, solvent mixtures and three-party vote shares are typical uses. Drawing one needs no special plotting type: it is a coordinate conversion followed by an ordinary scatter plot. This page gives the formula, a worked example and the details of gridlines and reading. It is one of the plotting techniques under Data and files.
Why three fractions fit in two dimensions
Three numbers that add to one have only two degrees of freedom. Once a and b are known, c = 1 − a − b follows. The set of all such triples, with each part at least zero, is a triangle in three-dimensional space with corners at (1, 0, 0), (0, 1, 0) and (0, 0, 1). The ternary plot is that triangle viewed face-on, a picture of a two-dimensional simplex.
The conversion formula
Place the corner for component A at (0, 0), the corner for B at (1, 0), and the corner for C at (½, √3/2), so the three corners form an equilateral triangle of side 1. A composition lands at the weighted average of the corners:
x = b + c/2 y = c × √3/2
Component a does not appear because its corner sits at the origin. Check the corners: for (1, 0, 0) the formula gives (0, 0); for (0, 1, 0) it gives (1, 0); for (0, 0, 1) it gives (½, 0.866). Each corner lands where it should.
A worked point: take (a, b, c) = (0.2, 0.3, 0.5). Then x = 0.3 + 0.25 = 0.55 and y = 0.5 × 0.8660 = 0.4330. The point lies above the middle of the triangle, closer to the C corner than to the other two because c is the largest fraction. The equal mixture (⅓, ⅓, ⅓) gives x = ⅓ + ⅙ = 0.5 and y = 0.2887, the centroid.
import numpy as np
def ternary_xy(a, b, c):
a, b, c = map(np.asarray, (a, b, c))
s = a + b + c
a, b, c = a / s, b / s, c / s # normalize
return b + c / 2, c * np.sqrt(3) / 2
x, y = ternary_xy([20], [30], [50])
print(x, y) # 0.55 0.4330...
Normalizing the input
Real data rarely sum to exactly one. Percentages sum to 100, and measured fractions are off by rounding, so divide each triple by its own sum before converting, as the snippet does. If the sums differ from 1 by more than a rounding amount, such as 0.95 or 1.08, something else is wrong: a missing fourth component or a unit mismatch. Report such rows instead of silently rescaling them. Rows with a negative component or a zero total cannot be plotted.
Gridlines and reading
Lines of constant a run parallel to the side opposite the A corner, and the same for b and c. Drawing gridlines at every tenth gives a reading grid. To read a point, follow the line of constant a to the scale on one side, the line of constant b to the next, and the line of constant c to the third; the three readings should add to one. Label each axis along the side where its values increase and use tick marks angled in the direction of the gridlines. Without that convention, readers frequently misjudge which scale applies.
Cautions
Ternary plots compress information: components near zero crowd against an edge, and small differences are hard to see. When one component is always small, a plot of the other two ratios or a log-ratio transform separates the points better. Compositions are also not independent, so ordinary averages and distances on the raw fractions can mislead; a statistician working with compositional data will usually transform first.
For other ways to display multi-part data, see data visualization, and to prepare the converted coordinates for a graphing package, see graphing results in SigmaPlot.