问题
date daily weekly monthly
1 11 88
2 12
3 45 44
4 54
5 45
6 45 66
7 77
8 78
9 71 99 88
For empty data points in weekly column , the plot is ploting values from monthly column. Monthly column plot and daily column plot are perfect. suggest something more than set datafile missing ' ' and set datafile separator "\t"
回答1:
Alas, Gnuplot doesn't support field based data files, the only current solution is is to preprocess the file. awk
is well suited for the task (note if the file contains hard tabs you need to adjust FIELDWIDTHS
):
awk '$3 ~ /^ *$/ { $3 = "?" } $4 ~ /^ *$/ { $4 = "?" } 1' FIELDWIDTHS='6 7 8 7' infile > outfile
This replaces empty fields (/^ *$/
) in column 3 and 4 with question marks, which means undefined to Gnuplot. The 1
at the end of the awk script invokes the default rule: { print $0 }
.
If you send awk's output to outfile
, you can for example now plot the file like this:
set key autotitle columnhead out
set style data linespoint
plot 'outfile' using 1:2, '' using 1:3, '' using 1:4
回答2:
If anyone runs into this, I recommend updating to at least the 4.6.5 Gnuplot version.
This is because from Gnuplot 4.6.4 update: * CHANGE treat empty fields in a csv file as "missing" rather than "bad"
And there seemed to be a (related?) bugfix in 4.6.5: * FIX empty first field in a tab-separated-values file was incorrectly ignored
来源:https://stackoverflow.com/questions/16317380/column-with-empty-datapoints