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.

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)

Where to go next#
Getting started: install the package, draw and save a first diagram, and pass compositions.
Customizing the diagram: change the border, grid, tick labels, axis titles and vertex labels.
Drawing phase diagrams: shade phase regions, label them and control how they overlap.
Heatmaps and contour maps: choose between colored scatter plots, contour maps and heatmaps.
Layout and colorbars: control the automatic layout adjustment and colorbars.
Migrating to v4.0.0: update code for the defaults that change in 4.0.0.
Tutorials: example notebooks with real data.
API reference: every class, method and function.
User guide
Tutorials
API Reference