home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume11 / gnuplot2 / part04 < prev    next >
Encoding:
Text File  |  1990-03-25  |  27.2 KB  |  741 lines

  1. Newsgroups: comp.sources.misc
  2. organization: Pixar -- Marin County, California
  3. subject: v11i069: Gnuplot 2.0 - 4 of 14
  4. From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 11, Issue 69
  8. Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
  9. Archive-name: gnuplot2/part04
  10.  
  11. This is gnuplot.sh04
  12.  
  13. --- CUT HERE ---
  14. #! /bin/sh
  15. echo x - docs/latextut/Makefile
  16. sed 's/^X//' >docs/latextut/Makefile <<'*-*-END-of-docs/latextut/Makefile-*-*'
  17. X# Makefile for gnuplot LaTeX tutorial
  18. X# To make the manual from scratch, we run latex three times
  19. Xall: tutorial.dvi
  20. X    latex tutorial
  21. X
  22. X# To touch it up after changes:
  23. Xremake: tutorial.dvi
  24. X
  25. X# Always runs latex, e.g., to get labels right
  26. Xforce: 
  27. X    latex tutorial
  28. X
  29. Xtutorial.dvi: eg1.tex eg2.tex eg3.tex eg4.tex eg5.tex eg6.tex \
  30. X    tutorial.tex header.tex
  31. X    latex tutorial
  32. X
  33. X.SUFFIXES: .tex .plt
  34. X
  35. X.plt.tex:
  36. X    gnuplot $<
  37. X
  38. Xclean:
  39. X    rm -f *~ *.log eg?.tex
  40. X
  41. Xspotless:
  42. X    rm -f *~ *.log *.aux *.dvi eg?.tex
  43. *-*-END-of-docs/latextut/Makefile-*-*
  44. echo x - docs/latextut/eg1.plt
  45. sed 's/^X//' >docs/latextut/eg1.plt <<'*-*-END-of-docs/latextut/eg1.plt-*-*'
  46. Xset terminal latex
  47. Xset output "eg1.tex"
  48. Xplot [-3.14:3.14] sin(x)
  49. *-*-END-of-docs/latextut/eg1.plt-*-*
  50. echo x - docs/latextut/eg2.plt
  51. sed 's/^X//' >docs/latextut/eg2.plt <<'*-*-END-of-docs/latextut/eg2.plt-*-*'
  52. Xset terminal latex
  53. Xset output "eg2.tex"
  54. Xset size 5/5., 4/3.
  55. Xset format xy "$%g$"
  56. Xset title "This is a plot of $y=sin(x)$"
  57. Xset xlabel "This is the $x$ axis"
  58. Xset ylabel "This is\\the\\$y$ axis"
  59. Xplot [0:6.28] [0:1] sin(x)
  60. *-*-END-of-docs/latextut/eg2.plt-*-*
  61. echo x - docs/latextut/eg3.dat
  62. sed 's/^X//' >docs/latextut/eg3.dat <<'*-*-END-of-docs/latextut/eg3.dat-*-*'
  63. X-20.000000 -9.125028
  64. X-19.000000 -9.109280
  65. X-18.000000 -9.091787
  66. X-17.000000 -9.072243
  67. X-16.000000 -9.050265
  68. X-15.000000 -9.025369
  69. X-14.000000 -8.996933
  70. X-13.000000 -8.964147
  71. X-12.000000 -8.925931
  72. X-11.000000 -8.880819
  73. X-10.000000 -8.826766
  74. X-9.000000 -8.760835
  75. X-8.000000 -8.678648
  76. X-7.000000 -8.573396
  77. X-6.000000 -8.433886
  78. X-5.000000 -8.240405
  79. X-4.000000 -7.954906
  80. X-3.000000 -7.494275
  81. X-2.000000 -6.642892
  82. X-1.000000 -4.712389
  83. X0.000000 0.000000
  84. X1.000000 4.712389
  85. X2.000000 6.642892
  86. X3.000000 7.494275
  87. X4.000000 7.954906
  88. X5.000000 8.240405
  89. X6.000000 8.433886
  90. X7.000000 8.573396
  91. X8.000000 8.678648
  92. X9.000000 8.760835
  93. X10.000000 8.826766
  94. X11.000000 8.880819
  95. X12.000000 8.925931
  96. X13.000000 8.964147
  97. X14.000000 8.996933
  98. X15.000000 9.025369
  99. X16.000000 9.050265
  100. X17.000000 9.072243
  101. X18.000000 9.091787
  102. X19.000000 9.109280
  103. *-*-END-of-docs/latextut/eg3.dat-*-*
  104. echo x - docs/latextut/eg3.plt
  105. sed 's/^X//' >docs/latextut/eg3.plt <<'*-*-END-of-docs/latextut/eg3.plt-*-*'
  106. Xset terminal latex
  107. Xset output "eg3.tex"
  108. Xset format xy "$%g$"
  109. Xset title "This is another plot"
  110. Xset xlabel "$x$ axis"
  111. Xset ylabel "$y$ axis"
  112. Xset key 15,-10
  113. Xplot x with lines, "eg3.dat" with linespoints
  114. *-*-END-of-docs/latextut/eg3.plt-*-*
  115. echo x - docs/latextut/eg4.plt
  116. sed 's/^X//' >docs/latextut/eg4.plt <<'*-*-END-of-docs/latextut/eg4.plt-*-*'
  117. Xset terminal latex
  118. Xset output "eg4.tex"
  119. Xset format y "$%g$"
  120. Xset format x "$%.2f$"
  121. Xset title "This is $\sin(x)$"
  122. Xset xlabel "This is the $x$ axis"
  123. Xset ylabel "$\sin(x)$"
  124. Xset nokey
  125. Xset xtics -pi, pi/4
  126. Xplot [-pi:pi] [-1:1] sin(x)
  127. *-*-END-of-docs/latextut/eg4.plt-*-*
  128. echo x - docs/latextut/eg5.plt
  129. sed 's/^X//' >docs/latextut/eg5.plt <<'*-*-END-of-docs/latextut/eg5.plt-*-*'
  130. Xset terminal latex
  131. Xset output "eg5.tex"
  132. Xset format y "$%g$"
  133. Xset format x "$%4.1f\pi$"
  134. Xset noclip points
  135. Xset title "This is $\sin(x)$"
  136. Xset xlabel "This is the $x$ axis"
  137. Xset ylabel "$\sin(x)$"
  138. Xset nokey
  139. Xset xtics ("$-\pi$" -pi,\
  140. X "$-\frac{\pi}{2}$" -pi/2,\
  141. X "0" 0,\
  142. X "$\frac{\pi}{2}$" pi/2,\
  143. X "$\pi$" pi)
  144. Xplot [-pi:pi] [-1:1] sin(x)
  145. *-*-END-of-docs/latextut/eg5.plt-*-*
  146. echo x - docs/latextut/eg6.plt
  147. sed 's/^X//' >docs/latextut/eg6.plt <<'*-*-END-of-docs/latextut/eg6.plt-*-*'
  148. Xset terminal latex
  149. Xset output "eg6.tex"
  150. Xset size 3.5/5, 3/3.
  151. Xset format y "$%g$"
  152. Xset format x "$%5.1f\mu$"
  153. Xset title "This is a title"
  154. Xset xlabel "This is the $x$ axis"
  155. Xset ylabel "This is\\a longer\\version\\ of\\the $y$\\ axis"
  156. Xset label "Data" at -5,-5 right
  157. Xset arrow from -5,-5 to -3.3,-6.7
  158. Xset key -4,8
  159. Xset xtic -10,5,10
  160. Xplot [-10:10] [-10:10] "eg3.dat" title "Data File"  with linespoints 1 7,\
  161. X   3*exp(-x*x)+1  title "$3e^{-x^{2}}+1$" with lines 4
  162. *-*-END-of-docs/latextut/eg6.plt-*-*
  163. echo x - docs/latextut/header.tex
  164. sed 's/^X//' >docs/latextut/header.tex <<'*-*-END-of-docs/latextut/header.tex-*-*'
  165. X% 
  166. X% Header file for gnutex.tex
  167. X%
  168. X
  169. X% Spacing
  170. X\newcommand{\singlespace}
  171. X  {\addtolength{\baselineskip}{-.333\baselineskip}}
  172. X\newcommand{\doublespace}
  173. X  {\addtolength{\baselineskip}{.5\baselineskip}}
  174. X
  175. X% Spacing for the whole document 
  176. X\newcommand{\currentspace}{} % use this for single space
  177. X% \newcommand{\currentspace}{\doubleespace} % use this for double space
  178. X
  179. X% Common abbreviations
  180. X% (Remember to put '\ ' after if an interword space is
  181. X%  desired rather than end-of-sentence space. Same for '.etc)' ).
  182. X\newcommand{\eg}{{\em e.g.}}        % e.g.
  183. X\newcommand{\ie}{{\em i.e.}}        % i.e.
  184. X\newcommand{\etc}{{\em etc.}}        % etc.
  185. X\newcommand{\vs}{{\em vs.}}        % vs.
  186. X\newcommand{\usec}{{$\mu$}sec}    % microseconds
  187. X
  188. X% \boxfigure{pos}{wid}{text}:  A figure with a box around it
  189. X%
  190. X% pos    the usual figure placement arg: eg. htbp
  191. X% wid    the width of the figure, in some units: eg. 5in
  192. X% text    the contents of the figure, including picture/caption/label/etc
  193. X%
  194. X\newlength{\boxwidth}
  195. X\newcommand{\boxfigure}[3]{
  196. X    \begin{figure}[#1]
  197. X        \setlength{\boxwidth}{#2}
  198. X        \addtolength{\boxwidth}{.1in}
  199. X
  200. X        \centering
  201. X        \framebox[\boxwidth]{
  202. X            \begin{minipage}{#2}
  203. X            #3
  204. X            \end{minipage}
  205. X        }
  206. X    \end{figure}  
  207. X}
  208. X
  209. X% use \fullboxwidth for arg 2 of boxfigure to get box of size \textwidth
  210. X
  211. X% To show a syntax for a gnutex command
  212. X\newenvironment{syntax}{\begin{quote}\tt}{\end{quote}}
  213. X
  214. X\documentstyle[titlepage,11pt]{article}
  215. X
  216. X% Margins
  217. X\sloppy
  218. X\setlength{\textwidth}{6.5in}
  219. X\setlength{\textheight}{9in}
  220. X\setlength{\topmargin}{-0.5in}
  221. X\setlength{\oddsidemargin}{0pt}
  222. X\setlength{\evensidemargin}{0pt}
  223. X
  224. X% see above
  225. X\newlength{\fullboxwidth}
  226. X\setlength{\fullboxwidth}{\textwidth}
  227. X\addtolength{\fullboxwidth}{-0.1in}
  228. X
  229. *-*-END-of-docs/latextut/header.tex-*-*
  230. echo x - docs/latextut/tutorial.tex
  231. sed 's/^X//' >docs/latextut/tutorial.tex <<'*-*-END-of-docs/latextut/tutorial.tex-*-*'
  232. X% 
  233. X% Tutorial for GNUPLOT plotting program, for LaTeX users
  234. X% David Kotz (dfk@cs.duke.edu)
  235. X% Duke University Computer Science Department
  236. X%
  237. X% NOTE: If LaTeX runs out of memory processing plots,
  238. X% add ``with lines 4'' to each curve in eg*.plt and rerun make.
  239. X%
  240. X
  241. X% some header info
  242. X\input{header}
  243. X
  244. X\begin{document}
  245. X
  246. X\title{\LaTeX\ and the GNUPLOT Plotting 
  247. XProgram\thanks{This document describes GNUPLOT version 2.0. All plots
  248. Xin this document were made with that version of GNUPLOT.} }
  249. X\author{David Kotz \\ \verb+dfk@cs.duke.edu+}
  250. X\date{February 10, 1990}
  251. X
  252. X\maketitle
  253. X
  254. X\pagestyle{myheadings}
  255. X\markright{GNUPLOT \LaTeX\ Tutorial Version 2.0}
  256. X
  257. X\currentspace % defined in header.tex
  258. X
  259. X\section{Introduction and History}
  260. X
  261. XGNUPLOT was originally developed by Colin Kelley and Thomas Williams
  262. Xin 1986 to plot functions and data files on a variety of terminals.
  263. XIn 1988 and 1989 I created an alternate version, known as Gnu\TeX,
  264. Xthat supported a new ``terminal type'' called {\tt latex}, so gnuplot
  265. Xwould output \LaTeX\ code. The plot could then be included in a
  266. X\LaTeX\ document. I added a number of embellishments, supported only
  267. Xby the {\tt latex} terminal, allowing the user to produce
  268. Xpublication-quality plots.
  269. X
  270. XIn late 1989 and early 1990 Gnu\TeX\ and a number of other GNUPLOT
  271. Xvariants were merged together into a new release of GNUPLOT, 2.0. This
  272. Xincludes, among many other improvements, a \LaTeX\ driver derived from
  273. Xthe one in Gnu\TeX. Former Gnu\TeX\ users are referred to
  274. XSection~\ref{oldusers} for information about adapting to GNUPLOT 2.0.
  275. XAnyone interested in using GNUPLOT 2.0 with \LaTeX\ should read the
  276. Xnext section, a tutorial.  GNUPLOT beginners should also read the
  277. Xprimary GNUPLOT manual. 
  278. X
  279. XThe reader should note that the \LaTeX\ picture environments output by
  280. XGNUPLOT can be quite large and complicated, and can easily exceed the
  281. Xmemory capacity of \TeX. If an enlarged version of \TeX\ is available,
  282. Xit is wise to use it. Otherwise, keep your plots simple and add
  283. X\verb+\clearpage+ to your document where necessary.
  284. X
  285. XThere is also a new EEPIC driver ({\tt eepic}), intended for use with
  286. Xthe EEPIC macro package for \LaTeX. EEPIC allows for much more
  287. Xefficient line-drawing, runs through \LaTeX\ faster, uses less memory,
  288. Xand may produce better-looking plots. See Section~\ref{s:eepic} for
  289. Xmore information.
  290. X
  291. X\section{Using GNUPLOT for \LaTeX: a Tutorial}
  292. X
  293. XGNUPLOT is by nature an interactive program. Users making plots for
  294. X\LaTeX\ will generally not use GNUPLOT interactively.  Whenever hard
  295. Xcopy is desired from GNUPLOT, the program need not be run on a
  296. Xgraphics terminal. In this case the output is directed to a file or
  297. Xpipe, then sent to the appropriate output device. For example, output
  298. Xfrom the terminal type {\tt unixplot} may be sent to a program
  299. Xinterpreting the Unix plotting standard. The terminal types {\tt
  300. Ximagen} and {\tt postscript} may be used for output to printers
  301. Xunderstanding those languages. (A shell script ({\tt lasergnu}) is
  302. Xsupplied with the distribution that will accept a GNUPLOT command or
  303. Xinput file and send the output to an Imagen or Postscript laser
  304. Xprinter. This script may have been adapted to your site.) The terminal
  305. Xtype {\tt fig} outputs FIG code that can be read by the Fig graphics
  306. Xprogram and translated into forms usable in both \TeX\ and
  307. X\LaTeX\ documents.
  308. X
  309. XWe now ignore the interactive nature of GNUPLOT and provide the input
  310. Xto GNUPLOT from a file, \ie,
  311. X\begin{verbatim}
  312. X      gnuplot gnu.input
  313. X\end{verbatim}
  314. XIn this example, all of the commands to GNUPLOT are contained in the
  315. Xfile {\tt gnu.input}. Multiple filenames may be supplied to GNUPLOT
  316. Xthis way, read in the order they are given.  The output (one or more
  317. Xplots) may be piped to another program or redirected to a file.
  318. XUsually, however, we direct the output explicitly with an instruction
  319. Xto GNUPLOT (the {\tt set output} command). GNUPLOT continues to print
  320. Xerror messages to the terminal (stderr).
  321. X
  322. X\paragraph{Example 1:} Here is a first example, producing a plot for
  323. Xthis document. The GNUPLOT input file is given below, and the output
  324. Xappears as Figure~\ref{eg1}. The input file defines the output to be
  325. Xin \LaTeX, gives a file name for the output, and plots $y=sin(x)$ for
  326. X$x$ on $[-\pi,\pi]$. To produce the figure, I simply
  327. X\verb+\input{eg1}+ in a {\tt center} environment in a {\tt figure}
  328. Xenvironment. In following examples, I will enclose the figure in a box
  329. Xto make it look a little better.
  330. X
  331. X\singlespace
  332. X\begin{verbatim}
  333. X    set terminal latex
  334. X    set output "eg1.tex"
  335. X    plot [-3.14:3.14] sin(x)
  336. X\end{verbatim}
  337. X\currentspace
  338. X
  339. X\begin{figure}[htbp]
  340. X  \begin{center}
  341. X    \input{eg1}
  342. X  \end{center}
  343. X  \caption{A first example: $y=sin(x)$} 
  344. X  \label{eg1}
  345. X\end{figure}
  346. X
  347. XNote that GNUPLOT has drawn in the axes, labeled the tic marks for us,
  348. Xscaled the $y$ axis automatically, and added a key in the
  349. Xupper-right-hand corner (this may be moved with the {\tt set key}
  350. Xcommand).
  351. X
  352. XThis is the default line style for the \LaTeX\ driver.  Because of the
  353. Xlimited picture capabilities of \LaTeX, many dots are required to
  354. Xapproximate drawing a solid line. This may overload the memory of many
  355. X\TeX\ implementations. There are other line types available that draw
  356. Xdotted lines and use much less memory. The EEPIC driver draws solid
  357. Xlines with much less memory usage.
  358. X
  359. X\paragraph{Example 2:} Now we will embellish the plot a little with
  360. Xsome labels.  This input file produces Figure~\ref{eg2}.
  361. X
  362. X\singlespace
  363. X\begin{verbatim}
  364. X    set terminal latex
  365. X    set output "eg2.tex"
  366. X    set size 5/5., 4/3.
  367. X    set format xy "$%g$"
  368. X    set title "This is a plot of $y=sin(x)$"
  369. X    set xlabel "This is the $x$ axis"
  370. X    set ylabel "This is\\the\\$y$ axis"
  371. X    plot [0:6.28] [0:1] sin(x)
  372. X\end{verbatim}
  373. X\currentspace
  374. X
  375. X\boxfigure{htbp}{\fullboxwidth}{
  376. X  \begin{center}
  377. X    \input{eg2}
  378. X  \end{center}
  379. X  \caption{A more fancy example.}
  380. X  \label{eg2}
  381. X}
  382. X
  383. XWe have specified the plot to be 5 inches wide and 4 inches tall with
  384. Xthe {\tt set size} command. This is the size of the area used by the
  385. Xplot, {\em including} space for the labels.  In the first example,
  386. Xthis size was the default 5 inches by 3 inches. By specifying the
  387. Xscaling factors of 1 (or 5/5) and 1.3333 (or 4/3), we obtain the
  388. Xdesired plot size. 
  389. X
  390. XWe have requested that the format used by the $x$- and $y$-axis tic
  391. Xmark labels be in \LaTeX\ math mode. This makes the labels look a
  392. Xlittle better. The default is \verb+set format xy "%g"+. The \verb+%g+
  393. Xrepresents the general-purpose floating point formatting specification
  394. Xfor the {\tt printf} function in C. Any valid floating-point
  395. Xformatting specification, or \LaTeX\ command, is allowed in the
  396. Xformat.
  397. X
  398. XA title for the plot and labels for the axes were set up in the next
  399. Xthree commands.  Note that they are processed by \LaTeX\ and so may
  400. Xhave math mode and other symbols in them. The ylabel may have multiple
  401. Xlines, delineated with \verb+\\+.  Once these are set up, they will be
  402. Xused for all subsequent plot commands until they are changed. These
  403. Xlabels are also supported by the other terminal types, but (of course)
  404. Xany \LaTeX\ code in the string will not be interpreted. We have also
  405. Xdefined the range of both $x$ (now $[0,2\pi]$) and $y$ (here $[0,1]$).
  406. X
  407. XSo far we have plotted one curve, $y=\sin(x)$, on one plot. In
  408. XGNUPLOT, each {\tt plot} command generates a new plot. If the output
  409. Xis to a screen, the screen is cleared. If to a printer, a new page is
  410. Xproduced. In the {\tt latex} case, a new picture is started. It is not
  411. Xlikely that \LaTeX\ users will want this to happen, so generally each
  412. Xplot has its own input file and is kept in a separate output ({\tt
  413. X.tex}) file for inclusion at different places in the document.
  414. X
  415. X\paragraph{Example 3:} To place more than one curve on a plot, use one
  416. X{\tt plot} statement and separate the description of each curve by a
  417. Xcomma. In our next example, we will plot both a function and a data
  418. Xfile on the same plot. This plot is shown in Figure~\ref{eg3}.
  419. X
  420. X\singlespace
  421. X\begin{verbatim}
  422. X    set terminal latex
  423. X    set output "eg3.tex"
  424. X    set format xy "$%g$"
  425. X    set title "This is another plot"
  426. X    set xlabel "$x$ axis"
  427. X    set ylabel "$y$ axis"
  428. X    set key 15,-10
  429. X    plot x with lines, "eg3.dat" with linespoints
  430. X\end{verbatim}
  431. X\currentspace
  432. X
  433. X\boxfigure{htbp}{\fullboxwidth}{
  434. X  \begin{center}
  435. X    \input{eg3}
  436. X  \end{center}
  437. X  \caption{An example with two curves on the same plot.}
  438. X  \label{eg3}
  439. X}
  440. X
  441. XHere you will see that the $x$ range was not specified. The $x$ range
  442. Xis determined automatically, unless specified by the user.  In
  443. Xthis case, it is defined by the range of the data file
  444. X\verb+"eg3.dat"+. The function is plotted over the same range. If no
  445. Xdata files or $x$ range are supplied, the default range of $[-10:10]$
  446. Xis used. We have also moved the key to a different position.  The
  447. Xfunction $y=x$ is plotted ``with lines'', which is the default plot
  448. Xstyle for functions, and is shown here to illustrate the plot style
  449. Xoption.  The data file {\tt eg3.dat} is plotted with style {\tt
  450. Xlinespoints}, a style like {\tt lines} that also plots a symbol at
  451. Xeach data point.
  452. X
  453. XThere is a style called {\tt points} that only plots the symbols at
  454. Xdata points, and another called {\tt dots} that plots a tiny dot for
  455. Xeach data point.  The {\tt points} and {\tt linespoints} styles
  456. Xproduce a different point symbol for each curve on the plot (for up to
  457. Xtwelve symbols, after which they are re-used). The {\tt lines} and
  458. X{\tt linespoints} styles use a different line style for each curve on
  459. Xthe plot (in this example the dots have different spacing). Finally,
  460. Xthe style {\tt impulses} draws a perpendicular from each point to the
  461. X$x$-axis.
  462. X
  463. X\paragraph{Example 4:} In the above plots of $\sin(x)$, it would make
  464. Xmore sense to label the axis in units of $\pi$. The position and
  465. Xlabels of the tic labels may be specified by the user, with the {\tt
  466. Xset xtics} and {\tt set ytics} commands. This is demonstrated by
  467. Xthe following example, shown in Figure~\ref{eg4}.
  468. X
  469. X\singlespace
  470. X\begin{verbatim}
  471. X    set terminal latex
  472. X    set output "eg4.tex"
  473. X    set format y "$%g$"
  474. X    set format x "$%.2f$"
  475. X    set title "This is $\sin(x)$"
  476. X    set xlabel "This is the $x$ axis"
  477. X    set ylabel "$\sin(x)$"
  478. X    set nokey
  479. X    set xtics -pi, pi/4
  480. X    plot [-pi:pi] [-1:1] sin(x)
  481. X\end{verbatim}
  482. X\currentspace
  483. X
  484. X\boxfigure{htbp}{\fullboxwidth}{
  485. X  \begin{center}
  486. X    \input{eg4}
  487. X  \end{center}
  488. X  \caption{An example of the {\tt set xtics} command.}
  489. X  \label{eg4}
  490. X}
  491. X
  492. XSince {\tt pi} is a predefined variable in GNUPLOT, we can use it
  493. Xanywhere we may use an expression. The {\tt set xtics} command here
  494. Xspecifies that the tics on the $x$ axis start at $-\pi$ and increment
  495. Xby $\pi/4$. Since no end point is given, the tics continue to the
  496. Xright edge. We have also turned off the key, and changed the format to
  497. Xrestrict the $x$-axis tic labels to 2 decimal places.
  498. X
  499. XWith a little more work, the plot can look even better.  Another form
  500. Xof this command allows us to specify the label and position of each
  501. Xtic individually.  Replacing the above {\tt set xtics} command with
  502. Xthe following gives us Figure~\ref{eg5}. We also make use of the line
  503. Xcontinuation character, the backslash (\verb+\+), to spread out this
  504. Xcommand for readability.
  505. X
  506. X\singlespace
  507. X\begin{verbatim}
  508. X    set xtics ("$-\pi$" -pi,\
  509. X     "$-\frac{\pi}{2}$" -pi/2,\
  510. X     "0" 0,\
  511. X     "$\frac{\pi}{2}$" pi/2,\
  512. X     "$\pi$" pi)
  513. X\end{verbatim}
  514. X\currentspace
  515. X
  516. X\boxfigure{htbp}{\fullboxwidth}{
  517. X  \begin{center}
  518. X    \input{eg5}
  519. X  \end{center}
  520. X  \caption{A fancy example of the {\tt set xtics} command.}
  521. X  \label{eg5}
  522. X}
  523. X
  524. X\paragraph{Going further:} You should now be able to make a variety of
  525. Xplots for your \LaTeX\ document. We will present a final example
  526. Xwithout explanation that showcases some of the capabilities of
  527. XGNUPLOT. You may find documentation for the various commands in the
  528. XGNUPLOT manual, though hopefully this example is somewhat
  529. Xself-explanatory. This is shown in Figure~\ref{eg6}.
  530. X
  531. X\singlespace
  532. X\begin{verbatim}
  533. X    set terminal latex
  534. X    set output "eg6.tex"
  535. X    set size 3.5/5, 3/3.
  536. X    set format y "$%g$"
  537. X    set format x "$%5.1f\mu$"
  538. X    set title "This is a title"
  539. X    set xlabel "This is the $x$ axis"
  540. X    set ylabel "This is\\a longer\\version\\ of\\the $y$\\ axis"
  541. X    set label "Data" at -5,-5 right
  542. X    set arrow from -5,-5 to -3.3,-6.7
  543. X    set key -4,8
  544. X    set xtic -10,5,10
  545. X    plot [-10:10] [-10:10] "eg3.dat" title "Data File"  with linespoints 1 7,\
  546. X       3*exp(-x*x)+1  title "$3e^{-x^{2}}+1$" with lines 4
  547. X\end{verbatim}
  548. X\currentspace
  549. X
  550. X\boxfigure{htbp}{\fullboxwidth}{
  551. X  \begin{center}
  552. X    \input{eg6}
  553. X  \end{center}
  554. X  \caption{An example of many features.}
  555. X  \label{eg6}
  556. X}
  557. X
  558. X\subsection{Summary --- Use with \LaTeX}
  559. XIn summary, to use the \LaTeX\ facilities of GNUPLOT, the first
  560. Xcommand to GNUPLOT should be
  561. X\begin{syntax}
  562. X    set terminal latex
  563. X\end{syntax}
  564. Xand the output of GNUPLOT should be directed to a file, for example,
  565. X\begin{verbatim}
  566. X    set output "plot.tex"
  567. X\end{verbatim}
  568. XThis may be anything you like but it should have a {\tt .tex} extension,
  569. Xof course. Then the size of the plot should be given. For example, the
  570. Xcommand 
  571. X\begin{verbatim}
  572. X    set size 1,2
  573. X\end{verbatim}
  574. Xtells GNUPLOT to use a 5 inch wide by 6 inch high box for the plot.
  575. XThe numbers given are {\em scale factors}, not the actual size.  The
  576. Xdefault is 5 inches by 3 inches.  This is the size of the complete
  577. Xplot, including all labels.
  578. X
  579. XWhen finished, the file will contain all of the plots you have
  580. Xspecified (you probably only want one plot per file). This file can
  581. Xthen be used in a \LaTeX\ document, \eg,
  582. X
  583. X\singlespace
  584. X\begin{verbatim}
  585. X    \begin {figure}
  586. X      \begin{center}
  587. X        \input{plot}
  588. X      \end{center}
  589. X    \end {figure}
  590. X\end{verbatim}
  591. X\currentspace
  592. XThis puts the plot into a figure. 
  593. X
  594. XYou will also want to read about the following commands: {\tt set
  595. Xtitle, set xlabel, set ylabel, set key, set label, set xtics, set
  596. Xytics}, and {\tt set clip}.  These are all described in the regular
  597. XGNUPLOT manual.
  598. X
  599. X\section{Use with EEPIC}
  600. X\label{s:eepic}
  601. XEEPIC is a macro package extending the picture environment of \LaTeX.
  602. XIf you have the EPIC or EEPIC macros, and your {\tt dvi} translator
  603. Xsupports the {\em tpic\/} \verb+\special+s, then you have the possible
  604. Xcapability for better-quality output. With EEPIC pictures, the {\tt
  605. Xplot.tex} file will be smaller, \LaTeX\ will run much faster (and need
  606. Xmuch less memory), and the {\tt dvi} file will be smaller.
  607. X
  608. XTo use EEPIC, set GNUPLOT's terminal type to {\tt eepic} instead of
  609. X{\tt latex}, and use GNUPLOT as before. The line styles will change.
  610. XInclude the file {\tt plot.tex} in your document as before, along with
  611. Xthe document style options {\tt [epic,eepic]}.
  612. X
  613. XThis driver should be considered experimental.
  614. X
  615. X\section{For Former Gnu\TeX\ Users}
  616. X\label{oldusers}
  617. X
  618. XFormer Gnu\TeX\ users may be pleased with many of the new features
  619. X(many inspired by your suggestions!), but will also find many changes.
  620. XGNUPLOT will {\em not\/} run all Gnu\TeX\ input files unchanged.
  621. XSeveral Gnu\TeX\ features were not included in GNUPLOT because they
  622. Xwere specific to the \LaTeX\ driver. I encourage you to use the newer
  623. XGNUPLOT.  A translator is supplied with the GNUPLOT distribution that
  624. Xattempts to translate your old Gnu\TeX\ 1.6 input files into GNUPLOT
  625. X2.0 files.
  626. X
  627. XNote also the new EEPIC driver (Section~\ref{s:eepic}).
  628. X
  629. X\subsection{The Differences}
  630. X\begin{itemize}
  631. X\item The {\tt key} command was replaced by the {\tt set key}
  632. Xcommand, and should therefore precede any {\tt plot} commands. A key
  633. Xis shown by default, and can be turned off with {\tt set nokey}. The
  634. Xposition specified is now the top center of the key, instead of the
  635. Xbottom center. The titles and styles of the curves are extracted from
  636. Xthe {\tt plot} command.
  637. X\item The {\tt label} command was replaced by the {\tt set label}
  638. Xcommand. The syntax is slightly different. Left, right, and center
  639. Xjustification are still available, but only vertical centering is
  640. Xpossible. Arrows are defined by the reference point of the label and
  641. Xan ending point. This allows arbitrary slope arrows to be drawn.
  642. XSince \LaTeX\ limits arrows (vectors) to particular slopes, we draw
  643. Xnon-standard-slope arrows with the solid plot line type, and then add
  644. Xan arrowhead. This will require less memory with the EEPIC driver.
  645. X\item The user-defined style facility, controlled by {\tt set style},
  646. Xis completely removed. This was too specific to the \LaTeX\ driver to
  647. Xbe kept in this GNUPLOT release. The \LaTeX\ driver now supports
  648. Xvarious line types in the {\tt lines} and {\tt linespoints} styles.
  649. XSolid lines are the default, with higher-numbered styles providing
  650. Xdotted lines. These solid lines are expensive. Avoid them if you run
  651. Xinto memory or time difficulties, or try the EEPIC driver. The
  652. X\LaTeX\ driver currently supports 6 point types (numbered 7-12) in
  653. Xaddition to the 6 original GNUPLOT points (numbered 1-6). This set may
  654. Xbe extended, so do not depend on wrap-around for point styles over 12. 
  655. X\item Multiple-line xlabels and titles, specified with \verb+\\+, are
  656. Xnot permitted. They are still allowed in the ylabel. The ylabel {\tt
  657. Xskip} parameter, however, is not available, so the ylabel is in a
  658. Xfixed position. 
  659. X\item The {\tt set size} command takes a pair of scale factors, rather
  660. Xthan absolute sizes. The default size is 5 inches wide by 3 inches
  661. Xhigh. In addition, this size is now the size of the entire plot,
  662. Xincluding labels, not just the box defining the plotting area. So you
  663. Xneed to specify a size a little larger than before, in particular
  664. Xwider. The easiest way to convert is to use the translator (see
  665. Xbelow). 
  666. X\item Clipping has been expanded. A {\tt lines}-style curve that
  667. Xcrossed out of the plotting area used to be cut at the last in-range
  668. Xpoint, to be continued at the next in-range point. Now the curve is
  669. Xdrawn from the last in-range point to the edge, toward the
  670. Xout-of-range point. Similarly for returning from out-of-range to
  671. Xin-range. A segment of the curve crossing the plotting area but
  672. Xbeginning outside and ending outside may also be shown. These are all
  673. Xuser-controlled. Read about {\tt set clip}.
  674. X\item The default tic label format is ``\%g'', instead of ``\$\%g\$''.
  675. X\item Ten-point roman (\verb+\tenrm+) is the default font for all text
  676. Xand symbols in the plot. 
  677. X\item Non-interactive behavior, including error messages, has been
  678. Xmuch improved. Input files may be specified as command-line arguments,
  679. Xas well as through redirection.
  680. X\item The help system was completely revamped.
  681. X\item New features (see the GNUPLOT manual):
  682. X  \begin{itemize}
  683. X  \item The {\tt replot} command.
  684. X  \item The {\tt save} command has been expanded.
  685. X  \item The factorial operator.
  686. X  \item The {\tt pause} command.
  687. X  \item The {\tt set dummy} command.
  688. X  \item The {\tt set tics} command.
  689. X  \item The {\tt set xtics} and {\tt set ytics} commands.
  690. X  \item The {\tt set offsets} command.
  691. X  \item The {\tt set grid} command.
  692. X  \item The {\tt set polar} command.
  693. X  \item The {\tt title} option on the {\tt plot} command to
  694. X  specify the title of the curve (for use in the key).
  695. X  \item The line-type and point-type options to the {\tt with} option
  696. X  of the {\tt plot} command. 
  697. X  \item Breaks are specified in data files with blank lines.
  698. X  \item The logical operators now short-circuit, thus 
  699. X\begin{verbatim}
  700. X     x = 4
  701. X     y = (x != 4 && 10/(x-4) < 0) 
  702. X\end{verbatim}
  703. X  gives y a value of false (0), instead of causing an error.
  704. X  \end{itemize}
  705. X
  706. X\end{itemize}
  707. X
  708. X\subsection{The Translator}
  709. XI have provided a translation program, {\tt gnut2p}, to convert gnutex
  710. Xfiles to gnuplot files.  This program does its best, but is not
  711. Xperfect. Most of gnutex will translate directly, some things will
  712. Xtranslated easily (such as {\tt set size}), but some things cannot be
  713. Xtranslated (such as {\tt set style}).  This program moves plot
  714. Xcommands down past the {\tt label} and {\tt key} commands (which
  715. Xchange into {\tt set label} and {\tt set key} commands). This may move
  716. Xit past other commands. If it moves past variable or function
  717. Xdefinitions, {\tt set} commands, or other commands which affect the
  718. Xplot command's execution, then the new version will be incorrect. I
  719. Xexpect this case to be rare; indeed, I generally expect the last lines
  720. Xin Gnu\TeX\ input files used with \LaTeX\ to consist of {\tt plot,
  721. Xlabel,} and {\tt key} commands.
  722. X
  723. XThe usage of this program is simple: 
  724. X\begin{verbatim}
  725. X   gnut2p infile outfile
  726. X\end{verbatim}
  727. X{\tt infile} is an existing Gnu\TeX\ file, and {\tt outfile} will be
  728. Xcreated as the GNUPLOT equivalent. The errors, warnings, and
  729. Xexplanatory comments appear on stderr. Any use of line continuation
  730. Xwill be lost, and some instances of the input style (\eg, white space)
  731. Xmay be changed.
  732. X
  733. X\section{Contact}
  734. XPlease contact me at dfk@cs.duke.edu with any comments you may have.
  735. X
  736. X\end{document}
  737. *-*-END-of-docs/latextut/tutorial.tex-*-*
  738. exit
  739.  
  740.  
  741.