diff options
Diffstat (limited to 'Master/texmf-dist/doc/metapost/base/source/mpgraph.tex')
-rw-r--r-- | Master/texmf-dist/doc/metapost/base/source/mpgraph.tex | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpgraph.tex b/Master/texmf-dist/doc/metapost/base/source/mpgraph.tex index 104b70bf917..e19b1024ce9 100644 --- a/Master/texmf-dist/doc/metapost/base/source/mpgraph.tex +++ b/Master/texmf-dist/doc/metapost/base/source/mpgraph.tex @@ -1,9 +1,11 @@ +% $Id: mpgraph.tex,v 1.3 2005/03/22 00:16:53 karl Exp $ +% MetaPost graph doc, by John Hobby. License at end. \documentclass{article} % article is NOT the original style \usepackage{makeidx} \usepackage{fancyvrb} \usepackage{ctabbing} \RecustomVerbatimEnvironment{verbatim}{BVerbatim}{baseline=c} -\usepackage{epsf} +\usepackage{graphics} \usepackage[textwidth=6in,textheight=8.75in]{geometry} \newcommand\descr[1]{{\langle\hbox{\rm#1}\rangle}} @@ -11,7 +13,7 @@ \newcommand\tdescr[1]{$\langle$\invisgap{\rm#1}\invisgap$\rangle$} \newcommand\Ignore[1]{} % For fooling delatex so spell will work -\newfont\psyvii{rpsyr at 7pt} +\newfont\psyvii{psyr at 7pt} \newcommand\regmark{$^{\hbox{\psyvii\char'322}}$} % Registered trademark \newcommand\logofn{\global\font\logofn=logo8 \logofn} \newcommand\logo{\global\font\logo=logo10 \logo} @@ -119,7 +121,7 @@ $$ Americans of that age in 1991 \cite{Census92}.) \begin{figure}[htp] -$$ \epsfbox{mpgraph.1} $$ +$$ \includegraphics{mpgraph-1.mps} $$ \caption{A graph of the 1991 age distribution in the United States} \label{fig1} \end{figure} @@ -165,11 +167,28 @@ generates only bullets as shown in Figure~\ref{fig2}. cause the line to reappear superimposed on the plotting symbols.) \begin{figure}[htp] -$$ \epsfbox{mpgraph.2} $$ +$$ \includegraphics{mpgraph-2.mps} $$ \caption{The 1991 age distribution plotted with bullets} \label{fig2} \end{figure} +Watch out for the following: the \tdescr{picture expression} is placed +with the lower-left corner at the path knot, not its center. If you +want it to be dead-center, you have to correct the placement +yourself. For the example above, you need something like this instead: + +\medskip +\begin{verbatim} +def MPbullet = + btex \lower\fontdimen22\cmsy \hbox to 0pt{\hss\cmsy\char15\hss} etex +enddef; +\end{verbatim} + +\medskip\noindent +followed by: +$$ \hbox{\verb|gdraw "agepop91.d" plot MPbullet|} $$ + + % glabel, gdotlabel, OUT The {\tt glabel} and {\tt gdotlabel} commands add labels to a graph. The @@ -211,7 +230,7 @@ large numbers. We shall see later that simple transformations such as this can be achieved without generating new data files. \begin{figure}[htp] -$$ \epsfbox{mpgraph.3} $$ +$$ \includegraphics{mpgraph-3.mps} $$ \caption{An improved version of the 1991 age distribution graph} \label{fig3} \end{figure} @@ -270,7 +289,7 @@ draw begingraph(3in,2in); endgraph; \end{verbatim} \atop -\epsfbox{mpgraph.4} +\includegraphics{mpgraph-4.mps} $$ \caption{The 1991 age distribution graph and the input that creates it.} \label{fig4} @@ -306,8 +325,8 @@ Figure~\ref{fig5} graphs execution times for two matrix multiplication algorithm using $$ \hbox{\tt setcoords(log,log)} $$ to specify logarithmic spacing on both axes. The data file {\tt matmul.d} gives -timings for both algorithms:\\ -\hbox to\hsize{\footnotesize\hfil$ +timings for both algorithms: +$$ \hbox to\hsize{\footnotesize\hfil$ \begin{verbatim} 20 .007861 standard MM: size, seconds 30 .022051 @@ -332,13 +351,14 @@ timings for both algorithms:\\ 480 72.60 \end{verbatim} \hfil$} +$$ A blank line in a data file ends a data set. Subsequent {\tt gdraw} commands access additional data sets by just naming the same data file again. Since each line gives one $x$~coordinate and one $y$~coordinate, commentary material after the second data field on a line is ignored. \begin{figure}[htp] -$$ \mathcenter{\epsfbox{mpgraph.5}} +$$ \mathcenter{\includegraphics{mpgraph-5.mps}} \quad \begin{BVerbatim}[baseline=c] draw begingraph(2.3in,2in); @@ -386,7 +406,7 @@ draw begingraph(6.5cm,4.5cm); endgraph; \end{verbatim} \atop -\mathcenter{\epsfbox{mpgraph.6}} +\mathcenter{\includegraphics{mpgraph-6.mps}} $$ \caption{Annual lead emissions and average level at atmospheric monitoring stations in the United States. The MetaPost input is shown above @@ -465,16 +485,19 @@ $$ \begin{verbatim} vardef newy(expr y) = (256/75)*y + mlog y enddef; draw begingraph(3in,2in); glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT); - gdraw "ttimepop.d"; + path p; + gdata("timepop.d", $, augment.p($1, newy(Scvnum $2)); ); + gdraw p withpen nullpen; for y=5,10,20,50,100,150,200,250: grid.lft(format("%g",y), newy(y)) withcolor .85white; endfor autogrid(grid.bot,) withcolor .85white; + gdraw p; frame.llft; endgraph; \end{verbatim} \atop - \epsfbox{mpgraph.7} + \includegraphics{mpgraph-7.mps} $$ \caption{Population of the United States in millions versus time with the population re-expressed as $p/75+\ln p$. The MetaPost input shown @@ -564,7 +587,7 @@ draw begingraph(3in,2in); endgraph; \end{verbatim} \atop - \epsfbox{mpgraph.8} + \includegraphics{mpgraph-8.mps} $$ \caption{A scatter plot and the commands that generated it} \label{fig8} @@ -638,7 +661,7 @@ draw begingraph(3in,2in); endgraph; \end{verbatim} \atop - \epsfbox{mpgraph.9} + \includegraphics{mpgraph-9.mps} $$ \caption{A graph of U.S. annual energy production and the commands that generated it} @@ -726,10 +749,10 @@ $$ \hbox{\tt format($\descr{string expression}$,\,% does this. You must first {\tt input graph} or {\tt input format} to load the macro file. The macro takes a format string and a number to typeset and returns a picture containing the typeset result. Thus -$$ \hbox{\verb|format("%g",2+2)|}\quad {\rm yields}\quad \epsfbox{mpgraph.10} $$ +$$ \hbox{\verb|format("%g",2+2)|}\quad {\rm yields}\quad \includegraphics{mpgraph-10.mps} $$ and $$ \hbox{\verb|format("%3g","6.022e23")|} - \quad {\rm yields}\quad \epsfbox{mpgraph.11} + \quad {\rm yields}\quad \includegraphics{mpgraph-11.mps} $$ A format string consists of @@ -1061,7 +1084,7 @@ For completeness, we also mention one other new feature of MetaPost Version 0.60. When \TeX\ material is included in a picture via the {\tt btex}\ldots{\tt etex} feature, the thickness of horizontal and vertical rules gets rounded to exactly the right number of pixels; i.e., -interpreting MetaPost output according to the PostScript\regmark\ scan +interpreting MetaPost output according to the PostScript scan conversion rules~\cite{ad:red} makes the pixel width equal to the ceiling of the unrounded width. In fact, a similar relationship holds for all line widths. The generated PostScript sets line widths by first transforming |