Ternary/simplex plotting recipe/addon for Plots.jl
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 or TernaryDiagrams.jl.
In the REPL you can paste this code to install the package:
using Pkg; pkg"add TernaryPlots"
and then load it with
using TernaryPlots
- Conversions between cartesian and ternary co-ordinates using the exported function
cart2tern
andtern2cart
- Construction of ternary axes using
ternary_axes
. (Currently not possible to reverse arrow/axis directions)
This package provides a function (more precisely: a recipe) to construct ternary plots via converting ternary co-ordinates to cartesian and plotting them:
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,:]))'
end
ternary_axes(
title="Rocks",
xguide="SiO2",
yguide="Al2O3",
zguide="MgO",
)
p = scatter!(a[:,1],a[:,2], legend=false)
- 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
onTernary_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.
- 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.
- @jacobusmmsmit - Author and maintainer
- @Hasnep - Maintainer
- @daschw - Major contributions to recipe implementation