I would like to pipe data into gnuplot and plot it without entering the gnuplot command line or providing an existing script file. Eg a one-liner such as cat datafile | gnuplot and see the plot come up. Suppose the datafile is well formatted, such as two simple columns of numerical data separated by a tab or space.
As is this would close immediately even if it would work (which it doesn't) but this can be resolved with the -persist option (abbreviated -p).
Essentially I would like the following line of code to work, or to understand why it doesn't and how to modify it to work: echo -e "1 3\n2 4\n3 5" | gnuplot -p <<< "plot '-'"
I can get something working using the -e option, but this seems to often break for me once I start making more complex plotting commands and I don't understand exactly what that option is doing, so I would prefer to simply write a short script file using a heredoc, as attempted above. This works: echo -e "1 3\n2 4\n3 5" | gnuplot -p -e "plot '-'"
Why doesn't the column data that is piped into gnuplot simply plot, even when using the plot '-' syntax to request that plot take the data in from stdin?
-etells gnuplot to execute the following code. As simple as this. I don't understand what your actual problem is: you have a working snippet. - Christophgnuplot -p <<< scriptbut when also piping in data like the following it failscat data | gnuplot -p <<< script. Is there a way to use a heredoc script and pipe data at the same time? - Daniel Naftalovichalias gp="gnuplot -p -e \"plot '-'\" ". Then you can use it ascat 'data.dat' | gp. Alternatively, you can create a gnuplot script and place it in/usr/bin/or/usr/local/bin/- vagoberto