next up previous contents index
Next: Set datafile separator Up: Datafile Previous: Set datafile nofpe_trap   Contents   Index

Set datafile missing

Syntax:
     set datafile missing "<string>"
     set datafile missing NaN
     show datafile missing
     unset datafile

The set datafile missing command tells gnuplot there is a special string used in input data files to denote a missing data entry. There is no default character for missing. Gnuplot makes a distinction between missing data and invalid data (e.g. "NaN", 1/0.). For example invalid data causes a gap in a line drawn through sequential data points; missing data does not.

Non-numeric characters found in a numeric field will usually be interpreted as invalid rather than as a missing data point unless they happen to match the missing string.

Conversely set datafile missing NaN causes all data or expressions evaluating to not-a-number (NaN) to be treated as missing data.

Note: The treatment of missing or invalid data values in certain cases has changed in this version of gnuplot. The example below shows differences between gnuplot version 4 and version 5. [r][rt][width=3in,keepaspectratio]figure_missing Example:

     set style data linespoints
     plot '-' title "(a)"
        1 10
        2 20
        3 ?
        4 40
        5 50
        e
     set datafile missing "?"
     plot '-' title "(b)"
        1 10
        2 20
        3 ?
        4 40
        5 50
        e
     plot '-' using 1:2 title "(c)"
        1 10
        2 20
        3 NaN
        4 40
        5 50
        e
     plot '-' using 1:($2) title "(d)"
        1 10
        2 20
        3 NaN
        4 40
        5 50
        e

Plot (a) differs in gnuplot 4 and gnuplot 5 because the third line contains only one valid number. Version 4 switched to a single-datum-on-a-line convention that the line number is "x" and the datum is "y", erroneously placing the point at(2,3).

Both the old and new gnuplot versions handle the same data correctly if the '?' character is designated as a marker for missing data (b).

Old gnuplot versions handled NaN differently depending of the form of the using clause, as shown in plots (c) and (d). Gnuplot now handles NaN the same whether the input column was specified as N or ($N). See also the

http://www.gnuplot.info/demo/mgr.htmlimageNaN demo.

As of version 5.0.6 this is also true for the missing value flag. Earlier versions failed to recognize the missing value flag if the plot command specified using ($N) rather than using N. Note, however, that even in current gnuplot using a "missing" value for computation will result in NaN. I.e. a missing string in either columns 1 or 2 will cause using ($1+$2) to evaluate as NaN. If you nevertheless want to treat this as missing data, use the command set datafile missing NaN.


next up previous contents index
Next: Set datafile separator Up: Datafile Previous: Set datafile nofpe_trap   Contents   Index
2018-08-13