gpt4 book ai didi

plot - 带调色板的 Gnuplot 填充曲线

转载 作者:行者123 更新时间:2023-12-02 00:08:17 25 4
gpt4 key购买 nike

我一直在尝试更改 gnuplot 中 fillcurves 选项的填充样式,以便填充颜色代表二维绘图上两条曲线之间的差异。我认为这是“上方/下方填充曲线”选项的扩展,其中不仅仅是代表上方或下方的两种颜色,还有一个颜色范围或调色板。

这是我想使用上方/下方填充曲线样式从数据文件制作的绘图示例。代表两条曲线之间 y 差异的颜色条将非常有用。

/image/RLlpU.png

我尝试通过向 using 命令添加第四列来实现此目的,即

plot 'data.txt' using 1:2:3:($3-$2) with filledcurves fs palette

filledcurves 似乎不接受第四列...我也考虑过尝试 rgb 变量,但这似乎也不起作用。

最佳答案

我正在研究 gnuplot 的补丁,以允许使用 linecolor rgb 变量 来填充曲线。然后可以使用以下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'

这给出了这个结果: enter image description here

我还没有提交补丁,因为我不知道我是否正确理解了这个问题,并且因为我不知道我是否涵盖了所有情况。因此可能需要进行一些微调。

关于plot - 带调色板的 Gnuplot 填充曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13513791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com