Search code examples
gnuplot

GNUPlot not recognizing "$DATA << EOD" in older versions


I am inputting data into GNUPlot 5.2 patchlevel 8 thus:

$DATA << EOD
0.3 -0.1599804163   53
2   0.1051269323    84
0.4 0.0227271412    87
0.4 0.1050702557    89
... a few thousand lines
EOD

http://www.gnuplotting.org/tag/standard-input/ is not very helpful

but when I use this in GNUPlot 4.6 patchlevel 2 (I cannot update GNUPlot on that server), I get an error:

$DATA << EOD
^
"/tmp/Q22N6GtW6R.gnuplot", line 2: invalid command

when I attempt to update via

sudo yum install gnuplot

I get the error:

Loaded plugins: product-id, search-disabled-repos, subscription-manager
Package gnuplot-4.6.2-3.el7.x86_64 already installed and latest version
Nothing to do

How can I write in data into the gnuplot file (I don't want a separate input file) in a way that is compatible with both GNUPlot 4.6 and 5.2?


Solution

  • @con, what is wrong or not helpful with the link you gave in your question? In gnuplot 4.6 you can use the special filename '-' for inline data. Check help special-filenames.

    Code:

    ### inline data which works for gnuplot 4.6 and 5.x
    reset
    
    plot '-' u 1:2 w lp pt 7 lc rgb "red"
    1   2
    2   3
    3   4
    4   5
    5   6
    e
    
    ### end of code
    

    Result: (same for gnuplot 4.6 and 5.x)

    enter image description here