Gnuplot
Table of Contents
Professional plotting tool
1. CLI
-e "command1; command2; ...-persist
-c <scriptfile> ARG1 ARG2 ...
2. Set
2.1. Input
set datafileseparator {whitespace | tab | comma | "chars"}missing {"<string>" | NaN}
2.2. Output
set output <filename>- The
filenameis a string variable. Note that strings can be concatenated with.in the middle. - The output can be piped with
"|<command>"
- The
set termlua tikz: TeXjpegpngtiny | small | medium | large | giantfont "<face> {, <pointsize>}",font <face> <pointsize>fontscale <scale>size <x>, <y>background <rgb_color>
gif,svg,pdfcanvasqt: Interactive
2.3. Annotations
Legend
set keyon | offdefault{ inside | outside | fixed } | { lmargin | rmargin | tmargin | bmargin } | { at <position> }{ left | right | center } { top | bottom | center }{ l | r | c } { t | b | c }
{ vertical | horizontal }{ Left | Right }title {"<text>"} {{no}enhanced} {center | left | right}
Label
set label {"<label text>"} {at <position>} {left | center | right}set {x|x2|y|y2|z|t}label {"label"} {offset <offset>} {rotate by <degrees> | rotate parallel | norotate}
Tick mark
set {x|x2|y|y2|z|t}tics{axis | border} {{no}mirror} {in | out} {front | back}{no}rotate {by <ang>}offset <offset> | nooffsetleft | right | center | autojustify{add} {autofreq | <incr> | <start>, <incr> {, <end>} | ({"<label>"} <pos> {<level>} {,...})}
2.4. Plot
set {x|x2|y|y2|z|cb|r|t|u|v}range [{{<min>}:{<max>}}] {{no}reverse} {{no}writeback} {{no}extend} | restoreset origin <x> <y>set stylefunction <style>data <style><style>
3. Fit
fit {<ranges>} <expression>'<datafile>' {datafile-modifiers}{{unitweights} | {y|xy|z}error | errors <var1>{, <var2>, ...}}via '<parameter file>' | <var1>{, <var2>, ...}- e.g.
fit f(x) 'data' using 1:2 via a, b,f(x) = ax + b - Fit 1 dependent variable to up to 12 independent variables.
- It uses the nonlinear least-square Levenberg-Marquardt algorithm
4. Plot
{[<trange>]}[<xrange>][<yrange>][<x2range>][<y2range>]...for [<var>=<start>:<end>:<increment>]for [<var> in "word1 word2 word3 ..."]
4.1. Data
'filename'every point_incr:block_incr:start_point:start_block:end_point:end_blockend_blockcannot be omitted.- The count starts from 0.
pointis the record, andblockis the list of records separated by black lines. (not the case for matrix)
skip N: Ignore the first N linesusing N:M:{K:...}u: Specify which column to use in which order.smooth: perform filtering.unique | frequency | fnormal | cumulative | cnormal: the distributionkdensity {bandwidth} {period}: kernel density estimatecsplines | acsplines | mcsplines | bezier | sbezier: curve interpolationcsplines:acsplines: Natural Smoothing Splines- The third column is used as the weights.
mcsplines: Monotomic Piecewise Cubic Interpolationbezier: Use the middle points as the control points
unwrap | zsort
bins=N: sort into equal-sized intervals, histogram.binrange [LOW:HIGH]: the total range of databinwidth=WIDTH: width of a single bin
4.1.1. Special Filenames
'': The previous input'+', -'++': Samples generated'-': Inline data"< <command>": Piped data
4.2. Function
4.2.1. Parametric
set parametricto enable- the function must be given in pairs (or triplets for
splot).
4.3. Style
t,title <text> | notitletitle columnheadertitle columnheader(N) at {beginning | end | <screenx>, <screeny>}ttitle ""is equivalent tonotitle
wwith <style>: style is one oflines points linespoints financebars dots impulses labels surface steps fsteps histeps arrows vectors xerrorbar xerrorlines yerrorbar yerrorlines xyerrorbars xyerrorlines parallelaxesboxes boxerrorbars boxxyerror isosurface boxplot candlesticks circles zerrorfill ellipses filledcurves fillsteps histograms image pm3d rgbalpha rgbimage polygonstable
linetype,lt:0Dotted linelinewidthlwlinecolor,lc:"color"pointtypept-1: No point0: Dot1: Plus2: Times3: Asterisk4: Box5: Filled Box
pointsizepsarrowstyleasfillfs- Multiple plots can drawn on the same canvas by joining them with
,. \Can be used at the end of a line to include a newline.
4.4. Multiplot
set multiplotlayout n,m
unset multiplot
5. Enhanced Text Mode
[no]enhanced option in the legend, label enable (or disable)
the enhanced text mode.
Enhanced mode allows writing complex formatted text with ASCII.
_,^subscript and superscript{/<fontfamily>:<typeface>=N ...}set font\U+OOOOUnicode