set terminal pdf enhanced fname "Helvetica" fsize 9 linewidth 8 dashed dl 4 size 3.25inches,3.25inches # output to PDF file set output 'ternary-diagram.pdf' #set output '|display png:-' # pipe the output for displaying in ImageMagick's display program set bmargin 3 set lmargin 3 set rmargin 3 set tmargin 3 set size ratio 1 1,1 set xrange [0:1] set yrange [0:1] set zrange [0:20] set noborder set noxtics set noytics set noztics #set angles degrees #set key 100,90 #################################################################### # Ternary phase diagrams using barycentric equilateral triangle, # whose sides (and the opposing vertices) are numbered a, b, and c. #################################################################### # w/o normalization (data satisfy a+b+c=1, so only a,b will be given) #################################################################### # vertex c at the origin and side a along the x-axis, clockwise #gx(a,b)=a/2.0+b #gy(a,b)=a*sqrt(3)/2 # vertex b at the origin and side a along the x-axis, counter-clockwise #gx(a,b)=a/2.0+c #gy(a,b)=a*sqrt(3)/2 # vertex c at the origin and side b along the x-axis #gx(a,b)=a+b/2.0 #gy(a,b)=b*sqrt(3)/2 #################################################################### # w/ normalization (data don't necessarily satisfy a+b+c=1, a,b,c should all be given) #################################################################### # vertex c at the origin and side a along the x-axis, clockwise #gx(a,b,c)=(a/2.0+b)/(a+b+c) #gy(a,b,c)=a*sqrt(3)/2/(a+b+c) # vertex b at the origin and side a along the x-axis, counter-clockwise #gx(a,b,c)=(a/2.0+c)/(a+b+c) #gy(a,b,c)=a*sqrt(3)/2/(a+b+c) # vertex c at the origin and side b along the x-axis gx(a,b,c)=(a+b/2.0)/(a+b+c) gy(a,b,c)=b*sqrt(3)/2/(a+b+c) #################################################################### set style line 1 lt 1 lc rgb "black" lw 1 pt -1 ps 1 set style line 2 lt 4 lc rgb "black" lw 0.25 pt -1 ps 1 set style line 3 lt 1 lc rgb "red" lw 0.5 pt -1 ps 1 set style arrow 1 nohead front linestyle 1 set style arrow 2 nohead back linestyle 2 set style arrow 3 nohead back linestyle 3 # vertex c at the origin and side a along the x-axis, clockwise offset=0.05 set label 1 'Label C' at gx(1,0,0)+offset,gy(1,0,0)-offset center set label 2 'Label B' at gx(0,1,0),gy(0,1,0)+offset center set label 3 'Label C' at gx(0,0,1)-offset,gy(0,0,1)-offset center set arrow 1 from 0,0 to 1,0 arrowstyle 1 set arrow 2 from 1,0 to 0.5,sqrt(3)/2 arrowstyle 1 set arrow 3 from 0.5,sqrt(3)/2 to 0,0 arrowstyle 1 #################################################################### # Suppose you want to plot two-phase tie lines as well as points corresonding to the individual phases. # In order to use the mechanism here, you need to provide a data file with each line containing all the information for one state point. # Here, columns 1, 3, 5 correspond to the three compositions in phase I, and columns 2, 4, 6 the three compositions in phase II. #################################################################### # run the following command in terminal to generate "tie_lines.gpl" #awk '{print "set arrow", NR+100, "from gx(", $2, ",", $4, "," ,$6, "), gy(", $2, ",", $4, "," ,$6, ") to gx(", $1, ",", $3, ",", $5, "), gy(", $1, ",", $3, "," ,$5, ") arrowstyle 3"}' raw_data.dat > tie_lines.gpl # plot tie lines using commands generated in "tie_lines.gpl", such as # set arrow 101 from gx( 0.014642 , 0.0014299 , 0.98393 ), gy( 0.014642 , 0.0014299 , 0.98393 ) to gx( 3.8404 , 4.9577 , 1.4384 ), gy( 3.8404 , 4.9577 , 1.4384 ) arrowstyle 3 load "tie_lines.gpl" #################################################################### set multiplot # x set arrow 4 from gx(0.2,0,0.8),gy(0.2,0,0.8) to gx(0.2,0.8,0),gy(0.2,0.8,0) arrowstyle 2 set arrow 5 from gx(0.4,0,0.6),gy(0.4,0,0.6) to gx(0.4,0.6,0),gy(0.4,0.6,0) arrowstyle 2 set arrow 6 from gx(0.6,0,0.4),gy(0.6,0,0.4) to gx(0.6,0.4,0),gy(0.6,0.4,0) arrowstyle 2 set arrow 7 from gx(0.8,0,0.2),gy(0.8,0,0.2) to gx(0.8,0.2,0),gy(0.8,0.2,0) arrowstyle 2 set label 4 '0.2' at gx(0,0.8,0.2)-offset,gy(0,0.8,0.2) center set label 5 '0.4' at gx(0,0.6,0.4)-offset,gy(0,0.6,0.4) center set label 6 '0.6' at gx(0,0.4,0.6)-offset,gy(0,0.4,0.6) center set label 7 '0.8' at gx(0,0.2,0.8)-offset,gy(0,0.2,0.8) center # y set arrow 8 from gx(0,0.2,0.8),gy(0,0.2,0.8) to gx(0.8,0.2,0),gy(0.8,0.2,0) arrowstyle 2 set arrow 9 from gx(0,0.4,0.6),gy(0,0.4,0.6) to gx(0.6,0.4,0),gy(0.6,0.4,0) arrowstyle 2 set arrow 10 from gx(0,0.6,0.4),gy(0,0.6,0.4) to gx(0.4,0.6,0),gy(0.4,0.6,0) arrowstyle 2 set arrow 11 from gx(0,0.8,0.2),gy(0,0.8,0.2) to gx(0.2,0.8,0),gy(0.2,0.8,0) arrowstyle 2 set label 8 '0.8' at gx(0.8,0,0.2),gy(0.8,0,0.2)-offset center set label 9 '0.6' at gx(0.6,0,0.4),gy(0.6,0,0.4)-offset center set label 10 '0.4' at gx(0.4,0,0.6),gy(0.4,0,0.6)-offset center set label 11 '0.2' at gx(0.2,0,0.8),gy(0.2,0,0.8)-offset center # z set arrow 12 from gx(0.8,0,0.2),gy(0.8,0,0.2) to gx(0,0.8,0.2),gy(0,0.8,0.2) arrowstyle 2 set arrow 13 from gx(0.6,0,0.4),gy(0.6,0,0.4) to gx(0,0.6,0.4),gy(0,0.6,0.4) arrowstyle 2 set arrow 14 from gx(0.4,0,0.6),gy(0.4,0,0.6) to gx(0,0.4,0.6),gy(0,0.4,0.6) arrowstyle 2 set arrow 15 from gx(0.2,0,0.8),gy(0.2,0,0.8) to gx(0,0.2,0.8),gy(0,0.2,0.8) arrowstyle 2 set label 12 '0.2' at gx(0.8,0.2,0)+offset,gy(0.8,0.2,0) center set label 13 '0.4' at gx(0.6,0.4,0)+offset,gy(0.6,0.4,0) center set label 14 '0.6' at gx(0.4,0.6,0)+offset,gy(0.4,0.6,0) center set label 15 '0.8' at gx(0.2,0.8,0)+offset,gy(0.2,0.8,0) center #################################################################### # plot points for individual phases #################################################################### plot 'raw_data.dat' using (gx($2,$4,$6)):(gy($2,$4,$6)) notitle with points lc rgb "blue" pt 7 plot 'raw_data.dat' using (gx($1,$3,$5)):(gy($1,$3,$5)) notitle with points lc rgb "cyan" pt 7 #plot "