gnuplot-”的缩写;自动标题栏“Columnhead”;键和数据文件,带有#&引用;

gnuplot-”的缩写;自动标题栏“Columnhead”;键和数据文件,带有#&引用;,plot,gnuplot,Plot,Gnuplot,我需要你的帮助。现在,我用这个小脚本来绘制下面的数据 问题是,由于注释字符“#”,gnuplot无法识别标题行。我不能简单地删除字符,因为这是每10秒覆盖一次的“实时数据” 所以,我的问题是:如何使用带有注释掉的标题行的自动文件 谢谢 #!/usr/bin/gnuplot set terminal pdf set output "./postProcessing/residuals/residuals.pdf" datafile = "./postProcessing/residuals/0/

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

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

所以,我的问题是:如何使用带有注释掉的标题行的自动文件

谢谢

#!/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   
# 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

你很接近。set datafile commentschars“%”是切换到其他注释字符的正确方法。但是,在您的情况下,文件中的第一行和第二行都以#开头。您希望它跳过第1行并使用第2行,但不能再根据主角执行此操作。因此,您必须明确跳过。此外,由于第2行开头的#不再是注释指示符,因此它将被解释为列标题。因此,您需要将标题移动一列。所以你的新命令是

plot for [col=2:7] datafile skip 1 using 1:col with lines title columnheader(col+1)
我忘了“跳过命令”-非常感谢,祝你周末愉快。