Search code examples
gnuplot

Is there a way to plot to a table without R characters (that is, "i", "o" or "u") in gnuplot?


Is there a way to plot to a table without R characters (that is, "i", "o" or "u") in gnuplot for windows?

I was trying to sort a file whose name is FILE:

set format y ""
set table $Data
plot FILE  u 1:2:1 smooth zsort
unset table

expecting to get rid of the "i" after each line thanks to the set format y ""; but when printing $Data I got them all again. For multicolumn files, you get a column of those characters after each column of numbers.


Solution

  • For plotting to a datablock/table and avoiding an extra column of i, o or u, you have the plotting style with table (check help with table). However, smooth and with table will not work together. So, you need a two step process.

    Data: SO78337085.dat

    4   4.1
    3   3.1
    7   7.1
    1   1.1
    9   9.1
    6   6.1
    5   5.1
    2   2.1
    8   8.1
    

    Script: (requires gnuplot>=5.4.0, because of smooth zsort)

    ### sort data without extra header and range column
    reset session
    
    FILE = "SO78337085.dat"
    set table $Data
        plot FILE u 1:2:1 smooth zsort
    unset table
    print $Data
    
    set table $Data2
        plot $Data u 1:2 w table
    unset table
    print $Data2
    ### end of script
    

    Result:

    # Curve 0 of 1, 9 points
    # Curve title: "FILE u 1:2:1"
    # x y type
     1  1.1  i
     2  2.1  i
     3  3.1  i
     4  4.1  i
     5  5.1  i
     6  6.1  i
     7  7.1  i
     8  8.1  i
     9  9.1  i
    
    
     1       1.1
     2       2.1
     3       3.1
     4       4.1
     5       5.1
     6       6.1
     7       7.1
     8       8.1
     9       9.1