It is not possible to use regexp to set datafile missing
, but you can use any program to filter your data before plotting and replacing the regular expression with one character, for example. ?
that you set to mark the missing data point.
Here is an example that does 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 script drawing might look like this:
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 result:

Thus, the plot command skips all missing data points. Can you refine the sed
filter to replace any non-numerical values ββwith ?
if this option is not enough.
This works fine, but only columns can be selected, for example. with using 1:2
, but does not perform calculations on columns, for example, for example. using ($1*0.1):2
. To allow this, you can filter out any line containing nan
, -inf
, etc. Using grep
, as done in gnuplot, without expression-evaluated data (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