您缺少的是告诉 gnuplot 将轮廓放在哪里。这是通过set cntrparam levels incr -0.3,0.1,0.5
命令的意思是:从 -0.3 开始,每隔 o.1 追踪一次轮廓,直至 0.5.
AFAIK如果你想让轮廓全黑,你必须将轮廓线保存在临时文件中(这里contour.txt
).
所以你的脚本是
reset
set contour
unset surface
set cntrparam levels incr -0.3,0.1,0.5
set view map
set xrange [0:30]
set yrange [0:30]
set dgrid3d 100,100,4
set table "contour.txt"
splot 'test.txt'
unset table
unset contour
set surface
set table "dgrid.txt"
splot 'test.txt'
unset table
reset
set pm3d map
unset key
set palette defined (0 '#352a87', 1 '#0363e1',2 '#1485d4', 3 '#06a7c6', 4 '#38b99e', 5 '#92bf73', 6 '#d9ba56', 7 '#fcce2e', 8 '#f9fb0e')
set autoscale fix
set grid
splot 'dgrid.txt' w pm3d, 'contour.txt' w l lc rgb "black"
这给了你这个:
Note:
你可以摆脱插值文件(dgrid.txt
)如果您通过在每行(即每 30 个数据点)后留下一个空行来格式化您的数据文件,因为它们已经是网格排序的。
这也可以通过awk
脚本。但我又懒得去研究了...
其余部分将保持不变并按预期工作。
它应该是这样的:
在这种情况下,脚本将简单地变为:
set pm3d map impl
set contour
set style increment user
do for [i=1:18] { set style line i lc rgb "black"}
set cntrparam levels incr -0.3,0.1,0.5
set palette defined (0 '#352a87', 1 '#0363e1',2 '#1485d4', 3 '#06a7c6', 4 '#38b99e', 5 '#92bf73', 6 '#d9ba56', 7 '#fcce2e', 8 '#f9fb0e')
set autoscale fix
splot 'test.txt' w pm3d notitle
不需要中间文件并且具有更好的轮廓,因为数据不通过网格插值: