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