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
|
\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplothandlers.code.tex,v 1.3 2005/07/06 15:58:57 tantau Exp $
% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>.
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 2.
\newif\ifpgf@plot@started
% This handler converts each plot stream command into a curveto
% command, except for the first, which is converted to the previously
% specified action.
%
% Example:
%
% \pgfpathmoveto{\pgfpointorigin}
% \pgfsetlinetofirstplotpoint
% \pgfplothandlercurveto
% \pgfplotxyfile{mytable}
\def\pgfplothandlercurveto{%
\def\pgf@plotstreamstart{%
\global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@initial%
\global\let\pgf@plotstreamspecial=\@gobble%
\global\let\pgf@plotstreamend=\pgf@plot@curveto@handler@finish%
\global\pgf@plot@startedfalse%
}%
}
\def\pgf@plot@curveto@handler@initial#1{%
\pgf@process{#1}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@plot@first@action{\pgfpoint{\pgf@xa}{\pgf@ya}}%
\xdef\pgf@plot@curveto@first{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}%
\global\let\pgf@plot@curveto@first@support=\pgf@plot@curveto@first%
\global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@second%
}
\def\pgf@plot@curveto@handler@second#1{%
\pgf@process{#1}%
\xdef\pgf@plot@curveto@second{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
\global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@third%
\global\pgf@plot@startedtrue%
}
\def\pgf@plot@curveto@handler@third#1{%
\pgf@process{#1}%
\xdef\pgf@plot@curveto@current{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
% compute difference vector:
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgf@plot@curveto@first}
\advance\pgf@xa by-\pgf@x%
\advance\pgf@ya by-\pgf@y%
% compute support directions:
\pgf@xa=\pgf@plottension\pgf@xa%
\pgf@ya=\pgf@plottension\pgf@ya%
% first marshal:
\pgf@process{\pgf@plot@curveto@second}%
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\advance\pgf@xb by-\pgf@xa%
\advance\pgf@yb by-\pgf@ya%
\advance\pgf@xc by\pgf@xa%
\advance\pgf@yc by\pgf@ya%
\edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@curveto@first@support}%
{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@curveto@second}}%
{\pgf@marshal}%
% Prepare next:
\global\let\pgf@plot@curveto@first=\pgf@plot@curveto@second%
\global\let\pgf@plot@curveto@second=\pgf@plot@curveto@current%
\xdef\pgf@plot@curveto@first@support{\noexpand\pgfpoint{\the\pgf@xc}{\the\pgf@yc}}%
}
\def\pgf@plot@curveto@handler@finish{%
\ifpgf@plot@started%
\pgfpathcurveto{\pgf@plot@curveto@first@support}{\pgf@plot@curveto@second}{\pgf@plot@curveto@second}%
\fi%
}
% This commands sets the tension for smoothing of plots.
%
% #1 = tension of curves. A value of 1 will yield a circle when the
% control points are at quarters of a circle. A smaller value
% will result in a tighter curve. Default is 0.5.
%
% Example:
%
% \pgfsetplottension{0.2}
\def\pgfsetplottension#1{%
\pgf@x=#1pt\relax%
\pgf@x=0.2775\pgf@x\relax%
\edef\pgf@plottension{\pgf@sys@tonumber\pgf@x}}
\pgfsetplottension{0.5}
% This handler converts the plot stream command into a curveto
% command that is closed using a closepath.
%
% Example:
%
% \pgfpathmoveto{\pgfpointorigin}
% \pgfplothandlerclosedcurve
% \pgfplotxyfile{mytable}
\def\pgfplothandlerclosedcurve{%
\def\pgf@plotstreamstart{%
\global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@initial%
\global\let\pgf@plotstreamspecial=\@gobble%
\global\let\pgf@plotstreamend=\pgf@plot@closedcurve@handler@finish%
}%
}
\def\pgf@plot@closedcurve@handler@initial#1{%
\pgf@process{#1}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\xdef\pgf@plot@closedcurve@initial{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}%
\global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@second%
\global\pgf@plot@startedfalse%
}
\def\pgf@plot@closedcurve@handler@second#1{%
\pgf@process{#1}%
\xdef\pgf@plot@closedcurve@after@initial{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
{\pgfpathmoveto{}}%
\global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@third%
}
\def\pgf@plot@closedcurve@handler@third#1{%
\global\pgf@plot@startedtrue%
\pgf@process{#1}%
\xdef\pgf@plot@closedcurve@current{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
% compute difference vector:
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgf@plot@closedcurve@initial}
\advance\pgf@xa by-\pgf@x%
\advance\pgf@ya by-\pgf@y%
% compute support directions:
\pgf@xa=\pgf@plottension\pgf@xa%
\pgf@ya=\pgf@plottension\pgf@ya%
% first marshal:
\pgf@process{\pgf@plot@closedcurve@after@initial}%
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\advance\pgf@xb by-\pgf@xa%
\advance\pgf@yb by-\pgf@ya%
\advance\pgf@xc by\pgf@xa%
\advance\pgf@yc by\pgf@ya%
\global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@after@initial%
\global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current%
\xdef\pgf@plot@closedcurve@after@initial@presupport{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}%
\xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfpoint{\the\pgf@xc}{\the\pgf@yc}}%
\global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@fourth%
}
\def\pgf@plot@closedcurve@handler@fourth#1{%
\pgf@process{#1}%
\xdef\pgf@plot@closedcurve@current{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
% compute difference vector:
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgf@plot@closedcurve@first}
\advance\pgf@xa by-\pgf@x%
\advance\pgf@ya by-\pgf@y%
% compute support directions:
\pgf@xa=\pgf@plottension\pgf@xa%
\pgf@ya=\pgf@plottension\pgf@ya%
% first marshal:
\pgf@process{\pgf@plot@closedcurve@second}%
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\advance\pgf@xb by-\pgf@xa%
\advance\pgf@yb by-\pgf@ya%
\advance\pgf@xc by\pgf@xa%
\advance\pgf@yc by\pgf@ya%
\edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}%
{\pgf@marshal}%
% Prepare next:
\global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@second%
\global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current%
\xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfpoint{\the\pgf@xc}{\the\pgf@yc}}%
}
\def\pgf@plot@closedcurve@handler@finish{%
\ifpgf@plot@started
%
% first, draw line from 2nd last to last:
%
\pgf@process{\pgf@plot@closedcurve@initial}%
% compute difference vector:
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgf@plot@closedcurve@first}%
\advance\pgf@xa by-\pgf@x%
\advance\pgf@ya by-\pgf@y%
% compute support directions:
\pgf@xa=\pgf@plottension\pgf@xa%
\pgf@ya=\pgf@plottension\pgf@ya%
% first marshal:
\pgf@process{\pgf@plot@closedcurve@second}%
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\advance\pgf@xb by-\pgf@xa%
\advance\pgf@yb by-\pgf@ya%
\advance\pgf@xc by\pgf@xa%
\advance\pgf@yc by\pgf@ya%
\edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}%
{\pgf@marshal}%
\xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfpoint{\the\pgf@xc}{\the\pgf@yc}}%
%
% second, draw line from last point to start:
%
\pgf@process{\pgf@plot@closedcurve@after@initial}%
% compute difference vector:
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgf@plot@closedcurve@second}%
\advance\pgf@xa by-\pgf@x%
\advance\pgf@ya by-\pgf@y%
% compute support directions:
\pgf@xa=\pgf@plottension\pgf@xa%
\pgf@ya=\pgf@plottension\pgf@ya%
% first marshal:
\pgf@process{\pgf@plot@closedcurve@initial}%
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\advance\pgf@xb by-\pgf@xa%
\advance\pgf@yb by-\pgf@ya%
\advance\pgf@xc by\pgf@xa%
\advance\pgf@yc by\pgf@ya%
\edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@initial}}%
{\pgf@marshal}%
%
% third, draw line from first to second point:
%
\edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgfpoint{\the\pgf@xc}{\the\pgf@yc}}%
{\noexpand\pgf@plot@closedcurve@after@initial@presupport}{\noexpand\pgf@plot@closedcurve@after@initial}}%
{\pgf@marshal}%
\pgfpathclose%
\fi%
}
% This handler converts each point in a stream into a line from the
% $y$-axis to the given points coordinate, resulting in a
% ``comb.''
%
% Example:
%
% \pgfplothandlerxcomb
% \pgfplotxyfile{mytable}
\def\pgfplothandlerxcomb{%
\def\pgf@plotstreamstart{%
\global\let\pgf@plotstreampoint=\pgf@plot@xcomb@handler%
\global\let\pgf@plotstreamspecial=\@gobble%
\global\let\pgf@plotstreamend=\relax%
}%
}
\def\pgf@plot@xcomb@handler#1{%
\pgf@process{#1}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgfpathmoveto{\pgfpoint{0pt}{\pgf@ya}}%
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@ya}}%
}
% This handler converts each point in a stream into a line from the
% $x$-axis straight up to the given points coordinate, resulting in a
% ``comb.''
%
% Example:
%
% \pgfplothandlerycomb
% \pgfplotxyfile{mytable}
\def\pgfplothandlerycomb{%
\def\pgf@plotstreamstart{%
\global\let\pgf@plotstreampoint=\pgf@plot@ycomb@handler%
\global\let\pgf@plotstreamspecial=\@gobble%
\global\let\pgf@plotstreamend=\relax%
}%
}
\def\pgf@plot@ycomb@handler#1{%
\pgf@process{#1}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgfpathmoveto{\pgfpoint{\pgf@xa}{0pt}}%
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@ya}}%
}
% This handler converts each point in a stream into a line from the
% origin to the point's coordinate, resulting in a ``star''.
%
% Example:
%
% \pgfplothandlerpolarcomb
% \pgfplotxyfile{mytable}
\def\pgfplothandlerpolarcomb{%
\def\pgf@plotstreamstart{%
\global\let\pgf@plotstreampoint=\pgf@plot@polarcomb@handler%
\global\let\pgf@plotstreamspecial=\@gobble%
\global\let\pgf@plotstreamend=\relax%
}%
}
\def\pgf@plot@polarcomb@handler#1{%
\pgf@process{#1}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgfpathmoveto{\pgfpointorigin}%
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@ya}}%
}
% This handler draws a given mark at each point.
%
% #1 = some code to be executed at each point (with the coordinate
% system translated to that point).
% Typically, this code will be \pgfuseplotmark{whatever}.
%
% Example:
%
% \pgfplothandlermark{\pgfuseplotmark{*}}
% \pgfplotxyfile{mytable}
\def\pgfplothandlermark#1{%
\def\pgf@plot@mark{#1}%
\def\pgf@plotstreamstart{%
\global\let\pgf@plotstreampoint=\pgf@plot@mark@handler%
\global\let\pgf@plotstreamspecial=\@gobble%
\global\let\pgf@plotstreamend=\relax%
}%
}
\def\pgf@plot@mark@handler#1{%
{\pgftransformshift{#1}\pgf@plot@mark}%
}
% Define a new plot mark for use with \pgfplotmark.
%
% #1 = a plot mark mnemonic
% #2 = code for drawing the mark
%
% Example:
%
% \pgfdeclareplotmark{*}{\pgfpathcircle{\pgfpointorigin}{2pt}\pgfusepathqfill}
\def\pgfdeclareplotmark#1#2{\expandafter\def\csname pgf@plot@mark@#1\endcsname{#2}}
% Set the size of plot marks. For circles, this will be the radius,
% for other shapes it should be about half the width/height.
%
% Example:
%
% \pgfsetplotmarksize{1pt}
\def\pgfsetplotmarksize#1{\setlength\pgfplotmarksize{#1}}
\newdimen\pgfplotmarksize
\pgfplotmarksize=2pt
% Insert a plot mark's code at the origin.
%
% #1 = plot mark mnemonic
%
% Example:
%
% \pgfuseplotmark{*}
\def\pgfuseplotmark#1{\csname pgf@plot@mark@#1\endcsname}
% A stroke-filled circle mark
\pgfdeclareplotmark{*}
{%
\pgfpathcircle{\pgfpointorigin}{\pgfplotmarksize}
\pgfusepathqfillstroke
}
% A plus-sign like mark
\pgfdeclareplotmark{+}
{%
\pgfpathmoveto{\pgfpoint{-\pgfplotmarksize}{0pt}}
\pgfpathlineto{\pgfpoint{\pgfplotmarksize}{0pt}}
\pgfpathmoveto{\pgfpoint{0pt}{\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{0pt}{-\pgfplotmarksize}}
\pgfusepathqstroke
}
% An x-shaped mark
\pgfdeclareplotmark{x}
{%
\pgfpathmoveto{\pgfpoint{-.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}}
\pgfpathmoveto{\pgfpoint{-.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}}
\pgfusepathqstroke
}
% See pgflibraryplotmarks for more plot marks
\endinput
|