LinuxCommandLibrary

gnuplot

Plot functions and data graphically

TLDR

Start the interactive graph plotting shell

$ gnuplot
copy

Plot the graph for the specified graph definition file
$ gnuplot [path/to/definition.plt]
copy

Set the output format by executing a command before loading the definition file
$ gnuplot -e "[set output "path/to/file.png" size 1024,768]" [path/to/definition.plt]
copy

Persist the graph plot preview window after gnuplot exits
$ gnuplot [[-p|--persist]] [path/to/definition.plt]
copy

SYNOPSIS

gnuplot [OPTION...] [FILE...]

PARAMETERS

-V, --version
    print version information and terminate

-h, --help
    show help message and terminate

-p, --persist
    keep plot windows open after exit

-e "command"
    execute gnuplot command(s)

-c "command"
    execute command persistently (with -p)

-d
    disable mouse and hotkey support

-g
    use graphics device (emulated terminals)

-r, --read-file FILE
    bind and call FILE on startup

-f FILE
    load script FILE on startup

-o FILE
    set output to FILE; infer terminal from extension

-C
    start interactive mode in multiplot

-E
    enable extended regex syntax

-H, --line-editing[=mode]
    enable readline/editline

-noend
    do not read ~/.gnuplot on startup

-npixel N
    set canvas size to N x N pixels

-save FILE
    save window contents to FILE

-shell COMMAND
    run shell COMMAND, pipe stdout to stdin

-timestamp
    add timestamp footer to plots

DESCRIPTION

Gnuplot is a portable, command-line driven graphing utility for Linux/UNIX and other platforms. It produces high-quality 2D and 3D plots from functions, data files, or piped input. Supports numerous terminals including X11 (interactive), PostScript, PDF, PNG, SVG, LaTeX, and more.

Key features: enhanced text with markup, multiple axes, logarithmic/polar/nonlinear scales, curve fitting, histograms, error bars, splines, geographic projections, data-driven color palettes, and 3D isosurfaces/voxels. Interactive mode allows zooming, rotation, replotting. Scripts automate batch processing.

Data formats: ASCII tables, binary, with auto-detection of columns, missing values. Commands like plot, splot (3D), fit, stats. Widely used in science, engineering, finance for publication-ready graphics. No GUI; relies on scripts or interactive shell.

Distributed as free software; compile from source or via packages like apt (gnuplot).

CAVEATS

Interactive graphics require DISPLAY (X11/Wayland); batch mode needs terminal set. Large datasets may need set datafile commentschars. No built-in data import GUI; use scripts. Multiplot mode can be tricky with persists.

INTERACTIVE START

Run gnuplot; type plot sin(x); use replot, set term png, exit.

KEY COMMANDS

plot 'data.dat' u 1:2 for columns; splot for 3D; fit for regression; set multiplot for layouts.

HISTORY

Developed since 1986 by Thomas Williams and Colin Kelley from a 1970s plotter. Public domain originally; now custom license. Evolved to v5.4+ (2022) with cairo/HTML5 support, mouse enhancements, Lua scripting.

SEE ALSO

xmgrace(1), grace(1), ploticus(1), graph(1)

Copied to clipboard