Reputation: 5465
As a follow up of: Gnuplot: Plotting several datasets with titles from one file, I have a test.dat
file:
"p = 0.1"
1 1
3 3
4 1
"p = 0.2"
1 3
2 2
5 2
and I can plot it with no issues from within gnuplot using:
> plot for [IDX=0:1] 'test.dat' i IDX u 1:2 w lines title columnheader(1)
however I cannot pipe the data.
Here is the single line example:
$ cat test.dat | gnuplot --persist -e "plot for [IDX=0:1] '-' i IDX u 1:2 w lines title columnheader(1)"
line 10: warning: Skipping data file with no valid points
I get the warning message and only the first set is plotted. I tried to add an e
at the end of the data file, but no luck... This should be trivial, am I making a silly mistake?
I've messing around a bit more. So these works:
gnuplot --persist -e "plot for [IDX=0:1] 'test.dat' i IDX u 1:2 w lines title columnheader(1)"
gnuplot --persist -e "plot for [IDX=0:1] '< cat test.dat' i IDX u 1:2 w lines title columnheader(1)"
These don't:
cat test.dat | gnuplot --persist -e "plot for [IDX=0:1] '-' i IDX u 1:2 w lines title columnheader(1)"
cat test.dat | gnuplot --persist -e "plot for [IDX=0:1] '< cat' i IDX u 1:2 w lines title columnheader(1)"
It looks like a bug to me. I tried few Gnuplot versions (4.6.6, 5.0.0, 5.0.3) but they all present the same behaviour.
Upvotes: 1
Views: 544
Reputation: 5465
Ok, I've finally got it browsing the documentation. When piping, each index selection requires to repeat the whole data:
plot '-' index 0, '-' index 1
2
4
6
10
12
14
e
2
4
6
10
12
14
e
or, as a much simpler alternative, one can just do:
plot '-', '-'
2
4
6
e
10
12
14
e
Upvotes: 2