用gnuplot

时间:2016-10-05 16:05:13

标签: colors gnuplot line

使用gnuplot我想绘制一个数据集,信号与时间(让我们说一个色谱图)用不同颜色的曲线选定区域(让我们说峰值)但我不是确定是否可能。 到目前为止我尝试过的是:

plot [2:4.6] [0:100] 'data.csv' using 1:2 with lines lt 1,\
[4.6:4.7] [0:100] 'data.csv' using 1:2 with lines lt 2,\
[4.7:6] [0:100] 'data.csv' using 1:2 with lines lt 3

但它似乎不起作用,因为我只得到了无效的表达式'消息。

2 个答案:

答案 0 :(得分:1)

使用linecolor variable动态指定从哪种线型获取颜色:

lt(x) = (x >= 4.7 ? 3 : (x >= 4.6 ? 2 : 1))
plot 'data.csv' using 1:2:(lt($1)) linecolor variable

答案 1 :(得分:0)

尽管Christoph回答提出的方法对于有限数量的颜色变化是有益的,但在我的情况下设置可能是漫长而复杂的,因为我的真实数据集将具有许多峰值和许多颜色变化。

我找到了一个更好的基于这个问题的gnuplot: yerrorbars with linecolor variable,它只是使用第三列(可以简单地使用电子表格添加)来设置每个数据点的颜色和gnuplot代码: / p>

plot [2:6] [0:100] 'data.csv' using 1:2:3 linecolor variable with lines notitle