Here's my minimal Gnuplot script:
data="3.000000\t49.200000\n3.500000\t42.800000\n4.000000\t37.800000\n4.500000\t33.800000\n5.000000\t30.400000\n5.500000\t28.000000\n"
plot '< echo -e '.sprintf('"%s"', data) using 1:2 title 'there is no data point for x=3.0?' w linespoints
In my actual script, of course, I populate the data string in a different way (using the stats command), so saving the data to a file first, then running plot should work, but I don't like it! Seems overly cumbersome, leaves stray files around, etc.
My current solution is to prepend the string with a dummy line (data="0\t0\n..."), but my concern is: am I doing something wrong, or is this a bug? (I'm on ubuntu 14.04, gnuplot 4.6 patchlevel 4, which I guess is not the super-most-up-to-date...) Thanks!
Remove the -e
option and it works fine:
data="3.000000\t49.200000\n3.500000\t42.800000\n4.000000\t37.800000\n4.500000\t33.800000\n5.000000\t30.400000\n5.500000\t28.000000\n"
plot '< echo '.sprintf('"%s"', data) using 1:2 title 'there is a data point for x=3.0!' w linespoints
But I can't tell you exactly why it works ;)
As an outlook for you: Gnuplot 5 has a new way of saving inline data as some kind of heredoc. In my eyes it isn't a good way to include actual data files into the plotting script, but it is supported:
$data <<EOD
3.000000 49.200000
3.500000 42.800000
4.000000 37.800000
4.500000 33.800000
5.000000 30.400000
5.500000 28.000000
EOD
plot $data using 1:2 notitle w linespoints