| 1 |
% |
| 2 |
% |
| 3 |
% |
| 4 |
%-------------------------------------------- |
| 5 |
% |
| 6 |
% Package pgfplots |
| 7 |
% |
| 8 |
% Provides a user-friendly interface to create function plots (normal |
| 9 |
% plots, semi-logplots and double-logplots). |
| 10 |
% |
| 11 |
% It is based on Till Tantau's PGF package. |
| 12 |
% |
| 13 |
% Copyright 2007/2008 by Christian Feuersänger. |
| 14 |
% |
| 15 |
% This program is free software: you can redistribute it and/or modify |
| 16 |
% it under the terms of the GNU General Public License as published by |
| 17 |
% the Free Software Foundation, either version 3 of the License, or |
| 18 |
% (at your option) any later version. |
| 19 |
% |
| 20 |
% This program is distributed in the hope that it will be useful, |
| 21 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 |
% GNU General Public License for more details. |
| 24 |
% |
| 25 |
% You should have received a copy of the GNU General Public License |
| 26 |
% along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 |
% |
| 28 |
%-------------------------------------------- |
| 29 |
|
| 30 |
\newif\ifpgfplots@usefpu |
| 31 |
\pgfkeys{% |
| 32 |
/pgfplots/use fpu/.is if=pgfplots@usefpu, |
| 33 |
/pgfplots/use fpu=true, |
| 34 |
} |
| 35 |
|
| 36 |
% only useful inside of \ifx (equals only itself) |
| 37 |
\def\pgfplots@EOI{\pgfplots@EOI}% |
| 38 |
|
| 39 |
% Produces an \aftergroup statement for each single token in #1. |
| 40 |
% |
| 41 |
% ATTENTION: you *can't* use braces inside of '#1'! |
| 42 |
\def\pgfplotsqaftergroupeach#1{% |
| 43 |
\pgfplotsqaftergroupeach@#1\pgfplots@EOI |
| 44 |
} |
| 45 |
\def\pgfplotsqaftergroupeach@#1{% |
| 46 |
\gdef\pgfplots@TMP{#1}% |
| 47 |
\ifx\pgfplots@TMP\pgfplots@EOI |
| 48 |
\else |
| 49 |
\aftergroup#1% |
| 50 |
\expandafter\pgfplotsqaftergroupeach@ |
| 51 |
\fi |
| 52 |
} |
| 53 |
|
| 54 |
\def\pgfplotsaftergroupcollectinto#1#2\pgfplots@EOI{% |
| 55 |
\def#1{#2}% |
| 56 |
}% |
| 57 |
|
| 58 |
% Assigns list contents #2 to a list macro #1. |
| 59 |
% |
| 60 |
% The list contents may be provided in one of two formats: |
| 61 |
% a) in the list format 'first\\second\\thirst\\' |
| 62 |
% or |
| 63 |
% b) in the PGF foreach list format 'first,second,third'. |
| 64 |
\def\pgfplots@assign@list#1#2{% |
| 65 |
\pgfplotslistnew#1{#2}% |
| 66 |
}% |
| 67 |
|
| 68 |
\def\pgfplots@shellescape@lua@eightseven#1{% |
| 69 |
\pgfplotsutil@directlua{os.execute("\pgfplotsutil@luaescapestring{#1}")}% |
| 70 |
}% |
| 71 |
\def\pgfplots@shellescape#1{% |
| 72 |
\immediate\write18{#1}% |
| 73 |
}% |
| 74 |
\pgfutil@IfUndefined{directlua}{% |
| 75 |
}{% |
| 76 |
\pgfutil@IfUndefined{lastsavedimageresourcepages}{% |
| 77 |
\pgfplots@log3{Found old luatex which supports write18 (shell-escape)}% |
| 78 |
}{% |
| 79 |
\pgfplots@log3{Found new luatex: initializing lua commands instead of write18 (shell-escape)}% |
| 80 |
\let\pgfplots@shellescape=\pgfplots@shellescape@lua@eightseven |
| 81 |
}% |
| 82 |
}% |
| 83 |
|
| 84 |
% Sets the boolean \ifpgfplots@is@old@list@format to true if and only |
| 85 |
% if the input is a list in the format '{first\\second\\}'. |
| 86 |
% |
| 87 |
% |
| 88 |
% Usage: |
| 89 |
% \pgfplots@check@backwards@compatible@list@format <argument>'\\'\pgfplots@EOI |
| 90 |
% you NEED to append '\\\pgfplots@EOI' at the end. |
| 91 |
\def\pgfplots@check@backwards@compatible@list@format#1\pgfplots@EOI{% |
| 92 |
\pgfplotslist@check@backslash@list#1\pgfplotslist@EOI |
| 93 |
\ifpgfplotslist@is@backslash@terminated |
| 94 |
\pgfplots@is@old@list@formattrue |
| 95 |
\else |
| 96 |
\pgfplots@is@old@list@formatfalse |
| 97 |
\fi |
| 98 |
}% |
| 99 |
|
| 100 |
% Issues an error message if the **LaTeX** package '#1' is not loaded |
| 101 |
% (An error is also raised if the document is not a LaTeX document). |
| 102 |
% #1: the required LaTeX package |
| 103 |
% #2: the feature which requires this package |
| 104 |
\def\pgfplots@assert@LaTeX@package@loaded#1#2{% |
| 105 |
\pgfutil@IfUndefined{@ifpackageloaded}{% |
| 106 |
\pgfplots@error{Sorry, #2 only works with LaTeX (it relies on the LaTeX package #1)}% |
| 107 |
}{% |
| 108 |
\pgfutil@IfUndefined{ver@#1.sty}% this here has been extracted from ltclass.dtx. \@ifpackageloaded is only usable in preamble. |
| 109 |
{\pgfplots@error{Sorry, use need \string\usepackage{#1} in your preamble for '#2'}}% |
| 110 |
{\relax}% |
| 111 |
}% |
| 112 |
}% |
| 113 |
\def\pgfplots@assert@tikzinternal@exists#1{% |
| 114 |
\pgfutil@IfUndefined{#1}{% |
| 115 |
\pgfplots@error{Sorry, pgfplots relies on the existence of the tikz internal macro '#1'. |
| 116 |
Unfortunately, this does no longer exist ... you will need to get an updated version of pgfplots to fix this problem.}% |
| 117 |
\expandafter\let\csname #1\endcsname=\pgfutil@empty |
| 118 |
}{}% |
| 119 |
}% |
| 120 |
|
| 121 |
|
| 122 |
% A future-version compatibility method which checks whether the |
| 123 |
% macro '#2' exists. |
| 124 |
% |
| 125 |
% We assume that '#2' usually contains the value of the tikz key '#1'. |
| 126 |
% Example: |
| 127 |
% /tikz/variable is usually stored into '\tikz@plot@var'. |
| 128 |
% |
| 129 |
% However, this may change in future versions. |
| 130 |
% |
| 131 |
% So, we do the following: |
| 132 |
% 1. check whether '#2' exists, if yet: ok. |
| 133 |
% 2. if not, check whether the value is stored directly into '/tikz/#1'. |
| 134 |
% 3. if not, check whether the value is stored directly into '/pgf/#1'. |
| 135 |
% 4. If everything fails, provide an error message. |
| 136 |
% |
| 137 |
% #1: a tikz key without key prefix (/tikz/ and /pgf/ will be prepended). |
| 138 |
% #2: a macro name WITHOUT backslash. |
| 139 |
% #3: the default value if everything fails. |
| 140 |
\def\pgfplots@gettikzinternal@keyval#1#2#3{% |
| 141 |
\pgfutil@IfUndefined{#2}{% |
| 142 |
\pgfkeysifdefined{/tikz/#1}{% |
| 143 |
\pgfkeysgetvalue{/tikz/#1}\pgfplots@TMP |
| 144 |
\expandafter\let\csname #1\endcsname=\pgfplots@TMP |
| 145 |
}{% |
| 146 |
\pgfkeysifdefined{/pgf/#1}{% |
| 147 |
\pgfkeysgetvalue{/pgf/#1}\pgfplots@TMP |
| 148 |
\expandafter\let\csname #1\endcsname=\pgfplots@TMP |
| 149 |
}{% |
| 150 |
\expandafter\def\csname #1\endcsname{#3}% |
| 151 |
{\t@pgfplots@tokc={#3}% |
| 152 |
\pgfplots@warning{Sorry, could not find value of '/tikz/#1'. Assuming '\the\t@pgfplots@tokc'.}% |
| 153 |
}% |
| 154 |
}% |
| 155 |
}% |
| 156 |
}{}% |
| 157 |
}% |
| 158 |
|
| 159 |
\def\pgfplots@getcurrent@plothandler#1{% |
| 160 |
\pgfutil@IfUndefined{tikz@plot@handler}{% |
| 161 |
\pgfplots@error{Sorry, can't get the current plot handler. It appears that tikz and pgfplots is no longer compatible!? You will need to get a newer version of pgfplots.}% |
| 162 |
\let#1=\pgfplothandlerlineto |
| 163 |
}{% |
| 164 |
\let#1=\tikz@plot@handler |
| 165 |
}% |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
% Converts an arbitrary command (without arguments) to a string in which all characters |
| 171 |
% have category 12. |
| 172 |
% |
| 173 |
% #1: a macro name (which takes no arguments) |
| 174 |
% #2: a macro name which will be assigned to '#1' converted to string. |
| 175 |
% |
| 176 |
% This uses '\meaning#1' hackery. |
| 177 |
\def\pgfplots@command@to@string#1#2{% |
| 178 |
\expandafter\pgfplots@command@to@string@@\meaning#1\pgfplots@EOI{#2}% |
| 179 |
}% |
| 180 |
\xdef\pgfplots@glob@TMPa{\meaning\pgfutil@empty}% |
| 181 |
\expandafter\def\expandafter\pgfplots@command@to@string@@\pgfplots@glob@TMPa#1\pgfplots@EOI#2{% |
| 182 |
\def#2{#1}% |
| 183 |
}% |
| 184 |
\def\pgfplotscommandtostring#1#2{\pgfplots@command@to@string{#1}{#2}}% |
| 185 |
|
| 186 |
\begingroup |
| 187 |
\catcode`\|=0 |
| 188 |
\catcode`\\=12 |
| 189 |
|gdef|pgfplots@backslash@as@other{\}% |
| 190 |
|endgroup |
| 191 |
|
| 192 |
% As \pgfplots@command@to@string, but it works for commands accepting |
| 193 |
% arguments. More precisely, #2 will be a string (!) of the form |
| 194 |
% <argument pattern>{ <body> } |
| 195 |
% such that you can write |
| 196 |
% \def\test #2 |
| 197 |
% into a file to restore the original macro. This IGNORES \long |
| 198 |
% (sorry) |
| 199 |
\def\pgfplots@command@with@args@to@string#1#2{% |
| 200 |
\expandafter\PGFPLOTS@CS@WITH@ARGS@TO@STRING\meaning#1\EOI{#2}% |
| 201 |
}% |
| 202 |
{ |
| 203 |
\let\CATCODE=\catcode |
| 204 |
\let\LONG=\long |
| 205 |
\CATCODE`\m=12 |
| 206 |
\CATCODE`\a=12 |
| 207 |
\CATCODE`\c=12 |
| 208 |
\CATCODE`\r=12 |
| 209 |
\CATCODE`\o=12 |
| 210 |
\CATCODE`\:=12 |
| 211 |
\CATCODE`\-=12 |
| 212 |
\CATCODE`\>=12 |
| 213 |
\LONG\gdef\PGFPLOTS@CS@WITH@ARGS@TO@STRING #1macro:#2->#3\EOI#4{\def#4{#2{#3}}}% |
| 214 |
}% |
| 215 |
|
| 216 |
% Defines \pgfplotsretval to be '#1' but without leading and trailing |
| 217 |
% spaces. |
| 218 |
\def\pgfplotsutil@trim#1{% |
| 219 |
\pgfkeys@spdef\pgfplotsretval{#1}% |
| 220 |
}% |
| 221 |
|
| 222 |
% Invokes '#2' if the token(s) '#1' are actually are defined control |
| 223 |
% sequence and '#3' if not. |
| 224 |
% |
| 225 |
% This method accepts different values '#1' than \pgfutil@ifundefined. |
| 226 |
% It is intended to autodetect values provided in the user interface |
| 227 |
% (ui), |
| 228 |
% that means '#1' can be anything. But I still like to know whether it |
| 229 |
% is a control sequence. |
| 230 |
% |
| 231 |
% \pgfplotsutil@ifdefinedui{\table} -> yes if \table is defined. |
| 232 |
% \pgfplotsutil@ifdefinedui{\csname abc\endcsname} -> no |
| 233 |
% \pgfplotsutil@ifdefinedui{a_file_name} -> no |
| 234 |
\def\pgfplotsutil@ifdefinedui#1#2#3{% |
| 235 |
{\toks0={#1}% this construction is necessary to handle '#' characters in '#1' |
| 236 |
\xdef\pgfplotsutil@@arg@ifdefined{\the\toks0}% |
| 237 |
}% |
| 238 |
\pgfplots@command@to@string\pgfplotsutil@@arg@ifdefined\pgfplotsutil@@arg@ifdefined |
| 239 |
\expandafter\pgfplotsutil@trim\expandafter{\pgfplotsutil@@arg@ifdefined}% |
| 240 |
\pgfutil@IfUndefined{\pgfplotsretval}{#3}{#2}% |
| 241 |
}% |
| 242 |
% The same as \pgfplotsutil@ifdefinedui but appends the suffix '#2' to |
| 243 |
% '#1' after '#1' has been normalized. |
| 244 |
% It invokes '#3' if '#1#2' is defined and '#4' if not. |
| 245 |
\def\pgfplotsutil@ifdefinedui@withsuffix#1#2#3#4{% |
| 246 |
{\toks0={#1}% |
| 247 |
\xdef\pgfplotsutil@@arg@ifdefined{\the\toks0}% |
| 248 |
}% |
| 249 |
\pgfplots@command@to@string\pgfplotsutil@@arg@ifdefined\pgfplotsutil@@arg@ifdefined |
| 250 |
\expandafter\pgfplotsutil@trim\expandafter{\pgfplotsutil@@arg@ifdefined}% |
| 251 |
\pgfutil@IfUndefined{\pgfplotsretval #2}{#4}{#3}% |
| 252 |
}% |
| 253 |
|
| 254 |
% Writes the command name of '#1' without the leading backslash to |
| 255 |
% macro #2. |
| 256 |
\def\pgfplotsutil@getcommandname#1#2{% |
| 257 |
\begingroup |
| 258 |
\escapechar=-1 |
| 259 |
\xdef\pgfplots@glob@TMPa{\string#1}% |
| 260 |
\endgroup |
| 261 |
\let#2=\pgfplots@glob@TMPa |
| 262 |
} |
| 263 |
|
| 264 |
{ |
| 265 |
\catcode`\%=12 |
| 266 |
\gdef\pgfplots@PERCENT@TEXT{%} |
| 267 |
\catcode`\^^I=12 |
| 268 |
\gdef\pgfplots@SPACE{ } |
| 269 |
\gdef\pgfplots@TAB{^^I} |
| 270 |
\catcode`\#=12 \gdef\pgfplots@ROUTE{#}} |
| 271 |
|
| 272 |
% Usage: |
| 273 |
% \pgfplots@if{pgfplots@scaled@ticks}{true-code}{false-code} |
| 274 |
% |
| 275 |
% it is to be used if the tex boolean is only known as string, not as |
| 276 |
% macro. |
| 277 |
\def\pgfplots@if#1#2#3{% |
| 278 |
\csname if#1\endcsname |
| 279 |
#2% |
| 280 |
\else |
| 281 |
#3% |
| 282 |
\fi |
| 283 |
}% |
| 284 |
|
| 285 |
% Executes '#2' if the number '#1' is zero and '#3' if not. |
| 286 |
% Example: |
| 287 |
% \pgfplotsmath@ifzero{0}{It's zero!}{It's not zero} |
| 288 |
% \pgfplotsmath@ifzero{0.0}{It's zero!}{It's not zero} |
| 289 |
% |
| 290 |
% The argument must be assignable to a TeX dimension as 'pt', but |
| 291 |
% without units. |
| 292 |
\def\pgfplotsmath@ifzero#1#2#3{% |
| 293 |
\begingroup |
| 294 |
\pgf@xa=#1pt |
| 295 |
\ifdim\pgf@xa=0pt |
| 296 |
\gdef\pgfplots@glob@TMPa{#2}% |
| 297 |
\else |
| 298 |
\gdef\pgfplots@glob@TMPa{#3}% |
| 299 |
\fi |
| 300 |
\endgroup |
| 301 |
\pgfplots@glob@TMPa |
| 302 |
}% |
| 303 |
|
| 304 |
% Invokes code `#4' if |#1 - #2| <= #3 and `#5' if not. |
| 305 |
% |
| 306 |
% #1,#2 are dimension (registers or numbers) with unit. |
| 307 |
% #3: absolute threshold (dimen) |
| 308 |
\def\pgfplotsmath@ifapproxequal@dim#1#2#3#4#5{% |
| 309 |
\begingroup |
| 310 |
\pgf@xa=#1\relax |
| 311 |
\pgf@xb=#2\relax |
| 312 |
\advance\pgf@xa by-\pgf@xb |
| 313 |
\ifdim\pgf@xa<0pt |
| 314 |
\multiply\pgf@xa by-1 |
| 315 |
\fi |
| 316 |
\ifdim\pgf@xa>#3\relax |
| 317 |
\gdef\pgfplots@glob@TMPa{#5}% |
| 318 |
\else |
| 319 |
\gdef\pgfplots@glob@TMPa{#4}% |
| 320 |
\fi |
| 321 |
\endgroup |
| 322 |
\pgfplots@glob@TMPa |
| 323 |
} |
| 324 |
|
| 325 |
\def\pgfplotsmathmin#1#2{% |
| 326 |
\ifdim#1 pt<#2 pt |
| 327 |
\edef\pgfmathresult{#1}% |
| 328 |
\else |
| 329 |
\edef\pgfmathresult{#2}% |
| 330 |
\fi |
| 331 |
}% |
| 332 |
\def\pgfplotsmathmax#1#2{% |
| 333 |
\ifdim#1 pt>#2 pt |
| 334 |
\edef\pgfmathresult{#1}% |
| 335 |
\else |
| 336 |
\edef\pgfmathresult{#2}% |
| 337 |
\fi |
| 338 |
}% |
| 339 |
\def\pgfplotsmathlessthan#1#2{\ifdim#1pt<#2pt \pgfmathfloatcomparisontrue\else\pgfmathfloatcomparisonfalse\fi} |
| 340 |
|
| 341 |
% Re-define two-argument function for min and max. |
| 342 |
% The pgfmath engine now uses a variable number of arguments. |
| 343 |
\def\pgfplotsmathfloatmax#1#2{% |
| 344 |
\pgfmathfloatlessthan{#1}{#2}% |
| 345 |
\ifpgfmathfloatcomparison |
| 346 |
\edef\pgfmathresult{#2}% |
| 347 |
\else |
| 348 |
\edef\pgfmathresult{#1}% |
| 349 |
\fi |
| 350 |
} |
| 351 |
\def\pgfplotsmathfloatmin#1#2{% |
| 352 |
\pgfmathfloatlessthan{#1}{#2}% |
| 353 |
\ifpgfmathfloatcomparison |
| 354 |
\edef\pgfmathresult{#1}% |
| 355 |
\else |
| 356 |
\edef\pgfmathresult{#2}% |
| 357 |
\fi |
| 358 |
} |
| 359 |
|
| 360 |
% Defines \pgfmathresult to be #1 * 10^{#2}. |
| 361 |
% |
| 362 |
% #1 a macro without unit suffix. |
| 363 |
% #2 an integer number (may be a register) |
| 364 |
\def\pgfplotsmathmultiplypowten@#1#2{% |
| 365 |
\begingroup |
| 366 |
\pgf@xa=#1pt |
| 367 |
\ifnum#2<0 |
| 368 |
\ifcase-#2 |
| 369 |
\or\divide\pgf@xa by10 |
| 370 |
\or\divide\pgf@xa by100 |
| 371 |
\or\divide\pgf@xa by1000 |
| 372 |
\or\divide\pgf@xa by10000 |
| 373 |
\or\divide\pgf@xa by100000 |
| 374 |
\fi |
| 375 |
\else |
| 376 |
\ifcase#2 |
| 377 |
\or\multiply\pgf@xa by10 |
| 378 |
\or\multiply\pgf@xa by100 |
| 379 |
\or\multiply\pgf@xa by1000 |
| 380 |
\or\multiply\pgf@xa by10000 |
| 381 |
\or\multiply\pgf@xa by100000 |
| 382 |
\fi |
| 383 |
\fi |
| 384 |
\edef\pgfmathresult{\pgf@sys@tonumber{\pgf@xa}}% |
| 385 |
\pgfmath@smuggleone\pgfmathresult |
| 386 |
\endgroup |
| 387 |
}% |
| 388 |
|
| 389 |
% defines \pgf@x to be the scalar product between points #1 and #2 |
| 390 |
% #1, #2 are pgfpoint commands |
| 391 |
\def\pgfplotsscalarproductofvectors#1#2{% |
| 392 |
\begingroup |
| 393 |
\pgf@process{#1}% |
| 394 |
\edef\pgfplots@scalarprod@a{\pgf@sys@tonumber\pgf@x}% |
| 395 |
\edef\pgfplots@scalarprod@b{\pgf@sys@tonumber\pgf@y}% |
| 396 |
\pgf@process{#2}% |
| 397 |
\pgf@x=\pgfplots@scalarprod@a\pgf@x |
| 398 |
\advance\pgf@x by\pgfplots@scalarprod@b\pgf@y |
| 399 |
\global\pgf@x=\pgf@x |
| 400 |
\endgroup |
| 401 |
}% |
| 402 |
|
| 403 |
% converts a comma-separated list (PGF foreach) to my internal list |
| 404 |
% structure. |
| 405 |
\long\def\pgfplots@foreach@to@list#1\to#2{% |
| 406 |
\global\pgfplotslistnewempty\pgfplots@glob@TMPa |
| 407 |
\begingroup |
| 408 |
\foreach \pgfplots@i in {#1} {% |
| 409 |
\expandafter\pgfplotslistpushbackglobal\pgfplots@i\to\pgfplots@glob@TMPa |
| 410 |
}% |
| 411 |
\endgroup |
| 412 |
\pgfplotslistcopy\pgfplots@glob@TMPa\to#2\relax |
| 413 |
} |
| 414 |
|
| 415 |
% converts a foreach list to a fully expanded comma-separated list and assigns the result to \pgfplotsretval |
| 416 |
\long\def\pgfplots@foreach@to@list@macro#1{% |
| 417 |
\begingroup |
| 418 |
\pgfplotsapplistXnewempty\pgfplots@tmpa |
| 419 |
\pgfplots@loc@tmptrue |
| 420 |
\pgfkeys{/pgf/fpu}% |
| 421 |
% |
| 422 |
\pgfplotsforeachungrouped \pgfplots@i in {#1} {% |
| 423 |
\ifpgfplots@loc@tmp |
| 424 |
\pgfplots@loc@tmpfalse |
| 425 |
\else |
| 426 |
\pgfplotsapplistXpushback,\to\pgfplots@tmpa |
| 427 |
\fi |
| 428 |
\pgfmathfloattosci\pgfplots@i |
| 429 |
\expandafter\pgfplotsapplistXpushback\pgfmathresult\to\pgfplots@tmpa |
| 430 |
}% |
| 431 |
\pgfplotsapplistXlet\pgfplots@loc@TMPa=\pgfplots@tmpa |
| 432 |
\global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa |
| 433 |
\endgroup |
| 434 |
\let\pgfplotsretval=\pgfplots@glob@TMPa |
| 435 |
} |
| 436 |
|
| 437 |
|
| 438 |
% Removes duplicates in a comma separated list and creates a new list |
| 439 |
% into the macro \pgfplotsretval. The list doesn't need to be sorted, |
| 440 |
% but it should not contain too much elements as the runtime for this |
| 441 |
% simple method is quadratic. |
| 442 |
% |
| 443 |
% #1: a CSV list. |
| 444 |
% Assigns \pgfplotsretval |
| 445 |
\def\pgfplotsutil@unify@short@csv@list#1{% |
| 446 |
\begingroup |
| 447 |
\def\pgfplotsretval{}% |
| 448 |
\pgfplotsutilforeachcommasep{#1}\as\pgfplots@unify@cur{% |
| 449 |
\pgfutil@ifundefined{pgfp@unify@\pgfplots@unify@cur @@@}{% |
| 450 |
\expandafter\def\csname pgfp@unify@\pgfplots@unify@cur @@@\endcsname{1}% |
| 451 |
\ifx\pgfplotsretval\pgfutil@empty |
| 452 |
\let\pgfplotsretval=\pgfplots@unify@cur% |
| 453 |
\else |
| 454 |
\t@pgfplots@toka=\expandafter{\pgfplotsretval}% |
| 455 |
\t@pgfplots@tokb=\expandafter{\pgfplots@unify@cur}% |
| 456 |
\edef\pgfplotsretval{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% |
| 457 |
\fi |
| 458 |
}{}% |
| 459 |
}% |
| 460 |
\pgfmath@smuggleone\pgfplotsretval |
| 461 |
\endgroup |
| 462 |
}% |
| 463 |
|
| 464 |
% Simply invokes the code of PGF key #1 with value #2, that means |
| 465 |
% #1#2\pgfeov |
| 466 |
\def\pgfplots@invoke@pgfkeyscode#1#2{% |
| 467 |
\pgfkeysvalueof{#1}#2\pgfeov |
| 468 |
} |
| 469 |
|
| 470 |
% Usage: |
| 471 |
% \pgfplots@letcsname pgfplots@xtick={pgfplots@kram@x} |
| 472 |
% -> invokes \csname ... \endcsname for both args. |
| 473 |
\def\pgfplots@letcsname#1=#2{% |
| 474 |
\expandafter\let\expandafter\pgfplots@loc@TMPc\csname #2\endcsname |
| 475 |
\expandafter\let\csname #1\endcsname=\pgfplots@loc@TMPc |
| 476 |
}% |
| 477 |
|
| 478 |
% Inside of a pgfplots axis, this method (together with |
| 479 |
% \pgfplotsqpointxyz for 3d axes) is THE |
| 480 |
% point method. If you override the mapping to PGF coordinates here, |
| 481 |
% all other \pgfplotspoint* commands should inherit the changes as well. |
| 482 |
\def\pgfplotsqpointxy#1#2{% |
| 483 |
\global\pgf@x=#1\pgf@xx% |
| 484 |
\global\advance\pgf@x by #2\pgf@yx% |
| 485 |
\global\pgf@y=#1\pgf@xy% |
| 486 |
\global\advance\pgf@y by #2\pgf@yy} |
| 487 |
|
| 488 |
% Inside of a pgfplots axis, this method (together with |
| 489 |
% \pgfplotsqpointxy for 2d axes) is THE |
| 490 |
% point method. If you override the mapping to PGF coordinates here, |
| 491 |
% all other \pgfplotspoint* commands should inherit the changes as well. |
| 492 |
\def\pgfplotsqpointxyz#1#2#3{% |
| 493 |
\global\pgf@x=#1\pgf@xx% |
| 494 |
\global\advance\pgf@x by #2\pgf@yx% |
| 495 |
\global\advance\pgf@x by #3\pgf@zx% |
| 496 |
\global\pgf@y=#1\pgf@xy% |
| 497 |
\global\advance\pgf@y by #2\pgf@yy% |
| 498 |
\global\advance\pgf@y by #3\pgf@zy} |
| 499 |
|
| 500 |
% A "quick" quick variant of \pgfqpointxy which assumes that |
| 501 |
% the X unit vector is ( e_xx,0 )^T and the Y unit vector is ( 0, |
| 502 |
% e_yy)^T. |
| 503 |
% |
| 504 |
% In words, the unit vectors are orthogonal. This is the usual case |
| 505 |
% for two-dimensional plots and shall be optimized. |
| 506 |
\def\pgfplotsqpointxy@orthogonal#1#2{% |
| 507 |
\global\pgf@x=#1\pgf@xx% |
| 508 |
\global\pgf@y=#2\pgf@yy |
| 509 |
} |
| 510 |
|
| 511 |
|
| 512 |
% Takes a domain as input and generates a foreach argument which |
| 513 |
% samples from the domain. |
| 514 |
% Writes the result to \pgfplotsretval |
| 515 |
% INPUT: |
| 516 |
% #1:#2 the domain |
| 517 |
% #3: the number of samples |
| 518 |
% OUTPUT: |
| 519 |
% \pgfplotsretval a foreach specification. |
| 520 |
\def\pgfplots@domain@to@foreach#1:#2\relax#3{% |
| 521 |
\pgfmathparse{#1}% |
| 522 |
\let\pgfplots@loc@TMPa=\pgfmathresult% |
| 523 |
\pgfmathparse{#2}% |
| 524 |
\let\pgfplots@loc@TMPb=\pgfmathresult% |
| 525 |
\pgfmathparse{\pgfplots@loc@TMPa+(\pgfplots@loc@TMPb-\pgfplots@loc@TMPa)/(#3-1)}% |
| 526 |
\edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfmathresult,...,\pgfplots@loc@TMPb}% |
| 527 |
} |
| 528 |
|
| 529 |
{ |
| 530 |
\catcode`\;=\active |
| 531 |
\catcode`\:=\active |
| 532 |
\gdef\pgfplots@activesemicolon{;}% |
| 533 |
\gdef\pgfplots@activecolon{:}% |
| 534 |
} |
| 535 |
|
| 536 |
% checks whether ';' is active and replaces a sequence of commands |
| 537 |
% accordingly. |
| 538 |
% |
| 539 |
% @see \pgfplots@appendto@activesemicolon@switcher |
| 540 |
\def\pgfplots@checkandpreparefor@active@semicolon{% |
| 541 |
\ifnum\the\catcode`\;=\active\relax |
| 542 |
\pgfplots@checkandpreparefor@active@semicolon@ |
| 543 |
\fi |
| 544 |
}% |
| 545 |
\def\pgfplots@checkandpreparefor@active@semicolon@{}% |
| 546 |
|
| 547 |
% Adds all commands '#1' to the sequence of commands which will be |
| 548 |
% issued in case ';' is active. |
| 549 |
\def\pgfplots@appendto@activesemicolon@switcher#1{% |
| 550 |
\expandafter\def\expandafter\pgfplots@checkandpreparefor@active@semicolon@\expandafter{% |
| 551 |
\pgfplots@checkandpreparefor@active@semicolon@ |
| 552 |
#1% |
| 553 |
}% |
| 554 |
}% |
| 555 |
|
| 556 |
% Invokes '#3' for every element in the comma separated list '#1'. |
| 557 |
% during '#3', the macro '#2' will be set to the current list element. |
| 558 |
% |
| 559 |
% In contrast to \foreach of tikz, this processing is NOT scoped by |
| 560 |
% TeX groups. However, it can be nested. |
| 561 |
% |
| 562 |
% Please note that no trimming of white spaces is performed. |
| 563 |
% |
| 564 |
% This is the (accidentally) the same as \pgfplotsforeachentryinCSV. |
| 565 |
\long\def\pgfplotsutilforeachcommasep#1\as#2#3{% |
| 566 |
\pgfplots@for@reset@break{% |
| 567 |
\pgfplotsforeachentryinCSVisterminated@loop{#2}{#3}#1,\pgfplots@EOI |
| 568 |
}% |
| 569 |
}% |
| 570 |
|
| 571 |
% Usage: |
| 572 |
% \pgfplotsforeachentryinCSV{\value}{1,2,3,4.5,6.7,10}{The value is \value\par} |
| 573 |
% |
| 574 |
% The loop is ungrouped. |
| 575 |
% |
| 576 |
% This is the same as \pgfplotsutilforeachcommasep, I must have been |
| 577 |
% sleeping somehow. |
| 578 |
% |
| 579 |
% @see \pgfplotsutilforeachcommasep |
| 580 |
% @see \pgfplotsforeachentryinCSVisterminated |
| 581 |
% @see \pgfplotsforeachungrouped |
| 582 |
% This loop can be nested. |
| 583 |
\long\def\pgfplotsforeachentryinCSV#1#2#3{% |
| 584 |
\pgfplots@for@reset@break{% |
| 585 |
\pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2,\pgfplots@EOI |
| 586 |
}% |
| 587 |
}% |
| 588 |
% A variant of \pgfplotsforeachentryinCSV where a trailing comma |
| 589 |
% indicates the end of input. |
| 590 |
% Example: |
| 591 |
% |
| 592 |
% \pgfplotsforeachentryinCSV{\value}{1,2,3,4.5,6.7,10,}{The value is \value\par} |
| 593 |
% ^ |
| 594 |
% |
| 595 |
% It is permissible to provide an empty list (without trailing comma) |
| 596 |
% |
| 597 |
% This loop can be nested. |
| 598 |
\long\def\pgfplotsforeachentryinCSVisterminated#1#2#3{% |
| 599 |
\pgfplots@for@reset@break{% |
| 600 |
\pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2\pgfplots@EOI |
| 601 |
}% |
| 602 |
}% |
| 603 |
% #1 : the loop macro |
| 604 |
% #2 : the loop BODY |
| 605 |
% #3 : the loop LIST |
| 606 |
% (note the different sequence) |
| 607 |
\long\def\pgfplotsforeachentryinCSVisterminated@loop#1#2{% |
| 608 |
\pgfutil@ifnextchar\pgfplots@EOI{% |
| 609 |
\pgfutil@gobble |
| 610 |
}{% |
| 611 |
\pgfplotsforeachentryinCSV@next{#1}{#2}% |
| 612 |
}% |
| 613 |
}% |
| 614 |
\long\def\pgfplotsforeachentryinCSV@next#1#2#3,{% |
| 615 |
\def#1{#3}% |
| 616 |
#2\relax |
| 617 |
\ifpgffor@continue |
| 618 |
\expandafter\pgfplotsforeachentryinCSVisterminated@loop |
| 619 |
\else |
| 620 |
\expandafter\pgfplots@gobble@until@EOI |
| 621 |
\fi |
| 622 |
{#1}{#2}% |
| 623 |
}% |
| 624 |
|
| 625 |
|
| 626 |
% Discards any token up to (and including) \relax. |
| 627 |
\def\pgfplots@gobble@until@relax#1\relax{}% |
| 628 |
\def\pgfplots@gobble@until@EOI#1\pgfplots@EOI{}% |
| 629 |
|
| 630 |
% A (simple) replacement for \foreach which |
| 631 |
% 1. does NOT scope the argument |
| 632 |
% 2. allows to use PGF Math routines for loops ( '...' notation) |
| 633 |
% instead of TeX registers. |
| 634 |
% |
| 635 |
% Usage: |
| 636 |
% \pgfplotsforeachungrouped \x in {1,2,3,4,5} {<code>} |
| 637 |
% |
| 638 |
% Some details: |
| 639 |
% 1. If #2 is a UNIFORM SAMPLING RANGE, the algorithm is supposed to be |
| 640 |
% most effective. This is considered to be the case for the syntax |
| 641 |
% \pgfplotsforeachungrouped \x in {1,2,...,8}. |
| 642 |
% 2. If case (1.) is not used, \foreach \x in {#2} {} is invoked to |
| 643 |
% generate a temporary list. Afterwards, this list is invoked without |
| 644 |
% scopes. |
| 645 |
% |
| 646 |
% This loop *can* be nested. |
| 647 |
\def\pgfplotsforeachungrouped#1{% |
| 648 |
\pgfutil@ifnextchar/{\pgfplotsforeachungrouped@{#1}}{\pgfplotsforeachungrouped@{#1}/{}}% |
| 649 |
}% |
| 650 |
|
| 651 |
% accept both |
| 652 |
% \pgfplotsforeachungrouped\x in{1,...,5}{a} |
| 653 |
% \pgfplotsforeachungrouped\x in {1,...,5}{a} |
| 654 |
\long\def\pgfplotsforeachungrouped@#1/#2in{% |
| 655 |
\pgfutil@ifnextchar\bgroup{% |
| 656 |
\pgfplotsforeachungrouped@@{#1}{#2}% |
| 657 |
}{% |
| 658 |
\pgfplots@error{Found unexpected characters: expected 'in '.}% |
| 659 |
}% |
| 660 |
} |
| 661 |
|
| 662 |
\long\def\pgfplots@for@reset@break#1{% |
| 663 |
\ifpgffor@continue |
| 664 |
\pgffor@continuetrue |
| 665 |
#1\relax |
| 666 |
\pgffor@continuetrue |
| 667 |
\else |
| 668 |
\pgffor@continuetrue |
| 669 |
#1\relax |
| 670 |
\pgffor@continuefalse |
| 671 |
\fi |
| 672 |
}% |
| 673 |
|
| 674 |
% Defines \pgfplotsretval to contain a 'domain' argument if '#1' is |
| 675 |
% actually a domain listing. In this case, '\pgfplotsretvalb' will be |
| 676 |
% set to the number of samples. |
| 677 |
% |
| 678 |
% If #1 is no valid domain argument, \pgfplotsretval will be set to |
| 679 |
% empty. |
| 680 |
\def\pgfplotsforeachtodomain#1{% |
| 681 |
\begingroup |
| 682 |
\long\def\pgfplotsforeachungroupednonuniform@##1##2##3{% |
| 683 |
\def\pgfplotsretval{}% |
| 684 |
\def\pgfplotsretvalb{}% |
| 685 |
}% |
| 686 |
\long\def\pgfplotsforeachungroupedslashed@##1/##2##3##4{% |
| 687 |
\def\pgfplotsretval{}% |
| 688 |
\def\pgfplotsretvalb{}% |
| 689 |
}% |
| 690 |
\long\def\pgfplotsforeachungroupeduniform@##1##2,##3,...,##4\relax##5{% |
| 691 |
\edef\pgfplotsretval{##2:##4}% |
| 692 |
\pgfkeys{/pgf/fpu}% |
| 693 |
\pgfmathparse{##3-##2}% |
| 694 |
\let\pgfplots@h=\pgfmathresult |
| 695 |
\pgfmathparse{(##4-##2)/\pgfplots@h + 1}% |
| 696 |
\pgfmathfloattofixed\pgfmathresult |
| 697 |
\afterassignment\pgfplotsforeachtodomain@@ |
| 698 |
\c@pgf@counta=\pgfmathresult\relax |
| 699 |
}% |
| 700 |
\edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungrouped \noexpand\x\space in{#1}{}}% |
| 701 |
\pgfplots@loc@TMPa |
| 702 |
% |
| 703 |
\xdef\pgfplots@glob@TMPa{% |
| 704 |
\noexpand\def\noexpand\pgfplotsretval{\pgfplotsretval}% |
| 705 |
\noexpand\def\noexpand\pgfplotsretvalb{\pgfplotsretvalb}% |
| 706 |
}% |
| 707 |
\endgroup |
| 708 |
\pgfplots@glob@TMPa |
| 709 |
}% |
| 710 |
|
| 711 |
\def\pgfplotsforeachtodomain@@.#1\relax{% |
| 712 |
\pgf@xa=0.#1pt % |
| 713 |
\ifdim\pgf@xa>0.01pt % FIXME : threshold is chosen in a bad way... should be relative to number range! |
| 714 |
% this is not an integer! We cannot convert it to a domain. |
| 715 |
\def\pgfplotsretval{}% |
| 716 |
\def\pgfplotsretvalb{}% |
| 717 |
\else |
| 718 |
% ok, it is an integer. Return it as number samples! |
| 719 |
% \pgfplotsretval already contains the domain. |
| 720 |
\edef\pgfplotsretvalb{\the\c@pgf@counta}% |
| 721 |
\fi |
| 722 |
}% |
| 723 |
|
| 724 |
\newif\ifpgfplotsforeachungroupedassumenumeric |
| 725 |
\pgfplotsforeachungroupedassumenumerictrue |
| 726 |
|
| 727 |
\long\def\pgfplotsforeachungrouped@@#1#2#3#4{% |
| 728 |
\pgfplots@for@reset@break{% |
| 729 |
% |
| 730 |
\def\pgfplots@foreach@loc@TMPa{#2}% |
| 731 |
\ifx\pgfplots@foreach@loc@TMPa\pgfutil@empty |
| 732 |
\pgfplotsforeachungrouped@isuniform{#3}% |
| 733 |
\ifpgfplots@loc@tmp |
| 734 |
% special handling: |
| 735 |
% \foreach #1 in {a,b,...,c} can be improved: |
| 736 |
\pgfplotsforeachungroupeduniform@{#1}#3\relax{#4}% |
| 737 |
\else |
| 738 |
\ifpgfplotsforeachungroupedassumenumeric |
| 739 |
\pgfplotsforeachungrouped@isuniform@dist@one{#3}% |
| 740 |
\ifpgfplots@loc@tmp |
| 741 |
% special handling: |
| 742 |
% \foreach #1 in {a,...,n} can be improved. Let us |
| 743 |
% hope it is numeric ... |
| 744 |
\pgfmathifexpression{\pgfplotsretval < \pgfplotsretvalb}{% |
| 745 |
\edef\pgfplots@foreach@loc@TMPa{\pgfplotsretval,\pgfplotsretval+1,...,\pgfplotsretvalb}% |
| 746 |
}{% |
| 747 |
\edef\pgfplots@foreach@loc@TMPa{\pgfplotsretval,\pgfplotsretval-1,...,\pgfplotsretvalb}% |
| 748 |
}% |
| 749 |
\def\pgfplots@foreach@loc@TMPb{\pgfplotsforeachungroupeduniform@{#1}}% |
| 750 |
\expandafter\pgfplots@foreach@loc@TMPb\pgfplots@foreach@loc@TMPa\relax{#4}% |
| 751 |
\else |
| 752 |
% invoke \foreach #1 in {#3} and transport results: |
| 753 |
\pgfplotsforeachungroupednonuniform@#1{#3}{#4}% |
| 754 |
\fi |
| 755 |
\else |
| 756 |
% invoke \foreach #1 in {#3} and transport results: |
| 757 |
\pgfplotsforeachungroupednonuniform@#1{#3}{#4}% |
| 758 |
\fi |
| 759 |
\fi |
| 760 |
\else |
| 761 |
% invoke \foreach #1/#2 in {#3} and transport results: |
| 762 |
\pgfplotsforeachungroupedslashed@#1/#2{#3}{#4}% |
| 763 |
\fi |
| 764 |
}% |
| 765 |
} |
| 766 |
\let\pgfplots@original@pgfmathadd@=\pgfmathadd@ |
| 767 |
|
| 768 |
\long\def\pgfplotsforeachungroupeduniform@#1#2,#3,...,#4\relax#5{% |
| 769 |
% Compute mesh width! |
| 770 |
\pgfmathparse{#2}% |
| 771 |
\let\pgfplots@foreach@loc@TMPa=\pgfmathresult |
| 772 |
\pgfmathparse{#3}% |
| 773 |
\let\pgfplots@foreach@loc@TMPb=\pgfmathresult |
| 774 |
\pgfmathsubtract@{\pgfplots@foreach@loc@TMPb}{\pgfplots@foreach@loc@TMPa}% |
| 775 |
% Use \pgfmath engine for the loop: |
| 776 |
% mesh width: |
| 777 |
\let\pgfplots@foreach@loc@meshwidth=\pgfmathresult |
| 778 |
\pgfmathparse{0}% invoke the parser - in case the fpu is active. |
| 779 |
\pgfmathlessthan@{\pgfplots@foreach@loc@meshwidth}{\pgfmathresult}% |
| 780 |
% the loop will run while ( NOT \pgfplots@foreach@loc@cmp{<cur>}{<last>} ) |
| 781 |
\ifdim\pgfmathresult pt=1pt |
| 782 |
\def\pgfplots@foreach@loc@cmp{\pgfmathlessthan@}% |
| 783 |
\else |
| 784 |
\def\pgfplots@foreach@loc@cmp{\pgfmathgreaterthan@}% |
| 785 |
\fi |
| 786 |
% |
| 787 |
\pgfmathparse{#4 + 0.5*\pgfplots@foreach@loc@meshwidth}% |
| 788 |
\let\pgfplots@foreach@loc@TMPb=\pgfmathresult |
| 789 |
% |
| 790 |
\t@pgfplots@toka={#5}% |
| 791 |
% to allow nesting without additional TeX groups of |
| 792 |
% \pgfplotsforeachungroupeduniform, I introduce this loop |
| 793 |
% structure here which does not need ANY state macro: |
| 794 |
\edef\pgfplots@foreach@loc@TMPc{% |
| 795 |
\noexpand\pgfplotsforeachungroupeduniform@loop@mathengine |
| 796 |
{\expandafter\noexpand\pgfplots@foreach@loc@cmp}% #1= comparison fct |
| 797 |
{\pgfplots@foreach@loc@TMPa}% #2 =lower limit (ITERATES) |
| 798 |
{\pgfplots@foreach@loc@TMPb}% #3 = upper limit |
| 799 |
{\noexpand#1}% #4 = the loop macro name |
| 800 |
{\pgfplots@foreach@loc@meshwidth}% #5 = h |
| 801 |
{\the\t@pgfplots@toka}% #6 = the code to invoke |
| 802 |
{0}% #7 : the loop variable |
| 803 |
}% |
| 804 |
\pgfplots@foreach@loc@TMPc |
| 805 |
}% |
| 806 |
|
| 807 |
% This here is much more accurate and does not suffer from the |
| 808 |
% numerical stability issues of the other loop. |
| 809 |
% |
| 810 |
% #1: comparison fct |
| 811 |
% #2: lower limit |
| 812 |
% #3: upper limit |
| 813 |
% #4: the loop macro name |
| 814 |
% #5: h |
| 815 |
% #6: code to invoke |
| 816 |
% #7: the loop variable (number samples) |
| 817 |
\long\def\pgfplotsforeachungroupeduniform@loop@mathengine@precise#1#2#3#4#5#6#7{% |
| 818 |
\pgflibraryfpuifactive{% |
| 819 |
\pgfmathfloatparsenumber{#7}% |
| 820 |
}{% |
| 821 |
\edef\pgfmathresult{#7}% |
| 822 |
}% |
| 823 |
\expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{#5}% |
| 824 |
\expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#2}% |
| 825 |
\let#4=\pgfmathresult |
| 826 |
#1{#4}{#3}% substitute this by integer arithmetics |
| 827 |
\ifdim\pgfmathresult pt=0pt % |
| 828 |
\def\pgfplotsforeach@loc@TMP@{\pgfutil@in@{.0\relax}}% |
| 829 |
\expandafter\pgfplotsforeach@loc@TMP@\expandafter{#4\relax}% |
| 830 |
\ifpgfutil@in@ |
| 831 |
% ah - our current loop variable has .0 as suffix. |
| 832 |
% Strip it. |
| 833 |
\def\pgfplotsforeach@loc@TMP@##1.0\relax{% |
| 834 |
\def#4{##1}% |
| 835 |
}% |
| 836 |
\expandafter\pgfplotsforeach@loc@TMP@#4\relax |
| 837 |
\fi |
| 838 |
#6\relax |
| 839 |
\def\pgfplotsforeach@loc@TMP@{#7}% |
| 840 |
\pgfplotsutil@advancestringcounter\pgfplotsforeach@loc@TMP@ |
| 841 |
% |
| 842 |
\t@pgfplots@tokc={{#1}{#2}{#3}{#4}{#5}{#6}}% |
| 843 |
% loop! |
| 844 |
\edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungroupeduniform@loop@mathengine |
| 845 |
\the\t@pgfplots@tokc{\pgfplotsforeach@loc@TMP@}}% |
| 846 |
\expandafter\pgfplots@loc@TMPa |
| 847 |
\fi |
| 848 |
}% |
| 849 |
\long\def\pgfplotsforeachungroupeduniform@loop@mathengine@legacy#1#2#3#4#5#6#7{% |
| 850 |
#1{#2}{#3}% |
| 851 |
\ifpgffor@continue |
| 852 |
\ifdim\pgfmathresult pt=0pt |
| 853 |
\pgfutil@in@{.0\relax}{#2\relax}% |
| 854 |
\ifpgfutil@in@ |
| 855 |
\def\pgfplotsforeach@loc@TMP##1.0\relax{% |
| 856 |
\def#4{##1}% |
| 857 |
}% |
| 858 |
\pgfplotsforeach@loc@TMP#2\relax |
| 859 |
\else |
| 860 |
\def#4{#2}% |
| 861 |
\fi |
| 862 |
#6\relax |
| 863 |
\pgfmathadd@{#2}{#5}% |
| 864 |
\t@pgfplots@toka={{#1}}% |
| 865 |
\t@pgfplots@tokb=\expandafter{\pgfmathresult}% |
| 866 |
\t@pgfplots@tokc={{#3}{#4}{#5}{#6}{--}}% |
| 867 |
% loop! |
| 868 |
\edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungroupeduniform@loop@mathengine |
| 869 |
\the\t@pgfplots@toka |
| 870 |
{\the\t@pgfplots@tokb}% |
| 871 |
\the\t@pgfplots@tokc}% |
| 872 |
\expandafter\expandafter\expandafter\pgfplots@loc@TMPa |
| 873 |
\fi |
| 874 |
\fi |
| 875 |
}% |
| 876 |
|
| 877 |
\let\pgfplotsforeachungroupeduniform@loop@mathengine=\pgfplotsforeachungroupeduniform@loop@mathengine@legacy |
| 878 |
|
| 879 |
|
| 880 |
\long\def\pgfplotsforeachungroupednonuniform@#1#2#3{% |
| 881 |
\pgfplotsapplistXXglobalnewempty |
| 882 |
\foreach\pgfplots@foreach@loc@TMPa in {#2} {% |
| 883 |
\expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfplots@foreach@loc@TMPa,}% |
| 884 |
}% |
| 885 |
\pgfplotsapplistXXgloballet\pgfplots@foreach@loc@TMPa |
| 886 |
\pgfplotsapplistXXglobalclear |
| 887 |
\expandafter\pgfplotsforeachentryinCSVisterminated\expandafter\pgfplots@foreach@loc@TMPa\expandafter{\pgfplots@foreach@loc@TMPa}{% |
| 888 |
\let#1=\pgfplots@foreach@loc@TMPa |
| 889 |
#3% |
| 890 |
}% |
| 891 |
} |
| 892 |
\long\def\pgfplotsforeachungroupedslashed@#1/#2#3#4{% |
| 893 |
\pgfplotsapplistXXglobalnewempty |
| 894 |
\foreach\pgfplots@foreach@loc@TMPa/\pgfplots@foreach@loc@TMPb in {#3} {% |
| 895 |
\edef\pgfplots@foreach@loc@TMPa{\pgfplots@foreach@loc@TMPa/\pgfplots@foreach@loc@TMPb}% |
| 896 |
\expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfplots@foreach@loc@TMPa,}% |
| 897 |
}% |
| 898 |
\pgfplotsapplistXXgloballet\pgfplots@foreach@loc@TMPa |
| 899 |
\pgfplotsapplistXXglobalclear |
| 900 |
\expandafter\pgfplotsforeachentryinCSVisterminated\expandafter\pgfplots@foreach@loc@TMPa\expandafter{\pgfplots@foreach@loc@TMPa}{% |
| 901 |
\expandafter\pgfplotsforeachungroupedslashed@@\pgfplots@foreach@loc@TMPa\pgfplots@EOI |
| 902 |
\let#1=\pgfplots@foreach@loc@TMPa |
| 903 |
\let#2=\pgfplots@foreach@loc@TMPb |
| 904 |
#4% |
| 905 |
}% |
| 906 |
} |
| 907 |
\def\pgfplotsforeachungroupedslashed@@#1/#2\pgfplots@EOI{% |
| 908 |
\def\pgfplots@foreach@loc@TMPa{#1}% |
| 909 |
\def\pgfplots@foreach@loc@TMPb{#2}% |
| 910 |
}% |
| 911 |
|
| 912 |
% Sets \ifpgfplots@loc@tmp to true if and only if '#1' is of the form |
| 913 |
% #1 = <number1>,<number2>,...,<number3>. |
| 914 |
\def\pgfplotsforeachungrouped@isuniform#1{% |
| 915 |
\edef\pgfplots@foreach@loc@TMPa{#1}% |
| 916 |
\expandafter\pgfplotsforeachungrouped@isuniform@\pgfplots@foreach@loc@TMPa,,,,\relax |
| 917 |
}% |
| 918 |
\def\pgfplotsforeachungrouped@isuniform@#1,#2,#3,#4,#5\relax{% |
| 919 |
\def\pgfplots@foreach@loc@TMPa{#5}% |
| 920 |
\def\pgfplots@foreach@loc@TMPb{,,,}% |
| 921 |
\pgfplots@loc@tmpfalse |
| 922 |
\ifx\pgfplots@foreach@loc@TMPa\pgfplots@foreach@loc@TMPb |
| 923 |
\def\pgfplots@foreach@loc@TMPa{#3}% |
| 924 |
\def\pgfplots@foreach@loc@TMPb{...}% |
| 925 |
\ifx\pgfplots@foreach@loc@TMPa\pgfplots@foreach@loc@TMPb |
| 926 |
\pgfutil@in@,{#4}% |
| 927 |
\ifpgfutil@in@ |
| 928 |
\else |
| 929 |
% ok, we REALLY have a uniform range! |
| 930 |
\pgfplots@loc@tmptrue |
| 931 |
\fi |
| 932 |
\fi |
| 933 |
\fi |
| 934 |
}% |
| 935 |
|
| 936 |
% Sets \ifpgfplots@loc@tmp to true if and only if '#1' is of the form |
| 937 |
% #1 = <number1>,...,<number2> |
| 938 |
% |
| 939 |
% In that case, \pgfplotsretval = <number1> and \pgfplotsretvalb = <number2> |
| 940 |
\def\pgfplotsforeachungrouped@isuniform@dist@one#1{% |
| 941 |
\edef\pgfplots@foreach@loc@TMPa{#1}% |
| 942 |
\expandafter\pgfplotsforeachungrouped@isuniform@dist@one@\pgfplots@foreach@loc@TMPa,,,\relax |
| 943 |
}% |
| 944 |
\def\pgfplotsforeachungrouped@isuniform@dist@one@#1,#2,#3,#4\relax{% |
| 945 |
\def\pgfplots@foreach@loc@TMPa{#4}% |
| 946 |
\def\pgfplots@foreach@loc@TMPb{,,}% |
| 947 |
\pgfplots@loc@tmpfalse |
| 948 |
\ifx\pgfplots@foreach@loc@TMPa\pgfplots@foreach@loc@TMPb |
| 949 |
\def\pgfplots@foreach@loc@TMPa{#2}% |
| 950 |
\def\pgfplots@foreach@loc@TMPb{...}% |
| 951 |
\ifx\pgfplots@foreach@loc@TMPa\pgfplots@foreach@loc@TMPb |
| 952 |
\pgfutil@in@,{#3}% |
| 953 |
\ifpgfutil@in@ |
| 954 |
\else |
| 955 |
\pgfplots@loc@tmptrue |
| 956 |
\def\pgfplotsretval{#1}% |
| 957 |
\def\pgfplotsretvalb{#3}% |
| 958 |
\fi |
| 959 |
\fi |
| 960 |
\fi |
| 961 |
}% |
| 962 |
|
| 963 |
|
| 964 |
% A variant of \pgfplotsforeachungrouped ( or \foreach ) which |
| 965 |
% *invokes* with #1 set to the current iterate. |
| 966 |
% |
| 967 |
% Example: |
| 968 |
% \pgfplotsinvokeforeach{a,b,c,d} |
| 969 |
% {\pgfkeys{key #1/.style={otherstyle #1}}} |
| 970 |
% -> will invoke |
| 971 |
% \pgfkeys{key a/.style={otherstyle a}} |
| 972 |
% \pgfkeys{key b/.style={otherstyle b}} |
| 973 |
% \pgfkeys{key c/.style={otherstyle c}} |
| 974 |
% \pgfkeys{key d/.style={otherstyle d}} |
| 975 |
% Note that \pgfplotsforeachungrouped \d in {a,b,c,d} |
| 976 |
% {\pgfkeys{key \d/.style={}}} |
| 977 |
% would not work: |
| 978 |
% \pgfkeys{key a/.style={otherstyle \d}} |
| 979 |
% \pgfkeys{key b/.style={otherstyle \d}} |
| 980 |
% \pgfkeys{key c/.style={otherstyle \d}} |
| 981 |
% \pgfkeys{key d/.style={otherstyle \d}} |
| 982 |
% such an application would need expansion control. |
| 983 |
% |
| 984 |
% #1: the iterates. Can be any argument as you would supply it to |
| 985 |
% \foreach, for example \foreach \x in {1,2,...,10} |
| 986 |
% -> #1 = {1,2,...,10} |
| 987 |
% #2: the loop body. It can contain the parameter string '#1' which |
| 988 |
% will be set to each element in the iterates list in turn. |
| 989 |
% |
| 990 |
% This method is actually just a light-weight adapter around |
| 991 |
% \pgfplotsforeachungrouped. |
| 992 |
\long\def\pgfplotsinvokeforeach#1#2{% |
| 993 |
\long\def\pgfplotsinvokeforeach@@##1{#2}% |
| 994 |
\pgfplotsforeachungrouped \pgfplotsinvokeforeach@ in {#1} {% |
| 995 |
\expandafter\pgfplotsinvokeforeach@@\expandafter{\pgfplotsinvokeforeach@}% |
| 996 |
}% |
| 997 |
} |
| 998 |
|
| 999 |
% Allows to provide an output routine for |
| 1000 |
% \pgfplotsforeachlogarithmicungrouped which changes the number format |
| 1001 |
% of \pgfmathresult. |
| 1002 |
% |
| 1003 |
% Example: |
| 1004 |
% \pgfplotsforeachlogarithmicformatresultwith{\pgfmathfloattofixed{\pgfmathresult}} |
| 1005 |
% |
| 1006 |
% #1: is code which modifies \pgfmathresult. |
| 1007 |
\def\pgfplotsforeachlogarithmicformatresultwith#1{% |
| 1008 |
\def\pgfplotsforeachlogarithmicungrouped@finalizeresult{#1}% |
| 1009 |
} |
| 1010 |
|
| 1011 |
% \pgfplotsforeachlogarithmicungrouped[<samples>] \x/\logx in {a:b} {#3} |
| 1012 |
% \pgfplotsforeachlogarithmicungrouped[<samples>][<math id>] \x/\logx in {a:b} {#3} |
| 1013 |
% |
| 1014 |
% samples \x between a and b using a logarithmic scale. |
| 1015 |
% |
| 1016 |
% During '#3', \x will contain the sample and \logx the logarithm of |
| 1017 |
% \x. |
| 1018 |
% |
| 1019 |
% Both, #1 and #2 will be provided as floating point numbers unless |
| 1020 |
% configured otherwise with \pgfplotsforeachlogarithmicsetoutput, |
| 1021 |
% see above. |
| 1022 |
% |
| 1023 |
% Arithmethics will be carried out with the math class '<math id>' |
| 1024 |
% (defaults to '\pgfplotsforeachlogarithmicmathid'). |
| 1025 |
% This macro should expand to something which is usable inside of |
| 1026 |
% \pgfplotscoordmath{<math id>}{....} |
| 1027 |
% the default is 'float' |
| 1028 |
% |
| 1029 |
% FIXME : THIS CAN'T BE NESTED YET! |
| 1030 |
\def\pgfplotsforeachlogarithmicungrouped[#1]{% |
| 1031 |
\pgfutil@ifnextchar[{% |
| 1032 |
\pgfplotsforeachlogarithmicungrouped@[#1]% |
| 1033 |
}{% |
| 1034 |
\pgfplotsforeachlogarithmicungrouped@[#1][\pgfplotsforeachlogarithmicmathid]% |
| 1035 |
}% |
| 1036 |
}% |
| 1037 |
\def\pgfplotsforeachlogarithmicungrouped@[#1][#2]#3/#4{\pgfplotsforeachlogarithmicungrouped@@[#1][#2]{#3}{#4}}% |
| 1038 |
\long\def\pgfplotsforeachlogarithmicungrouped@@[#1][#2]#3#4in #5#6{% |
| 1039 |
% define |
| 1040 |
% \pgfplots@foreachlog@loc@TMPd = N in fixed point |
| 1041 |
% \pgfplots@foreachlog@loc@TMPc = N-1 in float : |
| 1042 |
\edef\pgfplots@plot@samples@@{#1}% |
| 1043 |
\pgfplotscoordmath{#2}{one}% |
| 1044 |
\let\pgfplots@foreachlog@loc@TMPa=\pgfmathresult |
| 1045 |
\pgfplotscoordmath{#2}{parsenumber}{\pgfplots@plot@samples@@}% |
| 1046 |
\pgfplotscoordmath{#2}{op}{subtract}{{\pgfmathresult}{\pgfplots@foreachlog@loc@TMPa}}% |
| 1047 |
\let\pgfplots@foreachlog@loc@TMPc=\pgfmathresult |
| 1048 |
% |
| 1049 |
\edef\pgfplots@loc@TMPb{#5}% |
| 1050 |
\expandafter\pgfplotsforeachlogarithmicungrouped@readdomain\pgfplots@loc@TMPb\relax{#2}% |
| 1051 |
\pgfplotscoordmath{#2}{if is bounded}{\pgfplots@foreachlog@loc@TMPb}{% |
| 1052 |
}{% |
| 1053 |
\pgfplotsforeachlogarithmicmath@unbounded@domain{#5}% |
| 1054 |
\pgfplotscoordmath{#2}{parsenumber}{-10000}% |
| 1055 |
\let\pgfplots@foreachlog@loc@TMPb=\pgfmathresult |
| 1056 |
}% |
| 1057 |
\pgfplotscoordmath{#2}{if is bounded}{\pgfplots@foreachlog@loc@TMPa}{% |
| 1058 |
}{% |
| 1059 |
\pgfplotsforeachlogarithmicmath@unbounded@domain{#5}% |
| 1060 |
\pgfplotscoordmath{#2}{parsenumber}{-10000}% |
| 1061 |
\let\pgfplots@foreachlog@loc@TMPa=\pgfmathresult |
| 1062 |
}% |
| 1063 |
% compute mesh width into \pgfplots@foreachlog@loc@TMPc: |
| 1064 |
% \pgfplots@foreachlog@loc@TMPc := h := ( log(xmax) - log(xmin) ) / (N-1) |
| 1065 |
\pgfplotscoordmath{#2}{op}{subtract}{{\pgfplots@foreachlog@loc@TMPb}{\pgfplots@foreachlog@loc@TMPa}}% |
| 1066 |
\pgfplotscoordmath{#2}{op}{divide}{{\pgfmathresult}{\pgfplots@foreachlog@loc@TMPc}}% |
| 1067 |
\let\pgfplots@foreachlog@loc@TMPc=\pgfmathresult |
| 1068 |
% |
| 1069 |
% apply local scoping here: |
| 1070 |
\edef\pgfplots@foreachlog@loc@TMPd{% |
| 1071 |
\noexpand\c@pgf@counta=\the\c@pgf@counta\noexpand\relax |
| 1072 |
}% |
| 1073 |
\long\def\pgfplots@foreachlog@loc@TMPf{#6}% |
| 1074 |
\c@pgf@counta=0 |
| 1075 |
\pgfutil@loop |
| 1076 |
\ifnum\c@pgf@counta<\pgfplots@plot@samples@@ |
| 1077 |
% compute exp(log(min) + i * h) |
| 1078 |
\edef\pgfplots@loc@TMPa{\the\c@pgf@counta}% |
| 1079 |
\pgfplotscoordmath{#2}{parsenumber}{\pgfplots@loc@TMPa}% |
| 1080 |
\pgfplotscoordmath{#2}{op}{multiply}{{\pgfmathresult}{\pgfplots@foreachlog@loc@TMPc}}% |
| 1081 |
\pgfplotscoordmath{#2}{op}{add}{{\pgfmathresult}{\pgfplots@foreachlog@loc@TMPa}}% |
| 1082 |
\let\pgfplots@loc@TMPa=\pgfmathresult |
| 1083 |
\pgfplotsforeachlogarithmicungrouped@finalizeresult% |
| 1084 |
\let#4=\pgfmathresult |
| 1085 |
\pgfplotscoordmath{#2}{exp}{\pgfplots@loc@TMPa}% |
| 1086 |
\pgfplotsforeachlogarithmicungrouped@finalizeresult% |
| 1087 |
\let#3=\pgfmathresult |
| 1088 |
% |
| 1089 |
% ok, invoke it! |
| 1090 |
% -> store \c@pgf@counta before doing so. We need to scope |
| 1091 |
% manually here. |
| 1092 |
\edef\pgfplots@foreachlog@loc@TMPe{\the\c@pgf@counta}% |
| 1093 |
\pgfplots@foreachlog@loc@TMPf\relax |
| 1094 |
\c@pgf@counta=\pgfplots@foreachlog@loc@TMPe\relax |
| 1095 |
\advance\c@pgf@counta by 1 |
| 1096 |
\pgfutil@repeat |
| 1097 |
% restore scoped variables: |
| 1098 |
\pgfplots@foreachlog@loc@TMPd |
| 1099 |
} |
| 1100 |
|
| 1101 |
\def\pgfplotsforeachlogarithmicmath@unbounded@domain#1{% |
| 1102 |
\pgfplots@error{Sorry, the provided domain #1 is unsuitable for logarithmic sampling (applying the log results in unbounded values)}% |
| 1103 |
}% |
| 1104 |
|
| 1105 |
% can be used to convert the number format from float to something |
| 1106 |
% else. |
| 1107 |
\def\pgfplotsforeachlogarithmicungrouped@finalizeresult{}% |
| 1108 |
|
| 1109 |
|
| 1110 |
\def\pgfplotsforeachlogarithmicmathid{float} |
| 1111 |
|
| 1112 |
% defines |
| 1113 |
% \pgfplots@foreachlog@loc@TMPa := log(firstintervalpt) |
| 1114 |
% and |
| 1115 |
% \pgfplots@foreachlog@loc@TMPb := log(secondintervalpt) |
| 1116 |
\def\pgfplotsforeachlogarithmicungrouped@readdomain#1:#2\relax#3{% |
| 1117 |
\pgfplotscoordmath{default}{parse}{#1}% |
| 1118 |
\pgfplotscoordmath{#3}{log}{\pgfmathresult}% |
| 1119 |
\let\pgfplots@foreachlog@loc@TMPa=\pgfmathresult |
| 1120 |
\pgfplotscoordmath{default}{parse}{#2}% |
| 1121 |
\pgfplotscoordmath{#3}{log}{\pgfmathresult}% |
| 1122 |
\let\pgfplots@foreachlog@loc@TMPb=\pgfmathresult |
| 1123 |
} |
| 1124 |
|
| 1125 |
% invokes '#2' if #1 expands (\edef) to the empty string or '#3' if not. |
| 1126 |
\def\pgfplots@ifempty#1#2#3{% |
| 1127 |
\edef\pgfplots@loc@TMPa{#1}% |
| 1128 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty #2\else #3\fi |
| 1129 |
}% |
| 1130 |
|
| 1131 |
{ |
| 1132 |
\catcode`\#=12 |
| 1133 |
\catcode`\1=12 |
| 1134 |
\gdef\pgfplotsutil@add@to@macro@@one{#1}% |
| 1135 |
\gdef\pgfplotsutil@add@to@macro@@two{#1#2}% |
| 1136 |
} |
| 1137 |
|
| 1138 |
\def\pgfplotsutil@ifmacrodependsononearg#1#2#3{% |
| 1139 |
\edef\pgfplots@loc@TMPa{\noexpand\pgfutil@in@{\pgfplotsutil@add@to@macro@@one}{\meaning#1}}% |
| 1140 |
\pgfplots@loc@TMPa |
| 1141 |
\ifpgfutil@in@ |
| 1142 |
#2% |
| 1143 |
\else |
| 1144 |
#3% |
| 1145 |
\fi |
| 1146 |
}% |
| 1147 |
|
| 1148 |
\def\pgfplotsutil@ifmacrodependsontwoargs#1#2#3{% |
| 1149 |
\edef\pgfplots@util@add@to@macro@@{\noexpand\pgfutil@in@{\pgfplotsutil@add@to@macro@@two}{\meaning#1}}% |
| 1150 |
\pgfplots@util@add@to@macro@@ |
| 1151 |
\ifpgfutil@in@ |
| 1152 |
#2% |
| 1153 |
\else |
| 1154 |
#3% |
| 1155 |
\fi |
| 1156 |
}% |
| 1157 |
|
| 1158 |
% Appends '#2' to macro '#1'. |
| 1159 |
% |
| 1160 |
% #1: a macro which takes either no arguments or exactly one. |
| 1161 |
% #2: some token text. May depend on '#1' if #1 is a macro which |
| 1162 |
% depends on one arg. |
| 1163 |
\def\pgfplotsutil@add@to@macro#1#2{% |
| 1164 |
\pgfplotsutil@ifmacrodependsononearg#1{% |
| 1165 |
\pgfplotsutil@ifmacrodependsontwoargs#1{% |
| 1166 |
\pgfplotsutil@add@to@macro@twoargs{#1}{#2}% |
| 1167 |
}{% |
| 1168 |
\pgfplotsutil@add@to@macro@onearg{#1}{#2}% |
| 1169 |
}% |
| 1170 |
}{% |
| 1171 |
\pgfplotsutil@add@to@macro@noargs{#1}{#2}% |
| 1172 |
}% |
| 1173 |
}% |
| 1174 |
|
| 1175 |
\def\pgfplotsutil@add@to@macro@twoargs#1#2{% |
| 1176 |
\t@pgfplots@tokc=\expandafter{#1{##1}{##2}}% |
| 1177 |
\t@pgfplots@tokb={#2}% |
| 1178 |
\edef\pgfplots@util@add@to@macro@@{\the\t@pgfplots@tokc\the\t@pgfplots@tokb}% |
| 1179 |
\expandafter\def\expandafter#1\expandafter##\expandafter1\expandafter##\expandafter2\expandafter{\pgfplots@util@add@to@macro@@}% |
| 1180 |
} |
| 1181 |
|
| 1182 |
\def\pgfplotsutil@add@to@macro@onearg#1#2{% |
| 1183 |
\t@pgfplots@tokc=\expandafter{#1{##1}}% |
| 1184 |
\t@pgfplots@tokb={#2}% |
| 1185 |
\edef\pgfplots@util@add@to@macro@@{\the\t@pgfplots@tokc\the\t@pgfplots@tokb}% |
| 1186 |
\expandafter\def\expandafter#1\expandafter##\expandafter1\expandafter{\pgfplots@util@add@to@macro@@}% |
| 1187 |
} |
| 1188 |
|
| 1189 |
\def\pgfplotsutil@add@to@macro@noargs#1#2{% |
| 1190 |
\t@pgfplots@tokc=\expandafter{#1}% |
| 1191 |
\t@pgfplots@tokb=\expandafter{#2}% |
| 1192 |
\edef#1{\the\t@pgfplots@tokc\the\t@pgfplots@tokb}% |
| 1193 |
} |
| 1194 |
\def\pgfplots@logfileopen#1{% |
| 1195 |
\immediate\write-1{PGFPlots: reading {#1}}% |
| 1196 |
\pgfutil@IfUndefined{tikzifexternalizingcurrent}{% |
| 1197 |
% version not up-to-date or external lib not loaded? |
| 1198 |
}{% |
| 1199 |
% adjust the .dep file only if we are externalizing. |
| 1200 |
% Otherwise, it may be overwritten by \pgfplotstableread |
| 1201 |
% commands which are *before* the tikzpicture (and the picture |
| 1202 |
% will be replaced by its graphics) |
| 1203 |
\tikzifexternalizingcurrent{\tikzpicturedependsonfile{#1}}{}% |
| 1204 |
}% |
| 1205 |
}% |
| 1206 |
|
| 1207 |
% Expands #2 using \edef and invokes #1 with the resulting string. |
| 1208 |
% |
| 1209 |
% DEPRECATED |
| 1210 |
% Example: |
| 1211 |
% \pgf@xa=7.9pt |
| 1212 |
% \pgfplotsutil@edef@invoke\pgfmathexp@{{\pgf@sys@tonumber{\pgf@xa}}}% |
| 1213 |
% will invoke |
| 1214 |
% \pgfmathexp@{7.9} |
| 1215 |
\def\pgfplotsutil@edef@invoke#1#2{% |
| 1216 |
\edef\pgfutil@edef@invoke@{#2}% |
| 1217 |
\expandafter#1\pgfutil@edef@invoke@ |
| 1218 |
} |
| 1219 |
|
| 1220 |
% defines \pgfmathresult to be the INTEGER result of (#1 mod #2). |
| 1221 |
% |
| 1222 |
% \pgfplotsmathmod{2}{4} -> 2 |
| 1223 |
% \pgfplotsmathmod{9}{5} -> 4 |
| 1224 |
\def\pgfplotsmathmodint#1#2{% |
| 1225 |
\begingroup |
| 1226 |
\c@pgf@counta=#2\relax |
| 1227 |
\c@pgf@countb=#1\relax |
| 1228 |
\ifnum\c@pgf@counta=2 |
| 1229 |
\ifodd\c@pgf@countb |
| 1230 |
\def\pgfmathresult{1}% |
| 1231 |
\else |
| 1232 |
\def\pgfmathresult{0}% |
| 1233 |
\fi |
| 1234 |
\else |
| 1235 |
\c@pgf@countc=\c@pgf@countb |
| 1236 |
\ifnum\c@pgf@counta=0 |
| 1237 |
\pgfplots@error{Can't compute \the\c@pgf@countb\space mod \the\c@pgf@counta\space -- this yields division by zero (second argument is zero)!}% |
| 1238 |
\edef\pgfmathresult{#1}% |
| 1239 |
\else |
| 1240 |
\divide\c@pgf@countc by\c@pgf@counta |
| 1241 |
\multiply\c@pgf@countc by\c@pgf@counta |
| 1242 |
\advance\c@pgf@countb by-\c@pgf@countc |
| 1243 |
\edef\pgfmathresult{\the\c@pgf@countb}% |
| 1244 |
\fi |
| 1245 |
\fi |
| 1246 |
\pgfmath@smuggleone\pgfmathresult |
| 1247 |
\endgroup |
| 1248 |
}% |
| 1249 |
|
| 1250 |
% Advances a number stored in a macro and writes the result back into |
| 1251 |
% the macro. |
| 1252 |
% #1 is a macro containing a number. |
| 1253 |
\def\pgfplotsutil@advancestringcounter#1{% |
| 1254 |
\begingroup |
| 1255 |
\c@pgf@counta=#1\relax |
| 1256 |
\advance\c@pgf@counta by1 |
| 1257 |
\edef#1{\the\c@pgf@counta}% |
| 1258 |
\pgfmath@smuggleone#1% |
| 1259 |
\endgroup |
| 1260 |
}% |
| 1261 |
\def\pgfplotsutil@advancestringcounter@global#1{% |
| 1262 |
\begingroup |
| 1263 |
\c@pgf@counta=#1\relax |
| 1264 |
\advance\c@pgf@counta by1 |
| 1265 |
\xdef#1{\the\c@pgf@counta}% |
| 1266 |
\endgroup |
| 1267 |
}% |
| 1268 |
|
| 1269 |
\newif\ifpgfplotsloopcontinue |
| 1270 |
|
| 1271 |
% A loop construct which invokes '#1' and continues the loop if the |
| 1272 |
% boolean \ifpgfplotsloopcontinue is true and stops if it is false. |
| 1273 |
% |
| 1274 |
% #1: a statement which is expected to set \ifpgfplotsloopcontinue |
| 1275 |
% #2: the loop body. |
| 1276 |
\def\pgfplotsloop#1#2{% |
| 1277 |
#1\relax |
| 1278 |
\ifpgfplotsloopcontinue |
| 1279 |
#2\relax |
| 1280 |
\def\pgfplotsloop@{\pgfplotsloop{#1}{#2}}% |
| 1281 |
\expandafter\pgfplotsloop@ |
| 1282 |
\fi |
| 1283 |
}% |
| 1284 |
|
| 1285 |
% String comparison of '#1' and '#2'. |
| 1286 |
% Defines |
| 1287 |
% \pgfplotsretval=0 if #1 == #2 |
| 1288 |
% \pgfplotsretval=1 if #1 < #2 |
| 1289 |
% \pgfplotsretval=2 if #1 > #2 |
| 1290 |
\def\pgfplotsutilstrcmp#1#2{% |
| 1291 |
\begingroup |
| 1292 |
\def\pgfplots@strcmp@arga{#1}% |
| 1293 |
\pgfplots@command@to@string\pgfplots@strcmp@arga\pgfplots@strcmp@arga |
| 1294 |
\def\pgfplots@strcmp@argb{#2}% |
| 1295 |
\pgfplots@command@to@string\pgfplots@strcmp@argb\pgfplots@strcmp@argb |
| 1296 |
% |
| 1297 |
% |
| 1298 |
\def\pgfplotsretval{0}% |
| 1299 |
% |
| 1300 |
\pgfplotsloop{% |
| 1301 |
\if0\pgfplotsretval |
| 1302 |
% get next token of arga: |
| 1303 |
\expandafter\pgfplotsutilstrcmp@popfront\pgfplots@strcmp@arga\relax\relax |
| 1304 |
\let\pgfplots@strcmp@arga=\pgfplots@strcmp@rest |
| 1305 |
\let\pgfplots@strcmp@arga@=\pgfplots@strcmp@cur |
| 1306 |
% |
| 1307 |
% get next token of argb: |
| 1308 |
\expandafter\pgfplotsutilstrcmp@popfront\pgfplots@strcmp@argb\relax\relax |
| 1309 |
\let\pgfplots@strcmp@argb=\pgfplots@strcmp@rest |
| 1310 |
\let\pgfplots@strcmp@argb@=\pgfplots@strcmp@cur |
| 1311 |
% |
| 1312 |
% if one of them is empty: set retval and break loop. |
| 1313 |
\ifx\pgfplots@strcmp@arga@\pgfplotsutilstrcmp@relaxtext |
| 1314 |
\ifx\pgfplots@strcmp@argb@\pgfplotsutilstrcmp@relaxtext |
| 1315 |
\else |
| 1316 |
\def\pgfplotsretval{1}% |
| 1317 |
\fi |
| 1318 |
\pgfplotsloopcontinuefalse |
| 1319 |
\else |
| 1320 |
\ifx\pgfplots@strcmp@argb@\pgfplotsutilstrcmp@relaxtext |
| 1321 |
\def\pgfplotsretval{2}% |
| 1322 |
\pgfplotsloopcontinuefalse |
| 1323 |
\else |
| 1324 |
\pgfplotsloopcontinuetrue |
| 1325 |
\fi |
| 1326 |
\fi |
| 1327 |
\else |
| 1328 |
\pgfplotsloopcontinuefalse |
| 1329 |
\fi |
| 1330 |
}{% |
| 1331 |
% |
| 1332 |
\ifnum\expandafter`\pgfplots@strcmp@arga@<\expandafter`\pgfplots@strcmp@argb@ |
| 1333 |
\def\pgfplotsretval{1}% |
| 1334 |
\let\pgfplots@strcmp@arga=\pgfutil@empty |
| 1335 |
\else |
| 1336 |
\ifnum\expandafter`\pgfplots@strcmp@arga@>\expandafter`\pgfplots@strcmp@argb@ |
| 1337 |
\def\pgfplotsretval{2}% |
| 1338 |
\let\pgfplots@strcmp@arga=\pgfutil@empty |
| 1339 |
\fi |
| 1340 |
\fi |
| 1341 |
}% |
| 1342 |
% |
| 1343 |
\pgfmath@smuggleone\pgfplotsretval |
| 1344 |
\endgroup |
| 1345 |
}% |
| 1346 |
\def\pgfplotsutilstrcmp@relaxtext{\relax}% |
| 1347 |
\def\pgfplotsutilstrcmp@popfront#1#2\relax{% |
| 1348 |
\def\pgfplots@strcmp@cur{#1}% |
| 1349 |
\def\pgfplots@strcmp@rest{#2}% |
| 1350 |
}% |
| 1351 |
|
| 1352 |
% Takes two dimensional cartesian coordinates #1,#2 and |
| 1353 |
% defines the macros #3 and #4 to contain the associated polar |
| 1354 |
% coordinates. |
| 1355 |
% |
| 1356 |
% #1: x |
| 1357 |
% #2: y |
| 1358 |
% #3: a macro which will be filled with the angle (in degrees) |
| 1359 |
% #4: a macro which will be filled with the radius |
| 1360 |
\def\pgfplotsmathcarttopol#1#2#3#4{% |
| 1361 |
\pgfplotsmathcarttopol@{#1}{#2}{#3}{#4}{default}% |
| 1362 |
}% |
| 1363 |
\def\pgfplotsmathcarttopolbasic#1#2#3#4{% |
| 1364 |
\pgfplotsmathcarttopol@{#1}{#2}{#3}{#4}{pgfbasic}% |
| 1365 |
}% |
| 1366 |
% #5: the math engine to use (\pgfplotscoordmath argument) |
| 1367 |
\def\pgfplotsmathcarttopol@#1#2#3#4#5{% |
| 1368 |
\begingroup |
| 1369 |
\pgfplotscoordmath{#5}{parsenumber}{#1}% |
| 1370 |
\let\pgfplots@x=\pgfmathresult |
| 1371 |
\pgfplotscoordmath{#5}{parsenumber}{#2}% |
| 1372 |
\let\pgfplots@y=\pgfmathresult |
| 1373 |
\pgfplotscoordmath{#5}{op}{veclen}{{\pgfplots@x}{\pgfplots@y}}% |
| 1374 |
\let\pgfplots@r=\pgfmathresult |
| 1375 |
\pgfplotscoordmath{#5}{op}{atan2}{{\pgfplots@y}{\pgfplots@x}}% |
| 1376 |
\let\pgfplots@deg=\pgfmathresult |
| 1377 |
\xdef\pgfplots@glob@TMPa{\noexpand\def\noexpand#3{\pgfplots@deg}\noexpand\def\noexpand#4{\pgfplots@r}}% |
| 1378 |
\endgroup |
| 1379 |
\pgfplots@glob@TMPa |
| 1380 |
}% |
| 1381 |
|
| 1382 |
% Takes two dimensional polar coordinates #1,#2 and |
| 1383 |
% defines the macros #3 and #4 to contain the associated cartesian |
| 1384 |
% coordinates. |
| 1385 |
% |
| 1386 |
% #1: angle (in degrees) |
| 1387 |
% #2: radius |
| 1388 |
% #3: a macro which will be filled with the x value |
| 1389 |
% #4: a macro which will be filled with the y value |
| 1390 |
\def\pgfplotsmathpoltocart#1#2#3#4{% |
| 1391 |
\pgfplotsmathpoltocart@{#1}{#2}{#3}{#4}{default}% |
| 1392 |
}% |
| 1393 |
\def\pgfplotsmathpoltocartbasic#1#2#3#4{% |
| 1394 |
\pgfplotsmathpoltocart@{#1}{#2}{#3}{#4}{pgfbasic}% |
| 1395 |
}% |
| 1396 |
% #5: the math engine to use (\pgfplotscoordmath argument) |
| 1397 |
\def\pgfplotsmathpoltocart@#1#2#3#4#5{% |
| 1398 |
\begingroup |
| 1399 |
\pgfplotscoordmath{#5}{parsenumber}{#1}% |
| 1400 |
\let\pgfplots@deg=\pgfmathresult |
| 1401 |
\pgfplotscoordmath{#5}{parsenumber}{#2}% |
| 1402 |
\let\pgfplots@r=\pgfmathresult |
| 1403 |
\pgfplotscoordmath{#5}{op}{sin}{{\pgfplots@deg}}% |
| 1404 |
\pgfplotscoordmath{#5}{op}{multiply}{{\pgfplots@r}{\pgfmathresult}}% |
| 1405 |
\let\pgfplots@y=\pgfmathresult |
| 1406 |
\pgfplotscoordmath{#5}{op}{cos}{{\pgfplots@deg}}% |
| 1407 |
\pgfplotscoordmath{#5}{op}{multiply}{{\pgfplots@r}{\pgfmathresult}}% |
| 1408 |
\let\pgfplots@x=\pgfmathresult |
| 1409 |
\xdef\pgfplots@glob@TMPa{\noexpand\def\noexpand#3{\pgfplots@x}\noexpand\def\noexpand#4{\pgfplots@y}}% |
| 1410 |
\endgroup |
| 1411 |
\pgfplots@glob@TMPa |
| 1412 |
}% |
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
\pgfutil@IfUndefined{pgfmathdeclarefunction}{% |
| 1417 |
% BACKWARDS COMPATIBILITY: We have PGF 2.00 : |
| 1418 |
\def\pgfplotsmathdeclarepseudoconstant#1#2{% |
| 1419 |
\t@pgfplots@toka=\expandafter{\csname pgfmath#1@\endcsname}% |
| 1420 |
\t@pgfplots@tokb={\pgfmath@postfunction}% |
| 1421 |
\expandafter\edef\csname pgfmath@parsefunction@#1\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% |
| 1422 |
\expandafter\edef\csname pgfmath#1\endcsname{\the\t@pgfplots@toka}% |
| 1423 |
\expandafter\def\csname pgfmath#1@\endcsname{#2}% |
| 1424 |
}% |
| 1425 |
\let\pgfplotsmathredeclarepseudoconstant=\pgfplotsmathdeclarepseudoconstant |
| 1426 |
}{% |
| 1427 |
\def\pgfplotsmathdeclarepseudoconstant#1#2{% |
| 1428 |
\pgfmathdeclarefunction*{#1}{0}{#2}% |
| 1429 |
}% |
| 1430 |
\def\pgfplotsmathredeclarepseudoconstant#1#2{% |
| 1431 |
\pgfmathredeclarefunction{#1}{#2}% |
| 1432 |
}% |
| 1433 |
}% |
| 1434 |
|
| 1435 |
\def\pgfplotsmathfloatln@#1{% |
| 1436 |
\pgfmathfloatln@{#1}% |
| 1437 |
} |
| 1438 |
|
| 1439 |
% Defines a macro which computes ln(x)/ln(#2) in float. |
| 1440 |
% |
| 1441 |
% #1: a macro name without backslash |
| 1442 |
% #2: the log base as fixed point number. Maybe the empty string in |
| 1443 |
% which case the natural log is used. |
| 1444 |
% |
| 1445 |
% It will define the macros: |
| 1446 |
% <macro>##1 -> calls \pgfmathfloatparsenumber and then the '@' variant: |
| 1447 |
% <macro>@##1 -> expects and returns result in float |
| 1448 |
% <macro>@tofixed##1 -> expects result in float, returns it in fixed (or an empty string) |
| 1449 |
% <macro>inv@##1 -> the inverse (exponential) function, expects float, returns float |
| 1450 |
% % |
| 1451 |
% <macro>logbase -> the basis as number |
| 1452 |
% <macro>logofbasefixed -> log(#2) |
| 1453 |
% <macro>invlogofbasefixed -> 1/log(#2) |
| 1454 |
% <macro>logofbasefloat -> log(#2) in float |
| 1455 |
% <macro>invlogofbasefloat -> 1/log(#2) in float |
| 1456 |
\def\pgfplotsmathdefinemacrolnbase#1#2{% |
| 1457 |
\expandafter\edef\csname #1logbase\endcsname{#2}% |
| 1458 |
\expandafter\ifx\csname #1logbase\endcsname\pgfutil@empty |
| 1459 |
\expandafter\edef\csname #1logbase\endcsname{2.718281828459}% |
| 1460 |
\expandafter\def\csname #1logofbasefixed\endcsname{1}% |
| 1461 |
\expandafter\def\csname #1invlogofbasefixed\endcsname{1}% |
| 1462 |
\else |
| 1463 |
\pgfmathlog@{\csname #1logbase\endcsname}% |
| 1464 |
\expandafter\let\csname #1logofbasefixed\endcsname\pgfmathresult% |
| 1465 |
\expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% |
| 1466 |
\expandafter\let\csname #1invlogofbasefixed\endcsname\pgfmathresult% |
| 1467 |
\fi |
| 1468 |
% |
| 1469 |
\pgfmathfloatparsenumber{\csname #1logofbasefixed\endcsname}% |
| 1470 |
\expandafter\let\csname #1logofbasefloat\endcsname\pgfmathresult% |
| 1471 |
\pgfmathfloatparsenumber{\csname #1invlogofbasefixed\endcsname}% |
| 1472 |
\expandafter\let\csname #1invlogofbasefloat\endcsname\pgfmathresult% |
| 1473 |
% |
| 1474 |
\expandafter\def\csname #1@tofixed\endcsname##1{% |
| 1475 |
\pgfmathlog@float{##1}% |
| 1476 |
\ifx\pgfmathresult\pgfutil@empty |
| 1477 |
\else |
| 1478 |
\expandafter\pgfmath@basic@multiply@\expandafter |
| 1479 |
{\pgfmathresult}% |
| 1480 |
{\csname #1invlogofbasefixed\endcsname}% |
| 1481 |
\fi |
| 1482 |
}% |
| 1483 |
\expandafter\def\csname #1@\endcsname##1{% |
| 1484 |
\expandafter\csname #1@tofixed\endcsname{##1}% |
| 1485 |
\ifx\pgfmathresult\pgfutil@empty |
| 1486 |
\pgfmathfloatcreate{3}{0.0}{0}% |
| 1487 |
\else |
| 1488 |
\pgfmathfloatparsenumber{\pgfmathresult}% |
| 1489 |
\fi |
| 1490 |
}% |
| 1491 |
\expandafter\def\csname #1\endcsname##1{% |
| 1492 |
\pgfmathfloatparsenumber{##1}% |
| 1493 |
\csname #1@\endcsname{\pgfmathresult}% |
| 1494 |
}% |
| 1495 |
% |
| 1496 |
\expandafter\def\csname #1inv@\endcsname##1{% |
| 1497 |
\expandafter\pgfmathfloatmultiply@\expandafter{##1}{\csname #1logofbasefloat\endcsname}% |
| 1498 |
\pgfmathfloatexp@{\pgfmathresult}% |
| 1499 |
}% |
| 1500 |
}% |
| 1501 |
|
| 1502 |
% Tests if string '#2' starts with pattern '#1'. |
| 1503 |
% |
| 1504 |
% If so, it executes #3 and defines \pgfplotsretval to contain the |
| 1505 |
% suffix which is not equal to #1. Otherwise it executes #4. |
| 1506 |
\def\pgfplotsutilifstartswith#1#2#3#4{% |
| 1507 |
\def\pgfplotsutilifstartswith@ ##1#1##2\pgfplots@EOI{% |
| 1508 |
\def\pgfplotsutil@tmp{##1}% |
| 1509 |
\ifx\pgfplotsutil@tmp\pgfutil@empty |
| 1510 |
% Ah - a hit! |
| 1511 |
% |
| 1512 |
% define \pgfplotsretval to be the suffix... |
| 1513 |
\def\pgfplotsutil@tmp#1####1\pgfplots@EOI{% |
| 1514 |
\def\pgfplotsretval{####1}% |
| 1515 |
}% |
| 1516 |
\pgfplotsutil@tmp#2\pgfplots@EOI |
| 1517 |
% |
| 1518 |
% ... and execute the <true> code: |
| 1519 |
#3\relax |
| 1520 |
\else |
| 1521 |
% hm. No such prefix. |
| 1522 |
#4\relax |
| 1523 |
\fi |
| 1524 |
}% |
| 1525 |
\pgfplotsutilifstartswith@#2--#1\pgfplots@EOI |
| 1526 |
}% |
| 1527 |
|
| 1528 |
% Usage: |
| 1529 |
% \pgfplotsutilstrreplace{<token>}{<replacement>}{<string>} |
| 1530 |
% |
| 1531 |
% -> will assign the modified string into \pgfplotsretval. |
| 1532 |
% |
| 1533 |
% #1: the string to search (one or more tokens) |
| 1534 |
% #2: zero, one or more tokens which will be inserted instead of '#1'. |
| 1535 |
% #3: the string to search in |
| 1536 |
\long\def\pgfplotsutilstrreplace#1#2#3{% |
| 1537 |
\def\pgfplotsretval{}% |
| 1538 |
\long\def\pgfplotsutil@search@and@replace@@##1#1##2\pgfplots@EOI{% |
| 1539 |
\expandafter\def\expandafter\pgfplotsretval\expandafter{\pgfplotsretval ##1#2}% |
| 1540 |
\pgfplotsutil@search@and@replace@loop{#1}{##2}% |
| 1541 |
}% |
| 1542 |
\pgfplotsutil@search@and@replace@loop{#1}{#3}% |
| 1543 |
} |
| 1544 |
\long\def\pgfplotsutil@search@and@replace@loop#1#2{% |
| 1545 |
\pgfutil@in@{#1}{#2}% |
| 1546 |
\ifpgfutil@in@ |
| 1547 |
\def\pgfplots@loc@TMPa{\pgfplotsutil@search@and@replace@@ #2\pgfplots@EOI}% |
| 1548 |
\else |
| 1549 |
\expandafter\def\expandafter\pgfplotsretval\expandafter{\pgfplotsretval #2}% |
| 1550 |
\let\pgfplots@loc@TMPa=\relax |
| 1551 |
\fi |
| 1552 |
\pgfplots@loc@TMPa |
| 1553 |
}% |
| 1554 |
|
| 1555 |
% strcmp: invokes #3 if #1=#2 (top level expansion only) and it |
| 1556 |
% invokes #4 if #1!=#2. |
| 1557 |
\long\def\pgfplotsutilifstringequal#1#2#3#4{% |
| 1558 |
\def\pgfplotsifstringequal@{#1}% |
| 1559 |
\def\pgfplotsifstringequal@@{#2}% |
| 1560 |
\ifx\pgfplotsifstringequal@\pgfplotsifstringequal@@ #3\else #4\fi |
| 1561 |
}% |
| 1562 |
|
| 1563 |
% Checks if the token sequence #1 (unexpanded) contains a macro and |
| 1564 |
% invokes #2 if so and #3 if not. |
| 1565 |
\def\pgfplotsutilifcontainsmacro#1#2#3{% |
| 1566 |
\def\pgfplots@loc@TMPa{#1}% |
| 1567 |
\pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPa |
| 1568 |
\edef\pgfplots@loc@TMPa{\noexpand\pgfutil@in@{\pgfplots@backslash@as@other}{\pgfplots@loc@TMPa}}% |
| 1569 |
\pgfplots@loc@TMPa |
| 1570 |
\ifpgfutil@in@ |
| 1571 |
\def\pgfplots@loc@TMPa{#2}% |
| 1572 |
\else |
| 1573 |
\def\pgfplots@loc@TMPa{#3}% |
| 1574 |
\fi |
| 1575 |
\pgfplots@loc@TMPa |
| 1576 |
}% |
| 1577 |
|
| 1578 |
% this command is in pgfplotscore.code.tex: |
| 1579 |
% \pgfplotsiffileexists |
| 1580 |
|
| 1581 |
% EXPERIMENTAL OPTIMIZATION: |
| 1582 |
\let\pgfmathparsex@orig=\pgfmathparse |
| 1583 |
\def\pgfmathparsex#1{% |
| 1584 |
\begingroup |
| 1585 |
\message{WORKING ON #1...}% |
| 1586 |
\tracingmacros=2 \tracingcommands=2 |
| 1587 |
\let\pgfmath@parse@@@operator\relax |
| 1588 |
\let\pgfmath@parse@@operator\relax |
| 1589 |
\let\pgfmath@parse@operator\relax |
| 1590 |
\let\pgfmath@stack@push@operand\pgfutil@gobble |
| 1591 |
\let\pgfmath@base=\pgfmath@empty |
| 1592 |
\let\pgfmath@number=\pgfmath@empty |
| 1593 |
\let\pgfmath@parse@number@failed=\relax |
| 1594 |
\edef\pgfmath@expression{#1}% |
| 1595 |
\expandafter\pgfmathparsex@first\pgfmath@expression\pgfmathparsex@EOI% |
| 1596 |
\if1\pgfmathparsex@recover@ |
| 1597 |
\xdef\pgfmathparsex@@{\noexpand\pgfmathparsex@orig{\pgfmath@expression}}% |
| 1598 |
\else |
| 1599 |
\xdef\pgfmathparsex@@{\noexpand\def\noexpand\pgfmathresult{\pgfmathresult}}% |
| 1600 |
\fi |
| 1601 |
\endgroup |
| 1602 |
\pgfmathparsex@@ |
| 1603 |
}% |
| 1604 |
\def\pgfmathparsex@first#1#2\pgfmathparsex@EOI{% |
| 1605 |
\def\pgfmath@token@next{#1}% |
| 1606 |
\pgfmath@parse@number{#2}% |
| 1607 |
}% |
| 1608 |
\def\pgfmathparsex@recover{\def\pgfmathparsex@recover@{1}}% |
| 1609 |
\def\pgfmathparsex@recover@{0}% |
| 1610 |
|
| 1611 |
|
| 1612 |
% compares YYYY-MM-DD < YYYY-MM-DD |
| 1613 |
% |
| 1614 |
% \pgfplotsutilifdatelessthan 2010-01-01\cmp 2011-01-01\relax{<true>}{<false>} |
| 1615 |
\long\def\pgfplotsutilifdatelessthan#1-#2-#3\cmp #4-#5-#6\relax#7#8{% |
| 1616 |
\long\def\pgfplotsutilifdatelessthan@true{#7}% |
| 1617 |
\long\def\pgfplotsutilifdatelessthan@false{#8}% |
| 1618 |
\ifnum#1<#4\relax |
| 1619 |
\pgfplotsutilifdatelessthan@true |
| 1620 |
\else |
| 1621 |
\ifnum#1>#4\relax |
| 1622 |
\pgfplotsutilifdatelessthan@false |
| 1623 |
\else |
| 1624 |
\ifnum#2<#5\relax |
| 1625 |
\pgfplotsutilifdatelessthan@true |
| 1626 |
\else |
| 1627 |
\ifnum#2>#5\relax |
| 1628 |
\pgfplotsutilifdatelessthan@false |
| 1629 |
\else |
| 1630 |
\ifnum#3<#6\relax |
| 1631 |
\pgfplotsutilifdatelessthan@true |
| 1632 |
\else |
| 1633 |
\pgfplotsutilifdatelessthan@false |
| 1634 |
\fi |
| 1635 |
\fi |
| 1636 |
\fi |
| 1637 |
\fi |
| 1638 |
\fi |
| 1639 |
}% |
| 1640 |
\long\def\pgfplotsutilifdategreaterthan#1-#2-#3\cmp #4-#5-#6\relax#7#8{% |
| 1641 |
\long\def\pgfplotsutilifdatelessthan@true{#7}% |
| 1642 |
\long\def\pgfplotsutilifdatelessthan@false{#8}% |
| 1643 |
\ifnum#1>#4\relax |
| 1644 |
\pgfplotsutilifdatelessthan@true |
| 1645 |
\else |
| 1646 |
\ifnum#1<#4\relax |
| 1647 |
\pgfplotsutilifdatelessthan@false |
| 1648 |
\else |
| 1649 |
\ifnum#2>#5\relax |
| 1650 |
\pgfplotsutilifdatelessthan@true |
| 1651 |
\else |
| 1652 |
\ifnum#2<#5\relax |
| 1653 |
\pgfplotsutilifdatelessthan@false |
| 1654 |
\else |
| 1655 |
\ifnum#3>#6\relax |
| 1656 |
\pgfplotsutilifdatelessthan@true |
| 1657 |
\else |
| 1658 |
\pgfplotsutilifdatelessthan@false |
| 1659 |
\fi |
| 1660 |
\fi |
| 1661 |
\fi |
| 1662 |
\fi |
| 1663 |
\fi |
| 1664 |
}% |
| 1665 |
\pgfkeys{% |
| 1666 |
% /pgfplots/iflessthan{#1}{#2}{#3}{#4}: |
| 1667 |
% #1: arg1 (a macro containing the first argument) |
| 1668 |
% #2: arg2 (a macro containing the second argument) |
| 1669 |
% #3: code to invoke in case arg1<arg2 |
| 1670 |
% #4: code to invoke in case arg1>=arg2 |
| 1671 |
% the iflessthan method will be invoked within local scopes. |
| 1672 |
/pgfplots/fixed </.style={% |
| 1673 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{\ifdim##1pt<##2pt\relax##3\else ##4\fi},% |
| 1674 |
}, |
| 1675 |
/pgfplots/fixed <, |
| 1676 |
/pgfplots/fixed >/.style={% |
| 1677 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{\ifdim##1pt>##2pt\relax##3\else ##4\fi},% |
| 1678 |
}, |
| 1679 |
/pgfplots/int </.style={% |
| 1680 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{\ifnum##1<##2\relax##3\else ##4\fi},% |
| 1681 |
}, |
| 1682 |
/pgfplots/int >/.style={% |
| 1683 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{\ifnum##1>##2\relax##3\else ##4\fi},% |
| 1684 |
}, |
| 1685 |
/pgfplots/float </.style={% |
| 1686 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{% |
| 1687 |
\pgfmathfloatparsenumber{##1}% |
| 1688 |
\let\pgfplots@iflt@arga=\pgfmathresult |
| 1689 |
% |
| 1690 |
\pgfmathfloatparsenumber{##2}% |
| 1691 |
\let\pgfplots@iflt@argb=\pgfmathresult |
| 1692 |
% |
| 1693 |
\pgfmathfloatlessthan@{\pgfplots@iflt@arga}{\pgfplots@iflt@argb}% |
| 1694 |
\ifpgfmathfloatcomparison |
| 1695 |
##3% |
| 1696 |
\else |
| 1697 |
##4% |
| 1698 |
\fi |
| 1699 |
}% |
| 1700 |
},% |
| 1701 |
/pgfplots/float >/.style={% |
| 1702 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{% |
| 1703 |
\pgfmathfloatparsenumber{##1}% |
| 1704 |
\let\pgfplots@iflt@arga=\pgfmathresult |
| 1705 |
% |
| 1706 |
\pgfmathfloatparsenumber{##2}% |
| 1707 |
\let\pgfplots@iflt@argb=\pgfmathresult |
| 1708 |
% |
| 1709 |
\pgfmathfloatgreaterthan@{\pgfplots@iflt@arga}{\pgfplots@iflt@argb}% |
| 1710 |
\ifpgfmathfloatcomparison |
| 1711 |
##3% |
| 1712 |
\else |
| 1713 |
##4% |
| 1714 |
\fi |
| 1715 |
}% |
| 1716 |
},% |
| 1717 |
% |
| 1718 |
% compares YYYY-MM-DD < YYYY-MM-DD |
| 1719 |
/pgfplots/date </.style={% |
| 1720 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{% |
| 1721 |
\edef\pgfplotsarray@ltdate{##1\noexpand\cmp ##2}% |
| 1722 |
\expandafter\pgfplotsutilifdatelessthan\pgfplotsarray@ltdate\relax{##3}{##4}% |
| 1723 |
}% |
| 1724 |
},% |
| 1725 |
/pgfplots/date >/.style={% |
| 1726 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{% |
| 1727 |
\edef\pgfplotsarray@ltdate{##1\noexpand\cmp ##2}% |
| 1728 |
\expandafter\pgfplotsutilifdategreaterthan\pgfplotsarray@ltdate\relax{##3}{##4}% |
| 1729 |
}% |
| 1730 |
},% |
| 1731 |
% |
| 1732 |
/pgfplots/string </.style={% |
| 1733 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{% |
| 1734 |
\t@pgfplots@toka=\expandafter{##1}% |
| 1735 |
\t@pgfplots@tokb=\expandafter{##2}% |
| 1736 |
\edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}{\the\t@pgfplots@tokb}}% |
| 1737 |
\expandafter\pgfplotsutilstrcmp\pgfplots@loc@TMPa |
| 1738 |
\if1\pgfplotsretval ##3\else ##4\fi |
| 1739 |
}% |
| 1740 |
},% |
| 1741 |
/pgfplots/string >/.style={% |
| 1742 |
/pgfplots/iflessthan/.code args={##1##2##3##4}{% |
| 1743 |
\t@pgfplots@toka=\expandafter{##1}% |
| 1744 |
\t@pgfplots@tokb=\expandafter{##2}% |
| 1745 |
\edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}{\the\t@pgfplots@tokb}}% |
| 1746 |
\expandafter\pgfplotsutilstrcmp\pgfplots@loc@TMPa |
| 1747 |
\if2\pgfplotsretval ##3\else ##4\fi |
| 1748 |
}% |
| 1749 |
},% |
| 1750 |
} |
| 1751 |
|
| 1752 |
% defines \pgfplotsretval to be |
| 1753 |
% |
| 1754 |
% \ifpgfpicture #1\else #2\fi |
| 1755 |
% |
| 1756 |
% and handles the '/pgfplots/invoke before crossref tikzpicture' key. |
| 1757 |
% |
| 1758 |
% #1 first argument to \ifpgfpicture |
| 1759 |
% #2 second argument to \ifpgfpicture |
| 1760 |
\def\pgfplots@assemble@ref@picture#1#2{% |
| 1761 |
\begingroup |
| 1762 |
\pgfkeysgetvalue{/pgfplots/invoke before crossref tikzpicture}\pgfplots@loc@TMPa |
| 1763 |
\pgfkeysgetvalue{/pgfplots/invoke after crossref tikzpicture}\pgfplots@loc@TMPb |
| 1764 |
\toks0={#1}% |
| 1765 |
\toks1=\expandafter{\pgfplots@loc@TMPa}% |
| 1766 |
\toks2={#2}% |
| 1767 |
\toks3=\expandafter{\pgfplots@loc@TMPb}% |
| 1768 |
\xdef\pgfplots@glob@TMPa{% |
| 1769 |
\noexpand\ifpgfpicture |
| 1770 |
\the\toks0 % |
| 1771 |
\noexpand\else |
| 1772 |
\the\toks1 |
| 1773 |
\the\toks2 |
| 1774 |
\the\toks3 |
| 1775 |
\noexpand\fi |
| 1776 |
}% |
| 1777 |
\endgroup |
| 1778 |
\let\pgfplotsretval=\pgfplots@glob@TMPa |
| 1779 |
}% |
| 1780 |
|
| 1781 |
\def\pgfplots@auxwrite@latex#1{% |
| 1782 |
\if@filesw |
| 1783 |
\immediate\write\@auxout{#1}% |
| 1784 |
\fi |
| 1785 |
}% |
| 1786 |
\pgfutil@IfUndefined{if@filesw}{% |
| 1787 |
\def\pgfplots@auxwrite#1{}% |
| 1788 |
}{% |
| 1789 |
\let\pgfplots@auxwrite=\pgfplots@auxwrite@latex |
| 1790 |
}% |
| 1791 |
|
| 1792 |
% sorts three elements. |
| 1793 |
% |
| 1794 |
% #1,#2,#3 are three macros containing the input. |
| 1795 |
% On output, these macros are redefined to represent the sorted range. |
| 1796 |
% The values of these macros must be a <dimen>, followed by anything |
| 1797 |
% else (but no \relax please) |
| 1798 |
% |
| 1799 |
% Example: |
| 1800 |
% \def\A{10pt furthervalues} |
| 1801 |
% \def\B{4pt value of b} |
| 1802 |
% \def\C{1pt value of c} |
| 1803 |
% \pgfplotsutilsortthree\A\B\C |
| 1804 |
% -> |
| 1805 |
% \A={1pt value of c} |
| 1806 |
% \B={4pt value of b} |
| 1807 |
% \C={10pt furthervalues} |
| 1808 |
% |
| 1809 |
% It uses insertion sort. |
| 1810 |
\def\pgfplotsutilsortthree#1#2#3{% |
| 1811 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax |
| 1812 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xb=#2\relax |
| 1813 |
\ifdim\pgf@xa>\pgf@xb |
| 1814 |
\let\pgfplots@loc@TMPa=#2% |
| 1815 |
\let#2=#1% |
| 1816 |
\let#1=\pgfplots@loc@TMPa% |
| 1817 |
\fi |
| 1818 |
% first two are sorted. |
| 1819 |
% |
| 1820 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#2\relax |
| 1821 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xb=#3\relax |
| 1822 |
\let\pgfplots@loc@TMPa=#3% |
| 1823 |
\ifdim\pgf@xa>\pgf@xb |
| 1824 |
\let#3=#2% |
| 1825 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax |
| 1826 |
\ifdim\pgf@xa>\pgf@xb |
| 1827 |
\let#2=#1% |
| 1828 |
\let#1=\pgfplots@loc@TMPa% |
| 1829 |
\else |
| 1830 |
\let#2=\pgfplots@loc@TMPa% |
| 1831 |
\fi |
| 1832 |
\fi |
| 1833 |
% ok. |
| 1834 |
}% |
| 1835 |
|
| 1836 |
% Like \pgfplotsutilsortthree, but for four elements (of the same |
| 1837 |
% form, see \pgfplotsutilsortthree). |
| 1838 |
% |
| 1839 |
% It uses insertion sort. |
| 1840 |
\def\pgfplotsutilsortfour#1#2#3#4{% |
| 1841 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax |
| 1842 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xb=#2\relax |
| 1843 |
\ifdim\pgf@xa>\pgf@xb |
| 1844 |
\let\pgfplots@loc@TMPa=#2% |
| 1845 |
\let#2=#1% |
| 1846 |
\let#1=\pgfplots@loc@TMPa% |
| 1847 |
\fi |
| 1848 |
% first two are sorted. |
| 1849 |
% |
| 1850 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#2\relax |
| 1851 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xb=#3\relax |
| 1852 |
\let\pgfplots@loc@TMPa=#3% |
| 1853 |
\ifdim\pgf@xa>\pgf@xb |
| 1854 |
\let#3=#2% |
| 1855 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax |
| 1856 |
\ifdim\pgf@xa>\pgf@xb |
| 1857 |
\let#2=#1% |
| 1858 |
\let#1=\pgfplots@loc@TMPa% |
| 1859 |
\else |
| 1860 |
\let#2=\pgfplots@loc@TMPa% |
| 1861 |
\fi |
| 1862 |
\fi |
| 1863 |
% ok, first three are sorted. |
| 1864 |
% |
| 1865 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#3\relax |
| 1866 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xb=#4\relax |
| 1867 |
\let\pgfplots@loc@TMPa=#4% |
| 1868 |
\ifdim\pgf@xa>\pgf@xb |
| 1869 |
\let#4=#3% |
| 1870 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#2\relax |
| 1871 |
\ifdim\pgf@xa>\pgf@xb |
| 1872 |
\let#3=#2% |
| 1873 |
\afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax |
| 1874 |
\ifdim\pgf@xa>\pgf@xb |
| 1875 |
\let#2=#1% |
| 1876 |
\let#1=\pgfplots@loc@TMPa% |
| 1877 |
\else |
| 1878 |
\let#2=\pgfplots@loc@TMPa% |
| 1879 |
\fi |
| 1880 |
\else |
| 1881 |
\let#3=\pgfplots@loc@TMPa% |
| 1882 |
\fi |
| 1883 |
\fi |
| 1884 |
% ok, first four are sorted. |
| 1885 |
}% |
| 1886 |
|
| 1887 |
% A variant of \pgfutil@ifnextchar which allows the '#' character |
| 1888 |
% inside of either '#2' or '#3'. |
| 1889 |
% |
| 1890 |
% It is slightly more expensive and relies on \t@pgfplots@tokc |
| 1891 |
\long\def\pgfplotsutil@ifnextchar#1#2#3{% |
| 1892 |
\let\pgfplotsutil@reserved@d=#1% |
| 1893 |
\t@pgfplots@tokc={#2}% |
| 1894 |
\edef\pgfplotsutil@reserved@a{\the\t@pgfplots@tokc}% |
| 1895 |
\t@pgfplots@tokc={#3}% |
| 1896 |
\def\pgfplotsutil@reserved@b{\the\t@pgfplots@tokc}% |
| 1897 |
\futurelet\pgfplotsutil@let@token\pgfplotsutil@ifnch} |
| 1898 |
\def\pgfplotsutil@ifnch{% |
| 1899 |
\ifx\pgfplotsutil@let@token\pgfplotsutil@sptoken |
| 1900 |
\let\pgfplotsutil@reserved@c\pgfplotsutil@xifnch |
| 1901 |
\else |
| 1902 |
\ifx\pgfplotsutil@let@token\pgfplotsutil@reserved@d |
| 1903 |
\let\pgfplotsutil@reserved@c\pgfplotsutil@reserved@a |
| 1904 |
\else |
| 1905 |
\let\pgfplotsutil@reserved@c\pgfplotsutil@reserved@b |
| 1906 |
\fi |
| 1907 |
\fi |
| 1908 |
\pgfplotsutil@reserved@c} |
| 1909 |
{% |
| 1910 |
\def\:{\global\let\pgfplotsutil@sptoken= } \: |
| 1911 |
\def\:{\pgfplotsutil@xifnch} \expandafter\gdef\: {\futurelet\pgfplotsutil@let@token\pgfplotsutil@ifnch} |
| 1912 |
} |
| 1913 |
|
| 1914 |
|
| 1915 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1916 |
% |
| 1917 |
% basic 3d linear algebra utils. |
| 1918 |
% |
| 1919 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1920 |
|
| 1921 |
% Converts a 3d vectors to string. |
| 1922 |
% #1: a vector which expands to the form 'x,y,z' |
| 1923 |
% on output, \pgfplotsretval will contain the result vector. |
| 1924 |
% #3: the argument for \pgfplotscoordmath (such as 'default') |
| 1925 |
% |
| 1926 |
\def\pgfplotsmathvectortostring#1#2{% |
| 1927 |
\begingroup |
| 1928 |
\edef\pgfplots@loc@TMPa{#1}% |
| 1929 |
\expandafter\pgfplotsmathvectorcompwiseop@unary\pgfplots@loc@TMPa\pgfplots@EOI{#2}{{tostring}}% |
| 1930 |
\pgfmath@smuggleone\pgfplotsretval |
| 1931 |
\endgroup |
| 1932 |
}% |
| 1933 |
|
| 1934 |
% Reads a 3d vector's coordinates. |
| 1935 |
% #1: a vector which expands to the form 'x,y,z' |
| 1936 |
% on output, \pgfplotsretval will contain the result vector. |
| 1937 |
% #2: the argument for \pgfplotscoordmath (such as 'default') |
| 1938 |
% |
| 1939 |
% Example: |
| 1940 |
% \pgfplotsmathvectorfromstring{1,4,5}{default} |
| 1941 |
% will parse each component |
| 1942 |
\def\pgfplotsmathvectorfromstring#1#2{% |
| 1943 |
\begingroup |
| 1944 |
\edef\pgfplots@loc@TMPa{#1}% |
| 1945 |
\expandafter\pgfplotsmathvectorcompwiseop@unary\pgfplots@loc@TMPa\pgfplots@EOI{#2}{{parsenumber}}% |
| 1946 |
\pgfmath@smuggleone\pgfplotsretval |
| 1947 |
\endgroup |
| 1948 |
}% |
| 1949 |
|
| 1950 |
% Takes two 3d vectors and subtracts them. |
| 1951 |
% #1: a vector which expands to the form 'x,y,z' |
| 1952 |
% #2: a vector which expands to the form 'x,y,z' |
| 1953 |
% on output, \pgfplotsretval will contain the difference vector. |
| 1954 |
% #3: the argument for \pgfplotscoordmath (such as 'default') |
| 1955 |
% |
| 1956 |
\def\pgfplotsmathvectorsubtract#1#2#3{% |
| 1957 |
\begingroup |
| 1958 |
\edef\pgfplots@loc@TMPa{#1:#2}% |
| 1959 |
\expandafter\pgfplotsmathvectorcompwiseop@binary\pgfplots@loc@TMPa\pgfplots@EOI{#3}{subtract}% |
| 1960 |
\pgfmath@smuggleone\pgfplotsretval |
| 1961 |
\endgroup |
| 1962 |
}% |
| 1963 |
\def\pgfplotsmathvectorcompwiseop@binary#1,#2,#3:#4,#5,#6\pgfplots@EOI#7#8{% |
| 1964 |
\def\Ax{#1}% |
| 1965 |
\def\Ay{#2}% |
| 1966 |
\def\Az{#3}% |
| 1967 |
\def\Bx{#4}% |
| 1968 |
\def\By{#5}% |
| 1969 |
\def\Bz{#6}% |
| 1970 |
\pgfplotscoordmath{#7}{op}{#8}{{\Ax}{\Bx}}% |
| 1971 |
\let\pgfplots@loc@TMPa=\pgfmathresult |
| 1972 |
\pgfplotscoordmath{#7}{op}{#8}{{\Ay}{\By}}% |
| 1973 |
\let\pgfplots@loc@TMPb=\pgfmathresult |
| 1974 |
\pgfplotscoordmath{#7}{op}{#8}{{\Az}{\Bz}}% |
| 1975 |
\let\pgfplots@loc@TMPc=\pgfmathresult |
| 1976 |
\edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc}% |
| 1977 |
}% |
| 1978 |
|
| 1979 |
% #5: an operation ENCLOSED IN BRACES! |
| 1980 |
% like '{tostring}' or '{op}{<someunaryop>}' |
| 1981 |
\def\pgfplotsmathvectorcompwiseop@unary#1,#2,#3\pgfplots@EOI#4#5{% |
| 1982 |
\def\Ax{#1}% |
| 1983 |
\def\Ay{#2}% |
| 1984 |
\def\Az{#3}% |
| 1985 |
\pgfplotscoordmath{#4}#5{\Ax}% |
| 1986 |
\let\pgfplots@loc@TMPa=\pgfmathresult |
| 1987 |
\pgfplotscoordmath{#4}#5{\Ay}% |
| 1988 |
\let\pgfplots@loc@TMPb=\pgfmathresult |
| 1989 |
\pgfplotscoordmath{#4}#5{\Az}% |
| 1990 |
\let\pgfplots@loc@TMPc=\pgfmathresult |
| 1991 |
\edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc}% |
| 1992 |
}% |
| 1993 |
|
| 1994 |
% Takes two 3d vectors and adds them. |
| 1995 |
% #1: a vector which expands to the form 'x,y,z' |
| 1996 |
% #2: a vector which expands to the form 'x,y,z' |
| 1997 |
% on output, \pgfplotsretval will contain the added vector. |
| 1998 |
% #3: the argument for \pgfplotscoordmath (such as 'default') |
| 1999 |
% |
| 2000 |
\def\pgfplotsmathvectoradd#1#2#3{% |
| 2001 |
\begingroup |
| 2002 |
\edef\pgfplots@loc@TMPa{#1:#2}% |
| 2003 |
\expandafter\pgfplotsmathvectorcompwiseop@binary\pgfplots@loc@TMPa\pgfplots@EOI{#3}{add}% |
| 2004 |
\pgfmath@smuggleone\pgfplotsretval |
| 2005 |
\endgroup |
| 2006 |
}% |
| 2007 |
|
| 2008 |
% Takes two 3d vectors and applies a component-wise operation. |
| 2009 |
% #1: a vector which expands to the form 'x,y,z' |
| 2010 |
% #2: a vector which expands to the form 'x,y,z' |
| 2011 |
% on output, \pgfplotsretval will contain a boolean vector with three |
| 2012 |
% entries. |
| 2013 |
% #3: a scalar operation which takes two arguments (such as "add", "subtract", "equal") |
| 2014 |
% #4 the argument for \pgfplotscoordmath (such as 'default') |
| 2015 |
% |
| 2016 |
% Example: \pgfplotsmathvectorcompwise{1,1,1}{0,1,0}{add}{pgfbasic} |
| 2017 |
% -> \pgfplotsretval={1.0,2.0,1.0} |
| 2018 |
\def\pgfplotsmathvectorcompwise#1#2#3#4{% |
| 2019 |
\begingroup |
| 2020 |
\edef\pgfplots@loc@TMPa{#1:#2}% |
| 2021 |
\expandafter\pgfplotsmathvectorcompwiseop@binary\pgfplots@loc@TMPa\pgfplots@EOI{#4}{#3}% |
| 2022 |
\pgfmath@smuggleone\pgfplotsretval |
| 2023 |
\endgroup |
| 2024 |
}% |
| 2025 |
|
| 2026 |
% Defines \pgfplotsretval to x+y+z |
| 2027 |
% #1: a vector which expands to the form 'x,y,z' |
| 2028 |
% on output, \pgfplotsretval will contain the result scalar. |
| 2029 |
% #2: the argument for \pgfplotscoordmath (such as 'default') |
| 2030 |
% |
| 2031 |
% Example: |
| 2032 |
% \pgfplotsmathvectorsum{1,4,5}{default} |
| 2033 |
% \pgfplotsretval = 10 (in that format) |
| 2034 |
\def\pgfplotsmathvectorsum#1#2{% |
| 2035 |
\begingroup |
| 2036 |
\edef\pgfplots@loc@TMPa{#1}% |
| 2037 |
\expandafter\pgfplotsmathvectorsum@\pgfplots@loc@TMPa\pgfplots@EOI{#2}% |
| 2038 |
\pgfmath@smuggleone\pgfplotsretval |
| 2039 |
\endgroup |
| 2040 |
}% |
| 2041 |
|
| 2042 |
\def\pgfplotsmathvectorsum@#1,#2,#3\pgfplots@EOI#4{% |
| 2043 |
\def\Ax{#1}% |
| 2044 |
\def\Ay{#2}% |
| 2045 |
\def\Az{#3}% |
| 2046 |
\pgfplotscoordmath{#4}{op}{add}{{\Ax}{\Ay}}% |
| 2047 |
\let\pgfplotsretval=\pgfmathresult |
| 2048 |
\pgfplotscoordmath{#4}{op}{add}{{\pgfplotsretval}{\Az}}% |
| 2049 |
\let\pgfplotsretval=\pgfmathresult |
| 2050 |
}% |
| 2051 |
|
| 2052 |
% Computes the euclidean scalar product of two 3d vectors #1 and #2 in math |
| 2053 |
% format #3. |
| 2054 |
\def\pgfplotsmathvectorscalarproduct#1#2#3{% |
| 2055 |
\pgfplotsmathvectorscaleindividually{#1}{#2}{#3}% |
| 2056 |
\pgfplotsmathvectorsum{\pgfplotsretval}{#3}% |
| 2057 |
}% |
| 2058 |
|
| 2059 |
% takes a vector #1 and defines three new macros |
| 2060 |
% \csname #2x\endcsname, |
| 2061 |
% \csname #2y\endcsname, |
| 2062 |
% \csname #2z\endcsname, |
| 2063 |
% with the components. |
| 2064 |
% #3: the math format |
| 2065 |
\def\pgfplotsmathvectortocomponents#1#2#3{% |
| 2066 |
\edef\pgfplots@loc@TMPa{#1}% |
| 2067 |
\expandafter\pgfplotsmathvectortocomponents@\pgfplots@loc@TMPa\pgfplots@EOI{#3}{#2}% |
| 2068 |
}% |
| 2069 |
\def\pgfplotsmathvectortocomponents@#1,#2,#3\pgfplots@EOI#4#5{% |
| 2070 |
\expandafter\def\csname #5x\endcsname{#1}% |
| 2071 |
\expandafter\def\csname #5y\endcsname{#2}% |
| 2072 |
\expandafter\def\csname #5z\endcsname{#3}% |
| 2073 |
}% |
| 2074 |
|
| 2075 |
|
| 2076 |
% Takes two 3d vectors and computes their cross product. |
| 2077 |
% #1: a vector which expands to the form 'x,y,z' |
| 2078 |
% #2: a vector which expands to the form 'x,y,z' |
| 2079 |
% on output, \pgfplotsretval will contain the result vector. |
| 2080 |
% #3: the argument for \pgfplotscoordmath (such as 'default') |
| 2081 |
% |
| 2082 |
\def\pgfplotsmathvectorcrossprod#1#2#3{% |
| 2083 |
\begingroup |
| 2084 |
\edef\pgfplots@loc@TMPa{#1:#2}% |
| 2085 |
\expandafter\pgfplotsmathvectorcrossprod@\pgfplots@loc@TMPa\pgfplots@EOI{#3}% |
| 2086 |
%\message{\string\pgfplotsmathvectorcrossprod{#1}{#2} = \pgfplotsretval^^J}% |
| 2087 |
\pgfmath@smuggleone\pgfplotsretval |
| 2088 |
\endgroup |
| 2089 |
}% |
| 2090 |
\def\pgfplotsmathvectorcrossprod@#1,#2,#3:#4,#5,#6\pgfplots@EOI#7{% |
| 2091 |
\def\Ax{#1}% |
| 2092 |
\def\Ay{#2}% |
| 2093 |
\def\Az{#3}% |
| 2094 |
\def\Bx{#4}% |
| 2095 |
\def\By{#5}% |
| 2096 |
\def\Bz{#6}% |
| 2097 |
% |
| 2098 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Ay}{\Bz}}\let\AyBz=\pgfmathresult |
| 2099 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Az}{\By}}\let\AzBy=\pgfmathresult |
| 2100 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Az}{\Bx}}\let\AzBx=\pgfmathresult |
| 2101 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Ax}{\Bz}}\let\AxBz=\pgfmathresult |
| 2102 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Ax}{\By}}\let\AxBy=\pgfmathresult |
| 2103 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Ay}{\Bx}}\let\AyBx=\pgfmathresult |
| 2104 |
% |
| 2105 |
\pgfplotscoordmath{#7}{op}{subtract}{{\AyBz}{\AzBy}}\let\pgfplots@loc@TMPa=\pgfmathresult% |
| 2106 |
\pgfplotscoordmath{#7}{op}{subtract}{{\AzBx}{\AxBz}}\let\pgfplots@loc@TMPb=\pgfmathresult% |
| 2107 |
\pgfplotscoordmath{#7}{op}{subtract}{{\AxBy}{\AyBx}}\let\pgfplots@loc@TMPc=\pgfmathresult% |
| 2108 |
\edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc}% |
| 2109 |
}% |
| 2110 |
|
| 2111 |
% Takes two 3d vectors and defines a new vector (Ax*Bx,Ay*By,Az*Bz) |
| 2112 |
% #1: a vector which expands to the form 'x,y,z' |
| 2113 |
% #2: a vector which expands to the form 'x,y,z' |
| 2114 |
% on output, \pgfplotsretval will contain the result vector. |
| 2115 |
% #3: the argument for \pgfplotscoordmath (such as 'default') |
| 2116 |
% |
| 2117 |
\def\pgfplotsmathvectorscaleindividually#1#2#3{% |
| 2118 |
\begingroup |
| 2119 |
\edef\pgfplots@loc@TMPa{#1:#2}% |
| 2120 |
\expandafter\pgfplotsmathvectorscaleindividually@\pgfplots@loc@TMPa\pgfplots@EOI{#3}% |
| 2121 |
\pgfmath@smuggleone\pgfplotsretval |
| 2122 |
\endgroup |
| 2123 |
}% |
| 2124 |
\def\pgfplotsmathvectorscaleindividually@#1,#2,#3:#4,#5,#6\pgfplots@EOI#7{% |
| 2125 |
\def\Ax{#1}% |
| 2126 |
\def\Ay{#2}% |
| 2127 |
\def\Az{#3}% |
| 2128 |
\def\Bx{#4}% |
| 2129 |
\def\By{#5}% |
| 2130 |
\def\Bz{#6}% |
| 2131 |
% |
| 2132 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Ax}{\Bx}}\let\Cx=\pgfmathresult |
| 2133 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Ay}{\By}}\let\Cy=\pgfmathresult |
| 2134 |
\pgfplotscoordmath{#7}{op}{multiply}{{\Az}{\Bz}}\let\Cz=\pgfmathresult |
| 2135 |
% |
| 2136 |
\edef\pgfplotsretval{\Cx,\Cy,\Cz}% |
| 2137 |
}% |
| 2138 |
|
| 2139 |
% #1 a vector as x,y,z |
| 2140 |
% #2 the math format of its components |
| 2141 |
\def\pgfplotspointfromcsvvector#1#2{% |
| 2142 |
\begingroup |
| 2143 |
\edef\pgfplots@loc@TMPa{#1}% |
| 2144 |
\expandafter\pgfplotspointfromcsvvector@\pgfplots@loc@TMPa\pgfplots@EOI{#2} |
| 2145 |
\endgroup |
| 2146 |
}% |
| 2147 |
\def\pgfplotspointfromcsvvector@#1,#2,#3\pgfplots@EOI#4{% |
| 2148 |
\pgfplotscoordmath{#4}{tofixed}{#1}\let\Ax=\pgfmathresult |
| 2149 |
\pgfplotscoordmath{#4}{tofixed}{#2}\let\Ay=\pgfmathresult |
| 2150 |
\pgfplotscoordmath{#4}{tofixed}{#3}\let\Az=\pgfmathresult |
| 2151 |
\pgfplotsqpointxyz\Ax\Ay\Az |
| 2152 |
\pgf@process{}% |
| 2153 |
}% |
| 2154 |
|
| 2155 |
% #1 a vector as (x,y,z) |
| 2156 |
% #2 a coordmath value |
| 2157 |
% defines \pgfplotsretval to contain the vector length |
| 2158 |
\def\pgfplotsmathvectorlength#1#2{% |
| 2159 |
\begingroup |
| 2160 |
\edef\pgfplots@loc@TMPa{#1}% |
| 2161 |
\expandafter\pgfplotsmathvectorlength@\pgfplots@loc@TMPa\pgfplots@EOI{#2}% |
| 2162 |
\pgfmath@smuggleone\pgfplotsretval |
| 2163 |
\endgroup |
| 2164 |
}% |
| 2165 |
\def\pgfplotsmathvectorlength@#1,#2,#3\pgfplots@EOI#4{% |
| 2166 |
\begingroup |
| 2167 |
\def\Ax{#1}% |
| 2168 |
\def\Ay{#2}% |
| 2169 |
\def\Az{#3}% |
| 2170 |
% |
| 2171 |
\pgfplotscoordmath{#4}{op}{multiply}{{\Ax}{\Ax}}\let\Axx=\pgfmathresult |
| 2172 |
\pgfplotscoordmath{#4}{op}{multiply}{{\Ay}{\Ay}}\let\Ayy=\pgfmathresult |
| 2173 |
\pgfplotscoordmath{#4}{op}{multiply}{{\Az}{\Az}}\let\Azz=\pgfmathresult |
| 2174 |
% |
| 2175 |
\pgfplotscoordmath{#4}{op}{add}{{\Axx}{\Ayy}}% |
| 2176 |
\pgfplotscoordmath{#4}{op}{add}{{\Azz}{\pgfmathresult}}% |
| 2177 |
\pgfplotscoordmath{#4}{op}{sqrt}{{\pgfmathresult}}% |
| 2178 |
\let\pgfplotsretval=\pgfmathresult |
| 2179 |
\pgfmath@smuggleone\pgfplotsretval |
| 2180 |
\endgroup |
| 2181 |
}% |
| 2182 |
|
| 2183 |
% #1 a vector as (x,y,z) |
| 2184 |
% #2 a scale |
| 2185 |
% #3 a coordmath value |
| 2186 |
% defines \pgfplotsretval to contain the scaled vector |
| 2187 |
\def\pgfplotsmathvectorscale#1#2#3{% |
| 2188 |
\begingroup |
| 2189 |
\edef\pgfplots@loc@TMPa{#1:#2}% |
| 2190 |
\expandafter\pgfplotsmathvectorscale@\pgfplots@loc@TMPa\pgfplots@EOI{#3}% |
| 2191 |
\pgfmath@smuggleone\pgfplotsretval |
| 2192 |
\endgroup |
| 2193 |
}% |
| 2194 |
\def\pgfplotsmathvectorscale@#1,#2,#3:#4\pgfplots@EOI#5{% |
| 2195 |
\begingroup |
| 2196 |
\def\Ax{#1}% |
| 2197 |
\def\Ay{#2}% |
| 2198 |
\def\Az{#3}% |
| 2199 |
\pgfplotscoordmath{#5}{parsenumber}{#4}\let\S\pgfmathresult |
| 2200 |
% |
| 2201 |
\pgfplotscoordmath{#5}{op}{multiply}{{\Ax}{\S}}\let\Ax=\pgfmathresult |
| 2202 |
\pgfplotscoordmath{#5}{op}{multiply}{{\Ay}{\S}}\let\Ay=\pgfmathresult |
| 2203 |
\pgfplotscoordmath{#5}{op}{multiply}{{\Az}{\S}}\let\Az=\pgfmathresult |
| 2204 |
% |
| 2205 |
\edef\pgfplotsretval{\Ax,\Ay,\Az}% |
| 2206 |
\pgfmath@smuggleone\pgfplotsretval |
| 2207 |
\endgroup |
| 2208 |
}% |
| 2209 |
|
| 2210 |
% Takes an input vector #1 = x,y,z and applies the inverse data scale |
| 2211 |
% trafo. |
| 2212 |
% |
| 2213 |
% The result is \pgfplotsretval; it will be in '#2' coordmath for |
| 2214 |
% every component. |
| 2215 |
\def\pgfplotsmathvectordatascaletrafoinverse#1#2{% |
| 2216 |
\begingroup |
| 2217 |
\edef\pgfplots@loc@TMPa{#1}% |
| 2218 |
\expandafter\pgfplotsmathvectordatascaletrafoinverse@\pgfplots@loc@TMPa\pgfplots@EOI{#2}% |
| 2219 |
\pgfmath@smuggleone\pgfplotsretval |
| 2220 |
\endgroup |
| 2221 |
} |
| 2222 |
\def\pgfplotsmathvectordatascaletrafoinverse@#1,#2,#3\pgfplots@EOI#4{% |
| 2223 |
\begingroup |
| 2224 |
\def\Ax{#1}% |
| 2225 |
\def\Ay{#2}% |
| 2226 |
\def\Az{#3}% |
| 2227 |
\ifpgfplots@apply@datatrafo@x |
| 2228 |
\pgfplotscoordmath{x}{datascaletrafo inverse}{\Ax}\let\Ax=\pgfmathresult |
| 2229 |
\fi |
| 2230 |
\ifpgfplots@apply@datatrafo@y |
| 2231 |
\pgfplotscoordmath{y}{datascaletrafo inverse}{\Ay}\let\Ay=\pgfmathresult |
| 2232 |
\fi |
| 2233 |
\ifpgfplots@curplot@threedim |
| 2234 |
\ifpgfplots@apply@datatrafo@z |
| 2235 |
\pgfplotscoordmath{z}{datascaletrafo inverse}{\Az}\let\Az=\pgfmathresult |
| 2236 |
\fi |
| 2237 |
\fi |
| 2238 |
\pgfplotsmathvectorfromstring{\Ax,\Ay,\Az}{#4}% |
| 2239 |
\pgfmath@smuggleone\pgfplotsretval |
| 2240 |
\endgroup |
| 2241 |
}% |
| 2242 |
|
| 2243 |
|
| 2244 |
{ |
| 2245 |
\catcode`\"=12 |
| 2246 |
\gdef\pgfplotsDQ{"}% |
| 2247 |
\catcode`\|=12 |
| 2248 |
\gdef\pgfplotsVERTBAR{|}% |
| 2249 |
\catcode`\#=12 |
| 2250 |
\gdef\pgfplotsHASH{#}% |
| 2251 |
\catcode`\%=12 \gdef\pgfplotsPERCENT{%}} |
| 2252 |
|
| 2253 |
% swaps the content of two macros |
| 2254 |
\def\pgfplotsutil@swap#1#2{% |
| 2255 |
\let\pgfplotsutil@swap@=#1% |
| 2256 |
\let#1=#2% |
| 2257 |
\let#2=\pgfplotsutil@swap@ |
| 2258 |
}% |
| 2259 |
|
| 2260 |
\def\pgfplots@boolval#1{% |
| 2261 |
\pgfplots@if{#1}{true}{false}% |
| 2262 |
}% |
| 2263 |
|
| 2264 |
\input pgfplotsliststructure.code.tex |
| 2265 |
\input pgfplotsliststructureext.code.tex |
| 2266 |
\input pgfplotsarray.code.tex |
| 2267 |
\input pgfplotsmatrix.code.tex |
| 2268 |
\input pgfplotstableshared.code.tex |
| 2269 |
\input pgfplotsdeque.code.tex |
| 2270 |
\input pgfplotsbinary.code.tex |
| 2271 |
\input pgfplotsutil.verb.code.tex |
| 2272 |
|
| 2273 |
\usepgfplotslibrary{surfshading} |
| 2274 |
|
| 2275 |
\endinput |