? `gnuplot` is a command-driven interactive function and data plotting program. For help on any topic, type `help` followed by the name of the topic. If the precise name of the topic is not known, type `help` and a menu will be given. Typing a question mark `?` after any `help` prompt will cause the menu to be listed again. The new `gnuplot` user should begin by reading the `introduction` topic (see `help introduction`) and the `plot` topic (see `help plot`). Additional help can be obtained from the USENET newsgroup comp.graphics.apps.gnuplot. ?copyright Copyright (C) 1986 - 1993 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 appears 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 modified code. Modifications are to be distributed as patches to the released version. This software is provided "as is" without express or implied warranty. 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. ?seeking-assistance There is a mailing list for `gnuplot` users. Note, however, that the newsgroup comp.graphics.apps.gnuplot is identical to the mailing list (they both carry the same set of messages). We prefer that you read the messages through the newsgroup rather than subscribing to the mailing list. Administrative requests should be sent to majordomo@dartmouth.edu Send a message with the body (not the subject) consisting of the single word "help" (without the quotes) for more details. The address for mailing to list members is: info-gnuplot@dartmouth.edu Bug reports and code contributions should be mailed to: bug-gnuplot@dartmouth.edu The list of those interested in beta-test versions is: info-gnuplot-beta@dartmouth.edu There is also a World Wide Web page with up-to-date information, including known bugs: http://www.cs.dartmouth.edu/gnuplot Before seeking help, please check the FAQ (Frequently Asked Questions) list. If you do not have a copy of the FAQ, you may request a copy by email from the Majordomo address above, or see the WWW `gnuplot` page. When posting a question, please include full details of the version of `gnuplot`, the machine, and operating system you are using. A _small_ script demonstrating the problem may be useful. Function plots are preferable to datafile plots. If email-ing to info-gnuplot, please state whether or not you are subscribed to the list, so that users who use news will know to email a reply to you. There is a form for such postings on the WWW site. ?introduction `gnuplot` is a command-driven interactive function plotting program. It is case sensitive (commands and function names written in lowercase are not the same as those written in CAPS). 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 are indicated with quotes. They may be either single or double quotation marks, e.g., load "filename" cd 'dir' although there are some subtle differences (see `syntax` for more details). Any command-line arguments are assumed to be names of files containing `gnuplot` commands, with the exception of standard X11 arguments, which are processed first. Each file is loaded with the `load` command, in the order specified. `gnuplot` exits after the last file is processed. When no load files are named, `gnuplot` enters into an interactive mode. 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 `comment`). In this documentation, 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. For help on any topic, type `help` followed by the name of the topic or just `help` to get a menu of available topics. The new `gnuplot` user should begin by reading about the `plot` command (type `help plot`). ?cd The `cd` command changes the working directory. Syntax: cd '' The directory name must be enclosed in quotes. Examples: cd 'subdir' cd ".." DOS users _must_ use single-quotes---backslash [\] has special significance inside double-quotes. For example, cd "c:\newdata" fails, but cd 'c:\newdata' works as expected. ?call The `call` command is identical to the load command with one exception: you can have up to ten additional parameters to the command (delimited according to the standard parser rules) which can be substituted into the lines read from the file. As each line is read from the `call`ed input file, it is scanned for the sequence `$` (dollar-sign) followed by a digit (0--9). If found, the sequence is replaced by the corresponding parameter from the `call` command line. If the parameter was specified as a string in the `call` line, it is substituted without its enclosing quotes. `$` followed by any character other than a digit will be that character. E.g. use `$$` to get a single `$`. Providing more than ten parameters on the `call` command line will cause an error. A parameter that was not provided substitutes as nothing. Files being `call`ed may themselves contain `call` or `load` commands. The `call` command MUST be the last command on a multi-command line. Syntax: call "" ... The name of the input file must be enclosed in quotes, and it is recommended that parameters are similarly enclosed in quotes. Example: If the file 'calltest.gp' contains the line: pause 0 "p0=$0 p1=$1 p2=$2 p3=$3 p4=$4 p5=$5 p6=$6 p7=x$7x" entering the command: call 'calltest.gp' "abcd" 1.2 + "'quoted'" -- "$2" will display: p0=abcd p1=1.2 p2=+ p3='quoted' p4=- p5=- p6=$2 p7=xx NOTE: there is a clash in syntax with the datafile `using` callback operator. Use $$n to access column n from a datafile inside a `call`ed datafile plot. ?clear The `clear` command erases the current screen or output device as specified by `set output`. This usually generates a formfeed on hardcopy devices. Use `set terminal` to set the device type. ?line-editing ?editing ?history ?command-line-editing Command-line editing is supported by the Unix, Atari, VMS, MS-DOS and OS/2 versions of `gnuplot`. Also, a history mechanism allows previous commands to be edited and re-executed. After the command line has been edited, a newline or carriage return will enter the entire line without regard to where the cursor is positioned. The editing commands are as follows: `Line-editing`: ^B moves back a single character. ^F moves forward a single character. ^A moves to the beginning of the line. ^E moves to the end of the line. ^H and DEL delete the previous character. ^D deletes the current character. ^K deletes from current position to the end of line. ^L,^R redraws line in case it gets trashed. ^U deletes the entire line. ^W deletes the last word. `History`: ^P moves back through history. ^N moves forward through history. On the IBM PC, the use of a TSR program such as DOSEDIT or CED may be desired for line editing. The default makefile assumes that this is the case; by default `gnuplot` will be compiled with no line-editing capability. If you want to use `gnuplot`'s line editing, set READLINE in the makefile and add readline.obj to the link file. The following arrow keys may be used on the IBM PC and Atari versions if readline is used: Left Arrow - same as ^B. Right Arrow - same as ^F. Ctrl Left Arrow - same as ^A. Ctrl Right Arrow - same as ^E. Up Arrow - same as ^P. Down Arrow - same as ^N. The Atari version of readline defines some additional key aliases: Undo - same as ^L. Home - same as ^A. Ctrl Home - same as ^E. Esc - same as ^U. Help - `help' plus return. Ctrl Help - `help '. (The readline function in `gnuplot` is not the same as the readline used in GNU Bash and GNU Emacs. It is somewhat compatible, however.) ?comments Comments are supported as follows: a # may appear in most places in a line and `gnuplot` will ignore the rest of the line. It will not have this effect inside quotes, inside numbers (including complex numbers), inside command substitutions, etc. In short, it works anywhere it makes sense to work. ?environment A number of shell environment variables are understood by `gnuplot`. None of these are required, but may be useful. If GNUTERM is defined, it is used as the name of the terminal type to be used. This overrides any terminal type sensed by `gnuplot` on start-up, but is itself overridden by the .gnuplot (or equivalent) start-up file (see `start-up`) and, of course, by later explicit changes. On Unix, AmigaDOS, AtariTOS, MS-DOS and OS/2, GNUHELP may be defined to be the pathname of the HELP file (gnuplot.gih). On VMS, the logical name gnuplot$HELP should be defined as the name of the help library for `gnuplot`. The `gnuplot` help can be put inside any system help library, allowing access to help from both within and outside `gnuplot` if desired. On Unix, HOME is used as the name of a directory to search for a .gnuplot file if none is found in the current directory. On AmigaDOS, AtariTOS, MS-DOS and OS/2, `gnuplot` is used. On VMS, SYS$LOGIN: is used. See `help start-up`. On Unix, PAGER is used as an output filter for help messages. On Unix, AtariTOS and AmigaDOS, SHELL is used for the `shell` command. On MS-DOS and OS/2, COMSPEC is used for the `shell` command. On MS-DOS, if the BGI interface is used, the variable `BGI` is used to point to the full path of the BGI drivers directory. Furthermore, SVGA is used to name the Super VGA BGI driver in 800x600 resolution and its mode of operation as 'Name.Mode'. E.g., if the Super VGA driver is C:\TC\BGI\SVGADRV.BGI and mode 3 is used for 800x600 resolution, then use 'set BGI=C:\TC\BGI' and 'set SVGA=SVGADRV.3'. FIT_SCRIPT may be used to specify a `gnuplot` command to be executed when a fit is interrupted---see `fit`. FIT_LOG specifies the filename of the logfile maintained by fit. ?exit ?quit The commands `exit` and `quit` and the END-OF-FILE character will exit `gnuplot`. Each of these commands will clear the output device (as does the `clear` command) before exiting. ?expressions In general, any mathematical expression accepted by C, FORTRAN, Pascal, or BASIC is valid. The precedence of these operators is determined by the specifications of the C programming language. White space (spaces and tabs) is ignored inside expressions. Complex constants are expressed as {,}, where and must be numerical constants. For example, {3,2} represents 3 + 2i; {0,1} represents `i` itself. The curly braces are explicitly required here. Note that gnuplot uses both "real" and "integer" arithmetic, like FORTRAN and C. Integers are entered as "1", "-10", etc; reals as "1.0", "-10.0", "1e1", 3.5e-1, etc. The most important difference between the two forms is in division: division of integers truncates: 5/2 = 1; division of reals does not: 5.0/2.0 = 2.5. In mixed expressions, integers are "promoted" to reals before evaluation: 5/2e1 = 2.5. The result of division of a negative integer by a positive one may vary among compilers. Try a test like "print -5/2" to determine if your system chooses -2 or -3 as the answer. The real and imaginary parts of complex expressions are always real, whatever the form in which they are entered: in {3,2} the "3" and "2" are reals, not integers. ?expressions functions ?functions The functions in `gnuplot` are the same as the corresponding functions in the Unix math library, except that all functions accept integer, real, and complex arguments, unless otherwise noted. The `sgn` function is also supported, as in BASIC. ?expressions functions abs ?functions abs ?abs The `abs` function returns the absolute value of its argument. The returned value is of the same type as the argument. For complex arguments, abs(x) is defined as the length of x in the complex plane [i.e., sqrt(real(x)**2 + imag(x)**2) ]. ?expressions functions acos ?functions acos ?acos The `acos` function returns the arc cosine (inverse cosine) of its argument. `acos` returns its argument in radians. ?expressions functions arg ?functions arg ?arg The `arg` function returns the phase of a complex number, in radians. ?expressions functions asin ?functions asin ?asin The `asin` function returns the arc sin (inverse sin) of its argument. `asin` returns its argument in radians. ?expressions functions atan ?functions atan ?atan The `atan` function returns the arc tangent (inverse tangent) of its argument. `atan` returns its argument in radians. ?expressions functions besj0 ?functions besj0 ?besj0 The `besj0` function returns the j0th Bessel function of its argument. `besj0` expects its argument to be in radians. ?expressions functions besj1 ?functions besj1 ?besj1 The `besj1` function returns the j1st Bessel function of its argument. `besj1` expects its argument to be in radians. ?expressions functions besy0 ?functions besy0 ?besy0 The `besy0` function returns the y0th Bessel function of its argument. `besy0` expects its argument to be in radians. ?expressions functions besy1 ?functions besy1 ?besy1 The `besy1` function returns the y1st Bessel function of its argument. `besy1` expects its argument to be in radians. ?expressions functions ceil ?functions ceil ?ceil The `ceil` function returns the smallest integer that is not less than its argument. For complex numbers, `ceil` returns the smallest integer not less than the real part of its argument. ?expressions functions column ?functions column ?column `column(x)` may be used only in expressions as part of `using` manipulations to fits or datafile plots. See `plot datafile using`. ?expressions functions cos ?functions cos ?cos The `cos` function returns the cosine of its argument. `cos` expects its argument to be in radians. ?expressions functions cosh ?functions cosh ?cosh The `cosh` function returns the hyperbolic cosine of its argument. `cosh` expects its argument to be in radians. ?expressions functions erf ?functions erf ?erf The `erf` function returns the error function of the real part of its argument. If the argument is a complex value, the imaginary component is ignored. ?expressions functions erfc ?functions erfc ?erfc The `erfc` function returns 1.0 - the error function of the real part of its argument. If the argument is a complex value, the imaginary component is ignored. ?expressions functions exp ?functions exp ?exp The `exp` function returns the exponential function of its argument (`e` raised to the power of its argument). On some implementations (notably suns), exp(-x) returns undefined for very large x. A user-defined function like safe(x) = x<-100 ? 0 : exp(x) might prove useful in these cases. ?expressions functions floor ?functions floor ?floor The `floor` function returns the largest integer not greater than its argument. For complex numbers, `floor` returns the largest integer not greater than the real part of its argument. ?expressions functions gamma ?functions gamma ?gamma The `gamma` function returns the gamma function of the real part of its argument. For integer n, gamma(n+1) = n!. If the argument is a complex value, the imaginary component is ignored. ?expressions functions ibeta ?functions ibeta ?ibeta The `ibeta` function returns the incomplete beta function of the real parts of its arguments. p, q > 0 and x in [0:1]. If the arguments are complex, the imaginary components are ignored. ?expressions functions inverf ?functions inverf ?inverf The `inverf` function returns the inverse error function of the real part of its argument. ?expressions functions igamma ?functions igamma ?igamma The `igamma` function returns the incomplete gamma function of the real parts of its arguments. a > 0 and x >= 0. If the arguments are complex, the imaginary components are ignored. ?expressions functions imag ?functions imag ?imag The `imag` function returns the imaginary part of its argument as a real number. ?expressions functions invnorm ?functions invnorm ?invnorm The `invnorm` function returns the inverse normal distribution function of the real part of its argument. ?expressions functions int ?functions int ?int The `int` function returns the integer part of its argument, truncated toward zero. ?expressions functions lgamma ?functions lgamma ?lgamma The `lgamma` function returns the natural logarithm of the gamma function of the real part of its argument. If the argument is a complex value, the imaginary component is ignored. ?expressions functions log ?functions log ?log The `log` function returns the natural logarithm (base `e`) of its argument. ?expressions functions log10 ?functions log10 ?log10 The `log10` function returns the logarithm (base 10) of its argument. ?expressions functions norm ?functions norm ?norm The `norm` function returns the normal distribution function (or Gaussian) of the real part of its argument. ?expressions functions rand ?functions rand ?rand The `rand` function returns a pseudo random number in the interval [0:1] using the real part of its argument as a seed. If seed < 0, the sequence is (re)initialized. If the argument is a complex value, the imaginary component is ignored. ?expressions functions real ?functions real ?real The `real` function returns the real part of its argument. ?expressions functions sgn ?functions sgn ?sgn The `sgn` function returns 1 if its argument is positive, -1 if its argument is negative, and 0 if its argument is 0. If the argument is a complex value, the imaginary component is ignored. ?expressions functions sin ?functions sin ?sin The `sin` function returns the sine of its argument. `sin` expects its argument to be in radians. ?expressions functions sinh ?functions sinh ?sinh The `sinh` function returns the hyperbolic sine of its argument. `sinh` expects its argument to be in radians. ?expressions functions sqrt ?functions sqrt ?sqrt The `sqrt` function returns the square root of its argument. ?expressions functions tan ?functions tan ?tan The `tan` function returns the tangent of its argument. `tan` expects its argument to be in radians. ?expressions functions tanh ?functions tanh ?tanh The `tanh` function returns the hyperbolic tangent of its argument. `tanh` expects its argument to be in radians. ?expressions functions valid ?functions valid ?valid `valid(x)` may be used only in expressions as part of `using` manipulations to fits or datafile plots. See `plot datafile using`. ?expressions operators ?operators The operators in `gnuplot` are the same as the corresponding operators in the C programming language, except that all operators accept integer, real, and complex arguments, unless otherwise noted. The ** operator (exponentiation) is supported, as in FORTRAN. Parentheses may be used to change order of evaluation. ?expressions operators unary ?operators unary ?unary The following is a list of all the unary operators and their usages: 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 (*) Starred explanations indicate that the operator requires an integer argument. The factorial operator returns a real number to allow a greater range. ?expressions operators binary ?operators binary ?binary The following is a list of all the binary operators and their usages: 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 a>b greater than >= a>=b greater than or equal to & a&b * bitwise AND ^ a^b * bitwise exclusive OR | a|b * bitwise inclusive OR && a&&b * logical AND || a||b * logical OR (*) Starred explanations indicate that the operator requires integer arguments. Logical AND (&&) and OR (||) short-circuit the way they do in C. That is, the second && operand is not evaluated if the first is false; the second || operand is not evaluated if the first is true. ?expressions operators ternary ?operators ternary ?ternary There is a single ternary operator: Symbol Example Explanation ?: a?b:c ternary operation The ternary operator behaves as it does in C. The first argument (a), which must be an integer, is evaluated. If it is true (non-zero), the second argument (b) is evaluated and returned; otherwise the third argument (c) is evaluated and returned. The ternary operator is very useful both in constructing piecewise functions and in plotting points only when certain conditions are met. Examples: Plot a function that is to equal sin(x) for 0 <= x < 1, 1/x for 1 <= x < 2, and undefined elsewhere: f(x) = 0<=x & x<1 ? sin(x) : 1<=x & x<2 ? 1/x : 1/0 plot f(x) Note that `gnuplot` quietly ignores undefined values, so the final branch of the function (1/0) will produce no plottable points. Note also that it is plotted as a continuous function across the discontinuity if a line style is used. If you want it to be plotted discontinuously, create separate functions for the two pieces. For data in a file, plot the average of the data in columns 2 and 3 against the datum in column 1, but only if the datum in column 4 is non-negative: plot 'file' using 1:( $4<0 ? 1/0 : ($2+$3)/2 ) Please see `plot data-file using` for an explanation of the `using` syntax. ?fit This implementation incorporates the capability of nonlinear least squares fitting using the Marquardt-Levenberg Algorithm. It may fit any user-defined function to any set of data pairs (x,y). x, y and the function's return type MUST be real! Any variable occurring in the function body may serve as a fit parameter (fitting functions without adjustable parameters make no sense). Syntax: fit {range} '' {datafile-modifiers} \ via {'' | ,,...} Notice that `via` is now a required keyword, to distinguish it from a scanf format string. {[range]} is [ {variable=} { } { : } ], allowing the range of the fit to be limited temporarily in a manner analogous to `plot`. is any valid `gnuplot` expression, although it is usual to use a previously user-defined function of the form f(x). is treated as in the `plot` command. All the modifiers for datafiles (`using`, `every`,...) in `plot` are available here---see `plot datafile` for full details. The default column for x is 1 for y is 2. They may be changed by the `using x:y` mechanism. If a third column or expression is specified with `using`, uncertainties are read for each y value, to be used as weights during the fit. Otherwise all data are weighted equally. The start parameters may be specified in a (load-) file wherein each line is of the form: varname = value Comments, marked by '#', and blank lines are permissible. The form varname = value # FIXED means that the variable is treated as a `fixed parameter` that is initialized but will not be adjusted. It is not necessary (but sometimes useful for clarity) to specify them at all. The keyword '# FIXED' has to appear in exactly this form. The other means of specifying the adjustable parameters is to provide a comma-separated list of variable names after the `via` keyword. If any of these variables do not yet exist within the current `gnuplot` session, they are created with an initial value of 1.0, but the fit is more likely to converge if a more appropriate starting value is given. If this form is used, it may prove beneficial to iterate the fit, allowing only one or two variables to be adjusted at a time until a reasonably close fit is obtained, before allowing `fit` to vary all parameters. After each iteration step, detailed information is given about the fit's state, both on the screen and on a logfile "fit.log". This file will never be erased but always appended to so that the fit's history isn't lost. After each iteration step, the fit may be interrupted by pressing Ctrl-C (any key BUT Ctrl-C under MSDOS and Atari Multitasking Systems). Then you have the options of stopping (and accepting the current parameter values), continuing the iteration of the fit, or executing a `gnuplot` command specified by an environment variable FIT_SCRIPT. A `plot` or `load` command may be useful in this context. Special `gnuplot` variables: FIT_INDEX contains the current data point number during execution, starting with 1. You may use it in your fit function to implement multiple-branch fits. FIT_LIMIT may be specified to change the default epsilon limit (1e-5). When the sum of squared residuals changes between two iteration steps by less than a factor of this number, the fit is considered to have 'converged'. (FIT_SKIP was available in previous released of gnufit. Its functionality is now obtained using the `every` modifier for datafiles.) Environment variables: FIT_LOG changes the logfile's path from './fit.log' (write permission is necessary). FIT_SCRIPT specifies a command to be executed after an user interrupt. Examples: f(x) = a*x**2 + b*x + c fit f(x) 'measured.dat' via 'start.par' fit f(x) 'measured.dat' using 3:($7-5) via 'start.par' fit f(x) './data/trash.dat' using 1:2:3 via a, b, c SEE ALSO: `update` ?help The `help` command displays on-line help. To specify information on a particular topic use the syntax: help {} If is not specified, a short message is printed about `gnuplot`. After help for the requested topic is given, a menu of subtopics is given; help for a subtopic may be requested by typing its name, extending the help request. After that subtopic has been printed, the request may be extended again or you may go back one level to the previous topic. Eventually, the `gnuplot` command line will return. If a question mark (?) is given as the topic, the list of topics currently available is printed on the screen. ?if The `if` command allows commands to be executed conditionally. Syntax: if () will be evaluated. If it is true (non-zero), then the command(s) of the will be executed. If is false (zero), then the entire is ignored. Note that use of ';' to allow multiple commands on the same line will NOT end the conditionalized commands. Examples: pi=3 if (pi!=acos(-1)) pause 0 "?Fixing pi!";pi=acos(-1);show variables will display: ?Fixing pi! Variables: pi = 3.14159 but if (1==2) pause 0 "Never see this";pause 0 "Or this either" will not display anything. ?load The `load` command executes each line of the specified input file as if it had been typed in interactively. Files created by the `save` command can later be `load`ed. Any text file containing valid commands can be created and then executed by the `load` command. Files being `load`ed may themselves contain `load` or `call` commands. See `comment` for information about comments in commands. The `load` command MUST be the last command on a multi-command line. Syntax: load "" The name of the input file must be enclosed in quotes. Examples: load 'work.gnu' load "func.dat" The `load` command is performed implicitly on any file names given as arguments to `gnuplot`. These are loaded in the order specified, and then `gnuplot` exits. See also `call`. ?pause The `pause` command displays any text associated with the command and then waits a specified amount of time or until the carriage return is pressed. `pause` is especially useful in conjunction with `load` files. Syntax: pause