Ternary diagrams and surfaces on non-rectangular grids

I would like to plot a surface on a triangular domain. Is there a Julia project which can plot ternary diagrams, akin to this code?

1 Like

Maybe PGFplotsX? I managed to get something close to that example plotting directly in pgfplots in LaTeX. But the edges of the triangle were jagged as the surface was composed of squares. I’m sure Somone with more knowhow could do better!

Also, @lazarusA you seem to be a plotting master craftsman! Any ideas?

GMT.jl is possibly one of the best bets for this and @joa-quim is the guru.
See a simpler example here but package goes miles beyond in terms of plots layout complexity.

That example was one to show how one can easily clip the display area to any form, but if Ternary plots are wanted then GMT has this module that is wrapped in GMT.jl in the ternary module that has the same syntax as plot but I have not experimented it.

1 Like

This looks great. I’d never heard of GMT. But now I’m dreaming up reasons to include maps in publications!

I’m assuming the OP @SEA is interested in replicating this 3d surface

Out of curiosity, what’s the advantage of plotting on a triangle versus on the more common rectangular coordinates? It seems like they’d be equivalent, each having two degrees of freedom.

On a 2d ternary plot, if there is a fixed sum of all variables (e.g. the proportions of 3 competing Game theoretic strategies) you can represent each of 3 variable by the distance to each axis. with a surface on top, you can also show how some 4varable depends on the other 3.

1 Like

I’m not sure you can plot islolines in ternary plots with GMT. You can plot the whole collection of symbols but I don’t see a way to plot lines. If interested, raise this issue in the GMT forum.

See possibly one example here, a pdf with GMT ternary plot examples which also points to gmt scripts here.

If your surface is of equation z=f(a,b,c), where (a,b,c) are barycentric coordinates (i.e. a+b+c=1, a, b, c >=0), of the points in the planar triangular region of definition for f, then if you are defining a uniform triangulation of this region (with points expressed in cartesian coordinates, and then converted to barycentric ones) and lift the points of the triangulation onto the surface, you get a mesh defined on the surface and can plot it with Makie. For triangulation you can use Triangulate.js

There is TernaryPlots.jl under development in pure Julia, we had this discussion over Zulip recently in this thread: https://julialang.zulipchat.com/#narrow/stream/225542-helpdesk/topic/Can.20a.20recipe.20be.20used.20for.20ternary.20plots.3F

There you can find screenshots of what is currently possible. It looks great.

1 Like