Next: , Previous: (dir), Up: (dir)


Master Menu

                            GNUPLOT
     
                 An Interactive Plotting Program
                  Thomas Williams & Colin Kelley
               Version 4.2 organized by: Hans-Bernhard Broeker
     
      Copyright (C) 1986 - 1993, 1998, 2004   Thomas Williams, Colin Kelley
     
            Mailing list for comments: gnuplot-info@lists.sourceforge.net
          Mailing list for bug reports: gnuplot-bugs@lists.sourceforge.net
     
              This manual was originally prepared by Dick Crawford
                        Version 4.2 - 1 Oct 2006
     
     
     Major contributors (alphabetic order):

Next: , Previous: example_datafile, Up: data


2.12.1.5 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>}
     

Data sets are separated by pairs of blank records. `index <m>` selects only set <m>; `index <m>:<n>` selects sets in the range <m> to <n>; and `index <m>:<n>:<p>` selects indices <m>, <m>+<p>, <m>+2<p>, etc., but stopping at <n>. 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 index is not specified, all sets are 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 that 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 `lc variable`.

Example:

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

splot with indices demo.