Построение треугольных диаграмм в барицентрических координатах используя gnuplot

Собственно самая сложная часть - это пересчет в прямоугольные координаты

Результат no.svgОн же, но преобразованный в png ImageMagick'ом командой
"convert no.svg no.png" no.png:

Содержимое "no.dat":

Mg (левый)	Ca (верхний)	Fe (правый)
0.7	0.26	0.04
0.7	0.27	0.03
0.43	0.13	0.43
0.67	0.31	0.03
0.69	0.27	0.04
0.68	0.29	0.03
0.65	0.33	0.03
0.66	0.31	0.03
0.66	0.31	0.03
0.66	0.32	0.02
0.7	0.27	0.03
0.65	0.32	0.03
0.67	0.3	0.03
0.65	0.32	0.03
1	2	3
45	6	8
3	19	22
34	0	0
0	5	0
0	0	1
0	1	0
1	1	0
0	1	1
1	0	1
1	1	1
10	20	19
0	0	0

Содержимое скрипта для gnuplot "trigon.graph":

#!/usr/bin/gnuplot -persist

set terminal svg enhanced size 500,400 dashed
set output "no.svg"
set encoding utf8
unset border
unset xtics
unset ytics

set size square

set xrange [0:1]
set yrange [0:1] 
set bmargin 2


# Отрисовываем основной треугольник
set style arrow 11 nohead back lt -1 lw 2 # стиль

set arrow 11 from 0,0 to .5,sqrt(3)/2 as 11
set arrow 12 from 0,0 to 1,0          as 11
set arrow 13 from .5,sqrt(3)/2 to 1,0 as 11

# Промежуточные деления
set style arrow 2 nohead back lt 1 lw 1 lc rgb "gray" # стиль

set arrow 21 from 0.1,0 to 0.5+0.1*0.5,0.9*sqrt(3)/2 as 2
set arrow 22 from 0.2,0 to 0.5+0.2*0.5,0.8*sqrt(3)/2 as 2
set arrow 23 from 0.3,0 to 0.5+0.3*0.5,0.7*sqrt(3)/2 as 2
set arrow 24 from 0.4,0 to 0.5+0.4*0.5,0.6*sqrt(3)/2 as 2
set arrow 25 from 0.5,0 to 0.5+0.5*0.5,0.5*sqrt(3)/2 as 2
set arrow 26 from 0.6,0 to 0.5+0.6*0.5,0.4*sqrt(3)/2 as 2
set arrow 27 from 0.7,0 to 0.5+0.7*0.5,0.3*sqrt(3)/2 as 2
set arrow 28 from 0.8,0 to 0.5+0.8*0.5,0.2*sqrt(3)/2 as 2
set arrow 29 from 0.9,0 to 0.5+0.9*0.5,0.1*sqrt(3)/2 as 2

set arrow 31 from 0.1*0.5,0.1*sqrt(3)/2 to 0.1,0 as 2
set arrow 32 from 0.2*0.5,0.2*sqrt(3)/2 to 0.2,0 as 2
set arrow 33 from 0.3*0.5,0.3*sqrt(3)/2 to 0.3,0 as 2
set arrow 34 from 0.4*0.5,0.4*sqrt(3)/2 to 0.4,0 as 2
set arrow 35 from 0.5*0.5,0.5*sqrt(3)/2 to 0.5,0 as 2
set arrow 36 from 0.6*0.5,0.6*sqrt(3)/2 to 0.6,0 as 2
set arrow 37 from 0.7*0.5,0.7*sqrt(3)/2 to 0.7,0 as 2
set arrow 38 from 0.8*0.5,0.8*sqrt(3)/2 to 0.8,0 as 2
set arrow 39 from 0.9*0.5,0.9*sqrt(3)/2 to 0.9,0 as 2

set arrow 41 from 0.1*0.5,0.1*sqrt(3)/2 to 0.5+0.9*0.5,0.1*sqrt(3)/2 as 2
set arrow 42 from 0.2*0.5,0.2*sqrt(3)/2 to 0.5+0.8*0.5,0.2*sqrt(3)/2 as 2
set arrow 43 from 0.3*0.5,0.3*sqrt(3)/2 to 0.5+0.7*0.5,0.3*sqrt(3)/2 as 2
set arrow 44 from 0.4*0.5,0.4*sqrt(3)/2 to 0.5+0.6*0.5,0.4*sqrt(3)/2 as 2
set arrow 45 from 0.5*0.5,0.5*sqrt(3)/2 to 0.5+0.5*0.5,0.5*sqrt(3)/2 as 2
set arrow 46 from 0.6*0.5,0.6*sqrt(3)/2 to 0.5+0.4*0.5,0.6*sqrt(3)/2 as 2
set arrow 47 from 0.7*0.5,0.7*sqrt(3)/2 to 0.5+0.3*0.5,0.7*sqrt(3)/2 as 2
set arrow 48 from 0.8*0.5,0.8*sqrt(3)/2 to 0.5+0.2*0.5,0.8*sqrt(3)/2 as 2
set arrow 49 from 0.9*0.5,0.9*sqrt(3)/2 to 0.5+0.1*0.5,0.9*sqrt(3)/2 as 2



# Основные подписи (что по углам)
set label 11 center "Ca_2Si_2O_6" at 0.5,sqrt(3)/2+.06
set label 12 center "Fe_2Si_2O_6" at 1,-.06
set label 13 center "Mg_2Si_2O_6" at 0,-.06

# Подписи шкалы
set label 21 center "50" at 0.5,-.05
set label 32 right "50" at .5*.5-0.04,0.5*sqrt(3)/2
set label 43 left "50" at 1-.5*.5+0.04,.50*sqrt(3)/2


# Собственно построение с пересчетом
plot "no.dat" using (sqrt(3)/2*(1-$1/($1+$2+$3))/sqrt(3)*2-(sqrt(3)/2*$3/($1+$2+$3))/sqrt(3)):(sqrt(3)/2*$3/($1+$2+$3)) with points pt 13 ps 1.5 lc rgb "#0000ff" title "LK09-025"

Запускать из командной строки - "gnuplot trigon.graph"








Автор: Николай Латышев
Nikolay Latyshev Google