From f41811b55dfce3a5f59b953b68457b0aa5491baf Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 9 Aug 2008 23:39:38 +0000 Subject: pgfplots update (10aug08) git-svn-id: svn://tug.org/texlive/trunk@10222 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/context/pgfplots/t-pgfplots.tex | 61 - .../tex/context/third/pgfplots/t-pgfplots.tex | 64 + .../tex/context/third/pgfplots/t-pgfplotstable.tex | 26 + .../pgfplots/libs/tikzlibrarydateplot.code.tex | 75 + .../pgfplots/liststructure/pgfplotsarray.code.tex | 16 +- .../liststructure/pgfplotsliststructure.code.tex | 98 +- .../pgfplotsliststructureext.code.tex | 459 ++ .../pgfplots/numtable/pgfplotstable.code.tex | 1191 +++- .../pgfplotsoldpgfsupp_loader.code.tex | 12 + .../pgfplotsoldpgfsupp_misc.code.tex | 174 + .../pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex | 928 +++ ...plotsoldpgfsupp_pgflibraryplothandlers.code.tex | 922 +++ .../pgfplotsoldpgfsupp_pgfmathfloat.code.tex | 2322 +++++++ .../tex/generic/pgfplots/pgfplots.code.tex | 7192 ++++++++++++++++++++ .../pgfplots/pgfplots.stackedplots.code.tex | 487 ++ .../pgfplotsoldpgfsupp_loader.code.tex | 12 - .../pgfplotsoldpgfsupp_misc.code.tex | 96 - .../pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex | 927 --- ...plotsoldpgfsupp_pgflibraryplothandlers.code.tex | 922 --- .../pgfplotsoldpgfsupp_pgfmathfloat.code.tex | 2007 ------ .../generic/pgfplots/pgfplots/pgfplots.code.tex | 5918 ---------------- .../pgfplots/pgfplots.stackedplots.code.tex | 365 - .../generic/pgfplots/util/pgfplotsutil.code.tex | 206 + Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty | 4 +- .../tex/latex/pgfplots/pgfplotstable.sty | 27 + .../tex/plain/pgfplots/pgfplotstable.tex | 38 + 26 files changed, 14050 insertions(+), 10499 deletions(-) delete mode 100644 Master/texmf-dist/tex/context/pgfplots/t-pgfplots.tex create mode 100644 Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex create mode 100644 Master/texmf-dist/tex/context/third/pgfplots/t-pgfplotstable.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarydateplot.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots.stackedplots.code.tex delete mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex delete mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex delete mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex delete mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex delete mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex delete mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots/pgfplots.code.tex delete mode 100644 Master/texmf-dist/tex/generic/pgfplots/pgfplots/pgfplots.stackedplots.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex create mode 100644 Master/texmf-dist/tex/latex/pgfplots/pgfplotstable.sty create mode 100644 Master/texmf-dist/tex/plain/pgfplots/pgfplotstable.tex (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/context/pgfplots/t-pgfplots.tex b/Master/texmf-dist/tex/context/pgfplots/t-pgfplots.tex deleted file mode 100644 index 93324e1e5b0..00000000000 --- a/Master/texmf-dist/tex/context/pgfplots/t-pgfplots.tex +++ /dev/null @@ -1,61 +0,0 @@ -%-------------------------------------------- -% -% Package pgfplots -% -% Provides a user-friendly interface to create function plots (normal -% plots, semi-logplots and double-logplots). -% -% It is based on Till Tantau's PGF package. -% -% Copyright 2007/2008 by Christian Feuersänger. -% -% This program is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% This program is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with this program. If not, see . -% -%-------------------------------------------- - -\usemodule[tikz] -\usetikzlibrary[plotmarks] - -\edef\tikzatcode{\the\catcode`\@} -\edef\tikzbarcode{\the\catcode`\|} -\edef\tikzexclaimcode{\the\catcode`\!} -\catcode`\@=11 -\catcode`\|=12 -\catcode`\!=12 - -\input pgfplots.code.tex - -\let\pgfplots@ORIG@tikz@installcommands@before@context=\tikz@installcommands - -\def\tikz@installcommands{% - \pgfplots@ORIG@tikz@installcommands@before@context - % - \let\startaxis=\pgfplots@environment@axis - \let\stopaxis=\endpgfplots@environment@axis - % - \let\startsemilogxaxis=\pgfplots@environment@semilogxaxis - \let\stopsemilogxaxis=\endpgfplots@environment@semilogxaxis - % - \let\startsemilogyaxis=\pgfplots@environment@semilogyaxis - \let\stopsemilogyaxis=\endpgfplots@environment@semilogyaxis - % - \let\startloglogaxis=\pgfplots@environment@loglogaxis - \let\stoploglogaxis=\endpgfplots@environment@loglogaxis -}% - -\catcode`\@=\tikzatcode -\catcode`\|=\tikzbarcode -\catcode`\!=\tikzexclaimcode - -\endinput diff --git a/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex b/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex new file mode 100644 index 00000000000..1dbd5495cab --- /dev/null +++ b/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex @@ -0,0 +1,64 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\usemodule[tikz] +\usetikzlibrary[plotmarks] + +\edef\tikzatcode{\the\catcode`\@} +\edef\tikzbarcode{\the\catcode`\|} +\edef\tikzexclaimcode{\the\catcode`\!} +\catcode`\@=11 +\catcode`\|=12 +\catcode`\!=12 + +\input pgfplots.code.tex + +\let\pgfplots@ORIG@tikz@installcommands@before@context=\tikz@installcommands + +\def\tikz@installcommands{% + \pgfplots@ORIG@tikz@installcommands@before@context + % + \let\startaxis=\pgfplots@environment@axis + \let\stopaxis=\endpgfplots@environment@axis + % + \let\startsemilogxaxis=\pgfplots@environment@semilogxaxis + \let\stopsemilogxaxis=\endpgfplots@environment@semilogxaxis + % + \let\startsemilogyaxis=\pgfplots@environment@semilogyaxis + \let\stopsemilogyaxis=\endpgfplots@environment@semilogyaxis + % + \let\startloglogaxis=\pgfplots@environment@loglogaxis + \let\stoploglogaxis=\endpgfplots@environment@loglogaxis + % + \def\startpgfplotsinterruptdatabb{\pgfplotsinterruptdatabb}% + \def\stoppgfplotsinterruptdatabb{\endpgfplotsinterruptdatabb}% +}% + +\catcode`\@=\tikzatcode +\catcode`\|=\tikzbarcode +\catcode`\!=\tikzexclaimcode + +\endinput diff --git a/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplotstable.tex b/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplotstable.tex new file mode 100644 index 00000000000..0732df60c10 --- /dev/null +++ b/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplotstable.tex @@ -0,0 +1,26 @@ +%-------------------------------------------- +% +% Package pgfplotstable +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\usemodule[pgfplots] + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarydateplot.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarydateplot.code.tex new file mode 100644 index 00000000000..161943d6c28 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarydateplot.code.tex @@ -0,0 +1,75 @@ +%-------------------------------------------- +% +% Package pgfplots, library for high-level coordinates. +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\pgfutil@usemodule{pgfcalendar} + +% Idea: allow +%-------------------------------------------------- +% \begin{tikzpicture} +% \begin{axis}[ +% date coordinates in=x, +% xticklabel={\day.\month.}, +% ] +% \addplot coordinates { +% (2008-01-5, 5) +% (2008-01-12, 10) +% (2008-01-16, 20) +% }; +% \end{axis} +% \end{tikzpicture} +%-------------------------------------------------- + +\def\pgfplots@truncate@to@julian#1.#2\pgfplots@EOI#3{#3=#1\relax}% + +\pgfplotsset{ + /pgfplots/date ZERO/.code={% + \begingroup + \pgfcalendardatetojulian{#1}\c@pgf@counta + \edef\pgfmathresult{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@calender@ZEROSHIFT=\pgfmathresult + }, + date ZERO=2006-01-01, + /pgfplots/date coordinates in/.style={ + /pgfplots/#1 coord trafo/.code={% + \begingroup + \pgfcalendardatetojulian{##1}\c@pgf@counta + \advance\c@pgf@counta by-\pgfplots@calender@ZEROSHIFT\relax + \edef\pgfmathresult{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + }, + /pgfplots/#1 coord inv trafo/.code={% + \begingroup + \pgfplots@truncate@to@julian##1\pgfplots@EOI{\c@pgf@counta}% + \advance\c@pgf@counta by\pgfplots@calender@ZEROSHIFT\relax + \expandafter + \endgroup + \expandafter\pgfcalendarjuliantodate\expandafter{\the\c@pgf@counta}\year\month\day + \edef\pgfmathresult{\year-\month-\day}% + }, + /pgfplots/#1ticklabel={\tick},% + /pgfplots/scaled #1 ticks=false, + }, + /pgfplots/date coordinates in/.value required, +} + diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex index 16e4b539c02..77fc52b1115 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex @@ -56,7 +56,7 @@ \long\def\pgfplotsarraynew#1#2{% \pgfplotsarraynewempty{#1}% \long\def\pgfplotsarraynew@impl@rest{#2}% - \loop + \pgfutil@loop \ifx\pgfplotsarraynew@impl@rest\pgfutil@empty \pgfplots@loop@CONTINUEfalse \else @@ -64,7 +64,7 @@ \fi \ifpgfplots@loop@CONTINUE \expandafter\pgfplotsarraynew@impl\pgfplotsarraynew@impl@rest\toarray#1\relax - \repeat + \pgfutil@repeat } % helper macro for \pgfplotsarraynew @@ -96,11 +96,11 @@ \pgfplotsarray@@let{#2@size}={#1@size}% \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% \c@pgfplotsarray@tmp=0 - \loop + \pgfutil@loop \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP \pgfplotsarray@@let{#2@\the\c@pgfplotsarray@tmp}={#1@\the\c@pgfplotsarray@tmp}% \advance\c@pgfplotsarray@tmp by1 - \repeat + \pgfutil@repeat } @@ -179,24 +179,24 @@ \long\def\pgfplotsarrayforeach#1\as#2#3{% \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% \c@pgfplotsarray@tmp=0\relax - \loop + \pgfutil@loop \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP\relax \begingroup \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% #3% \endgroup \advance\c@pgfplotsarray@tmp by1 - \repeat + \pgfutil@repeat } % The same but without groups around #3. \long\def\pgfplotsarrayforeachungrouped#1\as#2#3{% \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% \c@pgfplotsarray@tmp=0\relax - \loop + \pgfutil@loop \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP\relax \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% #3% \advance\c@pgfplotsarray@tmp by1 - \repeat + \pgfutil@repeat } diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex index 48fd19a890c..d7bd7dc73ed 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex @@ -4,12 +4,17 @@ % % Its implementation is based on Knuth's list macros in "The TeXbook". % +% It features a convenient set of list macros, but it is not fast. +% In fact, every elementary operation requires time O(N), so working +% with this list easily leads to O(N^2) runtime. +% % The following macros are supplied: % % \pgfplotslistnewempty % \pgfplotslistnew % \pgfplotslistcopy % \pgfplotslistpopfront +% \pgfplotslistfront % \pgfplotslistpushback % \pgfplotslistpushfront % \pgfplotslistsize @@ -17,6 +22,10 @@ % \pgfplotslistcheckempty % \pgfplotslistforeach % +% @see \pgfplotsapplist a "real" list with O(1) pushback, but limited application. +% @see \pgfplotsapplistX a preasymptotical fast list to accumulate elements. +% @see \pgfplotsapplistXX an optimized version of \pgfplotsapplistX. +% % Copyright 2007/2008 by Christian Feuersänger. % % This program is free software: you can redistribute it and/or modify @@ -36,8 +45,6 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\newtoks\pgfplotslist@TOK@a -\newtoks\pgfplotslist@TOK@b \newif\ifpgfplotslistempty @@ -74,7 +81,7 @@ \else \expandafter\def\expandafter\pgfplotslistnew@impl@rest\expandafter{\pgfplotslistnew@impl@rest,}% \fi - \loop + \pgfutil@loop \ifx\pgfplotslistnew@impl@rest\pgfutil@empty \pgfplots@loop@CONTINUEfalse \else @@ -86,13 +93,13 @@ \else \expandafter\pgfplotslistnew@impl@comma\pgfplotslistnew@impl@rest\tolist#1\relax \fi - \repeat + \pgfutil@repeat } \def\pgfplotslist@EOI{\pgfplotslist@EOI} \def\pgfplotslist@check@backslash@list#1\\#2\pgfplotslist@EOI{% - \def\pgfplotslist@TMPB{#2}% - \ifx\pgfplotslist@TMPB\pgfutil@empty + \def\pgfplotslist@loc@TMPa{#2}% + \ifx\pgfplotslist@loc@TMPa\pgfutil@empty \pgfplotslist@is@backslash@terminatedfalse \else \pgfplotslist@is@backslash@terminatedtrue @@ -119,9 +126,15 @@ % Example: % \pgfplotslistpushfront Next first Element\to\foolist \long\def\pgfplotslistpushfront#1\to#2{% - \pgfplotslist@TOK@a={\pgfplotslist@sep{#1}}% - \pgfplotslist@TOK@b=\expandafter{#2}% - \edef#2{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \t@pgfplots@toka={\pgfpl@@{#1}}% + \t@pgfplots@tokb=\expandafter{#2}% + \edef#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% +} + +% Assembles a low-level list item representation into the token +% register #2. +\def\pgfplotslist@assembleentry#1\into#2{% + #2={\pgfpl@@{#1}}% } % #1: the item to append @@ -129,22 +142,32 @@ % Example: % \pgfplotslistpushback Next last element\to\foolist \long\def\pgfplotslistpushback#1\to#2{% - \pgfplotslist@TOK@a={\pgfplotslist@sep{#1}}% + \t@pgfplots@toka={\pgfpl@@{#1}}% \ifx#2\pgfutil@empty - \pgfplotslist@TOK@b={}% + \t@pgfplots@tokb={}% \else - \pgfplotslist@TOK@b=\expandafter{#2}% + \t@pgfplots@tokb=\expandafter{#2}% \fi - \edef#2{\the\pgfplotslist@TOK@b\the\pgfplotslist@TOK@a}% + \edef#2{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% +} +% Adds '#1' to the GLOBAL list '#2'. +\long\def\pgfplotslistpushbackglobal#1\to#2{% + \t@pgfplots@toka={\pgfpl@@{#1}}% + \ifx#2\pgfutil@empty + \t@pgfplots@tokb={}% + \else + \t@pgfplots@tokb=\expandafter{#2}% + \fi + \xdef#2{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% } % Concatenates two lists #2 and #3 into #1 % Example: % \pgfplotslistconcat\result=\foolist&\bar \long\def\pgfplotslistconcat#1=#2{% - \pgfplotslist@TOK@a=\expandafter{#2}% - \pgfplotslist@TOK@b=\expandafter{#3}% - \edef#1{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \t@pgfplots@toka=\expandafter{#2}% + \t@pgfplots@tokb=\expandafter{#3}% + \edef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% } % implements #2 := pop_front(#1) @@ -154,16 +177,29 @@ \pgfplotslistcheckempty#1\relax \ifpgfplotslistempty \pgfplots@error{ERROR: \string\pgfplotslistpopfront\ from \string#1\ although list is EMPTY}% + \let#2=\pgfutil@empty \else \expandafter\pgfplotslistpopfront@impl#1\pgfplotslistpopfront@macronames#1#2% \fi } +\long\def\pgfplotslistfront#1\to#2{% + \pgfplotslistcheckempty#1\relax + \ifpgfplotslistempty + \pgfplots@error{ERROR: \string\pgfplotslistfront\ from \string#1\ although list is EMPTY}% + \let#2=\pgfutil@empty + \else + \expandafter\pgfplotslistfront@impl#1\pgfplotslistpopfront@macronames#2% + \fi +} % implementation helper for listpopfront -\long\def\pgfplotslistpopfront@impl\pgfplotslist@sep#1#2\pgfplotslistpopfront@macronames#3#4{% +\long\def\pgfplotslistpopfront@impl\pgfpl@@#1#2\pgfplotslistpopfront@macronames#3#4{% \def#4{#1}% \def#3{#2}% } +\long\def\pgfplotslistfront@impl\pgfpl@@#1#2\pgfplotslistpopfront@macronames#3{% + \def#3{#1}% +} % Counts the number of elements in list #1, storing it into the count % register #2. @@ -172,7 +208,7 @@ % \the\count0 \long\def\pgfplotslistsize#1\to#2{% #2=0% - \long\def\pgfplotslist@sep##1{\advance#2 by 1 }% + \long\def\pgfpl@@##1{\advance#2 by 1 }% #1% } @@ -188,12 +224,15 @@ % \elem % Element \count1: % \pgfplotslistselect\count1\of\foo\to\elem -\long\def\pgfplotslistselect#1\of#2\to#3{% - \global\def\pgfplotslistselect@tmp{\def#3{\pgfplots@error{The requested item #1 of \string#2 is OUT OF RANGE.}}}% +\def\pgfplotslistselect#1\of#2\to#3{% + \global\def\pgfplotslistselect@tmp{\def#3{}\pgfplots@error{The requested list entry with index #1 of \string#2 is too large; this list has not enough elements.}}% + \pgfplotslistselect@{#1}\of{#2}\to{#3}% +} +\def\pgfplotslistselect@#1\of#2\to#3{% \begingroup \count0=#1\relax - \long\def\pgfplotslist@sep##1{% - \advance\count0-1\relax + \long\def\pgfpl@@##1{% + \advance\count0 by-1\relax \ifnum\count0=-1\relax \global\def\pgfplotslistselect@tmp{\def#3{##1}}% \fi% @@ -202,6 +241,10 @@ \endgroup \pgfplotslistselect@tmp } +\def\pgfplotslistselectorempty#1\of#2\to#3{% + \global\def\pgfplotslistselect@tmp{\def#3{}}% + \pgfplotslistselect@{#1}\of{#2}\to{#3}% +} % Sets the boolean \ifpgfplotslistempty depending on whether list #1 is empty % or not. @@ -217,7 +260,12 @@ \ifx#1\pgfutil@empty \pgfplotslistemptytrue \else - \pgfplotslistemptyfalse + \ifx#1\relax + \pgfplots@warning{WARNING: possible logic error in script code: the command \string\pgfplotslistcheckempty{\string#1} encountered an undefined argument.}% + \pgfplotslistemptytrue + \else + \pgfplotslistemptyfalse + \fi \fi } @@ -233,7 +281,7 @@ % Each single element will be grouped with TeX groups. \long\def\pgfplotslistforeach#1\as#2#3{% \begingroup - \long\def\pgfplotslist@sep##1{\def#2{##1}% + \long\def\pgfpl@@##1{\def#2{##1}% \begingroup #3 \endgroup}% @@ -249,7 +297,7 @@ \pgfplots@error{Sorry, you can't nest pgfplotslistforeachungrouped.}% \else \pgfplotslistforeachungroupedrunningtrue - \long\def\pgfplotslist@sep##1{\def#2{##1}#3}% + \long\def\pgfpl@@##1{\def#2{##1}#3}% #1\relax \pgfplotslistforeachungroupedrunningfalse \fi diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex new file mode 100644 index 00000000000..a10e67c82f3 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex @@ -0,0 +1,459 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This is a helper package with an elementary list datastructure. +% In contrast to \pgfplotslist, this one features fast append and fast +% copy-to-macro. +% +% The 'pgfplotsapplist' is a list which has ONLY the features +% +% \pgfplotsapplistnewempty +% \pgfplotsapplistpushback O(1) +% \pgfplotsapplistedefcontenttomacro (N) +% \pgfplotsapplistxdefcontenttomacro (N) +% +% It has been designed to accumulate macro content in O(N) (in +% contrast to TeX's macro append routines which lead to O(N^2) +% runtime). +% +% Furthermore, there is the +% +% \pgfplotsapplistXnewempty +% \pgfplotsapplistXpushback +% \pgfplotsapplistXedefcontenttomacro (N) +% \pgfplotsapplistXxdefcontenttomacro (N) +% \pgfplotsapplistXlet (N) +% +% structure which features **preasymptotical** constant runtime for +% pushback. That means, as long as N < 80000, the runtime is linear. +% It is only slightly slower than \pgfplotsapplist, and that only due +% to its generality. It could easily be adopted to be FASTER than +% \pgfplotsapplist. +% +% Credits for \pgfplotsapplist go to Till Tantau: he developped it for +% the PGF kernel. +% +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% the applist defines one macro for each element, like +% +% \def\element{\element} +% \def\element{\element} +% \def\element{} +% +% The '' value belongs to the private interface and is part of the +% macro name. +% +% It features: +% - real O(1) pushback +% - O(N) edef to macro +% - O(N) execute +% - it requires O(N) different macros. +% - it ***can't*** be copied outside of the current TeX group! +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Time: O(1), number of macros: 3 +\def\pgfplotsapplistnewempty#1{% + \expandafter\def\csname\string#1@endno\endcsname{0}% + \edef#1{\expandafter\noexpand\csname\string#1@0\endcsname}% + \expandafter\def\csname\string#1@0\endcsname{}% +}% + +% Time: O(1), number of macros per list: about N +% #1: the item to append +% #2: the list as macro name +\def\pgfplotsapplistpushback#1\to#2{% + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname\string#2@endno\endcsname + \begingroup + \c@pgf@counta=\pgfplots@loc@TMPa\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname\string#2@endno\endcsname=\pgfplots@glob@TMPa% + \t@pgfplots@toka={#1}% + \t@pgfplots@tokb=\expandafter{\csname\string#2@\pgfplots@glob@TMPa\endcsname}% + \expandafter\edef\csname\string#2@\pgfplots@loc@TMPa\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \expandafter\let\the\t@pgfplots@tokb=\pgfutil@empty +}% + +% time O(N) +% Expands the complete content of list #1 as-is into the macro #2. +\def\pgfplotsapplistedefcontenttomacro#1\to#2{\edef#2{#1}} +\def\pgfplotsapplistxdefcontenttomacro#1\to#2{\xdef#2{#1}} + +% Foreach list element, the stored value will simply be processed by +% TeX. Characters will be printed and commands will be executed. +% time O(N) +\def\pgfplotsapplistexecute#1{#1}% + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% +% This list here is a general re-implementation of the list used in +% the PGF system layer. +% It employs two collect-buffers to reduce the runtime. +% +% - It has preasymptotical runtime O(N), but is O(N^2) asymptotically. +% - It requires only 5 macros per list. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Usage: +% \pgfplotsapplistXnewempty\macro +% \pgfplotsapplistXnewempty[to global]\macro +% +% The 'to global' flag will configure the list such that all +% assignments to \macro are global. The list accumulation is +% LOCAL, however: 'to global' is to be used inside of a local +% group such that the final result, when all buffers are flushed, +% is assigned globally. +\def\pgfplotsapplistXnewempty{% + \pgfutil@ifnextchar[{% + \pgfplotsapplistXnewempty@opt + }{% + \pgfplotsapplistXnewempty@opt[]% + }% +} + +\def\pgfplotsapplistXnewempty@opt@TOGLOBAL{to global} + +\def\pgfplotsapplistXnewempty@opt[#1]#2{% + \def\pgfplots@loc@TMPa{#1}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \expandafter\let\csname\string#2@let\endcsname=\let% + \expandafter\let\csname\string#2@edef\endcsname=\edef + \else + \ifx\pgfplots@loc@TMPa\pgfplotsapplistXnewempty@opt@TOGLOBAL + \expandafter\def\csname\string#2@let\endcsname{\global\let}% + \expandafter\let\csname\string#2@edef\endcsname=\xdef + \else + \pgfplots@error{Sorry, the argument '#1' to \string\pgfplotsapplistXnewempty\ is unknown. Accepted is 'to global' or empty.}% + \fi + \fi + \pgfplotsapplistXnewempty@{#2}% +}% + +\def\pgfplotsapplistXnewempty@#1{% + \csname\string#1@let\endcsname#1=\pgfutil@empty + \expandafter\let\csname\string#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\let\csname\string#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#1@smallbuf@c\endcsname{0}% + \expandafter\def\csname\string#1@bigbuf@c\endcsname{0}% +}% + +% #1: the item to append +% #2: the list as macro name +\def\pgfplotsapplistXpushback#1\to#2{% + \begingroup + \c@pgf@counta=\csname\string#2@smallbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname\string#2@smallbuf@c\endcsname=\pgfplots@glob@TMPa + \ifnum\csname\string#2@smallbuf@c\endcsname<40 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \expandafter\edef\csname\string#2@smallbuf\endcsname{\the\t@pgfplots@toka}% + \else + \pgfplotsapplistXpushback@smallbufoverfl{#1}{#2}% + \fi +}% +\def\pgfplotsapplistXpushback@smallbufoverfl#1#2{% + \begingroup + \c@pgf@counta=\csname\string#2@bigbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname\string#2@bigbuf@c\endcsname=\pgfplots@glob@TMPa + % + \ifnum\csname\string#2@bigbuf@c\endcsname<30 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \expandafter\edef\csname\string#2@bigbuf\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \expandafter\let\csname\string#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#2@smallbuf@c\endcsname{0}% + \else% + \t@pgfplots@toka=\expandafter{#2}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}% + \csname\string#2@edef\endcsname#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\let\csname\string#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#2@smallbuf@c\endcsname{0}% + \expandafter\let\csname\string#2@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#2@bigbuf@c\endcsname{0}% + \fi% +}% +\def\pgfplotsapplistXflushbuffers#1{% + \t@pgfplots@toka=\expandafter{#1}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#1@bigbuf\endcsname}% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#1@smallbuf\endcsname}% + \csname\string#1@edef\endcsname#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\let\csname\string#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#1@smallbuf@c\endcsname{0}% + \expandafter\let\csname\string#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname\string#1@bigbuf@c\endcsname{0}% +}% + + +% Expands the complete content of list #1 as-is into the macro #2. +\def\pgfplotsapplistXedefcontenttomacro#1\to#2{% + \pgfplotsapplistXflushbuffers#1% + \edef#2{#1}} +\def\pgfplotsapplistXxdefcontenttomacro#1\to#2{% + \pgfplotsapplistXflushbuffers#1% + \xdef#2{#1}} +\def\pgfplotsapplistXlet#1=#2{% + \pgfplotsapplistXflushbuffers#2% + \let#1=#2} + +% Foreach list element, the stored value will simply be processed by +% TeX. Characters will be printed and commands will be executed. +\def\pgfplotsapplistXexecute#1{% + \pgfplotsapplistXflushbuffers#1% + #1}% + + + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% +% This list \pgfplotsapplistXX here is essentially the SAME as \pgfplotslistX. +% +% But there can only be one such list at a time, so it is faster than +% \pgfplotslistX. +% +% This here is probably the fastest list. +% +% It is nothing else but a copy of Till Tantau's pgf kernel list. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 + + + +% WARNING: call \pgfplotsapplistclear if there is another list active. +\def\pgfplotsapplistXXnewempty{% + \pgfutil@ifundefined{pgfplotsapplistXX}{}{% + \ifx\pgfplotsapplistXX\pgfutil@empty + \else + \pgfplots@error{\string\pgfplotsapplistXXnewempty: there is already another list which is *not* empty. It currently contains '\meaning\pgfplotsapplistXX'. Please call '\string\pgfplotsapplistXXclear' before using a new list to ensure clean separations.}% + \fi + }% + \let\pgfplotsapplistXX=\pgfutil@empty + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \def\pgfplotsapplistXX@bigbuf@c{0}% +}% + + +\def\pgfplotsapplistXXclear{% + \pgfutil@ifundefined{pgfplotsapplistXX}{}{% + \let\pgfplotsapplistXX=\pgfutil@empty + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \def\pgfplotsapplistXX@bigbuf@c{0}% + }% +}% + +% #1: the item to append +% #2: the list as macro name +\def\pgfplotsapplistXXpushback#1{% + \begingroup + \c@pgf@counta=\pgfplotsapplistXX@smallbuf@c\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \let\pgfplotsapplistXX@smallbuf@c=\pgfplots@glob@TMPa + \ifnum\pgfplotsapplistXX@smallbuf@c<40 + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX@smallbuf#1}% + \edef\pgfplotsapplistXX@smallbuf{\the\t@pgfplots@toka}% + \else + \pgfplotsapplistXXpushback@smallbufoverfl{#1}% + \fi +}% +\def\pgfplotsapplistXXpushback@smallbufoverfl#1{% + \begingroup + \c@pgf@counta=\pgfplotsapplistXX@bigbuf@c\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \let\pgfplotsapplistXX@bigbuf@c=\pgfplots@glob@TMPa + % + \ifnum\pgfplotsapplistXX@bigbuf@c<30 + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX@bigbuf}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@smallbuf#1}% + \edef\pgfplotsapplistXX@bigbuf{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \else% + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@bigbuf}% + \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXX@smallbuf#1}% + \edef\pgfplotsapplistXX{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty + \def\pgfplotsapplistXX@bigbuf@c{0}% + \fi% +}% +\def\pgfplotsapplistXXflushbuffers{% + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@bigbuf}% + \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXX@smallbuf}% + \edef\pgfplotsapplistXX{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty + \def\pgfplotsapplistXX@smallbuf@c{0}% + \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty + \def\pgfplotsapplistXX@bigbuf@c{0}% +}% + + +% Expands the complete content of list #1 as-is into the macro #2. +\def\pgfplotsapplistXXedefcontenttomacro#1{% + \pgfplotsapplistXXflushbuffers + \edef#1{\pgfplotsapplistXX}} +\def\pgfplotsapplistXXxdefcontenttomacro#1{% + \pgfplotsapplistXXflushbuffers% + \xdef#1{\pgfplotsapplistXX}} +\def\pgfplotsapplistXXlet#1{% + \pgfplotsapplistXXflushbuffers% + \let#1=\pgfplotsapplistXX} + +% Foreach list element, the stored value will simply be processed by +% TeX. Characters will be printed and commands will be executed. +\def\pgfplotsapplistXXexecute#1{% + \pgfplotsapplistXXflushbuffers + #1}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +% +% \pgfplotslistXXglobal assigns to a global list. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 +\def\pgfplotsapplistXXglobalnewempty{% + \pgfutil@ifundefined{pgfplotsapplistXXglobal}{}{% + \ifx\pgfplotsapplistXXglobal\pgfutil@empty + \else + \pgfplots@error{\string\pgfplotsapplistXXglobalnewempty: there is already another list which is *not* empty. It currently contains '\meaning\pgfplotsapplistXXglobal'. Please call '\string\pgfplotsapplistXXglobalclear' before using a new list to ensure clean separations.}% + \fi + }% + \global\let\pgfplotsapplistXXglobal=\pgfutil@empty + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}% +}% + + +\def\pgfplotsapplistXXglobalclear{% + \pgfutil@ifundefined{pgfplotsapplistXXglobal}{}{% + \global\let\pgfplotsapplistXXglobal=\pgfutil@empty + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}% + }% +}% + +% #1: the item to append +% #2: the list as macro name +\def\pgfplotsapplistXXglobalpushback#1{% + \begingroup + \c@pgf@counta=\pgfplotsapplistXXglobal@smallbuf@c\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \global\let\pgfplotsapplistXXglobal@smallbuf@c=\pgfplots@glob@TMPa + \ifnum\pgfplotsapplistXXglobal@smallbuf@c<40 + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}% + \xdef\pgfplotsapplistXXglobal@smallbuf{\the\t@pgfplots@toka}% + \else + \pgfplotsapplistXXglobalpushback@smallbufoverfl{#1}% + \fi +}% +\def\pgfplotsapplistXXglobalpushback@smallbufoverfl#1{% + \begingroup + \c@pgf@counta=\pgfplotsapplistXXglobal@bigbuf@c\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \global\let\pgfplotsapplistXXglobal@bigbuf@c=\pgfplots@glob@TMPa + % + \ifnum\pgfplotsapplistXXglobal@bigbuf@c<30 + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal@bigbuf}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}% + \xdef\pgfplotsapplistXXglobal@bigbuf{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \else% + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@bigbuf}% + \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}% + \xdef\pgfplotsapplistXXglobal{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}% + \fi% +}% +\def\pgfplotsapplistXXglobalflushbuffers{% + \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal}% + \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@bigbuf}% + \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXXglobal@smallbuf}% + \xdef\pgfplotsapplistXXglobal{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}% + \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty + \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}% +}% + + +% Expands the complete content of list #1 as-is into the macro #2. +% +% this assigns locally into #1. +\def\pgfplotsapplistXXglobaledefcontenttomacro#1{% + \pgfplotsapplistXXglobalflushbuffers + \edef#1{\pgfplotsapplistXXglobal}} +% this assigns locally into #1. +\def\pgfplotsapplistXXglobalxdefcontenttomacro#1{% + \pgfplotsapplistXXglobalflushbuffers% + \xdef#1{\pgfplotsapplistXXglobal}} +% this assigns locally into #1. +\def\pgfplotsapplistXXgloballet#1{% + \pgfplotsapplistXXglobalflushbuffers% + \let#1=\pgfplotsapplistXXglobal} + +% Foreach list element, the stored value will simply be processed by +% TeX. Characters will be printed and commands will be executed. +% this assigns locally into #1. +\def\pgfplotsapplistXXglobalexecute#1{% + \pgfplotsapplistXXglobalflushbuffers + #1}% 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 82e27215bf4..77a40d51ed5 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex @@ -28,13 +28,6 @@ % %-------------------------------------------- -% This file relies on -% - pgfplotsliststructure.code.tex -% - pgfplotsarraystructure.code.tex -% - a (quite!) recent PGF. -% -% and needs some token registers. It does not use more of pgfplots. -% \newif\ifpgfplotstable@search@header \newcount\c@pgfplotstable@counta \newwrite\pgfplotstable@outfile @@ -43,9 +36,15 @@ % should always be false; use only in grouped internal macros \newif\ifpgfplots@table@options@areset +\newif\ifpgfplots@tableread@to@listener \input pgfplotstable.coltype.code.tex +% keys which are NOT predefined: +% /pgfplots/table/alias//.initial={} +% /pgfplots/table/columns//.style={} +% /pgfplots/table/display columns//.style={} +% /pgfplots/table/create on use//.style={create options} \pgfkeys{% /pgfplots/table/header/.is if=pgfplotstable@search@header, /pgfplots/table/header=true, @@ -71,6 +70,38 @@ \fi \fi} }, + /pgfplots/table/select equal part entry of/.style 2 args={% + /pgfplots/table/row predicate/.code={% + \pgfplotstableuserowtrue + \begingroup + % this group re-uses counters as temporary variables. + \c@pgfplotstable@colindex=\pgfplotstablerows\relax + \divide\c@pgfplotstable@colindex by#2\relax + \edef\pgfplotstablepartsize{\the\c@pgfplotstable@colindex}% + % This here should create empty cells such that + % remaining entries are distributed equally: + \c@pgfplotstable@rowindex=\c@pgfplotstable@colindex + \multiply\c@pgfplotstable@rowindex by#2\relax + \ifnum\c@pgfplotstable@rowindex<\pgfplotstablerows\relax + \c@pgfplotstable@colindex=\pgfplotstablerows\relax + \advance\c@pgfplotstable@colindex by-\c@pgfplotstable@rowindex + \advance\c@pgfplotstable@colindex by\pgfplotstablepartsize + \edef\pgfplotstablepartsize{\the\c@pgfplotstable@colindex}% + \fi + % + \multiply\c@pgfplotstable@colindex by#1\relax + \ifnum##1<\c@pgfplotstable@colindex\relax + \aftergroup\pgfplotstableuserowfalse + \else + \advance\c@pgfplotstable@colindex by\pgfplotstablepartsize\relax + \ifnum##1<\c@pgfplotstable@colindex\relax + \else + \aftergroup\pgfplotstableuserowfalse + \fi + \fi + \endgroup + }% + }, /pgfplots/table/col sep/.is choice, /pgfplots/table/col sep/space/.code = {\def\pgfplotstableread@COLSEP@CASE{0}}, /pgfplots/table/col sep/comma/.code = {\def\pgfplotstableread@COLSEP@CASE{1}}, @@ -111,14 +142,44 @@ /pgfplots/table/multicolumn names/.default=c, /pgfplots/table/dec sep align/.style={% /pgf/number format/assume math mode, - /pgf/number format/set decimal separator/.add={&}{}, + /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/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}% + \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={% + /pgf/number format/assume math mode, + /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/assign cell content/.code={% - \pgfmathprintnumberto{##1}\pgfmathresult% - \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}% + \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&}% @@ -126,7 +187,7 @@ \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult }, }, - /pgfplots/table/dec sep align/.default=c, + /pgfplots/table/sci sep align/.default=c, % % A style which can be used together with the 'dcolumn' package by % David Carlisle. @@ -162,14 +223,22 @@ % #1: the cells content as it has been found in the input table % this command key should somehow fill |cell content|. /pgfplots/table/assign cell content/.code={% - \pgfmathprintnumberto{#1}\pgfmathresult% + \def\pgfmathresult{#1}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathprintnumberto{#1}\pgfmathresult% + \fi \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult }, % % this here is the default formatting. It uses % \pgfmathprintnumber. /pgfplots/table/assign cell content as number/.code={% - \pgfmathprintnumberto{#1}\pgfmathresult% + \def\pgfmathresult{#1}% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathprintnumberto{#1}\pgfmathresult% + \fi \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult }, /pgfplots/table/string type/.style={% @@ -177,11 +246,284 @@ /pgfplots/table/@cell content={##1}% }% },% + /pgfplots/table/set content/.style={% + /pgfplots/table/postproc cell content/.style={% + /pgfplots/table/@cell content={#1}% + }% + },% + % + /pgfplots/table/postproc cell content/.code={}, + /pgfplots/table/preproc cell content/.code={}, + % + /pgfplots/table/multiply -1/.style={% + /pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\empty + \else + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\pgfmatharga=\pgfmathresult + \pgfmathfloatcreate{2}{1.0}{0}% + \let\pgfmathargb=\pgfmathresult + \pgfmathfloatmultiply@{\pgfmatharga}{\pgfmathargb}% + \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 + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}% + \fi + \fi + }% + }, + % /pgfplots/table/font/.initial=, /pgfplots/table/.unknown/.code={% \pgfqkeys{/pgf/number format}{\pgfkeyscurrentname=#1}% - }% + },% + /pgfplots/table/create col/assign first/.style={ + /pgfplots/table/create col/assign% + }, + /pgfplots/table/create col/assign last/.style={ + /pgfplots/table/create col/assign% + }, + /pgfplots/table/create col/assign/.style={ + /pgfplots/table/create col/next content={}% + }, + /pgfplots/table/create col/next content/.initial={}, + /pgfplots/table/create col/expr/.style={% + /pgfplots/table/create col/assign/.code={% + \pgfmathparse{#1}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + },% + /pgfplots/table/create col/quotient/.style={% + /pgfplots/table/columns={#1}, + /pgfplots/table/create col/assign first/.style={% + /pgfplots/table/create col/next content= + },% + /pgfplots/table/create col/assign/.code={% + \pgfmathfloatparsenumber{\prevrow{#1}}% + \let\pgfmatharga=\pgfmathresult + \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/table/create col/iquotient/.style={% + /pgfplots/table/columns={#1}, + /pgfplots/table/create col/assign first/.style={% + /pgfplots/table/create col/next content= + },% + /pgfplots/table/create col/assign/.code={% + \pgfmathfloatparsenumber{\prevrow{#1}}% + \let\pgfmathargb=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmatharga=\pgfmathresult + \let\pgfmathaccuma=\pgfmathargb + \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}% + \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}% + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + }% + },% + % + % Produces 'log2( \prevrow{#1}/\thisrow{#1} ) + % + % Assumeing that every row contains error(h) = O(h^alpha) + % and h_this = h_prev/2, this result in 'alpha', the convergence + % rate. + /pgfplots/table/create col/dyadic refinement rate/.style={% + /pgfplots/table/columns={#1}, + /pgfplots/table/create col/assign first/.style={% + /pgfplots/table/create col/next content= + },% + /pgfplots/table/create col/assign/.code={% + \pgfmathfloatparsenumber{\prevrow{#1}}% + \let\pgfmatharga=\pgfmathresult + \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/table/create col/idyadic refinement rate/.style={% + /pgfplots/table/columns={#1}, + /pgfplots/table/create col/assign first/.style={% + /pgfplots/table/create col/next content= + },% + /pgfplots/table/create col/assign/.code={% + \pgfmathfloatparsenumber{\prevrow{#1}}% + \let\pgfmathargb=\pgfmathresult + \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/table/create col/gradient/.style 2 args={% + /pgfplots/table/columns={#1,#2}, + /pgfplots/table/create col/assign first/.code={% + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathaccuma=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#2}}% + \let\pgfmathaccumb=\pgfmathresult + \def\pgfmathresult{}% leave first empty. + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + /pgfplots/table/create col/assign/.code={% + \let\pgfmathcur@x=\pgfmathaccuma + \let\pgfmathcur@y=\pgfmathaccumb + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathnext@x=\pgfmathresult + \let\pgfmathaccuma=\pgfmathnext@x + \pgfmathfloatparsenumber{\thisrow{#2}}% + \let\pgfmathnext@y=\pgfmathresult + \let\pgfmathaccumb=\pgfmathnext@y + \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}% + \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/table/create col/gradient loglog/.style 2 args={% + /pgfplots/table/columns={#1,#2}, + /pgfplots/table/create col/assign first/.code={% + \pgfmathlog{\thisrow{#1}}% + \let\pgfmathaccuma=\pgfmathresult + \pgfmathlog{\thisrow{#2}}% + \let\pgfmathaccumb=\pgfmathresult + \def\pgfmathresult{}% leave first empty. + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + /pgfplots/table/create col/assign/.code={% + \let\pgfmathcur@x=\pgfmathaccuma + \let\pgfmathcur@y=\pgfmathaccumb + \pgfmathlog{\thisrow{#1}}% + \let\pgfmathnext@x=\pgfmathresult + \let\pgfmathaccuma=\pgfmathresult + \pgfmathlog{\thisrow{#2}}% + \let\pgfmathnext@y=\pgfmathresult + \let\pgfmathaccumb=\pgfmathresult + \pgfplots@loop@CONTINUEtrue + \ifx\pgfmathcur@x\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi + \ifx\pgfmathcur@y\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi + \ifx\pgfmathnext@x\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi + \ifx\pgfmathnext@y\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi + \ifpgfplots@loop@CONTINUE + \pgfmathsubtract@{\pgfmathnext@x}{\pgfmathcur@x}% + \let\pgfmathdiff@x=\pgfmathresult + \pgfmathsubtract@{\pgfmathnext@y}{\pgfmathcur@y}% + \let\pgfmathdiff@y=\pgfmathresult + \pgfmathdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}% + \else + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloattosci@\pgfmathresult + \fi + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + },% + /pgfplots/table/create col/gradient semilogx/.style 2 args={% + /pgfplots/table/columns={#1,#2}, + /pgfplots/table/create col/assign first/.code={% + \pgfmathlog{\thisrow{#1}}% + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloatcreate{3}{0.0}{0}% + \else + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \let\pgfmathaccuma=\pgfmathresult + \pgfmathfloatparsenumber{\thisrow{#2}}% + \let\pgfmathaccumb=\pgfmathresult + \def\pgfmathresult{}% leave first empty. + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + /pgfplots/table/create col/assign/.code={% + \let\pgfmathcur@x=\pgfmathaccuma + \let\pgfmathcur@y=\pgfmathaccumb + \pgfmathlog{\thisrow{#1}}% + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloatcreate{3}{0.0}{0}% + \else + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \let\pgfmathnext@x=\pgfmathresult + \let\pgfmathaccuma=\pgfmathresult + % + \pgfmathfloatparsenumber{\thisrow{#2}}% + \let\pgfmathnext@y=\pgfmathresult + \let\pgfmathaccumb=\pgfmathresult + \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}% + \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/table/create col/gradient semilogy/.style 2 args={% + /pgfplots/table/columns={#1,#2}, + /pgfplots/table/create col/assign first/.code={% + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathaccuma=\pgfmathresult + \pgfmathlog{\thisrow{#2}}% + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloatcreate{3}{0.0}{0}% + \else + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \let\pgfmathaccumb=\pgfmathresult + \def\pgfmathresult{}% leave first empty. + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + },% + /pgfplots/table/create col/assign/.code={% + \let\pgfmathcur@x=\pgfmathaccuma + \let\pgfmathcur@y=\pgfmathaccumb + \pgfmathlog{\thisrow{#2}}% + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloatcreate{3}{0.0}{0}% + \else + \expandafter\pgfmathfloatparsenumber\expandafter{\pgfmathresult}% + \fi + \let\pgfmathnext@y=\pgfmathresult + \let\pgfmathaccumb=\pgfmathresult + % + \pgfmathfloatparsenumber{\thisrow{#1}}% + \let\pgfmathnext@x=\pgfmathresult + \let\pgfmathaccuma=\pgfmathresult + \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}% + \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% + },% + },% } +\pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent@EMPTY % \pgfplotstableread[OPTIONS] {FILE} to \name % @@ -206,6 +548,18 @@ % % The table data is stored columnwise in lists and can be accessed % with the other methods of this package. +% +% \pgfplotstableread[]{}{<\macro>} +% \pgfplotstableread[]{} to listener{<\macro>} +% +% The 'to listener' variant does NOT assemble a table data structure. +% Instead, it processes the input table row-wise and invokes <\macro> +% after each complete row. During the evaluation of <\macro>, the +% following methods can be used to query values: +% \pgfplotstablereadgetcolindex{}{<\macro>} +% \pgfplotstablereadgetcolname{}{<\macro>} +% Attention: 'to listener' is scoped by TeX groups, so any assignments +% need to be done globally (or with aftergroup magic). \def\pgfplotstableread{% \pgfutil@ifnextchar[{% \pgfplotstableread@impl @@ -221,14 +575,111 @@ \let#2=#1 } +% Returns a column vector in form of \pgfplotslist +% into #3. +% +% #1: the column name (not a macro) +% #2: the table structure +% #3: the output macro name. \def\pgfplotstablegetcolumnbyname#1\of#2\to#3{% \pgfutil@ifundefined{\string#2@#1}{% - \pgfplots@error{Sorry, could not retrieve column '#1' from table...}% + % Oh, there is no column '#1' in table '#2'! + % + % Ok, then check for the 'create on use' and the 'alias' + % features... + % 1. create on use: + % + % WARNING : this code has been REPLICATED in + % *** \pgfplotstablereadgetptrtocolname *** + % *** \pgfplotstablegetcolumnbyname *** + % *** \pgfplotstableresolvecolname *** + \def\pgfplotstable@loc@TMPa{/pgfplots/table/create on use/#1}% + \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{% + % aah - a 'create on use' style exists. Apply it! + \expandafter\pgfplotstablecreatecol\expandafter[\pgfplotstable@loc@TMPa]{#1}{#2}% + % and return the newly generated col: + \expandafter\let\expandafter#3\csname\string#2@#1\endcsname + }{% + % ok, then it is either an alias or it is simply not + % existant. + \def\pgfplotstable@loc@TMPa{/pgfplots/table/alias/#1}% + \pgfkeysifdefined{\pgfplotstable@loc@TMPa}{% + \pgfkeysgetvalue{\pgfplotstable@loc@TMPa}{\pgfplotstable@loc@TMPb}% + \let\pgfplotstable@loc@TMPa=\pgfplotstable@loc@TMPb + \pgfutil@ifundefined{\string#2@\pgfplotstable@loc@TMPa}{% + \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.}% + \pgfplotslistnewempty#3 + }{% + \expandafter\let\expandafter#3\csname\string#2@\pgfplotstable@loc@TMPa\endcsname + }% + }{% + \pgfplots@error{Sorry, could not retrieve column '#1' from table '\pgfplotstablenameof{#2}'. Please check spelling (or introduce name aliases).}% + \pgfplotslistnewempty#3 + }% + }% }{% \expandafter\let\expandafter#3\csname\string#2@#1\endcsname }% } +% Retrieves the column *NAME* '#1' of table #2 and writes it into +% '#3'. +% +% If there is no such column, column aliases will be checked. Finally +% if there are no aliases, the command fails with an error. +% +% The 'create on use' statements can't be used in this context. +% @see \pgfplotstablegetcolumnbyname +% +% #1: a column name (not a macro) +% #2: the table structure +% #3: a macro name which will be filled with the (probably modified) +% column name into #2. +\def\pgfplotstableresolvecolname#1\of#2\to#3{% + \pgfutil@ifundefined{\string#2@#1}{% + % Oh, there is no column '#1' in table '#2'! + % + % Ok, then check for the 'alias' feature ... + % + % WARNING : this code has been REPLICATED in + % *** \pgfplotstablereadgetptrtocolname *** + % *** \pgfplotstablegetcolumnbyname *** + % *** \pgfplotstableresolvecolname *** + \def\pgfplotstable@loc@TMPa{/pgfplots/table/alias/#1}% + \pgfkeysifdefined{\pgfplotstable@loc@TMPa}{% + \pgfkeysgetvalue{\pgfplotstable@loc@TMPa}{\pgfplotstable@loc@TMPb}% + \let\pgfplotstable@loc@TMPa=\pgfplotstable@loc@TMPb + \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, could not retrieve aliased column '\pgfplotstable@loc@TMPa' from table '\pgfplotstablenameof{#2}'. The original request was for '#1', which does not exist either.}% + }% + \let#3=\pgfutil@empty + }{% + \let#3=\pgfplotstable@loc@TMPa + }% + }{% + \pgfplots@error{Sorry, could not retrieve column '#1' from table '\pgfplotstablenameof{#2}'. Please check spelling (or introduce name aliases).}% + \let#3=\pgfutil@empty + }% + }{% + \def#3{#1}% + }% +} + +% Invokes either \pgfplotstablegetcolumnbyindex or +% \pgfplotstablegetcolumnbyname. +\def\pgfplotstablegetcolumn#1\of#2\to#3{% + \pgfplotstable@is@colname{#1}% + \ifpgfplotstableread@foundcolnames + \else + \pgfplotstablegetcolumnnamebyindex{#1}\of{#2}\to{#3} + \fi + \pgfplotstablegetcolumnbyname{#1}\of#2\to{#3}% +}% + \def\pgfplotstablegetcolumnnamebyindex#1\of#2\to#3{% \pgfplotslistselect#1\of#2\to#3\relax }% @@ -239,13 +690,56 @@ \def\pgfplotstablecopy#1\to#2{% \let#2=#1% - \pgfplotslistforeachungrouped#1\as\pgfplotstable@TMP{% - \def\pgfplotstable@TMPB{% - \expandafter\let\csname\string#2@\pgfplotstable@TMP\endcsname}% - \expandafter\pgfplotstable@TMPB\csname\string#1@\pgfplotstable@TMP\endcsname + \pgfplotstablegetname#2\pgfplotstable@loc@TMPa + \expandafter\let\csname\string#1@@table@name\endcsname=\pgfplotstable@loc@TMPa + \pgfplotslistforeachungrouped#1\as\pgfplotstable@loc@TMPa{% + \def\pgfplotstable@loc@TMPb{% + \expandafter\let\csname\string#2@\pgfplotstable@loc@TMPa\endcsname}% + \expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname }% } +% Returns the file name of table '#1' into macro #2. +\def\pgfplotstablegetname#1#2{% + \expandafter\let\expandafter#2\csname\string#1@@table@name\endcsname +} + +% expands to the table file name of table '#1' +\def\pgfplotstablenameof#1{% + \csname\string#1@@table@name\endcsname +} + +% Creates a new column named #1 and appends it to table #2. +% +% The column entries will be created using the command keys +% 'create col/assign' +% 'create col/assign last' +% +% The key 'create col/assign' will be invoked for every row of table #2. +% It is supposed to assign the key 'create col/next content'. +% During evaluation of 'create col/assign', the macro '\thisrow{}' +% expands to the current row's value of the column named by . +% Furthermore, '\nextrow{}' expands to the \emph{next} row's +% value of the designated column. +% +% Since the "next row" is not available if we are currently processing +% the last row, 'create col/assign last' is used in for the last row's +% value. +% +% You can use +% - \thisrow{}, +% - \getthisrow{}{\macro} +% - \nextrow{}, +% - \getnextrow{}{\macro} +\def\pgfplotstablecreatecol{% + \pgfutil@ifnextchar[{% + \pgfplotstablecreatecol@opt + }{% + \pgfplotstablecreatecol@opt[]% + }% +}% + + % Typesets a table. % % \pgfplotstabletypeset[]<\tablestructure> @@ -285,7 +779,7 @@ \ifpgfplots@table@options@areset \else \pgfplots@table@options@aresettrue - \pgfplotstableset{/pgfplots/table/every table,#1}% + \pgfplotstableset{/pgfplots/table/every table={#2},#1}% \fi \pgfplotstableread{#2}\pgfplotstabletypesetfile@opt@@ \pgfplotstabletypeset\pgfplotstabletypesetfile@opt@@ @@ -300,6 +794,12 @@ \newif\ifpgfplotstableread@curline@contains@colnames \newif\ifpgfplotstableread@foundcolnames \newif\ifpgfplotstableread@skipline + +% Accept one of +% \pgfplotstableread[#1]{}{<\macro>} +% \pgfplotstableread[#1]{} to listener{<\macro>} +% or +% \pgfplotstableread[#1]{} to {<\macro>} (DEPRECATED) \def\pgfplotstableread@impl[#1]#2{% \pgfutil@ifnextchar t{% \pgfplotstableread@impl@@{#1}{#2}% @@ -312,18 +812,37 @@ % >> \pgfplotstableread[]{file} to \macro % That ' to ' is really ugly. This here is for backwards % compatibility: -\def\pgfplotstableread@impl@@#1#2to #3{% +\def\pgfplotstableread@impl@@#1#2to {% + \pgfutil@ifnextchar l{% + \pgfplotstableread@impl@@listener{#1}{#2}% + }{% + \pgfplotstableread@impl@{#1}{#2}% + }% +}% +\def\pgfplotstableread@impl@@listener#1#2listener#3{% + \pgfplots@tableread@to@listenertrue \pgfplotstableread@impl@{#1}{#2}{#3}% + \pgfplots@tableread@to@listenerfalse }% \def\pgfplotstableread@impl@#1#2#3{% \begingroup \ifpgfplots@table@options@areset \else - \pgfplotstableset{/pgfplots/table/every table,#1}% + \pgfplotstableset{/pgfplots/table/every table={#2},#1}% \fi %\pgfplots@message{ATTEMPTING TO READ #2}% - \openin1=#2\relax + \openin1=#2.tex + \ifeof1 + \openin1=#2\relax + \else + \pgfplots@warning{% + You requested to open table '#2', but there is also a '#2.tex'. + TeX will automatically append the suffix '.tex', so I will now open '#2.tex'. + Please make sure you don't accidentally load TeX files - this may produce unrecoverable errors.}% + \closein1 + \openin1=#2\relax + \fi \def\pgfplotstableread@filename{#2}% \let\pgfplotstableread@lineno=\c@pgf@counta \let\pgfplotstableread@numcols=\c@pgf@countb @@ -332,48 +851,63 @@ \pgfplotstableread@lineno=0 \pgfplotstableread@usablelineno=0 \pgfplotstableread@numcols=0 - \pgfplotslistnewempty\pgfplotstable@colnames + \global\pgfplotslistnewempty\pgfplotstable@colnames \ifeof1 \pgfplotstable@error{Could not read table file '#2'.}% - \fi - % - \pgfplotstableread@loop@over@lines - % - \ifpgfplotstableread@foundcolnames + \global\pgfplotslistnewempty\pgfplotstable@colnames \else - \pgfplotstableread@create@column@names@with@numbers + \ifpgfplots@tableread@to@listener + \let\pgfplotstable@listener=#3% + \let\pgfplotstableread@impl@nextrow@NEXT=\pgfplotstableread@impl@nextrow@NEXT@listener + \let\pgfplotstablereadgetcolindex=\pgfplotstablereadgetcolindex@ + \let\pgfplotstablereadgetcolname=\pgfplotstablereadgetcolname@ + \let\pgfplotstablereadgetptrtocolname=\pgfplotstablereadgetptrtocolname@ + \let\pgfplotstablereadgetptrtocolindex=\pgfplotstablereadgetptrtocolindex@ + \let\pgfplotstablereadevalptr=\pgfplotstablereadevalptr@ + \fi + % + \pgfplotstableread@loop@over@lines + \closein1 + % + \pgfplotstableread@finish \fi - % Well, now write the identified data to #3: - % - % make all temporaries global: - \global\let\pgfplotstable@colnames=\pgfplotstable@colnames - \pgfplotstableread@curcol=0\relax - \loop - \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols -%\pgfplots@message{ASSIGNING COLUMN NO \the\pgfplotstableread@curcol / \the\pgfplotstableread@numcols}% - % numtable@TMP := column list content - \expandafter\global\expandafter\let\expandafter\pgfplotstable@TMP\csname numtable@col@\the\pgfplotstableread@curcol\endcsname - % global := numtable@TMP - \expandafter\global\expandafter\let\csname numtable@col@\the\pgfplotstableread@curcol\endcsname=\pgfplotstable@TMP - \advance\pgfplotstableread@curcol by1\relax - \repeat - \closein1 \endgroup - % Now, we can access the global variables! - % copy them to #3. - \let#3=\pgfplotstable@colnames - \c@pgfplotstable@counta=0\relax% - \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@TMP{% - \def\pgfplotstable@TMPB{% - \expandafter\let\csname\string#3@\pgfplotstable@TMP\endcsname}% - \expandafter\pgfplotstable@TMPB\csname numtable@col@\the\c@pgfplotstable@counta\endcsname -%\message{Column '\pgfplotstable@TMP' has entries: \expandafter\meaning\csname numtable@col@\the\c@pgfplotstable@counta\endcsname}% - \expandafter\global\expandafter\let\csname numtable@col@\the\c@pgfplotstable@counta\endcsname=\pgfutil@empty - \advance\c@pgfplotstable@counta by1\relax - }% + \ifpgfplots@tableread@to@listener + % there are no data structures in this case. + \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 + }% + \fi \global\let\pgfplotstable@colnames=\pgfutil@empty } +\def\pgfplotstableread@finish{% + \ifpgfplots@tableread@to@listener + \else + \ifpgfplotstableread@foundcolnames + \else + \pgfplotstableread@create@column@names@with@numbers + \fi + \pgfplotstableread@curcol=0\relax% + \pgfutil@loop + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols + \expandafter\pgfplotsapplistXflushbuffers\csname pgfp@numtable@glob@col@\the\pgfplotstableread@curcol\endcsname + \advance\pgfplotstableread@curcol by1 + \pgfutil@repeat + \fi +} + \def\pgfplotstableread@loop@over@lines{% \ifeof1 %\pgfplots@message{EOF}% @@ -390,9 +924,9 @@ % \fi %-------------------------------------------------- %\pgfplots@message{READING LINE \the\pgfplotstableread@lineno: '\meaning\pgfplotstable@LINE'.}% + \pgfplotstableread@curline@contains@colnamesfalse \ifnum\pgfplotstableread@numcols=0\relax \pgfplotstableread@curcol=0\relax - \pgfplotstableread@curline@contains@colnamesfalse \pgfplotstableread@impl@DO\pgfplotstableread@impl@countcols@and@identifynames@NEXT\pgfplotstable@LINE %\expandafter\pgfplotstableread@impl@countcols@and@identifynames@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI \pgfplotstableread@numcols=\pgfplotstableread@curcol @@ -439,14 +973,22 @@ \else \pgfplotstable@error{ERROR: the input table has an unexpected number of columns in row '\the\pgfplotstableread@lineno'. Expected: '\the\pgfplotstableread@numcols'; got '\the\pgfplotstableread@curcol. Maybe the input table is corrupted?}% \fi + \ifpgfplots@tableread@to@listener + \ifpgfplotstableread@curline@contains@colnames + \else + % report row! + \pgfplotstable@listener + \fi + \fi \advance\pgfplotstableread@usablelineno by1\relax \fi \fi \advance\pgfplotstableread@lineno by1\relax - \pgfplotstableread@loop@over@lines + \expandafter\pgfplotstableread@loop@over@lines \fi } +% WARNING: this routine is also use in pgfplots.code.tex ... \def\pgfplotstableread@checkspecial@line{% \pgfutil@ifnextchar##{% \pgfplotstableread@skiplinetrue @@ -478,20 +1020,21 @@ } \def\pgfplotstableread@create@column@lists{% - \loop + \pgfutil@loop \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols - \expandafter\pgfplotslistnewempty\csname numtable@col@\the\pgfplotstableread@curcol\endcsname + \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}% + \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@\the\pgfplotstableread@curcol\endcsname \advance\pgfplotstableread@curcol by1\relax - \repeat + \pgfutil@repeat } \def\pgfplotstableread@create@column@names@with@numbers{% \pgfplotstableread@curcol=0\relax - \loop + \pgfutil@loop \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols - \expandafter\pgfplotslistpushback\the\pgfplotstableread@curcol\to\pgfplotstable@colnames + \expandafter\pgfplotslistpushbackglobal\the\pgfplotstableread@curcol\to\pgfplotstable@colnames \advance\pgfplotstableread@curcol by1\relax - \repeat + \pgfutil@repeat } \long\def\pgfplotstableread@impl@gobble#1\pgfplotstable@EOI{}% @@ -560,13 +1103,107 @@ \pgfplotstableread@impl@ITERATE@NEXT@{#1}% \pgfplotstableread@impl@ITERATE }% -%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% these values are only usable for a read-listener, that means: +% when using +% +% \pgfplotstableread{} to listener<\macro> +% +% -> <\macro> can than use the methods +% +% \pgfplotstablereadgetcolindex{}{<\content>} +% performs \let\content= > +\def\pgfplotstablereadgetcolindex@#1#2{% + \pgfutil@ifundefined{pgfplotstblread@colcontent@no#1}{% + \pgfplots@error{Sorry, the requested column number '#1' in table '\pgfplotstableread@filename' does not exist!? Please verify you used the correct index 0 <= i < N.}% + \let#2=\pgfutil@empty + }{% + \expandafter\let\expandafter#2\csname pgfplotstblread@colcontent@no#1\endcsname + }% +}% + +% \pgfplotstablereadgetcolname{}{} +% performs \let\content= > +\def\pgfplotstablereadgetcolname@#1#2{% + \pgfplotstablereadgetptrtocolname{#1}{\pgfplots@loc@TMPa}% + \pgfplotstablereadevalptr\pgfplots@loc@TMPa{#2}% +}% + +% \pgfplotstablereadgetptrtocolname{}{\ptr} +% Creates some sort of "pointer" to the column named . This +% pointer can than be used every time a new line has been reported to +% the listener. IT works like this: +% +% \let\ptr=\pgfutil@empty +% \def\macro{% +% \ifx\ptr\empty +% \pgfplotstablereadgetptrtocolname{}{\ptr}% +% \fi +% \pgfplotstablereadevalptr{\ptr}{\content}% +% -> do something with \content! +% } +% +% \pgfplotstableread{} to listener<\macro> +% +% -> will evaluate \macro foreach row. +\def\pgfplotstablereadgetptrtocolname@#1#2{% + % Implementation note: it is necessary to replicate code becuase + % in this context, the table structure is NOT available. + \pgfutil@ifundefined{pgfplotstblread@colindex@for@name#1}{% + % Oh, there is no column '#1'! + % + % Check for the 'alias' feature! + % + % WARNING : this code has been REPLICATED in + % *** \pgfplotstablereadgetptrtocolname *** + % *** \pgfplotstablegetcolumnbyname *** + % *** \pgfplotstableresolvecolname *** + % + \def\pgfplotstable@loc@TMPa{/pgfplots/table/alias/#1}% + \pgfkeysifdefined{\pgfplotstable@loc@TMPa}{% + \pgfkeysgetvalue{\pgfplotstable@loc@TMPa}{\pgfplotstable@loc@TMPb}% + \let\pgfplotstable@loc@TMPa=\pgfplotstable@loc@TMPb + \pgfutil@ifundefined{pgfplotstblread@colindex@for@name\pgfplotstable@loc@TMPa}{% + \pgfplots@error{Sorry, could not retrieve aliased column '\pgfplotstable@loc@TMPa' from table '\pgfplotstableread@filename'. The original request was for '#1', which does not exist either.}% + \def#2{0}% + }{% + \edef#2{\csname pgfplotstblread@colindex@for@name\pgfplotstable@loc@TMPa\endcsname}% + }% + }{% + \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, could not retrieve column '#1' from table '\pgfplotstableread@filename'. Please check spelling (or introduce name aliases).}% + }% + \def#2{0}% + }% + }{% + \edef#2{\csname pgfplotstblread@colindex@for@name#1\endcsname}% + }% +}% + +% As \pgfplotstablereadgetptrtocolname, but this here access columns +% by index. +\def\pgfplotstablereadgetptrtocolindex@#1#2{\def#2{#1}}% +% \pgfplotstablereadevalptr{<\ptr>}{<\content} +% writes the current value of <\ptr> to <\content>. The pointer <\ptr> +% must be initialised with \pgfplotstablereadgetptrtocolname +\let\pgfplotstablereadevalptr@=\pgfplotstablereadgetcolindex@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\long\def\pgfplotstableread@impl@nextrow@NEXT@listener#1{% + \expandafter\def\csname pgfplotstblread@colcontent@no\the\pgfplotstableread@curcol\endcsname{#1}% + \advance\pgfplotstableread@curcol by1\relax +} \long\def\pgfplotstableread@impl@nextrow@NEXT#1{% %\pgfplots@message{Inserting '#1' at (\the\pgfplotstableread@lineno, \the\pgfplotstableread@curcol).}% - \def\pgfplotstableread@TMP{\pgfplotslistpushback#1\to}% - \expandafter\pgfplotstableread@TMP\csname numtable@col@\the\pgfplotstableread@curcol\endcsname + \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 } @@ -575,13 +1212,20 @@ \long\def\pgfplotstableread@impl@collectcolnames@NEXT#1{% %\pgfplots@message{Got column name no \the\pgfplotstableread@curcol\ as '#1'}% \pgfutil@ifundefined{pgfplotstableread@impl@COLNAME@#1}{% - \def\pgfplotstable@TMP{#1}% + \def\pgfplotstable@loc@TMPa{#1}% }{% generate unique column names - \pgfplots@warning{Warning: table '\pgfplotstableread@filename' has non-unique column name '#1'. Only the first occurence can be accessed via column names.}% - \edef\pgfplotstable@TMP{#1--index\the\pgfplotstableread@curcol}% + \pgfplots@warning{Table '\pgfplotstableread@filename' has non-unique column name '#1'. Only the first occurence can be accessed via column names.}% + \edef\pgfplotstable@loc@TMPa{#1--index\the\pgfplotstableread@curcol}% }% \expandafter\def\csname pgfplotstableread@impl@COLNAME@#1\endcsname{foo}% remember this name. - \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@TMP}\to\pgfplotstable@colnames + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames + \ifpgfplots@tableread@to@listener + % create an associative container colindex -> colname + % for use in a listener. + \def\pgfplots@loc@TMPb{% + \expandafter\def\csname pgfplotstblread@colindex@for@name#1\endcsname}% + \expandafter\pgfplots@loc@TMPb\expandafter{\the\pgfplotstableread@curcol}% + \fi \advance\pgfplotstableread@curcol by1\relax } @@ -659,7 +1303,7 @@ \pgfplotstableread@NEXT } -\def\pgfplotstable@error#1{\PackageError{numtable}{#1}{Please refer to the manual for further information.}}% +\def\pgfplotstable@error#1{\pgfplots@error{#1}}% \def\pgfplotstableset{% @@ -675,11 +1319,11 @@ % returned into #1. % % Otherwise, \ifpgfplotstableread@foundcolnames is set to true. -\def\pgfplotstabletypeset@is@colname#1{% +\def\pgfplotstable@is@colname#1{% \expandafter\pgfplotstabletypeset@is@colname@#1\pgfplotstable@EOI \ifpgfplotstableread@foundcolnames \else - \let#1=\pgfplotstable@TMP + \let#1=\pgfplotstable@loc@TMPa \fi }% \def\pgfplotstabletypeset@is@colname@{% @@ -692,20 +1336,71 @@ } \def\pgfplotstabletypeset@is@colname@index@@{index}% \def\pgfplotstabletypeset@is@colname@index[#1]#2\pgfplotstable@EOI{% - \def\pgfplotstable@TMP{#1}% - \ifx\pgfplotstable@TMP\pgfplotstabletypeset@is@colname@index@@ + \def\pgfplotstable@loc@TMPa{#1}% + \ifx\pgfplotstable@loc@TMPa\pgfplotstabletypeset@is@colname@index@@ \pgfplotstableread@foundcolnamesfalse - \def\pgfplotstable@TMP{#2}% + \def\pgfplotstable@loc@TMPa{#2}% \else \pgfplotstableread@foundcolnamestrue \fi }% \def\pgfplotstabletypeset@is@colname@name#1\pgfplotstable@EOI{}% + \def\pgfplotstabletypeset@getfinalentry#1#2{% - \pgfkeysvalueof{/pgfplots/table/assign cell content/.@cmd}#1\pgfeov - \pgfkeysgetvalue{/pgfplots/table/@cell content}{#2}% + \begingroup + \def\pgfplotstablepartno{0}% + \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}% + \pgfkeysvalueof{/pgfplots/table/preproc cell content/.@cmd}#1\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + % + \pgfkeysgetvalue{/pgfplots/table/assign cell content/.@cmd}\pgfplotstable@assigncell + \expandafter\pgfplotstable@assigncell\pgfmathresult\pgfeov + % + \pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent + \ifx\pgfplotstable@postproccellcontent\pgfplotstable@postproccellcontent@EMPTY + \else + % apply postprocessing to final cell content. + % This is complicated if there is an '&' in '@cell content', + % so handle that specially! + % + % FIXME also support more than one '&' ? + \def\pgfplotstabletypeset@rawinput{#1}% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}% + \ifpgfutil@in@ + \expandafter\pgfplotstabletypeset@postproc@separately\pgfmathresult\pgfplotstable@EOI + \else + \pgfplotstable@postproccellcontent#1\pgfeov + \fi + \fi + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let#2=\pgfmathresult }% +% This routine invokes 'postproc cell content' for columns which +% contain the column separate '&'. +% +% #1 is the formatted number, the result of 'dec sep align +% #3 is the (unformatted) input number. +\def\pgfplotstabletypeset@postproc@separately#1\pgfplotstable@EOI{% + \def\pgfmathresult{#1}% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfplotstable@entry@a + % + \def\pgfplotstablepartno{1}% + \def\pgfmathresult{#2}% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry@a}% + \t@pgfplots@tokb=\expandafter{\pgfmathresult}% + \edef\pgfmathresult{\the\t@pgfplots@toka&\the\t@pgfplots@tokb}% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult +} + % processes the option 'assign column name' \def\pgfplotstabletypeset@assign@final@colname#1#2{% \pgfkeysifdefined{/pgfplots/table/assign column name/.@cmd}{% @@ -730,18 +1425,38 @@ }% +\def\pgfplotstable@insertemptycells@forbalance{% + \pgfutil@loop + \ifnum\c@pgfplotstable@counta<\pgfplotstable@firstnumrows\relax + % let's hope @getfinalentry handles empty strings! + \pgfplotstabletypeset@getfinalentry{}{\pgfplotstable@entry}% + \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed + \pgfplotslistpushback\to\pgfplotstable@col@processed + \advance\c@pgfplotstable@counta by1\relax + \pgfutil@repeat +} + % TODO % - replace grouped list foreach by popfront-loop and use arrays % directly -> group only the pgfkeys eval \def\pgfplotstabletypeset@opt[#1]#2{% \begingroup + %-------------------------------------------------- + % \pgfutil@ifundefined{#2}{% + % \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}'?}% + % \pgfplotslistnewempty#2 + % }{}% + %-------------------------------------------------- \def\pgfplotstablecol{\the\c@pgfplotstable@colindex}% \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}% -% \def\pgfplotstablecols{\the\c@pgfplotstable@numcols}% -% \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}% + \def\pgfplotstablecols{\the\c@pgfplotstable@numcols}% + \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}% \ifpgfplots@table@options@areset \else - \pgfplotstableset{/pgfplots/table/every table,#1}% + \pgfplotstablegetname{#2}\pgfplotstable@loc@TMPa + \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% + \edef\pgfplotstable@loc@TMPa{/pgfplots/table/every table={\the\t@pgfplots@toka}}% + \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa,#1}% \fi \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% \ifx\pgfplotstable@colnames\pgfutil@empty @@ -757,37 +1472,55 @@ \let\c@pgfplotstable@rowindex=\c@pgf@countc \let\c@pgfplotstable@colindex=\c@pgf@countb \pgfplotslistsize\pgfplotstable@colnames\to\c@pgfplotstable@numcols + \def\pgfplotstable@firstnumrows{-1}% + \c@pgfplotstable@numrows=-1\relax \c@pgfplotstable@colindex=0\relax \pgfplotslistforeach\pgfplotstable@colnames\as\pgfplotstable@colname{% \c@pgfplotstable@rowindex=0\relax - \pgfplotstabletypeset@is@colname\pgfplotstable@colname + \pgfplotstable@is@colname\pgfplotstable@colname \ifpgfplotstableread@foundcolnames \else \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#2\to\pgfplotstable@colname \fi \pgfplotstablegetcolumnbyname\pgfplotstable@colname\of#2\to\pgfplotstable@col % + % Init number of *input* rows here. This may not be the same + % as the number of *output* rows (see the row predicate + % below). + % + % Accessable with \pgfplotstablerows in style keys. + \ifnum\c@pgfplotstable@numrows=-1\relax + \pgfplotslistsize\pgfplotstable@col\to\c@pgfplotstable@numrows + \global\c@pgfplotstable@numrows=\c@pgfplotstable@numrows + \fi + % % Set keys for columns! \ifodd\c@pgfplotstable@colindex - \pgfplotslist@TOK@a={every odd column}% + \t@pgfplots@toka={every odd column}% \else - \pgfplotslist@TOK@a={every even column}% + \t@pgfplots@toka={every even column}% \fi \ifnum\c@pgfplotstable@colindex=0\relax - \pgfplotslist@TOK@a=\expandafter{\the\pgfplotslist@TOK@a,every first column}% + \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}% + % \global\advance\c@pgfplotstable@colindex by1\relax \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols - \pgfplotslist@TOK@a=\expandafter{\the\pgfplotslist@TOK@a,every last column}% + \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last column}% \fi - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@colname}% - \expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\pgfplotslist@TOK@b\pgfplotstable@EOI + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname}% + \expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\t@pgfplots@tokb\pgfplotstable@EOI \ifpgfutil@in@ - \edef\pgfplotstable@TMP{\the\pgfplotslist@TOK@a,columns/{\the\pgfplotslist@TOK@b}/.try}% + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/{\the\t@pgfplots@tokb}/.try}% \else - \edef\pgfplotstable@TMP{\the\pgfplotslist@TOK@a,columns/\the\pgfplotslist@TOK@b/.try}% + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/\the\t@pgfplots@tokb/.try}% \fi - \expandafter\pgfplotstableset\expandafter{\pgfplotstable@TMP}% + \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 @@ -803,16 +1536,35 @@ }% % \pgfplotslistnewempty\pgfplotstable@col@processed + \c@pgfplotstable@counta=0 \pgfplotslistforeachungrouped\pgfplotstable@col\as\pgfplotstable@entry{% \pgfplotstableuserowtrue - \edef\pgfplotstable@TMP{\noexpand\pgfkeysvalueof{/pgfplots/table/row predicate/.@cmd}\the\c@pgfplotstable@rowindex}% - \pgfplotstable@TMP\pgfeov + \edef\pgfplotstable@loc@TMPa{\noexpand\pgfkeysvalueof{/pgfplots/table/row predicate/.@cmd}\the\c@pgfplotstable@rowindex}% + \pgfplotstable@loc@TMPa\pgfeov \ifpgfplotstableuserow - \expandafter\pgfplotstabletypeset@getfinalentry\expandafter{\pgfplotstable@entry}{\pgfplotstable@entry}% - \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed + \ifnum\pgfplotstable@firstnumrows=-1\relax + \else + \ifnum\c@pgfplotstable@counta=\pgfplotstable@firstnumrows + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname@out}% + \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)}% + \pgfplotstableuserowfalse + \fi + \fi + \ifpgfplotstableuserow + \expandafter\pgfplotstabletypeset@getfinalentry\expandafter{\pgfplotstable@entry}{\pgfplotstable@entry}% + \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed + \advance\c@pgfplotstable@counta by1\relax + \fi \fi \advance\c@pgfplotstable@rowindex by1\relax }% + \ifnum\pgfplotstable@firstnumrows=-1\relax + \xdef\pgfplotstable@firstnumrows{\the\c@pgfplotstable@counta}% + \else + % balance columns: + \pgfplotstable@insertemptycells@forbalance + \fi {\globaldefs=1 \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols }% @@ -834,25 +1586,25 @@ % STEP 1.1: collect column types: \def\pgfplotstable@resulttypes{}% \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@coltypes\as\pgfplotstable@coltype{% - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@resulttypes}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@coltype}% - \edef\pgfplotstable@resulttypes{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \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}% - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@entry}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}% \ifx\pgfplotstable@resulttypes\pgfutil@empty - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@a}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka}% \else - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@resulttypes}% - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@a{\the\pgfplotslist@TOK@b}}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@resulttypes}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}% \fi % \pgfkeysgetvalue{/pgfplots/table/font}{\pgfplotstable@font}% \ifx\pgfplotstable@font\pgfutil@empty \else - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@font}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@result}% - \edef\pgfplotstable@result{\noexpand\begingroup\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \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}% \fi % @@ -861,33 +1613,33 @@ \pgfplotstableset{every head row}% \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}% \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}% - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@before}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@after}% - \xdef\pgfplotstable@TMP{% - \noexpand\def\noexpand\pgfplotstable@before{\the\pgfplotslist@TOK@a}% - \noexpand\def\noexpand\pgfplotstable@after{\the\pgfplotslist@TOK@b}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% + \xdef\pgfplots@glob@TMPc{% + \noexpand\def\noexpand\pgfplotstable@before{\the\t@pgfplots@toka}% + \noexpand\def\noexpand\pgfplotstable@after{\the\t@pgfplots@tokb}% }% \endgroup - \pgfplotstable@TMP + \pgfplots@glob@TMPc % insert 'before row' here: - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@before}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@result}% - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@b\the\pgfplotslist@TOK@a}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@result}% + \edef\pgfplotstable@result{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% % \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@colnames\as\pgfplotstable@colname@out{% \advance\c@pgfplotstable@colindex by1\relax - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@colname@out \\}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname@out \\}% \else - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@colname@out &}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname@out &}% \fi - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% }% % insert 'after row' here: - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@after}% - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% % %\message{I have now \meaning\pgfplotstable@result.}% % Step 2: column contents. @@ -910,92 +1662,94 @@ \else \pgfplots@loop@CONTINUEfalse \fi - \loop + \pgfutil@loop \ifpgfplots@loop@CONTINUE \pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed \pgfplotslistcheckempty\pgfplotstable@col@processed \ifpgfplotslistempty + % assume that each column has the same number of entries + % (normalised tables): \pgfplots@loop@CONTINUEfalse \else \ifnum\c@pgfplotstable@colindex=0\relax % Install styles for the next row. \begingroup \ifodd\c@pgfplotstable@rowindex - \pgfplotslist@TOK@a={every odd row}% + \t@pgfplots@toka={every odd row}% \else - \pgfplotslist@TOK@a={every even row}% + \t@pgfplots@toka={every even row}% \fi \ifnum\c@pgfplotstable@rowindex=0\relax - \pgfplotslist@TOK@a=\expandafter{\the\pgfplotslist@TOK@a,every first row}% + \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first row}% \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@TMP{\the\pgfplotslist@TOK@a,every row no \the\c@pgfplotstable@rowindex/.try,every last row}% + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,every row no \the\c@pgfplotstable@rowindex/.try,every last row}% \else - \edef\pgfplotstable@TMP{\the\pgfplotslist@TOK@a,every row no \the\c@pgfplotstable@rowindex/.try}% + \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,every row no \the\c@pgfplotstable@rowindex/.try}% \fi - \expandafter\pgfplotstableset\expandafter{\pgfplotstable@TMP}% + \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}% \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}% \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}% - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@before}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@after}% - \xdef\pgfplotstable@TMP{% - \noexpand\def\noexpand\pgfplotstable@before{\the\pgfplotslist@TOK@a}% - \noexpand\def\noexpand\pgfplotstable@after{\the\pgfplotslist@TOK@b}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% + \xdef\pgfplots@glob@TMPc{% + \noexpand\def\noexpand\pgfplotstable@before{\the\t@pgfplots@toka}% + \noexpand\def\noexpand\pgfplotstable@after{\the\t@pgfplots@tokb}% }% \endgroup - \pgfplotstable@TMP + \pgfplots@glob@TMPc % insert 'before row' here: - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@before}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@result}% - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@b\the\pgfplotslist@TOK@a}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@before}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@result}% + \edef\pgfplotstable@result{\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 - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@entry \\}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry \\}% \else - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@entry &}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry &}% \fi - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \edef\pgfplotstable@result{\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: - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@after}% - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% \advance\c@pgfplotstable@rowindex by1\relax \fi %\message{I have now \meaning\pgfplotstable@result.}% \fi - \repeat - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}% + \pgfutil@repeat + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% \pgfkeysgetvalue{/pgfplots/table/end table}{\pgfplotstable@entry}% - \pgfplotslist@TOK@b=\expandafter{\pgfplotstable@entry}% - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@a\the\pgfplotslist@TOK@b}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% \ifx\pgfplotstable@font\pgfutil@empty \else - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result\endgroup}% - \edef\pgfplotstable@result{\the\pgfplotslist@TOK@a}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@result\endgroup}% + \edef\pgfplotstable@result{\the\t@pgfplots@toka}% \fi \ifpgfplotstabletypesetdebug - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% \immediate\write16{------- PGFPLOTSTABLE DEBUG MODE: --------}% - \immediate\write16{{\the\pgfplotslist@TOK@a}}% + \immediate\write16{{\the\t@pgfplots@toka}}% \fi \pgfkeysgetvalue{/pgfplots/table/outfile}{\pgfplotstable@entry}% \ifx\pgfplotstable@entry\pgfutil@empty \else \begingroup \immediate\openout\pgfplotstable@outfile=\pgfplotstable@entry\relax - \pgfplotslist@TOK@a=\expandafter{\pgfplotstable@result}% - \immediate\write\pgfplotstable@outfile{\the\pgfplotslist@TOK@a}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@result}% + \immediate\write\pgfplotstable@outfile{\the\t@pgfplots@toka}% \immediate\closeout\pgfplotstable@outfile \endgroup \fi @@ -1003,5 +1757,130 @@ \endgroup }% +\newif\ifpgfplotstable@isfirstrow +\newif\ifpgfplotstable@islastrow +\newif\ifpgfplotstablecreatecol@isreallynew + +\def\pgfplotstablecreatecol@opt[#1]#2#3{% + \begingroup + \pgfplotstableset{columns=,#1}% + \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% + \ifx\pgfplotstable@colnames\pgfutil@empty + \pgfplotstablegetcolumnlist#3\to\pgfplotstable@colnames + \else + \expandafter\pgfplotslistnew\expandafter\pgfplotstable@colnames\expandafter{\pgfplotstable@colnames}% + \fi + \pgfplotslistnewempty\pgfplotstable@colnames@real + \t@pgfplots@toka=\expandafter{#2}% this should handle macro names in '#2'. + \edef\pgfplotstable@newcolname{\the\t@pgfplots@toka}% + \global\pgfplotstablecreatecol@isreallynewtrue + \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{% + \pgfplotstable@is@colname\pgfplotstable@colname + \ifpgfplotstableread@foundcolnames + \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@colname}\to\pgfplotstable@colnames@real + \else + \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#2\to\pgfplotstable@colname + \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@colname}\to\pgfplotstable@colnames@real + \fi + \ifx\pgfplotstable@colname\pgfplotstable@newcolname + \global\pgfplotstablecreatecol@isreallynewfalse + \fi + }% + \pgfplotstable@isfirstrowtrue + \pgfplotstable@islastrowfalse + \pgfplotslistnewempty\pgfplotstable@newcol + % + \let\c@pgfplotstable@numrows=\c@pgf@countd + \let\c@pgfplotstable@rowindex=\c@pgf@countc + \c@pgfplotstable@numrows=-1\relax + \c@pgfplotstable@rowindex=0\relax + \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}% + \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}% + % + \def\prevrow##1{\csname pgfplotstablecreate@prev@##1\endcsname}% + \def\thisrow##1{\csname pgfplotstablecreate@cur@##1\endcsname}% + \def\nextrow##1{\csname pgfplotstablecreate@next@##1\endcsname}% + \def\getprevrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@prev@##1\endcsname}% + \def\getthisrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@cur@##1\endcsname}% + \def\getnextrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@next@##1\endcsname}% + % + \pgfplots@loop@CONTINUEtrue + % allow this here to accumulate something. + \let\pgfmathaccuma=\pgfutil@empty + \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 + \pgfplotslistfront\pgfplotstable@colnames\to\pgfplotstable@colname + \expandafter\pgfplotslistsize\csname\string#3@\pgfplotstable@colname\endcsname\to\c@pgfplotstable@numrows + \fi + \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{% + \expandafter\pgfplotstableresolvecolname\expandafter{\pgfplotstable@colname}\of#3\to\pgfplotstable@real@colname + \ifpgfplotstable@isfirstrow + \expandafter\pgfplotslistcheckempty\csname\string#3@\pgfplotstable@real@colname\endcsname + \ifpgfplotslistempty + % the table is completely empty. break. + \pgfplots@loop@CONTINUEfalse + \else + \expandafter\let\csname pgfplotstablecreate@prev@\pgfplotstable@colname\endcsname=\pgfutil@empty + \expandafter\pgfplotslistpopfront\csname\string#3@\pgfplotstable@real@colname\endcsname\to\pgfplotstable@entry + \expandafter\let\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname=\pgfplotstable@entry + \fi + \else + \expandafter\let\expandafter\pgfplotstable@prev\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname + \expandafter\let\csname pgfplotstablecreate@prev@\pgfplotstable@colname\endcsname=\pgfplotstable@prev + % + \expandafter\let\expandafter\pgfplotstable@next\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname + \expandafter\let\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname=\pgfplotstable@next + \fi + \expandafter\pgfplotslistcheckempty\csname\string#3@\pgfplotstable@real@colname\endcsname + \ifpgfplotslistempty + \expandafter\let\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname=\pgfutil@empty + \pgfplotstable@islastrowtrue + \else + \expandafter\pgfplotslistpopfront\csname\string#3@\pgfplotstable@real@colname\endcsname\to\pgfplotstable@entry + \expandafter\let\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname=\pgfplotstable@entry + \fi + }% + \ifpgfplots@loop@CONTINUE + % Compute content: + % + \begingroup + \ifpgfplotstable@isfirstrow + \pgfkeysvalueof{/pgfplots/table/create col/assign first/.@cmd}\pgfeov + \else + \ifpgfplotstable@islastrow + \pgfkeysvalueof{/pgfplots/table/create col/assign last/.@cmd}\pgfeov + \else + \pgfkeysvalueof{/pgfplots/table/create col/assign/.@cmd}\pgfeov + \fi + \fi + \pgfkeysgetvalue{/pgfplots/table/create col/next content}{\pgfplotstable@entry}% + \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}% + \t@pgfplots@tokb=\expandafter{\pgfmathaccuma}% + \xdef\pgfplots@glob@TMPc{% + \noexpand\def\noexpand\pgfplotstable@entry{\the\t@pgfplots@toka}% + \noexpand\def\noexpand\pgfmathaccuma{\the\t@pgfplots@tokb}% + }% + \pgfmath@smuggleone\pgfmathaccumb + \endgroup + \pgfplots@glob@TMPc + \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@entry}\to\pgfplotstable@newcol + % + \ifpgfplotstable@islastrow + \pgfplots@loop@CONTINUEfalse + \fi + \fi + \pgfplotstable@isfirstrowfalse + \advance\c@pgfplotstable@rowindex by1\relax + \pgfutil@repeat + \global\let\pgfplots@glob@TMPc=\pgfplotstable@newcol + \global\let\pgfplots@glob@TMPb=\pgfplotstable@newcolname + \endgroup + \ifpgfplotstablecreatecol@isreallynew + \expandafter\pgfplotslistpushback\expandafter{\pgfplots@glob@TMPb}\to#3 + \fi + \expandafter\let\csname\string#3@\pgfplots@glob@TMPb\endcsname=\pgfplots@glob@TMPc +}% \endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex new file mode 100644 index 00000000000..ce780e866b2 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex @@ -0,0 +1,12 @@ +%-------------------------------------------------- +% \pgfutil@ifundefined{pgfmathfloattosci} +% {}% +% {\endinput}% +%-------------------------------------------------- +\pgfkeysifdefined{/pgf/number format/@dec sep mark}{\endinput}{} + +\immediate\write16{Package pgfplots: loading complementary code for your PGF version...} +\input pgfplotsoldpgfsupp_misc.code.tex +\input pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex +\input pgfplotsoldpgfsupp_pgfmathfloat.code.tex +\input pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex new file mode 100644 index 00000000000..def32476da4 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex @@ -0,0 +1,174 @@ + +% ====================================================== +% compatibility with PGF 2.0 +\def\pgfkeysaddvalue#1#2#3{% + {% + \toks0{#2}% + \pgfkeysifdefined{#1} + {\pgfkeys@temptoks\expandafter\expandafter\expandafter{\csname pgfk@#1\endcsname}}% + {\pgfkeys@temptoks{}}% + \toks1{#3}% + \xdef\pgfkeys@global@temp{\the\toks0 \the\pgfkeys@temptoks \the\toks1}% believe or don't: the spaces are important + }% + \pgfkeyslet{#1}\pgfkeys@global@temp% +} + +\def\pgfkeys@try{% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% + {% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@code}% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyscurrentpath/.@def}% + {\pgfkeysgetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeyscurrentvalue}} + {}% no default, so leave it + \fi% + \let\pgfkeyscurrentkey=\pgfkeyscurrentpath% make sure that \pgfkeys@code doesn't know about 'try'. Important for .is choice + % FIXME: maybe there are more things like that - also adjust currentname!? + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% + \pgfkeyssuccesstrue% + }% + {% + \pgfkeysifdefined{\pgfkeyscurrentpath}% + {% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \pgfkeysvalueof{\pgfkeyscurrentpath}% + \else% + \pgfkeyslet{\pgfkeyscurrentpath}\pgfkeyscurrentvalue% + \fi% + \pgfkeyssuccesstrue% + }% + {\pgfkeyssuccessfalse}% + }% +} +% ====================================================== + + +% pgfutil@loop (from plain.tex) + +\def\pgfutil@loop#1\pgfutil@repeat{\def\pgfutil@body{#1}\pgfutil@iterate} +\def\pgfutil@iterate{\pgfutil@body \let\pgfutil@next\pgfutil@iterate \else\let\pgfutil@next\relax\fi \pgfutil@next} +\let\pgfutil@repeat=\fi % this makes \loop...\if...\repeat skippable + +\def\pgfqpointxy#1#2{% + \pgf@x=#1\pgf@xx% + \advance\pgf@x by #2\pgf@yx% + \pgf@y=#1\pgf@xy% + \advance\pgf@y by #2\pgf@yy} +\def\pgfqpointxyz#1#2#3{% + \pgf@x=#1\pgf@xx% + \advance\pgf@x by #2\pgf@yx% + \advance\pgf@x by #3\pgf@zx% + \pgf@y=#1\pgf@xy% + \advance\pgf@y by #2\pgf@yy% + \advance\pgf@y by #3\pgf@zy} +\def\pgfcoordinate#1#2{% + \edef\pgf@temp{#1}% + \ifx\pgf@temp\pgfutil@empty% do nothing + \else% + \pgf@process{\pgfpointtransformed{#2}}% + \expandafter\gdef\csname pgf@sh@ns@#1\endcsname{coordinate}% + \expandafter\xdef\csname pgf@sh@np@#1\endcsname{% + \noexpand\def\noexpand\centerpoint{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + } + \expandafter\gdef\csname pgf@sh@nt@#1\endcsname{{1}{0}{0}{1}{0pt}{0pt}}% + \expandafter\global\expandafter\let\csname pgf@sh@ma@#1\endcsname\pgfutil@empty% + \expandafter\gdef\csname pgf@sh@pi@#1\endcsname{\pgfpictureid}% + \fi% +} +% ====================================================== + +\def\pgfutilensuremath#1{% + \ifmmode#1\else$#1$\fi +} + +\tikzoption{ybar}[]{\let\tikz@plot@handler=\pgfplothandlerybar} +\tikzoption{xbar}[]{\let\tikz@plot@handler=\pgfplothandlerxbar} +\tikzoption{ybar interval}[]{\let\tikz@plot@handler=\pgfplothandlerybarinterval} +\tikzoption{xbar interval}[]{\let\tikz@plot@handler=\pgfplothandlerxbarinterval} +\tikzoption{const plot}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto} +\tikzoption{const plot mark left}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto} +\tikzoption{const plot mark right}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkright} +\tikzoption{jump mark right}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkright} +\tikzoption{jump mark left}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkleft} + +% the 'every mark' style is new: +\tikzset{ + every mark/.style={}, + mark options/.style={% + every mark/.style={#1}% + }} +\def\tikz@@@plot{% + \def\pgfplotlastpoint{\pgfpointorigin}% + \tikz@plot@handler% + \tikz@plot@data% + \global\let\tikz@@@temp=\pgfplotlastpoint% + \ifx\tikz@plot@mark\pgfutil@empty% + \else% + % Marks are drawn after the path. + \setbox\tikz@figbox=\hbox{% + \unhbox\tikz@figbox% + \hbox{{% + \pgfinterruptpath% + \pgfscope% + \let\tikz@options=\pgfutil@empty% + \let\tikz@transform=\pgfutil@empty% + \tikzset{every mark}% + \tikz@options% + \ifx\tikz@mark@list\pgfutil@empty% + \pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}% + \else + \pgfplothandlermarklisted{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}{\tikz@mark@list}% + \fi + \tikz@plot@data% + \endpgfscope + \endpgfinterruptpath% + }}% + }% + \fi% + \global\setbox\tikz@tempbox=\copy\tikz@figbox% + %\global\let\tikz@after@path@smuggle=\tikz@after@path + \endgroup% + \setbox\tikz@figbox=\box\tikz@tempbox% + \tikz@make@last@position{\tikz@@@temp}% + %\expandafter\tikz@scan@next@command\tikz@after@path@smuggle% + \tikz@scan@next@command% +} + + + + +% ====================================================== + + +\newif\ifpgfmathcomparison + +% Assigns \pgfmathresult to 1.0 if #1 ~= #1. +% +% It will also set the boolean \ifpgfmathcomparison accordingly +% (globally). +\def\pgfmathapproxequalto#1#2{% + \edef\pgfmath@marshal{% + \noexpand\pgfmathparse{#2} + \noexpand\let\noexpand\pgfmath@arg\noexpand\pgfmathresult% + \noexpand\pgfmathparse{#1}% + }% + \pgfmath@marshal% + \pgfmathapproxequalto@{\pgfmathresult}{\pgfmath@arg}} +\def\pgfmathapproxequalto@#1#2{% + \begingroup% + \pgfmath@x#1pt% + \pgfmath@y#2pt% + \advance\pgfmath@x-\pgfmath@y% + \ifdim\pgfmath@x<0pt + \multiply\pgfmath@x by-1 + \fi + \ifdim\pgfmath@x<0.0001pt\relax% + \def\pgfmathresult{1.0}% + \global\pgfmathcomparisontrue + \else% + \def\pgfmathresult{0.0}% + \global\pgfmathcomparisonfalse + \fi% + \pgfmath@smuggleone\pgfmathresult + \endgroup% +} diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex new file mode 100644 index 00000000000..ed490784564 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex @@ -0,0 +1,928 @@ +% Copyright 2008 by Christian Feuersaenger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. +% +% This file contains additions to pgfkeys.code.tex (loaded +% automatically at the end of pgfkeys.code.tex) +% +% Improvements: +% +% - option filtering +% you provide +% - a boolean predicate +% - a "filter handler" which will be invoked for non-matching options, +% - a key=value list as usual. +% The filter sets only matching options and invokes the handler for +% unmatching ones. +% +% - Fast family support as in xkeyval. +% - A key like /my tree/my option can be associated with /my family +% - You can efficiently set keys which belong to a set of "active" +% families. +% Remaining options can be collected into a macro. + +% WARNING: +% this file overwrites +% \pgfkeys@addpath +% \pgfkeys@nevermind +% +% all other features are 'additive' + + +% these implementations will be switched dynamically with their +% filtered versions (in \pgfkeys@install@filter@and@invoke) +\let\pgfkeys@orig@case@one=\pgfkeys@case@one +\let\pgfkeys@orig@@set=\pgfkeys@@set +\let\pgfkeys@orig@@qset=\pgfkeys@@qset +\let\pgfkeys@orig@try=\pgfkeys@try +\let\pgfkeys@orig@unknown=\pgfkeys@unknown + +\newif\ifpgfkeysfilteringisactive +\newif\ifpgfkeysfiltercontinue +\let\pgfkeys@key@predicate=\pgfkeys@empty +\let\pgfkeys@filtered@handler=\pgfkeys@empty +\newtoks\pgfkeys@tmptoks + +% Performs 'filtered' key settings. +% +% For every option for which the path prefixing has already been done, +% the current key filter predicate will be invoked. If the predicate +% returns true, pgfkeys will process this key in the normal manner. +% If not, a key filter handler will be invoked. +% +% The *predicate* and *handler* semantics are as follows: +% PRECONDITION: +% 1. The variables +% \pgfkeyscurrentkey (full path including name) +% \pgfkeyscurrentkeyRAW (the current key as it has been +% found in the key=value list +% without path modification) +% \pgfkeyscurrentvalue +% are all set. If the current key is a handler variable, +% \pgfkeyscurrentname +% and +% \pgfkeyscurrentpath +% are also set. +% 2. The type of option has already been checked, that means +% case (1) whether '.@cmd' exists +% case (2) whether the key as such has its value +% case (3) it is a handler like '.code', '.cd' or whatever. +% case (0) it is unknown. +% The actual case number (0-3) will be provided as contents +% of the macro +% \pgfkeyscasenumber. +% Please note that unknown options will be processed with +% the usual '.unknown' handlers unless the key filter takes +% control over unknown options as well. +% +% POSTCONDITION: +% the predicate sets +% \pgfkeysfiltercontinuetrue +% or +% \pgfkeysfiltercontinuefalse +% (the boolean \ifpgfkeysfiltercontinue). +% Depending on this 'if', option processing will be continued or +% skipped. +% +% The handler can do anything with the option, for example collect +% unmatched ones. +% +% ATTENTION: \pgfkeysfiltered can't be nested (yet). Use the +% \pgfkeyspredicateAND if you need multiple predicates at once. +% Nesting would produce unexpected results because the current filter +% state can't be stored/restored without TeX-groups, therefor it is +% disabled. +% +% ATTENTION: you can't filter error messages. +% +% REMARK: In case (3), the macros \pgfkeyscurrentpath and +% \pgfkeyscurrentname have already been computed, you do not need to +% invoke \pgfkeyssplitpath. In any other case, neither path nor name +% are required for the options processing - if you need them for +% predicates/handlers, you need to compute them by hand. +% +% +% Example: +% \def\unmatched{} +% \pgfkeys{/pgf/key filters/is descendant of/.install key filter=/my group} +% \pgfkeys{/pgf/key filter handlers/append filtered to/.install key filter handler=\unmatched} +% \pgfkeysfiltered% +% {/my group/option 1=value 1,/tikz/option 2=value 2} +% -> +% will set '/my group/option 1' as usual, but '/tikz/option 2' will not +% be set. Instead, it will be appended to '\unmatched' such that +% \unmatched = {/tikz/option 2=value2} +% after the operation. +% +% Arguments: +% #1: key-value list. +\def\pgfkeysfiltered{% + % produce + % '{}' + % each expanded exactly one time into the register: + \expandafter\pgfkeysfiltered@@install\expandafter{\pgfkeysdefaultpath}% +} + +% #1: old value of default path. +% #2: key-value-list. +\def\pgfkeysfiltered@@install#1#2{% + \pgfkeys@install@filter@and@invoke{% + \let\pgfkeysdefaultpath\pgfkeys@root% + \pgfkeys@parse#2,\pgfkeys@mainstop% + \def\pgfkeysdefaultpath{#1}% + }% +} + +% Assuming that macro #1 contains a key=value list, this command +% performs an \pgfkeysalso command for the content of macro #1. +% +% It can be used in conjunction with +% - \pgfkeysfiltered and +% - \pgfkeysappendfilterednamestomacro: +% the first pass fill only process options matching the filter, then, +% a \pgfkeysalsofrom can be used at a later time to set the remaining +% options. +% +% Example: +% \pgfkeys{/my group/.cd,/utils/exec=\pgfkeysalsofrom\filtered} +\def\pgfkeysalsofrom#1{% + \expandafter\pgfkeysalso\expandafter{#1}% +} + +% The same as \pgfkeysalsofrom, but it invokes \pgfkeysalsofiltered. +\def\pgfkeysalsofilteredfrom#1{% + \expandafter\pgfkeysalsofiltered\expandafter{#1}% +} + +% #1 = options +\long\def\pgfkeysalsofiltered#1{% + \pgfkeys@install@filter@and@invoke{\pgfkeysalso{#1}}% +}% + +% The same like \pgfkeysfiltered, but with quick search path setting. +% +% #1: default path +% #2: key-value-pairs +\def\pgfqkeysfiltered#1{% + \expandafter\pgfqkeysfiltered@@install\expandafter{\pgfkeysdefaultpath}{#1}% +} + +% #1: old value of default path. +% #2: default path +% #3: key-value-list. +\def\pgfqkeysfiltered@@install#1#2#3{% + \pgfkeys@install@filter@and@invoke{% + \def\pgfkeysdefaultpath{#2/}\pgfkeys@parse#3,\pgfkeys@mainstop\def\pgfkeysdefaultpath{#1}% + }% +} + +% Family management +% +% The family code provides the following features: +% 1. every key can be associated with 0 or 1 'family'. +% 2. Families are a loose association which are independend of the key +% hierarchy. +% For example, /my tree/key1 can belong to family /tikz. +% +% 3. It is possible to "activate" or "deactivate" single families. +% Furthermore, it is possible to set only keys which belong to +% active families (using \pgfkeysfiltered). +% 4. Runtime complexities: +% If you have N options and you only want to process K active +% families, the runtime is O( N + K ): +% - activate every family O(K) +% - use \pgfkeyshasactivefamily as filter predicate O(N) +% - deactivate every family O(K) + + +% Activates family #1. +% +% #1 maybe a macro. +\def\pgfkeysactivatefamily#1{% + \pgfkeysiffamilydefined + {#1}% + {\csname pgfk@#1/familyactivetrue\endcsname}% + {\pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov}% +%\message{[ACTIVATING FAMILY #1]}% +} + +% Deactivates family #1. +% +% #1 maybe a macro. +\def\pgfkeysdeactivatefamily#1{ + \pgfkeysiffamilydefined + {#1}% + {\csname pgfk@#1/familyactivefalse\endcsname}% + {\pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov}% +%\message{[DEACTIVATING FAMILY #1]}% +} + +% Activates all families in the comma separated list #1. +% +% It will also generate code for deactivation of all those families +% into the command #2. +% +% #1: a comma-separated list of fully qualified family names. +% #2: a command which will be filled with a deactivate-all command. +\def\pgfkeysactivatefamilies#1#2{% + \pgfkeyssavekeyfilterstateto\pgfkeys@cur@state + \expandafter\pgfkeysactivatefamilies@impl\expandafter{\pgfkeys@cur@state}{#1}{#2}% +} +% #1: commands needed to restore the old filtering state +% #2: family name list +% #3: macro name for de-activate command +\def\pgfkeysactivatefamilies@impl#1#2#3{% + \pgfkeysinstallkeyfilter{/pgf/key filters/false}{}% + \let#3=\pgfkeys@empty% + \def\pgfkeys@filtered@handler{\pgfkeys@family@activate@handler{#3}}% + \pgfkeysalsofiltered{#2}% + #1% +} + +\def\pgfkeys@family@activate@handler#1{% + \pgfkeysactivatefamily{\pgfkeyscurrentkey}% + % produce + % '\pgfkeysdeactivatefamily{' '}' + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter#1\expandafter\pgfkeysdeactivatefamily\expandafter{\pgfkeyscurrentkey}}% + \edef#1{\the\pgfkeys@tmptoks}% +} + +% If for testing whether a family exists. +% +% #1 = fully qualified family name +% #2 = if-case +% #3 = else-case +% +% Description: +% +% If the family exists, #2 will be executed. Otherwise, #3 will be +% called. +\long\def\pgfkeysiffamilydefined#1#2#3{\pgfkeys@ifcsname ifpgfk@#1/familyactive\endcsname#2\else#3\fi} + +% Sets the TeX boolean +% \ifpgfkeysfiltercontinue := ( family #1 is active ) +% +% Argument: +% #1 the family name. Maybe a macro. +\def\pgfkeysisfamilyactive#1{% + \pgfkeysiffamilydefined{#1}{% + \expandafter\let\expandafter\ifpgfkeysfiltercontinue\csname ifpgfk@#1/familyactive\endcsname + }{% + \pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov% + \expandafter\expandafter\expandafter\let\csname ifpgfkeysfiltercontinue\endcsname\csname iffalse\endcsname + }% +}% + +% Retrieve the family of full key #1 into macro #2. +% +% Will set the TeX boolean \ifpgfkeyssuccess to whether the full key +% really has a family. +% +% The family for any key is stored in the sub-key #1/family. +% +% Parameters: +% #1: the full key name for which the family is requested. Maybe a +% macro. +% #2: a macro name which will be filled with the result. +\def\pgfkeysgetfamily#1#2{% + \pgfkeysifdefined{#1/family}{\pgfkeysgetvalue{#1/family}{#2}\pgfkeyssuccesstrue}{\pgfkeyssuccessfalse}% +} + + + +% Sets \ifpgfkeysfiltercontinue to true iff the current key belongs to +% the /errors tree. +\long\def\pgfkeys@cur@is@descendant@of@errors{% + \expandafter\pgfkeys@cur@is@descendant@of@errors@impl\pgfkeyscurrentkey/errors\pgf@@eov +}% +\long\def\pgfkeys@cur@is@descendant@of@errors@impl#1/errors#2\pgf@@eov{% + \def\pgfkeyspred@TMP{#1}% + \ifx\pgfkeyspred@TMP\pgfkeys@empty +%\message{[SPECIAL CHECK] '\pgfkeyscurrentkey' is descendant of '/errors': TRUE.}% + \pgfkeysfiltercontinuetrue + \else +%\message{[SPECIAL CHECK] '\pgfkeyscurrentkey' is descendant of '/errors': FALSE.}% + \pgfkeysfiltercontinuefalse + \fi +}% + +% \pgfkeysinterruptkeyfilter +% ... +% \endpgfkeysinterruptkeyfilter +% temporarily interrupts key filtering and enables it in +% \endpgfkeysinterruptkeyfilter. +% +% If key filtering it not active, this has no effect at all. +% +% REMARK: +% \pgfkeysinterruptkeyfilter...\endpgfkeysinterruptkeyfilter does NOT +% introduce a \TeX-group. +\def\pgfkeysinterruptkeyfilter{% + \ifpgfkeysfilteringisactive + \let\pgfkeys@case@one=\pgfkeys@orig@case@one + \let\pgfkeys@try=\pgfkeys@orig@try + \let\pgfkeys@unknown=\pgfkeys@orig@unknown + \fi +} + +\def\endpgfkeysinterruptkeyfilter{% + \ifpgfkeysfilteringisactive + \let\pgfkeys@case@one=\pgfkeys@case@one@filtered + \let\pgfkeys@try=\pgfkeys@try@filtered + \let\pgfkeys@unknown=\pgfkeys@unknown@filtered + \fi +} + +% Activates families #1, calls \pgfkeysfiltered and deactivates the +% families afterwards. +% +% REMARK: you need to install a family-based key filter predicate +% manually to benefit from the activated families! +% +% #1: comma separated family list +% #2: key-value pairs +% +% @see \pgfkeysactivatefamiliesandfilteroptions +\def\pgfkeysactivatefamiliesandfilteroptions#1#2{% + \pgfkeysactivatefamilies{#1}{\pgfkeys@family@deactivation}% + \pgfkeysfiltered{#2}% + \pgfkeys@family@deactivation +} + +% The "quick" variant of \pgfkeysactivatefamiliesandfilteroptions: it +% also assigns a default path. +% +% #1: comma separated family list +% #2: default path +% #3: key-value pairs +\def\pgfqkeysactivatefamiliesandfilteroptions#1#2#3{% + \pgfkeysactivatefamilies{#1}{\pgfkeys@family@deactivation}% + \pgfqkeysfiltered{#2}{#3}% + \pgfkeys@family@deactivation +} + +% Public version of split path: +\def\pgfkeyssplitpath{\pgfkeys@split@path}% + + +% The same as \pgfkeysactivatefamiliesandfilteroptions but just for +% ONE family. +% +% #1: family (maybe a macro) +% #2: key-value pairs +\def\pgfkeysactivatesinglefamilyandfilteroptions#1#2{% + \pgfkeysactivatefamily{#1}% + \pgfkeysfiltered{#2}% + \pgfkeysdeactivatefamily{#1}% +} + +% The "quick" variant of \pgfkeysactivatesinglefamilyandfilteroptions +% +% #1: family (maybe a macro) +% #2: default path +% #3: key-value pairs +\def\pgfqkeysactivatesinglefamilyandfilteroptions#1#2#3{% + \pgfkeysactivatefamily{#1}% + \pgfqkeysfiltered{#2}{#3}% + \pgfkeysdeactivatefamily{#1}% +} + +% Installs the key filter '#1' with argument '#2'. +% This is equivalent to +% \pgfkeys{#1/.install key filter=#2} +% +% The current values of the key filter handler is stored into the public +% macros +% \pgfkeyscurrentkeyfilter +% and +% \pgfkeyscurrentkeyfilterargs +% +% #1: a full key name; may be a macro +% #2: optional arguments for the key. If the key expects more than one +% argument, supply '{{first}{second}}' +\def\pgfkeysinstallkeyfilter#1#2{% + \pgfkeysifdefined{#1/.@cmd}{% + \edef\pgfkeyscurrentkeyfilter{#1}% + \def\pgfkeyscurrentkeyfilterargs{#2}% + \pgfkeysgetvalue{#1/.@cmd}{\pgfkeys@key@predicate@}% + \def\pgfkeys@key@predicate{\pgfkeys@key@predicate@#2\pgfeov}% + }{% + \pgfkeysvalueof{/errors/no such key filter/.@cmd}{#1}{#2}\pgfeov% + }% +} + +% Installs the key filter handler '#1' with argument '#2'. +% This is equivalent to +% \pgfkeys{#1/.install key filter handler=#2} +% +% The current values of the key filter handler is stored into the public +% macros +% \pgfkeyscurrentkeyfilterhandler +% and +% \pgfkeyscurrentkeyfilterhandlerargs +% +% #1: a full key name; may be a macro +% #2: optional arguments for the handler. If the handler expects more than one +% argument, supply '{{first}{second}}' +\def\pgfkeysinstallkeyfilterhandler#1#2{% + \pgfkeysifdefined{#1/.@cmd}{% + \edef\pgfkeyscurrentkeyfilterhandler{#1}% + \def\pgfkeyscurrentkeyfilterhandlerargs{#2}% + \pgfkeysgetvalue{#1/.@cmd}{\pgfkeys@filtered@handler@}% + \def\pgfkeys@filtered@handler{\pgfkeys@filtered@handler@#2\pgfeov}% + }{% + \pgfkeysvalueof{/errors/no such key filter handler/.@cmd}{#1}{#2}\pgfeov% + }% +} + +% Creates a macro which contains commands to re-activate the current +% key filter and key filter handler. It can be used to temporarily +% switch the key filter. +\def\pgfkeyssavekeyfilterstateto#1{% + % produce the string + % \pgfkeysinstallkeyfilter{...}{...} + % \pgfkeysinstallkeyfilterhandler{...}{...} + % where each argument is expanded once + % FIXME: Do the same with less overhead! + \pgfkeys@tmptoks={\pgfkeysinstallkeyfilter}% + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilter}}% + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterargs}\pgfkeysinstallkeyfilterhandler}% + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterhandler}}% + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterhandlerargs}}% + \edef#1{% + \the\pgfkeys@tmptoks + }% +} + + +\pgfkeys{% + /errors/family unknown/.code=\pgfkeys@error{% + Sorry, I do not know family '#1' and can't work with any assoicated family handling. Perhaps you misspelled it?}, + /errors/no such key filter/.code 2 args=\pgfkeys@error{Sorry, there is no such key filter '#1'.}, + /errors/no such key filter handler/.code 2 args=\pgfkeys@error{Sorry, there is no such key filter handler '#1'.}, + % HANDLERS: + % + % .is family should + % 1. '.cd' into the families' path, + % 2. define booleans to activate/deactive the family + % (see \pgfkeysisfamilyactive) + % 3. make sure that \pgfkeyshasactivefamily returns true for + % the family itsself. + /handlers/.is family/.append code={% + %\newif is an \outer macro in plain tex, so this here is not portable: + %\expandafter\newif\csname if\pgfkeyscurrentpath/familyactive\endcsname + \edef\pgfkeyspred@TMP{pgfk@\pgfkeyscurrentpath/familyactive}% + \expandafter\pgfkeys@non@outer@newif\expandafter{\pgfkeyspred@TMP}% + \edef\pgfkeyspred@TMP{\pgfkeyscurrentpath/.belongs to family=\pgfkeyscurrentpath}% + \expandafter\pgfkeysalso\expandafter{\pgfkeyspred@TMP}% + },% + /handlers/.activate family/.code=\pgfkeysactivatefamily{\pgfkeyscurrentpath}, + /handlers/.deactivate family/.code=\pgfkeysdeactivatefamily{\pgfkeyscurrentpath}, + /handlers/.belongs to family/.code={% + \pgfkeysiffamilydefined{#1}{% + \pgfkeyssetvalue{\pgfkeyscurrentpath/family}{#1}% + }{% + \pgfkeysalso{/errors/family unknown=#1}% + }% + },% + % + % + % An addition to the '.try' and '.retry' handlers: + % + % It is the same as '.retry', but if the option is still unknown, the + % usual handlers for unknown keys will be invoked. + /handlers/.lastretry/.code={% + \ifpgfkeyssuccess\else + \pgfkeys@try + \ifpgfkeyssuccess\else + % discard the '.lastretry' suffix: + \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% + \pgfkeys@split@path% + \pgfkeys@unknown + \fi + \fi + }, + % + % + /handlers/.install key filter/.code={% + \pgfkeysinstallkeyfilter{\pgfkeyscurrentpath}{#1}% + },% + /handlers/.install key filter handler/.code={% + \pgfkeysinstallkeyfilterhandler{\pgfkeyscurrentpath}{#1}% + },% + % + % + % KEY FILTER HANDLERS: + % + /pgf/key filter handlers/append filtered to/.code={% + % Produce + % '={' '}' + % where both, the key and the value are expanded just ONCE: + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\pgfkeyscurrentkeyRAW\expandafter=\expandafter{\pgfkeyscurrentvalue}}% + \ifx#1\pgfkeys@empty + \else + % Produce ',' '={' '}' + \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter#1\expandafter,\the\pgfkeys@tmptoks}% + \fi + \edef#1{\the\pgfkeys@tmptoks}% + },% + /pgf/key filter handlers/ignore/.code={}, + /pgf/key filter handlers/ignore/.install key filter handler, + /pgf/key filter handlers/log/.code={% + \immediate\write16{LOG: the option '\pgfkeyscurrentkey' (was originally '\pgfkeyscurrentkeyRAW') (case \pgfkeyscasenumber) has not been processed due to pgfkeysfiltered.}% + }, + % + % + % KEY FILTER PREDICATES: + % + % Returns true iff the currently processed key belongs to an active family. + % A family is active if it has been activated before. + /pgf/key filters/active families/.code={% + \ifnum\pgfkeyscasenumber=0 + % unknown options shall be processed with the + % unknown-handlers. + \pgfkeysfiltercontinuetrue + \else + \ifnum\pgfkeyscasenumber=3 + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \else% Ok, it does not belong to any family. + \pgfkeysfiltercontinuefalse + \fi + \fi + },% + % + % + % + % This filter works as follows: + % 1. if the current key belongs to a family: + % return whether its family is active, + % 2. if the current key does NOT belong to a family: + % return the result of criterion '#1', + % 3. the current key is unknown: + % return the result of criterion '#2'. + % + % Arguments: + % #1: the predicate which will be invoked in case 2. + % It will be invoked with the current case number as argument. + % #2: the predicate which will be invoked in case 3 with + % the current case number as argument. + /pgf/key filters/active families or no family/.code 2 args={% + \ifnum\pgfkeyscasenumber=0 + \pgfkeysevalkeyfilterwith{#2}% + \else + \ifnum\pgfkeyscasenumber=3 + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \else% Ok, it does not belong to any family. + \pgfkeysevalkeyfilterwith{#1}% + \fi + \fi + }, + /pgf/key filters/active families or no family DEBUG/.code 2 args={% + \ifnum\pgfkeyscasenumber=0 + \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) invoking unknown handler '#2']}% + \pgfkeysevalkeyfilterwith{#2}% + \else + \ifnum\pgfkeyscasenumber=3 + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \ifpgfkeysfiltercontinue + \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) family is ACTIVE]}% + \else + \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) family is NOT active.]}% + \fi + \else% Ok, it does not belong to any family. + \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) invoking has-no-family-handler '#1']}% + \pgfkeysevalkeyfilterwith{#1}% + \fi + \fi + }, + % + % Processes only options which are childs of #1. + % Example: + % is descendant of/.install key filter=/foo + % will be true for + % /foo/bar/x=y + % /foo/.cd + % /foo/bar/.style=... + % but not for + % /bar/foo/... + /pgf/key filters/is descendant of/.code={% + \ifnum\pgfkeyscasenumber=0 +%\message{'\pgfkeyscurrentkey' (case \pgfkeyscasenumber) is UNKNOWN. Calling unknown handler.}% + % unknown options shall be processed with the + % unknown-handlers. + \pgfkeysfiltercontinuetrue + \else + % string prefix comparison: + \long\def\pgfkeysisdescendantof@impl##1#1##2\pgf@@eov{% + \def\pgfkeyspred@TMP{##1}% + \ifx\pgfkeyspred@TMP\pgfkeys@empty +%\message{'\pgfkeyscurrentkey' (case \pgfkeyscasenumber) is descendant of '#1': TRUE.}% + \pgfkeysfiltercontinuetrue + \else +%\message{'\pgfkeyscurrentkey' (case \pgfkeyscasenumber) is descendant of '#1': FALSE.}% + \pgfkeysfiltercontinuefalse + \fi + }% + \expandafter\pgfkeysisdescendantof@impl\pgfkeyscurrentkey#1\pgf@@eov + \fi + },% + % + % + % + % Returns true if the currently processed full key equals #2. + /pgf/key filters/equals/.code={% + \ifnum\pgfkeyscasenumber=0 + % Unknown option: + \pgfkeysfiltercontinuetrue + \else + \def\pgfkeyspred@TMP{#1}% + \ifx\pgfkeyscurrentkey\pgfkeyspred@TMP + \pgfkeysfiltercontinuetrue + \else + \pgfkeysfiltercontinuefalse + \fi + \fi + },% + % + % + % Argument #1 can be any other (evaluated) filter predicate, its logical return + % value will be inverted. + % Example: + % not/.install key filter={is descendend of=/tikz} + % will install a key filter which evaluates 'is descendant of' with argument '/tikz' and returns the logical negation of the result. + /pgf/key filters/not/.code={% + \pgfkeysevalkeyfilterwith{#1}% + \ifpgfkeysfiltercontinue + \pgfkeysfiltercontinuefalse + \else + \pgfkeysfiltercontinuetrue + \fi + },% + /pgf/key filters/and/.code 2 args={% + \pgfkeysevalkeyfilterwith{#1}% + \ifpgfkeysfiltercontinue + \pgfkeysevalkeyfilterwith{#2}% + \fi + },% + /pgf/key filters/or/.code 2 args={% + \pgfkeysevalkeyfilterwith{#1}% + \ifpgfkeysfiltercontinue + \else + \pgfkeysevalkeyfilterwith{#2}% + \fi + },% + /pgf/key filters/true/.code={\pgfkeysfiltercontinuetrue},% + /pgf/key filters/true/.install key filter, + /pgf/key filters/false/.code={\pgfkeysfiltercontinuefalse},% + % + % Returns false if the current key is unknown, which avoids calling + % the unknown handlers. + /pgf/key filters/defined/.code={% + \ifnum\pgfkeyscasenumber=0 + \pgfkeysfiltercontinuefalse + \else + \pgfkeysfiltercontinuetrue + \fi + }, +}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Private IMPLEMENTATION +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% This command does THE SAME work as \pgfkeys@case@one, +% but it applies filtering whenever it identified the type of an +% option. +\def\pgfkeys@case@one@filtered{% + \pgfkeys@cur@is@descendant@of@errors + \ifpgfkeysfiltercontinue + \pgfkeys@orig@case@one + \else + \pgfkeysfiltercontinuetrue + \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}{% + % CASE ONE: a command option + \def\pgfkeyscasenumber{1}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + \else +%\message{FILTEReD OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi + }{% + % CASE TWO: a normal value option + \pgfkeysifdefined{\pgfkeyscurrentkey}{% + \def\pgfkeyscasenumber{2}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + \pgfkeys@case@two@extern + \else +%\message{FILTEReD OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi + }{% + \pgfkeys@split@path + % CASE THREE: a handler + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% + \def\pgfkeyscasenumber{3}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + \else +%\message{FILTERED OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi + }{% + \pgfkeys@unknown + }% + }% + }% + \fi +}% + +\def\pgfkeys@unknown@filtered{% + % CASE ZERO: an unknown option. + \def\pgfkeyscasenumber{0}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue +%\message{PROCESSING KEY \pgfkeyscurrentkey!}% + % start normal 'unknown' handlers: + \pgfkeys@orig@unknown + \else +%\message{FILTEReD OUT KEY \pgfkeyscurrentkey!}% + \pgfkeys@filtered@handler% + \fi +} + +% Does the same as \pgfkeys@try, but it also invokes the key filters. +\def\pgfkeys@try@filtered{% + \ifpgfkeysfiltercontinue + \pgfkeys@orig@try + \else + \pgfkeysfiltercontinuetrue + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% + {% + % CASE ONE: a command option + \def\pgfkeyscasenumber{1}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue + \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyscurrentpath/.@def}% + {\pgfkeysgetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeyscurrentvalue}} + {}% no default, so leave it + \fi% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% + \else + \pgfkeys@filtered@handler% + \fi + \pgfkeyssuccesstrue% + }% + {% + \pgfkeysifdefined{\pgfkeyscurrentpath}% + {% CASE TWO: a normal value option + \def\pgfkeyscasenumber{2}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \pgfkeysvalueof{\pgfkeyscurrentpath}% + \else% + \pgfkeyslet{\pgfkeyscurrentpath}\pgfkeyscurrentvalue% + \fi% + \else + \pgfkeys@filtered@handler% + \fi + \pgfkeyssuccesstrue% + }% + {\pgfkeyssuccessfalse}% + }% + \fi +} + + +% #1 the code to invoke after init and before cleanup +\def\pgfkeys@install@filter@and@invoke#1{% + \ifpgfkeysfilteringisactive + \pgfkeys@error{Sorry, nested calls to key filtering routines are not allowed. (reason: It is not possible to properly restore the previous filtering state after returning from the nested call)}% + \fi + \pgfkeysfilteringisactivetrue + \let\pgfkeys@case@one=\pgfkeys@case@one@filtered + \let\pgfkeys@try=\pgfkeys@try@filtered + \let\pgfkeys@unknown=\pgfkeys@unknown@filtered + #1% + \let\pgfkeys@case@one=\pgfkeys@orig@case@one + \let\pgfkeys@try=\pgfkeys@orig@try + \let\pgfkeys@unknown=\pgfkeys@orig@unknown + \pgfkeysfilteringisactivefalse +} + + +%-------------------------------------------------- +% \def\pgfkeys@eval@key@filter@subroutine@case@one{% +% \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}{% +% \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% +% \let\pgfkeyspred@TMP=\pgfkeyscurrentvalue +% \pgfkeys@eval@key@filter@subroutine@restorestate +% \expandafter\pgfkeys@code\pgfkeyspred@TMP\pgfeov +% }{% +% \pgfkeysvalueof{/errors/no such key filter/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% +% }% +% } +% % THIS VERSION IS TOO SLOW. See below. +% \def\pgfkeysevalkeyfilterwith#1{% +% \edef\pgfkeys@eval@key@filter@subroutine@restorestate{% +% \noexpand\def\noexpand\pgfkeyscurrentkey{\pgfkeyscurrentkey}% +% \noexpand\def\noexpand\pgfkeyscurrentkeyRAW{\pgfkeyscurrentkeyRAW}% +% \noexpand\def\noexpand\pgfkeyscurrentname{\pgfkeyscurrentname}% +% \noexpand\def\noexpand\pgfkeyscurrentvalue{\pgfkeyscurrentvalue}% +% \noexpand\pgfkeys@pathtoks={\pgfkeyscurrentpath}% +% }% +% \pgfkeysinterruptkeyfilter +% \let\pgfkeys@case@one=\pgfkeys@eval@key@filter@subroutine@case@one +% \pgfkeysalso{#1}% +% \endpgfkeysinterruptkeyfilter% this here also restored \pgfkeys@case@one. +% \pgfkeys@eval@key@filter@subroutine@restorestate +% }% +%-------------------------------------------------- + + +% Evaluates a key filter '#1'. Example: +% \pgfkeysevalkeyfilterwith{/pgf/key filters/equals=/tikz} +% +% \pgfkeysevalkeyfilterwith works only if key filtering is +% active. +% +% The argument '#1' MUST be a FULL KEY. +% +% The implementation employs a subset of the \pgfkeysalso code. +\def\pgfkeysevalkeyfilterwith#1{% + \pgfkeys@eval@key@filter@subroutine@unpack#1=\pgfkeysnovalue=\pgfkeys@stop +}% +\def\pgfkeys@eval@key@filter@subroutine@unpack#1=#2=#3\pgfkeys@stop{% + \pgfkeys@spdef\pgfkeyspred@TMP{#1}% + \edef\pgfkeyspred@TMP{\pgfkeyspred@TMP}% + \pgfkeys@spdef\pgfkeyspred@TMPB{#2}% TMPB=value + \ifx\pgfkeyspred@TMPB\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyspred@TMP/.@def}% + {\pgfkeysgetvalue{\pgfkeyspred@TMP/.@def}{\pgfkeyspred@TMPB}} + {}% no default, so leave it + \fi% + \ifx\pgfkeyspred@TMPB\pgfkeysvaluerequired% + \pgfkeysvalueof{/errors/value required/.@cmd}\pgfkeyspred@TMP\pgfkeyspred@TMPB\pgfeov% + \else% + \pgfkeysifdefined{\pgfkeyspred@TMP/.@cmd}{% + \pgfkeysgetvalue{\pgfkeyspred@TMP/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyspred@TMPB\pgfeov + }{% + \pgfkeysvalueof{/errors/no such key filter/.@cmd}\pgfkeyspred@TMP\pgfkeyspred@TMPB\pgfeov% + }% + \fi% +} + + +\def\pgfkeys@nevermind#1\relax{\let\pgfkeyscurrentkeyRAW=\pgfkeyscurrentkey} +\def\pgfkeys@addpath#1\relax{\def\pgfkeyscurrentkeyRAW{#1}% old @addpath: + \edef\pgfkeyscurrentkey{\pgfkeysdefaultpath#1}% +} + +\def\pgfkeys@non@outer@newif@#1#2{% + \expandafter\edef\csname #2true\endcsname{\noexpand\let\noexpand#1=\noexpand\iftrue}% + \expandafter\edef\csname #2false\endcsname{\noexpand\let\noexpand#1=\noexpand\iffalse}% + \csname #2false\endcsname +}% + +% For latex and context, this here has the same effect as a \newif +% applied to 'if#1'. For plain tex, it has also the same effect, but +% it is not an \outer macro as the plain-tex \newif. +\def\pgfkeys@non@outer@newif#1{% + \expandafter\pgfkeys@non@outer@newif@\csname if#1\endcsname{#1}% +} +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex new file mode 100644 index 00000000000..0d120a8b722 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex @@ -0,0 +1,922 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex,v 1.3 2008/06/07 17:08:33 ludewich Exp $ + +\newif\ifpgf@plot@started + + +% This handler converts each plot stream command into a curveto +% command, except for the first, which is converted to the previously +% specified action. +% +% Example: +% +% \pgfpathmoveto{\pgfpointorigin} +% \pgfsetlinetofirstplotpoint +% \pgfplothandlercurveto +% \pgfplotxyfile{mytable} + +\def\pgfplothandlercurveto{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@initial% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgf@plot@curveto@handler@finish% + \global\pgf@plot@startedfalse% + }% +} + +\def\pgf@plot@curveto@handler@initial#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@plot@first@action{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@curveto@first{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \global\let\pgf@plot@curveto@first@support=\pgf@plot@curveto@first% + \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@second% +} + +\def\pgf@plot@curveto@handler@second#1{% + \pgf@process{#1}% + \xdef\pgf@plot@curveto@second{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@third% + \global\pgf@plot@startedtrue% +} + +\def\pgf@plot@curveto@handler@third#1{% + \pgf@process{#1}% + \xdef\pgf@plot@curveto@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@curveto@first} + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@curveto@second}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@curveto@first@support}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@curveto@second}}% + {\pgf@marshal}% + % Prepare next: + \global\let\pgf@plot@curveto@first=\pgf@plot@curveto@second% + \global\let\pgf@plot@curveto@second=\pgf@plot@curveto@current% + \xdef\pgf@plot@curveto@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% +} + +\def\pgf@plot@curveto@handler@finish{% + \ifpgf@plot@started% + \pgfpathcurveto{\pgf@plot@curveto@first@support}{\pgf@plot@curveto@second}{\pgf@plot@curveto@second}% + \fi% +} + + +% This commands sets the tension for smoothing of plots. +% +% #1 = tension of curves. A value of 1 will yield a circle when the +% control points are at quarters of a circle. A smaller value +% will result in a tighter curve. Default is 0.5. +% +% Example: +% +% \pgfsetplottension{0.2} + +\def\pgfsetplottension#1{% + \pgf@x=#1pt\relax% + \pgf@x=0.2775\pgf@x\relax% + \edef\pgf@plottension{\pgf@sys@tonumber\pgf@x}} +\pgfsetplottension{0.5} + + +% This handler converts the plot stream command into a curveto +% command that is closed using a closepath. +% +% Example: +% +% \pgfpathmoveto{\pgfpointorigin} +% \pgfplothandlerclosedcurve +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerclosedcurve{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@initial% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgf@plot@closedcurve@handler@finish% + }% +} + +\def\pgf@plot@closedcurve@handler@initial#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \xdef\pgf@plot@closedcurve@initial{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@second% + \global\pgf@plot@startedfalse% +} + +\def\pgf@plot@closedcurve@handler@second#1{% + \pgf@process{#1}% + \xdef\pgf@plot@closedcurve@after@initial{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + {\pgfpathmoveto{}}% + \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@third% +} + +\def\pgf@plot@closedcurve@handler@third#1{% + \global\pgf@plot@startedtrue% + \pgf@process{#1}% + \xdef\pgf@plot@closedcurve@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@closedcurve@initial} + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@closedcurve@after@initial}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@after@initial% + \global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current% + \xdef\pgf@plot@closedcurve@after@initial@presupport{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% + \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@fourth% +} + +\def\pgf@plot@closedcurve@handler@fourth#1{% + \pgf@process{#1}% + \xdef\pgf@plot@closedcurve@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@closedcurve@first} + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@closedcurve@second}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}% + {\pgf@marshal}% + % Prepare next: + \global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@second% + \global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current% + \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% +} + +\def\pgf@plot@closedcurve@handler@finish{% + \ifpgf@plot@started + % + % first, draw line from 2nd last to last: + % + \pgf@process{\pgf@plot@closedcurve@initial}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@closedcurve@first}% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@closedcurve@second}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}% + {\pgf@marshal}% + \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + % + % second, draw line from last point to start: + % + \pgf@process{\pgf@plot@closedcurve@after@initial}% + % compute difference vector: + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgf@plot@closedcurve@second}% + \advance\pgf@xa by-\pgf@x% + \advance\pgf@ya by-\pgf@y% + % compute support directions: + \pgf@xa=\pgf@plottension\pgf@xa% + \pgf@ya=\pgf@plottension\pgf@ya% + % first marshal: + \pgf@process{\pgf@plot@closedcurve@initial}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by\pgf@xa% + \advance\pgf@yc by\pgf@ya% + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}% + {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@initial}}% + {\pgf@marshal}% + % + % third, draw line from first to second point: + % + \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}% + {\noexpand\pgf@plot@closedcurve@after@initial@presupport}{\noexpand\pgf@plot@closedcurve@after@initial}}% + {\pgf@marshal}% + \pgfpathclose% + \fi% +} + + + + + +% This handler converts each point in a stream into a line from the +% $y$-axis to the given points coordinate, resulting in a +% ``comb.'' +% +% Example: +% +% \pgfplothandlerxcomb +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerxcomb{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@xcomb@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfplotxzerolevelstreamstart + }% +} + +\def\pgf@plot@xcomb@handler#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% +} + + +% This handler converts each point in a stream into a line from the +% $x$-axis straight up to the given points coordinate, resulting in a +% ``comb.'' +% +% Example: +% +% \pgfplothandlerycomb +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerycomb{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@ycomb@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfplotyzerolevelstreamstart + }% +} + +\def\pgf@plot@ycomb@handler#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% +} + +% PGF Bar or comb plots usually draw something from zero to the current plot's coordinate. +% +% The 'zero' offset can be changed using an input stream. +% +% There are two such streams which can be configured independently. +% The first one returns "zeros" for coordinate x, the second one +% returns "zeros" for coordinate y. +% +% \pgfplotxzerolevelstreamstart +% \pgfplotxzerolevelstreamnext % assigns \pgf@x globally +% \pgfplotxzerolevelstreamnext +% \pgfplotxzerolevelstreamnext +% \pgfplotxzerolevelstreamend +% +% and +% \pgfplotyzerolevelstreamstart +% \pgfplotyzerolevelstreamnext % assigns \pgf@x globally +% \pgfplotyzerolevelstreamend +% +\def\pgfplotxzerolevelstreamstart{\pgf@plotxzerolevelstreamstart}% +\def\pgfplotxzerolevelstreamend{\pgf@plotxzerolevelstreamend}% +\def\pgfplotxzerolevelstreamnext{\pgf@plotxzerolevelstreamnext} +\def\pgfplotyzerolevelstreamstart{\pgf@plotyzerolevelstreamstart}% +\def\pgfplotyzerolevelstreamend{\pgf@plotyzerolevelstreamend}% +\def\pgfplotyzerolevelstreamnext{\pgf@plotyzerolevelstreamnext} + +% This zero level stream always returns '#1' (a dimension). +\def\pgfplotxzerolevelstreamconstant#1{% + \edef\pgfplotxzerolevelstreamconstant@val{#1}% + \def\pgf@plotxzerolevelstreamstart{% + \global\let\pgf@plotxzerolevelstreamend=\relax + \gdef\pgf@plotxzerolevelstreamnext{\global\pgf@x=\pgfplotxzerolevelstreamconstant@val\relax}% + }% +}% +\pgfplotxzerolevelstreamconstant{0pt}% + +% This zero level stream always returns '#1'. +\def\pgfplotyzerolevelstreamconstant#1{% + \edef\pgfplotyzerolevelstreamconstant@val{#1}% + \def\pgf@plotyzerolevelstreamstart{% + \global\let\pgf@plotyzerolevelstreamend=\relax + \gdef\pgf@plotyzerolevelstreamnext{\global\pgf@x=\pgfplotyzerolevelstreamconstant@val\relax}% + }% +}% +\pgfplotyzerolevelstreamconstant{0pt}% + +\def\pgfplotbarwidth{\pgfkeysvalueof{/pgf/bar width}} + +\pgfqkeys{/pgf}{% + bar width/.initial=10pt, + bar shift/.initial=0pt, + bar interval width/.initial=1, + bar interval shift/.initial=0.5, +} + +% This handler places a rectangle at each point in the plot stream, a +% rectangle which touches the x-axis at one end and the current point +% at the other end: +% --(X)-- +% | | +% | | +% | | +% --(0)-- +% Example: +% +% \pgfplothandlerybar +% \pgfplotxyfile{mytable} +\def\pgfplothandlerybar{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@ybar@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfmathparse{\pgfplotbarwidth}% + \xdef\pgfplotbarwidth@{\pgfmathresult pt}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar shift}}% + \xdef\pgfplotbarshift@{\pgfmathresult pt}% + \pgfplotyzerolevelstreamstart + }% +} + +\def\pgf@plot@ybar@handler#1{% + \pgf@process{#1}% + \pgf@ya=\pgf@y + \expandafter\pgf@xb\pgfplotbarwidth@\relax + \pgf@xc=\pgf@x + \advance\pgf@xc by-.5\pgf@xb + \advance\pgf@xc by\pgfplotbarshift@\relax + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@xc}{\pgf@yb}}% + {\pgfqpoint{\pgf@xb}{\pgf@ya}}% +} + +% This handler places a rectangle at each point in the plot stream, a +% rectangle which touches the y-axis at one end and the current point +% at the other end: +% --------- +% | | +% (0) (X) +% | | +% --------- +% Example: +% +% \pgfplothandlerxbar +% \pgfplotxyfile{mytable} +\def\pgfplothandlerxbar{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@xbar@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfmathparse{\pgfplotbarwidth}% + \xdef\pgfplotbarwidth@{\pgfmathresult pt}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar shift}}% + \xdef\pgfplotbarshift@{\pgfmathresult pt}% + \pgfplotxzerolevelstreamstart + }% +} + +\def\pgf@plot@xbar@handler#1{% + \pgf@process{#1}% + \pgf@ya=\pgf@x + \expandafter\pgf@xb\pgfplotbarwidth@\relax + \pgf@xc=\pgf@y + \advance\pgf@xc by-.5\pgf@xb + \advance\pgf@xc by\pgfplotbarshift@\relax + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@yb}{\pgf@xc}}% + {\pgfqpoint{\pgf@ya}{\pgf@xb}}% +} + +% This handler is a variant of \pgfplothandlerybar which works with +% intervals instead of points. +% +% Bars are drawn between successive input coordinates and the width is +% determined relatively to the interval length. +% +% It looks like this: +% +% |---| |-----| +% | | | | +% | | | | +% | | | | +% (X)------(X)-----------(X) +% +% where (X) denotes the x-axis offsets of input coordinates. +% +% In more detail, if (x_i,y_i) and (x_{i+1},y_{i+1}) denote successive +% input coordinates, the bar will be placed above the +% interval [x_i,x_{i+1}], centered at +% +% x_i + \pgfkeysvalueof{/pgf/bar interval shift} * (x_{i+1} - x_i) +% +% with width +% +% \pgfkeysvalueof{/pgf/bar interval width} * (x_{i+1} - x_i). +% +% If you have N+1 input points, you will get N bars (one for each +% interval). The y_i value of the last bar will be ignored. +% +% Example: +% +% \pgfplothandlerybarinterval +% \pgfplotxyfile{mytable} +\def\pgfplothandlerybarinterval{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler@first% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}% + \xdef\pgfplotbarintervalwidth@{\pgfmathresult}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}% + \xdef\pgfplotbarintervalshift@{\pgfmathresult}% + \pgfplotyzerolevelstreamstart + }% +} + +\def\pgf@plot@ybarinterval@handler@first#1{% + \pgf@process{#1}% + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}% + \xdef\pgf@plot@barinterval@bar{\the\pgf@y}% + \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler% +} +\def\pgf@plot@ybarinterval@handler#1{% + \pgf@process{#1}% + \pgf@ya=\pgf@plot@barinterval@bar + \xdef\pgf@plot@barinterval@bar{\the\pgf@y}% + \pgf@xc=\pgf@plot@barinterval@intervalstart\relax + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}% + \pgf@xb=\pgf@x + \advance\pgf@xb by-\pgf@xc + \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb + \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb + \advance\pgf@xc by-.5\pgf@xb% center + \begingroup + \pgfplotyzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@xc}{\pgf@yb}}% + {\pgfqpoint{\pgf@xb}{\pgf@ya}}% +} + +% Like \pgfplothandlerybarinterval but for xbar. +\def\pgfplothandlerxbarinterval{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler@first% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}% + \xdef\pgfplotbarintervalwidth@{\pgfmathresult}% + \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}% + \xdef\pgfplotbarintervalshift@{\pgfmathresult}% + \pgfplotxzerolevelstreamstart + }% +} + +\def\pgf@plot@xbarinterval@handler@first#1{% + \pgf@process{#1}% + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}% + \xdef\pgf@plot@barinterval@bar{\the\pgf@x}% + \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler% +} +\def\pgf@plot@xbarinterval@handler#1{% + \pgf@process{#1}% + \pgf@ya=\pgf@plot@barinterval@bar + \xdef\pgf@plot@barinterval@bar{\the\pgf@x}% + \pgf@xc=\pgf@plot@barinterval@intervalstart\relax + \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}% + \pgf@xb=\pgf@y + \advance\pgf@xb by-\pgf@xc + \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb + \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb + \advance\pgf@xc by-.5\pgf@xb% center + \begingroup + \pgfplotxzerolevelstreamnext + \endgroup + \pgf@yb=\pgf@x + \advance\pgf@ya by-\pgf@yb + \pgfpathrectangle + {\pgfqpoint{\pgf@yb}{\pgf@xc}}% + {\pgfqpoint{\pgf@ya}{\pgf@xb}}% +} + + +% This handler is very similar to \pgfplothandlerlineto, but it +% produces CONSTANT connected pieces of the form +% +% x +% | +% x--- | +% | x---- +% x-| +% +% Example: +% +% \pgfplothandlerconstantlineto +% \pgfplotxyfile{mytable} +\def\pgfplothandlerconstantlineto{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@const@line@handler#1{% + \pgf@plot@first@action{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler@@% +} +\def\pgf@plot@const@line@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \expandafter\pgf@yb\pgf@plot@const@line@handler@last + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}% +} + +% A variant of \pgfplothandlerconstantlineto which places its mark on +% the right line ends. +% +% |---x +% ---x | +% |--x +% x +% +% Example: +% +% \pgfplothandlerconstantlinetomarkright +% \pgfplotxyfile{mytable} +\def\pgfplothandlerconstantlinetomarkright{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@const@line@mark@right@handler#1{% + \pgf@plot@first@action{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}% + \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler@@% +} +\def\pgf@plot@const@line@mark@right@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \expandafter\pgf@yb\pgf@plot@const@line@handler@last + \pgfpathlineto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}% +} + +% This handler is in fact a variant of \pgfplothandlerconstantlineto, +% but it does not draw vertical lines. It produces a sequence of +% line-to and move-to operations such that plot marks are placed at +% each right end: +% +% ---x +% ---x +% ---x +% --x +% +% Example: +% +% \pgfplothandlerjumpmarkright +% \pgfplotxyfile{mytable} +\def\pgfplothandlerjumpmarkright{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@jumpmarkright@handler#1{% + \pgf@plot@first@action{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler@@% +} +\def\pgf@plot@jumpmarkright@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \expandafter\pgf@yb\pgf@plot@const@line@handler@last + \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}% +} + +% This handler is in fact a variant of \pgfplothandlerconstantlineto, +% but it does not draw vertical lines. It produces a sequence of +% line-to and move-to operations such that plot marks are placed at +% each left end: +% +% x--- +% x--- +% x--- +% x-- +% +% Example: +% +% \pgfplothandlerjumpmarkleft +% \pgfplotxyfile{mytable} +\def\pgfplothandlerjumpmarkleft{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} +\def\pgf@plot@jumpmarkleft@handler#1{% + \pgf@plot@first@action{#1}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}% + \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler@@% +} +\def\pgf@plot@jumpmarkleft@handler@@#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \expandafter\pgf@yb\pgf@plot@const@line@handler@last + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% + \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% + \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}% +} + + + +% This handler converts each point in a stream into a line from the +% origin to the point's coordinate, resulting in a ``star''. +% +% Example: +% +% \pgfplothandlerpolarcomb +% \pgfplotxyfile{mytable} + +\def\pgfplothandlerpolarcomb{% + \def\pgf@plotstreamstart{% + \global\let\pgf@plotstreampoint=\pgf@plot@polarcomb@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} + +\def\pgf@plot@polarcomb@handler#1{% + \pgf@process{#1}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgfpathmoveto{\pgfpointorigin}% + \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% +} + + + + +% This handler draws a given mark at each point. +% +% #1 = some code to be executed at each point (with the coordinate +% system translated to that point). +% Typically, this code will be \pgfuseplotmark{whatever}. +% +% Example: +% +% \pgfplothandlermark{\pgfuseplotmark{*}} +% \pgfplotxyfile{mytable} + +\def\pgfplothandlermark#1{% + \pgf@plothandlermark{% + \ifnum\pgf@plot@mark@count<\pgf@plot@mark@repeat\relax% + \else% + \global\pgf@plot@mark@count=0\relax% + #1% + \fi% + }% +} + +\newcount\pgf@plot@mark@count +\def\pgf@plot@mark@phase{0} + +\def\pgf@plothandlermark#1{% + \def\pgf@plot@mark{#1}% + \def\pgf@plotstreamstart{% + \global\pgf@plot@mark@count=\pgf@plot@mark@repeat\relax% + \global\advance\pgf@plot@mark@count by-\pgf@plot@mark@phase\relax% + \global\let\pgf@plotstreampoint=\pgf@plot@mark@handler% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\relax% + }% +} + +\def\pgf@plot@mark@handler#1{% + \global\advance\pgf@plot@mark@count by1\relax% + {\pgftransformshift{#1}\pgf@plot@mark}% +} + + +% Set the repeat count for marks. For example, if 3 is given as a +% value, only every third point will get a mark. +% +% #1 = repeat count +% +% Example: +% +% \pgfsetplotmarkrepeat{2} + +\def\pgfsetplotmarkrepeat#1{\def\pgf@plot@mark@repeat{#1}} +\pgfsetplotmarkrepeat{1} + + +% Set the phase for marks. For example, if 3 is the repeat and 3 is +% the phase, already the first point will be marked. +% +% #1 = the index of the first point that should be marked. +% +% Example: +% +% \pgfsetplotmarkphase{3} + +\def\pgfsetplotmarkphase#1{\def\pgf@plot@mark@phase{#1}} +\pgfsetplotmarkphase{1} + + + +% This handler draws a given mark at those points whose number is +% given in the (pgffor-like) list. +% +% #1 = some code to be executed at each point (with the coordinate +% system translated to that point). +% Typically, this code will be \pgfuseplotmark{whatever}. +% #2 = list of positions like "1,2,4,...,9,10" +% +% Example: +% +% \pgfplothandlermarklisted{\pgfuseplotmark{*}}{1,2,4,...,9} +% \pgfplotxyfile{mytable} + +\def\pgfplothandlermarklisted#1#2{% + \let\pgf@plot@mark@list=\pgfutil@empty% + \edef\pgf@marshal{\noexpand\foreach\noexpand\pgf@temp in{#2}} + \pgf@marshal{\xdef\pgf@plot@mark@list{\pgf@plot@mark@list(\pgf@temp)}}% + \pgf@plothandlermark{% + \edef\pgf@marshal{\noexpand\pgfutil@in@{(\the\pgf@plot@mark@count)}{\pgf@plot@mark@list}}% + \pgf@marshal% + \ifpgfutil@in@#1\fi}% +} + + +% Define a new plot mark for use with \pgfplotmark. +% +% #1 = a plot mark mnemonic +% #2 = code for drawing the mark +% +% Example: +% +% \pgfdeclareplotmark{*}{\pgfpathcircle{\pgfpointorigin}{2pt}\pgfusepathqfill} + +\def\pgfdeclareplotmark#1#2{\expandafter\def\csname pgf@plot@mark@#1\endcsname{#2}} + + +% Set the size of plot marks. For circles, this will be the radius, +% for other shapes it should be about half the width/height. +% +% Example: +% +% \pgfsetplotmarksize{1pt} + +\def\pgfsetplotmarksize#1{\pgfmathsetlength\pgfplotmarksize{#1}} + +\newdimen\pgfplotmarksize +\pgfplotmarksize=2pt + + +% Insert a plot mark's code at the origin. +% +% #1 = plot mark mnemonic +% +% Example: +% +% \pgfuseplotmark{*} + +\def\pgfuseplotmark#1{\csname pgf@plot@mark@#1\endcsname} + + +% A stroke-filled circle mark + +\pgfdeclareplotmark{*} +{% + \pgfpathcircle{\pgfpointorigin}{\pgfplotmarksize} + \pgfusepathqfillstroke +} + + +% A plus-sign like mark + +\pgfdeclareplotmark{+} +{% + \pgfpathmoveto{\pgfqpoint{-\pgfplotmarksize}{0pt}} + \pgfpathlineto{\pgfqpoint{\pgfplotmarksize}{0pt}} + \pgfpathmoveto{\pgfqpoint{0pt}{\pgfplotmarksize}} + \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}} + \pgfusepathqstroke +} + + +% An x-shaped mark + +\pgfdeclareplotmark{x} +{% + \pgfpathmoveto{\pgfqpoint{-.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}} + \pgfpathlineto{\pgfqpoint{.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}} + \pgfpathmoveto{\pgfqpoint{-.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}} + \pgfpathlineto{\pgfqpoint{.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}} + \pgfusepathqstroke +} + +% See pgflibraryplotmarks for more plot marks + + + + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex new file mode 100644 index 00000000000..e199d44f811 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex @@ -0,0 +1,2322 @@ +% Copyright 2008 by Christian Feuersaenger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. +% +% This file contains methods for basic floating point arithmetics, rounding +% to arbitrary precision and number pretty printing. +% +% Version 0.9.4 2008/03/18 + +\global\newif\ifpgfmathfloatcomparison +\newif\ifpgfmathfloatroundhasperiod +\newif\ifpgfmathprintnumberskipzeroperiod + + +% used internally in grouped macros: +\toksdef\pgfmathfloat@tmptoks=1 +\newif\ifpgfmathfloat@fixed@digits@after@period +\newif\ifpgfmathfloatroundmayneedrenormalize +\toksdef\pgfmathfloat@a@Mtok=0 + +%% WARNING: avoid conflicting register names! +\let\pgfmathfloat@a@S=\c@pgf@counta +\let\pgfmathfloat@a@M=\pgf@xa +\let\pgfmathfloat@a@E=\c@pgf@countb +\let\pgfmathfloat@b@S=\c@pgf@countc +\let\pgfmathfloat@b@M=\pgf@xb +\let\pgfmathfloat@b@E=\c@pgf@countd + +% can be changed with options. +\def\pgfmathfloat@round@precision{2} + +\gdef\pgfmathfloat@glob@TMP{} + + +% Computes a normalised floating point representation for #1 of the +% form +% [FLAGS] MANTISSE EXPONENT +% meaning +% [+-]X.XXXXXXX*10^C +% where +% X.XXXXXX is a mantisse with first number != 0, C is an integer and +% FLAGS contains the sign and some other special cases. +% +% This method does NOT use TeX Registers to represent the numbers! The +% computation is COMPLETELY STRING BASED. +% This allows numbers such at 10000000 or 5.23e-10 to be represented +% properly, although TeX-registers would produce overflow/underflow +% errors in these cases. +% +% It is to be used to compute logs, because log(X*10^Y) = log(X) + log(10)*Y +% +% Arguments: +% #1: an arbitrary number which shall be parsed. Maybe a macro. +% Examples: +% [+-]XXXXX.XXXXXX +% [+-]XXXXX.XXXXXXeXXXX +% [+-]0.0000XXXXXX +% [+-]0.0000XXXXXXeXXXX +% [+-]inf +% nan +% Maybe a macro containing such a number. +% +% Return value: +% \pgfmathresult will be \def'ed to +% FLAGS MANTISSE 'e' EXPONENT +% where +% FLAGS is a number in [0-5] where +% 0 == '0' (the number is +- 0.0), +% 1 == '+', +% 2 == '-', +% 3 == 'not a number' +% 4 == '+ infinity' +% 5 == '- infinity' +% +% MANTISSE is a normalised number 1 <= M < 10. It always contains a +% period and at least one digit after the period. +% +% EXPONENT is an integer value. +% +% Example: +% \pgfmathfloatparsenumber{1} +% -> \pgfmathresult = 11.0e0 +% \pgfmathfloatparsenumber{141.212} +% -> \pgfmathresult = 11.41212e2 +\def\pgfmathfloatparsenumber#1{% + \begingroup + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloatparsenumber@impl\pgfmathresult\pgfmathfloat@EOI + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.0}% + \fi + \edef\pgfmathresult{% + \the\pgfmathfloat@a@S\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +% The same as \pgfmathfloatparsenumber, but does not perform sanity checking. +\def\pgfmathfloatqparsenumber#1{% + \begingroup + \let\pgfmathfloatparsenumber@sanitize@digit=\relax + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloatparsenumber@impl\pgfmathresult\pgfmathfloat@EOI + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.0}% + \fi + \edef\pgfmathresult{% + \the\pgfmathfloat@a@S\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + + +% decomposes a lowlevel floating point representation into flags, +% mantisse and exponent. +% +% #4: integer register for the flags. +% #5: dimen registers for the mantisse. +% #6: integer register for the exponent. +\def\pgfmathfloat@decompose#1#2e#3\relax#4#5#6{% + #4=#1\relax + #5=#2pt% + #6=#3\relax% +} +% overloaded, #5 needs to be a token register for the mantisse. +\def\pgfmathfloat@decompose@tok#1#2e#3\relax#4#5#6{% + #4=#1\relax + #5={#2}% + #6=#3\relax% +} +% overloaded, returns only ONE of the three components into #4: +\def\pgfmathfloat@decompose@F#1#2e#3\relax#4{#4=#1\relax}% +\def\pgfmathfloat@decompose@M#1#2e#3\relax#4{#4=#2pt}% +\def\pgfmathfloat@decompose@Mtok#1#2e#3\relax#4{#4={#2}}% +\def\pgfmathfloat@decompose@E#1#2e#3\relax#4{#4=#3\relax}% + +% Takes a floating point number #1 as input and writes flags to macro +% #2, mantisse to macro #3 and exponent to macro #4. +\def\pgfmathfloattomacro#1#2#3#4{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \xdef\pgfmathfloat@glob@TMP{% + \noexpand\def\noexpand#2{\the\pgfmathfloat@a@S}% + \noexpand\def\noexpand#3{\the\pgfmathfloat@a@Mtok}% + \noexpand\def\noexpand#4{\the\pgfmathfloat@a@E}% + }% + \endgroup + \pgfmathfloat@glob@TMP +} + +% Takes a floating point number #1 as input and writes flags to count +% register #2, mantisse to dimen register #3 and exponent to count +% register #4. +\def\pgfmathfloattoregisters#1#2#3#4{% + \expandafter\pgfmathfloat@decompose#1\relax{#2}{#3}{#4}% +} + +% the same, but writes the mantisse into a token register. +\def\pgfmathfloattoregisterstok#1#2#3#4{% + \expandafter\pgfmathfloat@decompose@tok#1\relax{#2}{#3}{#4}% +} + +% Extracts the flags of #1 into the count register #2. +\def\pgfmathfloatgetflags#1#2{% + \expandafter\pgfmathfloat@decompose@F#1\relax{#2}% +} +% Extracts the mantisse of #1 into the dimen register #2. +\def\pgfmathfloatgetmantisse#1#2{% + \expandafter\pgfmathfloat@decompose@M#1\relax{#2}% +} +% Extracts the mantisse of #1 into the token register #2. +\def\pgfmathfloatgetmantissetok#1#2{% + \expandafter\pgfmathfloat@decompose@Mtok#1\relax{#2}% +} +% Extracts the exponent of #1 into the count register #2. +\def\pgfmathfloatgetexponent#1#2{% + \expandafter\pgfmathfloat@decompose@E#1\relax{#2}% +} + +% Defines \pgfmathresult as the floating point number encoded by +% the flags #1, mantisse #2 and exponent #3. +% +% All arguments are characters and will be expanded using '\edef'. +\def\pgfmathfloatcreate#1#2#3{% + \edef\pgfmathresult{#1#2e#3}% +}% + + +% Compares #1 with #2 and sets \pgfmathresult either to 1.0 or 0.0. +% +% It also sets the boolean \ifpgfmathfloatcomparison (globally. +\def\pgfmathfloatlessthan@#1#2{% +%\def\pgfmathfloatlessthan#1#2#3\and#4#5#6{% + \global\pgfmathfloatcomparisonfalse + \begingroup + \expandafter\pgfmathfloat@decompose#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E + \expandafter\pgfmathfloat@decompose#2\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E + \ifcase\pgfmathfloat@a@S + % x = 0 -> (x y >0) + \ifnum1=\pgfmathfloat@b@S + \global\pgfmathfloatcomparisontrue + \fi + \or + % x > 0 -> (x ( y > 0 && |x| < |y|) ) + \ifnum1=\pgfmathfloat@b@S + % y>0: + \pgfmathfloatlessthan@positive + \fi + \or + % x < 0 -> (x (y >= 0 || |x| > |y|) ) + \ifnum2=\pgfmathfloat@b@S + % 'y<0': + \pgfmathfloatgreaterthan@positive + \else + \global\pgfmathfloatcomparisontrue + \fi + \else + \pgfmath@error{Sorry, 'pgfmathfloatlessthan@{#1}{#2}' not yet supported.}% + \fi + \endgroup + \ifpgfmathfloatcomparison + \def\pgfmathresult{1.0}% + \else + \def\pgfmathresult{0.0}% + \fi +} +\let\pgfmathfloatlessthan=\pgfmathfloatlessthan@ + +% compares \pgfmathfloat@a@[SME] < \pgfmathfloat@b@[SME] +\def\pgfmathfloatlessthan@positive{% + \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E + \global\pgfmathfloatcomparisontrue + \else + \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E + \ifdim\pgfmathfloat@a@M<\pgfmathfloat@b@M + \global\pgfmathfloatcomparisontrue + \fi + \fi + \fi +} + +% compares \pgfmathfloat@a@[SME] > \pgfmathfloat@b@[SME] +\def\pgfmathfloatgreaterthan@positive{% + \ifnum\pgfmathfloat@a@E>\pgfmathfloat@b@E + \global\pgfmathfloatcomparisontrue + \else + \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E + \ifdim\pgfmathfloat@a@M>\pgfmathfloat@b@M + \global\pgfmathfloatcomparisontrue + \fi + \fi + \fi +} + + +\def\pgfmathfloatmax@#1#2{% + \pgfmathfloatlessthan{#1}{#2}% + \ifpgfmathfloatcomparison + \edef\pgfmathresult{#2}% + \else + \edef\pgfmathresult{#1}% + \fi +} +\let\pgfmathfloatmax=\pgfmathfloatmax@ + +\def\pgfmathfloatmin@#1#2{% + \pgfmathfloatlessthan{#1}{#2}% + \ifpgfmathfloatcomparison + \edef\pgfmathresult{#1}% + \else + \edef\pgfmathresult{#2}% + \fi +} +\let\pgfmathfloatmin=\pgfmathfloatmin@ + +% Renormalizes #1 to extended precision mantisse, meaning +% 100 <= m < 1000 +% instead of 1 <= m < 10. +% +% The 'extended precision' means we have higher accuracy when we apply pgfmath operations to mantisses. +% +% The input argument is expected to be a normalized floating point number; the output argument is a non-normalized floating point number (well, normalized to extended precision). +% +% The operation is supposed to be very fast. +\def\pgfmathfloattoextentedprecision#1{% + \begingroup + \pgfmathfloattoextentedprecision@a{#1}% + \pgfmathfloatcreate{\pgfmathfloat@a@S}{\pgfmathresult}{\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\def\pgfmathfloattoextentedprecision@@zero#1\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1}% +}% +\def\pgfmathfloattoextentedprecision@@one#1.#2#3\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1#2.#3}% +}% +\def\pgfmathfloattoextentedprecision@@two#1.#2#3#4\pgfmathfloat@EOI{% + \edef\pgfmathresult{#1#2#3.#4}% +}% + +% Sets extended precision to 10^#1. +% +% The default is 10^2, which means mantissas in extended precision are +% normalised to 100 <= m < 1000. +% +% The case 10^1 means they are normalised to 10 <= m < 100 and 10^0 +% deactivates extended precision. +% +% #1 is the exponent, #1 = 0,1 or 2. +% +% This setting applies to \pgfmathfloattoextentedprecision. +\def\pgfmathfloatsetextprecision#1{% + \ifcase#1\relax + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@zero + \def\pgfmathfloatextprec@shift{0}% + \or + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@one + \def\pgfmathfloatextprec@shift{1}% + \else + \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@two + \def\pgfmathfloatextprec@shift{2}% + \fi +}% +\pgfmathfloatsetextprecision{2}% + +% Does the same work as \pgfmathfloattoextentedprecision, but this one here fills the +% registers \pgfmathfloat@a@S and \pgfmathfloat@a@E with the flags and (renormalized) exponent. +% It destroys the content of \pgfmathfloat@a@Mtok. +\def\pgfmathfloattoextentedprecision@a#1{% + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifnum\pgfmathfloat@a@S<3 + \advance\pgfmathfloat@a@E by-\pgfmathfloatextprec@shift\relax% compensate for shift + \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 00\pgfmathfloat@EOI + \else + \edef\pgfmathresult{#1}% + \fi +}% + + +% Similar to \pgfmathfloattoextentedprecision@a, this one here fills the '@b' registers. +\def\pgfmathfloattoextentedprecision@b#1{% + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E + \ifnum\pgfmathfloat@b@S<3 + \advance\pgfmathfloat@b@E by-\pgfmathfloatextprec@shift\relax + \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 00\pgfmathfloat@EOI + \else + \edef\pgfmathresult{#1}% + \fi +}% + +% Addition of two floating point numbers using 8 significant digits. +\def\pgfmathfloatadd@#1#2{% + \begingroup + % + % renormalize argument to 100 <= m < 1000 for extended accuracy: + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloattoextentedprecision@b{#2}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + \edef\pgfmathresult{#2}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}% + \fi + \ifcase\pgfmathfloat@b@S + \edef\pgfmathresult{#1}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@argb{-\pgfmathfloat@argb}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}% + \fi + \ifpgfmathfloatcomparison + % Shift lesser mantisse to fit the larger one: + \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E + \pgfmathfloatadd@shift{\pgfmathfloat@arga}{\pgfmathfloat@a@E}{\pgfmathfloat@b@E}% + \else + \pgfmathfloatadd@shift{\pgfmathfloat@argb}{\pgfmathfloat@b@E}{\pgfmathfloat@a@E}% + \fi + % add them! + \pgfmathadd@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + + +% #1=mantisse which needs to be shifted (with smaller exponent) +% #2=smaller exponent +% #3=larger exponent +% +% ATTENTION: this helper method DESTROYS contents of \pgfmathfloat@a@S. +\def\pgfmathfloatadd@shift#1#2#3{% + \pgf@xa=#1 pt% + \pgfmathfloat@a@S=#3\relax + \advance\pgfmathfloat@a@S by-#2\relax + \ifcase\pgfmathfloat@a@S + \or + \divide\pgf@xa by10\relax + \or + \divide\pgf@xa by100\relax + \or + \divide\pgf@xa by1000\relax + \or + \divide\pgf@xa by10000\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by10\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by100\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by1000\relax + \or + \divide\pgf@xa by10000\relax + \divide\pgf@xa by10000\relax + \else + \pgf@xa=0pt% + \fi + #2=#3\relax + \edef#1{\pgf@sys@tonumber\pgf@xa}% +} + +\let\pgfmathfloatadd=\pgfmathfloatadd@ + + +% Subtracts two floating point numbers. +\def\pgfmathfloatsubtract@#1#2{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#2\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E + \ifcase\pgfmathfloat@b@S + \edef\pgfmathresult{#1}% + \or + \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}% + \let\pgfmathfloatsub@arg=\pgfmathresult + \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}% + \or + \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}% + \let\pgfmathfloatsub@arg=\pgfmathresult + \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}% + \else + \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\let\pgfmathfloatsubtract=\pgfmathfloatsubtract@ + +% Scales a floating point number #1 with a fixed point number #2 using pgfmathmultiply. +% +% Use this method if #2 is small number. +\def\pgfmathfloatmultiplyfixed@#1#2{% + \begingroup + % + % renormalize argument to 100 <= m < 1000 for extended accuracy: + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + \edef\pgfmathresult{#1}% + \pgfmathfloatcomparisonfalse + \or + \or + \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}% + \else + \pgfmathfloatcomparisonfalse + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}% + \fi + \ifpgfmathfloatcomparison + \pgfmathmultiply@{\pgfmathfloat@arga}{#2}% + % renormalize product. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\let\pgfmathfloatmultiplyfixed=\pgfmathfloatmultiplyfixed@ + + +\def\pgfmathfloatmultiply@#1#2{% + \begingroup + \pgfmathfloatsetextprecision{1}% + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloattoextentedprecision@b{#2}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + % 0 + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% + + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{1}% + \or + \def\pgfmathresult@S{2}% + \else + \expandafter\pgfmathfloatcreate\the\pgfmathfloat@b@S{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% - + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{2}% + \or + \def\pgfmathresult@S{1}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% nan + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% +infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% -infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \fi + \ifpgfmathfloatcomparison + \pgfmathmultiply@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatmultiply=\pgfmathfloatmultiply@ + +\def\pgfmathfloatdivide@#1#2{% + \begingroup + \pgfmathfloatsetextprecision{1}% + \pgfmathfloattoextentedprecision@a{#1}% + \let\pgfmathfloat@arga=\pgfmathresult + % + \pgfmathfloattoextentedprecision@b{#2}% + \let\pgfmathfloat@argb=\pgfmathresult + % + \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. + \ifcase\pgfmathfloat@a@S + % 0 + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% + + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{1}% + \or + \def\pgfmathresult@S{2}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \else + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% - + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \def\pgfmathresult@S{2}% + \or + \def\pgfmathresult@S{1}% + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \else + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \or% nan + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or% +infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% what is inf/inf ? + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% or inf/-inf ? + \pgfmathfloatcomparisonfalse + \fi + \or% -infty + \ifcase\pgfmathfloat@b@S + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{3}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{5}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \or + \pgfmathfloatcreate{4}{0.0}{0}% + \pgfmathfloatcomparisonfalse + \fi + \fi + \ifpgfmathfloatcomparison + \pgfmathdivide@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% + \advance\pgfmathfloat@a@E by-\pgfmathfloat@b@E + % renormalize sum. This is the only part were an expensive routine comes into play: + \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloatdivide=\pgfmathfloatdivide@ + +% Converts a composed floating point representation to fixed point. +% +% Example: +% \pgfmathfloattofixed{142e1} +% -> \pgfmathresult = 42.0 +\def\pgfmathfloattofixed@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + \def\pgfmathresult{0.0}% + \or + \expandafter\pgfmathfloattofixed@impl\the\pgfmathfloat@a@Mtok\relax + \or + \expandafter\pgfmathfloattofixed@impl\the\pgfmathfloat@a@Mtok\relax + \edef\pgfmathresult{-\pgfmathresult}% + \or\def\pgfmathresult{nan}% + \or\def\pgfmathresult{inf}% + \or\def\pgfmathresult{-inf}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloattofixed=\pgfmathfloattofixed@ + +% Converts a floating point number to scientific format 1.234e5. +% +% This operation is very fast. +\def\pgfmathfloattosci@#1{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \ifcase\pgfmathfloat@a@S + \def\pgfmathresult{0.0e0}% + \or + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \or + \edef\pgfmathresult{-\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \or\def\pgfmathresult{nan}% + \or\def\pgfmathresult{inf}% + \or\def\pgfmathresult{-inf}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\let\pgfmathfloattosci=\pgfmathfloattosci@ + +% Divides or multiplies the input number by 10^#4 using an arithmetic +% left/right shift. +% +% Input: +% #1 a normalised floating point number. +% #2 a positive or negative integer number denoting the shift. +% +% Example: +% \pgfmathfloatshift{11e3}{4}% +% -> pgfmathresult = 11e7 +\def\pgfmathfloatshift@#1#2{% + \begingroup + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \expandafter\advance\expandafter\pgfmathfloat@a@E#2\relax + \edef\pgfmathresult{\the\pgfmathfloat@a@S\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\let\pgfmathfloatshift=\pgfmathfloatshift@ + +% Computes a good guess for log(X.XXXX) where the input number should +% be between 0 < x < 10. +% +% If it is not in this range, the returned value will be bad. +% +% For use in the newton implementation of log(x). Please note that we +% first compute a normalized floating point representation of x, and +% the mantisse is always between 0 and 10. +\def\pgfmathlog@smaller@ten@newton@startval#1.#2\to#3{% + \ifcase#1 + \pgfmath@error{pgfmathlog@newton: INTERNAL ERROR: should not happen! + [\#1=0 should have been caught before!]}% + \or#3=0.530628pt + \or#3=0.993pt + \or#3=1.308pt + \or#3=1.5pt + \or#3=1.71pt + \or#3=1.872pt + \or#3=2.01pt + \or#3=2.145pt + \or#3=2.24pt + \fi +} + +% FIXME : eliminate \pgfmathlog@invoke@expanded ? + +% Expands #2 using \edef and invokes #1 with the resulting string. +% +% Example: +% \pgfmath@y=7.9pt +% \pgfmathlog@invoke@expanded\pgfmathexp@{{\pgf@sys@tonumber{\pgfmath@y}}}% +% will invoke +% \pgfmathexp@{7.9} +\def\pgfmathlog@invoke@expanded#1#2{% + \edef\pgfmath@resulttemp{#2}% + \expandafter#1\pgfmath@resulttemp +} + +% This implementation of log(X) is done with a newton method applied to x-exp(y) = 0. +% The implementation \pgfmathexp is used for exp(y). +% +% see \pgfmathlog@ +\def\pgfmathlog@newton#1{% + \pgfmathfloatparsenumber{#1}% + \pgfmathlog@newton@float{\pgfmathresult}% +} + +% the same as \pgfmathlog@newton, but this one takes a floating point number as input. +\def\pgfmathlog@newton@float#1{% + \begingroup% + % compute #1 = M*10^E with normalised mantisse M = [+-]*[1-9].XXXXX + \expandafter\pgfmathfloat@decompose#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E + \let\pgfmathlog@loopcount=\pgfmathfloat@b@S% this counter is not used here... use it as loop counter. + % + \ifnum\pgfmathfloat@a@S=1 + % Now, compute log(#1) = log(M) + E*log(10) + \expandafter\pgfmathlog@smaller@ten@newton@startval\the\pgfmathfloat@a@M.\to\pgfmathfloat@b@M + \pgfmathlog@loopcount=0 + \pgfutil@loop + \ifnum\pgfmathlog@loopcount<3 + \pgfmathlog@invoke@expanded\pgfmathexp@{{\pgf@sys@tonumber{\pgfmathfloat@b@M}}}% + \let\pgfmathlog@tmp=\pgfmathresult + \pgfmathlog@invoke@expanded\pgfmathdivide@{{\pgf@sys@tonumber{\pgfmathfloat@a@M}}{\pgfmathlog@tmp}}% + \expandafter\pgfmath@ya\pgfmathresult pt + \advance\pgfmathfloat@b@M by\pgfmath@ya + \advance\pgfmathfloat@b@M by-1pt + \advance\pgfmathlog@loopcount by1 + \pgfutil@repeat + \pgfmathfloat@a@M=2.302585pt% = log(10) + \multiply\expandafter\pgfmathfloat@a@M\pgfmathfloat@a@E + \advance\pgfmathfloat@b@M by\pgfmathfloat@a@M + \edef\pgfmathresult{\pgf@sys@tonumber{\pgfmathfloat@b@M}}% + \else + \let\pgfmathresult=\pgfutil@empty% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup% +} + +% Computes log(x) into \pgfmathresult. +% +% REMARK +% This method does NOT use TeX Registers to represent the numbers! The +% computation is COMPLETELY STRING BASED. +% This allows numbers such at 10000000 or 5.23e-10 to be represented +% properly, although TeX-registers would produce overflow/underflow +% errors in these cases. +% +% The natural logarithm is computed using log(X*10^Y) = log(X) + log(10)*Y +\let\pgfmathlog@=\pgfmathlog@newton + +\let\pgfmathlog@float=\pgfmathlog@newton@float + +% Public interface method. This is expected to use \pgfmathparse but +% it DOESN'T do that. \pgfmathparse naturally can't handle numbers +% which exceed TeX's numerical capabilities. However, exponentials are +% typically either too large or too small for TeX. +% +% @see \pgfmathnormalisedfloatingpoint for how we parse arguments. +% @see \pgfmathlog@ +\let\pgfmathlog=\pgfmathlog@newton + +% Rounds a fixed point number #1 to \pgfmathfloat@round@precision digits precision and returns +% the result into \pgfmathresult. +% +% Any trailing zeros after the period are discarded. +% See \pgfmathroundtozerofill if you want trailing zeros and fixed +% width. +% +% This method is PURELY text based and can work with arbirtrary +% precision (well, limited to TeX's stack size and integer size). +% +% Examples: +% \pgfmathroundto{1} +% -> \pgfmathresult = '1' +% +% \pgfmathroundto{19999.9996} +% -> \pgfmathresult = '20000' +% +% Arguments: +% #1 may be either a number or a macro expanding to a number. +% +% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set. +\def\pgfmathroundto#1{% + \pgfmathfloatroundhasperiodtrue + \begingroup + \pgfmathfloat@fixed@digits@after@periodfalse + \pgfmathroundto@impl{#1}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + + +% Overloaded method. +% +% This variant always uses a FIXED number behind the period and fills +% in zeros if necessary. +% Examples: +% \pgfmathroundtozerofill{1} +% -> \pgfmathresult = '1.00' +% +% \pgfmathroundtozerofill{19999.9996} +% -> \pgfmathresult = '20000.00' +% +% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set. +\def\pgfmathroundtozerofill#1{% + \pgfmathfloatroundhasperiodtrue + \begingroup + \pgfmathfloat@fixed@digits@after@periodtrue + \pgfmathroundto@impl{#1}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +% see \pgfmathprintnumber@fixed@style for docs +\def\pgfmathprintnumber@fixed@styleDEFAULT#1#2#3e#4\relax{% + \begingroup + \pgfkeysgetvalue{/pgf/number format/set decimal separator}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP + \pgfkeysgetvalue{/pgf/number format/@dec sep mark}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK + \pgfkeysgetvalue{/pgf/number format/set thousands separator}\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP + \c@pgf@counta=#4\relax + \def\pgfmathresult{}% + \ifpgfmathfloatroundhasperiod + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@period#1\pgfmathfloat@EOI + \else + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI% + \begingroup + \toks0=\expandafter{\pgfmathresult}% + \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@period#1.#2\pgfmathfloat@EOI{% + \ifpgfmathprintnumberskipzeroperiod + \def\pgfmathfloat@loc@TMPb{#1}% + \ifx\pgfmathfloatparsenumber@tok@ZERO\pgfmathfloat@loc@TMPb + \else + \def\pgfmathfloat@loc@TMPc{-0}% + \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb + \def\pgfmathresult{-}% + \else + \def\pgfmathfloat@loc@TMPc{+0}% + \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb + \def\pgfmathresult{+}% + \else + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI + \fi + \fi + \fi + \else + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI + \fi + \begingroup + \toks0=\expandafter{\pgfmathresult}% + \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}% + \toks2=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP #2}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 }% + \endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP +}% +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod{% + \ifx\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP\pgfutil@empty + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}% + \else + \ifnum\c@pgf@counta<0\relax + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}% + \else + \advance\c@pgf@counta by1% counta:= total number of digits, N. + \c@pgf@countb=\c@pgf@counta + \divide\c@pgf@countb by3% countb := N DIV 3 + \c@pgf@countc=\c@pgf@countb + \multiply\c@pgf@countc by3 + \advance\c@pgf@counta by-\c@pgf@countc% now counta := N MOD 3 + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printsign + }% + \fi + \fi + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printsign#1{% + \def\pgfmathfloat@loc@TMPb{#1}% + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@MINUS + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}% + \let\pgfmathfloat@loc@TMPb=\pgfutil@empty + \else + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@PLUS + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}% + \let\pgfmathfloat@loc@TMPb=\pgfutil@empty + \else + \ifpgfmathprintnumber@showpositive + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult +}% + \fi + \fi + \fi + \ifnum\c@pgf@counta>0 + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printtrailingdigits\pgfmathfloat@loc@TMPb + }% + \else + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird\pgfmathfloat@loc@TMPb + }% + \fi + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printtrailingdigits#1#2{% + \ifcase\c@pgf@counta + \or + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}% + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird#2% + }% + \or + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1#2}% + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird% + }% + \fi + \ifnum\c@pgf@countb>0\relax + \begingroup + \toks0=\expandafter{\pgfmathresult}% + \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \fi + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird#1#2#3{% + \ifnum\c@pgf@countb>0\relax + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1#2#3}% + \advance\c@pgf@countb by-1 + \ifnum\c@pgf@countb>0\relax + \begingroup + \toks0=\expandafter{\pgfmathresult}% + \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \endgroup + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \fi + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird% + }% + \else + % in thise case, #1#2#3 are expected to be + % \pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI + %-------------------------------------------------- + % \def\pgfmathfloat@loc@TMPb{\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI}% + % \def\pgfmathfloat@loc@TMPc{#1#2#3}% + % \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb + % \else + % \pgfmath@error{INTERNAL ERROR in fixed style - The input sequence did not terminate as expected; which indicates a wrong exponent argument provided to \string\pgfmathprintnumber@fixed@style}% + % \fi + %-------------------------------------------------- + \let\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT=\relax + \fi + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall#1{% + \def\pgfmathfloat@loc@TMPb{#1}% + \let\pgfmathfloat@loc@TMPc=\pgfutil@empty + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@MINUS + \else + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@PLUS + \else + \ifpgfmathprintnumber@showpositive + \def\pgfmathfloat@loc@TMPc{+}% + \fi + \fi + \fi + \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall@\pgfmathfloat@loc@TMPc#1% +} +\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall@#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI{% + \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}% +}% + +% #1 maybe a macro +\def\pgfmathprintnumber@fixed@stylePERIOD#1#2#3e#4\relax{% + \def\pgfmathresult{#1}% +} + +% #1 maybe a macro +\def\pgfmathprintnumber@fixed@styleCOMMA#1#2#3e#4\relax{% + \ifpgfmathfloatroundhasperiod + \expandafter\pgfmathprintnumber@fixed@styleCOMMA@impl#1\pgfmathfloat@EOI + \else + \def\pgfmathresult{#1}% + \fi +} +\def\pgfmathprintnumber@fixed@styleCOMMA@impl#1.#2\pgfmathfloat@EOI{\def\pgfmathresult{#1{,}#2}} + +% The default style to display fixed point numbers. +% +% It does not apply numerics, but it is responsable to typeset the +% rounded number. +% It can access the \ifpgfmathfloatroundhasperiod boolean. +% +% Arguments: +% #1#2#3e#4\relax + +% Input: +% #1 the fixed point number to be displayed (maybe a macro). +% #2#3e#4: the (possibly unformatted) floating point representation which belongs to #1. +% It is used to determine sign and exponent. +\let\pgfmathprintnumber@fixed@style=\pgfmathprintnumber@fixed@styleDEFAULT + + +% Rounds a normalized floating point number to \pgfmathfloat@round@precision +% digits precision and writes the result to \pgfmathresult. +% +% This method uses \pgfmathroundto for the mantisse. +% +% @see pgfmathfloatroundzerofill +% +% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set to +% whether the final mantisse #5 has a period or not. +\def\pgfmathfloatround#1{% + \pgfmathfloatroundhasperiodtrue + \begingroup + \pgfmathfloat@fixed@digits@after@periodfalse + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatround@impl + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +% Overload. +% +% This method uses a fixed width for the mantisse and fills in zeros +% if necessary. +% +% This method uses \pgfmathroundtozerofill for the mantisse. +% +% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set to +% whether the final mantisse #5 has a period or not. +\def\pgfmathfloatroundzerofill#1{% + \pgfmathfloatroundhasperiodtrue + \begingroup + \pgfmathfloat@fixed@digits@after@periodtrue + \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \pgfmathfloatround@impl + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\newif\ifpgfmathfloatround@allow@empty@mantisse +\def\pgfmathfloatround@mantisse@ONE{1.0}% + +% #1: sign +% #2: mantisse +% #3: exponent +% #4: CODE to display if the mantisse is drawn. +% #5: CODE to display if the mantisse is NOT draw. (unused) +% #6: CODE to display the exponent. +\def\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax#4#5#6{% + \pgfkeysgetvalue{/pgf/number format/@sci exponent mark}\pgfmathfloatrounddisplaystyle@e@mark + \ifcase#1\relax + \pgfmathprintnumber@fixed@style{#2}#1#2e0\relax% + \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \or\pgfmathprintnumber@fixed@style{#2}#1#2e0\relax% + \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \or\pgfmathprintnumber@fixed@style{-#2}#1#2e0\relax% + \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \or + \pgfmathfloatrounddisplaystyle@shared@impl@{NaN}{}% + \or + \ifpgfmathprintnumber@showpositive + \pgfmathfloatrounddisplaystyle@shared@impl@{+\infty}{}% + \else + \pgfmathfloatrounddisplaystyle@shared@impl@{\infty}{}% + \fi + \or + \pgfmathfloatrounddisplaystyle@shared@impl@{-\infty}{}% + \fi +} + +% #1: the part before the exponent code +% #2: the part for the exponent code. +\def\pgfmathfloatrounddisplaystyle@shared@impl@#1#2{% + {\toks0={#1}% + \toks1=\expandafter{\pgfmathfloatrounddisplaystyle@e@mark #2}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + }% + \let\pgfmathresult=\pgfmathfloat@glob@TMP +}% + +\def\pgfmathfloatrounddisplaystyle@std#1#2e#3\relax{% + \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{\cdot}{}{10^{#3}}% +} +\def\pgfmathfloatrounddisplaystyle@subscript#1#2e#3\relax{% + \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}{_{#3}}% +} +\def\pgfmathfloatrounddisplaystyle@e#1#2e#3\relax{% + \ifnum#3<0\relax + {\count0=#3\relax + \multiply\count0 by-1 + \xdef\pgfmathfloat@glob@TMP{e{-}\the\count0}% + }% + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \else + \def\pgfmathresult{e{+}#3}% + \fi + \def\pgfmathfloat@loc@TMPb{\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}}% + \expandafter\pgfmathfloat@loc@TMPb\expandafter{\pgfmathresult}% +} +\def\pgfmathfloatrounddisplaystyle@E#1#2e#3\relax{% + \ifnum#3<0\relax + {\count0=#3\relax + \multiply\count0 by-1 + \xdef\pgfmathfloat@glob@TMP{E{-}\the\count0}% + }% + \let\pgfmathresult=\pgfmathfloat@glob@TMP + \else + \def\pgfmathresult{E{+}#3}% + \fi + \def\pgfmathfloat@loc@TMPb{\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}}% + \expandafter\pgfmathfloat@loc@TMPb\expandafter{\pgfmathresult}% +} + +% A macro which takes three arguments, sign, mantisse and exponent and +% expands to the final TeX-representation for that floating point +% number. +% +% PRECONDITION: +% the floating point number has already been rounded properly and +% the mantisse has been rounded correcty. +% +% #1: SIGN +% #2: MANTISSE +% #3: EXPONENT +\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std +\newif\ifpgfmathfloat@usezerofill@sci +\newif\ifpgfmathfloat@usezerofill@fixed +\newif\ifpgfmathprintnumber@assumemathmode +\newif\ifpgfmathprintnumber@showpositive + +\pgfkeys{% + /pgf/number format/.is family, + /pgf/number format, + fixed/.code= \pgfmath@set@number@printer{pgfmathprintnumber@FIXED}, + sci/.code= \pgfmath@set@number@printer{pgfmathprintnumber@SCI}, + std/.code= \pgfmath@set@number@printer{pgfmathprintnumber@STD}, + int detect/.code= \pgfmath@set@number@printer{pgfmathprintnumber@INT@DETECT}, + int trunc/.code= \pgfmath@set@number@printer{pgfmathprintnumber@INT@TRUNC}, + assume math mode/.is if=pgfmathprintnumber@assumemathmode, + assume math mode/.default=true, + fixed zerofill/.is if= pgfmathfloat@usezerofill@fixed, + fixed zerofill/.default=true, + sci zerofill/.is if= pgfmathfloat@usezerofill@sci, + sci zerofill/.default=true, + zerofill/.style= {/pgf/number format/fixed zerofill=#1,/pgf/number format/sci zerofill=#1}, + zerofill/.default= true, + precision/.store in= \pgfmathfloat@round@precision, + fixed default/.code= {\let\pgfmathprintnumber@fixed@style=\pgfmathprintnumber@fixed@styleDEFAULT}, + set decimal separator/.initial=, + dec sep/.style={/pgf/number format/set decimal separator=#1}, + @dec sep mark/.initial=, + @sci exponent mark/.initial=, + set thousands separator/.initial=, + 1000 sep/.style={/pgf/number format/set thousands separator=#1}, + use period/.style= {/pgf/number format/set decimal separator={.},/pgf/number format/set thousands separator={{{,}}}}, + use comma/.style= {/pgf/number format/set decimal separator={{{,}}},/pgf/number format/set thousands separator={.}}, + showpos/.is if=pgfmathprintnumber@showpositive, + showpos/.default=true, + print sign/.is if=pgfmathprintnumber@showpositive, + print sign/.default=true, + skip 0./.is if=pgfmathprintnumberskipzeroperiod, + skip 0./.default=true, + skip 0.= false, + use period, + sci 10^e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std}, + sci 10e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std}, + sci e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@e}, + sci E/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@E}, + sci subscript/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@subscript}, +% sci may skip mantisse/.is if=pgfmathfloatround@allow@empty@mantisse, +% sci may skip mantisse/.default=true, +} + + + +\def\pgfmathprintnumber@STD#1{% + % parse the input: + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmathprintnumber@STD@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@STD@issci#1#2e#3\relax{% + \expandafter\ifnum#1<3 + \expandafter\ifnum#3>4 + \pgfmathprintnumber@SCI@issci#1#2e#3\relax% + \else + \begingroup + \c@pgf@counta=\pgfmathfloat@round@precision\relax + \divide\c@pgf@counta by-2\relax + \ifnum#3<\c@pgf@counta + \pgfmathprintnumber@SCI@issci#1#2e#3\relax% + \else + \pgfmathprintnumber@FIXED@issci#1#2e#3\relax% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup + \fi + \else% nan or inf: + \pgfmathfloatrounddisplaystyle#1#2e#3\relax% + \fi +} + + +\def\pgfmathprintnumber@INT@TRUNC#1{% + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmathprintnumber@INT@TRUNC@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@INT@TRUNC@impl#1.#2\relax#3#4e#5\relax{% + \pgfmathfloatroundhasperiodfalse + \pgfmathprintnumber@fixed@style{#1}#3#4e#5\relax% +} +\def\pgfmathprintnumber@INT@TRUNC@issci#1#2e#3\relax{% + \ifnum#1<3\relax + \pgfmathfloattofixed{#1#2e#3}% + \expandafter\pgfmathprintnumber@INT@TRUNC@impl\pgfmathresult\relax#1#2e#3\relax + \else + \pgfmathfloatrounddisplaystyle#1#2e#3\relax% + \fi +} + + +\def\pgfmathprintnumber@INT@DETECT#1{% + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmathprintnumber@INT@DETECT@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@INT@DETECT@issci#1#2e#3\relax{% + \begingroup + \ifnum#1<3\relax + \pgfmathfloattofixed{#1#2e#3}% + \def\pgfmathfloat@round@precision{6}% + \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% + \ifpgfmathfloatroundhasperiod + \pgfmathprintnumber@SCI@issci#1#2e#3\relax + \else + \expandafter\pgfmathprintnumber@fixed@style\expandafter{\pgfmathresult}#1#2e#3\relax + \fi + \else + \pgfmathfloatrounddisplaystyle#1#2e#3\relax% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\def\pgfmathprintnumber@FIXED#1{% + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmathprintnumber@FIXED@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@FIXED@issci#1#2e#3\relax{% + \begingroup + \ifnum#1<3 + \pgfmathfloattofixed{#1#2e#3}% + \ifpgfmathfloat@usezerofill@fixed + \expandafter\pgfmathroundtozerofill\expandafter{\pgfmathresult}% + \else + \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% + \fi + \ifpgfmathfloatroundmayneedrenormalize + \pgfmathfloat@a@E=#3\relax + \advance\pgfmathfloat@a@E by1 + \edef\pgfmathfloat@loc@TMPb{\noexpand\pgfmathprintnumber@fixed@style{\pgfmathresult}#1#2e\the\pgfmathfloat@a@E}% + \pgfmathfloat@loc@TMPb\relax% + \else + \expandafter\pgfmathprintnumber@fixed@style\expandafter{\pgfmathresult}#1#2e#3\relax% + \fi + \else% nan or inf: + \pgfmathfloatrounddisplaystyle#1#2e#3\relax% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + + +\def\pgfmathprintnumber@SCI#1{% + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmathprintnumber@SCI@issci\pgfmathresult\relax +} + +\def\pgfmathprintnumber@SCI@issci#1#2e#3\relax{% + \ifpgfmathfloat@usezerofill@sci + \pgfmathfloatroundzerofill{#1#2e#3}% + \else + \pgfmathfloatround{#1#2e#3}% + \fi + \expandafter\pgfmathfloatrounddisplaystyle\pgfmathresult\relax +} + +% Prints argument #1 using the current pretty printer environment (all +% variables in /pgf/number format). +% +% You may specify optional arguments with \pgfmathprintnumber[...]. +\def\pgfmathprintnumber{% + \pgfutil@ifnextchar[% + {\pgfmathprintnumber@OPT}% + {\pgfmathprintnumber@noopt}% +} + +\def\pgfmathprintnumber@noopt#1{% + \pgfmathprintnumber@{#1}% + \ifpgfmathprintnumber@assumemathmode + \else + \pgfutilensuremath{\pgfmathresult}% + \fi +}% +\def\pgfmathprintnumber@OPT[#1]#2{% + \begingroup + \pgfqkeys{/pgf/number format}{#1}% + \pgfmathprintnumber@{#2}% + \ifpgfmathprintnumber@assumemathmode + \else + \pgfutilensuremath{\pgfmathresult}% + \fi + \endgroup +}% + +% As \pgfmathprintnumber, but it produces its output into the second +% argument. +\def\pgfmathprintnumberto{% + \pgfutil@ifnextchar[% + {\pgfmathprintnumberto@OPT}% + {\pgfmathprintnumberto@noopt}% +} + +\def\pgfmathprintnumberto@noopt#1#2{% + \begingroup + \pgfmathprintnumber@{#1}% + \ifpgfmathprintnumber@assumemathmode + \global\let\pgfmathfloat@glob@TMP=\pgfmathresult + \else + \toks0=\expandafter{\pgfmathresult}% + \xdef\pgfmathfloat@glob@TMP{\noexpand\pgfutilensuremath{\the\toks0 }}% + \fi + \endgroup + \let#2=\pgfmathfloat@glob@TMP +}% +\def\pgfmathprintnumberto@OPT[#1]#2#3{% + \begingroup + \pgfqkeys{/pgf/number format}{#1}% + \pgfmathprintnumber@{#2}% + \ifpgfmathprintnumber@assumemathmode + \global\let\pgfmathfloat@glob@TMP=\pgfmathresult + \else + \toks0=\expandafter{\pgfmathresult}% + \xdef\pgfmathfloat@glob@TMP{\noexpand\pgfutilensuremath{\the\toks0 }}% + \fi + \endgroup + \let#3=\pgfmathfloat@glob@TMP +}% + + +% Changes the current number pretty printer to #1. +% +% #1 is the macro base name for the pretty print routine, without the +% leading '\'. +\def\pgfmath@set@number@printer#1{% + \expandafter\let\expandafter\pgfmathprintnumber@\csname #1\endcsname + \expandafter\let\expandafter\pgfmathprintnumber@issci\csname #1@issci\endcsname +} + +\pgfmath@set@number@printer{pgfmathprintnumber@STD} +%\pgfmath@set@number@printer{pgfmathprintnumber@FIXED} +%\pgfmath@set@number@printer{pgfmathprintnumber@FIXED@ZEROFILL} +%\pgfmath@set@number@printer{pgfmathprintnumber@SCI@ZEROFILL} +%\pgfmath@set@number@printer{pgfmathprintnumber@SCI} + +%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% IMPL +% +%%%%%%%%%%%%%%%%%%%%%%%%%% + +% equals only itsself when compared with \ifx: +\def\pgfmathfloat@EOI{\pgfmathfloat@EOI}% + +% Re-use counters internally. +% +% They are always grouped and only used inside of the rounding +% routines. +\let\c@pgfmathroundto@prec=\pgfmathfloat@b@S% ATTENTION: DOUBLE-USED REGISTERS! +\let\c@pgfmathroundto@offsetbehindperiod=\pgfmathfloat@b@E +\newcount\c@pgfmathroundto@lastzeros + +\newif\ifpgfmathround@impl@PREPERIOD@is@negative@zero + +% PRECONDITION: +% \ifpgfmathfloatroundhasperiod=\iftrue holds outside of the +% current TeX group. +% +% POSTCONDITION: +% \ifpgfmathfloatroundhasperiod will be set correctly AFTER the +% current TeX group. +% \ifpgfmathfloatroundmayneedrenormalize will be set globally +\def\pgfmathroundto@impl#1{% + \global\pgfmathfloatroundmayneedrenormalizefalse + \pgfmathfloat@tmptoks={}% + \let\pgfmathround@next=\pgfutil@empty + \let\pgfmathround@cur=\pgfutil@empty + \let\pgfmathresult=\pgfutil@empty + \edef\pgfmathround@input{#1}% + \expandafter\c@pgfmathroundto@prec\pgfmathfloat@round@precision\relax + \c@pgfmathroundto@lastzeros=0 + \c@pgfmathroundto@offsetbehindperiod=-1 % means: no period found so far + \pgfmathround@impl@PREPERIOD@is@negative@zerotrue + \expandafter\pgfmathroundto@impl@ITERATE@NODOT@firstcall\pgfmathround@input\pgfmathfloat@EOI +} + +% \pgfmathroundto implementation in WORDS: +% +% coarse idea: +% 1. collect all digits/sign BEFORE the first period in REVERSE order +% 2. then, collect UP TO \prec digits after the period in REVERSE order +% Steps 1. and 2. lead to the digit [sign] sequence +% "x_{-p} x_{-p+1} ... x_{-2} x_{-1} '.' x_0 ... x_r" +% where 'r' is the total number of digits. The integer 'p' denotes the +% ACTUALLY collected number of digits behind the period. +% +% Let 'k' be the desired precision. +% +% Please note that pgfmathroundto rounds the mantisse, that means |abs(x)|. +% +% There are exactly TWO cases: +% 1. The case with p<=k and x_{-p-1} = end of input. +% 2. The case with p=k and x_{-p-1} is a further, next character. +% +% Then, for case 1.): +% discard any unused zeros at the tail of our number (possibly +% including the period) +% +% and in case 2.) +% if NEXT DIGIT < 5: +% do exactly the same as in case 1.) above and discard any +% following digits. +% else +% let q := -p +% while(x_q = 9 and q<=r ) +% if q>=0 +% set x_q = '0' +% else +% discard digit x_q='9' +% fi +% ++q +% if q=0 +% discard the period +% fi +% end while +% if q = r+1 +% insert a '1' +% else +% set x_q = x_q + 1 +% fi +% fi +% +% All these loops have been implemented in spaghetti-code below. +% Sorry, I fear its hard to understand. In principle, everything is +% realised using more or less finite state machines (with some number +% counting logic). +% +% Some comments: +% - The token register \pgfmathfloat@tmptoks is used to accumulate the REVERSED input number. +% - \pgfmathfloat@EOI always denotes 'END OF INPUT'. +% - in the second stage, we need to reverse \pgfmathfloat@tmptoks. +% This is -again- done with \pgfmathfloat@tmptoks. + +\def\pgfmathroundto@impl@discard@period#1.#2\pgfmathfloat@EOI{% + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \def\pgfmathresult{#1}% +} + +\def\pgfmathroundto@impl@gobble@rest@and@start#1\pgfmathfloat@EOI{% + \pgfmathroundto@impl@start +} +\def\pgfmathroundto@impl@gobble@and@start\pgfmathfloat@EOI{% + \pgfmathroundto@impl@start +} +\def\pgfmathroundto@impl@gobble\pgfmathfloat@EOI{}% +\def\pgfmathroundto@impl@gobble@rest#1\pgfmathfloat@EOI{}% + +% This method will be invoked as soon as the first step, the reverse +% collection of up to PREC digits after the period, has finished. +\def\pgfmathroundto@impl@start{% + \ifx\pgfmathround@next\pgfutil@empty + \ifnum\c@pgfmathroundto@offsetbehindperiod<0 + % no period found. + \ifpgfmathfloat@fixed@digits@after@period + \ifnum\c@pgfmathroundto@prec=0\relax + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \edef\pgfmathresult{\pgfmathround@input}% + \else + \pgfmathfloat@tmptoks=\expandafter{\pgfmathround@input.}% + \c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec + \pgfmathroundto@impl@append@zeros + \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}% + \fi + \else + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \edef\pgfmathresult{\pgfmathround@input}% + \fi + \else + %\ifnum\c@pgfmathroundto@offsetbehindperiod>\c@pgfmathroundto@prec + % \pgfmath@error{Internal logic error in pgfmathroundto at [I] - should not have happened!?}% + %\fi + \pgfmathroundto@impl@finish@with@truncation + \fi + \else + %\ifnum\c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec + %\else + % \pgfmath@error{Internal logic error in pgfmathroundto at [II] - should not have happened!? I have offsetbehindperiod=\the\c@pgfmathroundto@offsetbehindperiod and prec = \the\c@pgfmathroundto@prec}% + %\fi + \expandafter\ifnum\pgfmathround@next<5\relax + \pgfmathroundto@impl@finish@with@truncation + \else + \multiply\c@pgfmathroundto@offsetbehindperiod by-1 + \expandafter\pgfmathroundto@impl@ADD@ONE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \fi + \fi +} + +% takes the current input and decides whether trailing zeros shall be +% discarded or more zeros need to be filled in. +\def\pgfmathroundto@impl@finish@with@truncation{% + \ifpgfmathfloat@fixed@digits@after@period + \expandafter\pgfmathroundto@impl@REVERSE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \ifnum\c@pgfmathroundto@lastzeros=\c@pgfmathroundto@offsetbehindperiod + \ifpgfmathround@impl@PREPERIOD@is@negative@zero + % write '0.0000' instead of '-0.0000': + \expandafter\pgfmathroundto@impl@discard@minus\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \fi + \fi + \ifnum\c@pgfmathroundto@prec=0\relax + \expandafter\pgfmathroundto@impl@discard@period\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \else + \advance\c@pgfmathroundto@prec by-\c@pgfmathroundto@offsetbehindperiod + \c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec + \pgfmathroundto@impl@append@zeros + \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}% + \fi + \else + \pgfmathroundto@impl@discard@suffix@zeros + \fi +} + +\def\pgfmathroundto@impl@discard@minus-#1\pgfmathfloat@EOI{\pgfmathfloat@tmptoks={#1}}% + +% appends \c@pgfmathroundto@offsetbehindperiod zeros at the end of \pgfmathfloat@tmptoks. +\def\pgfmathroundto@impl@append@zeros{% + \ifnum\c@pgfmathroundto@offsetbehindperiod>0 + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \advance\c@pgfmathroundto@offsetbehindperiod by-1 + \pgfmathroundto@impl@append@zeros + \fi +} + +\def\pgfmathroundto@impl@ADD@ONE{% + \pgfmathfloat@tmptoks={}% no longer needed because its old value will be read from input + \pgfmathroundto@impl@ADD@ONE@ITERATE +} +\def\pgfmathroundto@impl@ADD@ONE@ITERATE{% + \pgfutil@ifnextchar\pgfmathfloat@EOI{% + \global\pgfmathfloatroundmayneedrenormalizetrue + \edef\pgfmathresult{1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@gobble + }{% + \pgfutil@ifnextchar.{% + \ifnum\c@pgfmathroundto@prec=0 + % silently discard period in special case precision=0 + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot}% + \else + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@NEXT@COLLECT}% + \fi + \pgfmathround@nextcmd + }{% + \pgfutil@ifnextchar+{% + \global\pgfmathfloatroundmayneedrenormalizetrue + \edef\pgfmathresult{1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@gobble@rest + }{% + \pgfutil@ifnextchar-{% + \global\pgfmathfloatroundmayneedrenormalizetrue + \edef\pgfmathresult{-1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@gobble@rest + }{% + \pgfmathroundto@impl@ADD@ONE@NEXT + }% + }% + }% + }% +} + +\def\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot.{% + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \pgfmathroundto@impl@ADD@ONE@ITERATE +} + +\def\pgfmathroundto@impl@ADD@ONE@NEXT@COLLECT#1{% + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@ADD@ONE@ITERATE +} +\def\pgfmathroundto@impl@ADD@ONE@NEXT#1{% + \ifnum#1=9 + \ifnum\c@pgfmathroundto@offsetbehindperiod<0 + \ifpgfmathfloat@fixed@digits@after@period + \pgfmathfloat@tmptoks=\expandafter{\expandafter0\the\pgfmathfloat@tmptoks}% + \else + % silently DROP digit + \fi + \else + \pgfmathfloat@tmptoks=\expandafter{\expandafter0\the\pgfmathfloat@tmptoks}% + \fi + \advance\c@pgfmathroundto@offsetbehindperiod by1 + \ifnum\c@pgfmathroundto@offsetbehindperiod=0 + \ifpgfmathfloat@fixed@digits@after@period + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE}% + \else + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot}% + \fi + \else + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE}% + \fi + \else + % re-use this counter: + \c@pgfmathroundto@lastzeros=#1 + \advance\c@pgfmathroundto@lastzeros by1 + \edef\pgfmathresult{\the\c@pgfmathroundto@lastzeros\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks=\expandafter{\pgfmathresult}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@REVERSE@ITERATE}% + \fi + \pgfmathround@nextcmd +} + + +\def\pgfmathroundto@impl@discard@suffix@zeros{% + \ifnum\c@pgfmathroundto@lastzeros=\c@pgfmathroundto@offsetbehindperiod + \ifpgfmathround@impl@PREPERIOD@is@negative@zero + \pgfmathfloatroundhasperiodfalse + \aftergroup\pgfmathfloatroundhasperiodfalse + \def\pgfmathresult{0}% write '0' instead of '-0' + \else + \expandafter\pgfmathroundto@impl@discard@period\pgfmathround@input\pgfmathfloat@EOI + \fi + \else + \ifnum\c@pgfmathroundto@lastzeros=0 + \expandafter\pgfmathroundto@impl@REVERSE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \else + \expandafter\pgfmathroundto@impl@discard@suffix@zeros@ITERATE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI + \fi + \fi +} + +% PRECONDITION: +% \c@pgfmathroundto@lastzeros > 0 +\def\pgfmathroundto@impl@discard@suffix@zeros@ITERATE#1{% + \advance\c@pgfmathroundto@lastzeros by-1 + \ifnum\c@pgfmathroundto@lastzeros=0 + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@REVERSE}% + \else + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@discard@suffix@zeros@ITERATE}% + \fi + \pgfmathround@nextcmd +} + +% Usage: +% \pgfmathroundto@impl@REVERSE#1\pgfmathfloat@EOI +% -> writes #1 reversed into \pgfmathfloat@tmptoks +\def\pgfmathroundto@impl@REVERSE{% + \pgfmathfloat@tmptoks={}% + \pgfmathroundto@impl@REVERSE@ITERATE +} + +\def\pgfmathroundto@impl@REVERSE@ITERATE{% + \pgfutil@ifnextchar\pgfmathfloat@EOI{% + \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@gobble + }{% + \pgfmathroundto@impl@REVERSE@NEXT + }% +} + +\def\pgfmathroundto@impl@REVERSE@NEXT#1{% + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \pgfmathroundto@impl@REVERSE@ITERATE +} + +\def\pgfmathroundto@impl@BEGIN@DOT.{% + \pgfmathfloat@tmptoks=\expandafter{\expandafter.\the\pgfmathfloat@tmptoks}% + \c@pgfmathroundto@offsetbehindperiod=0 + \pgfmathroundto@impl@ITERATE@DOT +} +\def\pgfmathroundto@impl@ITERATE@DOT{% + \pgfutil@ifnextchar\pgfmathfloat@EOI{% + % finished. + \pgfmathroundto@impl@gobble@and@start + }{% + \pgfmathroundto@impl@NEXT@DOT + }% +} +\def\pgfmathroundto@impl@NEXT@DOT#1{% + \ifnum\c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec + \def\pgfmathround@next{#1}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@gobble@rest@and@start}% + \else + \advance\c@pgfmathroundto@offsetbehindperiod by1 + \ifnum#1=0 + \advance\c@pgfmathroundto@lastzeros by1 + \else + \c@pgfmathroundto@lastzeros=0 + \fi + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@DOT}% + \fi + \pgfmathround@nextcmd +}% + +% in contrast to pgfmathroundto@impl@ITERATE@NODOT, this method here +% checks also for signs +\def\pgfmathroundto@impl@ITERATE@NODOT@firstcall#1{% + \def\pgfmathround@cur{#1}% + \ifx\pgfmathround@cur\pgfmathfloat@EOI + \pgfmathround@impl@PREPERIOD@is@negative@zerofalse + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@start}% + \else + \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@PERIOD + \pgfmathround@impl@PREPERIOD@is@negative@zerofalse + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@BEGIN@DOT.}% + \else + \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@MINUS + \else + \pgfmathround@impl@PREPERIOD@is@negative@zerofalse + \fi + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@NODOT}% + \fi + \fi + \pgfmathround@nextcmd +} + +\def\pgfmathroundto@impl@ITERATE@NODOT#1{% + \def\pgfmathround@cur{#1}% + \ifx\pgfmathround@cur\pgfmathfloat@EOI + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@start}% + \else + \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@PERIOD + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@BEGIN@DOT.}% + \else + \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@ZERO + \else + \pgfmathround@impl@PREPERIOD@is@negative@zerofalse + \fi + \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}% + \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@NODOT}% + \fi + \fi + \pgfmathround@nextcmd +} + +%-------------------------------------------- +% END of pgfmathroundto implementation. +%-------------------------------------------- + + +% flags, mantisse and exponent has already been stored into +% \pgfmathfloat@a@* [using ...@Mtok] +% +% PRECONDITION: +% \ifpgfmathfloatroundhasperiod = \iftrue outside of the current +% group +% +% POSTCONDITION: +% \ifpgfmathfloatroundhasperiod will be set after the current TeX +% group. +\def\pgfmathfloatround@impl{% + \expandafter\pgfmathroundto@impl\expandafter{\the\pgfmathfloat@a@Mtok}% + \ifpgfmathfloatroundmayneedrenormalize + \ifpgfmathfloatroundhasperiod + \expandafter\pgfmathfloatround@impl@renormalize\pgfmathresult\pgfmathfloat@EOI% + \else + \expandafter\pgfmathfloatround@impl@renormalize\pgfmathresult.\pgfmathfloat@EOI% + \fi + \advance\pgfmathfloat@a@E by1 + \fi + \edef\pgfmathresult{\the\pgfmathfloat@a@S\pgfmathresult e\the\pgfmathfloat@a@E}% +} + +\def\pgfmathfloatround@impl@renormalize#1#2.#3\pgfmathfloat@EOI{% + \pgfmathroundto@impl{#1.#2#3}% +} + + + + + +% ATTENTION: this thing REQUIRES a period in the mantisse! +% collects everything into \pgfmathresult +\def\pgfmathfloattofixed@impl#1.#2\relax{% + \ifnum\pgfmathfloat@a@E<0 + \pgfmathfloat@a@Mtok={0.}% + \pgfutil@loop + \ifnum\pgfmathfloat@a@E<-1 + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok 0}% + \advance\pgfmathfloat@a@E by1 + \pgfutil@repeat + \def\pgfmathfloat@loc@TMPb{#2}% + \def\pgfmathfloat@loc@TMPc{0}% + \ifx\pgfmathfloat@loc@TMPb\pgfmathfloat@loc@TMPc + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok #1}% + \else + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok #1#2}% + \fi + \else + \ifnum\pgfmathfloat@a@E=0% + \edef\pgfmathresult{#1.#2}% + \else + \pgfmathfloat@a@Mtok={#1}% + \pgfmathfloattofixed@impl@collectmantisse#2\count\pgfmathfloat@a@E + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}% + \fi + \fi +} + +\def\pgfmathfloattofixed@impl@collectmantisse#1#2\count#3{% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok #1}% + \advance\pgfmathfloat@a@E by-1% + \def\pgfmathfloat@loc@TMPb{#2}% + \ifx\pgfmathfloat@loc@TMPb\pgfutil@empty + \pgfutil@loop + \ifnum\pgfmathfloat@a@E>0% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok 0}% + \advance\pgfmathfloat@a@E by-1% + \pgfutil@repeat + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok .0}% + \else + \ifnum\pgfmathfloat@a@E=0 + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok .#2}% + \else + \pgfmathfloattofixed@impl@collectmantisse#2\count#3% + \fi + \fi +} + + +% ============================================ +% +% +% \pgfmathfloatparsenumber implementation +% +% +% ============================================ + + +% accepted parser tokens: +\def\pgfmathfloatparsenumber@tok@ONE{1} +\def\pgfmathfloatparsenumber@tok@TWO{2} +\def\pgfmathfloatparsenumber@tok@THREE{3} +\def\pgfmathfloatparsenumber@tok@FOUR{4} +\def\pgfmathfloatparsenumber@tok@FIVE{5} +\def\pgfmathfloatparsenumber@tok@SIX{6} +\def\pgfmathfloatparsenumber@tok@SEVEN{7} +\def\pgfmathfloatparsenumber@tok@EIGHT{8} +\def\pgfmathfloatparsenumber@tok@NINE{9} +\def\pgfmathfloatparsenumber@tok@ZERO{0} +\def\pgfmathfloatparsenumber@tok@e{e} +\def\pgfmathfloatparsenumber@tok@E{E} +\def\pgfmathfloatparsenumber@tok@PLUS{+} +\def\pgfmathfloatparsenumber@tok@MINUS{-} +\def\pgfmathfloatparsenumber@tok@n{n} +\def\pgfmathfloatparsenumber@tok@N{N} +\def\pgfmathfloatparsenumber@tok@i{i} +\def\pgfmathfloatparsenumber@tok@I{I} +\def\pgfmathfloatparsenumber@tok@PERIOD{.} + +\newif\ifpgfmathfloatparsenumberpendingperiod + +% Starts a finite-start-machine parser to read a number. +% +% It assigns \pgfmathfloat@a@S, \pgfmathfloat@a@Mtok, \pgfmathfloat@a@E. +\def\pgfmathfloatparsenumber@impl#1{% + \pgfmathfloatparsenumberpendingperiodfalse + \pgfmathfloat@tmptoks={}% this register is used to collect PENDING ZEROS + \pgfmathfloat@a@E=0 + % start parsing: check for sign: + \def\pgfmathfloatparsenumber@curtok{#1}% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@PLUS + \pgfmathfloat@a@S=1\relax% + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@init}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@MINUS + \pgfmathfloat@a@S=2\relax% + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@init}% + \else + \pgfmathfloat@a@S=1\relax% + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@init#1}% + \fi + \fi + \pgfmathfloatparsenumber@NEXT +} + +\def\pgfmathfloatparsenumber@sanitize@digit{% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ONE + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@TWO + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@THREE + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@FOUR + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@FIVE + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@SIX + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@SEVEN + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@EIGHT + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@NINE + \else + \def\pgfmathfloatparsenumber@NEXT{\expandafter\pgfmathfloatparsenumber@impl@error\pgfmathfloatparsenumber@curtok}% + \fi\fi\fi\fi\fi\fi\fi\fi\fi +} + +% FROM: checksign. +% +\def\pgfmathfloatparsenumber@impl@init#1{% + \def\pgfmathfloatparsenumber@curtok{#1}% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@n + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readnan}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@i + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readinf}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@leadingzero}% + \else + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@Mtok={#1}% + \pgfmathfloatparsenumberpendingperiodtrue + \pgfmathfloatparsenumber@impl@positiveexp}% + \pgfmathfloatparsenumber@sanitize@digit + \fi + \fi + \fi + \pgfmathfloatparsenumber@NEXT +} + +\def\pgfmathfloatparsenumber@impl@error#1\pgfmathfloat@EOI{% + \begingroup + \pgfmathfloat@a@Mtok={#1}% + \pgfmath@error{Could not read input number, sorry. The unreadable part was near '\the\pgfmathfloat@a@Mtok'.}% + \endgroup +}% + +\def\pgfmathfloatparsenumber@impl@finish#1\pgfmathfloat@EOI{} + +\def\pgfmathfloatparsenumber@impl@readnan an{% + \pgfmathfloat@a@S=3\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfmathfloatparsenumber@impl@finish +} +\def\pgfmathfloatparsenumber@impl@readinf nf{% + \ifnum\pgfmathfloat@a@S=1 + \pgfmathfloat@a@S=4\relax% + \pgfmathfloat@a@Mtok={0.0}% + \else + \pgfmathfloat@a@S=5\relax% + \pgfmathfloat@a@Mtok={0.0}% + \fi + \pgfmathfloat@a@E=0% + \pgfmathfloatparsenumber@impl@finish +} +\def\pgfmathfloatparsenumber@impl@leadingzero#1{% + \def\pgfmathfloatparsenumber@curtok{#1}% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloatparsenumber@impl@leadingzero}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@PERIOD + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@E=-1 + \pgfmathfloatparsenumber@impl@leadingzero@foundperiod}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + }% + \else + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@Mtok={#1}% + \pgfmathfloatparsenumberpendingperiodtrue + \pgfmathfloatparsenumber@impl@positiveexp}% + \pgfmathfloatparsenumber@sanitize@digit + \fi\fi\fi + \fi + \fi + \pgfmathfloatparsenumber@NEXT +} + +\def\pgfmathfloatparsenumber@impl@leadingzero@foundperiod#1{% + \def\pgfmathfloatparsenumber@curtok{#1}% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO + \def\pgfmathfloatparsenumber@NEXT{% + \advance\pgfmathfloat@a@E by-1 + \pgfmathfloatparsenumber@impl@leadingzero@foundperiod}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + }% + \else + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@a@Mtok={#1}% + \pgfmathfloatparsenumberpendingperiodtrue + \pgfmathfloatparsenumber@impl@finish@number@after@period}% + \pgfmathfloatparsenumber@sanitize@digit + \fi\fi\fi + \fi + \pgfmathfloatparsenumber@NEXT +} + + +\def\pgfmathfloatparsenumber@impl@positiveexp#1{% + \def\pgfmathfloatparsenumber@curtok{#1}% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO + \def\pgfmathfloatparsenumber@NEXT{% + \advance\pgfmathfloat@a@E by1 + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfmathfloatparsenumber@impl@pendingzeros@positiveexp}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@PERIOD + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@finish@number@after@period}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI + \def\pgfmathfloatparsenumber@NEXT{}% + \else + \def\pgfmathfloatparsenumber@NEXT{% + \advance\pgfmathfloat@a@E by1 + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse + \fi + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfmathfloatparsenumber@impl@positiveexp}% + \pgfmathfloatparsenumber@sanitize@digit + \fi\fi\fi + \fi + \fi + \pgfmathfloatparsenumber@NEXT +} + +\def\pgfmathfloatparsenumber@impl@readexponent#1\pgfmathfloat@EOI{% + \advance\pgfmathfloat@a@E by#1\relax +} + +\def\pgfmathfloatparsenumber@impl@pendingzeros@positiveexp#1{% + \def\pgfmathfloatparsenumber@curtok{#1}% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \advance\pgfmathfloat@a@E by1 + \pgfmathfloatparsenumber@impl@pendingzeros@positiveexp}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@PERIOD + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@finish@number@after@period}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI + \def\pgfmathfloatparsenumber@NEXT{}% + \else + \def\pgfmathfloatparsenumber@NEXT{% + \advance\pgfmathfloat@a@E by1 + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse + \fi + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfmathfloatparsenumber@impl@positiveexp}% + \pgfmathfloatparsenumber@sanitize@digit + \fi\fi\fi + \fi + \fi + \pgfmathfloatparsenumber@NEXT +} + +\def\pgfmathfloatparsenumber@impl@finish@number@after@period#1{% + \def\pgfmathfloatparsenumber@curtok{#1}% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfmathfloatparsenumber@impl@pendingzeros}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI + \def\pgfmathfloatparsenumber@NEXT{}% + \else + \def\pgfmathfloatparsenumber@NEXT{% + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse + \fi + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfmathfloatparsenumber@impl@finish@number@after@period}% + \pgfmathfloatparsenumber@sanitize@digit + \fi\fi\fi + \fi + \pgfmathfloatparsenumber@NEXT +} + +\def\pgfmathfloatparsenumber@impl@pendingzeros#1{% + \def\pgfmathfloatparsenumber@curtok{#1}% + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO + \def\pgfmathfloatparsenumber@NEXT{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfmathfloatparsenumber@impl@pendingzeros}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E + \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% + \else + \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI + \def\pgfmathfloatparsenumber@NEXT{}% + \else + \def\pgfmathfloatparsenumber@NEXT{% + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse + \fi + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfmathfloatparsenumber@impl@finish@number@after@period}% + \pgfmathfloatparsenumber@sanitize@digit + \fi\fi\fi + \fi + \pgfmathfloatparsenumber@NEXT +} + + + diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex new file mode 100644 index 00000000000..53b602b0d9a --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex @@ -0,0 +1,7192 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . +% +%-------------------------------------------- + +\input pgfplotsutil.code.tex +\input pgfplotsoldpgfsupp_loader.code.tex +\input pgfplots.stackedplots.code.tex + +\usetikzlibrary{decorations,decorations.pathmorphing,decorations.pathreplacing} + +% FIXME: reduce number of variables! + +\newif\ifpgfplots@xislinear +\newif\ifpgfplots@yislinear +\newcount\pgfplots@numplots +\newdimen\pgfplots@xcoordminTEX +\newdimen\pgfplots@xcoordmaxTEX +\newdimen\pgfplots@ycoordminTEX +\newdimen\pgfplots@ycoordmaxTEX +\newif\ifpgfplots@warn@for@filter@discards +\newif\ifpgfplots@isuniformtick +\newif\ifpgfplots@clip@limits +\newif\ifpgfplots@enlargelimits +\newif\ifpgfplots@enlargelimits@rel@thresh +\newif\ifpgfplots@enlargelimits@auto +\newif\ifpgfplots@tickshow +\newif\ifpgfplots@xminorticks +\newif\ifpgfplots@xmajorticks +\newif\ifpgfplots@yminorticks +\newif\ifpgfplots@ymajorticks +\newif\ifpgfplots@xminorgrids +\newif\ifpgfplots@xmajorgrids +\newif\ifpgfplots@yminorgrids +\newif\ifpgfplots@ymajorgrids +\newif\ifpgfplots@clip@marker@paths +\newif\ifpgfplots@axis@on@top +\newif\ifpgfplots@separate@axis@lines +\newif\ifpgfplots@scaled@ticks@x +\newif\ifpgfplots@scaled@ticks@y +\newif\ifpgfplots@identify@log@minor@tick@pos +\newif\ifpgfplots@disablelogfilter +\newif\ifpgfplots@disabledatascaling +\newif\ifpgfplots@hide@x +\newif\ifpgfplots@hide@y +\newif\ifpgfplots@is@old@list@format +\newif\ifpgfplots@errorbars@enabled +\newif\ifpgfplots@scale@only@axis +\newif\ifpgfplots@xticklabel@interval +\newif\ifpgfplots@yticklabel@interval +\newif\ifpgfplots@stacked@x +\newif\ifpgfplots@stackedmode +\newif\ifpgfplots@stacked@reverse +\newif\ifpgfplots@stacked@plus +\newif\ifpgfplots@plot@file@skipfirst +\let\pgfnodepartimagebox=\pgfnodeparttextbox + +\newif\ifpgfplots@collect@firstplot@astick + +\def\pgfplots@errorbars@xdirection{0}% pre-init, see below +\def\pgfplots@errorbars@ydirection{0}% + +\def\axisdefaultwidth{240pt} +\def\axisdefaultheight{207pt} + + + + +% Creates a named plot cycle list. +% +% #1: the name of the final list. Can be used in 'cycle list name' +% #2: the list entries. You can use either a comma-separated list or +% a '\\'-terminated list. The latter case also requires '\\' +% AFTER the last entry. +\def\pgfcreateplotcyclelist#1#2{\pgfplots@assign@list#1{#2}} + +\pgfcreateplotcyclelist{\blackwhiteplotspeclist}{% + every mark/.append style={fill=gray},mark=*\\% + every mark/.append style={fill=gray},mark=square*\\% + every mark/.append style={fill=gray},mark=otimes*\\% + mark=star\\% + every mark/.append style={fill=gray},mark=diamond*\\% + densely dashed,every mark/.append style={solid,fill=gray},mark=*\\% + densely dashed,every mark/.append style={solid,fill=gray},mark=square*\\% + densely dashed,every mark/.append style={solid,fill=gray},mark=otimes*\\% + densely dashed,every mark/.append style={solid},mark=star\\% + densely dashed,every mark/.append style={solid,fill=gray},mark=diamond*\\% +} +\pgfcreateplotcyclelist{\coloredplotspeclist}{% + blue,every mark/.append style={fill=blue!80!black},mark=*\\% + red,every mark/.append style={fill=red!80!black},mark=square*\\% + brown!60!black,every mark/.append style={fill=brown!80!black},mark=otimes*\\% + black,mark=star\\% + blue,every mark/.append style={fill=blue!80!black},mark=diamond*\\% + red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=*\\% + brown!60!black,densely dashed,every mark/.append style={solid,fill=brown!80!black},mark=square*\\% + black,densely dashed,every mark/.append style={solid,fill=gray},mark=otimes*\\% + blue,densely dashed,mark=star,every mark/.append style=solid\\% + red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=diamond*\\% +} + +\def\pgfplotsset#{\pgfqkeys{/pgfplots}} + +\def\pgfplotsdeprecatedstylecheck#1{% + \pgfkeysifdefined{#1/.@cmd}{% + \begingroup + \edef\pgfkeyscurrentkey{#1}% + \pgfkeyssplitpath + \pgfplots@warning{Loading deprecated style option + \pgfkeyscurrentpath/\pgfkeyscurrentname. + Please replace '\string\tikzstyle{\pgfkeyscurrentname}' + with '\string\pgfplotsset{\pgfkeyscurrentname/.style={}}' + (or '\string\pgfplotsset{\pgfkeyscurrentname/.append style={}}').}% + \endgroup + \pgfkeysvalueof{#1/.@cmd}\pgfeov + }{}% +}% + +\pgfkeys{% + /pgfplots/search path for tikz/.unknown/.code={% + \let\searchname=\pgfkeyscurrentname% + \pgfkeysalso{% + /tikz/\searchname/.try=#1, + /pgfplots/\searchname/.lastretry=#1 + }% + },% + /pgfplots/.is family, + /pgfplots/scale/.is family, + /pgfplots/legend/.is family, + /pgfplots/tick/.is family, + /pgfplots/axis/.is family, + /pgfplots/descriptions/.is family, + /pgfplots/style commands/.is family, + /pgfplots/naming commands/.is family, + /pgfplots/error bars/.is family, + /pgfplots/every axis/.style={}, + /pgfplots/every axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis}}, + /pgfplots/every axis/.belongs to family=/pgfplots/style commands, + /pgfplots/every semilogx axis/.style={}, + /pgfplots/every semilogx axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every semilogx axis}}, + /pgfplots/every semilogx axis/.belongs to family=/pgfplots/style commands, + /pgfplots/every semilogy axis/.style={}, + /pgfplots/every semilogy axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every semilogy axis}}, + /pgfplots/every semilogy axis/.belongs to family=/pgfplots/style commands, + /pgfplots/every loglog axis/.style={}, + /pgfplots/every loglog axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every loglog axis}}, + /pgfplots/every loglog axis/.belongs to family=/pgfplots/style commands, + /pgfplots/every linear axis/.style={}, + /pgfplots/every linear axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every linear axis}}, + /pgfplots/every linear axis/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis plot/.style={}, + /pgfplots/every axis plot/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis plot}}, + /pgfplots/every axis plot/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis plot post/.style={}, + /pgfplots/every axis plot post/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis plot}}, + /pgfplots/every axis label/.style={}, + /pgfplots/every axis label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis label}}, + /pgfplots/every axis label/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis x label/.style={at={(0.5,0)},below,yshift=-15pt}, + /pgfplots/every axis x label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis x label}}, + /pgfplots/every axis x label/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis y label/.style={at={(0,0.5)},xshift=-35pt,rotate=90}, + /pgfplots/every axis y label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis y label}}, + /pgfplots/every axis y label/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis title/.style={at={(0.5,1)},above,yshift=6pt}, + /pgfplots/every axis title/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis title}}, + /pgfplots/every axis title/.belongs to family=/pgfplots/style commands, + /pgfplots/every tick/.style={very thin,gray}, + /pgfplots/every tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every tick}}, + /pgfplots/every tick/.belongs to family=/pgfplots/style commands, + /pgfplots/every inner x axis line/.style={}, + /pgfplots/every inner y axis line/.style={}, + /pgfplots/every outer x axis line/.style={}, + /pgfplots/every outer y axis line/.style={}, + /pgfplots/x axis line style/.style={ + /pgfplots/every outer x axis line/.append style={#1}, + /pgfplots/every inner x axis line/.append style={#1}, + }, + /pgfplots/y axis line style/.style={ + /pgfplots/every outer y axis line/.append style={#1}, + /pgfplots/every inner y axis line/.append style={#1}, + }, + /pgfplots/outer axis line style/.style={ + /pgfplots/every outer x axis line/.append style={#1}, + /pgfplots/every outer y axis line/.append style={#1}% + }, + /pgfplots/inner axis line style/.style={ + /pgfplots/every inner x axis line/.append style={#1}, + /pgfplots/every inner y axis line/.append style={#1}% + }, + /pgfplots/axis line style/.style={ + /pgfplots/inner axis line style={#1}, + /pgfplots/outer axis line style={#1}% + }, + /pgfplots/separate axis lines/.is if=pgfplots@separate@axis@lines, + /pgfplots/separate axis lines/.default=true, + /pgfplots/every minor tick/.style={}, + /pgfplots/every minor tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor tick}}, + /pgfplots/every minor tick/.belongs to family=/pgfplots/style commands, + /pgfplots/every major tick/.style={}, + /pgfplots/every major tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major tick}}, + /pgfplots/every major tick/.belongs to family=/pgfplots/style commands, + /pgfplots/every x tick/.style={}, + /pgfplots/every x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every x tick}}, + /pgfplots/every x tick/.belongs to family=/pgfplots/style commands, + /pgfplots/every minor x tick/.style={}, + /pgfplots/every minor x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor x tick}}, + /pgfplots/every minor x tick/.belongs to family=/pgfplots/style commands, + /pgfplots/every major x tick/.style={}, + /pgfplots/every major x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major x tick}}, + /pgfplots/every major x tick/.belongs to family=/pgfplots/style commands, + /pgfplots/every y tick/.style={}, + /pgfplots/every y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every y tick}}, + /pgfplots/every y tick/.belongs to family=/pgfplots/style commands, + /pgfplots/every minor y tick/.style={}, + /pgfplots/every minor y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor y tick}}, + /pgfplots/every minor y tick/.belongs to family=/pgfplots/style commands, + /pgfplots/every major y tick/.style={}, + /pgfplots/every major y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major y tick}}, + /pgfplots/every major y tick/.belongs to family=/pgfplots/style commands, + %/pgfplots/every axis grid/.style={help lines}, + /pgfplots/every axis grid/.style={thin,black!25}, + /pgfplots/every axis grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis grid}}, + /pgfplots/every axis grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every minor grid/.style={}, + /pgfplots/every minor grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor grid}}, + /pgfplots/every minor grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every major grid/.style={}, + /pgfplots/every major grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major grid}}, + /pgfplots/every major grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis x grid/.style={}, + /pgfplots/every axis x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis x grid}}, + /pgfplots/every axis x grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every minor x grid/.style={}, + /pgfplots/every minor x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor x grid}}, + /pgfplots/every minor x grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every major x grid/.style={}, + /pgfplots/every major x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major x grid}}, + /pgfplots/every major x grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis y grid/.style={}, + /pgfplots/every axis y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis y grid}}, + /pgfplots/every axis y grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every minor y grid/.style={}, + /pgfplots/every minor y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor y grid}}, + /pgfplots/every minor y grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every major y grid/.style={}, + /pgfplots/every major y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major y grid}}, + /pgfplots/every major y grid/.belongs to family=/pgfplots/style commands, + /pgfplots/every tick label/.style={}, + /pgfplots/every tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every tick label}}, + /pgfplots/every tick label/.belongs to family=/pgfplots/style commands, + /pgfplots/every x tick label/.style={}, + /pgfplots/every x tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every x tick label}}, + /pgfplots/every x tick label/.belongs to family=/pgfplots/style commands, + /pgfplots/every extra x tick/.style={ + /pgfplots/log identify minor tick positions=true, + }, + /pgfplots/every extra x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every extra x tick}}, + /pgfplots/every extra x tick/.belongs to family=/pgfplots/style commands, + /pgfplots/extra x tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/extra x tick style/.code={% + \pgfkeysalso{/pgfplots/every extra x tick/.append style={#1}}% + }, + /pgfplots/every x tick scale label/.style={at={(1,0)},yshift=-2em,left,inner sep=0pt}, + /pgfplots/every x tick scale label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every x tick scale label}}, + /pgfplots/every x tick scale label/.belongs to family=/pgfplots/style commands, + /pgfplots/every y tick label/.style={}, + /pgfplots/every y tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every y tick label}}, + /pgfplots/every y tick label/.belongs to family=/pgfplots/style commands, + /pgfplots/every extra y tick/.style={ + /pgfplots/log identify minor tick positions=true, + }, + /pgfplots/every extra y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every extra y tick}}, + /pgfplots/every extra y tick/.belongs to family=/pgfplots/style commands, + /pgfplots/extra y tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/extra y tick style/.code={% + \pgfkeysalso{/pgfplots/every extra y tick/.append style={#1}}% + }, + /pgfplots/every y tick scale label/.style={at={(0,1)},above right,inner sep=0pt,yshift=0.3em}, + /pgfplots/every y tick scale label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every y tick scale label}}, + /pgfplots/every y tick scale label/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis legend/.style={% + cells={anchor=center}, + inner xsep=3pt,inner ysep=2pt,nodes={inner sep=2pt,text depth=0.15em}, + anchor=north east,% + shape=rectangle,% + fill=white,% + draw=black, + at={(0.98,0.98)}, + }, + /pgfplots/every axis legend/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis legend}}, + /pgfplots/every axis legend/.belongs to family=/pgfplots/style commands, +% tick options: + /pgfplots/xticklabel/.store in= \pgfplots@xticklabel, + /pgfplots/xticklabel/.belongs to family=/pgfplots/tick, + /pgfplots/xticklabel=, + /pgfplots/xticklabels/.belongs to family=/pgfplots/tick, + /pgfplots/xticklabels/.code={% + \pgfplots@foreach@to@list{#1}\to\pgfplots@xticklabels + \let\pgfplots@xticklabel=\pgfplots@user@ticklabel@list@x + }, + /pgfplots/yticklabels/.belongs to family=/pgfplots/tick, + /pgfplots/yticklabels/.code={% + \pgfplots@foreach@to@list{#1}\to\pgfplots@yticklabels + \let\pgfplots@yticklabel=\pgfplots@user@ticklabel@list@y + }, + /pgfplots/yticklabel/.store in= \pgfplots@yticklabel, + /pgfplots/yticklabel/.belongs to family=/pgfplots/tick, + /pgfplots/yticklabel=, + /pgfplots/x tick label as interval/.is if=pgfplots@xticklabel@interval, + /pgfplots/x tick label as interval/.default=true, + /pgfplots/x tick label as interval/.belongs to family=/pgfplots/tick, + /pgfplots/y tick label as interval/.is if=pgfplots@yticklabel@interval, + /pgfplots/y tick label as interval/.default=true, + /pgfplots/y tick label as interval/.belongs to family=/pgfplots/tick, + /pgfplots/extra x tick label/.store in= \pgfplots@extra@xticklabel, + /pgfplots/extra x tick label/.belongs to family=/pgfplots/tick, + /pgfplots/extra x tick label=, + /pgfplots/extra x tick labels/.belongs to family=/pgfplots/tick, + /pgfplots/extra x tick labels/.code={% + \pgfplots@foreach@to@list{#1}\to\pgfplots@extra@xticklabels + \let\pgfplots@extra@xticklabel=\pgfplots@user@extra@ticklabel@list@x + }, + /pgfplots/extra y tick labels/.code={% + \pgfplots@foreach@to@list{#1}\to\pgfplots@extra@yticklabels + \let\pgfplots@extra@yticklabel=\pgfplots@user@extra@ticklabel@list@y + }, + /pgfplots/xtick/.store in= \pgfplots@xtick, + /pgfplots/xtick/.belongs to family=/pgfplots/tick, + /pgfplots/xtick=, + /pgfplots/extra x ticks/.store in=\pgfplots@extra@xtick, + /pgfplots/extra x ticks/.belongs to family=/pgfplots/tick, + /pgfplots/extra x ticks=, + /pgfplots/xtickten/.store in= \pgfplots@xtickten, + /pgfplots/xtickten/.belongs to family=/pgfplots/tick, + /pgfplots/xtickten=, + /pgfplots/extra y tick label/.store in= \pgfplots@extra@yticklabel, + /pgfplots/extra y tick label/.belongs to family=/pgfplots/tick, + /pgfplots/extra y tick label=, + /pgfplots/ytick/.store in= \pgfplots@ytick, + /pgfplots/ytick/.belongs to family=/pgfplots/tick, + /pgfplots/ytick=, + /pgfplots/extra y ticks/.store in=\pgfplots@extra@ytick, + /pgfplots/extra y ticks/.belongs to family=/pgfplots/tick, + /pgfplots/extra y ticks=, + /pgfplots/ytickten/.store in= \pgfplots@ytickten, + /pgfplots/ytickten/.belongs to family=/pgfplots/tick, + /pgfplots/ytickten=, + /pgfplots/tick scale label code/.code={$\cdot 10^{#1}$}, + /pgfplots/tick scale label code/.belongs to family=/pgfplots/tick, + /pgfplots/scaled x ticks/.is if=pgfplots@scaled@ticks@x, + /pgfplots/scaled x ticks/.belongs to family=/pgfplots/tick, + /pgfplots/scaled x ticks=true, + /pgfplots/scaled y ticks/.is if=pgfplots@scaled@ticks@y, + /pgfplots/scaled y ticks/.belongs to family=/pgfplots/tick, + /pgfplots/scaled y ticks=true, + /pgfplots/scaled ticks/.style={% + /pgfplots/scaled x ticks=#1, + /pgfplots/scaled y ticks=#1}, + /pgfplots/scale ticks above exponent/.store in= \pgfplots@scale@ticks@above@exponent, + /pgfplots/scale ticks above exponent/.belongs to family=/pgfplots/tick, + /pgfplots/scale ticks above exponent=3, + /pgfplots/scale ticks below exponent/.store in= \pgfplots@scale@ticks@below@exponent, + /pgfplots/scale ticks below exponent/.belongs to family=/pgfplots/tick, + /pgfplots/scale ticks below exponent=-1, + /pgfplots/subtickwidth/.store in= \pgfplots@subtickwidth, + /pgfplots/subtickwidth/.belongs to family=/pgfplots/tick, + /pgfplots/subtickwidth=0.1cm, + /pgfplots/tickwidth/.store in= \pgfplots@tickwidth, + /pgfplots/tickwidth/.belongs to family=/pgfplots/tick, + /pgfplots/tickwidth=0.15cm, + /pgfplots/minor x tick num/.initial=0, + /pgfplots/minor x tick num/.belongs to family=/pgfplots/tick, + /pgfplots/minor y tick num/.initial=0, + /pgfplots/minor y tick num/.belongs to family=/pgfplots/tick, + /pgfplots/minor tick num/.style={/pgfplots/minor x tick num=#1,/pgfplots/minor y tick num=#1}, + /pgfplots/minor tick num/.belongs to family=/pgfplots/tick, + /pgfplots/minor tick length/.estore in=\pgfplots@subtickwidth, + /pgfplots/minor tick length/.belongs to family=/pgfplots/tick, + /pgfplots/major tick length/.estore in=\pgfplots@tickwidth, + /pgfplots/major tick length/.belongs to family=/pgfplots/tick, + /pgfplots/max space between ticks/.estore in=\axisdefaulttickwidth, + /pgfplots/max space between ticks/.belongs to family=/pgfplots/tick, + /pgfplots/max space between ticks=35,% the maximum space between adjacent ticks (in pt, but don't specify the unit 'pt') + /pgfplots/try min ticks/.estore in= \axisdefaulttryminticks, + /pgfplots/try min ticks/.belongs to family=/pgfplots/tick, + /pgfplots/try min ticks=4, + /pgfplots/try min ticks log/.estore in= \pgfplots@default@try@minticks@log, + /pgfplots/try min ticks log/.belongs to family=/pgfplots/tick, + /pgfplots/try min ticks log=3, + /pgfplots/log plot exponent style/.style={/pgf/number format/fixed,/pgf/number format/precision=2}, + /pgfplots/log plot exponent style/.belongs to family=/pgfplots/tick, + /pgfplots/log identify minor tick positions/.is if=pgfplots@identify@log@minor@tick@pos, + /pgfplots/log identify minor tick positions/.belongs to family=/pgfplots/tick, + /pgfplots/log identify minor tick positions=false, + /pgfplots/log number format code/.code={{% + \pgfmathlogtologten@{#1}% + \ifpgfplots@identify@log@minor@tick@pos + \expandafter\pgfplots@is@log@tick@a@minor@tick@pos\pgfmathresult\relax% + \else + \pgfplots@log@tick@isminor@tick@posfalse + \fi + \ifpgfplots@log@tick@isminor@tick@pos + \pgfmathprintnumber[sci]{\pgfmathresult}% + \else + \pgfkeysalso{/pgfplots/log plot exponent style,/pgfplots/log base 10 number format code=\pgfmathresult}% + \fi + }}, + /pgfplots/log number format code/.belongs to family=/pgfplots/tick, + /pgfplots/log base 10 number format code/.code={$10^{\pgfmathprintnumber{#1}}$}, + /pgfplots/log base 10 number format code/.belongs to family=/pgfplots/tick, +% sets \pgfplots@[xy]tickposnum to + /pgfplots/xtick pos/.is choice, + /pgfplots/xtick pos/.belongs to family=/pgfplots/tick, + /pgfplots/xtick pos/left/.code ={\def\pgfplots@xtickposnum{1}}, + /pgfplots/xtick pos/left/.belongs to family=/pgfplots/tick, + /pgfplots/xtick pos/right/.code ={\def\pgfplots@xtickposnum{3}}, + /pgfplots/xtick pos/right/.belongs to family=/pgfplots/tick, + /pgfplots/xtick pos/both/.code ={\def\pgfplots@xtickposnum{0}}, + /pgfplots/xtick pos/both/.belongs to family=/pgfplots/tick, + /pgfplots/xtick pos=both, + /pgfplots/ytick pos/.is choice, + /pgfplots/ytick pos/.belongs to family=/pgfplots/tick, + /pgfplots/ytick pos/left/.code ={\def\pgfplots@ytickposnum{1}}, + /pgfplots/ytick pos/left/.belongs to family=/pgfplots/tick, + /pgfplots/ytick pos/right/.code ={\def\pgfplots@ytickposnum{3}}, + /pgfplots/ytick pos/right/.belongs to family=/pgfplots/tick, + /pgfplots/ytick pos/both/.code ={\def\pgfplots@ytickposnum{0}}, + /pgfplots/ytick pos/both/.belongs to family=/pgfplots/tick, + /pgfplots/ytick pos/top/.style={/pgfplots/ytick pos/right}, + /pgfplots/ytick pos/bottom/.style={/pgfplots/ytick pos/left}, + /pgfplots/ytick pos=both, + /pgfplots/tickpos/.style={/pgfplots/xtick pos={#1},/pgfplots/ytick pos={#1}}, + /pgfplots/tickpos/.belongs to family=/pgfplots/tick, +% sets the tick LABEL position, \pgfplots@[xy]ticklabelposnum + /pgfplots/xticklabel pos/.is choice, + /pgfplots/xticklabel pos/.belongs to family=/pgfplots/tick, + /pgfplots/xticklabel pos/default/.code ={\def\pgfplots@xticklabelposnum{0}}, + /pgfplots/xticklabel pos/default/.belongs to family=/pgfplots/tick, + /pgfplots/xticklabel pos/left/.code ={\def\pgfplots@xticklabelposnum{1}}, + /pgfplots/xticklabel pos/left/.belongs to family=/pgfplots/tick, + /pgfplots/xticklabel pos/right/.code ={\def\pgfplots@xticklabelposnum{3}}, + /pgfplots/xticklabel pos/right/.belongs to family=/pgfplots/tick, + /pgfplots/xticklabel pos=default, + /pgfplots/yticklabel pos/.is choice, + /pgfplots/yticklabel pos/.belongs to family=/pgfplots/tick, + /pgfplots/yticklabel pos/default/.code ={\def\pgfplots@yticklabelposnum{0}}, + /pgfplots/yticklabel pos/default/.belongs to family=/pgfplots/tick, + /pgfplots/yticklabel pos/left/.code ={\def\pgfplots@yticklabelposnum{1}}, + /pgfplots/yticklabel pos/left/.belongs to family=/pgfplots/tick, + /pgfplots/yticklabel pos/right/.code ={\def\pgfplots@yticklabelposnum{3}}, + /pgfplots/yticklabel pos/right/.belongs to family=/pgfplots/tick, + /pgfplots/yticklabel pos/top/.style={/pgfplots/yticklabel pos/right}, + /pgfplots/yticklabel pos/bottom/.style={/pgfplots/yticklabel pos/left}, + /pgfplots/yticklabel pos=default, + /pgfplots/ticklabelpos/.style={/pgfplots/xticklabel pos={#1},/pgfplots/yticklabel pos={#1}}, +% sets \pgfplots@{x,y}tickalignnum to +% inside=0 +% outside=1 +% center=2 + /pgfplots/xtick align/.is choice, + /pgfplots/xtick align/.belongs to family=/pgfplots/tick, + /pgfplots/xtick align/inside/.code ={\def\pgfplots@xtickalignnum{0}}, + /pgfplots/xtick align/inside/.belongs to family=/pgfplots/tick, + /pgfplots/xtick align/outside/.code ={\def\pgfplots@xtickalignnum{1}}, + /pgfplots/xtick align/outside/.belongs to family=/pgfplots/tick, + /pgfplots/xtick align/center/.code ={\def\pgfplots@xtickalignnum{2}}, + /pgfplots/xtick align/center/.belongs to family=/pgfplots/tick, + /pgfplots/xtick align=inside, + /pgfplots/ytick align/.is choice, + /pgfplots/ytick align/.belongs to family=/pgfplots/tick, + /pgfplots/ytick align/inside/.code ={\def\pgfplots@ytickalignnum{0}}, + /pgfplots/ytick align/inside/.belongs to family=/pgfplots/tick, + /pgfplots/ytick align/outside/.code ={\def\pgfplots@ytickalignnum{1}}, + /pgfplots/ytick align/outside/.belongs to family=/pgfplots/tick, + /pgfplots/ytick align/center/.code ={\def\pgfplots@ytickalignnum{2}}, + /pgfplots/ytick align/center/.belongs to family=/pgfplots/tick, + /pgfplots/ytick align=inside, + /pgfplots/tick align/.belongs to family=/pgfplots/tick, + /pgfplots/tick align/.style={% + /pgfplots/xtick align=#1, + /pgfplots/ytick align=#1, + },% +% 'axis' options: + /pgfplots/anchor/.belongs to family=/pgfplots, + /pgfplots/anchor/.store in= \pgfplots@anchorname, + /pgfplots/anchor=south west, +% tick options: + /pgfplots/ticks/.is choice, + /pgfplots/ticks/.belongs to family=/pgfplots/tick, + /pgfplots/ticks/none/.belongs to family=/pgfplots/tick, + /pgfplots/ticks/none/.code={% + \pgfplots@xminorticksfalse + \pgfplots@yminorticksfalse + \pgfplots@xmajorticksfalse + \pgfplots@ymajorticksfalse + }, + /pgfplots/ticks/major/.belongs to family=/pgfplots/tick, + /pgfplots/ticks/major/.code={% + \pgfplots@xminorticksfalse + \pgfplots@yminorticksfalse + \pgfplots@xmajortickstrue + \pgfplots@ymajortickstrue + }, + /pgfplots/ticks/minor/.belongs to family=/pgfplots/tick, + /pgfplots/ticks/minor/.code={% + \pgfplots@xminortickstrue + \pgfplots@yminortickstrue + \pgfplots@xmajorticksfalse + \pgfplots@ymajorticksfalse + }, + /pgfplots/ticks/both/.belongs to family=/pgfplots/tick, + /pgfplots/ticks/both/.code={% + \pgfplots@xminortickstrue + \pgfplots@yminortickstrue + \pgfplots@xmajortickstrue + \pgfplots@ymajortickstrue + }, + /pgfplots/ticks=both, + /pgfplots/grid/.is choice, + /pgfplots/grid/.belongs to family=/pgfplots/tick, + /pgfplots/grid/none/.belongs to family=/pgfplots/tick, + /pgfplots/grid/none/.code={% + \pgfplots@xminorgridsfalse + \pgfplots@yminorgridsfalse + \pgfplots@xmajorgridsfalse + \pgfplots@ymajorgridsfalse + }, + /pgfplots/grid/major/.belongs to family=/pgfplots/tick, + /pgfplots/grid/major/.code={% + \pgfplots@xminorgridsfalse + \pgfplots@yminorgridsfalse + \pgfplots@xmajorgridstrue + \pgfplots@ymajorgridstrue + }, + /pgfplots/grid/minor/.belongs to family=/pgfplots/tick, + /pgfplots/grid/minor/.code={% + \pgfplots@xminorgridstrue + \pgfplots@yminorgridstrue + \pgfplots@xmajorgridsfalse + \pgfplots@ymajorgridsfalse + }, + /pgfplots/grid/both/.belongs to family=/pgfplots/tick, + /pgfplots/grid/both/.code={% + \pgfplots@xminorgridstrue + \pgfplots@yminorgridstrue + \pgfplots@xmajorgridstrue + \pgfplots@ymajorgridstrue + }, + /pgfplots/grid=none, + /pgfplots/grid/.default=major, + /pgfplots/xminorticks/.is if=pgfplots@xminorticks, + /pgfplots/xminorticks/.default=true, + /pgfplots/xminorticks/.belongs to family=/pgfplots/tick, + /pgfplots/xmajorticks/.is if=pgfplots@xmajorticks, + /pgfplots/xmajorticks/.default=true, + /pgfplots/xmajorticks/.belongs to family=/pgfplots/tick, + /pgfplots/yminorticks/.is if=pgfplots@yminorticks, + /pgfplots/yminorticks/.default=true, + /pgfplots/yminorticks/.belongs to family=/pgfplots/tick, + /pgfplots/ymajorticks/.is if=pgfplots@ymajorticks, + /pgfplots/ymajorticks/.default=true, + /pgfplots/ymajorticks/.belongs to family=/pgfplots/tick, + /pgfplots/xminorgrids/.is if=pgfplots@xminorgrids, + /pgfplots/xminorgrids/.default=true, + /pgfplots/xminorgrids/.belongs to family=/pgfplots/tick, + /pgfplots/xmajorgrids/.is if=pgfplots@xmajorgrids, + /pgfplots/xmajorgrids/.default=true, + /pgfplots/xmajorgrids/.belongs to family=/pgfplots/tick, + /pgfplots/yminorgrids/.is if=pgfplots@yminorgrids, + /pgfplots/yminorgrids/.default=true, + /pgfplots/yminorgrids/.belongs to family=/pgfplots/tick, + /pgfplots/ymajorgrids/.is if=pgfplots@ymajorgrids, + /pgfplots/ymajorgrids/.default=true, + /pgfplots/ymajorgrids/.belongs to family=/pgfplots/tick, +% legend options: + /pgfplots/legend entries/.initial={}, + /pgfplots/legend entries/.belongs to family=/pgfplots/legend, + /pgfplots/legend columns/.store in=\pgfplots@legend@columns, + /pgfplots/legend columns/.belongs to family=/pgfplots/legend, + /pgfplots/legend columns=1, + /pgfplots/legend plot pos/.is choice, + /pgfplots/legend plot pos/.belongs to family=/pgfplots/legend, + /pgfplots/legend plot pos/left/.code= {\def\pgfplots@legend@plot@pos{0}}, + /pgfplots/legend plot pos/left/.belongs to family=/pgfplots/legend, + /pgfplots/legend plot pos/right/.code= {\def\pgfplots@legend@plot@pos{1}}, + /pgfplots/legend plot pos/right/.belongs to family=/pgfplots/legend, + /pgfplots/legend plot pos/none/.code= {\def\pgfplots@legend@plot@pos{2}}, + /pgfplots/legend plot pos/none/.belongs to family=/pgfplots/legend, + /pgfplots/legend plot pos=left, + /pgfplots/legend image code/.code={% + \draw[#1,mark repeat=2,mark phase=2] + plot coordinates { + (0cm,0cm) + (0.3cm,0cm) + (0.6cm,0cm)% + };% + }, + /pgfplots/legend image code/.belongs to family=/pgfplots/legend, +% axis description options: + /pgfplots/title/.initial=, + /pgfplots/title/.belongs to family=/pgfplots/descriptions, + /pgfplots/xlabel/.initial=, + /pgfplots/xlabel/.belongs to family=/pgfplots/descriptions, + /pgfplots/ylabel/.initial=, + /pgfplots/ylabel/.belongs to family=/pgfplots/descriptions, + /pgfplots/before end axis/.code=, + /pgfplots/after end axis/.code=, + /pgfplots/extra description/.code=, + /pgfplots/extra description/.belongs to family=/pgfplots/descriptions, +% axis options: + /pgfplots/at/.code={% + \pgfplots@assert@tikzinternal@exists{tikz@scan@one@point}% + \tikz@scan@one@point\pgfplots@set@at#1}, + /pgfplots/at/.belongs to family=/pgfplots, + /pgfplots/clip limits/.is if=pgfplots@clip@limits, + /pgfplots/clip limits/.default=true, + /pgfplots/clip limits=true, + /pgfplots/clip limits/.belongs to family=/pgfplots, + /pgfplots/xmin/.belongs to family=/pgfplots, + /pgfplots/xmin/.initial=, + /pgfplots/xmax/.belongs to family=/pgfplots, + /pgfplots/xmax/.initial=, + /pgfplots/ymin/.belongs to family=/pgfplots, + /pgfplots/ymin/.initial=, + /pgfplots/ymax/.belongs to family=/pgfplots, + /pgfplots/ymax/.initial=, + /pgfplots/stack plots/.is choice, + /pgfplots/stack plots/.belongs to family=/pgfplots, + /pgfplots/stack plots/x/.code={\pgfplots@stacked@xtrue\pgfplots@stackedmodetrue}, + /pgfplots/stack plots/x/.belongs to family=/pgfplots, + /pgfplots/stack plots/y/.code={\pgfplots@stacked@xfalse\pgfplots@stackedmodetrue}, + /pgfplots/stack plots/y/.belongs to family=/pgfplots, + /pgfplots/stack plots/false/.code={\pgfplots@stackedmodefalse}, + /pgfplots/stack plots/false/.belongs to family=/pgfplots, + /pgfplots/stack plots=false, + /pgfplots/reverse stacked plots/.is if=pgfplots@stacked@reverse, + /pgfplots/reverse stacked plots/.belongs to family=/pgfplots, + /pgfplots/reverse stacked plots/.default=true, + /pgfplots/reverse stacked plots=true, + /pgfplots/stack dir/.is choice, + /pgfplots/stack dir/.belongs to family=/pgfplots, + /pgfplots/stack dir/plus/.code={\pgfplots@stacked@plustrue}, + /pgfplots/stack dir/plus/.belongs to family=/pgfplots, + /pgfplots/stack dir/minus/.code={\pgfplots@stacked@plusfalse}, + /pgfplots/stack dir/minus/.belongs to family=/pgfplots, + /pgfplots/stack dir=plus, + /pgfplots/filter discard warning/.is if=pgfplots@warn@for@filter@discards, + /pgfplots/filter discard warning=true, + /pgfplots/x filter/.code={}, + /pgfplots/x filter/.belongs to family=/pgfplots, + /pgfplots/y filter/.code={}, + /pgfplots/y filter/.belongs to family=/pgfplots, + /pgfplots/skip coords between index/.style 2 args={% + /pgfplots/x filter/.append code={% + \ifnum\coordindex<#1\relax + \else + \ifnum\coordindex<#2\relax + \let\pgfmathresult=\pgfutil@empty + \fi + \fi} + }, + /pgfplots/xfilter/.initial=,% DEPRECATED + /pgfplots/xfilter/.belongs to family=/pgfplots, + /pgfplots/yfilter/.initial=,% DEPRECATED + /pgfplots/yfilter/.belongs to family=/pgfplots, + /pgfplots/width/.store in= \pgfplots@width, + /pgfplots/width/.belongs to family=/pgfplots, + /pgfplots/width=, + /pgfplots/height/.store in= \pgfplots@height, + /pgfplots/height/.belongs to family=/pgfplots, + /pgfplots/height=, + /pgfplots/execute at begin plot/.store in=\pgfplots@execute@at@begin@plot, + /pgfplots/execute at begin plot/.belongs to family=/pgfplots, + /pgfplots/execute at begin plot=, + /pgfplots/execute at end plot/.store in= \pgfplots@execute@at@end@plot, + /pgfplots/execute at end plot/.belongs to family=/pgfplots, + /pgfplots/execute at end plot=, + /pgfplots/enlarge x limits/.initial=auto, + /pgfplots/enlarge x limits/.default=true, + /pgfplots/enlarge y limits/.initial=auto, + /pgfplots/enlarge y limits/.default=true, + /pgfplots/enlargelimits/.style={% + /pgfplots/enlarge x limits=#1,% + /pgfplots/enlarge y limits=#1,% + },% + /pgfplots/enlargelimits/.default=true, + /pgfplots/x/.store in= \pgfplots@x, + /pgfplots/x/.belongs to family=/pgfplots, + /pgfplots/x=,% is implicitly set by 'width' and/or '\axisdefaultwidth' + /pgfplots/y/.store in= \pgfplots@y, + /pgfplots/y/.belongs to family=/pgfplots, + /pgfplots/y=,% is implicitly set by 'width' and/or '\axisdefaultwidth' + /pgfplots/cycle list/.code={\pgfplots@assign@list\autoplotspeclist{#1}}, + /pgfplots/cycle list/.belongs to family=/pgfplots, + /pgfplots/cycle list name/.code={\let\autoplotspeclist=#1\relax}, + /pgfplots/cycle list name/.belongs to family=/pgfplots, + /pgfplots/cycle list name=\coloredplotspeclist, + /pgfplots/legend style/.belongs to family=/pgfplots/style commands, + /pgfplots/legend style/.code={% + \pgfkeysalso{/pgfplots/every axis legend/.append style={#1}}% + }, + /pgfplots/label style/.belongs to family=/pgfplots/style commands, + /pgfplots/label style/.code={% + \pgfkeysalso{/pgfplots/every axis label/.append style={#1}}% + },% + /pgfplots/x label style/.belongs to family=/pgfplots/style commands, + /pgfplots/x label style/.code={% + \pgfkeysalso{/pgfplots/every axis x label/.append style={#1}}% + }, + /pgfplots/y label style/.belongs to family=/pgfplots/style commands, + /pgfplots/y label style/.code={% + \pgfkeysalso{/pgfplots/every axis y label/.append style={#1}}% + }, + /pgfplots/title style/.belongs to family=/pgfplots/style commands, + /pgfplots/title style/.code={% + \pgfkeysalso{/pgfplots/every axis title/.append style={#1}}% + }, + /pgfplots/tick label style/.belongs to family=/pgfplots/style commands, + /pgfplots/tick label style/.code={% + \pgfkeysalso{/pgfplots/every tick label/.append style={#1}}% + }, + /pgfplots/x tick label style/.belongs to family=/pgfplots/style commands, + /pgfplots/x tick label style/.code={% + \pgfkeysalso{/pgfplots/every x tick label/.append style={#1}}% + }, + /pgfplots/y tick label style/.belongs to family=/pgfplots/style commands, + /pgfplots/y tick label style/.code={% + \pgfkeysalso{/pgfplots/every y tick label/.append style={#1}}% + }, + /pgfplots/x tick scale label style/.belongs to family=/pgfplots/style commands, + /pgfplots/x tick scale label style/.code={% + \pgfkeysalso{/pgfplots/every x scale tick label/.append style={#1}}% + }, + /pgfplots/y tick scale label style/.belongs to family=/pgfplots/style commands, + /pgfplots/y tick scale label style/.code={% + \pgfkeysalso{/pgfplots/every y scale tick label/.append style={#1}}% + }, + /pgfplots/tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/tick style/.code={% + \pgfkeysalso{/pgfplots/every tick/.append style={#1}}% + }, + /pgfplots/minor tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/minor tick style/.code={% + \pgfkeysalso{/pgfplots/every minor tick/.append style={#1}}% + }, + /pgfplots/major tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/major tick style/.code={% + \pgfkeysalso{/pgfplots/every major tick/.append style={#1}}% + }, + /pgfplots/x tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/x tick style/.code={% + \pgfkeysalso{/pgfplots/every x tick/.append style={#1}}% + }, + /pgfplots/minor x tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/minor x tick style/.code={% + \pgfkeysalso{/pgfplots/every minor x tick/.append style={#1}}% + }, + /pgfplots/major x tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/major x tick style/.code={% + \pgfkeysalso{/pgfplots/every major x tick/.append style={#1}}% + }, + /pgfplots/y tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/y tick style/.code={% + \pgfkeysalso{/pgfplots/every y tick/.append style={#1}}% + }, + /pgfplots/minor y tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/minor y tick style/.code={% + \pgfkeysalso{/pgfplots/every minor y tick/.append style={#1}}% + }, + /pgfplots/major y tick style/.belongs to family=/pgfplots/style commands, + /pgfplots/major y tick style/.code={% + \pgfkeysalso{/pgfplots/every major y tick/.append style={#1}}% + }, + /pgfplots/grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/grid style/.code={% + \pgfkeysalso{/pgfplots/every axis grid/.append style={#1}}% + }, + /pgfplots/minor grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/minor grid style/.code={% + \pgfkeysalso{/pgfplots/every minor grid/.append style={#1}}% + }, + /pgfplots/major grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/major grid style/.code={% + \pgfkeysalso{/pgfplots/every major grid/.append style={#1}}% + }, + /pgfplots/x grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/x grid style/.code={% + \pgfkeysalso{/pgfplots/every axis x grid/.append style={#1}}% + }, + /pgfplots/minor x grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/minor x grid style/.code={% + \pgfkeysalso{/pgfplots/every minor x grid/.append style={#1}}% + }, + /pgfplots/major x grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/major x grid style/.code={% + \pgfkeysalso{/pgfplots/every major x grid/.append style={#1}}% + }, + /pgfplots/y grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/y grid style/.code={% + \pgfkeysalso{/pgfplots/every axis y grid/.append style={#1}}% + }, + /pgfplots/minor y grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/minor y grid style/.code={% + \pgfkeysalso{/pgfplots/every minor y grid/.append style={#1}}% + }, + /pgfplots/major y grid style/.belongs to family=/pgfplots/style commands, + /pgfplots/major y grid style/.code={% + \pgfkeysalso{/pgfplots/every major y grid/.append style={#1}}% + }, + /pgfplots/disablelogfilter/.is if=pgfplots@disablelogfilter, + /pgfplots/disablelogfilter/.default=true, + /pgfplots/disablelogfilter/.belongs to family=/pgfplots, + /pgfplots/disablelogfilter=false, + /pgfplots/disabledatascaling/.is if=pgfplots@disabledatascaling, + /pgfplots/disabledatascaling/.default=true, + /pgfplots/disabledatascaling/.belongs to family=/pgfplots, + /pgfplots/disabledatascaling=false, + /pgfplots/hide x axis/.is if=pgfplots@hide@x, + /pgfplots/hide x axis/.default=true, + /pgfplots/hide x axis=false, + /pgfplots/hide y axis/.is if=pgfplots@hide@y, + /pgfplots/hide y axis/.default=true, + /pgfplots/hide y axis=false, + /pgfplots/hide axis/.style={% + /pgfplots/hide x axis=#1, + /pgfplots/hide y axis=#1, + }, + /pgfplots/hide axis/.default=true, + /pgfplots/every non boxed x axis/.style={% + xtick align=center, + enlarge x limits=false, + x axis line style={-stealth} + }, + /pgfplots/every non boxed y axis/.style={% + ytick align=center, + enlarge y limits=false, + y axis line style={-stealth} + }, + /pgfplots/every boxed x axis/.style={}, + /pgfplots/every boxed y axis/.style={}, +% /pgfplots/hide axis/.belongs to family=/pgfplots, +% sets \pgfplots@xaxislinesnum to +% box=0 +% bottom=1 +% middle=2 ( aliased with center ) +% top=3 + /pgfplots/axis x line*/.is choice, + /pgfplots/axis x line*/box/.code ={\def\pgfplots@xaxislinesnum{0}\def\pgfplots@xtickposnum{0}}, + /pgfplots/axis x line*/bottom/.code ={\def\pgfplots@xaxislinesnum{1}\def\pgfplots@xtickposnum{1}}, + /pgfplots/axis x line*/middle/.code ={\def\pgfplots@xaxislinesnum{2}\def\pgfplots@xtickposnum{2}}, + /pgfplots/axis x line*/center/.style ={/pgfplots/axis x line*/middle}, + /pgfplots/axis x line*/top/.code ={\def\pgfplots@xaxislinesnum{3}\def\pgfplots@xtickposnum{3}}, + /pgfplots/axis x line*/none/.code ={\def\pgfplots@xaxislinesnum{4}\def\pgfplots@xtickposnum{4}}, + /pgfplots/axis x line*=box, + % + /pgfplots/axis x line/.is choice, + /pgfplots/axis x line/box/.style ={ + /pgfplots/axis x line*/box, + /pgfplots/every boxed x axis + }, + /pgfplots/axis x line/bottom/.style ={ + /pgfplots/axis x line*/bottom, + /pgfplots/every non boxed x axis + }, + /pgfplots/axis x line/middle/.code ={% + \ifnum\pgfplots@yaxislinesnum=3 % if 'axis y line==right' then + \pgfkeysalso{/pgfplots/every axis x label/.style={at={(current axis.left of origin)},anchor=south west}}% + \else + \pgfkeysalso{/pgfplots/every axis x label/.style={at={(current axis.right of origin)},anchor=south east}}% + \fi + \pgfkeysalso{/pgfplots/axis x line*/middle, + /pgfplots/every non boxed x axis}% + }, + /pgfplots/axis x line/center/.style ={/pgfplots/axis x line/middle}, + /pgfplots/axis x line/top/.code ={ + \ifnum\pgfplots@yaxislinesnum=2 % if 'axis y line==center' then + \pgfkeysalso{ + /pgfplots/every axis y label/.style={at={(current axis.below origin)},anchor=south west}}% + \fi + \pgfkeysalso{% + /pgfplots/axis x line*/top, + /pgfplots/every axis x label/.style={at={(0.5,1)},anchor=south,yshift=15pt}, + /pgfplots/every non boxed x axis}% + }, + /pgfplots/axis x line/none/.style ={axis x line*/none,hide x axis}, +% sets \pgfplots@yaxislinesnum to +% box=0 +% left=1 +% center=2 ( aliased with middle ) +% right=3 + /pgfplots/axis y line*/.is choice, + /pgfplots/axis y line*/box/.code ={\def\pgfplots@yaxislinesnum{0}\def\pgfplots@ytickposnum{0}}, + /pgfplots/axis y line*/left/.code ={\def\pgfplots@yaxislinesnum{1}\def\pgfplots@ytickposnum{1}}, + /pgfplots/axis y line*/center/.code ={\def\pgfplots@yaxislinesnum{2}\def\pgfplots@ytickposnum{2}}, + /pgfplots/axis y line*/middle/.style ={/pgfplots/axis y line*/center}, + /pgfplots/axis y line*/right/.code ={\def\pgfplots@yaxislinesnum{3}\def\pgfplots@ytickposnum{3}}, + /pgfplots/axis y line*/none/.code ={\def\pgfplots@yaxislinesnum{4}\def\pgfplots@ytickposnum{4}}, + /pgfplots/axis y line*=box, + % + /pgfplots/axis y line/.is choice, + /pgfplots/axis y line/box/.style ={ + /pgfplots/axis y line*/box, + /pgfplots/every boxed y axis + }, + /pgfplots/axis y line/left/.style ={ + /pgfplots/axis y line*/left, + /pgfplots/every non boxed y axis + }, + /pgfplots/axis y line/center/.code ={ + \ifnum\pgfplots@xaxislinesnum=3 % if 'axis x line==top' then + \pgfkeysalso{% + /pgfplots/every axis y label/.style={at={(current axis.below origin)},anchor=south west}}% + \else + \pgfkeysalso{% + /pgfplots/every axis y label/.style={at={(current axis.above origin)},anchor=north west}}% + \fi + \pgfkeysalso{% + /pgfplots/axis y line*/center, + /pgfplots/every non boxed y axis}% + }, + /pgfplots/axis y line/middle/.style ={/pgfplots/axis y line/center}, + /pgfplots/axis y line/right/.code ={% + \ifnum\pgfplots@xaxislinesnum=2 + \pgfkeysalso{every axis x label/.style={at={(current axis.left of origin)},anchor=south west}}% + \fi + \pgfkeysalso{ + axis y line*/right, + %every axis y label/.style={at={(1,1)},anchor=north west,xshift=15pt}, + every axis y label/.style={at={(1,0.5)},xshift=33pt,rotate=90}, + /pgfplots/every non boxed y axis + }% + },% + /pgfplots/axis y line/none/.style ={axis y line*/none,hide y axis}, +% set \pgfplots@xaxisdiscontnum +% none = 0 +% crunch = 1 +% open = 2 + /pgfplots/axis x discontinuity/.is choice, + /pgfplots/axis x discontinuity/.belongs to family=/pgfplots, %/axis, + /pgfplots/axis x discontinuity/none/.code ={\def\pgfplots@xaxisdiscontnum{0}}, + /pgfplots/axis x discontinuity/none/.belongs to family=/pgfplots, %/axis, + /pgfplots/axis x discontinuity/crunch/.code ={\def\pgfplots@xaxisdiscontnum{1}}, + /pgfplots/axis x discontinuity/crunch/.belongs to family=/pgfplots, %/axis, + /pgfplots/axis x discontinuity/parallel/.code ={\def\pgfplots@xaxisdiscontnum{2}}, + /pgfplots/axis x discontinuity/parallel/.belongs to family=/pgfplots, %/axis, + /pgfplots/axis x discontinuity=none, +% set \pgfplots@yaxisdiscontnum +% none = 0 +% crunch = 1 +% open = 2 + /pgfplots/axis y discontinuity/.is choice, + /pgfplots/axis y discontinuity/.belongs to family=/pgfplots, %/axis, + /pgfplots/axis y discontinuity/none/.code ={\def\pgfplots@yaxisdiscontnum{0}}, + /pgfplots/axis y discontinuity/none/.belongs to family=/pgfplots, %/axis, + /pgfplots/axis y discontinuity/crunch/.code ={\def\pgfplots@yaxisdiscontnum{1}}, + /pgfplots/axis y discontinuity/crunch/.belongs to family=/pgfplots, %/axis, + /pgfplots/axis y discontinuity/parallel/.code ={\def\pgfplots@yaxisdiscontnum{2}}, + /pgfplots/axis y discontinuity/parallel/.belongs to family=/pgfplots, %/axis, + /pgfplots/axis y discontinuity=none, + /pgfplots/scale only axis/.is if=pgfplots@scale@only@axis, + /pgfplots/scale only axis/.default=true, + /pgfplots/scale only axis/.belongs to family=/pgfplots, + /pgfplots/scale only axis=false, +% sets \pgfplots@xislinear to +% normal=true +% log=false + /pgfplots/xmode/.is choice, + /pgfplots/xmode/.belongs to family=/pgfplots/scale, + /pgfplots/xmode/normal/.code={\pgfplots@xislineartrue}, + /pgfplots/xmode/normal/.belongs to family=/pgfplots/scale, + /pgfplots/xmode/linear/.code={\pgfplots@xislineartrue}, + /pgfplots/xmode/linear/.belongs to family=/pgfplots/scale, + /pgfplots/xmode/log/.code={\pgfplots@xislinearfalse}, + /pgfplots/xmode/log/.belongs to family=/pgfplots/scale, + /pgfplots/xmode=linear, + /pgfplots/ymode/.is choice, + /pgfplots/ymode/.belongs to family=/pgfplots/scale, + /pgfplots/ymode/normal/.code={\pgfplots@yislineartrue}, + /pgfplots/ymode/normal/.belongs to family=/pgfplots/scale, + /pgfplots/ymode/linear/.code={\pgfplots@yislineartrue}, + /pgfplots/ymode/linear/.belongs to family=/pgfplots/scale, + /pgfplots/ymode/log/.code={\pgfplots@yislinearfalse}, + /pgfplots/ymode/log/.belongs to family=/pgfplots/scale, + /pgfplots/ymode=linear, + /pgfplots/error bars/x fixed/.code= \def\pgfplots@errorbars@xfixed{#1}\def\pgfplots@errorbars@xmode{0}, + /pgfplots/error bars/x fixed relative/.code= \def\pgfplots@errorbars@xrel{#1}\def\pgfplots@errorbars@xmode{1}, + /pgfplots/error bars/x explicit/.code= \def\pgfplots@errorbars@xmode{2}, + /pgfplots/error bars/x explicit relative/.code= \def\pgfplots@errorbars@xmode{3}, + /pgfplots/error bars/x fixed relative=0, + /pgfplots/error bars/x fixed=0, + /pgfplots/error bars/y fixed/.code= \def\pgfplots@errorbars@yfixed{#1}\def\pgfplots@errorbars@ymode{0}, + /pgfplots/error bars/y fixed relative/.code= \def\pgfplots@errorbars@yrel{#1}\def\pgfplots@errorbars@ymode{1}, + /pgfplots/error bars/y explicit/.code= \def\pgfplots@errorbars@ymode{2}, + /pgfplots/error bars/y explicit relative/.code= \def\pgfplots@errorbars@ymode{3}, + /pgfplots/error bars/y fixed relative=0, + /pgfplots/error bars/y fixed=0, + /pgfplots/error bars/x dir/.is choice, + /pgfplots/error bars/x dir/none/.code={% + \def\pgfplots@errorbars@xdirection{0}% + \ifnum\pgfplots@errorbars@ydirection=0 + \pgfplots@errorbars@enabledfalse + \fi + }, + /pgfplots/error bars/x dir/plus/.code= \def\pgfplots@errorbars@xdirection{1}\pgfplots@errorbars@enabledtrue, + /pgfplots/error bars/x dir/minus/.code= \def\pgfplots@errorbars@xdirection{2}\pgfplots@errorbars@enabledtrue, + /pgfplots/error bars/x dir/both/.code= \def\pgfplots@errorbars@xdirection{3}\pgfplots@errorbars@enabledtrue, + /pgfplots/error bars/x dir=none, + /pgfplots/error bars/y dir/.is choice, + /pgfplots/error bars/y dir/none/.code={% + \def\pgfplots@errorbars@ydirection{0}% + \ifnum\pgfplots@errorbars@xdirection=0 + \pgfplots@errorbars@enabledfalse + \fi + }, + /pgfplots/error bars/y dir/plus/.code= \def\pgfplots@errorbars@ydirection{1}\pgfplots@errorbars@enabledtrue, + /pgfplots/error bars/y dir/minus/.code= \def\pgfplots@errorbars@ydirection{2}\pgfplots@errorbars@enabledtrue, + /pgfplots/error bars/y dir/both/.code= \def\pgfplots@errorbars@ydirection{3}\pgfplots@errorbars@enabledtrue, + /pgfplots/error bars/y dir=none, + /pgfplots/error bars/error mark/.initial={-}, + /pgfplots/error bars/error mark options/.initial={rotate=90}, + /pgfplots/error bars/error bar style/.code={% + \pgfkeysalso{/pgfplots/every error bar/.append style={#1}}% + }, + /pgfplots/every error bar/.style={thin}, + /pgfplots/every error bar/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every error bar}}, + /pgfplots/error bars/draw error bar/.code 2 args={% +%\message{/pgfplots/error bars/draw error bar: working with '#1' -- '#2'.}% + \pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}% + \pgfkeysgetvalue{/pgfplots/error bars/error mark options}{\pgfplotserrorbarsmarkopts}% + \draw #1 -- #2 node[pos=1,sloped,allow upside down] {% + \expandafter\tikz\expandafter[\pgfplotserrorbarsmarkopts]{% + \expandafter\pgfuseplotmark\expandafter{\pgfplotserrorbarsmark}% + \pgfusepath{stroke}}% + }; + }, + /pgfplots/bar cycle list/.style={/pgfplots/cycle list={% + {blue,fill=blue!30!white,mark=none},% + {red,fill=red!30!white,mark=none},% + {brown!60!black,fill=brown!30!white,mark=none},% + {black,fill=gray,mark=none},% + } + }, + /pgfplots/area cycle list/.style={bar cycle list}, + /pgfplots/area legend/.style={% + /pgfplots/legend image code/.code={% + \draw[##1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm); + }% + }, + /pgfplots/area style/.style={% + area cycle list, + area legend, + axis on top, + }, + /pgfplots/ybar/.style={ + bar cycle list, + xtick align=outside, + /pgfplots/legend image code/.code={\draw[##1,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0cm,0.8em) (2*\pgfplotbarwidth,0.6em)};}, + /pgf/bar shift={% + % total width = n*w + (n-1)*skip + % -> subtract half for centering + -0.5*(\numplots*\pgfplotbarwidth + (\numplots-1)*#1) + + % the '0.5*w' is for centering + (.5+\plotnum)*\pgfplotbarwidth + \plotnum*#1},% + /tikz/ybar, + }, + /pgfplots/ybar/.default=2pt, + /pgfplots/ybar/.belongs to family=/pgfplots, + /pgfplots/xbar/.style={ + bar cycle list, + ytick align=outside, + /pgfplots/legend image code/.code={\draw[##1,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0cm,0.8em) (2*\pgfplotbarwidth,0.6em)};}, + /pgf/bar shift={% + % total width = n*w + (n-1)*skip + % -> subtract half for centering + -0.5*(\numplots*\pgfplotbarwidth + (\numplots-1)*#1) + + % the '0.5*w' is for centering + (.5+\plotnum)*\pgfplotbarwidth + \plotnum*#1},% + /tikz/xbar, + }, + /pgfplots/xbar/.default=2pt, + /pgfplots/xbar/.belongs to family=/pgfplots, + /pgfplots/ybar interval/.style={% + bar cycle list, + x tick label as interval, + xmajorgrids, + xtick align=outside, + % xtick=data, + /pgfplots/legend image code/.code={\draw[##1,yshift=-0.2em,bar interval width=0.7,bar interval shift=0.5] plot coordinates {(0cm,0.8em) (5pt,0.6em) (10pt,0.6em)};}, + bar interval width={#1/\numplots}, + bar interval shift={(\plotnum+0.5)/\numplots}, + /tikz/ybar interval, + }, + /pgfplots/ybar interval/.default=1, + /pgfplots/ybar interval/.belongs to family=/pgfplots, + /pgfplots/xbar interval/.style={% + bar cycle list, + y tick label as interval, + % ytick=data, + ymajorgrids, + ytick align=outside, + /pgfplots/legend image code/.code={\draw[##1,yshift=-0.2em,bar interval width=0.7,bar interval shift=0.5] plot coordinates {(0cm,0.8em) (5pt,0.6em) (10pt,0.6em)};}, + bar interval width={#1/\numplots}, + bar interval shift={(\plotnum+0.5)/\numplots}, + /tikz/xbar interval, + }, + /pgfplots/xbar interval/.default=1, + /pgfplots/xbar interval/.belongs to family=/pgfplots, + /pgfplots/xbar stacked/.style={ + bar cycle list, + stack plots=x, + stack dir=#1, + /tikz/xbar, + }, + /pgfplots/xbar stacked/.default=plus, + /pgfplots/xbar stacked/.belongs to family=/pgfplots, + /pgfplots/ybar stacked/.style={ + bar cycle list, + stack plots=y, + stack dir=#1, + /tikz/ybar, + }, + /pgfplots/ybar stacked/.default=plus, + /pgfplots/ybar stacked/.belongs to family=/pgfplots, + /pgfplots/xbar interval stacked/.style={ + bar cycle list, + stack plots=x, + stack dir=#1, + /tikz/xbar interval, + }, + /pgfplots/xbar interval stacked/.default=plus, + /pgfplots/xbar interval stacked/.belongs to family=/pgfplots, + /pgfplots/ybar interval stacked/.style={ + bar cycle list, + stack plots=y, + stack dir=#1, + /tikz/ybar interval, + }, + /pgfplots/ybar interval stacked/.default=plus, + /pgfplots/ybar interval stacked/.belongs to family=/pgfplots, + /pgfplots/yticklabel interval boundaries/.style={% + y tick label as interval, + yticklabel={$\pgfmathprintnumber{\tick}$ -- $\pgfmathprintnumber{\nexttick}$} + }, + /pgfplots/xticklabel interval boundaries/.style={% + x tick label as interval, + xticklabel={$\pgfmathprintnumber{\tick}$ -- $\pgfmathprintnumber{\nexttick}$} + }, + /pgfplots/plot file/skip first/.is if=pgfplots@plot@file@skipfirst, + /pgfplots/plot file/skip first/.default=true, + /pgfplots/clip marker paths/.is if=pgfplots@clip@marker@paths, + /pgfplots/clip marker paths/.default=true, + /pgfplots/axis on top/.is if=pgfplots@axis@on@top, + /pgfplots/axis on top/.default=true, + /pgfplots/every crossref picture/.style={% + baseline,yshift=0.3em + }, + /pgfplots/x coord trafo/.code={}, + /pgfplots/x coord inv trafo/.code={}, + /pgfplots/y coord trafo/.code={}, + /pgfplots/y coord inv trafo/.code={}, +} + +{ +\pgfkeysdef{/pgfplots/empty command key}{}% +\pgfkeysgetvalue{/pgfplots/empty command key/.@cmd}\pgfplots@loc@TMPa +\global\let\pgfplots@empty@command@key=\pgfplots@loc@TMPa +} + +\def\pgfplots@cmdkey@alias#1=#2;{% + \pgfkeysgetvalue{/pgfplots/#2/.@cmd}\pgfplots@glob@TMPa + \pgfkeyslet{/pgfplots/#1/.@cmd}\pgfplots@glob@TMPa +}% +\pgfplots@cmdkey@alias xlabel style=x label style; +\pgfplots@cmdkey@alias ylabel style=y label style; +\pgfplots@cmdkey@alias xticklabel style=x tick label style; +\pgfplots@cmdkey@alias yticklabel style=y tick label style; +%\pgfplots@cmdkey@alias xtick scale label style=x tick scale label style; +%\pgfplots@cmdkey@alias ytick scale label style=y tick scale label style; +\pgfplots@cmdkey@alias xtick style=x tick style; +\pgfplots@cmdkey@alias ytick style=y tick style; + +\newif\ifpgfplots@log@tick@isminor@tick@pos +% Checks whether the tick position given as #1.#2=log10(T) belongs to +% T=i*10^j with an integer i>1. +% +% If T=i*10^j, \ifpgfplots@log@tick@isminor@tick@pos will be set to true and +% \pgfmathresult will contain T. +% +% Otherwise, \ifpgfplots@log@tick@isminor@tick@pos will be set to false and +% pgfmathresult to #1.#2 +% +% Arguments: +% #1.#2 the value log10(T) +% +% Implementation: +% if T = i*10^j, log10(T) = log10(i) + j. +% That means if log10(T) in \Z, we have T = 10^j. If not, we need to +% check wether i is an integer. Please note that log10(i) < 1. +% +% Further note: log(T) < 0 <=> j<0. +% In case j<0, we have +% #1.#2 = j + log(i) +% = - ( -j - log(i) ) +% = - ( -j - 1 + (1-log(i)) ) +% = #1 '.' #2 [ up to the '0.' +% that means #1 = j-1 and #2 = 1-log(i). +\def\pgfplots@is@log@tick@a@minor@tick@pos#1.#2\relax{% + \pgfmathapproxequalto@{#1.#2}{#1.0}% + \ifpgfmathcomparison + % in MOST cases, this here will be true: + \pgfplots@log@tick@isminor@tick@posfalse + \def\pgfmathresult{#1.#2}% + \else + % I guess this won't happen too often. In fact, it's a very + % special case. + \begingroup + \c@pgf@counta=#1\relax + \ifnum\c@pgf@counta<0 + \advance\c@pgf@counta by-1 + \pgfmathsubtract@{1}{0.#2}% + \expandafter\pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi\pgfmathresult\relax + \ifpgfplots@log@tick@isminor@tick@pos + \aftergroup\pgfplots@log@tick@isminor@tick@postrue + \edef\pgfmathresult{\pgfmathresult e\the\c@pgf@counta}% + \else + \aftergroup\pgfplots@log@tick@isminor@tick@posfalse + \def\pgfmathresult{#1.#2}% + \fi + \else + \pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi0.#2\relax + \ifpgfplots@log@tick@isminor@tick@pos + \aftergroup\pgfplots@log@tick@isminor@tick@postrue + \edef\pgfmathresult{\pgfmathresult e\the\c@pgf@counta}% + \else + \aftergroup\pgfplots@log@tick@isminor@tick@posfalse + \def\pgfmathresult{#1.#2}% + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup + \fi +} + +% expects a positive number. +\def\pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi0.#1\relax{% + \pgfplots@log@tick@isminor@tick@postrue + \pgfmathapproxequalto@{0.#1}{0.3010299956639}% + \ifpgfmathcomparison + \def\pgfmathresult{2}% + \else + \pgfmathapproxequalto@{0.#1}{0.4771212547196}% + \ifpgfmathcomparison + \def\pgfmathresult{3}% + \else + \pgfmathapproxequalto@{0.#1}{0.6020599913279}% + \ifpgfmathcomparison + \def\pgfmathresult{4}% + \else + \pgfmathapproxequalto@{0.#1}{0.698970004}% + \ifpgfmathcomparison + \def\pgfmathresult{5}% + \else + \pgfmathapproxequalto@{0.#1}{0.7781512503}% + \ifpgfmathcomparison + \def\pgfmathresult{6}% + \else + \pgfmathapproxequalto@{0.#1}{0.8450980400}% + \ifpgfmathcomparison + \def\pgfmathresult{7}% + \else + \pgfmathapproxequalto@{0.#1}{0.9030899869}% + \ifpgfmathcomparison + \def\pgfmathresult{8}% + \else + \pgfmathapproxequalto@{0.#1}{0.954242509439}% + \ifpgfmathcomparison + \def\pgfmathresult{9}% + \else + \pgfplots@log@tick@isminor@tick@posfalse + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi +} + + +\def\pgfplots@set@at#1{\def\pgfplots@at{#1}}% + + + +% converts a comma-separated list (PGF foreach) to my internal list +% structure. +\long\def\pgfplots@foreach@to@list#1\to#2{% + \global\pgfplotslistnewempty\pgfplots@glob@TMPa + \begingroup + \foreach \pgfplots@i in {#1} {% + \expandafter\pgfplotslistpushbackglobal\pgfplots@i\to\pgfplots@glob@TMPa + }% + \endgroup + \pgfplotslistcopy\pgfplots@glob@TMPa\to#2\relax +} + +% Several tick options: +\long\def\axispreset#1{% + \pgfplotsset{every axis/.append style={#1}}% +} +\long\def\legendpreset#1{% + \pgfplots@error{Sorry, legendpreset is now deprecated, along with the legend options text width and font. Legends are now TikZ-matrizes which provide better alignment and can be placed horizontally. See the manual for details.}% +} + +% Checks whether we need to create a separate 'tick scale label', +% a node with ' * 10^3' on the side of the axis: +% +% PRECONDITION: +% Axis limits for #1 are given. I need their values before any data +% scale transformation has been applied. +% If +% \pgfplots@#1min@unscaled@as@float +% and +% \pgfplots@#1max@unscaled@as@float +% exist; I will use these macros. +% Otherwise, I will use \pgfplots@#1min and \pgfplots@#1max; +% assuming that no data scale transformation is active. +% FIXME : does that need further attention? +\def\pgfplots@init@scaled@tick@for#1{% + \begingroup + % the \pgfplots@xmin@unscaled@as@float is set just before the data + % scale transformation is initialised. + % + % The variables are empty if there is no datascale transformation. + \expandafter\let\expandafter\pgfplots@cur@min@unscaled\csname pgfplots@#1min@unscaled@as@float\endcsname + \expandafter\let\expandafter\pgfplots@cur@max@unscaled\csname pgfplots@#1max@unscaled@as@float\endcsname + % + \ifx\pgfplots@cur@min@unscaled\pgfutil@empty + \edef\pgfplots@loc@TMPa{\csname pgfplots@#1min\endcsname}% + \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \let\pgfplots@cur@min@unscaled=\pgfmathresult + \edef\pgfplots@loc@TMPa{\csname pgfplots@#1max\endcsname}% + \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \let\pgfplots@cur@max@unscaled=\pgfmathresult + \fi + % + \expandafter\pgfmathfloat@decompose@E\pgfplots@cur@min@unscaled\relax\pgfmathfloat@a@E + \expandafter\pgfmathfloat@decompose@E\pgfplots@cur@max@unscaled\relax\pgfmathfloat@b@E + \ifnum\pgfmathfloat@b@E<\pgfmathfloat@a@E + \pgfmathfloat@b@E=\pgfmathfloat@a@E + \fi + \xdef\pgfplots@glob@TMPa{\pgfplots@scale@ticks@above@exponent}% + \expandafter\ifnum\pgfplots@glob@TMPa<\pgfmathfloat@b@E + % ok, scale it: + \multiply\pgfmathfloat@b@E by-1 + \xdef\pgfplots@glob@TMPa{\the\pgfmathfloat@b@E}% + \else + \xdef\pgfplots@glob@TMPa{\pgfplots@scale@ticks@below@exponent}% + \expandafter\ifnum\pgfplots@glob@TMPa>\pgfmathfloat@b@E + % ok, scale it: + \multiply\pgfmathfloat@b@E by-1 + \xdef\pgfplots@glob@TMPa{\the\pgfmathfloat@b@E}% + \else + % no scaling necessary: + \xdef\pgfplots@glob@TMPa{0}% + \fi + \fi + \endgroup + \expandafter\let\csname pgfplots@tick@scale@#1\endcsname=\pgfplots@glob@TMPa% +} + +% x-axis tick labels for #1th tick +% #1: the axis (x or y) +% #2: the value +% #3,#4: coordinates for tikz +% #5: ticknumber +\def\pgfplots@show@ticklabel#1#2(#3,#4)#5{{% + \csname ifpgfplots@#1ticklabel@interval\endcsname + \pgfmathparse{#3}% + \edef\pgfplots@show@ticklabel@coord@x@new{\pgfmathresult pt}% + \pgfmathparse{#4}% + \edef\pgfplots@show@ticklabel@coord@y@new{\pgfmathresult pt}% + % + \pgfplots@show@ticklabel@{#1}{#2}% + \let\nexttick=\tick + \ifx\pgfplots@show@ticklabel@LASTTICK\pgfutil@empty + % its the first call. Simply remember arguments and wait + % for interval boundary before proceeding. + \else + % acquire options of first interval boundary: + \pgfplots@show@ticklabel@LASTTICK + % compute new node position: + \pgfmathparse{0.5*(\csname pgfplots@show@ticklabel@coord@#1\endcsname + \csname pgfplots@show@ticklabel@coord@#1@new\endcsname)}% + \expandafter\edef\csname pgfplots@show@ticklabel@coord@#1\endcsname{\pgfmathresult pt}% + \let\ticknum=\pgfplots@show@ticklabel@num\relax% + \let\tick=\pgfplots@show@ticklabel@tick% + \edef\pgfplots@loc@TMPa{at (\pgfplots@show@ticklabel@coord@x,\pgfplots@show@ticklabel@coord@y)}% + \expandafter\node\pgfplots@loc@TMPa + {\csname pgfplots@#1ticklabel\endcsname};% + \fi + \xdef\pgfplots@show@ticklabel@LASTTICK{% + \noexpand\def\noexpand\pgfplots@show@ticklabel@tick{\nexttick}% + \noexpand\def\noexpand\pgfplots@show@ticklabel@coord@x{\pgfplots@show@ticklabel@coord@x@new}% + \noexpand\def\noexpand\pgfplots@show@ticklabel@coord@y{\pgfplots@show@ticklabel@coord@y@new}% + \noexpand\edef\noexpand\pgfplots@show@ticklabel@num{#5}% + }% + \else + \let\ticknum=#5\relax% + \pgfplots@show@ticklabel@{#1}{#2}% + \node at (#3,#4) {\csname pgfplots@#1ticklabel\endcsname};% + \fi +}} + +% Defines \tick by applying any necessary math to the (possibly +% transformed) tick value #2. +% +% #1: axis (x or y) +% #2: tick value. +\def\pgfplots@show@ticklabel@#1#2{% + \csname ifpgfplots@apply@datatrafo@#1\endcsname + \csname pgfplots@inverse@datascaletrafo@#1\endcsname{#2}% + \pgfplots@if{pgfplots@scaled@ticks@#1}{% + \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% + }\relax + % .. and this here provides \tick as fixed point repr: + \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \let\tick=\pgfmathresult + \else + \edef\tick{#2}% + \pgfplots@if{pgfplots@#1islinear}{% + \pgfplots@if{pgfplots@scaled@ticks@#1}{% + \pgfmathfloatparsenumber{#2}% + \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% + \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \let\tick=\pgfmathresult + }{}% + }{}% + \fi + \pgfkeysgetvalue{/pgfplots/#1 coord inv trafo/.@cmd}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key + \else + \let\pgfmathresult=\tick% + \expandafter\pgfplots@loc@TMPa\expandafter{\tick}\pgfeov + \let\tick=\pgfmathresult + \fi +}% + +\def\pgfplots@user@ticklabel@list@x{% + \pgfplotslistselectorempty\ticknum\of\pgfplots@xticklabels\to\tick + \tick +} +\def\pgfplots@user@ticklabel@list@y{% + \pgfplotslistselectorempty\ticknum\of\pgfplots@yticklabels\to\tick + \tick +} +\def\pgfplots@user@extra@ticklabel@list@x{% + \pgfplotslistselectorempty\ticknum\of\pgfplots@extra@xticklabels\to\tick + \tick +} +\def\pgfplots@user@extra@ticklabel@list@y{% + \pgfplotslistselectorempty\ticknum\of\pgfplots@extra@yticklabels\to\tick + \tick +} + + +% #1 axis (x or y) +% #2 the label +\def\pgfplots@show@label#1#2{% + \node + [/pgfplots/every axis label,% + /pgfplots/every axis #1 label] + {#2}; +} + +\def\pgfplots@show@title#1{% + \node% + [/pgfplots/every axis title] + {#1}; +} + +% Check if a label does not cross the x-axis +\def\pgfplots@ytick@check@tickshow{% + \pgfplots@tickshowtrue + \ifnum\pgfplots@yaxislinesnum=2\relax + \ifcase\pgfplots@xaxislinesnum\relax + \ifdim\pgfplots@tmpa=\pgfplots@ycoordminTEX\relax + \pgfplots@tickshowfalse + \fi + \ifdim\pgfplots@tmpa=\pgfplots@ycoordmaxTEX\relax + \pgfplots@tickshowfalse + \fi + \or + \ifdim\pgfplots@tmpa=\pgfplots@ycoordminTEX\relax + \pgfplots@tickshowfalse + \fi + \or + \ifdim\pgfplots@tmpa=\pgfplots@ZERO@y\relax + \pgfplots@tickshowfalse + \fi + \or + \ifdim\pgfplots@tmpa=\pgfplots@ycoordmaxTEX\relax + \pgfplots@tickshowfalse + \fi + \fi + \fi +} + +% Fills the macros +% \pgfplots@tick@beg@a \pgfplots@tick@end@a +% \pgfplots@tick@beg@b \pgfplots@tick@end@b +% with coordinates such that +% (\pgfplots@tick@beg@a,\pgfplots@tmpa) -- (\pgfplots@tick@end@a,\pgfplots@tmpa) +% produces a correct tick line. +% +% The '@b' variant is only used in case of \pgfplots@ytickposnum = 0 +% +% #1 : the current axis (x or y). +% #2 : the axis which is NOT fixed. For x tick lines, this is the y +% axis and for y tick lines, this is the x axis (#1 = x or y) +% #3 : the current tick width +\def\pgfplots@prepare@tick@offsets@for@#1#2#3{% + \ifcase\csname pgfplots@#1tickposnum\endcsname\relax + %(\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #3, 0pt) + \edef\pgfplots@tick@beg@a{\pgf@sys@tonumber{\csname pgfplots@#2coordminTEX\endcsname}}% + \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% + \let\pgfplots@tick@beg@a=\pgfmathresult + \pgfmathadd@{\pgfplots@tick@beg@a}{#3}% + \edef\pgfplots@tick@beg@a{\pgfplots@tick@beg@a pt}% + \edef\pgfplots@tick@end@a{\pgfmathresult pt}% + % + %(\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#3, 0pt) + \edef\pgfplots@tick@beg@b{\pgf@sys@tonumber{\csname pgfplots@#2coordmaxTEX\endcsname}}% + \pgfmathadd@{\pgfplots@tick@beg@b}{\pgfplots@tick@offset}% + \let\pgfplots@tick@beg@b=\pgfmathresult + \pgfmathsubtract@{\pgfplots@tick@beg@b}{#3}% + \edef\pgfplots@tick@beg@b{\pgfplots@tick@beg@b pt}% + \edef\pgfplots@tick@end@b{\pgfmathresult pt}% + \or + % (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #3, 0pt); + \edef\pgfplots@tick@beg@a{\pgf@sys@tonumber{\csname pgfplots@#2coordminTEX\endcsname}}% + \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% + \let\pgfplots@tick@beg@a=\pgfmathresult + \pgfmathadd@{\pgfplots@tick@beg@a}{#3}% + \edef\pgfplots@tick@beg@a{\pgfplots@tick@beg@a pt}% + \edef\pgfplots@tick@end@a{\pgfmathresult pt}% + \or + % (\pgfplots@ZERO@x -\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #3, 0pt); + \pgf@xa=\csname pgfplots@ZERO@#2\endcsname + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}% + \pgfmathsubtract@{\pgfplots@loc@TMPa}{\pgfplots@tick@offset}% + \let\pgfplots@tick@beg@a=\pgfmathresult + \pgfmathadd@{\pgfplots@tick@beg@a}{#3}% + \edef\pgfplots@tick@beg@a{\pgfplots@tick@beg@a pt}% + \edef\pgfplots@tick@end@a{\pgfmathresult pt}% + \or + % (\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#3, 0pt); + \edef\pgfplots@tick@beg@a{\pgf@sys@tonumber{\csname pgfplots@#2coordmaxTEX\endcsname}}% + \pgfmathadd@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% + \let\pgfplots@tick@beg@a=\pgfmathresult + \pgfmathsubtract@{\pgfplots@tick@beg@a}{#3}% + \edef\pgfplots@tick@beg@a{\pgfplots@tick@beg@a pt}% + \edef\pgfplots@tick@end@a{\pgfmathresult pt}% + \fi +}% + +\def\pgfplots@drawyaxis@placecomputedtick{% + \pgfpathmoveto{\pgfqpoint{\pgfplots@tick@beg@a}{\pgfplots@tmpa}}% + \pgfpathlineto{\pgfqpoint{\pgfplots@tick@end@a}{\pgfplots@tmpa}}% + \ifnum\pgfplots@ytickposnum=0\relax + \pgfpathmoveto{\pgfqpoint{\pgfplots@tick@beg@b}{\pgfplots@tmpa}}% + \pgfpathlineto{\pgfqpoint{\pgfplots@tick@end@b}{\pgfplots@tmpa}}% + \fi +}% +\def\pgfplots@drawyaxis@placecomputedgridline{% + \pgfpathmoveto{\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@tmpa}}% + \pgfpathlineto{\pgfqpoint{\pgfplots@xcoordmaxTEX}{\pgfplots@tmpa}}% +}% + +\newif\ifpgfplots@needsminorloop + +\def\pgfplots@draw@tick@scale@label@for#1{% + \csname ifpgfplots@#1islinear\endcsname + \pgfplots@if{pgfplots@scaled@ticks@#1}{% + \begingroup + \xdef\pgfplots@glob@TMPa{\csname pgfplots@tick@scale@#1\endcsname}% + \expandafter\c@pgf@counta\pgfplots@glob@TMPa\relax + \multiply\c@pgf@counta by-1 + \ifnum\c@pgf@counta=0\relax + \global\let\pgfplots@glob@TMPa=\pgfutil@empty + \else + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \fi + \endgroup + \ifx\pgfplots@glob@TMPa\pgfutil@empty + \else + \edef\pgfplots@tick@scale@labels{\noexpand\pgfplots@invoke@pgfkeyscode{/pgfplots/tick scale label code/.@cmd}{\pgfplots@glob@TMPa}}% + \node + [% + xshift=\pgfplots@xcoordminTEX,% + yshift=\pgfplots@ycoordminTEX,% + x=\pgfplots@xcoordmaxTEX-\pgfplots@xcoordminTEX,% + y=\pgfplots@ycoordmaxTEX-\pgfplots@ycoordminTEX,% + /pgfplots/every tick label,% + /pgfplots/every #1 tick label,% + /pgfplots/every #1 tick scale label] + {\pgfplots@tick@scale@labels}; + \fi + }{\relax}% + \fi +} + +% Simply invokes the code of PGF key #1 with value #2, that means +% #1#2\pgfeov +\def\pgfplots@invoke@pgfkeyscode#1#2{% + \pgfkeysgetvalue{#1}\pgfplots@invoke@pgfkeyscode@CODE + \pgfplots@invoke@pgfkeyscode@CODE#2\pgfeov +} + +% Check if the current tick position, stored in \pgfplots@tmpa, +% does not cross the y-axis. +% +% This is just a special case for centered axis lines. +\def\pgfplots@xtick@check@tickshow{% + \pgfplots@tickshowtrue + \ifnum\pgfplots@xaxislinesnum=2\relax + \ifcase\pgfplots@yaxislinesnum\relax + \ifdim\pgfplots@tmpa=\pgfplots@xcoordminTEX\relax + \pgfplots@tickshowfalse + \fi + \ifdim\pgfplots@tmpa=\pgfplots@xcoordmaxTEX\relax + \pgfplots@tickshowfalse + \fi + \or + \ifdim\pgfplots@tmpa=\pgfplots@xcoordminTEX\relax + \pgfplots@tickshowfalse + \fi + \or + \ifdim\pgfplots@tmpa=\pgfplots@ZERO@x\relax + \pgfplots@tickshowfalse + \fi + \or + \ifdim\pgfplots@tmpa=\pgfplots@xcoordmaxTEX\relax + \pgfplots@tickshowfalse + \fi + \fi + \fi +} + +\def\pgfplots@drawxaxis@placecomputedtick{% + \pgfpathmoveto{\pgfqpoint{\pgfplots@tmpa}{\pgfplots@tick@beg@a}}% + \pgfpathlineto{\pgfqpoint{\pgfplots@tmpa}{\pgfplots@tick@end@a}}% + \ifnum\pgfplots@xtickposnum=0\relax + \pgfpathmoveto{\pgfqpoint{\pgfplots@tmpa}{\pgfplots@tick@beg@b}}% + \pgfpathlineto{\pgfqpoint{\pgfplots@tmpa}{\pgfplots@tick@end@b}}% + \fi +}% +\def\pgfplots@drawxaxis@placecomputedgridline{% + \pgfpathmoveto{\pgfqpoint{\pgfplots@tmpa}{\pgfplots@ycoordminTEX}}% + \pgfpathlineto{\pgfqpoint{\pgfplots@tmpa}{\pgfplots@ycoordmaxTEX}}% +}% + +% #1: axis (x or y) +% #2: axis index (0 or 1) +% #3: tick position list +\def\pgfplots@draw@extra@ticks@for#1#2#3{% + \begingroup + \pgfplots@scaled@ticks@xfalse + \pgfplots@scaled@ticks@yfalse + \csname pgfplots@#1minorticksfalse\endcsname + \csname pgfplots@#1minorgridsfalse\endcsname + \expandafter\let\expandafter\axis@TMP\csname pgfplots@extra@#1ticklabel\endcsname + \expandafter\let\csname pgfplots@#1ticklabel\endcsname=\axis@TMP + \pgfplotsset{/pgfplots/every extra #1 tick}% FIXME : used 'search path for tikz' before... + \pgfplots@prepare@ticks@for{#3}{#1}{#2}% + \pgfplots@drawgridlines@for{#1}{#2}% + \pgfplots@drawticklines@for{#1}{#2}% + \pgfplots@drawticklabels@for{#1}{#2}% + \endgroup +} + +\def\pgfplots@drawaxis@innerlines{% + \ifpgfplots@hide@y\else + \ifnum\pgfplots@yaxislinesnum=2 + \draw[/pgfplots/every inner y axis line,% + decorate,% + ydiscont,% + decoration={pre length=\ydisstart, post length=\ydisend}] + (\pgfplots@ZERO@x, \pgfplots@ycoordminTEX) -- (\pgfplots@ZERO@x, \pgfplots@ycoordmaxTEX); + \fi + \fi + \ifpgfplots@hide@x\else + \ifnum\pgfplots@xaxislinesnum=2 + \draw[/pgfplots/every inner x axis line,% + decorate,% + xdiscont,% + decoration={pre length=\xdisstart, post length=\xdisend}] + (\pgfplots@xcoordminTEX, \pgfplots@ZERO@y) -- (\pgfplots@xcoordmaxTEX, \pgfplots@ZERO@y); + \fi + \fi +}% + +% Ok, we don't mind whether edges with thick lines look ugly. We just +% draw separate lines. This here is necessary if we want arrow heads. +\def\pgfplots@drawaxis@outerlines@separate{% + \ifpgfplots@hide@x + \else + \scope[/pgfplots/every outer x axis line, + xdiscont,decoration={pre length=\xdisstart, post length=\xdisend}] + \ifcase\pgfplots@xaxislinesnum + \draw decorate { + (\pgfplots@xcoordminTEX,\pgfplots@ycoordminTEX) + -- (\pgfplots@xcoordmaxTEX,\pgfplots@ycoordminTEX) }; + \draw decorate { + (\pgfplots@xcoordminTEX,\pgfplots@ycoordmaxTEX) + -- (\pgfplots@xcoordmaxTEX,\pgfplots@ycoordmaxTEX) }; + + \or + \draw decorate { + (\pgfplots@xcoordminTEX,\pgfplots@ycoordminTEX) + -- (\pgfplots@xcoordmaxTEX,\pgfplots@ycoordminTEX) }; + \or + \or + \draw decorate { + (\pgfplots@xcoordminTEX,\pgfplots@ycoordmaxTEX) + -- (\pgfplots@xcoordmaxTEX,\pgfplots@ycoordmaxTEX) }; + + \fi + \endscope + \fi + \ifpgfplots@hide@y + \else + \scope[/pgfplots/every outer y axis line, + ydiscont,decoration={pre length=\ydisstart, post length=\ydisend}] + \ifcase\pgfplots@yaxislinesnum + \draw decorate { + (\pgfplots@xcoordminTEX,\pgfplots@ycoordminTEX) + -- (\pgfplots@xcoordminTEX,\pgfplots@ycoordmaxTEX) }; + \draw decorate { + (\pgfplots@xcoordmaxTEX,\pgfplots@ycoordminTEX) + -- (\pgfplots@xcoordmaxTEX,\pgfplots@ycoordmaxTEX) }; + + \or + \draw decorate { + (\pgfplots@xcoordminTEX,\pgfplots@ycoordminTEX) + -- (\pgfplots@xcoordminTEX,\pgfplots@ycoordmaxTEX) }; + \or + \or + \draw decorate { + (\pgfplots@xcoordmaxTEX,\pgfplots@ycoordminTEX) + -- (\pgfplots@xcoordmaxTEX,\pgfplots@ycoordmaxTEX) }; + + \fi + \endscope + \fi +}% + +% This here is complicated: we try to create good edges and draw a +% SINGLE path for the partial or complete rectangle +% +% ----- +% | | +% | | +% ----- +\def\pgfplots@drawaxis@outerlines@cycledpath{% + \draw[ + /pgfplots/every outer x axis line, % FIXME! these outer styles need much more attention :-( + /pgfplots/every outer y axis line] + (\pgfplots@xcoordminTEX, \pgfplots@ycoordminTEX) +\ifpgfplots@hide@y + { (\pgfplots@xcoordminTEX, \pgfplots@ycoordmaxTEX) } +\else + \ifcase\pgfplots@yaxislinesnum + decorate [ydiscont,decoration={pre length=\ydisstart, post length=\ydisend}] { -- (\pgfplots@xcoordminTEX, \pgfplots@ycoordmaxTEX) } + \or decorate [ydiscont,decoration={pre length=\ydisstart, post length=\ydisend}] { -- (\pgfplots@xcoordminTEX, \pgfplots@ycoordmaxTEX) } + \or { (\pgfplots@xcoordminTEX, \pgfplots@ycoordmaxTEX) } + \or { (\pgfplots@xcoordminTEX, \pgfplots@ycoordmaxTEX) } + \fi +\fi +\ifpgfplots@hide@x + { (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordmaxTEX) } +\else + \ifcase\pgfplots@xaxislinesnum + decorate [xdiscont,decoration={pre length=\xdisstart, post length=\xdisend}] { -- (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordmaxTEX) } + \or { (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordmaxTEX) } + \or { (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordmaxTEX) } + \or decorate [xdiscont,decoration={pre length=\xdisstart, post length=\xdisend}] { -- (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordmaxTEX) } + \fi +\fi +\ifpgfplots@hide@y + { (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordminTEX) } +\else + \ifcase\pgfplots@yaxislinesnum + decorate [ydiscont,decoration={pre length=\ydisend, post length=\ydisstart}] { -- (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordminTEX) } + \or { (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordminTEX) } + \or { (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordminTEX) } + \or decorate [ydiscont,decoration={pre length=\ydisend, post length=\ydisstart}] { -- (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordminTEX) } + \fi +\fi +\ifpgfplots@hide@x + { (\pgfplots@xcoordminTEX, \pgfplots@ycoordminTEX) } +\else + \ifcase\pgfplots@xaxislinesnum + decorate [xdiscont,decoration={pre length=\xdisend, post length=\xdisstart}] { -- (\pgfplots@xcoordminTEX, \pgfplots@ycoordminTEX) } + \or decorate [xdiscont,decoration={pre length=\xdisend, post length=\xdisstart}] { -- (\pgfplots@xcoordminTEX, \pgfplots@ycoordminTEX) } + \or { (\pgfplots@xcoordminTEX, \pgfplots@ycoordminTEX) } + \or { (\pgfplots@xcoordminTEX, \pgfplots@ycoordminTEX) } + \fi% can't use cycle here! +\fi + ; % -- cycle; +}% + +\def\pgfplots@drawaxis@outerlines{% + \ifnum\pgfplots@xaxislinesnum>0 + \pgfplots@separate@axis@linestrue + \fi + \ifnum\pgfplots@yaxislinesnum>0 + \pgfplots@separate@axis@linestrue + \fi + \ifpgfplots@separate@axis@lines + \pgfplots@drawaxis@outerlines@separate + \else + \pgfplots@drawaxis@outerlines@cycledpath + \fi +}% + +\def\pgfplots@drawaxis@lines{% + \begingroup + \begingroup + % this group employs several temporary dimension registers + % and is therefor scoped: + \let\ydisstart=\pgf@xa + \let\ydisend=\pgf@xb + \let\xdisstart=\pgf@ya + \let\xdisend=\pgf@yb + \ydisend=\pgfplots@ycoordmaxTEX + \advance \ydisend by -\pgfplots@ycoordminTEX + \ifcase\pgfplots@yaxisdiscontnum\relax + \let\ydiscontstyle=\pgfutil@empty + \or + \def\ydiscontstyle{decoration={zigzag,segment length=12pt, amplitude=4pt}}% + \advance \ydisend by -16pt + \or + \def\ydiscontstyle{decoration={ticks,segment length=4pt, amplitude=8pt}}% + \advance \ydisend by -8pt + \fi + \ifpgfplots@apply@datatrafo@y + \advance \pgfplots@ycoordmaxTEX by\pgfplots@data@scale@trafo@SHIFT@y pt + \fi + \ifdim\pgfplots@ycoordmaxTEX<0pt + \ydisstart=\ydisend + \ydisend=4pt + \else + \ydisstart=4pt + \fi + \ifpgfplots@apply@datatrafo@y + \advance \pgfplots@ycoordmaxTEX by-\pgfplots@data@scale@trafo@SHIFT@y pt + \fi + \xdisend=\pgfplots@xcoordmaxTEX + \advance \xdisend by -\pgfplots@xcoordminTEX + \ifcase\pgfplots@xaxisdiscontnum\relax + \let\xdiscontstyle=\pgfutil@empty + \or + \def\xdiscontstyle{decoration={zigzag,segment length=12pt, amplitude=4pt}}% + \advance \xdisend by -16pt + \or + \def\xdiscontstyle{decoration={ticks,segment length=4pt, amplitude=8pt}}% + \advance \xdisend by -8pt + \fi + \ifpgfplots@apply@datatrafo@x + \advance \pgfplots@xcoordmaxTEX by\pgfplots@data@scale@trafo@SHIFT@x pt + \fi + \ifdim\pgfplots@xcoordmaxTEX<0pt + \xdisstart=\xdisend + \xdisend=4pt + \else + \xdisstart=4pt + \fi + \ifpgfplots@apply@datatrafo@x + \advance \pgfplots@xcoordmaxTEX by-\pgfplots@data@scale@trafo@SHIFT@x pt + \fi + % carry local computations outside of group: + \xdef\pgfplots@glob@TMPa{% + \noexpand\def\noexpand\xdisstart{\the\xdisstart}% + \noexpand\def\noexpand\xdisend{\the\xdisend}% + \noexpand\def\noexpand\ydisstart{\the\ydisstart}% + \noexpand\def\noexpand\ydisend{\the\ydisend}% + \noexpand\pgfkeys{% + /tikz/xdiscont/.style={\xdiscontstyle},% + /tikz/ydiscont/.style={\ydiscontstyle}}% + }% + \endgroup + \pgfplots@glob@TMPa + \pgfplots@drawaxis@outerlines% + \pgfplots@drawaxis@innerlines% + \endgroup +}% + +% Computes final major and minor tick positions into global lists +% \pgfplots@prepared@tick@positions@major@x +% and +% \pgfplots@prepared@tick@positions@minor@x. +% +% The major tick list contains tuples (canvas position,logical position) +% while the minor tick list contains just the canvas position. +% +% #1: the tick list. +% #2: the axis name as character, i.e. 'x' or 'y' +% #3: the axis name as integer, i.e. 0 or 1 +\def\pgfplots@prepare@ticks@for#1#2#3{% + \begingroup + \expandafter\let\expandafter\ifpgfplots@islinear\csname ifpgfplots@#2islinear\endcsname + \expandafter\let\expandafter\ifpgfplots@minorticks\csname ifpgfplots@#2minorticks\endcsname + \expandafter\let\expandafter\ifpgfplots@minorgrids\csname ifpgfplots@#2minorgrids\endcsname + % these lists need to be global such that I can fill them inside + % of \foreach statements. And, yes: I have also added a TeX group + % on my own (but that's not the problem). + \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@major + \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@minor + \edef\pgfplots@loc@TMPa{#1}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \ifpgfplots@minorticks + \pgfplots@needsminorlooptrue + \else + \ifpgfplots@minorgrids + \pgfplots@needsminorlooptrue + \else + \pgfplots@needsminorloopfalse + \fi + \fi + \ifpgfplots@needsminorloop + \ifpgfplots@islinear + \expandafter\let\expandafter\pgfplots@minor@tick@num\csname pgfplots@minor@#2tick@num\endcsname + \begingroup + \c@pgf@counta=\pgfplots@minor@tick@num\relax + \advance\c@pgf@counta by1\relax + \pgfplots@tmpa=\csname pgfplots@tick@distance@#2\endcsname pt + \divide\pgfplots@tmpa by\c@pgf@counta + \edef\pgfmathresult{\pgf@sys@tonumber{\pgfplots@tmpa}}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@minor@tick@dist=\pgfmathresult + \else + \def\pgfplots@minor@tick@num{9}% + \fi + \fi + \foreach \x in {#1} {% + \ifcase#3\relax + \pgfextractx{\pgfplots@tmpa}{\pgfpointxy{\x}{0}}% + \or + \pgfextracty{\pgfplots@tmpa}{\pgfpointxy{0}{\x}}% + \fi + \csname pgfplots@#2tick@check@tickshow\endcsname + % + \ifpgfplots@tickshow + \ifdim\pgfplots@tmpa<\csname pgfplots@#2coordminTEX\endcsname + \else + \ifdim\pgfplots@tmpa>\csname pgfplots@#2coordmaxTEX\endcsname + \else + \edef\pgfplots@loc@TMPa{{\the\pgfplots@tmpa}{\x}}% + \expandafter\pgfplotslistpushbackglobal\pgfplots@loc@TMPa\to\pgfplots@prepared@tick@positions@major + \fi + \fi + \fi + % X-Axis ticks bottom and top + % in log: + % log( i*10^k ) = log\pgfplots@i + k\log10 -> draw ticks for i=1..9 + \ifpgfplots@needsminorloop + \foreach \pgfplots@i in {1,...,\pgfplots@minor@tick@num} {% + \begingroup + \ifcase#3\relax + \ifpgfplots@islinear + \pgfextractx{\pgfplots@tmpa}{\pgfpointxy{\pgfplots@i*\pgfplots@minor@tick@dist}{0}}% + \else + \pgfextractx{\pgfplots@tmpa}{\pgfpointxy{\logi\pgfplots@i}{0}}% + \fi + \or + \ifpgfplots@islinear + \pgfextracty{\pgfplots@tmpa}{\pgfpointxy{0}{\pgfplots@i*\pgfplots@minor@tick@dist}}% + \else + \pgfextracty{\pgfplots@tmpa}{\pgfpointxy{0}{\logi\pgfplots@i}}% + \fi + \fi + \edef\pgfmathresult{\the\pgfplots@tmpa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \advance\pgfplots@tmpa by\pgfmathresult\relax + \ifdim\pgfplots@tmpa<\csname pgfplots@#2coordminTEX\endcsname + \else + \ifdim\pgfplots@tmpa>\csname pgfplots@#2coordmaxTEX\endcsname + \else + \expandafter\pgfplotslistpushbackglobal\the\pgfplots@tmpa\to\pgfplots@prepared@tick@positions@minor + \fi + \fi + }% + \fi + }% + \fi + \endgroup + \expandafter\let\csname pgfplots@prepared@tick@positions@minor@#2\endcsname=\pgfplots@prepared@tick@positions@minor + \expandafter\let\csname pgfplots@prepared@tick@positions@major@#2\endcsname=\pgfplots@prepared@tick@positions@major + \global\let\pgfplots@prepared@tick@positions@major=\relax + \global\let\pgfplots@prepared@tick@positions@minor=\relax +}% + +% Converts the tuples in major tick lists into two separate variables. +% +% Usage: +% \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@x\as\curelement{% +% \expandafter\pgfplots@parse@prepared@major@tickpos\curelement\canvas\logical +% } +% +% #1#2 : the tuples as they are found in the prepared major tick list, +% #3 : a dimen register which will be filled with #1 +% #4 : a macro which will be assigned with #2 +\def\pgfplots@parse@prepared@major@tickpos#1#2#3#4{% + #3=#1\relax% + \def#4{#2}% +}% + + +% #1 : the verbatim axis name (either 'x' or 'y') +% #2 : the index of the axis (either 0 or 1) +\def\pgfplots@drawgridlines@for#1#2{% + \begingroup + \expandafter\let\expandafter\ifpgfplots@major\csname ifpgfplots@#1majorgrids\endcsname + \expandafter\let\expandafter\ifpgfplots@minor\csname ifpgfplots@#1minorgrids\endcsname + \expandafter\let\expandafter\pgfplots@prepared@tick@positions@major@\csname pgfplots@prepared@tick@positions@major@#1\endcsname + \expandafter\let\expandafter\pgfplots@prepared@tick@positions@minor@\csname pgfplots@prepared@tick@positions@minor@#1\endcsname + \pgfplots@loop@CONTINUEfalse + \ifpgfplots@major + \pgfplots@loop@CONTINUEtrue + \fi + \ifpgfplots@minor + \pgfplots@loop@CONTINUEtrue + \fi + \ifpgfplots@loop@CONTINUE + \scope + %\clip (\pgfplots@xcoordminTEX\pgfplots@leftover, \pgfplots@ycoordminTEX\pgfplots@leftover) + % rectangle (\pgfplots@xcoordmaxTEX\pgfplots@rightover, \pgfplots@ycoordmaxTEX\pgfplots@rightover); + \pgfinterruptboundingbox% + \ifcase#2\relax + \clip (\pgfplots@xcoordminTEX, \pgfplots@ycoordminTEX-5cm) + rectangle (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordmaxTEX+5cm); + \or + \clip (\pgfplots@xcoordminTEX-5cm, \pgfplots@ycoordminTEX) + rectangle (\pgfplots@xcoordmaxTEX+5cm, \pgfplots@ycoordmaxTEX); + \fi + \endpgfinterruptboundingbox% + \ifpgfplots@major + \draw[% + /pgfplots/every axis grid, + /pgfplots/every major grid, + /pgfplots/every axis #1 grid, + /pgfplots/every major #1 grid]% + \pgfextra + \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curgridpos{% + \expandafter\pgfplots@parse@prepared@major@tickpos\pgfplots@curgridpos\pgfplots@tmpa\pgfplots@curgridpos + \csname pgfplots@draw#1axis@placecomputedgridline\endcsname + }% + \endpgfextra; + \fi + % + \ifpgfplots@minor + \draw[% + /pgfplots/every axis grid, + /pgfplots/every minor grid, + /pgfplots/every axis #1 grid, + /pgfplots/every minor #1 grid]% + \pgfextra + \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curgridpos{% + \pgfplots@tmpa=\pgfplots@curgridpos + \csname pgfplots@draw#1axis@placecomputedgridline\endcsname + }% + \endpgfextra; + \fi + \endscope + \fi + \endgroup +} + +% #1 : the verbatim axis name (either 'x' or 'y') +% #2 : the index of the axis (either 0 or 1) +\def\pgfplots@drawticklines@for#1#2{% + \scope + \expandafter\let\expandafter\ifpgfplots@major\csname ifpgfplots@#1majorticks\endcsname + \expandafter\let\expandafter\ifpgfplots@minor\csname ifpgfplots@#1minorticks\endcsname + \expandafter\let\expandafter\pgfplots@prepared@tick@positions@major@\csname pgfplots@prepared@tick@positions@major@#1\endcsname + \expandafter\let\expandafter\pgfplots@prepared@tick@positions@minor@\csname pgfplots@prepared@tick@positions@minor@#1\endcsname + %\clip (\pgfplots@xcoordminTEX\pgfplots@leftover, \pgfplots@ycoordminTEX\pgfplots@leftover) + % rectangle (\pgfplots@xcoordmaxTEX\pgfplots@rightover, \pgfplots@ycoordmaxTEX\pgfplots@rightover); + \pgfinterruptboundingbox% + \ifcase#2\relax + \clip (\pgfplots@xcoordminTEX, \pgfplots@ycoordminTEX-5cm) + rectangle (\pgfplots@xcoordmaxTEX, \pgfplots@ycoordmaxTEX+5cm); + \or + \clip (\pgfplots@xcoordminTEX-5cm, \pgfplots@ycoordminTEX) + rectangle (\pgfplots@xcoordmaxTEX+5cm, \pgfplots@ycoordmaxTEX); + \fi + \endpgfinterruptboundingbox% + \ifpgfplots@major + \draw[% + /pgfplots/every tick, + /pgfplots/every major tick, + /pgfplots/every #1 tick, + /pgfplots/every major #1 tick]% + \pgfextra + \pgfmathparse{\pgfplots@tickwidth}% + \let\pgfplots@tickwidth@=\pgfmathresult + \edef\pgfplots@tickwidth{\pgfplots@tickwidth@ pt}% + \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax + \def\pgfplots@tick@offset{0} + \or + \let\pgfplots@tick@offset=\pgfplots@tickwidth@% + \or + \pgfmathmultiply@{0.5}{\pgfplots@tickwidth@}% + \let\pgfplots@tick@offset=\pgfmathresult% + \fi + \ifcase#2\relax + \pgfplots@prepare@tick@offsets@for@{#1}{y}{\pgfplots@tickwidth@}% + \else + \pgfplots@prepare@tick@offsets@for@{#1}{x}{\pgfplots@tickwidth@}% + \fi + \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% + \expandafter\pgfplots@parse@prepared@major@tickpos\pgfplots@curtickpos\pgfplots@tmpa\pgfplots@curtickpos + \csname pgfplots@draw#1axis@placecomputedtick\endcsname + }% + \endpgfextra; + \fi + % + \ifpgfplots@minor + \draw[% + /pgfplots/every tick, + /pgfplots/every minor tick, + /pgfplots/every #1 tick, + /pgfplots/every minor #1 tick]% + \pgfextra + \pgfmathparse{\pgfplots@subtickwidth}% + \let\pgfplots@subtickwidth@=\pgfmathresult + \edef\pgfplots@subtickwidth{\pgfplots@subtickwidth@ pt}% + \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax + \def\pgfplots@tick@offset{0}% + \or + \let\pgfplots@tick@offset=\pgfplots@subtickwidth@% + \or + \pgfmathmultiply@{0.5}{\pgfplots@subtickwidth@}% + \let\pgfplots@tick@offset=\pgfmathresult% + \fi + \ifcase#2\relax + \pgfplots@prepare@tick@offsets@for@{#1}{y}{\pgfplots@subtickwidth@}% + \else + \pgfplots@prepare@tick@offsets@for@{#1}{x}{\pgfplots@subtickwidth@}% + \fi + \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{% + \pgfplots@tmpa=\pgfplots@curtickpos + \csname pgfplots@draw#1axis@placecomputedtick\endcsname + }% + \endpgfextra; + \fi + \endscope +} + +% #1 : the verbatim axis name (either 'x' or 'y') +% #2 : the index of the axis (either 0 or 1) +\def\pgfplots@drawticklabels@for#1#2{% + \begingroup + \expandafter\let\expandafter\ifpgfplots@major\csname ifpgfplots@#1majorticks\endcsname + \expandafter\let\expandafter\ifpgfplots@islinear\csname ifpgfplots@#1islinear\endcsname + \expandafter\let\expandafter\pgfplots@prepared@tick@positions@major@\csname pgfplots@prepared@tick@positions@major@#1\endcsname + \ifpgfplots@major + \ifpgfplots@islinear + \pgfplots@if{pgfplots@scaled@ticks@#1}{% + \pgfplots@init@scaled@tick@for{#1}% + }\relax% + \fi + \begingroup + \pgfkeys{/tikz/every node/.append style={/pgfplots/every tick label,/pgfplots/every #1 tick label}}% + \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax + \def\pgfmathresult{0}% + \or + \pgfmathparse{\pgfplots@tickwidth}% + \or + \pgfmathmultiply{0.5}{\pgfplots@tickwidth}% + \fi + \let\pgfplots@tick@offset=\pgfmathresult + \ifnum\csname pgfplots@#1ticklabelposnum\endcsname=0 + % the choice '[xy]ticklabel pos=default': + \expandafter\let\expandafter\pgfplots@tmpposnum\csname pgfplots@#1tickposnum\endcsname + \else + \expandafter\let\expandafter\pgfplots@tmpposnum\csname pgfplots@#1ticklabelposnum\endcsname + \fi + \ifcase#2\relax + \ifcase\pgfplots@tmpposnum\relax + \edef\pgfplots@tick@origin{\pgf@sys@tonumber{\pgfplots@ycoordminTEX}}% + \or + \edef\pgfplots@tick@origin{\pgf@sys@tonumber{\pgfplots@ycoordminTEX}}% + \or + \pgf@xa=\pgfplots@ZERO@y + \edef\pgfplots@tick@origin{\pgf@sys@tonumber{\pgf@xa}}% + \or + \edef\pgfplots@tick@origin{\pgf@sys@tonumber{\pgfplots@ycoordmaxTEX}}% + \fi + \def\pgfplots@tickposchoicea{\tikzset{above}}% + \def\pgfplots@tickposchoiceb{\tikzset{below}}% + \or + \ifcase\pgfplots@tmpposnum\relax + \edef\pgfplots@tick@origin{\pgf@sys@tonumber{\pgfplots@xcoordminTEX}}% + \or + \edef\pgfplots@tick@origin{\pgf@sys@tonumber{\pgfplots@xcoordminTEX}}% + \or + \pgf@xa=\pgfplots@ZERO@x + \edef\pgfplots@tick@origin{\pgf@sys@tonumber{\pgf@xa}}% + \or + \edef\pgfplots@tick@origin{\pgf@sys@tonumber{\pgfplots@xcoordmaxTEX}}% + \fi + \def\pgfplots@tickposchoicea{\tikzset{right}}% + \def\pgfplots@tickposchoiceb{\tikzset{left}}% + \fi + \ifnum\pgfplots@tmpposnum=3 + \pgfplots@tickposchoicea + \pgfmathadd@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + \else + \pgfplots@tickposchoiceb + \pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + \fi + \edef\pgfplots@tick@origin{\pgfmathresult pt}% + \def\pgfplots@ticknum{0}% + \xdef\pgfplots@show@ticklabel@LASTTICK{}% + \pgfplotslistforeachungrouped\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% + \expandafter\pgfplots@parse@prepared@major@tickpos\pgfplots@curtickpos\pgfplots@tmpa\pgfplots@curtickpos + \ifcase#2\relax + \pgfplots@show@ticklabel + {#1}{\pgfplots@curtickpos}(\pgfplots@tmpa,\pgfplots@tick@origin)% + {\pgfplots@ticknum}% + \or + \pgfplots@show@ticklabel + {#1}{\pgfplots@curtickpos}(\pgfplots@tick@origin,\pgfplots@tmpa)% + {\pgfplots@ticknum}% + \fi + \begingroup + \c@pgf@counta=\pgfplots@ticknum\relax + \advance\c@pgf@counta by1 + \edef\pgfplots@ticknum{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfplots@ticknum + \endgroup + }% + \endgroup + \pgfplots@draw@tick@scale@label@for #1% + \fi + \endgroup +} + +\def\pgfplots@rememberplotspec#1{% + \pgfplotslistpushbackglobal{#1}\to\pgfplots@plotspeclist +} + +\def\pgfplots@getautoplotspec into#1{% + \pgfplotslistsize\autoplotspeclist\to\c@pgf@counta + \ifnum\c@pgf@counta=0 + \let#1=\pgfutil@empty + \else + \c@pgf@countb=\pgfplots@numplots + % offset modulo size: + \loop + \ifnum\c@pgf@countb<\c@pgf@counta + \pgfplots@loop@CONTINUEfalse + \else + \pgfplots@loop@CONTINUEtrue + \fi + \ifpgfplots@loop@CONTINUE + \advance\c@pgf@countb by-\c@pgf@counta + \repeat + \pgfplotslistselect\c@pgf@countb\of\autoplotspeclist\to#1 +%\pgfplots@message{pgfplots.sty: using \string\autoplotspeclist\ specification no\#\the\c@pgf@countb (of \the\c@pgf@counta): #1}% + \fi +} + +% The main interface to draw a plot into an axis. +% +% Usage: +% \addplot +% plot coordinates { +% (0,0) +% (1,1) +% }; +% +% or +% +% \addplot[color=blue,mark=*] +% plot coordinates { +% (0,0) +% (1,1) +% }; +% +% The first syntax will use the next plot specification in the list +% \autoplotspeclist +% and the first will use blue color and * markers. +% +% \addplot[