Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacobusmmsmit/ternaryplots.jl
Ternary/simplex plotting recipe/addon for Plots.jl
https://github.com/jacobusmmsmit/ternaryplots.jl
Last synced: 2 months ago
JSON representation
Ternary/simplex plotting recipe/addon for Plots.jl
- Host: GitHub
- URL: https://github.com/jacobusmmsmit/ternaryplots.jl
- Owner: jacobusmmsmit
- License: mit
- Created: 2021-03-23T15:49:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-06T16:12:20.000Z (about 1 year ago)
- Last Synced: 2024-10-13T19:36:39.918Z (3 months ago)
- Language: Julia
- Size: 173 KB
- Stars: 26
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TernaryPlots.jl
Ternary/simplex plotting recipe/addon for Plots.jl## Package status
This package is considered not in active development. I am not currently dedicating any time to adding features or fixing bugs but I will try to answer questions. If you are looking for such functionality may I suggest [GMT.jl](https://docs.juliahub.com/GMT/EoU0j/0.35.0/gallery/ternary/ternary/) or [TernaryDiagrams.jl](https://github.com/stelmo/TernaryDiagrams.jl).## Installation:
In the REPL you can paste this code to install the package:
```
using Pkg; pkg"add TernaryPlots"
```
and then load it with
```
using TernaryPlots
```## Current functionality:
* Conversions between cartesian and ternary co-ordinates using the exported function `cart2tern` and `tern2cart`
* Construction of ternary axes using `ternary_axes`. (Currently not possible to reverse arrow/axis directions)## How to use this package:
This package provides a function (more precisely: a recipe) to construct ternary plots via converting ternary co-ordinates to cartesian and plotting them:
```julia
push!(LOAD_PATH, "src")
using Plots
using TernaryPlots
using CSV
using DataFrames#Downloading Global whole-rock geochemical database compilation from zenodo.org
path = "https://zenodo.org/record/3359791/files/major.csv?download=1"
df = CSV.read(download(path), DataFrame)
df = coalesce.(df,0)
filter!(row -> row[:sio2] >= 0, df)
filter!(row -> row[:al2o3] >= 0, df)
filter!(row -> row[:mgo] >= 0, df)
filter!(row -> (row[:sio2] .+ row[:al2o3] .+ row[:mgo]) >= 0.9, df)
filter!(row -> (row[:sio2] .+ row[:al2o3] .+ row[:mgo]) <= 1.1, df)
compos = [df.sio2 df.al2o3 df.mgo]
a = [zeros(eltype(compos), size(compos, 1)) zeros(eltype(compos), size(compos, 1))]for i in 1:size(compos,1)
a[i,:] = collect(tern2cart(compos[i,:]))'
endternary_axes(
title="Rocks",
xguide="SiO2",
yguide="Al2O3",
zguide="MgO",
)p = scatter!(a[:,1],a[:,2], legend=false)
```
![](https://github.com/jacobusmmsmit/TernaryPlots.jl/blob/master/outputs/example_plot.png?raw=true)## Work (that was) in progress:
* Different axis scales (as opposed to just 0 to 1) and ability to update ticks after definition.
* Performance improvements and code cleanup.
* Documentation.
* Plotting of ternary heatmaps by overloading `heatmap` on `Ternary_Axes`. Users will be able to define a function of cartesian co-ordinates or ternary co-ordinates:
```
f = ((a, b, c) -> 3a^2 + b - c) # Function of ternary co-ordinates
g = (x,y) -> f(cart2tern(x, y)...) # Same function, but taking ternary co-ordinates as input
```
* Plotting of ternary histograms possibly simply by converting it into a heatmap and using the previous heatmap functionality.
* Plotting of contour maps.## Known issues:
* Rotation of labels is not consistent as you resize the graph, as such one needs to fiddle with the size parameter in order to get the angles correct, or specify them yourself.
* The figures are off-centered.## Contributions:
* [@jacobusmmsmit](https://github.com/jacobusmmsmit) - Author and maintainer
* [@Hasnep](https://github.com/Hasnep) - Maintainer
* [@daschw](https://github.com/daschw) - Major contributions to recipe implementation