Credits Overview Plotting Styles Commands Terminals

plot

plot and splot are the primary commands for drawing plots with gnuplot. They offer many different graphical representations for functions and data. plot is used to draw 2D functions and data. splot draws 2D projections of 3D surfaces and data.

Syntax:

      plot {<ranges>} <plot-element> {, <plot-element>, <plot-element>}

Each plot element consists of a definition, a function, or a data source together with optional properties or modifiers:

      plot-element:
           {<iteration>}
           <definition> | {sampling-range} <function> | <data source>
                        | keyentry
           {axes <axes>} {<title-spec>}
           {with <style>}

The graphical representation of each plot element is determined by the keyword with, e.g. with lines or with boxplot. See plotting styles.

The data to be plotted is either generated by a function (two functions if in parametric mode), read from a data file, read from a named data block that was defined previously, or extracted from an array. Multiple datafiles, data blocks, arrays, and/or functions may be plotted in a single plot command separated by commas.

Many additional keywords are specific to data plots. See plot datafile. Also see data, inline data, functions.

A plot-element that contains the definition of a function or variable does not create any visible output, see third example below.

Examples:

      plot sin(x)
      plot sin(x), cos(x)
      plot f(x) = sin(x*a), a = .2, f(x), a = .4, f(x)
      plot "datafile.1" with lines, "datafile.2" with points
      plot [t=1:10] [-pi:pi*2] tan(t), \
           "data.1" using (tan($2)):($3/$4) smooth csplines \
                    axes x1y2 notitle with lines 5
      plot for [datafile in "spinach.dat broccoli.dat"] datafile

See also show plot.

Subtopics