summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/numericplots/src/FurtherExamples.tex
blob: 1ef2e94ab2c389c62eaf0262b43657923aa93093 (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
\section{Further Examples}

\def\MoreData{
0 5
1 7
2 10
3 11
4 11.5
5 10
6 5
7 4
8 9
9 12
10 11
11 5
}

\def\MoreDataI{
0 -5
1 -7
2 -10
3 -11
4 -11.5
5 -10
6 10
7 15
8 10
9 -12
10 -11
11 -5
}

\def\NoiseData{
0 5
0.1 5.4
0.2 4.6
0.3 5.3
0.4 4.9
0.5 4.6
}
Here, some features of the pst-plot command \verb|listplot| are illustrated. With xStart, xEnd (yStart, yEnd), the data can be truncated. Note that all visible data points are connected by a straight line which may render a misleading plot, cf. the blue and green line in the next plot below.

\begin{minipage}{0.5\linewidth}
\begin{verbatim}
	\listplot
	[style=StdLineStyA]
	{\MoreData}
	\listplot
	[style=StdLineStyB, yEnd=10]
	{\MoreData}
	\listplot
	[style=StdLineStyC, xStart=5, xEnd=9]
	{\MoreData}
	\listplot
	[style=StdLineStyD, showpoints=true, nStep=2]
	{\MoreData}
\end{verbatim}
\end{minipage}
\begin{minipage}{0.45\linewidth}
\centering
\begin{NumericDataPlot}{\textwidth}{5cm}
	\setxAxis{xMin=0, xMax=15, Dx=5, xO=0}
	\setyAxis{yMin=0, yMax=15, Dy=5, yO=0}
	
	\plotxAxis[NoLabel]{x-axis label}
	\plotyAxis[NoLabel]{y-axis label}
	
	\listplot[style=StdLineStyA]{\MoreData}
	\listplot[style=StdLineStyB, yEnd=10]{\MoreData}
	\listplot[style=StdLineStyC, xStart=5, xEnd=9]{\MoreData}
	\listplot[style=StdLineStyD, showpoints=true, nStep=2]{\MoreData}
\end{NumericDataPlot}
\end{minipage}



\subsection{Fill area between plots}
\label{sec:FillArea}

\begin{minipage}{0.5\linewidth}
\begin{verbatim}
	\begin{NumericDataPlot}%
		{\textwidth}{5cm}
		\setxAxis
		{xMin=0, xMax=15, Dx=5, xO=0}
		\setyAxis
		{yMin=-15, yMax=15, Dy=5, yO=10}
		
		\plotxAxis{x-axis label}
		\plotyAxis[NoLabel]{}
		
		\pscustom%
		[style=StdLineStyA, fillstyle=solid, %
		fillcolor=blue!40]{%
			\listplot{\MoreData}%
			\listplot[ChangeOrder]{\MoreDataI}%
		}
	\end{NumericDataPlot}
\end{verbatim}
\end{minipage}
\begin{minipage}{0.45\linewidth}
\centering
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=0, xMax=15, Dx=5, xO=0}
		\setyAxis{yMin=-15, yMax=15, Dy=5, yO=10}
		
		\plotxAxis{x-axis label}
		\plotyAxis[NoLabel]{}
		
		\pscustom[style=StdLineStyA, fillstyle=solid, fillcolor=blue!40]{%
			\listplot{\MoreData}%
			\listplot[ChangeOrder]{\MoreDataI}%
		}
	\end{NumericDataPlot}
\end{minipage}






\begin{minipage}{0.5\linewidth}
\begin{verbatim}
	...
	\pscustom%
	[style=StdLineStyA, fillstyle=solid, %
	fillcolor=green!40]{%
			\NDPhline{0}
			\listplot[ChangeOrder]{\MoreDataI}%
		}
	...
\end{verbatim}
\end{minipage}\begin{minipage}{0.45\linewidth}
\centering
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=0, xMax=15, Dx=5, xO=0}
		\setyAxis{yMin=-15, yMax=15, Dy=5, yO=10}
		
		\plotxAxis{x-axis label}
		\plotyAxis[NoLabel]{}
		
		\pscustom%
		[style=StdLineStyA, fillstyle=solid, %
		fillcolor=green!40]{%
			\NDPhline{0}
			\listplot[ChangeOrder]{\MoreDataI}%
		}
	\end{NumericDataPlot}
\end{minipage}


\begin{minipage}{0.5\linewidth}
\begin{verbatim}
	...
	\pscustom%
	[style=StdLineStyA, fillstyle=solid, %
	fillcolor=red!40]{%
			\NDPline{0}{5}{11}{10}
			\listplot[ChangeOrder]{\MoreDataI}%
		}
	...
\end{verbatim}
\end{minipage}
\begin{minipage}{0.45\linewidth}
\centering
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=0, xMax=15, Dx=5, xO=0}
		\setyAxis{yMin=-15, yMax=15, Dy=5, yO=10}
		
		\plotxAxis{x-axis label}
		\plotyAxis[NoLabel]{}
		
		\pscustom%
		[fillstyle=solid, linestyle=none,%
		fillcolor=red!40]{%
			\NDPline{0}{5}{11}{10}
			\listplot[ChangeOrder]{\MoreDataI}%
		}
		\listplot[style=StdLineStyB]{\MoreDataI}
	\end{NumericDataPlot}
\end{minipage}


\subsection{Custom Grid}

To plot a custom grid (grid-lines are not äquidistant) the following procedure
may be used if working with Matlab:

Add the following code after export2latex (XTick is a vector containing the
positions of the desired x-gridlines):
\begin{verbatim}
    % export positions of the x-Tick-Marks
    fid = fopen(TargetTexFile, 'at');
    fprintf(fid, '\n\\def\\CustomXGrid{\n');
    for i=1:length(XTick)
        fprintf(fid, ...
        	'\\NDPvline[style=CustomXGridStyle]{%f}\n', adj.XTick(i));
    end
    fprintf(fid, '}\n');
    fclose(fid);
\end{verbatim}

In Latex just define the style ``CustomXGridStyle'' and use the command
\verb+\CustomXGrid+ after defining the axis.


\subsection{Plotting noisy data}
\label{sec:FurtherExamples:NoisyData}

Plotting measurement data with a lot of noise may be a little tricky. First, you
often have a lot of data to plot which may lead to memory problems in \TeX.
When filtering the data, the appearance of the noise may change which is not
what you intend to do. To solve this problem, the two Matlab-functions
``LatexFilterMinMax'' and ``LatexFilterHull'' are provided. Both take x- and
y-data and divide it in NrOfPoints equally intervals. The filter returns the
maximum and the minimum value of each interval.

The filter ``LatexFilterHull'' returns a vector which contains the minima first
and then the maxima. This data may be plotted with ``fillstyle=solid'' as in
section~\ref{sec:FillArea}.

The filter ``LatexFilterMinMax'' returns maximum and minimum value of each
interval (with corresponding x-data). This data may be plotted as a ``normal
line''. As pstricks-lines are normally closed lines, this may lead to a plot
where the noise seems exagerated. You may therefore use the option linejoin as
demonstrated in the following examples. The red dots mark the actual data.
Notice that the measurement data seems noisier than it is if it is plotted with
linejoin=0. Plotting with linejoin=2 represents the data much better. The
standard for linejoin is 0. The StdLineStyXX defined in this package are defined
with linejoin=1.

\begin{minipage}{0.4\linewidth}
\begin{verbatim}
	...
	% linejoin=0:
	\listplot[linewidth=5pt]%
	{\NoiseData}%
	...
	% linejoin=1:
	\listplot[linejoin=1, %
	linewidth=5pt]{\NoiseData}%
	...
	% linejoin=2:
	\listplot[linejoin=1, %
	linewidth=5pt]{\NoiseData}%
	...
\end{verbatim}
\end{minipage}
\begin{minipage}{0.55\linewidth}
\centering
	\begin{NumericDataPlot}{\textwidth}{5cm}
		\setxAxis{xMin=0.00, xMax=0.5, Dx=0.25, xO=0.00,
			xCoordMin=0, xCoordMax=300}
		\setyAxis{yMin=4.5, yMax=5.5, Dy=0.5}
		
		\plotxAxis{linejoin=0}
		\plotyAxis[NoLabel]{}
		
		\listplot[linewidth=5pt]{\NoiseData}%
		\listplot[plotstyle=dots, linecolor=red, dotsize=2pt]{\NoiseData}
		
		\setxAxis{xMin=0.00, xMax=0.5, Dx=0.25, xO=0.00,
			xCoordMin=330, xCoordMax=630}
		\setyAxis{yMin=4.5, yMax=5.5, Dy=0.5}
		
		\plotxAxis{linejoin=1}
		\plotyAxis[NoTickLabel,NoLabel]{}
		
		\listplot[linejoin=1, linewidth=5pt]{\NoiseData}%
		\listplot[plotstyle=dots, linecolor=red, dotsize=2pt]{\NoiseData}
		
		\setxAxis{xMin=0.00, xMax=0.5, Dx=0.25, xO=0.00,
			xCoordMin=660, xCoordMax=1000}
		\setyAxis{yMin=4.5, yMax=5.5, Dy=0.5}
		
		\plotxAxis{linejoin=2}
		\plotyAxis[NoTickLabel,NoLabel]{}
		
		\listplot[linejoin=2, linewidth=5pt]{\NoiseData}%
		\listplot[plotstyle=dots, linecolor=red, dotsize=2pt]{\NoiseData}
		
	\end{NumericDataPlot}
\end{minipage}

\begin{minipage}{0.48\linewidth}
	\centering
	\includegraphics{fig_NoiseData_ClosedLine}
\end{minipage}
\begin{minipage}{0.48\linewidth}
	\centering
	\includegraphics{fig_NoiseData_OpenLine}
\end{minipage}



\subsection{Customized Tick Labels}


\begin{minipage}[T]{0.5\linewidth}
	\lstinputlisting[linerange=5-12]{examples/furtherEx_TickLabels}
\end{minipage}
\hspace{1ex}
\begin{minipage}[T]{0.4\linewidth}
	\input{examples/furtherEx_TickLabels}
\end{minipage}