I need your help with gnuplot. Right now, I use this little script, to plot the data below.
The problem is, that gnuplot doesn't recognize the header line because of the comment char '#'. I can not simply remove the char, because this is "live data" that is overwritten every 10 sec.
So, my question is: How can I use autotitle with a commented out header line?
Thanks.
#!/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
You are very close. set datafile commentschars "%" is the correct way to switch to a different comment character. However in your case both the first and second line in the file start with #. You want it to skip line 1 and use line 2 and can no longer do this on the basis of the leading character. So instead you must make the skip explicit. Furthermore, since the # at the start of line 2 is no longer a comment indicator then it will be interpreted as a column header. So you need to shift the titles by one column. So your new command is
plot for [col=2:7] datafile skip 1 using 1:col with lines title columnheader(col+1)