gnuplot-“ autotitle coloumnhead”键和带有“#”的数据文件

时间:2018-08-04 15:34:41

标签: plot gnuplot

我需要您的gnuplot帮助。现在,我使用这个小脚本来绘制下面的数据。

问题是,由于注释char'#',gnuplot无法识别标题行。我不能简单地删除字符,因为这是每10秒就会被覆盖的“实时数据”。

所以,我的问题是:如何在标有注释的标题行中使用autotile?

谢谢。

#!/usr/bin/gnuplot

set terminal pdf
set output "./postProcessing/residuals/residuals.pdf"
datafile = "./postProcessing/residuals/0/residuals.dat"
set datafile commentschars "%"
set key autotitle columnhead
set log y
set title "Residuals"
set ylabel ''
set xlabel 'Time'
set format y "%g"
set grid
plot for [col=2:7] datafile using 1:col with lines title columnheader

residuals.dat

# Residuals   
# Time          p               Ux              Uy          
1               1.000000e+00    1.000000e+00    1.000000e+00
2               1.674960e-02    1.083190e-01    5.252060e-01
3               1.248170e-02    2.371500e-01    5.734970e-01
4               1.045440e-02    2.629550e-01    3.115170e-01
5               1.206470e-02    2.247980e-01    2.269900e-01
6               1.593340e-02    1.416050e-01    5.493240e-01
7               5.426080e-02    3.922100e-02    5.199160e-01

1 个答案:

答案 0 :(得分:0)

您非常亲密。设置数据文件commentschars“%”是切换到其他注释字符的正确方法。但是,根据您的情况,文件的第一行和第二行均以#开头。您希望它跳过第1行并使用第2行,并且不能再根据前导字符来执行此操作。因此,您必须使跳过显式。此外,由于第2行开头的#不再是注释指示符,因此它将被解释为列标题。因此,您需要将标题移动一列。所以您的新命令是

plot for [col=2:7] datafile skip 1 using 1:col with lines title columnheader(col+1)