diff options
author | Karl Berry <karl@freefriends.org> | 2009-02-05 01:04:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-02-05 01:04:42 +0000 |
commit | ad23c1c436c3e031cc4b81849d0fa2b892851467 (patch) | |
tree | d04be182dbf5cdb14c1728b8f2edddc84f77df03 /Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex | |
parent | 4041df693bc0b66ecdf77e891e5ff1a60f1497fc (diff) |
pgfplots update (4feb09)
git-svn-id: svn://tug.org/texlive/trunk@12087 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex | 1162 |
1 files changed, 995 insertions, 167 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex index 77a40d51ed5..2d0ec9c1911 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex @@ -28,11 +28,39 @@ % %-------------------------------------------- + +% This file provides a high-level table manipulation and typesetting +% package. +% +% +% --------------------------------------------- +% Implementation notes for programmers: +% --------------------------------------------- +% +% The table data structure consists of +% 1. A name which must be a valid TeX macro like '\table' +% 2. A column list in the \pgfplotslist format. +% In fact, the column list is stored in the table's name: +% \pgfplotslistnewempty\table +% 3. A "file name" stored in +% \csname\string<\namemacro>@@table@name\endcsname +% 4. foreach column, there is a list of row-values (a row-vector) in +% the \pgfplotslist format named +% \csname\string<\namemacro>@<column name>\endcsname +% + + \newif\ifpgfplotstable@search@header \newcount\c@pgfplotstable@counta \newwrite\pgfplotstable@outfile \newif\ifpgfplotstabletypesetdebug +\newif\ifpgfplotstabletypesetskipcoltypes +\newif\ifpgfplotstabletypesetresult \newif\ifpgfplotstableuserow +\newif\ifpgfplotstabletypeset@includeoutfiles +\newif\ifpgfplotstabletypeset@force@remake +\newif\ifpgfplots@addplotimpl@readcompletely +\newif\ifpgfplotstable@disable@rowcolstyles % should always be false; use only in grouped internal macros \newif\ifpgfplots@table@options@areset @@ -40,6 +68,22 @@ \input pgfplotstable.coltype.code.tex +% #1= floating point number +% #2= TeX code to execute if #1 == 0 +% #3= TeX code to execute if #1 != 0 +\def\pgfplots@ifzero#1#2#3{% + \expandafter\pgfmathfloat@decompose@F#1\relax\pgfmathfloat@a@S + \ifnum\pgfmathfloat@a@S=0 #2\else#3\fi +}% + +% just make sure no-one complaints if manual example are used without +% booktabs loaded: +\pgfutil@ifundefined{toprule}{% + \def\toprule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\toprule}}% + \def\midrule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\midrule}}% + \def\bottomrule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\bottomrule}}% +}{\relax}% + % keys which are NOT predefined: % /pgfplots/table/alias/<col alias>/.initial={<real col>} % /pgfplots/table/columns/<col name>/.style={} @@ -48,18 +92,24 @@ \pgfkeys{% /pgfplots/table/header/.is if=pgfplotstable@search@header, /pgfplots/table/header=true, - /pgfplots/table/x index/.store in=\pgfplots@plot@tbl@xindex, - /pgfplots/table/x index=0, - /pgfplots/table/x/.store in=\pgfplots@plot@tbl@x, - /pgfplots/table/x=, - /pgfplots/table/y index/.store in=\pgfplots@plot@tbl@yindex, - /pgfplots/table/y index=1, - /pgfplots/table/y/.store in=\pgfplots@plot@tbl@y, - /pgfplots/table/y=, + /pgfplots/table/x index/.initial=0, + /pgfplots/table/x/.initial=, + /pgfplots/table/y index/.initial=1, + /pgfplots/table/y/.initial=, + /pgfplots/table/z index/.initial=2, + /pgfplots/table/z/.initial=, + /pgfplots/table/meta index/.initial=, + /pgfplots/table/meta/.initial=, /pgfplots/table/x error index/.initial=, /pgfplots/table/y error index/.initial=, + /pgfplots/table/z error index/.initial=, /pgfplots/table/x error/.initial=, /pgfplots/table/y error/.initial=, + /pgfplots/table/z error/.initial=, + /pgfplots/table/read completely/.is if=pgfplots@addplotimpl@readcompletely, + /pgfplots/table/read completely/.default=true, + /pgfplots/table/disable rowcol styles/.is if=pgfplotstable@disable@rowcolstyles, + /pgfplots/table/disable rowcol styles/.default=true, /pgfplots/table/row predicate/.code={}, /pgfplots/table/skip rows between index/.style 2 args={% /pgfplots/table/row predicate/.append code={% @@ -140,52 +190,65 @@ }% }, /pgfplots/table/multicolumn names/.default=c, - /pgfplots/table/dec sep align/.style={% + /pgfplots/table/dec sep align/.code={% + \pgfplots@assert@LaTeX@package@loaded{array}{dec sep align}% + \pgfkeysalso{% /pgf/number format/assume math mode, - /pgf/number format/@dec sep mark={&}, + /pgf/number format/@dec sep mark={$&$}, /pgfplots/table/assign column name/.code={% \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}% },% - /pgfplots/table/column type={>{$}r<{$}@{}>{$}l<{$}}, + /pgfplots/table/column type={% + r<{\pgfplotstableresetcolortbloverhangright}% + @{}% + l<{\pgfplotstableresetcolortbloverhangleft}% + }, /pgfplots/table/assign cell content/.code={% \def\pgfmathresult{##1}% \ifx\pgfmathresult\pgfutil@empty \def\pgfmathresult{&}% - % \pgfutil@in@false \else \pgfmathprintnumberto{##1}\pgfmathresult% - % \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}% + % now make sure we have math mode for the single + % columns: + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}% \fi - %\ifpgfutil@in@ - %\else - % \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult&}% - %\fi \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult }, + }% }, /pgfplots/table/dec sep align/.default=c, - /pgfplots/table/sci sep align/.style={% + /pgfplots/table/sci sep align/.code={% + \pgfplots@assert@LaTeX@package@loaded{array}{sci sep align}% + \pgfkeysalso{% /pgf/number format/assume math mode, - /pgf/number format/@sci exponent mark={&}, + /pgf/number format/@sci exponent mark={$&$}, /pgfplots/table/assign column name/.code={% \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}% },% - /pgfplots/table/column type={>{$}r<{$}@{}>{$}l<{$}}, + /pgfplots/table/column type={% + r<{\pgfplotstableresetcolortbloverhangright}% + @{}% + l<{\pgfplotstableresetcolortbloverhangleft}% + }, /pgfplots/table/assign cell content/.code={% \def\pgfmathresult{##1}% \ifx\pgfmathresult\pgfutil@empty \def\pgfmathresult{&}% - \pgfutil@in@true \else \pgfmathprintnumberto{##1}\pgfmathresult% \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}% - \fi - \ifpgfutil@in@ - \else - \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult&}% + % now make sure we have math mode for the single + % columns: + \ifpgfutil@in@ + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}% + \else + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter\pgfutilensuremath\expandafter{\pgfmathresult}&}% + \fi \fi \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult }, + }% }, /pgfplots/table/sci sep align/.default=c, % @@ -215,6 +278,15 @@ /pgfplots/table/begin table/.initial={\begin{tabular}}, /pgfplots/table/end table/.initial={\end{tabular}}, /pgfplots/table/outfile/.initial=, + /pgfplots/table/include outfiles/.is if=pgfplotstabletypeset@includeoutfiles, + /pgfplots/table/include outfiles/.default=true, + /pgfplots/table/force remake/.is if=pgfplotstabletypeset@force@remake, + /pgfplots/table/force remake/.default=true, + /pgfplots/table/write to macro/.initial=, + /pgfplots/table/typeset/.is if=pgfplotstabletypesetresult, + /pgfplots/table/typeset=true, + /pgfplots/table/skip coltypes/.is if=pgfplotstabletypesetskipcoltypes, + /pgfplots/table/skip coltypes/.default=true, /pgfplots/table/debug/.is if=pgfplotstabletypesetdebug, % % will be redefined by |assign cell content| for every cell: @@ -246,6 +318,23 @@ /pgfplots/table/@cell content={##1}% }% },% + /pgfplots/table/date type/.style={% + /pgfplots/table/assign cell content/.code={% + \begingroup + \pgfcalendardatetojulian{##1}\c@pgfplotstable@counta + \pgfcalendarjuliantodate{\c@pgfplotstable@counta}\year\month\day + \pgfcalendarjuliantoweekday\c@pgfplotstable@counta\c@pgf@countc + \edef\weekday{\the\c@pgf@countc }% + \edef\weekdayname{\pgfcalendarweekdayname\c@pgf@countc}% + \edef\weekdayshortname{\pgfcalendarweekdayshortname\c@pgf@countc}% + \edef\monthname{\pgfcalendarmonthname\month}% + \edef\monthshortname{\pgfcalendarmonthshortname\month}% + \xdef\pgfplots@glob@TMPa{#1}% + \endgroup + \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPa% + }% + },% + /pgfplots/table/date type/.default={\year/\month/\day}% /pgfplots/table/set content/.style={% /pgfplots/table/postproc cell content/.style={% /pgfplots/table/@cell content={#1}% @@ -255,10 +344,40 @@ /pgfplots/table/postproc cell content/.code={}, /pgfplots/table/preproc cell content/.code={}, % + /pgfplots/table/clear infinite/.style={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\pgfmatharga=\pgfmathresult + {% + \pgfmathfloatgetflags\pgfmatharga\c@pgfplotstable@counta + \xdef\pgfplots@glob@TMPc{\the\c@pgfplotstable@counta}% + }% + \ifnum\pgfplots@glob@TMPc<3 + \pgfmathfloattosci@\pgfmathresult + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \else + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfutil@empty}% + \fi + \fi + } + }, + /pgfplots/table/string replace/.style 2 args={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \def\pgfplots@loc@TMPa{#1}% + \ifx\pgfmathresult\pgfplots@loc@TMPa + \def\pgfplots@loc@TMPb{#2}% + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplots@loc@TMPb}% + \fi + } + }, /pgfplots/table/multiply -1/.style={% /pgfplots/table/preproc cell content/.append code={% \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult - \ifx\pgfmathresult\empty + \ifx\pgfmathresult\pgfutil@empty \else \pgfmathfloatparsenumber{\pgfmathresult}% \let\pgfmatharga=\pgfmathresult @@ -270,6 +389,44 @@ \fi } }, + /pgfplots/table/multiply with/.code={% + \pgfmathfloatparsenumber{#1}% + \let\pgfplotstable@scale=\pgfmathresult + \pgfkeysalso{ + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\pgfmatharga=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmatharga}{\pgfplotstable@scale}% + \pgfmathfloattosci@\pgfmathresult + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \fi + }% + }% + }, + /pgfplots/table/divide by/.code={% + \pgfkeysalso{/pgfplots/table/multiply with=#1}% + \let\pgfplotstable@divisor=\pgfplotstable@scale + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfplotstable@ONE=\pgfmathresult + \pgfmathfloatdivide@{\pgfplotstable@ONE}{\pgfplotstable@divisor}% + \let\pgfplotstable@scale=\pgfmathresult + }, + /pgfplots/table/sqrt/.style={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\pgfmatharga=\pgfmathresult + \pgfmathfloatsqrt@{\pgfmatharga}% + \pgfmathfloattosci@\pgfmathresult + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \fi + }% + }, /pgfplots/table/empty cells with/.style={% /pgfplots/table/postproc cell content/.append code={% \ifnum\pgfplotstablepartno=0 @@ -283,7 +440,8 @@ % /pgfplots/table/font/.initial=, /pgfplots/table/.unknown/.code={% - \pgfqkeys{/pgf/number format}{\pgfkeyscurrentname=#1}% + \let\pgfplots@table@curkeyname=\pgfkeyscurrentname + \pgfqkeys{/pgf/number format}{\pgfplots@table@curkeyname=#1}% },% /pgfplots/table/create col/assign first/.style={ /pgfplots/table/create col/assign% @@ -295,12 +453,63 @@ /pgfplots/table/create col/next content={}% }, /pgfplots/table/create col/next content/.initial={}, - /pgfplots/table/create col/expr/.style={% + /pgfplots/table/create col/copy/.style={% /pgfplots/table/create col/assign/.code={% + \getthisrow{#1}\pgfmathresult + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + }, + /pgfplots/table/create col/set/.style={% + /pgfplots/table/create col/assign/.code={% + \def\pgfmathresult{#1}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + },% + /pgfplots/table/create col/set list/.code={% + \pgfplots@assign@list\pgfmathaccumb{#1}% + \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}% + },% + /pgfplots/table/create col/expr accum/.code 2 args={% + \ifpgfplots@usefpu + \pgfkeysalso{/pgf/fpu=true,/pgf/fpu/output format=sci}% + \fi + \pgfkeysdef{/pgfplots/table/create col/assign}{% + \ifx\pgfmathaccuma\pgfutil@empty + \pgfmathparse{#2}% + \let\pgfmathaccuma=\pgfmathresult + \fi \pgfmathparse{#1}% \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \let\pgfmathaccuma=\pgfmathresult }% + }, + /pgfplots/table/create col/expr/.style={% + /pgfplots/table/create col/expr accum={#1}{0}% },% + /pgfplots/table/create col/copy column from table/.code 2 args={% + \pgfplotstable@isloadedtable{#1}{% + \pgfplotstablegetcolumnbyname{#2}\of#1\to\pgfmathaccumb + }{% + \begingroup + \pgfplotstableread{#1}\pgfplotstable@tmptbl + \pgfplotstablegetcolumnbyname{#2}\of\pgfplotstable@tmptbl\to\pgfmathaccumb + \pgfmath@smuggleone\pgfmathaccumb + \endgroup + }% + \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}% + }, + /pgfplots/table/create col/@from list struct/.code={% + \pgfplotslistcopy#1\to\pgfmathaccumb + \pgfkeysdef{/pgfplots/table/create col/assign}{% + \pgfplotslistcheckempty\pgfmathaccumb + \ifpgfplotslistempty + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + \else + \pgfplotslistpopfront\pgfmathaccumb\to\pgfmathresult + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \fi + }% + }, /pgfplots/table/create col/quotient/.style={% /pgfplots/table/columns={#1}, /pgfplots/table/create col/assign first/.style={% @@ -312,9 +521,13 @@ \pgfmathfloatparsenumber{\thisrow{#1}}% \let\pgfmathargb=\pgfmathresult \let\pgfmathaccuma=\pgfmathargb - \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% - \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfplots@ifzero\pgfmathargb{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% }% },% /pgfplots/table/create col/iquotient/.style={% @@ -328,9 +541,13 @@ \pgfmathfloatparsenumber{\thisrow{#1}}% \let\pgfmatharga=\pgfmathresult \let\pgfmathaccuma=\pgfmathargb - \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% - \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfplots@ifzero\pgfmathargb{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% }% },% % @@ -350,13 +567,17 @@ \pgfmathfloatparsenumber{\thisrow{#1}}% \let\pgfmathargb=\pgfmathresult \let\pgfmathaccuma=\pgfmathargb - \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% - \pgfmathlog@float{\pgfmathresult}% - \ifx\pgfmathresult\pgfutil@empty - \else - \pgfmathmultiply@{1.442695}{\pgfmathresult}% - \fi - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfplots@ifzero\pgfmathargb{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \pgfmathlog@float{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathmultiply@{1.442695}{\pgfmathresult}% + \fi + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% }% },% /pgfplots/table/create col/idyadic refinement rate/.style={% @@ -370,13 +591,17 @@ \pgfmathfloatparsenumber{\thisrow{#1}}% \let\pgfmatharga=\pgfmathresult \let\pgfmathaccuma=\pgfmathargb - \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% - \pgfmathlog@float{\pgfmathresult}% - \ifx\pgfmathresult\pgfutil@empty - \else - \pgfmathmultiply@{1.442695}{\pgfmathresult}% - \fi - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfplots@ifzero\pgfmathargb{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \pgfmathlog@float{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathmultiply@{1.442695}{\pgfmathresult}% + \fi + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% }% },% /pgfplots/table/create col/gradient/.style 2 args={% @@ -402,9 +627,13 @@ \let\pgfmathdiff@x=\pgfmathresult \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% \let\pgfmathdiff@y=\pgfmathresult - \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% - \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfplots@ifzero\pgfmathdiff@x{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% },% },% /pgfplots/table/create col/gradient loglog/.style 2 args={% @@ -436,12 +665,18 @@ \let\pgfmathdiff@x=\pgfmathresult \pgfmathsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% \let\pgfmathdiff@y=\pgfmathresult - \pgfmathdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \ifdim\pgfmathdiff@x pt=0.0pt + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + \else + \pgfmathdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \fi \else - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloattosci@\pgfmathresult + % \pgfmathfloatcreate{3}{0.0}{0}% + % \pgfmathfloattosci@\pgfmathresult + % \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% \fi - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% },% },% /pgfplots/table/create col/gradient semilogx/.style 2 args={% @@ -478,9 +713,13 @@ \let\pgfmathdiff@x=\pgfmathresult \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% \let\pgfmathdiff@y=\pgfmathresult - \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% - \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfplots@ifzero\pgfmathdiff@x{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% },% },% /pgfplots/table/create col/gradient semilogy/.style 2 args={% @@ -517,14 +756,95 @@ \let\pgfmathdiff@x=\pgfmathresult \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% \let\pgfmathdiff@y=\pgfmathresult - \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% - \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \pgfplots@ifzero\pgfmathdiff@x{% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + }{% + \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% },% },% + /pgfplots/table/typeset cell/.code={% + \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax + \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1\\}% + \else + \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1&}% + \fi + }, + /pgfplots/table/reset styles/.style={ + /pgfplots/table/every table/.code=, + /pgfplots/table/every odd column/.code=, + /pgfplots/table/every even column/.code=, + /pgfplots/table/every first column/.code=, + /pgfplots/table/every last column/.code=, + /pgfplots/table/every head row/.code=, + /pgfplots/table/every odd row/.code=, + /pgfplots/table/every even row/.code=, + /pgfplots/table/every first row/.code=, + /pgfplots/table/every last row/.code=, + }, } + +% 'function graph cut y'={<epsilon>}{<options>}{comma-separated-list of specs where to get yi} +% +% fills the column with x1,...,xN such that yi(xi) == epsilon where +% +% In other words, it computes cuts points between the line +% y == epsilon and one or more other plots yi(x) and returns the 'x' +% values of the cuts. +% +% Example: +% \pgfplotstableset{ +% create on use/cut/.style={create col/function graph cut y={7e-4}{x=Basis,ymode=log,xmode=log}{{table=regtable,y=special-L2}}}, +%} +\pgfkeysdefargs{/pgfplots/table/create col/function graph cut y}{#1#2#3}{\pgfplotstable@fgc@init{#1}{#2}{#3}{y}{x}} +\pgfkeysdefargs{/pgfplots/table/create col/function graph cut x}{#1#2#3}{\pgfplotstable@fgc@init{#1}{#2}{#3}{x}{y}} +\pgfkeys{% + /pgfplots/table/create col/function graph cut/xmode/.is choice, + /pgfplots/table/create col/function graph cut/xmode/linear/.code={\def\pgfplotstable@fgc@xmode{0}},% + /pgfplots/table/create col/function graph cut/xmode/log/.code={\def\pgfplotstable@fgc@xmode{1}},% + /pgfplots/table/create col/function graph cut/ymode/.is choice, + /pgfplots/table/create col/function graph cut/ymode/linear/.code={\def\pgfplotstable@fgc@ymode{0}},% + /pgfplots/table/create col/function graph cut/ymode/log/.code={\def\pgfplotstable@fgc@ymode{1}},% + /pgfplots/table/create col/function graph cut/x/.initial=, + /pgfplots/table/create col/function graph cut/y/.initial=, + /pgfplots/table/create col/function graph cut/table/.initial=, +} + + +\pgfkeyslet{/pgfplots/table/TeX comment}\pgfplots@PERCENT@TEXT \pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent@EMPTY + +% A helper macro to automatically remove the "hangover" created by +% 'colortbl'. +% This allows compatibility between my 'sci sep align' and 'dec sep align' +% implementations and \rowcolor. Otherwise, the hangover +% would overwrite digits near the separator. +% +% @remark This does also work if colortbl is not loaded. +\def\pgfplotstableresetcolortbloverhangright{% + \pgfutil@ifundefined{CT@row@color}{\relax}{% + \global\let\pgfplots@origrowcolorcmd=\CT@row@color + \gdef\CT@row@color{% + \pgfplots@origrowcolorcmd + \@tempdimc=0pt + \global\let\CT@row@color=\pgfplots@origrowcolorcmd + }% + }% +}% +\def\pgfplotstableresetcolortbloverhangleft{% + \pgfutil@ifundefined{CT@row@color}{\relax}{% + \global\let\pgfplots@origrowcolorcmd=\CT@row@color + \gdef\CT@row@color{% + \pgfplots@origrowcolorcmd + \@tempdimb=0pt + \global\let\CT@row@color=\pgfplots@origrowcolorcmd + }% + }% +}% + % \pgfplotstableread[OPTIONS] {FILE} to \name % % This method reads a table from FILE to macro \name. @@ -571,10 +891,172 @@ % BACKWARDS COMPATIBILITY \let\pgfnumtableread=\pgfplotstableread -\def\pgfplotstablegetcolumnlist#1\to#2{% - \let#2=#1 +% Invokes #2 if '#1' is an already loaded table and #3 if not. +\long\def\pgfplotstable@isloadedtable#1#2#3{% + \pgfutil@ifundefined{\string#1@@table@name}{#3}{#2}% +}% + +% Defines \pgfmathresult to be the number of rows in table #1. +% +% #1 may be either a loaded table structure (a macro name) or a table +% file name. In the latter case, the file will be loaded temporarily. +\def\pgfplotstablegetrowsof#1{% + \pgfplotstable@isloadedtable{#1}{% + % ah - it is an already loaded table! + \begingroup + \pgfplotslistfront#1\to\pgfplotstablegetrows@@ + \expandafter\pgfplotslistsize\csname\string#1@\pgfplotstablegetrows@@\endcsname\to\c@pgfplotstable@counta + \edef\pgfmathresult{\the\c@pgfplotstable@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + }{% + % ah - it is a file name. + \begingroup + \pgfplotstableread{#1}\pgfplotstablegetrows@ + \pgfplotstablegetrowsof{\pgfplotstablegetrows@}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + }% +}% + +% \pgfplotstablesave[<options>]{<\tablename>}{file name} +\def\pgfplotstablesave{% + \pgfutil@ifnextchar[{% + \pgfplotstablesave@impl + }{% + \pgfplotstablesave@impl[]% + }% +} + +{ +\catcode`\^^I=12 +\gdef\pgfplotstablesave@impl@TAB{^^I} } +\def\pgfplotstablesave@impl[#1]#2#3{% + \pgfplotstabletypeset[% + reset styles,% + disable rowcol styles,% + begin table={}, end table={},% + typeset cell/.code={% + \begingroup + \t@pgfplots@toka={##1}% + \ifcase\pgfplotstableread@OUTCOLSEP@CASE\relax + % SPACE: + \t@pgfplots@tokb=\expandafter{\pgfplotstablesave@impl@TAB}% + \pgfplots@ifempty{##1}{% + \t@pgfplots@toka={{}}% + }{}% + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \or + % comma: + \t@pgfplots@tokb={,}% + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \or + % semicolon: + \t@pgfplots@tokb={;}% + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \or + % colon: + \t@pgfplots@tokb={:}% + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \or + % braces: + \xdef\pgfplots@glob@TMPc{{\the\t@pgfplots@toka}}% + \fi + \endgroup + \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPc% + },% + before row=,after row=,% + skip coltypes, typeset=false, string type,% + TeX comment=,% + columns=,% + font=,% + /pgfplots/table/col sep/.is choice,% + /pgfplots/table/col sep/space/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{0}},% + /pgfplots/table/col sep/comma/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{1}},% + /pgfplots/table/col sep/semicolon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{2}},% + /pgfplots/table/col sep/colon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{3}},% + /pgfplots/table/col sep/braces/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{4}},% + /pgfplots/table/col sep=space,% + /pgfplots/table/in col sep/.is choice,% + /pgfplots/table/in col sep/space/.code = {\def\pgfplotstableread@COLSEP@CASE{0}},% + /pgfplots/table/in col sep/comma/.code = {\def\pgfplotstableread@COLSEP@CASE{1}},% + /pgfplots/table/in col sep/semicolon/.code = {\def\pgfplotstableread@COLSEP@CASE{2}},% + /pgfplots/table/in col sep/colon/.code = {\def\pgfplotstableread@COLSEP@CASE{3}},% + /pgfplots/table/in col sep/braces/.code = {\def\pgfplotstableread@COLSEP@CASE{4}},% + /pgfplots/table/in col sep=space,% + % WARNING: you NEED a '%' before '#1': + #1,% + outfile={#3}% + ]{#2}% +}% + +% \pgfplotstablenew[<options>]{<numrows>}{<\name>} +% +% Creates a new table from scratch. +% +% The new table will contain all columns listed in the 'columns' key +% which must be present in <options>. +% +% Furthermore, there must be 'create on use' statements for every +% column which shall be generated. Columns are generated +% independently, in the order of appearance in 'columns'. +% The table will contain exactly <numrows> rows. +\def\pgfplotstablenew{% + \pgfutil@ifnextchar[{% + \pgfplotstablenew@impl + }{% + \pgfplotstablenew@impl[]% + }% +}% +\def\pgfplotstablenew@impl[#1]#2#3{% + \pgfutil@namedef{\string#3@@table@name}{newlycreatedtable}% + \begingroup + % create a temporary column with the desired number of rows: + \pgfutil@in@\pgfplotstablegetrowsof{#2}% + \ifpgfutil@in@ + #2% + \let\pgfplotstable@loc@TMPa=\pgfmathresult + \else + \def\pgfplotstable@loc@TMPa{#2}% + \fi + \pgfplotslistnew#3{@@@@@temporary@column@\\}% + \expandafter\pgfplots@assign@list\csname\string#3@@@@@@temporary@column@\endcsname{1,2,...,\pgfplotstable@loc@TMPa}% + % + % now, create all real columns: + \pgfkeyslet{/pgfplots/table/columns}{\pgfutil@empty}% + \pgfplotstableset{#1}% + \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% + \ifx\pgfplotstable@colnames\pgfutil@empty + \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 artifical column which contains temporary values.}% + \else + \expandafter\pgfplots@assign@list\expandafter\pgfplotstablenew@cols\expandafter{\pgfplotstable@colnames}% + % make sure every requested column exists: + \pgfutil@loop + \pgfplotslistcheckempty\pgfplotstablenew@cols + \ifpgfplotslistempty + \pgfplots@loop@CONTINUEfalse + \else + \pgfplots@loop@CONTINUEtrue + \fi + \ifpgfplots@loop@CONTINUE + \pgfplotslistpopfront\pgfplotstablenew@cols\to\pgfplotstablenew@col + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstablenew@col}\of#3\to\pgfplotstable@loc@TMPa + \pgfutil@repeat + % remove the temporary column: + % FIXME this should be done after the '\fi'. But that will + % lead to an error because empty tables are currently + % unsupported! + \pgfplotslistpopfront#3\to\pgfplotstable@loc@TMPa + \fi + \pgfplotstable@copy@to@globalbuffers#3 + \endgroup + \pgfplotstable@copy@globalbuffers@to#3 +}% + +\def\pgfplotstablegetcolumnlist#1\to#2{\let#2=#1} + % Returns a column vector in form of \pgfplotslist % into #3. % @@ -652,7 +1134,7 @@ \pgfutil@ifundefined{\string#2@\pgfplotstable@loc@TMPa}{% \def\pgfplotstable@loc@TMPb{/pgfplots/table/create on use/#1}% \pgfkeysifdefined{\pgfplotstable@loc@TMPb/.@cmd}{% - \pgfplots@error{Sorry, '\pgfplotstable@loc@TMPb' from table '\pgfplotstableread@filename' can't be evaluated in this context. Please prepare the table before using it here.}% + \pgfplots@error{Sorry, '\pgfplotstable@loc@TMPb' from table '\pgfplotstableread@filename' can't be evaluated in this context. Please prepare the table before using it here. You can do this using the 'read completely' key, see the manual for details.}% }{% \pgfplots@error{Sorry, could not retrieve aliased column '\pgfplotstable@loc@TMPa' from table '\pgfplotstablenameof{#2}'. The original request was for '#1', which does not exist either.}% }% @@ -731,6 +1213,8 @@ % - \getthisrow{<col name>}{\macro} % - \nextrow{<col name>}, % - \getnextrow{<col name>}{\macro} +% +% FIXME this documentation is incomplete. Please refer to pgfplotstable.pdf . \def\pgfplotstablecreatecol{% \pgfutil@ifnextchar[{% \pgfplotstablecreatecol@opt @@ -743,6 +1227,8 @@ % Typesets a table. % % \pgfplotstabletypeset[<options>]<\tablestructure> +% or +% \pgfplotstabletypeset[<options>]{<file name>} % % If you do not select any columns, the complete table is drawn. % @@ -765,24 +1251,55 @@ \pgfplotstabletypeset@opt[]% }% } +\def\pgfplotstabletypeset@opt[#1]#2{% + \pgfplotstable@isloadedtable{#2}% + {\pgfplotstabletypeset@opt@[#1]{#2}}% + {\pgfplotstabletypesetfile@opt@[#1]{#2}}% +} % Like \pgfplotstabletypeset, but the first argument is a file name. -\def\pgfplotstabletypesetfile{% - \pgfutil@ifnextchar[{% - \pgfplotstabletypesetfile@opt - }{% - \pgfplotstabletypesetfile@opt[]% - }% -} -\def\pgfplotstabletypesetfile@opt[#1]#2{% +% This is the same now; it will be recognised automatically. +\let\pgfplotstabletypesetfile=\pgfplotstabletypeset +\def\pgfplotstabletypesetfile@opt@[#1]#2{% \begingroup \ifpgfplots@table@options@areset \else \pgfplots@table@options@aresettrue \pgfplotstableset{/pgfplots/table/every table={#2},#1}% \fi - \pgfplotstableread{#2}\pgfplotstabletypesetfile@opt@@ - \pgfplotstabletypeset\pgfplotstabletypesetfile@opt@@ + \ifpgfplotstabletypeset@force@remake + \pgfplotstabletypeset@includeoutfilesfalse + \else + \ifpgfplotstabletypeset@includeoutfiles + \pgfplotstabletypeset@includeoutfilesfalse + \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename + \ifx\pgfplotstable@outfilename\pgfutil@empty + \else + \openin1=\pgfplotstable@outfilename\relax + \ifeof1 + \else + \pgfplotstabletypeset@includeoutfilestrue + \fi + \closein1 + \fi + \fi + \fi + \ifpgfplotstabletypeset@includeoutfiles + \input \pgfplotstable@outfilename\relax + \else + \pgfplotstableread{#2}\pgfplotstabletypesetfile@opt@@ + \pgfplotstabletypeset\pgfplotstabletypesetfile@opt@@ + \fi + \pgfkeysgetvalue{/pgfplots/table/write to macro}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\pgfplots@loc@TMPa{\pgfutil@empty}% + \else + \expandafter\ifx\pgfplots@loc@TMPa\relax + % is it really defined? NO! Sanity checking here: + \def\pgfplots@loc@TMPa{\pgfutil@empty}% + \fi + \fi + \expandafter\pgfmath@smuggleone\pgfplots@loc@TMPa \endgroup }% @@ -843,6 +1360,7 @@ \closein1 \openin1=#2\relax \fi + \pgfplots@logfileopen{#2}% \def\pgfplotstableread@filename{#2}% \let\pgfplotstableread@lineno=\c@pgf@counta \let\pgfplotstableread@numcols=\c@pgf@countb @@ -851,10 +1369,10 @@ \pgfplotstableread@lineno=0 \pgfplotstableread@usablelineno=0 \pgfplotstableread@numcols=0 - \global\pgfplotslistnewempty\pgfplotstable@colnames + \global\pgfplotslistnewempty\pgfplotstable@colnames@glob \ifeof1 \pgfplotstable@error{Could not read table file '#2'.}% - \global\pgfplotslistnewempty\pgfplotstable@colnames + \global\pgfplotslistnewempty\pgfplotstable@colnames@glob \else \ifpgfplots@tableread@to@listener \let\pgfplotstable@listener=#3% @@ -877,21 +1395,44 @@ \else % Now, we can access the global variables! % copy them to #3. - \let#3=\pgfplotstable@colnames \expandafter\def\csname\string#3@@table@name\endcsname{#2}% - \c@pgfplotstable@counta=0\relax% - \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@loc@TMPa{% - \def\pgfplotstable@loc@TMPb{% - \expandafter\let\csname\string#3@\pgfplotstable@loc@TMPa\endcsname}% - \expandafter\pgfplotstable@loc@TMPb\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname - %\message{Column '\pgfplotstable@loc@TMPa' has entries: \expandafter\meaning\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname}% - \expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname=\pgfutil@empty - \advance\c@pgfplotstable@counta by1\relax - }% + \pgfplotstable@copy@globalbuffers@to#3 \fi - \global\let\pgfplotstable@colnames=\pgfutil@empty } +% Copies the table column list and the column vectors of #1 to global buffers. +% @see \pgfplotstable@copy@globalbuffers@to +% +% Use these two methods to avoid scoping problems. +\def\pgfplotstable@copy@to@globalbuffers#1{% + \global\let\pgfplotstable@colnames@glob=#1 + \c@pgfplotstable@counta=0\relax% + \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{% + \def\pgfplotstable@loc@TMPb{% + \expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname% + }% + \expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname + \advance\c@pgfplotstable@counta by1\relax + }% +}% + +% copies the global column list and the global column vectors to #1 +% (NOT the table file name). +% @see \pgfplotstable@copy@to@globalbuffers +\def\pgfplotstable@copy@globalbuffers@to#1{% + \let#1=\pgfplotstable@colnames@glob + \c@pgfplotstable@counta=0\relax% + \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{% + \def\pgfplotstable@loc@TMPb{% + \expandafter\let\csname\string#1@\pgfplotstable@loc@TMPa\endcsname}% + \expandafter\pgfplotstable@loc@TMPb\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname +%\message{Column '\pgfplotstable@loc@TMPa' has entries: \expandafter\meaning\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname}% + \expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname=\pgfutil@empty + \advance\c@pgfplotstable@counta by1\relax + }% + \global\let\pgfplotstable@colnames@glob=\pgfutil@empty +}% + \def\pgfplotstableread@finish{% \ifpgfplots@tableread@to@listener \else @@ -926,6 +1467,9 @@ %\pgfplots@message{READING LINE \the\pgfplotstableread@lineno: '\meaning\pgfplotstable@LINE'.}% \pgfplotstableread@curline@contains@colnamesfalse \ifnum\pgfplotstableread@numcols=0\relax + % STEP 0: initialise + % - count columns + % - find header data \pgfplotstableread@curcol=0\relax \pgfplotstableread@impl@DO\pgfplotstableread@impl@countcols@and@identifynames@NEXT\pgfplotstable@LINE %\expandafter\pgfplotstableread@impl@countcols@and@identifynames@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI @@ -963,7 +1507,7 @@ \pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE %\expandafter\pgfplotstableread@impl@nextrow@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI \fi -%\pgfplots@message{After reading first row: found '\the\pgfplotstableread@numcols' columns; column name list='\meaning\pgfplotstable@colnames'}% +%\pgfplots@message{After reading first row: found '\the\pgfplotstableread@numcols' columns; column name list='\meaning\pgfplotstable@colnames@glob'}% \else \pgfplotstableread@curcol=0\relax \pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE @@ -1032,7 +1576,7 @@ \pgfplotstableread@curcol=0\relax \pgfutil@loop \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols - \expandafter\pgfplotslistpushbackglobal\the\pgfplotstableread@curcol\to\pgfplotstable@colnames + \expandafter\pgfplotslistpushbackglobal\the\pgfplotstableread@curcol\to\pgfplotstable@colnames@glob \advance\pgfplotstableread@curcol by1\relax \pgfutil@repeat } @@ -1173,7 +1717,7 @@ }{% \def\pgfplotstable@loc@TMPa{/pgfplots/table/create on use/#1}% \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{% - \pgfplots@error{Sorry, '\pgfplotstable@loc@TMPa' from table '\pgfplotstableread@filename' can't be evaluated in this context. Please prepare the table before using it here.}% + \pgfplots@error{Sorry, '\pgfplotstable@loc@TMPa' from table '\pgfplotstableread@filename' can't be evaluated in this context. Please prepare the table before using it here. You can do this using the 'read completely' key, see the manual for details.}% }{% \pgfplots@error{Sorry, could not retrieve column '#1' from table '\pgfplotstableread@filename'. Please check spelling (or introduce name aliases).}% }% @@ -1201,10 +1745,17 @@ \long\def\pgfplotstableread@impl@nextrow@NEXT#1{% %\pgfplots@message{Inserting '#1' at (\the\pgfplotstableread@lineno, \the\pgfplotstableread@curcol).}% - \pgfplotslist@assembleentry{#1}\into\t@pgfplots@tokc - \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}% - \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\the\pgfplotstableread@curcol\endcsname - \advance\pgfplotstableread@curcol by1\relax + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols + \pgfplotslist@assembleentry{#1}\into\t@pgfplots@tokc + \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}% + \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\the\pgfplotstableread@curcol\endcsname + \advance\pgfplotstableread@curcol by1\relax + \else + \begingroup + \t@pgfplots@tokc={#1}% + \pgfplots@error{Table '\pgfplotstableread@filename' has too much columns in line \the\pgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. Please verify that every cell entry is separated correctly (use braces {<cell entry>} if necessary). This error is not critical}% + \endgroup + \fi } @@ -1218,7 +1769,7 @@ \edef\pgfplotstable@loc@TMPa{#1--index\the\pgfplotstableread@curcol}% }% \expandafter\def\csname pgfplotstableread@impl@COLNAME@#1\endcsname{foo}% remember this name. - \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames@glob \ifpgfplots@tableread@to@listener % create an associative container colindex -> colname % for use in a listener. @@ -1404,6 +1955,7 @@ % processes the option 'assign column name' \def\pgfplotstabletypeset@assign@final@colname#1#2{% \pgfkeysifdefined{/pgfplots/table/assign column name/.@cmd}{% + \pgfkeysdef{/pgfplots/table/column name}{#1}% \pgfkeysvalueof{/pgfplots/table/assign column name/.@cmd}#1\pgfeov \pgfkeysgetvalue{/pgfplots/table/column name}{#2}% }{}% @@ -1439,7 +1991,7 @@ % TODO % - replace grouped list foreach by popfront-loop and use arrays % directly -> group only the pgfkeys eval -\def\pgfplotstabletypeset@opt[#1]#2{% +\def\pgfplotstabletypeset@opt@[#1]#2{% \begingroup %-------------------------------------------------- % \pgfutil@ifundefined{#2}{% @@ -1458,6 +2010,61 @@ \edef\pgfplotstable@loc@TMPa{/pgfplots/table/every table={\the\t@pgfplots@toka}}% \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa,#1}% \fi + \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename + \pgfkeysgetvalue{/pgfplots/table/TeX comment}\pgfplots@TeX@comment + \ifpgfplotstabletypeset@force@remake + \pgfplotstabletypeset@includeoutfilesfalse + \else + \ifpgfplotstabletypeset@includeoutfiles + \pgfplotstabletypeset@includeoutfilesfalse + \ifx\pgfplotstable@outfilename\pgfutil@empty + \else + \pgfplots@logfileopen{\pgfplotstable@outfilename}% + \openin1=\pgfplotstable@outfilename\relax + \ifeof1 \else\pgfplotstabletypeset@includeoutfilestrue \fi + \closein1 + \fi + \fi + \fi + \ifpgfplotstabletypeset@includeoutfiles + \input \pgfplotstable@outfilename\relax + \else + % + % Prepare outfile and debug options: + \let\pgfplotstable@notify@finished@line=\pgfutil@empty + % + % FLUSH assumes that \pgfplotstable@curline is finished. It + % appends all its contents as-is to \pgfplotstable@result. + % + % Furthermore, it calls \pgfplotstable@notify@finished@line which + % in turn may invoke additional output routines for the debug and + % outfile options. + % + % Finally, it resets \pgfplotstable@curline. + \def\pgfplotstable@curline@FLUSH{% + \pgfplotstable@notify@finished@line + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \let\pgfplotstable@curline=\pgfutil@empty + }% + \ifpgfplotstabletypesetdebug + \immediate\write16{------- PGFPLOTSTABLE DEBUG MODE: --------}% + \expandafter\def\expandafter\pgfplotstable@notify@finished@line\expandafter{\pgfplotstable@notify@finished@line + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \immediate\write16{\the\t@pgfplots@toka\pgfplots@TeX@comment}% + }% + \fi + \ifx\pgfplotstable@outfilename\pgfutil@empty + \else + \immediate\openout\pgfplotstable@outfile=\pgfplotstable@outfilename\relax + \expandafter\def\expandafter\pgfplotstable@notify@finished@line\expandafter{\pgfplotstable@notify@finished@line + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \immediate\write\pgfplotstable@outfile{\the\t@pgfplots@toka\pgfplots@TeX@comment}% + }% + \fi + % + % Start operation: \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% \ifx\pgfplotstable@colnames\pgfutil@empty \pgfplotstablegetcolumnlist#2\to\pgfplotstable@colnames @@ -1494,6 +2101,8 @@ \global\c@pgfplotstable@numrows=\c@pgfplotstable@numrows \fi % + % + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Set keys for columns! \ifodd\c@pgfplotstable@colindex \t@pgfplots@toka={every odd column}% @@ -1504,23 +2113,30 @@ \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first column}% \fi % save this now before we increment '\c@pgfplotstable@colindex': - \edef\pgfplotstable@displaycolkey{display columns/\the\c@pgfplotstable@colindex/.try}% + \edef\pgfplotstable@displaycolkey{display columns/\the\c@pgfplotstable@colindex/.try,every col no \the\c@pgfplotstable@colindex/.try}% % \global\advance\c@pgfplotstable@colindex by1\relax \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last column}% \fi - \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname}% - \expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\t@pgfplots@tokb\pgfplotstable@EOI - \ifpgfutil@in@ - \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/{\the\t@pgfplots@tokb}/.try}% + \ifpgfplotstable@disable@rowcolstyles + % ok, then don't check for 'columns/<name>' and + % 'display columns/<index>': + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka}% \else - \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/\the\t@pgfplots@tokb/.try}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname}% + \expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\t@pgfplots@tokb\pgfplotstable@EOI + \ifpgfutil@in@ + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/{\the\t@pgfplots@tokb}/.try}% + \else + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/\the\t@pgfplots@tokb/.try}% + \fi + \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@displaycolkey}% + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% \fi - \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% - \t@pgfplots@tokb=\expandafter{\pgfplotstable@displaycolkey}% - \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}% + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \pgfkeysgetvalue{/pgfplots/table/column name}{\pgfplotstable@colname@out}% \ifx\pgfplotstable@colname@out\pgfplotstabletypeset@nocolname @@ -1583,31 +2199,42 @@ %\message{I have now \meaning\pgfplotstabletypeset@final@colnames, and \meaning\pgfplotstabletypeset@final@cols.}% % Step 1: column names. \c@pgfplotstable@colindex=0\relax - % STEP 1.1: collect column types: - \def\pgfplotstable@resulttypes{}% - \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@coltypes\as\pgfplotstable@coltype{% - \t@pgfplots@toka=\expandafter{\pgfplotstable@resulttypes}% - \t@pgfplots@tokb=\expandafter{\pgfplotstable@coltype}% - \edef\pgfplotstable@resulttypes{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% - }% - \pgfkeysgetvalue{/pgfplots/table/begin table}{\pgfplotstable@entry}% - \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}% - \ifx\pgfplotstable@resulttypes\pgfutil@empty - \edef\pgfplotstable@result{\the\t@pgfplots@toka}% - \else - \t@pgfplots@tokb=\expandafter{\pgfplotstable@resulttypes}% - \edef\pgfplotstable@result{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}% - \fi + \c@pgfplotstable@rowindex=-1\relax + \let\pgfplotstable@result=\pgfutil@empty % \pgfkeysgetvalue{/pgfplots/table/font}{\pgfplotstable@font}% \ifx\pgfplotstable@font\pgfutil@empty \else \t@pgfplots@toka=\expandafter{\pgfplotstable@font}% - \t@pgfplots@tokb=\expandafter{\pgfplotstable@result}% - \edef\pgfplotstable@result{\noexpand\begingroup\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \edef\pgfplotstable@curline{\noexpand\begingroup\the\t@pgfplots@toka}% + \pgfplotstable@curline@FLUSH + \fi + % + \pgfkeysgetvalue{/pgfplots/table/begin table}{\pgfplotstable@entry}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka}% + % + \ifpgfplotstabletypesetskipcoltypes + \else + % STEP 1.1: collect column types: + \def\pgfplotstable@resulttypes{}% + \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@coltypes\as\pgfplotstable@coltype{% + \t@pgfplots@toka=\expandafter{\pgfplotstable@resulttypes}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@coltype}% + \edef\pgfplotstable@resulttypes{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + }% + \ifx\pgfplotstable@resulttypes\pgfutil@empty + \else + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@resulttypes}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}% + \fi + \fi + \ifx\pgfplotstable@curline\pgfutil@empty + \else + \pgfplotstable@curline@FLUSH \fi % - % Step 1.2: Collect FIRST ROW (column names) \begingroup \pgfplotstableset{every head row}% @@ -1623,23 +2250,28 @@ \pgfplots@glob@TMPc % insert 'before row' here: \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% - \t@pgfplots@tokb=\expandafter{\pgfplotstable@result}% - \edef\pgfplotstable@result{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}% + \edef\pgfplotstable@curline{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% % \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@colnames\as\pgfplotstable@colname@out{% + % \advance\c@pgfplotstable@colindex by1\relax - \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% - \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax - \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname@out \\}% - \else - \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname@out &}% - \fi - \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + % typeset the cell: + \pgfkeysgetvalue{/pgfplots/table/typeset cell/.@cmd}\pgfplots@loc@TMPa + \expandafter\pgfplots@loc@TMPa\pgfplotstable@colname@out\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + % + % append this cell: + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \t@pgfplots@tokb=\expandafter{\pgfmathresult}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% }% % insert 'after row' here: - \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% - \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + % + \pgfplotstable@curline@FLUSH % %\message{I have now \meaning\pgfplotstable@result.}% % Step 2: column contents. @@ -1682,15 +2314,18 @@ \ifnum\c@pgfplotstable@rowindex=0\relax \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first row}% \fi + \ifpgfplotstable@disable@rowcolstyles + \else + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,every row no \the\c@pgfplotstable@rowindex/.try}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% + \fi % misuse as temporary variable: \c@pgfplotstable@colindex=\c@pgfplotstable@rowindex \advance\c@pgfplotstable@colindex by1\relax \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numrows - \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,every row no \the\c@pgfplotstable@rowindex/.try,every last row}% - \else - \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,every row no \the\c@pgfplotstable@rowindex/.try}% + \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last row}% \fi - \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}% + \expandafter\pgfplotstableset\expandafter{\the\t@pgfplots@toka}% \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}% \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}% \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% @@ -1703,58 +2338,70 @@ \pgfplots@glob@TMPc % insert 'before row' here: \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% - \t@pgfplots@tokb=\expandafter{\pgfplotstable@result}% - \edef\pgfplotstable@result{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}% + \edef\pgfplotstable@curline{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% \fi % % \pgfplotslistpopfront\pgfplotstable@col@processed\to\pgfplotstable@entry \pgfplotsarrayletentry\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array=\pgfplotstable@col@processed \advance\c@pgfplotstable@colindex by1\relax - \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% - \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax - \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry \\}% - \else - \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry &}% - \fi - \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + % typeset the cell: + \pgfkeysgetvalue{/pgfplots/table/typeset cell/.@cmd}\pgfplots@loc@TMPa + \expandafter\pgfplots@loc@TMPa\pgfplotstable@entry\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + % + % append this cell: + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% + \t@pgfplots@tokb=\expandafter{\pgfmathresult}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + % \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax \c@pgfplotstable@colindex=0\relax % insert 'after row' here: - \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% - \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% \advance\c@pgfplotstable@rowindex by1\relax + \pgfplotstable@curline@FLUSH \fi %\message{I have now \meaning\pgfplotstable@result.}% \fi \pgfutil@repeat - \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}% \pgfkeysgetvalue{/pgfplots/table/end table}{\pgfplotstable@entry}% \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry}% - \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \ifx\pgfplotstable@curline\pgfutil@empty + \else + \pgfplotstable@curline@FLUSH + \fi + % \ifx\pgfplotstable@font\pgfutil@empty \else - \t@pgfplots@toka=\expandafter{\pgfplotstable@result\endgroup}% - \edef\pgfplotstable@result{\the\t@pgfplots@toka}% + \edef\pgfplotstable@curline{\noexpand\endgroup}% + \pgfplotstable@curline@FLUSH \fi - \ifpgfplotstabletypesetdebug - \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% - \immediate\write16{------- PGFPLOTSTABLE DEBUG MODE: --------}% - \immediate\write16{{\the\t@pgfplots@toka}}% + \ifx\pgfplotstable@outfilename\pgfutil@empty + \else + \immediate\closeout\pgfplotstable@outfile \fi - \pgfkeysgetvalue{/pgfplots/table/outfile}{\pgfplotstable@entry}% - \ifx\pgfplotstable@entry\pgfutil@empty +%\message{I have now \meaning\pgfplotstable@result.}% + \def\pgfplotstablecol{\pgfplots@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).}}% + \def\pgfplotstablerow{\pgfplots@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).}}% + \ifpgfplotstabletypesetresult + \pgfplotstable@result + \fi + \pgfkeysgetvalue{/pgfplots/table/write to macro}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \global\let\pgfplots@glob@TMPa=\relax \else - \begingroup - \immediate\openout\pgfplotstable@outfile=\pgfplotstable@entry\relax \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% - \immediate\write\pgfplotstable@outfile{\the\t@pgfplots@toka}% - \immediate\closeout\pgfplotstable@outfile - \endgroup + \xdef\pgfplots@glob@TMPa{\noexpand\def\expandafter\noexpand\pgfplots@loc@TMPa{\the\t@pgfplots@toka}}% + \fi \fi - \pgfplotstable@result \endgroup + \pgfplots@glob@TMPa% execute 'write to macro' if set. }% \newif\ifpgfplotstable@isfirstrow @@ -1806,8 +2453,12 @@ % \pgfplots@loop@CONTINUEtrue % allow this here to accumulate something. - \let\pgfmathaccuma=\pgfutil@empty - \let\pgfmathaccumb=\pgfutil@empty + \pgfutil@ifundefined{pgfmathaccuma}{% + \let\pgfmathaccuma=\pgfutil@empty + }{}% + \pgfutil@ifundefined{pgfmathaccumb}{% + \let\pgfmathaccumb=\pgfutil@empty + }{}% \pgfutil@loop% loop over each row until there are no more rows. \ifpgfplots@loop@CONTINUE \ifnum\c@pgfplotstable@numrows=-1\relax @@ -1883,4 +2534,181 @@ \expandafter\let\csname\string#3@\pgfplots@glob@TMPb\endcsname=\pgfplots@glob@TMPc }% + +%----------------------------------------------------------- +% +% Implementation of '/pgfplots/table/create col/function graph cut y': +% +%----------------------------------------------------------- + +% create on use/cut/.style={create col/function graph cut y={7e-4}{x=Basis,ymode=log,xmode=log}{{table=regtable,y=special-L2}}}, +% #1 = value of fixed line (I call it epsilon) +% #2 = options +% #3 = specification where to get the y from. It is a comma separated +% list of key-value sets, on set for every y(x) graph which shall be +% used. +% #4 = the direction in which the line does NOT vary (either 'x' or 'y') +% #5 = the direction in which the line DOES vary (either 'x' or 'y') +\def\pgfplotstable@fgc@init#1#2#3#4#5{% + \def\pgfplotstable@fgc@xmode{0}% + \def\pgfplotstable@fgc@ymode{0}% + % + \pgfkeysalso{/pgf/fpu=true}% + % + \pgfqkeys{/pgfplots/table/create col/function graph cut}{#2}% + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table + \ifx\pgfplotstable@fgc@table\pgfutil@empty + \else + % ok, we need to query (or load) a table! + \pgfplotstable@isloadedtable{\pgfplotstable@fgc@table}{% + }{% + \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}% + }% + \fi + % + \ifnum\csname pgfplotstable@fgc@#4mode\endcsname=1 + \pgfmathparse{ln(#1)}% + \else + \pgfmathparse{#1}% + \fi + \let\pgfplotstable@fgc@eps=\pgfmathresult + \pgfplots@assign@list\pgfmathaccumb{#3}% + % + \pgfkeysdef{/pgfplots/table/create col/assign}{% +%\message{working on next cell ...}% + \pgfplotslistcheckempty\pgfmathaccumb + \ifpgfplotslistempty + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% + \else + \pgfplotslistpopfront\pgfmathaccumb\to\pgfmathresult + \begingroup + % set local keys: + \def\pgfplots@loc@TMPa{\pgfqkeys{/pgfplots/table/create col/function graph cut}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% + % acquire any sources: + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/x}\pgfplotstable@fgc@x + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/y}\pgfplotstable@fgc@y + \ifx\pgfplotstable@fgc@table\pgfutil@empty + \else + % ok, we need to query (or load) a table! + \pgfplotstable@isloadedtable{\pgfplotstable@fgc@table}{% + }{% + \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}% + }% + \fi + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@x}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@x@col + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@y}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@y@col + % + % search for epsilon in the y values: + \expandafter\pgfplotstable@fgc@findintervalwitheps\expandafter{\csname pgfplotstable@fgc@#4@col\endcsname}{\csname pgfplotstable@fgc@#4mode\endcsname}% + \ifx\pgfplotstable@fgc@second\pgfutil@empty + \let\pgfmathresult=\pgfutil@empty + \else + % + % acquire the associated x values: + \expandafter\pgfplotstable@fgc@getassociated\expandafter{\csname pgfplotstable@fgc@#5@col\endcsname}{\csname pgfplotstable@fgc@#5mode\endcsname}% + % + % Interpolate: + \pgfmathparse{ + \pgfplotstable@fgc@abscissafirst + + (\pgfplotstable@fgc@eps - \pgfplotstable@fgc@first) / (\pgfplotstable@fgc@second-\pgfplotstable@fgc@first) + * (\pgfplotstable@fgc@abscissasecond - \pgfplotstable@fgc@abscissafirst) }% + \if\pgfplotstable@fgc@xmode1 + \pgfmathfloatexp@{\pgfmathresult}% + \fi + \pgflibraryfpuifactive{\pgfmathfloattosci{\pgfmathresult}}{}% +%\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}% + \fi + % + \pgfmath@smuggleone\pgfmathresult + \endgroup + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \fi + }% +}% + +% #1 : the coordinate list to query +% #2 : the mode +% +% POSTCONDITION: +% - \pgfplotstable@fgc@abscissafirst and \pgfplotstable@fgc@abscissasecond +% contain the abscissa values +% +\def\pgfplotstable@fgc@getassociated#1#2{% + \c@pgfplotstable@counta=\pgfplotstable@fgc@index + \pgfplotslistselect\c@pgfplotstable@counta\of#1\to\pgfplotstable@fgc@abscissasecond + \advance\c@pgfplotstable@counta by-1 + \pgfplotslistselect\c@pgfplotstable@counta\of#1\to\pgfplotstable@fgc@abscissafirst + \pgfmathfloatparsenumber{\pgfplotstable@fgc@abscissafirst}% + \let\pgfplotstable@fgc@abscissafirst=\pgfmathresult + \pgfmathfloatparsenumber{\pgfplotstable@fgc@abscissasecond}% + \let\pgfplotstable@fgc@abscissasecond=\pgfmathresult + \if1#2 + \pgfmathln@{\pgfplotstable@fgc@abscissafirst}% + \let\pgfplotstable@fgc@abscissafirst=\pgfmathresult + \pgfmathln@{\pgfplotstable@fgc@abscissasecond}% + \let\pgfplotstable@fgc@abscissasecond=\pgfmathresult + \fi +}% + +% Search for the (first) interval in #1 containing epsilon and return +% \pgfplotstable@fgc@first and \pgfplotstable@fgc@second. +% +% #1 : the list of values. +% #2 : the mode (0 = linear, 1 = log) +% +% PRECONDITION: +% - \pgfplotstable@fgc@eps contains the value to search for +% +% POSTCONDITION +% On success, +% - \pgfplotstable@fgc@first and \pgfplotstable@fgc@second contain the interval. +% - \pgfplotstable@fgc@index contains the index of the @second coordinate. +% - \pgfplotstable@fgc@lastwasless is +% 1 if \pgfplotstable@fgc@second < eps +% 0 if \pgfplotstable@fgc@second >= eps +% If there was no such interval, +% \pgfplotstable@fgc@second will be empty. +\def\pgfplotstable@fgc@findintervalwitheps#1#2{% + \global\let\pgfplotstable@fgc@first=\pgfutil@empty + \global\let\pgfplotstable@fgc@second=\pgfutil@empty + \global\def\pgfplotstable@fgc@lastwasless{2}% + \global\def\pgfplotstable@fgc@break{0}% + \global\def\pgfplotstable@fgc@index{0}% + \pgfplotslistforeach#1\as\pgfplotstable@fgc@val{% + \if\pgfplotstable@fgc@break0 + \pgfmathfloatparsenumber{\pgfplotstable@fgc@val}% + \let\pgfplotstable@fgc@val=\pgfmathresult + \ifnum#2=1 + \pgfmathln@{\pgfplotstable@fgc@val}% + \let\pgfplotstable@fgc@val=\pgfmathresult + \fi + \pgfmathfloatlessthan@{\pgfplotstable@fgc@val}{\pgfplotstable@fgc@eps}% + \ifpgfmathfloatcomparison + \pgfplotstable@fgc@findintervalwitheps@updateresult 01 + \else + \pgfplotstable@fgc@findintervalwitheps@updateresult 10 + \fi + \fi + }% +} + +% #1 : the value of \pgfplotstable@fgc@lastwasless for which the loop +% shall break. +% #2 : the next value for \pgfplotstable@fgc@lastwasless +\def\pgfplotstable@fgc@findintervalwitheps@updateresult#1#2{% + \if\pgfplotstable@fgc@lastwasless#1 + % found it ! + \global\let\pgfplotstable@fgc@second=\pgfplotstable@fgc@val + \global\def\pgfplotstable@fgc@break{1}% + \else + \global\let\pgfplotstable@fgc@first=\pgfplotstable@fgc@val + \c@pgfplotstable@counta=\pgfplotstable@fgc@index + \advance\c@pgfplotstable@counta by1 + \xdef\pgfplotstable@fgc@index{\the\c@pgfplotstable@counta}% + \fi + \global\def\pgfplotstable@fgc@lastwasless{#2}% +}% + \endinput |