Reputation: 119
Given the following data file datafile.txt
"distance bus1 bicycle1"
12.1 16.29994171768731
15.0 23.23394929838676
20.0 17.63884633415712
25.0 2.2977170652861667
30.0 22.638830796409298
35.0 37.904820273943606
38.2 49.68696609775994
"distance bus1 bicycle2"
12.1 10.389230000341742
15.0 15.82783623872837
20.0 11.262011365648817
25.0 2.3291889288592533
30.0 25.930554010842158
35.0 45.36376748022544
38.2 57.535263969151465
This command works.
plot for [i=0:1] 'datafile.txt' index i with lines title columnheader(1), 1.0 with lines title "collision limit"
This command also works.
plot for [i=0:*] 'datafile.txt' index i with lines title columnheader(1)
But combining * and comma gives a syntax error in gnuplot:
plot for [i=0:*] 'datafile.txt' index i with lines title columnheader(1), 1.0 with lines title "collision limit"
gnuplot> plot for [i=0:*] 'datafile.txt' index i with lines title columnheader(1), 1.0 with lines title
"collisio
^
warning: ignoring trailing comma in plot command
gnuplot> plot for [i=0:*] 'datafile.txt' index i with lines title columnheader(1), 1.0 with lines title
"collisio"
^
unexpected or unrecognized token
gnuplot> n limit"
gnuplot> plot for [i=0:*]
^
function to plot expected
Any ideas what I'm doing wrong? I'm using gnuplot 5.2 patchlevel 7.
Upvotes: 2
Views: 427
Reputation: 15093
I cannot explain why that is happening, probably a bug of some sort, but I can offer a work-around:
plot for [i=0:*] 'datafile.txt' index i with lines title columnheader(1), \
'+' using 1:(1.0) with lines title "collision limit"
Note: The bug is now fixed upstream and the fix will first appear in gnuplot 5.2.8
Upvotes: 1
Reputation: 25734
Loops with *
, e.g. plot for [i=0:*] ...
will also cause problems at other occasions (at least that's what I experienced). Another workaround would be the following, however, at the cost of some extra calculations by stats
. Then you can use the variable STATS_blocks
, which should tell you the number of datasets, i.e. maximum index is equal STATS_blocks-1
:
FILE = 'datafile.txt'
stats FILE nooutput
plot for [i=0:STATS_blocks-1] FILE index i with lines title columnheader(1), \
1.0 with lines title "collision limit"
Upvotes: 1