### Using

The most common datafile modifier is using. It tells the program which columns of data in the input file are to be plotted.

Syntax:

         plot 'file' using <entry> {:<entry> {:<entry> ...}} {'format'}

If a format is specified, it is used to read in each datafile record using the C library 'scanf' function. Otherwise the record is interpreted as consisting of columns (fields) of data separated by whitespace (spaces and/or tabs), but see datafile separator (p. ).

Each entry may be a simple column number that selects the value from one field of the input file, a string that matches a column label in the first line of a data set, an expression enclosed in parentheses, or a special function not enclosed in parentheses such as xticlabels(2).

If the entry is an expression in parentheses, then the function column(N) may be used to indicate the value in column N. That is, column(1) refers to the first item read, column(2) to the second, and so on. The special symbols $1, $2, ... are shorthand for column(1), column(2) ...

The special symbol $# evaluates to the total number of columns in the current line of input, so column($#) or stringcolumn($#) always returns the content of the final column even if the number of columns is unknown or different lines in the file contain different numbers of columns.

The function valid(N) tests whether column N contains a valid number. If each column of data in the input file contains a label in the first row rather than a data value, this label can be used to identify the column on input and/or in the plot legend. The column() function can be used to select an input column by label rather than by column number. For example, if the data file contains

         Height    Weight    Age
         val1      val1      val1
         ...       ...       ...

then the following plot commands are all equivalent

         plot 'datafile' using 3:1, ” using 3:2
         plot 'datafile' using (column("Age")):(column(1)), \
                      ” using (column("Age")):(column(2))
         plot 'datafile' using "Age":"Height", ” using "Age":"Weight"

The full string must match. Comparison is case-sensitive. To use column labels in the plot legend, use set key autotitle columnhead.

In addition to the actual columns 1...N in the input data file, gnuplot presents data from several "pseudo-columns" that hold bookkeeping information. E.g. $0 or column(0) returns the sequence number of this data record within a dataset. Please see pseudocolumns (p. ).

An empty entry will default to its order in the list of entries. For example, using ::4 is interpreted as using 1:2:4.

If the using list has only a single entry, that entry will be used for y and the data point number (pseudo-column $0) is used for x; for example, "plot 'file' using 1" is identical to "plot 'file' using 0:1". If the using list has two entries, these will be used for x and y. See set style (p. ) and fit (p. ) for details about plotting styles that make use of data from additional columns of input.

'scanf' accepts several numerical specifications but gnuplot requires all inputs to be double-precision floating-point variables, so "%lf" is essentially the only permissible specifier. A format string given by the user must contain at least one such input specifier, and no more than seven of them. 'scanf' expects to see white space — a blank, tab ("t"), newline ("n"), or formfeed ("f") — between numbers; anything else in the input stream must be explicitly skipped.

Note that the use of "t", "n", or "f" requires use of double-quotes rather than single-quotes.

Subsections

- Using_examples
- Pseudocolumns
- Key
- Xticlabels
- X2ticlabels
- Yticlabels
- Y2ticlabels
- Zticlabels
- Cbticlabels