Debian Codegraph @

texmf-dist/source/latex/makeplot/makeplot.dtx

raw
1 % \iffalse (meta-comment)
2 %
3 % Doc-Source file to use with LaTeX2e
4 %
5 % Copyright 2005-2009 by Jose-Emilio Vila-Forcen ([email protected])
6 %
7 % All rights reserved.
8 %
9 % This work may be distributed and/or modified under the conditions of
10 % the LaTeX Project Public License, either version 1.3 of this license
11 % or (at your option) any later version. The latest version of the
12 % license is in
13 %
14 % http://www.latex-project.org/lppl.txt
15 %
16 % and version 1.3 or later is part of all distributions of LaTeX
17 % version 2003/12/01 or later.
18 %
19 % This work has the LPPL maintenance status "maintained".
20 % The Current Maintainer of this work is Tobias Oetiker ([email protected]).
21 %
22 % I N S T A L L A T I O N
23 %
24 % makeplot.sty:
25 % run: latex makeplot.ins
26 %
27 % makeplot.dvi and pdf:
28 % run: latex makeplot.dtx
29 % makeindex -s gind.ist -o makeplot.ind makeplot.idx
30 % makeindex -s gglo.ist -o makeplot.gls makeplot.glo
31 % latex makeplot.dtx
32 % pdflatex makeplot.dtx
33
34 %<*driver>
35 \documentclass{ltxdoc}
36 \usepackage{makeplot} % to get file info
37 \EnableCrossrefs
38 %\DisableCrossrefs % say \DisableCrossrefs if index is ready
39 \CodelineIndex
40 \RecordChanges % gather update information
41 %\OnlyDescription % comment out for implementation details
42 %\OldMakeindex % use if your MakeIndex is pre-v2.9
43 %\setlength\hfuzz{15pt} % dont make so many
44 %\hbadness=7000 % over and under full box warnings
45 \begin{document}
46 \DocInput{makeplot.dtx}
47 \end{document}
48 %</driver>
49 % \fi
50 %
51 % \CheckSum{1234}
52 %
53 %% \CharacterTable
54 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
55 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
56 %% Digits \0\1\2\3\4\5\6\7\8\9
57 %% Exclamation \! Double quote \" Hash (number) \#
58 %% Dollar \$ Percent \% Ampersand \&
59 %% Acute accent \' Left paren \( Right paren \)
60 %% Asterisk \* Plus \+ Comma \,
61 %% Minus \- Point \. Solidus \/
62 %% Colon \: Semicolon \; Less than \<
63 %% Equals \= Greater than \> Question mark \?
64 %% Commercial at \@ Left bracket \[ Backslash \\
65 %% Right bracket \] Circumflex \^ Underscore \_
66 %% Grave accent \` Left brace \{ Vertical bar \|
67 %% Right brace \} Tilde \~}
68 %%
69 %
70 % \DoNotIndex{\@ifnextchar,\@legend}
71 % \DoNotIndex{\@legendA,\@legendB,\@legendC,\@legendD,\@legendE,\@legendF,\@legendG,%
72 % \@legendAf,\@legendBf,\@legendCf,\@legendDf,\@legendEf,\@legendFf,\@legendGf}
73 % \DoNotIndex{\@legendDL,\@legendDR,\@legendUL,\@legendUR,\@legendXY,\@legendf,\@legendText}
74 % \DoNotIndex{\@makeplot,\@plotFile,\@plotFileA,\@plotFileB,\@plotFileC,\@plotFileD,%
75 % \@plotFileE,\@plotFileF,\@plotFileG,\@whiteBG}
76 % \DoNotIndex{\begin,\CurrentOption,\data,\dataplot,\def,\define@choicekey, \define@key,\dif,\factorX,\factorXmakeplot,\factorY,\factorYmakeplot, \drawmargins,\drawmarginsmakeplot,\ff,\fi,\fillcolorWhiteBG, \fillstyleWhiteBG,\footnotesize,\FPadd,\FPdiv,\FPmul,\heightPlotFactor, \heightPlotFactormakeplot,\highY,\hspace,\ifMP@color,\ifMP@drawmargins, \ifnum,\l,\leftX,\linecolorWhiteBG,\linestyleWhiteBG,\linewidthWhiteBG, \llegendXY,\lowY,\makeatletter,\makeatother,\makebox,\MP@colorfalse, \MP@colortrue,\MP@drawmarginsfalse,\MP@drawmarginstrue,\n,\NeedsTeXFormat, \newcommand,\newenvironment,\newif\normalsize,\nr,\nrr,\orgX,\orgXmakeplot, \orgY,\orgYmakeplot,\posx,\posy,\ProvidesPackage,\psframe,\pshlabel, \psline,\psset,\pst@addfams,\psvlabel,\readdata,\relax,\RequirePackage, \rightX,\rotateleft,\rput,\s,\sep,\sepTx,\sepTxlegendXY,\sepY,\sepYleendXY, \sepYy,\slegendXY,\tickHerex,\tickHerey,\ticky,\tickymakeplot,\typeout, \unitX,\unitY,\val,\vall,\var,\w,widthPlot,\widthPlotmakeplot,\ww,\www, \x,\xa,\xaa,\xaaa,\xaDL,\xaDR,\xamakeplot,\xaOrigin,\xaXY,\xb,\xbb,\xc, \xDiff,\xinc,\xmid,\xp,\xUL,\xUR,\xx,\xz,\xzDL,\xzDR,\xzmakeplot,\xzz, \y,\ya,\yaa,\yaaa,\yaDL,\yaDR,\yamakeplot,\yaOrigin,\yDiff,\yinc,\ymid, \yUL,\yUR,\yz,\yzDL,\yzDR,\yzmakeplot,\yzXY,\factorBOUNDARYx, \factorBOUNDARYxmakeplot,\factorBOUNDARYy,\factorBOUNDARYymakeplot, \framearcWhiteBG,\newif,\gridDx,\gridDxmakeplot,\gridDy,\gridDymakeplot, \widthPlot,\sepYlegendXY,\sepTy,\ProcessOptions,\definecolor}
77 %
78 % \changes{v1.0.7}{2009/08/26}{minor bugs corrected thanks to Herbert Voss}
79 % \changes{v1.0.6}{2008/01/18}{minor bugs corrected due to other packages updates and improved slightly documentation}
80 % \changes{v1.0.5}{2005/12/20}{added option big}
81 % \changes{v1.0.4}{2005/11/23}{corrected small problem that made labels appear twice in the 'ticky' part}
82 % \changes{v1.0.3}{2005/10/24}{added optional parameters to readdata, changed fileplot to listplot command (allows more options from pstricks-add) and corrected a bug related to the option tickyplot}
83 % \changes{v1.0.2}{2005/10/04}{rounded some calculated parameters to avoid overflow (tickherex and tickherey)}
84 % \changes{v1.0.1}{2005/09/24}{data1.mat and data2.mat files are now generated automatically, thanks to Dan}
85 % \changes{v1.0}{2005/09/22}{Initial version by Jose-Emilio Vila-Forcen}
86 %
87 %
88 %
89 %
90 % \GetFileInfo{makeplot.sty}
91 %
92 % \title{A plot package for \LaTeXe\thanks{^^A
93 % This file has version number \fileversion,
94 % last revised \filedate.}}
95 % \author{Jose-Emilio Vila-Forcen \\ \texttt{[email protected]}}
96 % \date{\filedate}
97 % \maketitle
98 %
99 % \PrintChanges
100 %
101 % \section{Introduction}
102 %
103 % The functions described in the present document have been created
104 % to help in the drawing of plots from Matlab to \LaTeX. The overall
105 % objective is to create a easy and fast framework to create plots with
106 % the same style, proper fonts, and just enough parameters.
107 %
108 % \section{Known problems}
109 % \begin{itemize}
110 % \item Sometimes a combination of numbers in the dimensions of the plot might cause an error in latex. That is because the combination of numbers has caused some kind of overflow. The source of the problem might be in the makeplot package or in the pstricks family (supposed to be solved in v2.64 of pstricks-add). Send an email to the package author with all the data and hopefully you will receive an answer with an update of the package: the workaround solution is to use a different number, a close one to the original numbe might work.
111 %
112 % \end{itemize}
113 %
114 %
115 % \section{Description}
116 % The package Startplot is composed of several functions. Due to the
117 % author's limited knowledge of \TeX, it is done following \LaTeX\ macros
118 % and the robustness of the package is not fully demonstrated.
119 %
120 % All positions, total size of the figure and so on are calcul%ated
121 % automatically using package FP.
122 %
123 %
124 % \subsection{Definition of an especific style}
125 % Some functions are provided to change the style of the plots:
126 % \DescribeMacro{\MPbg}
127 % Execute |\MPbg| it in order to use black lines with different styles already predefined.
128 % It is by default
129 %
130 % \DescribeMacro{\MPcolor}
131 % Execute |\MPcolor| it in order to use solid color lines already predefined.
132 % It can be selected using the |color| package option or executing the command.
133 %
134 % \DescribeMacro{colorLine[ABCDEFG]}
135 % If you want to change the colors of the lines, you may change one by one redefining the colors.
136 % For example:
137 % \begin{quote}
138 % |\definecolor{colorLineA}{rgb}{1,1,1}|
139 % \end{quote}
140 %
141 % \DescribeMacro{\styleofLine[ABCDEFG]}
142 % It is possible to modify the seven predefined styles one by one: simply recreate a new definition
143 % for the desired one(s).
144 %
145 % \DescribeMacro{Font commands}
146 % The commands |\fontaxeX|, |\fontaxeY|, |\fonttitleX|, |\fonttitleY| and |\fontlegend| contains
147 % the definitions of the fonts used in different parts of the legend: axes, labels (or titles) and legend.
148 % You may change them as, for example:
149 % \begin{quote}
150 % |\def\fontaxeY{\small}|
151 % \end{quote}
152 %
153 % \DescribeMacro{\defaultOptionsMakeplot}
154 % The |\defaultOptionsMakeplot| command is executed at the beginning of the definition of the plot.
155 % redefine it to your desired code if you need to execute something more for each picture.
156 %
157 %
158 %\subsection{Create the plot}
159 % The plot is composed of several orders consecutive. Besides the order
160 % described here, a lot of them exist in the file which obtain the same
161 % result, but using more input parameters. The ones that I describe here
162 % are enough for the most of the cases.
163 %
164 % \DescribeEnv{makeplot}
165 % The |makeplot| environment is the starting point to create the plot. The
166 % command line is as follows:
167 % \begin{quote}
168 % |\begin{makeplot}|\oarg{keys}\marg{label in Y}\marg{label in X}
169 % .....
170 % |\end{makeplot}|
171 % \end{quote}
172 % The optional arguments are the keys from PsTricks, including the ones for |\psaxes| function. Also,
173 % some new keys are added:
174 %\begin{description}
175 % \item[Dx] Distance between labels in X
176 % \item[Dy] Distance between labels in Y
177 % \item[width] Width of the plot in mm
178 % \item[heightFactor] Factor of height length respect to the width
179 % \item[startX] Minimum value in the axis X
180 % \item[startY] Minimum value in the axis Y
181 % \item[endX] Maximum value in the axis X
182 % \item[endY] Maximum value in the axis Y
183 % \item[factorBoundaryX] Separation to the border
184 % \item[factorBoundaryY] Separation to the border
185 % \item[captionX] Separation to the caption in X, over 100
186 % \item[captionY] Separation to the caption in Y, over 100
187 % \item[changeEndXpos] If it is needed to change the end of the axis X, because of external legend (yes or no)
188 % \item[changeEndXsize] How many mm more than the estandard
189 % \item[tickyplot] Special ticks (all, x, y, none)
190 % \item[drawmargins] Draw margins in this figure (there exist an option in the package to do it globally)
191 % \item[orgX and orgY] Not working properly, intended to change the origin of the graphic
192 %\end{description}
193 % For example, a typical configuration for semilog case it is to use the options:
194 %\begin{quote}
195 % ylogBase=10, logLines=y, subticks=10, xsubticks=1
196 %\end{quote}
197 % and LogLines can take the values x, y or all.
198 %
199 % \DescribeMacro{\makeplot}
200 % The |\makeplot| macro works as the environment, but once the plot is finished it is needed to write |\end{pspicture}|
201 %
202 % \subsection{Plotting the data from files}
203 %
204 % \DescribeMacro{\plotFile}
205 % The |\plotFile|\oarg{keys}\marg{file} macro takes the data from a file and plot it using the existing
206 % properties for lines in PsTricks taking into account the optional keys given to the command.
207 %
208 % \DescribeMacro{\plotFile[ABCDEFG]}
209 % These macros have the same configuration as |\plotFile|, but each one uses the line style predefined. It accept the optinal arguments plotNoMax and PlotNo to say how many different plots are in the file and which one is intented to be plot, and nStep, xStart, xEnd, yStart and yEnd in order to select which values of the file should be plot.
210 %
211 % \subsection{The legend}
212 % The |makeplot| package can do very nice legends and without effort. There exists the next keys to control the apearance of the legend:
213 %\begin{description}
214 % \item[fillcolorWhiteBG] Select the color name for the background of the legend
215 % \item[fillstyleWhiteBG] Select the fillstyle for the background of the legend
216 % \item[framearcWhiteBG] dimension of the arc of the legend box
217 % \item[linewidthWhiteBG] linewidth of the legend box
218 % \item[linestyleWhiteBG] linestyle of the legend box
219 % \item[linecolorWhiteBG] color of the line of the legend box
220 %\end{description}
221 % and
222 %\begin{description}
223 % \item[legendSep] Separation between legends in vertical
224 % \item[lineLength] Length of the line in the legend area
225 % \item[lineTextSep] Separation between the line and the text
226 % \item[borderlineSep] Separation from the border of the box to the line
227 %\end{description}
228 %
229 % The main commands are as follows:
230 %
231 %
232 % \DescribeMacro{\legendXY}
233 % The |\legendXY| macro usage is as follows:
234 % \begin{quote}
235 % |\legendXY|\oarg{keys}\parg{coordinate X,coordinateY}\marg{number of lines to be in the legend}%
236 % \marg{width in mm}
237 % \end{quote}
238 %
239 % \DescribeMacro{\legend[DL,DR,UL,UR]}
240 % These macros avoid the needed to specify a coordinate and draw the legend in the
241 % position down-left, down-right, up-left or up-right of the plot. Therefore, the syntax is:
242 % \begin{quote}
243 % |\legendDL|\oarg{keys}\marg{number of lines to be in the legend}%
244 % \marg{width in mm}
245 % \end{quote}
246 %
247 % There exist some different ways to write the legends into the box. The easiest one is to use the
248 % next commands:
249 %
250 % \DescribeMacro{\legend[ABCDEFG]f}
251 % These macros write the legends into the box in the order of the tex source. Each one has a different
252 % line style as it was for the plot. The syntax is:
253 % \begin{quote}
254 % |\legendCf|\oarg{keys}\marg{text}%
255 % \end{quote}
256 % where the keys might modify the line style.
257 %
258 %
259 % \DescribeMacro{\legendText}
260 % The |\legendText| macro includes some text in the legend without a line:
261 % \begin{quote}
262 % |\legendText|\oarg{keys}\marg{text}%
263 % \end{quote}
264 % where the keys are not used, but kept in the definition of the macro for paralelism.
265 %
266 % \section{Record proper Matlab data}
267 % \index{Matlab}
268 % Matlab is one of the most famous data processing software in the
269 % research community. Because of its simplicity, the generation of the
270 % needed files can be done easily after their generation.
271 %
272 % Each plot should be saved in a separate file in ASCII format. Thus,
273 %follow the next process for each one of the lines to plot:
274 % \begin{enumerate}
275 % \item Create a matrix Nx2, where N denotes the dimensionality of the
276 % data. Put in the first column the data of the X-axis, and in the
277 % second one the values in the Y-axis corresponding to the previous X
278 % one, let's call this matrix \emph{values};
279 % \item Save \emph{values} in a file as follows: \verb+ save file.mat values -ascii+.
280 % \end{enumerate}
281 %
282 %\paragraph{Remarks}
283 %\begin{itemize}
284 % \item Editing in a text editor should be possible, and numbers should be visible in ASCII format;
285 % \item The data should be real;
286 % \item It is possible to comment values in the file with \verb+%+;
287 % \item It is possible to modify manually the values in the file.
288 %\end{itemize}
289 %
290 %
291 %
292 % \section{Create EPS files}
293 % \index{EPS}
294 % It is possible to create EPS files and use them directly in latex. The %
295 % benefits are faster compilation and it is always good to have them in%
296 % separate files, for example for distribution.
297 %
298 % In order to create EPS files, follow the procedure:
299 % \begin{enumerate}
300 % \item Install perl from www.perl.com; \index{perl}
301 % \item Copy bbox.exe from ps2eps.zip file to \verb+c:\texmf\miktex\bin+. \index{ps2eps}%
302 % ps2eps.zip can be found at \\ { \verb+www.telematik.informatik.uni-karlsruhe.de/~bless/ps2eps.html+};
303 % \item \verb+SET PATHEXT=.pl;%PATHEXT%+ or use the start, settings, control panel,%
304 % system, advanced tab, environment variables and edit the PATHEXT entry accordingly;
305 % \item Rename ps2eps to ps2eps.pl and copy it to \verb+c:\texmf\miktex\bin+.
306 % \end{enumerate}
307 %
308 % Now, we create a batch file to help in the compilation of each time:%
309 % Create a bat file something like: \verb+makefigure.bat+, \index{makefigure.bat} save it%
310 % in \verb+c:\texmf\miktex\bin+. It should contain the following lines:
311 % \begin{verbatim}
312 % echo off
313 % del figures/%1.eps
314 % latex %1eps.tex
315 % dvips -t a4 -P pdf %1eps.dvi
316 % ps2eps.pl %1eps.ps %1eps.eps
317 % del %1eps.ps
318 % del %1eps.eps
319 % mkdir figures
320 % rename %1eps.eps.eps %1.eps
321 % move %1.eps figures
322 % \end{verbatim}
323 % It is possible to change the contain above for different file names.%
324 % In my case, I am creating files are follows:
325 %
326 % \begin{verbatim}
327 % \input{headers.tex}
328 % \begin{document}
329 % \pagestyle{empty}
330 % \input{fig1.tex}
331 % \end{document}
332 % \end{verbatim}
333 % with the name \verb+NAMEeps.tex+ where \verb+NAME+ can be changed%
334 % to the desired name. The file \verb+headers.tex+ contains all%
335 % the headers of my report and therefore all proper fonts and so on%
336 % will be used in this file and in the general one.
337 %
338 % To create this file, it is possible to make another batch file called \verb+fileForEPS.bat+ such that:
339 %
340 % \begin{verbatim}
341 % echo off
342 % echo \input{headers.tex} \begin{document} \emph{(continue in the same line)}
343 % \pagestyle{empty} \input{%1.tex} \end{document} > %1eps.tex
344 % \end{verbatim}
345 %
346 % Execute \verb+makefigure NAME+ in the proper directory, and the EPS picture file%
347 % will be created in the directory \verb+figures/+. If you need to create the%
348 % additional tex file, execute \verb+fileForEPS NAME+ and it will be done.
349 %
350 %
351 % The procedure described above allows to use the following code in the main file:
352 % \begin{verbatim}
353 % \begin{figure}
354 % \centering
355 % %\input{fig.tex}
356 % \includegraphics{figure/fig.eps}
357 % \caption{Caption of the figure}
358 % \label{fig:fig}
359 % \end{figure}
360 % \end{verbatim}
361 %where the commented line will describe which file is used: it is possible%
362 % to choose between the tex file or (once picture is fixed and in order to%
363 % improve speed) the eps one.
364 %
365 %
366 % \clearpage
367 % \section{An example file}
368 % \begin{macrocode}
369 %<*mptest>
370 \documentclass[]{article}
371 \usepackage[color]{makeplot}
372 \begin{document}
373 \begin{figure}
374 \centering
375
376 \begin{makeplot}[startX=-10, endX=5, startY=-1, endY=0, Dx = 5,%
377 width=40, heightFactor=1, %
378 ylogBase=10, logLines=y, subticks=10, xsubticks=1]%
379 {$P_e$}{WNR, [dB]}
380 \plotFileA{data1.mat}
381 \plotFileB{data2.mat}
382 \legendDL{24.5}{2}
383 \legendAf{UDQ-QIM}
384 \legendBf{UQ-QIM}
385 \end{makeplot}
386
387 \caption{Performance analysis result.}
388 \label{fig:results}
389 \end{figure}
390
391 \end{document}
392 %</mptest>
393 % \end{macrocode}
394 % \subsection{Data files:}
395 % \paragraph{data1.mat}
396 % \begin{macrocode}
397 %<*data1>
398 -1.0000000e+001 -3.1186120e-001
399 -9.5000000e+000 -3.1382220e-001
400 -9.0000000e+000 -3.1610308e-001
401 -8.5000000e+000 -3.1874224e-001
402 -8.0000000e+000 -3.2177814e-001
403 -7.5000000e+000 -3.2524775e-001
404 -7.0000000e+000 -3.2918480e-001
405 -6.5000000e+000 -3.3361772e-001
406 -6.0000000e+000 -3.3856759e-001
407 -5.5000000e+000 -3.4404614e-001
408 -5.0000000e+000 -3.5005399e-001
409 -4.5000000e+000 -3.5657933e-001
410 -4.0000000e+000 -3.6359717e-001
411 -3.5000000e+000 -3.7106902e-001
412 -3.0000000e+000 -3.7894319e-001
413 -2.5000000e+000 -3.8715537e-001
414 -2.0000000e+000 -3.9562939e-001
415 -1.5000000e+000 -4.0427825e-001
416 -1.0000000e+000 -4.1300527e-001
417 -5.0000000e-001 -4.2170561e-001
418 0.0000000e+000 -4.3026847e-001
419 5.0000000e-001 -4.5284882e-001
420 1.0000000e+000 -4.8524584e-001
421 1.5000000e+000 -5.2154969e-001
422 2.0000000e+000 -5.6193985e-001
423 2.5000000e+000 -6.0664420e-001
424 3.0000000e+000 -6.5595407e-001
425 3.5000000e+000 -7.1023618e-001
426 4.0000000e+000 -7.6994081e-001
427 4.5000000e+000 -8.3560655e-001
428 5.0000000e+000 -9.0786295e-001
429 %</data1>
430 % \end{macrocode}
431 % \paragraph{data2.mat}
432 % \begin{macrocode}
433 %<*data2>
434 -1.0000000e+001 -3.0170171e-001
435 -9.5000000e+000 -3.0182275e-001
436 -9.0000000e+000 -3.0197731e-001
437 -8.5000000e+000 -3.0217679e-001
438 -8.0000000e+000 -3.0243768e-001
439 -7.5000000e+000 -3.0278484e-001
440 -7.0000000e+000 -3.0325664e-001
441 -6.5000000e+000 -3.0391260e-001
442 -6.0000000e+000 -3.0484295e-001
443 -5.5000000e+000 -3.0617875e-001
444 -5.0000000e+000 -3.0809964e-001
445 -4.5000000e+000 -3.1083660e-001
446 -4.0000000e+000 -3.1466753e-001
447 -3.5000000e+000 -3.1990577e-001
448 -3.0000000e+000 -3.2688343e-001
449 -2.5000000e+000 -3.3593295e-001
450 -2.0000000e+000 -3.4737023e-001
451 -1.5000000e+000 -3.6148225e-001
452 -1.0000000e+000 -3.7852034e-001
453 -5.0000000e-001 -3.9869936e-001
454 0.0000000e+000 -4.2220206e-001
455 5.0000000e-001 -4.4918738e-001
456 1.0000000e+000 -4.7980138e-001
457 1.5000000e+000 -5.1418989e-001
458 2.0000000e+000 -5.5251165e-001
459 2.5000000e+000 -5.9495142e-001
460 3.0000000e+000 -6.4173231e-001
461 3.5000000e+000 -6.9312654e-001
462 4.0000000e+000 -7.4946429e-001
463 4.5000000e+000 -8.1114012e-001
464 5.0000000e+000 -8.7861718e-001
465 %</data2>
466 % \end{macrocode}
467 %
468 % \StopEventually{}
469 % \clearpage
470 %
471 % \section{The implementation}
472 % \begin{macrocode}
473 %<*makeplot>
474 % \end{macrocode}
475 %
476 %
477 % \subsection{Headers}
478 %
479 % First we test that we got the right format and name the package, and load external packages.
480 % \begin{macrocode}
481 \NeedsTeXFormat{LaTeX2e}%
482 \ProvidesPackage{makeplot}[2009/08/26 %
483 v1.0.7 %
484 Plots utility from Jose-Emilio Vila-Forcen]%
485 \RequirePackage[nomessages]{fp}%
486 \RequirePackage{pst-plot}%
487 \RequirePackage{pstricks-add}%
488 \RequirePackage{xkeyval}%
489 % \end{macrocode}
490 %
491 % \begin{macro}{color}
492 % The option |color| leads to a redefinition of the line styles
493 % of the plot and uses colors with solid lines. Otherwise, black lines
494 % with different line styles are used
495 % \begin{macrocode}
496 \newif\ifMP@color%
497 \MP@colorfalse%
498 \DeclareOption{color}{%
499 \MP@colortrue%
500 \typeout{ ------}%
501 \typeout{ ------ makePlot package working in color}%
502 \typeout{ ------}}%
503 % \end{macrocode}
504 % \end{macro}
505 %
506 % \begin{macro}{drawmargins}
507 % The option | drawmargins | draw the margins of the figues. This option
508 % is useful in order to check if something is going out of the margins,
509 % since there is not internal checking for that.
510 % \begin{macrocode}
511 \newif\ifMP@drawmargins%
512 \MP@drawmarginsfalse%
513 \DeclareOption{drawmargins}{%
514 \MP@drawmarginstrue%
515 \typeout{ ------}%
516 \typeout{ ------ makePlot package drawing the margins}%
517 \typeout{ ------}}%
518 % \end{macrocode}
519 % \end{macro}
520 %
521 % \begin{macro}{big}
522 % The option | big | put the lines of the plot larger
523 % \begin{macrocode}
524 \newif\ifMP@big%
525 \MP@bigfalse%
526 \DeclareOption{big}{%
527 \MP@bigtrue
528 \typeout{ ------}%
529 \typeout{ ------ makePlot package in big size}%
530 \typeout{ ------}}%
531 % \end{macrocode}
532 % \end{macro}
533 %
534 % If an unknown option is used, a warning will be displayed.
535 % \begin{macrocode}
536 \DeclareOption*{%
537 \PackageWarning{startPlot}{%
538 Unknown option '\CurrentOption'}}%
539 % \end{macrocode}
540 %
541 % Now we process the options.
542 % \begin{macrocode}
543 \ProcessOptions\relax%
544 % \end{macrocode}
545 %
546 % \subsection{Commands to fix the style}
547 %
548 % \begin{macro}{\MPbg}
549 % Command to use the styles of the lines in black and white, by default:
550 % \begin{macrocode}
551 \newcommand{\MPbg}{%
552 \def\styleoflineA{%
553 \psset{linestyle=solid, dash=1pt 0pt 0pt 0pt, dotsep=0pt,%
554 linecolor=black}}%
555 \def\styleoflineB{%
556 \psset{linestyle=dashed, dash=5pt 5pt 0pt 0pt, dotsep=0pt,%
557 linecolor=black}}%
558 \def\styleoflineC{%
559 \psset{linestyle=dotted, dash=3pt 2pt 0pt 0pt, dotsep=1pt,%
560 linecolor=black}}%
561 \def\styleoflineD{%
562 \psset{linestyle=dashed, dash=4pt 1.5pt 1pt 1.5pt, dotsep=3pt,%
563 linecolor=black}}%
564 \def\styleoflineE{%
565 \psset{linestyle=dotted, dash=1pt 4pt 0pt 0pt, dotsep=3pt,%
566 linecolor=black}}%
567 \def\styleoflineF{%
568 \psset{linestyle=dashed, dash=6pt 1.5pt 3pt 1.5pt, dotsep=3pt,%
569 linecolor=black}}%
570 \def\styleoflineG{%
571 \psset{linestyle=dashed, dash=2pt 6pt 0pt 0pt, dotsep=0pt,%
572 linecolor=black}}}%
573 % \end{macrocode}
574 % \end{macro}
575 %
576 % \begin{macro}{MPcolor}
577 % Definition of the standard colors for the lines, using the
578 % color option of the package. They might be changed by the user:
579 % \begin{macrocode}
580 \definecolor{colorLineA}{rgb}{0,0,1}%
581 \definecolor{colorLineB}{rgb}{1,0,0}%
582 \definecolor{colorLineC}{rgb}{0,1,0}%
583 \definecolor{colorLineD}{rgb}{0,1,1}%
584 \definecolor{colorLineE}{rgb}{1,0,1}%
585 \definecolor{colorLineF}{rgb}{1,1,0}%
586 \definecolor{colorLineG}{rgb}{0.5,0.5,0.5}%
587 % \end{macrocode}
588 %
589 % Command to set the styles of the lines using colors:
590 % \begin{macrocode}
591 \newcommand{\MPcolor}{%
592 \def\styleoflineA{\psset{linestyle=solid, linecolor=colorLineA}}%
593 \def\styleoflineB{\psset{linestyle=solid, linecolor=colorLineB}}%
594 \def\styleoflineC{\psset{linestyle=solid, linecolor=colorLineC}}%
595 \def\styleoflineD{\psset{linestyle=solid, linecolor=colorLineD}}%
596 \def\styleoflineE{\psset{linestyle=solid, linecolor=colorLineE}}%
597 \def\styleoflineF{\psset{linestyle=solid, linecolor=colorLineF}}%
598 \def\styleoflineG{\psset{linestyle=solid, linecolor=colorLineG}}}%
599 % \end{macrocode}
600 % \end{macro}
601 %
602 % According to the package option, one of the styles will be loaded:
603 % \begin{macrocode}
604 \ifMP@color%
605 \MPcolor%
606 \else%
607 \MPbg%
608 \fi%
609 % \end{macrocode}
610 %
611 % \begin{macrocode}
612 \makeatletter%
613 % \end{macrocode}
614 %
615 % \begin{macro}{Font sizes}
616 % Definition of the standard font sizes in the plot. It is possible to redefine them.
617 % \begin{macrocode}
618 \def\fontaxeY{\normalsize}%
619 \def\fontaxeX{\normalsize}%
620 \def\fonttitleY{\normalsize}%
621 \def\fonttitleX{\normalsize}%
622 \def\fontlegend{\footnotesize}%
623 % \end{macrocode}
624 % \end{macro}
625 %
626 % \subsection{Main macros: makeplot}
627 % Options for the command |makeplot| and the addition of the family of keys.
628 %
629 % \begin{macrocode}
630 \define@key[psset]{makeplot}{Dx}[1]%
631 {\def\gridDxmakeplot{#1}}%
632 \define@key[psset]{makeplot}{Dy}[1]%
633 {\def\gridDymakeplot{#1}}%
634 \define@key[psset]{makeplot}{width}[50]%
635 {\def\widthPlotmakeplot{#1}}%
636 \define@key[psset]{makeplot}{heightFactor}[1]%
637 {\def\heightPlotFactormakeplot{#1}}%
638 \define@key[psset]{makeplot}{startX}[0]%
639 {\def\xamakeplot{#1}}%
640 \define@key[psset]{makeplot}{startY}[0]%
641 {\def\yamakeplot{#1}}%
642 \define@key[psset]{makeplot}{endX}[1]%
643 {\def\xzmakeplot{#1}}%
644 \define@key[psset]{makeplot}{endY}[1]%
645 {\FPmul\yzmakeplot{#1}{1.0001}}%
646 \define@key[psset]{makeplot}{factorBoundaryX}%
647 {\FPdiv\factorBOUNDARYxmakeplot{#1}{1.5}}%
648 \define@key[psset]{makeplot}{factorBoundaryY}%
649 {\FPdiv\factorBOUNDARYymakeplot{#1}{1.5}}%
650 \define@key[psset]{makeplot}{captionY}%
651 {\FPdiv\factorXmakeplot{#1}{8}}%
652 \define@key[psset]{makeplot}{captionX}%
653 {\FPdiv\factorYmakeplot{#1}{11}}%
654 \define@choicekey[psset]{makeplot}{changeEndXpos}[\var\nr]{no,yes}%
655 {\def\endXamakeplot{\nr}}%
656 \define@key[psset]{makeplot}{changeEndXsize}%
657 {\def\endXbmakeplot{#1}}%
658 \define@choicekey[psset]{makeplot}{tickyplot}[\val\nr]{all,x,y,none}%
659 {\def\tickymakeplot{\nr}} %
660 \define@choicekey[psset]{makeplot}{drawmargins}[\vall\nrr]{yes,no}%
661 {\def\drawmarginsmakeplot{\nrr}} %
662 \define@key[psset]{makeplot}{orgX}%
663 {\def\orgXmakeplot{#1}} %
664 \define@key[psset]{makeplot}{orgY}%
665 {\def\orgYmakeplot{#1}} %
666 \pst@addfams{makeplot}%
667 % \end{macrocode}
668 %
669 % Default values for the above parameters
670 % \begin{macrocode}
671 \psset{Dx=1, Dy=1,
672 width=50, heightFactor=1, startX=0, endX=1, startY=0, endY=1,
673 showorigin=true, axesstyle=frame, ticks=all, labels=all,
674 factorBoundaryX=1, factorBoundaryY=1, captionY=100, captionX=100,
675 xsubticks=0, subticksize=1, subtickcolor=black}%
676 \ifMP@big%
677 \psset{tickwidth=0.5pt, subtickwidth=0.5pt, linewidth=1pt}%
678 \else%
679 \psset{tickwidth=0.2pt, subtickwidth=0.2pt, linewidth=0.5pt}%
680 \fi%
681 \psset{tickyplot=all}%
682 \psset{changeEndXsize=0, changeEndXpos=no}%
683 \ifMP@drawmargins%
684 \psset{drawmargins=yes}%
685 \else%
686 \psset{drawmargins=no}%
687 \fi%
688 \psset{orgX=314, orgY=314}%
689 % \end{macrocode}
690 %
691 % \begin{environment}{makeplot}
692 % The |makeplot| environemnt perfoms most of the tasks needed for the plot. The
693 % axes are drawn, the legends and everything related with the background of the plot
694 % besides the legend, that will arrive later.
695 % \begin{macrocode}
696 \newenvironment{makeplot}[3][]%
697 {\makeplot[#1]{#2}{#3}}%
698 {\end{pspicture}}%
699 % \end{macrocode}
700 % \end{environment}
701 %
702 % \begin{macro}{\defaultOptionsMakeplot}
703 % Default values, it is possible to change this command as desired
704 % to include some source to be executed in each |makeplot| command
705 % or enviroment call
706 % \begin{macrocode}
707 \def\defaultOptionsMakeplot{}%
708 % \end{macrocode}
709 % \end{macro}
710 %
711 % \begin{macro}{\makeplot}
712 % This is the most important macro, it can be used instead of the
713 % makeplot enviroment just adding |\end{pspicture}| at the end of the
714 % plot.
715 % \begin{macrocode}
716 \def\makeplot{\@ifnextchar[\@makeplot{\@makeplot[]}}%
717 \def\@makeplot[#1]#2#3{%
718 % Use the default options command and process
719 % the options of the command line
720 \defaultOptionsMakeplot%
721 \psset{#1}%
722 % Calculate the dimensions of the plot
723 \def\gridDx{\gridDxmakeplot}%
724 \def\gridDy{\gridDymakeplot}%
725 \def\widthPlot{\widthPlotmakeplot}%
726 \def\heightPlotFactor{\heightPlotFactormakeplot}%
727 \def\xa{\xamakeplot}%
728 \def\ya{\yamakeplot}%
729 \def\xz{\xzmakeplot}%
730 \def\yz{\yzmakeplot}%
731 \def\factorBOUNDARYx{\factorBOUNDARYxmakeplot}%
732 \def\factorBOUNDARYy{\factorBOUNDARYymakeplot}%
733 \def\factorX{\factorXmakeplot}%
734 \def\factorY{\factorYmakeplot}%
735 \def\endXa{\endXamakeplot}%
736 \def\endXb{\endXbmakeplot}%
737 \def\ticky{\tickymakeplot}%
738 \def\drawmargins{\drawmarginsmakeplot}%
739 \def\orgX{\orgXmakeplot}%
740 \def\orgY{\orgYmakeplot}%
741 %
742 % Use the fonts established
743 \def\pshlabel{\fontaxeX}%
744 \def\psvlabel{\fontaxeY}%
745 \def\pshlabel{\fontaxeX}%
746 \def\psvlabel{\fontaxeY}%
747 %
748 % Calculate the proper units for the plot
749 \FPadd\xDiff\xz{-\xa}%
750 \FPdiv\unitX\widthPlot\xDiff%
751 \FPadd\yDiff\yz{-\ya}%
752 \FPmul\ff\widthPlot\heightPlotFactor%
753 \FPdiv\unitY\ff\yDiff%
754 \psset{xunit=\unitX mm,yunit=\unitY mm}%
755 %
756 \FPadd\yinc\yz{-\ya}%
757 \FPdiv\ymid\yinc{2}%
758 \FPadd\ymid\ymid\ya%
759 \FPadd\xinc\xz{-\xa}%
760 \FPdiv\xmid\xinc{2}%
761 \FPadd\xmid\xmid\xa%
762 \FPadd\xzz\xz{0}%
763 %
764 % Related to the position of the legends
765 \FPdiv\factorX\factorX\unitX%
766 \FPadd\xaa\xa{-\factorX}%
767 \FPdiv\factorY\factorY\unitY%
768 \FPadd\yaa\ya{-\factorY}%
769 %
770 % Related to the size of the plot
771 \FPdiv\factorBOUNDARYx\factorBOUNDARYx\unitX%
772 \FPadd\xaaa\xaa{-\factorBOUNDARYx}%
773 \FPdiv\factorBOUNDARYy\factorBOUNDARYy\unitY%
774 \FPadd\yaaa\yaa{-\factorBOUNDARYy}%
775 %
776 % Change of the size of the plot
777 % if it is asked in the options,
778 % like putting the legend at the right
779 \ifnum \endXb>0
780 \FPdiv\w{\endXb}\unitX%
781 \ifnum \endXa=0
782 \def\endXa{\xz}%
783 \fi%
784 \FPadd\ww{\endXa}{-\xz}%
785 \def\sep{0.5}%
786 \FPdiv\www\sep\unitX%
787 \FPadd\xzz\xz\w%
788 \FPadd\xzz\xzz\ww%
789 \FPadd\xzz\xzz\www %
790 \fi%
791 %
792 % Starting the pspicture environment
793 \begin{pspicture}(\xaaa,\yaaa)(\xzz,\yz)%
794 %
795 % Draw a box with the margins if requested
796 \ifnum \drawmargins=0
797 \psframe(\xaaa,\yaaa)(\xzz,\yz)%
798 \fi%
799 %
800 \FPadd\tickHerex{\yz}{-\ya}%
801 \FPmul\tickHerex\tickHerex\unitY%
802 \FPadd\tickHerey{\xz}{-\xa}%
803 \FPmul\tickHerey\tickHerey\unitX%
804 %
805 % To change the origin of the plot
806 % not working yet
807 \def\xaOrigin{\xa}%
808 \def\yaOrigin{\ya}%
809 \ifnum \orgX=314
810 \else%
811 \def\xaOrigin{\orgX}%
812 \fi%
813 \ifnum \orgY=314
814 \else%
815 \def\yaOrigin{\orgY}%
816 \fi %
817 %
818 % Put the ticks as given in the options
819 \ifnum \ticky=0
820 \psaxes[Ox=\xa,Oy=\ya,Dx=\gridDx,Dy=\gridDy, #1,%
821 ticksize=-4pt 4pt, subticks=0, subticksize=0,%
822 tickwidth=0.5pt, linewidth=0pt,%
823 axesstyle=axes, linecolor=white, #1, ticks=all, labels=none]%
824 {-}(\xa,\ya)(\xa,\ya)(\xz,\yz)%
825 \fi%
826 \ifnum \ticky=1
827 \psaxes[Ox=\xa,Oy=\ya,Dx=\gridDx,Dy=\gridDy, #1,%
828 ticksize=-4pt 4pt, subticks=0, subticksize=0,%
829 tickwidth=0.5pt, linewidth=0pt,%
830 axesstyle=axes, linecolor=white, #1, ticks=x, labels=none]%
831 {-}(\xa,\ya)(\xa,\ya)(\xz,\yz)%
832 \fi%
833 \ifnum \ticky=2
834 \psaxes[Ox=\xa,Oy=\ya,Dx=\gridDx,Dy=\gridDy, #1,%
835 ticksize=-4pt 4pt, subticks=0, subticksize=0,%
836 tickwidth=0.5pt, linewidth=0pt,%
837 axesstyle=axes, linecolor=white, #1, ticks=y, labels=none]%
838 {-}(\xa,\ya)(\xa,\ya)(\xz,\yz)%
839 \fi%
840 \ifnum \ticky=3
841 \fi%
842 %
843 % Put the main axes and the grid
844 \FPround\tickHerex{\tickHerex}{10}%
845 \FPround\tickHerey{\tickHerey}{10}%
846 \psaxes[xticksize=0mm \tickHerex mm, yticksize=0mm \tickHerey mm,%
847 Ox=\xa,Oy=\ya,Dx=\gridDx,Dy=\gridDy, #1]%
848 {-}(\xaOrigin,\yaOrigin)(\xa,\ya)(\xz,\yz)%
849 \def\MP@xa{\xaOrigin}%
850 \def\MP@ya{\yaOrigin}%
851 \def\MP@xz{\xz}%
852 \def\MP@yz{\yz}%
853 %
854 % Write the legend of the plot
855 \rput(\xaa,\ymid){\rotateleft{\fonttitleY #2}}%
856 \rput(\xmid,\yaa){\fonttitleX #3}%
857 \ifMP@big%
858 \psset{linewidth=2pt}%
859 \else%
860 \psset{linewidth=1pt}%
861 \fi%
862 }%
863 % \end{macrocode}
864 % \end{macro}
865 %
866 % \subsection{How to plot the data of a file}
867 % \begin{macro}{\plotFile}
868 % Function to plot a file with the linestyle given
869 % \begin{macrocode}
870 \def\plotFile{\@ifnextchar[\@plotFile{\@plotFile[]}}%
871 \def\@plotFile[#1]#2{%
872 \readdata[#1]{\data}{#2}\listplot[#1]{\data}}%
873 % \end{macrocode}
874 % \end{macro}
875 % And now, a specific function for each linestyle predefined:
876 % \begin{macro}{\plotFileA}
877 % \begin{macrocode}
878 \def\plotFileA{\@ifnextchar[\@plotFileA{\@plotFileA[]}}%
879 \def\@plotFileA[#1]#2{%
880 \styleoflineA%
881 \plotFile[#1]{#2}}%
882 % \end{macrocode}
883 % \end{macro}
884 % \begin{macro}{\plotFileB}
885 % \begin{macrocode}
886 \def\plotFileB{\@ifnextchar[\@plotFileB{\@plotFileB[]}}%
887 \def\@plotFileB[#1]#2{%
888 \styleoflineB%
889 \plotFile[#1]{#2}}%
890 % \end{macrocode}
891 % \end{macro}
892 % \begin{macro}{\plotFileC}
893 % \begin{macrocode}
894 \def\plotFileC{\@ifnextchar[\@plotFileC{\@plotFileC[]}}%
895 \def\@plotFileC[#1]#2{%
896 \styleoflineC%
897 \plotFile[#1]{#2}}%
898 % \end{macrocode}
899 % \end{macro}
900 % \begin{macro}{\plotFileD}
901 % \begin{macrocode}
902 \def\plotFileD{\@ifnextchar[\@plotFileD{\@plotFileD[]}}%
903 \def\@plotFileD[#1]#2{%
904 \styleoflineD%
905 \plotFile[#1]{#2}}%
906 % \end{macrocode}
907 % \end{macro}
908 % \begin{macro}{\plotFileE}
909 % \begin{macrocode}
910 \def\plotFileE{\@ifnextchar[\@plotFileE{\@plotFileE[]}}%
911 \def\@plotFileE[#1]#2{%
912 \styleoflineE%
913 \plotFile[#1]{#2}}%
914 % \end{macrocode}
915 % \end{macro}
916 % \begin{macro}{\plotFileF}
917 % \begin{macrocode}
918 \def\plotFileF{\@ifnextchar[\@plotFileF{\@plotFileF[]}}%
919 \def\@plotFileF[#1]#2{%
920 \styleoflineF%
921 \plotFile[#1]{#2}}%
922 % \end{macrocode}
923 % \end{macro}
924 % \begin{macro}{\plotFileG}
925 % \begin{macrocode}
926 \def\plotFileG{\@ifnextchar[\@plotFileG{\@plotFileG[]}}%
927 \def\@plotFileG[#1]#2{%
928 \styleoflineG%
929 \plotFile[#1]{#2}}%
930 % \end{macrocode}
931 % \end{macro}
932 %
933 % \subsection{Legends code}
934 %
935 % \begin{macro}{\legend}
936 % Defines the general |\legend| command, the inputs are:
937 % the optional parameter with PSTricks keys, the position in X,
938 % the length of the line, the separation between line and text,
939 % the position in Y and the text of the legend.
940 % \begin{macrocode}
941 \def\legend{\@ifnextchar[\@legend{\@legendf[]}}%
942 \def\@legend[#1]#2#3#4#5#6{%
943 \def\xb{#2}%
944 \def\x{#3}%
945 \FPdiv\x\x\unitX%
946 \FPadd\xbb\xb\x%
947 \def\x{#4}%
948 \FPdiv\x\x\unitX%
949 \FPadd\xc\xbb\x%
950 %
951 \def\y{#5}%
952 \psline[#1]{-}(\xb,\y)(\xbb,\y)%
953 \rput(\xc,\y){\makebox[0 cm][l]{{\fontlegend #6}}}}%
954 % \end{macrocode}
955 % \end{macro}
956 %
957 % \begin{macro}{\legend[ABCDEFG]}
958 % One command for each line style: as the previous command, but
959 % now using the predefined styles
960 % \begin{macrocode}
961 \def\legendA{\@ifnextchar[\@legendA{\@legendA[]}}%
962 \def\@legendA[#1]#2#3#4#5{%
963 \styleoflineA%
964 \legend[#1]{#2}{#3}{#4}{#5}}%
965 \def\legendB{\@ifnextchar[\@legendB{\@legendB[]}}%
966 \def\@legendB[#1]#2#3#4#5{%
967 \styleoflineB%
968 \legend[#1]{#2}{#3}{#4}{#5}}%
969 \def\legendC{\@ifnextchar[\@legendC{\@legendC[]}}%
970 \def\@legendC[#1]#2#3#4#5{%
971 \styleoflineC%
972 \legend[#1]{#2}{#3}{#4}{#5}}%
973 \def\legendD{\@ifnextchar[\@legendD{\@legendD[]}}%
974 \def\@legendD[#1]#2#3#4#5{%
975 \styleoflineD%
976 \legend[#1]{#2}{#3}{#4}{#5}}%
977 \def\legendE{\@ifnextchar[\@legendE{\@legendE[]}}%
978 \def\@legendE[#1]#2#3#4#5{%
979 \styleoflineE%
980 \legend[#1]{#2}{#3}{#4}{#5}}%
981 \def\legendF{\@ifnextchar[\@legendF{\@legendF[]}}%
982 \def\@legendF[#1]#2#3#4#5{%
983 \styleoflineF%
984 \legend[#1]{#2}{#3}{#4}{#5}}%
985 \def\legendG{\@ifnextchar[\@legendG{\@legendG[]}}%
986 \def\@legendG[#1]#2#3#4#5{%
987 \styleoflineG%
988 \legend[#1]{#2}{#3}{#4}{#5}}%
989 % \end{macrocode}
990 % \end{macro}
991 %
992 % \begin{macro}{\legend[ABCDEFG]f}
993 % An automatic legend mode, where the position is automatically
994 % calculated for each one in consecutive order
995 % \begin{macrocode}
996 \def\legendAf{\@ifnextchar[\@legendAf{\@legendAf[]}}%
997 \def\@legendAf[#1]#2{%
998 \legendA[#1]{\posx}{\l}{\s}{\posy}{#2}%
999 \FPadd\posy\posy{-\dif}}%
1000 \def\legendBf{\@ifnextchar[\@legendBf{\@legendBf[]}}%
1001 \def\@legendBf[#1]#2{%
1002 \legendB[#1]{\posx}{\l}{\s}{\posy}{#2}%
1003 \FPadd\posy\posy{-\dif}}%
1004 \def\legendCf{\@ifnextchar[\@legendCf{\@legendCf[]}}%
1005 \def\@legendCf[#1]#2{%
1006 \legendC[#1]{\posx}{\l}{\s}{\posy}{#2}%
1007 \FPadd\posy\posy{-\dif}}%
1008 \def\legendDf{\@ifnextchar[\@legendDf{\@legendDf[]}}%
1009 \def\@legendDf[#1]#2{%
1010 \legendD[#1]{\posx}{\l}{\s}{\posy}{#2}%
1011 \FPadd\posy\posy{-\dif}}%
1012 \def\legendEf{\@ifnextchar[\@legendEf{\@legendEf[]}}%
1013 \def\@legendEf[#1]#2{%
1014 \legendE[#1]{\posx}{\l}{\s}{\posy}{#2}%
1015 \FPadd\posy\posy{-\dif}}%
1016 \def\legendFf{\@ifnextchar[\@legendFf{\@legendFf[]}}%
1017 \def\@legendFf[#1]#2{%
1018 \legendF[#1]{\posx}{\l}{\s}{\posy}{#2}%
1019 \FPadd\posy\posy{-\dif}}%
1020 \def\legendGf{\@ifnextchar[\@legendGf{\@legendGf[]}}%
1021 \def\@legendGf[#1]#2{%
1022 \legendG[#1]{\posx}{\l}{\s}{\posy}{#2}%
1023 \FPadd\posy\posy{-\dif}}%
1024 % \end{macrocode}
1025 % \end{macro}
1026 %
1027 % \begin{macro}{\legendText}
1028 % A legend without a line: to include some text in the legend box
1029 % \begin{macrocode}
1030 \def\legendText{\@ifnextchar[\@legendText{\@legendText[]}}%
1031 \def\@legendText[#1]#2{%
1032 \rput(\posx,\posy){%
1033 \makebox[0 cm][l]{%
1034 \hspace{-0.1cm}{\footnotesize #2}}}%
1035 \FPadd\posy\posy{-\dif}}%
1036 % \end{macrocode}
1037 % \end{macro}
1038 %
1039 % Keys to be used in the legend environment:
1040 % \begin{macrocode}
1041 \define@key[psset]{whiteBG}{fillcolorWhiteBG}{\def\fillcolorWhiteBG{#1}}%
1042 \define@key[psset]{whiteBG}{fillstyleWhiteBG}{\def\fillstyleWhiteBG{#1}}%
1043 \define@key[psset]{whiteBG}{framearcWhiteBG}{\def\framearcWhiteBG{#1}}%
1044 \define@key[psset]{whiteBG}{linewidthWhiteBG}{\def\linewidthWhiteBG{#1}}%
1045 \define@key[psset]{whiteBG}{linestyleWhiteBG}{\def\linestyleWhiteBG{#1}}%
1046 \define@key[psset]{whiteBG}{linecolorWhiteBG}{\def\linecolorWhiteBG{#1}}%
1047 \pst@addfams{whiteBG}%
1048 % \end{macrocode}
1049 % Default values for the above keys:
1050 % \begin{macrocode}
1051 \psset{fillcolorWhiteBG=white, fillstyleWhiteBG=solid,
1052 framearcWhiteBG=0.3, linewidthWhiteBG=0.01,
1053 linestyleWhiteBG=solid, linecolorWhiteBG=black}%
1054 % \end{macrocode}
1055 %
1056 % \begin{macro}{\whiteBG}
1057 % Create the box of the legend in the given position
1058 % \begin{macrocode}
1059 \def\whiteBG{\@ifnextchar[\@whiteBG{\@whiteBG[]}}%
1060 \def\@whiteBG[#1]#2#3#4#5{%
1061 \psframe[framearc=\framearcWhiteBG, fillcolor=\fillcolorWhiteBG,%
1062 fillstyle=\fillstyleWhiteBG, linewidth=\linewidthWhiteBG cm,%
1063 linestyle=\linestyleWhiteBG, linecolor=\linecolorWhiteBG, #1]%
1064 (#2,#3)(#4,#5)}%
1065 % \end{macrocode}
1066 % \end{macro}
1067 %
1068 % Keys to control the line length and separation with the text
1069 % in the legend:
1070 % \begin{macrocode}
1071 \define@key[psset]{legendXY}{legendSep}{\def\sepYlegendXY{#1}} %
1072 \define@key[psset]{legendXY}{lineLength}{\def\llegendXY{#1}} %
1073 \define@key[psset]{legendXY}{lineTextSep}{\def\slegendXY{#1}} %
1074 \define@key[psset]{legendXY}{borderlineSep}{\FPmul\sepTxlegendXY{#1}{2}} %
1075 \pst@addfams{legendXY}%
1076 % \end{macrocode}
1077 %
1078 % Default values:
1079 % \begin{macrocode}
1080 \psset{legendSep=4, lineLength=5, lineTextSep=1, borderlineSep=1}%
1081 % \end{macrocode}
1082 %
1083 % \begin{macro}{\legendXY}
1084 % Plot a legend box and calculate the parameters of the legend
1085 % in the position given in round brackets, for |#4| different legends
1086 % and with a width of |#5|.
1087 % \begin{macrocode}
1088 \def\legendXY{\@ifnextchar[\@legendXY{\@legendXY[]}}%
1089 \def\@legendXY[#1](#2,#3)#4#5{%
1090 \psset{#1}%
1091 \def\sepY{\sepYlegendXY}%
1092 \def\l{\llegendXY}%
1093 \def\s{\slegendXY}%
1094 \def\sepTx{\sepTxlegendXY}%
1095 \def\xaXY{#2}%
1096 \def\yzXY{#3}%
1097 \FPdiv\sep\sepY{8}%
1098 \FPdiv\sepYy\sepY{1.33} %
1099 \FPdiv\x\sep\unitX% To separate \sep mm the legend from the axe
1100 \FPdiv\y\sep\unitY% To separate \sep mm the legend from the axe
1101 \FPadd\leftX\xaXY{\x}%
1102 \FPadd\highY\yzXY{-\y}%
1103 \FPdiv\w{#4}\unitX%
1104 \FPadd\rightX\leftX{\w}%
1105 \FPdiv\sepTx\sepTx\unitX%
1106 \FPadd\posx\leftX\sepTx%
1107 \FPdiv\sepTy\sepYy\unitY%
1108 \FPadd\posy\highY{-\sepTy}%
1109 \FPdiv\dif{\sepY}\unitY% Separation of the legends
1110 \FPadd\n{#5}{-1}%
1111 \FPmul\lowY\dif\n%
1112 \FPadd\lowY\lowY\sepTy%
1113 \FPadd\lowY\posy{-\lowY}%
1114 \whiteBG[#1]{\leftX}{\lowY}{\rightX}{\highY}}%
1115 % \end{macrocode}
1116 % \end{macro}
1117 %
1118 % \begin{macro}{\legend[UL,UR,DL,DR]}
1119 % Put the legend box in the positions upper-left, upper-right,
1120 % down-left and down-right. The input parameters are the optional keys,
1121 % the number of legends and the width.
1122 % \begin{macrocode}
1123 \def\legendUL{\@ifnextchar[\@legendUL{\@legendUL[]}}%
1124 \def\@legendUL[#1]#2#3{%
1125 \FPmul\xUL\MP@xa{1}%
1126 \FPmul\yUL\MP@yz{1}%
1127 \legendXY[#1](\xUL,\yUL){#2}{#3}}%
1128 %
1129 \def\legendUR{\@ifnextchar[\@legendUR{\@legendUR[]}}%
1130 \def\@legendUR[#1]#2#3{%
1131 \FPmul\xUR\MP@xz{1}%
1132 \FPmul\yUR\MP@yz{1}%
1133 \def\sep{0.5}%
1134 \FPdiv\xp\sep\unitX% To separate \sep mm the legend from the axe
1135 \FPmul\xp\xp{2}%
1136 \FPadd\xp\xUR{-\xp}%
1137 \FPdiv\xx{#2}\unitX%
1138 \FPadd\xp\xp{-\xx}%
1139 \legendXY[#1](\xp,\yUR){#2}{#3}}%
1140 %
1141 \def\legendDL{\@ifnextchar[\@legendDL{\@legendDL[]}}%
1142 \def\@legendDL[#1]#2#3{%
1143 \psset{#1}%
1144 \def\sepY{\sepYlegendXY}%
1145 \def\sepTx{\sepTxlegendXY}%
1146 \FPmul\xzDL\MP@xz{1}%
1147 \FPmul\xaDL\MP@xa{1}%
1148 \FPmul\yzDL\MP@yz{1}%
1149 \FPmul\yaDL\MP@ya{1}%
1150 \FPdiv\sep\sepY{8}%
1151 \FPdiv\sep\sepY{8}%
1152 \FPdiv\sepYy\sepY{1.33} %
1153 \FPdiv\x\sep\unitX% To separate \sep mm the legend from the axe
1154 \FPdiv\y\sep\unitY% To separate \sep mm the legend from the axe
1155 \FPadd\leftX\xaDL{0}%
1156 \FPdiv\w{#2}\unitX%
1157 \FPadd\rightX\leftX{\w}%
1158 \FPdiv\sepTx\sepTx\unitX%
1159 \FPadd\posx\leftX\sepTx%
1160 \FPadd\lowY\yaDL{\y}%
1161 \FPadd\lowY\lowY{\y}%
1162 \FPdiv\sepTy\sepYy\unitY%
1163 \FPadd\posy\lowY{\sepTy}%
1164 \FPdiv\dif\sepY\unitY% Separation of the legends
1165 \FPadd\n{#3}{-1}%
1166 \FPmul\highY\dif\n%
1167 \FPadd\highY\highY\sepTy%
1168 \FPadd\highY\posy{\highY}%
1169 \FPadd\posy\highY{-\sepTy}%
1170 \legendXY[#1](\leftX,\highY){#2}{#3}}%
1171 %
1172 \def\legendDR{\@ifnextchar[\@legendDR{\@legendDR[]}}%
1173 \def\@legendDR[#1]#2#3{%
1174 \psset{#1}%
1175 \def\sepY{\sepYlegendXY}%
1176 \def\sepTx{\sepTxlegendXY}%
1177 \FPmul\xzDR\MP@xz{1}%
1178 \FPmul\xaDR\MP@xa{1}%
1179 \FPmul\yzDR\MP@yz{1}%
1180 \FPmul\yaDR\MP@ya{1}%
1181 \FPdiv\sep\sepY{8}%
1182 \FPdiv\sepYy\sepY{1.33} %
1183 \FPdiv\x\sep\unitX% To separate \sep mm the legend from the axe
1184 \FPdiv\y\sep\unitY% To separate \sep mm the legend from the axe
1185 \FPadd\rightX\xzDR{-\x}%
1186 \FPdiv\w{#2}\unitX%
1187 \FPadd\leftX\rightX{-\w}%
1188 \FPadd\leftX\leftX{-\x}%
1189 \FPdiv\sepTx\sepTx\unitX%
1190 \FPadd\posx\leftX\sepTx%
1191 \FPadd\lowY\yaDR{\y}%
1192 \FPadd\lowY\lowY{\y}%
1193 \FPdiv\sepTy\sepYy\unitY%
1194 \FPadd\posy\lowY{\sepTy}%
1195 \FPdiv\dif{\sepY}\unitY% Separation of the legends
1196 \FPadd\n{#3}{-1}%
1197 \FPmul\highY\dif\n%
1198 \FPadd\highY\highY\sepTy%
1199 \FPadd\highY\posy{\highY}%
1200 \FPadd\posy\highY{-\sepTy}%
1201 \legendXY[#1](\leftX,\highY){#2}{#3}}%
1202 % \end{macrocode}
1203 % \end{macro}
1204 %
1205 % This is the end
1206 % \begin{macrocode}
1207 \makeatother%
1208 %</makeplot>
1209 % \end{macrocode}
1210 % \clearpage
1211 % \PrintIndex
1212 % \Finale
1213 \endinput