Debian Codegraph @

texmf-dist/doc/latex/numericplots/src/FurtherExamples.tex

raw
1 \section{Further Examples}
2
3 \def\MoreData{
4 0 5
5 1 7
6 2 10
7 3 11
8 4 11.5
9 5 10
10 6 5
11 7 4
12 8 9
13 9 12
14 10 11
15 11 5
16 }
17
18 \def\MoreDataI{
19 0 -5
20 1 -7
21 2 -10
22 3 -11
23 4 -11.5
24 5 -10
25 6 10
26 7 15
27 8 10
28 9 -12
29 10 -11
30 11 -5
31 }
32
33 \def\NoiseData{
34 0 5
35 0.1 5.4
36 0.2 4.6
37 0.3 5.3
38 0.4 4.9
39 0.5 4.6
40 }
41 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.
42
43 \begin{minipage}{0.5\linewidth}
44 \begin{verbatim}
45 \listplot
46 [style=StdLineStyA]
47 {\MoreData}
48 \listplot
49 [style=StdLineStyB, yEnd=10]
50 {\MoreData}
51 \listplot
52 [style=StdLineStyC, xStart=5, xEnd=9]
53 {\MoreData}
54 \listplot
55 [style=StdLineStyD, showpoints=true, nStep=2]
56 {\MoreData}
57 \end{verbatim}
58 \end{minipage}
59 \begin{minipage}{0.45\linewidth}
60 \centering
61 \begin{NumericDataPlot}{\textwidth}{5cm}
62 \setxAxis{xMin=0, xMax=15, Dx=5, xO=0}
63 \setyAxis{yMin=0, yMax=15, Dy=5, yO=0}
64
65 \plotxAxis[NoLabel]{x-axis label}
66 \plotyAxis[NoLabel]{y-axis label}
67
68 \listplot[style=StdLineStyA]{\MoreData}
69 \listplot[style=StdLineStyB, yEnd=10]{\MoreData}
70 \listplot[style=StdLineStyC, xStart=5, xEnd=9]{\MoreData}
71 \listplot[style=StdLineStyD, showpoints=true, nStep=2]{\MoreData}
72 \end{NumericDataPlot}
73 \end{minipage}
74
75
76
77 \subsection{Fill area between plots}
78 \label{sec:FillArea}
79
80 \begin{minipage}{0.5\linewidth}
81 \begin{verbatim}
82 \begin{NumericDataPlot}%
83 {\textwidth}{5cm}
84 \setxAxis
85 {xMin=0, xMax=15, Dx=5, xO=0}
86 \setyAxis
87 {yMin=-15, yMax=15, Dy=5, yO=10}
88
89 \plotxAxis{x-axis label}
90 \plotyAxis[NoLabel]{}
91
92 \pscustom%
93 [style=StdLineStyA, fillstyle=solid, %
94 fillcolor=blue!40]{%
95 \listplot{\MoreData}%
96 \listplot[ChangeOrder]{\MoreDataI}%
97 }
98 \end{NumericDataPlot}
99 \end{verbatim}
100 \end{minipage}
101 \begin{minipage}{0.45\linewidth}
102 \centering
103 \begin{NumericDataPlot}{\textwidth}{5cm}
104 \setxAxis{xMin=0, xMax=15, Dx=5, xO=0}
105 \setyAxis{yMin=-15, yMax=15, Dy=5, yO=10}
106
107 \plotxAxis{x-axis label}
108 \plotyAxis[NoLabel]{}
109
110 \pscustom[style=StdLineStyA, fillstyle=solid, fillcolor=blue!40]{%
111 \listplot{\MoreData}%
112 \listplot[ChangeOrder]{\MoreDataI}%
113 }
114 \end{NumericDataPlot}
115 \end{minipage}
116
117
118
119
120
121
122 \begin{minipage}{0.5\linewidth}
123 \begin{verbatim}
124 ...
125 \pscustom%
126 [style=StdLineStyA, fillstyle=solid, %
127 fillcolor=green!40]{%
128 \NDPhline{0}
129 \listplot[ChangeOrder]{\MoreDataI}%
130 }
131 ...
132 \end{verbatim}
133 \end{minipage}\begin{minipage}{0.45\linewidth}
134 \centering
135 \begin{NumericDataPlot}{\textwidth}{5cm}
136 \setxAxis{xMin=0, xMax=15, Dx=5, xO=0}
137 \setyAxis{yMin=-15, yMax=15, Dy=5, yO=10}
138
139 \plotxAxis{x-axis label}
140 \plotyAxis[NoLabel]{}
141
142 \pscustom%
143 [style=StdLineStyA, fillstyle=solid, %
144 fillcolor=green!40]{%
145 \NDPhline{0}
146 \listplot[ChangeOrder]{\MoreDataI}%
147 }
148 \end{NumericDataPlot}
149 \end{minipage}
150
151
152 \begin{minipage}{0.5\linewidth}
153 \begin{verbatim}
154 ...
155 \pscustom%
156 [style=StdLineStyA, fillstyle=solid, %
157 fillcolor=red!40]{%
158 \NDPline{0}{5}{11}{10}
159 \listplot[ChangeOrder]{\MoreDataI}%
160 }
161 ...
162 \end{verbatim}
163 \end{minipage}
164 \begin{minipage}{0.45\linewidth}
165 \centering
166 \begin{NumericDataPlot}{\textwidth}{5cm}
167 \setxAxis{xMin=0, xMax=15, Dx=5, xO=0}
168 \setyAxis{yMin=-15, yMax=15, Dy=5, yO=10}
169
170 \plotxAxis{x-axis label}
171 \plotyAxis[NoLabel]{}
172
173 \pscustom%
174 [fillstyle=solid, linestyle=none,%
175 fillcolor=red!40]{%
176 \NDPline{0}{5}{11}{10}
177 \listplot[ChangeOrder]{\MoreDataI}%
178 }
179 \listplot[style=StdLineStyB]{\MoreDataI}
180 \end{NumericDataPlot}
181 \end{minipage}
182
183
184 \subsection{Custom Grid}
185
186 To plot a custom grid (grid-lines are not equidistant) the following procedure
187 may be used if working with Matlab:
188
189 Add the following code after export2latex (XTick is a vector containing the
190 positions of the desired x-gridlines):
191 \begin{verbatim}
192 % export positions of the x-Tick-Marks
193 fid = fopen(TargetTexFile, 'at');
194 fprintf(fid, '\n\\def\\CustomXGrid{\n');
195 for i=1:length(XTick)
196 fprintf(fid, ...
197 '\\NDPvline[style=CustomXGridStyle]{%f}\n', adj.XTick(i));
198 end
199 fprintf(fid, '}\n');
200 fclose(fid);
201 \end{verbatim}
202
203 In Latex just define the style ``CustomXGridStyle'' and use the command
204 \verb+\CustomXGrid+ after defining the axis.
205
206
207 \subsection{Plotting noisy data}
208 \label{sec:FurtherExamples:NoisyData}
209
210 Plotting measurement data with a lot of noise may be a little tricky. First, you
211 often have a lot of data to plot which may lead to memory problems in \TeX.
212 When filtering the data, the appearance of the noise may change which is not
213 what you intend to do. To solve this problem, the two Matlab-functions
214 ``LatexFilterMinMax'' and ``LatexFilterHull'' are provided. Both take x- and
215 y-data and divide it in NrOfPoints equally intervals. The filter returns the
216 maximum and the minimum value of each interval.
217
218 The filter ``LatexFilterHull'' returns a vector which contains the minima first
219 and then the maxima. This data may be plotted with ``fillstyle=solid'' as in
220 section~\ref{sec:FillArea}.
221
222 The filter ``LatexFilterMinMax'' returns maximum and minimum value of each
223 interval (with corresponding x-data). This data may be plotted as a ``normal
224 line''. As pstricks-lines are normally closed lines, this may lead to a plot
225 where the noise seems exagerated. You may therefore use the option linejoin as
226 demonstrated in the following examples. The red dots mark the actual data.
227 Notice that the measurement data seems noisier than it is if it is plotted with
228 linejoin=0. Plotting with linejoin=2 represents the data much better. The
229 standard for linejoin is 0. The StdLineStyXX defined in this package are defined
230 with linejoin=1.
231
232 \begin{minipage}{0.4\linewidth}
233 \begin{verbatim}
234 ...
235 % linejoin=0:
236 \listplot[linewidth=5pt]%
237 {\NoiseData}%
238 ...
239 % linejoin=1:
240 \listplot[linejoin=1, %
241 linewidth=5pt]{\NoiseData}%
242 ...
243 % linejoin=2:
244 \listplot[linejoin=1, %
245 linewidth=5pt]{\NoiseData}%
246 ...
247 \end{verbatim}
248 \end{minipage}
249 \begin{minipage}{0.55\linewidth}
250 \centering
251 \begin{NumericDataPlot}{\textwidth}{5cm}
252 \setxAxis{xMin=0.00, xMax=0.5, Dx=0.25, xO=0.00,
253 xCoordMin=0, xCoordMax=300}
254 \setyAxis{yMin=4.5, yMax=5.5, Dy=0.5}
255
256 \plotxAxis{linejoin=0}
257 \plotyAxis[NoLabel]{}
258
259 \listplot[linewidth=5pt]{\NoiseData}%
260 \listplot[plotstyle=dots, linecolor=red, dotsize=2pt]{\NoiseData}
261
262 \setxAxis{xMin=0.00, xMax=0.5, Dx=0.25, xO=0.00,
263 xCoordMin=330, xCoordMax=630}
264 \setyAxis{yMin=4.5, yMax=5.5, Dy=0.5}
265
266 \plotxAxis{linejoin=1}
267 \plotyAxis[NoTickLabel,NoLabel]{}
268
269 \listplot[linejoin=1, linewidth=5pt]{\NoiseData}%
270 \listplot[plotstyle=dots, linecolor=red, dotsize=2pt]{\NoiseData}
271
272 \setxAxis{xMin=0.00, xMax=0.5, Dx=0.25, xO=0.00,
273 xCoordMin=660, xCoordMax=1000}
274 \setyAxis{yMin=4.5, yMax=5.5, Dy=0.5}
275
276 \plotxAxis{linejoin=2}
277 \plotyAxis[NoTickLabel,NoLabel]{}
278
279 \listplot[linejoin=2, linewidth=5pt]{\NoiseData}%
280 \listplot[plotstyle=dots, linecolor=red, dotsize=2pt]{\NoiseData}
281
282 \end{NumericDataPlot}
283 \end{minipage}
284
285 \begin{minipage}{0.48\linewidth}
286 \centering
287 \includegraphics{fig_NoiseData_ClosedLine}
288 \end{minipage}
289 \begin{minipage}{0.48\linewidth}
290 \centering
291 \includegraphics{fig_NoiseData_OpenLine}
292 \end{minipage}
293
294
295
296 \subsection{Customized Tick Labels}\label{sec:CustomTickLabels}
297
298 A common task is to plot a graph without numeric tick labels but with selected customized labels. This is easily accomplished by setting the option \verb|NoTickLabel| when plotting the axis and adding the customized labels with the commands \verb|PutTickLabelXaxis| and \verb|PutTickLabelYaxis|. Note that when setting \verb|NoTickLabel| for an axis, the option \verb|ax| has to be set in each call of \verb|PutTickLabelXaxis| and \verb|PutTickLabelYaxis| according to the axis one wishes to place the label at. This is also required if only the lower x-axis or left y-axis are plotted and tick labelled.
299
300 \begin{minipage}[T]{0.5\linewidth}
301 \lstinputlisting[linerange=5-12]{examples/furtherEx_TickLabels}
302 \end{minipage}
303 \hspace{1ex}
304 \begin{minipage}[T]{0.4\linewidth}
305 \input{examples/furtherEx_TickLabels}
306 \end{minipage}