2012-11-22 70 views
12

我一直在尝试改变gnuplot中的filledcurves选项的填充样式,以便填充颜色代表2维曲线上两条曲线之间的差异。我正在考虑将此作为'filledcurves above/below'选项的扩展,而不是只有两种颜色代表上面或下面的颜色范围或调色板。Gnuplot与调色板的填充曲线

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

http://i.stack.imgur.com/RLlpU.png

我曾尝试即

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

filledcurves增加了第四个栏的用命令来做到这一点似乎并不接受第四列...我也考虑尝试rgb变量,但这似乎并没有工作。

+2

这看起来像一个功能请求的工作(http://sourceforge.net/tracker/?group_id=2055&atid=352055);我不认为gnuplot可以做你想要的东西。在实施之前,您可能会考虑将热状态和冷状态光谱之间的差异绘制为图上的单独一行。 (这可能会更好地复制印刷品,并且对色盲更容易理解) – andyras

+0

我还没有足够的想法,但是您可能可以通过组合'set view map ','splot'和'pm3d' ... – mgilson

+0

这看起来像你在找什么。 http://gnuplot-tricks.blogspot.com/2009/08/filled-curves-in-gnuplot.html –

回答

-2

诀窍是画线,然后用filledcurves填充它们。以下是如何做到这一点(基于examples at 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 

输出看起来是这样的: enter image description here

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

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 
4

我正在玩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' 

这给了这样的结果: enter image description here

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

+0

那么补丁怎么样?你上传了什么地方?它可用吗? – rgcalsaverini

+0

@rgcalsaverini不,我没有上传它。我写了它的乐趣,但因为我不需要这样的图形,我不知道这是否是正确的方法,如果我错过了一些东西......并且因为我从来没有得到任何反馈,所以我第一次初步实施就停止了。 – Christoph

+1

不错的补丁!这个解决方案至少应该和问题一样多! ;) –

0

尝试使用填充直方图。

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列定义了数据点。您也可以使用背景颜色直方图清除图形下方的部分。

我想添加图片,但我不能因为低信誉。