It is not possible to use a regexp for set datafile missing
, but you can use any program to filter you data before plotting, and replacing a regexp with one character, e.g. ?
which you set to mark a missing data point.
Here is an example which accomplishes, what you originally requested: filtering -nan
, inf
etc. For testing, I used the following data file:
1 0
2 nan
3 -inf
4 2
5 -NaN
6 1
And the plotting script may look like the following:
filter = 'sed -e "s/-\?\(nan\|inf\)/?/ig"'
set datafile missing "?"
set offset 0.5,0.5,0.5,0.5
plot '< '.filter.' data.txt' with linespoints ps 2 notitle
This gives the following output:
So the plot command skips all missing data points. You can refine the sed
filter to replace any non-numerical values with ?
, if this variant is not enough.
This works fine, but allows only to select columns e.g. with using 1:2
, but not doing computations on the columns, like e.g. using ($1*0.1):2
. To allow this, you can filter out any row, which contains nan
, -inf
etc with grep
, like its done in gnuplot missing data with expression evaluation (thanks @Thiru for the link):
filter = 'grep -vi -- "-\?\(nan\|inf\)"'
set offset 0.5,0.5,0.5,0.5
plot '< '.filter.' data.txt' with linespoints ps 2 notitle