C RCS $Id: gnuplot.doc,v 1.916 2014/09/20 11:31:13 markisch Exp $ C C Copyright (C) 1986 - 1993, 1998, 1999, 2000, 2001, 2004 Thomas Williams, Colin Kelley et al. C 1 gnuplot ?gnuplot ^
Thomas Williams & Colin Kelley
^Version 5.0 organized by Ethan A Merritt and others
^Major contributors (alphabetic order):
^
^ Hans-Bernhard Broeker, John Campbell,
^ Robert Cunningham, David Denholm,
^ Gershon Elber, Roger Fearick,
^ Carsten Grammes, Lucas Hart,
^ Lars Hecking, Péter Juhász,
^ Thomas Koenig, David Kotz,
^ Ed Kubaitis, Russell Lang,
^ Timothée Lecomte, Alexander Lehmann,
^ Alexander Mai, Bastian Märkisch,
^ Ethan A Merritt, Petr Mikulík,
^ Carsten Steger, Shigeharu Takeno,
^ Tom Tkacik, Jos Van der Woude,
^ James R. Van Zandt, Alex Woo, Johannes Zellner
^
Copyright (C) 1986 - 1993, 1998 - 2004 Thomas Williams, Colin Kelley
^ Copyright (C) 2004 - 2014 various authors
Mailing list for comments: gnuplot-info@lists.sourceforge.net
^ Mailing list for bug reports: gnuplot-bugs@lists.sourceforge.net
^ Web access (preferred): http://sourceforge.net/projects/gnuplot
This manual was originally prepared by Dick Crawford
2 Copyright ?copyright ?license Copyright (C) 1986 - 1993, 1998, 2004, 2007 Thomas Williams, Colin Kelley Permission to use, copy, and distribute this software and its documentation for any purpose with or without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Permission to modify the software is granted, but not the right to distribute the complete modified source code. Modifications are to be distributed as patches to the released version. Permission to distribute binaries produced by compiling modified sources is granted, provided you 1. distribute the corresponding source modifications from the released version in the form of a patch file along with the binaries, 2. add special version identification to distinguish your version in addition to the base release version number, 3. provide your name and address as the primary contact for the support of your modified version, and 4. retain our contact information in regard to use of the base software. Permission to distribute the released version of the source code along with corresponding source modifications in the form of a patch file is granted with same provisions 2 through 4 for binary distributions. This software is provided "as is" without express or implied warranty to the extent permitted by applicable law. AUTHORS Original Software: Thomas Williams, Colin Kelley. Gnuplot 2.0 additions: Russell Lang, Dave Kotz, John Campbell. Gnuplot 3.0 additions: Gershon Elber and many others. Gnuplot 4.0 and 5.0 additions: See list of contributors at head of this document. 2 Introduction ?introduction ? `Gnuplot` is a portable command-line driven graphing utility for Linux, OS/2, MS Windows, OSX, VMS, and many other platforms. The source code is copyrighted but freely distributed (i.e., you don't have to pay for it). It was originally created to allow scientists and students to visualize mathematical functions and data interactively, but has grown to support many non-interactive uses such as web scripting. It is also used as a plotting engine by third-party applications like Octave. Gnuplot has been supported and under active development since 1986. Gnuplot supports many types of plots in either 2D and 3D. It can draw using lines, points, boxes, contours, vector fields, surfaces, and various associated text. It also supports various specialized plot types. Gnuplot supports many different types of output: interactive screen terminals (with mouse and hotkey input), direct output to pen plotters or modern printers, and output to many file formats (eps, emf, fig, jpeg, LaTeX, pdf, png, postscript, ...). Gnuplot is easily extensible to include new output modes. Recent additions include interactive terminals based on wxWidgets (usable on multiple platforms), and Qt. Mouseable plots embedded in web pages can be generated using the svg or HTML5 canvas terminal drivers. The command language of `gnuplot` is case sensitive, i.e. commands and function names written in lowercase are not the same as those written in capitals. All command names may be abbreviated as long as the abbreviation is not ambiguous. Any number of commands may appear on a line, separated by semicolons (;). Strings may be set off by either single or double quotes, although there are some subtle differences. See `syntax` and `quotes` for more details. Example: set title "My First Plot"; plot 'data'; print "all done!" Commands may extend over several input lines by ending each line but the last with a backslash (\). The backslash must be the _last_ character on each line. The effect is as if the backslash and newline were not there. That is, no white space is implied, nor is a comment terminated. Therefore, commenting out a continued line comments out the entire command (see `comments`). But note that if an error occurs somewhere on a multi-line command, the parser may not be able to locate precisely where the error is and in that case will not necessarily point to the correct line. In this document, curly braces ({}) denote optional arguments and a vertical bar (|) separates mutually exclusive choices. `Gnuplot` keywords or `help` topics are indicated by backquotes or `boldface` (where available). Angle brackets (<>) are used to mark replaceable tokens. In many cases, a default value of the token will be taken for optional arguments if the token is omitted, but these cases are not always denoted with braces around the angle brackets. For built-in help on any topic, type `help` followed by the name of the topic or `help ?` to get a menu of available topics. A large set of demo plots is available on the web page ^ http://www.gnuplot.info/demo/ ^ When run from command line, gnuplot is invoked using the syntax gnuplot {OPTIONS} file1 file2 ... where file1, file2, etc. are input file as in the `load` command. On X11-based systems, you can use gnuplot {X11OPTIONS} {OPTIONS} file1 file2 ... see your X11 documentation and `x11` in this document. Options interpreted by gnuplot may come anywhere on the line. Files are executed in the order specified, as are commands supplied by the -e option, for example gnuplot file1.in -e "reset" file2.in The special filename "-" is used to force reading from stdin. `Gnuplot` exits after the last file is processed. If no load files are named, `Gnuplot` takes interactive input from stdin. See help `batch/interactive` for more details. The options specific to gnuplot can be listed by typing gnuplot --help See `command line options` for more details. In sessions with an interactive plot window you can hit 'h' anywhere on the plot for help about `hotkeys` and `mousing` features. Section `seeking-assistance` will help you to find further information, help and FAQ. 2 Seeking-assistance ?help-desk ?faq ?FAQ ?seeking-assistance The canonical gnuplot web page can be found at ^ http://www.gnuplot.info ^ Before seeking help, please check file FAQ.pdf or the above website for ^ FAQ (Frequently Asked Questions) list. ^ If you need help as a gnuplot user, please use the newsgroup comp.graphics.apps.gnuplot We prefer that you read the messages through the newsgroup rather than subscribing to the mailing list which is also available and carries the same set of messages. Instructions for subscribing to gnuplot mailing lists may be found via the gnuplot development website on SourceForge ^ http://sourceforge.net/projects/gnuplot ^ The address for mailing to list members is: gnuplot-info@lists.sourceforge.net Bug reports and code contributions should be uploaded to the trackers at http://sourceforge.net/projects/gnuplot/support Please check previous bug reports if the bug you want to report has not been already fixed in a newer version. A mailing list for those interested in development version of gnuplot is: gnuplot-beta@lists.sourceforge.net When posting a question, please include full details of the gnuplot version, the terminal type, and the operating system you are using. A _small_ script demonstrating the problem may be useful. Function plots are preferable to datafile plots. 2 New features in version 5 ?new-features * The dot-dash pattern of a line can now be specified independent of other line properties. See `dashtype`, `set dashtype`, `set linetype`. * Text markup now supports bold and italic font settings in addition to subscript, superscript, font size and other previously available properties. Enhanced text mode is now enabled by default. See `enhanced text`. * Interactive terminals support hypertext labels that only appear when the mouse hovers over the label's anchor point. * New coordinate system (Degrees, Minutes, Seconds). See `set xdata geographic`. * The default format for axis labels is "% h" ("$%h$" for LaTeX terminals). This format is like the C standard format %g except that the exponential term, if present, is written using a superscript. E.g. 1.2 x 10^5 rather than 1.2E05. * Command scripts may place in-line data in a named data block for repeated plotting. See `inline data`. * Support for 32-bit Alpha channel + RGB color #AARRGGBB. See `colorspec`. * Support for HSV color space via a translation function hsv2rgb(H,S,V). * Secondary axes (x2, y2) may be locked to the primary axis via a mapping function. In the simplest case this guarantees that the primary and secondary axis ranges are identical. In the general case it allows you to define a non-linear axis, something that previously was possible only for log scaling. See `set link`. * Each function in a plot command may optionally be preceded by a sampling range. This does not affect the overall range of the plot, only the range over which this function is sampled. See `plot` and `piecewise.dem`. * If the external library libcerf is available, it is used to provide complex math routines cerf, cdawson, erfi, faddeeva, and the Voigt profile VP(x,sigma,gamma). * The `import` command attaches a user-defined function name to a function provided by an external shared object (support is operating-system dependent). A template header and example source and make files for creating a suitable external shared object are provided in the demo collection. * Previous commands in the history list of an interactive session can be reexecuted by number. For example, `history !5` will reexecute the command numbered 5 in the `history` list. * Bit-shift operators >> and <<. * New plot styles: `with parallelaxes`, `with table`, labeled contours. * Shell invocation of gnuplot can pass parameters to a gnuplot script. gnuplot -c scriptfile.gp ARG1 ARG2 ARG3 ... 3 New commands #start # import f(x) from "plugin.so" # load function from shared library # set history {quiet|numers} {full|trim} # controls output of history command # history !N # re-execute prior command by number # plot| Character | Function |
|---|---|
| Line Editing | |
| ^B | move back a single character. |
| ^F | move forward a single character. |
| ^A | move to the beginning of the line. |
| ^E | move to the end of the line. |
| ^H | delete the previous character. |
| DEL | delete the current character. |
| ^D | delete current character. EOF if line is empty |
| ^K | delete from current position to the end of line. |
| ^L, ^R | redraw line in case it gets trashed. |
| ^U | delete the entire line. |
| ^W | delete previous word. |
| History | |
| ^P | move back through history. |
| ^N | move forward through history. |
| Control | Examples | Explanation |
|---|---|---|
| ^ | a^x | superscript |
| _ | a_x | subscript |
| @ | @x or a@^b_{cd} | phantom box (occupies no width) |
| & | &{space} | inserts space of specified length |
| ~ | ~a{.8-} | overprints '-' on 'a', raised by .8 times the current fontsize |
| Math library functions | ||
|---|---|---|
| Function | Arguments | Returns |
| abs(x) | any | |x|, absolute value of x; same type |
| abs(x) | complex | length of x, √( Re(x)2 + Im(x)2 ) |
| acos(x) | any | cos-1 x (inverse cosine) |
| acosh(x) | any | cosh-1 x (inverse hyperbolic cosine) in radians |
| airy(x) | any | Airy function Ai(x) |
| arg(x) | complex | the phase of x |
| asin(x) | any | sin-1 x (inverse sin) |
| asinh(x) | any | sinh-1 x (inverse hyperbolic sin) in radians |
| atan(x) | any | tan-1 x (inverse tangent) |
| atan2(y,x) | int or real | tan-1(y/x) (inverse tangent) |
| atanh(x) | any | tanh-1 x (inverse hyperbolic tangent) in radians |
| EllipticK(k) | real k in (-1:1) | K(k) complete elliptic integral of the first kind |
| EllipticE(k) | real k in [-1:1] | E(k) complete elliptic integral of the second kind |
| EllipticPi(n,k) | real n<1, real k in (-1:1) | Π(n,k) complete elliptic integral of the third kind |
| besj0(x) | int or real | J0 Bessel function of x, in radians |
| besj1(x) | int or real | J1 Bessel function of x, in radians |
| besy0(x) | int or real | Y0 Bessel function of x, in radians |
| besy1(x) | int or real | Y1 Bessel function of x, in radians |
| ceil(x) | any | ⌈x⌉, smallest integer not less than x (real part) |
| cos(x) | radians | cos x, cosine of x |
| cosh(x) | any | cosh x, hyperbolic cosine of x in radians |
| erf(x) | any | erf(Re(x)), error function of real(x) |
| erfc(x) | any | erfc(Re(x)), 1.0 - error function of real(x) |
| exp(x) | any | ex, exponential function of x |
| expint(n,x) | any | En(x), exponential integral function of x |
| floor(x) | any | ⌊x⌋, largest integer not greater than x (real part) |
| gamma(x) | any | Γ(Re(x)), gamma function of real(x) |
| ibeta(p,q,x) | any | ibeta(Re(p,q,x)), ibeta function of real(p,q,x) |
| inverf(x) | any | inverse error function real(x) |
| igamma(a,x) | any | igamma(Re(a,x)), igamma function of real(a,x) |
| imag(x) | complex | Im(x), imaginary part of x as a real number |
| invnorm(x) | any | inverse normal distribution function real(x) |
| int(x) | real | integer part of x, truncated toward zero |
| lambertw(x) | real | Lambert W function |
| lgamma(x) | any | lgamma(Re(x)), lgamma function of real(x) |
| log(x) | any | ln x, natural logarithm (base e) of x |
| log10(x) | any | log10 x, logarithm (base 10) of x |
| norm(x) | any | norm(x), normal distribution function of real(x) |
| rand(x) | int | pseudo random number in the interval [0:1] |
| real(x) | any | Re(x), real part of x |
| sgn(x) | any | 1 if x > 0, -1 if x < 0, 0 if x = 0. ℑ(x) ignored |
| sin(x) | any | sin x, sine of x |
| sinh(x) | any | sinh x, hyperbolic sine of x in radians |
| sqrt(x) | any | √x, square root of x |
| tan(x) | any | tan x, tangent of x |
| tanh(x) | any | tanh x, hyperbolic tangent of x in radians |
| voigt(x,y) | real | convolution of Gaussian and Lorentzian |
^
| Special functions from libcerf (only if available) | ||
|---|---|---|
| Function | Arguments | Returns |
| cerf(z) | complex | complex error function |
| cdawson(z) | complex | complex Dawson's integral |
| faddeeva(z) | complex | rescaled complex error function w(z) = exp(-z²) × erfc(-iz) |
| erfi(x) | real | imaginary error function erfi(x) = -i × erf(ix) |
| VP(x,sigma,gamma) | real | Voigt profile |
^
| String functions | ||
|---|---|---|
| Function | Arguments | Returns |
| gprintf("format",x,...) | any | string result from applying gnuplot's format parser |
| sprintf("format",x,...) | multiple | string result from C-language sprintf |
| strlen("string") | string | int length of string in bytes |
| strstrt("string","key") | strings | int index of first character of substring "key" |
| substr("string",beg,end) | multiple | string "string"[beg:end] |
| strftime("timeformat",t) | any | string result from applying gnuplot's time parser |
| strptime("timeformat",s) | string | seconds since year 1970 as given in string s |
| system("command") | string | string containing output stream of shell command |
| word("string",n) | string, int | returns the nth word in "string" |
| words("string") | string | returns the number of words in "string" |
^
| other gnuplot functions | ||
|---|---|---|
| Function | Arguments | Returns |
| column(x) | int or string | contents of column x during data input. |
| columnhead(x) | int | string containing first entry of column x in datafile. |
| exists("X") | string | returns 1 if a variable named X is defined, 0 otherwise. |
| hsv2rgb(h,s,v) | h,s,v in [0:1] | converts HSV color to 24bit RGB color. |
| stringcolumn(x) | int | content column x as a string. |
| timecolumn(N,format) | int, string | time data in column N during data input |
| tm_hour(x) | int | the hour |
| tm_mday(x) | int | the day of the month |
| tm_min(x) | int | the minute |
| tm_mon(x) | int | the month |
| tm_sec(x) | int | the second |
| tm_wday(x) | int | the day of the week |
| tm_yday(x) | int | the day of the year |
| tm_year(x) | int | the year |
| time(x) | any | the current system time |
| valid(x) | int | test validity of column(x) during datafile manip. |
| value("name") | string | returns the current value of the named variable. |
| Symbol | Example | Explanation |
|---|---|---|
| - | -a | unary minus |
| + | +a | unary plus (no-operation) |
| ~ | ~a | * one's complement |
| ! | !a | * logical negation |
| ! | a! | * factorial |
| $ | $3 | * call arg/column during `using` manipulation |
| Symbol | Example | Explanation |
|---|---|---|
| ** | a**b | exponentiation |
| * | a*b | multiplication |
| / | a/b | division |
| % | a%b | * modulo |
| + | a+b | addition |
| - | a-b | subtraction |
| == | a==b | equality |
| != | a!=b | inequality |
| < | a<b | less than |
| <= | a<=b | less than or equal to |
| > | a>b | greater than |
| >= | a>=b | greater than or equal to |
| << | 0xff<<1 | left shift unsigned |
| >> | 0xff>>1 | right shift unsigned |
| & | a&b | * bitwise AND |
| ^ | a^b | * bitwise exclusive OR |
| | | a|b | * bitwise inclusive OR |
| && | a&&b | * logical AND |
| || | a||b | * logical OR |
| = | a = b | assignment |
| , | (a,b) | serial evaluation |
| . | a.b | string concatenation |
| eq | A eq B | string equality |
| ne | A ne B | string inequality |
| Symbol | Example | Explanation |
|---|---|---|
| ?: | a?b:c | * ternary operation |