-->

gnuplot的filledcurves调色板(Gnuplot filledcurves with

2019-07-04 01:41发布

我一直在试图改变在gnuplot的的filledcurves选项的填充样式,使填充颜色代表了一个2维图表两条曲线之间的差异。 我想到的这个作为的延伸“filledcurves上方/下方”选项,由此而不是仅具有高于或低于代表有一个色彩范围或调色板两种颜色。

下面是我想从使用上/下充满曲线式的数据文件,使情节的例子。 代表两个曲线之间的y差A colourbar将是非常有用的。

我试图通过添加第四列的使用命令,即要做到这一点

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

filledcurves似乎并不接受第四列...我也考虑过尝试RGB变量,但这似乎并没有任何工作。

Answer 1:

我玩弄了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'

这给出了这样的结果:

我还没有提交的补丁,但是,因为我不知道我是否正确,因为我不知道我是否涵盖所有情况了解的问题。 所以一些微调可能需要。



Answer 2:

尝试使用实心直方图。

set style fill solid 1.0
plot \
 datafile u 1:2:3 lt palette w boxes,\
 datafile u 1:2:3 lt palette lw 2 w l

塔3根据调色板设置,将列1和2定义的数据点定义的颜色填充颜色。 您还可以使用的背景颜色直方图下图清除部分。

我想补充的图像,但我不能因为低信誉的。



Answer 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

输出看起来是这样的:

数据文件包含这些虚拟值(类似于你的第二个图):

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


文章来源: Gnuplot filledcurves with palette