Debian Codegraph @

texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex

raw
1 %--------------------------------------------
2 %
3 % Package pgfplotstable
4 %
5 % Provides support to read and work with abstract numeric tables of the
6 % form
7 %
8 % COLUMN1 COLUMN2 COLUMN3
9 % 1 2 3
10 % 4 4 552
11 % 1e124 0.00001 1.2345e-12
12 % ...
13 %
14 % Copyright 2007-2010 by Christian Feuersänger.
15 %
16 % This program is free software: you can redistribute it and/or modify
17 % it under the terms of the GNU General Public License as published by
18 % the Free Software Foundation, either version 3 of the License, or
19 % (at your option) any later version.
20 %
21 % This program is distributed in the hope that it will be useful,
22 % but WITHOUT ANY WARRANTY; without even the implied warranty of
23 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 % GNU General Public License for more details.
25 %
26 % You should have received a copy of the GNU General Public License
27 % along with this program. If not, see <http://www.gnu.org/licenses/>.
28 %
29 %--------------------------------------------
30
31
32 % This file provides a high-level table manipulation and typesetting
33 % package.
34 %
35 % see pgfplotstableshared.code.tex for the low level routines.
36
37
38 \newif\ifpgfplotstabletypesetdebug
39 \newif\ifpgfplotstable@sort
40 \newif\ifpgfplotstabletypesetskipcoltypes
41 \newif\ifpgfplotstabletypesetresult
42 \newif\ifpgfplotstableuserow
43 \newif\ifpgfplotstabletypeset@includeoutfiles
44 \newif\ifpgfplotstabletypeset@force@remake
45 \newif\ifpgfplotstable@disable@rowcolstyles
46
47 \let\pgfplotstable@outfile=\w@pgf@writea
48
49 \input pgfplotstable.coltype.code.tex
50
51 % #1= floating point number
52 % #2= TeX code to execute if #1 == 0
53 % #3= TeX code to execute if #1 != 0
54 \def\pgfplots@ifzero#1#2#3{%
55 \expandafter\pgfmathfloat@decompose@F#1\relax\pgfmathfloat@a@S
56 \ifnum\pgfmathfloat@a@S=0 #2\else#3\fi
57 }%
58
59 % just make sure no-one complaints if manual example are used without
60 % booktabs loaded:
61 \pgfutil@IfUndefined{toprule}{%
62 \def\toprule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\toprule}}%
63 \def\midrule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\midrule}}%
64 \def\bottomrule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\bottomrule}}%
65 }{\relax}%
66
67 % keys which are NOT predefined:
68 % /pgfplots/table/alias/<col alias>/.initial={<real col>}
69 % /pgfplots/table/columns/<col name>/.style={}
70 % /pgfplots/table/display columns/<col index>/.style={}
71 % /pgfplots/table/create on use/<col name>/.style={create options}
72 \pgfkeys{%
73 /pgfplots/table/disable rowcol styles/.is if=pgfplotstable@disable@rowcolstyles,
74 /pgfplots/table/disable rowcol styles/.default=true,
75 /pgfplots/table/row predicate/.code={},
76 /pgfplots/table/skip rows between index/.style 2 args={%
77 /pgfplots/table/row predicate/.append code={%
78 \ifnum##1<#1\relax
79 \else
80 \ifnum##1<#2\relax
81 \pgfplotstableuserowfalse
82 \fi
83 \fi}
84 },
85 /pgfplots/table/select equal part entry of/.style 2 args={%
86 /pgfplots/table/row predicate/.code={%
87 \pgfplotstableuserowtrue
88 \begingroup
89 % this group re-uses counters as temporary variables.
90 \c@pgfplotstable@colindex=\pgfplotstablerows\relax
91 \divide\c@pgfplotstable@colindex by#2\relax
92 \edef\pgfplotstablepartsize{\the\c@pgfplotstable@colindex}%
93 % This here should create empty cells such that
94 % remaining entries are distributed equally:
95 \c@pgfplotstable@rowindex=\c@pgfplotstable@colindex
96 \multiply\c@pgfplotstable@rowindex by#2\relax
97 \ifnum\c@pgfplotstable@rowindex<\pgfplotstablerows\relax
98 \c@pgfplotstable@colindex=\pgfplotstablerows\relax
99 \advance\c@pgfplotstable@colindex by-\c@pgfplotstable@rowindex
100 \advance\c@pgfplotstable@colindex by\pgfplotstablepartsize
101 \edef\pgfplotstablepartsize{\the\c@pgfplotstable@colindex}%
102 \fi
103 %
104 \multiply\c@pgfplotstable@colindex by#1\relax
105 \ifnum##1<\c@pgfplotstable@colindex\relax
106 \aftergroup\pgfplotstableuserowfalse
107 \else
108 \advance\c@pgfplotstable@colindex by\pgfplotstablepartsize\relax
109 \ifnum##1<\c@pgfplotstable@colindex\relax
110 \else
111 \aftergroup\pgfplotstableuserowfalse
112 \fi
113 \fi
114 \endgroup
115 }%
116 },
117 % #1: colname
118 /pgfplots/table/unique/.code={%
119 \pgfkeys{/pgfplots/table/row predicate/.append code={%
120 \ifnum\pgfplotstablerow=0
121 \ifnum\pgfplotstablecol=0
122 \pgfutil@ifundefined{pgfplotstable@unique@bitlist@backup}{%
123 }{%
124 \pgfplots@error{It seems there are *multiple* 'unique' keys running on one table. That doesn't work correctly, I guess. Consider using '\string\pgfplotstableset{row predicate/.code={}}' to reset it.}%
125 }%
126 % PREPARE ONCE! Assemble the boolean results into
127 % a list which is used for the complete table:
128 \def\pgfplotstable@loc@TMPd{\pgfplotstablegetcolumnfromstruct{#1}\of}%
129 \expandafter\pgfplotstable@loc@TMPd\pgfplotstablename\to\pgfplotstable@unique@col
130 \pgfplotslistnewempty\pgfplotstable@unique@bitlist
131 \let\pgfplotstable@unique@LAST=\pgfutil@empty
132 \pgfplotslistforeachungrouped\pgfplotstable@unique@col\as\pgfplotstable@unique@cur{%
133 \def\pgfplotstable@unique@bit{1}%
134 \ifx\pgfplotstable@unique@LAST\pgfutil@empty
135 \else
136 \ifx\pgfplotstable@unique@LAST\pgfplotstable@unique@cur
137 \def\pgfplotstable@unique@bit{0}%
138 \fi
139 \fi
140 \ifpgfplotstabletypesetdebug
141 \pgfplots@message{unique={#1}: cur == last <=> ( \pgfplotstable@unique@cur\space == \pgfplotstable@unique@LAST ) = \pgfplotstable@unique@bit.}%
142 \fi
143 \expandafter\pgfplotslistpushback\pgfplotstable@unique@bit\to\pgfplotstable@unique@bitlist
144 \let\pgfplotstable@unique@LAST=\pgfplotstable@unique@cur
145 }%
146 \global\let\pgfplotstable@unique@bitlist@backup=\pgfplotstable@unique@bitlist
147 \else
148 \pgfutil@ifundefined{pgfplotstable@unique@bitlist@backup}{%
149 % this sanity checking is NOT fool proof: it
150 % fails if there are different occurrences of
151 % unique in the same file
152 \pgfplotsthrow{invalid argument}{Sorry, the row predicate /pgfplots/table/unique={#1} has been used in the wrong context: it needs to be invoked for the very first processed column, not column no \pgfplotstablecol. Please provide it as argument to \string\pgfplotstabletypeset[unique={#1}] and not inside of column-specific styles}\pgfeov%
153 }{}%
154 \fi
155 % acquire the assembled list here: we'll do a lot of
156 % popfronts with it.
157 \let\pgfplotstable@unique@bitlist=\pgfplotstable@unique@bitlist@backup
158 \fi
159 \pgfplotslistcheckempty\pgfplotstable@unique@bitlist
160 \ifpgfplotslistempty
161 % should not happen!
162 \pgfplotstableuserowfalse
163 \else
164 \pgfplotslistpopfront\pgfplotstable@unique@bitlist\to\pgfplots@loc@TMPa
165 \if\pgfplots@loc@TMPa0%
166 \pgfplotstableuserowfalse
167 \fi
168 \fi
169 % cleanup:
170 {%
171 \count0=\pgfplotstablecol\relax \advance\count0 by1
172 \ifnum\count0=\pgfplotstablecols\relax
173 \count0=\pgfplotstablerow\relax \advance\count0 by1
174 \ifnum\count0=\pgfplotstablerows\relax
175 \global\let\pgfplotstable@unique@bitlist@backup=\relax
176 \fi
177 \fi
178 }%
179 }}%
180 },%
181 % columns={name1,name2}
182 % or
183 % columns={[index]2,name2,name3,[index]5}
184 /pgfplots/table/columns/.initial=,
185 %
186 % this choice allows
187 % \pgfplotstableset{
188 % column name={}, % means: the column's display name is an empty string!
189 % column name=\pgfkeysnovalue, % means: no value specified. In this case,
190 % the column's display name will default to column's name.
191 % }
192 /pgfplots/table/column name/.initial=\pgfkeysnovalue,
193 %
194 % this thing here allows to MODIFY 'column name'.
195 %
196 % Argument #1 is the current column name, that means after
197 % evaluating 'column name'. If this key changes anything, it
198 % should write its result back into 'column name'.
199 %
200 % That means you can use 'column name' to assign the name as such
201 % and 'assign column name' to generate final TeX code (for example
202 % to insert \multicolumn{1}{c}{#1} or so).
203 % default is empty which means no change.
204 %/pgfplots/table/assign column name/.code={
205 % \pgfkeyssetvalue{/pgfplots/table/column name}{#1}%
206 %},
207 %
208 %
209 %
210 % A style which inserts \multicolumn{1}{#1}{<column name>} for
211 % each column name.
212 % The column name as such can be set with the 'column name' option.
213 /pgfplots/table/multicolumn names/.style={%
214 /pgfplots/table/assign column name/.code={%
215 \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{1}{#1}{##1}}%
216 }%
217 },
218 /pgfplots/table/multicolumn names/.default=c,
219 /pgfplots/table/dec sep align/.code={%
220 \pgfplots@assert@LaTeX@package@loaded{array}{dec sep align}%
221 \def\pgfplotstable@scisepalign@headeralign{#1}%
222 \pgfkeysalso{%
223 /pgf/number format/assume math mode,
224 /pgf/number format/@dec sep mark={$&$},
225 /pgfplots/table/assign column name/.code={%
226 \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}%
227 },%
228 /pgfplots/table/column type={%
229 r<{\pgfplotstableresetcolortbloverhangright}%
230 @{}%
231 l<{\pgfplotstableresetcolortbloverhangleft}%
232 },
233 /pgfplots/table/assign cell content/.code={%
234 \def\pgfmathresult{##1}%
235 \let\continue=\pgfutil@empty
236 % allow special handling:
237 \pgfplots@invoke@pgfkeyscode{/pgfplots/table/dec sep align/process/.@cmd}{##1}%
238 \ifx\continue\pgfutil@empty
239 % nothing has changed. Processed as usual:
240 \ifx\pgfmathresult\pgfutil@empty
241 \def\pgfmathresult{&}%
242 \else
243 % -6.90000001e-01 -> \meaning\pgfmathresult = macro:->-0$&$.69
244 \pgfmathprintnumberto{\pgfmathresult}\pgfmathresult%
245 % now make sure we have math mode for the single
246 % columns:
247 \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}%
248 \fi
249 \fi
250 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
251 },
252 }%
253 },
254 /pgfplots/table/dec sep align/.default=c,
255 %
256 % A part of dec sep align which can be used to process special
257 % cases.
258 %
259 % #1: the unprocessed input argument.
260 % PRECONDITION:
261 % \pgfmathresult contains '#1', not more.
262 % \continue is empty.
263 %
264 % POSTCONDITION:
265 % If \continue is empty, `dec sep align' will continue just as
266 % if the 'process' key hadn't been invoked.
267 % It will, however, use the current value of \pgfmathresult.
268 %
269 % If \continue is NOT empty, for example \def\continue{0},
270 % `dec sep align' assumes that \pgfmathresult contains the
271 % completely typeset cell, including any alignment material.
272 /pgfplots/table/dec sep align/process/.code=,%
273 /pgfplots/table/dec sep align/no unbounded/.style={%
274 % FIXME : this thing doesn't work as intended! It looks ugly!
275 /pgfplots/table/dec sep align/process/.code={%
276 \ifx\pgfmathresult\pgfutil@empty
277 \else
278 \pgfmathfloatparsenumber\pgfmathresult
279 \pgfmathfloatiffinite{\pgfmathresult}{%
280 % do nothing, just communicate the parsed
281 % \pgfmathresult
282 }{%
283 \begingroup
284 \t@pgfplots@toka=\expandafter{\pgfplotstable@scisepalign@headeralign}%
285 \t@pgfplots@tokb={\pgfkeyslet{/pgf/number format/@dec sep mark}\pgfutil@empty\pgfmathprintnumber}%
286 \t@pgfplots@tokc=\expandafter{\pgfmathresult}%
287 \xdef\pgfplotstable@glob@TMPc{%
288 \noexpand\multicolumn{2}{\the\t@pgfplots@toka}%
289 {\the\t@pgfplots@tokb{\the\t@pgfplots@tokc}}%
290 }%
291 \endgroup
292 \let\pgfmathresult=\pgfplotstable@glob@TMPc
293 \def\continue{0}%
294 }%
295 \fi
296 },%
297 },%
298 /pgfplots/table/sci sep align/.code={%
299 \pgfplots@assert@LaTeX@package@loaded{array}{sci sep align}%
300 \pgfkeysalso{%
301 /pgf/number format/assume math mode,
302 /pgf/number format/@sci exponent mark={$&$},
303 /pgfplots/table/assign column name/.code={%
304 \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}%
305 },%
306 /pgfplots/table/column type={%
307 r<{\pgfplotstableresetcolortbloverhangright}%
308 @{}%
309 l<{\pgfplotstableresetcolortbloverhangleft}%
310 },
311 /pgfplots/table/assign cell content/.code={%
312 \def\pgfmathresult{##1}%
313 \ifx\pgfmathresult\pgfutil@empty
314 \def\pgfmathresult{&}%
315 \else
316 \pgfmathprintnumberto{##1}\pgfmathresult%
317 \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}%
318 % now make sure we have math mode for the single
319 % columns:
320 \ifpgfutil@in@
321 \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}%
322 \else
323 \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter\pgfutilensuremath\expandafter{\pgfmathresult}&}%
324 \fi
325 \fi
326 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
327 },
328 }%
329 },
330 /pgfplots/table/sci sep align/.default=c,
331 %
332 % A style which can be used together with the 'dcolumn' package by
333 % David Carlisle.
334 % #1: the dcolumn type, defaults to 'D{.}{.}{2}'
335 % #2: the column name type, defaults to 'c'
336 /pgfplots/table/dcolumn/.style 2 args={%
337 /pgf/number format/assume math mode,
338 column type={#1},
339 multicolumn names=#2,
340 },
341 /pgfplots/table/dcolumn/.default={D{.}{.}{2}}{c},
342 /pgfplots/table/column type/.initial={c},
343 /pgfplots/table/every even row/.style={},
344 /pgfplots/table/every odd row/.style={},
345 /pgfplots/table/every last row/.style={},
346 /pgfplots/table/every first row/.style={},
347 /pgfplots/table/every head row/.style={},
348 /pgfplots/table/every first column/.style={},
349 /pgfplots/table/every last column/.style={},
350 /pgfplots/table/every even column/.style={},
351 /pgfplots/table/every column/.style={},
352 /pgfplots/table/every odd column/.style={},
353 /pgfplots/table/every nth row/.code 2 args={%
354 \pgfplotstabletypeset@append@every@nth@row{#1}{#2}%
355 },
356 /pgfplots/table/every nth row/.style 2 args/.code 2 args={%
357 \pgfplotstabletypeset@append@every@nth@row{#1}{#2}%
358 },
359 /pgfplots/table/before row/.initial=,
360 /pgfplots/table/after row/.initial=,
361 /pgfplots/table/begin table/.initial={\begin{tabular}},
362 /pgfplots/table/end table/.initial={\end{tabular}},
363 /pgfplots/table/outfile/.initial=,
364 /pgfplots/table/include outfiles/.is if=pgfplotstabletypeset@includeoutfiles,
365 /pgfplots/table/include outfiles/.default=true,
366 /pgfplots/table/force remake/.is if=pgfplotstabletypeset@force@remake,
367 /pgfplots/table/force remake/.default=true,
368 /pgfplots/table/write to macro/.initial=,
369 /pgfplots/table/typeset/.is if=pgfplotstabletypesetresult,
370 /pgfplots/table/typeset=true,
371 /pgfplots/table/skip coltypes/.is if=pgfplotstabletypesetskipcoltypes,
372 /pgfplots/table/skip coltypes/.default=true,
373 /pgfplots/table/debug/.is if=pgfplotstabletypesetdebug,
374 /pgfplots/table/debug level/.initial=0,%
375 %
376 % will be redefined by |assign cell content| for every cell:
377 /pgfplots/table/@cell content/.initial=,
378 %
379 % #1: the cells content as it has been found in the input table
380 % this command key should somehow fill |cell content|.
381 /pgfplots/table/assign cell content/.code={%
382 \def\pgfmathresult{#1}%
383 \ifx\pgfmathresult\pgfutil@empty
384 \else
385 \pgfmathprintnumberto{#1}\pgfmathresult%
386 \fi
387 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
388 },
389 %
390 % this here is the default formatting. It uses
391 % \pgfmathprintnumber.
392 /pgfplots/table/assign cell content as number/.code={%
393 \def\pgfmathresult{#1}%
394 \ifx\pgfmathresult\pgfutil@empty
395 \else
396 \pgfmathprintnumberto{#1}\pgfmathresult%
397 \fi
398 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
399 },
400 /pgfplots/table/numeric type/.code={%
401 \pgfkeysgetvalue{/pgfplots/table/assign cell content as number/.@cmd}\pgfplotstable@loc@TMPa%
402 \pgfkeyslet{/pgfplots/table/assign cell content/.@cmd}\pgfplotstable@loc@TMPa
403 },
404 /pgfplots/table/string type/.style={%
405 /pgfplots/table/assign cell content/.style={%
406 /pgfplots/table/@cell content={##1}%
407 }%
408 },%
409 /pgfplots/table/verb string type/.style={%
410 /pgfplots/table/text special chars={\#,\|,\_},% FIXME: too limited ...
411 /pgfplots/table/assign cell content/.code={%
412 \def\pgfplotstable@loc@TMPa{##1}%
413 % hm... this here might be more robust instead of the line
414 % above. But not much, I suppose:
415 %\t@pgfplotstable@a={##1}%
416 %\edef\pgfplotstable@loc@TMPa{\the\t@pgfplotstable@a}%
417 \pgfplots@command@to@string\pgfplotstable@loc@TMPa\pgfplotstable@loc@TMPa
418 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplotstable@loc@TMPa}%
419 }%
420 },%
421 /pgfplots/table/numeric as string type/.style={%
422 /pgfplots/table/assign cell content/.code={%
423 \def\pgfmathresult{##1}%
424 \ifx\pgfmathresult\pgfutil@empty
425 \else
426 \pgfmathifisint{##1}{\let\pgfmathresult=\pgfretval}{\pgfmathfloattosci{\pgfretval}}%
427 \fi
428 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
429 }%
430 },%
431 /pgfplots/table/date type/.style={%
432 /pgfplots/table/assign cell content/.code={%
433 \begingroup
434 \pgfcalendardatetojulian{##1}\c@pgfplotstable@counta
435 \pgfcalendarjuliantodate{\c@pgfplotstable@counta}\year\month\day
436 \pgfcalendarjuliantoweekday\c@pgfplotstable@counta\c@pgf@countc
437 \edef\weekday{\the\c@pgf@countc }%
438 \edef\weekdayname{\pgfcalendarweekdayname\c@pgf@countc}%
439 \edef\weekdayshortname{\pgfcalendarweekdayshortname\c@pgf@countc}%
440 \edef\monthname{\pgfcalendarmonthname\month}%
441 \edef\monthshortname{\pgfcalendarmonthshortname\month}%
442 \xdef\pgfplots@glob@TMPa{#1}%
443 \endgroup
444 \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPa%
445 }%
446 },%
447 /pgfplots/table/date type/.default={\year/\month/\day},%
448 /pgfplots/table/set content/.style={%
449 /pgfplots/table/postproc cell content/.style={%
450 /pgfplots/table/@cell content={#1}%
451 }%
452 },%
453 %
454 /pgfplots/table/postproc cell content/.code={},
455 /pgfplots/table/preproc cell content/.code={},
456 %
457 /pgfplots/table/clear infinite/.style={%
458 /pgfplots/table/preproc cell content/.append code={%
459 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
460 \ifx\pgfmathresult\pgfutil@empty
461 \else
462 \pgfmathfloatparsenumber{\pgfmathresult}%
463 \let\pgfmatharga=\pgfmathresult
464 {%
465 \pgfmathfloatgetflags\pgfmatharga\c@pgfplotstable@counta
466 \xdef\pgfplots@glob@TMPc{\the\c@pgfplotstable@counta}%
467 }%
468 \ifnum\pgfplots@glob@TMPc<3
469 \pgfmathfloattosci@\pgfmathresult
470 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
471 \else
472 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfutil@empty}%
473 \fi
474 \fi
475 }
476 },
477 /pgfplots/table/string replace/.style 2 args={%
478 /pgfplots/table/preproc cell content/.append code={%
479 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
480 \def\pgfplots@loc@TMPa{#1}%
481 \ifx\pgfmathresult\pgfplots@loc@TMPa
482 \def\pgfplots@loc@TMPb{#2}%
483 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplots@loc@TMPb}%
484 \fi
485 }
486 },
487 /pgfplots/table/string replace*/.style 2 args={%
488 /pgfplots/table/preproc cell content/.append code={%
489 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
490 \def\pgfplots@loc@TMPa{\pgfplotsutilstrreplace{#1}{#2}}%
491 \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
492 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplotsretval}%
493 }
494 },
495 /pgfplots/table/preproc/expr/.code={%
496 \ifpgfplots@usefpu
497 \pgfkeysalso{/pgf/fpu=true,/pgf/fpu/output format=sci}%
498 \fi
499 \expandafter\def\csname pgfplotstable@preproc@expr@thisrow@\pgfplotstablecolname\endcsname{\pgfkeysvalueof{/pgfplots/table/@cell content}}%
500 \def\thisrow##1{%
501 \pgfutil@ifundefined{pgfplotstable@preproc@expr@thisrow@##1}{%
502 --inaccessable--%
503 }{%
504 \csname pgfplotstable@preproc@expr@thisrow@##1\endcsname
505 }%
506 }%
507 \pgfkeysalso{/pgfplots/table/preproc cell content/.append code={%
508 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
509 \ifx\pgfmathresult\pgfutil@empty
510 \else
511 \pgfmathparse{#1}%
512 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult%
513 \fi
514 }%
515 }%
516 },
517 /pgfplots/table/multiply -1/.style={%
518 /pgfplots/table/preproc cell content/.append code={%
519 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
520 \ifx\pgfmathresult\pgfutil@empty
521 \else
522 \pgfmathfloatparsenumber{\pgfmathresult}%
523 \let\pgfmatharga=\pgfmathresult
524 \pgfmathfloatcreate{2}{1.0}{0}%
525 \let\pgfmathargb=\pgfmathresult
526 \pgfmathfloatmultiply@{\pgfmatharga}{\pgfmathargb}%
527 \pgfmathfloattosci@\pgfmathresult
528 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
529 \fi
530 }
531 },
532 /pgfplots/table/multiply with/.style={/pgfplots/table/multiply by={#1}},%
533 /pgfplots/table/multiply by/.code={%
534 \pgfmathfloatparsenumber{#1}%
535 \let\pgfplotstable@scale=\pgfmathresult
536 \pgfkeysalso{
537 /pgfplots/table/preproc cell content/.append code={%
538 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
539 \ifx\pgfmathresult\pgfutil@empty
540 \else
541 \pgfmathfloatparsenumber{\pgfmathresult}%
542 \let\pgfmatharga=\pgfmathresult
543 \pgfmathfloatmultiply@{\pgfmatharga}{\pgfplotstable@scale}%
544 \pgfmathfloattosci@\pgfmathresult
545 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
546 \fi
547 }%
548 }%
549 },
550 /pgfplots/table/divide by/.code={%
551 \pgfkeysalso{/pgfplots/table/multiply by=#1}%
552 \let\pgfplotstable@divisor=\pgfplotstable@scale
553 \pgfmathfloatcreate{1}{1.0}{0}%
554 \let\pgfplotstable@ONE=\pgfmathresult
555 \pgfmathfloatdivide@{\pgfplotstable@ONE}{\pgfplotstable@divisor}%
556 \let\pgfplotstable@scale=\pgfmathresult
557 },
558 /pgfplots/table/sqrt/.style={%
559 /pgfplots/table/preproc cell content/.append code={%
560 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
561 \ifx\pgfmathresult\pgfutil@empty
562 \else
563 \pgfmathfloatparsenumber{\pgfmathresult}%
564 \let\pgfmatharga=\pgfmathresult
565 \pgfmathfloatsqrt@{\pgfmatharga}%
566 \pgfmathfloattosci@\pgfmathresult
567 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
568 \fi
569 }%
570 },
571 /pgfplots/table/empty cells with/.style={%
572 /pgfplots/table/postproc cell content/.append code={%
573 \ifnum\pgfplotstablepartno=0
574 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
575 \ifx\pgfmathresult\pgfutil@empty
576 \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}%
577 \fi
578 \fi
579 }%
580 },
581 /pgfplots/table/fonts by sign/.style 2 args={%
582 /pgfplots/table/postproc cell content/.append code={%
583 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfplotsretval
584 \ifx\pgfplotsretval\pgfutil@empty
585 \else
586 \t@pgfplots@toka=\expandafter{\pgfplotsretval}%
587 \t@pgfplots@tokb={#1}%
588 \t@pgfplots@tokc={#2}%
589 \pgfmathfloatparsenumber{\pgfkeysvalueof{/pgfplots/table/@preprocessed cell content}}%
590 \pgfmathfloatifflags{\pgfmathresult}{-}{%
591 \edef\pgfmathresult{{\the\t@pgfplots@tokc{\the\t@pgfplots@toka}}}%
592 }{%
593 \edef\pgfmathresult{{\the\t@pgfplots@tokb{\the\t@pgfplots@toka}}}%
594 }%
595 \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
596 \fi
597 }%
598 },%
599 %
600 /pgfplots/table/font/.initial=,
601 /pgfplots/table/.search also={/pgf/number format,/pgfplots/table/create col},
602 %--------------------------------------------------
603 % /pgfplots/table/.unknown/.code={%
604 % \let\pgfplots@table@curkeyname=\pgfkeyscurrentname
605 % \pgfqkeys{/pgf/number format}{\pgfplots@table@curkeyname=#1}%
606 % },%
607 %--------------------------------------------------
608 /pgfplots/table/create col/assign first/.style={
609 /pgfplots/table/create col/assign%
610 },
611 /pgfplots/table/create col/assign last/.style={
612 /pgfplots/table/create col/assign%
613 },
614 /pgfplots/table/create col/assign/.style={
615 /pgfplots/table/create col/next content={}%
616 },
617 /pgfplots/table/create col/next content/.initial={},
618 /pgfplots/table/create col/copy/.style={%
619 /pgfplots/table/create col/assign/.code={%
620 \getthisrow{#1}\pgfmathresult
621 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
622 }%
623 },
624 /pgfplots/table/create col/set/.style={%
625 /pgfplots/table/create col/assign/.code={%
626 \def\pgfmathresult{#1}%
627 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
628 }%
629 },%
630 /pgfplots/table/create col/set list/.code={%
631 \pgfplots@assign@list\pgfmathaccumb{#1}%
632 \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}%
633 },%
634 /pgfplots/table/create col/expr accum/.code 2 args={%
635 \ifpgfplots@usefpu
636 \pgfkeysalso{/pgf/fpu=true,/pgf/fpu/output format=sci}%
637 \fi
638 \pgfkeysdef{/pgfplots/table/create col/assign}{%
639 \ifx\pgfmathaccuma\pgfutil@empty
640 \pgfmathparse{#2}%
641 \let\pgfmathaccuma=\pgfmathresult
642 \fi
643 \pgfmathparse{#1}%
644 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
645 \let\pgfmathaccuma=\pgfmathresult
646 }%
647 },
648 /pgfplots/table/create col/expr/.style={%
649 /pgfplots/table/create col/expr accum={#1}{0}%
650 },%
651 /pgfplots/table/create col/copy column from table/.code 2 args={%
652 \pgfplotstablegetcolumn{#2}\of{#1}\to\pgfmathaccumb
653 \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}%
654 },
655 /pgfplots/table/create col/@from list struct/.code={%
656 \pgfplotslistcopy#1\to\pgfmathaccumb
657 \pgfkeysdef{/pgfplots/table/create col/assign}{%
658 \pgfplotslistcheckempty\pgfmathaccumb
659 \ifpgfplotslistempty
660 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
661 \else
662 \pgfplotslistpopfront\pgfmathaccumb\to\pgfmathresult
663 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
664 \fi
665 }%
666 },
667 /pgfplots/table/create col/linear regression/.code={%
668 \pgfplotstable@linear@regression{#1}%
669 \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfplotsretval}%
670 },
671 /pgfplots/table/create col/linear regression/.default=,%
672 /pgfplots/table/create col/linear regression/x/.initial=,%
673 /pgfplots/table/create col/linear regression/y/.initial=,%
674 /pgfplots/table/create col/linear regression/table/.initial=,%
675 /pgfplots/table/create col/linear regression/variance/.initial=,%
676 /pgfplots/table/create col/linear regression/variance list/.initial=,%
677 /pgfplots/table/create col/linear regression/variance src/.initial=,%
678 /pgfplots/table/create col/linear regression/variance format/.is choice,%
679 /pgfplots/table/create col/linear regression/variance format/linear/.code={\def\pgfplotstable@regression@variance@format{l}},%
680 /pgfplots/table/create col/linear regression/variance format/log/.code={\def\pgfplotstable@regression@variance@format{m}},%
681 /pgfplots/table/create col/linear regression/variance format/log,%
682 /pgfplots/table/create col/linear regression/xmode/.initial=,% auto
683 /pgfplots/table/create col/linear regression/ymode/.initial=,% auto
684 /pgfplots/table/create col/quotient/.style={%
685 /pgfplots/table/columns={#1},
686 /pgfplots/table/create col/assign first/.style={%
687 /pgfplots/table/create col/next content=
688 },%
689 /pgfplots/table/create col/assign/.code={%
690 \pgfmathfloatparsenumber{\prevrow{#1}}%
691 \let\pgfmatharga=\pgfmathresult
692 \pgfmathfloatparsenumber{\thisrow{#1}}%
693 \let\pgfmathargb=\pgfmathresult
694 \let\pgfmathaccuma=\pgfmathargb
695 \pgfplots@ifzero\pgfmathargb{%
696 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
697 }{%
698 \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}%
699 \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
700 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
701 }%
702 }%
703 },%
704 /pgfplots/table/create col/iquotient/.style={%
705 /pgfplots/table/columns={#1},
706 /pgfplots/table/create col/assign first/.style={%
707 /pgfplots/table/create col/next content=
708 },%
709 /pgfplots/table/create col/assign/.code={%
710 \pgfmathfloatparsenumber{\prevrow{#1}}%
711 \let\pgfmathargb=\pgfmathresult
712 \pgfmathfloatparsenumber{\thisrow{#1}}%
713 \let\pgfmatharga=\pgfmathresult
714 \let\pgfmathaccuma=\pgfmathargb
715 \pgfplots@ifzero\pgfmathargb{%
716 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
717 }{%
718 \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}%
719 \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
720 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
721 }%
722 }%
723 },%
724 %
725 % Produces 'log2( \prevrow{#1}/\thisrow{#1} )
726 %
727 % Assumeing that every row contains error(h) = O(h^alpha)
728 % and h_this = h_prev/2, this result in 'alpha', the convergence
729 % rate.
730 /pgfplots/table/create col/dyadic refinement rate/.style={%
731 /pgfplots/table/columns={#1},
732 /pgfplots/table/create col/assign first/.style={%
733 /pgfplots/table/create col/next content=
734 },%
735 /pgfplots/table/create col/assign/.code={%
736 \pgfmathfloatparsenumber{\prevrow{#1}}%
737 \let\pgfmatharga=\pgfmathresult
738 \pgfmathfloatparsenumber{\thisrow{#1}}%
739 \let\pgfmathargb=\pgfmathresult
740 \let\pgfmathaccuma=\pgfmathargb
741 \pgfplots@ifzero\pgfmathargb{%
742 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
743 }{%
744 \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}%
745 \pgfmathlog@float{\pgfmathresult}%
746 \ifx\pgfmathresult\pgfutil@empty
747 \else
748 \pgfmathmultiply@{1.442695}{\pgfmathresult}%
749 \fi
750 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
751 }%
752 }%
753 },%
754 /pgfplots/table/create col/idyadic refinement rate/.style={%
755 /pgfplots/table/columns={#1},
756 /pgfplots/table/create col/assign first/.style={%
757 /pgfplots/table/create col/next content=
758 },%
759 /pgfplots/table/create col/assign/.code={%
760 \pgfmathfloatparsenumber{\prevrow{#1}}%
761 \let\pgfmathargb=\pgfmathresult
762 \pgfmathfloatparsenumber{\thisrow{#1}}%
763 \let\pgfmatharga=\pgfmathresult
764 \let\pgfmathaccuma=\pgfmathargb
765 \pgfplots@ifzero\pgfmathargb{%
766 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
767 }{%
768 \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}%
769 \pgfmathlog@float{\pgfmathresult}%
770 \ifx\pgfmathresult\pgfutil@empty
771 \else
772 \pgfmathmultiply@{1.442695}{\pgfmathresult}%
773 \fi
774 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
775 }%
776 }%
777 },%
778 /pgfplots/table/create col/gradient/.style 2 args={%
779 /pgfplots/table/columns={#1,#2},
780 /pgfplots/table/create col/assign first/.code={%
781 \pgfmathfloatparsenumber{\thisrow{#1}}%
782 \let\pgfmathaccuma=\pgfmathresult
783 \pgfmathfloatparsenumber{\thisrow{#2}}%
784 \let\pgfmathaccumb=\pgfmathresult
785 \def\pgfmathresult{}% leave first empty.
786 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
787 },%
788 /pgfplots/table/create col/assign/.code={%
789 \let\pgfmathcur@x=\pgfmathaccuma
790 \let\pgfmathcur@y=\pgfmathaccumb
791 \pgfmathfloatparsenumber{\thisrow{#1}}%
792 \let\pgfmathnext@x=\pgfmathresult
793 \let\pgfmathaccuma=\pgfmathnext@x
794 \pgfmathfloatparsenumber{\thisrow{#2}}%
795 \let\pgfmathnext@y=\pgfmathresult
796 \let\pgfmathaccumb=\pgfmathnext@y
797 \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}%
798 \let\pgfmathdiff@x=\pgfmathresult
799 \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}%
800 \let\pgfmathdiff@y=\pgfmathresult
801 \pgfplots@ifzero\pgfmathdiff@x{%
802 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
803 }{%
804 \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}%
805 \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
806 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
807 }%
808 },%
809 },%
810 /pgfplots/table/create col/gradient loglog/.style 2 args={%
811 /pgfplots/table/columns={#1,#2},
812 /pgfplots/table/create col/assign first/.code={%
813 \pgfmathlog{\thisrow{#1}}%
814 \let\pgfmathaccuma=\pgfmathresult
815 \pgfmathlog{\thisrow{#2}}%
816 \let\pgfmathaccumb=\pgfmathresult
817 \def\pgfmathresult{}% leave first empty.
818 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
819 },%
820 /pgfplots/table/create col/assign/.code={%
821 \let\pgfmathcur@x=\pgfmathaccuma
822 \let\pgfmathcur@y=\pgfmathaccumb
823 \pgfmathlog{\thisrow{#1}}%
824 \let\pgfmathnext@x=\pgfmathresult
825 \let\pgfmathaccuma=\pgfmathresult
826 \pgfmathlog{\thisrow{#2}}%
827 \let\pgfmathnext@y=\pgfmathresult
828 \let\pgfmathaccumb=\pgfmathresult
829 \pgfplots@loop@CONTINUEtrue
830 \ifx\pgfmathcur@x\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi
831 \ifx\pgfmathcur@y\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi
832 \ifx\pgfmathnext@x\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi
833 \ifx\pgfmathnext@y\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi
834 \ifpgfplots@loop@CONTINUE
835 \pgfmathsubtract@{\pgfmathnext@x}{\pgfmathcur@x}%
836 \let\pgfmathdiff@x=\pgfmathresult
837 \pgfmathsubtract@{\pgfmathnext@y}{\pgfmathcur@y}%
838 \let\pgfmathdiff@y=\pgfmathresult
839 % FPU is more robust:
840 \pgfmathfloatparsenumber\pgfmathdiff@x\let\pgfmathdiff@x=\pgfmathresult
841 \pgfmathfloatparsenumber\pgfmathdiff@y\let\pgfmathdiff@y=\pgfmathresult
842 \pgfplots@ifzero\pgfmathdiff@x{%
843 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
844 }{%
845 \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}%
846 \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
847 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
848 }%
849 \else
850 % \pgfmathfloatcreate{3}{0.0}{0}%
851 % \pgfmathfloattosci@\pgfmathresult
852 % \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
853 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
854 \fi
855 },%
856 },%
857 /pgfplots/table/create col/gradient semilogx/.style 2 args={%
858 /pgfplots/table/columns={#1,#2},
859 /pgfplots/table/create col/assign first/.code={%
860 \pgfmathfloatparsenumber{\thisrow{#1}}
861 \pgfmathfloatln@{\pgfmathresult}%
862 \let\pgfmathaccuma=\pgfmathresult
863 \pgfmathfloatparsenumber{\thisrow{#2}}%
864 \let\pgfmathaccumb=\pgfmathresult
865 \def\pgfmathresult{}% leave first empty.
866 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
867 },%
868 /pgfplots/table/create col/assign/.code={%
869 \let\pgfmathcur@x=\pgfmathaccuma
870 \let\pgfmathcur@y=\pgfmathaccumb
871 \pgfmathfloatparsenumber{\thisrow{#1}}
872 \pgfmathfloatln@{\pgfmathresult}%
873 \let\pgfmathnext@x=\pgfmathresult
874 \let\pgfmathaccuma=\pgfmathresult
875 %
876 \pgfmathfloatparsenumber{\thisrow{#2}}%
877 \let\pgfmathnext@y=\pgfmathresult
878 \let\pgfmathaccumb=\pgfmathresult
879 \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}%
880 \let\pgfmathdiff@x=\pgfmathresult
881 \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}%
882 \let\pgfmathdiff@y=\pgfmathresult
883 \pgfplots@ifzero\pgfmathdiff@x{%
884 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
885 }{%
886 \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}%
887 \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
888 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
889 }%
890 },%
891 },%
892 /pgfplots/table/create col/gradient semilogy/.style 2 args={%
893 /pgfplots/table/columns={#1,#2},
894 /pgfplots/table/create col/assign first/.code={%
895 \pgfmathfloatparsenumber{\thisrow{#1}}%
896 \let\pgfmathaccuma=\pgfmathresult
897 \pgfmathfloatparsenumber{\thisrow{#2}}
898 \pgfmathfloatln@{\pgfmathresult}%
899 \let\pgfmathaccumb=\pgfmathresult
900 \def\pgfmathresult{}% leave first empty.
901 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
902 },%
903 /pgfplots/table/create col/assign/.code={%
904 \let\pgfmathcur@x=\pgfmathaccuma
905 \let\pgfmathcur@y=\pgfmathaccumb
906 \pgfmathfloatparsenumber{\thisrow{#2}}
907 \pgfmathfloatln@{\pgfmathresult}%
908 \let\pgfmathnext@y=\pgfmathresult
909 \let\pgfmathaccumb=\pgfmathresult
910 %
911 \pgfmathfloatparsenumber{\thisrow{#1}}%
912 \let\pgfmathnext@x=\pgfmathresult
913 \let\pgfmathaccuma=\pgfmathresult
914 \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}%
915 \let\pgfmathdiff@x=\pgfmathresult
916 \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}%
917 \let\pgfmathdiff@y=\pgfmathresult
918 \pgfplots@ifzero\pgfmathdiff@x{%
919 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
920 }{%
921 \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}%
922 \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
923 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
924 }%
925 },%
926 },%
927 /pgfplots/table/typeset cell/.code={%
928 \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax
929 \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1\\}%
930 \else
931 \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1&}%
932 \fi
933 },
934 % this can be omitted to omit the header row:
935 /pgfplots/table/output empty row/.style={%
936 /pgfplots/table/typeset cell/.code={%
937 \pgfkeyslet{/pgfplots/table/@cell content}\pgfutil@empty%
938 }%
939 },
940 /pgfplots/table/reset styles/.style={
941 /pgfplots/table/every table/.code=,
942 /pgfplots/table/every odd column/.code=,
943 /pgfplots/table/every column/.code=,
944 /pgfplots/table/every even column/.code=,
945 /pgfplots/table/every first column/.code=,
946 /pgfplots/table/every last column/.code=,
947 /pgfplots/table/every head row/.code=,
948 /pgfplots/table/every odd row/.code=,
949 /pgfplots/table/every even row/.code=,
950 /pgfplots/table/every first row/.code=,
951 /pgfplots/table/every last row/.code=,
952 /pgfplots/table/postproc cell content/.code=,
953 /pgfplots/table/preproc cell content/.code=,
954 },
955 /pgfplots/table/colnames from/.initial=,% for \pgfplotstabletranspose
956 /pgfplots/table/input colnames to/.initial=colnames,% for \pgfplotstabletranspose
957 /pgfplots/table/sort/.is if=pgfplotstable@sort,
958 /pgfplots/table/sort/.default=true,
959 /pgfplots/table/sort key/.initial=[index]0,%
960 % the argument of `sort cmp' will be evaluates as style in the key
961 % path /pgfplots/. See pgfplotsutil.code.tex for available
962 % styles.
963 /pgfplots/table/sort cmp/.initial=float <,
964 /pgfplots/table/sort key from/.initial=,
965 }
966 % 'function graph cut y'={<epsilon>}{<options>}{comma-separated-list of specs where to get yi}
967 %
968 % fills the column with x1,...,xN such that yi(xi) == epsilon where
969 %
970 % In other words, it computes cuts points between the line
971 % y == epsilon and one or more other plots yi(x) and returns the 'x'
972 % values of the cuts.
973 %
974 % Example:
975 % \pgfplotstableset{
976 % create on use/cut/.style={create col/function graph cut y={7e-4}{x=Basis,ymode=log,xmode=log}{{table=regtable,y=special-L2}}},
977 %}
978 \pgfkeysdefnargs{/pgfplots/table/create col/function graph cut y}{3}{\pgfplotstable@fgc@init{#1}{#2}{#3}{y}{x}}
979 \pgfkeysdefnargs{/pgfplots/table/create col/function graph cut x}{3}{\pgfplotstable@fgc@init{#1}{#2}{#3}{x}{y}}
980 \pgfkeys{%
981 /pgfplots/table/create col/function graph cut/xmode/.is choice,
982 /pgfplots/table/create col/function graph cut/xmode/linear/.code={\def\pgfplotstable@fgc@xmode{0}},%
983 /pgfplots/table/create col/function graph cut/xmode/log/.code={\def\pgfplotstable@fgc@xmode{1}},%
984 /pgfplots/table/create col/function graph cut/ymode/.is choice,
985 /pgfplots/table/create col/function graph cut/ymode/linear/.code={\def\pgfplotstable@fgc@ymode{0}},%
986 /pgfplots/table/create col/function graph cut/ymode/log/.code={\def\pgfplotstable@fgc@ymode{1}},%
987 /pgfplots/table/create col/function graph cut/x/.initial=,
988 /pgfplots/table/create col/function graph cut/y/.initial=,
989 /pgfplots/table/create col/function graph cut/table/.initial=,
990 % foreach={\d in {1,2,3,4}}{{table\d}}
991 /pgfplots/table/create col/function graph cut/foreach/.initial=,
992 }
993
994
995 \pgfkeyslet{/pgfplots/table/TeX comment}\pgfplots@PERCENT@TEXT
996 \pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent@EMPTY
997
998
999 % A helper macro to automatically remove the "hangover" created by
1000 % 'colortbl'.
1001 % This allows compatibility between my 'sci sep align' and 'dec sep align'
1002 % implementations and \rowcolor. Otherwise, the hangover
1003 % would overwrite digits near the separator.
1004 %
1005 % @remark This does also work if colortbl is not loaded.
1006 \def\pgfplotstableresetcolortbloverhangright{%
1007 \pgfutil@ifundefined{CT@row@color}{\relax}{%
1008 \global\let\pgfplots@origrowcolorcmd=\CT@row@color
1009 \gdef\CT@row@color{%
1010 \pgfplots@origrowcolorcmd
1011 \@tempdimc=0pt
1012 \global\let\CT@row@color=\pgfplots@origrowcolorcmd
1013 }%
1014 }%
1015 }%
1016 \def\pgfplotstableresetcolortbloverhangleft{%
1017 \pgfutil@ifundefined{CT@row@color}{\relax}{%
1018 \global\let\pgfplots@origrowcolorcmd=\CT@row@color
1019 \gdef\CT@row@color{%
1020 \pgfplots@origrowcolorcmd
1021 \@tempdimb=0pt
1022 \global\let\CT@row@color=\pgfplots@origrowcolorcmd
1023 }%
1024 }%
1025 }%
1026
1027
1028 % \pgfplotstablesave[<options>]{<\tablename>}{file name}
1029 \def\pgfplotstablesave{%
1030 \pgfutil@ifnextchar[{%
1031 \pgfplotstablesave@impl
1032 }{%
1033 \pgfplotstablesave@impl[]%
1034 }%
1035 }
1036
1037 \def\pgfplotstablesave@impl[#1]#2#3{%
1038 \pgfplotstabletypeset[%
1039 reset styles,%
1040 disable rowcol styles,%
1041 begin table={},%
1042 end table={},%
1043 typeset cell/.code={%
1044 \begingroup
1045 \t@pgfplots@toka={##1}%
1046 \ifcase\pgfplotstableread@OUTCOLSEP@CASE\relax
1047 % col sep=SPACE:
1048 \t@pgfplots@tokb=\expandafter{\pgfplotstableread@tab}%
1049 \pgfplots@ifempty{##1}{%
1050 \t@pgfplots@toka={{}}%
1051 }{}%
1052 \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
1053 \or
1054 % col sep=comma:
1055 \t@pgfplots@tokb={,}%
1056 \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
1057 \or
1058 % col sep=semicolon:
1059 \t@pgfplots@tokb={;}%
1060 \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
1061 \or
1062 % col sep=colon:
1063 \t@pgfplots@tokb={:}%
1064 \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
1065 \or
1066 % col sep=braces:
1067 \xdef\pgfplots@glob@TMPc{{\the\t@pgfplots@toka}}%
1068 \or
1069 % col sep=tab:
1070 \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\pgfplotstableread@tab}%
1071 \or
1072 % col sep=&:
1073 \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka&}%
1074 \fi
1075 \endgroup
1076 \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPc%
1077 },%
1078 before row=,%
1079 after row=,%
1080 skip coltypes,%
1081 typeset=false,%
1082 string type,%
1083 TeX comment=,%
1084 columns=,%
1085 font=,%
1086 /pgfplots/table/col sep/.is choice,%
1087 /pgfplots/table/col sep/space/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{0}},%
1088 /pgfplots/table/col sep/comma/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{1}},%
1089 /pgfplots/table/col sep/semicolon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{2}},%
1090 /pgfplots/table/col sep/colon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{3}},%
1091 /pgfplots/table/col sep/braces/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{4}},%
1092 /pgfplots/table/col sep/tab/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{5}},%
1093 /pgfplots/table/col sep/&/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{6}},%
1094 /pgfplots/table/col sep/ampersand/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{6}},%
1095 /pgfplots/table/col sep=space,%
1096 /pgfplots/table/in col sep/.is choice,%
1097 /pgfplots/table/in col sep/space/.code = {\def\pgfplotstableread@COLSEP@CASE{0}},%
1098 /pgfplots/table/in col sep/comma/.code = {\def\pgfplotstableread@COLSEP@CASE{1}},%
1099 /pgfplots/table/in col sep/semicolon/.code = {\def\pgfplotstableread@COLSEP@CASE{2}},%
1100 /pgfplots/table/in col sep/colon/.code = {\def\pgfplotstableread@COLSEP@CASE{3}},%
1101 /pgfplots/table/in col sep/braces/.code = {\def\pgfplotstableread@COLSEP@CASE{4}},%
1102 /pgfplots/table/in col sep/tab/.code = {\def\pgfplotstableread@COLSEP@CASE{5}},%
1103 /pgfplots/table/in col sep/&/.code = {\def\pgfplotstableread@COLSEP@CASE{6}},%
1104 /pgfplots/table/in col sep/ampersand/.code = {\def\pgfplotstableread@COLSEP@CASE{6}},%
1105 /pgfplots/table/in col sep=space,%
1106 % WARNING: you NEED a '%' before '#1':
1107 #1,%
1108 /pgfplots/table/include outfiles=false,
1109 /pgfplots/table/outfile={#3}%
1110 ]{#2}%
1111 }%
1112
1113 % clears the table.
1114 \def\pgfplotstableclear#1{%
1115 \let#1=\relax
1116 \expandafter\let\csname \string#1@@table@name\endcsname=\relax
1117 }%
1118
1119
1120 % \pgfplotstablenew[<options>]{<numrows>}{<\name>}
1121 % \pgfplotstablenew*[<options>]{<numrows>}{<\name>}
1122 %
1123 % Creates a new table from scratch.
1124 %
1125 % The new table will contain all columns listed in the 'columns' key
1126 % which must be present in <options>. The starred version
1127 % \pgfplotstablenew* is not that strict: it will use the current value
1128 % of the columns key (not matter where and when it has been set).
1129 %
1130 % Furthermore, there must be 'create on use' statements for every
1131 % column which shall be generated. Columns are generated
1132 % independently, in the order of appearance in 'columns'.
1133 % The table will contain exactly <numrows> rows.
1134 \def\pgfplotstablenew{%
1135 \begingroup
1136 \pgfutil@ifnextchar*{\pgfplotstablenew@star}{\pgfplotstablenew@nostar}}
1137 \def\pgfplotstablenew@star*{\pgfutil@ifnextchar[{\pgfplotstablenew@impl}{\pgfplotstablenew@impl[]}}%
1138 \def\pgfplotstablenew@nostar{%
1139 % reset columns key:
1140 \pgfkeyslet{/pgfplots/table/columns}{\pgfutil@empty}%
1141 \pgfutil@ifnextchar[{\pgfplotstablenew@impl}{\pgfplotstablenew@impl[]}}
1142
1143 \def\pgfplotstablenew@impl[#1]#2#3{%
1144 \ifx#3\pgfutil@undefined
1145 \else
1146 \ifx#3\relax
1147 \else
1148 % oh - there *is* already such a table. The 'getcolumnbyname' method suffers from a flaw in 'ifexists' that I do not want to fix right now.
1149 % To work around that flaw, I merely clear the old table here:
1150 % let's hope that '#3' really *was* a table and not some other junk...
1151 \pgfplotslistforeachungrouped#3\as\pgfplotstable@loc@TMPa{%
1152 \expandafter\let\csname\string#3@\pgfplotstable@loc@TMPa\endcsname=\relax%
1153 }%
1154 \fi
1155 \fi
1156 %
1157 \pgfplotsscanlinelengthinitzero
1158 % create a temporary column with the desired number of rows:
1159 \pgfutil@in@\pgfplotstablegetrowsof{#2}%
1160 \ifpgfutil@in@
1161 #2%
1162 \let\pgfplotstable@loc@TMPa=\pgfmathresult
1163 \else
1164 \def\pgfplotstable@loc@TMPa{#2}%
1165 \fi
1166 %
1167 % let the table contain one column named '@@@@@temporary@column@':
1168 \pgfplotslistnew#3{@@@@@temporary@column@\\}%
1169 % populate the temporary column with enough rows:
1170 \ifnum\pgfplotstable@loc@TMPa>0
1171 \expandafter\pgfplots@assign@list\csname\string#3@@@@@@temporary@column@\endcsname{1,...,\pgfplotstable@loc@TMPa}%
1172 \else
1173 \expandafter\pgfplotslistnewempty\csname\string#3@@@@@@temporary@column@\endcsname%
1174 \fi
1175 %
1176 % now, create all real columns:
1177 \pgfplotstableset{#1,%
1178 /pgf/fpu/handlers/empty number/.code 2 args={%
1179 \pgfmathfloatcreate{0}{0.0}{0}%
1180 }%
1181 }%
1182 \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}%
1183 \ifx\pgfplotstable@colnames\pgfutil@empty
1184 \pgfplots@warning{\string\pgfplotstablenew[columns={},...]{#2}{\string#3} has been invoked - but empty tables are currently not really supported, sorry. You will have to live with an artificial column which contains temporary values.}%
1185 \else
1186 \expandafter\pgfplots@assign@list\expandafter\pgfplotstablenew@cols\expandafter{\pgfplotstable@colnames}%
1187 % make sure every requested column exists:
1188 \pgfutil@loop
1189 \pgfplotslistcheckempty\pgfplotstablenew@cols
1190 \ifpgfplotslistempty
1191 \pgfplots@loop@CONTINUEfalse
1192 \else
1193 \pgfplots@loop@CONTINUEtrue
1194 \fi
1195 \ifpgfplots@loop@CONTINUE
1196 \pgfplotslistpopfront\pgfplotstablenew@cols\to\pgfplotstablenew@col
1197 \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstablenew@col}\of#3\to\pgfplotstable@loc@TMPa
1198 \pgfutil@repeat
1199 % remove the temporary column:
1200 % FIXME this should be done after the '\fi'. But that will
1201 % lead to an error because empty tables are currently
1202 % unsupported!
1203 \pgfplotslistpopfront#3\to\pgfplotstable@loc@TMPa
1204 \fi
1205 \pgfplotsscanlinelengthcleanup
1206 \pgfplotstable@copy@to@globalbuffers#3{newlycreatedtable}%
1207 \endgroup
1208 \pgfplotstable@copy@globalbuffers@to#3%
1209 }%
1210
1211 % \pgfplotstablevertcat{<table1>}{<table2>}
1212 % appends the contents of <table2> to <table1>. To be more precise,
1213 % only columns which exist already in <table1> will be used.
1214 %
1215 % If <table1> is undefined, <table2> will be copied completely to
1216 % <table1>.
1217 %
1218 % #1 a table macro.
1219 % #2 either a file name or a table macro.
1220 \long\def\pgfplotstablevertcat#1#2{%
1221 \pgfplotstable@isloadedtable{#2}{%
1222 \pgfplotstable@isloadedtable{#1}{%
1223 % for each column in '#1':
1224 \pgfplotslistforeachungrouped#1\as\pgfplotstable@loc@TMPa{%
1225 % for each row in the corresponding column of '#2':
1226 \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@loc@TMPa}\of{#2}\to\pgfplotstable@loc@TMPb
1227 \pgfplotslistforeachungrouped\pgfplotstable@loc@TMPb\as\pgfplotstable@loc@TMPc{%
1228 \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPc}%
1229 \edef\pgfplotstable@loc@TMPd{%
1230 \noexpand\pgfplotslistpushback{\the\t@pgfplots@toka}\noexpand\to\expandafter\noexpand\csname\string#1@\pgfplotstable@loc@TMPa\endcsname
1231 }%
1232 \pgfplotstable@loc@TMPd
1233 }%
1234 }%
1235 }{%
1236 \pgfplotstablecopy{#2}\to{#1}%
1237 }%
1238 }{%
1239 % FIXME : restore memory here !? SCOPING BUG
1240 \pgfplotstableread{#2}\pgfplotstable@tmptbl
1241 \pgfplotstablevertcat{#1}{\pgfplotstable@tmptbl}%
1242 }%
1243 }
1244
1245 % \pgfplotstabletranspose{<\outtable>}{<intable>}
1246 % \pgfplotstabletranspose[<colname>]{<\outtable>}{<intable>}
1247 % Defines <\outtable> to be the transposed of <intable>.
1248 %
1249 % If <colname> is not empty, the respective column's entries will be used to
1250 % make output column names.
1251 %
1252 % #1: a table macro name which will be overwritten (redefined)
1253 % #2: either a file name or a table macro (loaded table).
1254 \def\pgfplotstabletranspose{%
1255 \begingroup
1256 \pgfutil@ifnextchar*{%
1257 \pgfplotstabletranspose@star%
1258 }{%
1259 \pgfkeyslet{/pgfplots/table/columns}\pgfutil@empty% clear!
1260 \pgfplotstabletranspose@star*%
1261 }%
1262 }
1263 \def\pgfplotstabletranspose@star*{\pgfutil@ifnextchar[{\pgfplotstabletranspose@opt}{\pgfplotstabletranspose@opt[]}}%
1264 \long\def\pgfplotstabletranspose@opt[#1]#2#3{%
1265 \pgfplotstable@isloadedtable{#3}{%
1266 \pgfplotstabletranspose@[#1]{#2}{#3}%
1267 }{%
1268 \pgfplotstableread{#3}\pgfplotstable@tmptbl
1269 \pgfplotstabletranspose@[#1]{#2}{\pgfplotstable@tmptbl}%
1270 }%
1271 }%
1272
1273
1274 % Creates a new column named #1 and appends it to table #2.
1275 %
1276 % The column entries will be created using the command keys
1277 % 'create col/assign'
1278 % 'create col/assign last'
1279 %
1280 % The key 'create col/assign' will be invoked for every row of table #2.
1281 % It is supposed to assign the key 'create col/next content'.
1282 % During evaluation of 'create col/assign', the macro '\thisrow{<col name>}'
1283 % expands to the current row's value of the column named by <col name>.
1284 % Furthermore, '\nextrow{<col name>}' expands to the \emph{next} row's
1285 % value of the designated column.
1286 %
1287 % Since the "next row" is not available if we are currently processing
1288 % the last row, 'create col/assign last' is used in for the last row's
1289 % value.
1290 %
1291 % You can use
1292 % - \thisrow{<col name>},
1293 % - \getthisrow{<col name>}{\macro}
1294 % - \nextrow{<col name>},
1295 % - \getnextrow{<col name>}{\macro}
1296 %
1297 % FIXME this documentation is incomplete. Please refer to pgfplotstable.pdf .
1298 \def\pgfplotstablecreatecol{%
1299 \pgfutil@ifnextchar[{%
1300 \pgfplotstablecreatecol@opt
1301 }{%
1302 \pgfplotstablecreatecol@opt[]%
1303 }%
1304 }%
1305
1306
1307 % Typesets a table.
1308 %
1309 % \pgfplotstabletypeset[<options>]<\tablestructure>
1310 % or
1311 % \pgfplotstabletypeset[<options>]{<file name>}
1312 %
1313 % If you do not select any columns, the complete table is drawn.
1314 %
1315 % There are several options and styles which are available in
1316 % <options>, see the declaration above.
1317 %
1318 % ATTENTION: the default implementation employs
1319 % \begin{tabular}...\end{tabular} and is therefore only usable with
1320 % LaTeX!
1321 %
1322 % You will need to reconfigure the tables.
1323 %
1324 % Inside of \pgfplotstabletypeset, the macros
1325 % \pgfplotstablecol,\pgfplotstablecolname and
1326 % \pgfplotstablerow will expand to the current column index, column
1327 % name and row index, respectively.
1328 \def\pgfplotstabletypeset{%
1329 \pgfutil@ifnextchar[{%
1330 \pgfplotstabletypeset@opt
1331 }{%
1332 \pgfplotstabletypeset@opt[]%
1333 }%
1334 }
1335 \long\def\pgfplotstabletypeset@opt[#1]{%
1336 \begingroup
1337 \ifpgfplots@table@options@areset
1338 \else
1339 \pgfplotstableset{#1}%
1340 \fi
1341 \pgfplotstablecollectoneargwithpreparecatcodes{%
1342 \pgfplotstabletypeset@opt@collectarg[#1]%
1343 }%
1344 }
1345 \long\def\pgfplotstabletypeset@opt@collectarg[#1]#2{%
1346 \pgfplotstable@isloadedtable{#2}%
1347 {\pgfplotstabletypeset@opt@[#1]{#2}}%
1348 {\pgfplotstabletypesetfile@opt@[#1]{#2}}%
1349 }
1350
1351
1352 % Like \pgfplotstabletypeset, but the first argument is a file name.
1353 % This is the same now; it will be recognised automatically.
1354 \let\pgfplotstabletypesetfile=\pgfplotstabletypeset
1355 \long\def\pgfplotstabletypesetfile@opt@[#1]#2{%
1356 %\begingroup <--- is already opened!
1357 \ifpgfplots@table@options@areset
1358 \else
1359 \pgfplotstableset@every@table{#2}{#1}%
1360 \pgfplots@table@options@aresettrue
1361 \fi
1362 \ifpgfplotstabletypeset@force@remake
1363 \pgfplotstabletypeset@includeoutfilesfalse
1364 \else
1365 \ifpgfplotstabletypeset@includeoutfiles
1366 \pgfplotstabletypeset@includeoutfilesfalse
1367 \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename
1368 \ifx\pgfplotstable@outfilename\pgfutil@empty
1369 \else
1370 \openin\r@pgfplots@reada=\pgfplotstable@outfilename\relax
1371 \ifeof\r@pgfplots@reada
1372 \else
1373 \pgfplotstabletypeset@includeoutfilestrue
1374 \fi
1375 \closein\r@pgfplots@reada
1376 \fi
1377 \fi
1378 \fi
1379 \ifpgfplotstabletypeset@includeoutfiles
1380 \input \pgfplotstable@outfilename\relax
1381 \else
1382 \pgfplotstableread{#2}\pgfplotstabletypesetfile@opt@@
1383 \ifx\pgfplotstabletypesetfile@opt@@\relax
1384 % ERROR.
1385 \else
1386 \pgfplotstabletypeset\pgfplotstabletypesetfile@opt@@
1387 \fi
1388 \fi
1389 \pgfkeysgetvalue{/pgfplots/table/write to macro}\pgfplots@loc@TMPa
1390 \ifx\pgfplots@loc@TMPa\pgfutil@empty
1391 \def\pgfplots@loc@TMPa{\pgfutil@empty}%
1392 \else
1393 \expandafter\ifx\pgfplots@loc@TMPa\relax
1394 % is it really defined? NO! Sanity checking here:
1395 \def\pgfplots@loc@TMPa{\pgfutil@empty}%
1396 \fi
1397 \fi
1398 \expandafter\pgfmath@smuggleone\pgfplots@loc@TMPa
1399 \endgroup
1400 }%
1401
1402 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1403 %
1404 % IMPLEMENTATION
1405 %
1406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1407
1408
1409 %%%%%%%%%%%%%%%
1410
1411
1412 % #1: the original value
1413 % #2: the output macro
1414 \long\def\pgfplotstabletypeset@getfinalentry#1#2{%
1415 \begingroup
1416 \def\pgfkeysdefaultpath{/pgfplots/table/}%
1417 \def\pgfplotstablepartno{0}%
1418 \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}%
1419 \pgfkeyssetvalue{/pgfplots/table/@unprocessed cell content}{#1}%
1420 \ifpgfplotstable@disable@rowcolstyles
1421 \else
1422 \def\pgfplots@loc@TMPb##1{%
1423 \edef\pgfplotstable@loc@TMPa{/pgfplots/table/every row ##1\pgfplotstablerow\space column ##1\pgfplotstablecol}%
1424 \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{%
1425 \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}%
1426 }{}%
1427 \edef\pgfplotstable@loc@TMPa{/pgfplots/table/every row ##1\pgfplotstablerow\space column \pgfplotstable@colname@for@styles}%
1428 \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{%
1429 \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}%
1430 }{}%
1431 }%
1432 \pgfplots@loc@TMPb{}%
1433 % also accept the same with the 'row no' style:
1434 \pgfplots@loc@TMPb{no }%
1435 \pgfplotstable@debug@notify@cellcontent@afterrowcolstyles%
1436 \fi
1437 \pgfplotstable@debug@notify@cellcontent%
1438 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1439 \pgfkeyslet{/pgfplots/table/@cell content after rowcol styles}\pgfmathresult%
1440 \pgfkeysgetvalue{/pgfplots/table/preproc cell content/.@cmd}\pgfplotstable@assigncell
1441 \expandafter\pgfplotstable@assigncell\pgfmathresult\pgfeov
1442 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1443 \pgfkeyslet{/pgfplots/table/@preprocessed cell content}\pgfmathresult%
1444 \pgfplotstable@debug@notify@cellcontent@preprocessed%
1445 %
1446 \pgfkeysgetvalue{/pgfplots/table/assign cell content/.@cmd}\pgfplotstable@assigncell
1447 \expandafter\pgfplotstable@assigncell\pgfmathresult\pgfeov
1448 \pgfplotstable@debug@notify@cellcontent@assigned%
1449 %
1450 \pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent
1451 \ifx\pgfplotstable@postproccellcontent\pgfplotstable@postproccellcontent@EMPTY
1452 \else
1453 % apply postprocessing to final cell content.
1454 \def\pgfplotstabletypeset@rawinput{#1}%
1455 %
1456 % This is complicated if there is an '&' in '@cell content',
1457 % so handle that specially!
1458 %
1459 % FIXME also support more than one '&' ?
1460 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1461 \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}%
1462 \ifpgfutil@in@
1463 \expandafter\pgfplotstabletypeset@postproc@separately\pgfmathresult\pgfplotstable@EOI
1464 \else
1465 \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov
1466 \fi
1467 \fi
1468 \pgfplotstable@debug@notify@cellcontent@postprocessed%
1469 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1470 \pgfmath@smuggleone\pgfmathresult
1471 \endgroup
1472 \let#2=\pgfmathresult
1473 }%
1474
1475 \def\pgfplotstable@debug@notify@cellcontent{}%
1476 \def\pgfplotstable@debug@notify@cellcontent@preprocessed{}%
1477 \def\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles{}%
1478 \def\pgfplotstable@debug@notify@cellcontent@assigned{}%
1479 \def\pgfplotstable@debug@notify@cellcontent@postprocessed{}%
1480 \def\pgfplotstable@debug@notify@preprocess@incol#1{}%
1481 \def\pgfplotstable@debug@notify@preprocess@col#1{}%
1482 \def\pgfplotstable@debug@notify@preprocessed@col#1{}%
1483 \def\pgfplotstable@debug@notify@balancingcell{}%
1484
1485 \def\pgfplotstable@debug@notify@cellcontent@ACTIVE{%
1486 \begingroup
1487 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1488 \toks0=\expandafter{\pgfmathresult}%
1489 \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: Before cell content processing: `\the\toks0'}%
1490 \endgroup
1491 }%
1492 \def\pgfplotstable@debug@notify@cellcontent@preprocessed@ACTIVE{%
1493 \begingroup
1494 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1495 \toks0=\expandafter{\pgfmathresult}%
1496 \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After '@preproc cell content : `\the\toks0'}%
1497 \endgroup
1498 }%
1499 \def\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles@ACTIVE{%
1500 \begingroup
1501 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1502 \toks0=\expandafter{\pgfmathresult}%
1503 \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After applying 'every row * column [no] *' styles : `\the\toks0'}%
1504 \endgroup
1505 }%
1506 \def\pgfplotstable@debug@notify@cellcontent@assigned@ACTIVE{%
1507 \begingroup
1508 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1509 \toks0=\expandafter{\pgfmathresult}%
1510 \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After 'assign cell content : `\the\toks0'}%
1511 \endgroup
1512 }%
1513 \def\pgfplotstable@debug@notify@cellcontent@postprocessed@ACTIVE{%
1514 \begingroup
1515 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
1516 \toks0=\expandafter{\pgfmathresult}%
1517 \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After 'postproc cell content : `\the\toks0'}%
1518 \endgroup
1519 }
1520 \def\pgfplotstable@debug@notify@balancingcell@ACTIVE{%
1521 \immediate\write16{Row --/out \the\c@pgfplotstable@counta: Inserting empty cell to balance rows}%
1522 }%
1523 \def\pgfplotstable@debug@notify@preprocess@incol@ACTIVE#1{%
1524 \begingroup
1525 \toks0=\expandafter{#1}%
1526 \immediate\write16{>=== Loading input column `\the\toks0' <===}%
1527 \endgroup
1528 }%
1529 \def\pgfplotstable@debug@notify@preprocess@col@ACTIVE#1{%
1530 \begingroup
1531 \toks0=\expandafter{#1}%
1532 \immediate\write16{>=== Preprocessing output column `\the\toks0' <===}%
1533 \endgroup
1534 }%
1535 \def\pgfplotstable@debug@notify@preprocessed@col@ACTIVE#1{%
1536 \begingroup
1537 \toks0=\expandafter{#1}%
1538 \immediate\write16{>=== output column `\the\toks0' prepared, ok. <===}%
1539 \endgroup
1540 }%
1541 \def\pgfplotstable@debug@activate{%
1542 \ifnum\pgfkeysvalueof{/pgfplots/table/debug level}>0
1543 \let\pgfplotstable@debug@notify@preprocess@incol=\pgfplotstable@debug@notify@preprocess@incol@ACTIVE
1544 \let\pgfplotstable@debug@notify@preprocess@col=\pgfplotstable@debug@notify@preprocess@col@ACTIVE
1545 \let\pgfplotstable@debug@notify@preprocessed@col=\pgfplotstable@debug@notify@preprocessed@col@ACTIVE
1546 \let\pgfplotstable@debug@notify@cellcontent=\pgfplotstable@debug@notify@cellcontent@ACTIVE
1547 \let\pgfplotstable@debug@notify@cellcontent@preprocessed=\pgfplotstable@debug@notify@cellcontent@preprocessed@ACTIVE
1548 \let\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles=\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles@ACTIVE
1549 \let\pgfplotstable@debug@notify@cellcontent@assigned=\pgfplotstable@debug@notify@cellcontent@assigned@ACTIVE
1550 \let\pgfplotstable@debug@notify@cellcontent@postprocessed=\pgfplotstable@debug@notify@cellcontent@postprocessed@ACTIVE
1551 \let\pgfplotstable@debug@notify@balancingcell=\pgfplotstable@debug@notify@balancingcell@ACTIVE
1552 \fi
1553 }%
1554
1555 % This routine invokes 'postproc cell content' for columns which
1556 % contain the column separator '&'.
1557 %
1558 % #1&#2 is the formatted number, the result of 'dec sep align
1559 % #3 is the (unformatted) input number.
1560 \def\pgfplotstabletypeset@postproc@separately#1&#2\pgfplotstable@EOI{%
1561 \def\pgfmathresult{#1}%
1562 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
1563 \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov
1564 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfplotstable@entry@a
1565 %
1566 \def\pgfplotstablepartno{1}%
1567 \def\pgfmathresult{#2}%
1568 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
1569 \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov
1570 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
1571 \t@pgfplots@toka=\expandafter{\pgfplotstable@entry@a}%
1572 \t@pgfplots@tokb=\expandafter{\pgfmathresult}%
1573 \edef\pgfmathresult{\the\t@pgfplots@toka&\the\t@pgfplots@tokb}%
1574 \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
1575 }
1576
1577 % processes the option 'assign column name'
1578 % FIXME : seems to be deprecated
1579 \def\pgfplotstabletypeset@assign@final@colname#1#2{%
1580 \pgfkeysifdefined{/pgfplots/table/assign column name/.@cmd}{%
1581 \pgfkeyssetvalue{/pgfplots/table/column name}{#1}%
1582 \pgfkeysvalueof{/pgfplots/table/assign column name/.@cmd}#1\pgfeov
1583 \pgfkeysgetvalue{/pgfplots/table/column name}{#2}%
1584 }{}%
1585 }
1586 \def\pgfplotstabletypeset@nocolname{\pgfkeysnovalue}
1587
1588 % checks if #1 contains invalid chars for pgfkeys and sets
1589 % \ifpgfutil@in@ to true if that is the case.
1590 \def\pgfplotstable@checkspecialchars@pgfkeys#1\pgfplotstable@EOI{%
1591 \pgfutil@in@/{#1}%
1592 \ifpgfutil@in@
1593 \else
1594 \pgfutil@in@={#1}%
1595 \ifpgfutil@in@
1596 \else
1597 \pgfutil@in@,{#1}%
1598 \fi
1599 \fi
1600 }%
1601
1602 % Upon execution, \pgfplotsretval contains a set of /pgfplots/table
1603 % keys from 'every nth row' styles.
1604 %
1605 % @PRECONDITION this macro assumes it is run in \pgfplotstabletypeset.
1606 \def\pgfplots@each@nth@styles{\let\pgfplotsretval\pgfutil@empty}%
1607
1608 % Defines an 'every nth row' style for an integer #1.
1609 %
1610 % #1: integer
1611 % #2: style arguments
1612 %
1613 % All these styles are accumulated into the macro
1614 % \pgfplots@each@nth@styles.
1615 \def\pgfplotstabletypeset@append@every@nth@row#1#2{%
1616 \edef\pgfplots@loc@TMPa{#1}%
1617 % check for the special 'each nth row={3[+1]}{...} format:
1618 \expandafter\pgfutil@in@\expandafter[\expandafter{\pgfplots@loc@TMPa}%
1619 \ifpgfutil@in@
1620 \expandafter\pgfplotstabletypeset@append@every@nth@row@getshift\pgfplots@loc@TMPa%
1621 \t@pgfplots@toka={#2}%
1622 \edef\pgfplots@loc@TMPa{%
1623 \noexpand\pgfplotstabletypeset@append@every@nth@row@{\pgfplots@loc@TMPa}{\the\t@pgfplots@toka}{\pgfplots@loc@TMPb}%
1624 }%
1625 \pgfplots@loc@TMPa
1626 \else
1627 \expandafter\pgfplotstabletypeset@append@every@nth@row@\expandafter{\pgfplots@loc@TMPa}{#2}{0}%
1628 \fi
1629 }%
1630 \def\pgfplotstabletypeset@append@every@nth@row@getshift#1[#2]{%
1631 \def\pgfplots@loc@TMPa{#1}%
1632 \ifnum#2<0
1633 \c@pgf@countc=#1\relax
1634 \advance\c@pgf@countc by#2
1635 \edef\pgfplots@loc@TMPb{\the\c@pgf@countc}%
1636 \else
1637 \def\pgfplots@loc@TMPb{#2}%
1638 \fi
1639 }%
1640 % #3 is an additional shift. It is usually 0
1641 \def\pgfplotstabletypeset@append@every@nth@row@#1#2#3{%
1642 \expandafter\def\expandafter\pgfplots@each@nth@styles\expandafter{%
1643 \pgfplots@each@nth@styles
1644 \expandafter\pgfplotsmathmodint\expandafter{\the\c@pgfplotstable@rowindex}{#1}%
1645 \ifnum\pgfmathresult=#3\relax
1646 \ifx\pgfplotsretval\pgfutil@empty
1647 \def\pgfplotsretval{#2}%
1648 \else
1649 \expandafter\def\expandafter\pgfplotsretval\expandafter{\pgfplotsretval,%
1650 #2}%
1651 \fi
1652 \fi
1653 }%
1654 }
1655
1656 \def\pgfplotstable@insertemptycells@forbalance{%
1657 \pgfutil@loop
1658 \ifnum\c@pgfplotstable@counta<\pgfplotstable@firstnumrows\relax
1659 \pgfplotstable@debug@notify@balancingcell
1660 % let's hope @getfinalentry handles empty strings!
1661 \pgfplotstabletypeset@getfinalentry{}{\pgfplotstable@entry}%
1662 \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed
1663 \pgfplotslistpushback\to\pgfplotstable@col@processed
1664 \advance\c@pgfplotstable@counta by1\relax
1665 \pgfutil@repeat
1666 }
1667
1668 % TODO
1669 % - replace grouped list foreach by popfront-loop and use arrays
1670 % directly -> group only the pgfkeys eval
1671 \long\def\pgfplotstabletypeset@opt@[#1]#2{%
1672 %\begingroup <--- is already opened!
1673 %--------------------------------------------------
1674 % \pgfutil@ifundefined{#2}{%
1675 % \pgfplots@error{There is no such table '\string#2' loaded into memory. Maybe you meant to use '\string\pgfplotstabletypesetfile{\string#2}' instead of '\string\pgfplotstabletypeset{\string#2}'?}%
1676 % \pgfplotslistnewempty#2
1677 % }{}%
1678 %--------------------------------------------------
1679 \def\pgfplotstablename{#2}% the name of the actual table struct
1680 \def\pgfplotstablecolname{\pgfplotstable@colname}%
1681 \def\pgfplotstablecol{\the\c@pgfplotstable@colindex}%
1682 \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}%
1683 \def\pgfplotstablecols{\the\c@pgfplotstable@numcols}%
1684 \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}%
1685 \ifpgfplots@table@options@areset
1686 \else
1687 \pgfplotstablegetname{#2}\pgfplotstable@loc@TMPa
1688 \expandafter\pgfplotstableset@every@table\expandafter{\pgfplotstable@loc@TMPa}{#1}%
1689 \fi
1690 \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename
1691 \pgfkeysgetvalue{/pgfplots/table/TeX comment}\pgfplots@TeX@comment
1692 \ifpgfplotstabletypeset@force@remake
1693 \pgfplotstabletypeset@includeoutfilesfalse
1694 \else
1695 \ifpgfplotstabletypeset@includeoutfiles
1696 \pgfplotstabletypeset@includeoutfilesfalse
1697 \ifx\pgfplotstable@outfilename\pgfutil@empty
1698 \else
1699 \pgfplots@logfileopen{\pgfplotstable@outfilename}%
1700 \openin\r@pgfplots@reada=\pgfplotstable@outfilename\relax
1701 \ifeof\r@pgfplots@reada \else\pgfplotstabletypeset@includeoutfilestrue \fi
1702 \closein\r@pgfplots@reada
1703 \fi
1704 \fi
1705 \fi
1706 \ifpgfplotstabletypeset@includeoutfiles
1707 \def\pgfplots@loc@TMPa{%
1708 \input \pgfplotstable@outfilename\relax
1709 \endgroup
1710 }%
1711 \else
1712 \def\pgfplots@loc@TMPa{%
1713 \pgfplotstabletypeset@opt@prepare{#2}%
1714 }%
1715 \fi
1716 \pgfplots@loc@TMPa
1717 }%
1718 \def\pgfplotstabletypeset@opt@prepare#1{%
1719 %
1720 % Prepare outfile and debug options:
1721 \let\pgfplotstable@notify@finished@line=\pgfutil@empty
1722 %
1723 % FLUSH assumes that \pgfplotstable@curline is finished. It
1724 % appends all its contents as-is to \pgfplotstable@result.
1725 %
1726 % Furthermore, it calls \pgfplotstable@notify@finished@line which
1727 % in turn may invoke additional output routines for the debug and
1728 % outfile options.
1729 %
1730 % Finally, it resets \pgfplotstable@curline.
1731 \def\pgfplotstable@curline@FLUSH{%
1732 \pgfplotstable@notify@finished@line
1733 \t@pgfplots@toka=\expandafter{\pgfplotstable@result}%
1734 \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}%
1735 \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
1736 \let\pgfplotstable@curline=\pgfutil@empty
1737 }%
1738 \ifpgfplotstabletypesetdebug
1739 \immediate\write16{------- PGFPLOTSTABLE DEBUG MODE: --------}%
1740 \expandafter\def\expandafter\pgfplotstable@notify@finished@line\expandafter{\pgfplotstable@notify@finished@line
1741 \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
1742 \immediate\write16{\the\t@pgfplots@toka\pgfplots@TeX@comment}%
1743 }%
1744 \pgfplotstable@debug@activate
1745 \fi
1746 \ifx\pgfplotstable@outfilename\pgfutil@empty
1747 \else
1748 \immediate\openout\pgfplotstable@outfile=\pgfplotstable@outfilename\relax
1749 \expandafter\def\expandafter\pgfplotstable@notify@finished@line\expandafter{\pgfplotstable@notify@finished@line
1750 \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
1751 \immediate\write\pgfplotstable@outfile{\the\t@pgfplots@toka\pgfplots@TeX@comment}%
1752 }%
1753 \fi
1754 %
1755 % Start operation:
1756 \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}%
1757 \ifx\pgfplotstable@colnames\pgfutil@empty
1758 \pgfplotstablegetcolumnlist#1\to\pgfplotstable@colnames
1759 \else
1760 \expandafter\pgfplotslistnew\expandafter\pgfplotstable@colnames\expandafter{\pgfplotstable@colnames}%
1761 \fi
1762 %
1763 %
1764 \ifpgfplotstable@sort
1765 % make sure any columns exist (especially create on use).
1766 % this can be done by calling getcolumnbyname once for every
1767 % column:
1768 \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{%
1769 \pgfplotstable@is@colname\pgfplotstable@colname
1770 \ifpgfplotstableread@foundcolnames
1771 \else
1772 \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#1\to\pgfplotstable@colname
1773 \fi
1774 \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@colname}\of#1\to\pgfplotstable@col
1775 }%
1776 \let\pgfplotstable@colname=\relax
1777 \let\pgfplotstable@col=\relax
1778 %
1779 \def\pgfplots@loc@TMPa{%
1780 \pgfplotstablesort\pgfplotstable@sortedtbl{#1}%
1781 \pgfplotstabletypeset@opt@@{\pgfplotstable@sortedtbl}%
1782 }%
1783 \else
1784 \def\pgfplots@loc@TMPa{%
1785 \pgfplotstabletypeset@opt@@{#1}%
1786 }%
1787 \fi
1788 \pgfplots@loc@TMPa
1789 }
1790 \def\pgfplotstabletypeset@opt@@#1{%
1791 \global\pgfplotslistnewempty\pgfplotstabletypeset@final@colnames
1792 \global\pgfplotslistnewempty\pgfplotstabletypeset@final@coltypes
1793 \global\pgfplotslistnewempty\pgfplotstabletypeset@final@cols
1794 \let\c@pgfplotstable@numcols=\c@pgf@counta
1795 \let\c@pgfplotstable@numrows=\c@pgf@countd
1796 \let\c@pgfplotstable@rowindex=\c@pgf@countc
1797 \let\c@pgfplotstable@colindex=\c@pgf@countb
1798 \pgfplotslistsize\pgfplotstable@colnames\to\c@pgfplotstable@numcols
1799 \def\pgfplotstable@firstnumrows{-1}%
1800 \c@pgfplotstable@numrows=-1\relax
1801 \c@pgfplotstable@colindex=0\relax
1802 % FOREACH COLUMN:
1803 \pgfplotslistforeach\pgfplotstable@colnames\as\pgfplotstable@colname{%
1804 \pgfplotstable@debug@notify@preprocess@incol\pgfplotstable@colname
1805 %
1806 \c@pgfplotstable@rowindex=0\relax
1807 \pgfplotstable@is@colname\pgfplotstable@colname
1808 \ifpgfplotstableread@foundcolnames
1809 \else
1810 \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#1\to\pgfplotstable@colname
1811 \fi
1812 \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@colname}\of#1\to\pgfplotstable@col
1813 %
1814 % Init number of *input* rows here. This may not be the same
1815 % as the number of *output* rows (see the row predicate
1816 % below).
1817 %
1818 % Accessible with \pgfplotstablerows in style keys.
1819 \ifnum\c@pgfplotstable@numrows=-1\relax
1820 \pgfplotslistsize\pgfplotstable@col\to\c@pgfplotstable@numrows
1821 \global\c@pgfplotstable@numrows=\c@pgfplotstable@numrows
1822 \fi
1823 %
1824 %
1825 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1826 % Set keys for columns!
1827 \ifodd\c@pgfplotstable@colindex
1828 \t@pgfplots@toka={every odd column}%
1829 \else
1830 \t@pgfplots@toka={every even column}%
1831 \fi
1832 \ifnum\c@pgfplotstable@colindex=0\relax
1833 \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first column}%
1834 \fi
1835 % save this now before we increment '\c@pgfplotstable@colindex':
1836 \edef\pgfplotstable@displaycolkey{display columns/\the\c@pgfplotstable@colindex/.try,every col no \the\c@pgfplotstable@colindex/.try}%
1837 %
1838 \global\advance\c@pgfplotstable@colindex by1\relax
1839 \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols
1840 \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last column}%
1841 \fi
1842 % temporarily restore it: we may need it in row predicates:
1843 \global\advance\c@pgfplotstable@colindex by-1\relax
1844 \ifpgfplotstable@disable@rowcolstyles
1845 % ok, then don't check for 'columns/<name>' and
1846 % 'display columns/<index>':
1847 \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka}%
1848 \else
1849 \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname}%
1850 \expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\t@pgfplots@tokb\pgfplotstable@EOI
1851 \ifpgfutil@in@
1852 \edef\pgfplotstable@colname@for@styles{{\the\t@pgfplots@tokb}}%
1853 \else
1854 \edef\pgfplotstable@colname@for@styles{\the\t@pgfplots@tokb}%
1855 \fi
1856 \edef\pgfplotstable@loc@TMPa{every column,\the\t@pgfplots@toka,columns/\pgfplotstable@colname@for@styles/.try}%
1857 \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}%
1858 \t@pgfplots@tokb=\expandafter{\pgfplotstable@displaycolkey}%
1859 \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}%
1860 \fi
1861 \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}%
1862 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1863 %
1864 \pgfkeysgetvalue{/pgfplots/table/column name}{\pgfplotstable@colname@out}%
1865 \ifx\pgfplotstable@colname@out\pgfplotstabletypeset@nocolname
1866 \let\pgfplotstable@colname@out=\pgfplotstable@colname
1867 \fi
1868 \expandafter\pgfplotstabletypeset@assign@final@colname\expandafter{\pgfplotstable@colname@out}\pgfplotstable@colname@out
1869 %
1870 \pgfplotstable@debug@notify@preprocess@col\pgfplotstable@colname@out
1871 %
1872 \expandafter\pgfplotslistpushbackglobal\pgfplotstable@colname@out\to\pgfplotstabletypeset@final@colnames
1873 \pgfkeysgetvalue{/pgfplots/table/column type}{\pgfplotstable@coltype}%
1874 \expandafter\pgfplotslistpushbackglobal\pgfplotstable@coltype\to\pgfplotstabletypeset@final@coltypes
1875 %
1876 \pgfplotslistnewempty\pgfplotstable@col@processed
1877 \c@pgfplotstable@counta=0
1878 \pgfplotslistforeachungrouped\pgfplotstable@col\as\pgfplotstable@entry{%
1879 \pgfplotstableuserowtrue
1880 \edef\pgfplotstable@loc@TMPa{\noexpand\pgfkeysvalueof{/pgfplots/table/row predicate/.@cmd}\the\c@pgfplotstable@rowindex}%
1881 \pgfplotstable@loc@TMPa\pgfeov
1882 \ifpgfplotstableuserow
1883 \ifnum\pgfplotstable@firstnumrows=-1\relax
1884 \else
1885 \ifnum\c@pgfplotstable@counta<\pgfplotstable@firstnumrows\relax
1886 \else
1887 \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}%
1888 \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname@out}%
1889 \pgfplots@warning{Unbalanced cell with content '\the\t@pgfplots@toka' of column '\the\t@pgfplots@tokb' has been skipped: row count \the\c@pgfplotstable@counta+1 > \pgfplotstable@firstnumrows (which is the number of rows in the first column)}%
1890 \pgfplotstableuserowfalse
1891 \fi
1892 \fi
1893 \ifpgfplotstableuserow
1894 \expandafter\pgfplotstabletypeset@getfinalentry\expandafter{\pgfplotstable@entry}{\pgfplotstable@entry}%
1895 \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed
1896 \advance\c@pgfplotstable@counta by1\relax
1897 \fi
1898 \fi
1899 \advance\c@pgfplotstable@rowindex by1\relax
1900 }%
1901 \ifnum\pgfplotstable@firstnumrows=-1\relax
1902 \xdef\pgfplotstable@firstnumrows{\the\c@pgfplotstable@counta}%
1903 \else
1904 % balance columns:
1905 \pgfplotstable@insertemptycells@forbalance
1906 \fi
1907 %
1908 \pgfplotstable@debug@notify@preprocessed@col\pgfplotstable@colname@out
1909 %
1910 \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols
1911 \global\advance\c@pgfplotstable@colindex by1\relax
1912 }%
1913 %
1914 \pgfplotstable@disable@column@styles
1915 %
1916 \pgfplotslistcheckempty\pgfplotstabletypeset@final@colnames
1917 \ifpgfplotslistempty
1918 \let\pgfplotstable@result=\pgfutil@empty
1919 \else
1920 % Ok, I have now everything which will come into the final table.
1921 %
1922 % But I have it column-oriented; I need to transpose the storage.
1923 %
1924 % The following code assembles a
1925 % \begin{tabular}{}
1926 % ...
1927 % \end{tabular}
1928 % statement piece after piece.
1929 %
1930 %\message{I have now \meaning\pgfplotstabletypeset@final@colnames, and \meaning\pgfplotstabletypeset@final@cols.}%
1931 % Step 1: column names.
1932 \c@pgfplotstable@colindex=0\relax
1933 \c@pgfplotstable@rowindex=-1\relax
1934 \let\pgfplotstable@result=\pgfutil@empty
1935 %
1936 \pgfkeysgetvalue{/pgfplots/table/font}{\pgfplotstable@font}%
1937 \ifx\pgfplotstable@font\pgfutil@empty
1938 \else
1939 \t@pgfplots@toka=\expandafter{\pgfplotstable@font}%
1940 \edef\pgfplotstable@curline{\noexpand\begingroup\the\t@pgfplots@toka}%
1941 \pgfplotstable@curline@FLUSH
1942 \fi
1943 %
1944 \pgfkeysgetvalue{/pgfplots/table/begin table}{\pgfplotstable@entry}%
1945 \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}%
1946 \edef\pgfplotstable@curline{\the\t@pgfplots@toka}%
1947 %
1948 \ifpgfplotstabletypesetskipcoltypes
1949 \else
1950 % STEP 1.1: collect column types:
1951 \def\pgfplotstable@resulttypes{}%
1952 \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@coltypes\as\pgfplotstable@coltype{%
1953 \t@pgfplots@toka=\expandafter{\pgfplotstable@resulttypes}%
1954 \t@pgfplots@tokb=\expandafter{\pgfplotstable@coltype}%
1955 \edef\pgfplotstable@resulttypes{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
1956 }%
1957 \ifx\pgfplotstable@resulttypes\pgfutil@empty
1958 \else
1959 \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
1960 \t@pgfplots@tokb=\expandafter{\pgfplotstable@resulttypes}%
1961 \edef\pgfplotstable@curline{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}%
1962 \fi
1963 \fi
1964 \ifx\pgfplotstable@curline\pgfutil@empty
1965 \else
1966 \pgfplotstable@curline@FLUSH
1967 \fi
1968 %
1969 % Step 1.2: Collect FIRST ROW (column names)
1970 \begingroup
1971 \pgfplotstableset{every head row}%
1972 \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}%
1973 \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}%
1974 \t@pgfplots@toka=\expandafter{\pgfplotstable@before}%
1975 \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}%
1976 \xdef\pgfplots@glob@TMPc{%
1977 \noexpand\def\noexpand\pgfplotstable@before{\the\t@pgfplots@toka}%
1978 \noexpand\def\noexpand\pgfplotstable@after{\the\t@pgfplots@tokb}%
1979 }%
1980 \pgfkeysgetvalue{/pgfplots/table/typeset cell/.@cmd}\pgfplots@loc@TMPa
1981 \global\let\pgfplots@glob@TMPd=\pgfplots@loc@TMPa
1982 \endgroup
1983 \pgfplots@glob@TMPc
1984 \let\pgfplotstable@headrow@typesetcell=\pgfplots@glob@TMPd
1985 % insert 'before row' here:
1986 \t@pgfplots@toka=\expandafter{\pgfplotstable@before}%
1987 \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}%
1988 \edef\pgfplotstable@curline{\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
1989 %
1990 \def\pgfplotstablecolname{\pgfplotstable@colname@out}%
1991 \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@colnames\as\pgfplotstable@colname@out{%
1992 %
1993 \advance\c@pgfplotstable@colindex by1\relax
1994 % typeset the cell:
1995 \expandafter\pgfplotstable@headrow@typesetcell\pgfplotstable@colname@out\pgfeov
1996 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
1997 %
1998 % append this cell:
1999 \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
2000 \t@pgfplots@tokb=\expandafter{\pgfmathresult}%
2001 \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
2002 }%
2003 % insert 'after row' here:
2004 \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
2005 \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}%
2006 \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
2007 %
2008 \pgfplotstable@curline@FLUSH
2009 %
2010 %\message{I have now \meaning\pgfplotstable@result.}%
2011 % Step 2: column contents.
2012 % I will first convert \pgfplotstabletypeset@final@cols into an array.
2013 \c@pgfplotstable@colindex=0\relax
2014 \pgfplotsarraynewempty\pgfplotstabletypeset@final@cols@array
2015 \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@cols\as\pgfplotstable@col@processed{%
2016 \expandafter\pgfplotsarraypushback\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols@array
2017 }%
2018 % init numrows:
2019 \pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed
2020 \pgfplotslistsize\pgfplotstable@col@processed\to\c@pgfplotstable@numrows
2021 %
2022 % Now, we loop over every column as long as there are still rows
2023 % left. We assemble rows while we go.
2024 %
2025 \c@pgfplotstable@rowindex=0\relax
2026 \ifnum\c@pgfplotstable@colindex<\c@pgfplotstable@numcols
2027 \pgfplots@loop@CONTINUEtrue
2028 \else
2029 \pgfplots@loop@CONTINUEfalse
2030 \fi
2031 \def\pgfplotstablecolname{\pgfplotstable@error{Sorry, you can't evaluate \string\pgfplotstablecolname\space in this context.}}%
2032 \pgfutil@loop
2033 \ifpgfplots@loop@CONTINUE
2034 \pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed
2035 \pgfplotslistcheckempty\pgfplotstable@col@processed
2036 \ifpgfplotslistempty
2037 % assume that each column has the same number of entries
2038 % (normalised tables):
2039 \pgfplots@loop@CONTINUEfalse
2040 \else
2041 \ifnum\c@pgfplotstable@colindex=0\relax
2042 % Install styles for the next row.
2043 \begingroup
2044 \ifodd\c@pgfplotstable@rowindex
2045 \t@pgfplots@toka={every odd row}%
2046 \else
2047 \t@pgfplots@toka={every even row}%
2048 \fi
2049 \ifnum\c@pgfplotstable@rowindex=0\relax
2050 \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first row}%
2051 \fi
2052 \ifpgfplotstable@disable@rowcolstyles
2053 \else
2054 \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,every row no \the\c@pgfplotstable@rowindex/.try}%
2055 \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}%
2056 %
2057 \ifnum\c@pgfplotstable@rowindex=0\relax
2058 \else
2059 % process 'every nth row' styles:
2060 \begingroup
2061 \pgfplots@each@nth@styles
2062 \pgfmath@smuggleone\pgfplotsretval
2063 \endgroup
2064 \ifx\pgfplotsretval\pgfutil@empty
2065 \else
2066 \t@pgfplots@tokb=\expandafter{\pgfplotsretval}%
2067 \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}%
2068 \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}%
2069 \fi
2070 \fi
2071 \fi
2072 % misuse as temporary variable:
2073 \c@pgfplotstable@colindex=\c@pgfplotstable@rowindex
2074 \advance\c@pgfplotstable@colindex by1\relax
2075 \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numrows
2076 \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last row}%
2077 \fi
2078 \expandafter\pgfplotstableset\expandafter{\the\t@pgfplots@toka}%
2079 \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}%
2080 \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}%
2081 \t@pgfplots@toka=\expandafter{\pgfplotstable@before}%
2082 \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}%
2083 \xdef\pgfplots@glob@TMPc{%
2084 \noexpand\def\noexpand\pgfplotstable@before{\the\t@pgfplots@toka}%
2085 \noexpand\def\noexpand\pgfplotstable@after{\the\t@pgfplots@tokb}%
2086 }%
2087 \endgroup
2088 \pgfplots@glob@TMPc
2089 % insert 'before row' here:
2090 \t@pgfplots@toka=\expandafter{\pgfplotstable@before}%
2091 \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}%
2092 \edef\pgfplotstable@curline{\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
2093 \fi
2094 %
2095 %
2096 \pgfplotslistpopfront\pgfplotstable@col@processed\to\pgfplotstable@entry
2097 \pgfplotsarrayletentry\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array=\pgfplotstable@col@processed
2098 \advance\c@pgfplotstable@colindex by1\relax
2099 % typeset the cell:
2100 \pgfkeysgetvalue{/pgfplots/table/typeset cell/.@cmd}\pgfplots@loc@TMPa
2101 \expandafter\pgfplots@loc@TMPa\pgfplotstable@entry\pgfeov
2102 \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
2103 %
2104 % append this cell:
2105 \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
2106 \t@pgfplots@tokb=\expandafter{\pgfmathresult}%
2107 \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
2108 %
2109 \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax
2110 \c@pgfplotstable@colindex=0\relax
2111 % insert 'after row' here:
2112 \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
2113 \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}%
2114 \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
2115 \advance\c@pgfplotstable@rowindex by1\relax
2116 \pgfplotstable@curline@FLUSH
2117 \fi
2118 %\message{I have now \meaning\pgfplotstable@result.}%
2119 \fi
2120 \pgfutil@repeat
2121 \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
2122 \pgfkeysgetvalue{/pgfplots/table/end table}{\pgfplotstable@entry}%
2123 \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry}%
2124 \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
2125 \ifx\pgfplotstable@curline\pgfutil@empty
2126 \else
2127 \pgfplotstable@curline@FLUSH
2128 \fi
2129 %
2130 \ifx\pgfplotstable@font\pgfutil@empty
2131 \else
2132 \edef\pgfplotstable@curline{\noexpand\endgroup}%
2133 \pgfplotstable@curline@FLUSH
2134 \fi
2135 \ifx\pgfplotstable@outfilename\pgfutil@empty
2136 \else
2137 \immediate\closeout\pgfplotstable@outfile
2138 \fi
2139 %\message{I have now \meaning\pgfplotstable@result.}%
2140 \def\pgfplotstablecol{\pgfplotstable@error{Sorry, you can't access the \string\pgfplotstablecol\ in this context. It is ONLY valid during the preparation routines (please check the 'display columns/<index>' style in the manual).}}%
2141 \def\pgfplotstablerow{\pgfplotstable@error{Sorry, you can't access the \string\pgfplotstablerow\ in this context. It is ONLY valid during the preparation routines (please check the 'every row no <index>' style).}}%
2142 \ifpgfplotstabletypesetresult
2143 \pgfplotstable@result
2144 \fi
2145 \fi
2146 \pgfkeysgetvalue{/pgfplots/table/write to macro}\pgfplots@loc@TMPa
2147 \ifx\pgfplots@loc@TMPa\pgfutil@empty
2148 \global\let\pgfplots@glob@TMPa=\relax
2149 \else
2150 \t@pgfplots@toka=\expandafter{\pgfplotstable@result}%
2151 \xdef\pgfplots@glob@TMPa{\noexpand\def\expandafter\noexpand\pgfplots@loc@TMPa{\the\t@pgfplots@toka}}%
2152 \fi
2153 \endgroup
2154 \pgfplots@glob@TMPa% execute 'write to macro' if set.
2155 }%
2156
2157 \def\pgfplotstable@disable@column@styles@error#1{%
2158 \pgfplotsthrow{invalid argument}\pgfplots@loc@TMPa{Sorry, the key '#1' has been assigned while processing row options. However, it needs to be invoked while processing column options. If your options depend on specific row indices, consider using \string\pgfplotstablerow\space and \string\pgfplotstablerows}\pgfeov%
2159 }%
2160 \def\pgfplotstable@disable@column@styles@#1{%
2161 \pgfkeysdef{/pgfplots/table/#1/.code}{\pgfplotstable@disable@column@styles@error{#1}}%
2162 \pgfkeysdef{/pgfplots/table/#1/.append code}{\pgfplotstable@disable@column@styles@error{#1}}%
2163 \pgfkeysdefargs{/pgfplots/table/#1/.add code}{##1##2}{\pgfplotstable@disable@column@styles@error{#1}}%
2164 \pgfkeysdef{/pgfplots/table/#1/.append style}{\pgfplotstable@disable@column@styles@error{#1}}%
2165 }
2166 \def\pgfplotstable@disable@column@styles{%
2167 \pgfplotstable@disable@column@styles@{postproc cell content}%
2168 \pgfplotstable@disable@column@styles@{preproc cell content}%
2169 \pgfplotstable@disable@column@styles@{assign cell content}%
2170 }%
2171
2172 \newif\ifpgfplotstable@isfirstrow
2173 \newif\ifpgfplotstable@islastrow
2174 \newif\ifpgfplotstablecreatecol@isreallynew
2175
2176 \def\pgfplotstablecreatecol@opt[#1]#2#3{%
2177 \begingroup
2178 \pgfkeysinterruptkeyfilter
2179 \def\pgfplotstablename{#3}% the name of the table struct
2180 \pgfplotstableset{columns=,#1,%
2181 /pgf/fpu/handlers/empty number/.code 2 args={%
2182 \pgfmathfloatcreate{0}{0.0}{0}%
2183 }%
2184 }%
2185 \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}%
2186 \ifx\pgfplotstable@colnames\pgfutil@empty
2187 \pgfplotstablegetcolumnlist#3\to\pgfplotstable@colnames
2188 \else
2189 \expandafter\pgfplotslistnew\expandafter\pgfplotstable@colnames\expandafter{\pgfplotstable@colnames}%
2190 \fi
2191 \pgfplotslistnewempty\pgfplotstable@colnames@real
2192 \t@pgfplots@toka=\expandafter{#2}% this should handle macro names in '#2'.
2193 \edef\pgfplotstable@newcolname{\the\t@pgfplots@toka}%
2194 \global\pgfplotstablecreatecol@isreallynewtrue
2195 \c@pgf@countd=0
2196 \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{%
2197 \pgfplotstable@is@colname\pgfplotstable@colname
2198 \ifpgfplotstableread@foundcolnames
2199 \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@colname}\to\pgfplotstable@colnames@real
2200 \else
2201 \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#2\to\pgfplotstable@colname
2202 \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@colname}\to\pgfplotstable@colnames@real
2203 \fi
2204 \ifx\pgfplotstable@colname\pgfplotstable@newcolname
2205 \global\pgfplotstablecreatecol@isreallynewfalse
2206 \fi
2207 \expandafter\edef\csname pgfplotstablecreate@index@to@name@\the\c@pgf@countd\endcsname{\pgfplotstable@colname}%
2208 \advance\c@pgf@countd by1
2209 }%
2210 \edef\pgfplotstablecols{\the\c@pgf@countd}%
2211 \pgfplotstable@isfirstrowtrue
2212 \pgfplotstable@islastrowfalse
2213 \pgfplotslistnewempty\pgfplotstable@newcol
2214 %
2215 \let\c@pgfplotstable@numrows=\c@pgf@countd
2216 \let\c@pgfplotstable@rowindex=\c@pgf@countc
2217 \c@pgfplotstable@numrows=-1\relax
2218 \c@pgfplotstable@rowindex=0\relax
2219 \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}%
2220 \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}%
2221 %
2222 \def\prevrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@prev@}{\pgfplotstable@thisrow@impl@}}%
2223 \def\thisrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@cur@}{\pgfplotstable@thisrow@impl@}}%
2224 \def\nextrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@next@}{\pgfplotstable@thisrow@impl@}}%
2225 \def\pgfplotstable@rowno@impl##1##2{%
2226 \pgfutil@ifundefined{pgfplotstablecreate@index@to@name@##1}{%
2227 \csname ##2row\endcsname{colindex##1}%
2228 }{%
2229 \csname ##2row\endcsname{\csname pgfplotstablecreate@index@to@name@##1\endcsname}%
2230 }%
2231 }%
2232 \def\prevrowno##1{\pgfplotstable@rowno@impl{##1}{prev}}%
2233 \def\thisrowno##1{\pgfplotstable@rowno@impl{##1}{this}}%
2234 \def\nextrowno##1{\pgfplotstable@rowno@impl{##1}{next}}%
2235 %
2236 \def\getprevrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@prev@##1\endcsname}%
2237 \def\getthisrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@cur@##1\endcsname}%
2238 \def\getnextrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@next@##1\endcsname}%
2239 %
2240 \pgfplots@loop@CONTINUEtrue
2241 % allow this here to accumulate something.
2242 \pgfutil@ifundefined{pgfmathaccuma}{%
2243 \let\pgfmathaccuma=\pgfutil@empty
2244 }{}%
2245 \pgfutil@ifundefined{pgfmathaccumb}{%
2246 \let\pgfmathaccumb=\pgfutil@empty
2247 }{}%
2248 \pgfutil@loop% loop over each row until there are no more rows.
2249 \ifpgfplots@loop@CONTINUE
2250 \ifnum\c@pgfplotstable@numrows=-1\relax
2251 \pgfplotslistfront\pgfplotstable@colnames\to\pgfplotstable@colname
2252 \expandafter\pgfplotslistsize\csname\string#3@\pgfplotstable@colname\endcsname\to\c@pgfplotstable@numrows
2253 \fi
2254 \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{%
2255 \expandafter\pgfplotstableresolvecolname\expandafter{\pgfplotstable@colname}\of#3\to\pgfplotstable@real@colname
2256 \ifpgfplotstable@isfirstrow
2257 \expandafter\pgfplotslistcheckempty\csname\string#3@\pgfplotstable@real@colname\endcsname
2258 \ifpgfplotslistempty
2259 % the table is completely empty. break.
2260 \pgfplots@loop@CONTINUEfalse
2261 \else
2262 \expandafter\let\csname pgfplotstablecreate@prev@\pgfplotstable@colname\endcsname=\pgfutil@empty
2263 \expandafter\pgfplotslistpopfront\csname\string#3@\pgfplotstable@real@colname\endcsname\to\pgfplotstable@entry
2264 \expandafter\let\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname=\pgfplotstable@entry
2265 \fi
2266 \else
2267 \expandafter\let\expandafter\pgfplotstable@prev\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname
2268 \expandafter\let\csname pgfplotstablecreate@prev@\pgfplotstable@colname\endcsname=\pgfplotstable@prev
2269 %
2270 \expandafter\let\expandafter\pgfplotstable@next\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname
2271 \expandafter\let\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname=\pgfplotstable@next
2272 \fi
2273 \expandafter\pgfplotslistcheckempty\csname\string#3@\pgfplotstable@real@colname\endcsname
2274 \ifpgfplotslistempty
2275 \expandafter\let\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname=\pgfutil@empty
2276 \pgfplotstable@islastrowtrue
2277 \else
2278 \expandafter\pgfplotslistpopfront\csname\string#3@\pgfplotstable@real@colname\endcsname\to\pgfplotstable@entry
2279 \expandafter\let\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname=\pgfplotstable@entry
2280 \fi
2281 }%
2282 \ifpgfplots@loop@CONTINUE
2283 % Compute content:
2284 %
2285 \begingroup
2286 \ifpgfplotstable@isfirstrow
2287 \pgfkeysvalueof{/pgfplots/table/create col/assign first/.@cmd}\pgfeov
2288 \else
2289 \ifpgfplotstable@islastrow
2290 \pgfkeysvalueof{/pgfplots/table/create col/assign last/.@cmd}\pgfeov
2291 \else
2292 \pgfkeysvalueof{/pgfplots/table/create col/assign/.@cmd}\pgfeov
2293 \fi
2294 \fi
2295 \pgfkeysgetvalue{/pgfplots/table/create col/next content}{\pgfplotstable@entry}%
2296 \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}%
2297 \t@pgfplots@tokb=\expandafter{\pgfmathaccuma}%
2298 \xdef\pgfplots@glob@TMPc{%
2299 \noexpand\def\noexpand\pgfplotstable@entry{\the\t@pgfplots@toka}%
2300 \noexpand\def\noexpand\pgfmathaccuma{\the\t@pgfplots@tokb}%
2301 }%
2302 \pgfmath@smuggleone\pgfmathaccumb
2303 \endgroup
2304 \pgfplots@glob@TMPc
2305 \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@entry}\to\pgfplotstable@newcol
2306 %
2307 \ifpgfplotstable@islastrow
2308 \pgfplots@loop@CONTINUEfalse
2309 \fi
2310 \fi
2311 \pgfplotstable@isfirstrowfalse
2312 \advance\c@pgfplotstable@rowindex by1\relax
2313 \pgfutil@repeat
2314 \endpgfkeysinterruptkeyfilter
2315 \global\let\pgfplots@glob@TMPc=\pgfplotstable@newcol
2316 \global\let\pgfplots@glob@TMPb=\pgfplotstable@newcolname
2317 \endgroup
2318 \ifpgfplotstablecreatecol@isreallynew
2319 \expandafter\pgfplotslistpushback\expandafter{\pgfplots@glob@TMPb}\to#3%
2320 \fi
2321 \expandafter\let\csname\string#3@\pgfplots@glob@TMPb\endcsname=\pgfplots@glob@TMPc
2322 }%
2323
2324
2325 %-----------------------------------------------------------
2326 %
2327 % Implementation of '/pgfplots/table/create col/function graph cut y':
2328 %
2329 %-----------------------------------------------------------
2330
2331 % create on use/cut/.style={create col/function graph cut y={7e-4}{x=Basis,ymode=log,xmode=log}{{table=regtable,y=special-L2}}},
2332 % #1 = value of fixed line (I call it epsilon)
2333 % #2 = options
2334 % #3 = specification where to get the y from. It is a comma separated
2335 % list of key-value sets, on set for every y(x) graph which shall be
2336 % used.
2337 % #4 = the direction in which the line does NOT vary (either 'x' or 'y')
2338 % #5 = the direction in which the line DOES vary (either 'x' or 'y')
2339 \def\pgfplotstable@fgc@init#1#2#3#4#5{%
2340 \def\pgfplotstable@fgc@xmode{0}%
2341 \def\pgfplotstable@fgc@ymode{0}%
2342 %
2343 \pgfkeysalso{/pgf/fpu=true}%
2344 %
2345 \pgfqkeys{/pgfplots/table/create col/function graph cut}{#2}%
2346 \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table
2347 \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/x}\pgfplotstable@fgc@x
2348 \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/y}\pgfplotstable@fgc@y
2349 \ifx\pgfplotstable@fgc@table\pgfutil@empty
2350 % no table here, ok.
2351 \else
2352 % ok, we need to query (or load) a table!
2353 \expandafter\pgfplotstable@isloadedtable\expandafter{\pgfplotstable@fgc@table}{%
2354 \expandafter\let\expandafter\pgfplotstable@fgc@table\pgfplotstable@fgc@table
2355 }{%
2356 \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}%
2357 }%
2358 \fi
2359 %
2360 \ifnum\csname pgfplotstable@fgc@#4mode\endcsname=1
2361 \pgfmathparse{ln(#1)}%
2362 \else
2363 \pgfmathparse{#1}%
2364 \fi
2365 \let\pgfplotstable@fgc@eps=\pgfmathresult
2366 \pgfplots@assign@list\pgfmathaccumb{#3}%
2367 \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/foreach}\pgfplotstable@fgc@foreach@
2368 \ifx\pgfplotstable@fgc@foreach@\pgfutil@empty
2369 \else
2370 \edef\pgfplotstable@fgc@foreach@process@append{x={\pgfplotstable@fgc@x},y={\pgfplotstable@fgc@y}}%
2371 % we have something like
2372 % foreach={\d in {1,2,3,4}}{table\d}
2373 % -> process it!
2374 % This will modify \pgfmathaccumb
2375 \expandafter\pgfplotstable@fgc@foreach@process\pgfplotstable@fgc@foreach@\pgfplots@EOI
2376 \pgfkeyssetvalue{/pgfplots/table/create col/function graph cut/foreach}{}%
2377 \fi
2378 %
2379 \pgfkeysdef{/pgfplots/table/create col/assign}{%
2380 %\message{working on next cell ...}%
2381 \pgfplotslistcheckempty\pgfmathaccumb
2382 \ifpgfplotslistempty
2383 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
2384 \else
2385 \pgfplotslistpopfront\pgfmathaccumb\to\pgfmathresult
2386 %\message{working on next cell: \meaning\pgfmathresult ...}%
2387 \global\let\pgfplotstable@fgc@foreach=\pgfutil@empty
2388 \begingroup
2389 % set local keys:
2390 \def\pgfplots@loc@TMPa{\pgfqkeys{/pgfplots/table/create col/function graph cut}}%
2391 \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
2392 % acquire any sources:
2393 \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table
2394 \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/x}\pgfplotstable@fgc@x
2395 \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/y}\pgfplotstable@fgc@y
2396 \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/foreach}\pgfplotstable@fgc@foreach@
2397 \ifx\pgfplotstable@fgc@foreach@\pgfutil@empty
2398 \ifx\pgfplotstable@fgc@table\pgfutil@empty
2399 \else
2400 % ok, we need to query (or load) a table!
2401 \expandafter\pgfplotstable@isloadedtable\expandafter{\pgfplotstable@fgc@table}{%
2402 \expandafter\let\expandafter\pgfplotstable@fgc@table\pgfplotstable@fgc@table
2403 }{%
2404 \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}%
2405 }%
2406 \fi
2407 \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@x}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@x@col
2408 \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@y}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@y@col
2409 %
2410 % search for epsilon in the y values:
2411 \expandafter\pgfplotstable@fgc@findintervalwitheps\expandafter{\csname pgfplotstable@fgc@#4@col\endcsname}{\csname pgfplotstable@fgc@#4mode\endcsname}%
2412 \ifx\pgfplotstable@fgc@second\pgfutil@empty
2413 \let\pgfmathresult=\pgfutil@empty
2414 \else
2415 %
2416 % acquire the associated x values:
2417 \expandafter\pgfplotstable@fgc@getassociated\expandafter{\csname pgfplotstable@fgc@#5@col\endcsname}{\csname pgfplotstable@fgc@#5mode\endcsname}%
2418 %
2419 % Interpolate:
2420 \pgfmathparse{
2421 \pgfplotstable@fgc@abscissafirst +
2422 (\pgfplotstable@fgc@eps - \pgfplotstable@fgc@first) / (\pgfplotstable@fgc@second-\pgfplotstable@fgc@first)
2423 * (\pgfplotstable@fgc@abscissasecond - \pgfplotstable@fgc@abscissafirst) }%
2424 \if\pgfplotstable@fgc@xmode1
2425 \pgfmathfloatexp@{\pgfmathresult}%
2426 \fi
2427 \pgflibraryfpuifactive{\pgfmathfloattosci{\pgfmathresult}}{}%
2428 %\message{FGC: found \pgfplotstable@fgc@eps\space in no \pgfplotstable@fgc@index; \pgfplotstable@fgc@first:\pgfplotstable@fgc@second; lastwasless=\pgfplotstable@fgc@lastwasless; abscissa interval = \pgfplotstable@fgc@abscissafirst:\pgfplotstable@fgc@abscissasecond; result = \pgfmathresult}%
2429 \fi
2430 \else
2431 \global\let\pgfplotstable@fgc@foreach=\pgfplotstable@fgc@foreach@
2432 \edef\pgfmathresult{x={\pgfplotstable@fgc@x},y={\pgfplotstable@fgc@y}}%
2433 \fi
2434 %
2435 \pgfmath@smuggleone\pgfmathresult
2436 \endgroup
2437 \ifx\pgfplotstable@fgc@foreach\pgfutil@empty
2438 \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
2439 \else
2440 % we have something like
2441 % foreach={\d in {1,2,3,4}}{table\d}
2442 % -> process it!
2443 % This will modify \pgfmathaccumb
2444 \let\pgfplotstable@fgc@foreach@process@append=\pgfmathresult
2445 \expandafter\pgfplotstable@fgc@foreach@process\pgfplotstable@fgc@foreach\pgfplots@EOI
2446 \fi
2447 \fi
2448 }%
2449 }%
2450
2451 \def\pgfplotstable@fgc@foreach@process{%
2452 \pgfutil@ifnextchar\bgroup
2453 {\pgfplotstable@fgc@foreach@process@a}{%
2454 \pgfplotstable@fgc@foreach@process@error}%
2455 }%
2456 \def\pgfplotstable@fgc@foreach@process@a#1{%
2457 \pgfutil@ifnextchar\bgroup
2458 {\pgfplotstable@fgc@foreach@process@b{#1}}{%
2459 \pgfplotstable@fgc@foreach@process@error}%
2460 }%
2461 \def\pgfplotstable@fgc@foreach@process@error#1\pgfplots@EOI{%
2462 \def\pgfplots@loc@TMPa{#1}%
2463 \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPb
2464 \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, I expected two arguments for /pgfplots/table/create col/function graph cut/foreach, but I found 'foreach=\pgfplots@loc@TMPb'. Perhaps the braces are not as expected?}\pgfeov%
2465 }%
2466 \def\pgfplotstable@fgc@foreach@process@b#1#2#3\pgfplots@EOI{%
2467 \global\pgfplotslistnewempty\pgfplots@glob@TMPa
2468 \begingroup
2469 \foreach #1 {%
2470 \edef\pgfplots@loc@TMPa{#2}%
2471 \expandafter\pgfplotslistpushfrontglobal\pgfplots@loc@TMPa\to\pgfplots@glob@TMPa
2472 }%
2473 \endgroup
2474 \pgfplotslistforeachungrouped\pgfplots@glob@TMPa\as\pgfplots@loc@TMPa{%
2475 \edef\pgfplots@loc@TMPa{table={\pgfplots@loc@TMPa},\pgfplotstable@fgc@foreach@process@append}%
2476 \expandafter\pgfplotslistpushfront\pgfplots@loc@TMPa\to\pgfmathaccumb
2477 }%
2478 }%
2479
2480 % #1 : the coordinate list to query
2481 % #2 : the mode
2482 %
2483 % POSTCONDITION:
2484 % - \pgfplotstable@fgc@abscissafirst and \pgfplotstable@fgc@abscissasecond
2485 % contain the abscissa values
2486 %
2487 \def\pgfplotstable@fgc@getassociated#1#2{%
2488 \c@pgfplotstable@counta=\pgfplotstable@fgc@index
2489 \pgfplotslistselect\c@pgfplotstable@counta\of#1\to\pgfplotstable@fgc@abscissasecond
2490 \advance\c@pgfplotstable@counta by-1
2491 \pgfplotslistselect\c@pgfplotstable@counta\of#1\to\pgfplotstable@fgc@abscissafirst
2492 \pgfmathfloatparsenumber{\pgfplotstable@fgc@abscissafirst}%
2493 \let\pgfplotstable@fgc@abscissafirst=\pgfmathresult
2494 \pgfmathfloatparsenumber{\pgfplotstable@fgc@abscissasecond}%
2495 \let\pgfplotstable@fgc@abscissasecond=\pgfmathresult
2496 \if1#2
2497 \pgfmathln@{\pgfplotstable@fgc@abscissafirst}%
2498 \let\pgfplotstable@fgc@abscissafirst=\pgfmathresult
2499 \pgfmathln@{\pgfplotstable@fgc@abscissasecond}%
2500 \let\pgfplotstable@fgc@abscissasecond=\pgfmathresult
2501 \fi
2502 }%
2503
2504 % Search for the (first) interval in #1 containing epsilon and return
2505 % \pgfplotstable@fgc@first and \pgfplotstable@fgc@second.
2506 %
2507 % #1 : the list of values.
2508 % #2 : the mode (0 = linear, 1 = log)
2509 %
2510 % PRECONDITION:
2511 % - \pgfplotstable@fgc@eps contains the value to search for
2512 %
2513 % POSTCONDITION
2514 % On success,
2515 % - \pgfplotstable@fgc@first and \pgfplotstable@fgc@second contain the interval.
2516 % - \pgfplotstable@fgc@index contains the index of the @second coordinate.
2517 % - \pgfplotstable@fgc@lastwasless is
2518 % 1 if \pgfplotstable@fgc@second < eps
2519 % 0 if \pgfplotstable@fgc@second >= eps
2520 % If there was no such interval,
2521 % \pgfplotstable@fgc@second will be empty.
2522 \def\pgfplotstable@fgc@findintervalwitheps#1#2{%
2523 \global\let\pgfplotstable@fgc@first=\pgfutil@empty
2524 \global\let\pgfplotstable@fgc@second=\pgfutil@empty
2525 \global\def\pgfplotstable@fgc@lastwasless{2}%
2526 \global\def\pgfplotstable@fgc@break{0}%
2527 \global\def\pgfplotstable@fgc@index{0}%
2528 \pgfplotslistforeach#1\as\pgfplotstable@fgc@val{%
2529 \if\pgfplotstable@fgc@break0
2530 \pgfmathfloatparsenumber{\pgfplotstable@fgc@val}%
2531 \let\pgfplotstable@fgc@val=\pgfmathresult
2532 \ifnum#2=1
2533 \pgfmathln@{\pgfplotstable@fgc@val}%
2534 \let\pgfplotstable@fgc@val=\pgfmathresult
2535 \fi
2536 \pgfmathfloatlessthan@{\pgfplotstable@fgc@val}{\pgfplotstable@fgc@eps}%
2537 \ifpgfmathfloatcomparison
2538 \pgfplotstable@fgc@findintervalwitheps@updateresult 01%
2539 \else
2540 \pgfplotstable@fgc@findintervalwitheps@updateresult 10%
2541 \fi
2542 \fi
2543 }%
2544 }%
2545
2546 % #1 : the value of \pgfplotstable@fgc@lastwasless for which the loop
2547 % shall break.
2548 % #2 : the next value for \pgfplotstable@fgc@lastwasless
2549 \def\pgfplotstable@fgc@findintervalwitheps@updateresult#1#2{%
2550 \if\pgfplotstable@fgc@lastwasless#1
2551 % found it !
2552 \global\let\pgfplotstable@fgc@second=\pgfplotstable@fgc@val
2553 \global\def\pgfplotstable@fgc@break{1}%
2554 \else
2555 \global\let\pgfplotstable@fgc@first=\pgfplotstable@fgc@val
2556 \c@pgfplotstable@counta=\pgfplotstable@fgc@index
2557 \advance\c@pgfplotstable@counta by1
2558 \xdef\pgfplotstable@fgc@index{\the\c@pgfplotstable@counta}%
2559 \fi
2560 \global\def\pgfplotstable@fgc@lastwasless{#2}%
2561 }%
2562
2563
2564
2565 \def\pgfplotstabletranspose@[#1]#2#3{%
2566 %\begingroup is already in \pgfplotstabletranspose
2567 \def\pgfplotstable@loc@TMPa{#1}%
2568 \ifx\pgfplotstable@loc@TMPa\pgfutil@empty
2569 \else
2570 \pgfplotstableset{#1}%
2571 \fi
2572 %
2573 \pgfkeysgetvalue{/pgfplots/table/colnames from}\pgfplotstabletranspose@outcolnames
2574 \pgfkeysgetvalue{/pgfplots/table/input colnames to}\pgfplotstabletranspose@incolnames
2575 \pgfkeysgetvalue{/pgfplots/table/columns}\pgfplotstable@colnames
2576 %
2577 \ifx\pgfplotstable@colnames\pgfutil@empty
2578 \pgfplotstableforeachcolumn{#3}\as\pgfplots@colname{%
2579 \t@pgfplots@toka=\expandafter{\pgfplots@colname}%
2580 \ifnum\pgfplotstablecol=0
2581 \edef\pgfplotstable@colnames{{\the\t@pgfplots@toka}}%
2582 \else
2583 \t@pgfplots@tokb=\expandafter{\pgfplotstable@colnames}%
2584 \edef\pgfplotstable@colnames{\the\t@pgfplots@tokb,{\the\t@pgfplots@toka}}%
2585 \fi
2586 }%
2587 \fi
2588 %
2589 % sanity checking:
2590 \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty
2591 \else
2592 \def\pgfplotstabletranspose@outcolnames@foundit{0}%
2593 \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotstable@colnames}\as\pgfplots@colname{%
2594 \ifx\pgfplots@colname\pgfplotstabletranspose@outcolnames
2595 \def\pgfplotstabletranspose@outcolnames@foundit{1}%
2596 \fi
2597 }%
2598 \if1\pgfplotstabletranspose@outcolnames@foundit
2599 \else
2600 % insert the 'colnames from' column into 'columns':
2601 \pgfplots@warning{table transposition: the 'colnames from=\pgfplotstabletranspose@outcolnames' is not part of 'columns'. Adding it.}%
2602 \t@pgfplots@toka=\expandafter{\pgfplotstabletranspose@outcolnames}%
2603 \t@pgfplots@tokb=\expandafter{\pgfplotstable@colnames}%
2604 \edef\pgfplotstable@colnames{\the\t@pgfplots@tokb,{\the\t@pgfplots@toka}}%
2605 \fi
2606 \fi
2607 %
2608 % The column NAMES are collected into this list:
2609 \global\pgfplotslistnewempty\pgfplotstable@colnames@glob
2610 % this thing counts output columns:
2611 \let\c@pgfplotstable@numoutcols=\c@pgf@countd
2612 \c@pgfplotstable@numoutcols=0
2613 \let\c@pgfplotstable@rowindex=\c@pgf@counta
2614 \c@pgfplotstable@rowindex=0
2615 %
2616 \ifx\pgfplotstabletranspose@incolnames\pgfutil@empty
2617 \else
2618 \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstabletranspose@incolnames}\to\pgfplotstable@colnames@glob
2619 \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}%
2620 \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@0\endcsname
2621 \advance\c@pgfplotstable@numoutcols by1
2622 \fi
2623 \def\pgfplotstable@isfirstcol{1}%
2624 \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotstable@colnames}\as\pgfplots@colname{%
2625 \c@pgfplotstable@rowindex=0
2626 \ifx\pgfplotstabletranspose@incolnames\pgfutil@empty
2627 \else
2628 \def\pgfplotstabletranspose@useit{1}%
2629 \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty
2630 \else
2631 \ifx\pgfplotstabletranspose@outcolnames\pgfplots@colname
2632 \def\pgfplotstabletranspose@useit{0}%
2633 \fi
2634 \fi
2635 \if1\pgfplotstabletranspose@useit
2636 \expandafter\pgfplotslist@assembleentry\expandafter{\pgfplots@colname}\into\t@pgfplots@tokc
2637 \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}%
2638 \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname
2639 \fi
2640 \advance\c@pgfplotstable@rowindex by1
2641 \fi
2642 %
2643 \pgfplotstableforeachcolumnelement\pgfplots@colname\of#3\as\pgfplots@cell{%
2644 \if1\pgfplotstable@isfirstcol
2645 % prepare a new column for the output:
2646 \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}%
2647 \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname
2648 %
2649 \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty
2650 \edef\pgfplotstable@loc@TMPa{\pgfplotstablerow}%
2651 \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames@glob
2652 \fi
2653 \advance\c@pgfplotstable@numoutcols by1
2654 \fi
2655 \def\pgfplotstabletranspose@useit{1}%
2656 \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty
2657 \else
2658 \ifx\pgfplotstabletranspose@outcolnames\pgfplots@colname
2659 \pgfutil@ifundefined{pgfplotstabletranspose@@\pgfplots@cell}{%
2660 }{%
2661 \let\pgfplots@loc@TMPa=\pgfplots@cell
2662 \pgfplotsthrow{non unique colname}{\pgfplots@loc@TMPa}{Sorry, 'colnames from=\pgfplotstabletranspose@outcolnames' doesn't yield unique column names (`\pgfplots@cell' comes twice)}\pgfeov%
2663 \ifx\pgfplots@loc@TMPa\pgfutil@empty
2664 \edef\pgfplots@cell{row no \pgfplotstablerow}%
2665 \fi
2666 }%
2667 \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@cell}\to\pgfplotstable@colnames@glob
2668 \expandafter\def\csname pgfplotstabletranspose@@\pgfplots@cell\endcsname{1}%
2669 \def\pgfplotstabletranspose@useit{0}%
2670 \fi
2671 \fi
2672 \if1\pgfplotstabletranspose@useit
2673 % append everything to the output column with index
2674 % \pgfplotstablerow
2675 \expandafter\pgfplotslist@assembleentry\expandafter{\pgfplots@cell}\into\t@pgfplots@tokc
2676 \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}%
2677 \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname
2678 \fi
2679 \advance\c@pgfplotstable@rowindex by1
2680 }%
2681 \def\pgfplotstable@isfirstcol{0}%
2682 }%
2683 %
2684 % flush the buffers of the applistX things:
2685 \c@pgfplotstable@rowindex=0
2686 \pgfutil@loop
2687 \ifnum\c@pgfplotstable@rowindex<\c@pgfplotstable@numoutcols
2688 \expandafter\pgfplotsapplistXflushbuffers\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname
2689 \advance\c@pgfplotstable@rowindex by1
2690 \pgfutil@repeat
2691 % finalize the global buffers:
2692 \def\pgfplotsscanlinelength{-1}%
2693 \edef\pgfplots@loc@TMPa{\pgfplotstablenameof{#3}_transposed}%
2694 \expandafter\pgfplotstable@copy@to@globalbuffers@simple\expandafter{\pgfplots@loc@TMPa}%
2695 \endgroup
2696 \pgfplotstable@copy@globalbuffers@to{#2}%
2697 }%
2698
2699 % #1: keys
2700 \def\pgfplotstable@linear@regression#1{%
2701 \begingroup
2702 \pgfqkeys{/pgfplots/table/create col/linear regression}{/pgf/fpu,#1}%
2703 \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/x}{\pgfplotstable@xsrc}%
2704 \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/y}{\pgfplotstable@ysrc}%
2705 \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/table}{\pgfplotstable@table}%
2706 \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/xmode}{\pgfplotstable@xmode}%
2707 \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/ymode}{\pgfplotstable@ymode}%
2708 \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance}{\pgfplotstable@variance@colname}%
2709 \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance list}{\pgfplotstable@variance@list}%
2710 \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance src}{\pgfplotstable@variance@table}%
2711 %
2712 \ifx\pgfplotstable@table\pgfutil@empty
2713 \pgfutil@ifundefined{pgfplotstablename}{}{% query the name of the actual table struct
2714 \let\pgfplotstable@table=\pgfplotstablename
2715 }%
2716 \fi
2717 \ifx\pgfplotstable@table\pgfutil@empty
2718 \pgfplots@error{Sorry, I couldn't determine a value for create col/linear regression/table. Which table should I load?}%
2719 \fi
2720 \ifx\pgfplotstable@xsrc\pgfutil@empty
2721 \pgfplotsifinaddplottablestruct{%
2722 \pgfutil@ifundefined{pgfplots@plot@tbl@x}{}{%
2723 \let\pgfplotstable@xsrc=\pgfplots@plot@tbl@x
2724 \ifx\pgfplotstable@ysrc\pgfutil@empty
2725 \pgfplotstablegetcolsof\pgfplots@table
2726 \ifnum\pgfplotsretval=2
2727 \else
2728 \pgfplotsthrow{invalid argument}{\pgfplotstable@ysrc}{Sorry, I don't which column should be used as `y' for the linear regression. Please provide 'linear regression={y=<colname>}'}\pgfeov%
2729 \fi
2730 \fi
2731 }%
2732 }{}%
2733 \fi
2734 \ifx\pgfplotstable@xsrc\pgfutil@empty
2735 \def\pgfplotstable@xsrc{[index]0}%
2736 \fi
2737 \ifx\pgfplotstable@ysrc\pgfutil@empty
2738 \def\pgfplotstable@ysrc{[index]1}%
2739 \fi
2740 %
2741 \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
2742 \t@pgfplots@tokb=\expandafter{\pgfplotstable@xsrc}%
2743 \t@pgfplots@tokc=\expandafter{\pgfplotstable@ysrc}%
2744 \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
2745 \edef\pgfplots@loc@TMPb{{\the\t@pgfplots@tokc}\noexpand\of{\the\t@pgfplots@toka}}%
2746 \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@X
2747 \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPb\to\pgfplotstable@Y
2748 %
2749 \edef\pgfplotstable@xmode{\pgfplotstable@xmode}%
2750 \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@xmode}{x}%%
2751 \edef\pgfplotstable@ymode{\pgfplotstable@ymode}%
2752 \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@ymode}{y}%%
2753 %
2754 \ifx\pgfplotstable@variance@list\pgfutil@empty
2755 % check 'variance' key (loaded from table)
2756 \pgfplotslistnewempty\pgfplotstable@VARIANCE
2757 \ifx\pgfplotstable@variance@colname\pgfutil@empty
2758 \else
2759 \ifx\pgfplotstable@variance@table\pgfutil@empty
2760 \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
2761 \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@colname}%
2762 \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
2763 \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@VARIANCE
2764 \else
2765 \t@pgfplots@toka=\expandafter{\pgfplotstable@variance@colname}%
2766 \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@table}%
2767 \edef\pgfplotstable@loc@TMPa{%
2768 \noexpand\pgfplotstablegetcolumn{\the\t@pgfplots@toka}\noexpand\of{\the\t@pgfplots@tokb}\noexpand\to\noexpand\pgfplotstable@VARIANCE}%
2769 \pgfplotstable@loc@TMPa
2770 \fi
2771 \fi
2772 \else
2773 % load from list:
2774 \expandafter\pgfplotslistnew\expandafter\pgfplotstable@VARIANCE\expandafter{\pgfplotstable@variance@list}%
2775 \fi
2776 %
2777 \pgfplotslistnewempty\pgfplotstable@Xparsed
2778 %
2779 \pgfmathfloatcreate{0}{0.0}{0}%
2780 \let\pgfplotstable@S=\pgfmathresult
2781 \let\pgfplotstable@Sxx=\pgfmathresult
2782 \let\pgfplotstable@Sx=\pgfmathresult
2783 \let\pgfplotstable@Sy=\pgfmathresult
2784 \let\pgfplotstable@Sxy=\pgfmathresult
2785 \pgfutil@loop
2786 \pgfplotslistcheckempty\pgfplotstable@X
2787 \ifpgfplotslistempty
2788 \pgfplots@loop@CONTINUEfalse
2789 \else
2790 \pgfplots@loop@CONTINUEtrue
2791 \fi
2792 \ifpgfplots@loop@CONTINUE
2793 \pgfplotslistpopfront\pgfplotstable@X\to\pgfplotstable@x
2794 \pgfplotslistpopfront\pgfplotstable@Y\to\pgfplotstable@y
2795 %
2796 % if either the x or y entry is non-finite, skip this point
2797 \pgfplotstableread@if@finite\pgfplotstable@x{%
2798 \pgfplotstableread@if@finite\pgfplotstable@y{%
2799 \pgfplotstableparsex{\pgfplotstable@x}%
2800 \let\pgfplotstable@x=\pgfmathresult
2801 \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@Xparsed
2802 \pgfplotstableparsey{\pgfplotstable@y}%
2803 \let\pgfplotstable@y=\pgfmathresult
2804 %
2805 \pgfplotslistcheckempty\pgfplotstable@VARIANCE
2806 \ifpgfplotslistempty
2807 \pgfmathfloatcreate{1}{1.0}{0}%
2808 \let\pgfplotstable@variance=\pgfmathresult
2809 \else
2810 \pgfplotslistpopfront\pgfplotstable@VARIANCE\to\pgfplotstable@variance
2811 \pgfmathfloatparsenumber{\pgfplotstable@variance}%
2812 \let\pgfplotstable@variance=\pgfmathresult
2813 \fi
2814 %
2815 % if we're in y log mode, then instead of y +- dy, we have log_b(y +- dy)
2816 % which Taylor expands to log_b(y) +- dy/(y ln(b)) + O(dy^2)
2817 % However, this might introduce a division-by-zero in the exceptional case
2818 % where b=1 or log_b(0) = -infinity, so instead of computing 1/(dy/(y ln b))^2
2819 % we will compute (y ln b)^2*1/dy^2. Note that we don't factor out the ^2
2820 % because floating point operations don't commute and the historical behavior
2821 % was to compute 1/dy^2.
2822 %
2823 \pgfmathfloatmultiply@{\pgfplotstable@variance}{\pgfplotstable@variance}%
2824 \let\pgfplotstable@sqr=\pgfmathresult
2825 \pgfmathfloatreciprocal@{\pgfplotstable@sqr}%
2826 \let\pgfplotstable@invsqr=\pgfmathresult
2827 \ifx\pgfplotstableparseylogbase\pgfutil@empty
2828 \else
2829 \if m\pgfplotstable@regression@variance@format
2830 % variance format=log
2831 \else
2832 % variance format=linear
2833 % N.B. at this point, \pgfplotstable@invsqr, \pgfplotstable@sqr, and \pgfplotstable@variance are
2834 % all missing log-scaling. We update \pgfplotstable@invsqr now, but leave \pgfplotstable@sqr
2835 % and \pgfplotstable@variance alone because they are not used below this point.
2836 \pgfplotstableparseyinv@{\pgfplotstable@y}% y
2837 \let\pgfplotstable@tmp=\pgfmathresult
2838 \pgfmathfloatmultiply@{\pgfplotstable@tmp}{\pgfplotstableparseylogofbasefloat}% y * ln(b)
2839 \let\pgfplotstable@ylnb=\pgfmathresult
2840 \pgfmathfloatmultiply@{\pgfplotstable@ylnb}{\pgfplotstable@ylnb}% (y * ln(b))^2
2841 \let\pgfplotstable@ylnbsqr=\pgfmathresult
2842 % since \pgfplotstable@invsqr is used, but \pgfplotstable@sqr and \pgfplotstable@variance are not
2843 % we only need to update \pgfplotstable@invsqr
2844 \pgfmathfloatmultiply@{\pgfplotstable@invsqr}{\pgfplotstable@ylnbsqr}% (y * ln(b))^2 / dy^2
2845 \let\pgfplotstable@invsqr=\pgfmathresult
2846 \fi
2847 \fi
2848 %
2849 \pgfmathfloatadd@{\pgfplotstable@S}{\pgfplotstable@invsqr}%
2850 \let\pgfplotstable@S=\pgfmathresult
2851 %
2852 \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@invsqr}%
2853 \let\pgfplots@table@accum=\pgfmathresult
2854 \pgfmathfloatadd@{\pgfplotstable@Sx}{\pgfplots@table@accum}%
2855 \let\pgfplotstable@Sx=\pgfmathresult
2856 %
2857 \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}%
2858 \let\pgfplots@table@accum=\pgfmathresult
2859 \pgfmathfloatadd@{\pgfplotstable@Sxx}{\pgfplots@table@accum}%
2860 \let\pgfplotstable@Sxx=\pgfmathresult
2861 %
2862 \pgfmathfloatmultiply@{\pgfplotstable@y}{\pgfplotstable@invsqr}%
2863 \let\pgfplots@table@accum=\pgfmathresult
2864 \pgfmathfloatadd@{\pgfplotstable@Sy}{\pgfplots@table@accum}%
2865 \let\pgfplotstable@Sy=\pgfmathresult
2866 %
2867 \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}%
2868 \let\pgfplots@table@accum=\pgfmathresult
2869 \pgfmathfloatadd@{\pgfplotstable@Sxy}{\pgfplots@table@accum}%
2870 \let\pgfplotstable@Sxy=\pgfmathresult
2871 }{%
2872 \pgfplotslistpushback\to\pgfplotstable@Xparsed%
2873 }}{%
2874 \pgfplotslistpushback\to\pgfplotstable@Xparsed%
2875 }%
2876 \pgfutil@repeat
2877 %
2878 \pgfmathparse{\pgfplotstable@S * \pgfplotstable@Sxx - \pgfplotstable@Sx *\pgfplotstable@Sx}%
2879 \let\pgfplotstable@delta=\pgfmathresult
2880 %
2881 \pgfmathparse{(\pgfplotstable@S * \pgfplotstable@Sxy - \pgfplotstable@Sx * \pgfplotstable@Sy) / \pgfplotstable@delta}%
2882 \let\pgfplotstable@a=\pgfmathresult
2883 %
2884 \pgfmathparse{(\pgfplotstable@Sxx * \pgfplotstable@Sy - \pgfplotstable@Sx * \pgfplotstable@Sxy) / \pgfplotstable@delta}%
2885 \let\pgfplotstable@b=\pgfmathresult
2886 %
2887 \pgfplotslistnewempty\pgfplotstable@RESULT
2888 \pgfplotslistforeachungrouped\pgfplotstable@Xparsed\as\pgfplotstable@x{%
2889 \pgfplotstableread@if@finite\pgfplotstable@x{%
2890 \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@a}%
2891 \let\pgfplotstable@tmp=\pgfmathresult
2892 \pgfmathfloatadd@{\pgfplotstable@tmp}{\pgfplotstable@b}%
2893 \ifx\pgfplotstableparseylogbase\pgfutil@empty
2894 \else
2895 \pgfplotstableparseyinv@{\pgfmathresult}%
2896 \fi
2897 \pgfmathfloattosci{\pgfmathresult}%
2898 \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@RESULT
2899 }{%
2900 \pgfplotslistpushback\to\pgfplotstable@RESULT%
2901 }%
2902 }%
2903 \pgfmathfloattosci\pgfplotstable@a
2904 \let\pgfplotstable@a=\pgfmathresult
2905 %
2906 \pgfmathfloattosci\pgfplotstable@b
2907 \let\pgfplotstable@b=\pgfmathresult
2908 %
2909 \global\let\pgfplotstableregressiona\pgfplotstable@a%
2910 \global\let\pgfplotstableregressionb\pgfplotstable@b%
2911 \let\pgfplotsretval=\pgfplotstable@RESULT
2912 \pgfmath@smuggleone\pgfplotsretval
2913 \endgroup
2914 }%
2915 \def\pgfplotstable@linear@regression@prepare@mode#1#2{%
2916 \expandafter\def\csname pgfplotstableparse#2\endcsname##1{\pgfmathfloatparsenumber{##1}}%
2917 \expandafter\def\csname pgfplotstableparse#2logbase\endcsname{}%
2918 \edef\pgfplots@loc@TMPa{#1}%
2919 \def\pgfplots@loc@TMPb{auto}%
2920 \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
2921 \def\pgfplots@loc@TMPa{}% auto == empty string
2922 \fi
2923 %
2924 \ifx\pgfplots@loc@TMPa\pgfutil@empty
2925 % `auto' mode.
2926 \pgfplotsifinaxis{%
2927 \pgfplots@if{pgfplots@#2islinear}{%
2928 \def\pgfplots@loc@TMPa{linear}%
2929 }{%
2930 \def\pgfplots@loc@TMPa{log}%
2931 }%
2932 }{%
2933 \def\pgfplots@loc@TMPa{linear}%
2934 }%
2935 \fi
2936 %
2937 \def\pgfplots@loc@TMPb{linear}%
2938 \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
2939 \else
2940 \def\pgfplots@loc@TMPb{log}%
2941 \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
2942 \pgfplotsmathdefinemacrolnbase{pgfplotstableparse#2}{\pgfkeysvalueof{/pgfplots/log basis #2}}%
2943 \else
2944 \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, the value '#1' is unexpected for 'linear regression/#2mode'}\pgfeov%
2945 \fi
2946 \fi
2947 }%
2948
2949
2950 % Sorts table #3 according to options defined in #1 and writes result
2951 % to #2.
2952 %
2953 % \pgfplotstablesort[sort key=<colname>]\result{<input table>}
2954 % \pgfplotstablesort[sort key=<colname>,sort key source=<\table>]\result{<input table>}
2955 \def\pgfplotstablesort{\pgfutil@ifnextchar[{\pgfplotstablesort@opt}{\pgfplotstablesort@opt[]}}
2956 \def\pgfplotstablesort@opt[#1]#2{%
2957 \begingroup
2958 \pgfplotstableset{#1}%
2959 \pgfplotstablecollectoneargwithpreparecatcodes{%
2960 \pgfplotstablesort@{#2}%
2961 }%
2962 }
2963 \def\pgfplotstablesort@#1#2{%
2964 \pgfkeysgetvalue{/pgfplots/table/sort key}\pgfplotstable@sort@key@colname
2965 \pgfkeysgetvalue{/pgfplots/table/sort key from}\pgfplotstable@sort@key@table
2966 \pgfkeysgetvalue{/pgfplots/table/sort cmp}\pgfplotstable@sort@cmp
2967 %
2968 %
2969 \pgfplotstable@isloadedtable{#2}{%
2970 \pgfplotstablegetrowsof{#2}%
2971 \let\pgfplotstable@numrows=\pgfplotsretval
2972 %
2973 \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp{#2}%
2974 \def\pgfplotstable@table{#2}%
2975 \let\pgfplotstable@input@colnames=#2\relax
2976 }{%
2977 \pgfplotstableread{#2}\pgfp@tmp@in
2978 \pgfplotstablegetrowsof\pgfp@tmp@in
2979 \let\pgfplotstable@numrows=\pgfplotsretval
2980 \def\pgfplotstable@table{\pgfp@tmp@in}%
2981 \let\pgfplotstable@input@colnames=\pgfp@tmp@in
2982 %
2983 \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp\pgfp@tmp@in
2984 }%
2985 %
2986 \ifx\pgfplotstable@sort@key@colname\pgfutil@empty
2987 \else
2988 \ifx\pgfplotstable@sort@key@table\pgfutil@empty
2989 \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
2990 \t@pgfplots@tokb=\expandafter{\pgfplotstable@sort@key@colname}%
2991 \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
2992 \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@sort@key
2993 \else
2994 \t@pgfplots@toka=\expandafter{\pgfplotstable@sort@key@colname}%
2995 \t@pgfplots@tokb=\expandafter{\pgfplotstable@sort@key@table}%
2996 \edef\pgfplotstable@loc@TMPa{%
2997 \noexpand\pgfplotstablegetcolumn{\the\t@pgfplots@toka}\noexpand\of{\the\t@pgfplots@tokb}\noexpand\to\noexpand\pgfplotstable@sort@key}%
2998 \pgfplotstable@loc@TMPa
2999 \fi
3000 \fi
3001 \pgfplotsarraynewempty\pgfplotstable@sort@key@array
3002 \pgfplotslistforeachungrouped{\pgfplotstable@sort@key}\as\pgfplotstable@loc@TMPa{%
3003 \expandafter\pgfplotsarraypushback\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@sort@key@array
3004 }%
3005 %
3006 %
3007 % use a side effect: columns are integers, they are stored as
3008 % '\pgfp@tmp@<index>'. Thus, column names and array indices are
3009 % essentially the same! That simplifies the operation and explains
3010 % why we transposed the table.
3011 % We simply interpret the transposed table as array. We don't
3012 % even need to copy anything.
3013 \pgfplotsarrayresize{\pgfp@tmp}{\pgfplotstable@numrows}%
3014 % Oh, we also need the index to access the sort key. Well, then we
3015 % did not win anything.
3016 \pgfplotsarrayforeachungrouped\pgfp@tmp\as\pgfplotstable@loc@TMPa{%
3017 \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}%
3018 \edef\pgfplotstable@loc@TMPa{\pgfplotsarrayforeachindex:{\the\t@pgfplots@toka}}%
3019 \pgfplotsarrayletentry{\pgfplotsarrayforeachindex}\of\pgfp@tmp=\pgfplotstable@loc@TMPa
3020 }%
3021 % extract current row index and row content:
3022 \def\pgfplotstable@sort@extractindex##1:##2{%
3023 \def\pgfmathresult{##1}%
3024 \def\pgfplotstable@row{##2}%
3025 }%
3026 %
3027 \expandafter\pgfplotsset\expandafter{\pgfplotstable@sort@cmp}%
3028 \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotstable@sort@cmp@routine
3029 \def\pgfplotstable@sort@iflt##1##2##3##4{\pgfplotstable@sort@cmp@routine{##1}{##2}{##3}{##4}\pgfeov}%
3030 %
3031 \pgfkeysdefargs{/pgfplots/iflessthan}{##1##2##3##4}{%
3032 \expandafter\pgfplotstable@sort@extractindex##1%
3033 \pgfplotsarrayselect{\pgfmathresult}\of\pgfplotstable@sort@key@array\to\pgfplotstable@arga
3034 \expandafter\pgfplotstable@sort@extractindex##2%
3035 \pgfplotsarrayselect{\pgfmathresult}\of\pgfplotstable@sort@key@array\to\pgfplotstable@argb
3036 \pgfplotstable@sort@iflt{\pgfplotstable@arga}{\pgfplotstable@argb}{##3}{##4}%
3037 }%
3038 \pgfkeysdef{/pgfplots/array/unscope pre}{%
3039 % remove the row index:
3040 \pgfplotsarrayforeachungrouped\pgfp@tmp\as\pgfplotstable@loc@TMPa{%
3041 \expandafter\pgfplotstable@sort@extractindex\pgfplotstable@loc@TMPa%
3042 \pgfplotsarrayletentry{\pgfplotsarrayforeachindex}\of\pgfp@tmp=\pgfplotstable@row
3043 }%
3044 % restore original form:
3045 \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp@result\pgfp@tmp
3046 % technical, transport result out of the current scope ...
3047 \pgfplotstable@copy@to@globalbuffers\pgfp@tmp@result{\pgfplotstablenameof\pgfp@tmp}%
3048 % ... and use this lowlevel thing to transport the original column names.
3049 \global\let\pgfplotstable@colnames@glob=\pgfplotstable@input@colnames
3050 }%
3051 \pgfkeysdef{/pgfplots/array/unscope post}{}%
3052 \pgfplotsarraysort{\pgfp@tmp}%
3053 \endgroup
3054 \pgfplotstable@copy@globalbuffers@to{#1}%
3055 }%
3056
3057 \pgfutil@IfUndefined{pgfcalendardatetojulian}{%
3058 \def\pgfcalendardatetojulian#1#2{\pgfplots@error{Sorry, you need to use \string\usepackage{pgfcalendar} before using date specific methods}}%
3059 }{}%
3060 \endinput