Skip to main content

Ternary Plot

What is a ternary plot?​

A ternary plot (also called a ternary diagram, ternary graph or triangle plot) shows mixtures of three parts that add up to a constant, usually 100%. Each corner of an equilateral triangle stands for 100% of one part, and each point's position shows its share of all three at once.

A ternary plot of 40 soil samples on the USDA soil texture triangle: clay rises to the top corner, sand to the bottom-left and silt to the bottom-right, with the 12 soil texture classes shaded and labelled, and the samples clustered in sandy loam, silt loam and the clay classes

A ternary plot of 40 soil samples from three imaginary fields, on the USDA soil texture triangle (sample data). Try the interactive version.

Key takeaways
  • A ternary plot shows three proportions that add up to 100% as one point in a triangle.
  • Each corner is 100% of one component; the side opposite it is 0%.
  • To read a value, follow the gridline parallel to the side opposite that component's corner to its scale. The three readings must add up to 100%.
  • Classic uses: soil texture, rock classification, and phase diagrams in chemistry and metallurgy.
  • Only use one when the parts really add up to a fixed whole, and show which way each scale runs.

How to read a ternary plot​

How to read point P on a ternary plot with sand at the bottom-left corner, silt at the bottom-right and clay at the top: a horizontal line from P to the left side reads 30% clay, a line parallel to the left side up to the right side reads 20% silt, and a line parallel to the right side down to the base reads 50% sand, which add up to 100

  1. Find the three corners. Each is labelled with one component and stands for 100% of it. In the diagram, the top is 100% clay, the bottom-left 100% sand and the bottom-right 100% silt.
  2. Find each component's zero. A component is 0% along the whole side opposite its corner. Clay is 0% along the base, so the closer a point is to the base, the less clay it has.
  3. Use that component's gridlines. Its gridlines all run parallel to its zero side. Clay's gridlines are horizontal, because clay's zero side is the base.
  4. Follow the gridline from the point to the scale. Each side carries the scale for one component. Point P sits on the 30% clay line, the 20% silt line and the 50% sand line.
  5. Check the total. 30 + 20 + 50 = 100. If your three readings don't add up to 100, you have read at least one of them along the wrong set of lines.

Which gridlines belong to which scale?​

Three sets of gridlines cross at every point, and each side has numbers on it, so it is easy to follow a line to the wrong side. Two checks help:

  • Look at the tick marks. On a well-drawn ternary plot, each tick sticks out of the triangle at the same angle as the gridline it belongs to. Follow the tick inwards and you are on the right line.
  • Look at the direction of the numbers. Each scale reaches 100 at its own corner. If the numbers increase towards the wrong corner, you are reading the wrong scale.

Some diagrams number the scales running clockwise round the triangle and some anticlockwise, so the same point can look different on two diagrams. Check the corners and the tick direction every time; don't assume.

A worked example: naming soil textures​

Soil scientists sort soil into 12 texture classes by how much sand, silt and clay it contains, as shares of its mineral particles: sand is 0.05 to 2 mm across, silt 0.002 to 0.05 mm, and clay smaller than 0.002 mm. The soil texture triangle of the US Department of Agriculture (USDA) draws those classes as regions on a ternary plot, which is what the chart at the top of this page shows.

SampleSandSiltClayWhere it fallsTexture class
A65%25%10%Low on the triangle, towards the sand cornerSandy loam
B20%55%25%Towards the silt corner, just below the 27% clay lineSilt loam
C30%28%42%Above the 40% clay line, near the middleClay

To place sample B, start on the horizontal 25% clay line. Move along it until you reach the 55% silt line, which runs parallel to the left side. Check: that point also sits on the 20% sand line. It lies in the silt loam region.

Three things the triangle shows that a table doesn't:

  • The classes aren't equal in size. Anything from 40% to 100% clay with little sand or silt is "clay", while near the sand corner a few percent more silt or clay moves a sample from sand to loamy sand to sandy loam.
  • Groups of samples stand out. On the chart at the top, the samples form three clusters, one for each field, without any colour coding.
  • The spread within a group is visible. The hill slope samples spread across five classes (clay, clay loam, silty clay, loam and silt loam), so one class for the whole field would hide real variation.

How to describe a ternary plot​

Use this template when you report a ternary plot:

[Number] of the [samples] contain [range of component 1] and [range of component 2], which places them in [region or class]. The other [number] fall in [other region], because they have more [component].

Worked example: "Eleven of the 14 valley floor samples contain 57% to 76% silt and 8% to 23% clay, which places them in the silt loam class. The other three fall in silty clay loam, because they have more than 27% clay."

How does a ternary plot work?​

A ternary plot uses barycentric coordinates: a point's distance from each side of the triangle is set by its share of the component at the opposite corner. Two steps turn three values into a position you can draw:

  1. Scale the values to a fixed total. Divide each of the three values by their sum. A mixture of 6 g, 3 g and 1 g becomes 60%, 30% and 10%. This is why a ternary plot shows proportions, not amounts.
  2. Convert to x and y. For a triangle with sides of length 1, the bottom-left corner at (0, 0), the bottom-right corner at (1, 0) and the top at (0.5, 0.866):
    • x = right-hand component + ½ × top component
    • y = top component × √3 ⁄ 2 (about 0.866)

The left-hand component doesn't appear in the formula: once the other two are known, it is whatever is left. Reading values back works the other way round: top = y ÷ 0.866, right = x − top ÷ 2, and left = 1 − top − right. The interactive example on this page runs this conversion every time you move the mouse.

The same chart has other names in other fields: a Gibbs triangle in thermodynamics, a de Finetti diagram in population genetics, where the corners are the three genotypes AA, Aa and aa, and a simplex plot in statistics and game theory.

Where ternary plots are used​

  • Soil science: the soil texture triangle names a soil from its sand, silt and clay content, as in the example above.
  • Geology and petrology: sandstones are classified by their quartz, feldspar and rock fragment content, and ultramafic igneous rocks by their olivine, orthopyroxene and clinopyroxene content.
  • Chemistry and chemical engineering: a ternary phase diagram shows which phases form when three substances are mixed at a fixed temperature and pressure, such as when one liquid dissolves in a mix of two others. Process engineers use them to design extraction and separation steps.
  • Metallurgy and materials science: alloys of three metals, such as the tin, silver and copper of lead-free solders, are mapped on ternary phase diagrams. Polymer blends, and membranes made from a polymer, a solvent and a non-solvent, are designed the same way.
  • Shares of a whole: any three shares that add up to 100%, such as a three-way election, how a team splits its time between three kinds of work, or the mix of three energy sources in a country's power supply.

When to use a ternary plot​

Use a ternary plot when each item is a mixture of exactly three parts that add up to a fixed whole, and you want to compare many items, see clusters or place them in named regions.

ChartBest for
Ternary plotMany mixtures of three parts at once, with clusters, trends and classification regions
Bar chart (100% stacked)A few items, or more than three parts, where exact shares matter more than patterns
Pie chart or donut chartA single mixture, split into a few parts
Scatter plotTwo variables that don't have to add up to anything, or two of the three parts when the third doesn't matter

Common ternary plot mistakes​

  • Values that don't add up. Plotting raw values that sum to 97 or 104 puts points in the wrong place. Rescale every point so its three values add up to exactly 100%, and say that you did.
  • Unlabelled direction. Without angled tick marks, arrows or corner labels, readers can't tell which way each scale runs. Label every corner and every side.
  • Hiding the dropped parts. If a fourth component was removed before plotting (water, organic matter, other minerals), say so: the plotted shares are of the three parts, not of the whole sample.
  • Too few points to need a triangle. For two or three mixtures, a 100% stacked bar chart or a table is clearer.
  • Overplotting. Thousands of points pile up in one area. Use smaller, partly transparent markers, or shade the triangle by how many points fall in each area.
  • Stretched triangles. If the chart stretches the triangle to fit its box, the gridlines still work but the shape no longer matches the diagram readers know. Keep it equilateral.

How to create a ternary plot in JavaScript, React or Angular​

SciChart.js has no separate ternary series, but a short helper converts each mixture to x and y, and SciChart's line segment, scatter and triangle series draw the rest. Because SciChart.js draws with WebGL and WebGPU, the chart stays smooth to zoom and pan with many points. Try the chart below: hover anywhere in the triangle to read all three values and see the three gridlines you are reading along, or hover over a sample to read its values. Scroll to zoom, drag to pan and double-click to reset.

Here is the code for this chart. The data is plain JSON: one object per point, with a value for each component:

[
{ "name": "Sample 1", "sand": 65, "silt": 25, "clay": 10 },
{ "name": "Sample 2", "sand": 20, "silt": 55, "clay": 25 }
]
// Create a JavaScript ternary plot with SciChart.js: a triangular grid, shaded regions and scatter points
const {
SciChartSurface,
NumericAxis,
NumberRange,
EAutoRange,
XyDataSeries,
FastLineSegmentRenderableSeries,
FastTriangleRenderableSeries,
ETriangleSeriesDrawMode,
XyScatterRenderableSeries,
EllipsePointMarker,
NativeTextAnnotation,
LineAnnotation,
EHorizontalAnchorPoint,
EVerticalAnchorPoint,
EMultiLineAlignment,
Thickness,
CustomChartModifier2D,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier,
translateFromCanvasToSeriesViewRect,
SciChartJsNavyTheme
} = SciChart;
// or, for npm, import { SciChartSurface, ... } from "scichart"

// 1. TERNARY HELPER (plain JavaScript, no SciChart code)
// The triangle has sides of 100 units. `left` is the bottom-left corner, `right` the bottom-right corner and
// `top` the apex. Each component's scale runs from 0 on the opposite side to 100 at its own corner.
const HEIGHT = Math.sqrt(3) / 2;

function createTernary(components) {
const { left, right, top } = components;
return {
components,
// (a, b, c) to (x, y): any three values that add up to a constant
toXY(values) {
const total = values[left.key] + values[right.key] + values[top.key];
const r = (100 * values[right.key]) / total;
const t = (100 * values[top.key]) / total;
return { x: r + t / 2, y: t * HEIGHT };
},
// (x, y) back to percentages of each component
fromXY(x, y) {
const t = y / HEIGHT;
const r = x - t / 2;
return { [left.key]: 100 - r - t, [right.key]: r, [top.key]: t };
},
isInside(x, y) {
const t = y / HEIGHT;
const r = x - t / 2;
return t >= 0 && r >= 0 && r + t <= 100;
},
// [a, b, c] given in the order left, right, top
cornerToXY([a, b, c]) {
return this.toXY({ [left.key]: a, [right.key]: b, [top.key]: c });
}
};
}

// Rounds percentages to whole numbers that still add up to 100 (largest remainder)
function roundTo100(values, keys) {
const floors = keys.map((key) => Math.floor(values[key]));
let missing = 100 - floors.reduce((sum, v) => sum + v, 0);
const order = keys.map((key, i) => i).sort((i, j) => (values[keys[j]] % 1) - (values[keys[i]] % 1));
for (const i of order) if (missing-- > 0) floors[i]++;
return Object.fromEntries(keys.map((key, i) => [key, floors[i]]));
}

// Ear clipping: splits any simple polygon (convex or not) into triangles, returned as a flat list of corners
function triangulate(points) {
const cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
const pts = points.slice();
const area = pts.reduce((sum, p, i) => sum + cross({ x: 0, y: 0 }, p, pts[(i + 1) % pts.length]), 0);
if (area < 0) pts.reverse(); // make it anticlockwise
const triangles = [];
while (pts.length > 3) {
let earIndex = -1;
for (let i = 0; i < pts.length && earIndex < 0; i++) {
const a = pts[(i + pts.length - 1) % pts.length];
const b = pts[i];
const c = pts[(i + 1) % pts.length];
if (cross(a, b, c) <= 1e-9) continue; // not convex here
const blocked = pts.some(
(p) => p !== a && p !== b && p !== c && cross(a, b, p) >= 0 && cross(b, c, p) >= 0 && cross(c, a, p) >= 0
);
if (!blocked) earIndex = i;
}
if (earIndex < 0) break;
const n = pts.length;
triangles.push(pts[(earIndex + n - 1) % n], pts[earIndex], pts[(earIndex + 1) % n]);
pts.splice(earIndex, 1);
}
if (pts.length === 3) triangles.push(...pts);
return triangles;
}

function pointInPolygon(x, y, points) {
let inside = false;
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
const a = points[i];
const b = points[j];
if (a.y > y !== b.y > y && x < ((b.x - a.x) * (y - a.y)) / (b.y - a.y) + a.x) inside = !inside;
}
return inside;
}

// 2. DRAWING HELPERS (SciChart)
function addText(sciChartSurface, x, y, text, options) {
sciChartSurface.annotations.add(
new NativeTextAnnotation({
x1: x,
y1: y,
text,
fontSize: 13,
horizontalAnchorPoint: EHorizontalAnchorPoint.Center,
verticalAnchorPoint: EVerticalAnchorPoint.Center,
multiLineAlignment: EMultiLineAlignment.Center,
...options
})
);
}

// Frame, gridlines every `step` percent, ticks, tick labels and a title for each side
function addTernaryGrid(sciChartSurface, wasmContext, ternary, step = 10) {
const { left, right, top } = ternary.components;
const gridX = [];
const gridY = [];
const tickX = [];
const tickY = [];
const tickLength = 2.5;
// Each component's ticks continue its own gridlines out of the triangle, so they show which way to read
const sides = [
{ component: top, dir: { x: -1, y: 0 }, anchorH: EHorizontalAnchorPoint.Right, anchorV: EVerticalAnchorPoint.Center },
{ component: right, dir: { x: 0.5, y: HEIGHT }, anchorH: EHorizontalAnchorPoint.Left, anchorV: EVerticalAnchorPoint.Center },
{ component: left, dir: { x: 0.5, y: -HEIGHT }, anchorH: EHorizontalAnchorPoint.Left, anchorV: EVerticalAnchorPoint.Top }
];
// Where the gridline for `value` of each component starts (on its labelled side) and ends
const ends = {
[top.key]: (v) => [ternary.cornerToXY([100 - v, 0, v]), ternary.cornerToXY([0, 100 - v, v])],
[right.key]: (v) => [ternary.cornerToXY([0, v, 100 - v]), ternary.cornerToXY([100 - v, v, 0])],
[left.key]: (v) => [ternary.cornerToXY([v, 100 - v, 0]), ternary.cornerToXY([v, 0, 100 - v])]
};
for (const side of sides) {
for (let v = 0; v <= 100; v += step) {
const [start, end] = ends[side.component.key](v);
if (v > 0 && v < 100) {
gridX.push(start.x, end.x);
gridY.push(start.y, end.y);
}
tickX.push(start.x, start.x + side.dir.x * tickLength);
tickY.push(start.y, start.y + side.dir.y * tickLength);
addText(sciChartSurface, start.x + side.dir.x * 3.5, start.y + side.dir.y * 3.5, `${v}`, {
textColor: side.component.color,
horizontalAnchorPoint: side.anchorH,
verticalAnchorPoint: side.anchorV
});
}
}
const corners = [ternary.cornerToXY([100, 0, 0]), ternary.cornerToXY([0, 100, 0]), ternary.cornerToXY([0, 0, 100])];
const frameX = [];
const frameY = [];
corners.forEach((corner, i) => {
const next = corners[(i + 1) % 3];
frameX.push(corner.x, next.x);
frameY.push(corner.y, next.y);
});
const segments = (xValues, yValues, stroke, strokeThickness) =>
new FastLineSegmentRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, { xValues, yValues }),
stroke,
strokeThickness
});
sciChartSurface.renderableSeries.add(
segments(gridX, gridY, "#FFFFFF22", 1),
segments(tickX, tickY, "#C8D3E6", 1.5),
segments(frameX, frameY, "#C8D3E6", 2)
);
// Side titles, rotated to run along each side, with an arrow pointing the way the values increase
addText(sciChartSurface, 25 - 13 * HEIGHT, 43.3 + 13 * 0.5, `${top.name} (%) →`, { textColor: top.color, fontSize: 16, rotation: -60 });
addText(sciChartSurface, 75 + 13 * HEIGHT, 43.3 + 13 * 0.5, `${right.name} (%) →`, { textColor: right.color, fontSize: 16, rotation: 60 });
addText(sciChartSurface, 50, -11, `← ${left.name} (%)`, { textColor: left.color, fontSize: 16 });
}

// Shaded regions (for example soil texture classes), each a polygon of [left, right, top] corners
function addTernaryRegions(sciChartSurface, wasmContext, ternary, regions) {
const palette = ["#6C8EF5", "#30BC9A", "#9B7BD4", "#E8336D", "#50C7E0"];
const borderX = [];
const borderY = [];
const shapes = regions.map((region, index) => {
const points = region.corners.map((corner) => ternary.cornerToXY(corner));
const triangles = triangulate(points);
sciChartSurface.renderableSeries.add(
new FastTriangleRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, {
xValues: triangles.map((p) => p.x),
yValues: triangles.map((p) => p.y)
}),
drawMode: ETriangleSeriesDrawMode.List,
fill: region.color ?? palette[index % palette.length],
opacity: 0.16
})
);
points.forEach((p, i) => {
const next = points[(i + 1) % points.length];
borderX.push(p.x, next.x);
borderY.push(p.y, next.y);
});
// Label at the region's centre, unless a position is given
const label = region.labelAt
? ternary.cornerToXY(region.labelAt)
: { x: points.reduce((s, p) => s + p.x, 0) / points.length, y: points.reduce((s, p) => s + p.y, 0) / points.length };
addText(sciChartSurface, label.x, label.y, region.name, { textColor: "#E6ECF5", fontSize: region.fontSize ?? 13, opacity: 0.85 });
return { name: region.name.replace(/\n/g, " "), points };
});
sciChartSurface.renderableSeries.add(
new FastLineSegmentRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, { xValues: borderX, yValues: borderY }),
stroke: "#FFFFFF66",
strokeThickness: 1.5
})
);
// Returns the name of the region that (x, y) falls in
return (x, y) => shapes.find((shape) => pointInPolygon(x, y, shape.points))?.name ?? "";
}

// Keeps the triangle equilateral: one data unit is the same number of pixels across and up
function fitTernaryView(sciChartSurface, area = { xMin: -18, xMax: 118, yMin: -18, yMax: 96 }) {
const rect = sciChartSurface.seriesViewRect;
if (!rect || rect.width <= 0 || rect.height <= 0) return;
const pixelsPerUnit = Math.min(rect.width / (area.xMax - area.xMin), rect.height / (area.yMax - area.yMin));
const halfWidth = rect.width / pixelsPerUnit / 2;
const halfHeight = rect.height / pixelsPerUnit / 2;
const xMid = (area.xMin + area.xMax) / 2;
const yMid = (area.yMin + area.yMax) / 2;
sciChartSurface.xAxes.get(0).visibleRange = new NumberRange(xMid - halfWidth, xMid + halfWidth);
sciChartSurface.yAxes.get(0).visibleRange = new NumberRange(yMid - halfHeight, yMid + halfHeight);
}

// Refits the view whenever the chart changes size (zooming and panning keep the shape on their own)
function keepTernaryEquilateral(sciChartSurface) {
let lastSize = "";
sciChartSurface.layoutMeasured.subscribe(() => {
const rect = sciChartSurface.seriesViewRect;
const size = `${Math.round(rect.width)}x${Math.round(rect.height)}`;
if (size !== lastSize) {
lastSize = size;
fitTernaryView(sciChartSurface);
}
});
}

// 3. TOOLTIP: reads all three components at the mouse, or of the nearest sample, and draws its three gridlines
class TernaryTooltipModifier extends CustomChartModifier2D {
ternary;
samples;
findRegion;
tooltip;
guides;

constructor(ternary, samples, findRegion) {
super();
this.ternary = ternary;
this.samples = samples;
this.findRegion = findRegion;
this.tooltip = new NativeTextAnnotation({
text: "",
isHidden: true,
textColor: "#FFFFFF",
fontSize: 14,
background: "#0F1A2BEE",
multiLineAlignment: EMultiLineAlignment.Left,
padding: new Thickness(6, 10, 6, 10),
lineSpacing: 4,
verticalAnchorPoint: EVerticalAnchorPoint.Bottom
});
const { left, right, top } = ternary.components;
this.guides = [top, right, left].map(
(component) =>
new LineAnnotation({ stroke: component.color, strokeThickness: 2, strokeDashArray: [4, 3], isHidden: true })
);
}

onAttach() {
super.onAttach();
this.parentSurface.annotations.add(...this.guides, this.tooltip);
}

onDetach() {
this.parentSurface?.annotations.remove(this.tooltip);
this.guides.forEach((guide) => this.parentSurface?.annotations.remove(guide));
super.onDetach();
}

hide() {
this.tooltip.isHidden = true;
this.guides.forEach((guide) => (guide.isHidden = true));
}

modifierMouseMove(args) {
super.modifierMouseMove(args);
const surface = this.parentSurface;
const point = translateFromCanvasToSeriesViewRect(args.mousePoint, surface.seriesViewRect);
if (!point) return this.hide();
const xCalc = surface.xAxes.get(0).getCurrentCoordinateCalculator();
const yCalc = surface.yAxes.get(0).getCurrentCoordinateCalculator();

// The nearest sample within 14 pixels, otherwise the composition under the mouse
let nearest = null;
let nearestDistance = 14;
for (const sample of this.samples) {
const p = this.ternary.toXY(sample);
const distance = Math.hypot(xCalc.getCoordinate(p.x) - point.x, yCalc.getCoordinate(p.y) - point.y);
if (distance < nearestDistance) {
nearest = sample;
nearestDistance = distance;
}
}
const mouseX = xCalc.getDataValue(point.x);
const mouseY = yCalc.getDataValue(point.y);
if (!nearest && !this.ternary.isInside(mouseX, mouseY)) return this.hide();

const { left, right, top } = this.ternary.components;
const keys = [left.key, right.key, top.key];
const exact = nearest ?? this.ternary.fromXY(mouseX, mouseY);
const values = nearest ? exact : roundTo100(exact, keys);
const at = this.ternary.toXY(exact);

// Each guide runs along that component's gridline, from the point to the side where its scale is
const ends = [
this.ternary.cornerToXY([100 - exact[top.key], 0, exact[top.key]]),
this.ternary.cornerToXY([0, exact[right.key], 100 - exact[right.key]]),
this.ternary.cornerToXY([exact[left.key], 100 - exact[left.key], 0])
];
this.guides.forEach((guide, i) => {
guide.x1 = at.x;
guide.y1 = at.y;
guide.x2 = ends[i].x;
guide.y2 = ends[i].y;
guide.isHidden = false;
});

const lines = [
nearest ? nearest.name : "Under the cursor",
`${top.name}: ${values[top.key]}%`,
`${right.name}: ${values[right.key]}%`,
`${left.name}: ${values[left.key]}%`,
`Class: ${this.findRegion(at.x, at.y)}`
];
const xRange = surface.xAxes.get(0).visibleRange;
const nearRightEdge = at.x > xRange.min + xRange.diff * 0.6;
this.tooltip.text = lines.join("\n");
this.tooltip.horizontalAnchorPoint = nearRightEdge ? EHorizontalAnchorPoint.Right : EHorizontalAnchorPoint.Left;
this.tooltip.x1 = at.x + xRange.diff * (nearRightEdge ? -0.015 : 0.015);
this.tooltip.y1 = at.y + surface.yAxes.get(0).visibleRange.diff * 0.02;
this.tooltip.isHidden = false;
}

modifierMouseLeave(args) {
super.modifierMouseLeave(args);
this.hide();
}
}

// 4. THE CHART
async function ternaryPlot(divElementId) {
const { wasmContext, sciChartSurface } = await SciChartSurface.create(divElementId, {
theme: new SciChartJsNavyTheme()
});

// Which component goes on which corner, in the USDA soil texture triangle's layout
const ternary = createTernary({
left: { key: "sand", name: "Sand", color: "#F2C14E" },
right: { key: "silt", name: "Silt", color: "#50C7E0" },
top: { key: "clay", name: "Clay", color: "#F48420" }
});

// The axes only set the drawing area. They're hidden: a ternary plot draws its own three scales.
const axisOptions = { isVisible: false, autoRange: EAutoRange.Never };
sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { ...axisOptions, visibleRange: new NumberRange(-18, 118) }));
sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { ...axisOptions, visibleRange: new NumberRange(-18, 96) }));

const findRegion = addTernaryRegions(sciChartSurface, wasmContext, ternary, getSoilTextureClasses());
addTernaryGrid(sciChartSurface, wasmContext, ternary, 10);

// Your data: one object per point, with a value for each component
const samples = getSoilSampleData();
const points = samples.map((sample) => ternary.toXY(sample));
sciChartSurface.renderableSeries.add(
new XyScatterRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, {
xValues: points.map((p) => p.x),
yValues: points.map((p) => p.y),
dataSeriesName: "Soil samples"
}),
pointMarker: new EllipsePointMarker(wasmContext, { width: 10, height: 10, fill: "#FFFFFF", stroke: "#14233C", strokeThickness: 1.5 })
})
);

// Keep the triangle equilateral whenever the chart changes size
keepTernaryEquilateral(sciChartSurface);

// Hover to read all three values, scroll to zoom, drag to pan, double-click to reset
sciChartSurface.chartModifiers.add(
new TernaryTooltipModifier(ternary, samples, findRegion),
new MouseWheelZoomModifier(),
new ZoomPanModifier(),
new ZoomExtentsModifier({
onZoomExtents: () => {
fitTernaryView(sciChartSurface);
return false; // skip the default, which would stretch the triangle to fill the chart
}
})
);
}

Key points:

  • createTernary is plain JavaScript with no SciChart code. Its toXY and fromXY convert between three values and a position in a triangle with sides of 100, using the formula above. You choose which component goes on which corner.
  • The triangle, gridlines and tick marks are FastLineSegmentRenderableSeries, drawn as pairs of points. Each component's ticks continue its own gridlines out of the triangle, so they show which way to read. Labels and side titles are NativeTextAnnotations, with rotation to run the titles along the sides.
  • Each shaded region is a FastTriangleRenderableSeries in ETriangleSeriesDrawMode.List mode. The triangulate helper cuts any outline, including the notched sandy loam class, into triangles. The samples are an XyScatterRenderableSeries.
  • The two normal axes are hidden but still set the drawing area. fitTernaryView sets their ranges so one unit is the same number of pixels across and up, keepTernaryEquilateral runs it whenever the chart changes size, and onZoomExtents calls it on double-click instead of stretching the triangle to fill the chart. TernaryTooltipModifier extends CustomChartModifier2D (custom chart modifiers) to read the values under the mouse.

See it in the demo app: JavaScript scatter chart · React scatter chart · Angular scatter chart, and the JavaScript triangle series chart for filled shapes.

Go deeper: SciChart.js triangle series documentation, including the list, strip and polygon draw modes, and the SciChart.js scatter chart documentation.

If you're building a Windows desktop app, SciChart WPF has a built-in ternary chart, with ternary scatter, polygon and error bar series.

Frequently asked questions​

What is a ternary plot used for?​

A ternary plot is used to compare mixtures made of three parts. Soil scientists use it to name soil textures from their sand, silt and clay content; geologists to classify rocks by three minerals; chemists and metallurgists to map which phases form in three-component mixtures and alloys. It also works for any three shares of a whole, such as a three-way vote or how a team splits its time.

How do you read a ternary plot?​

Read each component separately. Find its corner, where it is 100%, and the opposite side, where it is 0%. From the point, follow the gridline that runs parallel to that opposite side until it meets the scale for that component, and read the value. Do the same for the other two components, then check that the three values add up to 100%.

Why do the values on a ternary plot add up to 100%?​

A ternary plot shows proportions, not amounts. Each point is a mixture whose three parts are scaled so they add up to a fixed total, usually 100% or 1. Because the third value always follows from the other two, three values fit on a flat triangle. If your values don't add up to the total, divide each by their sum before plotting.

What is the difference between a ternary plot and a ternary phase diagram?​

A ternary plot is the general chart: any data with three parts that add up to a total, plotted in a triangle. A ternary phase diagram is one use of it in chemistry and materials science. It divides the triangle into regions that show which phases (solid, liquid, or several solids) exist at each composition, usually at one fixed temperature and pressure.

Can a ternary plot show more than three components?​

Not directly. A ternary plot has exactly three corners. With four or more components, either group them into three (for example, quartz, feldspar and all other rock fragments), plot three of them after removing the rest and rescaling to 100%, or use a different chart, such as a stacked bar chart.

How do I make a ternary plot in JavaScript?​

Convert each point's three values to x and y: divide each value by the sum, then x is the right-hand component plus half the top component, and y is the top component times the square root of 3 divided by 2. Plot those points as a scatter series, and draw the triangle, gridlines and tick labels yourself. With SciChart.js you can do this with line segment series, text annotations, a scatter series, and triangle series to shade regions. The same code works in React with scichart-react and in Angular with scichart-angular.

Sources​

  • Soil Science Division Staff (2017), Soil Survey Manual. USDA Handbook 18, Natural Resources Conservation Service. Defines the sand, silt and clay size limits and the 12 soil texture classes used in the example.
  • USDA Natural Resources Conservation Service, Soil texture calculator. Finds the texture class of a soil from its sand, silt and clay percentages.
  • Science Education Resource Center, Carleton College, How do I use ternary diagrams? Ternary diagrams in the earth sciences, including soil and igneous rock classification.
  • DoITPoMS, University of Cambridge, Ternary phase diagrams. A teaching package on reading ternary phase diagrams for alloys, with a tin–silver–copper case study.
  • Howarth, R. J. (1996), Sources for a history of the ternary diagram. The British Journal for the History of Science, 29(3), 337–356.