From decwrl!uunet!allbery Sun Mar 25 18:42:54 PST 1990
Article 1443 of comp.sources.misc:
Path: decwrl!uunet!allbery
From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
Newsgroups: comp.sources.misc
Subject: v11i068: Gnuplot 2.0 - 3 of 14
Message-ID: <82362@uunet.UU.NET>
Date: 26 Mar 90 00:11:09 GMT
Sender: allbery@uunet.UU.NET
Organization: Pixar -- Marin County, California
Lines: 1460
Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
Posting-number: Volume 11, Issue 68
Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
Archive-name: gnuplot2/part03
This is gnuplot.sh03
--- CUT HERE ---
#! /bin/sh
echo x - docs/gnuplot.doc
sed 's/^X//' >docs/gnuplot.doc <<'*-*-END-of-docs/gnuplot.doc-*-*'
X1 gnuplot
X?
X GNUPLOT is a command-driven interactive function plotting program. It
X is case sensitive (commands and function names written in lowercase
X are not the same as those written in CAPS). All command names may be
X abbreviated, as long as the abbreviation is not ambiguous. Any number
X of commands may appear on a line, separated by semicolons (;).
X
X Any command-line arguments are assumed to be names of files containing
X gnuplot commands. Each file is loaded with the `load` command, in the
X order specified. Gnuplot exits after the last file is processed.
X
X Commands may extend over several input lines, by ending each line but
X the last with a backslash (\). The backslash must be the LAST
X character on each line. The effect is as if the backslash and newline
X were not there. That is, no white space is implied, nor is a comment
X terminated. Therefore, commenting out a continued line comments out
X the entire command (see `comment`).
X
X In this documentation, curly braces ({}) denote optional arguments to
X many commands.
X
X For help on any topic, type 'help' followed by the name of the topic.
X2 clear
X?clear
X The `clear` command erases the current screen or output device as
X specified by `set output`. This usually generates a formfeed on
X hardcopy devices. Use `set terminal` to set the device type.
X2 comment
X?comments
X Comments are supported as follows: a # may appear in most places in a line
X and GNUPLOT will ignore the rest of the line. It will not have this
X affect inside quotes, inside numbers (including complex numbers), inside
X command substitutions, etc. In short, it works anywhere it makes sense
X to work.
X2 environment
X?environment
X A number of shell environment variables are understood by GNUPLOT.
X None of these are required, but may be useful.
X
X If GNUTERM is defined, it is used as the name of the terminal type to
X be used. This overrides any terminal type sensed by GNUPLOT on start
X up, but is itself overridden by the .gnuplot (or equivalent) start-up
X file (see help start-up), and of course by later explicit changes.
X
X On Unix and MS-DOS, GNUHELP may be defined to be the pathname of the
X HELP file (gnuplot.gih).
X
X On VMS, the symbol GNUPLOT$HELP should be defined as the name of
X the help library for gnuplot.
X
X On Unix, HOME is used as the name of a directory to search for a
X .gnuplot file if none is found in the current directory.
X On MS-DOS, GNUPLOT is used. On VMS, SYS$LOGIN: is used.
X See help start-up.
X
X On Unix, PAGER is used as an output filter for help messages. SHELL
X is used for the `shell` command.
X
X On MS-DOS, COMSPEC is used for the `shell` command.
X2 exit
X?exit
X?quit
X The commands `exit` and `quit` and your computer's END-OF-FILE character
X will exit GNUPLOT. All these commands will clear the output device
X (as the `clear` command does) before exiting.
X2 expressions
X?expressions
X In general, any mathematical expression accepted by C, FORTRAN,
X Pascal, or BASIC is valid. The precedence of these operators is
X determined by the specifications of the C programming language.
X White space (spaces and tabs) is ignored inside expressions.
X
X Complex constants may be expressed as the {,}, where
X and must be numerical constants. For example {3,2}
X represents 3 + 2i; {0,1} represents `i` itself. The curly braces
X are explicitly required here.
X3 functions
X?expressions functions
X?functions
X The functions in GNUPLOT are the same as the corresponding functions
X in the UNIX math library, except that all functions accept integer,
X real, and complex arguments, unless otherwise noted. The `sgn`
X function is also supported, as in BASIC.
X@start table
X#Function & Arguments & Returns \\ \hline
X%Function@Arguments@Returns
X%_
X4 abs
X?expressions functions abs
X?functions abs
X?abs
X#abs(x) & any & absolute value of {\tt x}, $|x|$; same type \\
X#abs(x) & complex & length of {\tt x}, $\sqrt{{\mbox{real}(x)^{2} +
X#\mbox{imag}(x)^{2}}}$ \\
X%abs(x)@any@absolute value of x, $|x|$; same type
X%abs(x)@complex@length of x, $sqrt{real (x) sup 2 + imag (x) sup 2}$
X The `abs` function returns the absolute value of its argument. The
X returned value is of the same type as the argument.
X
X For complex arguments, abs(x) is defined as the length of x in the
X complex plane [i.e., sqrt(real(x)**2 + imag(x)**2) ].
X4 acos
X?expressions functions acos
X?functions acos
X?acos
X#acos(x) & any & $\cos^{-1} x$ (inverse cosine) in radians \\
X%acos(x)@any@$cos sup -1 x$ (inverse cosine) in radians
X The `acos` function returns the arc cosine (inverse cosine) of its
X argument. `acos` returns its argument in radians.
X4 arg
X?expressions functions arg
X?functions arg
X?arg
X#arg(x) & complex & the phase of $x$ in radians\\
X%arg(x)@complex@the phase of $x$ in radians
X The `arg` function returns the phase of a complex number, in radians.
X4 asin
X?expressions functions asin
X?functions asin
X?asin
X#asin(x) & any & $\sin^{-1} x$ (inverse sin) in radians \\
X%asin(x)@any@$sin sup -1 x$ (inverse sin) in radians
X The `asin` function returns the arc sin (inverse sin) of its argument.
X `asin` returns its argument in radians.
X4 atan
X?expressions functions atan
X?functions atan
X?atan
X#atan(x) & any & $\tan^{-1} x$ (inverse tangent) in radians \\
X%atan(x)@any@$tan sup -1 x$ (inverse tangent) in radians
X The `atan` function returns the arc tangent (inverse tangent) of its
X argument. `atan` returns its argument in radians.
X4 besj0
X?expressions functions besj0
X?functions besj0
X?besj0
X#besj0(x) & radians & $j_{0}$ Bessel function of $x$ \\
X%besj0(x)@radians@$j sub 0$ Bessel function of $x$
X The `besj0` function returns the j0th Bessel function of its argument.
X `besj0` expects its argument to be in radians.
X4 besj1
X?expressions functions besj1
X?functions besj1
X?besj1
X#besj1(x) & radians & $j_{1}$ Bessel function of $x$ \\
X%besj1(x)@radians@$j sub 1$ Bessel function of $x$
X The `besj1` function returns the j1st Bessel function of its argument.
X `besj1` expects its argument to be in radians.
X4 besy0
X?expressions functions besy0
X?functions besy0
X?besy0
X#besy0(x) & radians & $y_{0}$ Bessel function of $x$ \\
X%besy0(x)@radians@$y sub 0$ Bessel function of $x$
X The `besy0` function returns the y0th Bessel function of its argument.
X `besy0` expects its argument to be in radians.
X4 besy1
X?expressions functions besy1
X?functions besy1
X?besy1
X#besy1(x) & radians & $y_{1}$ Bessel function of $x$ \\
X%besy1(x)@radians@$y sub 1$ Bessel function of $x$
X The `besy1` function returns the y1st Bessel function of its argument.
X `besy1` expects its argument to be in radians.
X4 ceil
X?expressions functions ceil
X?functions ceil
X?ceil
X#ceil(x) & any & $\lceil x \rceil$, smallest integer not less than $x$
X#(real part) \\
X%ceil(x)@any@$left ceiling x right ceiling$, smallest integer not less than $x$ (real part)
X The `ceil` function returns the smallest integer that is not less than its
X argument. For complex numbers, `ceil` returns the smallest integer
X not less than the real part of its argument.
X4 cos
X?expressions functions cos
X?functions cos
X?cos
X#cos(x) & radians & $\cos x$, cosine of $x$ \\
X%cos(x)@radians@$cos~x,$ cosine of $x$
X The `cos` function returns the cosine of its argument. `cos` expects its
X argument to be in radians.
X4 cosh
X?expressions functions cosh
X?functions cosh
X?cosh
X#cosh(x) & radians & $\cosh x$, hyperbolic cosine of $x$ \\
X%cosh(x)@radians@$cosh~x,$ hyperbolic cosine of $x$
X The `cosh` function returns the hyperbolic cosine of its argument.
X `cosh` expects its argument to be in radians.
X4 exp
X?expressions functions exp
X?functions exp
X?exp
X#exp(x) & any & $e^{x}$, exponential function of $x$ \\
X%exp(x)@any@$e sup x$, exponential function of $x$
X The `exp` function returns the exponential function of its argument
X (`e` raised to the power of its argument).
X4 floor
X?expressions functions floor
X?functions floor
X?floor
X#floor(x) & any & $\lfloor x \rfloor$, largest integer not greater
X#than $x$ (real part) \\
X%floor(x)@any@$left floor x right floor$, largest integer not greater than $x$ (real part)
X The `floor` function returns the largest integer not greater than its
X argument. For complex numbers, `floor` returns the largest
X integer not greater than the real part of its argument.
X4 imag
X?expressions functions imag
X?functions imag
X?imag
X#imag(x) & complex & imaginary part of $x$ as a real number \\
X%imag(x)@complex@imaginary part of $x$ as a real number
X The `imag` function returns the imaginary part of its argument as a
X real number.
X4 int
X?expressions functions int
X?functions int
X?int
X#int(x) & real & integer part of $x$, truncated toward zero \\
X%int(x)@real@integer part of $x,$ truncated toward zero
X The `int` function returns the integer part of its argument, truncated
X toward zero.
X4 log
X?expressions functions log
X?functions log
X?log
X#log(x) & any & $\log_{e} x$, natural logarithm (base $e$) of $x$ \\
X%log(x)@any@$ln~x,$ natural logarithm (base $e$) of $x$
X The `log` function returns the natural logarithm (base `e`) of its
X argument.
X4 log10
X?expressions functions log10
X?functions log10
X?log10
X#log10(x) & any & $\log_{10} x$, logarithm (base $10$) of $x$ \\
X%log10(x)@any@${log sub 10}~x,$ logarithm (base $10$) of $x$
X The `log10` function returns the logarithm (base 10) of its argument.
X4 real
X?expressions functions real
X?functions real
X?real
X#real(x) & any & real part of $x$ \\
X%real(x)@any@real part of $x$
X The `real` function returns the real part of its argument.
X4 sgn
X?expressions functions sgn
X?functions sgn
X?sgn
X#sgn(x) & any & 1 if $x>0$, -1 if $x<0$, 0 if $x=0$. imag($x$) ignored \\
X%sgn(x)@any@1 if $x > 0$, -1 if $x < 0$, 0 if $x = 0$. $imag (x)$ ignored
X The `sgn` function returns 1 if its argument is positive, -1 if its
X argument is negative, and 0 if its argument is 0. If the argument
X is a complex value, the imaginary component is ignored.
X4 sin
X?expressions functions sin
X?functions sin
X?sin
X#sin(x) & radians & $\sin x$, sine of $x$ \\
X%sin(x)@radians@$sin~x,$ sine of $x$
X The `sin` function returns the sine of its argument. `sin` expects its
X argument to be in radians.
X4 sinh
X?expressions functions sinh
X?functions sinh
X?sinh
X#sinh(x) & radians & $\sinh x$, hyperbolic sine $x$ \\
X%sinh(x)@radians@$sinh~x,$ hyperbolic sine $x$
X The `sinh` function returns the hyperbolic sine of its argument. `sinh`
X expects its argument to be in radians.
X4 sqrt
X?expressions functions sqrt
X?functions sqrt
X?sqrt
X#sqrt(x) & any & $\sqrt{x}$, square root of $x$ \\
X%sqrt(x)@any@$sqrt x $, square root of $x$
X The `sqrt` function returns the square root of its argument.
X4 tan
X?expressions functions tan
X?functions tan
X?tan
X#tan(x) & radians & $\tan x$, tangent of $x$ \\
X%tan(x)@radians@$tan~x,$ tangent of $x$
X The `tan` function returns the tangent of its argument. `tan` expects
X its argument to be in radians.
X4 tanh
X?expressions functions tanh
X?functions tanh
X?tanh
X#tanh(x) & radians & $\tanh x$, hyperbolic tangent of $x$\\
X%tanh(x)@radians@$tanh~x,$ hyperbolic tangent of $x$
X The `tanh` function returns the hyperbolic tangent of its argument.
X `tanh` expects its argument to be in radians.
X@end table
X3 operators
X?expressions operators
X?operators
X The operators in GNUPLOT are the same as the corresponding operators
X in the C programming language, except that all operators accept
X integer, real, and complex arguments, unless otherwise noted.
X The ** operator (exponentiation) is supported, as in FORTRAN.
X
X Parentheses may be used to change order of evaluation.
X4 binary
X?expressions operators binary
X?operators binary
X?binary
X The following is a list of all the binary operators and their
X usages:
X
X@start table - first is interactive cleartext form
X Symbol Example Explanation
X ** a**b exponentiation
X * a*b multiplication
X / a/b division
X % a%b * modulo
X + a+b addition
X - a-b subtraction
X == a==b equality
X != a!=b inequality
X & a&b * bitwise AND
X ^ a^b * bitwise exclusive OR
X | a|b * bitwise inclusive OR
X && a&&b * logical AND
X || a||b * logical OR
X ?: a?b:c * ternary operation
X#\multicolumn{3}{|c|}{Binary Operators} \\
X#Symbol & Example & Explanation \\ \hline
X#\verb~**~ & \verb~a**b~ & exponentiation\\
X#\verb~*~ & \verb~a*b~ & multiplication\\
X#\verb~/~ & \verb~a/b~ & division\\
X#\verb~%~ & \verb~a%b~ & * modulo\\
X#\verb~+~ & \verb~a+b~ & addition\\
X#\verb~-~ & \verb~a-b~ & subtraction\\
X#\verb~==~ & \verb~a==b~ & equality\\
X#\verb~!=~ & \verb~a!=b~ & inequality\\
X#\verb~&~ & \verb~a&b~ & * bitwise AND\\
X#\verb~^~ & \verb~a^b~ & * bitwise exclusive OR\\
X#\verb~|~ & \verb~a|b~ & * bitwise inclusive OR\\
X#\verb~&&~ & \verb~a&&b~ & * logical AND\\
X#\verb~||~ & \verb~a||b~ & * logical OR\\
X#\verb~?:~ & \verb~a?b:c~ & * ternary operation\\
X%Symbol@Example@Explanation
X%_
X%**@a**b@exponentiation
X%*@a*b@multiplication
X%/@a/b@division
X%%@a%b@* modulo
X%+@a+b@addition
X%-@a-b@subtraction
X%==@a==b@equality
X%!=@a!=b@inequality
X%&@a&b@* bitwise AND
X%^@a^b@* bitwise exclusive OR
X%|@a|b@* bitwise inclusive OR
X%&&@a&&b@* logical AND
X%||@a||b@* logical OR
X%?:@a?b:c@* ternary operation
X
X@end table
X (*) Starred explanations indicate that the operator requires
X integer arguments.
X
X Logical AND (&&) and OR (||) short-circuit the way they do in C.
X That is, the second && operand is not evaluated if the first is
X false; the second || operand is not evaluated if the first is true.
X
X The ternary operator evaluates its first argument (a). If it is
X true (non-zero) the second argument (b) is evaluated and returned,
X otherwise the third argument (c) is evaluated and returned.
X4 unary
X?expressions operators unary
X?operators unary
X?unary
X The following is a list of all the unary operators and their
X usages:
X
X@start table - first is interactive cleartext form
X Symbol Example Explanation
X - -a unary minus
X ~ ~a * one's complement
X ! !a * logical negation
X ! a! * factorial
X#\multicolumn{3}{|c|}{Unary Operators}\\
X#Symbol & Example & Explanation \\ \hline
X#\verb@-@ & \verb@-a@ & unary minus \\
X#\verb@~@ & \verb@~a@ & * one's complement \\
X#\verb@!@ & \verb@!a@ & * logical negation \\
X#\verb@!@ & \verb@a!@ & * factorial \\
X%-@-a@unary minus
X%~@~a@* one's complement
X%!@!a@* logical negation
X%!@a!@*factorial
X
X@end table
X (*) Starred explanations indicate that the operator requires an
X integer argument.
X
X The factorial operator returns a real number to allow a greater range.
X2 help
X?help
X The `help` command displays on-line help. To specify information on a
X particular topic use the syntax:
X
X help
X
X If is not specified, a short message is printed about
X GNUPLOT. After help for the requested topic is given, help for
X a subtopic may be requested by typing its name, extending the help
X request. After that subtopic has been printed, you may extend the
X request again, as before, or go back one level to the previous topic,
X by simply pressing return without typing anything. Eventually, you
X will return to the GNUPLOT command line.
X2 load
X?load
X The `load` command executes each line of the specified input file as
X if it had been typed in interactively. Files created by the `save`
X command can later be `load`ed. Any text file containing valid
X commands can be created and then executed by the `load` command.
X Files being `load`ed may themselves contain `load` commands. See
X `comment` for information about comments in commands.
X
X The `load` command must be the last command on the line.
X
X Syntax:
X load
X
X The name of the input file must be enclosed in quotes.
X
X Examples:
X
X load 'work.gnu'
X load "func.dat"
X
X The `load` command is performed implicitly on any file names given as
X arguments to gnuplot. These are loaded in the order specified, and
X then gnuplot exits.
X2 pause
X?pause
X Pause is useful in conjunction with `load` files. The command `pause`
X displays any text associated with the command and then waits the
X specified amount of time. This allows one to build a `load` file
X and control the amount of time a finished graph is displayed. The
X first argument is an expression that can be -1, 0, or a positive
X integer. Choosing -1 will wait until a carriage return is hit. Zero (0)
X won't pause at all, and a positive integer (such as 1 or 15) will
X wait the specified number of seconds.
X
X Note: Since pause is not part of the plot it may interact with
X different device drivers differently (depending upon how text and
X graphics are mixed).
X
X Examples:
X pause -1 ! Wait until a carriage return is hit
X pause 3 ! Wait three seconds
X pause -1 "Hit return to continue"
X pause 10 "Isn't this pretty? It's a cubic-spline."
X
X Syntax:
X pause {"string"}
X Note the string is optional, and if present must be enclosed in quotes.
X2 plot
X?plot
X `plot` is the primary command of the program. It plots functions and
X data in many, many ways. The full syntax of this command is:
X
X plot {ranges} {title} {style} {, {title} {style}...}
X
X Where is either a mathematical expression or the name of a
X data file enclosed in quotes. User-defined functions and variables
X may also be defined here.
X
X Curly braces {,} denote optional items.
X
X A `plot` command can be as simple as
X
X plot sin(x)
X
X or as complex as (!)
X
X plot [t=1:10] [-pi:pi*2] tan(t),"data.1" with lines,t**2 with points
X3 data-file
X?plot datafile
X?plot data-file
X?datafile
X?data-file
X?data
X Discrete data contained in a file can displayed by specifying the
X name of the data file (enclosed in quotes) on the `plot` command
X line.
X
X Data files should contain one data point per line. A data point may
X be specified either as an X and Y value separated by blank space, or
X as just the Y value, in which case the program will use the number
X of the coordinate as the X value. Coordinate numbers start at 0
X and are incremented for each data point read. Lines beginning with #
X (or ! on VMS) will be treated as comments and ignored.
X
X NOTE that blank lines cause a break in the input, and if the plot
X style is `lines` or `linespoints` (see `plot style`) there will be no
X line drawn between the preceding and following points. This does not
X change the plot style, as would plotting the data as separate curves.
X
X This example compares the data in the file population.dat to a
X theoretical curve:
X
X pop(x) = 103*exp((1965-x)/10)
X plot [1960:1990] 'population.dat', pop(x)
X
X The file population.dat might contain:
X
X # Gnu population in Antarctica since 1965
X 1965 103
X 1970 55
X 1975 34
X 1980 24
X 1985 10
X3 ranges
X?plot ranges
X?ranges
X The optional range specifies the region of the plot which will be displayed.
X
X Ranges may be provided on the `plot` command line and affect only
X that plot, or in the `set xrange` and `set yrange` commands, to
X change the default ranges for future plots.
X
X Syntax:
X [{dummy-var =} {xmin : xmax}] { [{ymin : ymax}] }
X
X Where dummy-var is the independent variable (the default is `x`,
X but this may be changed with the `set dummy` command) and the min
X and max terms can be expressions or constants.
X
X Both the min and max terms are optional. The ':' is also optional
X if neither a min nor a max term is specified. This allows '[]' to
X be used as a null range specification.
X
X Specifying a range in the `plot` command line turns autoscaling for
X that axis OFF for that plot. Using one of the `set` range commands
X turns autoscaling off for that axis for future plots, unless changed
X later. (See `set autoscale`).
X
X
X Examples:
X
X This uses current ranges:
X plot cos(x)
X
X This sets the xrange only:
X plot [-10:30] sin(pi*x)/(pi*x)
X
X This is the same, but uses t as the dummy-variable:
X plot [t = -10 :30] sin(pi*t)/(pi*t)
X
X This sets both the x and yranges:
X plot [-pi:pi] [-3:3] tan(x), 1/x
X
X This sets only the yrange:
X plot [] [-2:sin(5)*-8] sin(x)**besj0(x)
X
X This sets xmax and ymin only:
X plot [:200] [-pi:] exp(sin(x))
X3 style
X?plot style
X?style
X Plots may be displayed in one of four styles: `lines`, `points`,
X `linespoints`, `impulses`, or `dots`. The `lines` style connects
X adjacent points with lines. The `points` style displays a small
X symbol at each point. The `linespoints` style does both `lines` and
X `points`. The `impulses` style displays a vertical line from the X
X axis to each point. The `dots` style plots a tiny dot at each point;
X this is useful for scatter plots with many points.
X
X Default styles are chosen with the `set function style` and
X `set data style` commands.
X
X By default, each function and data file will use a different
X line type and point type, up to the maximum number of available
X types. All terminal drivers support at least six different point
X types, and re-use them, in order, if more than six are required.
X The LaTeX driver supplies an additional six point types (all variants
X of a circle), and thus will only repeat after twelve curves are
X plotted with points.
X
X If desired, the actual line type and point type used for a plot can
X be specified. Syntax:
X
X with