Index

The index keyword allows you to select specific data sets in a multi-data-set file for plotting.

Syntax:

     plot 'file' index { <m>{:<n>{:<p>}} | "<name>" }

Data sets are separated by pairs of blank records. index 4#4m5#5 selects only set 4#4m5#5; index 4#4m5#5:4#4n5#5 selects sets in the range 4#4m5#5 to 4#4n5#5; and index 4#4m5#5:4#4n5#5:4#4p5#5 selects indices 4#4m5#5, 4#4m5#5+4#4p5#5, 4#4m5#5+24#4p5#5, etc., but stopping at 4#4n5#5. Following C indexing, the index 0 is assigned to the first data set in the file. Specifying too large an index results in an error message. If 4#4p5#5 is specified but 4#4n5#5 is left blank then every 4#4p5#5-th dataset is read until the end of the file. If index is not specified, the entire file is plotted as a single data set.

Example:

     plot 'file' index 4:5

For each point in the file, the index value of the data set it appears in is available via the pseudo-column column(-2). This leads to an alternative way of distinguishing individual data sets within a file as shown below. This is more awkward than the index command if all you are doing is selecting one data set for plotting, but is very useful if you want to assign different properties to each data set. See pseudocolumns (p. [*]), lc variable (p. [*]).

Example:

     plot 'file' using 1:(column(-2)==4 ? $2 : NaN)        # very awkward
     plot 'file' using 1:2:(column(-2)) linecolor variable # very useful!

index '4#4name5#5' selects the data set with name '4#4name5#5'. Names are assigned to data sets in comment lines. The comment character and leading white space are removed from the comment line. If the resulting line starts with 4#4name5#5, the following data set is now named 4#4name5#5 and can be selected.

Example:

     plot 'file' index 'Population'

Please note that every comment that starts with 4#4name5#5 will name the following data set. To avoid problems it may be useful to choose a naming scheme like '== Population ==' or '[Population]'.

http://www.gnuplot.info/demo/multimsh.html