Making ternary diagrams in GMT

Hi,

Apologies if this has been covered elsewhere, but I searched and couldn’t find a similar thread.

I want to make a AFP diagram with the field labels and lines included, with the ternary inverted (i.e. the bottom half of this https://www.mindat.org/photo-469339.html ). I haven’t written a full script for this myself yet but I have tried plotting the lines on the example from the psternary man page.

I was trying to do this by setting up a basemap and then using psxy / psxyz to plot the fields before adding the data. However these didn’t work.

Given most of the ternary plots I’ve seen people post from GMT don’t have this type of annotation I was wondering if it is even possible?

Full disclosure I am relatively new to GMT using mostly PSXY for plots, and I have both GMT 5 and 6 installed. The other option I considered is to plot my data, which I can do relatively easily and then add the lines in inkscape afterwards, but I sort of wanted to do it all within GMT to learn the right structure and expand the functions I can use.

Thanks for any advice you can provide.
Anthony

Plotting lines with ternary seems possible. However -C must be specified, otherwise ternary fails to plot lines and throws an error message.

code:

cat << EOF > ternary_lines.txt
> -W5p,red
 5  5 90
 5 90  5
90  5  5
 5  5 90
> -W5p,green
30  0 70
30 30 40
 0 80 20
20 80  0
40 30 30
70  0 30
30  0 70
> -W5p,blue
40  0 60
 0 40 60
 0 60 40
40 60  0
60 40  0
60  0 40
40  0 60
EOF

gmt begin ternary_example png -C
  gmt makecpt -Cturbo -T0/80/10
  gmt ternary @ternary.txt -R0/100/0/100/0/100 -JX15c -Sc0.1c -C -LLimestone/Water/Air \
    -Baafg+l"Limestone component"+u" %" -Bbafg+l"Water component"+u" %" -Bcagf+l"Air component"+u" %" \
    -B+givory+t"Example data from MATLAB Central"
  gmt ternary ternary_lines.txt -C
cat << EOF | gmt ternary -W1p
40 60  0
60 40  0
60  0 40
40  0 60
EOF
gmt end show

calling gmt ternary ternary_lines.txt without -C fails plotting the lines silently

cat ... | gmt ternary -W1p produces the following error message:

plot [WARNING]: Representation of pen color (@GMTAPI@-S-I-D-D-L-N-000000) not recognized. Using default.
plot [ERROR]: Cannot find file 1p
ternary [ERROR]: Unable to plot lines

so the plotting lines on a ternary diagram is definitely possible.

how to plot a second ternary diagram upside down remains unclear to me.

Variable color background is not possible with plain GMT (needs grdimage). For that you need GMT.jl
https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/ternary/index.html#ternary
https://www.generic-mapping-tools.org/GMTjl_doc/examples/ternary/

The upside-down diagram can be, in principle, obtained with a proper rotation (-p180) and a -Y shift

with ternary adding -p180 destroys the map frame and ignored by the plotting symbols

looks quite exotic I believe, like every frame element has its uinque -p180 perspective.

I was thinking more on rotating a finished PS. All GMT ps can be used as custom symbols, or inserted in other PS with psimage.

That could be a really interesting exercise.