Gnuplot: skip missing columns
I am drawing something like (gnuplot 4.6rc1):
plot "data1.csv" using "time":"value_a", \
"data2.csv" using "time":"value_b", \
"data3.csv" using "time":"value_c"
The presence of csv files, for example:
time, value_a, value_c
0, 1, 2
4, 5, 6
If one column is missing (say value_b
), the entire graph will not be generated with an error could not find column with header "value_b"
.
Is there a way to just skip plotting that column and not skip the whole plot?
source to share
You can use the following data file:
time, value_a, value_c, value_b
0, 1, 2
4, 5, 6
Note that the column value_b
has a header, but it does not require any data points. GNUplot will find the column and be happy, but since there is no data, it will not be displayed. Since header generation occurs only once in each output file, we hope to add all the column names easily enough.
I don't know of a solution that allows you to omit the column completely. But ... another way to plot your data:
plot "data1.csv" using "time":"value_a"
replot "data2.csv" using "time":"value_b"
replot "data3.csv" using "time":"value_c"
So, if you can keep track of which columns you are printing, then you can build the plot file that way.
And if that is not possible, then your problem is for GNUplot to continue with the next line if there is an error. Unfortunately I am not sure how to do this.
source to share