Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ternary plot

Plot 3-component compositional data on an equilateral triangle. Each point's position uniquely encodes all three component ratios; constructors normalise so the components sum to 1. The classic use case is soil composition (sand / silt / clay) but ternary diagrams turn up everywhere portfolios sum to a constant.

The demo plots eight reference points from the USDA soil-texture triangle — sand at the bottom-left vertex, silt at bottom-right, clay at the top. The points span the canonical texture classes (sand, sandy loam, loam at the visual centre, silty clay loam, clay…) — the same classification agronomists have used since the Soil Survey Manual published the diagram in 1951.

Source: Soil texture — Wikipedia

Public surface

use wisp_chart::ternary::{TernaryPlot, TernaryPoint};

let points = vec![
    TernaryPoint::new(0.5, 0.3, 0.2, color),
    TernaryPoint::new(0.2, 0.3, 0.5, color),
    // ...
];
let plot = TernaryPlot::new("Sand", "Silt", "Clay", points);
let g = plot.emit_graphics(&theme, Vec2::new(360.0, 360.0));

Barycentric → cartesian

For triangle vertices A (bottom-left), B (bottom-right), C (top), a point with normalised components (a, b, c) lands at a·A + b·B + c·C. v1 draws the triangle outline, internal grid lines at 25 / 50 / 75 %, and one ellipse per point.

Use it when…

  • Three categories must sum to a fixed total (percentages, composition, portfolio weights).
  • Comparing many compositions at once — the triangle reveals clustering that a stacked-bar over time would hide.
  • Sediment / petrology / metallurgy — the textbook home of ternary diagrams.