首页 > 解决方案 > 如何用gnuplot制作三元图?

问题描述

如何使用 gnuplot 绘制三元图?它似乎本身并不支持这种类型的情节。

标签: gnuplot

解决方案


我使用https://staff.aist.go.jp/a.noda/programs/ternary/ternary-en.html作为此模板的基础。我更喜欢使用 Excel 获取图表的坐标并将它们保存在文件中。我喜欢使用 Sans Fira 作为图表的字体,但我使用 Arial 作为通用字体。这是使用的脚本


set bmargin 3
set lmargin 3
set rmargin 3
set tmargin 3
set size ratio 0.866
set yrange [0:0.866]
set xrange [0:1]
set noborder
unset xtics
unset ytics
unset key
set tmargin 5
set title "Ternary diagram template" font "Arial, 14" offset 0, 1

#~Red
C1 = '#FE5F55'
#~Blue
C2 = '#5E52FE'
#~Green
C3 = '#0CCE6B'


set label 'x' at 0.5, 0.9 center textcolor rgb C1 font "Arial, 12"
set label 'y' at -0.02, -0.03 center textcolor rgb C2 font "Arial, 12"
set label 'z' at 1.02, -0.03 center textcolor rgb C3 font "Arial, 12"

#Grid lines
set style line 1 lc rgb C1 lt 1 lw 2 pt -1 ps 1
set style line 10 lc rgb C1 lt 0 lw 1.5 pt -1 ps 1
set style line 2 lc rgb C2 lt 1 lw 2 pt -1 ps 1
set style line 20 lc rgb C2 lt 0 lw 1.5 pt -1 ps 1
set style line 3 lc rgb C3 lt 1 lw 2 pt -1 ps 1
set style line 30 lc rgb C3 lt 0 lw 1.5 pt -1 ps 1

# x
set arrow 1 from 0,0 to 1, 0.0 nohead linestyle 1
set arrow 2 from 0.97, 0.0866 to 0.05, 0.0866 nohead linestyle 10
set arrow 3 from 0.92, 0.1732 to 0.10, 0.173 nohead linestyle 10
set arrow 4 from 0.87, 0.2598 to 0.15, 0.260 nohead linestyle 10
set arrow 5 from 0.82, 0.3464 to 0.20, 0.346 nohead linestyle 10
set arrow 6 from 0.77, 0.4330 to 0.25, 0.433 nohead linestyle 10
set arrow 7 from 0.72, 0.5196 to 0.30, 0.520 nohead linestyle 10
set arrow 8 from 0.67, 0.6062 to 0.35, 0.606 nohead linestyle 10
set arrow 9 from 0.62, 0.6928 to 0.40, 0.693 nohead linestyle 10
set arrow 10 from 0.57, 0.7794 to 0.45, 0.779 nohead linestyle 10

set label '0.1' at 0.99, 0.0866 textcolor rgb C1 font "Arial, 9"
set label '0.2' at 0.94, 0.1732 textcolor rgb C1 font "Arial, 9"
set label '0.3' at 0.89, 0.2598 textcolor rgb C1 font "Arial, 9"
set label '0.4' at 0.84, 0.3464 textcolor rgb C1 font "Arial, 9"
set label '0.5' at 0.79, 0.4330 textcolor rgb C1 font "Arial, 9"
set label '0.6' at 0.74, 0.5196 textcolor rgb C1 font "Arial, 9"
set label '0.7' at 0.69, 0.6062 textcolor rgb C1 font "Arial, 9"
set label '0.8' at 0.64, 0.6928 textcolor rgb C1 font "Arial, 9"
set label '0.9' at 0.59, 0.7794 textcolor rgb C1 font "Arial, 9"

# z
set arrow 11 from 1, 0 to 0.50, 0.866 nohead linestyle 2
set arrow 12 from 0.04, 0.1039 to 0.1,0 nohead linestyle 20
set arrow 13 from 0.09, 0.1905 to 0.2,0 nohead linestyle 20
set arrow 14 from 0.14, 0.2771 to 0.3,0 nohead linestyle 20
set arrow 15 from 0.19, 0.3637 to 0.4,0 nohead linestyle 20
set arrow 16 from 0.24, 0.4503 to 0.5,0 nohead linestyle 20
set arrow 17 from 0.29, 0.5369 to 0.6,0 nohead linestyle 20
set arrow 18 from 0.34, 0.6235 to 0.7,0 nohead linestyle 20
set arrow 19 from 0.39, 0.7101 to 0.8,0 nohead linestyle 20
set arrow 20 from 0.44, 0.7967 to 0.9,0 nohead linestyle 20

set label '0.9' at 0.01, 0.1559 textcolor rgb C2 font "Arial, 9" rotate by -60
set label '0.8' at 0.06, 0.2425 textcolor rgb C2 font "Arial, 9" rotate by -60
set label '0.7' at 0.11, 0.3291 textcolor rgb C2 font "Arial, 9" rotate by -60
set label '0.6' at 0.16, 0.4157 textcolor rgb C2 font "Arial, 9" rotate by -60
set label '0.5' at 0.21, 0.5023 textcolor rgb C2 font "Arial, 9" rotate by -60
set label '0.4' at 0.26, 0.5889 textcolor rgb C2 font "Arial, 9" rotate by -60
set label '0.3' at 0.31, 0.6755 textcolor rgb C2 font "Arial, 9" rotate by -60
set label '0.2' at 0.36, 0.7621 textcolor rgb C2 font "Arial, 9" rotate by -60
set label '0.1' at 0.41, 0.8487 textcolor rgb C2 font "Arial, 9" rotate by -60

# y
set arrow 21 from 0.50, 0.866 to 0,0 nohead linestyle 3
set arrow 22 from 0.09,-0.0173 to 0.55, 0.779 nohead linestyle 30 
set arrow 23 from 0.19,-0.0173 to 0.60, 0.693 nohead linestyle 30
set arrow 24 from 0.29,-0.0173 to 0.65, 0.606 nohead linestyle 30
set arrow 25 from 0.39,-0.0173 to 0.70, 0.520 nohead linestyle 30
set arrow 26 from 0.49,-0.0173 to 0.75, 0.433 nohead linestyle 30
set arrow 27 from 0.59,-0.0173 to 0.80, 0.346 nohead linestyle 30
set arrow 28 from 0.69,-0.0173 to 0.85, 0.260 nohead linestyle 30
set arrow 29 from 0.79,-0.0173 to 0.90, 0.173 nohead linestyle 30
set arrow 30 from 0.89,-0.0173 to 0.95, 0.0866 nohead linestyle 30


set label '0.9' at 0.86, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60
set label '0.8' at 0.76, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60
set label '0.7' at 0.66, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60
set label '0.6' at 0.56, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60
set label '0.5' at 0.46, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60
set label '0.4' at 0.36, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60
set label '0.3' at 0.26, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60
set label '0.2' at 0.16, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60
set label '0.1' at 0.06, -0.0693 textcolor rgb C3 font "Arial, 9" rotate by 60

plot "Template_data.txt"

在此处输入图像描述


推荐阅读