Skip to content

feat(viz): ternary plot of three parts of a whole - #4841

Merged
jqnatividad merged 4 commits into
masterfrom
feat/viz-ternary
Oct 18, 2026
Merged

jqnatividad merged 4 commits into
masterfrom
feat/viz-ternary

Conversation

@jqnatividad

Copy link
Copy Markdown
Collaborator

Stacked on #4840 (barpolar), which is stacked on #4839 (parcoords). Retarget to master once those merge; this branch will need the same rebase onto master as #4839.

What's new

  • viz ternary: a ternary (triangle) plot from plotly.js's scatterternary trace.
    • --cols names exactly 3 numeric columns, the a, b and c parts of a whole: the first column's corner is the top, the second's bottom-left, the third's bottom-right. Any other count is a usage error.
    • Each row is drawn at its shares a/(a+b+c), b/(a+b+c), c/(a+b+c); the axes are titled with the column names and read 0–100%.
    • --series splits the points into one colored trace per value (first-appearance order). --color/--size encode numeric columns onto a single trace (Viridis colorbar; bubble sizes rescaled as on viz scatter). As on scatter, the two can't be combined.
    • The hover shows each part's raw value next to its share (sand: 60 (60.0%)), plus the series and any color/size value.
    • Rows with a blank, non-numeric or negative part, parts summing to zero, or a missing --color/--size value are skipped and counted on stderr. A file with no plottable row is an error.
  • Why --cols rather than --a/--b/--c: every other chart that takes a fixed set of numeric columns (radar, splom, parcoords, heatmap) uses --cols, and three single-purpose flags would add to an already long USAGE. The axes are titled with the column names, so the chart shows the corner mapping, and the USAGE states it.
  • Dark themes: the plotly_dark ternary styling comes from the plotly.rs pin moved in feat(viz): barpolar wind rose; clock-face polar bars for the smart seasonality panel #4840.
  • No new i18n keys (axis titles are the column names; the hover is built from them).
  • Regenerated docs/help/viz.md and qsv-viz.json (new subcommand, the --cols/--series/--color/--size descriptions, a usage example).

Gallery

New soil-texture triangle from a synthetic soil_samples.csv (320 samples in 4 texture classes, listed in the README dataset table). Dashboards were not changed: their regen diffs were timestamps only.

Verification

  • cargo t viz -F all_features: 485 unit and 657 integration tests pass, including 3 new ternary tests.
  • Mutation-checked: dropping the normalization, each skip rule (negative part, zero sum, missing --color), the percent axis format, the series names, --size, and the skip count each fails a test.
  • scripts/double-run-check.py --check OK; cargo +nightly fmt; clippy reports no warnings on added lines.
  • In Chrome: light and plotly_dark output (dark ternary background and grid), the hover, and the gallery figure.

Known rough edge: a text column in --cols (e.g. --cols texture,sand,silt) gets the generic "no plottable rows" error, not one naming the column.

The wiki Visualization page update is staged locally and will be pushed after merge.

🤖 Generated with Claude Code

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Base automatically changed from feat/viz-barpolar to master October 18, 2026 18:40
jqnatividad and others added 4 commits October 18, 2026 14:41
`viz ternary --cols a,b,c` draws each row at its shares of a+b+c on a
plotly scatterternary triangle, axes reading 0-100%. --series splits
the points into colored traces; --color/--size encode numeric columns
(the two can't be combined, as on scatter). The hover shows each part's
raw value next to its share.

Rows with a blank, non-numeric or negative part, parts summing to zero,
or a missing --color/--size value are skipped and counted on stderr; a
file with no plottable row is an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds a synthetic soil_samples.csv (320 samples in 4 texture classes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jqnatividad
jqnatividad merged commit 8ac0ef1 into master Oct 18, 2026
31 checks passed
@jqnatividad
jqnatividad deleted the feat/viz-ternary branch October 18, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant