Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoalopez committed Oct 10, 2022
1 parent ae54d68 commit 257e64f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
![](https://github.com/marcoalopez/ternary_plots/blob/main/imgs/header.jpg?raw=true)
_Brought to you by [Marco A. Lopez-Sanchez](https://marcoalopez.github.io/) - Last update: 2022-10-06_
_Brought to you by [Marco A. Lopez-Sanchez](https://marcoalopez.github.io/) - Last update: 2022-10-10_

## **What is a ternary plot?**

A [ternary plot](https://en.wikipedia.org/wiki/Ternary_plot) is a triangular diagram that displays the proportion of three variables that sum to a constant, usually 1 or 100%. It is a common diagram in solid-earth but also in other physical sciences.
A [ternary plot](https://en.wikipedia.org/wiki/Ternary_plot) is a triangular diagram that displays the proportion of three variables that sum to a constant, usually 1 or 100%. It is a common diagram in solid-earth but also in other physical sciences.

## **What is the purpose of this repository?**
You want to use ternary diagrams in your Jupyter notebook (or Python script). Sadly you realise that matplolib does not have ternary plots by default. After some research on the internet, you realise that the alternatives are either to install other plotting libraries (e.g. [Plotly](https://plotly.com/python/ternary-plots/)) or third-party libraries that rely on matplolib (e.g. [python-ternary](https://github.com/marcharper/python-ternary) or [mpltern](https://mpltern.readthedocs.io/en/latest/index.html)). Unfortunately, you don't feel like learning a new syntax for plotting (you are too comfortable with your matplolib buddy) or don't want to install a new Python library with all that this entails (dependencies, etc.) and that it seem too overkill for your needs\*. This is where the good news comes in. You can create a simple ternary diagram in matplolib in few lines of code, where simple means that it has the minimum necessary elements to correctly interpret it. In short, **no installations, no new dependencies, your usual matplolib syntax, and no fuss**.
You want to use ternary diagrams in your Jupyter notebook (or Python script). Sadly you realise that matplolib does not have ternary plots by default. After some research on the internet, you realise that the alternatives are either to install other plotting libraries (e.g. [Plotly](https://plotly.com/python/ternary-plots/)) or third-party libraries that rely on matplolib (e.g. [python-ternary](https://github.com/marcharper/python-ternary) or [mpltern](https://mpltern.readthedocs.io/en/latest/index.html)). Unfortunately, you don't feel like learning a new syntax for plotting (you are too comfortable with your matplolib buddy) or don't want to install a new Python library with all that this entails (dependencies, etc.) and that it seem overkill for your needs\*. This is where the good news comes in. You can create a barebones ternary diagram with the minimum necessary elements in matplolib in few lines of code. In short, **no installations, no new dependencies, your usual matplolib syntax, and no fuss**.

\*_I have nothing against these libraries, quite the opposite, if you need more advanced features use them!_

Expand All @@ -20,7 +20,7 @@ The modules you must import
import matplotlib.pyplot as plt
from types import SimpleNamespace

# other modules used in the examples
# also used in the example although not strictly necessary
import numpy as np
```

Expand Down Expand Up @@ -168,9 +168,9 @@ ax.legend(fontsize=14)

### Real life examples

To create ternary diagrams it is always the same two-step process:
To use ternary diagrams it is always the same two-step process:

1) Normalise and convert your ternary coordinates to Cartesian coordinates. For this you will use the ``tri2cart()`` function.
1) Normalise and convert your ternary coordinates to Cartesian ones. For this you will use the ``tri2cart()`` function.
2) Then initialize your ternary diagram using the ``ternary()`` function and use your ususal matplolib commands (``plot()``, ``scatter()``, etc.)

> **Important: Usage example, jupyter notebooks and script will be available soon**
Expand Down

0 comments on commit 257e64f

Please sign in to comment.