summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/numericplots/BasicFunctionality.tex
blob: b738a0e4789effe4913d87ea34dfc154fc5ed8c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
% Copyright 2010 Thomas König, Alexander Michel
%
% This file is part of NumericPlots.
%
% NumericPlots is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% any later version.
%
% NumericPlots is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with NumericPlots.  If not, see <http://www.gnu.org/licenses/>.

\part{Using the package}

\section{Basic Functionality}

The package NumericPlots\\
\verb+\usepackage{NumericPlots}+
\\
is intended to be used to plot numeric data which
may, e.g., be exported from Matlab by export2latex.m. The data must be defined
in the form
\begin{verbatim}
	\def\IdentI{
	1.0 1.0e2
	1.1 11e1
	1.2 1.25e2
	1.3 110
	1.4 100
	1.5 90
	1.6 80
	}
\end{verbatim}
\def\IdentI{
	1.0 1.0e2
	1.1 11e1
	1.2 1.25e2
	1.3 110
	1.4 100
	1.5 90
	1.6 80
	}
\def\IdentII{
	1.0 125
	1.05 100
	1.1 75
	1.15 85
	1.2 90
	1.3 115
	1.4 130
	1.5 125
	1.6 120
	}
\def\LogData{
	6 6
	10 10
	20 20
	30 30
	40 40
	50 50
	60 60
	70 70
	80 80
	90 90
	100 100
	200 200
	300 300
	400 400
	500 500
	600 600
	700 700
	800 800
	900 900
	1000 1000
	1100 1100
	1200 1200
	1300 1300
	1400 1400
	1500 1500
}
where the first column contains the x, the second column the y-data.

\subsection{plots}

% \begin{LTXExample}
% \begin{NumericDataPlot}{\textwidth}{5cm}
% 	\setxAxis{xMin=1, xMax=2, Dx=0.1}
% 	\setyAxis{yMin=50, yMax=150, Dy=25}
% 	
% 	\plotxAxis{x-axis label}
% 	\plotyAxis{y-axis label}
% 	
% 	\listplot[style=StdLineStyA]{\IdentI}
% \end{NumericDataPlot}
% \end{LTXExample}

The easiest plot may be done by
\begin{verbatim}
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=-1, xMax=2, Dx=0.5}
		\setyAxis{yMin=-50, yMax=150, Dy=25}
		
		\plotxAxis{x-axis label}
		\plotyAxis{y-axis label}
		
		\listplot[style=StdLineStyA]{\IdentI}
	\end{NumericDataPlot}
\end{verbatim}
\begin{NumericDataPlot}{\textwidth}{5cm}
	\setxAxis{xMin=-1, xMax=2, Dx=0.5, xO=0}
	\setyAxis{yMin=-50, yMax=150, Dy=25, yO=0}
	
	\plotxAxis{x-axis label}
	\plotyAxis{y-axis label}
	
	\listplot[style=StdLineStyA]{\IdentI}
\end{NumericDataPlot}

if you want to add a legend, you simply call

\begin{minipage}{0.5\linewidth}
\begin{verbatim}
\LegendDefinition{
	\LegLine{style=StdLineStyA} & IdentI
}
\end{verbatim}
\end{minipage}\begin{minipage}{0.5\linewidth}
\centering
\LegendDefinition{
	\LegLine{style=StdLineStyA} & IdentI
}
\end{minipage}

To plot multiple data in one plot call \newline
\begin{minipage}[T]{0.5\linewidth}
	\begin{verbatim}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=2, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxAxis{x-axis label}
		\plotyAxis{y-axis label}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		\listplot[style=StdLineStyB]
		   {\IdentII}
		   
		\putSE{\LegendDefinition{
			\LegLine{style=StdLineStyA} & IdentI \\
			\LegLine{style=StdLineStyB} & IdentII
		}}
	\end{NumericDataPlot}
	\end{verbatim}
\end{minipage}
\begin{minipage}[T]{0.5\linewidth}
	\vspace{10pt}
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=1, xMax=2, Dx=0.2}
		\setyAxis{yMin=50, yMax=150, Dy=25}
		
		\plotxAxis{x-axis label}
		\plotyAxis{y-axis label}
		
		\listplot[style=StdLineStyA]{\IdentI}
		\listplot[style=StdLineStyB]{\IdentII}
		
		\putSE{\LegendDefinition{
			\LegLine{style=StdLineStyA} & IdentI \\
			\LegLine{style=StdLineStyB} & IdentII
		}}
	\end{NumericDataPlot}
\end{minipage}


\subsection{Label and TickLabels}

The commands \texttt{plotxAxis} and \texttt{plotyAxis} take the options
\texttt{NoLabel}, \texttt{NoTicks}, \texttt{NoTickLabel} as well as
\texttt{LabelOption} and \texttt{TickLabelOption} which may be used to eliminate
or change the look of the labels.

Standard values for \texttt{LabelOption} and \texttt{TickLabelOption} may be set
by \verb|\newcommand{\StdLabelOption}{\color{blue}| and
\verb|\newcommand{\StdTickLabelOption}{\small}|.

The option \texttt{xLabelSep} for \verb|\plotxAxis| (and \texttt{yLabelSep} for
\verb|\plotyAxis|) may be used to set the seperation between the axis and the label. Standard value
is 10pt for the x-label and 20pt for the y-label.

\begin{minipage}[T]{0.5\linewidth}
	\begin{verbatim}
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=1, xMax=1.6, Dx=0.2}
		\setyAxis{yMin=75, yMax=130, Dy=25}
		
		\plotxAxis
		[LabelOption=\LARGE,%
		TickLabelOption=\color{red},%
		xLabelSep=40pt]
		{x-axis label}
		\plotyAxis
		[NoLabel, NoTicks, NoTickLabel]
		{y-axis label}
		
		\listplot[style=StdLineStyA]{\IdentI}
		\listplot[style=StdLineStyB]{\IdentII}
		
	\end{NumericDataPlot}
	\end{verbatim}
\end{minipage}
\begin{minipage}[T]{0.5\linewidth}
	\vspace{10pt}
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=1, xMax=1.6, Dx=0.2}
		\setyAxis{yMin=75, yMax=130, Dy=25}
		
		\plotxAxis[LabelOption=\LARGE, TickLabelOption=\color{red},
		xLabelSep=40pt]{x-axis label}
		\plotyAxis[NoLabel, NoTicks, NoTickLabel]{y-axis label}
		
		\listplot[style=StdLineStyA]{\IdentI}
		\listplot[style=StdLineStyB]{\IdentII}
		
	\end{NumericDataPlot}
\end{minipage}


\subsection{Place ``Objects'' in the plot.}

There are basically two different options to place objects in the plot. To
understand the difference one has to keep in mind that the axis have two
different coordinate systems. One is the system defined by xMin, xMax, yMin and
yMax (refered to as ``DataCoordinateSystem''), the other ist the system defined
by xCoordMin, xCoordMax, yCoordMin and yCoordMax (refered to as
``PictureCoordinateSystem''), see section \ref{sec:MultiplePlots}.

It is now possible to place stuff in the graph with the DataCoordinates with the
command NDPput, see the following example.

\begin{minipage}[T]{0.5\linewidth}
	\begin{verbatim}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=2, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxAxis{x-axis label}
		\plotyAxis[NoLabel]{}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		   
		% put some stuff somewhere
		\NDPput[x=1.2, y=75, RefPoint=br]{text}
		\NDPput[x=1.2, y=100]{$a^2$}
		
		% or put nodes...
		\NDPput[x=1.6, y=100]{\pnode{A}}
		\NDPput[x=1.8, y=150]{\pnode{B}}
		% ...and draw a line between them
		\ncline{A}{B}  
		 
		% or put the legend at a specific position
		\NDPput[x=1.8, y=75]{\LegendDefinition{
			\LegLine{style=StdLineStyA} & IdentI
		}}
	\end{NumericDataPlot}
	\end{verbatim}
\end{minipage}
\begin{minipage}[T]{0.5\linewidth}
	\vspace{10pt}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=2, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxAxis{x-axis label}
		\plotyAxis[NoLabel]{}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		   
		% put some stuff somewhere
		\NDPput[x=1.2, y=75, RefPoint=br]{text}
		\NDPput[x=1.2, y=100]{$a^2$}
		
		% or put nodes...
		\NDPput[x=1.6, y=100]{\pnode{A}}
		\NDPput[x=1.8, y=150]{\pnode{B}}
		% ...and draw a line between them
		\ncline{A}{B}  
		 
		% or put the legend at a specific position
		\NDPput[x=1.8, y=75]{\LegendDefinition{
			\LegLine{style=StdLineStyA} & IdentI
		}}
	\end{NumericDataPlot}
\end{minipage}

Alternatively, stuff can be placed within the plot with \verb|\rput|.

\begin{minipage}[T]{0.5\linewidth}
	\begin{verbatim}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=1.6, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxAxis{x-axis label}
		\plotyAxis[NoLabel]{}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		   
		% put text in the middle of the plot
		\rput{45}(500,500){text}
		% put a formula in the lower left corner
		\rput[bl](0,0){$a^2+b^2=c^2$}
		
		% or put nodes...
		\NDPput[x=1.2, y=125]{\pnode{A}}
		\rput(750,900){\Rnode{B}{peak}}
		% ...and draw a line between them
		\ncline{<-}{A}{B}  
		 
		% or put the legend at a specific position
		\rput{-45}(750,250){\LegendDefinition{
			\LegLine{style=StdLineStyA} & IdentI
		}}
	\end{NumericDataPlot}
	\end{verbatim}
\end{minipage}
\begin{minipage}[T]{0.5\linewidth}
	\vspace{10pt}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=1.6, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxAxis{x-axis label}
		\plotyAxis[NoLabel]{}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		   
		% put text in the middle of the plot
		\rput{45}(500,500){text}
		% put a formula in the lower left corner
		\rput[bl](0,0){$a^2+b^2=c^2$}
		
		% or put nodes...
		\NDPput[x=1.2, y=125]{\pnode{A}}
		\rput(750,900){\Rnode{B}{peak}}
		% ...and draw a line between them
		\ncline{<-}{A}{B}  
		 
		% or put the legend at a specific position
		\rput{-45}(750,250){\LegendDefinition{
			\LegLine{style=StdLineStyA} & IdentI
		}}
	\end{NumericDataPlot}
\end{minipage}



\subsection{Line Styles}

\subsection{Legend}

The legend may be created with \verb|\LegendDefinition|. The command takes the
two optional arguments \texttt{nrCols} and \texttt{LabelOrientation=[l|c|r]}.
The mandatory argument is the definition of a table as demonstrated in the
follwing examples.

	\begin{verbatim}
	\LegendDefinition{
		\LegLine{style=StdLineStyA} & IdentI\\
		\LegLine{style=StdLineStyB, linewidth=3pt} & second legend
	}
	\end{verbatim}
	\LegendDefinition{
		\LegLine{style=StdLineStyA} & IdentI\\
		\LegLine{style=StdLineStyB, linewidth=3pt} & second legend
	}
	\begin{verbatim}
	\LegendDefinition[nrCols=2]{
		\LegLine{style=StdLineStyA} & IdentI &
		\LegLine{style=StdLineStyB, linewidth=3pt} & legend 2
	}
	\end{verbatim}
	\LegendDefinition[nrCols=2]{
		\LegLine{style=StdLineStyA} & IdentI &
		\LegLine{style=StdLineStyB, linewidth=3pt} & legend 2
	}
	\begin{verbatim}
	\LegendDefinition[LabelOrientation=c]{
		\LegLine{style=StdLineStyA} & IdentI\\
		\LegLine{style=StdLineStyB, linewidth=3pt} & legend 2 \\
		\LegLine{style=StdLineStyC} & whatever this data is\ldots\\
		\LegLine{style=StdLineStyD} & and more data
	}
	\end{verbatim}
	\LegendDefinition[LabelOrientation=c]{
		\LegLine{style=StdLineStyA} & IdentI\\
		\LegLine{style=StdLineStyB, linewidth=3pt} & second legend\\
		\LegLine{style=StdLineStyC} & whatever this data is\ldots\\
		\LegLine{style=StdLineStyD} & and more data
	}

\subsection{Add Lines to the Plot}

Horizontal and vertical lines may be added to the plot with the commands
\verb|\NDPhline{coord}| and \verb|\NDPvline{coord}|. It is also possible to put
nodes and draw lines between them, see placing stuff\ldots

\begin{minipage}[T]{0.5\linewidth}
	\begin{verbatim}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=1.6, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxAxis[NoLabel]{}
		\plotyAxis[NoLabel]{}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		   
		\NDPhline[linecolor=LineColorD]{73}
		\NDPvline[linecolor=LineColorE, linestyle=dashed]{1.5}
		\NDPline[linecolor=red]{1.1}{75}{1.3}{125}
	\end{NumericDataPlot}
	\end{verbatim}
\end{minipage}
\begin{minipage}[T]{0.5\linewidth}
	\vspace{10pt}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=1.6, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxAxis[NoLabel]{}
		\plotyAxis[NoLabel]{}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		   
		\NDPhline[linecolor=LineColorD]{73}
		\NDPvline[linecolor=LineColorE, linestyle=dashed]{1.5}
		\NDPline[linecolor=red]{1.1}{75}{1.3}{125}
	\end{NumericDataPlot}
\end{minipage}




\subsection{Grid}

One may choose not to plot the grid with the option \texttt{NoGrid} for the
commands \verb|\plotxAxis| and \verb|\plotyAxis|.

If the grid is plottet with the axis it may happen that the grid is plottet over
the axis. To avoid this, plot the grid first and then plot the axis as shown.

\begin{minipage}[T]{0.5\linewidth}
	\begin{verbatim}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=1.6, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxGrid
		\plotyGrid
		\plotxAxis
		[NoLabel, NoGrid, AxisStyle=Boxed]{}
		\plotyAxis
		[NoLabel, NoGrid, AxisStyle=Boxed]{}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		
	\end{NumericDataPlot}
	\end{verbatim}
\end{minipage}
\begin{minipage}[T]{0.5\linewidth}
	\vspace{10pt}
	\begin{NumericDataPlot}
	   {\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=1.6, Dx=0.2}
		\setyAxis
		   {yMin=50, yMax=150, Dy=25}
		
		\plotxGrid
		\plotyGrid
		\plotxAxis[NoLabel, NoGrid, AxisStyle=Boxed]{}
		\plotyAxis[NoLabel, NoGrid, AxisStyle=Boxed]{}
		
		\listplot[style=StdLineStyA]
		   {\IdentI}
		
	\end{NumericDataPlot}
\end{minipage}


\subsection{Logarithmic axes}


\begin{minipage}[T]{0.5\linewidth}
	\begin{verbatim}
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis
		   {xMin=6, xMax=2500, Dx=10, xLog}
		\setyAxis
		   {yMin=0, yMax=2500, Dy=500}
		\plotxAxis{}
		\plotyAxis{}
		
		\listplot{\LogData}
	\end{NumericDataPlot}
	\end{verbatim}
\end{minipage}
\begin{minipage}[T]{0.5\linewidth}
	\vspace{10pt}
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=6, xMax=2500, Dx=10, xLog}
		\setyAxis{yMin=0, yMax=2500, Dy=500}
		\plotxAxis{}
		\plotyAxis{}
		
		\listplot{\LogData}
	\end{NumericDataPlot}
\end{minipage}


\begin{minipage}[T]{0.5\linewidth}
	\begin{verbatim}
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis
		   {xMin=1, xMax=1500, Dx=10, xLog}
		\setyAxis
		   {yMin=1, yMax=1500, Dy=10, yLog}
		\plotxAxis{}
		\plotyAxis{}
		
		\listplot{\LogData}
	\end{NumericDataPlot}
	\end{verbatim}
\end{minipage}
\begin{minipage}[T]{0.5\linewidth}
	\vspace{10pt}
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=1, xMax=1500, Dx=10, xLog}
		\setyAxis{yMin=1, yMax=1500, Dy=10, yLog}
		\plotxAxis{}
		\plotyAxis{}
		
		\listplot{\LogData}
	\end{NumericDataPlot}
\end{minipage}





\subsection{export2latex.m}

The function \texttt{export2latex(data, filename, [options])} may be used to
export data from Matlab to be used with NumericPlots.sty. The function takes the two parameters
data and filename, where filename is the name of the file where the data should
be stored with full path but without extension. Data is a structure with the
three entries x, y, and ident, where x are the x-data, y the y-data and ident is
an identifier to have access to the data in Latex. To access the data in Latex
the command \verb+\Data<ident>+ is used.

The parameter data may be provided as an 1xK array if each entry of the array is
a structure with the entries x, y and ident. There may be an additional entry
descr.
\begin{itemize}
  \item data(1,i).x = $X_i$
  \item data(1,i).y = $Y_i$
  \item data(1,i).ident = Identifier
  \item (data(1,i).descr = Description)
\end{itemize}
Identifier must be a valid Latex command name, which basically means it must be
a string without numbers.

For every entry of data, $X$ and $Y$ must be arrays of the same size
$M\text{x}N$. If $M>1$, each column of the array is exported to the file and the
identifier is expanded by the roman representation of the column number.

It might be useful to do a \texttt{interp1} before exporting the data to get
smaller files and to use less of \TeX's memory. ($\rightarrow$ script
Patrick?!?)

The optional parameter \texttt{options} might be used to control which
additional information is provided in the output file.
\begin{itemize}
  \item \texttt{options.DataBoundaries} [true] If set to true, the output file
  contains the commands \verb+\DataXmin+, \verb+\DataXmax+, \verb+\DataYmin+ and
  \verb+\DataYmax+ which may be used to define the axis.
  \item \texttt{options.AxisBoundaries} [false] If set to true, the output file
  contains the commands \verb+\DataXminAxis+, \verb+\DataXmaxAxis+,
  \verb+\DataYminAxis+ and \verb+\DataYmaxAxis+ which may be used to define the
  axis. In contrary to the DataBoundaries the AxisBoundaries add an additional
  gap of \texttt{options.AxisBoundariesGap} [10] percent of the full scale to
  the data boundaries such that the plot doesn't touch the axis.
\end{itemize}