根据特定调色板在Gnuplot中改变填充颜色

根据特定调色板在Gnuplot中改变填充颜色,gnuplot,fill,Gnuplot,Fill,我想用Gnuplot填充一些闭合曲线。这就是我目前得到的结果 不错。我使用了以下代码: plot \ 'fort.40' u 1:2 smooth bezier w filledcurves lt 1 lc 4 lw 3 t 't=100 s' ,\ 'fort.30' u 1:2 smooth bezier w filledcurves lt 1 lc 3 lw 3 t 't=20 s' ,\ 'fort.20' u 1:2 smooth bezier w filledcurves lt 1

我想用Gnuplot填充一些闭合曲线。这就是我目前得到的结果

不错。我使用了以下代码:

plot \
'fort.40' u 1:2 smooth bezier w filledcurves lt 1 lc 4 lw 3 t 't=100 s' ,\
'fort.30' u 1:2 smooth bezier w filledcurves lt 1 lc 3 lw 3 t 't=20 s' ,\
'fort.20' u 1:2 smooth bezier w filledcurves lt 1 lc 2 lw 3 t 't=1 s' ,\
'fort.10' u 1:2 smooth bezier w filledcurves lt 1 lc 1 lw 3 t 't=0'
然而,我真正想要的是画出100条这样的曲线(对于物理学家来说,我想要的是说明一个圆在相空间中的时间演化,就像一个双摆)。每条闭合曲线存储为两列,曲线坐标位于不同的ASCII文件中。正如你所看到的,我已经通过手工设置四种不同的填充颜色实现了上面的数字。但现在我想概括一下,它有一个平稳过渡的颜色,遵循一定的调色板。这个想法是,颜色暗示了数字中隐含的第三维度:时间

你知道有没有可能使用一种符合特定调色板的填充颜色,而不是固定的颜色?在最坏的情况下,我可以定义100种填充样式(我在shell脚本中创建代码,因此自动化过程相对容易),但我仍然不知道是否可以根据调色板指定颜色,而不是手动指定颜色

编辑:感谢@Christoph的出色回答,这是最终输出。我把它放在这里只是为了说明Gnuplot的强大功能


填充曲线的打印样式不支持
lc调色板
lc[rgb]变量
,这是用于为线条着色的

对于
填充曲线
可以使用
lc调色板分形
,其中
是范围
[0:1]
中的一个数字,该范围指定当前调色板中的分数位置,颜色取自该位置。这要求您知道正在打印的文件数:

set style fill solid noborder
plot \
'fort.40' u 1:2 smooth bezier w filledcurves lc palette frac 1 t 't=100 s' ,\
'fort.30' u 1:2 smooth bezier w filledcurves lc palette frac 0.6667 t 't=20 s' ,\
'fort.20' u 1:2 smooth bezier w filledcurves lc palette frac 0.3333 t 't=1 s' ,\
'fort.10' u 1:2 smooth bezier w filledcurves lc palette frac 0 t 't=0'
迭代您可以使用的文件

files = 'fort.40 fort.30 fort.20 fort.10'
times = '100     20      1       0'
N = words(files)

set style fill solid noborder
plot for [i=1:words(files)] word(files, i) u 1:2 smooth bezier with filledcurves lc palette frac (N-i)/(N-1.0) t sprintf('t=%s s', word(times, i)

填充曲线
打印样式不支持
lc调色板
lc[rgb]变量
,这是用于为线条着色的

对于
填充曲线
可以使用
lc调色板分形
,其中
是范围
[0:1]
中的一个数字,该范围指定当前调色板中的分数位置,颜色取自该位置。这要求您知道正在打印的文件数:

set style fill solid noborder
plot \
'fort.40' u 1:2 smooth bezier w filledcurves lc palette frac 1 t 't=100 s' ,\
'fort.30' u 1:2 smooth bezier w filledcurves lc palette frac 0.6667 t 't=20 s' ,\
'fort.20' u 1:2 smooth bezier w filledcurves lc palette frac 0.3333 t 't=1 s' ,\
'fort.10' u 1:2 smooth bezier w filledcurves lc palette frac 0 t 't=0'
迭代您可以使用的文件

files = 'fort.40 fort.30 fort.20 fort.10'
times = '100     20      1       0'
N = words(files)

set style fill solid noborder
plot for [i=1:words(files)] word(files, i) u 1:2 smooth bezier with filledcurves lc palette frac (N-i)/(N-1.0) t sprintf('t=%s s', word(times, i)

不仅是一个非常精确的答案,而且我可以学到一些新的东西,你的回答比我写的问题还要快。在将其标记为已回答之前,我会尝试一下,但我非常肯定它会起作用。谢谢。只是出于好奇,我对问题进行了编辑,添加了最终输出。我希望这不违反网络规则。非常整洁,虽然阴影有丑陋的人工制品,我想删除。但我想这是另一个问题的主题。不仅是一个非常精确的答案,而且我可以学到一些新的东西,你的回答比我写的问题还要快。在将其标记为已回答之前,我会尝试一下,但我非常肯定它会起作用。谢谢。只是出于好奇,我对问题进行了编辑,添加了最终输出。我希望这不违反网络规则。非常整洁,虽然阴影有丑陋的人工制品,我想删除。但我想这是另一个问题的主题。