Menu

#2889 Set Table ignores user defined separator for output data

None
open
nobody
None
1 day ago
3 days ago
No

Hey,

set table generally uses spaces as separator rather then the currently active one (defined via "set datafile separator .."). Is this indented behaviour or a bug?

This leads to a problem, if I want to smooth some data prior to plotting and then still access the data in the table via the $-operator. The following example will not work:

set datafile separator tab
$data << EOD
0   0   0
1   NaN 1
2       2
EOD

set table $smooth_data
    plot $data u 1:3 smooth unique
unset table

plot $data u 1:3, \
    $smooth_data u 1:2  # same with: u ($1):($2)

but produces the error: '"plot.plt" line 30: warning: Skipping data file with no valid points'
The table option "separator tab" only work in combination with the plot option "with table", which itself ignores filters and smoothing options.

Explicitly specifying the data structure via a format string works:

plot $smooth_data u ($1):($2) "%lf %lf"

but ideally would not be necessary (in my opinion).

Thanks,
Alex

Discussion

  • Alexander Stangl

    • summary: Incompatibility of tab separators + table + smoothing --> Set Table ignores user defined separator for output data
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2 days ago

    There are separate commands for input and output.

    The command "set datafile separator tab" explicitly only affects input data files. It does not change the output from either "set table" or "plot with table".

    The command "set table separator tab" is the one you want for changing output from "plot with table".

    You are correct that neither of these affects the output from a normal "plot" command. But I am not following exactly what problem you are trying to solve. The example you give works fine if you simply omit the "separator tab" in the initial command, since the default is to separate on whitespace and tabs count as whitespace. Is the issue that your true input data file contains tab-separated fields where the individual fields may themselves contain whitespace? In that case, would the following sequence work for you?

    set datafile separator tab
    set table $raw_data
        plot $data u 1:3
    unset table
    set table $smooth_data
        plot $data u 1:3 smooth unique
    unset table
    
    set datafile separator whitespace
    plot $raw_data with points, $smooth_data with lines
    
     
  • Alexander Stangl

    Yes, I have whitespace within the data, a better example would have been this one ;)

    $data << EOD
    0   A 1 0
    1   A2  1
    2   g 2 2
    EOD
    

    Yes, your example also works, but still it would be more convenient if set table uses the input separator if not specified otherwise (e.g. for csv output). Is there a reason, why set table needs to use the whitespace seperator in general?

     

Log in to post a comment.