[ANN]: TernaryDiagrams.jl

Hi all! I made a small Makie recipe package that allows you to draw ternary plots like this:

I am planning on eventually making a ternary axis properly (instead of co-opting the regular 2D axis like I do currently), so that there won’t be as much white space around the figure. In the mean time, if you use the package and have any comments, let me know!


Just used this, it looks really neat! One potential idea which you could use is to create something like the PolarAxis layoutable, wherein the Scene has a fixed transform_func which translates 3D points to 2D points.

I just made this plot for a colorlegend, the output is below:

with the script (slightly kludgey, I know :slightly_frowning_face:)

xs = LinRange(0, 1, 1000)
ys = LinRange(0, 1, 1000)

barycentric_points = TernaryDiagrams.from_cart_to_bary.(xs, ys')

colors = map(barycentric_points) do barycentric_point
    if any(barycentric_point .< 0.0)
        return RGBf(1,1,1)
        return RGBf(barycentric_point...)

fig = Figure();
ax = Axis(fig[1, 1]);

    labelx = "Bad",
    labely = "Good",
    labelz = "Uncertain",
    xtickformat = tick -> TernaryDiagrams._default_formatter(tick*100)*"%",
    ytickformat = tick -> TernaryDiagrams._default_formatter(tick*100)*"%",
    ztickformat = tick -> Makie.rich(Makie.rich(TernaryDiagrams._default_formatter(tick*100)*"%", color = :black), "--"; color = :white)
xlims!(ax, -0.2, 1.2)
ylims!(ax, -0.3, 1.1)
img_plt = image!(ax, xs, ys, colors)
translate!(img_plt, 0, 0, -100)
1 Like

That is really great! I will definitely look into the way you made the colorlegend. Filling the triangle with colors was by far the hardest part of the entire recipe.

Sadly, I don’t see myself having time for this until mid March, but I will keep you posted!

1 Like