Time 将颜色渐变与Gnuplot中的数据匹配

Time 将颜色渐变与Gnuplot中的数据匹配,time,plot,colors,gnuplot,gradient,Time,Plot,Colors,Gnuplot,Gradient,我有显示随时间变化的数据,我使用Gnuplot 4.6生成了以下绘图: 在这里,我手动定义了11种线条样式,随着“时间”的推移,颜色逐渐从红色(#ff0000)更改为深红色(#5f0000)。以下是我的意见: # svg set terminal svg size 600,600 fname 'CMU Sans Serif' fsize '10' set output 'plot.svg' # color definitions set style line 1 lc rgb '#ff000

我有显示随时间变化的数据,我使用Gnuplot 4.6生成了以下绘图:

在这里,我手动定义了11种线条样式,随着“时间”的推移,颜色逐渐从红色(#ff0000)更改为深红色(#5f0000)。以下是我的意见:

# svg
set terminal svg size 600,600 fname 'CMU Sans Serif' fsize '10'
set output 'plot.svg'

# color definitions
set style line 1 lc rgb '#ff0000' lt 1 lw 2 pt 7 # starting light red
set style line 2 lc rgb '#ef0000' lt 1 lw 2 pt 7 
set style line 3 lc rgb '#df0000' lt 1 lw 2 pt 7
set style line 4 lc rgb '#cf0000' lt 1 lw 2 pt 7
set style line 5 lc rgb '#bf0000' lt 1 lw 2 pt 7
set style line 6 lc rgb '#af0000' lt 1 lw 2 pt 7
set style line 7 lc rgb '#9f0000' lt 1 lw 2 pt 7
set style line 8 lc rgb '#8f0000' lt 1 lw 2 pt 7
set style line 9 lc rgb '#7f0000' lt 1 lw 2 pt 7
set style line 10 lc rgb '#6f0000' lt 1 lw 2 pt 7
set style line 11 lc rgb '#5f0000' lt 1 lw 2 pt 7

# visual elements
unset key
set xlabel 'x Axis'
set ylabel 'y Axis'

# plot data
plot for [n=2:11] 'data.dat' using 1:n with lines ls (n-1)

有没有更简单的方法让Gnuplot在绘制多行时逐渐改变颜色?理想情况下,我希望有一个脚本,可以根据“data.dat”文件中的数据量处理任意数量的颜色渐变。

例如,您可以使用一个函数,根据迭代计数器计算颜色

# values r, g, b, x must be in the range [0:1]
rgb(r,g,b) = (255*r*256**2 + 255*g*256 + 255*b) 
grad(x) = rgb(1 - x*0.7)
set style data lines
plot for [n=2:11] 'data.dat' using 1:2 lc rgb grad((n-2)/9.0)
或者,可以定义渐变并为每条线选择分数位置

set palette defined (0 '#5f0000', 1 '#ff0000')
set style data lines
plot for [n=2:11] 'data.dat' using 1:2 lc palette frac (n-2)/9.0