home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume24
/
gnuplot3
/
part10
< prev
next >
Wrap
Text File
|
1991-10-27
|
50KB
|
1,526 lines
Newsgroups: comp.sources.misc
From: gershon%gr@cs.utah.edu (Elber Gershon)
Subject: v24i032: gnuplot3 - interactive function plotting utility, Part10/26
Message-ID: <1991Oct28.002111.12035@sparky.imd.sterling.com>
X-Md4-Signature: d552b94adbfaec352034e3662dbd63ca
Date: Mon, 28 Oct 1991 00:21:11 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
Posting-number: Volume 24, Issue 32
Archive-name: gnuplot3/part10
Environment: UNIX, MS-DOS, VMS
Supersedes: gnuplot2: Volume 11, Issue 65-79
#!/bin/sh
# this is Part.10 (part 10 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file gnuplot/docs/gnuplot.doc continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 10; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping gnuplot/docs/gnuplot.doc'
else
echo 'x - continuing file gnuplot/docs/gnuplot.doc'
sed 's/^X//' << 'SHAR_EOF' >> 'gnuplot/docs/gnuplot.doc' &&
?nozeroaxis
X `set zeroaxis` draws the x-axis and y-axis. By default, this option is
X on. `set nozeroaxis` causes GNUPLOT to omit the axes, and is
X equivalent to `set noxzeroaxis; set noyzeroaxis.`
X
X Syntax:
X set zeroaxis
X set nozeroaxis
X show zeroaxis
X See `set xzeroaxis` and `set yzeroaxis`.
3 zlabel
?set zlabel
?show zlabel
?zlabel
X The `set zlabel` command sets the z-axis label that is centered along
X the z axis. Using the optional x,y screen offsets, the label can be
X placed anywhere on the plot. `set zlabel` with no parameters clears
X the label.
X
X Syntax:
X set zlabel {"<label>"} {<xoff>}{,<yoff>}
X show zlabel
X
X Specifying constants <xoff> or <yoff> as optional offsets for the
X label will move the label <xoff> or <yoff> character screen
X coordinates. For example,
X
X set zlabel ,1
X
X will change only the y offset of the zlabel, moving the label roughly
X one character height up.
X
X The zlabel will be drawn whenever surfaces or contours are plotted,
X in the space above the grid level.
X
X (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
X a newline.)
3 zrange
?set zrange
?show zrange
?zrange
X The `set zrange` command sets the vertical range that will be
X displayed. This command turns z axis autoscaling off. The zrange is
X used only by `splot` and is ignored by `plot`.
X
X This range may also be specified on the `splot` command line.
X
X Syntax:
X set zrange [{<zmin> : <zmax>}]
X
X where <zmin> and <zmax> terms are constants or expressions.
X
X Both the <zmin> and <zmax> terms are optional. Anything omitted will
X not be changed, so
X set zrange [2:]
X changes zmin to 2 without affecting zmax.
3 ztics
?set ztics
?set noztics
?show ztics
?ztics
?noztics
X The `set ztics` and `set noztics` commands are similar to the `set
X xtics` and `set noxtics` commands. Please see `set xtics`.
2 shell
?shell
X The `shell` command spawns an interactive shell. To return to
X GNUPLOT, type `logout` if using VMS, `exit` or the END-OF-FILE
X character if using Unix, `endcli` if using AmigaDOS, or `exit` if
X using MS-DOS.
X
X A single shell command may be spawned by preceding it with the !
X character ($ if using VMS) at the beginning of a command line.
X Control will return immediately to GNUPLOT after this command is
X executed. For example, in VMS, AmigaDOS, or MS-DOS,
X
X ! dir
X
X prints a directory listing and then returns to GNUPLOT.
2 splot
X Three-dimensional surface and contour plotting is available in
X GNUPLOT with the `splot` command. See the `plot` command for features
X common to the `plot` command.
X
X See also `set contour`, `set cntrparam`, and `set surface`.
2 start-up
?startup
?start
?.gnuplot
X When GNUPLOT is run, it looks for an initialization file to load.
X This file is called `.gnuplot` on Unix and AmigaDOS systems, and
X `GNUPLOT.INI` on other systems. If this file is not found in the
X current directory, the program will look for it in the home directory
X (under AmigaDOS and MS-DOS, the environment variable GNUPLOT should
X contain the name of this directory).
X
X If this file is found, GNUPLOT executes the commands in this file.
X This is most useful for setting the terminal type and defining any
X functions or variables that are used often.
2 substitution
?substitution
X Command-line substitution is specified by a system command enclosed in
X backquotes. This command is spawned and the output it produces
X replaces the name of the command (and backquotes) on the command line.
X
X Newlines in the output produced by the spawned command are replaced
X with blanks.
X
X Command-line substitution can be used anywhere on the GNUPLOT command
X line.
X
X Example:
X
X This will run the program `leastsq` and replace `leastsq` (including
X backquotes) on the command line with its output:
X
X f(x) = `leastsq`
X
X or, in VMS
X
X f(x) = `run leastsq`
2 user-defined
?userdefined
?variables
X New user-defined variables and functions of one or two variables may be
X declared and used anywhere.
X
X User-defined function syntax:
X <function-name> ( <dummy-var1> {,<dummy-var2>} ) = <expression>
X
X where <expression> is defined in terms of <dummy-var1> and <dummy-var2>.
X
X User-defined variable syntax:
X <variable-name> = <constant-expression>
X
X Examples:
X w = 2
X q = floor(tan(pi/2 - 0.1))
X f(x) = sin(w*x)
X sinc(x) = sin(pi*x)/(pi*x)
X delta(t) = (t == 0)
X ramp(t) = (t > 0) ? t : 0
X min(a,b) = (a < b) ? a : b
X comb(n,k) = n!/(k!*(n-k)!)
X
X Note that the variable `pi` is already defined.
X
X See `show functions` and `show variables`.
2 bugs
?bugs
X The atan() function does not work correctly for complex arguments.
X
X The bessel functions do not work for complex arguments.
X
X The gamma function does not work for complex arguments.
X
X There is a bug in the stdio library for old Sun operating systems
X (SunOS Sys4-3.2). The "%g" format for 'printf' sometimes incorrectly
X prints numbers (e.g., 200000.0 as "2"). Thus, tic mark labels may be
X incorrect on a Sun4 version of GNUPLOT. A work-around is to rescale
X the data or use the `set format` command to change the tic mark format
X to "%7.0f" or some other appropriate format. This appears to have been
X fixed in SunOS 4.0.
X
X Another bug: On a Sun3 under SunOS 4.0, and on Sun4's under Sys4-3.2
X and SunOS 4.0, the 'sscanf' routine incorrectly parses "00 12" with
X the format "%f %f" and reads 0 and 0 instead of 0 and 12. This
X affects data input. If the data file contains x coordinates that are
X zero but are specified like '00', '000', etc, then you will read the
X wrong y values. Check any data files or upgrade the SunOS.
X It appears to have been fixed in SunOS 4.1.1.
X
X Microsoft C 5.1 has a nasty bug associated with the %g format for
X printf. When any of the formats "%.2g", "%.1g", "%.0g", "%.g" are
X used, printf will incorrectly print numbers in the range 1e-4 to 1e-1.
X Numbers that should be printed in the %e format are incorrectly
X printed in the %f format, with the wrong number of zeros after the
X decimal point.
X
X To work around this problem, use the %e or %f formats explicitly.
X
X GNUPLOT, when compiled with Microsoft C, did not work correctly on two
X VGA displays that were tested. The CGA, EGA and VGA drivers should
X probably be rewritten to use the Microsoft C graphics library.
X GNUPLOT compiled with Turbo C uses the Turbo C graphics drivers and
X does work correctly with VGA displays.
X
X VAX/VMS 4.7 C compiler release 2.4 also has a poorly implemented %g
X format for printf. The numbers are printed numerically correct, but
X may not be in the requested format. The K&R second edition says that
X for the %g format, %e is used if the exponent is less than -4 or greater
X than or equal to the precision. The VAX uses %e format if the exponent
X is less than -1. The VAX appears to take no notice of the precision
X when deciding whether to use %e or %f for numbers less than 1.
X To work around this problem, use the %e or %f formats explicitly.
X From the VAX C 2.4 release notes:
X e,E,f,F,g,G Result will always contain a decimal point.
X For g and G, trailing zeros will not be removed from the result.
X
X VAX/VMS 5.2 C compiler release 3.0 has a slightly better implemented
X %g format than release 2.4, but not much. Trailing decimal points are
X now removed, but trailing zeros are still not removed from %g numbers
X in exponential format.
X
X ULTRIX X11R3 has a bug that causes the X11 driver to display "every
X other" plot. The bug seems to be fixed in DEC's release of X11R4 so
X newer releases of ULTRIX don't seem to have the problem. Solutions for
X older sites include upgrading the X11 libraries (from DEC or direct from
X MIT) or defining ULTRIX_KLUDGE when compiling the x11.trm file. Note
X that the kludge is not an ideal fix, however.
X
X The constant HUGE was incorrectly defined in the NeXT OS 2.0 operating
X system. HUGE should be set to 1e38 in plot.h. This error has been
X corrected in the 2.1 version of NeXT OS.
X
X Please report any bugs to pixar!bug-gnuplot@sun.com or
X pixar!bug-gnuplot@ucbvax.berkeley.edu.
SHAR_EOF
echo 'File gnuplot/docs/gnuplot.doc is complete' &&
chmod 0644 gnuplot/docs/gnuplot.doc ||
echo 'restore of gnuplot/docs/gnuplot.doc failed'
Wc_c="`wc -c < 'gnuplot/docs/gnuplot.doc'`"
test 90586 -eq "$Wc_c" ||
echo 'gnuplot/docs/gnuplot.doc: original size 90586, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/lasergnu.1 ==============
if test -f 'gnuplot/docs/lasergnu.1' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/lasergnu.1 (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/lasergnu.1 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/lasergnu.1' &&
.TH LASERGNU l
.SH NAME
lasergnu \- send gnuplot output to a printer
.SH SYNOPSIS
.B lasergnu
[ flags ] plot-command...
.SH DESCRIPTION
.I lasergnu
runs
.IR gnuplot (1)
in an environment to produce typeset output on an IMAGEN or
Postscript printer.
.PP
The
.B gnuplot
commands
.B plot-command
are performed and the output sent to the printer.
If the
.B -f
option specifies a file for input, the plot command is optional.
The command-line plot commands are executed prior to any in the
file(s).
.PP
For example, to plot the function
.I sin(x)
from -1 to +1, and to use printer im1, use the command
.br
.nf
X lasergnu -Pim1 'plot [-1:1] sin(x) with lines'
.fi
To execute the gnuplot command file
.I myplot,
on the postscript printer lw0, use the command
.br
.nf
X lasergnu -Plw0 -p -f myplot
.fi
The following switches are recognized:
.TP
.BI \-p
Use the postscript language to make the plot, instead of Impress.
This is for use on Postscript printers only. This uses a double-size
plot in landscape mode as the default.
.TP
.BI \-P\0 printer
The output of this program is intended for
.I printer.
\ If the file is being spooled, this determines the printer it is spooled
to (default: $LASER).
Be sure to use the -p flag if the printer is a postscript printer.
.TP
.BI \-f\0 file
Take gnuplot commands from the named file.
Multiple files may be supplied with separate -f options.
.TP
.BI \-t\0 title
Specify the title of the plot.
.TP
.BI \-b
Do not print a banner page.
.TP
.BI \-J
Do not print a banner page.
.TP
.B \-help
Prints a list of options.
.SH SEE ALSO
gnuplot(l), lpr(1)
SHAR_EOF
chmod 0644 gnuplot/docs/lasergnu.1 ||
echo 'restore of gnuplot/docs/lasergnu.1 failed'
Wc_c="`wc -c < 'gnuplot/docs/lasergnu.1'`"
test 1594 -eq "$Wc_c" ||
echo 'gnuplot/docs/lasergnu.1: original size 1594, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/Makefile ==============
if test ! -d 'gnuplot/docs/latextut'; then
echo 'x - creating directory gnuplot/docs/latextut'
mkdir 'gnuplot/docs/latextut'
fi
if test -f 'gnuplot/docs/latextut/Makefile' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/Makefile (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/Makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/Makefile' &&
# Makefile for gnuplot LaTeX tutorial
# To make the manual from scratch, we run latex two times
all: tutorial.dvi done
X
done:
X latex tutorial
X echo > done
X
# To touch it up after changes:
remake: tutorial.dvi
X
# Always runs latex, e.g., to get labels right
force:
X latex tutorial
X
tutorial.dvi: eg1.tex eg2.tex eg3.tex eg4.tex eg5.tex eg6.tex linepoint.tex \
X tutorial.tex header.tex
X latex tutorial
X rm -f done
X
.SUFFIXES: .tex .plt
X
.plt.tex:
X gnuplot $<
X
clean:
X rm -f *~ *.log eg?.tex linepoint.tex
X
spotless:
X rm -f *~ *.log *.aux *.dvi eg?.tex linepoint.tex done
SHAR_EOF
chmod 0644 gnuplot/docs/latextut/Makefile ||
echo 'restore of gnuplot/docs/latextut/Makefile failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/Makefile'`"
test 570 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/Makefile: original size 570, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/eg1.plt ==============
if test -f 'gnuplot/docs/latextut/eg1.plt' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/eg1.plt (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/eg1.plt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/eg1.plt' &&
set terminal latex
set output "eg1.tex"
plot [-3.14:3.14] sin(x)
SHAR_EOF
chmod 0666 gnuplot/docs/latextut/eg1.plt ||
echo 'restore of gnuplot/docs/latextut/eg1.plt failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/eg1.plt'`"
test 65 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/eg1.plt: original size 65, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/eg2.plt ==============
if test -f 'gnuplot/docs/latextut/eg2.plt' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/eg2.plt (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/eg2.plt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/eg2.plt' &&
set terminal latex
set output "eg2.tex"
set size 5/5., 4/3.
set format xy "$%g$"
set title "This is a plot of $y=sin(x)$"
set xlabel "This is the $x$ axis"
set ylabel "This is\\the\\$y$ axis"
plot [0:6.28] [0:1] sin(x)
SHAR_EOF
chmod 0666 gnuplot/docs/latextut/eg2.plt ||
echo 'restore of gnuplot/docs/latextut/eg2.plt failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/eg2.plt'`"
test 219 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/eg2.plt: original size 219, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/eg3.dat ==============
if test -f 'gnuplot/docs/latextut/eg3.dat' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/eg3.dat (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/eg3.dat (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/eg3.dat' &&
-20.000000 -9.125028
-19.000000 -9.109280
-18.000000 -9.091787
-17.000000 -9.072243
-16.000000 -9.050265
-15.000000 -9.025369
-14.000000 -8.996933
-13.000000 -8.964147
-12.000000 -8.925931
-11.000000 -8.880819
-10.000000 -8.826766
-9.000000 -8.760835
-8.000000 -8.678648
-7.000000 -8.573396
-6.000000 -8.433886
-5.000000 -8.240405
-4.000000 -7.954906
-3.000000 -7.494275
-2.000000 -6.642892
-1.000000 -4.712389
0.000000 0.000000
1.000000 4.712389
2.000000 6.642892
3.000000 7.494275
4.000000 7.954906
5.000000 8.240405
6.000000 8.433886
7.000000 8.573396
8.000000 8.678648
9.000000 8.760835
10.000000 8.826766
11.000000 8.880819
12.000000 8.925931
13.000000 8.964147
14.000000 8.996933
15.000000 9.025369
16.000000 9.050265
17.000000 9.072243
18.000000 9.091787
19.000000 9.109280
SHAR_EOF
chmod 0666 gnuplot/docs/latextut/eg3.dat ||
echo 'restore of gnuplot/docs/latextut/eg3.dat failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/eg3.dat'`"
test 781 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/eg3.dat: original size 781, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/eg3.plt ==============
if test -f 'gnuplot/docs/latextut/eg3.plt' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/eg3.plt (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/eg3.plt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/eg3.plt' &&
set terminal latex
set output "eg3.tex"
set format xy "$%g$"
set title "This is another plot"
set xlabel "$x$ axis"
set ylabel "$y$ axis"
set key 15,-10
plot x with lines, "eg3.dat" with linespoints
SHAR_EOF
chmod 0666 gnuplot/docs/latextut/eg3.plt ||
echo 'restore of gnuplot/docs/latextut/eg3.plt failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/eg3.plt'`"
test 199 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/eg3.plt: original size 199, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/eg4.plt ==============
if test -f 'gnuplot/docs/latextut/eg4.plt' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/eg4.plt (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/eg4.plt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/eg4.plt' &&
set terminal latex
set output "eg4.tex"
set format y "$%g$"
set format x "$%.2f$"
set title "This is $\sin(x)$"
set xlabel "This is the $x$ axis"
set ylabel "$\sin(x)$"
set nokey
set xtics -pi, pi/4
plot [-pi:pi] [-1:1] sin(x)
SHAR_EOF
chmod 0666 gnuplot/docs/latextut/eg4.plt ||
echo 'restore of gnuplot/docs/latextut/eg4.plt failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/eg4.plt'`"
test 227 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/eg4.plt: original size 227, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/eg5.plt ==============
if test -f 'gnuplot/docs/latextut/eg5.plt' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/eg5.plt (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/eg5.plt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/eg5.plt' &&
set terminal latex
set output "eg5.tex"
set format y "$%g$"
set format x "$%4.1f\pi$"
set noclip points
set title "This is $\sin(x)$"
set xlabel "This is the $x$ axis"
set ylabel "$\sin(x)$"
set nokey
set xtics ("$-\pi$" -pi,\
X "$-\frac{\pi}{2}$" -pi/2,\
X "0" 0,\
X "$\frac{\pi}{2}$" pi/2,\
X "$\pi$" pi)
plot [-pi:pi] [-1:1] sin(x)
SHAR_EOF
chmod 0666 gnuplot/docs/latextut/eg5.plt ||
echo 'restore of gnuplot/docs/latextut/eg5.plt failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/eg5.plt'`"
test 331 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/eg5.plt: original size 331, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/eg6.plt ==============
if test -f 'gnuplot/docs/latextut/eg6.plt' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/eg6.plt (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/eg6.plt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/eg6.plt' &&
set terminal latex
set output "eg6.tex"
set size 3.5/5, 3/3.
set format y "$%g$"
set format x "$%5.1f\mu$"
set title "This is a title"
set xlabel "This is the $x$ axis"
set ylabel "This is\\a longer\\version\\ of\\the $y$\\ axis"
set label "Data" at -5,-5 right
set arrow from -5,-5 to -3.3,-6.7
set key -4,8
set xtic -10,5,10
plot [-10:10] [-10:10] "eg3.dat" title "Data File" with linespoints 1 7,\
X 3*exp(-x*x)+1 title "$3e^{-x^{2}}+1$" with lines 4
SHAR_EOF
chmod 0666 gnuplot/docs/latextut/eg6.plt ||
echo 'restore of gnuplot/docs/latextut/eg6.plt failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/eg6.plt'`"
test 457 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/eg6.plt: original size 457, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/header.tex ==============
if test -f 'gnuplot/docs/latextut/header.tex' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/header.tex (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/header.tex (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/header.tex' &&
%
% Header file for tutorial.tex
%
X
% Spacing
\newcommand{\singlespace}
X {\addtolength{\baselineskip}{-.333\baselineskip}}
\newcommand{\doublespace}
X {\addtolength{\baselineskip}{.5\baselineskip}}
X
% Spacing for the whole document
\newcommand{\currentspace}{} % use this for single space
% \newcommand{\currentspace}{\doubleespace} % use this for double space
X
% Common abbreviations
% (Remember to put '\ ' after if an interword space is
% desired rather than end-of-sentence space. Same for '.etc)' ).
\newcommand{\eg}{{\em e.g.}} % e.g.
\newcommand{\ie}{{\em i.e.}} % i.e.
\newcommand{\etc}{{\em etc.}} % etc.
\newcommand{\vs}{{\em vs.}} % vs.
\newcommand{\usec}{{$\mu$}sec} % microseconds
X
% \boxfigure{pos}{wid}{text}: A figure with a box around it
%
% pos the usual figure placement arg: eg. htbp
% wid the width of the figure, in some units: eg. 5in
% text the contents of the figure, including picture/caption/label/etc
%
\newlength{\boxwidth}
\newcommand{\boxfigure}[3]{
X \begin{figure}[#1]
X \setlength{\boxwidth}{#2}
X \addtolength{\boxwidth}{.1in}
X
X \centering
X \framebox[\boxwidth]{
X \begin{minipage}{#2}
X #3
X \end{minipage}
X }
X \end{figure}
}
X
% use \fullboxwidth for arg 2 of boxfigure to get box of size \textwidth
X
% To show a syntax for a gnutex command
\newenvironment{syntax}{\begin{quote}\tt}{\end{quote}}
X
\documentstyle[titlepage,11pt]{article}
X
% Margins
\sloppy
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{9in}
\setlength{\topmargin}{-0.5in}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
X
% see above
\newlength{\fullboxwidth}
\setlength{\fullboxwidth}{\textwidth}
\addtolength{\fullboxwidth}{-0.1in}
X
SHAR_EOF
chmod 0644 gnuplot/docs/latextut/header.tex ||
echo 'restore of gnuplot/docs/latextut/header.tex failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/header.tex'`"
test 1677 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/header.tex: original size 1677, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/tutorial.tex ==============
if test -f 'gnuplot/docs/latextut/tutorial.tex' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/tutorial.tex (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/tutorial.tex (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/tutorial.tex' &&
%
% Tutorial for GNUPLOT plotting program, for LaTeX users
% David Kotz (David.Kotz@Dartmouth.edu)
% Duke University Computer Science Department
%
% NOTE: If LaTeX runs out of memory processing plots,
% add ``with lines 4'' to each curve in eg*.plt and rerun make.
%
X
% some header info
\input{header}
X
\begin{document}
X
\title{\LaTeX\ and the GNUPLOT Plotting
Program\thanks{This document describes GNUPLOT version 3.0. All plots
in this document were made with that version of GNUPLOT.} }
\author{David Kotz \\ \verb+David.Kotz@Dartmouth.edu+}
\date{July 3, 1991}
X
\maketitle
X
\pagestyle{myheadings}
\markright{GNUPLOT \LaTeX\ Tutorial Version 3.0}
X
\currentspace % defined in header.tex
X
\section{Introduction and History}
X
GNUPLOT was originally developed by Colin Kelley and Thomas Williams
in 1986 to plot functions and data files on a variety of terminals.
In 1988 and 1989 I created an alternate version, known as Gnu\TeX,
that supported a new ``terminal type'' called {\tt latex}, so gnuplot
would output \LaTeX\ code. The plot could then be included in a
\LaTeX\ document. I added a number of embellishments, supported only
by the {\tt latex} terminal, allowing the user to produce
publication-quality plots.
X
In late 1989 and early 1990 Gnu\TeX\ and a number of other GNUPLOT
variants were merged together into a new release of GNUPLOT, 2.0. This
includes, among many other improvements, a \LaTeX\ driver derived from
the one in Gnu\TeX. Former Gnu\TeX\ users are referred to
Section~\ref{oldusers} for information about adapting to GNUPLOT.
Anyone interested in using GNUPLOT with \LaTeX\ should read the next
section, a tutorial, and the primary GNUPLOT manual.
X
The reader should note that the \LaTeX\ picture environments output by
GNUPLOT can be quite large and complicated, and can easily exceed the
memory capacity of \TeX. If an enlarged version of \TeX\ is available,
it is wise to use it. Otherwise, keep your plots simple and add
\verb+\clearpage+ to your document where necessary.
X
There is also a new EEPIC driver ({\tt eepic}), intended for use with
the EEPIC macro package for \LaTeX. EEPIC allows for much more
efficient line-drawing, runs through \LaTeX\ faster, and uses less
memory. See Section~\ref{s:eepic} for more information.
X
There is a small package of auxiliary files (makefiles and scripts)
that I find useful for making \LaTeX\ plots with GNUPLOT. This is
available for \verb+ftp+ as \verb+pub/gnuplot-latex.shar+ from
\verb+cs.duke.edu+. I can mail copies (see the end of this paper for
information).
X
\section{Using GNUPLOT for \LaTeX: a Tutorial}
X
GNUPLOT is by nature an interactive program. Users making plots for
\LaTeX\ will generally not use GNUPLOT interactively. Whenever hard
copy is desired from GNUPLOT, the program need not be run on a
graphics terminal. In this case the output is directed to a file or
pipe, then sent to the appropriate output device. For example, output
from the terminal type {\tt unixplot} may be sent to a program
interpreting the Unix plotting standard. The terminal types {\tt
imagen} and {\tt postscript} may be used for output to printers
understanding those languages. (A shell script ({\tt lasergnu}) is
supplied with the distribution that will accept a GNUPLOT command or
input file and send the output to an Imagen or Postscript laser
printer. This script may have been adapted to your site.) The terminal
type {\tt fig} outputs FIG code that can be read by the Fig graphics
program and translated into forms usable in both \TeX\ and
\LaTeX\ documents.
X
We now ignore the interactive nature of GNUPLOT and provide the input
to GNUPLOT from a file, \ie,
\begin{verbatim}
X gnuplot gnu.input
\end{verbatim}
In this example, all of the commands to GNUPLOT are contained in the
file {\tt gnu.input}. Multiple filenames may be supplied to GNUPLOT
this way, read in the order they are given. The output (one or more
plots) may be piped to another program or redirected to a file.
Usually, however, we direct the output explicitly with an instruction
to GNUPLOT (the {\tt set output} command). GNUPLOT continues to print
error messages to the terminal (stderr).
X
\paragraph{Example 1:} Here is a first example, producing a plot for
this document. The GNUPLOT input file is given below, and the output
appears as Figure~\ref{eg1}. The input file defines the output to be
in \LaTeX, gives a file name for the output, and plots $y=sin(x)$ for
$x$ on $[-\pi,\pi]$. To produce the figure, I simply
\verb+\input{eg1}+ in a {\tt center} environment in a {\tt figure}
environment. In following examples, I will enclose the figure in a box
to make it look a little better.
X
\singlespace
\begin{verbatim}
X set terminal latex
X set output "eg1.tex"
X plot [-3.14:3.14] sin(x)
\end{verbatim}
\currentspace
X
\begin{figure}[htbp]
X \begin{center}
X \input{eg1}
X \end{center}
X \caption{A first example: $y=sin(x)$}
X \label{eg1}
\end{figure}
X
Note that GNUPLOT has drawn in the axes, labeled the tic marks for us,
scaled the $y$ axis automatically, and added a key in the
upper-right-hand corner (this may be moved with the {\tt set key}
command, and removed with {\tt set nokey}).
X
This is the default line style for the \LaTeX\ driver. Because of the
limited picture capabilities of \LaTeX, many dots are required to
approximate drawing a solid line. This may overload the memory of many
\TeX\ implementations. There are other line types available that draw
dotted lines and use much less memory. The EEPIC driver draws solid
lines with much less memory usage.
X
\paragraph{Example 2:} Now we will embellish the plot a little with
some labels. This input file produces Figure~\ref{eg2}.
X
\singlespace
\begin{verbatim}
X set terminal latex
X set output "eg2.tex"
X set size 5/5., 4/3.
X set format xy "$%g$"
X set title "This is a plot of $y=sin(x)$"
X set xlabel "This is the $x$ axis"
X set ylabel "This is\\the\\$y$ axis"
X plot [0:6.28] [0:1] sin(x)
\end{verbatim}
\currentspace
X
\boxfigure{htbp}{\fullboxwidth}{
X \begin{center}
X \input{eg2}
X \end{center}
X \caption{A more fancy example.}
X \label{eg2}
}
X
We have specified the plot to be 5 inches wide and 4 inches tall with
the {\tt set size} command. This is the size of the area used by the
plot, {\em including} space for the labels. In the first example,
this size was the default 5 inches by 3 inches. By specifying the
scaling factors of 1 (or 5/5) and 1.3333 (or 4/3), we obtain the
desired plot size.
X
We have requested that the format used by the $x$- and $y$-axis tic
mark labels be in \LaTeX\ math mode. This makes the labels look a
little better. The default is \verb+set format xy "%g"+. The \verb+%g+
represents the general-purpose floating point formatting specification
for the {\tt printf} function in C. Any valid floating-point
formatting specification, or \LaTeX\ command, is allowed in the
format.
X
A title for the plot and labels for the axes were set up in the next
three commands. Note that they are processed by \LaTeX\ and so may
have math mode and other symbols in them. The ylabel may have multiple
lines, delineated with \verb+\\+. The ylabel can be moved around with
optional offset parameters (see {\tt set ylabel} in the GNUPLOT
manual). Typically, the ylabel needs to be moved to the left to avoid
interfering with the left-hand side of the plot. Once these labels
are set up, they will be used for all subsequent plot commands until
they are changed. These labels are also supported by the other
terminal types, but (of course) any \LaTeX\ code in the string will
not be interpreted. We have also defined the range of both $x$ (now
$[0,2\pi]$) and $y$ (here $[0,1]$).
X
So far we have plotted one curve, $y=\sin(x)$, on one plot. In
GNUPLOT, each {\tt plot} command generates a new plot. If the output
is to a screen, the screen is cleared. If to a printer, a new page is
produced. In the {\tt latex} case, a new picture is started. It is not
likely that \LaTeX\ users will want this to happen, so generally each
plot has its own input file and is kept in a separate output ({\tt
.tex}) file for inclusion at different places in the document.
X
\paragraph{Example 3:} To place more than one curve on a plot, use one
{\tt plot} statement and separate the description of each curve by a
comma. In our next example, we will plot both a function and a data
file on the same plot. This plot is shown in Figure~\ref{eg3}.
X
\singlespace
\begin{verbatim}
X set terminal latex
X set output "eg3.tex"
X set format xy "$%g$"
X set title "This is another plot"
X set xlabel "$x$ axis"
X set ylabel "$y$ axis"
X set key 15,-10
X plot x with lines, "eg3.dat" with linespoints
\end{verbatim}
\currentspace
X
\boxfigure{htbp}{\fullboxwidth}{
X \begin{center}
X \input{eg3}
X \end{center}
X \caption{An example with two curves on the same plot.}
X \label{eg3}
}
X
Here you will see that the $x$ range was not specified. The $x$ range
is determined automatically, unless specified by the user. In
this case, it is defined by the range of the data file
\verb+"eg3.dat"+. The function is plotted over the same range. If no
data files or $x$ range are supplied, the default range of $[-10:10]$
is used. We have also moved the key to a different position. The
function $y=x$ is plotted ``with lines'', which is the default plot
style for functions, and is shown here to illustrate the plot style
option. The data file {\tt eg3.dat} is plotted with style {\tt
linespoints}, a style like {\tt lines} that also plots a symbol at
each data point.
X
There is a style called {\tt points} that only plots the symbols at
data points, and another called {\tt dots} that plots a tiny dot for
each data point. The {\tt points} and {\tt linespoints} styles
produce a different point symbol for each curve on the plot (for up to
twelve symbols, after which they are re-used; see
Figure~\ref{linepoint} for a complete list). The {\tt lines} and {\tt
linespoints} styles use a different line style for each curve on the
plot (in this example the dots have different spacing). The
style {\tt impulses} draws a perpendicular from each point to the
$x$-axis. Finally, the {\tt errorbars} style can draw error bars at
each data point (see the GNUPLOT manual).
X
\paragraph{Example 4:} In the above plots of $\sin(x)$, it would make
more sense to label the axis in units of $\pi$. The position and
labels of the tic labels may be specified by the user, with the {\tt
set xtics} and {\tt set ytics} commands. This is demonstrated by
the following example, shown in Figure~\ref{eg4}.
X
\singlespace
\begin{verbatim}
X set terminal latex
X set output "eg4.tex"
X set format y "$%g$"
X set format x "$%.2f$"
X set title "This is $\sin(x)$"
X set xlabel "This is the $x$ axis"
X set ylabel "$\sin(x)$"
X set nokey
X set xtics -pi, pi/4
X plot [-pi:pi] [-1:1] sin(x)
\end{verbatim}
\currentspace
X
\boxfigure{htbp}{\fullboxwidth}{
X \begin{center}
X \input{eg4}
X \end{center}
X \caption{An example of the {\tt set xtics} command.}
X \label{eg4}
}
X
Since {\tt pi} is a predefined variable in GNUPLOT, we can use it
anywhere we may use an expression. The {\tt set xtics} command here
specifies that the tics on the $x$ axis start at $-\pi$ and increment
by $\pi/4$. Since no end point is given, the tics continue to the
right edge. We have also turned off the key, and changed the format to
restrict the $x$-axis tic labels to 2 decimal places.
X
With a little more work, the plot can look even better. Another form
of this command allows us to specify the label and position of each
tic individually. Replacing the above {\tt set xtics} command with
the following gives us Figure~\ref{eg5}. We also make use of the line
continuation character, the backslash (\verb+\+), to spread out this
command for readability.
X
\singlespace
\begin{verbatim}
X set xtics ("$-\pi$" -pi,\
X "$-\frac{\pi}{2}$" -pi/2,\
X "0" 0,\
X "$\frac{\pi}{2}$" pi/2,\
X "$\pi$" pi)
\end{verbatim}
\currentspace
X
\boxfigure{htbp}{\fullboxwidth}{
X \begin{center}
X \input{eg5}
X \end{center}
X \caption{A fancy example of the {\tt set xtics} command.}
X \label{eg5}
}
X
\paragraph{Going further:} You should now be able to make a variety of
plots for your \LaTeX\ document. We will present a final example
without explanation that showcases some of the capabilities of
GNUPLOT. You may find documentation for the various commands in the
GNUPLOT manual, though hopefully this example is somewhat
self-explanatory. This is shown in Figure~\ref{eg6}.
X
\singlespace
\begin{verbatim}
X set terminal latex
X set output "eg6.tex"
X set size 3.5/5, 3/3.
X set format y "$%g$"
X set format x "$%5.1f\mu$"
X set title "This is a title"
X set xlabel "This is the $x$ axis"
X set ylabel "This is\\a longer\\version\\ of\\the $y$\\ axis"
X set label "Data" at -5,-5 right
X set arrow from -5,-5 to -3.3,-6.7
X set key -4,8
X set xtic -10,5,10
X plot [-10:10] [-10:10] "eg3.dat" title "Data File" with linespoints 1 7,\
X 3*exp(-x*x)+1 title "$3e^{-x^{2}}+1$" with lines 4
\end{verbatim}
\currentspace
X
\boxfigure{htbp}{\fullboxwidth}{
X \begin{center}
X \input{eg6}
X \end{center}
X \caption{An example of many features.}
X \label{eg6}
}
X
\paragraph{Line and point types:} For reference, we show all of the
line and point types available in Figure~\ref{linepoint}.
X
\boxfigure{htbp}{\fullboxwidth}{
X \begin{center}
X \input{linepoint}
X \end{center}
X \caption{All of the line and point types in the \LaTeX\ driver.}
X \label{linepoint}
}
X
\subsection{Summary --- Use with \LaTeX}
In summary, to use the \LaTeX\ facilities of GNUPLOT, the first
command to GNUPLOT should be
\begin{syntax}
X set terminal latex
\end{syntax}
and the output of GNUPLOT should be directed to a file, for example,
\begin{verbatim}
X set output "plot.tex"
\end{verbatim}
This may be anything you like but it should have a {\tt .tex} extension,
of course. Then the size of the plot should be given. For example, the
command
\begin{verbatim}
X set size 1,2
\end{verbatim}
tells GNUPLOT to use a 5 inch wide by 6 inch high box for the plot.
The numbers given are {\em scale factors}, not the actual size. The
default is 5 inches by 3 inches. This is the size of the complete
plot, including all labels.
X
When finished, the file will contain all of the plots you have
specified (you probably only want one plot per file). This file can
then be used in a \LaTeX\ document, \eg,
X
\singlespace
\begin{verbatim}
X \begin {figure}
X \begin{center}
X \input{plot}
X \end{center}
X \end {figure}
\end{verbatim}
\currentspace
This puts the plot into a figure.
X
You will also want to read about the following commands: {\tt set
title, set xlabel, set ylabel, set key, set label, set xtics, set
ytics}, and {\tt set clip}. These are all described in the regular
GNUPLOT manual.
X
\section{Use with EEPIC}
\label{s:eepic}
EEPIC is a macro package extending the picture environment of \LaTeX.
If you have the EPIC or EEPIC macros, and your {\tt dvi} translator
supports the {\em tpic\/} \verb+\special+s, then you can save \LaTeX\
memory. With EEPIC pictures, the {\tt plot.tex} file will be smaller,
\LaTeX\ will run much faster (and need much less memory), and the {\tt
dvi} file will be smaller. The quality of the output is about the
same. If you change the source, you can generate some more interesting
line styles.
X
To use EEPIC, set GNUPLOT's terminal type to {\tt eepic} instead of
{\tt latex}, and use GNUPLOT as before. The line styles will change.
Include the file {\tt plot.tex} in your document as before, along with
the document style options {\tt [epic,eepic]}.
X
\section{For Former Gnu\TeX\ Users}
\label{oldusers}
X
Former Gnu\TeX\ users may be pleased with many of the new features
(many inspired by your suggestions!), but will also find many changes.
GNUPLOT will {\em not\/} run all Gnu\TeX\ input files unchanged.
Several Gnu\TeX\ features were not included in GNUPLOT because they
were specific to the \LaTeX\ driver. I encourage you to use the newer
GNUPLOT. A translator is available that attempts to translate your
old Gnu\TeX\ 1.6 input files into GNUPLOT 3.0 files. You can ftp it
from \verb+cs.duke.edu+ as \verb+dist/sources/gnuplot/gnut2p.tar.Z+.
This file also contains directions and a list of changes from Gnu\TeX\
to GNUPLOT.
X
\section{Contact}
Please contact me at \verb+David.Kotz@Dartmouth.edu+ with any comments you may
have on GNUPLOT's \LaTeX\ driver. For general GNUPLOT questions, send
mail to the GNUPLOT mailing list
(\verb+pixar!info-gnuplot@ucbvax.berkeley.edu+).
X
X
\end{document}
SHAR_EOF
chmod 0644 gnuplot/docs/latextut/tutorial.tex ||
echo 'restore of gnuplot/docs/latextut/tutorial.tex failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/tutorial.tex'`"
test 16623 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/tutorial.tex: original size 16623, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/latextut/linepoint.plt ==============
if test -f 'gnuplot/docs/latextut/linepoint.plt' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/latextut/linepoint.plt (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/latextut/linepoint.plt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/latextut/linepoint.plt' &&
# Plots all line types and point types
set term latex
set out "linepoint.tex"
set clip points
set dummy t,y
set nokey
set parametric
set samples 14 # for trange 0:13, we get 14 points: 0, 1, ..., 13
set function style lines
set xtics 1,1,12
set ytics 1,1,6
set title "Up to 6 line types and 12 point types"
set trange [0 : 13]
set xlabel "Points"
set xrange [0 : 13]
set ylabel "Lines"
set yrange [0 : 7]
plot t,1, t,2, t,3, t,4, t,5, t,6, 1,t w p, 2,t w p, 3,t w p, 4,t w p,5,t w p, 6,t w p, 7,t w p, 8,t w p, 9,t w p, 10,t w p, 11,t w p, 12,t w p
SHAR_EOF
chmod 0644 gnuplot/docs/latextut/linepoint.plt ||
echo 'restore of gnuplot/docs/latextut/linepoint.plt failed'
Wc_c="`wc -c < 'gnuplot/docs/latextut/linepoint.plt'`"
test 550 -eq "$Wc_c" ||
echo 'gnuplot/docs/latextut/linepoint.plt: original size 550, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/titlepage.ms ==============
if test -f 'gnuplot/docs/titlepage.ms' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/titlepage.ms (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/titlepage.ms (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/titlepage.ms' &&
.nr HM 3.2i
.TL
GNUPLOT
.br
An Interactive Plotting Program
.sp
.AU
Thomas Williams & Colin Kelley
.br
X Version 3.0 organized by: Gershon Elber
.br
X Version 3.0 major contributors (alphabetic order):
.br
X John Campbell
.br
X Gershon Elber
.br
X David Kotz
.br
X Ed Kubaitis
.br
X Russell Lang
.br
X Tom Tkacik
.br
X Alex Woo
X
.AI
X Mailing list for comments: pixar!info-gnuplot@sun.com
.br
X Mailing list for bug reports: pixar!bug-gnuplot@sun.com
\*(DY
.br
X
X
X
X
X
X
This manual is for GNUPLOT version 3.0.
.AB no
.AE
.LP
.nr HM 1.2i
.ds CH
.ds LH GNUPLOT 3.0
.ds RH %
.\".nr PS 12
.\".nr VS 13
SHAR_EOF
chmod 0644 gnuplot/docs/titlepage.ms ||
echo 'restore of gnuplot/docs/titlepage.ms failed'
Wc_c="`wc -c < 'gnuplot/docs/titlepage.ms'`"
test 599 -eq "$Wc_c" ||
echo 'gnuplot/docs/titlepage.ms: original size 599, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/doc2tex.c ==============
if test -f 'gnuplot/docs/doc2tex.c' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/doc2tex.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/doc2tex.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/doc2tex.c' &&
/*
X * doc2tex.c -- program to convert Gnuplot .DOC format to LaTeX document
X * Also will work for VMS .HLP files.
X * Modified by Russell Lang from hlp2ms.c by Thomas Williams
X * Extended by David Kotz to support quotes ("), backquotes, tables.
X *
X * usage: doc2tex < file.doc > file.tex
X *
X * where file.doc is a Gnuplot .DOC file, and file.tex will be an
X * article document suitable for printing with LaTeX.
X *
X * typical usage for GNUPLOT:
X *
X * doc2tex < gnuplot.doc > gnuplot.tex
X * latex gnuplot.tex ; latex gnuplot.tex
X */
X
static char rcsid[] = "$Id: doc2tex.c,v 1.1 90/01/11 15:44:06 dfk Exp Locker: dfk $";
X
#include <stdio.h>
#include <ctype.h>
#ifdef AMIGA_LC_5_1
#include <string.h>
#endif
X
#define MAX_NAME_LEN 256
#define MAX_LINE_LEN 256
#define TRUE 1
#define FALSE 0
X
typedef int boolean;
X
boolean intable = FALSE;
boolean verb = FALSE;
X
main()
{
X init(stdout);
X convert(stdin,stdout);
X finish(stdout);
X exit(0);
}
X
X
init(b)
FILE *b;
{
X (void) fputs("\\input{titlepage.tex}\n",b);
}
X
X
convert(a,b)
X FILE *a,*b;
{
X static char line[MAX_LINE_LEN];
X
X while (fgets(line,MAX_LINE_LEN,a)) {
X process_line(line, b);
X }
}
X
process_line(line, b)
X char *line;
X FILE *b;
{
X switch(line[0]) { /* control character */
X case '?': { /* interactive help entry */
X break; /* ignore */
X }
X case '@': { /* start/end table */
X if (intable) {
X (void) fputs("\\hline\n\\end{tabular}\n", b);
X (void) fputs("\\end{center}\n",b);
X intable = FALSE;
X } else {
X if (verb) {
X (void) fputs("\\end{verbatim}\n",b);
X verb=FALSE;
X }
X (void) fputs("\n\\begin{center}\n", b);
X (void) fputs("\\begin{tabular}{|ccl|} \\hline\n", b);
X intable = TRUE;
X }
X /* ignore rest of line */
X break;
X }
X case '#': { /* latex table entry */
X if (intable)
X (void) fputs(line+1, b); /* copy directly */
X else
X fprintf(stderr, "error: # line found outside of table\n");
X break;
X }
X case '%': { /* troff table entry */
X break; /* ignore */
X }
X case '\n': /* empty text line */
X case ' ': { /* normal text line */
X if (intable)
X break; /* ignore while in table */
X if (line[1] == ' ') {
X /* verbatim mode */
X if (!verb) {
X (void) fputs("\\begin{verbatim}\n",b);
X verb=TRUE;
X }
X (void) fputs(line+1,b);
X } else {
X if (verb) {
X (void) fputs("\\end{verbatim}\n",b);
X verb=FALSE;
X }
X if (line[0] == '\n')
X puttex(line,b); /* handle totally blank line */
X else
X puttex(line+1,b);
X }
X break;
X }
X default: {
X if (isdigit(line[0])) { /* start of section */
X if (!intable) /* ignore while in table */
X section(line, b);
X } else
X fprintf(stderr, "unknown control code '%c' in column 1\n",
X line[0]);
X break;
X }
X }
}
X
/* process a line with a digit control char */
/* starts a new [sub]section */
X
section(line, b)
X char *line;
X FILE *b;
{
X static char string[MAX_LINE_LEN];
X int sh_i;
X
X if (verb) {
X (void) fputs("\\end{verbatim}\n",b);
X verb=FALSE;
X }
#ifdef AMIGA_LC_5_1
X (void) sscanf(line,"%d",&sh_i);
X strcpy(string,strchr(line,' ')+1);
X {
X char *p;
X p = strchr(string,'\n');
X if (p != NULL) *p = '\0';
X }
#else
X (void) sscanf(line,"%d %[^\n]s",&sh_i,string);
#endif
X switch(sh_i)
X {
X case 1:
X (void) fprintf(b,"\\section{");
X break;
X case 2:
X (void) fprintf(b,"\\section{");
X break;
X case 3:
X (void) fprintf(b,"\\subsection{");
X break;
X case 4:
X (void) fprintf(b,"\\subsubsection{");
X break;
X default:
X case 5:
X (void) fprintf(b,"\\paragraph{");
X break;
X }
X if (islower(string[0]))
X string[0] = toupper(string[0]);
X puttex(string,b);
X (void) fprintf(b,"}\n");
}
X
/* put text in string str to file while buffering special TeX characters */
puttex(str,file)
FILE *file;
register char *str;
{
register char ch;
static boolean inquote = FALSE;
X
X while( (ch = *str++) != '\0') {
X switch(ch) {
X case '#':
X case '$':
X case '%':
X case '&':
X case '_':
X case '{':
X case '}':
X (void) fputc('\\',file);
X (void) fputc(ch,file);
X break;
X case '\\':
X (void) fputs("$\\backslash$",file);
X break;
X case '~':
X (void) fputs("\\~{\\ }",file);
X break;
X case '^':
X (void) fputs("\\verb+^+",file);
X break;
X case '>':
X case '<':
X case '|':
X (void) fputc('$',file);
X (void) fputc(ch,file);
X (void) fputc('$',file);
X break;
X case '"':
X /* peek at next character: if space, end of quote */
X if (*str == NULL || isspace(*str) || ispunct(*str))
X (void) fputs("''", file);
X else
X (void) fputs("``", file);
X break;
X case '`': /* backquotes mean boldface */
X if (inquote) {
X fputs("}", file);
X inquote = FALSE;
X } else {
X fputs("{\\bf ", file);
X inquote = TRUE;
X }
X break;
X default:
X (void) fputc(ch,file);
X break;
X }
X }
}
X
X
finish(b)
FILE *b;
{
X (void) fputs("\\end{document}\n",b);
}
SHAR_EOF
chmod 0644 gnuplot/docs/doc2tex.c ||
echo 'restore of gnuplot/docs/doc2tex.c failed'
Wc_c="`wc -c < 'gnuplot/docs/doc2tex.c'`"
test 5029 -eq "$Wc_c" ||
echo 'gnuplot/docs/doc2tex.c: original size 5029, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/docs/titlepage.tex ==============
if test -f 'gnuplot/docs/titlepage.tex' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/docs/titlepage.tex (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/docs/titlepage.tex (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/docs/titlepage.tex' &&
\documentstyle[toc_entry]{article}
\setlength{\textwidth}{6.25in}
\setlength{\oddsidemargin}{0.5cm}
\setlength{\topmargin}{-0.5in}
\setlength{\textheight}{9in}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\adjustarticle
\begin{document}
X
\pagestyle{empty}
X \rule{0in}{3in}
X \begin{center}
SHAR_EOF
true || echo 'restore of gnuplot/docs/titlepage.tex failed'
fi
echo 'End of part 10'
echo 'File gnuplot/docs/titlepage.tex is continued in part 11'
echo 11 > _shar_seq_.tmp
exit 0
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.