Skip to main content

Ternary Diagram

python_badge license_badge PyPI version Downloads

CI docs Ruff Conda Version Conda Platforms

ternary-diagram draws ternary diagrams of three-component compositions on matplotlib, without pymatgen. It only requires numpy>=1.20 and matplotlib, and draws on any matplotlib Axes.

A contour map of a ternary system drawn with ternary-diagram

Features

  • Contour maps, scatter plots, tie lines and annotations of compositions
  • Automatic formatting of chemical formulas with subscripts (Li2O becomes Li2O)
  • Customizable diagram parts: border, grid, tick labels, axis titles and vertex labels
  • Phase diagrams: filled regions (fill) and labels placed at compositions (text)
  • Heatmaps: of scattered data (tripcolor) and of a function of the composition (heatmapf)
  • Control over the automatic layout adjustment and colorbars, respecting the figure's layout engine
  • Keyword arguments are passed through to matplotlib, and matplotlib objects are returned

Installation

pip install ternary-diagram

or, from conda-forge:

conda install -c conda-forge ternary-diagram

Quick start

import matplotlib.pyplot as plt

from ternary_diagram import TernaryDiagram

fig, ax = plt.subplots(layout="constrained")
td = TernaryDiagram(["Li2O", "La2O3", "TiO2"], ax=ax)

# scatter plot colored by values
td.scatter(vector=[[1, 1, 1], [1, 2, 3]], z=[0, 1])
# keyword arguments are passed to `Axes.scatter`
td.scatter(vector=[[2, 1, 3], [3, 2, 1]], marker="s", c="#022c5e", s=30)

# line plot; keyword arguments are passed to `Axes.plot`
td.plot([[1, 1, 1], [1, 2, 3]], color="black")

fig.savefig("figure.png", dpi=144)

The figure drawn by the quick start example

Documentation

The documentation is at https://yu9824.github.io/ternary-diagram/.

Changelog

See CHANGELOG.md and GitHub Releases.

License

MIT License. See LICENSE.

Copyright (c) 2021 yu9824

Metadata

Release files for ternary-diagram 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ternary-diagram 3.3.0
File Size Uploaded Provenance Actions
ternary_diagram-3.3.0.tar.gz 2.7 MB With provenance Details for ternary_diagram-3.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ternary-diagram 3.3.0
File Interpreter ABI Platform Actions
ternary_diagram-3.3.0-py3-none-any.whl Python 3 none any Details for ternary_diagram-3.3.0-py3-none-any.whl

Total release size: 2.8 MB

Release files / ternary_diagram-3.3.0.tar.gz

Download URL ternary_diagram-3.3.0.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
ea7485d9ee5aad846e160db4ee10678e7553cf9513c7cc875545012c59f46e11
BLAKE2b-256 checksum
How to use checksums
a16856855fb406a4657d743f67c5d9e183c5d414ba92e2a483f4654d4eaa9475
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / ternary_diagram-3.3.0-py3-none-any.whl

Download URL ternary_diagram-3.3.0-py3-none-any.whl
Size 64.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3170a38bbf3a96a57c955227535dcbe23639c4f5b658bf9925e4d3ee05f60cf
BLAKE2b-256 checksum
How to use checksums
c3659ec8884522507fd23a3e15e7a429dbcb1bc900ccd7076f3972c254ee9e71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for ternary-diagram 3.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ternary_diagram-3.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page