Menu

#725 Option to treat invalid data values as missing values

Version 6
closed-accepted
nobody
None
5
2025-07-21
2016-01-30
No

I propose a flag to have gnuplot treat invalid data (like 1/0) to be treated as missing data values. That would allow doing simple filtering to skip points inside of gnuplot's using statement and still have the data plotted with lines:

set datafile undefined_as_missing
set xrange [0:10]
set samples 101
plot '+' using 1:(y=-($1-5)**2, y < -5 ? y : 1/0) with lines

I know, that the option name is quite bad, but shows what I intend. In case this patch gets accepted, I would include the respective option name to show.c and the docs.

2 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2016-01-30

    I'll have to think about this one. My first inclination is that the intervention is in the wrong place. Wouldn't this simpler patch be sufficient?

    --- gnuplot/src/plot2d.c        2016-01-28 19:40:51.617746646 -0800
    +++ gnuplot-cvs/src/plot2d.c    2016-01-30 09:59:34.412535734 -0800
    @@ -649,7 +649,10 @@ get_data(struct curve_points *current_pl
             */
            if (j == DF_UNDEFINED) {
                current_plot->points[i].type = UNDEFINED;
    
    -           j = df_no_use_specs;
    +           if (missing_val && !strcmp(missing_val, "NaN"))
    +               j = DF_MISSING;
    +           else
    +               j = df_no_use_specs;
            }
    
            if (j > 0) {
    
     
  • Ethan Merritt

    Ethan Merritt - 2016-01-31

    Is there any case when one might want to distinguish between "undefined" in x (column ), y (column 2), or some other value (columns 3 and up)? All three cases currently return DF_UNDEFINED from df_readline() but the caller could inspect the values that were returned to see which one[s] are the cause.

    I'm vaguely thinking you might want to distinguish between undefined x (no data point was measured; i.e. "missing") and undefined y (data point was measured but gave some weird value; i.e. not "missing").

     
  • Ethan Merritt

    Ethan Merritt - 2017-01-21
    • status: open --> closed-accepted
     
  • Ethan Merritt

    Ethan Merritt - 2017-01-21

    Add a variant of this to CVS for 5.0 5.1 that uses the syntax
    set datafile missing NaN
    or
    set datafile missing "NaN"

     

Log in to post a comment.

MongoDB Logo MongoDB