ats*_*ack 12 plot gnuplot palette
我一直在尝试更改gnuplot中filledcurves选项的fillstyle,以便填充颜色代表二维图上两条曲线之间的差异.我认为这是"上方/下方的填充曲线"选项的扩展,而不是只有两种颜色代表上方或下方,而是有一个颜色范围或调色板.
下面是我想使用上面/下面填充的曲线样式从数据文件中创建的图的示例.表示两条曲线之间的y差异的颜色条将非常有用.

我试图通过在using命令中添加第四列来实现这一点
plot 'data.txt' using 1:2:3:($3-$2) with filledcurves fs palette
Run Code Online (Sandbox Code Playgroud)
但filledcurves似乎没有接受第四列...我也考虑过尝试rgb变量,但这似乎也不起作用.
我正在玩gnuplot的补丁,以允许使用linecolor rgb variable填充曲线.然后可以使用以下gnuplot代码:
max_color=1
# for a datafile one could extract the maximum diffference with e.g.
# stats 'hotcold.dat' using 1:($3-$2)
# max_color = (abs(STATS_min_y) > abs(STATS_max_y)) ? abs(STATS_min_y) : abs(STATS_max_y)
red(val) = (val < 0 ? abs(1+val/max_color) : 1)
green(val) = (1 - abs(val)/max_color)
blue(val) = red(-val)
rgb(val) = 65536*int(255*red(val)) + 256*int(255*green(val)) + int(255*blue(val))
set yrange[0:1]
set xrange[400:2500]
set samples 200
fhot(x) = 0.1*exp(-((x-400)/200)**2) + 0.8*exp(-((x-2000)/300)**2)
fcold(x) = 0.25*exp(-((x-700)/100)**6)+ 0.4 - (2e-4*(x-2500))**2
plot '+' using 1:(fhot($1)):(fcold($1)):(rgb(fhot($1)-fcold($1))) with filledcurves lc rgb var t '',\
'' using 1:(fhot($1)) with lines lw 4 lc rgb rgb(max_color) t 'Hot',\
'' using 1:(fcold($1)) with lines lw 4 lc rgb rgb(-max_color) t 'Cold'
Run Code Online (Sandbox Code Playgroud)
这给出了这个结果:

我还没有提交补丁,因为我不知道我是否正确理解了这个问题,因为我不知道是否涵盖了所有案例.因此可能需要进行一些微调.
Yeh*_*hia -3
诀窍是绘制线条,然后用 填充线条filledcurves。以下是具体操作方法(基于gnuplot 中的示例):
set style line 2 lc rgb 'forest-green'
set style line 3 lc rgb 'plum'
set style fill pattern 5 lc 'yellow'
set xrange [0:3000]
set yrange [0:1]
plot 'data.txt' u 1:2:3 w filledcurves notitle, \
'' u 1:2 ls 2 with lines notitle, \
'' u 1:3 ls 3 with lines notitle
Run Code Online (Sandbox Code Playgroud)
输出如下所示:

数据文件包含这些虚拟值(类似于您的第二个图表):
500 0.90 0.90
1000 0.90 0.75
1500 0.92 0.40
2000 0.95 0.30
2500 0.94 0.23
Run Code Online (Sandbox Code Playgroud)