2
votes

I would like a way to plot only the last (final) dataset in a file that contains multiple datasets. Can anyone suggest a way of doing that? e.g. if I know there are exactly 10 datasets in the file then:

plot 'myfile.txt' index 9

would plot the final one. I don't know in advance how many datasets there will be though. On the off-chance that it might work, I tried

plot 'myfile.txt' index -1

but no joy. Is there any way to do what I want?

1

1 Answers

2
votes

If you have gnuplot 4.6.0+, you can use the stats command to get that information:

stats 'foo.dat' name 'foo'
stats 'bar.dat' name 'bar'

plot 'foo.dat' index (foo_blocks-1) title 'bar', \
     'bar.dat' index (bar_blocks-1) title 'foo'

The name 'prefix' key-value pair makes gnuplot save its statistical results in variables with the prefix prefix instead of STATS.

For details type ? stats at the gnuplot command line.