Gnuplot用调色板填充曲线 [英] Gnuplot filledcurves with palette

查看:264
本文介绍了Gnuplot用调色板填充曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试为gnuplot中的filledcurves选项更改fillstyle,以便填充颜色代表二维图上两条曲线之间的差异.我认为这是上方/下方填充曲线"选项的扩展,通过该选项,不仅可以使用两种颜色来表示上方或下方,还可以使用颜色范围或调色板.

I have been trying to change the fillstyle for the filledcurves option in gnuplot so that the fill colour represents the difference between the two curves on a 2-dimensional plot. I am thinking of this as an extension of the 'filledcurves above/below' option whereby instead of just having two colours representing above or below there is a colour range or palette.

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

Here is an example of the plot I would like to make from a datafile using the above/below filled curve style. A colourbar representing the y-difference between the two curves would be very useful.

我试图通过在using命令中添加第四列来实现此目的.

I have tried to do this by adding a fourth column to the using command i.e.

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

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

but the filledcurves does not appear to accept the fourth column... I have also considered trying rgb variable but this doesn't seem to work either.

推荐答案

我正在研究gnuplot的补丁,以允许使用linecolor rgb variable填充曲线.然后可以使用以下gnuplot代码:

I am playing around with a patch for gnuplot to allow using linecolor rgb variable for filled curves. Then the following gnuplot code can be used:

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'

得出以下结果:

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

I haven't submitted the patch, yet, because I don't know if I understood the question correctly and because I don't know if I covered all cases. So some fine-tuning may be required.

这篇关于Gnuplot用调色板填充曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆