3
votes

I plot something like (gnuplot 4.6rc1):

plot "data1.csv" using "time":"value_a", \
     "data2.csv" using "time":"value_b", \
     "data3.csv" using "time":"value_c"

Having csv files like:

time, value_a, value_c
0, 1, 2
4, 5, 6

If one column is missing (say value_b) the whole plot will not be produced with error could not find column with header "value_b".

Is there a way to just skip plotting this column, instead of skipping the whole plot?

1
Can you not set these values to some arbitrary char and then use set missing? - Azrael3000
The problem is not with missing values, but with missing columns (as for example in 2-line csv above where there is no value_b column). - Vladimir Keleshev
Yes I see that, but could you not just place a whole column with missing values? - Azrael3000
No, it is very preferable that the file does not change, otherwise this question would not exist. - Vladimir Keleshev
Okay fair enough. The only solution I can think of would be a pre-processing program that reads the files. If the column does not exist it appends missing values and then pipes the output to gnuplot. But maybe there is somebody who knows something else. - Azrael3000

1 Answers

0
votes

You can use the following data file:

time, value_a, value_c, value_b
0, 1, 2
4, 5, 6

Notice that the value_b column 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 plotted. Since header generation only occurs once per output file it is hopefully easy enough to add all the column names.

I don't know of a solution which allow you to omit the column entirely. But... another way to plot your data is with:

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 out, then you can build the plot file in this way.

And, if that isn't possible, then your problem is now reduced to getting GNUplot to continue to the next line if there's an error. Sadly, I'm not sure how to make it do that.