0

I have a Gnuplot data file broken into sections (2 blank lines). I wish to capture the indices I've selected to plot into the key of the plot, "plot 'datafile' index 5:10:1 us 7:8 ti XXX", where XXX is the index. I understand the the pseudocolumn, column(-2), contains the index value.

How do I capture the index and 'sprint' it into the title? The index is, of course, and integer.

Donal Day
  • 1
  • 1
  • Problem solved? Question answered? If yes, then please accept one of the answers, indicating that your question is answered. – theozh Nov 08 '22 at 07:31

2 Answers2

0

What do you want to see as XXX? The index? Do you actually mean the indices from 5 to 10 as several key entries? As far as I know the title is only evaluated once per plot command. Hence, you have to put the plot command into a for loop.

Script:

### plotting several blocks with index as title
reset session

# create some random test data
set table $Data
    set samples 10
    do for [i=1:12] {
        plot '+' u 1:(i+rand(0)) w table, \
             '+' u ("") every ::::1 w table   # two empty lines
    }
unset table

set key out

plot for [i=5:10] $Data u 1:2 index i w l ti sprintf("index %d",i)
### end of script

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72
  • Thank you. That did it. I was frustrated when using 'index 1:10 ' that I would get the last index value. – Donal Day Oct 27 '22 at 18:37
0

Here is a relevant plot from the on-line demo collection: plot #2 of 'iterate.dem' The plot command that generated it is

splot for [i=1:*] "whale.dat" index i title sprintf("scan %d",i) with lines

If you do not want to extract all the available data segments you can adjust the iteration limits to match which set of index values you want to select. enter image description here

Ethan
  • 13,715
  • 2
  • 12
  • 21