Skip to main content
1 of 5
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
plot $DATA w lines

expands to

plot 10
12
15 w lines

i.e. whatever $DATA contains gets put there literally, newlines and all. That likely breaks the command. (I'm not sure if gnuplot has a way to give the data directly on the plot command line, but it'd probably need to be in some other format.)

The shell has process substitution that makes the output of a command available as a "file", and expands to the filename, but you might be better off passing the data through stdin, and giving the plot command to gnuplot as an option.

Based on the example command used here, something like this might work:

echo "$DATA" | gnuplot -e 'plot "-" w lines"'
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441