ternary-diagram

ternary-diagram#

ternary-diagram draws ternary diagrams of three-component compositions on matplotlib, without pymatgen: scatter plots, contour maps, heatmaps, phase regions and labels, on any matplotlib Axes. It only requires numpy and matplotlib at runtime.

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

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

Where to go next#