Skip to main content

Ternary Diagram

python_badge license_badge PyPI version Downloads

CI docs Ruff Conda Version Conda Platforms

This package makes it easier for you to draw beautiful ternary diagram without pymatgen.

Specifically, it only requires numpy>=1.20 and matplotlib.

What you will be able to do with this package

  • Create beautiful contour maps easily
  • Creating a scatter plot
  • Draw tie lines
  • Automatically format chemical composition using subscripts
  • Most of the matplotlib options are available

/example/contour/example_contour.png

How to install

PyPI

pip install ternary-diagram

PyPI project is here.

Anaconda

conda install -c conda-forge ternary-diagram

Anaconda (conda-forge) package site is here.

Usage

See Examples and the documentation.

Examples

An easy example is here.

import matplotlib.pyplot as plt
from ternary_diagram import TernaryDiagram

# You can set `ax` to select which axes to draw. If not, the current axes will be used.
td = TernaryDiagram(["Li2O", "La2O3", "TiO2"])

# scatter
td.scatter(vector=[[1, 1, 1], [1, 2, 3]], z=[0, 1])
# You can set some options in `plt.scatter` like `marker`, `c` etc.
td.scatter(vector=[[2, 1, 3], [3, 2, 1]], marker="s", c="#022c5e", s=30)

# line plot
# You can set some options in `plt.plot` like `lw`, `c`, and so on.
td.plot([[1, 1, 1], [1, 2, 3]], color="black")

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

/example/example_on_readme/figure.png

It can be written like this.

# The background color is sometimes transparent in jupyter notebooks, so set facecolor 'white'.
fig, ax = plt.subplots(facecolor="w")

# You can set `ax` to select which axes to draw. If not, the current axes will be used.
td = TernaryDiagram(["Li2O", "La2O3", "TiO2"], ax=ax)

# scatter
td.scatter(vector=[[1, 1, 1], [1, 2, 3]], z=[0, 1])
# You can set some options in `plt.scatter` like `marker`, `c` etc.
td.scatter(vector=[[2, 1, 3], [3, 2, 1]], marker="s", c="#022c5e", s=30)

# line plot
# You can set some options in `plt.plot` like `lw`, `c`, and so on.
td.plot([[1, 1, 1], [1, 2, 3]], color="black")

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

It means that you can draw multiple figures in one figure object.

See also the example folder.

Histories

v3.1.0

  • Delete .utils._BasePlotter.get_x_y (we should access directly).
  • Resolve #10 (Create fill argument in TernaryDiagram.contour).
  • Resolve #11 (Create auto_latex_notation argument in TernaryDiagram).
  • Update documentation.
  • Update docstrings and typings.

LICENSE

See LICENSE.

MIT Licence

Copyright (c) 2021 yu9824

Metadata

Release files for ternary-diagram 3.2.2

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.2.2
File Size Uploaded Provenance Actions
ternary_diagram-3.2.2.tar.gz 14.9 kB With provenance Details for ternary_diagram-3.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 27.6 kB

Release files / ternary_diagram-3.2.2.tar.gz

Download URL ternary_diagram-3.2.2.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f0f56044856904e8623f365a2bb1a33856487641e13f7f89a4d2a92c94198998
BLAKE2b-256 checksum
How to use checksums
886c3105908e89287f5a285d03d8806aaf0268c6a65260ee61b40b15db086049
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 15, 2026.

Transparency log

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

Download URL ternary_diagram-3.2.2-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1073403a2f82c2e8486acfacc7e76f53bfba6d1bd25dc4907c478ef243f7d135
BLAKE2b-256 checksum
How to use checksums
e4672caf9a68b4502f0b831234ea34f3dfbea84242bb2934ee73b51f339c0eec
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 15, 2026.

Transparency log

Security for ternary-diagram 3.2.2

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.2.2.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 15, 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