Credits | Overview | Plotting Styles | Commands | Terminals |
---|
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'}
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. It returns 0 if the column value is missing, uninterpretable, or NaN. 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 or use function columnhead(N) when specifying an individual title.
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.
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 and fit for details about plotting styles that make use of data from additional columns of input.
Subtopics | ||
---|---|---|