Debian Codegraph @

texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %%% This file is a copy of some part of PGF/Tikz.
3 %%% It has been copied here to provide :
4 %%% - compatibility with older PGF versions
5 %%% - availability of PGF contributions by Christian Feuersaenger
6 %%% which are necessary or helpful for pgfplots.
7 %%%
8 %%% For reasons of simplicity, I have copied the whole file, including own contributions AND
9 %%% PGF parts. The copyrights are as they appear in PGF.
10 %%%
11 %%% Note that pgfplots has compatible licenses.
12 %%%
13 %%% This copy has been modified in the following ways:
14 %%% - nested \input commands have been updated
15 %%%
16 %
17 % Support for the contents of this file will NOT be done by the PGF/TikZ team.
18 % Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
19 % with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
20 % This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22 %%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%%
23
24
25
26 % Copyright 2006 by Till Tantau
27 %
28 % This file may be distributed and/or modified
29 %
30 % 1. under the LaTeX Project Public License and/or
31 % 2. under the GNU Public License.
32 %
33 % See the file doc/generic/pgf/licenses/LICENSE for more details.
34
35 \ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplothandlers.code.tex,v 1.17 2012/09/11 20:03:46 ludewich Exp $
36
37 \newif\ifpgf@plot@started
38
39
40 % This handler converts each plot stream command into a curveto
41 % command, except for the first, which is converted to the previously
42 % specified action.
43 %
44 % Example:
45 %
46 % \pgfpathmoveto{\pgfpointorigin}
47 % \pgfsetlinetofirstplotpoint
48 % \pgfplothandlercurveto
49 % \pgfplotxyfile{mytable}
50
51 \def\pgfplothandlercurveto{%
52 \def\pgf@plotstreamstart{%
53 \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@initial%
54 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
55 \global\let\pgf@plotstreamend=\pgf@plot@curveto@handler@finish%
56 \global\pgf@plot@startedfalse%
57 }%
58 }
59
60 \def\pgf@plot@curveto@handler@initial#1{%
61 \pgf@process{#1}%
62 \pgf@xa=\pgf@x%
63 \pgf@ya=\pgf@y%
64 \pgf@plot@first@action{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
65 \xdef\pgf@plot@curveto@first{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
66 \global\let\pgf@plot@curveto@first@support=\pgf@plot@curveto@first%
67 \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@second%
68 }
69
70 \def\pgf@plot@curveto@handler@second#1{%
71 \pgf@process{#1}%
72 \xdef\pgf@plot@curveto@second{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
73 \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@third%
74 \global\pgf@plot@startedtrue%
75 }
76
77 \def\pgf@plot@curveto@handler@third#1{%
78 \pgf@process{#1}%
79 \xdef\pgf@plot@curveto@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
80 % compute difference vector:
81 \pgf@xa=\pgf@x%
82 \pgf@ya=\pgf@y%
83 \pgf@process{\pgf@plot@curveto@first}
84 \advance\pgf@xa by-\pgf@x%
85 \advance\pgf@ya by-\pgf@y%
86 % compute support directions:
87 \pgf@xa=\pgf@plottension\pgf@xa%
88 \pgf@ya=\pgf@plottension\pgf@ya%
89 % first marshal:
90 \pgf@process{\pgf@plot@curveto@second}%
91 \pgf@xb=\pgf@x%
92 \pgf@yb=\pgf@y%
93 \pgf@xc=\pgf@x%
94 \pgf@yc=\pgf@y%
95 \advance\pgf@xb by-\pgf@xa%
96 \advance\pgf@yb by-\pgf@ya%
97 \advance\pgf@xc by\pgf@xa%
98 \advance\pgf@yc by\pgf@ya%
99 \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@curveto@first@support}%
100 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@curveto@second}}%
101 {\pgf@marshal}%
102 % Prepare next:
103 \global\let\pgf@plot@curveto@first=\pgf@plot@curveto@second%
104 \global\let\pgf@plot@curveto@second=\pgf@plot@curveto@current%
105 \xdef\pgf@plot@curveto@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
106 }
107
108 \def\pgf@plot@curveto@handler@finish{%
109 \ifpgf@plot@started%
110 \pgfpathcurveto{\pgf@plot@curveto@first@support}{\pgf@plot@curveto@second}{\pgf@plot@curveto@second}%
111 \fi%
112 }
113
114
115 % This commands sets the tension for smoothing of plots.
116 %
117 % #1 = tension of curves. A value of 1 will yield a circle when the
118 % control points are at quarters of a circle. A smaller value
119 % will result in a tighter curve. Default is 0.5.
120 %
121 % Example:
122 %
123 % \pgfsetplottension{0.2}
124
125 \def\pgfsetplottension#1{%
126 \pgf@x=#1pt\relax%
127 \pgf@x=0.2775\pgf@x\relax%
128 \edef\pgf@plottension{\pgf@sys@tonumber\pgf@x}}
129 \pgfsetplottension{0.5}
130
131
132 % This handler converts the plot stream command into a curveto
133 % command that is closed using a closepath.
134 %
135 % Example:
136 %
137 % \pgfpathmoveto{\pgfpointorigin}
138 % \pgfplothandlerclosedcurve
139 % \pgfplotxyfile{mytable}
140
141 \def\pgfplothandlerclosedcurve{%
142 \def\pgf@plotstreamstart{%
143 \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@initial%
144 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
145 \global\let\pgf@plotstreamend=\pgf@plot@closedcurve@handler@finish%
146 }%
147 }
148
149 \def\pgf@plot@closedcurve@handler@initial#1{%
150 \pgf@process{#1}%
151 \pgf@xa=\pgf@x%
152 \pgf@ya=\pgf@y%
153 \xdef\pgf@plot@closedcurve@initial{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
154 \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@second%
155 \global\pgf@plot@startedfalse%
156 }
157
158 \def\pgf@plot@closedcurve@handler@second#1{%
159 \pgf@process{#1}%
160 \xdef\pgf@plot@closedcurve@after@initial{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
161 {\pgfpathmoveto{}}%
162 \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@third%
163 }
164
165 \def\pgf@plot@closedcurve@handler@third#1{%
166 \global\pgf@plot@startedtrue%
167 \pgf@process{#1}%
168 \xdef\pgf@plot@closedcurve@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
169 % compute difference vector:
170 \pgf@xa=\pgf@x%
171 \pgf@ya=\pgf@y%
172 \pgf@process{\pgf@plot@closedcurve@initial}
173 \advance\pgf@xa by-\pgf@x%
174 \advance\pgf@ya by-\pgf@y%
175 % compute support directions:
176 \pgf@xa=\pgf@plottension\pgf@xa%
177 \pgf@ya=\pgf@plottension\pgf@ya%
178 % first marshal:
179 \pgf@process{\pgf@plot@closedcurve@after@initial}%
180 \pgf@xb=\pgf@x%
181 \pgf@yb=\pgf@y%
182 \pgf@xc=\pgf@x%
183 \pgf@yc=\pgf@y%
184 \advance\pgf@xb by-\pgf@xa%
185 \advance\pgf@yb by-\pgf@ya%
186 \advance\pgf@xc by\pgf@xa%
187 \advance\pgf@yc by\pgf@ya%
188 \global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@after@initial%
189 \global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current%
190 \xdef\pgf@plot@closedcurve@after@initial@presupport{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
191 \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
192 \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@fourth%
193 }
194
195 \def\pgf@plot@closedcurve@handler@fourth#1{%
196 \pgf@process{#1}%
197 \xdef\pgf@plot@closedcurve@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
198 % compute difference vector:
199 \pgf@xa=\pgf@x%
200 \pgf@ya=\pgf@y%
201 \pgf@process{\pgf@plot@closedcurve@first}
202 \advance\pgf@xa by-\pgf@x%
203 \advance\pgf@ya by-\pgf@y%
204 % compute support directions:
205 \pgf@xa=\pgf@plottension\pgf@xa%
206 \pgf@ya=\pgf@plottension\pgf@ya%
207 % first marshal:
208 \pgf@process{\pgf@plot@closedcurve@second}%
209 \pgf@xb=\pgf@x%
210 \pgf@yb=\pgf@y%
211 \pgf@xc=\pgf@x%
212 \pgf@yc=\pgf@y%
213 \advance\pgf@xb by-\pgf@xa%
214 \advance\pgf@yb by-\pgf@ya%
215 \advance\pgf@xc by\pgf@xa%
216 \advance\pgf@yc by\pgf@ya%
217 \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
218 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}%
219 {\pgf@marshal}%
220 % Prepare next:
221 \global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@second%
222 \global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current%
223 \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
224 }
225
226 \def\pgf@plot@closedcurve@handler@finish{%
227 \ifpgf@plot@started
228 %
229 % first, draw line from 2nd last to last:
230 %
231 \pgf@process{\pgf@plot@closedcurve@initial}%
232 % compute difference vector:
233 \pgf@xa=\pgf@x%
234 \pgf@ya=\pgf@y%
235 \pgf@process{\pgf@plot@closedcurve@first}%
236 \advance\pgf@xa by-\pgf@x%
237 \advance\pgf@ya by-\pgf@y%
238 % compute support directions:
239 \pgf@xa=\pgf@plottension\pgf@xa%
240 \pgf@ya=\pgf@plottension\pgf@ya%
241 % first marshal:
242 \pgf@process{\pgf@plot@closedcurve@second}%
243 \pgf@xb=\pgf@x%
244 \pgf@yb=\pgf@y%
245 \pgf@xc=\pgf@x%
246 \pgf@yc=\pgf@y%
247 \advance\pgf@xb by-\pgf@xa%
248 \advance\pgf@yb by-\pgf@ya%
249 \advance\pgf@xc by\pgf@xa%
250 \advance\pgf@yc by\pgf@ya%
251 \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
252 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}%
253 {\pgf@marshal}%
254 \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
255 %
256 % second, draw line from last point to start:
257 %
258 \pgf@process{\pgf@plot@closedcurve@after@initial}%
259 % compute difference vector:
260 \pgf@xa=\pgf@x%
261 \pgf@ya=\pgf@y%
262 \pgf@process{\pgf@plot@closedcurve@second}%
263 \advance\pgf@xa by-\pgf@x%
264 \advance\pgf@ya by-\pgf@y%
265 % compute support directions:
266 \pgf@xa=\pgf@plottension\pgf@xa%
267 \pgf@ya=\pgf@plottension\pgf@ya%
268 % first marshal:
269 \pgf@process{\pgf@plot@closedcurve@initial}%
270 \pgf@xb=\pgf@x%
271 \pgf@yb=\pgf@y%
272 \pgf@xc=\pgf@x%
273 \pgf@yc=\pgf@y%
274 \advance\pgf@xb by-\pgf@xa%
275 \advance\pgf@yb by-\pgf@ya%
276 \advance\pgf@xc by\pgf@xa%
277 \advance\pgf@yc by\pgf@ya%
278 \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
279 {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@initial}}%
280 {\pgf@marshal}%
281 %
282 % third, draw line from first to second point:
283 %
284 \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
285 {\noexpand\pgf@plot@closedcurve@after@initial@presupport}{\noexpand\pgf@plot@closedcurve@after@initial}}%
286 {\pgf@marshal}%
287 \pgfpathclose%
288 \fi%
289 }
290
291
292
293
294
295 % This handler converts each point in a stream into a line from the
296 % $y$-axis to the given points coordinate, resulting in a
297 % ``comb.''
298 %
299 % Example:
300 %
301 % \pgfplothandlerxcomb
302 % \pgfplotxyfile{mytable}
303
304 \def\pgfplothandlerxcomb{%
305 \def\pgf@plotstreamstart{%
306 \global\let\pgf@plotstreampoint=\pgf@plot@xcomb@handler%
307 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
308 \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend%
309 \pgfplotxzerolevelstreamstart
310 }%
311 }
312
313 \def\pgf@plot@xcomb@handler#1{%
314 \pgf@process{#1}%
315 \pgf@xa=\pgf@x%
316 \pgf@ya=\pgf@y%
317 \begingroup
318 \pgfplotxzerolevelstreamnext
319 \endgroup
320 \pgf@yb=\pgf@x
321 \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}%
322 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
323 }
324
325
326 % This handler converts each point in a stream into a line from the
327 % $x$-axis straight up to the given points coordinate, resulting in a
328 % ``comb.''
329 %
330 % Example:
331 %
332 % \pgfplothandlerycomb
333 % \pgfplotxyfile{mytable}
334
335 \def\pgfplothandlerycomb{%
336 \def\pgf@plotstreamstart{%
337 \global\let\pgf@plotstreampoint=\pgf@plot@ycomb@handler%
338 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
339 \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend%
340 \pgfplotyzerolevelstreamstart
341 }%
342 }
343
344 \def\pgf@plot@ycomb@handler#1{%
345 \pgf@process{#1}%
346 \pgf@xa=\pgf@x%
347 \pgf@ya=\pgf@y%
348 \begingroup
349 \pgfplotyzerolevelstreamnext
350 \endgroup
351 \pgf@yb=\pgf@x
352 \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yb}}%
353 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
354 }
355
356 % PGF Bar or comb plots usually draw something from zero to the current plot's coordinate.
357 %
358 % The 'zero' offset can be changed using an input stream.
359 %
360 % There are two such streams which can be configured independently.
361 % The first one returns "zeros" for coordinate x, the second one
362 % returns "zeros" for coordinate y.
363 %
364 % \pgfplotxzerolevelstreamstart
365 % \pgfplotxzerolevelstreamnext % assigns \pgf@x globally
366 % \pgfplotxzerolevelstreamnext
367 % \pgfplotxzerolevelstreamnext
368 % \pgfplotxzerolevelstreamend
369 %
370 % and
371 % \pgfplotyzerolevelstreamstart
372 % \pgfplotyzerolevelstreamnext % assigns \pgf@x globally
373 % \pgfplotyzerolevelstreamend
374 %
375 \def\pgfplotxzerolevelstreamstart{\pgf@plotxzerolevelstreamstart}%
376 \def\pgfplotxzerolevelstreamend{\pgf@plotxzerolevelstreamend}%
377 \def\pgfplotxzerolevelstreamnext{\pgf@plotxzerolevelstreamnext}
378 \def\pgfplotyzerolevelstreamstart{\pgf@plotyzerolevelstreamstart}%
379 \def\pgfplotyzerolevelstreamend{\pgf@plotyzerolevelstreamend}%
380 \def\pgfplotyzerolevelstreamnext{\pgf@plotyzerolevelstreamnext}
381
382 % This zero level stream always returns '#1' (a dimension).
383 \def\pgfplotxzerolevelstreamconstant#1{%
384 \edef\pgfplotxzerolevelstreamconstant@val{#1}%
385 \def\pgf@plotxzerolevelstreamstart{%
386 \global\let\pgf@plotxzerolevelstreamend=\relax
387 \gdef\pgf@plotxzerolevelstreamnext{\global\pgf@x=\pgfplotxzerolevelstreamconstant@val\relax}%
388 }%
389 }%
390 \pgfplotxzerolevelstreamconstant{0pt}%
391
392 % This zero level stream always returns '#1'.
393 \def\pgfplotyzerolevelstreamconstant#1{%
394 \edef\pgfplotyzerolevelstreamconstant@val{#1}%
395 \def\pgf@plotyzerolevelstreamstart{%
396 \global\let\pgf@plotyzerolevelstreamend=\relax
397 \gdef\pgf@plotyzerolevelstreamnext{\global\pgf@x=\pgfplotyzerolevelstreamconstant@val\relax}%
398 }%
399 }%
400 \pgfplotyzerolevelstreamconstant{0pt}%
401
402 \def\pgfplotbarwidth{\pgfkeysvalueof{/pgf/bar width}}
403 \def\pgfplotbarshift{\pgfkeysvalueof{/pgf/bar shift}}
404
405 \pgfqkeys{/pgf}{%
406 bar width/.initial=10pt,
407 bar shift/.initial=0pt,
408 bar interval width/.initial=1,
409 bar interval shift/.initial=0.5,
410 %
411 % hook which is executed right before a new bar is begun.
412 at begin bar/.initial=,
413 % hook which is executed right after a bar path has been finished.
414 % In this context, the bar's path has not been used.
415 at end bar/.initial=,
416 }
417
418 % This handler places a rectangle at each point in the plot stream, a
419 % rectangle which touches the x-axis at one end and the current point
420 % at the other end:
421 % --(X)--
422 % | |
423 % | |
424 % | |
425 % --(0)--
426 % Example:
427 %
428 % \pgfplothandlerybar
429 % \pgfplotxyfile{mytable}
430 \def\pgfplothandlerybar{%
431 \def\pgf@plotstreamstart{%
432 \global\let\pgf@plotstreampoint=\pgf@plot@ybar@handler%
433 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
434 \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend%
435 \pgfmathparse{\pgfplotbarwidth}%
436 \xdef\pgfplotbarwidth@{\pgfmathresult pt}%
437 \pgfmathparse{\pgfplotbarshift}%
438 \xdef\pgfplotbarshift@{\pgfmathresult pt}%
439 \pgfplotyzerolevelstreamstart
440 }%
441 }
442
443 \def\pgf@plot@ybar@handler#1{%
444 \pgfkeysvalueof{/pgf/at begin bar}%
445 \pgf@process{#1}%
446 \pgf@ya=\pgf@y
447 \expandafter\pgf@xb\pgfplotbarwidth@\relax
448 \pgf@xc=\pgf@x
449 \advance\pgf@xc by-.5\pgf@xb
450 \advance\pgf@xc by\pgfplotbarshift@\relax
451 \begingroup
452 \pgfplotyzerolevelstreamnext
453 \endgroup
454 \pgf@yb=\pgf@x
455 \advance\pgf@ya by-\pgf@yb
456 \pgfpathrectangle
457 {\pgfqpoint{\pgf@xc}{\pgf@yb}}%
458 {\pgfqpoint{\pgf@xb}{\pgf@ya}}%
459 \pgfkeysvalueof{/pgf/at end bar}%
460 }
461
462 % This handler places a rectangle at each point in the plot stream, a
463 % rectangle which touches the y-axis at one end and the current point
464 % at the other end:
465 % ---------
466 % | |
467 % (0) (X)
468 % | |
469 % ---------
470 % Example:
471 %
472 % \pgfplothandlerxbar
473 % \pgfplotxyfile{mytable}
474 \def\pgfplothandlerxbar{%
475 \def\pgf@plotstreamstart{%
476 \global\let\pgf@plotstreampoint=\pgf@plot@xbar@handler%
477 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
478 \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend%
479 \pgfmathparse{\pgfplotbarwidth}%
480 \xdef\pgfplotbarwidth@{\pgfmathresult pt}%
481 \pgfmathparse{\pgfplotbarshift}%
482 \xdef\pgfplotbarshift@{\pgfmathresult pt}%
483 \pgfplotxzerolevelstreamstart
484 }%
485 }
486
487 \def\pgf@plot@xbar@handler#1{%
488 \pgfkeysvalueof{/pgf/at begin bar}%
489 \pgf@process{#1}%
490 \pgf@ya=\pgf@x
491 \expandafter\pgf@xb\pgfplotbarwidth@\relax
492 \pgf@xc=\pgf@y
493 \advance\pgf@xc by-.5\pgf@xb
494 \advance\pgf@xc by\pgfplotbarshift@\relax
495 \begingroup
496 \pgfplotxzerolevelstreamnext
497 \endgroup
498 \pgf@yb=\pgf@x
499 \advance\pgf@ya by-\pgf@yb
500 \pgfpathrectangle
501 {\pgfqpoint{\pgf@yb}{\pgf@xc}}%
502 {\pgfqpoint{\pgf@ya}{\pgf@xb}}%
503 \pgfkeysvalueof{/pgf/at end bar}%
504 }
505
506 % This handler is a variant of \pgfplothandlerybar which works with
507 % intervals instead of points.
508 %
509 % Bars are drawn between successive input coordinates and the width is
510 % determined relatively to the interval length.
511 %
512 % It looks like this:
513 %
514 % |---| |-----|
515 % | | | |
516 % | | | |
517 % | | | |
518 % (X)------(X)-----------(X)
519 %
520 % where (X) denotes the x-axis offsets of input coordinates.
521 %
522 % In more detail, if (x_i,y_i) and (x_{i+1},y_{i+1}) denote successive
523 % input coordinates, the bar will be placed above the
524 % interval [x_i,x_{i+1}], centered at
525 %
526 % x_i + \pgfkeysvalueof{/pgf/bar interval shift} * (x_{i+1} - x_i)
527 %
528 % with width
529 %
530 % \pgfkeysvalueof{/pgf/bar interval width} * (x_{i+1} - x_i).
531 %
532 % If you have N+1 input points, you will get N bars (one for each
533 % interval). The y_i value of the last bar will be ignored.
534 %
535 % Example:
536 %
537 % \pgfplothandlerybarinterval
538 % \pgfplotxyfile{mytable}
539 \def\pgfplothandlerybarinterval{%
540 \def\pgf@plotstreamstart{%
541 \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler@first%
542 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
543 \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend%
544 \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}%
545 \xdef\pgfplotbarintervalwidth@{\pgfmathresult}%
546 \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}%
547 \xdef\pgfplotbarintervalshift@{\pgfmathresult}%
548 \pgfplotyzerolevelstreamstart
549 }%
550 }
551
552 \def\pgf@plot@ybarinterval@handler@first#1{%
553 \pgf@process{#1}%
554 \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}%
555 \xdef\pgf@plot@barinterval@bar{\the\pgf@y}%
556 \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler%
557 }
558 \def\pgf@plot@ybarinterval@handler#1{%
559 \pgfkeysvalueof{/pgf/at begin bar}%
560 \pgf@process{#1}%
561 \pgf@ya=\pgf@plot@barinterval@bar
562 \xdef\pgf@plot@barinterval@bar{\the\pgf@y}%
563 \pgf@xc=\pgf@plot@barinterval@intervalstart\relax
564 \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}%
565 \pgf@xb=\pgf@x
566 \advance\pgf@xb by-\pgf@xc
567 \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb
568 \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb
569 \advance\pgf@xc by-.5\pgf@xb% center
570 \begingroup
571 \pgfplotyzerolevelstreamnext
572 \endgroup
573 \pgf@yb=\pgf@x
574 \advance\pgf@ya by-\pgf@yb
575 \pgfpathrectangle
576 {\pgfqpoint{\pgf@xc}{\pgf@yb}}%
577 {\pgfqpoint{\pgf@xb}{\pgf@ya}}%
578 \pgfkeysvalueof{/pgf/at end bar}%
579 }
580
581 % Like \pgfplothandlerybarinterval but for xbar.
582 \def\pgfplothandlerxbarinterval{%
583 \def\pgf@plotstreamstart{%
584 \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler@first%
585 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
586 \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend%
587 \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}%
588 \xdef\pgfplotbarintervalwidth@{\pgfmathresult}%
589 \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}%
590 \xdef\pgfplotbarintervalshift@{\pgfmathresult}%
591 \pgfplotxzerolevelstreamstart
592 }%
593 }
594
595 \def\pgf@plot@xbarinterval@handler@first#1{%
596 \pgf@process{#1}%
597 \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}%
598 \xdef\pgf@plot@barinterval@bar{\the\pgf@x}%
599 \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler%
600 }
601 \def\pgf@plot@xbarinterval@handler#1{%
602 \pgfkeysvalueof{/pgf/at begin bar}%
603 \pgf@process{#1}%
604 \pgf@ya=\pgf@plot@barinterval@bar
605 \xdef\pgf@plot@barinterval@bar{\the\pgf@x}%
606 \pgf@xc=\pgf@plot@barinterval@intervalstart\relax
607 \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}%
608 \pgf@xb=\pgf@y
609 \advance\pgf@xb by-\pgf@xc
610 \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb
611 \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb
612 \advance\pgf@xc by-.5\pgf@xb% center
613 \begingroup
614 \pgfplotxzerolevelstreamnext
615 \endgroup
616 \pgf@yb=\pgf@x
617 \advance\pgf@ya by-\pgf@yb
618 \pgfpathrectangle
619 {\pgfqpoint{\pgf@yb}{\pgf@xc}}%
620 {\pgfqpoint{\pgf@ya}{\pgf@xb}}%
621 \pgfkeysvalueof{/pgf/at end bar}%
622 }
623
624
625 % This handler is very similar to \pgfplothandlerlineto, but it
626 % produces CONSTANT connected pieces of the form
627 %
628 % x
629 % |
630 % x--- |
631 % | x----
632 % x-|
633 %
634 % Example:
635 %
636 % \pgfplothandlerconstantlineto
637 % \pgfplotxyfile{mytable}
638 \def\pgfplothandlerconstantlineto{%
639 \def\pgf@plotstreamstart{%
640 \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler%
641 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
642 \global\let\pgf@plotstreamend=\relax%
643 }%
644 }
645 \def\pgf@plot@const@line@handler#1{%
646 \pgf@process{#1}%
647 \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}%
648 \pgf@plot@first@action{}%
649 \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler@@%
650 }
651 \def\pgf@plot@const@line@handler@@#1{%
652 \pgf@process{#1}%
653 \pgf@xa=\pgf@x
654 \pgf@ya=\pgf@y
655 \pgf@yb\pgf@plot@const@line@handler@last\relax
656 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}%
657 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
658 \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}%
659 }
660
661 % A variant of \pgfplothandlerconstantlineto which places its mark on
662 % the right line ends.
663 %
664 % |---x
665 % ---x |
666 % |--x
667 % x
668 %
669 % Example:
670 %
671 % \pgfplothandlerconstantlinetomarkright
672 % \pgfplotxyfile{mytable}
673 \def\pgfplothandlerconstantlinetomarkright{%
674 \def\pgf@plotstreamstart{%
675 \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler%
676 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
677 \global\let\pgf@plotstreamend=\relax%
678 }%
679 }
680 \def\pgf@plot@const@line@mark@right@handler#1{%
681 \pgf@process{#1}%
682 \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}%
683 \pgf@plot@first@action{}%
684 \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler@@%
685 }
686 \def\pgf@plot@const@line@mark@right@handler@@#1{%
687 \pgf@process{#1}%
688 \pgf@xa=\pgf@x
689 \pgf@ya=\pgf@y
690 \pgf@yb\pgf@plot@const@line@handler@last\relax
691 \pgfpathlineto{\pgfqpoint{\pgf@yb}{\pgf@ya}}%
692 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
693 \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}%
694 }
695
696 % A variant of \pgfplothandlerconstantlineto which places its mark on
697 % the middle of the line segment.
698 %
699 % ----x
700 % |
701 % --x--- |
702 % | |--x----
703 % x--
704 %
705 % Example:
706 %
707 % \pgfplothandlerconstantlinetomarkmid
708 % \pgfplotxyfile{mytable}
709 \def\pgfplothandlerconstantlinetomarkmid{%
710 \def\pgf@plotstreamstart{%
711 \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@mid@handler%
712 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
713 \global\let\pgf@plotstreamend=\relax%
714 }%
715 }
716 \def\pgf@plot@const@line@mark@mid@handler#1{%
717 \pgf@process{#1}%
718 \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
719 \pgf@plot@first@action{}%
720 \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@mid@handler@@%
721 }
722 \def\pgf@plot@const@line@mark@mid@handler@@#1{%
723 \pgf@process{#1}%
724 \pgf@xa=\pgf@x
725 \pgf@ya=\pgf@y
726 \pgf@plot@const@line@handler@last
727 \pgf@xc=.5\pgf@xa
728 \advance\pgf@xc by.5\pgf@x
729 \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@y}}%
730 \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@ya}}%
731 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
732 \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
733 }
734
735 % This handler is in fact a variant of \pgfplothandlerconstantlineto,
736 % but it does not draw vertical lines. It produces a sequence of
737 % line-to and move-to operations such that plot marks are placed at
738 % each right end:
739 %
740 % ---x
741 % ---x
742 % ---x
743 % --x
744 %
745 % Example:
746 %
747 % \pgfplothandlerjumpmarkright
748 % \pgfplotxyfile{mytable}
749 \def\pgfplothandlerjumpmarkright{%
750 \def\pgf@plotstreamstart{%
751 \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler%
752 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
753 \global\let\pgf@plotstreamend=\relax%
754 }%
755 }
756 \def\pgf@plot@jumpmarkright@handler#1{%
757 \pgf@process{#1}%
758 \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}%
759 \pgf@plot@first@action{}%
760 \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler@@%
761 }
762 \def\pgf@plot@jumpmarkright@handler@@#1{%
763 \pgf@process{#1}%
764 \pgf@xa=\pgf@x
765 \pgf@ya=\pgf@y
766 \pgf@yb\pgf@plot@const@line@handler@last\relax
767 \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}%
768 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
769 \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}%
770 }
771
772 % This handler is in fact a variant of \pgfplothandlerconstantlineto,
773 % but it does not draw vertical lines. It produces a sequence of
774 % line-to and move-to operations such that plot marks are placed at
775 % each left end:
776 %
777 % x---
778 % x---
779 % x---
780 % x--
781 %
782 % Example:
783 %
784 % \pgfplothandlerjumpmarkleft
785 % \pgfplotxyfile{mytable}
786 \def\pgfplothandlerjumpmarkleft{%
787 \def\pgf@plotstreamstart{%
788 \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler%
789 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
790 \global\let\pgf@plotstreamend=\relax%
791 }%
792 }
793 \def\pgf@plot@jumpmarkleft@handler#1{%
794 \pgf@process{#1}%
795 \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}%
796 \pgf@plot@first@action{}%
797 \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler@@%
798 }
799 \def\pgf@plot@jumpmarkleft@handler@@#1{%
800 \pgf@process{#1}%
801 \pgf@xa=\pgf@x
802 \pgf@ya=\pgf@y
803 \pgf@yb\pgf@plot@const@line@handler@last\relax
804 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}%
805 \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
806 \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}%
807 }
808
809 % This handler is in fact a variant of
810 % \pgfplothandlerconstantlinetomarkmid,
811 % but it does not draw vertical lines. It produces a sequence of
812 % line-to and move-to operations such that plot marks are placed like
813 %
814 % ----x
815 %
816 % --x--
817 % --x----
818 % x--
819 %
820 % Example:
821 %
822 % \pgfplothandlerjumpmarkmid
823 % \pgfplotxyfile{mytable}
824 \def\pgfplothandlerjumpmarkmid{%
825 \def\pgf@plotstreamstart{%
826 \global\let\pgf@plotstreampoint=\pgf@plot@jump@mark@mid@handler%
827 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
828 \global\let\pgf@plotstreamend=\relax%
829 }%
830 }
831 \def\pgf@plot@jump@mark@mid@handler#1{%
832 \pgf@process{#1}%
833 \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
834 \pgf@plot@first@action{}%
835 \global\let\pgf@plotstreampoint=\pgf@plot@jump@mark@mid@handler@@%
836 }
837 \def\pgf@plot@jump@mark@mid@handler@@#1{%
838 \pgf@process{#1}%
839 \pgf@xa=\pgf@x
840 \pgf@ya=\pgf@y
841 \pgf@plot@const@line@handler@last
842 \pgf@xc=.5\pgf@xa
843 \advance\pgf@xc by.5\pgf@x
844 \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@y}}%
845 \pgfpathmoveto{\pgfqpoint{\pgf@xc}{\pgf@ya}}%
846 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
847 \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
848 }
849
850
851 % This handler converts each point in a stream into a line from the
852 % origin to the point's coordinate, resulting in a ``star''.
853 %
854 % Example:
855 %
856 % \pgfplothandlerpolarcomb
857 % \pgfplotxyfile{mytable}
858
859 \def\pgfplothandlerpolarcomb{%
860 \def\pgf@plotstreamstart{%
861 \global\let\pgf@plotstreampoint=\pgf@plot@polarcomb@handler%
862 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
863 \global\let\pgf@plotstreamend=\relax%
864 }%
865 }
866
867 \def\pgf@plot@polarcomb@handler#1{%
868 \pgf@process{#1}%
869 \pgf@xa=\pgf@x%
870 \pgf@ya=\pgf@y%
871 \pgfpathmoveto{\pgfpointorigin}%
872 \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
873 }
874
875
876
877
878 % This handler draws a given mark at each point.
879 %
880 % #1 = some code to be executed at each point (with the coordinate
881 % system translated to that point).
882 % Typically, this code will be \pgfuseplotmark{whatever}.
883 %
884 % Example:
885 %
886 % \pgfplothandlermark{\pgfuseplotmark{*}}
887 % \pgfplotxyfile{mytable}
888
889 \def\pgfplothandlermark#1{%
890 \pgf@plothandlermark{%
891 \ifnum\pgf@plot@mark@count<\pgf@plot@mark@repeat\relax%
892 \else%
893 \global\pgf@plot@mark@count=0\relax%
894 #1%
895 \fi%
896 }%
897 }
898
899 \newcount\pgf@plot@mark@count
900 \def\pgf@plot@mark@phase{0}
901
902 \def\pgf@plothandlermark#1{%
903 \def\pgf@plot@mark{#1}%
904 \def\pgf@plotstreamstart{%
905 \global\pgf@plot@mark@count=\pgf@plot@mark@repeat\relax%
906 \global\advance\pgf@plot@mark@count by-\pgf@plot@mark@phase\relax%
907 \global\let\pgf@plotstreampoint=\pgf@plot@mark@handler%
908 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
909 \global\let\pgf@plotstreamend=\relax%
910 }%
911 }
912
913 \def\pgf@plot@mark@handler#1{%
914 \global\advance\pgf@plot@mark@count by1\relax%
915 {\pgftransformshift{#1}\pgf@plot@mark}%
916 }
917
918
919 % Set the repeat count for marks. For example, if 3 is given as a
920 % value, only every third point will get a mark.
921 %
922 % #1 = repeat count
923 %
924 % Example:
925 %
926 % \pgfsetplotmarkrepeat{2}
927
928 \def\pgfsetplotmarkrepeat#1{\def\pgf@plot@mark@repeat{#1}}
929 \pgfsetplotmarkrepeat{1}
930
931
932 % Set the phase for marks. For example, if 3 is the repeat and 3 is
933 % the phase, already the first point will be marked.
934 %
935 % #1 = the index of the first point that should be marked.
936 %
937 % Example:
938 %
939 % \pgfsetplotmarkphase{3}
940
941 \def\pgfsetplotmarkphase#1{\def\pgf@plot@mark@phase{#1}}
942 \pgfsetplotmarkphase{1}
943
944
945
946 % This handler draws a given mark at those points whose number is
947 % given in the (pgffor-like) list.
948 %
949 % #1 = some code to be executed at each point (with the coordinate
950 % system translated to that point).
951 % Typically, this code will be \pgfuseplotmark{whatever}.
952 % #2 = list of positions like "1,2,4,...,9,10"
953 %
954 % Example:
955 %
956 % \pgfplothandlermarklisted{\pgfuseplotmark{*}}{1,2,4,...,9}
957 % \pgfplotxyfile{mytable}
958
959 \def\pgfplothandlermarklisted#1#2{%
960 \let\pgf@plot@mark@list=\pgfutil@empty%
961 \edef\pgf@marshal{\noexpand\foreach\noexpand\pgf@temp in{#2}}
962 \pgf@marshal{\xdef\pgf@plot@mark@list{\pgf@plot@mark@list(\pgf@temp)}}%
963 \pgf@plothandlermark{%
964 \edef\pgf@marshal{\noexpand\pgfutil@in@{(\the\pgf@plot@mark@count)}{\pgf@plot@mark@list}}%
965 \pgf@marshal%
966 \ifpgfutil@in@#1\fi}%
967 }
968
969
970 % Define a new plot mark for use with \pgfplotmark.
971 %
972 % #1 = a plot mark mnemonic
973 % #2 = code for drawing the mark
974 %
975 % Example:
976 %
977 % \pgfdeclareplotmark{*}{\pgfpathcircle{\pgfpointorigin}{2pt}\pgfusepathqfill}
978
979 \def\pgfdeclareplotmark#1#2{\expandafter\def\csname pgf@plot@mark@#1\endcsname{#2}}
980
981
982 % Set the size of plot marks. For circles, this will be the radius,
983 % for other shapes it should be about half the width/height.
984 %
985 % Example:
986 %
987 % \pgfsetplotmarksize{1pt}
988
989 \def\pgfsetplotmarksize#1{\pgfmathsetlength\pgfplotmarksize{#1}}
990
991 \newdimen\pgfplotmarksize
992 \pgfplotmarksize=2pt
993
994
995 % Insert a plot mark's code at the origin.
996 %
997 % #1 = plot mark mnemonic
998 %
999 % Example:
1000 %
1001 % \pgfuseplotmark{*}
1002
1003 \def\pgfuseplotmark#1{\csname pgf@plot@mark@#1\endcsname}
1004
1005
1006 % A stroke-filled circle mark
1007
1008 \pgfdeclareplotmark{*}
1009 {%
1010 \pgfpathcircle{\pgfpointorigin}{\pgfplotmarksize}
1011 \pgfusepathqfillstroke
1012 }
1013
1014
1015 % A plus-sign like mark
1016
1017 \pgfdeclareplotmark{+}
1018 {%
1019 \pgfpathmoveto{\pgfqpoint{-\pgfplotmarksize}{0pt}}
1020 \pgfpathlineto{\pgfqpoint{\pgfplotmarksize}{0pt}}
1021 \pgfpathmoveto{\pgfqpoint{0pt}{\pgfplotmarksize}}
1022 \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}
1023 \pgfusepathqstroke
1024 }
1025
1026
1027 % An x-shaped mark
1028
1029 \pgfdeclareplotmark{x}
1030 {%
1031 \pgfpathmoveto{\pgfqpoint{-.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}}
1032 \pgfpathlineto{\pgfqpoint{.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}}
1033 \pgfpathmoveto{\pgfqpoint{-.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}}
1034 \pgfpathlineto{\pgfqpoint{.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}}
1035 \pgfusepathqstroke
1036 }
1037
1038 % See pgflibraryplotmarks for more plot marks
1039
1040
1041
1042
1043 % This handler turns creates a series of straight line segements
1044 % between consecutive points, but leaving /pgf/gap around stream point
1045 % space.
1046 %
1047 % Example:
1048 %
1049 % \pgfplothandlergaplineto
1050 % \pgfplotxyfile{mytable}
1051
1052 \pgfkeys{/pgf/gap around stream point/.initial=1.5pt}
1053
1054 \def\pgfplothandlergaplineto{%
1055 \def\pgf@plotstreamstart{%
1056 \global\let\pgf@plotstreampoint=\pgf@plot@gap@lineto@handler@initial%
1057 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
1058 \global\let\pgf@plotstreamend=\relax%
1059 }%
1060 }
1061
1062 \def\pgf@plot@gap@lineto@handler@initial#1{%
1063 \pgf@process{#1}%
1064 \pgf@xa=\pgf@x%
1065 \pgf@ya=\pgf@y%
1066 \xdef\pgf@plot@gap@lineto@last{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
1067 \global\let\pgf@plotstreampoint=\pgf@plot@gap@lineto@handler%
1068 }
1069
1070 \def\pgf@plot@gap@lineto@handler#1{%
1071 % Ok, compute normalized line vector
1072 \pgf@process{#1}%
1073 \pgf@xa=\pgf@x%
1074 \pgf@ya=\pgf@y%
1075 \xdef\pgf@plot@gap@lineto@next{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
1076 \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@plot@gap@lineto@last}{\pgf@plot@gap@lineto@next}}}%
1077 \pgf@xc=\pgf@x%
1078 \pgf@yc=\pgf@y%
1079 \pgfpathmoveto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap
1080 around stream point}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgf@plot@gap@lineto@last}}%
1081 \pgfpathlineto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap
1082 around stream point}}{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}}{\pgf@plot@gap@lineto@next}}%
1083 \global\let\pgf@plot@gap@lineto@last=\pgf@plot@gap@lineto@next%
1084 }
1085
1086
1087
1088
1089 % This handler works like \pgfplothandlergaplineto, only the last
1090 % point is connected to the first point, creating a closed curve
1091 % space.
1092 %
1093 % Example:
1094 %
1095 % \pgfplothandlergapcycle
1096 % \pgfplotxyfile{mytable}
1097
1098 \def\pgfplothandlergapcycle{%
1099 \def\pgf@plotstreamstart{%
1100 \global\let\pgf@plotstreampoint=\pgf@plot@gap@cycle@handler@initial%
1101 \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
1102 \global\let\pgf@plotstreamend=\pgf@plot@gap@cycle@handler@finish%
1103 \global\let\pgf@plot@gap@cycle@first=\relax%
1104 }%
1105 }
1106
1107 \def\pgf@plot@gap@cycle@handler@initial#1{%
1108 \pgf@process{#1}%
1109 \pgf@xa=\pgf@x%
1110 \pgf@ya=\pgf@y%
1111 \xdef\pgf@plot@gap@cycle@last{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
1112 \global\let\pgf@plot@gap@cycle@first=\pgf@plot@gap@cycle@last%
1113 \global\let\pgf@plotstreampoint=\pgf@plot@gap@cycle@handler%
1114 }
1115
1116 \def\pgf@plot@gap@cycle@handler#1{%
1117 % Ok, compute normalized line vector
1118 \pgf@process{#1}%
1119 \pgf@xa=\pgf@x%
1120 \pgf@ya=\pgf@y%
1121 \xdef\pgf@plot@gap@cycle@next{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
1122 \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@plot@gap@cycle@last}{\pgf@plot@gap@cycle@next}}}%
1123 \pgf@xc=\pgf@x%
1124 \pgf@yc=\pgf@y%
1125 \pgfpathmoveto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap
1126 around stream point}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgf@plot@gap@cycle@last}}%
1127 \pgfpathlineto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap
1128 around stream point}}{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}}{\pgf@plot@gap@cycle@next}}%
1129 \global\let\pgf@plot@gap@cycle@last=\pgf@plot@gap@cycle@next%
1130 }
1131
1132 \def\pgf@plot@gap@cycle@handler@finish{%
1133 \ifx\pgf@plot@gap@cycle@first\relax%
1134 \else
1135 \pgf@plot@gap@cycle@handler{\pgf@plot@gap@cycle@first}%
1136 \fi
1137 }
1138
1139
1140
1141 \endinput