Skip to main content

No project description provided

Project description

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.

Meaningly, only need 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ternary_diagram-3.2.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

ternary_diagram-3.2.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file ternary_diagram-3.2.1.tar.gz.

File metadata

  • Download URL: ternary_diagram-3.2.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for ternary_diagram-3.2.1.tar.gz
Algorithm Hash digest
SHA256 9c58793619dd84a08c3d5c2aea08c91b53c6766d515edbc34d4b728518e1f331
MD5 3a6932870c84fa4e16ca313f3e9eab95
BLAKE2b-256 64208d0a232834dc10726a998892c012536943b053ac8117dd190b92d0bb400e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ternary_diagram-3.2.1.tar.gz:

Publisher: release-pypi.yml on yu9824/ternary-diagram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ternary_diagram-3.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ternary_diagram-3.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4572fa89e728e52da0251e8926963fefc8e65aee249c868c7f4b7f0a2fb655d7
MD5 0c4fb800ecf6d1d6eb1380d16836fce8
BLAKE2b-256 39f582753829978ab67a3b2f65af2b6cf2ce20034d9d3b8935a2380cf3385957

See more details on using hashes here.

Provenance

The following attestation bundles were made for ternary_diagram-3.2.1-py3-none-any.whl:

Publisher: release-pypi.yml on yu9824/ternary-diagram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page