diff options
author | Karl Berry <karl@freefriends.org> | 2010-01-03 01:14:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-01-03 01:14:11 +0000 |
commit | 98837e31bcd7413ffa40c85ebbce9aa3ff3fdbed (patch) | |
tree | 1ed7f18cb8a81bb3f209bf158a38f5b624c2d607 /Master/texmf-dist/tex/generic | |
parent | 080069f58e2325db5ab0ac5f5ea584f3021bc383 (diff) |
pgfplots 1.3 (2jan10)
git-svn-id: svn://tug.org/texlive/trunk@16576 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic')
36 files changed, 18307 insertions, 3372 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex new file mode 100644 index 00000000000..616c0730726 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex @@ -0,0 +1,231 @@ +%-------------------------------------------- +% $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/libs/pgflibrarysurfshading.code.tex,v 1.18 2009/06/26 17:56:58 ludewich Exp $ +% +% 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +%-------------------------------------------------- +% \pgfqkeys{/pgfplots/surf shading}{ +% cols=3, +% % test colormap 1, +% } +% \pgfplotslibrarysurfstreamstart +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{0pt}{10pt}}{0} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{100pt}{10pt}}{100} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{180pt}{10pt}}{30} +% % +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{0pt}{100pt}}{300} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{110pt}{90pt}}{1000} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{190pt}{110pt}}{600} +% % +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{0pt}{200pt}}{0} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{110pt}{200pt}}{100} +% \pgfplotslibrarysurfstreamcoord{\pgfqpoint{190pt}{200pt}}{60} +% \pgfplotslibrarysurfstreamend +% \fbox{% +% \pgfplotslibrarysurfdraw +% }% +%-------------------------------------------------- + + +\pgfkeys{% + % the extends need to provided as \pgfpoint... The boundary box + % won't be computed manually! + /pgfplots/surf shading/south west corner/.initial={\pgfpointorigin},% + /pgfplots/surf shading/north east corner/.initial={\pgfqpoint{6cm}{6cm}},% + /pgfplots/surf shading/anchor/.initial=\pgfpointorigin,% + /pgfplots/surf shading/precision/.is choice, + /pgfplots/surf shading/precision/pdf/.code={% + % Lossless coordinate output. + \def\pgfplotslibrarysurf@bitspercoordinate{32}% + \def\pgfplotslibrarysurf@bytespercoordinate{4}% + \def\pgfplotslibrarysurf@filter@encode{}% raw binary. + \def\pgfplotslibrarysurf@filter@decode{}% + },% + /pgfplots/surf shading/precision/ps/.code={% + % quantized coordinate output (introduces quantization error). + \def\pgfplotslibrarysurf@bitspercoordinate{24}% + \def\pgfplotslibrarysurf@bytespercoordinate{3}% + % doesn't improve behavior of pdf2ps: + %\def\pgfplotslibrarysurf@filter@encode{ASCIIHexEncode}% + %\def\pgfplotslibrarysurf@filter@decode{ASCIIHexDecode}% + \def\pgfplotslibrarysurf@filter@encode{}% raw binary. + \def\pgfplotslibrarysurf@filter@decode{}% + },% + /pgfplots/surf shading/precision/postscript/.style={% + /pgfplots/surf shading/precision/ps},% + /pgfplots/surf shading/precision/ps,% + /pgfplots/surf shading/cols/.initial=,% + /pgfplots/surf shading/colormap/.initial={% + << + /FunctionType 2 + /Domain [0 1] + /C0 [0 0 1] /C1 [1 0 0] /N 1 + >> + },% + /pgfplots/surf shading/test colormap 1/.style={% + /pgfplots/surf shading/colormap={ + << + /FunctionType 3 + /Domain [0 1] + /Functions [ + << + /FunctionType 2 + /Domain [0 1] + /C0 [0 0 1] /C1 [1 1 0] /N 1 + >> + << + /FunctionType 2 + /Domain [0 1] + /C0 [1 1 0] /C1 [1 0.5 0] /N 1 + >> + << + /FunctionType 2 + /Domain [0 1] + /C0 [1 0.5 0] /C1 [1 0 0] /N 1 + >> + ] + /Bounds [ 0.3 0.6 ] + /Encode [0 1 0 1 0 1] + %/Range [0 1 0 1 0 1] INCOMPATIBLE WITH ACROBAT 6.0 + >> + }% + },% +}% + +\def\pgfplotslibrarysurf@corner@sw{\pgfkeysvalueof{/pgfplots/surf shading/south west corner}} +\def\pgfplotslibrarysurf@corner@ne{\pgfkeysvalueof{/pgfplots/surf shading/north east corner}}% + + +\def\pgfplotslibrarysurf@decode{% + -16383.999992 16384 % see the docs of \pgfplotsbinaryencodedimenmaplinearly + -16383.999992 16384 % + 0 \pgfplotscolormappdfmax % map [0,2^BitsPerComponent-1] linearly to [0 1] for parametric color data +}% +\def\pgfplotslibrarysurf@count{0}% + +% driver specific: +\def\pgfplotslibrarysurf@initstream{} +\def\pgfplotslibrarysurf@advancestreamlen#1{}% + +\def\pgfplotslibrarysurfstreamstart{% + \pgfplotsapplistXnewempty\pgfplotslibrarysurf@binarystream@accum + \pgfplotslibrarysurf@initstream + \ifx\pgfplotslibrarysurf@filter@encode\pgfutil@empty + \else + \pgfkeysalso{/pgfplots/bin/\pgfplotslibrarysurf@filter@encode}% + \fi +}% +\def\pgfplotslibrarysurfstreamend{% + \pgfplotsapplistXlet\pgfplotslibrarysurf@binarystream=\pgfplotslibrarysurf@binarystream@accum +}% + +% #1: a pgf point. +% #2: a color coordinate in the range [0,1000] +\def\pgfplotslibrarysurfstreamcoord#1#2{% + \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercoordinate% + \pgf@process{#1}% + % The idea is to map + % the low-level point coordinates LINEARLY into [0,2^{8*<bytes>}]. + % + % This is what the pdf standard expects for surface shadings. + % + % To do that, we simply map + % [-16384,16384] linearly into [0,2^{32}] + % and write the resulting integer in big endian binary format to + % the pdf low level stream. + % + % The decode procedure tells the pdf viewer how to invert that + % stuff. + % + \pgf@sys@bp@correct\pgf@x% + \pgfplotsbinaryencodedimenmaplinearly\pgf@x +%\message{POINT \the\c@pgfplots@scanlineindex: ENCODING(x=\the\pgf@x)=\pgfplotsbinaryresult.}\advance\c@pgfplots@scanlineindex by1 + \t@pgfplots@toka=\expandafter{\pgfplotsbinaryresult}% + \pgf@sys@bp@correct\pgf@y% + \pgfplotsbinaryencodedimenmaplinearly\pgf@y +%\message{ENCODING(y=\the\pgf@y)=\pgfplotsbinaryresult.}% + \t@pgfplots@tokb=\expandafter{\pgfplotsbinaryresult}% + {% + % read fixed point input (in the range [0,1000]). + \pgf@xa=#2pt + % convert to integer (= *65536): + \c@pgf@counta=\pgf@xa + % provide map [0,1000] -> [0,2^16-1] + \divide\c@pgf@counta by1000 + % now, we have \c@pgf@counta in [0,2^16]. Simply strip it into + % the required range, that's ok. + \ifnum\c@pgf@counta<0 + \c@pgf@counta=0 + \else + \ifnum\c@pgf@counta>65535 + \c@pgf@counta=65535 + \fi + \fi + % Now, we have CDATA in the range [0,65535] + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% +%\message{ENCODING(C=\pgfplots@glob@TMPa\space for \the\pgf@xa)=}% + }% + \pgfplotsbinarysetbytes2% + \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa +%\message{\pgfplotsbinaryresult.}% + \t@pgfplots@tokc=\expandafter{\pgfplotsbinaryresult}% + \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% + \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum + \pgfplotslibrarysurf@advancestreamlen{10}% +} + +\def\pgfplotslibrarysurfactivateshadefill{% + \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa% + \expandafter\pgfutil@addpdfresource@patterns\expandafter{\pgfplots@loc@TMPa}%% +} + +%-------------------------------------------------- +% \def\pgfplotslibrarysurfdraw{% +% % \pgftext[at=\pgfqpoint{0pt}{0pt}]% +% {\pgfplotssys@do@surfshading}% +% }% +%-------------------------------------------------- + +\def\pgfplotslibrarysurfdrawinpicture{% + \begingroup + \pgftransformshift{\pgfplotslibrarysurf@corner@sw}% + \pgftext[at=\pgfqpoint{0pt}{0pt},left,bottom] {% + \pgfplotslibrarysurfdraw +% this does NOT work because I can't undo the box' shift: +%\pgfplotssys@do@surfshading + }% + \endgroup +} + +\pgfplotsiffileexists{pgflibrarypgfplots.surfshading.\pgfsysdriver}{% + \input pgflibrarypgfplots.surfshading.\pgfsysdriver\relax + \def\pgflibrarysurfshadingifactive#1#2{#1}% +}{% + \def\pgfplotslibrarysurfdraw{% + \pgfplots@error{Sorry, surfshading (shader=interp) is NOT available for the selected driver `\pgfsysdriver'.}% + }% + \def\pgflibrarysurfshadingifactive#1#2{#2}% +} +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex new file mode 100644 index 00000000000..06bade77b9e --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex @@ -0,0 +1,56 @@ +% 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. +% Comment: This file has been modified to utilize libraries in the pgfplots package. +% Edited by Nick Papior Andersen + + + +% Loading further libraries + +% Include a library file. +% +% #1 = List of names of library file. +% +% Description: +% +% This command includes a list of pgfplots library files. For each file X in the +% list, the file tikzlibrarypgfplots.X.code.tex is included, provided this has +% not been done earlier. +% +% For the convenience of Context users, both round and square brackets +% are possible for the argument. +% +% Example: +% +% \usepgfplotslibrary{units} +% \usepgfplotslibrary[units,dateplot] + +\def\usepgfplotslibrary{\pgfutil@ifnextchar[{\use@pgfplotslibrary}{\use@@pgfplotslibrary}}%} +\def\use@pgfplotslibrary[#1]{\use@@pgfplotslibrary{#1}} +\def\use@@pgfplotslibrary#1{% + \edef\pgf@list{#1}% + \pgfutil@for\pgf@temp:=\pgf@list\do{% + \expandafter\ifx\csname pgfp@library@\pgf@temp @loaded\endcsname\relax% + \expandafter\global\expandafter\let\csname pgfp@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} + \catcode`\@=11 + \catcode`\|=12 + \pgfplots@iffileexists{tikzlibrarypgfplots.\pgf@temp.code.tex}{% + \input tikzlibrarypgfplots.\pgf@temp.code.tex}{% + \input pgflibrarypgfplots.\pgf@temp.code.tex}% + \catcode`\@=\csname tikz@library@#1@atcode\endcsname + \catcode`\|=\csname tikz@library@#1@barcode\endcsname + \fi% + }% +} + + +% Default loaded libraries: +% Currently none diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarydateplot.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarydateplot.code.tex deleted file mode 100644 index 161943d6c28..00000000000 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarydateplot.code.tex +++ /dev/null @@ -1,75 +0,0 @@ -%-------------------------------------------- -% -% 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 <http://www.gnu.org/licenses/>. -% -%-------------------------------------------- - -\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/libs/tikzlibrarypgfplots.dateplot.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex new file mode 100644 index 00000000000..8ac9a7631c0 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex @@ -0,0 +1,163 @@ +%-------------------------------------------- +% +% Package pgfplots, library for high-level coordinates. +% +% Copyright 2007/2008/2009 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +\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\pgfplotslibdateplot@number@to@julian@and@time#1.#2\julianto#3\hourto#4\minuteto#5{% + #3=#1 + \pgf@xa=0.#2pt + \multiply\pgf@xa by24 + \afterassignment\pgfplots@gobble@until@relax + \c@pgf@countb=\the\pgf@xa\relax + \edef#4{\the\c@pgf@countb}% + \advance\pgf@xa by-#4pt + \multiply\pgf@xa by60 + \afterassignment\pgfplots@gobble@until@relax + \c@pgf@countb=\the\pgf@xa\relax + % round minutes (we may loose precision here) + \advance\pgf@xa by-\the\c@pgf@countb pt + \ifdim\pgf@xa>0.5pt + \advance\c@pgf@countb by1 + \fi + \edef#5{\the\c@pgf@countb}% +} + +% #1 the date +% #2 the hours +% #3 the minutes +% #4 is either empty or is the seconds. +% #5 a macro which will be filled with the date part. +% #6 the macro which will contain a number in the range [0,1] +% representing hours and minutes. +% +% If you don't have seconds, you have to provide the second ':' sign +% as dummy! In that case #4 will be empty. +\def\pgfplotslibdateplot@map@time#1 #2:#3:#4\dateto#5\timeto#6{% + \pgf@xa=#2pt + \divide\pgf@xa by24 + \pgf@xb=#3pt + \divide\pgf@xb by1440 + \advance\pgf@xa by\pgf@xb + \ifdim\pgf@xa<0pt + \pgf@xa=0pt + \else + \ifdim\pgf@xa>1pt + \pgf@xa=1pt + \fi + \fi + \def#5{#1}% + \edef#6{\pgf@sys@tonumber\pgf@xa}% +}% +\def\pgfplotslibdateplot@discard@zero@dot 0.#1\to#2{\def#2{#1}}% + +\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 + \edef\pgfplotstempjuliandate{##1}% + % check if we also have a TIME like '2006-01-01 11:21' + \expandafter\pgfutil@in@\expandafter:\expandafter{\pgfplotstempjuliandate}% + \ifpgfutil@in@ + % we have a TIME! + \expandafter\pgfplotslibdateplot@map@time\pgfplotstempjuliandate:\dateto\pgfplotstempjuliandate\timeto\pgfplotstemptime + \else + \let\pgfplotstemptime=\pgfutil@empty + \fi + \expandafter\pgfcalendardatetojulian\expandafter{\pgfplotstempjuliandate}\c@pgf@counta + \advance\c@pgf@counta by-\pgfplots@calender@ZEROSHIFT\relax + \ifx\pgfplotstemptime\pgfutil@empty + % no time: + \edef\pgfmathresult{\the\c@pgf@counta}% + \else + % add time fraction (which should be in the range + % [0,1]). + \ifdim\pgfplotstemptime pt<1pt + % discard prefix '0.': + \expandafter\pgfplotslibdateplot@discard@zero@dot\pgfplotstemptime\to\pgfplotstemptime + \edef\pgfmathresult{\the\c@pgf@counta.\pgfplotstemptime}% + \else + % assume \pgfplotstemptime=1pt : + \advance\c@pgf@counta by1 + \edef\pgfmathresult{\the\c@pgf@counta}% + \fi + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup + }, + /pgfplots/#1 coord inv trafo/.code={% + \begingroup + \pgfplotslibdateplot@number@to@julian@and@time##1\julianto{\c@pgf@counta}\hourto\Hour\minuteto\Minute% + \advance\c@pgf@counta by\pgfplots@calender@ZEROSHIFT\relax + \expandafter\pgfcalendarjuliantodate\expandafter{\the\c@pgf@counta}\year\month\day + \xdef\pgfplotslibdateplot@TMP{% + \noexpand\def\noexpand\year{\year}% + \noexpand\def\noexpand\month{\month}% + \noexpand\def\noexpand\day{\day}% + \noexpand\def\noexpand\Hour{\Hour}% + \noexpand\def\noexpand\Minute{\Minute}% + }% + \endgroup + \pgfplotslibdateplot@TMP + \let\hour=\Hour + \let\minute=\Minute + \ifnum\hour<10 + \edef\hour{0\hour}% + \fi + \ifnum\minute<10 + \edef\minute{0\minute}% + \fi + \def\Second{0}% + \def\second{00}% + \edef\lowlevel{##1}% + \edef\pgfmathresult{\year-\month-\day}% + }, + /pgfplots/#1ticklabel={\tick},% + /pgfplots/scaled #1 ticks=false, + /pgfplots/plot coordinates/math parser=false,% + }, + /pgfplots/date coordinates in/.value required, +} + diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex new file mode 100644 index 00000000000..2df18861a1e --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex @@ -0,0 +1,98 @@ +%-------------------------------------------- +% +% Package pgfplots, library for high-level coordinates. +% +% Copyright 2007/2008/2009 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +% This file is a wrapper which loads the external library. +% +% If we have a recent pgf version, use its external lib. If not: load +% the copy shipped with pgfplots. +% +% NOTE: +% the external library has been written by Christian Feuersänger as +% part of his work on pgfplots -- since it is general purpose, it is +% part of tikz. A copy comes with pgfplots. +% +% + +\def\pgfplots@orig@pgfincludeexternalgraphics#1{% + \begingroup + \openin\r@pgfplots@reada=#1.dpth + \setbox1=\hbox{\pgfkeysvalueof{/pgf/images/include external/.@cmd}{#1}\pgfeov}% + \ifeof\r@pgfplots@reada + \box1 + \else + \read\r@pgfplots@reada to\pgfincludeexternalgraphics@dp + \closein\r@pgfplots@reada + \dimen0=\pgfincludeexternalgraphics@dp\relax + \hbox{\lower\dimen0 \box1 }% + \fi + \endgroup +} +\def\pgfplots@orig@pgf@external@grab#1{% + \def\pgf@filename{#1}% + \setbox\pgfpic=\hbox\bgroup\bgroup% + \let\endpgfgraphicnamed=\pgf@externalend% +} +\def\pgfplots@orig@pgf@externalend{% + \unskip\egroup\egroup% + {% + \parindent0pt% +% \leftmargin0pt% +% \rightmargin0pt% + \dimen0\ht\pgfpic% + \advance\dimen0\dp\pgfpic% + \ifdim\dp\pgfpic=0pt\relax + \else% store the picture's depth. Otherwise, it would be lost. + \immediate\openout\pgf@plotwrite=\pgf@filename.dpth + \immediate\write\pgf@plotwrite{\the\dp\pgfpic}% + \immediate\closeout\pgf@plotwrite + \fi + \pgfsys@papersize{\the\wd\pgfpic}{\the\dimen0}% + \setbox0=\vbox{% + \kern -1truein% + \hbox{% + \kern -1truein% + \hbox to0pt{% + \wd\pgfexternal@startupbox=0pt% + \ht\pgfexternal@startupbox=0pt% + \dp\pgfexternal@startupbox=0pt% + \box\pgfexternal@startupbox% + \pgfsys@atbegindocument\hss}% + \box\pgfpic% + \kern 1truein}% + \kern1truein}% + \pgfexternal@originalshipout\box0% + }% +} + +\pgfplotsiffileexists{tikzlibraryexternal.code.tex}{% + \usetikzlibrary{external}% +}{% + % Backwards compatibility: + \input pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex + \pgfkeys{ + /pgf/images/include external/.code={\pgfimage{#1}}, + }% + \let\pgfincludeexternalgraphics=\pgfplots@orig@pgfincludeexternalgraphics + \let\pgf@external@grab=\pgfplots@orig@pgf@external@grab + \let\pgf@externalend=\pgfplots@orig@pgf@externalend +}% + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex new file mode 100644 index 00000000000..ac81e8f5491 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex @@ -0,0 +1,330 @@ +%-------------------------------------------- +% +% 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 2009 by Nick Papior Andersen. +% +% 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +\newif\ifpgfplots@group@sharedlabels + +\def\pgfplots@group@xticklabels{} +\def\pgfplots@group@yticklabels{} +\def\pgfplots@group@totalplots{1} +\def\pgfplots@group@columns{1} +\def\pgfplots@group@rows{1} +\def\pgfplots@group@name{group} +\def\pgfplots@group@style{} +\gdef\pgfplots@group@rmopts{} +\newcount\pgfplots@group@current@plot +\newcount\pgfplots@group@current@row +\newcount\pgfplots@group@current@column + +\usetikzlibrary{calc} + +\pgfkeys{ + /pgfplots/group/.is family, + /pgfplots/group style/.store in=\pgfplots@group@style, + /pgfplots/group/horizontal sep/.initial=1cm, + /pgfplots/group/vertical sep/.initial=1cm, + /pgfplots/group/group size/.style args={#1 by #2}{/pgfplots/group/columns=#1,/pgfplots/group/rows=#2}, + /pgfplots/group/group size/.default={1 by 1}, + /pgfplots/group/columns/.store in=\pgfplots@group@columns, + /pgfplots/group/rows/.store in=\pgfplots@group@rows, + /pgfplots/group/every plot/.style=, + /pgfplots/group/shared labels/.is if=pgfplots@group@sharedlabels, + /pgfplots/group/shared labels=false, + /pgfplots/group/xticklabels at/.is choice, + /pgfplots/group/xticklabels at/all/.code=\def\pgfplots@group@xticklabels{all}, + /pgfplots/group/xticklabels at/edge top/.code=\def\pgfplots@group@xticklabels{edgeT}, + /pgfplots/group/xticklabels at/edge bottom/.code=\def\pgfplots@group@xticklabels{edgeB}, + /pgfplots/group/xticklabels at=all, + /pgfplots/group/yticklabels at/.is choice, + /pgfplots/group/yticklabels at/all/.code=\def\pgfplots@group@yticklabels{all}, + /pgfplots/group/yticklabels at/edge left/.code=\def\pgfplots@group@yticklabels{edgeL}, + /pgfplots/group/yticklabels at/edge right/.code=\def\pgfplots@group@yticklabels{edgeR}, + /pgfplots/group/yticklabels at=all, + /pgfplots/group/group name/.store in=\pgfplots@group@name, + /pgfplots/group/empty plot/.style={/pgfplots/hide axis=true}, +} + +\def\nextgroupplot{% + \pgfutil@ifnextchar[{\pgfplots@group@nextplot}{\pgfplots@group@nextplot[]}%} +} + +% +% The actual addition of the new plots +% +\def\pgfplots@group@nextplot[#1]{% + % Check if it legal to produce another plot + \ifnum\pgfplots@group@current@plot=\pgfplots@group@totalplots\relax + \pgfplots@warning{You are adding more plots than you specified, current plots=\the\pgfplots@group@current@plot\space vs. total allowed + plots=\pgfplots@group@totalplots.} + \else + % + % If there has been other plots before then end the plot + % + \ifnum0<\pgfplots@group@current@plot\relax + \endpgfplots@environment@opt + \fi + % Prepare for next plot, increment plot, row and column + \pgfplots@group@increment@numbers + % DEBUG: \message{DEBUG: Cur. Plot: \the\pgfplots@group@current@plot. Current Row: \the\pgfplots@group@current@row. Current Column: \the\pgfplots@group@current@column.} + % Creation of the new axis environment + \pgfplots@group@environment@create{#1} + \fi +} +% +% This creates an environment according to which plots that have been typeset. +% The code utilizes previous plots anchor points to position themselves, unless it's the +% first plot. +% Using the figure below to describe the code implementation: +% ____ ____ ____ +%| | | | | | +%| 1 | | 2 | | 3 | +%|___| |___| |___| +% ____ ____ ____ +%| | | | | | +%| 4 | | 5 | | 6 | +%|___| |___| |___| +% ____ ____ ____ +%| | | | | | +%| 7 | | 8 | | 9 | +%|___| |___| |___| +% +% The plots anchors are as follows: +% 1: plot is typeset normally +% 2: the "1" plot anchor "east" is anchored to "west" +% 3: the "2" plot anchor "east" is anchored to "west" +% 4: the "1" plot anchor "south" is anchored to "north" +% 5: the "2" plot anchor "south" is anchored to "north" +% 6: the "3" plot anchor "south" is anchored to "north" +% 7: the "4" plot anchor "south" is anchored to "north" +% 8: the "5" plot anchor "south" is anchored to "north" +% 9: the "6" plot anchor "south" is anchored to "north" +% +\def\pgfplots@group@environment@create#1{% + \ifnum1=\pgfplots@group@current@row\relax + \ifnum1=\pgfplots@group@current@column\relax + \pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% + /pgfplots/group/every plot,% + /pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% + #1] + \else + \pgfplotsgroupplotsmath@decrease\pgfplots@group@current@column + \xdef\pgfplots@glob@TMPb{\pgfplots@group@name\space c\pgfmathresult r\the\pgfplots@group@current@row} + \pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% + /pgfplots/group/every plot,% + /pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% + at={($(\pgfplots@glob@TMPb.east)+(\pgfkeysvalueof{/pgfplots/group/horizontal sep},0)$)},anchor=west,% + #1] + \fi + \else + \pgfplotsgroupplotsmath@decrease\pgfplots@group@current@row + \xdef\pgfplots@glob@TMPb{\pgfplots@group@name\space c\the\pgfplots@group@current@column r\pgfmathresult} + \pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% + /pgfplots/group/every plot,% + /pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% + at={($(\pgfplots@glob@TMPb.south)-(0,\pgfkeysvalueof{/pgfplots/group/vertical sep})$)},anchor=north,% + #1]% + \fi% +} + +\def\pgfplots@group@determine@ticklabels{% + \def\pgfplots@loc@TMPa{all} + \def\pgfplots@loc@TMPb{edgeT} + \def\pgfplots@loc@TMPc{edgeB} + \ifx\pgfplots@loc@TMPa\pgfplots@group@xticklabels% + % Do nothing as all should have xticklabels + \fi + \gdef\pgfplots@glob@TMPa{} + \ifx\pgfplots@loc@TMPb\pgfplots@group@xticklabels% + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r1/.append style={xticklabel pos=upper}}% + \ifnum1<\pgfplots@group@rows\relax + \foreach \pgfplots@row in {2,...,\pgfplots@group@rows} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xticklabels={}}}% + }% + \fi% + }% + \fi + \ifx\pgfplots@loc@TMPc\pgfplots@group@xticklabels% + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@group@rows/.append style={xticklabel pos=lower}}% + \ifnum1<\pgfplots@group@rows\relax + \pgfplotsgroupplotsmath@decrease\pgfplots@group@rows + \foreach \pgfplots@row in {1,...,\pgfmathresult} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xticklabels={}}}% + }% + \fi% + }% + \fi% + % + % Defining styles for the ytick's + % + \def\pgfplots@loc@TMPb{edgeL} + \def\pgfplots@loc@TMPc{edgeR} + \ifx\pgfplots@loc@TMPa\pgfplots@group@yticklabels% + % Do nothing as all should have yticklabels + \fi + \ifx\pgfplots@loc@TMPb\pgfplots@group@yticklabels% + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c1r\pgfplots@row/.append style={yticklabel pos=left}}% + \ifnum1<\pgfplots@group@columns\relax + \foreach \pgfplots@column in {2,...,\pgfplots@group@columns} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/yticklabels={}}}% + }% + \fi% + }% + \fi + \ifx\pgfplots@loc@TMPc\pgfplots@group@yticklabels% + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@group@columns r\pgfplots@row/.append style={yticklabel pos=right}}% + \ifnum1<\pgfplots@group@columns\relax + \pgfplotsgroupplotsmath@decrease\pgfplots@group@columns + \foreach \pgfplots@column in {1,...,\pgfmathresult} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/yticklabels={}}}% + }% + \fi% + }% + \fi% + \expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa} +} + +% +% The counters which are used to determine the current plot: +% \pgfplots@group@current@plot +% \pgfplots@group@current@column +% \pgfplots@group@current@row +% gets incremented according to the scheme below: +% ____ ____ ____ +%| | | | | | +%| 1 | | 2 | | 3 | +%|___| |___| |___| +% ____ ____ ____ +%| | | | | | +%| 4 | | 5 | | 6 | +%|___| |___| |___| +% ____ ____ ____ +%| | | | | | +%| 7 | | 8 | | 9 | +%|___| |___| |___| +% where the number matches the plot number. +% +\def\pgfplots@group@increment@numbers{% + \advance\pgfplots@group@current@plot by1 + \ifnum\pgfplots@group@current@column=\pgfplots@group@columns\relax + \ifnum1=\pgfplots@group@current@plot\relax + \else + \advance\pgfplots@group@current@row by1 + \fi + \pgfplots@group@current@column=1 + \else + \advance\pgfplots@group@current@column by1 + \fi +} + +\def\pgfplots@group@get@plot@name#1,#2\in#3{% + \edef#3{c#1r#2}% +} + + +% +% Setting up all possible styles in current plot +% I.e. Setting: +% /pgfplots/group/plot c1r1/.style= +% /pgfplots/group/plot c2r1/.style= +% ... +% /pgfplots/group/plot c<columns>r<rows>/.style= +% +\def\pgfplots@group@individual@setup{% + \gdef\pgfplots@glob@TMPa{} + \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% + \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% + \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.style=}% + }% + }% + \expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa}% +} + + + +% +% Implementation of the environment {groupplots} +\def\pgfplots@environment@groupplot{% + \pgfutil@ifnextchar[{\pgfplots@@environment@groupplot}{\pgfplots@@environment@groupplot[\pgfutil@empty]}% +} + +\def\endpgfplots@environment@groupplot{\endpgfplots@environment@opt\endgroup} + +\def\pgfplots@@environment@groupplot[#1]{% + \begingroup% + % Only find the keys column and row + % the following things appear to be complete... ? + \pgfkeysinstallkeyfilterhandler{/pgf/key filter handlers/append filtered to}{\pgfplots@group@rmopts}% + \let\pgfplots@group@rmopts=\pgfutil@empty + \pgfkeysinstallkeyfilter{/pgf/key filters/equals}{/pgfplots/group style} + \pgfkeysinstallkeyfilter{/pgf/key filters/is descendant of}{/pgfplots/group} + \pgfqkeysfiltered{/pgfplots}{#1} + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfkeys{/pgfplots/group/.cd,\pgfplots@group@style} + }\pgfplots@loc@TMPa + \expandafter\pgfplots@set@options\expandafter{\pgfplots@group@rmopts} + \pgfplots@group@individual@setup + \pgfplots@group@determine@ticklabels + \pgfplots@group@current@plot=0% + \pgfplots@group@current@row=1% + \pgfplots@group@current@column=0% + \begingroup + \c@pgf@counta=\pgfplots@group@rows\relax + \multiply \c@pgf@counta by\pgfplots@group@columns\relax + \edef\pgfmathresult{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \edef\pgfplots@group@totalplots{\pgfmathresult}% + %DEBUG: \message{TEST: \pgfplots@group@totalplots, rows=\pgfplots@group@rows, columns=\pgfplots@group@columns}% +} + +% Assigns \pgfmathresult as #1-1 (in integer arithmetics) +% +% #1 an integer (a register or something which expands to an integer). +\def\pgfplotsgroupplotsmath@decrease#1{% + \begingroup + \c@pgf@counta=#1\relax + \advance\c@pgf@counta by-1 + \edef\pgfmathresult{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +} + +\tikzaddtikzonlycommandshortcutlet\groupplot\pgfplots@environment@groupplot +\tikzaddtikzonlycommandshortcutlet\endgroupplot\endpgfplots@environment@groupplot + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.units.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.units.code.tex new file mode 100644 index 00000000000..5326db78aba --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.units.code.tex @@ -0,0 +1,224 @@ +%-------------------------------------------- +% +% 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 2009 by Nick Papior Andersen. +% +% 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +% +% This file contains the implementation for using units in labels. +% +% Default the unit setting system isn't used, It is thus required to use the key "use units". +% +% Programming Structure: +% +% 1. All associated keys are first set. This includes some prefix values of the unit system. +% In example one can redefine prefix and postfix such that units are shown on a per-user setting. +% +% 2. The other main thing is scaling of the dimension. If one uses units one might not +% have scaled the data. For this the keys "scaled <axis> ticks" are used at a base 10. +% Currently it is not provided to scale in other bases. +% FIXME Adding of other bases. +% +% 3. Some predefined SI prefixes are specified which should minimize mistakes. +% For example the key "change <axis> base,<axis> SI prefix=kilo" allows the +% <axis> to be rescaled according to the above at base 10 with a factor of -3 and sets the +% unit prefix to "k". +% FIXME Adding other basis systems than SI. For example the addition of CGS units. + +\newif\ifpgfplots@units@change@x@base +\newif\ifpgfplots@units@change@y@base +\newif\ifpgfplots@units@change@z@base + +% +% Constants for writing the unit marking +% +\def\pgfplots@units@marking@pre{} +\def\pgfplots@units@marking@post{} + +\pgfkeys{% + /pgfplots/use units/.is if=pgfplots@units@use,% + /pgfplots/use units=true,% So when called from \usepgfplotslibrary{units} it's automatically 'on' + % + % Setup basic x settings + % + /pgfplots/x unit/.initial={},% + /pgfplots/x unit prefix/.initial={},% + /pgfplots/change x base/.is if=pgfplots@units@change@x@base,% + /pgfplots/change x base/.initial=false,% + % + % Setup basic y settings + % + /pgfplots/y unit/.initial={},% + /pgfplots/y unit prefix/.initial={},% + /pgfplots/change y base/.is if=pgfplots@units@change@y@base,% + /pgfplots/change y base/.initial=false,% + % + % Setup basic z settings + % + /pgfplots/z unit/.initial={},% + /pgfplots/z unit prefix/.initial={},% + /pgfplots/change z base/.is if=pgfplots@units@change@z@base,% + /pgfplots/change z base/.initial=false,% + % + % default markings of units. I.e. the surroundings of the unit: + % [unit markings=curly braces] yields {<unit>} + % + /pgfplots/unit marking pre/.store in={\pgfplots@units@marking@pre},% + /pgfplots/unit marking post/.store in={\pgfplots@units@marking@post},% + /pgfplots/unit markings/.is choice,% + /pgfplots/unit markings/parenthesis/.style={/pgfplots/unit marking pre={\left(},/pgfplots/unit marking post={\right)}},% + /pgfplots/unit markings/square braces/.style={/pgfplots/unit marking pre={\left[},/pgfplots/unit marking post={\right]}},% + /pgfplots/unit markings/curly braces/.style={/pgfplots/unit marking pre={\left\{},/pgfplots/unit marking post={\right\}}},% + /pgfplots/unit markings/slash space/.style={/pgfplots/unit marking pre={/$\space$},/pgfplots/unit marking post={\relax}},% + /pgfplots/unit markings=square braces,% + % + % The code used to type units, and the base change code. + % + /pgfplots/unit code/.code 2 args={\mathrm{#1#2}},% + /pgfplots/axis base prefix/.code args={axis #1 base #2 prefix #3}{% + \csname ifpgfplots@units@change@#1@base\endcsname% + \pgfkeys{/pgfplots/#1\space unit prefix={#3},% + /pgfplots/scaled #1\space ticks={base 10:#2},% + /pgfplots/#1tick scale label code/.code={\relax}% + }% + \else% + \pgfkeys{/pgfplots/#1\space unit prefix={#3}}% + \fi% + },% + % + % x SI prefixes + % + /pgfplots/x SI prefix/.is choice,% + /pgfplots/x SI prefix/yocto/.style={/pgfplots/axis base prefix={axis x base 24 prefix y}},% + /pgfplots/x SI prefix/zepto/.style={/pgfplots/axis base prefix={axis x base 21 prefix z}},% + /pgfplots/x SI prefix/atto/.style={/pgfplots/axis base prefix={axis x base 18 prefix a}},% + /pgfplots/x SI prefix/femto/.style={/pgfplots/axis base prefix={axis x base 15 prefix f}},% + /pgfplots/x SI prefix/pico/.style={/pgfplots/axis base prefix={axis x base 12 prefix p}},% + /pgfplots/x SI prefix/nano/.style={/pgfplots/axis base prefix={axis x base 9 prefix n}},% + /pgfplots/x SI prefix/micro/.style={/pgfplots/axis base prefix={axis x base 6 prefix \mu}},% + /pgfplots/x SI prefix/milli/.style={/pgfplots/axis base prefix={axis x base 3 prefix m}},% + /pgfplots/x SI prefix/centi/.style={/pgfplots/axis base prefix={axis x base 2 prefix c}},% + /pgfplots/x SI prefix/deci/.style={/pgfplots/axis base prefix={axis x base 1 prefix d}},% + /pgfplots/x SI prefix/deca/.style={/pgfplots/axis base prefix={axis x base -1 prefix da}},% + /pgfplots/x SI prefix/hecto/.style={/pgfplots/axis base prefix={axis x base -2 prefix h}},% + /pgfplots/x SI prefix/kilo/.style={/pgfplots/axis base prefix={axis x base -3 prefix k}},% + /pgfplots/x SI prefix/mega/.style={/pgfplots/axis base prefix={axis x base -6 prefix M}},% + /pgfplots/x SI prefix/giga/.style={/pgfplots/axis base prefix={axis x base -9 prefix G}},% + /pgfplots/x SI prefix/tera/.style={/pgfplots/axis base prefix={axis x base -12 prefix T}},% + /pgfplots/x SI prefix/peta/.style={/pgfplots/axis base prefix={axis x base -15 prefix P}},% + /pgfplots/x SI prefix/exa/.style={/pgfplots/axis base prefix={axis x base -18 prefix E}},% + /pgfplots/x SI prefix/zetta/.style={/pgfplots/axis base prefix={axis x base -21 prefix Z}},% + /pgfplots/x SI prefix/yotta/.style={/pgfplots/axis base prefix={axis x base -24 prefix Y}},% + % + % y SI prefixes + % + /pgfplots/y SI prefix/.is choice,% + /pgfplots/y SI prefix/yocto/.style={/pgfplots/axis base prefix={axis y base 24 prefix y}},% + /pgfplots/y SI prefix/zepto/.style={/pgfplots/axis base prefix={axis y base 21 prefix z}},% + /pgfplots/y SI prefix/atto/.style={/pgfplots/axis base prefix={axis y base 18 prefix a}},% + /pgfplots/y SI prefix/femto/.style={/pgfplots/axis base prefix={axis y base 15 prefix f}},% + /pgfplots/y SI prefix/pico/.style={/pgfplots/axis base prefix={axis y base 12 prefix p}},% + /pgfplots/y SI prefix/nano/.style={/pgfplots/axis base prefix={axis y base 9 prefix n}},% + /pgfplots/y SI prefix/micro/.style={/pgfplots/axis base prefix={axis y base 6 prefix \mu}},% + /pgfplots/y SI prefix/milli/.style={/pgfplots/axis base prefix={axis y base 3 prefix m}},% + /pgfplots/y SI prefix/centi/.style={/pgfplots/axis base prefix={axis y base 2 prefix c}},% + /pgfplots/y SI prefix/deci/.style={/pgfplots/axis base prefix={axis y base 1 prefix d}},% + /pgfplots/y SI prefix/deca/.style={/pgfplots/axis base prefix={axis y base -1 prefix da}},% + /pgfplots/y SI prefix/hecto/.style={/pgfplots/axis base prefix={axis y base -2 prefix h}},% + /pgfplots/y SI prefix/kilo/.style={/pgfplots/axis base prefix={axis y base -3 prefix k}},% + /pgfplots/y SI prefix/mega/.style={/pgfplots/axis base prefix={axis y base -6 prefix M}},% + /pgfplots/y SI prefix/giga/.style={/pgfplots/axis base prefix={axis y base -9 prefix G}},% + /pgfplots/y SI prefix/tera/.style={/pgfplots/axis base prefix={axis y base -12 prefix T}},% + /pgfplots/y SI prefix/peta/.style={/pgfplots/axis base prefix={axis y base -15 prefix P}},% + /pgfplots/y SI prefix/exa/.style={/pgfplots/axis base prefix={axis y base -18 prefix E}},% + /pgfplots/y SI prefix/zetta/.style={/pgfplots/axis base prefix={axis y base -21 prefix Z}},% + /pgfplots/y SI prefix/yotta/.style={/pgfplots/axis base prefix={axis y base -24 prefix Y}},% + % + % z SI prefixes + % + /pgfplots/z SI prefix/.is choice,% + /pgfplots/z SI prefix/yocto/.style={/pgfplots/axis base prefix={axis z base 24 prefix y}},% + /pgfplots/z SI prefix/zepto/.style={/pgfplots/axis base prefix={axis z base 21 prefix z}},% + /pgfplots/z SI prefix/atto/.style={/pgfplots/axis base prefix={axis z base 18 prefix a}},% + /pgfplots/z SI prefix/femto/.style={/pgfplots/axis base prefix={axis z base 15 prefix f}},% + /pgfplots/z SI prefix/pico/.style={/pgfplots/axis base prefix={axis z base 12 prefix p}},% + /pgfplots/z SI prefix/nano/.style={/pgfplots/axis base prefix={axis z base 9 prefix n}},% + /pgfplots/z SI prefix/micro/.style={/pgfplots/axis base prefix={axis z base 6 prefix \mu}},% + /pgfplots/z SI prefix/milli/.style={/pgfplots/axis base prefix={axis z base 3 prefix m}},% + /pgfplots/z SI prefix/centi/.style={/pgfplots/axis base prefix={axis z base 2 prefix c}},% + /pgfplots/z SI prefix/deci/.style={/pgfplots/axis base prefix={axis z base 1 prefix d}},% + /pgfplots/z SI prefix/deca/.style={/pgfplots/axis base prefix={axis z base -1 prefix da}},% + /pgfplots/z SI prefix/hecto/.style={/pgfplots/axis base prefix={axis z base -2 prefix h}},% + /pgfplots/z SI prefix/kilo/.style={/pgfplots/axis base prefix={axis z base -3 prefix k}},% + /pgfplots/z SI prefix/mega/.style={/pgfplots/axis base prefix={axis z base -6 prefix M}},% + /pgfplots/z SI prefix/giga/.style={/pgfplots/axis base prefix={axis z base -9 prefix G}},% + /pgfplots/z SI prefix/tera/.style={/pgfplots/axis base prefix={axis z base -12 prefix T}},% + /pgfplots/z SI prefix/peta/.style={/pgfplots/axis base prefix={axis z base -15 prefix P}},% + /pgfplots/z SI prefix/exa/.style={/pgfplots/axis base prefix={axis z base -18 prefix E}},% + /pgfplots/z SI prefix/zetta/.style={/pgfplots/axis base prefix={axis z base -21 prefix Z}},% + /pgfplots/z SI prefix/yotta/.style={/pgfplots/axis base prefix={axis z base -24 prefix Y}}% +} +% +% The initial insert of labels. It utilizes the same method of implementation as +% the default label typesetting. +% +\def\pgfplots@label@units#1{% + \pgfkeysgetvalue{/pgfplots/#1label}{\pgfplots@loc@TMPa}% + \pgfplots@loc@TMPa\space\pgfplots@label@units@@{#1}% +} + +% +% The main macro for typesetting the units. In steps: +% +% 1. Save the unit prefix, unit and the unit code in macros. +% +% 2. If the unit isn't present then don't utilize any of the things. +% FIXME, should this also happen if the prefix is given? Currently it is not! +% +% 3. Defines \pgfplots@loc@TMPa as the real typeset label. +% It inserts the <marking pre><unit prefix><unit><marking post>. +% It is encapsulated within a $$ notation. Currently this is enough. +% FIXME, maybe this should be changed to \ensuremath? +% +\def\pgfplots@label@units@@#1{% + \pgfkeysgetvalue{/pgfplots/#1\space unit prefix}{\pgfplots@loc@TMPb}% + \pgfkeysgetvalue{/pgfplots/#1\space unit}{\pgfplots@loc@TMPc}% + \ifx\pgfplots@loc@TMPc\pgfutil@empty% + \pgfutil@empty% + \else% + \ifx\pgfplots@loc@TMPb\pgfutil@empty% + $ + \pgfplots@units@marking@pre + \pgfplots@invoke@pgfkeyscode{/pgfplots/unit code/.@cmd}{{}{\pgfkeysvalueof{/pgfplots/#1\space unit}}} + \pgfplots@units@marking@post + $% + \else% + $ + \pgfplots@units@marking@pre + \pgfplots@invoke@pgfkeyscode{/pgfplots/unit code/.@cmd}{{\pgfkeysvalueof{/pgfplots/#1\space unit prefix}}{\pgfkeysvalueof{/pgfplots/#1\space unit}}} + \pgfplots@units@marking@post + $% + \fi% + \fi% +} +\endinput
\ No newline at end of file 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 acc5ec7c53b..7464dc43876 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex @@ -7,13 +7,22 @@ % % \pgfplotsarraynewempty % \pgfplotsarraynew +% \pgfplotsarrayresize % \pgfplotsarraycopy % \pgfplotsarraypushback % \pgfplotsarraysize % \pgfplotsarrayselect +% \pgfplotsarrayset % \pgfplotsarrayletentry % \pgfplotsarraycheckempty % \pgfplotsarrayforeach +% \pgfplotsarraysort +% +% and a subset also for global arrays: +% \pgfplotsarraynewemptyglobal +% \pgfplotsarrayresizeglobal +% \pgfplotsarraysetglobal +% \pgfplotsarrayletentryglobal % % Copyright 2007/2008 by Christian Feuersänger. % @@ -38,9 +47,22 @@ \newif\ifpgfplotsarrayempty % Creates a new, empty array. -\long\def\pgfplotsarraynewempty#1{% +\def\pgfplotsarraynewempty#1{% \pgfplotsarray@@def{#1@size}{0}% } +\def\pgfplotsarraynewemptyglobal#1{% + \expandafter\gdef\csname\string#1@size\endcsname{0}% +} + +% resizes (truncates) array #1 to size #2 +% +% the elements won't be initialised. Use 'set' for each element. +\def\pgfplotsarrayresize#1#2{% + \pgfplotsarray@@edef{#1@size}{#2}% +} +\def\pgfplotsarrayresizeglobal#1#2{% + \expandafter\xdef\csname\string#1@size\endcsname{#2}% +} % Invokes code '#2' if the array named '#1' exists and '#3' if it does % not exist. @@ -51,15 +73,30 @@ % Creates a new array with an abirtrary number of elements. % Arguments: % #1: the array's name (a macro name) -% #2: the elements in the form +% #2: the elements in one of the following forms +% a) a '\\' terminated list: % first\\second\\third\\ ...\\ -% like in tabular with one column. +% like in tabular with one column. The final '\\' necessary! +% b) a comma-separated list: +% first,second,third,5,10,last +% ATTENTION: arrays do not support the '...' syntax of tikz! % % Example: % \pgfplotsarraynew\fooarray{First Element\\Second Element\\Third Element\\} +% \pgfplotsarraynew\fooarray{First Element,Second Element,Third Element} +% \pgfplotsarraynew\fooarray{0,1,2,...,10} +% % -% WARNING: do NOT forget the final '\\'! \long\def\pgfplotsarraynew#1#2{% + \pgfplots@check@backwards@compatible@list@format #2\\\pgfplots@EOI + \ifpgfplots@is@old@list@format + \pgfplotsarraynew@backslash{#1}{#2}% + \else + \pgfplotsarraynew@commasep{#1}{#2}% + \fi +} + +\def\pgfplotsarraynew@backslash#1#2{% \pgfplotsarraynewempty{#1}% \long\def\pgfplotsarraynew@impl@rest{#2}% \pgfutil@loop @@ -71,8 +108,16 @@ \ifpgfplots@loop@CONTINUE \expandafter\pgfplotsarraynew@impl\pgfplotsarraynew@impl@rest\toarray#1\relax \pgfutil@repeat -} +}% +% converts a comma-separated list (PGF foreach) to my internal list +% structure. +\long\def\pgfplotsarraynew@commasep#1#2{% + \pgfplotsarraynewempty{#1}% + \pgfplotsutilforeachcommasep{#2}\as\pgfplotsarraynew@elem{% + \expandafter\pgfplotsarraypushback\expandafter{\pgfplotsarraynew@elem}\to#1% + }% +} % helper macro for \pgfplotsarraynew \long\def\pgfplotsarraynew@impl#1\\#2\toarray#3{% \pgfplotsarraypushback#1\to#3\relax% @@ -135,6 +180,9 @@ \expandafter\let\expandafter#2\csname\string#1@size\endcsname } +% expands to the size of array #1. +\def\pgfplotsarraysizeof#1{\csname\string#1@size\endcsname}% + % Returns the #1th element of array #2 into macro #3 % Arguments: @@ -148,14 +196,33 @@ % \elem % Element \count1: % \pgfplotsarrayselect\count1\of\foo\to\elem -\long\def\pgfplotsarrayselect#1\of#2\to#3{% +\def\pgfplotsarrayselect#1\of#2\to#3{% \c@pgfplotsarray@tmp=#1\relax - \expandafter\let\expandafter#3\expandafter=\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname% + \expandafter\let\expandafter#3\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname% +} + +% Expands to the value at index #1 of array #2. +% #1: a number (not a register) +% #2: an array +\def\pgfplotsarrayvalueofelem#1\of#2{\csname\string#2@#1\endcsname}% + +% Sets element '#1' of array '#2' to '#3'. +\def\pgfplotsarrayset#1\of#2\to#3{% + \c@pgfplotsarray@tmp=#1\relax + \pgfutil@namedef{\string#2@\the\c@pgfplotsarray@tmp}{#3}% +} +\def\pgfplotsarraysetglobal#1\of#2\to#3{% + \c@pgfplotsarray@tmp=#1\relax + \expandafter\gdef\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname{#3}% } \long\def\pgfplotsarrayletentry#1\of#2=#3{% \c@pgfplotsarray@tmp=#1\relax \expandafter\let\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname=#3\relax } +\long\def\pgfplotsarrayletentryglobal#1\of#2=#3{% + \c@pgfplotsarray@tmp=#1\relax + \expandafter\global\expandafter\let\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname=#3\relax +} % Sets the boolean \ifpgfplotsarrayempty depending on whether array #1 is empty % or not. @@ -185,27 +252,288 @@ % Element Zwei % Element Drei % Each single element will be grouped with TeX groups. +% +% During the loop, \pgfplotsarrayforeachindex expands to the current index. \long\def\pgfplotsarrayforeach#1\as#2#3{% \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% \c@pgfplotsarray@tmp=0\relax + \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% + \long\def\pgfplotsarray@TMPb{#3}% \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 + \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP\relax + \begingroup + \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% + \pgfplotsarray@TMPb + \endgroup + \advance\c@pgfplotsarray@tmp by1 \pgfutil@repeat + \let\pgfplotsarrayforeachindex=\relax% } % The same but without groups around #3. \long\def\pgfplotsarrayforeachungrouped#1\as#2#3{% \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% \c@pgfplotsarray@tmp=0\relax + \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% + \long\def\pgfplotsarray@TMPb{#3}% \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 + \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP\relax + \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% + \pgfplotsarray@TMPb + \advance\c@pgfplotsarray@tmp by1 \pgfutil@repeat + \let\pgfplotsarrayforeachindex=\relax% +} + +\long\def\pgfplotsarrayforeachreversed#1\as#2#3{% + \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% + \c@pgfplotsarray@tmp=\pgfplotsarray@TMP\relax + \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% + \long\def\pgfplotsarray@TMPb{#3}% + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp>0 % + \advance\c@pgfplotsarray@tmp by-1 + \begingroup + \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% + \pgfplotsarray@TMPb + \endgroup + \pgfutil@repeat + \let\pgfplotsarrayforeachindex=\relax% +} + +\long\def\pgfplotsarrayforeachreversedungrouped#1\as#2#3{% + \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% + \c@pgfplotsarray@tmp=\pgfplotsarray@TMP\relax + \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% + \long\def\pgfplotsarray@TMPb{#3}% + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp>0 % + \advance\c@pgfplotsarray@tmp by-1 + \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% + \pgfplotsarray@TMPb + \pgfutil@repeat + \let\pgfplotsarrayforeachindex=\relax% +} + +% #1: arg1 (possibly not fully expanded) +% #2: arg2 (possibly not fully expanded) +% #3: code to invoke in case arg1<arg2 +% #4: code to invoke in case arg1>=arg2 +\pgfkeys{% + /pgfplots/array/iflessthan/.code args={#1#2#3#4}{\ifnum#1<#2\relax#3\else#4\fi},% + /pgfplots/array/unscope pre/.code={% + % That's more or less efficient (although some runtime factors + % could be saved). + \c@pgfplotsarraysort@i=0 + \c@pgfplotsarray@tmp=\pgfplotsarraysizeof{#1}\relax + \pgfutil@loop + \ifnum\c@pgfplotsarraysort@i<\c@pgfplotsarray@tmp + \pgfplotsarrayselect{\c@pgfplotsarraysort@i}\of{#1}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarraysort@i by1 + \pgfutil@repeat + },% + /pgfplots/array/unscope post/.code={% + % copy from global temp -> #1 + \c@pgfplotsarray@tmp=0 + \pgfplotsarraysizetomacro{#1}\to\pgfplots@loc@TMPb + \pgfutil@loop + \ifnum\c@pgfplotsarray@tmp<\pgfplots@loc@TMPb + \pgfplotsarrayselect{\c@pgfplotsarray@tmp}\of{pgfparraytmp}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentry\c@pgfplotsarray@tmp\of{#1}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarray@tmp by1 + \pgfutil@repeat + },% +}% + +% Sorts array '#1' using N log N time. +% +% The sort key is provided as argument in +% /pgfplots/array/iflessthan/.code args={#1#2#3#4}, see above. +% +% Remarks: +% - the sorting algorithm is a sub-optimal mergesort currently - +% but it has runtime N log N. +% - As usual, it is very difficult to move the final result out of the +% current scope. The initial configuration allocates a *global* copy of #1 +% to carry results out of one TeX group. This means that memory will NEVER be freed. +% I don't see a general N log N alternative for doing so (short of discarding +% the scopes for local groups). +% BUT: +% you can redefine the code key pair +% |/pgfplots/array/unscope pre| +% and +% |/pgfplots/array/unscope post| +% to define your own routine which may benefit from special needs of +% your application. The |... pre| command is invoked JUST before the +% \endgroup and the |... post| JUST after the |\endgroup|. +% +% +% EXAMPLE: +%-------------------------------------------------- +% \pgfplotsarraynewempty\testarray +% \pgfplotsarraypushback503\to\testarray +% \pgfplotsarraypushback087\to\testarray +% \pgfplotsarraypushback512\to\testarray +% \pgfplotsarraypushback061\to\testarray +% \pgfplotsarraypushback908\to\testarray +% \pgfplotsarraypushback170\to\testarray +% \pgfplotsarraypushback897\to\testarray +% \pgfplotsarraypushback275\to\testarray +% \pgfplotsarraypushback653\to\testarray +% \pgfplotsarraypushback426\to\testarray +% \pgfplotsarraypushback154\to\testarray +% \pgfplotsarraypushback509\to\testarray +% \pgfplotsarraypushback612\to\testarray +% \pgfplotsarraypushback677\to\testarray +% \pgfplotsarraypushback765\to\testarray +% \pgfplotsarraypushback703\to\testarray +% +% Unsorted: +% +% [\pgfplotsarrayforeach\testarray\as\elem{\elem\space}] +% +% \pgfplotsarraysort\testarray +% +% sorted: +% +% [\pgfplotsarrayforeach\testarray\as\elem{\elem\space}] +% +%-------------------------------------------------- +\def\pgfplotsarraysort#1{% + % I admit, the implementation is more-or less copy-paste of an + % experiment I had done at university. It does its job, but it is + % certainly not optimal. + \begingroup + \pgfkeysgetvalue{/pgfplots/array/iflessthan/.@cmd}\pgfplotsarraysort@iflt + \pgfplotsarraysize{#1}\to\c@pgfplotsarray@tmp + \pgfplotsarrayresizeglobal{pgfparraytmp}{\the\c@pgfplotsarray@tmp}% + \countdef\c@pgfplotsarraysort@m=0 + \countdef\c@pgfplotsarraysort@k=1 + \countdef\c@pgfplotsarraysort@i=2 + \countdef\c@pgfplotsarraysort@l=3 + \countdef\c@pgfplotsarraysort@j=4 + \countdef\c@pgfplotsarraysort@q=5 + \def\pgfplotsarray@mergesort@{\pgfplotsarray@mergesort{#1}}% + \def\pgfplotsarray@mergesort@recurse@{\pgfplotsarray@mergesort@recurse{#1}}% + \edef\pgfplotsarray@mergesort@@{{0}{\the\c@pgfplotsarray@tmp}}% + \expandafter\pgfplotsarray@mergesort@\pgfplotsarray@mergesort@@ + % + % copy the complete, sorted result outside of the current scope. + \pgfkeysvalueof{/pgfplots/array/unscope pre/.@cmd}#1\pgfeov + \endgroup + \pgfkeysvalueof{/pgfplots/array/unscope post/.@cmd}#1\pgfeov +}% + +% #1: array name, +% #2: start offset (as string number) +% #3: number of elems (as string number) +\def\pgfplotsarray@mergesort#1#2#3{% + \ifnum#3<2 + % ready! + \else + \c@pgfplotsarraysort@m=#3\relax + \divide\c@pgfplotsarraysort@m by2 + \c@pgfplotsarraysort@q=#3\relax + \advance\c@pgfplotsarraysort@q by-\c@pgfplotsarraysort@m + \c@pgfplotsarraysort@i=\c@pgfplotsarraysort@m + \advance\c@pgfplotsarraysort@i by#2\relax + \edef\pgfplotsarray@mergesort@@{% + {#2}{\the\c@pgfplotsarraysort@m}% start1, N_1 + {\the\c@pgfplotsarraysort@i}{\the\c@pgfplotsarraysort@q}% start2, N_2 + }% + \expandafter\pgfplotsarray@mergesort@recurse@\pgfplotsarray@mergesort@@ + % + % Merge: + % restore 'm': + \c@pgfplotsarraysort@m=#3\relax + \divide\c@pgfplotsarraysort@m by2 + \c@pgfplotsarraysort@q=#3 + \advance\c@pgfplotsarraysort@q by-\c@pgfplotsarraysort@m + \c@pgfplotsarraysort@k=0 + \c@pgfplotsarraysort@l=0 + \c@pgfplotsarraysort@i=0 + % + % direct comparisons for merge: + \pgfutil@loop + \pgfplots@loop@CONTINUEtrue + \ifnum\c@pgfplotsarraysort@k<\c@pgfplotsarraysort@m + \ifnum\c@pgfplotsarraysort@l<\c@pgfplotsarraysort@q + \else + \pgfplots@loop@CONTINUEfalse + \fi + \else + \pgfplots@loop@CONTINUEfalse + \fi + \ifpgfplots@loop@CONTINUE + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@m + \advance\c@pgfplotsarraysort@j by\c@pgfplotsarraysort@l + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplotsarray@x@mpl + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@k + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplotsarray@x@k + \pgfplotsarraysort@iflt + {\pgfplotsarray@x@mpl}% + {\pgfplotsarray@x@k}% + {% x[m+l] < x[k] + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@mpl + \advance\c@pgfplotsarraysort@i by1 + \advance\c@pgfplotsarraysort@l by1 + }% + {% x[k] <= x[m+l] + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@k + \advance\c@pgfplotsarraysort@i by1 + \advance\c@pgfplotsarraysort@k by1 + }% + \pgfeov + \pgfutil@repeat + % + % append: + \pgfutil@loop + \ifnum\c@pgfplotsarraysort@k<\c@pgfplotsarraysort@m + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@k + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarraysort@i by1 + \advance\c@pgfplotsarraysort@k by1 + \pgfutil@repeat + \pgfutil@loop + \ifnum\c@pgfplotsarraysort@l<\c@pgfplotsarraysort@q + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@m + \advance\c@pgfplotsarraysort@j by\c@pgfplotsarraysort@l + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarraysort@i by1 + \advance\c@pgfplotsarraysort@l by1 + \pgfutil@repeat + % + % copy back from temporary to '#1' + \c@pgfplotsarraysort@i=0 + \c@pgfplotsarraysort@k=#3 + \pgfutil@loop + \ifnum\c@pgfplotsarraysort@i<\c@pgfplotsarraysort@k + \c@pgfplotsarraysort@j=\c@pgfplotsarraysort@i + \advance\c@pgfplotsarraysort@j by#2 + \pgfplotsarrayselect{\c@pgfplotsarraysort@i}\of{pgfparraytmp}\to\pgfplots@loc@TMPa + \pgfplotsarrayletentry\c@pgfplotsarraysort@j\of{#1}=\pgfplots@loc@TMPa + \advance\c@pgfplotsarraysort@i by1 + \pgfutil@repeat +%\pgfplotsarraysort@DEBUGTEST{#1}{after mergesort(start=#2,n=#3):}% + \fi +}% +\long\def\pgfplotsarraysort@DEBUGTEST#1#2{% + \par#2\par + [\pgfplotsarrayforeach{#1}\as\elem{\elem\space}]\par% +} +% #1: array name +% #2: start1 +% #3: N1 +% #4: start2 +% #5: N2 +\def\pgfplotsarray@mergesort@recurse#1#2#3#4#5{% + \pgfplotsarray@mergesort{#1}{#2}{#3}% + \pgfplotsarray@mergesort{#1}{#4}{#5}% } diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsdeque.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsdeque.code.tex new file mode 100644 index 00000000000..7a524f1ee64 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsdeque.code.tex @@ -0,0 +1,125 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This is a helper package with an elementary double-ended-queue +% (deque) datastructure, +% featuring O(1) index access and O(N) creation, deletion, copy. +% +% The following macros are supplied: +% +% \pgfplotsdequenewempty +% \pgfplotsdequecopy +% \pgfplotsdequepushback +% \pgfplotsdequepopfront +% \pgfplotsdequecheckempty +% \pgfplotsdequeforeach +% +% 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 <http://www.gnu.org/licenses/>. +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% IMPLEMENTATION NOTES: +% I allocate an array which provides storage capacity and two pointers +% (indices) into that array. +% +% The deque is stored as +% - an array: \csname pgfpldq@<name>\endcsname +% - the pointers: +% \csname pgfpldq@<name>@beg\endcsname +% \csname pgfpldq@<name>@end\endcsname (one after the end) +% +% ATTENTION: <name> may NOT be a control sequence! +% this is in contrast to my other container structures. + + +% Allocates a new, empty deque #1. +% +% #1 the name of a deque (NO control sequence!) +% #2 is an integer denoting the maximum capacity. For now, this +% capacity is fixed afterwards and denotes the maximum number of +% entries. +\def\pgfplotsdequenewempty#1{% + \pgfutil@ifnextchar\capacity{% + \pgfplotsdequenewempty@{#1}% + }{% + \pgfplots@error{Expected \string\capacity\{the capacity\} after \string\pgfplotsdequenewempty...}% + \pgfplotsdequenewempty@{#1}\capacity{100}% + }% +}% +\def\pgfplotsdequenewempty@#1\capacity#2{% + \pgfplotsarrayresize{pgfpldq@#1}{#2}% + \pgfutil@namedef{pgfpldq@#1@beg}{0}% + \pgfutil@namedef{pgfpldq@#1@end}{0}% +}% + +\def\pgfplotsdequecopy#1\to#2{% + \pgfutil@namelet{pgfpldq@#1@beg}{pgfpldq@#2@beg}% + \pgfutil@namelet{pgfpldq@#1@end}{pgfpldq@#2@end}% + \pgfplotsarraycopy{pgfpldq@#1}\to{pgfpldq@#2}% +}% + +\def\pgfplotsdequepushback#1\to#2{% + \pgfplotsarrayset{\csname pgfpldq@#2@end\endcsname}\of{pgfpldq@#2}\to{#1}% + \c@pgfplotsarray@tmp=\csname pgfpldq@#2@end\endcsname + \advance\c@pgfplotsarray@tmp by1 + \ifnum\c@pgfplotsarray@tmp=\pgfplotsarraysizeof{pgfpldq@#2} + \c@pgfplotsarray@tmp=0 + \fi + \expandafter\edef\csname pgfpldq@#2@end\endcsname{\the\c@pgfplotsarray@tmp}% + \pgfplotsdequeifempty{#2}{\pgfplots@error{Error: \string\pgfplotsdeque\space capacity has been reached - it was too small. Sorry, I didn't write auto-enlargement...}}{}% +}% + +\def\pgfplotsdequepopfront#1\to#2{% + \pgfplotsarrayselect{\csname pgfpldq@#1@beg\endcsname}\of{pgfpldq@#1}\to{#2}% + \c@pgfplotsarray@tmp=\csname pgfpldq@#1@beg\endcsname + \advance\c@pgfplotsarray@tmp by1 + \ifnum\c@pgfplotsarray@tmp=\pgfplotsarraysizeof{pgfpldq@#1} + \c@pgfplotsarray@tmp=0 + \fi + \expandafter\edef\csname pgfpldq@#1@beg\endcsname{\the\c@pgfplotsarray@tmp}% +}% + +% invokes #2 if deque '#1' is empty and '#3' if it is not empty. +\def\pgfplotsdequeifempty#1#2#3{% + \ifnum\csname pgfpldq@#1@beg\endcsname=\csname pgfpldq@#1@end\endcsname\relax + #2% + \else + #3% + \fi +}% + + +\long\def\pgfplotsdequeforeach#1\as#2#3{% + \c@pgfplotsarray@tmp=\csname pgfpldq@#1@beg\endcsname + \long\def\pgfplotsdequeforeach@next{\pgfplotsdequeforeach@iter{#1}{#2}{#3}}% + \pgfplotsdequeforeach@next +}% +\long\def\pgfplotsdequeforeach@iter#1#2#3{% + \ifnum\c@pgfplotsarray@tmp=\csname pgfpldq@#1@end\endcsname + \def\pgfplotsdequeforeach@next{}% + \else + \pgfplotsarrayselect\c@pgfplotsarray@tmp\of pgfpldq@#1\to#2% + \edef\pgfplotsdequeforeach@{\the\c@pgfplotsarray@tmp}% + #3\relax + \c@pgfplotsarray@tmp=\pgfplotsdequeforeach@ + \advance\c@pgfplotsarray@tmp by1 + \ifnum\c@pgfplotsarray@tmp=\pgfplotsarraysizeof{pgfpldq@#1} + \c@pgfplotsarray@tmp=0 + \fi + \fi + \pgfplotsdequeforeach@next +}% 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 aa21ad13dc4..87ce40e586b 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex @@ -19,6 +19,7 @@ % \pgfplotslistpushfront % \pgfplotslistsize % \pgfplotslistselect +% \pgfplotslistset % \pgfplotslistcheckempty % \pgfplotslistforeach % @@ -47,6 +48,9 @@ \newif\ifpgfplotslistempty +% Low-level IMPLEMENTATION NOTE +% the list is stored in the form +% '\pgfpl@@{<first>}\pgfpl@@{<second>}\pgfpl@@{<third>}....\pgfpl@@{<last>}' \newif\ifpgfplots@loop@CONTINUE \newif\ifpgfplotslist@is@backslash@terminated @@ -74,6 +78,14 @@ % Use braces '{}' to use '\\' or ',' as arguments. % \long\def\pgfplotslistnew#1#2{% + \pgfplots@check@backwards@compatible@list@format #2\\\pgfplots@EOI + \ifpgfplots@is@old@list@format + \pgfplotslistnew@backslash{#1}{#2}% + \else + \pgfplots@foreach@to@list{#2}\to#1% + \fi +} +\long\def\pgfplotslistnew@backslash#1#2{% \pgfplotslistnewempty{#1}% \long\def\pgfplotslistnew@impl@rest{#2}% \pgfplotslist@check@backslash@list #2\\\pgfplotslist@EOI @@ -94,10 +106,10 @@ \expandafter\pgfplotslistnew@impl@comma\pgfplotslistnew@impl@rest\tolist#1\relax \fi \pgfutil@repeat -} +}% \def\pgfplotslist@EOI{\pgfplotslist@EOI} -\def\pgfplotslist@check@backslash@list#1\\#2\pgfplotslist@EOI{% +\long\def\pgfplotslist@check@backslash@list#1\\#2\pgfplotslist@EOI{% \def\pgfplotslist@loc@TMPa{#2}% \ifx\pgfplotslist@loc@TMPa\pgfutil@empty \pgfplotslist@is@backslash@terminatedfalse @@ -130,10 +142,15 @@ \t@pgfplots@tokb=\expandafter{#2}% \edef#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% } +\long\def\pgfplotslistpushfrontglobal#1\to#2{% + \t@pgfplots@toka={\pgfpl@@{#1}}% + \t@pgfplots@tokb=\expandafter{#2}% + \xdef#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{% +\long\def\pgfplotslist@assembleentry#1\into#2{% #2={\pgfpl@@{#1}}% } @@ -176,8 +193,7 @@ \long\def\pgfplotslistpopfront#1\to#2{% \pgfplotslistcheckempty#1\relax \ifpgfplotslistempty - \pgfplots@error{ERROR: \string\pgfplotslistpopfront\ from \string#1\ although list is EMPTY}% - \let#2=\pgfutil@empty + \pgfplotsthrow{no such element}{#1}{\string\pgfplotslistpopfront\ from \string#1\ although list is EMPTY}\pgfeov% \else \expandafter\pgfplotslistpopfront@impl#1\pgfplotslistpopfront@macronames#1#2% \fi @@ -185,8 +201,7 @@ \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 + \pgfplotsthrow{no such element}{#2}{\string\pgfplotslistfront\ from \string#1\ although list is EMPTY}\pgfeov% \else \expandafter\pgfplotslistfront@impl#1\pgfplotslistpopfront@macronames#2% \fi @@ -224,11 +239,11 @@ % \elem % Element \count1: % \pgfplotslistselect\count1\of\foo\to\elem -\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.}}% +\long\def\pgfplotslistselect#1\of#2\to#3{% + \global\def\pgfplotslistselect@tmp{\pgfplotsthrow{no such element}{#3}{The requested list entry with index #1 of \string#2 is too large; this list has not enough elements.}\pgfeov}% \pgfplotslistselect@{#1}\of{#2}\to{#3}% } -\def\pgfplotslistselect@#1\of#2\to#3{% +\long\def\pgfplotslistselect@#1\of#2\to#3{% \begingroup \count0=#1\relax \long\def\pgfpl@@##1{% @@ -241,11 +256,73 @@ \endgroup \pgfplotslistselect@tmp } -\def\pgfplotslistselectorempty#1\of#2\to#3{% + +% Selects a list entry. If it does not exist, '#' will be empty. +\long\def\pgfplotslistselectorempty#1\of#2\to#3{% \global\def\pgfplotslistselect@tmp{\def#3{}}% \pgfplotslistselect@{#1}\of{#2}\to{#3}% } +% Changes the element at index '#1' of list '#2' to the content '#3'. +% +% This operation has quadratic (!) time in the worst case. +\long\def\pgfplotslistset#1\of#2\to#3{% + \ifcase#1\relax + % change first: + \def\pgfplotslistset@\pgfpl@@##1##2\relax{\def#2{\pgfpl@@{#3}##2}}% + \expandafter\pgfplotslistset@#2\relax + \or + % change second: + \def\pgfplotslistset@\pgfpl@@##1\pgfpl@@##2##3\relax{\def#2{\pgfpl@@{##1}\pgfpl@@{#3}##2}}% + \expandafter\pgfplotslistset@#2\relax + \or + \def\pgfplotslistset@\pgfpl@@##1\pgfpl@@##2\pgfpl@@##3##4\relax{\def#2{\pgfpl@@{##1}\pgfpl@@{##2}\pgfpl@@{#3}##3}}% + \expandafter\pgfplotslistset@#2\relax + \or + \def\pgfplotslistset@\pgfpl@@##1\pgfpl@@##2\pgfpl@@##3\pgfpl@@##4##5\relax{\def#2{\pgfpl@@{##1}\pgfpl@@{##2}\pgfpl@@{##3}\pgfpl@@{#3}##4}}% + \expandafter\pgfplotslistset@#2\relax + \else + \begingroup + \global\pgfplotslistnewempty\pgfplotslistnewempty\pgfplotslist@glob@TMPa + \let\pgfpl@@=\pgfutil@empty % make sure it is not \relax. + \count0=#1\relax + \count1=0 + \def\pgfplotslistset@newelem{#3}% + \expandafter\pgfplotslistset@loop#2\relax + \ifnum\count1 =\count0 + \else + \pgfplotsthrow{no such element}{\pgfplots@loc@TMPa}{\string\pgfplotslistset{\the\count0} failed because there are only \the\count1\space elements in the list. Use pushback to resize it.}\pgfeov% + \global\let\pgfplotslist@glob@TMPa=\pgfplots@loc@TMPa + \fi + \endgroup + \let#3=\pgfplotslist@glob@TMPa + \global\let\pgfplotslist@glob@TMPa=\relax + \fi +}% + +\def\pgfplotslistset@loop{% + \pgfutil@ifnextchar\relax{% + \pgfplotslistset@loop@break + }{% + \pgfplotslistset@loop@next + }% +} +\def\pgfplotslistset@loop@break#1\relax{% + % re-append remaining elements: + \expandafter\gdef\expandafter\pgfplotslist@glob@TMPa\expandafter{\pgfplotslist@glob@TMPa#1} +}% +\def\pgfplotslistset@loop@next\pgfpl@@#1{% + \ifnum\count1 =\count0 + % Ah - we found the element to replace! + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotslistset@newelem}\to\pgfplotslist@glob@TMPa + \expandafter\pgfplotslistset@loop@break + \else + \pgfplotslistpushbackglobal{#1}\to\pgfplotslist@glob@TMPa + \advance\count1 by1 + \expandafter\pgfplotslistset@loop + \fi +}% + % Sets the boolean \ifpgfplotslistempty depending on whether list #1 is empty % or not. % Example: @@ -287,8 +364,6 @@ \endgroup } -\newif\ifpgfplotslistforeachungroupedrunning - % The same but without groups around #3. % % The list can be nested. @@ -329,16 +404,3 @@ }% \def\pgfplotslistforeachungrouped@EOI{\pgfplotslistforeachungrouped@EOI}% equals only itself in \ifx -%-------------------------------------------------- -% \long\def\pgfplotslistforeachungrouped#1\as#2#3{% -% \ifpgfplotslistforeachungroupedrunning -% \pgfplots@error{Sorry, you can't nest pgfplotslistforeachungrouped.}% -% \else -% \pgfplotslistforeachungroupedrunningtrue -% \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 index a10e67c82f3..bea65490068 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex @@ -85,7 +85,7 @@ % 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{% +\long\def\pgfplotsapplistpushback#1\to#2{% \expandafter\let\expandafter\pgfplots@loc@TMPa\csname\string#2@endno\endcsname \begingroup \c@pgf@counta=\pgfplots@loc@TMPa\relax @@ -168,7 +168,7 @@ % #1: the item to append % #2: the list as macro name -\def\pgfplotsapplistXpushback#1\to#2{% +\long\def\pgfplotsapplistXpushback#1\to#2{% \begingroup \c@pgf@counta=\csname\string#2@smallbuf@c\endcsname\relax \advance\c@pgf@counta by1 @@ -182,7 +182,7 @@ \pgfplotsapplistXpushback@smallbufoverfl{#1}{#2}% \fi }% -\def\pgfplotsapplistXpushback@smallbufoverfl#1#2{% +\long\def\pgfplotsapplistXpushback@smallbufoverfl#1#2{% \begingroup \c@pgf@counta=\csname\string#2@bigbuf@c\endcsname\relax \advance\c@pgf@counta by1 @@ -237,8 +237,77 @@ #1}% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% A variant of applist which has the same runtime requirements, but +% does PUSH FRONT only. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Usage: +% \pgfplotsprependlistXnewempty{liste} +\def\pgfplotsprependlistXnewempty#1{% + \expandafter\let\csname pgfpPRP@#1\endcsname=\pgfutil@empty + \expandafter\let\csname pgfpPRP@#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\let\csname pgfpPRP@#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@smallbuf@c\endcsname{0}% + \expandafter\def\csname pgfpPRP@#1@bigbuf@c\endcsname{0}% +}% +% #1: the item to append +% #2: the list as macro name +\long\def\pgfplotsprependlistXpushfront#1\to#2{% + \begingroup + \c@pgf@counta=\csname pgfpPRP@#2@smallbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname pgfpPRP@#2@smallbuf@c\endcsname=\pgfplots@glob@TMPa + \ifnum\csname pgfpPRP@#2@smallbuf@c\endcsname<40 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}% + \t@pgfplots@tokb={#1}% + \expandafter\edef\csname pgfpPRP@#2@smallbuf\endcsname{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \else + \pgfplotsprependlistXpushfront@smallbufoverfl{#1}{#2}% + \fi +}% +\long\def\pgfplotsprependlistXpushfront@smallbufoverfl#1#2{% + \begingroup + \c@pgf@counta=\csname pgfpPRP@#2@bigbuf@c\endcsname\relax + \advance\c@pgf@counta by1 + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \expandafter\let\csname pgfpPRP@#2@bigbuf@c\endcsname=\pgfplots@glob@TMPa + % + \ifnum\csname pgfpPRP@#2@bigbuf@c\endcsname<30 + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@bigbuf\endcsname}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}% + \t@pgfplots@tokc={#1}% + \expandafter\edef\csname pgfpPRP@#2@bigbuf\endcsname{\the\t@pgfplots@tokc\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \expandafter\let\csname pgfpPRP@#2@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#2@smallbuf@c\endcsname{0}% + \else% + \pgfplotsprependlistXflushbuffers{#2}% + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2\endcsname}% + \t@pgfplots@tokb={#1}% + \expandafter\edef\csname pgfpPRP@#2\endcsname{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \fi% +}% +\def\pgfplotsprependlistXflushbuffers#1{% + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1\endcsname}% + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@bigbuf\endcsname}% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@smallbuf\endcsname}% + \expandafter\edef\csname pgfpPRP@#1\endcsname{\the\t@pgfplots@tokc\the\t@pgfplots@tokb\the\t@pgfplots@toka}% + \expandafter\let\csname pgfpPRP@#1@smallbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@smallbuf@c\endcsname{0}% + \expandafter\let\csname pgfpPRP@#1@bigbuf\endcsname=\pgfutil@empty + \expandafter\def\csname pgfpPRP@#1@bigbuf@c\endcsname{0}% +}% +\def\pgfplotsprependlistXlet#1=#2{% + \pgfplotsprependlistXflushbuffers{#2}% + \expandafter\let\expandafter#1\csname pgfpPRP@#2\endcsname} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 @@ -284,7 +353,7 @@ % #1: the item to append % #2: the list as macro name -\def\pgfplotsapplistXXpushback#1{% +\long\def\pgfplotsapplistXXpushback#1{% \begingroup \c@pgf@counta=\pgfplotsapplistXX@smallbuf@c\relax \advance\c@pgf@counta by1 @@ -298,7 +367,7 @@ \pgfplotsapplistXXpushback@smallbufoverfl{#1}% \fi }% -\def\pgfplotsapplistXXpushback@smallbufoverfl#1{% +\long\def\pgfplotsapplistXXpushback@smallbufoverfl#1{% \begingroup \c@pgf@counta=\pgfplotsapplistXX@bigbuf@c\relax \advance\c@pgf@counta by1 @@ -385,7 +454,7 @@ % #1: the item to append % #2: the list as macro name -\def\pgfplotsapplistXXglobalpushback#1{% +\long\def\pgfplotsapplistXXglobalpushback#1{% \begingroup \c@pgf@counta=\pgfplotsapplistXXglobal@smallbuf@c\relax \advance\c@pgf@counta by1 @@ -399,7 +468,7 @@ \pgfplotsapplistXXglobalpushback@smallbufoverfl{#1}% \fi }% -\def\pgfplotsapplistXXglobalpushback@smallbufoverfl#1{% +\long\def\pgfplotsapplistXXglobalpushback@smallbufoverfl#1{% \begingroup \c@pgf@counta=\pgfplotsapplistXXglobal@bigbuf@c\relax \advance\c@pgf@counta by1 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 1c074e70bf7..ef27a7a2728 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex @@ -44,13 +44,18 @@ % \pgfplotslistnewempty\table % 3. A "file name" stored in % \csname\string<\namemacro>@@table@name\endcsname -% 4. foreach column, there is a list of row-values (a row-vector) in +% 4. A "scan line length" number stored in +% \csname\string<\namemacro>@@table@scanline\endcsname +% It contains the value of \pgfplotsscanlinelength which has +% been identified right after \pgfplotstableread. +% 5. foreach column, there is a list of row-values (a row-vector) in % the \pgfplotslist format named % \csname\string<\namemacro>@<column name>\endcsname % \newif\ifpgfplotstable@search@header +\newif\ifpgfplotstable@firstline@is@header \newcount\c@pgfplotstable@counta \newwrite\pgfplotstable@outfile \newif\ifpgfplotstabletypesetdebug @@ -65,6 +70,7 @@ % should always be false; use only in grouped internal macros \newif\ifpgfplots@table@options@areset \newif\ifpgfplots@tableread@to@listener +\newif\ifpgfplots@tableread@use@begingroup \input pgfplotstable.coltype.code.tex @@ -90,22 +96,32 @@ % /pgfplots/table/display columns/<col index>/.style={} % /pgfplots/table/create on use/<col name>/.style={create options} \pgfkeys{% - /pgfplots/table/header/.is if=pgfplotstable@search@header, + /pgfplots/table/header/.is choice, + /pgfplots/table/header/true/.code={\pgfplotstable@firstline@is@headerfalse\pgfplotstable@search@headertrue}, + /pgfplots/table/header/false/.code={\pgfplotstable@firstline@is@headerfalse\pgfplotstable@search@headerfalse}, + /pgfplots/table/header/has colnames/.code={\pgfplotstable@firstline@is@headertrue\pgfplotstable@search@headerfalse}, /pgfplots/table/header=true, /pgfplots/table/x index/.initial=0, /pgfplots/table/x/.initial=, + /pgfplots/table/x expr/.initial=, /pgfplots/table/y index/.initial=1, /pgfplots/table/y/.initial=, + /pgfplots/table/y expr/.initial=, /pgfplots/table/z index/.initial=2, /pgfplots/table/z/.initial=, + /pgfplots/table/z expr/.initial=, /pgfplots/table/meta index/.initial=, /pgfplots/table/meta/.initial=, + /pgfplots/table/meta expr/.initial=, /pgfplots/table/x error index/.initial=, /pgfplots/table/y error index/.initial=, /pgfplots/table/z error index/.initial=, /pgfplots/table/x error/.initial=, /pgfplots/table/y error/.initial=, /pgfplots/table/z error/.initial=, + /pgfplots/table/x error expr/.initial=, + /pgfplots/table/y error expr/.initial=, + /pgfplots/table/z error expr/.initial=, /pgfplots/table/read completely/.is if=pgfplots@addplotimpl@readcompletely, /pgfplots/table/read completely/.default=true, /pgfplots/table/disable rowcol styles/.is if=pgfplotstable@disable@rowcolstyles, @@ -152,12 +168,59 @@ \endgroup }% }, + % #1: colname + /pgfplots/table/unique/.code={% + \pgfkeys{/pgfplots/table/row predicate/.append code={% + \ifnum\pgfplotstablerow=0 + \ifnum\pgfplotstablecol=0 + % PREPARE ONCE! Assemble the boolean results into + % a list which is used for the complete table: + \expandafter\pgfplotstablegetcolumnfromstruct\expandafter{\expandafter\pgfplotstablecolname\expandafter}\expandafter\of\pgfplotstablename\to\pgfplotstable@unique@col + \pgfplotslistnewempty\pgfplotstable@unique@bitlist + \let\pgfplotstable@unique@LAST=\relax + \pgfplotslistforeachungrouped\pgfplotstable@unique@col\as\pgfplotstable@unique@cur{% + \def\pgfplotstable@unique@bit{1}% + \ifx\pgfplotstable@unique@LAST\relax + \else + \ifx\pgfplotstable@unique@LAST\pgfplotstable@unique@cur + \def\pgfplotstable@unique@bit{0}% + \fi + \fi + \expandafter\pgfplotslistpushback\pgfplotstable@unique@bit\to\pgfplotstable@unique@bitlist + \let\pgfplotstable@unique@LAST=\pgfplotstable@unique@cur + }% + \global\let\pgfplotstable@unique@bitlist@backup=\pgfplotstable@unique@bitlist + \else + \ifx\pgfplotstable@unique@bitlist@backup\relax + % this sanity checking is NOT fool proof: it + % fails if there are different occurances of + % unique in the same file + \pgfplotstable@error{Sorry, the row predicate /pgfplots/table/unique={#1} has been used in the wrong context: it needs to be invoked for the very first processed column, not column no \pgfplotstablecol. Please provide it as argument to \string\pgfplotstabletypeset[unique={#1}] and not inside of column-specific styles.}% + \fi + \fi + % acquire the assembled list here: we'll do a lot of + % popfronts with it. + \let\pgfplotstable@unique@bitlist=\pgfplotstable@unique@bitlist@backup + \fi + \pgfplotslistcheckempty\pgfplotstable@unique@bitlist + \ifpgfplotslistempty + % should not happen! + \pgfplotstableuserowfalse + \else + \pgfplotslistpopfront\pgfplotstable@unique@bitlist\to\pgfplots@loc@TMPa + \if\pgfplots@loc@TMPa0% + \pgfplotstableuserowfalse + \fi + \fi + }}% + },% /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}}, /pgfplots/table/col sep/semicolon/.code = {\def\pgfplotstableread@COLSEP@CASE{2}}, /pgfplots/table/col sep/colon/.code = {\def\pgfplotstableread@COLSEP@CASE{3}}, /pgfplots/table/col sep/braces/.code = {\def\pgfplotstableread@COLSEP@CASE{4}}, + /pgfplots/table/col sep/tab/.code = {\def\pgfplotstableread@COLSEP@CASE{5}}, /pgfplots/table/col sep=space, % columns={name1,name2} % or @@ -192,62 +255,113 @@ /pgfplots/table/multicolumn names/.default=c, /pgfplots/table/dec sep align/.code={% \pgfplots@assert@LaTeX@package@loaded{array}{dec sep align}% + \def\pgfplotstable@scisepalign@headeralign{#1}% \pgfkeysalso{% - /pgf/number format/assume math mode, - /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<{\pgfplotstableresetcolortbloverhangright}% - @{}% - l<{\pgfplotstableresetcolortbloverhangleft}% - }, - /pgfplots/table/assign cell content/.code={% - \def\pgfmathresult{##1}% - \ifx\pgfmathresult\pgfutil@empty - \def\pgfmathresult{&}% - \else - \pgfmathprintnumberto{##1}\pgfmathresult% - % now make sure we have math mode for the single - % columns: - \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}% - \fi - \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult - }, + /pgf/number format/assume math mode, + /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<{\pgfplotstableresetcolortbloverhangright}% + @{}% + l<{\pgfplotstableresetcolortbloverhangleft}% + }, + /pgfplots/table/assign cell content/.code={% + \def\pgfmathresult{##1}% + \let\continue=\pgfutil@empty + % allow special handling: + \pgfplots@invoke@pgfkeyscode{/pgfplots/table/dec sep align/process/.@cmd}{##1}% + \ifx\continue\pgfutil@empty + % nothing has changed. Processed as usual: + \ifx\pgfmathresult\pgfutil@empty + \def\pgfmathresult{&}% + \else + % -6.90000001e-01 -> \meaning\pgfmathresult = macro:->-0$&$.69 + \pgfmathprintnumberto{\pgfmathresult}\pgfmathresult% + % now make sure we have math mode for the single + % columns: + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}% + \fi + \fi + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + }, }% }, /pgfplots/table/dec sep align/.default=c, - /pgfplots/table/sci sep align/.code={% - \pgfplots@assert@LaTeX@package@loaded{array}{sci sep align}% - \pgfkeysalso{% - /pgf/number format/assume math mode, - /pgf/number format/@sci exponent mark={$&$}, - /pgfplots/table/assign column name/.code={% - \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}% - },% - /pgfplots/table/column type={% - r<{\pgfplotstableresetcolortbloverhangright}% - @{}% - l<{\pgfplotstableresetcolortbloverhangleft}% - }, - /pgfplots/table/assign cell content/.code={% - \def\pgfmathresult{##1}% + % + % A part of dec sep align which can be used to process special + % cases. + % + % #1: the unprocessed input argument. + % PRECONDITION: + % \pgfmathresult contains '#1', not more. + % \continue is empty. + % + % POSTCONDITION: + % If \continue is empty, `dec sep align' will continue just as + % if the 'process' key hadn't been invoked. + % It will, however, use the current value of \pgfmathresult. + % + % If \continue is NOT empty, for example \def\continue{0}, + % `dec sep align' assumes that \pgfmathresult contains the + % completely typeset cell, including any alignment material. + /pgfplots/table/dec sep align/process/.code=,% + /pgfplots/table/dec sep align/no unbounded/.style={% + % FIXME : this thing doesn't work as intended! It looks ugly! + /pgfplots/table/dec sep align/process/.code={% \ifx\pgfmathresult\pgfutil@empty - \def\pgfmathresult{&}% \else - \pgfmathprintnumberto{##1}\pgfmathresult% - \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}% - % now make sure we have math mode for the single - % columns: - \ifpgfutil@in@ - \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}% + \pgfmathfloatparsenumber\pgfmathresult + \pgfmathfloatiffinite{\pgfmathresult}{% + % do nothing, just communicate the parsed + % \pgfmathresult + }{% + \begingroup + \t@pgfplots@toka=\expandafter{\pgfplotstable@scisepalign@headeralign}% + \t@pgfplots@tokb={\pgfkeyslet{/pgf/number format/@dec sep mark}\pgfutil@empty\pgfmathprintnumber}% + \t@pgfplots@tokc=\expandafter{\pgfmathresult}% + \xdef\pgfplotstable@glob@TMPc{% + \noexpand\multicolumn{2}{\the\t@pgfplots@toka}% + {\the\t@pgfplots@tokb{\the\t@pgfplots@tokc}}% + }% + \endgroup + \let\pgfmathresult=\pgfplotstable@glob@TMPc + \def\continue{0}% + }% + \fi + },% + },% + /pgfplots/table/sci sep align/.code={% + \pgfplots@assert@LaTeX@package@loaded{array}{sci sep align}% + \pgfkeysalso{% + /pgf/number format/assume math mode, + /pgf/number format/@sci exponent mark={$&$}, + /pgfplots/table/assign column name/.code={% + \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{2}{#1}{##1}}% + },% + /pgfplots/table/column type={% + r<{\pgfplotstableresetcolortbloverhangright}% + @{}% + l<{\pgfplotstableresetcolortbloverhangleft}% + }, + /pgfplots/table/assign cell content/.code={% + \def\pgfmathresult{##1}% + \ifx\pgfmathresult\pgfutil@empty + \def\pgfmathresult{&}% \else - \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter\pgfutilensuremath\expandafter{\pgfmathresult}&}% + \pgfmathprintnumberto{##1}\pgfmathresult% + \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}% + % now make sure we have math mode for the single + % columns: + \ifpgfutil@in@ + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter$\pgfmathresult$}% + \else + \expandafter\def\expandafter\pgfmathresult\expandafter{\expandafter\pgfutilensuremath\expandafter{\pgfmathresult}&}% + \fi \fi - \fi - \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult - }, + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult + }, }% }, /pgfplots/table/sci sep align/.default=c, @@ -374,6 +488,28 @@ \fi } }, + /pgfplots/table/preproc/expr/.code={% + \ifpgfplots@usefpu + \pgfkeysalso{/pgf/fpu=true,/pgf/fpu/output format=sci}% + \fi + \expandafter\def\csname pgfplotstable@preproc@expr@thisrow@\pgfplotstablecolname\endcsname{\pgfkeysvalueof{/pgfplots/table/@cell content}}% + \def\thisrow##1{% + \pgfutil@ifundefined{pgfplotstable@preproc@expr@thisrow@##1}{% + --inaccessable--% + }{% + \csname pgfplotstable@preproc@expr@thisrow@##1\endcsname + }% + }% + \pgfkeysalso{/pgfplots/table/preproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfmathparse{#1}% + \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult% + \fi + }% + }% + }, /pgfplots/table/multiply -1/.style={% /pgfplots/table/preproc cell content/.append code={% \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult @@ -437,12 +573,33 @@ \fi }% }, + /pgfplots/table/fonts by sign/.style 2 args={% + /pgfplots/table/postproc cell content/.append code={% + \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfplotsretval + \ifx\pgfplotsretval\pgfutil@empty + \else + \t@pgfplots@toka=\expandafter{\pgfplotsretval}% + \t@pgfplots@tokb={#1}% + \t@pgfplots@tokc={#2}% + \pgfmathfloatparsenumber{\pgfkeysvalueof{/pgfplots/table/@preprocessed cell content}}% + \pgfmathfloatifflags{\pgfmathresult}{-}{% + \edef\pgfmathresult{{\the\t@pgfplots@tokc{\the\t@pgfplots@toka}}}% + }{% + \edef\pgfmathresult{{\the\t@pgfplots@tokb{\the\t@pgfplots@toka}}}% + }% + \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}% + \fi + }% + },% % /pgfplots/table/font/.initial=, - /pgfplots/table/.unknown/.code={% - \let\pgfplots@table@curkeyname=\pgfkeyscurrentname - \pgfqkeys{/pgf/number format}{\pgfplots@table@curkeyname=#1}% - },% + /pgfplots/table/.search also={/pgf/number format,/pgfplots/table/create col}, + %-------------------------------------------------- + % /pgfplots/table/.unknown/.code={% + % \let\pgfplots@table@curkeyname=\pgfkeyscurrentname + % \pgfqkeys{/pgf/number format}{\pgfplots@table@curkeyname=#1}% + % },% + %-------------------------------------------------- /pgfplots/table/create col/assign first/.style={ /pgfplots/table/create col/assign% }, @@ -487,15 +644,7 @@ /pgfplots/table/create col/expr accum={#1}{0}% },% /pgfplots/table/create col/copy column from table/.code 2 args={% - \pgfplotstable@isloadedtable{#1}{% - \pgfplotstablegetcolumnbyname{#2}\of#1\to\pgfmathaccumb - }{% - \begingroup - \pgfplotstableread{#1}\pgfplotstable@tmptbl - \pgfplotstablegetcolumnbyname{#2}\of\pgfplotstable@tmptbl\to\pgfmathaccumb - \pgfmath@smuggleone\pgfmathaccumb - \endgroup - }% + \pgfplotstablegetcolumn{#2}\of{#1}\to\pgfmathaccumb \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}% }, /pgfplots/table/create col/@from list struct/.code={% @@ -682,12 +831,8 @@ /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 + \pgfmathfloatparsenumber{\thisrow{#1}} + \pgfmathfloatln@{\pgfmathresult}% \let\pgfmathaccuma=\pgfmathresult \pgfmathfloatparsenumber{\thisrow{#2}}% \let\pgfmathaccumb=\pgfmathresult @@ -697,12 +842,8 @@ /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 + \pgfmathfloatparsenumber{\thisrow{#1}} + \pgfmathfloatln@{\pgfmathresult}% \let\pgfmathnext@x=\pgfmathresult \let\pgfmathaccuma=\pgfmathresult % @@ -727,12 +868,8 @@ /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 + \pgfmathfloatparsenumber{\thisrow{#2}} + \pgfmathfloatln@{\pgfmathresult}% \let\pgfmathaccumb=\pgfmathresult \def\pgfmathresult{}% leave first empty. \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% @@ -740,12 +877,8 @@ /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 + \pgfmathfloatparsenumber{\thisrow{#2}} + \pgfmathfloatln@{\pgfmathresult}% \let\pgfmathnext@y=\pgfmathresult \let\pgfmathaccumb=\pgfmathresult % @@ -784,8 +917,21 @@ /pgfplots/table/every first row/.code=, /pgfplots/table/every last row/.code=, }, + /pgfplots/table/colnames from/.initial=,% for \pgfplotstabletranspose + /pgfplots/table/input colnames to/.initial=colnames,% for \pgfplotstabletranspose +} +\pgfkeys{ + % #1: the argument which should have been assigned. + % #2: an error message. + /pgfplots/exception/non unique colname/.code 2 args={% + \ifx\pgfplotsexceptionmsg\relax + \pgfplots@error{#2}% + \else + \pgfplots@error{\pgfplotsexceptionmsg}% + \fi + \let#1=\pgfutil@empty + },% } - % 'function graph cut y'={<epsilon>}{<options>}{comma-separated-list of specs where to get yi} % % fills the column with x1,...,xN such that yi(xi) == epsilon where @@ -810,6 +956,8 @@ /pgfplots/table/create col/function graph cut/x/.initial=, /pgfplots/table/create col/function graph cut/y/.initial=, /pgfplots/table/create col/function graph cut/table/.initial=, + % foreach={\d in {1,2,3,4}}{{table\d}} + /pgfplots/table/create col/function graph cut/foreach/.initial=, } @@ -878,9 +1026,45 @@ % following methods can be used to query values: % \pgfplotstablereadgetcolindex{<index>}{<\macro>} % \pgfplotstablereadgetcolname{<name>}{<\macro>} +% \pgfplotstablereadvalueofcolname{<name>} +% \pgfplotstablereadvalueofcolindex{<index>} +% \thisrow{<name>} (equivalent to \pgfplotstablereadvalueofcolname) +% \getthisrow{<name>}{<\macro>} (equivalent to \pgfplotstablereadgetcolname) +% \thisrowno{<index>} (equivalent to \pgfplotstablereadvalueofcolindex) +% \getthisrowno{<index>}{<\macro>} +% \pgfplotstableforeachcolumn\as{<\iteratemacro>}{<loop body>} +% (the '\as' is required directly after +% \pgfplotstableforeachcolumn in this context) % Attention: 'to listener' is scoped by TeX groups, so any assignments % need to be done globally (or with aftergroup magic). +% +% More remarks about scoping: +% \pgfplotstableread to listener works as follows: +% \begingroup +% // load table +% while file has more lines: +% load line, read every column; +% invoke listener; +% repeat +% \endgroup +% +% In short: all invocations of listener have the same level of +% scoping: they are inside of one TeX group. But single listener +% invocations as such are not scoped. Make sure you don't +% accidentally overwrite one of the internals in listener. And: make +% sure you don't change temporary registers without scoping them! +% +% Note: this command also updates \pgfplotsscanlinelength. \def\pgfplotstableread{% + \pgfutil@ifnextchar*{% + \pgfplots@tableread@use@begingroupfalse + \pgfplotstableread@impl@star + }{% + \pgfplots@tableread@use@begingrouptrue + \pgfplotstableread@impl@star*% + }% +}% +\def\pgfplotstableread@impl@star*{% \pgfutil@ifnextchar[{% \pgfplotstableread@impl }{% @@ -893,7 +1077,7 @@ % Invokes #2 if '#1' is an already loaded table and #3 if not. \long\def\pgfplotstable@isloadedtable#1#2#3{% - \pgfutil@ifundefined{\string#1@@table@name}{#3}{#2}% + \pgfplotsutil@ifdefinedui@withsuffix{#1}{@@table@name}{#2}{#3}% }% % Defines \pgfmathresult to be the number of rows in table #1. @@ -928,47 +1112,49 @@ }% } -{ -\catcode`\^^I=12 -\gdef\pgfplotstablesave@impl@TAB{^^I} -} - \def\pgfplotstablesave@impl[#1]#2#3{% \pgfplotstabletypeset[% reset styles,% disable rowcol styles,% - begin table={}, end table={},% + begin table={},% + end table={},% typeset cell/.code={% \begingroup \t@pgfplots@toka={##1}% \ifcase\pgfplotstableread@OUTCOLSEP@CASE\relax - % SPACE: - \t@pgfplots@tokb=\expandafter{\pgfplotstablesave@impl@TAB}% + % col sep=SPACE: + \t@pgfplots@tokb=\expandafter{\pgfplotstableread@tab}% \pgfplots@ifempty{##1}{% \t@pgfplots@toka={{}}% }{}% \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% \or - % comma: + % col sep=comma: \t@pgfplots@tokb={,}% \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% \or - % semicolon: + % col sep=semicolon: \t@pgfplots@tokb={;}% \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% \or - % colon: + % col sep=colon: \t@pgfplots@tokb={:}% \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% \or - % braces: + % col sep=braces: \xdef\pgfplots@glob@TMPc{{\the\t@pgfplots@toka}}% + \or + % col sep=tab: + \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\pgfplotstableread@tab}% \fi \endgroup \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPc% },% - before row=,after row=,% - skip coltypes, typeset=false, string type,% + before row=,% + after row=,% + skip coltypes,% + typeset=false,% + string type,% TeX comment=,% columns=,% font=,% @@ -978,6 +1164,7 @@ /pgfplots/table/col sep/semicolon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{2}},% /pgfplots/table/col sep/colon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{3}},% /pgfplots/table/col sep/braces/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{4}},% + /pgfplots/table/col sep/tab/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{5}},% /pgfplots/table/col sep=space,% /pgfplots/table/in col sep/.is choice,% /pgfplots/table/in col sep/space/.code = {\def\pgfplotstableread@COLSEP@CASE{0}},% @@ -985,6 +1172,7 @@ /pgfplots/table/in col sep/semicolon/.code = {\def\pgfplotstableread@COLSEP@CASE{2}},% /pgfplots/table/in col sep/colon/.code = {\def\pgfplotstableread@COLSEP@CASE{3}},% /pgfplots/table/in col sep/braces/.code = {\def\pgfplotstableread@COLSEP@CASE{4}},% + /pgfplots/table/in col sep/tab/.code = {\def\pgfplotstableread@COLSEP@CASE{5}},% /pgfplots/table/in col sep=space,% % WARNING: you NEED a '%' before '#1': #1,% @@ -992,27 +1180,38 @@ ]{#2}% }% +% clears the table. +\def\pgfplotstableclear#1{% + \let#1=\relax + \expandafter\let\csname \string#1@@table@name\endcsname=\relax +}% + + % \pgfplotstablenew[<options>]{<numrows>}{<\name>} +% \pgfplotstablenew*[<options>]{<numrows>}{<\name>} % % Creates a new table from scratch. % % The new table will contain all columns listed in the 'columns' key -% which must be present in <options>. +% which must be present in <options>. The starred version +% \pgfplotstablenew* is not that strict: it will use the current value +% of the columns key (not matter where and when it has been set). % % Furthermore, there must be 'create on use' statements for every % column which shall be generated. Columns are generated % independently, in the order of appearance in 'columns'. % The table will contain exactly <numrows> rows. \def\pgfplotstablenew{% - \pgfutil@ifnextchar[{% - \pgfplotstablenew@impl - }{% - \pgfplotstablenew@impl[]% - }% -}% -\def\pgfplotstablenew@impl[#1]#2#3{% - \pgfutil@namedef{\string#3@@table@name}{newlycreatedtable}% \begingroup + \pgfutil@ifnextchar*{\pgfplotstablenew@star}{\pgfplotstablenew@nostar}} +\def\pgfplotstablenew@star*{\pgfutil@ifnextchar[{\pgfplotstablenew@impl}{\pgfplotstablenew@impl[]}}% +\def\pgfplotstablenew@nostar{% + % reset columns key: + \pgfkeyslet{/pgfplots/table/columns}{\pgfutil@empty}% + \pgfutil@ifnextchar[{\pgfplotstablenew@impl}{\pgfplotstablenew@impl[]}} + +\def\pgfplotstablenew@impl[#1]#2#3{% + \pgfplotsscanlinelengthinitzero % create a temporary column with the desired number of rows: \pgfutil@in@\pgfplotstablegetrowsof{#2}% \ifpgfutil@in@ @@ -1025,8 +1224,11 @@ \expandafter\pgfplots@assign@list\csname\string#3@@@@@@temporary@column@\endcsname{1,2,...,\pgfplotstable@loc@TMPa}% % % now, create all real columns: - \pgfkeyslet{/pgfplots/table/columns}{\pgfutil@empty}% - \pgfplotstableset{#1}% + \pgfplotstableset{#1,% + /pgf/fpu/handlers/empty number/.code 2 args={% + \pgfmathfloatcreate{0}{0.0}{0}% + }% + }% \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% \ifx\pgfplotstable@colnames\pgfutil@empty \pgfplots@warning{\string\pgfplotstablenew[columns={},...]{#2}{\string#3} has been invoked - but empty tables are currently not really supported, sorry. You will have to live with an artifical column which contains temporary values.}% @@ -1050,9 +1252,10 @@ % unsupported! \pgfplotslistpopfront#3\to\pgfplotstable@loc@TMPa \fi - \pgfplotstable@copy@to@globalbuffers#3 + \pgfplotsscanlinelengthcleanup + \pgfplotstable@copy@to@globalbuffers#3{newlycreatedtable}% \endgroup - \pgfplotstable@copy@globalbuffers@to#3 + \pgfplotstable@copy@globalbuffers@to#3% }% % \pgfplotstablevertcat{<table1>}{<table2>} @@ -1089,6 +1292,180 @@ }% } +% \pgfplotstabletranspose{<\outtable>}{<intable>} +% \pgfplotstabletranspose[<colname>]{<\outtable>}{<intable>} +% Defines <\outtable> to be the transposed of <intable>. +% +% If <colname> is not empty, the respective column's entries will be used to +% make output column names. +% +% #1: a table macro name which will be overwritten (redefined) +% #2: either a file name or a table macro (loaded table). +\def\pgfplotstabletranspose{% + \begingroup + \pgfutil@ifnextchar*{% + \pgfplotstabletranspose@star% + }{% + \pgfkeyslet{/pgfplots/table/columns}\pgfutil@empty% clear! + \pgfplotstabletranspose@star*% + }% +} +\def\pgfplotstabletranspose@star*{\pgfutil@ifnextchar[{\pgfplotstabletranspose@opt}{\pgfplotstabletranspose@opt[]}}% +\def\pgfplotstabletranspose@opt[#1]#2#3{% + \pgfplotstable@isloadedtable{#3}{% + \pgfplotstabletranspose@[#1]{#2}{#3}% + }{% + \pgfplotstableread{#3}\pgfplotstable@tmptbl + \pgfplotstabletranspose@[#1]{#2}{\pgfplotstable@tmptbl}% + }% +}% + +% Iterates through every column of table '#1' and invokes the code +% '#3' for each column. The current column name will be available as +% '#2' and the current column index as |\pgfplotstablecol| (starting +% with 0). +% +% Example: +% \pgfplotstableforeachcolumn{\table}\as\colname{% +% The column name is `\colname'; its index \pgfplotstablecol.\par +% }% +% +% REMARK: this routine does NOT introduce TeX groups. +\long\def\pgfplotstableforeachcolumn#1\as#2#3{% + \def\pgfplotstablecol{0}% + \pgfplotslistforeachungrouped#1\as#2{% + #3\relax% + \pgfplotsutil@advancestringcounter\pgfplotstablecol + }% + \let\pgfplotstablecol=\relax +}% +% A variant of \pgfplotstableforeachcolumn which is used inside of +% \pgfplotstableread to listener. +% +% It is used as \pgfplotstableforeachcolumn\as\cur{<do something with \cur>} +\long\def\pgfplotstableforeachcolumn@listener\as#1#2{% + \def\pgfplotstablecol{0}% + \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as#1{% + #2\relax% + \pgfplotsutil@advancestringcounter\pgfplotstablecol + }% + \let\pgfplotstablecol=\relax +}% + +% Reports every element t_{ij} for a fixed column j (in read-only +% mode). +% +% For every cell, the code '#4' will be executed where '#3' will +% contain the cell's value. During code '#4', the macro +% \pgfplotstablerow will contain the current row index. +% +% #1: either a column name or the string '[index]' followed by a +% number denoting a column index Access by column name is much faster.. +% #2: the table (macro or file name) +% #3: the macro in which the cell values shall be written +% #4: the code to execute. +% +% Example: +% \pgfplotstableforeachcolumnelement{colname}\of\table\as\cellelem{% +% I have now cell element `\cellelem' at row index +% `\pgfplotstablerow'. +% \par +% } +% +% REMARK: this routine does NOT introduce TeX groups. +\long\def\pgfplotstableforeachcolumnelement#1\of#2\as#3#4{% + \def\pgfplotstablerow{0}% + \pgfplotstablegetcolumn{#1}\of{#2}\to\pgfplotstableforeachcolumnelement@list + \pgfplotslistforeachungrouped\pgfplotstableforeachcolumnelement@list\as#3{% + % allow nesting by copying the old value of \pgfplotstablerow: + \expandafter\pgfplotstableforeachcolumnelement@\expandafter{\pgfplotstablerow}{#4}% + }% + \let\pgfplotstablerow=\relax +}% +% helper method to allow nesting. It copies \pgfplotstablerow. +% #1: the expanded value of \pgfplotstablerow. +\long\def\pgfplotstableforeachcolumnelement@#1#2{% + #2\relax + \def\pgfplotstablerow{#1}% restore to old value. + % advance. + \pgfplotsutil@advancestringcounter\pgfplotstablerow +}% + +% A routine which is similar to \pgfplotstableforeachcolumnelement, +% but this here checks for changes in \pgfplotsretval and writes them +% back into the respected cell. +% +% The runtime is quadratic in the number of rows. +\long\def\pgfplotstablemodifyeachcolumnelement#1\of#2\as#3#4{% + \def\pgfplotstablerow{0}% + % + % Step 0: get the REAL column name for '#1'. + % This needs modifications if '#1' is [index]<integer>. + % -> store the colname to \pgfplotstable@loc@TMPc: + \def\pgfplotstable@loc@TMPc{#1}% + \pgfplotstable@is@colname{\pgfplotstable@loc@TMPc}%% + \ifpgfplotstableread@foundcolnames + \else + \expandafter\pgfplotstablegetcolumnnamebyindex\pgfplotstable@loc@TMPc\of{#2}\to\pgfplotstable@loc@TMPc + \fi + % Step 0.1: prepare a command which re-assembles column '#1' + % (using the real column name). + % The re-assemblation command will be invoked at the end of each + % iteration. This complicated macro preparation allows nested + % calls to \pgfplotstablemodifyeachcolumnelement. + \t@pgfplots@toka={\expandafter\pgfplotslistpushback\expandafter{#3}\to}% + \edef\pgfplotstable@loc@TMPd{% + \the\t@pgfplots@toka{\expandafter\noexpand\csname\string#2@\pgfplotstable@loc@TMPc\endcsname}}% + % Step 1: copy the column data to \pgfplotstable@loc@TMPb + \expandafter\pgfplotstablegetcolumnbyname\pgfplotstable@loc@TMPc\of#2\to\pgfplotstable@loc@TMPb% + % + % clear the original column: + \expandafter\pgfplotslistnewempty\csname\string#2@\pgfplotstable@loc@TMPc\endcsname + % + % Call loop. The prepared re-assemble macro will be provided as macro argument + % to allow nested calls: + \expandafter\pgfplotstablemodifyeachcolumnelement@\expandafter{\pgfplotstable@loc@TMPd} + {\pgfplotstable@loc@TMPb}{#3}{#4}% + \let\pgfplotstablerow=\relax +}% +% #1: post-iteration code +% #2: the row list +% #3: the loop macro to assign +% #4: the loop body +\long\def\pgfplotstablemodifyeachcolumnelement@#1#2#3#4{% + \pgfplotslistforeachungrouped{#2}\as#3{% + % allow nesting by copying the old value of \pgfplotstablerow: + \expandafter\pgfplotstableforeachcolumnelement@\expandafter{\pgfplotstablerow}{#4}% + #1% + }% +} + +% Selects a single table element at row #1 and column #2 from table +% #3. +% +% #1: a row index. +% #2: a column name or the string '[index]' followed by a number +% denoting a column index. Access by column name is much faster. +% #3: the table (macro or file name). +% +% The cell value will be written into the macro \pgfplotsretval. +% +% REMARK: +% this routine is supposed to be very slow: it needs time O(N) where N +% is the number of rows. This may change in future versions. +% +% Example: +% \pgfplotstablegetelem{0}{[index]2}\of\table +% The elem is `\pgfplotsretval'. +\def\pgfplotstablegetelem#1#2\of#3{% + \begingroup + \pgfplotstablegetcolumn{#2}\of{#3}\to\pgfplotstable@loc@TMPa + \def\pgfplotsexceptionmsg{Sorry, row `#1' does not exist in table \pgfplotstablenameof{#3}}% + \pgfplotslistselect#1\of\pgfplotstable@loc@TMPa\to\pgfplotsretval + \pgfmath@smuggleone\pgfplotsretval + \endgroup +}% + \def\pgfplotstablegetcolumnlist#1\to#2{\let#2=#1} % Returns a column vector in form of \pgfplotslist @@ -1097,6 +1474,8 @@ % #1: the column name (not a macro) % #2: the table structure % #3: the output macro name. +% +% @throw `no such element' on error \def\pgfplotstablegetcolumnbyname#1\of#2\to#3{% \pgfutil@ifundefined{\string#2@#1}{% % Oh, there is no column '#1' in table '#2'! @@ -1109,6 +1488,7 @@ % *** \pgfplotstablereadgetptrtocolname *** % *** \pgfplotstablegetcolumnbyname *** % *** \pgfplotstableresolvecolname *** + % *** \pgfplotstablereadvalueofcolname *** \def\pgfplotstable@loc@TMPa{/pgfplots/table/create on use/#1}% \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{% % aah - a 'create on use' style exists. Apply it! @@ -1123,14 +1503,12 @@ \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 + \pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve aliased column '\pgfplotstable@loc@TMPa' from table '\pgfplotstablenameof{#2}'. The original request was for '#1', which does not exist either.}\pgfeov% }{% \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 + \pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve column '#1' from table '\pgfplotstablenameof{#2}'. Please check spelling (or introduce name aliases).}\pgfeov% }% }% }{% @@ -1161,6 +1539,7 @@ % *** \pgfplotstablereadgetptrtocolname *** % *** \pgfplotstablegetcolumnbyname *** % *** \pgfplotstableresolvecolname *** + % *** \pgfplotstablereadvalueofcolname *** \def\pgfplotstable@loc@TMPa{/pgfplots/table/alias/#1}% \pgfkeysifdefined{\pgfplotstable@loc@TMPa}{% \pgfkeysgetvalue{\pgfplotstable@loc@TMPa}{\pgfplotstable@loc@TMPb}% @@ -1168,17 +1547,15 @@ \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. You can do this using the 'read completely' key, see the manual for details.}% + \pgfplotstable@error{Sorry, '\pgfplotstable@loc@TMPb' from table '\pgfplotstableread@filename' can't be evaluated in this context. Please prepare the table before using it here. You can do this using the 'read completely' key, see the manual for details.}% }{% - \pgfplots@error{Sorry, could not retrieve aliased column '\pgfplotstable@loc@TMPa' from table '\pgfplotstablenameof{#2}'. The original request was for '#1', which does not exist either.}% + \pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve aliased column '\pgfplotstable@loc@TMPa' from table '\pgfplotstablenameof{#2}'. The original request was for '#1', which does not exist either.}\pgfeov% }% - \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 + \pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve column '#1' from table '\pgfplotstablenameof{#2}'. Please check spelling (or introduce name aliases).}\pgfeov% }% }{% \def#3{#1}% @@ -1187,13 +1564,31 @@ % Invokes either \pgfplotstablegetcolumnbyindex or % \pgfplotstablegetcolumnbyname. +% +% #1: either a column name, alias or create on use specification, or +% [index]<integer> denoting a column index. +% #2: either a loaded table or a table macro. +% #3: a macro name which will be filled with the column, in the format +% accepted of \pgfplotslist... \def\pgfplotstablegetcolumn#1\of#2\to#3{% - \pgfplotstable@is@colname{#1}% + \begingroup + \pgfplotstable@isloadedtable{#2}{% + \pgfplotstablegetcolumnfromstruct{#1}\of{#2}\to{#3}% + }{% + \pgfplotstableread{#2}\pgfplotstable@tmptbl + \pgfplotstablegetcolumnfromstruct{#1}\of\pgfplotstable@tmptbl\to{#3}% + }% + \pgfmath@smuggleone#3% + \endgroup +}% +\def\pgfplotstablegetcolumnfromstruct#1\of#2\to#3{% + \def\pgfplotstable@loc@TMPc{#1}% + \pgfplotstable@is@colname{\pgfplotstable@loc@TMPc}%% \ifpgfplotstableread@foundcolnames \else - \pgfplotstablegetcolumnnamebyindex{#1}\of{#2}\to{#3} + \expandafter\pgfplotstablegetcolumnnamebyindex\pgfplotstable@loc@TMPc\of{#2}\to\pgfplotstable@loc@TMPc \fi - \pgfplotstablegetcolumnbyname{#1}\of#2\to{#3}% + \expandafter\pgfplotstablegetcolumnbyname\pgfplotstable@loc@TMPc\of#2\to{#3}% }% \def\pgfplotstablegetcolumnnamebyindex#1\of#2\to#3{% @@ -1208,6 +1603,7 @@ \let#2=#1% \pgfplotstablegetname#1\pgfplotstable@loc@TMPa \expandafter\let\csname\string#2@@table@name\endcsname=\pgfplotstable@loc@TMPa + \expandafter\edef\csname\string#2@@table@scanline\endcsname{\pgfplotstablescanlinelengthof{#1}}% \pgfplotslistforeachungrouped#1\as\pgfplotstable@loc@TMPa{% \def\pgfplotstable@loc@TMPb{% \expandafter\let\csname\string#2@\pgfplotstable@loc@TMPa\endcsname}% @@ -1225,6 +1621,15 @@ \csname\string#1@@table@name\endcsname } +% Returns the value of \pgfplotsscanlinelength for table '#1' into +% macro #2. +\def\pgfplotstablegetscanlinelength#1#2{% + \expandafter\let\expandafter#2\csname\string#1@@table@scanline\endcsname +}% + +% Expands to the scan line length of table '#1'. +\def\pgfplotstablescanlinelengthof#1{\csname\string#1@@table@scanline\endcsname}% + % Creates a new column named #1 and appends it to table #2. % % The column entries will be created using the command keys @@ -1275,9 +1680,10 @@ % % You will need to reconfigure the tables. % -% Inside of \pgfplotstabletypeset, the macros \pgfplotstablecol and -% \pgfplotstablerow will expand to the current column index and row -% index. +% Inside of \pgfplotstabletypeset, the macros +% \pgfplotstablecol,\pgfplotstablecolname and +% \pgfplotstablerow will expand to the current column index, column +% name and row index, respectively. \def\pgfplotstabletypeset{% \pgfutil@ifnextchar[{% \pgfplotstabletypeset@opt @@ -1309,12 +1715,12 @@ \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename \ifx\pgfplotstable@outfilename\pgfutil@empty \else - \openin1=\pgfplotstable@outfilename\relax - \ifeof1 + \openin\r@pgfplots@reada=\pgfplotstable@outfilename\relax + \ifeof\r@pgfplots@reada \else \pgfplotstabletypeset@includeoutfilestrue \fi - \closein1 + \closein\r@pgfplots@reada \fi \fi \fi @@ -1322,7 +1728,11 @@ \input \pgfplotstable@outfilename\relax \else \pgfplotstableread{#2}\pgfplotstabletypesetfile@opt@@ - \pgfplotstabletypeset\pgfplotstabletypesetfile@opt@@ + \ifx\pgfplotstabletypesetfile@opt@@\relax + % ERROR. + \else + \pgfplotstabletypeset\pgfplotstabletypesetfile@opt@@ + \fi \fi \pgfkeysgetvalue{/pgfplots/table/write to macro}\pgfplots@loc@TMPa \ifx\pgfplots@loc@TMPa\pgfutil@empty @@ -1377,68 +1787,125 @@ }% \def\pgfplotstableread@impl@#1#2#3{% + \ifpgfplots@tableread@use@begingroup \begingroup - \ifpgfplots@table@options@areset - \else - \pgfplotstableset{/pgfplots/table/every table={#2},#1}% \fi %\pgfplots@message{ATTEMPTING TO READ #2}% - \openin1=#2.tex - \ifeof1 - \openin1=#2\relax + \openin\r@pgfplots@reada=#2.tex + \ifeof\r@pgfplots@reada + \openin\r@pgfplots@reada=#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 + \closein\r@pgfplots@reada + \openin\r@pgfplots@reada=#2\relax \fi \pgfplots@logfileopen{#2}% - \def\pgfplotstableread@filename{#2}% - \let\pgfplotstableread@lineno=\c@pgf@counta - \let\pgfplotstableread@numcols=\c@pgf@countb - \let\pgfplotstableread@curcol=\c@pgf@countc - \let\pgfplotstableread@usablelineno=\c@pgf@countd - \pgfplotstableread@lineno=0 - \pgfplotstableread@usablelineno=0 - \pgfplotstableread@numcols=0 - \global\pgfplotslistnewempty\pgfplotstable@colnames@glob - \ifeof1 - \pgfplotstable@error{Could not read table file '#2'.}% - \global\pgfplotslistnewempty\pgfplotstable@colnames@glob + % + \edef\pgfplotstableread@oldendlinechar{\the\endlinechar}% + \endlinechar=-1 % do not append a white space after each line + % + \pgfplotstableread@impl@prepare{#1}{#2}{#3}% + \ifeof\r@pgfplots@reada + \pgfplotsthrow{no such table file}{\pgfplots@loc@TMPa}{#2}{Could not read table file '#2'.}\pgfeov% + \global\let\pgfplotstable@colnames@glob=\pgfplots@loc@TMPa \else - \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 + % + \closein\r@pgfplots@reada % \pgfplotstableread@finish \fi + \endlinechar=\pgfplotstableread@oldendlinechar + \pgfplotsscanlinelengthcleanup + \pgfplotstable@copy@to@globalbuffers@simple{#2}% + \ifpgfplots@tableread@use@begingroup \endgroup + \fi \ifpgfplots@tableread@to@listener % there are no data structures in this case. + \let\pgfplotsscanlinelength=\pgfplotstable@glob@buf@scanline \else % Now, we can access the global variables! % copy them to #3. - \expandafter\def\csname\string#3@@table@name\endcsname{#2}% - \pgfplotstable@copy@globalbuffers@to#3 + \pgfplotstable@copy@globalbuffers@to#3% \fi } +% #1: any options to set (respect \ifpgfplots@table@options@areset ) +% #2: the file name +% #3: the output macro (or listener) +\def\pgfplotstableread@impl@prepare#1#2#3{% + \ifpgfplots@table@options@areset + \else + \pgfplotstableset{/pgfplots/table/every table={#2},#1}% + \fi + \def\pgfplotstableread@filename{#2}% + % + % local counter definitions: + \ifpgfplots@tableread@use@begingroup + \let\pgfplotstableread@lineno=\c@pgf@counta + \let\pgfplotstableread@numcols=\c@pgf@countb + \let\pgfplotstableread@curcol=\c@pgf@countc + \let\pgfplotstableread@usablelineno=\c@pgf@countd + \def\thepgfplotstableread@lineno{\the\pgfplotstableread@lineno}% + \def\thepgfplotstableread@usablelineno{\the\pgfplotstableread@usablelineno}% + \def\thepgfplotstableread@curcol{\the\pgfplotstableread@curcol}% + \def\thepgfplotstableread@numcols{\the\pgfplotstableread@numcols}% + \def\pgfplotstableread@countreset##1{##1=0 }% + \def\pgfplotstableread@countset##1##2{##1=##2 }% + \def\pgfplotstableread@countadvance##1{\advance##1 by1 }% + \else + % don't re-use integers! We have no protecting scopes! + \def\thepgfplotstableread@lineno{\pgfplotstableread@lineno}% + \def\thepgfplotstableread@usablelineno{\pgfplotstableread@usablelineno}% + \def\thepgfplotstableread@curcol{\pgfplotstableread@curcol}% + \def\thepgfplotstableread@numcols{\pgfplotstableread@numcols}% + \def\pgfplotstableread@countreset##1{\def##1{0}}% + \def\pgfplotstableread@countset##1##2{\def##1{##2}}% + \def\pgfplotstableread@countadvance##1{\pgfplotsutil@advancestringcounter{##1}}% + \fi + \pgfplotstableread@countreset\pgfplotstableread@lineno + \pgfplotstableread@countreset\pgfplotstableread@usablelineno + \pgfplotstableread@countreset\pgfplotstableread@numcols + \pgfplotstableread@countreset\pgfplotstableread@curcol + % + \pgfplotstableread@impl@prepare@DO + \def\pgfplotstableread@isgnuplotformat{0}% + \global\pgfplotslistnewempty\pgfplotstable@colnames@glob + \pgfplotsscanlinelengthinitzero + \ifpgfplots@tableread@to@listener + \def\pgfplotstablerow{\thepgfplotstableread@usablelineno}% + \def\pgfplotstablelineno{\thepgfplotstableread@lineno}% + \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@ + \let\pgfplotstablereadvalueofptr=\pgfplotstablereadvalueofptr@ + \let\pgfplotstableforeachcolumn=\pgfplotstableforeachcolumn@listener + \let\pgfplotstablereadvalueofcolname=\pgfplotstablereadvalueofcolname@ + \let\pgfplotstablereadvalueofcolindex=\pgfplotstablereadvalueofcolindex@ + \let\getthisrow=\pgfplotstablereadgetcolname + \let\thisrow=\pgfplotstablereadvalueofcolname + \let\thisrowno=\pgfplotstablereadvalueofcolindex + \let\getthisrowno=\pgfplotstablereadgetcolindex + \fi +}% + % Copies the table column list and the column vectors of #1 to global buffers. % @see \pgfplotstable@copy@globalbuffers@to % % Use these two methods to avoid scoping problems. -\def\pgfplotstable@copy@to@globalbuffers#1{% +% +% #1: the <\macro> name of the table which is to be copied to global buffers. +% #2: the table file name. +\def\pgfplotstable@copy@to@globalbuffers#1#2{% \global\let\pgfplotstable@colnames@glob=#1 \c@pgfplotstable@counta=0\relax% \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{% @@ -1448,11 +1915,29 @@ \expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname \advance\c@pgfplotstable@counta by1\relax }% + \pgfplotstable@copy@to@globalbuffers@simple{#2}% +}% +% A variant of \pgfplotstable@copy@to@globalbuffers which copies only +% the member variables of a loaded table (the name and scanline length) to +% global buffers. +% +% #1: the table's file name. +% +% @PRECONDITION: any other variables and cell data of the table are already stored +% in global buffers. +\def\pgfplotstable@copy@to@globalbuffers@simple#1{% + \gdef\pgfplotstable@glob@buf@name{#1}% + \global\let\pgfplotstable@glob@buf@scanline=\pgfplotsscanlinelength }% % copies the global column list and the global column vectors to #1 % (NOT the table file name). % @see \pgfplotstable@copy@to@globalbuffers +% +% @PRECONDITION the global buffers contain all members of a table. +% +% @POSTCONDITION The table '#1' is be initialised to these members. +% Furthermore, \pgfplotsscanlinelength is set. \def\pgfplotstable@copy@globalbuffers@to#1{% \let#1=\pgfplotstable@colnames@glob \c@pgfplotstable@counta=0\relax% @@ -1465,108 +1950,124 @@ \advance\c@pgfplotstable@counta by1\relax }% \global\let\pgfplotstable@colnames@glob=\pgfutil@empty + \expandafter\let\csname\string#1@@table@scanline\endcsname=\pgfplotstable@glob@buf@scanline + \expandafter\let\csname\string#1@@table@name\endcsname=\pgfplotstable@glob@buf@name + \let\pgfplotsscanlinelength=\pgfplotstable@glob@buf@scanline }% \def\pgfplotstableread@finish{% + \pgfplotsscanlinecomplete \ifpgfplots@tableread@to@listener \else \ifpgfplotstableread@foundcolnames \else \pgfplotstableread@create@column@names@with@numbers \fi - \pgfplotstableread@curcol=0\relax% + \pgfplotstableread@countreset\pgfplotstableread@curcol% \pgfutil@loop - \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols - \expandafter\pgfplotsapplistXflushbuffers\csname pgfp@numtable@glob@col@\the\pgfplotstableread@curcol\endcsname - \advance\pgfplotstableread@curcol by1 + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax + \expandafter\pgfplotsapplistXflushbuffers\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname + \pgfplotstableread@countadvance\pgfplotstableread@curcol \pgfutil@repeat \fi } \def\pgfplotstableread@loop@over@lines{% - \ifeof1 + \ifeof\r@pgfplots@reada %\pgfplots@message{EOF}% \else - \read1 to\pgfplotstable@LINE - \ifeof1 - \else - \expandafter\pgfplotstableread@checkspecial@line\pgfplotstable@LINE\pgfplotstable@EOI - \ifpgfplotstableread@skipline + \read\r@pgfplots@reada to\pgfplotstable@LINE + \ifeof\r@pgfplots@reada \else - %-------------------------------------------------- - % \ifnum\pgfplotstableread@lineno=0 - % \let\pgfplotstable@firstline=\pgfplotstable@LINE - % \fi - %-------------------------------------------------- -%\pgfplots@message{READING LINE \the\pgfplotstableread@lineno: '\meaning\pgfplotstable@LINE'.}% - \pgfplotstableread@curline@contains@colnamesfalse - \ifnum\pgfplotstableread@numcols=0\relax - % STEP 0: initialise - % - count columns - % - find header data - \pgfplotstableread@curcol=0\relax - \pgfplotstableread@impl@DO\pgfplotstableread@impl@countcols@and@identifynames@NEXT\pgfplotstable@LINE - %\expandafter\pgfplotstableread@impl@countcols@and@identifynames@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI - \pgfplotstableread@numcols=\pgfplotstableread@curcol - \pgfplotstableread@curcol=0\relax - % Create empty column lists: - \pgfplotstableread@create@column@lists - % - \ifnum\pgfplotstableread@usablelineno=0\relax - \ifnum\pgfplotstableread@lineno=2\relax - \ifnum\pgfplotstableread@numcols=3\relax - % The file started with - % #... - % #... - % X Y i - % -> thats a gnuplot file! - \pgfplotstableread@curline@contains@colnamesfalse - \fi - \fi - \fi - % Now, read the first line. - % It contains either - % - column names, - % - numerical data, - % - nothing (comments). - \ifpgfplotstableread@curline@contains@colnames - \pgfplotstableread@foundcolnamestrue - \pgfplotstableread@curcol=0\relax - \pgfplotstableread@impl@DO\pgfplotstableread@impl@collectcolnames@NEXT\pgfplotstable@LINE - %\expandafter\pgfplotstableread@impl@collectcolnames@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI - \else - \pgfplotstableread@foundcolnamesfalse - \pgfplotstableread@curcol=0\relax - % Leave column name lists empty... - \pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE - %\expandafter\pgfplotstableread@impl@nextrow@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI - \fi -%\pgfplots@message{After reading first row: found '\the\pgfplotstableread@numcols' columns; column name list='\meaning\pgfplotstable@colnames@glob'}% + \pgfplotstableread@loop@processnextline + \fi + \expandafter\pgfplotstableread@loop@over@lines + \fi +} +% PRECONDITION: +% \pgfplotstable@LINE contains the current input line. +\def\pgfplotstableread@loop@processnextline{% + \expandafter\pgfplotstableread@checkspecial@line\pgfplotstable@LINE\pgfplotstable@EOI + \ifpgfplotstableread@skipline + \def\pgfplotstableread@gnuplotcheck{####x y type}% + \ifx\pgfplotstableread@gnuplotcheck\pgfplotstable@LINE + \def\pgfplotstableread@isgnuplotformat{1}% + \fi + \def\pgfplotstableread@gnuplotcheck{####x y z type}% + \ifx\pgfplotstableread@gnuplotcheck\pgfplotstable@LINE + \def\pgfplotstableread@isgnuplotformat{1}% + \fi + \else + %-------------------------------------------------- + % \ifnum\pgfplotstableread@lineno=0 + % \let\pgfplotstable@firstline=\pgfplotstable@LINE + % \fi + %-------------------------------------------------- +%\pgfplots@message{READING LINE \thepgfplotstableread@lineno: '\meaning\pgfplotstable@LINE'.}% + \pgfplotstableread@curline@contains@colnamesfalse + \ifnum\pgfplotstableread@numcols=0\relax + % STEP 0: initialise + % - count columns + % - find header data + \pgfplotstableread@countreset\pgfplotstableread@curcol + \ifpgfplotstable@firstline@is@header + \pgfplotstableread@curline@contains@colnamestrue + \fi + \pgfplotstableread@impl@DO\pgfplotstableread@impl@countcols@and@identifynames@NEXT\pgfplotstable@LINE + \pgfplotstableread@countset\pgfplotstableread@numcols{\pgfplotstableread@curcol}% + \pgfplotstableread@countreset\pgfplotstableread@curcol + % Create empty column lists: + \pgfplotstableread@create@column@lists + % + \ifnum\pgfplotstableread@usablelineno=0\relax + \if1\pgfplotstableread@isgnuplotformat% + % The file started with + % #... + % #x y type + % X Y i + % -> thats a gnuplot file! + \pgfplotstableread@curline@contains@colnamesfalse + \fi + \fi + % Now, read the first line. + % It contains either + % - column names, + % - numerical data, + % - nothing (comments). + \ifpgfplotstableread@curline@contains@colnames + \pgfplotstableread@foundcolnamestrue + \pgfplotstableread@countreset\pgfplotstableread@curcol + \pgfplotstableread@impl@DO\pgfplotstableread@impl@collectcolnames@NEXT\pgfplotstable@LINE \else - \pgfplotstableread@curcol=0\relax + \pgfplotsscanlinelengthincrease + \pgfplotstableread@foundcolnamesfalse + \pgfplotstableread@countreset\pgfplotstableread@curcol + % Leave column name lists empty... \pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE - %\expandafter\pgfplotstableread@impl@nextrow@ITERATE\pgfplotstable@LINE\pgfplotstable@EOI \fi - \ifnum\pgfplotstableread@curcol=\pgfplotstableread@numcols +%\pgfplots@message{After reading first row: found '\thepgfplotstableread@numcols' columns; column name list='\meaning\pgfplotstable@colnames@glob'}% + \else + \pgfplotsscanlinelengthincrease + \pgfplotstableread@countreset\pgfplotstableread@curcol + \pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE + \fi + \ifnum\pgfplotstableread@curcol=\pgfplotstableread@numcols\relax + \else + \pgfplotstable@error{input table '\pgfplotstableread@filename' has an unbalanced number of columns in row '\thepgfplotstableread@lineno' (expected '\thepgfplotstableread@numcols' cols; got '\thepgfplotstableread@curcol'). Maybe the input table is corrupted? If you need unbalanced data, consider using 'nan' in empty cells (perhaps combined with 'unbounded coords=jump')}% + \fi + \ifpgfplots@tableread@to@listener + \ifpgfplotstableread@curline@contains@colnames \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 + % report row! + \pgfplotstable@listener \fi - \advance\pgfplotstableread@usablelineno by1\relax \fi - \fi - \advance\pgfplotstableread@lineno by1\relax - \expandafter\pgfplotstableread@loop@over@lines + \pgfplotstableread@countadvance\pgfplotstableread@usablelineno \fi -} + \pgfplotstableread@countadvance\pgfplotstableread@lineno +}% -% WARNING: this routine is also use in pgfplots.code.tex ... +% WARNING: this routine is also used in pgfplots.code.tex ... \def\pgfplotstableread@checkspecial@line{% \pgfutil@ifnextchar##{% \pgfplotstableread@skiplinetrue @@ -1577,10 +2078,12 @@ }{% \pgfutil@ifnextchar\pgfplotstable@EOI{% \pgfplotstableread@skiplinetrue + \pgfplotsscanlinecomplete% the line is empty; same as \par! \pgfplotstableread@impl@gobble }{% \pgfutil@ifnextchar\par{% \pgfplotstableread@skiplinetrue + \pgfplotsscanlinecomplete \pgfplotstableread@impl@gobble }{% \pgfplotstableread@skiplinefalse @@ -1599,19 +2102,20 @@ \def\pgfplotstableread@create@column@lists{% \pgfutil@loop - \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax \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 + \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname + \pgfplotstableread@countadvance\pgfplotstableread@curcol \pgfutil@repeat } \def\pgfplotstableread@create@column@names@with@numbers{% - \pgfplotstableread@curcol=0\relax + \pgfplotstableread@countreset\pgfplotstableread@curcol \pgfutil@loop - \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols - \expandafter\pgfplotslistpushbackglobal\the\pgfplotstableread@curcol\to\pgfplotstable@colnames@glob - \advance\pgfplotstableread@curcol by1\relax + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax + \edef\pgfplotstable@loc@TMPb{\thepgfplotstableread@curcol}% + \expandafter\pgfplotslistpushbackglobal\pgfplotstable@loc@TMPb\to\pgfplotstable@colnames@glob + \pgfplotstableread@countadvance\pgfplotstableread@curcol \pgfutil@repeat } @@ -1631,56 +2135,82 @@ % % #2: a macro containing a raw data line with <col sep> separated % entries. -\def\pgfplotstableread@impl@DO#1#2{% +\long\def\pgfplotstableread@impl@DO#1#2{% \let\pgfplotstableread@impl@ITERATE@NEXT@=#1\relax - \ifcase\pgfplotstableread@COLSEP@CASE\relax - % SPACE: - \expandafter\pgfplotstableread@impl@ITERATE#2\pgfplotstable@EOI - \or - % COMMA: - \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COMMA - \expandafter\pgfplotstableread@impl@ITERATE#2,\pgfplotstable@EOI - \or - % SEMICOLON: - \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON - \expandafter\pgfplotstableread@impl@ITERATE#2;\pgfplotstable@EOI - \or - % COLON: - \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COLON - \expandafter\pgfplotstableread@impl@ITERATE#2:\pgfplotstable@EOI - \or - % BRACE: - \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@BRACE - \expandafter\pgfplotstableread@impl@ITERATE#2\pgfplotstable@EOI - \fi + \expandafter\pgfplotstableread@impl@DO@\expandafter{#2}% +} +{% + \catcode`\ =10 + \catcode`\;=12 + \catcode`\:=12 + \gdef\pgfplotstableread@impl@prepare@DO{% + \ifcase\pgfplotstableread@COLSEP@CASE\relax + % col sep=space: + \catcode`\ =10 + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1 \pgfplotstable@EOI}% + \or + % col sep=comma: + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COMMA + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1,\pgfplotstable@EOI}% + \or + % col sep=semicolon: + \catcode`\;=12 + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1;\pgfplotstable@EOI}% + \or + % col sep=colon: + \catcode`\:=12 + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@COLON + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1:\pgfplotstable@EOI}% + \or + % col sep=brace: + % allow multi line cells: + \endlinechar=\pgfplotstableread@oldendlinechar\relax + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@BRACE + \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1\pgfplotstable@EOI}% + \or + % col sep=tab: + \catcode`\^^I=12 + \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@TAB + \long\edef\pgfplotstableread@impl@DO@##1{\noexpand\pgfplotstableread@impl@ITERATE##1\pgfplotstableread@tab\noexpand\pgfplotstable@EOI}% + \fi + }% }% -\def\pgfplotstableread@impl@ITERATE{% +\long\def\pgfplotstableread@impl@ITERATE{% \pgfutil@ifnextchar\pgfplotstable@EOI{% \pgfplotstableread@impl@gobble }{% \pgfplotstableread@impl@ITERATE@NEXT }% }% -\def\pgfplotstableread@impl@ITERATE@NEXT#1 {% +\long\def\pgfplotstableread@impl@ITERATE@NEXT#1 {% \pgfplotstableread@impl@ITERATE@NEXT@{#1}% \pgfplotstableread@impl@ITERATE }% -\def\pgfplotstableread@impl@ITERATE@NEXT@COMMA#1,{% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@COMMA#1,{% \pgfplotstableread@impl@ITERATE@NEXT@{#1}% \pgfplotstableread@impl@ITERATE }% -\def\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON#1;{% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON#1;{% \pgfplotstableread@impl@ITERATE@NEXT@{#1}% \pgfplotstableread@impl@ITERATE }% -\def\pgfplotstableread@impl@ITERATE@NEXT@COLON#1:{% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@COLON#1:{% \pgfplotstableread@impl@ITERATE@NEXT@{#1}% \pgfplotstableread@impl@ITERATE }% -\def\pgfplotstableread@impl@ITERATE@NEXT@BRACE#1{% +\long\def\pgfplotstableread@impl@ITERATE@NEXT@BRACE#1{% \pgfplotstableread@impl@ITERATE@NEXT@{#1}% \pgfplotstableread@impl@ITERATE }% +\begingroup +\catcode`\^^I=12 +\gdef\pgfplotstableread@tab{^^I}% +\long\gdef\pgfplotstableread@impl@ITERATE@NEXT@TAB#1^^I{% the following white spaces are SPACES, not tabs: + \pgfplotstableread@impl@ITERATE@NEXT@{#1}% + \pgfplotstableread@impl@ITERATE +}% +\endgroup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % these values are only usable for a read-listener, that means: @@ -1694,24 +2224,110 @@ % performs \let\content=<content of column no <index> > \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 + \pgfplotsthrow{no such element}{#2}{Sorry, the requested column number '#1' in table '\pgfplotstableread@filename' does not exist!? Please verify you used the correct index 0 <= i < N.}\pgfeov% }{% \expandafter\let\expandafter#2\csname pgfplotstblread@colcontent@no#1\endcsname }% }% -% \pgfplotstablereadgetcolname{<index>}{<name>} +\pgfkeysdef{/pgfplots/table/@undefined column text}{#1__column_not_found.}% +\def\pgfplotstable@undefinedtext#1{\pgfkeysvalueof{/pgfplots/table/@undefined column text/.@cmd}#1\pgfeov}% + +% As \pgfplotstablereadgetcolindex, but +% \pgfplotstablereadvalueofcolindex{<index>} +% directly expands to the value stored in the desired column. +% +% Example: +% \pgfplotstablereadvalueofcolindex{3} -> expands to '42' if '42' is +% written in column no 3. +% +% Column indexing starts at 0. +% +% @ATTENTION: since such a command may occur within an \edef or an +% \csname, it can't perform sanity checking. Proving an invalid index +% expands to \pgfkeysvalueof{/pgfplots/table/@undefined column text}. +\def\pgfplotstablereadvalueofcolindex@#1{% + \pgfutil@ifundefined{pgfplotstblread@colcontent@no#1}{% + \pgfplotstable@undefinedtext{colindex#1}% + }{% + \csname pgfplotstblread@colcontent@no#1\endcsname + }% +} + +% \pgfplotstablereadgetcolname{<name>}{<\content>} % performs \let\content=<content of column named <name> > \def\pgfplotstablereadgetcolname@#1#2{% \pgfplotstablereadgetptrtocolname{#1}{\pgfplots@loc@TMPa}% \pgfplotstablereadevalptr\pgfplots@loc@TMPa{#2}% }% +% This here is the implementation of \pgfplotstablereadvalueofcolname +% (and \thisrow{<colname>}) for use inside of the 'read to listener' +% framework. +% +% Like \pgfplotstablereadgetcolname, but this one expands directly to +% the value of the desired column. +% +% #1: a column name or a column alias. +% +% @ATTENTION: since such a command may occur within an \edef or an +% \csname, it can't perform sanity checking. Proving an invalid index +% expands to \pgfkeysvalueof{/pgfplots/table/@undefined column text}. +\def\pgfplotstablereadvalueofcolname@#1{% + \pgfplotstable@thisrow@impl{#1}{pgfplotstblread@colindex@for@name}{\pgfplotstable@thisrow@impl@read}% +}% +\def\pgfplotstable@thisrow@impl@read#1{\csname pgfplotstblread@colcontent@no#1\endcsname}% + +% This implements \thisrow in different contexts. +% +% Usage: +% \def\thisrow#1{\pgfplotstable@thisrow@impl{#1}{macroprefix@}{\pgfplotstable@thisrow@impl@}} +% +% Then, \thisrow{existingcol} +% will expand to +% -> \pgfplotstable@thisrow@impl@{\csname macroprefix@existingcol\endcsname} +% -> \csname macroprefix@existingcol\endcsname +% +% Furthermore, if '#1' is no existing col and there exists /pgfplots/table/alias/#1, +% \thisrow{aliased} +% will expand to +% -> \pgfplotstable@thisrow@impl@{\csname macroprefix@\pgfkeysvalueof{/pgfplots/table/alias/aliased}\endcsname} +% -> \csname macroprefix@\pgfkeysvalueof{/pgfplots/table/alias/aliased}\endcsname +% +% #1: the argument for \thisrow{#1} +% #2: a macro prefix such that \csname #2<colname>\endcsname contains +% the value of the current row for (physical) column <colname> +% #3: the name of a one-argument-macro which will get \csname #2<colname>\endcsname +% as argument. This is the last step of \thisrow. It allows indirect +% access by translating colnames to col indices in '\pgfplotstableread to listener' +\def\pgfplotstable@thisrow@impl#1#2#3{% + \pgfutil@ifundefined{#2#1}% + {% + % WARNING : this code has been REPLICATED in + % *** \pgfplotstablereadgetptrtocolname *** + % *** \pgfplotstablegetcolumnbyname *** + % *** \pgfplotstableresolvecolname *** + % *** \pgfplotstablereadvalueofcolname *** + \pgfkeysifdefined{/pgfplots/table/alias/#1}{% + \pgfutil@ifundefined{#2\pgfkeysvalueof{/pgfplots/table/alias/#1}}{% + \pgfplotstable@undefinedtext{\pgfkeysvalueof{/pgfplots/table/alias/#1}}% + }{% + #3{\csname #2\pgfkeysvalueof{/pgfplots/table/alias/#1}\endcsname}% + }% + }{% + \pgfplotstable@undefinedtext{#1}% + }% + }% + {% + #3{\csname #2#1\endcsname}% + }% +}% +\def\pgfplotstable@thisrow@impl@#1{#1}% + % \pgfplotstablereadgetptrtocolname{<name>}{\ptr} % Creates some sort of "pointer" to the column named <name>. This % pointer can than be used every time a new line has been reported to -% the listener. IT works like this: +% the listener. It works like this: % % \let\ptr=\pgfutil@empty % \def\macro{% @@ -1725,6 +2341,11 @@ % \pgfplotstableread{<file>} to listener<\macro> % % -> will evaluate \macro foreach row. +% +% The advantage of such a prepared pointer over \thisrow{#1} or +% \getthisrow{#1} is simply efficiency and sanity checking: the checks +% are done at the time of pointer creation, dereferencing the pointer +% is fast. \def\pgfplotstablereadgetptrtocolname@#1#2{% % Implementation note: it is necessary to replicate code becuase % in this context, the table structure is NOT available. @@ -1737,13 +2358,14 @@ % *** \pgfplotstablereadgetptrtocolname *** % *** \pgfplotstablegetcolumnbyname *** % *** \pgfplotstableresolvecolname *** + % *** \pgfplotstablereadvalueofcolname *** % \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.}% + \pgfplotsthrow{no such element}{#2}{Sorry, could not retrieve aliased column '\pgfplotstable@loc@TMPa' from table '\pgfplotstableread@filename'. The original request was for '#1', which does not exist either.}\pgfeov% \def#2{0}% }{% \edef#2{\csname pgfplotstblread@colindex@for@name\pgfplotstable@loc@TMPa\endcsname}% @@ -1751,9 +2373,9 @@ }{% \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. You can do this using the 'read completely' key, see the manual for details.}% + \pgfplotstable@error{Sorry, '\pgfplotstable@loc@TMPa' from table '\pgfplotstableread@filename' can't be evaluated in this context. Please prepare the table before using it here. You can do this using the 'read completely' key, see the manual for details.}% }{% - \pgfplots@error{Sorry, could not retrieve column '#1' from table '\pgfplotstableread@filename'. Please check spelling (or introduce name aliases).}% + \pgfplotsthrow{no such element}{#2}{Sorry, could not retrieve column '#1' from table '\pgfplotstableread@filename'. Please check spelling (or introduce name aliases).}\pgfeov% }% \def#2{0}% }% @@ -1770,24 +2392,30 @@ % writes the current value of <\ptr> to <\content>. The pointer <\ptr> % must be initialised with \pgfplotstablereadgetptrtocolname \let\pgfplotstablereadevalptr@=\pgfplotstablereadgetcolindex@ + +% \pgfplotstablereadvalueofptr{<\ptr>} -> expands to the pointers value. +% +% The pointer \ptr must be initialised with +% \pgfplotstablereadgetptrtocolname. +\let\pgfplotstablereadvalueofptr@=\pgfplotstablereadvalueofcolindex@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \long\def\pgfplotstableread@impl@nextrow@NEXT@listener#1{% - \expandafter\def\csname pgfplotstblread@colcontent@no\the\pgfplotstableread@curcol\endcsname{#1}% - \advance\pgfplotstableread@curcol by1\relax + \expandafter\def\csname pgfplotstblread@colcontent@no\thepgfplotstableread@curcol\endcsname{#1}% + \pgfplotstableread@countadvance\pgfplotstableread@curcol } \long\def\pgfplotstableread@impl@nextrow@NEXT#1{% -%\pgfplots@message{Inserting '#1' at (\the\pgfplotstableread@lineno, \the\pgfplotstableread@curcol).}% - \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols +%\pgfplots@message{Inserting '#1' at (\thepgfplotstableread@lineno, \thepgfplotstableread@curcol).}% + \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax \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 + \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\thepgfplotstableread@curcol\endcsname + \pgfplotstableread@countadvance\pgfplotstableread@curcol \else \begingroup \t@pgfplots@tokc={#1}% - \pgfplots@error{Table '\pgfplotstableread@filename' has too much columns in line \the\pgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. Please verify that every cell entry is separated correctly (use braces {<cell entry>} if necessary). This error is not critical}% + \pgfplotstable@error{Table '\pgfplotstableread@filename' has too much columns in line \thepgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. Please verify that every cell entry is separated correctly (use braces {<cell entry>} if necessary). This error is not critical}% \endgroup \fi } @@ -1795,30 +2423,28 @@ \long\def\pgfplotstableread@impl@collectcolnames@NEXT#1{% -%\pgfplots@message{Got column name no \the\pgfplotstableread@curcol\ as '#1'}% +%\pgfplots@message{Got column name no \thepgfplotstableread@curcol\ as '#1'}% \pgfutil@ifundefined{pgfplotstableread@impl@COLNAME@#1}{% \def\pgfplotstable@loc@TMPa{#1}% - }{% generate unique column names + }{% generate unique column names warning: \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}% + \edef\pgfplotstable@loc@TMPa{#1--index\thepgfplotstableread@curcol}% }% \expandafter\def\csname pgfplotstableread@impl@COLNAME@#1\endcsname{foo}% remember this name. \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames@glob \ifpgfplots@tableread@to@listener % create an associative container colindex -> colname % for use in a listener. - \def\pgfplots@loc@TMPb{% - \expandafter\def\csname pgfplotstblread@colindex@for@name#1\endcsname}% - \expandafter\pgfplots@loc@TMPb\expandafter{\the\pgfplotstableread@curcol}% + \expandafter\edef\csname pgfplotstblread@colindex@for@name#1\endcsname{\thepgfplotstableread@curcol}% \fi - \advance\pgfplotstableread@curcol by1\relax + \pgfplotstableread@countadvance\pgfplotstableread@curcol } \long\def\pgfplotstableread@impl@countcols@and@identifynames@NEXT#1{% - \advance\pgfplotstableread@curcol by1\relax + \pgfplotstableread@countadvance\pgfplotstableread@curcol \ifpgfplotstable@search@header \ifpgfplotstableread@curline@contains@colnames \else @@ -1888,7 +2514,7 @@ \pgfplotstableread@NEXT } -\def\pgfplotstable@error#1{\pgfplots@error{#1}}% +\def\pgfplotstable@error#1{\pgfplotsthrow{unsupported operation}{#1}\pgfeov}% \def\pgfplotstableset{% @@ -1898,7 +2524,7 @@ % Accepts a macro #1 which contains an argument denoting a column % name. % -% It checks whether #1 starts with '#', indicating that it is actually +% It checks whether #1 starts with '[index]', indicating that it is actually % a column INDEX. If that is the case, % \ifpgfplotstableread@foundcolnames is set to false and the index is % returned into #1. @@ -1924,19 +2550,21 @@ \def\pgfplotstable@loc@TMPa{#1}% \ifx\pgfplotstable@loc@TMPa\pgfplotstabletypeset@is@colname@index@@ \pgfplotstableread@foundcolnamesfalse - \def\pgfplotstable@loc@TMPa{#2}% + \edef\pgfplotstable@loc@TMPa{#2}% \else \pgfplotstableread@foundcolnamestrue \fi }% \def\pgfplotstabletypeset@is@colname@name#1\pgfplotstable@EOI{}% -\def\pgfplotstabletypeset@getfinalentry#1#2{% +\long\def\pgfplotstabletypeset@getfinalentry#1#2{% \begingroup \def\pgfplotstablepartno{0}% \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}% + \pgfkeyssetvalue{/pgfplots/table/@unprocessed cell content}{#1}% \pgfkeysvalueof{/pgfplots/table/preproc cell content/.@cmd}#1\pgfeov \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% + \pgfkeyslet{/pgfplots/table/@preprocessed cell content}\pgfmathresult% % \pgfkeysgetvalue{/pgfplots/table/assign cell content/.@cmd}\pgfplotstable@assigncell \expandafter\pgfplotstable@assigncell\pgfmathresult\pgfeov @@ -1945,17 +2573,18 @@ \ifx\pgfplotstable@postproccellcontent\pgfplotstable@postproccellcontent@EMPTY \else % apply postprocessing to final cell content. + \def\pgfplotstabletypeset@rawinput{#1}% + % % 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 + \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov \fi \fi \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult% @@ -1965,7 +2594,7 @@ }% % This routine invokes 'postproc cell content' for columns which -% contain the column separate '&'. +% contain the column separator '&'. % % #1 is the formatted number, the result of 'dec sep align % #3 is the (unformatted) input number. @@ -2033,6 +2662,8 @@ % \pgfplotslistnewempty#2 % }{}% %-------------------------------------------------- + \def\pgfplotstablename{#2}% + \def\pgfplotstablecolname{\pgfplotstable@colname}% \def\pgfplotstablecol{\the\c@pgfplotstable@colindex}% \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}% \def\pgfplotstablecols{\the\c@pgfplotstable@numcols}% @@ -2054,9 +2685,9 @@ \ifx\pgfplotstable@outfilename\pgfutil@empty \else \pgfplots@logfileopen{\pgfplotstable@outfilename}% - \openin1=\pgfplotstable@outfilename\relax - \ifeof1 \else\pgfplotstabletypeset@includeoutfilestrue \fi - \closein1 + \openin\r@pgfplots@reada=\pgfplotstable@outfilename\relax + \ifeof\r@pgfplots@reada \else\pgfplotstabletypeset@includeoutfilestrue \fi + \closein\r@pgfplots@reada \fi \fi \fi @@ -2116,6 +2747,7 @@ \def\pgfplotstable@firstnumrows{-1}% \c@pgfplotstable@numrows=-1\relax \c@pgfplotstable@colindex=0\relax + % FOREACH COLUMN: \pgfplotslistforeach\pgfplotstable@colnames\as\pgfplotstable@colname{% \c@pgfplotstable@rowindex=0\relax \pgfplotstable@is@colname\pgfplotstable@colname @@ -2153,6 +2785,8 @@ \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last column}% \fi + % temporarily restore it: we may need it in row predicates: + \global\advance\c@pgfplotstable@colindex by-1\relax \ifpgfplotstable@disable@rowcolstyles % ok, then don't check for 'columns/<name>' and % 'display columns/<index>': @@ -2177,13 +2811,9 @@ \let\pgfplotstable@colname@out=\pgfplotstable@colname \fi \expandafter\pgfplotstabletypeset@assign@final@colname\expandafter{\pgfplotstable@colname@out}\pgfplotstable@colname@out - {\globaldefs=1 - \expandafter\pgfplotslistpushback\pgfplotstable@colname@out\to\pgfplotstabletypeset@final@colnames - }% + \expandafter\pgfplotslistpushbackglobal\pgfplotstable@colname@out\to\pgfplotstabletypeset@final@colnames \pgfkeysgetvalue{/pgfplots/table/column type}{\pgfplotstable@coltype}% - {\globaldefs=1 - \expandafter\pgfplotslistpushback\pgfplotstable@coltype\to\pgfplotstabletypeset@final@coltypes - }% + \expandafter\pgfplotslistpushbackglobal\pgfplotstable@coltype\to\pgfplotstabletypeset@final@coltypes % \pgfplotslistnewempty\pgfplotstable@col@processed \c@pgfplotstable@counta=0 @@ -2194,7 +2824,8 @@ \ifpgfplotstableuserow \ifnum\pgfplotstable@firstnumrows=-1\relax \else - \ifnum\c@pgfplotstable@counta=\pgfplotstable@firstnumrows + \ifnum\c@pgfplotstable@counta<\pgfplotstable@firstnumrows\relax + \else \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)}% @@ -2215,9 +2846,8 @@ % balance columns: \pgfplotstable@insertemptycells@forbalance \fi - {\globaldefs=1 - \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols - }% + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols + \global\advance\c@pgfplotstable@colindex by1\relax }% % % Ok, I have now everything which will come into the final table. @@ -2287,6 +2917,7 @@ \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}% \edef\pgfplotstable@curline{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% % + \def\pgfplotstablecolname{\pgfplotstable@colname@out}% \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@colnames\as\pgfplotstable@colname@out{% % \advance\c@pgfplotstable@colindex by1\relax @@ -2328,6 +2959,7 @@ \else \pgfplots@loop@CONTINUEfalse \fi + \def\pgfplotstablecolname{\pgfplotstable@error{Sorry, you can't evaluate \string\pgfplotstablecolname\space in this context.}}% \pgfutil@loop \ifpgfplots@loop@CONTINUE \pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed @@ -2421,8 +3053,8 @@ \immediate\closeout\pgfplotstable@outfile \fi %\message{I have now \meaning\pgfplotstable@result.}% - \def\pgfplotstablecol{\pgfplots@error{Sorry, you can't access the \string\pgfplotstablecol\ in this context. It is ONLY valid during the preparation routines (please check the 'display columns/<index>' style in the manual).}}% - \def\pgfplotstablerow{\pgfplots@error{Sorry, you can't access the \string\pgfplotstablerow\ in this context. It is ONLY valid during the preparation routines (please check the 'every row no <index>' style).}}% + \def\pgfplotstablecol{\pgfplotstable@error{Sorry, you can't access the \string\pgfplotstablecol\ in this context. It is ONLY valid during the preparation routines (please check the 'display columns/<index>' style in the manual).}}% + \def\pgfplotstablerow{\pgfplotstable@error{Sorry, you can't access the \string\pgfplotstablerow\ in this context. It is ONLY valid during the preparation routines (please check the 'every row no <index>' style).}}% \ifpgfplotstabletypesetresult \pgfplotstable@result \fi @@ -2444,7 +3076,11 @@ \def\pgfplotstablecreatecol@opt[#1]#2#3{% \begingroup - \pgfplotstableset{columns=,#1}% + \pgfplotstableset{columns=,#1,% + /pgf/fpu/handlers/empty number/.code 2 args={% + \pgfmathfloatcreate{0}{0.0}{0}% + }% + }% \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}% \ifx\pgfplotstable@colnames\pgfutil@empty \pgfplotstablegetcolumnlist#3\to\pgfplotstable@colnames @@ -2478,9 +3114,9 @@ \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\prevrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@prev@}{\pgfplotstable@thisrow@impl@}}% + \def\thisrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@cur@}{\pgfplotstable@thisrow@impl@}}% + \def\nextrow##1{\pgfplotstable@thisrow@impl{##1}{pgfplotstablecreate@next@}{\pgfplotstable@thisrow@impl@}}% \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}% @@ -2591,10 +3227,14 @@ % \pgfqkeys{/pgfplots/table/create col/function graph cut}{#2}% \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/x}\pgfplotstable@fgc@x + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/y}\pgfplotstable@fgc@y \ifx\pgfplotstable@fgc@table\pgfutil@empty + % no table here, ok. \else % ok, we need to query (or load) a table! - \pgfplotstable@isloadedtable{\pgfplotstable@fgc@table}{% + \expandafter\pgfplotstable@isloadedtable\expandafter{\pgfplotstable@fgc@table}{% + \expandafter\let\expandafter\pgfplotstable@fgc@table\pgfplotstable@fgc@table }{% \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}% }% @@ -2607,6 +3247,17 @@ \fi \let\pgfplotstable@fgc@eps=\pgfmathresult \pgfplots@assign@list\pgfmathaccumb{#3}% + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/foreach}\pgfplotstable@fgc@foreach@ + \ifx\pgfplotstable@fgc@foreach@\pgfutil@empty + \else + \edef\pgfplotstable@fgc@foreach@process@append{x={\pgfplotstable@fgc@x},y={\pgfplotstable@fgc@y}}% + % we have something like + % foreach={\d in {1,2,3,4}}{table\d} + % -> process it! + % This will modify \pgfmathaccumb + \expandafter\pgfplotstable@fgc@foreach@process\pgfplotstable@fgc@foreach@\pgfplots@EOI + \pgfkeyssetvalue{/pgfplots/table/create col/function graph cut/foreach}{}% + \fi % \pgfkeysdef{/pgfplots/table/create col/assign}{% %\message{working on next cell ...}% @@ -2615,6 +3266,8 @@ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty% \else \pgfplotslistpopfront\pgfmathaccumb\to\pgfmathresult +%\message{working on next cell: \meaning\pgfmathresult ...}% + \global\let\pgfplotstable@fgc@foreach=\pgfutil@empty \begingroup % set local keys: \def\pgfplots@loc@TMPa{\pgfqkeys{/pgfplots/table/create col/function graph cut}}% @@ -2623,45 +3276,90 @@ \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/x}\pgfplotstable@fgc@x \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/y}\pgfplotstable@fgc@y - \ifx\pgfplotstable@fgc@table\pgfutil@empty - \else - % ok, we need to query (or load) a table! - \pgfplotstable@isloadedtable{\pgfplotstable@fgc@table}{% - }{% - \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}% - }% - \fi - \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@x}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@x@col - \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@y}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@y@col - % - % search for epsilon in the y values: - \expandafter\pgfplotstable@fgc@findintervalwitheps\expandafter{\csname pgfplotstable@fgc@#4@col\endcsname}{\csname pgfplotstable@fgc@#4mode\endcsname}% - \ifx\pgfplotstable@fgc@second\pgfutil@empty - \let\pgfmathresult=\pgfutil@empty - \else - % - % acquire the associated x values: - \expandafter\pgfplotstable@fgc@getassociated\expandafter{\csname pgfplotstable@fgc@#5@col\endcsname}{\csname pgfplotstable@fgc@#5mode\endcsname}% - % - % Interpolate: - \pgfmathparse{ - \pgfplotstable@fgc@abscissafirst + - (\pgfplotstable@fgc@eps - \pgfplotstable@fgc@first) / (\pgfplotstable@fgc@second-\pgfplotstable@fgc@first) - * (\pgfplotstable@fgc@abscissasecond - \pgfplotstable@fgc@abscissafirst) }% - \if\pgfplotstable@fgc@xmode1 - \pgfmathfloatexp@{\pgfmathresult}% + \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/foreach}\pgfplotstable@fgc@foreach@ + \ifx\pgfplotstable@fgc@foreach@\pgfutil@empty + \ifx\pgfplotstable@fgc@table\pgfutil@empty + \else + % ok, we need to query (or load) a table! + \expandafter\pgfplotstable@isloadedtable\expandafter{\pgfplotstable@fgc@table}{% + \expandafter\let\expandafter\pgfplotstable@fgc@table\pgfplotstable@fgc@table + }{% + \expandafter\pgfplotstableread\expandafter{\pgfplotstable@fgc@table}{\pgfplotstable@fgc@table}% + }% \fi - \pgflibraryfpuifactive{\pgfmathfloattosci{\pgfmathresult}}{}% + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@x}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@x@col + \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@fgc@y}\of\pgfplotstable@fgc@table\to\pgfplotstable@fgc@y@col + % + % search for epsilon in the y values: + \expandafter\pgfplotstable@fgc@findintervalwitheps\expandafter{\csname pgfplotstable@fgc@#4@col\endcsname}{\csname pgfplotstable@fgc@#4mode\endcsname}% + \ifx\pgfplotstable@fgc@second\pgfutil@empty + \let\pgfmathresult=\pgfutil@empty + \else + % + % acquire the associated x values: + \expandafter\pgfplotstable@fgc@getassociated\expandafter{\csname pgfplotstable@fgc@#5@col\endcsname}{\csname pgfplotstable@fgc@#5mode\endcsname}% + % + % Interpolate: + \pgfmathparse{ + \pgfplotstable@fgc@abscissafirst + + (\pgfplotstable@fgc@eps - \pgfplotstable@fgc@first) / (\pgfplotstable@fgc@second-\pgfplotstable@fgc@first) + * (\pgfplotstable@fgc@abscissasecond - \pgfplotstable@fgc@abscissafirst) }% + \if\pgfplotstable@fgc@xmode1 + \pgfmathfloatexp@{\pgfmathresult}% + \fi + \pgflibraryfpuifactive{\pgfmathfloattosci{\pgfmathresult}}{}% %\message{FGC: found \pgfplotstable@fgc@eps\space in no \pgfplotstable@fgc@index; \pgfplotstable@fgc@first:\pgfplotstable@fgc@second; lastwasless=\pgfplotstable@fgc@lastwasless; abscissa interval = \pgfplotstable@fgc@abscissafirst:\pgfplotstable@fgc@abscissasecond; result = \pgfmathresult}% + \fi + \else + \global\let\pgfplotstable@fgc@foreach=\pgfplotstable@fgc@foreach@ + \edef\pgfmathresult{x={\pgfplotstable@fgc@x},y={\pgfplotstable@fgc@y}}% \fi % \pgfmath@smuggleone\pgfmathresult \endgroup - \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \ifx\pgfplotstable@fgc@foreach\pgfutil@empty + \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult% + \else + % we have something like + % foreach={\d in {1,2,3,4}}{table\d} + % -> process it! + % This will modify \pgfmathaccumb + \let\pgfplotstable@fgc@foreach@process@append=\pgfmathresult + \expandafter\pgfplotstable@fgc@foreach@process\pgfplotstable@fgc@foreach\pgfplots@EOI + \fi \fi }% }% +\def\pgfplotstable@fgc@foreach@process{% + \pgfutil@ifnextchar\bgroup + {\pgfplotstable@fgc@foreach@process@a}{% + \pgfplotstable@fgc@foreach@process@error}% +}% +\def\pgfplotstable@fgc@foreach@process@a#1{% + \pgfutil@ifnextchar\bgroup + {\pgfplotstable@fgc@foreach@process@b{#1}}{% + \pgfplotstable@fgc@foreach@process@error}% +}% +\def\pgfplotstable@fgc@foreach@process@error#1\pgfplots@EOI{% + \def\pgfplots@loc@TMPa{#1}% + \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, I expected two arguments for /pgfplots/table/create col/function graph cut/foreach, but I found 'foreach=\pgfplots@loc@TMPb'. Perhaps the braces are not as expected?}\pgfeov% +}% +\def\pgfplotstable@fgc@foreach@process@b#1#2#3\pgfplots@EOI{% + \global\pgfplotslistnewempty\pgfplots@glob@TMPa + \begingroup + \foreach #1 {% + \edef\pgfplots@loc@TMPa{#2}% + \expandafter\pgfplotslistpushfrontglobal\pgfplots@loc@TMPa\to\pgfplots@glob@TMPa + }% + \endgroup + \pgfplotslistforeachungrouped\pgfplots@glob@TMPa\as\pgfplots@loc@TMPa{% + \edef\pgfplots@loc@TMPa{table={\pgfplots@loc@TMPa},\pgfplotstable@fgc@foreach@process@append}% + \expandafter\pgfplotslistpushfront\pgfplots@loc@TMPa\to\pgfmathaccumb + }% +}% + % #1 : the coordinate list to query % #2 : the mode % @@ -2745,4 +3443,135 @@ \global\def\pgfplotstable@fgc@lastwasless{#2}% }% + + +\def\pgfplotstabletranspose@[#1]#2#3{% + %\begingroup is already in \pgfplotstabletranspose + \def\pgfplotstable@loc@TMPa{#1}% + \ifx\pgfplotstable@loc@TMPa\pgfutil@empty + \else + \pgfplotstableset{#1}% + \fi + % + \pgfkeysgetvalue{/pgfplots/table/colnames from}\pgfplotstabletranspose@outcolnames + \pgfkeysgetvalue{/pgfplots/table/input colnames to}\pgfplotstabletranspose@incolnames + \pgfkeysgetvalue{/pgfplots/table/columns}\pgfplotstable@colnames + % + \ifx\pgfplotstable@colnames\pgfutil@empty + \pgfplotstableforeachcolumn{#3}\as\pgfplots@colname{% + \ifnum\pgfplotstablecol=0 + \let\pgfplotstable@colnames=\pgfplots@colname + \else + \t@pgfplots@toka=\expandafter{\pgfplots@colname}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colnames}% + \edef\pgfplotstable@colnames{\the\t@pgfplots@tokb,\the\t@pgfplots@toka}% + \fi + }% + \fi + % + % sanity checking: + \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty + \else + \def\pgfplotstable@loc@TMPa{\expandafter\pgfutil@in@\expandafter{\pgfplotstabletranspose@outcolnames}}% + \expandafter\pgfplotstable@loc@TMPa\expandafter{\pgfplotstable@colnames}% + \ifpgfutil@in@ + \else + % insert the 'colnames from' column into 'columns': + \pgfplots@warning{table transposition: the 'colnames from=\pgfplotstabletranspose@outcolnames' is not part of 'columns'. Adding it.}% + \t@pgfplots@toka=\expandafter{\pgfplotstabletranspose@outcolnames}% + \t@pgfplots@tokb=\expandafter{\pgfplotstable@colnames}% + \edef\pgfplotstable@colnames{\the\t@pgfplots@tokb,\the\t@pgfplots@toka}% + \fi + \fi + % + \global\pgfplotslistnewempty\pgfplotstable@colnames@glob + % this thing counts output columns: + \let\c@pgfplotstable@numoutcols=\c@pgf@countd + \c@pgfplotstable@numoutcols=0 + \let\c@pgfplotstable@rowindex=\c@pgf@counta + \c@pgfplotstable@rowindex=0 + % + \ifx\pgfplotstabletranspose@incolnames\pgfutil@empty + \else + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstabletranspose@incolnames}\to\pgfplotstable@colnames@glob + \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}% + \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@0\endcsname + \advance\c@pgfplotstable@numoutcols by1 + \fi + \def\pgfplotstable@isfirstcol{1}% + \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotstable@colnames}\as\pgfplots@colname{% + \c@pgfplotstable@rowindex=0 + \ifx\pgfplotstabletranspose@incolnames\pgfutil@empty + \else + \def\pgfplotstabletranspose@useit{1}% + \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty + \else + \ifx\pgfplotstabletranspose@outcolnames\pgfplots@colname + \def\pgfplotstabletranspose@useit{0}% + \fi + \fi + \if1\pgfplotstabletranspose@useit + \expandafter\pgfplotslist@assembleentry\expandafter{\pgfplots@colname}\into\t@pgfplots@tokc + \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}% + \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname + \advance\c@pgfplotstable@rowindex by1 + \fi + \fi + % + \pgfplotstableforeachcolumnelement\pgfplots@colname\of#3\as\pgfplots@cell{% + \if1\pgfplotstable@isfirstcol + % prepare a new column for the output: + \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}% + \expandafter\pgfplots@loc@TMPa\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname + % + \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty + \edef\pgfplotstable@loc@TMPa{\pgfplotstablerow}% + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@colnames@glob + \fi + \advance\c@pgfplotstable@numoutcols by1 + \fi + \def\pgfplotstabletranspose@useit{1}% + \ifx\pgfplotstabletranspose@outcolnames\pgfutil@empty + \else + \ifx\pgfplotstabletranspose@outcolnames\pgfplots@colname + \pgfutil@ifundefined{pgfplotstabletranspose@@\pgfplots@cell}{% + }{% + \let\pgfplots@loc@TMPa=\pgfplots@cell + \pgfplotsthrow{non unique colname}{\pgfplots@loc@TMPa}{Sorry, 'colnames from=\pgfplotstabletranspose@outcolnames' doesn't yield unique column names (`\pgfplots@cell' comes twice)}\pgfeov% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \edef\pgfplots@cell{row no \pgfplotstablerow}% + \fi + }% + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@cell}\to\pgfplotstable@colnames@glob + \expandafter\def\csname pgfplotstabletranspose@@\pgfplots@cell\endcsname{1}% + \def\pgfplotstabletranspose@useit{0}% + \fi + \fi + \if1\pgfplotstabletranspose@useit + % append everything to the output column with index + % \pgfplotstablerow + \expandafter\pgfplotslist@assembleentry\expandafter{\pgfplots@cell}\into\t@pgfplots@tokc + \def\pgfplotstableread@TMP{\expandafter\pgfplotsapplistXpushback\expandafter{\the\t@pgfplots@tokc}\to}% + \expandafter\pgfplotstableread@TMP\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname + \advance\c@pgfplotstable@rowindex by1 + \fi + }% + \def\pgfplotstable@isfirstcol{0}% + }% + % + % flush the buffers of the applistX things: + \c@pgfplotstable@rowindex=0 + \pgfutil@loop + \ifnum\c@pgfplotstable@rowindex<\c@pgfplotstable@numoutcols + \expandafter\pgfplotsapplistXflushbuffers\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@rowindex\endcsname + \advance\c@pgfplotstable@rowindex by1 + \pgfutil@repeat + % finalize the global buffers: + \def\pgfplotsscanlinelength{-1}% + \edef\pgfplots@loc@TMPa{\pgfplotstablenameof{#3}_transposed}% + \expandafter\pgfplotstable@copy@to@globalbuffers@simple\expandafter{\pgfplots@loc@TMPa}% + \endgroup + \pgfplotstable@copy@globalbuffers@to{#2}% +}% + \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 index 26e55e00402..c63985e38c4 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex @@ -9,21 +9,39 @@ % The development of pgfplots and pgf is intermingled, so pgfplots % always uses up-to-date pgf CVS versions - the relevant complements between % PGF 2.00 and PGF CVS are loaded here: -%\pgfutil@ifundefined{pgfmathfloatparsenumber@handleerror}{% -\pgfkeysifdefined{/pgf/text mark}{\relax}{% - \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 -} - {\relax} +% +% #1: for backwards compatibility +% #2: for normal processing. +\def\pgfplots@ifneedspgfcompabitibilitycode#1#2{% + %\pgfkeysifdefined{/handlers/.search also/.@cmd}{#2}{#1}% + \pgfutil@ifundefined{pgfutilsolvetwotwoleq}{#1}{#2}% +}% + +\pgfplots@ifneedspgfcompabitibilitycode + {% + \immediate\write16{Package pgfplots: loading complementary code for your PGF version...} + \input pgfplotsoldpgfsupp_misc.code.tex + \let\pgfkeysloaded=\undefined + % FIXME: this does also load pgfkeysfiltered.code.tex again: + \input pgfplotsoldpgfsupp_pgfkeys.code.tex + \input pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex + \input pgfplotsoldpgfsupp_pgfmathfloat.code.tex + \input pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex + \input pgfplotsoldpgfsupp_pgflibraryfpu.code.tex + }% + {% + \pgfplots@iffileexists{pgflibraryfpu.code.tex}{% + \usepgflibrary{fpu}% + }{% + \immediate\write16{Package pgfplots: loading FPU library which doesn't appear to exist in your PGF version...} + \input pgfplotsoldpgfsupp_pgflibraryfpu.code.tex + }% + }% -\pgfplots@iffileexists{pgflibraryfpu.code.tex}{% - \usepgflibrary{fpu}% -}{% - \immediate\write16{Package pgfplots: loading FPU library which doesn't appear to exist in your PGF version...} +\pgfutil@ifundefined{pgfmathdeclarepseudoconstant}{ + \immediate\write16{Package pgfplots: loading complementary arithmetics for your pgf version...} \input pgfplotsoldpgfsupp_pgflibraryfpu.code.tex -}% +} +{}% \endinput 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 index 749c547563a..132240e77c7 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex @@ -1,47 +1,191 @@ % ====================================================== % 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% +% ====================================================== + +% from pgfutil-common.tex: + +% Usage: +% \pgfutilstrreplace{<token>}{<replacement>}{<string>} +% +% -> will assign the modified string into \pgfretval. +% +% #1: the string to search (one or more tokens) +% #2: zero, one or more tokens which will be inserted instead of '#1'. +% #3: the string to search in +\long\def\pgfutilstrreplace#1#2#3{% + \def\pgfretval{}% + \long\def\pgfutil@search@and@replace@@##1#1##2\pgf@EOI{% + \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval ##1#2}% + \pgfutil@search@and@replace@loop{#1}{##2}% + }% + \pgfutil@search@and@replace@loop{#1}{#3}% } +\long\def\pgfutil@search@and@replace@loop#1#2{% + \pgfutil@in@{#1}{#2}% + \ifpgfutil@in@ + \def\pgf@loc@TMPa{\pgfutil@search@and@replace@@ #2\pgf@EOI}% + \else + \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #2}% + \let\pgf@loc@TMPa=\relax + \fi + \pgf@loc@TMPa +}% +% Solves a linear equation system of size 2x2 using gauss elimination. +% +% It employs TeX register arithmetics to do so. +% #1: should contain 4 sets of braces with matrix entries, +% {<a11>}{<a12>} +% {<a21>}{<a22>} +% where each entry should be a number without unit. +% #2: should contain 2 sets of braces with the right-hand-side, +% {<r1>}{<r2>} +% where each entry should be a number without unit. +% +% It will assign \pgfmathresult to contain two sets of braces with the +% result. +% +% Example: +% \pgfutilsolvetwotwoleq{ +% {0.24}{1} +% {-0.97}{0} +% }{ +% {-7} +% {18} +% } +% -> yields \pgfmathresult={−18.55618}{−2.54642} +% +% The algorithm employs column pivotisation. +\def\pgfutilsolvetwotwoleq#1#2{% + \begingroup + \dimendef\aa=0 + \dimendef\ab=1 + \dimendef\ba=2 + \dimendef\bb=3 + \dimendef\ra=4 + \dimendef\rb=5 + \dimendef\tmpa=6 + \dimendef\tmpb=7 + \edef\pgf@temp{#1}% + \expandafter\pgfutilsolvetwotwoleq@A\pgf@temp + \edef\pgf@temp{#2}% + \expandafter\pgfutilsolvetwotwoleq@r\pgf@temp + % + \pgfutilsolvetwotwoleq@ifislarger\aa\ba{% + % identity "permutation": + \def\Pa{a}% + \def\Pb{b}% + }{% + % permutation matrix: switch rows! + \def\Pa{b}% + \def\Pb{a}% + }% + % \pivot := 1/aa + \pgfmathreciprocal@ + {\csname m\Pa a\endcsname}% + \let\pivot=\pgfmathresult + % + % \factor := 1/aa * ba + \csname \Pb a\endcsname=\pivot\csname \Pb a\endcsname + \edef\factor{\expandafter\pgf@sys@tonumber\csname \Pb a\endcsname}% + % + % bb -= ba/aa * ab + \tmpa=-\factor\csname \Pa b\endcsname + \advance\csname \Pb b\endcsname by\tmpa + % + % rb -= ba/aa * ra + \tmpa=-\factor\csname r\Pa\endcsname + \advance\csname r\Pb\endcsname by\tmpa + % + % xb := rb / bb (the modified rb and modified bb!) + \pgfmathdivide@ + {\expandafter\pgf@sys@tonumber\csname r\Pb\endcsname} + {\expandafter\pgf@sys@tonumber\csname \Pb b\endcsname}% + \expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult + % + % ra -= xb * ab + \tmpa=\csname pgfmathresult\Pb\endcsname\csname \Pa b\endcsname + \advance\csname r\Pa\endcsname by-\tmpa + % + % xa := 1/aa * ra (the modified ra!) + \tmpa=\pivot\csname r\Pa\endcsname + \expandafter\edef\csname pgfmathresult\Pa\endcsname{\pgf@sys@tonumber\tmpa}% + % + \edef\pgfmathresult{% + {\csname pgfmathresult\Pa\endcsname}% + {\csname pgfmathresult\Pb\endcsname}% + }% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfutilsolvetwotwoleq@ifislarger#1#2#3#4{% + \tmpa=#1 + \ifdim\tmpa<0pt + \multiply\tmpa by-1 + \fi + \tmpb=#2 + \ifdim\tmpb<0pt + \multiply\tmpb by-1 + \fi + \ifdim\tmpa>\tmpb + #3% + \else + #4% + \fi +}% +\def\pgfutilsolvetwotwoleq@A#1#2#3#4{% + \def\maa{#1}\def\mab{#2}% + \def\mba{#3}\def\mbb{#3}% + \aa=#1pt \ab=#2pt + \ba=#3pt \bb=#4pt +} +\def\pgfutilsolvetwotwoleq@r#1#2{% + \ra=#1pt \rb=#2pt +}% -\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% - }% + +%%%%%%% +%%%%%%% + +% from pgfmoduleshapes.code.tex: +% Invoke an anchor +\def\pgf@sh@reanchor#1#2{% + \pgfutil@ifundefined{pgf@anchor@#1@#2}% {% - \pgfkeysifdefined{\pgfkeyscurrentpath}% - {% - \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% - \pgfkeysvalueof{\pgfkeyscurrentpath}% - \else% - \pgfkeyslet{\pgfkeyscurrentpath}\pgfkeyscurrentvalue% - \fi% - \pgfkeyssuccesstrue% + \pgfutil@ifundefined{pgf@anchor@generic@#2}{% + \pgfmathsetcounter{pgf@counta}{#2}% + \csname pgf@anchor@#1@border\endcsname{\pgfqpointpolar{\c@pgf@counta}{1pt}}% + }{% + \csname pgf@anchor@generic@#2\endcsname{#1}% }% - {\pgfkeyssuccessfalse}% }% + {\csname pgf@anchor@#1@#2\endcsname}% } -% ====================================================== +% Defines a generic anchor, i.e. one which gets the associated shape +% as first argument. +% +% #1: the anchor name. +% #2: the code of the anchor. It may depend upon '##1', the shape's +% name. +% +% The anchor will be defined locally in the current TeX scope. +\def\pgfdeclaregenericanchor#1#2{% + \expandafter\def\csname pgf@anchor@generic@#1\endcsname##1{#2}% +}% + +% from pgfcoretransformations.code.tex : +\def\pgfgettransformentries#1#2#3#4#5#6{% + \edef#1{\pgf@pt@aa}% + \edef#2{\pgf@pt@ab}% + \edef#3{\pgf@pt@ba}% + \edef#4{\pgf@pt@bb}% + \edef#5{\the\pgf@pt@x}% + \edef#6{\the\pgf@pt@y}% +}% +\def\pgfsettransformentries#1#2#3#4#5#6{% + \pgfsettransform{{#1}{#2}{#3}{#4}{#5}{#6}}% +}% % pgfutil@loop (from plain.tex) @@ -75,6 +219,13 @@ \expandafter\gdef\csname pgf@sh@pi@#1\endcsname{\pgfpictureid}% \fi% } +% A "quick" variant of \pgfpointscale which doesn't invoke the math parser for '#1'. +% #1 must be a number without units, no registers are accepted. +\def\pgfqpointscale#1#2{% + \pgf@process{#2}% + \pgf@x=#1\pgf@x% + \pgf@y=#1\pgf@y% +} % ====================================================== \def\pgfutilensuremath#1{% @@ -91,6 +242,11 @@ \tikzoption{jump mark right}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkright} \tikzoption{jump mark left}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkleft} +\def\tikz@plot@samples{25} +\def\tikz@plot@domain{-5:5} +\def\tikz@plot@var{\x} +\def\tikz@plot@samplesat{-5,-4.5833333,...,5} + \tikzoption{mark}{ \def\tikz@plot@mark{#1}% \def\tikz@temp{none}% this check is relatively new @@ -98,8 +254,17 @@ \let\tikz@plot@mark=\pgfutil@empty \fi } + +% the 'pt' suffix is new: +\pgfdeclareplotmark{ball} +{% + \def\tikz@shading{ball}% + \shade (0pt,0pt) circle (\pgfplotmarksize);% +} + % the 'every mark' style is new: \tikzset{ + no marks/.style={mark=none},% every mark/.style={}, mark options/.style={% every mark/.style={#1}% @@ -183,14 +348,19 @@ \newif\ifpgfmarktext@usetikznode \pgfkeys{ /pgf/text mark/.initial=p, - /pgf/text mark/style/.initial=, - /pgf/text mark/as node/.is if=pgfmarktext@usetikznode, - /pgf/text mark/.default=true, + /pgf/text mark style/.initial=, + /pgf/text mark as node/.is if=pgfmarktext@usetikznode, + /pgf/text mark as node/.default=true, + % + % backw. compat: the extra search path confuses the '.unknown' + % handlers, so this here is deprecated: + /pgf/text mark/style/.style={/pgf/text mark style={#1}},% + /pgf/text mark/as node/.style={/pgf/text mark as node=#1},% }% \pgfdeclareplotmark{text} { - \pgfkeysgetvalue{/pgf/text mark/style}\pgfmarktext@style + \pgfkeysgetvalue{/pgf/text mark style}\pgfmarktext@style \pgfkeysgetvalue{/pgf/text mark}\pgfmarktext@ \ifpgfmarktext@usetikznode \expandafter\node\expandafter[\pgfmarktext@style]{\pgfmarktext@}; @@ -232,3 +402,16 @@ \pgfmatrixbegincode% }% } + +% From pgfmoduleplot.code.tex: +{ + \catcode`\%=12 + \catcode`\"=12 + \xdef\pgf@gnuplot@head@pgf@two@oo#1{set terminal table; set output "#1.table"; set format "%.5f"} + \ifx\pgf@gnuplot@head\pgf@gnuplot@head@pgf@two@oo + \xdef\pgf@gnuplot@head#1{set table "#1.table"; set format "%.5f"} + \else + \xdef\pgf@gnuplot@head{set table \noexpand\pgf@plottablefile@quoted; set format "%.5f"} + \fi +} + diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex new file mode 100644 index 00000000000..6ae79bec9bf --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex @@ -0,0 +1,921 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + +% Copyright 2007 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. + + +% The files pgfkeys.code.tex and pgfkeysfiltered.code.tex are +% perfectly self-contained, except that the catcode of @ +% should be made a letter. + + +% Guard against reading twice +\ifx\pgfkeysloaded\undefined + \let\pgfkeysloaded=\relax +\else + \expandafter\endinput +\fi + +% The purpose of this file is to provide a general settings engine that +% works with all TeX formats and has no save-stack impact + + +% This is useful: + +\def\pgfkeys@ifcsname#1\endcsname#2\else#3\fi{\expandafter\ifx\csname#1\endcsname\relax#3\else#2\fi}% +\ifx\eTeXrevision\undefined% +\else% + \expandafter\let\expandafter\pgfkeys@ifcsname\csname ifcsname\endcsname% +\fi + +\def\pgfkeys@empty{} + +% This also: + +\ifx\PackageError\undefined + \def\pgfkeys@error#1{\immediate\write-1{Package pgfkeys: Error! #1.}}% +\else + \def\pgfkeys@error#1{\PackageError{pgfkeys}{#1}{}}% +\fi + +% Set a key to a value +% +% #1 = key +% #2 = tokens +% +% Description: +% +% This command sets the key to the given tokens. The tokens are stored as +% is and can even contain things like #9. +% +% Keys are organized hierarchically using something similar to Unix +% paths. Thus, a typically key might be called "/tikz/length" or +% "/tikz/length dimension/.@cmd". Some keys starting with a dot are +% special, so they should not be used as normal key names (they are +% similar to Unix files starting with a dot -- you can use them, but +% be careful). +% +% Keys are always local to the current TeX group. +% +% Example: +% +% \pgfkeyssetvalue{/tikz/length}{2cm-3cm} +% \pgfkeyssetvalue{/algo/swap}{{#2}{#1}} + +\long\def\pgfkeyssetvalue#1#2{% + \pgfkeys@temptoks{#2}\expandafter\edef\csname pgfk@#1\endcsname{\the\pgfkeys@temptoks}% +} + + + +% Add text to a key at the end +% +% #1 = key +% #2 = a value to be added at the beginning +% #3 = a value to be added at the end +% +% Description: +% +% This command adds #2 to the definition of the key. The key should +% have been set previously using \pgfkeyssetvalue. +% +% Example: +% +% \pgfkeysaddvalue{/tikz/length}{}{-3cm} + +\long\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% +} + + + +% Makes a key equal a given code +% +% #1 = key +% #2 = a code name +% +% Description: +% +% This command executes a \let command so that a key gets the same +% value as the parameter #2. +% +% Keys are always local to the current TeX group. +% +% Example: +% +% \pgfkeyslet{/algo/swap}{\myswap} + +\def\pgfkeyslet#1#2{% + \expandafter\let\csname pgfk@#1\endcsname#2% +} + + +% Retrieve the code stored in a key into a code +% +% #1 = key +% #2 = code +% +% Description: +% +% This command will set #2 to "point" to the value stored in the key. +% +% Example: +% +% \pgfkeysgetvalue{/tikz/swap}{\myswap} + +\def\pgfkeysgetvalue#1#2{\expandafter\let\expandafter#2\csname pgfk@#1\endcsname} + + + +% Retrieve the value stored in a key +% +% #1 = key +% +% Description: +% +% This command will expand to the value stored in the key. The key +% should previously have been set using \pgfkeyasetkey or \pgfkeyslet. +% +% Example: +% +% The length is \pgfkeysvalue{/tikz/length}. + +\def\pgfkeysvalueof#1{\csname pgfk@#1\endcsname} + + + +% If for testing whether a key exists +% +% #1 = key +% #2 = if-case +% #3 = else-case +% +% Description: +% +% This if will be executed if the key exists. In eTeX mode this works +% like a normal if, in normal TeX mode you need to provide an \else. +% +% Example: +% +% \pgfkeysifdefined{/tikz/length}{key exists}{does not exist} + +\long\def\pgfkeysifdefined#1#2#3{\pgfkeys@ifcsname pgfk@#1\endcsname#2\else#3\fi} + +% Tests whether a key is assignable. For standard keys which just +% store their value, this is identical to \pgfkeysifdefined. +% +% But \pgfkeysifassignable is true for command keys as well (but not +% for handled keys). +\long\def\pgfkeysifassignable#1#2#3{% + \pgfkeysifdefined{#1}% + {#2} + {\pgfkeysifdefined{#1/.@cmd}% + {#2}% + {#3}}% +}% + + + +% Execute settings +% +% #1 = list of settings +% +% Description: +% +% The list of settings should contain comma-separated settings. Each +% setting has the following form: +% +% /path/key=value +% +% The parts "/path/" and "=value" are optional. When the path is not +% specified, the value of the token register "\pgfkeypath" is used. If +% "=value" is missing, the value of the setting "/path/key/.@def" is used +% instead. If this key is set to "\pgfvaluerequired", the key +% "/errors/value required/.@cmd" is executed. Theis error handler, +% like all other error handlers, will get the current key as its first +% parameter (unexpanded) and the current value as its second value +% (also unexpanded). +% +% Any spaces at the beginning and at the end and around the +% equals-sign are removed. The key with the complete path is set to +% the code \pgfcurrentkey. +% +% The setting is then processed according to the following rules: +% +% 1) If the key /path/key/.@cmd" is present, its code is executed +% with the value computed above, followed by \pgfeov (end of +% value). So, to handle +% +% "/stuff/height= 1.5 ," +% +% /stuff/height/.@cmd should be set to some code, that can +% handle the parameter +% +% "1.5\pgfeov" +% +% For instance, saying +% +% \pgfkeys{/stuff/height/.@cmd}{#1\pgfeov}{\def\myheight{#1}} +% +% will do nicely. +% +% 2) Otherwise, if the key /path/key is present, this key is +% set to the value computed above. +% +% 3) Otherwise, if the key /handlers/key/.@cmd is present, it is executed +% with the same parameters as in 1). Additionally, the +% token register \pgfcurrentkeypath will be set to "/path/" and the +% macor \pgfcurrentkeywithoutpath to "key". So, in the above +% example if neither "/stuff/height/.@cmd" nor +% "/stuff/height" is present, but "/handlers/height" is, +% then "/handlers/height" is executed with the parameters: +% +% "1.5\pgfeov" +% +% and \pgfcurrentkey is set to "/stuff/height" and \pgfcurrentkeypath +% is set to "/stuff/" and \pgfcurrentkeywithoutpath to "height". +% +% 4) Otherwise, if the key "/path/.unknown/.@cmd" is present, its code is +% executed with the same parameters as in 3). +% +% 5) Otherwise, the key "/handlers/.unknown/.@cmd" is executed with the same +% parameters as in 1). +% +% After all settings have been processed, the value of the token +% register \pgfdefaultkeypath is set to its original value. Thus, any local +% change of this token register has no effect outside the call. +% +% Example: +% +% \pgfkeys{/tikz/.is family} +% \pgfkeys{/tikz/line width/.cd, +% .def=\pgfsetlinewidth{##1}, +% .set default=.4pt} +% \pgfkeys{tikz,line width=1pt} + +\newtoks\pgfkeys@pathtoks +\def\pgfkeyscurrentpath{\the\pgfkeys@pathtoks} +\newtoks\pgfkeys@temptoks + +\def\pgfkeys@root{/} +\let\pgfkeysdefaultpath\pgfkeys@root + +\def\pgfkeys{\expandafter\pgfkeys@@set\expandafter{\pgfkeysdefaultpath}}% +\long\def\pgfkeys@@set#1#2{% + \let\pgfkeysdefaultpath\pgfkeys@root% + \pgfkeys@parse#2,\pgfkeys@mainstop% + \def\pgfkeysdefaultpath{#1}} + +\def\pgfkeys@parse{\futurelet\pgfkeys@possiblerelax\pgfkeys@parse@main} +\def\pgfkeys@parse@main{% + \ifx\pgfkeys@possiblerelax\pgfkeys@mainstop% + \expandafter\pgfkeys@cleanup% + \else% + \expandafter\pgfkeys@normal% + \fi% +} +\long\def\pgfkeys@normal#1,{% + \pgfkeys@unpack#1=\pgfkeysnovalue=\pgfkeys@stop% + \pgfkeys@parse% +} +\def\pgfkeys@cleanup\pgfkeys@mainstop{} + +\def\pgfkeys@mainstop{\pgfkeys@mainstop} % equals only itself +\def\pgfkeys@novalue{} % equals only itself +\def\pgfkeysnovalue{\pgfkeys@novalue} % equals only itself +\def\pgfkeysnovalue@text{\pgfkeysnovalue} +\def\pgfkeysvaluerequired{\pgfkeysvaluerequired} % equals only itself + +\long\def\pgfkeys@unpack#1=#2=#3\pgfkeys@stop{% + \pgfkeys@spdef\pgfkeyscurrentkey{#1}% + \edef\pgfkeyscurrentkey{\pgfkeyscurrentkey}% + \ifx\pgfkeyscurrentkey\pgfkeys@empty% + % Skip + \else% + \pgfkeys@add@path@as@needed% + \pgfkeys@spdef\pgfkeyscurrentvalue{#2}% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyscurrentkey/.@def}% + {\pgfkeysgetvalue{\pgfkeyscurrentkey/.@def}{\pgfkeyscurrentvalue}} + {}% no default, so leave it + \fi% + \ifx\pgfkeyscurrentvalue\pgfkeysvaluerequired% + \pgfkeysvalueof{/errors/value required/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% + \else% + \pgfkeys@case@one% + \fi% + \fi} + +\def\pgfkeys@case@one{% + \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}% + {\pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} + {\pgfkeys@case@two}% +} + +\def\pgfkeys@case@two{% + \pgfkeysifdefined{\pgfkeyscurrentkey}% + {\pgfkeys@case@two@extern}% + {\pgfkeys@case@three}% +} + +\def\pgfkeys@case@two@extern{% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \pgfkeysvalueof{\pgfkeyscurrentkey}% + \else% + \pgfkeyslet{\pgfkeyscurrentkey}\pgfkeyscurrentvalue% + \fi% +} + + +% either handled key or unknown. +% +% This macro will be replaced by the /handler config/handle only existing +% configuration, see below. +\def\pgfkeys@case@three{% + \pgfkeys@split@path% + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}% + {\pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} + {\pgfkeys@unknown}% +} +\let\pgfkeys@case@three@handleall=\pgfkeys@case@three +\def\pgfkeys@case@three@handle@restricted{% + \pgfkeys@split@path% + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% + \pgfkeys@ifexecutehandler{% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + }{% + % this here is necessary: /my search path/key/.code + % won't be called, so \pgfkeyscurrentpath == '/my search path/key' + % -> it should be one directory higher! We want to invoke the + % .unknown handler in + % '/my search path' + % + % Idea: + % set + % - path := '/my search path' + % - name := 'key/.code' + % - key = '/my search path/key/.code' + \let\pgfkeys@temp=\pgfkeyscurrentkey + \let\pgfkeys@tempb=\pgfkeyscurrentname + \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% + \pgfkeys@split@path% + \let\pgfkeyscurrentkey=\pgfkeys@temp + \edef\pgfkeyscurrentname{\pgfkeyscurrentname/\pgfkeys@tempb}% + \pgfkeys@unknown + }% + }{% + \pgfkeys@unknown + }% +} + +% this macro is to implement the |handly only existing| key in key filtering: +% #1: the code to invoke IF the key handler shall be executed +% #2: the code to invoke if it shall not run. +\def\pgfkeys@ifexecutehandler#1#2{#1}% +\let\pgfkeys@ifexecutehandler@handleall=\pgfkeys@ifexecutehandler +\def\pgfkeys@ifexecutehandler@handleonlyexisting#1#2{% + \pgfkeys@ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname% + #1% ok, this particular key handler is known and should be processed in any case (for example .try) + \else + % implement the 'only existing' feature here: + \pgfkeysifdefined{\pgfkeyscurrentpath}{#1}{% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{#1}{#2}% + }{}% + \fi% +}% +\def\pgfkeys@ifexecutehandler@handlefullorexisting#1#2{% + \ifpgfkeysaddeddefaultpath + \pgfkeys@ifcsname pgfk@excpt@\pgfkeyscurrentname\endcsname% +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentname' is an exception; processing it (on \pgfkeyscurrentpath).}% + #1% ok, this particular key handler is known and be processed in any case (for example .try) + \else + % implement the 'only existing' feature here: + \pgfkeysifdefined{\pgfkeyscurrentpath}{% +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath' does exist. Executing '\pgfkeyscurrentname'.}% + #1% + }{% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{% +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath/.@cmd' does exist. Executing '\pgfkeyscurrentname'.}% + #1% + }{% +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): '\pgfkeyscurrentpath' does NOT exist. Skipping '\pgfkeyscurrentname'.}% + #2% + }% + }% + \fi% + \else +%\message{ifexecutehandler(\pgfkeyscurrentkeyRAW, path \pgfkeysdefaultpath): Fully qualified key provided. Executing '\pgfkeyscurrentname'.}% + #1% ok, always true if the USER explicitly provided the full key path. + \fi +}% +\def\pgfkeysaddhandlyonlyexistingexception#1{\expandafter\def\csname pgfk@excpt@#1\endcsname{1}}% + + +\def\pgfkeys@unknown{% + \pgfkeysifdefined{\pgfkeyscurrentpath/.unknown/.@cmd}% + {% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.unknown/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov} + {% + \pgfkeysgetvalue{/handlers/.unknown/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% + }% +} + + +\long\def\pgfkey@argumentisspace#1{% + \long\def\pgfkeys@spdef##1##2{% + \futurelet\pgfkeys@possiblespace\pgfkeys@sp@a##2\pgfkeys@stop\pgfkeys@stop#1\pgfkeys@stop\relax##1}% + \def\pgfkeys@sp@a{% + \ifx\pgfkeys@possiblespace\pgfkeys@sptoken% + \expandafter\pgfkeys@sp@b% + \else% + \expandafter\pgfkeys@sp@b\expandafter#1% + \fi}% + \long\def\pgfkeys@sp@b#1##1 \pgfkeys@stop{\pgfkeys@sp@c##1}% +} +\pgfkey@argumentisspace{ } +\long\def\pgfkeys@sp@c#1\pgfkeys@stop#2\relax#3{\pgfkeys@temptoks{#1}\edef#3{\the\pgfkeys@temptoks}} +{\def\:{\global\let\pgfkeys@sptoken= } \: } + + + +\def\pgfkeys@add@path@as@needed{% Should add the path if the + % \pgfkeyscurrentkey does not start with / + \expandafter\futurelet\expandafter\pgfkeys@possibleslash\expandafter\pgfkeys@check@slash\pgfkeyscurrentkey\relax% +} +\newif\ifpgfkeysaddeddefaultpath +\def\pgfkeys@check@slash{% + \ifx\pgfkeys@possibleslash/% + \expandafter\pgfkeys@nevermind% + \else% + \expandafter\pgfkeys@addpath% + \fi% +} + +\def\pgfkeys@nevermind#1\relax{% + \pgfkeysaddeddefaultpathfalse + \let\pgfkeyscurrentkeyRAW\pgfkeyscurrentkey +} +\def\pgfkeys@addpath#1\relax{% + \pgfkeysaddeddefaultpathtrue + \def\pgfkeyscurrentkeyRAW{#1}% + \edef\pgfkeyscurrentkey{\pgfkeysdefaultpath#1}% +} + + +\def\pgfkeys@split@path{% Should assign the two codes + % \pgfkeyscurrentname and \pgfcurrentlkeypath + \pgfkeys@pathtoks{}% + \expandafter\pgfkeys@splitter\pgfkeyscurrentkey//% +} +\def\pgfkeys@splitter#1/#2/{% + \def\pgfkeys@temp{#2}% + \ifx\pgfkeys@temp\pgfkeys@empty% + % Ah. done + \def\pgfkeyscurrentname{#1}% + \expandafter\pgfkeys@gobbletoslash% + \else% + \expandafter\pgfkeys@pathtoks\expandafter{\the\pgfkeys@pathtoks#1/}% + \fi% + \pgfkeys@splitter#2/% +} +\def\pgfkeys@gobbletoslash\pgfkeys@splitter/{\expandafter\pgfkeys@remove@slash\the\pgfkeys@pathtoks\relax}% +\def\pgfkeys@remove@slash#1/\relax{\pgfkeys@pathtoks{#1}} + + + +% Quickly set keys +% +% #1 = default path +% #2 = key-value pairs +% +% Desscription: +% +% This command starts the execution with the default path set to +% #1. This command should only be used when speed is important (like +% in a heavily used macro like \tikzset). Normally, keys should be +% used to set the path. Note that if #1 equals /, then \pgfkeys will +% actually be quicker! +% +% Example: +% +% \pgfqkeys{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} + +\def\pgfqkeys{\expandafter\pgfkeys@@qset\expandafter{\pgfkeysdefaultpath}}% +\long\def\pgfkeys@@qset#1#2#3{\def\pgfkeysdefaultpath{#2/}\pgfkeys@parse#3,\pgfkeys@mainstop\def\pgfkeysdefaultpath{#1}} + + +% Sets keys while setting keys +% +% #1 = key-value pairs +% +% Desscription: +% +% This code may only be called inside the code that is executed for a +% key. The #1 should be a list of settings pairs. They will be executed +% as if they had been given as the argument to the \pgfkeys command. +% +% Example: +% +% \pgfkeys{tikz,myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} + +\long\def\pgfkeysalso#1{\pgfkeys@parse#1,\pgfkeys@mainstop} + + + +% Quickly sets keys while setting keys +% +% #1 = default path +% #2 = key-value pairs +% +% Desscription: +% +% This command executes #2 with the default path set to #1. This +% command will cause chaos if used incorrectly. The only safe +% place to use it instead of \pgfkeys is at the beginning of a TeX group. +% +% Example: +% +% \begingroup +% \pgfqkeysalso{/tikz}{myother length/.code=\def\myotherlength{#1}\pgfkeysalso{length=#1}} + +\long\def\pgfqkeysalso#1#2{\def\pgfkeysdefaultpath{#1/}\pgfkeys@parse#2,\pgfkeys@mainstop} + + + + +% Now setup the default handelers and keys: + +% Define a key macro with one argument (\def or \edef) +% +% #1 = key +% #2 = code +% +% Description: +% +% This command will setup things so the key/.@cmd contains a macro +% that takes one parameter and has #2 as its code. +% +% Example: +% +% \pgfkeysdef{/my key}{\show#1} + +\long\def\pgfkeysdef#1#2{% + \long\def\pgfkeys@temp##1\pgfeov{#2}% + \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% +} +\long\def\pgfkeysedef#1#2{% + \long\edef\pgfkeys@temp##1\pgfeov{#2}% + \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% +} + + +% Define a key macro with mutliple arguments (\def or \edef) +% +% #1 = key +% #2 = argument pattern +% #2 = code +% +% Description: +% +% This command will setup things so the key/.@cmd contains a macro +% that takes #2 as its parameter pattern and has #3 as its code. +% +% Example: +% +% \pgfkeysdefargs{/swap}{#1#2}{#2#1} + +\long\def\pgfkeysdefargs#1#2#3{% + \def\pgfkeys@temp#2\pgfeov{#3}% + \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% + \pgfkeyssetvalue{#1/.@args}{#2\pgfeov}% + \pgfkeyssetvalue{#1/.@body}{#3}% +} +\long\def\pgfkeysedefargs#1#2#3{% + \edef\pgfkeys@temp#2\pgfeov{#3}% + \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}% + \pgfkeyssetvalue{#1/.@args}{#2\pgfeov}% + \pgfkeyssetvalue{#1/.@body}{#3}% +} + + + +% Defining a key command + +\pgfkeysdef{/handlers/.code}{\pgfkeysdef{\pgfkeyscurrentpath}{#1}} +\pgfkeysdef{/handlers/.code 2 args}{\pgfkeysdefargs{\pgfkeyscurrentpath}{##1##2}{#1}} +\pgfkeysdef{/handlers/.ecode}{\pgfkeysedef{\pgfkeyscurrentpath}{#1}} +\pgfkeysdef{/handlers/.ecode 2 args}{\pgfkeysedefargs{\pgfkeyscurrentpath}{##1##2}{#1}} +\pgfkeysdefargs{/handlers/.code args}{#1#2}{\pgfkeysdefargs{\pgfkeyscurrentpath}{#1}{#2}} +\pgfkeysdefargs{/handlers/.ecode args}{#1#2}{\pgfkeysedefargs{\pgfkeyscurrentpath}{#1}{#2}} + +% Adding to a key command + +\pgfkeys{/handlers/.add code/.code 2 args=% + % Find out, whether with args or not. + \pgfkeysifdefined{\pgfkeyscurrentpath/.@args}% + {% Yes, so add to body and reuse args + \pgfkeysaddvalue{\pgfkeyscurrentpath/.@body}{#1}{#2}% + % Redefine code + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@args}{\pgfkeys@tempargs}% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@body}{\pgfkeys@tempbody}% + \expandafter\expandafter\expandafter\def\expandafter\pgfkeys@temp\expandafter\pgfkeys@tempargs\expandafter{\pgfkeys@tempbody}% + \pgfkeyslet{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@temp}% + }% + {% + % No, so single argument. Redefine accordingly. + {% + \toks0{#1}% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% + {\pgfkeys@temptoks\expandafter\expandafter\expandafter{\csname pgfk@\pgfkeyscurrentpath/.@cmd\endcsname##1\pgfeov}}% + {\pgfkeys@temptoks{}}% + \toks1{#2}% + \xdef\pgfkeys@global@temp{\the\toks0 \the\pgfkeys@temptoks \the\toks1 }% + }% + \expandafter\def\expandafter\pgfkeys@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + \pgfkeyslet{\pgfkeyscurrentpath/.@cmd}\pgfkeys@temp% + }% +} +\pgfkeys{/handlers/.prefix code/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={#1}{}}}% +\pgfkeys{/handlers/.append code/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={}{#1}}}% + + +% Defining a style + +\pgfkeys{/handlers/.style/.code=\pgfkeys{\pgfkeyscurrentpath/.code=\pgfkeysalso{#1}}} +\pgfkeys{/handlers/.estyle/.code=\pgfkeys{\pgfkeyscurrentpath/.ecode=\noexpand\pgfkeysalso{#1}}} +\pgfkeys{/handlers/.style args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.code args={#1}{\pgfkeysalso{#2}}}} +\pgfkeys{/handlers/.estyle args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.ecode args={#1}{\noexpand\pgfkeysalso{#2}}}} +\pgfkeys{/handlers/.style 2 args/.code=\pgfkeys{\pgfkeyscurrentpath/.code 2 args=\pgfkeysalso{#1}}} + +% Adding to a style + +\pgfkeys{/handlers/.add style/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.add code={\pgfkeysalso{#1}}{\pgfkeysalso{#2}}}}% +\pgfkeys{/handlers/.prefix style/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={\pgfkeysalso{#1}}{}}}% +\pgfkeys{/handlers/.append style/.code=\pgfkeys{\pgfkeyscurrentpath/.add code={}{\pgfkeysalso{#1}}}}% + + +% Defining a value + +\pgfkeys{/handlers/.initial/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath}{#1}} +\pgfkeys{/handlers/.add/.code 2 args=\pgfkeysaddvalue{\pgfkeyscurrentpath}{#1}{#2}} +\pgfkeys{/handlers/.prefix/.code=\pgfkeysaddvalue{\pgfkeyscurrentpath}{#1}{}} +\pgfkeys{/handlers/.append/.code=\pgfkeysaddvalue{\pgfkeyscurrentpath}{}{#1}} +\pgfkeys{/handlers/.get/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath}{#1}} +\pgfkeys{/handlers/.link/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath}{\pgfkeysvalueof{#1}}} + + +% Defining a default + +\pgfkeys{/handlers/.default/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath/.@def}{#1}} +\pgfkeys{/handlers/.value required/.code=\pgfkeyssetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeysvaluerequired}} +\pgfkeys{/handlers/.value forbidden/.code=\pgfkeys{\pgfkeyscurrentpath/.add code=% +{% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \else% + \pgfkeysvalueof{/errors/value forbidden/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov% + \fi% +}{}}} + + +% High-level cmds + +\pgfkeys{/handlers/.store in/.code=\pgfkeysalso{\pgfkeyscurrentpath/.code=\def#1{##1}}} +\pgfkeys{/handlers/.estore in/.code=\pgfkeysalso{\pgfkeyscurrentpath/.code=\edef#1{##1}}} + +\pgfkeys{/handlers/.is if/.code=\pgfkeysalso{% + \pgfkeyscurrentpath/.code=\pgfkeys@handle@boolean{#1}{##1}, + \pgfkeyscurrentpath/.default=true% + }% +} +\def\pgfkeys@handle@boolean#1#2{% + \pgfkeys@ifcsname#1#2\endcsname% + \csname#1#2\endcsname% + \else% + \pgfkeysvalueof{/errors/boolean expected/.@cmd}\pgfkeyscurrentkey{#2}\pgfeov% + \fi +} + +\pgfkeys{/handlers/.is choice/.code=% + \pgfkeys{% + \pgfkeyscurrentpath/.cd,% + .code=\expandafter\pgfkeysalso\expandafter{\pgfkeyscurrentkey/##1}, + .unknown/.style={/errors/unknown choice value=\pgfkeyscurrentkey\pgfkeyscurrentvalue}}} + + +% Inspection handlers + +\pgfkeys{/handlers/.show value/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath}{\pgfkeysshower}\show\pgfkeysshower} % inspect the value +\pgfkeys{/handlers/.show code/.code=\pgfkeysgetvalue{\pgfkeyscurrentpath/.@cmd}{\pgfkeysshower}\show\pgfkeysshower} % inspect the body of the command + + +% Path handling + +% Prepares the .unknown handler used by '.search also'. +% It will be stored into \pgfkeys@global@temp. +\def\pgfkeys@searchalso@prepare@unknown@handler#1{% + \global\def\pgfkeys@global@temp##1\pgfeov{}% + \pgfkeys@searchalso@parse#1,\pgfkeys@mainstop + {% + \toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% + \toks1={\def\pgfutilnext{\pgfkeysvalueof{/handlers/.unknown/.@cmd}##1\pgfeov}\pgfutilnext}% + \xdef\pgfkeys@global@temp{% + \noexpand\ifpgfkeysaddeddefaultpath + \noexpand\pgfkeyssuccessfalse + \noexpand\let\noexpand\pgfkeys@searchalso@name=\noexpand\pgfkeyscurrentkeyRAW + \the\toks0 % one or more /.try things; one for each path. The last element won't have a /.try + %\noexpand\ifpgfkeyssuccess + %\noexpand\else + % \the\toks1 % invoke /handlers/.unknown handler + %\noexpand\fi + \noexpand\else + \the\toks1 % invoke /handlers/.unknown handler + \noexpand\fi + }% + \expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + }% +}% + +\def\pgfkeys@searchalso@parse{\futurelet\pgfkeys@possiblerelax\pgfkeys@searchalso@parse@main} +\def\pgfkeys@searchalso@parse@main{% + \ifx\pgfkeys@possiblerelax\pgfkeys@mainstop% + \expandafter\pgfkeys@cleanup% + \else% + \expandafter\pgfkeys@searchalso@appendentry% + \fi% +} +\def\pgfkeys@searchalso@appendentry#1,#2{% + \def\pgfkeys@searchalso@nexttok{#2}% + \pgfkeys@spdef\pgfkeys@temp{#1}% + {% + \toks0=\expandafter{\pgfkeys@global@temp##1\pgfeov}% + \toks1=\expandafter{\pgfkeys@temp}% + \toks2={##1}% + \xdef\pgfkeys@global@temp{% + \the\toks0 % the space is important! + \noexpand\ifpgfkeyssuccess\noexpand\else + \noexpand\pgfqkeys{\the\toks1 }{\noexpand\pgfkeys@searchalso@name + \ifx\pgfkeys@searchalso@nexttok\pgfkeys@mainstop\else/.try\fi={\the\toks2 }}% + \noexpand\fi}% + \expandafter\gdef\expandafter\pgfkeys@global@temp\expandafter##\expandafter1\expandafter\pgfeov\expandafter{\pgfkeys@global@temp}% + }% + \pgfkeys@searchalso@parse#2% +} +\pgfkeys{% + /handlers/.is family/.code=\pgfkeys{\pgfkeyscurrentpath/.ecode=\edef\noexpand\pgfkeysdefaultpath{\pgfkeyscurrentpath/}},% + /handlers/.cd/.code=\edef\pgfkeysdefaultpath{\pgfkeyscurrentpath/},% + /handlers/.search also/.code={% + \pgfkeys@searchalso@prepare@unknown@handler{#1}% +%\message{I prepared the '\pgfkeyscurrentpath/.unknown' handler \meaning\pgfkeys@global@temp\space for '#1'.}% + \pgfkeyslet{\pgfkeyscurrentpath/.unknown/.@cmd}{\pgfkeys@global@temp}% + } +}% + + +% Value expansion + +\pgfkeys{/handlers/.expand once/.code=\expandafter\pgfkeys@exp@call\expandafter{#1}} +\pgfkeys{/handlers/.expand twice/.code=\expandafter\expandafter\expandafter\pgfkeys@exp@call\expandafter\expandafter\expandafter{#1}} +\pgfkeys{/handlers/.expanded/.code=\edef\pgfkeys@temp{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfkeys@temp}} + +\def\pgfkeys@exp@call#1{\pgfkeysalso{\pgfkeyscurrentpath={#1}}} + +% Try to set a key and do nothing if not define + +\newif\ifpgfkeyssuccess +\pgfkeys{/handlers/.try/.code=\pgfkeys@try} +\pgfkeys{/handlers/.retry/.code=\ifpgfkeyssuccess\else\pgfkeys@try\fi} +\def\pgfkeys@try{% + \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% make sure that \pgfkeys@code doesn't know about 'try'. Important for .is choice + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyscurrentpath/.@def}% + {\pgfkeysgetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeyscurrentvalue}} + {}% no default, so leave it + \fi% + \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% + {% + \pgfkeysgetvalue{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% + \pgfkeyssuccesstrue% + }% + {% + \pgfkeysifdefined{\pgfkeyscurrentpath}% + {% + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% + \pgfkeysvalueof{\pgfkeyscurrentpath}% + \else% + \pgfkeyslet{\pgfkeyscurrentpath}\pgfkeyscurrentvalue% + \fi% + \pgfkeyssuccesstrue% + }% + {% + \pgfkeys@split@path% + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% + % in the standard configuration, this check here is redundand + % because pgfkeys@ifexecutehandler === true. + % It is only interesting for 'handle only existing'. + \pgfkeys@ifexecutehandler{% + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + \pgfkeyssuccesstrue% + }{% + \pgfkeyssuccessfalse + }% + }{% + \pgfkeyssuccessfalse + }% + }% + }% +} + +% Utilities + +\pgfkeys{/utils/exec/.code=#1} % simply execute the given code directly. + + +% Errors + +\pgfkeys{/errors/boolean expected/.code 2 args=\pgfkeys@error{% + Boolean parameter of key '#1' must be 'true' or 'false', not + '#2'. I am going to ignore it}} +\pgfkeys{/errors/value required/.code 2 args=\pgfkeys@error{% + The key '#1' requires a value. I am going to ignore this key}{}} +\pgfkeys{/errors/value forbidden/.code 2 args=\pgfkeys@error{% + You may not specify a value for the key '#1'. I am going to ignore + the value '#2' that you provided}} +\pgfkeys{/errors/unknown choice value/.code 2 args=\pgfkeys@error{% + Choice '\pgfkeyscurrentname' unknown in key + '\pgfkeyscurrentpath'. I am going to ignore this key}} +\pgfkeys{/errors/unknown key/.code 2 args=\pgfkeys@error{% + I do not know the key '#1' and I am going to ignore it. Perhaps + you misspelled it}} + +\pgfkeys{/handlers/.unknown/.code=% + {% + \let\pgfkeys@orig@key=\pgfkeyscurrentkey% + \pgfkeysalso{/errors/unknown key=\pgfkeys@orig@key{}}% + } +} + +\pgfkeys{ + /handler config/.is choice, + /handler config/all/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handleall + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleall + }, + /handler config/only existing/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handleonlyexisting + }, + /handler config/full or existing/.code={% + \let\pgfkeys@case@three=\pgfkeys@case@three@handle@restricted + \let\pgfkeys@ifexecutehandler=\pgfkeys@ifexecutehandler@handlefullorexisting + }, + /handler config/only existing/add exception/.code={\pgfkeysaddhandlyonlyexistingexception{#1}}, +}% +\pgfkeysaddhandlyonlyexistingexception{.cd}% +\pgfkeysaddhandlyonlyexistingexception{.try}% +\pgfkeysaddhandlyonlyexistingexception{.retry}% +\pgfkeysaddhandlyonlyexistingexception{.lastretry}% +\pgfkeysaddhandlyonlyexistingexception{.unknown}% + + +\input pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex + +\endinput 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 index ed490784564..5d7a731334d 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex @@ -1,3 +1,23 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + % Copyright 2008 by Christian Feuersaenger % % This file may be distributed and/or modified @@ -76,6 +96,8 @@ % The actual case number (0-3) will be provided as contents % of the macro % \pgfkeyscasenumber. +% It is always a one-character token, so it may be compared +% with both, \ifnum or \if. % Please note that unknown options will be processed with % the usual '.unknown' handlers unless the key filter takes % control over unknown options as well. @@ -150,17 +172,17 @@ % % Example: % \pgfkeys{/my group/.cd,/utils/exec=\pgfkeysalsofrom\filtered} -\def\pgfkeysalsofrom#1{% +\long\def\pgfkeysalsofrom#1{% \expandafter\pgfkeysalso\expandafter{#1}% } % The same as \pgfkeysalsofrom, but it invokes \pgfkeysalsofiltered. -\def\pgfkeysalsofilteredfrom#1{% +\long\def\pgfkeysalsofilteredfrom#1{% \expandafter\pgfkeysalsofiltered\expandafter{#1}% } % #1 = options -\long\def\pgfkeysalsofiltered#1{% +\long\long\def\pgfkeysalsofiltered#1{% \pgfkeys@install@filter@and@invoke{\pgfkeysalso{#1}}% }% @@ -168,14 +190,14 @@ % % #1: default path % #2: key-value-pairs -\def\pgfqkeysfiltered#1{% +\long\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{% +\long\def\pgfqkeysfiltered@@install#1#2#3{% \pgfkeys@install@filter@and@invoke{% \def\pgfkeysdefaultpath{#2/}\pgfkeys@parse#3,\pgfkeys@mainstop\def\pgfkeysdefaultpath{#1}% }% @@ -214,7 +236,7 @@ % Deactivates family #1. % % #1 maybe a macro. -\def\pgfkeysdeactivatefamily#1{ +\def\pgfkeysdeactivatefamily#1{% \pgfkeysiffamilydefined {#1}% {\csname pgfk@#1/familyactivefalse\endcsname}% @@ -292,7 +314,15 @@ \def\pgfkeysgetfamily#1#2{% \pgfkeysifdefined{#1/family}{\pgfkeysgetvalue{#1/family}{#2}\pgfkeyssuccesstrue}{\pgfkeyssuccessfalse}% } - + +% Equivalent to \pgfkeys{#1/.belongs to family=#2} +\def\pgfkeyssetfamily#1#2{% + \pgfkeysiffamilydefined{#2}{% + \pgfkeyssetvalue{#1/family}{#2}% + }{% + \pgfkeysalso{/errors/family unknown=#2}% + }% +}% % Sets \ifpgfkeysfiltercontinue to true iff the current key belongs to @@ -483,13 +513,7 @@ },% /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}% - }% - },% + /handlers/.belongs to family/.code={\pgfkeyssetfamily{\pgfkeyscurrentpath}{#1}},% % % % An addition to the '.try' and '.retry' handlers: @@ -543,12 +567,12 @@ % 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 + \if\pgfkeyscasenumber0% % unknown options shall be processed with the % unknown-handlers. \pgfkeysfiltercontinuetrue \else - \ifnum\pgfkeyscasenumber=3 + \if\pgfkeyscasenumber3% \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP \else \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP @@ -577,10 +601,10 @@ % #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 + \if\pgfkeyscasenumber0% \pgfkeysevalkeyfilterwith{#2}% \else - \ifnum\pgfkeyscasenumber=3 + \if\pgfkeyscasenumber3% \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP \else \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP @@ -593,11 +617,11 @@ \fi }, /pgf/key filters/active families or no family DEBUG/.code 2 args={% - \ifnum\pgfkeyscasenumber=0 + \if\pgfkeyscasenumber0% \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) invoking unknown handler '#2']}% \pgfkeysevalkeyfilterwith{#2}% \else - \ifnum\pgfkeyscasenumber=3 + \if\pgfkeyscasenumber3% \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP \else \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP @@ -616,6 +640,59 @@ \fi }, % + % A (faster) shortcut for + % /pgf/key filters/active families or no family= + % {/pgf/keys filters/false} + % {/pgf/keys filters/false} + /pgf/key filters/active families and known/.code={% + \if\pgfkeyscasenumber0% + \pgfkeysfiltercontinuefalse + \else + \if\pgfkeyscasenumber3% + \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 + }, + % A (faster) shortcut for + % /pgf/key filters/active families or no family= + % {/pgf/key filters/is descendant of=#1}% for keys without family + % {/pgf/keys filters/false} + /pgf/key filters/active families or descendants of/.code={% + \if\pgfkeyscasenumber0% + \pgfkeysfiltercontinuefalse + \else + \if\pgfkeyscasenumber3% + \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP + \else + \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP + \fi + \ifpgfkeyssuccess + \pgfkeysisfamilyactive{\pgfkeyspred@TMP}% + \else% Ok, it does not belong to any family. + % the 'is descendendant of' implementation has been + % COPY PASTED here: + % + % string prefix comparison: + \def\pgfkeysisdescendantof@impl##1#1##2\pgf@@eov{% + \def\pgfkeyspred@TMP{##1}% + \ifx\pgfkeyspred@TMP\pgfkeys@empty + \pgfkeysfiltercontinuetrue + \else + \pgfkeysfiltercontinuefalse + \fi + }% + \expandafter\pgfkeysisdescendantof@impl\pgfkeyscurrentkey#1\pgf@@eov + \fi + \fi + }, + % % Processes only options which are childs of #1. % Example: % is descendant of/.install key filter=/foo @@ -626,14 +703,16 @@ % but not for % /bar/foo/... /pgf/key filters/is descendant of/.code={% - \ifnum\pgfkeyscasenumber=0 + \if\pgfkeyscasenumber0% %\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{% + % [ note : this has been COPY-PASTED to + % |active families or descendants of| ] + \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.}% @@ -651,7 +730,7 @@ % % Returns true if the currently processed full key equals #2. /pgf/key filters/equals/.code={% - \ifnum\pgfkeyscasenumber=0 + \if\pgfkeyscasenumber0% % Unknown option: \pgfkeysfiltercontinuetrue \else @@ -670,6 +749,7 @@ % 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 @@ -693,12 +773,14 @@ },% /pgf/key filters/true/.code={\pgfkeysfiltercontinuetrue},% /pgf/key filters/true/.install key filter, - /pgf/key filters/false/.code={\pgfkeysfiltercontinuefalse},% + /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 + \if\pgfkeyscasenumber0% \pgfkeysfiltercontinuefalse \else \pgfkeysfiltercontinuetrue @@ -731,7 +813,7 @@ \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}% \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov \else -%\message{FILTEReD OUT KEY \pgfkeyscurrentkey!}% +%\message{FILTERED OUT KEY \pgfkeyscurrentkey!}% \pgfkeys@filtered@handler% \fi }{% @@ -750,16 +832,20 @@ \pgfkeys@split@path % CASE THREE: a handler \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% - \def\pgfkeyscasenumber{3}% - \pgfkeys@key@predicate% - \ifpgfkeysfiltercontinue + \pgfkeys@ifexecutehandler{% + \def\pgfkeyscasenumber{3}% + \pgfkeys@key@predicate% + \ifpgfkeysfiltercontinue %\message{PROCESSING KEY \pgfkeyscurrentkey!}% - \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% - \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov - \else + \pgfkeysgetvalue{/handlers/\pgfkeyscurrentname/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov + \else %\message{FILTERED OUT KEY \pgfkeyscurrentkey!}% - \pgfkeys@filtered@handler% - \fi + \pgfkeys@filtered@handler% + \fi + }{% + \pgfkeys@unknown + }% }{% \pgfkeys@unknown }% @@ -788,6 +874,12 @@ \pgfkeys@orig@try \else \pgfkeysfiltercontinuetrue + \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}% make sure that \pgfkeys@code doesn't know about 'try'. Important for .is choice + \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text% Hmm... no value + \pgfkeysifdefined{\pgfkeyscurrentpath/.@def}% + {\pgfkeysgetvalue{\pgfkeyscurrentpath/.@def}{\pgfkeyscurrentvalue}} + {}% no default, so leave it + \fi% \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}% {% % CASE ONE: a command option @@ -795,11 +887,6 @@ \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% @@ -822,7 +909,33 @@ \fi \pgfkeyssuccesstrue% }% - {\pgfkeyssuccessfalse}% + {% + \pgfkeys@split@path% + \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{% + % CASE THREE: a handled key + % + % in the standard configuration, this check here is redundand + % because pgfkeys@ifexecutehandler === true. + % It is only interesting for 'handle only existing'. + \pgfkeys@ifexecutehandler{% + \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 + \pgfkeyssuccesstrue% + }{% + \pgfkeyssuccessfalse + }% + }{% + \pgfkeyssuccessfalse + }% + }% }% \fi } @@ -883,10 +996,10 @@ % The argument '#1' MUST be a FULL KEY. % % The implementation employs a subset of the \pgfkeysalso code. -\def\pgfkeysevalkeyfilterwith#1{% +\long\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{% +\long\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 @@ -908,11 +1021,6 @@ } -\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}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex index 1c985f27d47..3bb41804bdb 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex @@ -1,3 +1,23 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + % Copyright 2008/2009 by Christian Feuersaenger % % This file may be distributed and/or modified @@ -217,7 +237,9 @@ \pgfmathfloat@install\pgfmathe@=\pgfmathfloate@% \pgfmathfloat@install\pgfmathe=\pgfmathfloate@% \pgfmathfloat@install\pgfmathlessthan@=\pgfmathfloatlessthan@% + \pgfmathfloat@install\pgfmathless@=\pgfmathfloatlessthan@% \pgfmathfloat@install\pgfmathgreaterthan@=\pgfmathfloatgreaterthan@% + \pgfmathfloat@install\pgfmathgreater@=\pgfmathfloatgreaterthan@% \pgfmathfloat@install\pgfmathpow@=\pgfmathfloatpow@ \pgfmathfloat@install\pgfmathrand@=\pgfmathfloatrand@ \pgfmathfloat@install\pgfmathrand=\pgfmathfloatrand@ @@ -233,20 +255,20 @@ \pgfmathfloat@install\pgfmathand@=\pgfmathfloatand@ \pgfmathfloat@install\pgfmathor@=\pgfmathfloator@ \pgfmathfloat@install\pgfmathfactorial@=\pgfmathfloatfactorial@ + \pgfmathfloat@install\pgfmathveclen@=\pgfmathfloatveclen@ + \pgfmathfloat@install\pgfmathcosh@=\pgfmathfloatcosh@ + \pgfmathfloat@install\pgfmathsinh@=\pgfmathfloatsinh@ + \pgfmathfloat@install\pgfmathtanh@=\pgfmathfloattanh@ \pgfmathfloat@install@unimplemented{ceil}% \pgfmathfloat@install@unimplemented{frac}% \pgfmathfloat@install@unimplemented{log2}% \pgfmathfloat@install@unimplemented{log10}% - \pgfmathfloat@install@unimplemented{veclen}% \pgfmathfloat@install@unimplemented{equalto}% \pgfmathfloat@install@unimplemented{random}% \pgfmathfloat@install@unimplemented{setseed}% \pgfmathfloat@install@unimplemented{Mod}% \pgfmathfloat@install@unimplemented{real}% \pgfmathfloat@install@unimplemented{notequal}% - \pgfmathfloat@install@unimplemented{sinh}% - \pgfmathfloat@install@unimplemented{cosh}% - \pgfmathfloat@install@unimplemented{tanh}% % \pgfmathfloat@install@unimplemented{atan2}% % \pgfmathfloat@install@unimplemented{height}% % @@ -306,6 +328,9 @@ \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{hex}% \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{bin}% \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{oct}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{tanh}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{sinh}% + \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{cosh}% % % The following methods actually enable the parser to work with % the internal floating point number representation. @@ -329,6 +354,31 @@ \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse@pgf@two@null@null% }% +\pgfutil@ifundefined{pgfmathdeclarefunction}{% + % BACKWARDS COMPATIBILITY: We have PGF 2.00 : + \def\pgfmathdeclarepseudoconstant#1#2{% + \begingroup + \toks0=\expandafter{\csname pgfmath#1@\endcsname}% + \toks1={\pgfmath@postfunction}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }% + \xdef\pgfmathfloat@glob@TMPb{\the\toks0 }% + \endgroup + \expandafter\let\csname pgfmath@parsefunction@#1\endcsname=\pgfmathfloat@glob@TMP + \expandafter\let\csname pgfmath#1\endcsname=\pgfmathfloat@glob@TMPb + \expandafter\def\csname pgfmath#1@\endcsname{#2}% + }% + \let\pgfmathredeclarepseudoconstant=\pgfmathdeclarepseudoconstant +}{% + \pgfutil@ifundefined{pgfmathdeclarepseudoconstant}{% + \def\pgfmathdeclarepseudoconstant#1#2{\pgfmathdeclarefunction*{#1}{0}{#2}} + }{}% +}% + +\pgfmathdeclarepseudoconstant{inf}{\def\pgfmathresult{inf}} +\pgfmathdeclarepseudoconstant{infty}{\def\pgfmathresult{inf}} +\pgfmathdeclarepseudoconstant{nan}{\def\pgfmathresult{nan}} +\pgfmathdeclarepseudoconstant{NaN}{\def\pgfmathresult{nan}} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Hacks to the basic level pgf math engine: @@ -482,6 +532,7 @@ \let\pgfmath@basic@subtract@=\pgfmathsubtract@ \let\pgfmath@basic@multiply@=\pgfmathmultiply@ \let\pgfmath@basic@divide@=\pgfmathdivide@ +\let\pgfmath@basic@reciprocal@=\pgfmathreciprocal@ \let\pgfmath@basic@abs@=\pgfmathabs@ \let\pgfmath@basic@round@=\pgfmathround@ \let\pgfmath@basic@rand@=\pgfmathrand@ @@ -523,34 +574,63 @@ } % Compares #1 with #2 and sets \pgfmathresult either to 1.0 or 0.0. % -% It also sets the boolean \ifpgfmathfloatcomparison (globally. +% 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 + \edef\pgfmathfloat@loc@TMPa{#1}% + \edef\pgfmathfloat@loc@TMPb{#2}% + \expandafter\pgfmathfloat@decompose\pgfmathfloat@loc@TMPa\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E + \expandafter\pgfmathfloat@decompose\pgfmathfloat@loc@TMPb\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E \ifcase\pgfmathfloat@a@S % x = 0 -> (x<y <=> y >0) - \ifnum1=\pgfmathfloat@b@S + \ifcase\pgfmathfloat@b@S + % y = 0 + \or% y > 0 \global\pgfmathfloatcomparisontrue + \or% y < 0 + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty \fi \or % x > 0 -> (x<y <=> ( y > 0 && |x| < |y|) ) - \ifnum1=\pgfmathfloat@b@S - % y>0: + \ifcase\pgfmathfloat@b@S + % y = 0 + \or% y>0: \pgfmathfloatlessthan@positive + \or% y < 0 + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty \fi \or % x < 0 -> (x<y <=> (y >= 0 || |x| > |y|) ) - \ifnum2=\pgfmathfloat@b@S - % 'y<0': + \ifcase\pgfmathfloat@b@S + % y = 0 + \global\pgfmathfloatcomparisontrue + \or%y > 0 + \global\pgfmathfloatcomparisontrue + \or% 'y<0': \pgfmathfloatgreaterthan@positive + \or% y = nan + \or% y = + infty + \global\pgfmathfloatcomparisontrue + \or% y = -infty + \fi + \or + % x = nan. + \or + % x = +infty + \or + % x = -infty + \ifnum\pgfmathfloat@b@S=3 \else \global\pgfmathfloatcomparisontrue \fi - \else - \pgfmath@error{Sorry, 'pgfmathfloatlessthan@{#1}{#2}' not yet supported.}{}% \fi \endgroup \ifpgfmathfloatcomparison @@ -736,24 +816,22 @@ % - \pgfmathfloat@a@Mtok : undefined (its contents will be destroyed. % \def\pgfmathfloattoextentedprecision@a#1{% - \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\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 000\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 + \edef\pgfmathresult{#1}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\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 }% @@ -810,8 +888,40 @@ % #2= TeX code to execute if #1 == 0 % #3= TeX code to execute if #1 != 0 \def\pgfmathfloatifzero#1#2#3{% - \expandafter\pgfmathfloat@decompose@F#1\relax\pgfmathfloat@a@S - \ifnum\pgfmathfloat@a@S=0 #2\else#3\fi + \pgfmathfloatgetflagstomacro{#1}\pgfmathfloat@loc@TMPa + \if\pgfmathfloat@loc@TMPa0 #2\else#3\fi +}% + +\def\pgfmathfloatiffinite#1#2#3{% + \pgfmathfloatgetflagstomacro{#1}\pgfmathfloatiffinite@ + \ifnum\pgfmathfloatiffinite@>2 #3\else #2\fi +}% + +% Invokes code '#3' if the flags of the floating point number '#1' +% match the flag provided in '#2'. +% +% \pgfmathfloatcreate{1}{1.0}{2} +% \pgfmathfloatifflags{\pgfmathresult}{0}{It's zero!}{It's not zero!}% +% \pgfmathfloatifflags{\pgfmathresult}{1}{It's positive!}{It's not positive!}% +% \pgfmathfloatifflags{\pgfmathresult}{2}{It's negative!}{It's not negative!}% +% or, equivalently +% \pgfmathfloatifflags{\pgfmathresult}{+}{It's positive!}{It's not positive!}% +% \pgfmathfloatifflags{\pgfmathresult}{-}{It's negative!}{It's not negative!}% +\def\pgfmathfloatifflags#1#2#3#4{% + \if#2-% + \pgfmathfloatifflags{#1}{2}{#3}{#4}% + \else + \if#2+% + \pgfmathfloatifflags{#1}{1}{#3}{#4}% + \else + \pgfmathfloatgetflagstomacro#1\pgfmathfloat@loc@TMPa + \if\pgfmathfloat@loc@TMPa#2 + #3\relax + \else + #4\relax + \fi + \fi + \fi }% % #1=mantisse which needs to be shifted (with smaller exponent) @@ -857,7 +967,8 @@ % 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 + \edef\pgfmathresult{#2}% + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E \ifcase\pgfmathfloat@b@S \edef\pgfmathresult{#1}% \or @@ -914,12 +1025,10 @@ \def\pgfmathfloatmultiply@#1#2{% \begingroup \pgfmathfloatsetextprecision{1}% - \edef\pgfmathfloat@arga{#1}% - \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}% + \pgfmathfloattoextentedprecision@a{#1}% \let\pgfmathfloat@arga=\pgfmathresult % - \edef\pgfmathfloat@argb{#2}% - \pgfmathfloattoextentedprecision@b{\pgfmathfloat@argb}% + \pgfmathfloattoextentedprecision@b{#2}% \let\pgfmathfloat@argb=\pgfmathresult % \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. @@ -1764,4 +1873,66 @@ \pgfmath@smuggleone\pgfmathresult \endgroup }% + +% Implements the vector length of a 2D vector. +% +% ATTENTION: this does NOT use the improved code of the basic layer! +% It simply computed sqrt( #1^2 + #2^2 )! +\def\pgfmathfloatveclen@#1#2{% + \begingroup + \edef\pgfmathfloat@@a{#1}% + \pgfmathfloatmultiply@{\pgfmathfloat@@a}{\pgfmathfloat@@a}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \edef\pgfmathfloat@@b{#2}% + \pgfmathfloatmultiply@{\pgfmathfloat@@b}{\pgfmathfloat@@b}% + \let\pgfmathfloat@@b=\pgfmathresult + % + \pgfmathfloatadd@{\pgfmathfloat@@a}{\pgfmathfloat@@b}% + \pgfmathfloatsqrt@{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +\def\pgfmathfloatcosh@#1{% + \begingroup + \pgfmathfloatexp@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatneg@{#1}% + \pgfmathfloatexp@{\pgfmathresult}% + % + \pgfmathfloatadd@{\pgfmathresult}{\pgfmathfloat@@a}% + \expandafter\pgfmathfloatmultiplyfixed@\expandafter{\pgfmathresult}{0.5}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloatsinh@#1{% + \begingroup + \pgfmathfloatexp@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatneg@{#1}% + \pgfmathfloatexp@{\pgfmathresult}% + % + \pgfmathfloatsubtract@{\pgfmathfloat@@a}{\pgfmathresult}% + \expandafter\pgfmathfloatmultiplyfixed@\expandafter{\pgfmathresult}{0.5}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% +\def\pgfmathfloattanh@#1{% + \begingroup + \pgfmathfloatsinh@{#1}% + \let\pgfmathfloat@@a=\pgfmathresult + % + \pgfmathfloatcosh@{#1}% + \let\pgfmathfloat@@b=\pgfmathresult + % + \pgfmathfloatdivide@{\pgfmathfloat@@a}{\pgfmathfloat@@b}% + % + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% \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 index a3a1410968b..d2089a6fd67 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex @@ -1,3 +1,23 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + % Copyright 2006 by Till Tantau % % This file may be distributed and/or modified @@ -7,7 +27,7 @@ % % 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.7 2009/02/13 21:00:47 ludewich Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplothandlers.code.tex,v 1.14 2009/11/18 20:27:45 ludewich Exp $ \newif\ifpgf@plot@started @@ -603,15 +623,16 @@ }% } \def\pgf@plot@const@line@handler#1{% - \pgf@plot@first@action{#1}% + \pgf@process{#1}% \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}% + \pgf@plot@first@action{}% \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 + \pgf@yb\pgf@plot@const@line@handler@last\relax \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}% @@ -637,15 +658,16 @@ }% } \def\pgf@plot@const@line@mark@right@handler#1{% - \pgf@plot@first@action{#1}% + \pgf@process{#1}% \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}% + \pgf@plot@first@action{}% \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 + \pgf@yb\pgf@plot@const@line@handler@last\relax \pgfpathlineto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}% @@ -673,15 +695,16 @@ }% } \def\pgf@plot@jumpmarkright@handler#1{% - \pgf@plot@first@action{#1}% + \pgf@process{#1}% \xdef\pgf@plot@const@line@handler@last{\the\pgf@x}% + \pgf@plot@first@action{}% \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 + \pgf@yb\pgf@plot@const@line@handler@last\relax \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}% \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% \xdef\pgf@plot@const@line@handler@last{\the\pgf@xa}% @@ -709,15 +732,16 @@ }% } \def\pgf@plot@jumpmarkleft@handler#1{% - \pgf@plot@first@action{#1}% + \pgf@process{#1}% \xdef\pgf@plot@const@line@handler@last{\the\pgf@y}% + \pgf@plot@first@action{}% \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 + \pgf@yb\pgf@plot@const@line@handler@last\relax \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}% \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% \xdef\pgf@plot@const@line@handler@last{\the\pgf@ya}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex new file mode 100644 index 00000000000..93a7a0c59e2 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex @@ -0,0 +1,85 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + +% Copyright 2009 by Till Tantau and Christian Feuersänger +% +% 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. + +\input pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex +\input pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex + +% TODO for auto xrefs: +% 1. check the already identified labels, preferrably using +% /pdflinks/show labels=true +% and the image externalization debug mode (see pgfmanual-en-main.tex) +% (to strip almost all images away) +% +% 2. Insert '\declareandlabel' in the document whenever something has been +% defined in the text, so it should get a pdf anchor (see +% pgfmanual.pdflinks.code.tex ) +% +% 2.1 perhaps insert \pgfmanualpdflabel{<label>}{} where needed. +% +% 3. Verify that the |...| commands occuring in situations where catcodes can't +% be changed (footnotes or macro arguments) work as expected. +% +% 4. Consider telling the pretty printer that several control sequences +% have arguments which are options (see below for the predefined list). +% This may apply to \pgfpageslogicalpageoptions or so. +% +% 5. @Christian: consider extensions of the parser such that it identifies path commands (at least partially) +% +% + +\def\pgfmanual@warning#1{\immediate\write16{! Package pgfmanual Warning: #1}}% + + +\pgfkeys{ + % set this to 'false' to disable auto reference generation. + % However, a little bit runtime overhead will still remain + % (and the \pgfmanualpdflabel commands will still be used) + /pdflinks/codeexample links=true, + % + /codeexample/prettyprint/cs arguments/tikzset/.initial=1, + /codeexample/prettyprint/cs/tikzset/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/usetikzlibrary/.initial=1, + /codeexample/prettyprint/cs/usetikzlibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/usepgflibrary/.initial=1, + /codeexample/prettyprint/cs/usepgflibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace}, + % + % + % + % whenever an unqualified key is found, the following key prefix + % list is tried to find a match. + /pdflinks/search key prefixes in={/tikz/,/pgf/}, + % + % the link prefix written to the pdf file: + /pdflinks/internal link prefix=pgf, + % + /pdflinks/warnings=false, + % for debugging: + /pdflinks/show labels=false, +}% + diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex new file mode 100644 index 00000000000..edfc48d5a4e --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex @@ -0,0 +1,429 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + +%-------------------------------------------- +% +% 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/2009 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +% This file provides an interface to the +% pgfmanual.prettyprint.code.tex thing -- it allows to +% *generate pdf crossrefs inside of codeexamples automatically* +% without any user input. +% +% Thus, you write +% \begin{codeexample}[] +% \begin{tikzpicture}[options] +% \end{tikzpicture} +% \end{codeexample} +% and pdf cross references to the definitions of 'tikzpicture' +% and any options will be generated automatically. +% +% Furthermore, pdf cross references will be generated for everything +% within vertical bars, |....|. +% +% +% +% +% +% The only necessary thing is that \pgfmanualpdflabel has been called +% for every (fully qualified) key, control sequence, environment or +% whatever. + +\newif\ifpgfmanualpdfwarnings +\pgfmanualpdfwarningstrue + +\newif\ifpgfmanualshowlabels + +\pgfkeys{% + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + % + /codeexample/prettyprint/autolinks/.style={% + /codeexample/prettyprint/key name/.code={\pgfmanualpdfref{##1}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\pgfmanualpdfref{##1}{##1}/\pgfmanualpdfref{/handlers/##2}{##2}}, + /codeexample/prettyprint/key value display only/.code={\pgfmanualprettyprintcode{##1}}, + /codeexample/prettyprint/cs/.code={\pgfmanualpdfref{##1}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\pgfmanualpdfref{##1}{##1}\{\pgfmanualprettyprintcode{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\pgfmanualpdfref{##1}{##1}\{\pgfmanualprettyprintpgfkeys{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={##1\{\pgfmanualpdfref{##2}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={##1\{\pgfmanualpdfref{##2}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\begingroup\pgfkeyssetvalue{/pdflinks/search key prefixes in}{}\pgfmanualpdfref{##1}{##1}\endgroup}, + /codeexample/prettyprint/point/.code={##1},% + /codeexample/prettyprint/point with cs/.code 2 args={(\pgfmanualpdfref{##1}{##1}:##2},% + },% + /codeexample/prettyprint/autolinks, +}% + +\pgfkeys{ + % + % Enables or disables the parsing of codeexamples. + /pdflinks/codeexample links/.is if=pgfmanualprettyenabled, + /pdflinks/codeexample links/.default=true, + % + % whenever an unqualified key is found, the following key prefix + % list is tried to find a match. + /pdflinks/search key prefixes in/.initial={/tikz/,/pgf/}, + % + % Enables or disables warnings for failed auto links: + /pdflinks/warnings/.is if=pgfmanualpdfwarnings, + /pdflinks/warnings/.default=true, + % + % Shows the autogenerated labels. This is useful to check if the + % 'search key prefixes in' worked as it ought to. + /pdflinks/show labels/.is if=pgfmanualshowlabels, + /pdflinks/show labels/.default=true, + /pdflinks/show labels=false, + % will be invoked with '#1' set to the generated label. + /pdflinks/show labels code/.code={ + \hbox to 0pt{% + \vbox to 0pt{\hsize=0pt + \vskip-\baselineskip + \hbox to \hsize{% + \hss + {\footnotesize\ttfamily\textcolor{red}{#1}}% + \hss + }% + \vss + }% + \vbox to 0pt{\hsize=0pt + \vss + \hbox to \hsize{% + \hss + {\footnotesize\ttfamily\textcolor{red}{$\vert$}}% + \hss + }% + }% + \vsize=0pt + }% + }, + % + % the link prefix written to the pdf file: + /pdflinks/internal link prefix/.initial=pgf, +} + +\gdef\pgfmanualpdf@installreplacements{% + \def\marg##1{{##1}}% + \def\oarg##1{[##1]}% + \def\meta##1{<##1>}% + \def\x{x}% + \def\textbackslash{<CS>}% + \def\\{\textbackslash}% + \def\space{:}% + \edef\ {\space}% + \edef\#{}% + \def\printanat{@}% + \def\protect{}% + \def\textasciicircum{o}% + \expandafter\edef\pgfmanual@verb@activebar{\pgfmanual@verb@bar}% +}% + +% Defines a new pdf cross ref label for use with \pgfmanualpdfref. +% +% Usage: +% \pgfmanualpdflabel{<label>}{<text>} +% #1: the label. +% The text #2 will be shown in the resulting pdf (if it is not empty). +% +% There is also support for catcode changes if <label> contains +% something which shouldn't be written as-is into .aux files: +% \pgfmanualpdflabel[\catcode`\|=12 ]{|-}{} +% -> this will write +% \begingroup \catcode `\|=12 +% <code to deal with the label |- > +% \endgroup +% into the .aux file. +% +\def\pgfmanualpdflabel{\pgfutil@ifnextchar[{\pgfmanualpdflabel@opt}{\pgfmanualpdflabel@opt[]}}% +\def\pgfmanualpdflabel@opt[#1]#2#3{% + \begingroup + % + \def\pgfmanualpdf@catcode{#1}% + \pgfmanualpdf@catcode + % + \pgfmanualpdflabel@generate{#2}{#3}% + % + % this is pgfplots-specific: pgfplots supports generic styles which + % contain '\x' where '\x' iterates through 'x,y,z'. + \pgfutil@in@\x{#2}% + \ifpgfutil@in@ + \def\x{y}% + \pgfmanualpdflabel@generate{#2}{#3}% + \def\x{z}% + \pgfmanualpdflabel@generate{#2}{#3}% + \fi + \endgroup +}% +\def\pgfmanualpdflabel@generate#1#2{% + \pgfmanual@handlespeciallabeltokens@in{#1}% + % + \def\pgfmanualpdflabel@generateone{0}% + \pgfutil@ifundefined{pgfd@lbl@\pgfmanualpdflabel@@}{% + % ok, no such label is known. + \def\pgfmanualpdflabel@generateone{1}% + }{% + \if\csname pgfd@lbl@\pgfmanualpdflabel@@\endcsname a% "a"ux + % ah, it is "just" known from a previous run, but there is + % no code in the pdf! Write it! + \def\pgfmanualpdflabel@generateone{1}% + \else + % ok, we already wrote one before. Skip. + \fi + }% + \if\pgfmanualpdflabel@generateone1% + \ifpgfmanualshowlabels + \pgfkeysvalueof{/pdflinks/show labels code/.@cmd}{\pgfmanualpdflabel@@}\pgfeov + \fi + % + \ifx\pgfmanualpdf@catcode\pgfutil@empty + \else + \toks0=\expandafter{\pgfmanualpdf@catcode}% + \immediate\write\@auxout{% + \noexpand\begingroup + \the\toks0 + }% + \fi + \immediate\write\@auxout{% + \noexpand\expandafter\noexpand\gdef + \noexpand\csname pgfd@lbl@\pgfmanualpdflabel@@\noexpand\endcsname{a}% a = known in "a"ux file + }% + \ifx\pgfmanualpdf@catcode\pgfutil@empty + \else + \immediate\write\@auxout{\noexpand\endgroup}% + \fi + \expandafter\gdef\csname pgfd@lbl@\pgfmanualpdflabel@@\endcsname{w}% 1. remember the label AND remember that we "w"rote it into the pdf. + \edef\pgfmanualpdflabel@@{\pgfkeysvalueof{/pdflinks/internal link prefix}.\pgfmanualpdflabel@@}% + \expandafter\hypertarget\expandafter{\pgfmanualpdflabel@@}{#2}% + \else + #2% + \fi +}% + +% A pdf reference to label `#1' with (TeX) text `#2'. +% @see also \verbpdfref. +\def\pgfmanualpdfref#1#2{% + \begingroup + \pgfmanual@handlespeciallabeltokens@in{#1}% + % + \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname + \else + \global\let\pgfmanual@glob=\pgfmanualpdflabel@@ + \def\pgfmanual@tempa{\foreach \prefix in }% + \pgfkeysgetvalue{/pdflinks/search key prefixes in}\pgfmanual@tempb + \expandafter\pgfmanual@tempa\expandafter{\pgfmanual@tempb}{% + \ifcsname pgfd@lbl@\prefix\pgfmanualpdflabel@@\endcsname + \xdef\pgfmanual@glob{\prefix\pgfmanualpdflabel@@}% + \breakforeach + \fi + }% + \let\pgfmanualpdflabel@@=\pgfmanual@glob + \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname + \else + \ifpgfmanualpdfwarnings + \begingroup + \toks0={#1}% + \pgfmanual@warning{pgfmanualpdfref{\the\toks0 }: target label does not exist.}% + \endgroup + \fi + #2% + \let\pgfmanualpdflabel@@=\pgfutil@empty + \fi + \fi + \ifx\pgfmanualpdflabel@@\pgfutil@empty + \else + \expandafter\pgfmanualpdfref@\expandafter{\pgfmanualpdflabel@@}{#2}% + \fi + \endgroup +}% +\def\pgfmanualpdfref@#1#2{% + \pgfkeysgetvalue{/pdflinks/internal link prefix}\pgfmanual@temp + \expandafter\hyperlink\expandafter{\pgfmanual@temp.#1}{#2}% + \ifpgfmanualshowlabels + \pgfkeysvalueof{/pdflinks/show labels code/.@cmd}{#1}\pgfeov + \fi +}% + +% Handles special tokens in a pdf label which should be treated with +% care. +% +% For example, backslashes might produce problems. +% This occurs quite frequently with automatically generated hyperrefs +% inside of codeexamples where \pgfmanualpdfref will be invoked - +% there, we get the catcode 12 backslashes. +% Check for them! +% +% #1: a token list which shall be used either as cross ref or as +% label. +% +% On output, the macro \pgfmanualpdflabel@@ will be '\edef'ed to the +% new, possibly modified value. +\def\pgfmanual@handlespeciallabeltokens@in#1{% + \begingroup + \pgfmanualpdf@installreplacements + \expandafter\pgfutil@in@\pgfmanual@pretty@backslash{#1}% + \ifpgfutil@in@ + % assume the backslash is the first char and substitute it: + \pgfmanualpdfref@substitute@backslash#1\relax + \else + \edef\pgfmanualpdflabel@@{#1}% + \fi + \def\pgfmanual@tmp{\pgfutilstrreplace{ }{\space}}% + \expandafter\pgfmanual@tmp\expandafter{\pgfmanualpdflabel@@}% + \edef\pgfmanualpdflabel@@{\pgfretval}% + \pgfmath@smuggleone\pgfmanualpdflabel@@ + \endgroup +}% +\expandafter\def\expandafter\pgfmanualpdfref@substitute@backslash\expandafter#\expandafter1\pgfmanual@pretty@backslash#2\relax{% + \edef\pgfmanualpdflabel@@{#1\textbackslash #2}% +}% + +% Typesets '#1' in red,\texttt like every declaration. It will also +% generate a pdf cross ref anchor for #1. +% +% WARNING: this changes catcodes! In case this is not acceptable in +% your context, you will need to generate a \pgfmanualpdflabel +% manually. +% +% \declareandlabel{\controlsequence} can be used as |\controlsequence| +\def\declareandlabel{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \pgfmanualpdflabel##1{\texttt{\declare##1}}% mark: '##1' contains already braces. + \endgroup + }% + \pgfmanualprettyprintercollectargcount1{\relax}% +} + +% +% \verbpdfref{\controlsequence more stuff} +% is the same as writing |\controlsequence more stuff|, but the +% *complete* argument is supposed to be one label. +% +% The difference to \pgfmanualpdfref{...}{} is that the argument is +% supposed to be verbatim text. +\def\verbpdfref{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \pgfmanualpdfref##1{\texttt{##1}}% mark: '##1' contains already braces. + \endgroup + }% + \pgfmanualprettyprintercollectargcount1{\relax}% +} + +% Prepare active vertical bars, |....| for auto-pretty cross +% referencing. +% +% Example: +% |\pgfkeys| -> will generate a hyperref! +{ + \catcode`\|=12 + \gdef\pgfmanual@verb@bar{|}% +% \gdef\pgfmanual@verb@collect#1|{% +% % this command will also handle control sequences. +% \texttt{\pgfmanualprettyprintpgfkeys{#1}}% +% \endgroup +% }% + \catcode`\|=13 + \gdef\pgfmanual@verb@activebar{|}% +} +\def\pgfmanual@verb{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \toksdef\t@pgfmanual@verb=0 + \t@pgfmanual@verb={}% + \pgfmanual@verb@collect +} +% this version of \pgfmanual@verb@collect is less efficient than the +% one uncommented above. BUT: it can auto-detect the case when +% |...| has been provided somewhere where I can't change catcodes! +% The other one would simply fail to compile. +\def\pgfmanual@verb@collect#1{% + \def\pgfmanual@temp{#1}% + \ifx\pgfmanual@temp\pgfmanual@verb@bar + % ok, finish: + \edef\pgfmanual@verb@collect@next{% + % this command will also handle control sequences. + \noexpand\endgroup + \noexpand\texttt{\noexpand\pgfmanualprettyprintpgfkeys{\the\t@pgfmanual@verb}}% + }% + \else + \ifx\pgfmanual@temp\pgfmanual@verb@activebar + % ohoh... that should not happen! It means someone invoked + % |...| within an argument; I couln't change catcodes. + % Ok, resort to a simple fallback solution. + % FIXME : I have just realized that THIS DOESN'T PRESERVE SPACES + \edef\pgfmanual@verb@collect@next{% + \noexpand\endgroup + \noexpand\texttt{\the\t@pgfmanual@verb}% + }% + \else + \t@pgfmanual@verb=\expandafter{\the\t@pgfmanual@verb #1}% + \let\pgfmanual@verb@collect@next=\pgfmanual@verb@collect + \fi + \fi + \pgfmanual@verb@collect@next +}% + +\AtBeginDocument{% + \ifpgfmanualprettyenabled + \catcode`\|=13 + \expandafter\let\pgfmanual@verb@activebar=\pgfmanual@verb + \fi +}% + +\def\pgfmanual@verb@preparecatcodes@{% + \let\do\@makeother% + \dospecials% + \catcode`\%=12 % THATS IMPORTANT! Do *not* handle comments! + % these catcodes are expected by the pretty printer... + %\catcode`\^^M=13 + \catcode`\ =13 + \catcode`\^^I=13 + \expandafter\def\pgfmanual@pretty@activespace{\space}% + \expandafter\def\pgfmanual@pretty@activetab{\space\space\space\space}% +}% +\endinput +% vi: ts=4 sw=4 diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex new file mode 100644 index 00000000000..04fed087887 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex @@ -0,0 +1,1115 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + +%-------------------------------------------- +% +% 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/2009 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +% this is some kind of "plug-in" for pgfmanual-en-macros.tex which +% provides pretty printing of the code lines in 'codeexample'. +% +% It requires to be invoked with \pgfmanualprettyprintcode{#1} at the +% right place. +% +% ATTENTION: +% this is NOT a sophisticated syntax highlighter like lstlistings! +% It has rather strict assumptions about how to use it (the input must +% have been read verbatim, for example). + +% Special code for syntax highlighting: +% +% +% USER INTERFACE +\pgfkeys{% + % this is the public hook into + % \begin{codeexample}...\end{codeexample} which triggers pretty + % printing: + /codeexample/typeset listing/.code= {\pgfmanualprettyprintcode{#1}}, + % + % this key will be invoked whenever a key in key-value context has been identified. + % + % It won't be invoked for handled keys like |my style/.style=....|, see below. + % + % #1 will be the keys name. + /codeexample/prettyprint/key name/.code={#1}, + % + % A variant which will be used instead of |key name| if the key + % has a key handler. For example, when the pretty printer finds + % |my style/.style|, it will call + % |key name with handler={my style}{.style}. + /codeexample/prettyprint/key name with handler/.code 2 args={#1/#2}, + % + % Will be invoked whenever the value of a key has been found. + % It will be invoked AFTER 'key name' and not at all if there was + % no value. + % + % #1: the key's name + % #2: the key's value. + % + % The default implementation checks if there is a special handler + % for the key name '#1', in + % /codeexample/prettyprint/key value/#1. + % For example: + % /codeexample/prettyprint/key value/my key/.code 2 args={name=#1, value =#2} + % If such a key exists, it will be invoked with {#1}{#2} as + % arguments. Otherwise, the generic method + % /codeexample/prettyprint/key value with style detection={#1}{#2} + % will be invoked. + /codeexample/prettyprint/key value/.code 2 args={% + \pgfkeysifdefined{/codeexample/prettyprint/key value/#1}{% + \pgfkeysalso{/codeexample/prettyprint/key value/#1={#1}{#2}}% + }{% + \pgfkeysalso{/codeexample/prettyprint/key value with style detection={#1}{#2}}% + }% + }, + % A helper macro for the default 'key value' implementation. + /codeexample/prettyprint/key value with style detection/.code 2 args={% + \pgfutil@in@{style}{#1}% + \ifpgfutil@in@ + \pgfmanualprettyprintpgfkeys{#2}% + \else + \pgfkeysalso{/codeexample/prettyprint/key value display only={#2}}% + \fi + },% + % + % Will be invoked by the default 'key value' implementation to + % typeset the value as such. + /codeexample/prettyprint/key value display only/.code={#1}, + % + % Used to typeset a single word. A word is something which has not + % been identified in any other context; a maximal sequence of + % non-white-space tokens. + /codeexample/prettyprint/word/.code={#1}, + % + % A two-argument code key which invokes '#1' if spaces shall + % delimit words and '#2' if not. + % This may be useless. Handle with care! + /codeexample/prettyprint/if space is word delim/.code 2 args={% + #1% + },% + % + % A three-argument code key which should invoke '#2' if the single + % token '#1' is a word delimiter and '#3' if that is not the case. + % Note that '#1' doesn't have the usual catcodes (see the + % \pgfmanual@pretty@** macros)! + % Furthermore, white spaces are treated separately. + /codeexample/prettyprint/if is word delim/.code args={#1#2#3}{% + \edef\pgfmanual@check{,;().;\pgfmanual@pretty@lbrace\pgfmanual@pretty@rbrace}% + \def\pgfmanual@check@{\pgfutil@in@{#1}}% + \expandafter\pgfmanual@check@\expandafter{\pgfmanual@check}% + \ifpgfutil@in@ #2\else #3\fi + },% + % + % Used to typeset a single control sequence. + % #1 is the control sequence's name as a sequence of catcode 12 + % tokens. + /codeexample/prettyprint/cs/.code={#1}, + % + % Used to typeset a single control sequence together with one or + % more arguments. + % + % #1 is the control sequence's name (including the backslash as + % literal string) and + % #2,#3,...,#9 are the arguments. The number of arguments depends + % on the 'cs arguments/<CS NAME>' key; it contains the integer + % number. + % + % For example, if + % |cs arguments/pgfkeys/.initial=1|, + % the pretty printer invokes + % |cs with args={\pgfkeys}{<argument>}. + % + % If + % |cs arguments/mycommand/.initial=2|, + % the pretty printer invokes + % |cs with args={\pgfkeys}{<argument1>}{<argument2>}. + % In this case, 'cs with args' needs to be defined in a way which + % allows to deal with 3 arguments. + % + % Please note that the value do not contain braces! The braces + % need to be inserted manually. + % + % Special cases: + % 1. If end-of-input is encountered BEFORE the expected number of + % arguments has been found, the following happens: + % - if not even one (partial) argument has been found, the + % /codeexample/prettyprint/cs/.@cmd key will be used instead. + % - the \ifpgfmanualprettyprinterarghasunmatchedbraces boolean + % indicates if the trailing brace is missing. + /codeexample/prettyprint/cs with args/.code 2 args={#1\{#2\pgfmanualclosebrace}, + % + % For every identified control sequence, the key + % /codeexample/prettyprint/cs arguments/<CSNAME> + % will be checked. If it exists, it contains an integer with the + % number of arguments it takes. + % The <CSNAME> must not contain the '\'. + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + % + % For every identified control sequence, the key + % /codeexample/prettyprint/cs/<CSNAME>/.@cmd + % will be checked. If it exists, it will be used instead of + % 'cs with args' (with the same special case restrictions for + % early end-of-input). + % + % The <CSNAME> must not contain the '\'. + % + % This allows special treatment for special + % commands like \pgfkeys: + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={#1\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + % + % recognise environments: + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={#1\{#2\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={#1\{#2\pgfmanualclosebrace}, + % + % a point coordinate (#1) + % Note that '#1' will contain the braces (if there was one), + /codeexample/prettyprint/point/.code={#1},% + % + % a point coordinate with explicit coordinate system: (#1:#2) + % Note that '#2' will contain the terminating brace (if there was one) + % #1: the coordinate system name (*without* the leading brace). + % The leading brace must be re-inserted by this style. + /codeexample/prettyprint/point with cs/.code 2 args={(#1:#2},% + % the same with specialised code: + %/codeexample/prettyprint/point with cs/<CS NAME>/.code 2 args={(#1:#2},% + % + % + % A predefined style which colors every identified token. It's + % purpose is only debugging. + /codeexample/prettyprint/colored/.style={% + /codeexample/prettyprint/key name/.code={\textcolor{red!75!black}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\textcolor{red!75!black}{##1}/\textcolor{red!90!black}{##2}}, + /codeexample/prettyprint/key value display only/.code={\textcolor{yellow}{##1}}, + /codeexample/prettyprint/cs/.code={\textcolor{green}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\textcolor{green}{##1}\{\pgfmanualprettyprintpgfkeys{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\textcolor{brown}{##1}}, + /codeexample/prettyprint/point/.code={\textcolor{red}{##1}},% + /codeexample/prettyprint/point with cs/.code 2 args={(\textcolor{green}{##1}:\textcolor{red}{##2}},% + },% + % A further debuggin helper. + /codeexample/prettyprint/colored and verbose/.style={% + /codeexample/prettyprint/colored, + /codeexample/prettyprint/key name/.code={\message{[key name=##1]}\textcolor{red!75!black}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\message{[key name with handler=##1/##2]}\textcolor{red!75!black}{##1}/\textcolor{red!90!black}{##2}}, + /codeexample/prettyprint/key value display only/.code={\def\temp{##1}\message{[key value=\meaning\temp]}\textcolor{yellow}{##1}}, + /codeexample/prettyprint/cs/.code={\message{[cs=##1]}\textcolor{green}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\def\temp{##2}\message{[cs with args={##1}{\meaning\temp}]}\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\message{[word=##1]}\textcolor{brown}{##1}}, + /codeexample/prettyprint/point/.code={\message{[point=##1]}\textcolor{red}{##1}},% + /codeexample/prettyprint/point with cs/.code 2 args={\message{[point with cs={##1}{##2}]}(\textcolor{green}{##1}:\textcolor{red}{##2}},% + },% + %/codeexample/prettyprint/colored, + %/codeexample/prettyprint/colored and verbose, +}% + +\newif\ifpgfmanualprettyenabled +\pgfmanualprettyenabledtrue + +% User interface command to handle unmatched braces: +% +% It expands to '\}' unless the preceding argument had unmatched braces. +\def\pgfmanualclosebrace{% + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \}% + \fi +}% + + +% Typesets '#1', possibly using some sort of pretty printer. +% +% The argument '#1' is expected to be a long token list in which +% 1. all characters have catcode 11 or 12 (normal letters), +% 2. white spaces, tabs and newlines have catcode 13 (are active). +% +% @see \pgfmanualprettyprintpgfkeys +\long\def\pgfmanualprettyprintcode#1{% +%\def\temp{#1}\message{STARTING PRETTY PRINTING for \meaning\temp}% + \ifpgfmanualprettyenabled + \begingroup + \pgfmanualprettyprintstyles + \pgfmanual@pretty@mainloop#1\pgfmanual@EOI + \endgroup + \else + #1% + \fi +}% +% DISABLE: +%\long\def\pgfmanualprettyprintcode#1{#1}% + +\def\pgfmanualprettyprintstyles{% +%\tracingmacros=2 \tracingcommands=2 \message{PRETTYPRINT INIT}% + \def\{{\pgfmanual@pretty@lbrace}% + \def\}{\pgfmanual@pretty@rbrace}% + \pgfmanual@pretty@installcommenthandler + \let\pgfmanualprettyprintstyles=\relax +}% + + +\newif\ifpgfmanualprettycommentactive + +% we can't use the \@typeset@till@return method for comments because +% the pretty printer needs full control over the token list. +% +% We try a replacement here. +% +% FIXME +% THIS INTRODUCES A NEW GROUP! Does that hurt the pretty printer?? +% +\def\pgfmanual@pretty@installcommenthandler{% + \expandafter\def\pgfmanual@pretty@activepercent{% + \begingroup + \pgfmanualprettycommentactivetrue + \expandafter\let\pgfmanual@pretty@activenl=\pgfmanual@pretty@recoveraftercomment + \expandafter\def\pgfmanual@pretty@activepercent{\%}% + %\tt + \% % + }% +}% +\def\pgfmanual@pretty@recoveraftercomment{% + \endgroup + \pgfmanual@pretty@activenl +}% + +\def\pgfmanual@EOI{\pgfmanual@EOI}% + +{ + \catcode`\[=0 + \catcode`\\=12 + [gdef[pgfmanual@pretty@backslash{\}% +} +\begingroup + \catcode`\:=12 + \catcode`\(=12 + \catcode`\)=12 + \gdef\pgfmanual@pretty@colon{:}% + \gdef\pgfmanual@pretty@lroundbrace{(}% + \gdef\pgfmanual@pretty@rroundbrace{)}% + \catcode`\[=1 + \catcode`\]=2 + \catcode`\{=12 + \catcode`\}=12 + \gdef\pgfmanual@pretty@lbrace[{]% + \gdef\pgfmanual@pretty@rbrace[}]% + \catcode`\{=1 + \catcode`\}=2 + \catcode`\[=12 + \catcode`\]=12 + \catcode`\,=12 + \catcode`\ =10\relax\gdef\pgfmanual@pretty@space{ }% + \gdef\pgfmanual@pretty@lbracket{[}% + \gdef\pgfmanual@pretty@rbracket{]}% + \gdef\pgfmanual@pretty@comma{,}% + \catcode`\==12 + \gdef\pgfmanual@pretty@eq{=}% +\endgroup +\begingroup + \catcode`\%=12 + \gdef\pgfmanual@pretty@percent{%} + \catcode`\%=13 + \gdef\pgfmanual@pretty@activepercent{%} + \catcode`\^^M=13 + \gdef\pgfmanual@pretty@activenl{^^M}\endgroup +\begingroup +\catcode`\^^I=13\relax\gdef\pgfmanual@pretty@activetab{^^I}% +\catcode`\ =13\relax\gdef\pgfmanual@pretty@activespace{ }\endgroup + +% loops through all tokens. +% #1 is a single token. +\def\pgfmanual@pretty@mainloop{% + \def\pgfmanual@pretty@mainloop@currentword{}% + \pgfmanual@pretty@mainloop@ +}% +\long\def\pgfmanual@pretty@mainloop@#1{% + \def\pgfmanual@loc@TMPa{#1}% + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@mainloop@ + \ifx\pgfmanual@loc@TMPa\pgfmanual@EOI + % stop iteration. + \pgfmanual@pretty@mainloop@finishword + \let\pgfmanual@pretty@mainloop@NEXT=\relax + \else + \ifpgfmanualprettycommentactive + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lbracket% + % we found the start of OPTIONS '[ ... ]'. + \pgfmanual@pretty@mainloop@finishword + % Attempt syntax highlighting for pgfkeys: + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@pgfkeys + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@backslash + % we found the start of a control sequence '\command' + \pgfmanual@pretty@mainloop@finishword + % + % collect the control sequence name into + % \pgfmanual@loc@TMPa, but without the backslash: + \let\pgfmanual@loc@TMPa=\pgfutil@empty + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@collectcs@loop + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lroundbrace% + \pgfmanual@pretty@mainloop@finishword + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@collectpoint + \else + \def\pgfmanual@isspace{0}% + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + \def\pgfmanual@isspace{1}% + \else + \ifnum10=\catcode`#1 + \def\pgfmanual@isspace{1}% + \fi + \fi + \if\pgfmanual@isspace1% + \pgfkeysvalueof{/codeexample/prettyprint/if space is word delim/.@cmd}{% + \pgfmanual@pretty@mainloop@finishword + #1% ok, show it. + }{% + % collect the word. + \expandafter\def\expandafter\pgfmanual@pretty@mainloop@currentword\expandafter{\pgfmanual@pretty@mainloop@currentword #1}% + }% + \else + \pgfkeysvalueof{/codeexample/prettyprint/if is word delim/.@cmd}{#1}{% + \pgfmanual@pretty@mainloop@finishword + #1% ok, show the delimiter. + }{% + % collect the word. + \expandafter\def\expandafter\pgfmanual@pretty@mainloop@currentword\expandafter{\pgfmanual@pretty@mainloop@currentword #1}% + }\pgfeov% + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@mainloop@NEXT +}% + +\def\pgfmanual@pretty@mainloop@finishword{% + \ifx\pgfmanual@pretty@mainloop@currentword\pgfutil@empty + \else + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/word/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@pretty@mainloop@currentword\pgfeov + \let\pgfmanual@pretty@mainloop@currentword=\pgfutil@empty + \fi +}% + +\def\pgfmanual@pretty@collectpoint{% + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@collectargs@finish@collectpoint + \expandafter\pgfmanualprettyprintercollectupto\pgfmanual@pretty@rroundbrace + {\afterpgfmanual@pretty@collectpoint}% +} + +{ +\catcode`\:=12 +\gdef\pgfmanual@pretty@collectargs@finish@collectpoint#1{% + \expandafter\pgfutil@in@\pgfmanual@pretty@colon{#1}% + \ifpgfutil@in@ + \def\pgfmanual@pretty@collectpoint@getcoordsystem##1:##2\relax{% + \begingroup + \pgfmanual@pretty@restorespaces + % remove active spaces from ##1: + \xdef\pgfmanual@pretty@glob@TMPa{##1}% + \endgroup + \pgfkeysifdefined{/codeexample/prettyprint/point with cs/\pgfmanual@pretty@glob@TMPa/.@cmd}{% + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point with cs/\pgfmanual@pretty@glob@TMPa/.@cmd}}% + }{% + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point with cs/.@cmd}}% + }% + \expandafter\def\expandafter\pgfmanual@loc@TMPa\expandafter{\expandafter{\pgfmanual@pretty@glob@TMPa}{##2}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + }% + \ifpgfmanualprettyprinterfoundterminator + \pgfmanual@pretty@collectpoint@getcoordsystem#1)\relax + \else + \pgfmanual@pretty@collectpoint@getcoordsystem#1\relax + \fi + \else + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point/.@cmd}}% + \ifpgfmanualprettyprinterfoundterminator + \pgfmanual@loc@TMPb(#1)\pgfeov + \else + \pgfmanual@loc@TMPb(#1\pgfeov + \fi + \fi +}% +} +\def\afterpgfmanual@pretty@collectpoint{\pgfmanual@pretty@mainloop}% + +% loops through all tokens, assembling the cs name as it goes. +% #1 is a single token. +\def\pgfmanual@pretty@collectcs@loop#1{% + \let\pgfmanual@pretty@collectcs@loop@NEXT=\pgfmanual@pretty@collectcs@loop + \def\pgfmanual@loc@TMPb{#1}% + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + \def\pgfmanual@pretty@collectcs@loop@NEXT{\pgfmanual@pretty@collectcs@loop@END #1}% + \else + % a csname may only use letters. And: only letters have a + % positive lcccode! + \ifnum\lccode`#1=0 + \ifx\pgfmanual@loc@TMPb @% + % ok, we may also accept an `@': + \edef\pgfmanual@loc@TMPa{\pgfmanual@loc@TMPa #1}% + \else + % This here is the first non-letter. + \def\pgfmanual@pretty@collectcs@loop@NEXT{\pgfmanual@pretty@collectcs@loop@END #1}% + \fi + \else + % continue iterating and assemble the csname... + \edef\pgfmanual@loc@TMPa{\pgfmanual@loc@TMPa #1}% + \fi + \fi + \pgfmanual@pretty@collectcs@loop@NEXT +}% +\def\afterpgfmanual@pretty@cs{\pgfmanual@pretty@mainloop}% + +\def\pgfmanual@pretty@collectcs@loop@END{% + \pgfkeysifdefined{/codeexample/prettyprint/cs arguments/\pgfmanual@loc@TMPa}{% + % oh. The collected control sequence expects arguments. That + % means a lot of work since there are no nestable braces in + % the token list! All of them have catcode 12... we need to do + % that manually. + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@collectargs@finish@cs + \def\pgfmanual@pretty@collectcs@loop@END@next{% + \pgfmanualprettyprintercollectargcount + {\pgfkeysvalueof{/codeexample/prettyprint/cs arguments/\pgfmanual@loc@TMPa}}% + {\afterpgfmanual@pretty@cs}% + }% + }{% + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{\pgfmanual@pretty@backslash \pgfmanual@loc@TMPa}% + % ok, report the macro and continue with the main loop. + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/cs/.@cmd}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + \let\pgfmanual@pretty@collectcs@loop@END@next=\afterpgfmanual@pretty@cs + }% + \pgfmanual@pretty@collectcs@loop@END@next +}% + +\newif\ifpgfmanualprettyprinterarghasunmatchedbraces + +% Collects arguments inside of a token list, dealing with nested +% catcode-12-braces. +% +% #1: is the NUMBER of arguments to collect. +% #2: is TeX code which shall be invoked after +% \pgfmanualprettyprinterhandlecollectedargs has been invoked (see +% below). +% +% PRECONDITION: +% there is a large token list following +% \pgfmanualprettyprintercollectargcount with balanced braces. The braces +% have \catcode 12. +% POSTCONDITION: +% 1. the arguments will be collected as +% '<result> := {<first arg>}{<second arg>}', +% 2.1 the macro \pgfmanualprettyprinternumcollectedargs will contain +% the *actual* number of *completely* collected arguments, +% 2.2 the if \ifpgfmanualprettyprinterarghasunmatchedbraces will be +% set to \c true if the last found argument had an unmatched brace, +% 3. then, \pgfmanualprettyprinterhandlecollectedargs{<result>} will be +% invoked. Just define \pgfmanualprettyprinterhandlecollectedargs +% properly. +% Afterwards, #2 will be invoked to recover from the argument +% collection. +% +% +% Example: +% \pgfmanualprettyprintercollectargcount{2}{\donnextstep} +% {_12 first argument }_12 {_12 second argument }_12 next tokens% +% +% will result in the expansion +% \pgfmanualprettyprinterhandlecollectedargs{{_1 first argument }_2 {_1 second argument }_2 } +% \donnextstep +% next tokens +% +% +% +% ATTENTION: +% \pgfmanualprettyprinterhandlecollectedargs will be invoked with a SINGLE +% argument. The argument as such will contain extra braces, one pair +% of braces for each of the #1 arguments. These braces will have +% catcode 1 and 2, i.e. they can *really* be used in TeX. Thus, the +% finish routine will be invoked with +% \pgfmanualprettyprinterhandlecollectedargs{{<arg>}} +% for one argument and with +% \pgfmanualprettyprinterhandlecollectedargs{{<first arg>}{<second arg>}} +% for two and more arguments. Note the extra set of braces for one +% arg. +% It might happen that not all arguments have been found if +% end-of-input occured before. The +% \pgfmanualprettyprinterhandlecollectedargs routine has to check +% this using the macro \pgfmanualprettyprinternumcollectedargs which +% contains the actual number of collected args. +% +% @remark This macro checks for the end-of-input indicator, \pgfmanual@EOI. In case it encounters +% \pgfmanual@EOI, it +% 1. stops collecting, leaving the \pgfmanual@EOI as next token to be read, +% 2. sets \ifpgfmanualprettyprinterarghasunmatchedbraces to \iftrue if necessary, +% 3. assigns \pgfmanualprettyprinternumcollectedargs +% 4. invokes the finish routine. +% The \pgfmanual@EOI needs to be collected by following routines in +% this case. You can also use \pgfutil@ifnextchar\pgfmanual@EOI{}{} in +% following routines to check for \pgfmanual@EOI. +\def\pgfmanualprettyprintercollectargcount#1#2{% + \pgfmanualprettyprinterarghasunmatchedbracesfalse + \begingroup + \edef\pgfmanual@loc@csargcount{#1}% + \toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 + \t@afterpgfmanualprettyprinterhandlecollected={#2}% + \let\c@pgfmanual@pretty@openbracecount=\c@pgf@counta + \let\c@pgfmanual@pretty@curargcount=\c@pgf@countb + % I will track open braces and the number of completely + % collected arguments here: + \c@pgfmanual@pretty@openbracecount=0 + \c@pgfmanual@pretty@curargcount=0 + % + % and I will accumulate the argument token lists as such here: + \toksdef\t@pgfmanual@currentarg=0 + \toksdef\t@pgfmanual@allargs=1 + \t@pgfmanual@currentarg={}% + \t@pgfmanual@allargs={}% + % + \pgfmanual@pretty@collectargs@loop +}% + +% loops through all tokens, collecting the required number of +% arguments. This involves to track nested braces manually. +% #1 is a single token. +\def\pgfmanual@pretty@collectargs@loop#1{% + \let\pgfmanual@pretty@collectargs@loop@NEXT=\pgfmanual@pretty@collectargs@loop + \def\pgfmanual@loc@TMPc{#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@EOI + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \ifpgfmanualpdfwarnings + \pgfplots@warning{The pretty printer did not found the closing curly brace!? This will potentially lead to display errors}% + \fi + \fi + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \noexpand\pgfmanualprettyprinterarghasunmatchedbracestrue + \fi + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand\pgfmanual@EOI% <- put this token back into token list! + }% + \else + \ifpgfmanualprettycommentactive + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activenl + \pgfmanualprettycommentactivefalse + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activepercent + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \pgfmanualprettycommentactivetrue + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@lbrace + \advance\c@pgfmanual@pretty@openbracecount by1 + \ifnum\c@pgfmanual@pretty@openbracecount>1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@rbrace + \advance\c@pgfmanual@pretty@openbracecount by-1 + \ifnum\c@pgfmanual@pretty@openbracecount=0 + % we have one complete argument ready! + % append it -- with REAL braces if needed: + \edef\pgfmanual@loc@TMPc{\the\t@pgfmanual@allargs{\the\t@pgfmanual@currentarg}}% + \t@pgfmanual@allargs=\expandafter{\pgfmanual@loc@TMPc}% + \t@pgfmanual@currentarg={}% + % + % check it we need more arguments: + \advance\c@pgfmanual@pretty@curargcount by1 + \ifnum\c@pgfmanual@pretty@curargcount=\pgfmanual@loc@csargcount\relax + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs}% + \the\t@afterpgfmanualprettyprinterhandlecollected + }% + \fi + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifnum10=\catcode`#1 + % we found a white space (space, TAB + % or NL) with unexpected catcode + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifnum\c@pgfmanual@pretty@openbracecount=0 + \ifpgfmanualpdfwarnings + \begingroup + \toks4{#1}% + \pgfplots@warning{The pretty printer did not find the expected \pgfmanual@loc@csargcount\space arguments (only token \the\toks4 )}% + \endgroup + \fi + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand#1% <- put this token back into token list! + }% + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@collectargs@loop@NEXT +}% + +\newif\ifpgfmanualprettyprinterfoundterminator + +% Collects tokens inside of a token list up to a single delimiting token, dealing with nested +% catcode-12-braces. +% +% #1: is the end token, the delimiter. It won't be collected. +% #2: is code to invoke after +% \pgfmanualprettyprinterhandlecollectedargs has been invoked. +% +% PRECONDITION: +% there is a large token list following +% \pgfmanualprettyprintercollectargcount with balanced braces. The braces +% have \catcode 12. +% POSTCONDITION: +% - the arguments will be collected as +% '<result> := <token list>' +% and then, \pgfmanualprettyprinterhandlecollectedargs{<result>} will be +% invoked. Just define \pgfmanualprettyprinterhandlecollectedargs +% properly. +% Then, #2 will be invoked. +% - The boolean \ifpgfmanualprettyprinterfoundterminator will be set to true if and only if '#1' has been found. +% +% @see \pgfmanualprettyprintercollectargcount for more details. +% +\def\pgfmanualprettyprintercollectupto#1#2{% + \pgfmanualprettyprinterarghasunmatchedbracesfalse + \pgfmanualprettyprinterfoundterminatortrue + \begingroup + \def\pgfmanual@loc@delimittoken{#1}% + \toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 + \t@afterpgfmanualprettyprinterhandlecollected={#2}% + % + \let\c@pgfmanual@pretty@openbracecount=\c@pgf@counta + % I will track open braces here: + \c@pgfmanual@pretty@openbracecount=0 + % + % and I will accumulate the argument token lists as such here: + \toksdef\t@pgfmanual@currentarg=0 + \t@pgfmanual@currentarg={}% + % + \pgfmanual@pretty@collectupto@loop +}% + +% loops through all tokens, collecting the required number of +% arguments. This involves to track nested braces manually. +% #1 is a single token. +\def\pgfmanual@pretty@collectupto@loop#1{% + \let\pgfmanual@pretty@collectupto@loop@NEXT=\pgfmanual@pretty@collectupto@loop + \def\pgfmanual@loc@TMPc{#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@EOI + \edef\pgfmanual@pretty@collectupto@loop@NEXT{% + \noexpand\endgroup + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \noexpand\pgfmanualprettyprinterarghasunmatchedbracestrue + \fi + \noexpand\pgfmanualprettyprinterfoundterminatorfalse + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand\pgfmanual@EOI% <- put this token back into token list! + }% + \else + \ifpgfmanualprettycommentactive + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activenl + \pgfmanualprettycommentactivefalse + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activepercent + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \pgfmanualprettycommentactivetrue + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@lbrace + \advance\c@pgfmanual@pretty@openbracecount by1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@rbrace + \advance\c@pgfmanual@pretty@openbracecount by-1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@loc@delimittoken + \ifnum\c@pgfmanual@pretty@openbracecount=0 + % do NOT include the delimit token. + \edef\pgfmanual@pretty@collectupto@loop@NEXT{% + \noexpand\endgroup + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + }% + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@collectupto@loop@NEXT +}% + +\def\pgfmanual@pretty@collectargs@finish@cs#1{% + \def\pgfmanual@pretty@collectargs@finish@cs@hasargs{1}% + \ifnum\pgfmanualprettyprinternumcollectedargs=0 + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \def\pgfmanual@pretty@collectargs@finish@cs@hasargs{0}% + \fi + \fi + \if\pgfmanual@pretty@collectargs@finish@cs@hasargs1% + % report the macro and its arguments: + \pgfkeysifdefined{/codeexample/prettyprint/cs/\pgfmanual@loc@TMPa/.@cmd}{% + % oh, we have a separate routine for this macro! Ok, use it: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs/\pgfmanual@loc@TMPa/.@cmd}}% + }{% + % use the generic routine: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs with args/.@cmd}}% + }% + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@backslash\pgfmanual@loc@TMPa}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa #1\pgfeov + \else + % Oh. We probably got |\pgfkeys| instead of |\pgfkeys{arg}| + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@backslash\pgfmanual@loc@TMPa}}% + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs/.@cmd}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + #1\relax% simply typeset any encountered tokens after the control sequence. + \fi +}% + +% A user macro which pretty prints a set of keys. +% +% If '#1' is NOT an argument for \pgfkeys, +% \pgfmanualprettyprintpgfkeys will try to recognise at least control +% sequences (in the same way as usual). Thus, you can even use this +% method if there *could* be pgfkeys arguments in an automated pretty +% printing environment. +% +% However, '#1' should only have catcode 12 characters with the +% exception of catcode 13 for newlines, spaces and comments. +\long\def\pgfmanualprettyprintpgfkeys#1{% + \ifpgfmanualprettyenabled + \begingroup + \pgfmanualprettyprintstyles + \pgfmanual@pretty@pgfkeys@loop#1\pgfmanual@EOI + \endgroup + \else + #1% + \fi +} + +\def\pgfmanual@pretty@pgfkeys{% + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@pgfkeys@start + \pgfmanualprettyprintercollectupto]{\pgfmanual@pretty@mainloop}%% +}% +\long\def\pgfmanual@pretty@pgfkeys@start#1{% + [% + \pgfmanual@pretty@pgfkeys@loop#1\pgfmanual@EOI + ]% +}% +% iterates through single tokens, detecting key names and values while +% it goes. +\long\def\pgfmanual@pretty@pgfkeys@loop#1{% + \def\pgfmanual@loc@TMPa{#1}% + \ifx\pgfmanual@loc@TMPa\pgfmanual@EOI + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\relax}% + \else + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\pgfmanual@pretty@pgfkeys@loop}% + \ifpgfmanualprettycommentactive + #1% + \else + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@comma% + %\let\pgfmanual@pretty@pgfkeys@loop@NEXT=\pgfmanual@pretty@pgfkeys@checkforEOI + ,% + \else + \ifnum10=\catcode`#1 + % another white space... I thought they'd have + % catcode 13. doesn't matter. + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lbrace + % braces may not occur in the first place - + % but there are circumstances where it is + % convenient to deal with them here (when + % processing arguments of styles) + % Do it. + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@rbrace + #1% + \else + % found the beginning of a key! + % We will collect the key name into + % \toks0. + \toks0={}% + % + % Handle it: + % FIXME what if we found an opening brace!? + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\pgfmanual@pretty@pgfkeys@collectkey #1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@pgfkeys@loop@NEXT +}% +\def\pgfmanual@pretty@pgfkeys@collectkey#1{% + \def\pgfmanual@loc@TMPb{#1}% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@collectkey}% + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + % finish key name. + \edef\pgfmanual@loc@TMPb{\the\toks0 }% + \ifx\pgfmanual@loc@TMPb\pgfutil@empty + \else + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + \fi + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\relax}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@eq + % finish key name. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + % now, we do the same with the value - we collect it into + % \toks0. + \toks0={}% + \def\pgfmanual@pretty@pgfkeys@collectvalue@hasconsumedspaces{0}% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@collectvalue}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@comma + % finish key name. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@activenl + % finish key name before newline. This is not + % necessarily as in TeX, but its simpler here + % because we don't need special cases for comments + % and we don't need to gobble following white + % spaces. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@backslash + % This is confusing. I simply try to invoke + % the control sequence code and recover as + % good as possible. Let's see if that's + % useful. + \edef\pgfmanual@loc@TMPb{\the\toks0 }% + \ifx\pgfmanual@loc@TMPb\pgfutil@empty + \else + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + \fi + % + % we found the start of a control sequence '\command': + % + % collect the control sequence name into + % \pgfmanual@loc@TMPa, but without the backslash: + \begingroup + \let\pgfmanual@loc@TMPa=\pgfutil@empty + \def\afterpgfmanual@pretty@cs{% + \endgroup + \pgfmanual@pretty@pgfkeys@loop + }% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@collectcs@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@lbrace + % Braces in key names are allowed (if they + % are not the first character of a key + % name) + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \toks1={##1}% + \edef\pgfmanual@loc@TMPc{% + \the\toks0 \pgfmanual@pretty@lbrace \the\toks1 + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \pgfmanual@pretty@rbrace + \fi + }% + \toks0=\expandafter{\pgfmanual@loc@TMPc}% + }% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{% + \pgfmanualprettyprintercollectargcount{1}{\pgfmanual@pretty@pgfkeys@collectkey}% + #1% + }% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@rbrace + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \toks0=\expandafter{\the\toks0 #1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@pgfkeys@collectkey@next +}% +\def\pgfmanual@pretty@pgfkeys@collectvalue#1{% + \def\pgfmanual@loc@TMPb{#1}% + \let\pgfmanual@pretty@pgfkeys@collectvalue@next=\pgfmanual@pretty@pgfkeys@collectvalue + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + % the key value is empty. + %\expandafter\pgfmanual@pretty@pgfkeys@processvalue\expandafter{\the\toks0 }% + \let\pgfmanual@pretty@pgfkeys@collectvalue@next=\relax + \else + \def\pgfmanual@pretty@isconsumed{0}% + \if\pgfmanual@pretty@pgfkeys@collectvalue@hasconsumedspaces0% + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) + #1% + \def\pgfmanual@pretty@isconsumed{1}% + \else + \ifnum10=\catcode`#1 + % another white space... I thought they'd have + % catcode 13. doesn't matter. + \def\pgfmanual@pretty@isconsumed{1}% + #1% + \fi + \fi + \fi + \if\pgfmanual@pretty@isconsumed0% + \def\pgfmanualprettyprinterhandlecollectedargs##1{\pgfmanual@pretty@pgfkeys@processvalue{##1}}% the braces will be handled separately. + \def\pgfmanual@pretty@pgfkeys@collectvalue@next{% + \pgfmanualprettyprintercollectupto,{\afterpgfmanual@pretty@collectargs@finish@value}#1% + }% + \fi + \fi + \pgfmanual@pretty@pgfkeys@collectvalue@next +}% +\def\afterpgfmanual@pretty@collectargs@finish@value{% + \pgfutil@ifnextchar\pgfmanual@EOI{% + \pgfmanual@pretty@pgfkeys@loop + }{% + \pgfmanual@pretty@pgfkeys@loop,% re-insert the gobbled comma here! + }% +}% + +{\catcode`\^^M=13 \catcode`\ =13\relax\catcode`\%=13\relax\gdef\pgfmanual@pretty@restorespaces{\def%{\pgfmanual@pretty@percent}\def^^M{\pgfmanual@pretty@space}\def {\pgfmanual@pretty@space}}} + +% #1: the key's name +\def\pgfmanual@pretty@pgfkeys@processkey#1{% + \begingroup + \pgfmanual@pretty@restorespaces + % remember this key name! It is used when we are dealing with + % its value later... (if it has a value) + \xdef\pgfmanual@pretty@pgfkeys@collectkey@keyname{#1}% + \endgroup + % + % check if it is a handled key. FIXME: this could be done in a + % rigorous way! This here assumes that all key handlers start with + % '.' and the '.' occurs never right after a '/' otherwise: + \def\pgfmanual@loc@TMPa{\pgfutil@in@{/.}}% + \expandafter\pgfmanual@loc@TMPa\expandafter{\pgfmanual@pretty@pgfkeys@collectkey@keyname}% + \ifpgfutil@in@ + % split into key name and handler name... + \def\pgfmanual@pretty@splitit##1/.##2\relax{% + \def\pgfmanual@loc@TMPb{{##1}{.##2}}% + }% + \expandafter\pgfmanual@pretty@splitit\pgfmanual@pretty@pgfkeys@collectkey@keyname\relax + % + % report key name AND handler: + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/key name with handler/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@loc@TMPb\pgfeov + \else + % report key name ... + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/key name/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@pretty@pgfkeys@collectkey@keyname\pgfeov + \fi +} +\def\pgfmanual@pretty@pgfkeys@processvalue#1{% + % report or process the value, depending on the keyname. + % After all, it *may* be a style which needs to be pretty printed + % as well. + \pgfkeysifdefined{/codeexample/prettyprint/key value/\pgfmanual@pretty@pgfkeys@collectkey@keyname/.@cmd}{% + % oh, we have a separate routine for this macro! Ok, use it: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/key value/\pgfmanual@pretty@pgfkeys@collectkey@keyname/.@cmd}}% + }{% + % use the generic routine: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/key value/.@cmd}}% + }% + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@pgfkeys@collectkey@keyname}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa{#1}\pgfeov +} + 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 index 3d0cad1b196..67d2be8c72b 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex @@ -1,3 +1,23 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + % Copyright 2008 by Christian Feuersaenger % % This file may be distributed and/or modified @@ -100,17 +120,48 @@ } % The same as \pgfmathfloatparsenumber, but does not perform sanity checking. -\def\pgfmathfloatqparsenumber#1{% +% FIXME: there is no longer any difference here. +\let\pgfmathfloatqparsenumber=\pgfmathfloatparsenumber + +% 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 flags of #1 into the macro #2. +\def\pgfmathfloatgetflagstomacro#1#2{% \begingroup - \edef\pgfmathresult{#1}% - \expandafter\pgfflt@impl\pgfmathresult\pgfflt@EOI - \ifpgfmathfloatparsenumberpendingperiod - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.0}% - \fi - \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% - \pgfmath@smuggleone\pgfmathresult + \edef\pgfmathfloat@loc@TMPa{#1}% + \expandafter\pgfmathfloat@decompose@F\pgfmathfloat@loc@TMPa\relax{\count0}% + \xdef\pgfmathfloat@glob@TMP{\the\count0 }% \endgroup + \let#2=\pgfmathfloat@glob@TMP +}% + +% 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}% +} + % Assigns \pgfmathresult to be a float encoded as % <FLAGS><MANTISSE>e<EXPONENT> @@ -121,8 +172,26 @@ % -> % \pgfmathresult is now '12.0e10' regardless of the internal float % format. -\def\pgfmathfloat@to@FMeE@style#1{\expandafter\pgfmathfloat@to@FMeE@style@#1\relax}% -\def\pgfmathfloat@to@FMeE@style@#1Y#2e#3]\relax{\def\pgfmathresult{#1#2e#3}}% +\def\pgfmathfloat@to@FMeE@style#1{\expandafter\pgfmathfloat@to@FMeE@style@#1\relax\relax}% +\def\pgfmathfloat@to@FMeE@style@#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@to@FMeE@style@@% + \else + \expandafter\pgfmathfloat@to@FMeE@style@error% + \fi + #1#2% +}% +\def\pgfmathfloat@to@FMeE@style@@#1Y#2e#3]\relax\relax{\def\pgfmathresult{#1#2e#3}}% +\def\pgfmathfloat@to@FMeE@style@error#1\relax\relax{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{% + \noexpand\pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% + }% + \endgroup + \pgfmathfloat@decompose@TMP +}% + % decomposes a lowlevel floating point representation into flags, % mantisse and exponent. @@ -130,23 +199,131 @@ % #4: integer register for the flags. % #5: dimen registers for the mantisse. % #6: integer register for the exponent. -\def\pgfmathfloat@decompose#1Y#2e#3]\relax#4#5#6{% +% +% \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E +% -> the three temp registers contain flags, mantisse and exponent +\def\pgfmathfloat@decompose#1#2{% sanitize! + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@% + \else + \expandafter\pgfmathfloat@decompose@error% + \fi + #1#2% +} +\def\pgfmathfloat@decompose@#1Y#2e#3]\relax#4#5#6{% #4=#1\relax - #5=#2pt% + #5=#2pt % keep space here. #6=#3\relax% } + % overloaded, #5 needs to be a token register for the mantisse. -\def\pgfmathfloat@decompose@tok#1Y#2e#3]\relax#4#5#6{% +% @see also \pgfmathfloatvalueof which does also employ the load +% level repr. +% \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E +% -> the three temp registers contain flags, mantisse and exponent +\def\pgfmathfloat@decompose@tok#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@tok@% + \else + \expandafter\pgfmathfloat@decompose@tok@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@tok@#1Y#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#1Y#2e#3]\relax#4{#4=#1\relax}% -\def\pgfmathfloat@decompose@M#1Y#2e#3]\relax#4{#4=#2pt}% -\def\pgfmathfloat@decompose@Mtok#1Y#2e#3]\relax#4{#4={#2}}% -\def\pgfmathfloat@decompose@E#1Y#2e#3]\relax#4{#4=#3\relax}% +% \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S +% -> \pgfmathfloat@a@S contains the flags field. +\def\pgfmathfloat@decompose@F#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@F@% + \else + \expandafter\pgfmathfloat@decompose@F@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@M#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@M@% + \else + \expandafter\pgfmathfloat@decompose@M@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@E#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@E@% + \else + \expandafter\pgfmathfloat@decompose@E@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@Mtok#1#2{% + \ifx#2Y% + \expandafter\pgfmathfloat@decompose@Mtok@% + \else + \expandafter\pgfmathfloat@decompose@Mtok@error% + \fi + #1#2% +}% +\def\pgfmathfloat@decompose@F@#1Y#2e#3]\relax#4{#4=#1\relax}% +\def\pgfmathfloat@decompose@M@#1Y#2e#3]\relax#4{#4=#2pt}% +\def\pgfmathfloat@decompose@Mtok@#1Y#2e#3]\relax#4{#4={#2}}% +\def\pgfmathfloat@decompose@E@#1Y#2e#3]\relax#4{#4=#3\relax}% +\def\pgfmathfloat@decompose@error#1\relax#2#3#4{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{% + \noexpand#2=\the\pgfmathfloat@a@S\space + \noexpand#3=\the\pgfmathfloat@a@Mtok pt + \noexpand#4=\the\pgfmathfloat@a@E\space + }% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@tok@error#1\relax#2#3#4{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{% + \noexpand#2=\the\pgfmathfloat@a@S\space + \noexpand#3={\the\pgfmathfloat@a@Mtok}% + \noexpand#4=\the\pgfmathfloat@a@E\space + }% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@F@error#1\relax#2{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{\noexpand#2=\the\pgfmathfloat@a@S\space}% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@M@error#1\relax#2{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{\noexpand#2=\the\pgfmathfloat@a@Mtok pt }% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@Mtok@error#1\relax#2{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{\noexpand#2={\the\pgfmathfloat@a@Mtok}}% + \endgroup + \pgfmathfloat@decompose@TMP +}% +\def\pgfmathfloat@decompose@E@error#1\relax#2{% + \begingroup + \pgfmathfloatparsenumber@handleerror{wrong lowlevel format}{#1}{#1}% + \xdef\pgfmathfloat@decompose@TMP{\noexpand#2=\the\pgfmathfloat@a@E\space}% + \endgroup + \pgfmathfloat@decompose@TMP +}% % 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{% @@ -161,34 +338,6 @@ \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. @@ -250,6 +399,23 @@ }% \let\pgfmathfloattosci=\pgfmathfloattosci@ +% Expands a floating point number to scientific format 1.234e5. +% +% This operation is very fast. +\def\pgfmathfloatvalueof#1{\expandafter\pgfmathfloatvalueof@@#1\relax}% +\def\pgfmathfloatvalueof@@#1Y#2e#3]\relax{% + \ifcase#1 % + 0.0e0% + \or + #2e#3% + \or + -#2e#3% + \or nan% + \or inf% + \or -inf% + \fi +}% + % Rounds a fixed point number #1 to \pgfmathfloat@round@precision digits precision and returns % the result into \pgfmathresult. @@ -1489,14 +1655,29 @@ /pgf/fpu/handlers/empty number/.style 2 args={% /pgf/fpu/handlers/invalid number={#1}{#2}% }, + /pgf/fpu/empty number is zero/.style={% + /pgf/fpu/handlers/empty number/.code 2 args={% + \pgfmathfloatcreate{0}{0.0}{0}% + }% + },% /pgf/fpu/handlers/invalid number/.code 2 args={% \pgfmath@error{Could not parse input '#1' as a floating point number, sorry. The unreadable part was near '#2'.}{}% }, + /pgf/fpu/handlers/wrong lowlevel format/.code 2 args={% + \pgfmath@error{Sorry, an internal routine of the floating point unit got an ill-formatted floating point number `#1'. The unreadable part was near '#2'.}{}% + \let\pgfmathresult=\pgfutil@empty + }, } % #1 the error handler % #2 the number which was invalid. % #3 the part which produced the error +% +% POSTCONDITION: the three registers +% \pgfmathfloat@a@S +% \pgfmathfloat@a@Mtok +% \pgfmathfloat@a@E +% will contain the number which results from the error handler. \def\pgfmathfloatparsenumber@handleerror#1#2#3{% \let\pgfmathresult=\pgfutil@empty \pgfmathfloatparsenumberpendingperiodfalse @@ -1545,45 +1726,47 @@ \pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}% \expandafter\def\csname pgffltA@n\endcsname{\pgfflt@readnan}% FIXME: inlining? -\expandafter\def\csname pgffltA@N\endcsname{\pgfflt@readNaN}% FIXME: inlining? +\expandafter\def\csname pgffltA@N\endcsname{\pgfflt@readnan}% FIXME: inlining? \expandafter\def\csname pgffltA@i\endcsname{\pgfflt@readinf}% FIXME: inlining? -\expandafter\def\csname pgffltA@I\endcsname{\pgfflt@readINF}% FIXME: inlining? +\expandafter\def\csname pgffltA@I\endcsname{\pgfflt@readinf}% FIXME: inlining? +\expandafter\def\csname pgffltA@.\endcsname{% read '.9' like '0.9' + \pgfmathfloat@a@E=-1 + \pgfflt@leadingzero@foundperiod}% \def\pgfflt@finish#1\pgfflt@EOI{} -\def\pgfflt@readnan an{% - \pgfmathfloat@a@S=3\relax% - \pgfmathfloat@a@Mtok={0.0}% - \pgfmathfloat@a@E=0% - \pgfflt@finish -} -\def\pgfflt@readNaN aN{% - \pgfmathfloat@a@S=3\relax% - \pgfmathfloat@a@Mtok={0.0}% - \pgfmathfloat@a@E=0% - \pgfflt@finish -} -\def\pgfflt@readinf nf{% - \ifnum\pgfmathfloat@a@S=1 - \pgfmathfloat@a@S=4\relax% +\def\pgfflt@readnan #1#2{% + \def\pgfflt@readnan@ok{1}% + \if#1a\else\if#1A\else\def\pgfflt@readnan@ok{0}\fi\fi + \if#2n\else\if#2N\else\def\pgfflt@readnan@ok{0}\fi\fi + \if\pgfflt@readnan@ok1% + \pgfmathfloat@a@S=3\relax% \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \expandafter\pgfflt@finish \else - \pgfmathfloat@a@S=5\relax% - \pgfmathfloat@a@Mtok={0.0}% + \def\pgfflt@readnan@{\pgfflt@error #1#2}% + \expandafter\pgfflt@readnan@ \fi - \pgfmathfloat@a@E=0% - \pgfflt@finish } -\def\pgfflt@readINF NF{% - \ifnum\pgfmathfloat@a@S=1 - \pgfmathfloat@a@S=4\relax% - \pgfmathfloat@a@Mtok={0.0}% +\def\pgfflt@readinf #1#2{% + \def\pgfflt@readinf@ok{1}% + \if#1n\else\if#1N\else\def\pgfflt@readinf@ok{0}\fi\fi + \if#2f\else\if#2F\else\def\pgfflt@readinf@ok{0}\fi\fi + \if\pgfflt@readinf@ok1% + \ifnum\pgfmathfloat@a@S=1 % + \pgfmathfloat@a@S=4 % + \pgfmathfloat@a@Mtok={0.0}% + \else + \pgfmathfloat@a@S=5 % + \pgfmathfloat@a@Mtok={0.0}% + \fi + \pgfmathfloat@a@E=0 % + \expandafter\pgfflt@finish \else - \pgfmathfloat@a@S=5\relax% - \pgfmathfloat@a@Mtok={0.0}% + \def\pgfflt@readinf@{\pgfflt@error #1#2}% + \expandafter\pgfflt@readinf@ \fi - \pgfmathfloat@a@E=0% - \pgfflt@finish } \def\pgfflt@leadingzero#1{% \expandafter\ifx\csname pgffltB@#1\endcsname\relax @@ -1693,7 +1876,19 @@ }% \def\pgfflt@readexponent#1\pgfflt@EOI{% - \advance\pgfmathfloat@a@E by#1\relax + \afterassignment\pgfflt@readexponent@ + \pgfmathfloat@b@E=#1\relax\pgfflt@EOI +} +\def\pgfflt@readexponent@{% + \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E\relax + \afterassignment\pgfflt@readexponent@@ + \let\pgfmathfloat@loc@TMPb=}% +\def\pgfflt@readexponent@@#1\pgfflt@EOI{% + \ifx\pgfmathfloat@loc@TMPb\relax + \else + \def\pgfmathfloat@loc@TMPb{\pgfflt@error#1\pgfflt@EOI}% + \expandafter\pgfmathfloat@loc@TMPb + \fi } \def\pgfflt@pendingzeros@positiveexp#1{% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty new file mode 100644 index 00000000000..eefc385245e --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty @@ -0,0 +1,127 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + +% 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. +% +% In addition to the above licenses, this particular file may also be +% directly inlined into other documents and this copyright notice may +% be removed. Additionally, when you inline this file, you may modify +% it as needed and you may remove comments. +% +% This file is intended to be distributed or even inlined into a file +% when a document needs to be typeset on a system that does not have +% pgf/TikZ installed. +% +% It replaces \tikzpicture/ \endtikzpicture and \tikz and invokes the +% \includegraphics with the correct file name instead. + +\RequirePackage{graphicx} + +\toksdef\t@tikzexternal@tmpa=0 +\toksdef\t@tikzexternal@tmpb=1 + +\def\tikzexternalize{\@ifnextchar[{\tikzexternalize@opt}{\tikzexternalize@opt[]}}% +\def\tikzexternalize@opt[#1]#2{\def\tikzexternal@realjob{#2}} + +\def\tikzsetnextfilename#1{\gdef\tikzexternal@nextfile{#1}} +\def\tikzsetexternalprefix#1{\def\tikzexternal@filenameprefix{#1}} +\def\tikzsetfigurename#1{\def\tikzexternal@figurename{#1}}% +\tikzsetnextfilename{} +\tikzsetexternalprefix{} +\tikzsetfigurename{\tikzexternal@realjob-figure}% + +\long\def\tikzpicture#1\end#2{% collect every thing up to \end{tikzpicture} + \def\tikzexternal@laTeX@collectpicture@@{#2}% + \ifx\tikzexternal@laTeX@collectpicture@@\tikzexternal@laTeX@tikzpicturestring + \tikzexternal@image + \end{tikzpicture}% + \else + \expandafter + \tikzpicture + \fi +}% +\def\endtikzpicture{} +\def\tikzexternal@laTeX@tikzpicturestring{tikzpicture}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Replacement for \tikz short command: +\def\tikz{\@ifnextchar[{\tikz@opt}{\tikz@opt[]}} +\def\tikz@opt[#1]{\@ifnextchar\bgroup{\tikz@opt@{#1}}{\tikz@opt@@{#1}}} +\def\tikz@opt@#1#2{\tikz@opt@process{#1}{#2}} +\def\tikz@opt@@#1{% + \def\tikz@next{\tikz@collectnormalsemicolon{#1}}% + \ifnum\the\catcode`\;=\active\relax% + \def\tikz@next{\tikz@collectactivesemicolon{#1}}% + \fi% + \tikz@next} +\def\tikz@collectnormalsemicolon#1#2;{\tikz@opt@process{#1}{#2;}} +{ + \catcode`\;=\active + \gdef\tikz@collectactivesemicolon#1#2;{% + \tikz@opt@process{#1}{#2;}% + } +} +\def\tikz@opt@process#1#2{\tikzexternal@image} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\tikzexternal@image{% + \leavevmode + \begingroup + \t@tikzexternal@tmpa=\expandafter{\tikzexternal@filenameprefix}% + \ifx\tikzexternal@nextfile\empty + \expandafter\ifx\csname c@tikzext@no@\tikzexternal@figurename\endcsname\relax + \expandafter\gdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{0}% + \fi + \t@tikzexternal@tmpb=\expandafter{\tikzexternal@figurename}% + \count0=\csname c@tikzext@no@\tikzexternal@figurename\endcsname + \xdef\tikzexternal@curfilename{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb\the\count0 }% + \advance\count0 by1\relax + \expandafter\xdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{\the\count0 }% + \else + \t@tikzexternal@tmpb=\expandafter{\tikzexternal@nextfile}% + \xdef\tikzexternal@curfilename{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb}% + \fi + \endgroup + \global\let\tikzexternal@nextfile=\empty + \tikzexternalimage\tikzexternal@curfilename +}% +\def\tikzexternalimage#1{% + % now check for (optional) .dpth files for the 'baseline' option: + \begingroup + \setbox1=\hbox{\includegraphics{#1}}% + \openin1=#1.dpth + \ifeof1 \box1 + \else + \read1 to\pgfincludeexternalgraphics@dp \closein1 + \dimen0=\pgfincludeexternalgraphics@dp\relax + \hbox{\lower\dimen0\box1}% + \fi + \endgroup +} +\def\tikzset#1{}\def\pgfkeys#1{}\def\pgfqkeys#1#2{} +\long\def\beginpgfgraphicnamed#1#2\endpgfgraphicnamed{\tikzexternalimage{#1}} + diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex new file mode 100644 index 00000000000..1993db33660 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex @@ -0,0 +1,1031 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + +% 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 here is the shared implementation of TeX-dialect specific files +% tikzlibraryexternal.code.tex +% ****************************** +% +% +% This file provides a high-level automatic export feature for tikz pictures. +% It allows to export EACH SINGLE FIGURE into a separate PDF. +% +% The simplest way is to use the 'convert with system call' option; it simply converts every figure using the write18 method. If that is not possible, a list of figure file names is generated and you need to generate these figures manually (or with a script). +% +% +% It replaces \tikzpicture/ \endtikzpicture and \tikz and invokes \beginpgfgraphicnamed ... \endpgfgraphicnamed +% commands if necessary. + +% handle with extreme care and only in small, local groups: +\toksdef\t@tikzexternal@tmpa=0 +\toksdef\t@tikzexternal@tmpb=1 + +\newwrite\tikzexternal@outfile +\newif\iftikzexternal@nestedflag +\newif\iftikzexternal@verboseio +\newif\iftikzexternal@genfigurelist +\newif\iftikzexternal@onlynamed +\newif\iftikzexternal@file@isuptodate +\newif\iftikzexternal@force@remake +\newif\iftikzexternal@optimize +\newif\iftikzexternal@export@enabled +\tikzexternal@export@enabledtrue + +% This 'if' can be used as part of the public user interface. +% +% It is set by the 'remake next' key. +% +% It disables any up-to-date checks for the *next* picture, forcing a +% remake of it. +% +% It applies only to *one* picture. +\newif\iftikzexternalremakenext +\newif\iftikzexternal@verbose@optimize +\tikzexternal@verbose@optimizetrue + +% A global boolean which can be used to skip single figures. +\newif\iftikzexternalexportnext +\tikzexternalexportnexttrue + +% Invokes '#1' if the external lib is currently externalizing +% something and '#2' if not. +% +% This command must be called *after* \tikzexternalize. +\def\tikzifexternalizing#1#2{% + \ifpgf@external@grabshipout #1\else #2\fi +}% +% Invokes '#1' if the external lib is currently externalizing the NEXT FOLLOWING +% tikzpicture. It invokes '#2' if that is not the case. +\def\tikzifexternalizingnext#1#2{% + \ifpgf@external@grabshipout + \tikzexternalgetnextfilename\tikzexternal@temp + \tikzifexternaljobnamematches\tikzexternal@temp{#1}{#2}% + \else + #2 + \fi +}% + +% Invokes '#2' if \jobname equals '#1' and '#3' if not. +% I suppose that '#1' is a macro containing the file name. +% +\def\tikzifexternaljobnamematches#1#2#3{% + \edef\pgf@tempa{\expandafter\string\csname#1\endcsname}% + \edef\pgf@tempb{\expandafter\string\csname\jobname\endcsname}% + \ifx\pgf@tempa\pgf@tempb #2\else#3 \fi% +}% + +\pgfqkeys{/tikz/external}{ + figure list/.is if=tikzexternal@genfigurelist, + figure list=true, + % 'mode' applies only if \jobname==real job name. + mode/.is choice, + mode/only graphics/.code = {\def\tikzexternal@opmode{0}}, + mode/no graphics/.code = {\def\tikzexternal@opmode{1}}, + % an alias for 'no graphics:' + mode/only pictures/.code = {\def\tikzexternal@opmode{1}}, + mode/graphics if exists/.code= {\def\tikzexternal@opmode{2}}, + mode/list only/.code = {\def\tikzexternal@opmode{3}\tikzexternal@genfigurelisttrue}, + mode/convert with system call/.code={\def\tikzexternal@opmode{4}\tikzexternal@genfigurelistfalse}, + mode/list and make/.code = {\def\tikzexternal@opmode{5}\tikzexternal@genfigurelisttrue}, + mode=convert with system call, + system call/.initial={pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}, +% system call/.initial={pdflatex -interaction=batchmode -jobname '\image' '\texsource'; pdftops -eps \image.pdf}, + force remake/.is if=tikzexternal@force@remake, + force remake/.default=true, + export next/.is if=tikzexternalexportnext, + export/.is if=tikzexternal@export@enabled, + remake next/.is if=tikzexternalremakenext, + remake next/.default=true, + verbose IO/.is if=tikzexternal@verboseio, + verbose IO/.default=true, + verbose IO=true, + verbose optimize/.is if=tikzexternal@verbose@optimize, + optimize/.is choice, + optimize/true/.code={% + \tikzexternal@optimizetrue + \iftikzexternal@optimize + \ifpgf@external@grabshipout + % we have already started the externalization! Install + % optimization commands to activate the new one: + \tikzexternal@optimize@REPLACE + \fi + \fi + }, + optimize/false/.code={% + \tikzexternal@optimizefalse% + \tikzexternal@optimize@RESTORE + },% + optimize=true, + optimize/install/.code={},% + optimize/restore/.code={},% + % Expects two arguments, the command name and (optionally) a count + % of expected arguments. + % Example: + % 'optimize command away=\includegraphics' + % 'optimize command away={\mycommand}{3}' + % + % It accepts commands which have '[]' arguments and whose first + % argument always begins with '{'. + % + % #1: the command name + % #2: either empty or a number of EXPECTED arguments. It will be checked + % for one optional argument in square brackets as well. + optimize command away/.code 2 args={% + \expandafter\global\expandafter\let\csname\string#1@ORIG\endcsname=#1% + \pgfkeysalso{% + /tikz/external/optimize/install/.append code={% + \def#1{\tikzexternal@optimize@away@cmd{#1}{#2}}% + }, + /tikz/external/optimize/restore/.append code={% + \expandafter\let\expandafter#1\csname\string#1@ORIG\endcsname + } + }% + \iftikzexternal@optimize + \ifpgf@external@grabshipout + % we have already started the externalization! Install + % optimization commands to activate the new one: + \tikzexternal@optimize@REPLACE + \fi + \fi + }, + optimize command away=\includegraphics, + % EXPERIMENTAL (UNTESTED): + optimize latex env away/.code={% + \expandafter\let\expandafter\pgf@tempa\csname #1\endcsname + \expandafter\global\expandafter\let\csname #1@ORIG\endcsname=\pgf@tempa% + \pgfkeysalso{% + /tikz/external/optimize/install/.append code={% + \pgfutil@namedef{#1}{\tikzexternal@optimize@away@latex@env{#1}}% + }, + /tikz/external/optimize/restore/.append code={% + \pgfutil@namelet{#1}{#1@ORIG}% + }% + }% + }, + only named/.is if=tikzexternal@onlynamed, + only named/.default=true, + figure name/.initial=\tikzexternal@realjob-figure, + reset counter/.code={% + \expandafter\gdef\csname c@tikzext@no@#1\endcsname{0}% + },% + prefix/.code={\tikzsetexternalprefix{#1}}, +} + +\def\tikzsetfigurename#1{\pgfkeyssetvalue{/tikz/external/figure name}{#1}}% + +% This method sets the file name prefix used for every import/export. +% +% It is invoked by the '/tikz/external/prefix' key. +\def\tikzsetexternalprefix#1{\def\tikzexternal@filenameprefix{#1}} +\tikzsetexternalprefix{} + +% This method initialises automatic externalization. +% +% The first argument is the job's real name, without suffix. +% +% \tikzexternalize{myarticle} +% +% Doing so will +% 1. automatically surround EVERY tikzpicture by \beginpgfgraphicnamed % sections. +% 2. in case that the job's real name and the current \jobname differ, +% it will process ONLY the matching tikzpicture. +\def\tikzexternalize{% + \pgfutil@ifnextchar[{% + \tikzexternalize@opt + }{% + \tikzexternalize@opt[]% + }% +}% +\def\tikzexternalize@hasbeencalled{0}% +\def\tikzexternalize@opt[#1]#2{% + \pgfqkeys{/tikz/external}{#1}% + \def\tikzexternal@realjob{#2}% + \pgfrealjobname{#2}% + \def\tikzexternalize@hasbeencalled{1}% + \tikzexternalenable + \def\tikzexternal@determineimgextension##1:##2\relax{\gdef\tikzexternal@imgext{##1}}% + \xdef\pgf@tempa{\pgfsys@imagesuffixlist}% + \expandafter\tikzexternal@determineimgextension\pgf@tempa\relax + \pgfutil@ifundefined{includegraphics}{% + \let\tikzexternal@orig@includegraphics=\relax + }{% + \let\tikzexternal@orig@includegraphics=\includegraphics + }% +} + +% can be used to (temporarily) disable the externalization. +\def\tikzexternaldisable{% + \let\tikz=\tikzexternal@origtikz + \tikzexternal@TEXDIALECT@restore@picture + \pgfutil@ifundefined{tikzexternal@orig@tikzfadingfrompicture} + {}% NOP + {% + \let\tikzfadingfrompicture=\tikzexternal@orig@tikzfadingfrompicture + \let\endtikzfadingfrompicture=\tikzexternal@orig@endtikzfadingfrompicture + \let\tikzfading=\tikzexternal@orig@tikzfading + }% + \iftikzexternal@optimize + \ifpgf@external@grabshipout + \tikzexternal@optimize@RESTORE + \fi + \fi +}% +% re-enables externalization after a \tikzexternalizedisable. +\def\tikzexternalenable{% + \if\tikzexternalize@hasbeencalled1% + \let\tikz=\tikzexternal@tikz@replacement + \tikzexternal@TEXDIALECT@installreplacement@picture + \pgfutil@ifundefined{tikzfadingfrompicture}% + {}% no special handling for 'fading lib' + {% + % oh, ok -- patch fading lib! + \pgfutil@ifundefined{tikzexternal@orig@tikzfadingfrompicture}{% + \let\tikzexternal@orig@tikzfadingfrompicture=\tikzfadingfrompicture + \let\tikzexternal@orig@endtikzfadingfrompicture=\endtikzfadingfrompicture + \let\tikzexternal@orig@tikzfading=\tikzfading + }{}% + \def\tikzfadingfrompicture{% + \begingroup + \tikzexternaldisable + \tikzexternal@orig@tikzfadingfrompicture}% + \def\endtikzfadingfrompicture{% + \tikzexternal@orig@endtikzfadingfrompicture + \endgroup}% + \def\tikzfading[##1]{% + \begingroup + \tikzexternaldisable + \tikzexternal@orig@tikzfading[##1]% + \endgroup}% + }% + \iftikzexternal@optimize + \ifpgf@external@grabshipout + \tikzexternal@optimize@REPLACE + \fi + \fi + \fi +}% + +% Sets the filename for the next tikzpicture or \tikz shortcommand. +% +% It will *only* be used for the next picture. +% +% If you don't call \tikzsetnextfilename for a picture, a file name +% will be assembled automatically. +% +% Please note that the global file prefix will be prepended anyway. +\def\tikzsetnextfilename#1{\gdef\tikzexternal@nextfile{#1}} +\tikzsetnextfilename{} + + +% These are few TeX dialect-specific commands which need to be overriden when used with +% something different than plain TeX: +% +% 1. this command collects a complete image into a macro, up to (but not including) the +% final TeX-dialect specific end-image command. +% This is really difficult for LaTeX because \end{tikzpicture} either involves dirty +% catcode-hacks to parse the braces or an ugly loop which loops until it +% finds \end followed by {tikzpicture}. +% +% #1: a macro which will be called with the collected environment contents. +% all following tokens: the environment contents. +\long\gdef\tikzexternal@TEXDIALECT@collectpicture#1#2\endtikzpicture{#1{#2}} +% +% 2. the following commands should expand to the TeX-dialect specific begin and end image command, i.e. +% \tikzpicture / \endtikzpicture +% or +% \begin{tikzpicture} / \end{tikzpicture} +% or +% \starttikzpicture / \stoptikzpicture +\def\tikzexternal@TEXDIALECT@begpicture{\tikzpicture} +\def\tikzexternal@TEXDIALECT@endpicture{\endtikzpicture}% +% +% 3. This installs the replacement macros: +\def\tikzexternal@TEXDIALECT@installreplacement@picture{% + \let\tikzpicture=\tikzexternal@tikzpicture@replacement +}% +\def\tikzexternal@TEXDIALECT@restore@picture{% + \let\tikzpicture=\tikzexternal@origpicture +}% + + + + +\let\tikzexternal@origtikz=\tikz +\let\tikzexternal@origpicture=\tikzpicture +\let\tikzexternal@origendpicture=\endtikzpicture + +% Replacement for '\tikzpicture'. +% +% There are two different states in which this method is applied: +% - normal typesetting. Then, the 'mode' key controls its behavior. +% - externalize mode (i.e. jobname != real job name). Then, it will +% externalize the picture selected by 'jobname' (and only this picture). +\def\tikzexternal@tikzpicture@replacement{% + \leavevmode + \tikzexternal@getnextfilename\tikzexternal@curfilename + \ifx\tikzexternal@curfilename\pgfutil@empty + \ifpgf@external@grabshipout + % This picture won't be externalized. + % But maybe we can optimize it away: + \iftikzexternal@optimize + % -> it won't be shipped out anyway, so save typesetting time! + \let\tikzexternal@next=\tikzexternal@skipfigure + \else + % include this graphics into the output (even if + % it will be discarded anyway). + \let\tikzexternal@next=\tikzexternal@normalpicture@nographics + \fi + \else + \let\tikzexternal@next=\tikzexternal@normalpicture@nographics + \fi + \else + \ifpgf@external@grabshipout + \tikzifexternaljobnamematches\tikzexternal@curfilename{% + % ok, this here IS the picture for which + % pdflatex --jobname <my name> + % has been invoked. + \let\tikzexternal@next=\tikzexternal@externalizefig + }{% + \iftikzexternal@optimize + % No, another picture should be exported. Simply skip this one + % -> it won't be shipped out anyway, so save typesetting time! + \let\tikzexternal@next=\tikzexternal@skipfigure + \else + % include this graphics into the output (even it + % it will be discarded anyway). + \let\tikzexternal@next=\tikzexternal@normalpicture@nographics + \fi + }% + \else + \ifcase\tikzexternal@opmode\relax + % 'mode=only graphics' + \let\tikzexternal@next=\tikzexternal@forcegraphics + \or + % 'mode=no graphics' + \let\tikzexternal@next=\tikzexternal@normalpicture@nographics + \or + % 'mode=graphics if exists' + \let\tikzexternal@next=\tikzexternal@externalizefig + \or + % 'mode=list only' + \let\tikzexternal@next=\tikzexternal@listmodepicture + \or + % 'mode=convert with system call' + \let\tikzexternal@next=\tikzexternal@externalizefig@systemcall + \or + % 'mode=list and make' + \let\tikzexternal@next=\tikzexternal@list@and@makefile@mode@picture + \fi + \fi + \fi + \tikzexternal@next +}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Replacement for \tikz short command: +\def\tikzexternal@tikz@replacement{% + \pgfutil@ifnextchar[{\tikzexternal@tikz@replacement@opt}{\tikzexternal@tikz@replacement@opt[]}% +}% +\def\tikzexternal@tikz@replacement@opt[#1]{% + \pgfutil@ifnextchar\bgroup{\tikzexternal@tikz@replacement@opt@{#1}}{\tikzexternal@tikz@replacement@opt@@{#1}}% +} +\long\def\tikzexternal@tikz@replacement@opt@#1#2{% + \tikzexternal@tikz@replacement@opt@process{#1}{#2}% +}% +\def\tikzexternal@tikz@replacement@opt@@#1{% + \def\tikz@next{\tikzexternal@tikz@replacement@collectnormalsemicolon{#1}}% + \ifnum\the\catcode`\;=\active\relax% + \def\tikz@next{\tikzexternal@tikz@replacement@collectactivesemicolon{#1}}% + \fi% + \tikz@next} +\long\def\tikzexternal@tikz@replacement@collectnormalsemicolon#1#2;{% + \tikzexternal@tikz@replacement@opt@process{#1}{#2;}% +}% +{ + \catcode`\;=\active + \long\gdef\tikzexternal@tikz@replacement@collectactivesemicolon#1#2;{% + \tikzexternal@tikz@replacement@opt@process{#1}{#2;}% + } +} +\long\def\tikzexternal@tikz@replacement@opt@process#1#2{% + \begingroup + \t@tikzexternal@tmpa=\expandafter{\tikzexternal@TEXDIALECT@begpicture[#1]#2}% + \t@tikzexternal@tmpb=\expandafter{\tikzexternal@TEXDIALECT@endpicture}% + \xdef\pgf@tempa{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb}% + \endgroup + \pgf@tempa +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\tikzexternal@getnextfilename@advancecount{% + \begingroup + \c@pgf@counta=\csname c@tikzext@no@\tikzexternal@figurename\endcsname\relax + \advance\c@pgf@counta by1 + \expandafter\xdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{\the\c@pgf@counta}% + \endgroup +}% + +% Returns the file name which will be used for the next tikzpicture (based on the currently available information only, of course). +\def\tikzexternalgetnextfilename#1{% + \begingroup + \let\tikzexternal@getnextfilename@advancecount\relax% NOP + \tikzexternal@getnextfilename#1% + \pgfmath@smuggleone#1% + \endgroup +}% + +% Fills #1 with a filename for the current picture. +% +% The filename will be generated automatically by appending '-figure<number>' to the real jobname. +% +% This method deals with +% - \tikzsetnextfilename +% - \tikzexternalexportnextfalse +% +% It returns #1={} if the current figure shall NOT be exported. +% +% Please note that both, \tikzsetnextfilename and \tikzexternalexportnextfalse +% affect only ONE picture. They will be reset afterwards. +\def\tikzexternal@getnextfilename#1{% + \let#1=\pgfutil@empty + % determine next file name: + \iftikzexternal@export@enabled + \iftikzexternalexportnext + \begingroup + \t@tikzexternal@tmpa=\expandafter{\tikzexternal@filenameprefix}% + \ifx\tikzexternal@nextfile\pgfutil@empty + \iftikzexternal@onlynamed + \xdef\pgf@tempa{}% + \else + \pgfkeysgetvalue{/tikz/external/figure name}\tikzexternal@figurename + \pgfutil@ifundefined{c@tikzext@no@\tikzexternal@figurename}{% + % initialise on first usage: + \expandafter\gdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{0}% + }{}% + \t@tikzexternal@tmpb=\expandafter{\tikzexternal@figurename}% + \xdef\pgf@tempa{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb\csname c@tikzext@no@\tikzexternal@figurename\endcsname}% + % advance the counter for 'figure name': + \tikzexternal@getnextfilename@advancecount + \fi + \else + \t@tikzexternal@tmpb=\expandafter{\tikzexternal@nextfile}% + \xdef\pgf@tempa{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb}% + \fi + \endgroup + \let#1=\pgf@tempa + \fi + \fi + % + % Reset global flags: + \global\let\tikzexternal@nextfile=\pgfutil@empty + \global\tikzexternalexportnexttrue + % + % Handle verbose output: + \ifpgf@external@grabshipout% + \else + \iftikzexternal@genfigurelist + \ifx#1\pgfutil@empty + \else + \pgfutil@ifundefined{tikzexternal@listmode@openedfile}{% + \message{Opening '\tikzexternal@realjob.figlist' for writing.}% + \immediate\openout\tikzexternal@outfile=\tikzexternal@realjob.figlist\relax + \gdef\tikzexternal@listmode@openedfile{1}% + \if\tikzexternal@opmode5% mode='list and make' + \iftikzexternal@verboseio + \immediate\write16{Opening '\tikzexternal@realjob.makefile' for writing.}% + \fi + \begingroup + % this makes \tikzexternal@outmakefile global: + \globaldefs=1 + % this gets round '\outer\newwrite' in plain TeX: + \csname newwrite\endcsname\tikzexternal@outmakefile + \endgroup + \immediate\openout\tikzexternal@outmakefile=\tikzexternal@realjob.makefile\relax + \immediate\write\tikzexternal@outmakefile{ALL_FIGURE_NAMES=\tikzexternal@DOLLARchar(shell cat \tikzexternal@realjob.figlist)}% + \immediate\write\tikzexternal@outmakefile{ALL_FIGURES=\tikzexternal@DOLLARchar(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar\tikzexternal@imgext)}% + \immediate\write\tikzexternal@outmakefile{}% + \immediate\write\tikzexternal@outmakefile{allimages: \tikzexternal@DOLLARchar(ALL_FIGURES)}% + \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar @echo All images exist now. Use make -B to re-generate them.}% + \immediate\write\tikzexternal@outmakefile{}% + \pgfutil@ifundefined{AtEndDocument}{}{% + \AtEndDocument{\immediate\write16{===== mode=`list and make': Use 'make -f \tikzexternal@realjob.makefile' to generate all images. Then, re-run (pdf)latex \tikzexternal@realjob. =====}}% + }% + \fi + }{}% + \iftikzexternal@verboseio + \immediate\write16{Writing '#1' to '\tikzexternal@realjob.figlist'.}% + \fi + \immediate\write\tikzexternal@outfile{#1}% + \if\tikzexternal@opmode5% mode='list and make' + \tikzexternal@assemble@systemcall{\pgf@tempa}% + \iftikzexternal@verboseio + \immediate\write16{Writing '#1' to '\tikzexternal@realjob.makefile'.}% + \fi + \immediate\write\tikzexternal@outmakefile{#1\tikzexternal@imgext:}% + \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar\pgf@tempa}% + \immediate\write\tikzexternal@outmakefile{}% + \fi + \fi + \fi + \fi +}% + +% This command is invoked +% if and only if ( (grab mode && --jobname matches) || 'mode=graphics if exists' ) +% +% It converts the current tikzpicture into an image in grab mode +% or processes the 'graphics if exist' mode. +\def\tikzexternal@externalizefig{% + \ifpgf@external@grabshipout% + % In this case, we already KNOW that the filename matches. + \expandafter\tikzexternal@externalizefig@GRAB% + \else + \expandafter\tikzexternal@externalizefig@mode@graphics@if@exists + \fi% +} +\def\tikzexternal@externalizefig@mode@graphics@if@exists{% + % check if there is already a file. + % In that case, use it. If not, typeset the picture normally. + \gdef\pgf@filename{}% + \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}% + \pgf@tempa + \ifx\pgf@filename\pgfutil@empty% + % Note: since we have no 'GRAB' mode, we do not have to deal with optimization. + % there is no graphics. + \expandafter\tikzexternal@normalpicture@nographics + \else + \expandafter\tikzexternal@forcegraphics + \fi +}% + +\def\tikzexternal@externalizefig@GRAB{% + \iftikzexternal@optimize + \ifpgf@external@grabshipout + \tikzexternal@optimize@RESTORE + \fi + \fi + \def\tikzpicture{% + \def\tikzpicture{% make sure that nested \tikzpicture are processed normally. + \begingroup + \def\endtikzpicture{% + \tikzexternal@origendpicture + \endgroup + }% + \tikzexternal@origpicture + }% + \pgf@external@grab{\tikzexternal@curfilename}% + \tikzexternal@origpicture + }% + \def\endtikzpicture{% + \tikzexternal@origendpicture + \pgf@externalend + \let\tikzpicture=\tikzexternal@tikzpicture@replacement + \let\endtikzpicture=\tikzexternal@origendpicture + \iftikzexternal@optimize + \ifpgf@external@grabshipout + \tikzexternal@optimize@REPLACE + \fi + \fi + }% + \tikzpicture +}% + +% FIXME : this does not respect catcode changes! +%-------------------------------------------------- +% \long\def\tikzexternal@externalizefig@@#1{% +% \let\tikzpicture=\tikzexternal@origpicture +% \iftikzexternal@optimize +% \ifpgf@external@grabshipout +% \tikzexternal@optimize@RESTORE +% \fi +% \fi +% \expandafter\beginpgfgraphicnamed\expandafter{\tikzexternal@curfilename}% +% \tikzpicture +% #1 +% \endtikzpicture +% \endpgfgraphicnamed +% \let\tikzpicture=\tikzexternal@tikzpicture@replacement +% \iftikzexternal@optimize +% \ifpgf@external@grabshipout +% \tikzexternal@optimize@REPLACE +% \fi +% \fi +% \tikzexternal@closeenvironments +% }% +%-------------------------------------------------- + +% Used by the optimization code. +% It will be called if GRAB mode is on. +% See the 'optimize command away' key. +\def\tikzexternal@optimize@away@cmd#1#2{% + \pgfutil@ifnextchar[{% + \tikzexternal@optimize@away@cmd@{#1}{#2}% + }{% + \tikzexternal@optimize@away@cmd@{#1}{#2}[]% + }% +}% +\def\tikzexternal@optimize@away@cmd@#1#2[#3]{% + \def\tikz@temp{#2}% + \ifx\tikz@temp\pgfutil@empty + \def\tikz@temp{\tikzexternal@optimize@away@cmd@auto{#1}{#3}}% + \else + \ifcase#2\relax + \def\tikzexternal@optimize@away@cmd@manual{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1##2{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1##2##3{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5##6{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}{##6}}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5##6##7{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}{##6}{##7}}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5##6##7##8{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8}}% + }% + \or + \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5##6##7##8##9{% + \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8}{##9}}% + }% + \fi + \def\tikz@temp{\tikzexternal@optimize@away@cmd@manual}% + \fi + \tikz@temp +}% +\def\tikzexternal@optimize@away@cmd@auto#1#2{% + \pgfutil@ifnextchar\bgroup{% + \tikzexternal@optimize@away@cmd@auto@{#1}{#2}% + }{% + \tikzexternal@optimize@away@cmd@auto@{#1}{#2}{<no argument in curly braces>}% give empty argument. + } +}% + +\def\tikzexternal@optimize@away@cmd@auto@#1#2#3{% + \tikzexternal@optimize@away@cmd@@@{#1}{#2}{{#3}}% <-- provide braces +}% +\def\tikzexternal@optimize@away@cmd@@@#1#2#3{% + \begingroup + \toks0={#1[#2]#3}% + \iftikzexternal@verbose@optimize + \immediate\write16{The command '\the\toks0' has been optimized away. Use '/tikz/external/optimize=false' to disable this.}% + \fi + [ {\sc \string#1\ optimized away because it does not contribute to exported PDF}]% + \endgroup +}% + +\def\tikzexternal@optimize@away@latex@env#1{% + \def\tikzexternal@optimize@away@latex@env@{#1}% + \begingroup + \def\tikzexternal@laTeX@collect@until@end@tikzpicturetikzpicturestring{#1}% + \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@optimize@away@latex@env@close +}% +\long\def\tikzexternal@optimize@away@latex@env@close#1{% + \iftikzexternal@verbose@optimize + \immediate\write16{The complete contents of \string\begin{tikzexternal@optimize@away@latex@env@} up to the next \end{tikzexternal@optimize@away@latex@env@} has been optimized away because it does not contribute to exported PDF. Use '/tikz/external/optimize=false' to disable this.}% + \fi + \endgroup + % we still need to invoke \end{<name>} in latex because \begin{<name>} + % starts a local group - that must be closed properly. Make sure then \end<name> does nothing: + \expandafter\let\csname end\tikzexternal@optimize@away@latex@env@\endcsname=\relax + \expandafter\end\expandafter{\tikzexternal@optimize@away@latex@env@}% +}% + +\def\tikzexternal@optimize@REPLACE{% + \pgfkeysvalueof{/tikz/external/optimize/install/.@cmd}\pgfeov +}% + +\def\tikzexternal@optimize@RESTORE{% + \pgfkeysvalueof{/tikz/external/optimize/restore/.@cmd}\pgfeov +}% + +% Closes one 'tikzpicture' environment. This is only used for LaTeX, +% because the '\end{tikzpicture}' command would raise an exception otherwise. +% It does *not* call \endtikzpicture. +\def\tikzexternal@closeenvironments{% + \let\endtikzpicture=\relax + \tikzexternal@TEXDIALECT@endpicture + \let\endtikzpicture=\tikzexternal@origendpicture +} + +% Throws a tikzpicture away - without further notice. +% Used if we are currently converting *another* picture. No need to waste time +% with expensive pictures if they are not shipped out anyway. +% +% See the 'optimize' key to disable this. +\def\tikzexternal@skipfigure{% + \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@skipfigure@@ +} +\long\def\tikzexternal@skipfigure@@#1{% + \iftikzexternal@verbose@optimize + \immediate\write16{A tikzpicture has been optimized away. Use '/tikz/external/optimize=false' to disable this.}% + \fi + \tikzexternal@closeenvironments +} + +% Processes tikzpicture normally; without any externalization. +% +% We need to do further work here to deal with NESTED tikzpicture environments +% because all of them shall also be typeset normally. +% +% Idea: +% 1. restore the original \tikzpicture macro +% 2. install the replacement \tikzpicture in \end{tikzpicture}. +% and keep track of nesting. +% +% FIXME: could it be possible that nested tikzpictures use other code anyway? +\def\tikzexternal@normalpicture@nographics{% + \tikzexternal@nestedflagfalse + \let\tikzpicture=\tikzexternal@normalpicture@begreplace + \let\endtikzpicture=\tikzexternal@normalpicture@endreplace + \tikzpicture +} +\def\tikzexternal@normalpicture@begreplace{% + \begingroup + \tikzexternal@nestedflagtrue + \tikzexternal@origpicture +} +\def\tikzexternal@normalpicture@endreplace{% + \tikzexternal@origendpicture + \endgroup + \iftikzexternal@nestedflag + \else + \let\tikzpicture=\tikzexternal@tikzpicture@replacement + \let\endtikzpicture=\tikzexternal@origendpicture + \fi +}% + +% Assumes there is an image on disk and reads it. The tikzpicture is thrown away. +\def\tikzexternal@forcegraphics{% + \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@forcegraphics@@ +} +\long\def\tikzexternal@forcegraphics@@#1{% + \expandafter\pgfincludeexternalgraphics\expandafter{\tikzexternal@curfilename}% + \tikzexternal@closeenvironments +} + +% Simply replaces the complete picture by some placeholder text. +% It is used by 'mode=list only' to reduce runtime. +\def\tikzexternal@listmodepicture{% + \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@listmodepicture@@ +} +\long\def\tikzexternal@listmodepicture@@#1{% + [[ {\sc Image Discarded Due To} {\tt`/tikz/external/% + \ifcase\tikzexternal@opmode\relax + mode=only graphics% + \or + mode=no graphics% + \or + mode=graphics if exists% + \or + mode=list only% + \or + mode=convert with system call% + \or + mode=list and make% + \fi + '}~]]% + \tikzexternal@closeenvironments +} + +% check if there is already a file. +% In that case, use it. If not, skip it. +\def\tikzexternal@list@and@makefile@mode@picture{% + \gdef\pgf@filename{}% + \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}% + \pgf@tempa + \ifx\pgf@filename\pgfutil@empty% + % Note: since we have no 'GRAB' mode, we do not have to deal with optimization. + % there is no graphics. + \expandafter\tikzexternal@listmodepicture + \else + \expandafter\tikzexternal@forcegraphics + \fi +}% + +\def\tikzexternal@externalizefig@GRAB{% + \iftikzexternal@optimize + \ifpgf@external@grabshipout + \tikzexternal@optimize@RESTORE + \fi + \fi + \def\tikzpicture{% + \def\tikzpicture{% make sure that nested \tikzpicture are processed normally. + \begingroup + \def\endtikzpicture{% + \tikzexternal@origendpicture + \endgroup + }% + \tikzexternal@origpicture + }% + \pgf@external@grab{\tikzexternal@curfilename}% + \tikzexternal@origpicture + }% + \def\endtikzpicture{% + \tikzexternal@origendpicture + \pgf@externalend + \let\tikzpicture=\tikzexternal@tikzpicture@replacement + \let\endtikzpicture=\tikzexternal@origendpicture + \iftikzexternal@optimize + \ifpgf@external@grabshipout + \tikzexternal@optimize@REPLACE + \fi + \fi + }% + \tikzpicture +}% + + +% 1. Discards the current picture in this document. +% 2. Checks whether an image exists already. If that is the case: acquire it. +% 3. If no image exists: call '/tikz/external/system call'. This will +% process \tikzexternal@externalizefig. +% 4. Assert that finally an image exists and use it. +\def\tikzexternal@externalizefig@systemcall{% + \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@externalizefig@systemcall@@ +} + +{ +\catcode`\"=12 +\catcode`\'=12 +\catcode`\;=12 +\catcode`\&=12 +\catcode`\-=12 +\xdef\tikzexternal@normal@dq{"} +\xdef\tikzexternal@normal@sq{'} +\xdef\tikzexternal@normal@semic{;} +\xdef\tikzexternal@normal@and{&} +\xdef\tikzexternal@normal@dash{-} +\catcode`\"=13 +\catcode`\'=13 +\catcode`\;=13 +\catcode`\&=13 +\catcode`\-=13 +\gdef\tikzexternal@activate@normal@dq{\let"=\tikzexternal@normal@dq} +\gdef\tikzexternal@activate@normal@sq{\let'=\tikzexternal@normal@sq} +\gdef\tikzexternal@activate@normal@semic{\let;=\tikzexternal@normal@semic} +\gdef\tikzexternal@activate@normal@and{\let&=\tikzexternal@normal@and} +\gdef\tikzexternal@activate@normal@dash{\let-=\tikzexternal@normal@dash} +\catcode`\|=0 +\catcode`\\=12 +|xdef|tikzexternal@normal@backslash{\}% +} +{ +\catcode`\^^I=12 +\catcode`\$=12 +\catcode`\%=12 +\xdef\tikzexternal@TABchar{^^I}\xdef\tikzexternal@PERCENTchar{%}\xdef\tikzexternal@DOLLARchar{$}} + +% Creates the '/tikz/external/system call' command as string and +% returns it into the (global!) macro #1. +\def\tikzexternal@assemble@systemcall#1{% + \begingroup + \let\image=\tikzexternal@curfilename + \let\texsource=\tikzexternal@realjob + \ifnum\the\catcode`\"=13 \tikzexternal@activate@normal@dq\fi + \ifnum\the\catcode`\'=13 \tikzexternal@activate@normal@sq\fi + \ifnum\the\catcode`\;=13 \tikzexternal@activate@normal@semic\fi + \ifnum\the\catcode`\-=13 \tikzexternal@activate@normal@dash\fi + \let\\=\tikzexternal@normal@backslash + \xdef#1{\pgfkeysvalueof{/tikz/external/system call}}% + \endgroup +}% +\long\def\tikzexternal@externalizefig@systemcall@@#1{% + \tikzexternal@externalizefig@systemcall@uptodatecheck% + \iftikzexternal@file@isuptodate + \iftikzexternal@verboseio + \immediate\write16{===== Image '\tikzexternal@curfilename' is up-to-date. ======}% + \fi + \let\pgf@filename=\tikzexternal@curfilename + \else + \begingroup + % no such image. Generate it! + \tikzexternal@assemble@systemcall{\pgf@tempa}% + \iftikzexternal@verboseio + \immediate\write16{===== 'mode=convert with system call': Invoking '\pgf@tempa' ========}% + \fi + \immediate\write18{\pgf@tempa}% + \expandafter\tikzexternal@externalizefig@systemcall@assertsuccess\expandafter{\pgf@tempa}% + \pgfmath@smuggleone\pgf@filename + \endgroup + \fi + \ifx\pgf@filename\pgfutil@empty + % error recovery: something did not work! Try to load it + % anyway. Perhaps it was just that shell-escape wasn't + % enabled. + \begingroup + \toks0={% + \tikzexternaldisable + \pgfutil@ifundefined{scantokens}{\long\def\scantokens##1{##1}}{}% + }% + % FIXME : THIS WILL FAIL IF THERE IS '##' INSIDE OF '#1'! + % for example something like /.style={#1} in the picture environment *will* fail. + \toks1={% + \tikzpicture#1% + }% + \toks2={% + \tikzexternal@TEXDIALECT@endpicture + \tikzexternalenable + }% + \xdef\tikzexternal@externalizefig@systemcall@next{% + \the\toks0 + % try reading them again as if they were in the input file. + \noexpand\scantokens{\the\toks1 }% + \the\toks2 + }% + \endgroup + \else + % ok, take the image! + \expandafter\pgfincludeexternalgraphics\expandafter{\tikzexternal@curfilename}% + \gdef\tikzexternal@externalizefig@systemcall@next{\tikzexternal@closeenvironments}% + \fi + \tikzexternal@externalizefig@systemcall@next +}% + +% Checks whether the current picture needs to be externalized. +% +% This is the case if +% a) there is no external image yet, +% b) the picture has been invalidated manually. +% +% It returns \iftikzexternal@file@isuptodate accordingly. +\def\tikzexternal@externalizefig@systemcall@uptodatecheck{% + \iftikzexternal@force@remake + \global\tikzexternal@file@isuptodatefalse + \else + \iftikzexternalremakenext + \global\tikzexternal@file@isuptodatefalse + \global\tikzexternalremakenextfalse + \else + % check if there is already a file. + % In that case, use it. If that is not the case, generate it and include it afterwards. + \gdef\pgf@filename{}% + \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}% + \pgf@tempa + \ifx\pgf@filename\pgfutil@empty% + \global\tikzexternal@file@isuptodatefalse + \else + \global\tikzexternal@file@isuptodatetrue + \fi + \fi + \fi +}% + +% \pgf@filename will be empty if the assertion failed. +\def\tikzexternal@externalizefig@systemcall@assertsuccess#1{% + % check if there is a file now and raise an error message if not. + \gdef\pgf@filename{}% + \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}% + \pgf@tempa + \ifx\pgf@filename\pgfutil@empty% + \PackageError{tikz}{Sorry, the system call '#1' did NOT result in a usable output file '\tikzexternal@curfilename' (expected one of \pgfsys@imagesuffixlist). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed? Error messages can be found in '\tikzexternal@curfilename.log'. If you continue now, I'll try to typeset the picture.}% + \fi +}% + diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex new file mode 100644 index 00000000000..ee158b55427 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex @@ -0,0 +1,83 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% This file is a copy of some part of PGF/Tikz. +%%% It has been copied here to provide : +%%% - compatibility with older PGF versions +%%% - availability of PGF contributions by Christian Feuersaenger +%%% which are necessary or helpful for pgfplots. +%%% +%%% For reasons of simplicity, I have copied the whole file, including own contributions AND +%%% PGF parts. The copyrights are as they appear in PGF. +%%% +%%% Note that pgfplots has compatible licenses. +%%% +%%% This copy has been modified in the following ways: +%%% - nested \input commands have been updated +%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%% + + + +% 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 provides a high-level automatic export feature for tikz pictures. +% It allows to export EACH SINGLE FIGURE into a separate PDF. +% +% The simplest way is to use +% +% \tikzexternalize{myarticle} +% +% it simply converts every figure using the write18 method. If that is not possible, +% you need to reconfigure \tikzexternalize: it can generate a list of figure file names +% and you need to generate these figures manually (or with a script). +% +% It replaces \tikzpicture/ \endtikzpicture and \tikz and invokes \beginpgfgraphicnamed ... \endpgfgraphicnamed +% commands if necessary. + +% source generic implementation: +\input pgfplotsoldpgfsupp_tikzexternalshared.code.tex + +\def\tikzexternal@TEXDIALECT@begpicture{\begin{tikzpicture}} +\def\tikzexternal@TEXDIALECT@endpicture{\end{tikzpicture}}% + +% this latex specific this assumes it starts at the beginning of an +% environment. The environment is named +% '\tikzexternal@laTeX@collect@until@end@tikzpicturetikzpicturestring'. +% +% Everything up to \end{<name>} will be collected and passed as +% argument to the macro '#1'. +% +% This does also work if <name> is NOT tikzpicture! +\def\tikzexternal@TEXDIALECT@collectpicture#1{% + \begingroup + \t@tikzexternal@tmpa={}% + \tikzexternal@laTeX@collect@until@end@tikzpicture{#1}% +} + +% Loop until we find '\end{tikzpicture}'. We have to make sure that +% even strings like '#1' are allowed inside of the collected argument. +\long\def\tikzexternal@laTeX@collect@until@end@tikzpicture#1#2\end#3{% + \def\tikzexternal@laTeX@collect@until@end@tikzpicture@{#3}% + \ifx\tikzexternal@laTeX@collect@until@end@tikzpicture@\tikzexternal@laTeX@collect@until@end@tikzpicturetikzpicturestring + \t@tikzexternal@tmpa=\expandafter{\the\t@tikzexternal@tmpa #2}% + \edef\tikzexternal@TEXDIALECT@collectpicture@next{% + \noexpand\endgroup + \noexpand#1{\the\t@tikzexternal@tmpa}% + }% + \else + \t@tikzexternal@tmpa=\expandafter{\the\t@tikzexternal@tmpa #2\end{#3}}% + \def\tikzexternal@TEXDIALECT@collectpicture@next{% + \tikzexternal@laTeX@collect@until@end@tikzpicture{#1}}% + \fi + \tikzexternal@TEXDIALECT@collectpicture@next +}% +\def\tikzexternal@laTeX@collect@until@end@tikzpicturetikzpicturestring{tikzpicture}% + diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfplotscompatib/tikzlibrarydateplot.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfplotscompatib/tikzlibrarydateplot.code.tex new file mode 100644 index 00000000000..04bcb776a21 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfplotscompatib/tikzlibrarydateplot.code.tex @@ -0,0 +1,24 @@ +%-------------------------------------------- +% +% 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +\usepgfplotslibrary{dateplot} + +\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex index d386b2195a3..a5ba73ca4ad 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex @@ -7,7 +7,7 @@ % % It is based on Till Tantau's PGF package. % -% Copyright 2007/2008 by Christian Feuersänger. +% Copyright 2007/2008/2009 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 @@ -28,24 +28,30 @@ \catcode`\;=12 \input pgfplotscore.code.tex +\input pgfplotslibrary.code.tex \input pgfplotsoldpgfsupp_loader.code.tex \input pgfplotsutil.code.tex \input pgfplotscolormap.code.tex -\input pgfplots.stackedplots.code.tex +\input pgfplotsstackedplots.code.tex \input pgfplotscoordprocessing.code.tex \input pgfplotsticks.code.tex + \usetikzlibrary{decorations,decorations.pathmorphing,decorations.pathreplacing} % FIXME: reduce number of variables! \newif\ifpgfplots@bb@isactive \newif\ifpgfplots@xislinear +\newif\ifpgfplots@has@label@information \newif\ifpgfplots@yislinear \newif\ifpgfplots@zislinear \newif\ifpgfplots@axis@equal \newif\ifpgfplots@axis@equal@image +\newif\ifpgfplots@reverse@legend +\newif\ifpgfplots@allow@reversal@of@rel@axis@cs +\newif\ifpgfplots@scanline@verbose \newcount\pgfplots@numplots \newdimen\pgfplots@xmin@reg \newdimen\pgfplots@xmax@reg @@ -57,6 +63,8 @@ \newif\ifpgfplots@isuniformtick \newif\ifpgfplots@clip@limits \newif\ifpgfplots@clip +\newif\ifpgfplots@plot@coords@mathparser +\pgfplots@plot@coords@mathparsertrue \pgfplots@cliptrue \newif\ifpgfplots@enlargelimits \newif\ifpgfplots@enlargelimits@rel@thresh @@ -86,6 +94,9 @@ \newif\ifpgfplots@hide@x \newif\ifpgfplots@hide@y \newif\ifpgfplots@hide@z +\newif\ifpgfplots@shownothingof@x +\newif\ifpgfplots@shownothingof@y +\newif\ifpgfplots@shownothingof@z \newif\ifpgfplots@is@old@list@format \newif\ifpgfplots@errorbars@enabled \newif\ifpgfplots@scale@only@axis @@ -97,11 +108,16 @@ \newif\ifpgfplots@stacked@plus \newif\ifpgfplots@plot@file@skipfirst \newif\ifpgfplots@threedim +\newif\ifpgfplotsthreedim \newif\ifpgfplots@curplot@isirrelevant -\newif\ifpgfplots@perpointmeta@usesfloat +\newif\ifpgfplots@colorbar +\newif\ifpgfplots@deprecated@anchors +\newif\ifpgfplots@translategnuplot +\pgfplots@translategnuplottrue \let\pgfnodepartimagebox=\pgfnodeparttextbox \newif\ifpgfplots@collect@firstplot@astick +\newif\ifpgfplots@units@use \def\pgfplots@errorbars@xdirection{0}% pre-init, see below \def\pgfplots@errorbars@ydirection{0}% @@ -111,7 +127,10 @@ \def\axisdefaultheight{207pt} - +% Invokes '#2' if a cycle list named '#1' exists and '#3' if not. +\long\def\pgfplotsifcyclelistexists#1#2#3{% + \pgfutil@ifundefined{pgfp@cyclist@\string#1@}{#3}{#2}% +}% % Creates a named plot cycle list. % @@ -146,6 +165,20 @@ blue,densely dashed,mark=star,every mark/.append style=solid\\% red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=diamond*\\% } +\pgfplotscreateplotcyclelist{linestyles}{solid,dashed,dotted} +\pgfplotscreateplotcyclelist{color list}{red,blue,black,yellow,brown,teal,orange,violet,cyan,green!70!black,magenta,gray} +\pgfplotscreateplotcyclelist{mark list}{% + every mark/.append style={fill=.!80!black},mark=*\\% + every mark/.append style={fill=.!80!black},mark=square*\\% + every mark/.append style={fill=.!80!black},mark=triangle*\\% + mark=star\\% + every mark/.append style={fill=.!80!black},mark=diamond*\\% + every mark/.append style={fill=.!80!black},mark=otimes*\\% + mark=|\\% + every mark/.append style={fill=.!80!black},mark=pentagon*\\% + mark=text,text mark=p\\% + mark=text,text mark=a\\% +} \pgfplotscreateplotcyclelist{exotic}{% teal,every mark/.append style={fill=teal!80!black},mark=*\\% orange,every mark/.append style={fill=orange!80!black},mark=square*\\% @@ -207,27 +240,177 @@ } } -% does the work for '[xyz]ticklabel pos'. -% #1 : one of [xyz] -% #2 : an axis line spec. -\def\pgfplots@setticklabelpos@for#1#2{% - \pgfkeysifdefined{/pgfplots/#1ticklabel pos/#2/.@cmd}{% - \pgfkeysvalueof{/pgfplots/#1ticklabel pos/#2/.@cmd}\pgfeov +% Sets the keys for /pgfplots/[xyz]ticklabel anchor. +% #1: one of [xyz] +% #2: the value +\def\pgfplots@setticklabel@anchor@for#1#2{% + \def\pgfplots@loc@TMPa{#2}% + \def\pgfplots@loc@TMPb{auto}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \expandafter\def\csname pgfplots@ticklabel@anchor@#1\endcsname{0}% + \else + \def\pgfplots@loc@TMPb{near ticklabel}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \expandafter\def\csname pgfplots@ticklabel@anchor@#1\endcsname{1}% + \else + \def\pgfplots@loc@TMPb{tikz}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \expandafter\def\csname pgfplots@ticklabel@anchor@#1\endcsname{2}% + \else + \pgfplots@error{Sorry, I got an unexpected value for '#1ticklabel anchor': '#2'. Expected one of 'auto', 'near ticklabel' or 'tikz'.}% + \fi + \fi + \fi +}% + +% Does the work for '[xyz]ticklabel pos'. +% +% #1: the axis (x,y or z). +% #2: the key argument. Accepts +% 'lower', +% 'upper', +% 'default' -> depends on 'tick pos' +% 'left' = 'lower', +% 'bottom' = 'lower', +% 'right' = 'upper' +% 'top' = 'upper'. +% +\def\pgfplots@setkey@ticklabelpos#1#2{% + \def\pgfplots@loc@TMPa{#2}% + \def\pgfplots@loc@TMPb{lower}% + \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{l}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \else + \def\pgfplots@loc@TMPb{upper}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{u}% + \else + \def\pgfplots@loc@TMPb{default}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{}% + \else + \def\pgfplots@loc@TMPb{left}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \else + \def\pgfplots@loc@TMPb{right}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{u}% + \else + \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{}% + \pgfplots@error{Sorry, the key '#1ticklabel pos' does not know what to do with '#2'... accepted values are 'default, 'lower', 'upper' and some aliases. Maybe you misspelled it?}% + \fi + \fi + \fi + \fi + \fi +}% + +% Sets 'x dir={normal,reverse}' +% #1: an axis +% #2: the key's value to apply +\def\pgfplots@setkey@axisdir@for#1#2{% + \def\pgfplots@loc@TMPa{#2}% + \def\pgfplots@loc@TMPb{normal}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \pgfkeyssetvalue{/pgfplots/#1 dir/value}{n}% + \else + \def\pgfplots@loc@TMPb{reverse}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \pgfkeyssetvalue{/pgfplots/#1 dir/value}{r}% + \else + \pgfkeyssetvalue{/pgfplots/#1 dir/value}{n}% + \pgfplots@error{Sorry, the key '#1 dir' does not know what to do with '#2'... accepted values are 'normal' or 'reverse'.}% + \fi + \fi +}% + + +\def\pgfplots@meshmode{n}% none +\def\pgfplotsplothandlermesh@flatmode{m}% mean + +\def\pgfplots@cycle@multi@list@EOI{\pgfplots@cycle@multi@list@EOI}% +\def\pgfplots@cycle@multi@list#1{% + \def\pgfplots@loc@TMPb{0}% + \gdef\pgfplots@cycle@multi@list@finalize@{}% + \pgfplots@cycle@multi@list@#1\nextlist\pgfplots@cycle@multi@list@EOI +}% +\def\pgfplots@cycle@multi@list@#1\nextlist{% + \def\pgfplots@loc@TMPa{#1}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % ignore it if someone provided too many \nextlist commands. + \else + % parse and store list: + \begingroup + \def\pgfplots@as@string{#1}% this deals with control sequences inside of #1. + \pgfplots@command@to@string\pgfplots@as@string\pgfplots@as@string + \expandafter\pgfplots@cycle@multi@list@findnamed\pgfplots@as@string\pgfplots@EOI + \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa + \endgroup + \ifx\pgfplots@glob@TMPa\pgfutil@empty + % create it: + \pgfplotscreateplotcyclelist{/pgfplots/cycle multi list/@list\pgfplots@loc@TMPb}{#1}% + \else + % ok, take an existing one + \expandafter\let\csname pgfp@cyclist@/pgfplots/cycle multi list/@list\pgfplots@loc@TMPb @\endcsname=\pgfplots@glob@TMPa + \fi + \begingroup + \expandafter\pgfplotslistsize\csname pgfp@cyclist@/pgfplots/cycle multi list/@list\pgfplots@loc@TMPb @\endcsname\to\c@pgf@counta + \edef\pgfmathresult{\the\c@pgf@counta}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \pgfkeyslet{/pgfplots/cycle multi list/@totalN\pgfplots@loc@TMPb}\pgfmathresult + \pgfkeyslet{/pgfplots/cycle multi list/@N\pgfplots@loc@TMPb}\pgfmathresult +%\def\temp{#1}\message{cycle multi list/@list={\meaning\temp}; /@N\pgfplots@loc@TMPb = \pgfkeysvalueof{/pgfplots/cycle multi list/@N\pgfplots@loc@TMPb}.}% + \pgfplotsutil@advancestringcounter\pgfplots@loc@TMPb + \fi + % + \pgfutil@ifnextchar{\pgfplots@cycle@multi@list@EOI}{% + \pgfplots@cycle@multi@list@finalize }{% - \expandafter\def\csname pgfplots@#1ticklabelaxisspec\endcsname{#2}% + \pgfplots@cycle@multi@list@ }% }% +% checks for +% - <known list> +% - [<elements> of]<known list> +% POSTCONDITION: +% 1. pgfplots@loc@TMPa will be \pgfutil@empty if there is no such +% list. +% 2. \pgfplots@loc@TMPa will be \let to the list if there is one. +% 3. \pgfplots@cycle@multi@list@finalize@ will contain any 'partial sublist' +% commands. +\def\pgfplots@cycle@multi@list@findnamed{\pgfutil@ifnextchar[{\pgfplots@cycle@multi@list@findnamed@}{\pgfplots@cycle@multi@list@findnamed@[]}}% +\def\pgfplots@cycle@multi@list@findnamed@[#1]#2\pgfplots@EOI{% + \def\pgfplots@loc@TMPa{#1}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplots@cycle@multi@list@findnamed@@#1 \pgfplots@EOI + \fi + \pgfplotsifcyclelistexists{#2}{% + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@cyclist@\string#2@\endcsname% + }{% + \let\pgfplots@loc@TMPa=\pgfutil@empty + }% +} +\def\pgfplots@cycle@multi@list@findnamed@@#1 {\pgfutil@ifnextchar o{\pgfplots@cycle@multi@list@findnamed@@@{#1}}{\pgfplots@cycle@multi@list@findnamed@@@{#1}of}}% +\def\pgfplots@cycle@multi@list@findnamed@@@#1of#2\pgfplots@EOI{% + \begingroup + \t@pgfplots@toka=\expandafter{\pgfplots@cycle@multi@list@finalize@}% + \t@pgfplots@tokb={#1}% + \xdef\pgfplots@cycle@multi@list@finalize@{\the\t@pgfplots@toka + \noexpand\pgfkeys{/pgfplots/cycle multi list/partial sublist={\pgfplots@loc@TMPb}{\the\t@pgfplots@tokb}}% + }% + \endgroup +} +\def\pgfplots@cycle@multi@list@finalize\pgfplots@cycle@multi@list@EOI{% + \pgfkeyslet{/pgfplots/cycle multi list/@dim}\pgfplots@loc@TMPb + \pgfplots@cycle@multi@list@finalize@ +}% \pgfkeys{% - /pgfplots/search path for tikz/.unknown/.code={% - \let\searchname=\pgfkeyscurrentname% - \pgfkeysalso{% - /tikz/\searchname/.try=#1, - /pgfplots/\searchname/.lastretry=#1 - }% - },% + /pgfplots/search path for tikz/.search also={/tikz,/pgfplots}, /pgfplots/.is family, /pgfplots/scale/.is family, /pgfplots/legend/.is family, @@ -257,22 +440,52 @@ /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/no marks/.style={/pgfplots/no markers}, /pgfplots/no markers/.style={/pgfplots/every axis plot post/.append style={mark=none}}, /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 label/.belongs to family=/pgfplots/descriptions, + /pgfplots/xlabel near ticks/.style={% + /pgfplots/every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every x tick scale label/.style={at={(xticklabel cs:0.9,5pt)},anchor=near xticklabel,inner sep=0pt}, + },% + /pgfplots/xlabel absolute/.style={% + /pgfplots/every axis x label/.style={at={(0.5,0)},below,yshift=-15pt},% + /pgfplots/every x tick scale label/.style={at={(1,0)},yshift=-2em,left,inner sep=0pt}, + },% /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 x label/.belongs to family=/pgfplots/descriptions, + % + /pgfplots/ylabel near ticks/.style={% + /pgfplots/every axis y label/.style={at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel},% + /pgfplots/every y tick scale label/.style={at={(yticklabel cs:1.03,-\pgfplotsvalueoflargesttickdimen y -0.3em)},anchor=south west,inner sep=0pt}, + },% + /pgfplots/ylabel absolute/.style={% + /pgfplots/every axis y label/.style={at={(0,0.5)},xshift=-35pt,rotate=90}, + /pgfplots/every y tick scale label/.style={at={(0,1)},above right,inner sep=0pt,yshift=0.3em}, + },% /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 z label/.style={at={(0,0.5)},xshift=-35pt,rotate=90}, + /pgfplots/every axis y label/.belongs to family=/pgfplots/descriptions, + /pgfplots/every axis z label/.style={at={(ticklabel cs:0.5)},rotate=90, anchor=near ticklabel}, /pgfplots/every axis z label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis z label}}, - /pgfplots/every axis z label/.belongs to family=/pgfplots/style commands, + /pgfplots/every axis z label/.belongs to family=/pgfplots/descriptions, + /pgfplots/every 3d description/.style={% + /pgfplots/every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every axis y label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},% + /pgfplots/every x tick scale label/.style={at={(xticklabel cs:0.95,5pt)},anchor=near xticklabel,inner sep=0pt}, + /pgfplots/every y tick scale label/.style={at={(yticklabel cs:0.95,5pt)},anchor=near yticklabel,inner sep=0pt}, + /pgfplots/try min ticks=3,% + },% + /pgfplots/every 3d view {0}{90}/.style={% + /pgfplots/xlabel near ticks,% + /pgfplots/ylabel near ticks,% + /pgfplots/axis on top=true,% + },% + % will be defined in \pgfplotspoint@initialisation: + %/tikz/sloped like x axis/.code={...},% /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 axis title/.belongs to family=/pgfplots/descriptions, /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, @@ -395,9 +608,15 @@ /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/extra tick style/.code={% + \pgfkeysalso{% + /pgfplots/every extra x tick/.append style={#1},% + /pgfplots/every extra y tick/.append style={#1},% + /pgfplots/every extra z tick/.append style={#1}}% + }, + /pgfplots/every x tick scale label/.initial=,% set by compat/labels=... /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 x tick scale label/.belongs to family=/pgfplots/descriptions, /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, @@ -410,9 +629,9 @@ /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/.initial=,% set by compat/labels=... /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 y tick scale label/.belongs to family=/pgfplots/descriptions, /pgfplots/every z tick label/.style={}, /pgfplots/every z tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every z tick label}}, /pgfplots/every z tick label/.belongs to family=/pgfplots/style commands, @@ -425,9 +644,8 @@ /pgfplots/extra z tick style/.code={% \pgfkeysalso{/pgfplots/every extra z tick/.append style={#1}}% }, - /pgfplots/every z tick scale label/.style={at={(0,1)},above right,inner sep=0pt,yshift=0.3em}, - /pgfplots/every z tick scale label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every z tick scale label}}, - /pgfplots/every z tick scale label/.belongs to family=/pgfplots/style commands, + /pgfplots/every z tick scale label/.style={at={(zticklabel cs:1.2,-\pgfplotsvalueoflargesttickdimen z -0.3em)},anchor=near zticklabel,inner sep=0pt}, + /pgfplots/every z tick scale label/.belongs to family=/pgfplots/descriptions, /pgfplots/every axis legend/.style={% cells={anchor=center}, inner xsep=3pt,inner ysep=2pt,nodes={inner sep=2pt,text depth=0.15em}, @@ -439,6 +657,121 @@ }, /pgfplots/every axis legend/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis legend}}, /pgfplots/every axis legend/.belongs to family=/pgfplots/style commands, + % + % Colorbar interface: + /pgfplots/colorbar/.is if=pgfplots@colorbar, + /pgfplots/colorbar/.default=true, + /pgfplots/colorbar right/.style={% + /pgfplots/colorbar=true, + /pgfplots/colorbar shift/.style={xshift=0.3cm}, + /pgfplots/every colorbar/.style={% + title=, + xlabel=, + ylabel=, + zlabel=, + legend entries=, + axis on top, + at={(parent axis.right of north east)}, + anchor=north west, + grid=none, + xmin=0, + xmax=1, + ymin=\pgfkeysvalueof{/pgfplots/point meta min}, + ymax=\pgfkeysvalueof{/pgfplots/point meta max}, + plot graphics/xmin=0,% + plot graphics/xmax=1, + plot graphics/ymin=\pgfkeysvalueof{/pgfplots/point meta min}, + plot graphics/ymax=\pgfkeysvalueof{/pgfplots/point meta max}, + enlargelimits=false, + scale only axis, + height=\pgfkeysvalueof{/pgfplots/parent axis height},% + x=\pgfkeysvalueof{/pgfplots/colorbar/width}, + xtick=\empty, + xticklabel=, + ytick=, + yticklabel=, + yticklabel pos=right, + colorbar vertical/lowlevel, + }% + },% + /pgfplots/colorbar left/.style={% + /pgfplots/colorbar right, + /pgfplots/colorbar shift/.style={xshift=-0.3cm}, + /pgfplots/every colorbar/.append style={% + at={(parent axis.left of north west)}, + anchor=north east, + yticklabel pos=left, + }% + },% + /pgfplots/colorbar horizontal/.style={% + /pgfplots/colorbar=true, + /pgfplots/colorbar shift/.style={yshift=-0.3cm}, + /pgfplots/every colorbar/.style={% + title=, + xlabel=, + ylabel=, + zlabel=, + legend entries=, + axis on top, + at={(parent axis.below south west)}, + anchor=north west, + grid=none, + ymin=0, + ymax=1, + xmin=\pgfkeysvalueof{/pgfplots/point meta min}, + xmax=\pgfkeysvalueof{/pgfplots/point meta max}, + plot graphics/ymin=0,% + plot graphics/ymax=1, + plot graphics/xmin=\pgfkeysvalueof{/pgfplots/point meta min}, + plot graphics/xmax=\pgfkeysvalueof{/pgfplots/point meta max}, + enlargelimits=false, + scale only axis, + width=\pgfkeysvalueof{/pgfplots/parent axis width},% + y=\pgfkeysvalueof{/pgfplots/colorbar/width}, + xticklabel pos=left, + xtick=, + xticklabel=, + ytick=\empty, + colorbar horizontal/lowlevel, + }% + },% + % You might wonder why this special treatment with '/lowlevel' + % keys is necessary. Well, It turned out that using '##' inside of + % styles is incompatible with '.add code' -- and therefor also + % with '.append style'. This here is a work-around which works. + /pgfplots/colorbar vertical/lowlevel/.style={% + plot graphics/lowlevel draw/.code 2 args={% + \if\pgfkeysvalueof{/pgfplots/y dir/value}n% + \pgfplotscolormaptoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##2}\pgfplots@loc@TMPa + \else + \pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##2}\pgfplots@loc@TMPa + \fi + \def\pgfplots@loc@TMPb{\pgfdeclareverticalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% + \pgfuseshading{tempshading}% + },% + }, + /pgfplots/colorbar horizontal/lowlevel/.style={% + plot graphics/lowlevel draw/.code 2 args={% + \if\pgfkeysvalueof{/pgfplots/x dir/value}n% + \pgfplotscolormaptoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##1}\pgfplots@loc@TMPa + \else + \pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##1}\pgfplots@loc@TMPa + \fi + \def\pgfplots@loc@TMPb{\pgfdeclarehorizontalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% + \pgfuseshading{tempshading}% + },% + },% + /pgfplots/colorbar right, + /pgfplots/colorbar=false, + /pgfplots/colorbar style/.style={/pgfplots/every colorbar/.append style={#1}}, + /pgfplots/colorbar/width/.initial=0.5cm, + /pgfplots/colorbar/draw/.code={% + \axis[every colorbar,colorbar shift,colorbar=false] + \addplot graphics {}; + \endaxis + },% % tick options: /pgfplots/xticklabel/.store in= \pgfplots@xticklabel, /pgfplots/xticklabel/.belongs to family=/pgfplots/tick, @@ -448,11 +781,25 @@ \pgfplots@foreach@to@list{#1}\to\pgfplots@xticklabels \let\pgfplots@xticklabel=\pgfplots@user@ticklabel@list@x }, + % #1 table name or macro + % #2 column name (or alias or create on use) + /pgfplots/xticklabels from table/.code 2 args={% + \pgfplotstablegetcolumn{#2}\of{#1}\to\pgfplots@xticklabels + \let\pgfplots@xticklabel=\pgfplots@user@ticklabel@list@x + }, + /pgfplots/xticklabels from table/.belongs to family=/pgfplots/tick, /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 }, + % #1 table name or macro + % #2 column name (or alias or create on use) + /pgfplots/yticklabels from table/.code 2 args={% + \pgfplotstablegetcolumn{#2}\of{#1}\to\pgfplots@yticklabels + \let\pgfplots@yticklabel=\pgfplots@user@ticklabel@list@y + }, + /pgfplots/yticklabels from table/.belongs to family=/pgfplots/tick, /pgfplots/yticklabel/.store in= \pgfplots@yticklabel, /pgfplots/yticklabel/.belongs to family=/pgfplots/tick, /pgfplots/yticklabel=, @@ -461,6 +808,13 @@ \pgfplots@foreach@to@list{#1}\to\pgfplots@zticklabels \let\pgfplots@zticklabel=\pgfplots@user@ticklabel@list@z }, + % #1 table name or macro + % #2 column name (or alias or create on use) + /pgfplots/zticklabels from table/.code 2 args={% + \pgfplotstablegetcolumn{#2}\of{#1}\to\pgfplots@zticklabels + \let\pgfplots@zticklabel=\pgfplots@user@ticklabel@list@z + }, + /pgfplots/zticklabels from table/.belongs to family=/pgfplots/tick, /pgfplots/zticklabel/.store in= \pgfplots@zticklabel, /pgfplots/zticklabel/.belongs to family=/pgfplots/tick, /pgfplots/zticklabel=, @@ -522,11 +876,12 @@ /pgfplots/ztickten/.store in= \pgfplots@ztickten, /pgfplots/ztickten/.belongs to family=/pgfplots/tick, /pgfplots/ztickten=, - /pgfplots/xtick scale label code/.code={$\cdot 10^{#1}$}, + /pgfplots/tick scale binop/.initial=\cdot, + /pgfplots/xtick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} 10^{#1}$}, /pgfplots/xtick scale label code/.belongs to family=/pgfplots/tick, - /pgfplots/ytick scale label code/.code={$\cdot 10^{#1}$}, + /pgfplots/ytick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} 10^{#1}$}, /pgfplots/ytick scale label code/.belongs to family=/pgfplots/tick, - /pgfplots/ztick scale label code/.code={$\cdot 10^{#1}$}, + /pgfplots/ztick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} 10^{#1}$}, /pgfplots/ztick scale label code/.belongs to family=/pgfplots/tick, /pgfplots/tick scale label code/.style={% /pgfplots/xtick scale label code={#1}, @@ -539,7 +894,7 @@ /pgfplots/scaled x ticks/base 10/.code= {\def\pgfplots@scaled@ticks@x@choice{2}\def\pgfplots@scaled@ticks@x@arg{#1}}, /pgfplots/scaled x ticks/real/.code= {% \def\pgfplots@scaled@ticks@x@choice{3}\def\pgfplots@scaled@ticks@x@arg{#1}% - \pgfkeys{/pgfplots/xtick scale label code/.code={$\cdot \pgfmathprintnumber{#1}$}}}, + \pgfkeys{/pgfplots/xtick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} \pgfmathprintnumber{#1}$}}}, /pgfplots/scaled x ticks/manual/.code 2 args= {% \def\pgfplots@scaled@ticks@x@choice{4}\def\pgfplots@scaled@ticks@x@arg##1{#2}% \pgfkeys{/pgfplots/xtick scale label code/.code={#1}}}, @@ -551,7 +906,7 @@ /pgfplots/scaled y ticks/base 10/.code= {\def\pgfplots@scaled@ticks@y@choice{2}\def\pgfplots@scaled@ticks@y@arg{#1}}, /pgfplots/scaled y ticks/real/.code= {% \def\pgfplots@scaled@ticks@y@choice{3}\def\pgfplots@scaled@ticks@y@arg{#1}% - \pgfkeys{/pgfplots/ytick scale label code/.code={$\cdot \pgfmathprintnumber{#1}$}}}, + \pgfkeys{/pgfplots/ytick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} \pgfmathprintnumber{#1}$}}}, /pgfplots/scaled y ticks/manual/.code 2 args= {% \def\pgfplots@scaled@ticks@y@choice{4}\def\pgfplots@scaled@ticks@y@arg##1{#2}% \pgfkeys{/pgfplots/ytick scale label code/.code={#1}}}, @@ -563,7 +918,7 @@ /pgfplots/scaled z ticks/base 10/.code= {\def\pgfplots@scaled@ticks@z@choice{2}\def\pgfplots@scaled@ticks@z@arg{#1}}, /pgfplots/scaled z ticks/real/.code= {% \def\pgfplots@scaled@ticks@z@choice{3}\def\pgfplots@scaled@ticks@z@arg{#1}% - \pgfkeys{/pgfplots/ztick scale label code/.code={$\cdot \pgfmathprintnumber{#1}$}}}, + \pgfkeys{/pgfplots/ztick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} \pgfmathprintnumber{#1}$}}}, /pgfplots/scaled z ticks/manual/.code 2 args= {% \def\pgfplots@scaled@ticks@z@choice{4}\def\pgfplots@scaled@ticks@z@arg##1{#2}% \pgfkeys{/pgfplots/ztick scale label code/.code={#1}}}, @@ -611,12 +966,19 @@ /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 basis x/.initial=, + /pgfplots/log basis y/.initial=, + /pgfplots/log basis z/.initial=, + /pgfplots/log base x/.style={log basis x={#1}},% + /pgfplots/log base y/.style={log basis y={#1}},% + /pgfplots/log base z/.style={log basis z={#1}},% /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={{% + /pgfplots/log number format code/.code={% + \begingroup \pgfmathlogtologten@{#1}% \ifpgfplots@identify@log@minor@tick@pos \expandafter\pgfplots@is@log@tick@a@minor@tick@pos\pgfmathresult\relax% @@ -628,10 +990,25 @@ \else \pgfkeysalso{/pgfplots/log plot exponent style,/pgfplots/log base 10 number format code=\pgfmathresult}% \fi - }}, + \endgroup + }, /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/.code={{\pgfplots@invoke@pgfkeyscode{/pgfplots/log number format basis/.@cmd}{{10}{#1}}}}, /pgfplots/log base 10 number format code/.belongs to family=/pgfplots/tick, + % #1 = basis + % #2 = exponent + /pgfplots/log number format basis/.code 2 args={$#1^{\pgfmathprintnumber{#2}}$}, + % takes #1 = [xyz]: + /pgfplots/log basis ticks/.style={% + /pgfplots/every #1 tick label/.append style={% + /pgfplots/log number format code/.code={% + \begingroup + \pgfkeysalso{/pgfplots/log plot exponent style}% + \pgfplots@invoke@pgfkeyscode{/pgfplots/log number format basis/.@cmd}{{\pgfkeysvalueof{/pgfplots/log basis #1}}{####1}}% + \endgroup + }% + }% + }, % sets \pgfplots@[xy]tickposnum to /pgfplots/xtick pos/.is choice, /pgfplots/xtick pos/.belongs to family=/pgfplots/tick, @@ -670,43 +1047,55 @@ /pgfplots/ztick pos={#1} }, /pgfplots/tickpos/.belongs to family=/pgfplots/tick, -% sets the tick LABEL position, \pgfplots@[xy]ticklabelaxisspec + /pgfplots/tick pos/.style={/pgfplots/tickpos={#1}}, +% sets the tick LABEL position, \pgfplots@[xy]ticklabel@pos % to one of -% default : 0 -% left : 1 -% right : 3 - /pgfplots/xticklabel pos/.code={\pgfplots@setticklabelpos@for x{#1}}, +% lower (alias left alias bottom) : l +% upper (alias right alias top) : u +% default: uses one matches 'tick pos' + /pgfplots/xticklabel pos/.code={\pgfplots@setkey@ticklabelpos{x}{#1}}, /pgfplots/xticklabel pos/.belongs to family=/pgfplots/tick, - /pgfplots/xticklabel pos/default/.code ={\def\pgfplots@xticklabelaxisspec{}}, - /pgfplots/xticklabel pos/default/.belongs to family=/pgfplots/tick, - /pgfplots/xticklabel pos/left/.code ={\def\pgfplots@xticklabelaxisspec{v00}}, - /pgfplots/xticklabel pos/left/.belongs to family=/pgfplots/tick, - /pgfplots/xticklabel pos/right/.code ={\def\pgfplots@xticklabelaxisspec{v10}}, - /pgfplots/xticklabel pos/right/.belongs to family=/pgfplots/tick, - /pgfplots/xticklabel pos/top/.style={/pgfplots/xticklabel pos/right}, - /pgfplots/xticklabel pos/bottom/.style={/pgfplots/xticklabel pos/left}, /pgfplots/xticklabel pos=default, - /pgfplots/yticklabel pos/.code={\pgfplots@setticklabelpos@for y{#1}}, + /pgfplots/yticklabel pos/.code={\pgfplots@setkey@ticklabelpos{y}{#1}}, /pgfplots/yticklabel pos/.belongs to family=/pgfplots/tick, - /pgfplots/yticklabel pos/default/.code ={\def\pgfplots@yticklabelaxisspec{}}, - /pgfplots/yticklabel pos/default/.belongs to family=/pgfplots/tick, - /pgfplots/yticklabel pos/left/.code ={\def\pgfplots@yticklabelaxisspec{0v0}}, - /pgfplots/yticklabel pos/left/.belongs to family=/pgfplots/tick, - /pgfplots/yticklabel pos/right/.code ={\def\pgfplots@yticklabelaxisspec{1v0}}, - /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/zticklabel pos/.code={\pgfplots@setticklabelpos@for z{#1}}, + /pgfplots/zticklabel pos/.code={\pgfplots@setkey@ticklabelpos{z}{#1}}, /pgfplots/zticklabel pos/.belongs to family=/pgfplots/tick, - /pgfplots/zticklabel pos/default/.code ={\def\pgfplots@zticklabelaxisspec{}}, - /pgfplots/zticklabel pos/default/.belongs to family=/pgfplots/tick, /pgfplots/zticklabel pos=default, - /pgfplots/ticklabelpos/.style={ + /pgfplots/ticklabelpos/.style={/pgfplots/ticklabel pos={#1}}, + /pgfplots/ticklabel pos/.style={ /pgfplots/xticklabel pos={#1}, /pgfplots/yticklabel pos={#1}, - % /pgfplots/zticklabel pos={#1}, + /pgfplots/zticklabel pos={#1}, }, + % This feature is more or less deprecated. + % The choice 'auto' should always use 'near ticklabel'. + % + % Choices are + % 'auto' (value 0), + % 'near ticklabel' (value 1), + % 'tikz' (value 2) + % with values stored in \pgfplots@ticklabel@anchor@[xyz] + /pgfplots/xticklabel anchor/.code={\pgfplots@setticklabel@anchor@for x{#1}}, + /pgfplots/xticklabel anchor/.belongs to family=/pgfplots/tick, + /pgfplots/yticklabel anchor/.code={\pgfplots@setticklabel@anchor@for y{#1}}, + /pgfplots/yticklabel anchor/.belongs to family=/pgfplots/tick, + /pgfplots/zticklabel anchor/.code={\pgfplots@setticklabel@anchor@for z{#1}}, + /pgfplots/zticklabel anchor/.belongs to family=/pgfplots/tick, + /pgfplots/ticklabel anchor/.style={ + /pgfplots/xticklabel anchor={#1}, + /pgfplots/yticklabel anchor={#1}, + /pgfplots/zticklabel anchor={#1} + }, + /pgfplots/ticklabel anchor=auto, + /pgfplots/xticklabel shift/.initial=, + /pgfplots/yticklabel shift/.initial=, + /pgfplots/zticklabel shift/.initial=, + /pgfplots/ticklabel shift/.style={ + /pgfplots/xticklabel shift={#1}, + /pgfplots/yticklabel shift={#1}, + /pgfplots/zticklabel shift={#1} + },% % sets \pgfplots@{x,y}tickalignnum to % inside=0 % outside=1 @@ -867,6 +1256,12 @@ % legend options: /pgfplots/legend entries/.initial={}, /pgfplots/legend entries/.belongs to family=/pgfplots/legend, + /pgfplots/legend pos/.is choice, + /pgfplots/legend pos/south west/.style={/pgfplots/legend style={at={(0.03,0.03)},anchor=south west}}, + /pgfplots/legend pos/south east/.style={/pgfplots/legend style={at={(0.97,0.03)},anchor=south east}}, + /pgfplots/legend pos/north west/.style={/pgfplots/legend style={at={(0.03,0.97)},anchor=north west}}, + /pgfplots/legend pos/north east/.style={/pgfplots/legend style={at={(0.97,0.97)},anchor=north east}}, + /pgfplots/legend pos/outer north east/.style={/pgfplots/legend style={at={(1.03,1)},anchor=north west}}, /pgfplots/legend columns/.store in=\pgfplots@legend@columns, /pgfplots/legend columns/.belongs to family=/pgfplots/legend, /pgfplots/legend columns=1, @@ -879,28 +1274,36 @@ /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/line legend/.style={% + /pgfplots/legend image code/.code={% + \draw[mark repeat=2,mark phase=2,##1] + plot coordinates { + (0cm,0cm) + (0.3cm,0cm) + (0.6cm,0cm)% + };% + }% + }, + /pgfplots/line legend, /pgfplots/legend image code/.belongs to family=/pgfplots/legend, + /pgfplots/reverse legend/.is if=pgfplots@reverse@legend, + /pgfplots/reverse legend/.default=true, % 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/zlabel/.initial=, - /pgfplots/zlabel/.belongs to family=/pgfplots/descriptions, + /pgfplots/xlabel shift/.initial=0pt, + /pgfplots/ylabel shift/.initial=0pt, + /pgfplots/zlabel shift/.initial=0pt, + /pgfplots/label shift/.style={% + /pgfplots/xlabel shift={#1}, + /pgfplots/ylabel shift={#1}, + /pgfplots/zlabel shift={#1}, + },% /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}% @@ -911,6 +1314,8 @@ /pgfplots/clip limits=true, /pgfplots/clip limits/.belongs to family=/pgfplots, /pgfplots/clip/.is if=pgfplots@clip, + % will be used if it exists: + %/pgfplots/axis background/.style={}, /pgfplots/axis equal/.is if=pgfplots@axis@equal, /pgfplots/axis equal/.default=true, /pgfplots/axis equal image/.is if=pgfplots@axis@equal@image, @@ -969,6 +1374,71 @@ /pgfplots/y filter/.belongs to family=/pgfplots, /pgfplots/z filter/.code={}, /pgfplots/z filter/.belongs to family=/pgfplots, + /pgfplots/filter point/.code=, + /pgfplots/restrict x to domain/.style={/pgfplots/@restrict to domain={x}{}{#1}},% + /pgfplots/restrict y to domain/.style={/pgfplots/@restrict to domain={y}{}{#1}},% + /pgfplots/restrict z to domain/.style={/pgfplots/@restrict to domain={z}{}{#1}},% + /pgfplots/restrict expr to domain/.style 2 args={/pgfplots/@restrict to domain={x}{#1}{#2}},% + % '#1': the filter to install + % '#2': a mathematical expression (or empty) + % '#3': the interval. must be numeric currently. + /pgfplots/@restrict to domain/.code args={#1#2#3}{% + \edef\pgfplots@loc@TMPa{#3}% + % when invoked, ##1 and ##2 will be floats: + \def\pgfplots@loc@TMPb##1:##2\relax{% + \pgfkeysalso{% + /pgfplots/unbounded coords=jump,% + /pgfplots/#1 filter/.append code={% + \let\pgfplots@restrict@to@domain@orig=\pgfmathresult + \def\pgfplots@restrict@to@domain@tmp{#2}% + \ifx\pgfplots@restrict@to@domain@tmp\pgfutil@empty + % we don't have an expression. + \pgfmathfloatparsenumber{\pgfmathresult}% + \else + % evaluate the expression! + \pgfmathparse{#2}% + \fi + \let\pgfplots@restrict@to@domain@tmp=\pgfmathresult + \pgfmathfloatlessthan@{\pgfplots@restrict@to@domain@tmp}{##1}% ##1 is the lower argument + \ifpgfmathfloatcomparison + \def\pgfmathresult{inf}% + \else + \pgfmathfloatgreaterthan@{\pgfplots@restrict@to@domain@tmp}{##2}% + \ifpgfmathfloatcomparison + \def\pgfmathresult{-inf}% + \else + \let\pgfmathresult=\pgfplots@restrict@to@domain@orig + \fi + \fi + }% + }% + }% + % when invoked, ##1 and ##2 will be the user-supplied args. + \def\pgfplots@loc@TMPc##1:##2\relax{% + \pgfmathfloatparsenumber{##1}% + \let\pgfplots@rangea=\pgfmathresult + \pgfmathfloatparsenumber{##2}% + \edef\pgfplots@loc@TMPc{\pgfplots@rangea:\pgfmathresult}% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPc\relax + }% + \expandafter\pgfplots@loc@TMPc\pgfplots@loc@TMPa\relax + },% + % -> keeps only the nth point, all other ones will get ''. + /pgfplots/each nth point/.style 2 args={% + /pgfplots/x filter/.append code={% + \ifnum\coordindex=0 + \def\c@pgfplots@eachnthpoint@xfilter{0}% + \edef\c@pgfplots@eachnthpoint@xfilter@cmp{#1}% + \else + \pgfplotsutil@advancestringcounter\c@pgfplots@eachnthpoint@xfilter + \ifx\c@pgfplots@eachnthpoint@xfilter@cmp\c@pgfplots@eachnthpoint@xfilter + \def\c@pgfplots@eachnthpoint@xfilter{0}% + \else + \let\pgfmathresult\pgfutil@empty + \fi + \fi + }% + }, /pgfplots/skip coords between index/.style 2 args={% /pgfplots/x filter/.append code={% \ifnum\coordindex<#1\relax @@ -978,6 +1448,7 @@ \fi \fi} }, + /pgfplots/translate gnuplot/.is if=pgfplots@translategnuplot, /pgfplots/xfilter/.initial=,% DEPRECATED /pgfplots/yfilter/.initial=,% DEPRECATED /pgfplots/zfilter/.initial=,% DEPRECATED @@ -989,27 +1460,30 @@ % else % use 'samples at' /pgfplots/domain/.initial=,% empty -> use value of /tikz/domain! see \pgfplots@validate@plot@domain@arguments + /pgfplots/y domain/.initial=,% means: use the same as 'domain' + /pgfplots/domain y/.style={/pgfplots/y domain={#1}}, /pgfplots/samples at/.initial=,% empty -> use value of /tikz/samples at! /pgfplots/samples/.initial=,% empty -> use /tikz/samples! + /pgfplots/samples y/.initial=,% empty -> use the same as 'samples'. For use in mesh plots. + /pgfplots/variable y/.initial=\y,% % and provide aliases in the '/pgfplots/' tree to avoid - % search path problems just for these two options: + % search path problems just for the following options: /pgfplots/name/.belongs to family=/pgfplots/naming commands, /pgfplots/name/.code={\pgfkeysalso{/tikz/name={#1}}}, /pgfplots/alias/.belongs to family=/pgfplots/naming commands, /pgfplots/alias/.code={\pgfkeysalso{/tikz/alias={#1}}}, - /pgfplots/y domain/.initial=-5:5, - /pgfplots/width/.store in= \pgfplots@width, + /pgfplots/id/.code={\pgfkeysalso{/tikz/id={#1}}}, + /pgfplots/prefix/.code={\pgfkeysalso{/tikz/prefix={#1}}}, + /pgfplots/raw gnuplot/.code={\pgfkeysalso{/tikz/raw gnuplot={#1}}}, + % + /pgfplots/width/.initial=,% /pgfplots/width/.belongs to family=/pgfplots, - /pgfplots/width=, - /pgfplots/height/.store in= \pgfplots@height, + /pgfplots/height/.initial=,% /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/execute at begin plot/.initial=, + /pgfplots/execute at begin plot@@/.initial=,% an internal variant + /pgfplots/execute at end plot/.initial=, + /pgfplots/execute at end plot@@/.initial=,% an internal variant /pgfplots/enlarge x limits/.initial=auto, /pgfplots/enlarge x limits/.default=true, /pgfplots/enlarge y limits/.initial=auto, @@ -1028,35 +1502,72 @@ /pgfplots/y/.belongs to family=/pgfplots, /pgfplots/z/.initial=, /pgfplots/z/.belongs to family=/pgfplots, - /pgfplots/view/.code 2 args={% - \def\pgfplots@loc@TMPa{#1}% - \ifx\pgfplots@loc@TMPa\pgfutil@empty - \let\pgfplots@view@pitch=\pgfutil@empty - \let\pgfplots@view@yaw=\pgfutil@empty - \else - \pgfmathparse{#1}\let\pgfplots@view@pitch=\pgfmathresult - \pgfmathparse{#2}\let\pgfplots@view@yaw=\pgfmathresult - \fi + /pgfplots/x dir/.code={\pgfplots@setkey@axisdir@for x{#1}},% + /pgfplots/y dir/.code={\pgfplots@setkey@axisdir@for y{#1}},% + /pgfplots/z dir/.code={\pgfplots@setkey@axisdir@for z{#1}},% + /pgfplots/x dir=normal,% + /pgfplots/y dir=normal,% + /pgfplots/z dir=normal,% + /pgfplots/allow reversal of rel axis cs/.is if=pgfplots@allow@reversal@of@rel@axis@cs,% + /pgfplots/allow reversal of rel axis cs/.default=true,% + /pgfplots/allow reversal of rel axis cs=true,% + /pgfplots/plot box ratio/.initial={1}{1}{1},% + /pgfplots/view/az/.initial=25,% + /pgfplots/view/h/.code={\pgfkeyssetvalue{/pgfplots/view/az}{#1}},% + /pgfplots/view/el/.initial=30,% + /pgfplots/view/v/.code={\pgfkeyssetvalue{/pgfplots/view/el}{#1}},% + /pgfplots/view/.style 2 args={% + /pgfplots/view/az={#1},% + /pgfplots/view/el={#2}% + },% + /pgfplots/cycle list/.code={% + \pgfplots@assign@list\autoplotspeclist{#1}% + \expandafter\let\csname pgfp@cyclist@auto@\endcsname=\autoplotspeclist + \pgfkeyssetvalue{/pgfplots/cycle multi list/@dim}{0}% de-activate. }, - /pgfplots/view={}{}, - /pgfplots/cycle list/.code={\pgfplots@assign@list\autoplotspeclist{#1}}, /pgfplots/cycle list/.belongs to family=/pgfplots, /pgfplots/cycle list name/.code={% - \pgfutil@ifundefined{pgfp@cyclist@\string#1@}{% - \pgfplots@error{Sorry, there is no such cycle list named \string#1. Maybe you misspelled it?}% - }{% + \pgfplotsifcyclelistexists{#1}{% \expandafter\let\expandafter\autoplotspeclist\csname pgfp@cyclist@\string#1@\endcsname + \expandafter\let\csname pgfp@cyclist@auto@\endcsname=\autoplotspeclist + \pgfkeyssetvalue{/pgfplots/cycle multi list/@dim}{0}% de-activate. + }{% + \pgfplots@error{Sorry, there is no such cycle list named \string#1. Maybe you misspelled it?}% }% }, /pgfplots/cycle list name/.belongs to family=/pgfplots, /pgfplots/cycle list name=color, + % accepts arguments of the form + % <first list spec>\nextlist <second list spec>\nextlist .... + % where each list spec is EITHER a cycle list name OR a cycle list + % argument. + /pgfplots/cycle multi list/.code={\pgfplots@cycle@multi@list{#1}}, + % #1: list index + % #2: maximum number of elements to use + /pgfplots/cycle multi list/partial sublist/.code 2 args={% + \ifnum#1<\pgfkeysvalueof{/pgfplots/cycle multi list/@dim} + \ifnum#2<\pgfkeysvalueof{/pgfplots/cycle multi list/@totalN#1} + \pgfkeyssetvalue{/pgfplots/cycle multi list/@N#1}{#2}% + \fi + \else + \pgfplots@error{Sorry, the first argument of `cycle multi list/partial sublist=<list index><num elems>' is no valid list index (should be less than \pgfkeysvalueof{/pgfplots/cycle multi list/@dim}).}% + \fi + },% + /pgfplots/cycle multi list/@dim/.initial=0, + %/pgfplots/cycle multi list/@list0/.style={}, + %/pgfplots/cycle multi list/@N0/.initial=0,% + %/pgfplots/cycle multi list/@totalN0/.initial=0,% /pgfplots/legend style/.belongs to family=/pgfplots/style commands, /pgfplots/legend style/.code={% \pgfkeysalso{/pgfplots/every axis legend/.append style={#1}}% }, + /pgfplots/every forget plot/.code={},% + /pgfplots/forget plot style/.style={/pgfplots/every forget plot/.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/label style/.style={% + /pgfplots/every axis x label/.append style={#1},% + /pgfplots/every axis y label/.append style={#1},% + /pgfplots/every axis z label/.append style={#1}% },% /pgfplots/x label style/.belongs to family=/pgfplots/style commands, /pgfplots/x label style/.code={% @@ -1092,15 +1603,15 @@ }, /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}}% + \pgfkeysalso{/pgfplots/every x tick scale 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}}% + \pgfkeysalso{/pgfplots/every y tick scale label/.append style={#1}}% }, /pgfplots/z tick scale label style/.belongs to family=/pgfplots/style commands, /pgfplots/z tick scale label style/.code={% - \pgfkeysalso{/pgfplots/every z scale tick label/.append style={#1}}% + \pgfkeysalso{/pgfplots/every z tick scale label/.append style={#1}}% }, /pgfplots/tick style/.belongs to family=/pgfplots/style commands, /pgfplots/tick style/.code={% @@ -1219,7 +1730,7 @@ /pgfplots/hide y axis/.is if=pgfplots@hide@y, /pgfplots/hide y axis/.default=true, /pgfplots/hide y axis=false, - /pgfplots/hide z axis/.is if=pgfplots@hide@y, + /pgfplots/hide z axis/.is if=pgfplots@hide@z, /pgfplots/hide z axis/.default=true, /pgfplots/hide z axis=false, /pgfplots/hide axis/.style={% @@ -1239,9 +1750,9 @@ y axis line style={-stealth} }, /pgfplots/every non boxed z axis/.style={% - ytick align=center, + ztick align=center, enlarge z limits=false, - y axis line style={-stealth} + z axis line style={-stealth} }, /pgfplots/every boxed x axis/.style={}, /pgfplots/every boxed y axis/.style={}, @@ -1254,11 +1765,13 @@ % 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*/bottom/.code ={\def\pgfplots@xaxislinesnum{1}\def\pgfplots@xtickposnum{1}\let\pgfplots@xticklabel@pos\pgfutil@empty}, + /pgfplots/axis x line*/left/.style={/pgfplots/axis x line*/bottom}, + /pgfplots/axis x line*/middle/.code ={\def\pgfplots@xaxislinesnum{2}\def\pgfplots@xtickposnum{2}\let\pgfplots@xticklabel@pos\pgfutil@empty}, /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*/top/.code ={\def\pgfplots@xaxislinesnum{3}\def\pgfplots@xtickposnum{3}\let\pgfplots@xticklabel@pos\pgfutil@empty}, + /pgfplots/axis x line*/right/.style={/pgfplots/axis x line*/top}, + /pgfplots/axis x line*/none/.code ={\def\pgfplots@xaxislinesnum{4}\def\pgfplots@xtickposnum{4}\let\pgfplots@xticklabel@pos\pgfutil@empty}, /pgfplots/axis x line*=box, % /pgfplots/axis x line/.is choice, @@ -1270,6 +1783,7 @@ /pgfplots/axis x line*/bottom, /pgfplots/every non boxed x axis }, + /pgfplots/axis x line/left/.style={/pgfplots/axis x line/bottom},% /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}}% @@ -1280,6 +1794,7 @@ /pgfplots/every non boxed x axis}% }, /pgfplots/axis x line/center/.style ={/pgfplots/axis x line/middle}, + /pgfplots/axis x line/right/.style={/pgfplots/axis x line/top},% /pgfplots/axis x line/top/.code ={ \ifnum\pgfplots@yaxislinesnum=2 % if 'axis y line==center' then \pgfkeysalso{ @@ -1298,11 +1813,11 @@ % 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*/left/.code ={\def\pgfplots@yaxislinesnum{1}\def\pgfplots@ytickposnum{1}\let\pgfplots@yticklabel@pos\pgfutil@empty}, + /pgfplots/axis y line*/center/.code ={\def\pgfplots@yaxislinesnum{2}\def\pgfplots@ytickposnum{2}\let\pgfplots@yticklabel@pos\pgfutil@empty}, /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*/right/.code ={\def\pgfplots@yaxislinesnum{3}\def\pgfplots@ytickposnum{3}\let\pgfplots@yticklabel@pos\pgfutil@empty}, + /pgfplots/axis y line*/none/.code ={\def\pgfplots@yaxislinesnum{4}\def\pgfplots@ytickposnum{4}\let\pgfplots@yticklabel@pos\pgfutil@empty}, /pgfplots/axis y line*=box, % /pgfplots/axis y line/.is choice, @@ -1334,6 +1849,7 @@ \pgfkeysalso{ axis y line*/right, %every axis y label/.style={at={(1,1)},anchor=north west,xshift=15pt}, + % FIXME : DEPRECATED !? USE 'near tick' things .... every axis y label/.style={at={(1,0.5)},xshift=33pt,rotate=90}, /pgfplots/every non boxed y axis }% @@ -1347,11 +1863,11 @@ % right=3 /pgfplots/axis z line*/.is choice, /pgfplots/axis z line*/box/.code ={\def\pgfplots@zaxislinesnum{0}\def\pgfplots@ztickposnum{0}}, - /pgfplots/axis z line*/left/.code ={\def\pgfplots@zaxislinesnum{1}\def\pgfplots@ztickposnum{1}}, - /pgfplots/axis z line*/center/.code ={\def\pgfplots@zaxislinesnum{2}\def\pgfplots@ztickposnum{2}}, + /pgfplots/axis z line*/left/.code ={\def\pgfplots@zaxislinesnum{1}\def\pgfplots@ztickposnum{1}\let\pgfplots@zticklabel@pos\pgfutil@empty}, + /pgfplots/axis z line*/center/.code ={\def\pgfplots@zaxislinesnum{2}\def\pgfplots@ztickposnum{2}\let\pgfplots@zticklabel@pos\pgfutil@empty}, /pgfplots/axis z line*/middle/.style ={/pgfplots/axis z line*/center}, - /pgfplots/axis z line*/right/.code ={\def\pgfplots@zaxislinesnum{3}\def\pgfplots@ztickposnum{3}}, - /pgfplots/axis z line*/none/.code ={\def\pgfplots@zaxislinesnum{4}\def\pgfplots@ztickposnum{4}}, + /pgfplots/axis z line*/right/.code ={\def\pgfplots@zaxislinesnum{3}\def\pgfplots@ztickposnum{3}\let\pgfplots@zticklabel@pos\pgfutil@empty}, + /pgfplots/axis z line*/none/.code ={\def\pgfplots@zaxislinesnum{4}\def\pgfplots@ztickposnum{4}\let\pgfplots@zticklabel@pos\pgfutil@empty}, /pgfplots/axis z line*=box, % /pgfplots/axis z line/.is choice, @@ -1364,13 +1880,13 @@ /pgfplots/every non boxed z axis }, /pgfplots/axis z line/center/.code ={ - \ifnum\pgfplots@xaxislinesnum=3 % if 'axis x line==top' then - \pgfkeysalso{% - /pgfplots/every axis z label/.style={at={(current axis.below origin)},anchor=south west}}% - \else + % \ifnum\pgfplots@xaxislinesnum=3 % if 'axis x line==top' then + % \pgfkeysalso{% + % /pgfplots/every axis z label/.style={at={(current axis.below origin)},anchor=south west}}% + % \else \pgfkeysalso{% /pgfplots/every axis z label/.style={at={(current axis.above origin)},anchor=north west}}% - \fi + % \fi \pgfkeysalso{% /pgfplots/axis z line*/center, /pgfplots/every non boxed z axis}% @@ -1384,10 +1900,30 @@ axis z line*/right, %every axis y label/.style={at={(1,1)},anchor=north west,xshift=15pt}, every axis z label/.style={at={(1,0.5)},xshift=33pt,rotate=90}, - /pgfplots/every non boxed z axis + /pgfplots/every non boxed z axis }% },% /pgfplots/axis z line/none/.style ={axis z line*/none,hide z axis}, + /pgfplots/axis lines/.style={% + axis x line=#1,% + axis y line=#1,% + axis z line=#1% + }, + /pgfplots/axis lines*/.style={% + axis x line*=#1,% + axis y line*=#1,% + axis z line*=#1% + }, + /pgfplots/3d box/.is choice, + /pgfplots/3d box/background/.code ={\def\pgfplots@threedimbox@choice{0}},% + /pgfplots/3d box/complete/.code ={\def\pgfplots@threedimbox@choice{1}},% + /pgfplots/3d box/complete*/.code ={\def\pgfplots@threedimbox@choice{2}},% + /pgfplots/3d box/.default=complete,% + /pgfplots/3d box/background,% + /pgfplots/every 3d box foreground/.style={}, + /pgfplots/3d box foreground style/.style={% + /pgfplots/every 3d box foreground/.append style={#1}% + }, % set \pgfplots@xaxisdiscontnum % none = 0 % crunch = 1 @@ -1535,6 +2071,91 @@ \pgfusepath{stroke}}% }; }, + /pgfplots/every node near coord/.style={}, + % values: 'horizontal', 'vertical' or any tikz alignment command + % like 'left' or 'anchor=south west' or so. + /pgfplots/nodes near coords align/.initial=auto,% + % + % 'nodes near coords=<content of node>'. + % The content is by default \pgfmathprintnumber\pgfplotspointmeta. + % + % Use 'point meta=y' after 'nodes near coords' to typeset the y coordinates + % Use 'point meta=x' to typeset the x coordinates + /pgfplots/nodes near coords/.style={% + /pgfplots/scatter/@pre marker code/.code={},% + /pgfplots/scatter/@post marker code/.code={},% + /pgfplots/nodes near coords*={#1},% + },% + /pgfplots/nodes near coords*/.style={% + /pgfplots/scatter/true*,% + /pgfplots/set point meta if empty=f(x),% + scatter/@post marker code/.append code={% + % determine default alignment: + \pgfkeysgetvalue{/pgfplots/nodes near coords align}{\pgfplots@nodes@near@coords@align}% + \edef\pgfplots@nodes@near@coords@align{\pgfplots@nodes@near@coords@align}% + \def\pgfplots@loc@TMPa{auto}% + \ifx\pgfplots@nodes@near@coords@align\pgfplots@loc@TMPa + \ifx\pgfplotspointmetainputhandler x% + % point meta=x: + \def\pgfplots@nodes@near@coords@align{horizontal}% + \else + \def\pgfplots@nodes@near@coords@align{vertical}% + \fi + \fi + % check for sign-dependand alignment options: + \def\pgfplots@loc@TMPa{horizontal}% + \ifx\pgfplots@nodes@near@coords@align\pgfplots@loc@TMPa + \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname% + \def\pgfplots@nodes@near@coords@align{above}% + \else + \pgfmathfloatifflags{\pgfplotspointmeta}{2}{% + % \pgfplotspointmeta < 0 + \def\pgfplots@nodes@near@coords@align{left}% + }{% + % \pgfplotspointmeta >= 0 + \def\pgfplots@nodes@near@coords@align{right}% + }% + \fi + \else + \def\pgfplots@loc@TMPa{vertical}% + \ifx\pgfplots@nodes@near@coords@align\pgfplots@loc@TMPa + \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname% + \def\pgfplots@nodes@near@coords@align{above}% + \else + \pgfmathfloatifflags{\pgfplotspointmeta}{2}{% + % \pgfplotspointmeta < 0 + \def\pgfplots@nodes@near@coords@align{below}% + }{% + % \pgfplotspointmeta >= 0 + \def\pgfplots@nodes@near@coords@align{above}% + }% + \fi + \fi + \fi + % ok, place the node. + \expandafter\node\expandafter[\pgfplots@nodes@near@coords@align,% + /pgfplots/every node near coord] + at (0pt,0pt) + {% + \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname% + % point meta=explicit symbolic + % do no try to invoke \pgfmathprintnumber on + % symbolic data... this check should keep the user + % interface simpler. + \def\pgfplots@loc@TMPa{\pgfmathprintnumber\pgfplotspointmeta}% + \def\pgfplots@loc@TMPb{#1}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \pgfplotspointmeta + \else + #1% + \fi + \else + #1% + \fi + }; + },% + },% + /pgfplots/nodes near coords*/.default={\pgfmathprintnumber\pgfplotspointmeta}, /pgfplots/bar cycle list/.style={/pgfplots/cycle list={% {blue,fill=blue!30!white,mark=none},% {red,fill=red!30!white,mark=none},% @@ -1553,10 +2174,14 @@ area legend, axis on top, }, + /pgfplots/ybar legend/.style={ + /pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0cm,0.8em) (2*\pgfplotbarwidth,0.6em)};}, + }, /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)};}, + ybar legend, + /pgfplots/set point meta if empty=f(x),% /pgf/bar shift={% % total width = n*w + (n-1)*skip % -> subtract half for centering @@ -1574,14 +2199,19 @@ \pgfusepath{stroke}}% }; },% + /pgfplots/every node near coord/.append style={xshift={\pgfkeysvalueof{/pgf/bar shift}}},% /tikz/ybar, }, /pgfplots/ybar/.default=2pt, /pgfplots/ybar/.belongs to family=/pgfplots, + /pgfplots/xbar legend/.style={ + /pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0cm,0.8em) (2*\pgfplotbarwidth,0.6em)};}, + }, /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)};}, + /pgfplots/xbar legend, + /pgfplots/set point meta if empty=x,% /pgf/bar shift={% % total width = n*w + (n-1)*skip % -> subtract half for centering @@ -1599,30 +2229,39 @@ \pgfusepath{stroke}}% }; },% + /pgfplots/every node near coord/.append style={yshift={\pgfkeysvalueof{/pgf/bar shift}}},% /tikz/xbar, }, /pgfplots/xbar/.default=2pt, /pgfplots/xbar/.belongs to family=/pgfplots, + /pgfplots/ybar interval legend/.style={ + /pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,yshift=-0.2em,bar interval width=0.7,bar interval shift=0.5] plot coordinates {(0cm,0.8em) (5pt,0.6em) (10pt,0.6em)};}, + }, /pgfplots/ybar interval/.style={% + /pgfplots/set point meta if empty=f(x),% 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)};}, + xtick=data, + ybar interval legend, 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 legend/.style={% + /pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,yshift=-0.2em,bar interval width=0.7,bar interval shift=0.5] plot coordinates {(0cm,0.8em) (5pt,0.6em) (10pt,0.6em)};}, + }, /pgfplots/xbar interval/.style={% + /pgfplots/set point meta if empty=x,% bar cycle list, y tick label as interval, - % ytick=data, + 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)};}, + xbar interval legend, bar interval width={#1/\numplots}, bar interval shift={(\plotnum+0.5)/\numplots}, /tikz/xbar interval, @@ -1630,6 +2269,7 @@ /pgfplots/xbar interval/.default=1, /pgfplots/xbar interval/.belongs to family=/pgfplots, /pgfplots/xbar stacked/.style={ + /pgfplots/set point meta if empty=x,% bar cycle list, stack plots=x, stack dir=#1, @@ -1638,6 +2278,7 @@ /pgfplots/xbar stacked/.default=plus, /pgfplots/xbar stacked/.belongs to family=/pgfplots, /pgfplots/ybar stacked/.style={ + /pgfplots/set point meta if empty=f(x),% bar cycle list, stack plots=y, stack dir=#1, @@ -1646,6 +2287,7 @@ /pgfplots/ybar stacked/.default=plus, /pgfplots/ybar stacked/.belongs to family=/pgfplots, /pgfplots/xbar interval stacked/.style={ + /pgfplots/set point meta if empty=x,% bar cycle list, stack plots=x, stack dir=#1, @@ -1654,6 +2296,7 @@ /pgfplots/xbar interval stacked/.default=plus, /pgfplots/xbar interval stacked/.belongs to family=/pgfplots, /pgfplots/ybar interval stacked/.style={ + /pgfplots/set point meta if empty=f(x),% bar cycle list, stack plots=y, stack dir=#1, @@ -1671,10 +2314,9 @@ }, /pgfplots/plot file/skip first/.is if=pgfplots@plot@file@skipfirst, /pgfplots/plot file/skip first/.default=true, - /pgfplots/plot file/.unknown/.code={% - \let\pgfplots@table@curkeyname=\pgfkeyscurrentname - \pgfqkeys{/pgfplots}{\pgfplots@table@curkeyname=##1}% - }, + /pgfplots/plot file/ignore first/.style={/pgfplots/plot file/skip first={#1}}, + /pgfplots/plot file/.search also=/pgfplots,% + /pgfplots/plot coordinates/math parser/.is if=pgfplots@plot@coords@mathparser, /pgfplots/plot graphics/.code={\let\tikz@plot@handler=\pgfplotsplothandlergraphics},% /pgfplots/plot graphics/src/.initial=, /pgfplots/plot graphics/includegraphics/.initial=, @@ -1684,6 +2326,9 @@ /pgfplots/plot graphics/ymax/.initial=, /pgfplots/plot graphics/zmin/.initial=, /pgfplots/plot graphics/zmax/.initial=, + /pgfplots/plot graphics/lowlevel draw/.code 2 args={% + \pgfplots@plot@handler@graphics@DRAW{#1}{#2}% + },% /pgfplots/plot graphics/node/.style={ transform shape, inner sep=0pt, @@ -1693,6 +2338,92 @@ at={(0pt,0pt)}, rectangle }, + % 'mesh' plots. + % The macro \pgfplots@meshmode is + % n if meshmode == false, + % m if meshmode == 'mesh', + % s if meshmode == 'surf'. + % + % The type of surface plot can be configured with 'shader'. + /pgfplots/mesh/.is choice, + /pgfplots/mesh/true/.code={% + \def\pgfplots@meshmode{m}% + \let\tikz@plot@handler=\pgfplotsplothandlermesh + \pgfkeysalso{/pgfplots/set point meta if empty=f(x),/pgfplots/every mesh,/pgfplots/mesh legend,/tikz/color=mapped color}% + }, + /pgfplots/mesh/false/.code={ + \def\pgfplots@meshmode{n}% + \ifx\tikz@plot@handler\pgfplotsplothandlermesh + \let\tikz@plot@handler=\pgfplothandlerlineto + \fi}, + /pgfplots/mesh/.default=true, + /pgfplots/surf/.code={% + \pgfkeysalso{/pgfplots/mesh=#1}% + \def\pgfplots@meshmode{s}% + },% + /pgfplots/mesh/rows/.initial=, + /pgfplots/mesh/cols/.initial=, + /pgfplots/mesh/scanline verbose/.is if=pgfplots@scanline@verbose,% + /pgfplots/mesh/scanline verbose/.default=true, + /pgfplots/mesh/check/.code={% + \pgfplotsutilifstringequal{#1}{false}{% + \def\pgfplots@mesh@checkmode{0}% + }{% + \pgfplotsutilifstringequal{#1}{warning}{% + \def\pgfplots@mesh@checkmode{1}% + }{% + \pgfplotsutilifstringequal{#1}{error}{% + \def\pgfplots@mesh@checkmode{2}% + }{% + \pgfplots@error{Invalid value `#1' for /pgfplots/mesh/check. Please use one of false,warning,error}% + }% + }% + }% + },% + /pgfplots/mesh/check=error, + /pgfplots/mesh/ordering/.is choice, + /pgfplots/mesh/ordering/x varies/.code={\def\pgfplots@plot@mesh@ordering{0}}, + /pgfplots/mesh/ordering/y varies/.code={\def\pgfplots@plot@mesh@ordering{1}}, + /pgfplots/mesh/ordering/rowwise/.style={/pgfplots/mesh/ordering/x varies}, + /pgfplots/mesh/ordering/colwise/.style={/pgfplots/mesh/ordering/y varies}, + /pgfplots/mesh/ordering/x varies, + /pgfplots/every mesh/.code={% + % is slower: + %\pgfkeysalso{/pgfplots/unbounded coords=jump}% mesh plots need balanced cols! + },% + /pgfplots/mesh legend/.style={% + /pgfplots/legend image code/.code={% + \pgfplotsplothandlermesh@defaultlegend@img{##1}% + }% + }, + /pgfplots/mesh/num points/.initial=\numcoords,% this is NOT part of the public interface. Don't change it. + /pgfplots/z buffer/.is choice,% + /pgfplots/z buffer/none/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{0}},% + /pgfplots/z buffer/reverse x seq/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{1}},% + /pgfplots/z buffer/reverse y seq/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{2}},% + /pgfplots/z buffer/reverse xy seq/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{3}},% + /pgfplots/z buffer/sort/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{4}},% + /pgfplots/z buffer/auto/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{5}},% + /pgfplots/z buffer/default/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{6}},% + /pgfplots/z buffer/default,% + % + % Set the shader used for surface plots. + % RULES: + % 1. meshmode == 'm' (mesh): + % This means we use "shader/flat" to determine the colors + % and ignore fill colors. + % 2. meshmode == 's' (surf): + % the shader specifies how colors are used. + % 3. Onedimensional mesh/surf plots are treated like 'mesh' + % plots. + /pgfplots/shader/.is choice, + /pgfplots/shader/flat corner/.code={\def\pgfplotsplothandlermesh@shader{0}\def\pgfplotsplothandlermesh@flatmode{c}}, + /pgfplots/shader/flat mean/.code={\def\pgfplotsplothandlermesh@shader{0}\def\pgfplotsplothandlermesh@flatmode{m}}, + /pgfplots/shader/flat/.style={/pgfplots/shader/flat mean},% + /pgfplots/shader/faceted/.code={\def\pgfplotsplothandlermesh@shader{1}}, + /pgfplots/shader/interp/.code={\def\pgfplotsplothandlermesh@shader{2}}, + /pgfplots/shader/faceted, + /pgfplots/faceted color/.initial=mapped color!80!black, /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, @@ -1700,47 +2431,115 @@ /pgfplots/every crossref picture/.style={% baseline,yshift=0.3em }, + /pgfplots/unbounded coords/.code={% + \edef\pgfplots@loc@TMPa{#1}% + \def\pgfplots@loc@TMPb{discard}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \def\pgfplots@unbounded@handler{d}% + \else + \def\pgfplots@loc@TMPb{jump}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \def\pgfplots@unbounded@handler{j}% + \else + \pgfplots@error{Sorry, the choice `#1' is unknown for \pgfkeyscurrentkey. Please use either 'discard' or 'jump'.}% + \fi + \fi + },% + /pgfplots/unbounded coords=discard, /pgfplots/x coord trafo/.code={}, /pgfplots/x coord inv trafo/.code={}, /pgfplots/y coord trafo/.code={}, /pgfplots/y coord inv trafo/.code={}, /pgfplots/z coord trafo/.code={}, /pgfplots/z coord inv trafo/.code={}, -% Set \pgfplots@perpointmeta@choice to -% 0: mi is not available/not used. -% 1: mi = xi -% 2: mi = yi -% 3: mi = zi -% 4: mi = given explicitly somehow -% 5: mi = given explicitly somehow AS SYMBOLIC CONSTANTS. - /pgfplots/point meta/.is choice, - /pgfplots/point meta/none/.code={ - \def\pgfplots@perpointmeta@choice{0}% - \def\pgfplots@perpointmeta@arg{}% - }, - /pgfplots/point meta/x/.code={ - \def\pgfplots@perpointmeta@choice{1}% - \def\pgfplots@perpointmeta@arg{}% - }, - /pgfplots/point meta/y/.code={ - \def\pgfplots@perpointmeta@choice{2}% - \def\pgfplots@perpointmeta@arg{}% - }, - /pgfplots/point meta/z/.code={ - \def\pgfplots@perpointmeta@choice{3}% - \def\pgfplots@perpointmeta@arg{}% - }, - /pgfplots/point meta/explicit/.code={ - \def\pgfplots@perpointmeta@choice{4}% - \def\pgfplots@perpointmeta@arg{#1}% - }, - /pgfplots/point meta/explicit symbolic/.code={ - \def\pgfplots@perpointmeta@choice{5}% - \def\pgfplots@perpointmeta@arg{#1}% + % + % #1 = {<symbol1>,<symbol2>,....<symboln>} + /pgfplots/symbolic coords/.code 2 args={% + \pgfplotsarraynew\pgfplots@symbolic@coords@inverse{#2}% + \pgfplotsarrayforeachungrouped\pgfplots@symbolic@coords@inverse\as\pgfplots@loc@TMPa{% + \expandafter\edef\csname pgfp@symb@coords@\pgfplots@loc@TMPa\endcsname{\pgfplotsarrayforeachindex}% + }% + \pgfkeysdef{/pgfplots/#1 coord trafo}{% + \pgfutil@ifundefined{pgfp@symb@coords@##1}{% + \pgfplots@error{Sorry, the input coordinate `##1' has not been defined with 'symbolic #1 coords={#2}... Maybe it has been misspelled?}% + \def\pgfmathresult{0}% + }{% + \edef\pgfmathresult{\csname pgfp@symb@coords@##1\endcsname}% + }% + }% + \pgfkeysdef{/pgfplots/#1 coord inv trafo}{% + \begingroup + % discard everything up to the period: + \pgfmath@basic@round@{##1}% + \afterassignment\pgfplots@gobble@until@relax + \count0=\pgfmathresult\relax + \ifnum\count0<0 + \count0=0 + \else + \count1=\pgfplotsarraysizeof\pgfplots@symbolic@coords@inverse\relax + \ifnum\count0<\count1 + \else + \count0=\count1 + \advance\count0 by-1 + \fi + \fi + \pgfplotsarrayselect\count0 \of\pgfplots@symbolic@coords@inverse\to\pgfmathresult + \pgfmath@smuggleone\pgfmathresult + \endgroup + }% + \pgfkeysalso{% + /pgfplots/#1ticklabel={\tick},% + /pgfplots/scaled #1 ticks=false,% + /pgfplots/plot coordinates/math parser=false,% + }% + },% + /pgfplots/symbolic x coords/.style={symbolic coords={x}{#1}},% + /pgfplots/symbolic y coords/.style={symbolic coords={y}{#1}},% + /pgfplots/symbolic z coords/.style={symbolic coords={z}{#1}},% +% Defines the class name \pgfplotspointmetainputhandler: + /pgfplots/point meta/.code={% + % this thing here converts control sequences to + % characters, they won't cause 'unknown control sequence' + % errors: + \def\pgfplots@loc@TMPa{#1}% + \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \pgfkeysifdefined{/pgfplots/point meta/\pgfplots@loc@TMPb/.@cmd}{% + \pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/#1/.@cmd}{}% + }{% + \pgfplotssetpointmetainput{expr}{#1}% + }% + },% + /pgfplots/point meta/none/.code ={\pgfplotssetpointmetainput{}{}},% + /pgfplots/point meta/x/.code ={\pgfplotssetpointmetainput{x}{}},% + /pgfplots/point meta/y/.code ={\pgfplotssetpointmetainput{y}{}},% + /pgfplots/point meta/z/.code ={\pgfplotssetpointmetainput{z}{}},% + /pgfplots/point meta/explicit/.code={\pgfplotssetpointmetainput{explicit}{}},% + /pgfplots/point meta/explicit symbolic/.code={\pgfplotssetpointmetainput{explicit symbolic}{}},% + /pgfplots/point meta/f(x)/.code={ + \ifpgfplots@curplot@threedim + \pgfplotssetpointmetainput{z}{}% + \else + \pgfplotssetpointmetainput{y}{}% + \fi }, + /pgfplots/set point meta if empty/.code={% + \ifx\pgfplotspointmetainputhandler\pgfutil@empty + \pgfkeysalso{/pgfplots/point meta/#1}% + \fi + },% /pgfplots/point meta/none, + /pgfplots/point meta rel/.is choice, + /pgfplots/point meta rel/axis wide/.code={\def\pgfplots@perpointmeta@rel@choice{0}},% + /pgfplots/point meta rel/per plot/.code={\def\pgfplots@perpointmeta@rel@choice{1}},% + /pgfplots/point meta rel/axis wide,% + /pgfplots/point meta min/.initial=,% + /pgfplots/point meta max/.initial=,% /pgfplots/colormap name/.initial=hot, - /pgfplots/colormap/.code 2 args={ + /pgfplots/colormap access/.is choice, + /pgfplots/colormap access/direct/.code={\def\pgfplots@colormap@access{d}},% + /pgfplots/colormap access/map/.code={\def\pgfplots@colormap@access{m}},% + /pgfplots/colormap access/map,% + /pgfplots/colormap/.code 2 args={% \pgfplotscreatecolormap{#1}{#2}% \pgfkeysalso{/pgfplots/colormap name=#1}% }, @@ -1762,12 +2561,20 @@ /pgfplots/colormap/blackwhite/.style={ colormap={blackwhite}{gray(0cm)=(0); gray(1cm)=(1)} }, + /pgfplots/colormap/violet/.style={ + colormap={violet}{rgb255=(25,25,122) color=(white) rgb255=(238,140,238)} + }, /pgfplots/scatter/.is choice, /pgfplots/scatter/false/.code={% \pgfplots@scatterplotenabledfalse - }, + },% + /pgfplots/scatter/true*/.code={% + \pgfplots@scatterplotenabledtrue + \pgfkeysalso{/pgfplots/set point meta if empty=f(x)}% + },% /pgfplots/scatter/true/.code={% \pgfplots@scatterplotenabledtrue + \pgfkeysalso{/pgfplots/set point meta if empty=f(x)}% % make sure there is a mark set! \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}% \def\pgfplots@loc@TMPa{none}% @@ -1781,7 +2588,7 @@ \fi }, /pgfplots/scatter/.default=true, - /pgfplots/scatter src/.style={/pgfplots/point meta=#1}, + /pgfplots/scatter src/.style={/pgfplots/point meta={#1}}, /tikz/scatter/.style={/pgfplots/scatter=#1}, % % ARGUMENTS: the macros @@ -1791,90 +2598,72 @@ % - \pgfplotspointmetatransformedrange % are set during @pre marker code and @post marker code. % '#1' is empty. - /pgfplots/scatter/@pre marker code/.code={}, - /pgfplots/scatter/@post marker code/.code={}, - /pgfplots/scatter/use mapped color/.style={ - /pgfplots/scatter/@pre marker code/.code={ - \expandafter\pgfplotscolormapfind\expandafter[\pgfplotspointmetatransformedrange] - [1.0] - {\pgfplotspointmetatransformed} - {\pgfkeysvalueof{/pgfplots/colormap name}} -%\message{Color for current point is RGB '\pgfmathresult' (determined using meta 'phi(\pgfplotspointmeta) = \pgfplotspointmetatransformed')}% - \def\pgfplots@loc@TMPb{\definecolor{mapped color}{rgb}}% - \expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}% + /pgfplots/scatter/@pre marker code/.code=,% + /pgfplots/scatter/@post marker code/.code=,% + /pgfplots/scatter/use mapped color/.style={% + /pgfplots/scatter/@pre marker code/.code=,% + /pgfplots/scatter/@post marker code/.code=,% + /pgfplots/scatter/use mapped color*={#1},% + },% + /pgfplots/scatter/use mapped color*/.style={ + /pgfplots/scatter/@pre marker code/.append code={ + \pgfplotscolormapdefinemappedcolor\pgfplotspointmetatransformed \scope[#1]% }, - /pgfplots/scatter/@post marker code/.code={\endscope} + /pgfplots/scatter/@post marker code/.prefix code={\endscope} }, - /pgfplots/scatter/use mapped color/.default={draw=mapped color!80!black,fill=mapped color}, - /pgfplots/scatter/use mapped color, + /pgfplots/scatter/use mapped color*/.default={draw=mapped color!80!black,fill=mapped color}, + /pgfplots/scatter/use mapped color*, % expect '#1 = {<class>=<style>,<class>=<style>,...} where <class> % is expected as SYMBOL, not as number. See 'point meta/explicit symbolic' - /pgfplots/scatter/classes/.code={% + /pgfplots/scatter/classes/.style={% + /pgfplots/scatter/@pre marker code/.code=,% + /pgfplots/scatter/@post marker code/.code=,% + /pgfplots/scatter/classes*={#1},% + },% + /pgfplots/scatter/classes*/.code={% % Step 1: remember the per class-styles as % \csname pgfp@scatter@class@<class name>\endcsname % -> this is done locally! - \global\let\pgfplots@glob@TMPa=\pgfutil@empty - \def\pgfplots@loc@TMPa##1=##2\relax{% - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% - \t@pgfplots@tokb={\expandafter\def\csname pgfp@scatter@class@##1\endcsname{##2}}% - \xdef\pgfplots@glob@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \def\pgfplots@loc@TMPa##1=##2\pgfplots@EEOI{% + \expandafter\def\csname pgfp@scatter@class@##1\endcsname{##2}% }% - % accumulate the \def-macros in a global macro because - % \foreach is scoped: - \foreach \entry in {#1} {% - \edef\eentry{\entry}% - \expandafter\pgfplots@loc@TMPa\eentry\relax + \pgfplotsforeachentryinCSV{\pgfplots@loc@TMPb}{#1}{% + \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb\pgfplots@EEOI }% - % do the assignments: - \pgfplots@glob@TMPa - \global\let\pgfplots@glob@TMPa=\pgfutil@empty - \pgfkeysdef{/pgfplots/scatter/@pre marker code}{% - \pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% - \let\pgfplots@loc@TMPa=\pgfplotspointmeta - % - % ups - no styles available? Maybe something went - % wrong with the 'scatter src' key. Check whether it - % was accidentally a numerical style: - \ifnum\pgfplots@perpointmeta@choice=5 - \else - % ok, be fault tolerant and round to an integer: - \pgfmathfloattofixed{\pgfplotspointmeta}% - \begingroup - \pgfkeys{/pgf/number format/precision=0}% - \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% - \pgfmath@smuggleone\pgfmathresult - \endgroup - \let\pgfplotspointmeta=\pgfmathresult - \fi - % now, check again: - \pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% - % still not possible? Then, try truncating the - % number to an integer. - \expandafter\pgfutil@in@\expandafter.\expandafter{\pgfplotspointmeta}% + % + \pgfkeysalso{% + /pgfplots/scatter/@pre marker code/.append code={\pgfplots@scatter@classes@pre@marker@code},% + /pgfplots/scatter/@post marker code/.prefix code={\endscope}% + }% + % Now:remember the classes. + \pgfkeyssetvalue{/pgfplots/scatter/classes/values}{#1}% + % + % and generate legend items for every single class, + % But ONLY if we really *have* a plot which uses + % scatter/classes! + \pgfkeys{/pgfplots/execute at begin plot@@/.add={}{% + \ifpgfplots@scatterplotenabled + \pgfkeysgetvalue{/pgfplots/scatter/@pre marker code/.@cmd}\pgfplots@loc@TMPa + \def\pgfplots@loc@TMPb{\pgfutil@in@{\pgfplots@scatter@classes@pre@marker@code}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa\pgfeov}% \ifpgfutil@in@ - \def\pgfplots@loc@TMPb####1.####2\relax{\def\pgfplotspointmeta{####1}}% - \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\relax + % modify '\pgfplots@rememberplotspec' such + % that it generates entries for every class: + \let\pgfplots@rememberplotspec@orig=\pgfplots@rememberplotspec + \def\pgfplots@rememberplotspec##1{% + \def\pgfplots@scatter@loc@TMPa####1=####2\pgfplots@EEOI{% + \pgfplots@rememberplotspec@orig{##1,####2}% + \pgfplots@rememberplotspec@for@label[####1]{##1,####2}% + }% + \pgfplotsforeachentryinCSV{\pgfplots@scatter@loc@TMPb}{#1}{% + \expandafter\pgfplots@scatter@loc@TMPa\pgfplots@scatter@loc@TMPb\pgfplots@EEOI + }% + }% \fi - % now, check again: - \pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% - \pgfutil@ifundefined{pgfp@scatter@WARNING@\pgfplotspointmeta}{% - \pgfplots@warning{scatter/classes: can't find class for '\pgfplotspointmeta'!? Please make sure you have specified 'scatter src=explicit symbolic'. Ignoring class '\pgfplotspointmeta' (this message will not come again).}% - \expandafter\gdef\csname pgfp@scatter@WARNING@\pgfplotspointmeta\endcsname{ALREADY CHECKED}% - }{}% - \def\pgfplots@loc@TMPa{}% - }{% - \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname - }% - }{% - \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname - }% - }{% - \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname + \fi }% - \expandafter\scope\expandafter[\pgfplots@loc@TMPa]% }% - \pgfkeysdef{/pgfplots/scatter/@post marker code}{\endscope}% }, /pgfplots/refstyle/.code={% \pgfutil@ifundefined{pgfplots@labelstyle@#1}{% @@ -1905,7 +2694,82 @@ label style={font=\small}, /pgfplots/max space between ticks=15, every mark/.append style={mark size=8}, - ylabel style={yshift=-0.3cm}, + major tick length=0.1cm, + minor tick length=0.066cm, + %ylabel style={yshift=-0.3cm}, + }, + /pgfplots/cube/set size/.code 2 args={% + \expandafter\def\csname pgfplots@cube@gethalf@#1\endcsname{% + \afterassignment\pgfplots@gobble@until@relax + \pgfplots@tmpa=#2pt\relax + \pgfplotsconvertunittocoordinate #1{0.5\pgfplots@tmpa}% + }% + },% + /pgfplots/cube/size x/.style={/pgfplots/cube/set size=x{#1}}, + /pgfplots/cube/size y/.style={/pgfplots/cube/set size=y{#1}}, + /pgfplots/cube/size z/.style={/pgfplots/cube/set size=z{#1}}, + /pgfplots/cube/size x=\pgfplotmarksize, + /pgfplots/cube/size y=\pgfplotmarksize, + /pgfplots/cube/size z=\pgfplotmarksize, + /pgfplots/xtick placement tolerance/.initial=0.05pt, + /pgfplots/ytick placement tolerance/.initial=0.05pt, + /pgfplots/ztick placement tolerance/.initial=0.05pt, + /pgfplots/compat/anchors/.is choice, + /pgfplots/compat/anchors/pre 1.3/.code={\pgfplots@deprecated@anchorstrue},% FIXME: WAS \global + /pgfplots/compat/anchors/newest/.code= {\pgfplots@deprecated@anchorsfalse},% + /pgfplots/compat/anchors/default/.code={\pgfplots@deprecated@anchorsfalse},% + /pgfplots/compat/labels/.is choice, + /pgfplots/compat/labels/pre 1.3/.style={% + /pgfplots/xlabel absolute, + /pgfplots/ylabel absolute},% + /pgfplots/compat/labels/newest/.style={% + /pgfplots/xlabel near ticks, + /pgfplots/ylabel near ticks},% + /pgfplots/compat/labels/default/.style={/pgfplots/compat/labels/pre 1.3},% maintain backwards compatibility for labels :-( + /pgfplots/compat/.style={% + /pgfplots/compat/anchors=#1,% + /pgfplots/compat/labels=#1,% + },% + /pgfplots/compat/.default=pre 1.3,% + /pgfplots/compat=default,% + % + /pgfplots/show outer normals/.style={% + extra description/.append code={ + \def\length{5} + \draw[->,blue] \pgfextra{% + \pgfpathmoveto{#1} + \pgfpathlineto{% + \pgfpointadd + {#1} + {\pgfqpointscale{\length}{\pgfplotspointouternormalvectorofticklabelaxis{x}}}% + }% + }; + \draw[->,red] \pgfextra{% + \pgfpathmoveto{#1}% + \pgfpathlineto{% + \pgfpointadd + {#1} + {\pgfqpointscale{\length}{\pgfplotspointouternormalvectorofticklabelaxis{y}}}% + }% + }; + \ifpgfplots@threedim + \draw[->,black] \pgfextra{% + \pgfpathmoveto{#1}% + \pgfpathlineto{% + \pgfpointadd + {#1} + {\pgfqpointscale{\length}{\pgfplotspointouternormalvectorofticklabelaxis{z}}}% + }% + }; + \fi + }, + }, + /pgfplots/show outer normals/.default={% + \ifpgfplots@threedim + \pgfplotspointrelaxisxy{-0.03}{-0.03}% + \else + \pgfplotspointrelaxisxyz{-0.03}{-0.03}{-0.03}% + \fi }, } @@ -1931,6 +2795,7 @@ \pgfplots@cmdkey@alias xticklabel style=x tick label style; \pgfplots@cmdkey@alias yticklabel style=y tick label style; \pgfplots@cmdkey@alias zticklabel style=z tick label style; +\pgfplots@cmdkey@alias ticklabel style=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; @@ -1970,6 +2835,11 @@ \pgfkeysgetvalue{/pgfplots/domain}\pgfplots@plot@domain \pgfkeysgetvalue{/pgfplots/samples at}\pgfplots@plot@samples@at \ifx\pgfplots@plot@domain\pgfutil@empty + % simply acquire /tikz/domain value: + \pgfplots@gettikzinternal@keyval{domain}{tikz@plot@domain}{-5:5}% + \pgfkeyslet{/pgfplots/domain}{\tikz@plot@domain}% + \let\pgfplots@plot@domain=\tikz@plot@domain + % \ifx\pgfplots@plot@samples@at\pgfutil@empty \if 1\pgfplots@loc@TMPa % Resample! See above. @@ -1981,12 +2851,11 @@ \else % routines should use \pgfplots@plot@samples@at. \fi - \else - % do that such that any active ':' sign will be expanded - for - % french babel support. - \edef\pgfplots@plot@domain{\pgfplots@plot@domain}% - \pgfkeyslet{/pgfplots/domain}\pgfplots@plot@domain \fi + % do that such that any active ':' sign will be expanded - for + % french babel support. + \edef\pgfplots@plot@domain{\pgfplots@plot@domain}% + \pgfkeyslet{/pgfplots/domain}\pgfplots@plot@domain }% \def\pgfplots@set@at#1{\def\pgfplots@at{#1}}% @@ -2005,12 +2874,36 @@ % #1 axis (x or y) % #2 the label \def\pgfplots@show@label#1#2{% + \begingroup + % Prepare special alignment features here. + % + % The idea is to: + % 1. Declare a local COORDINATE SYSTEM to place labels, + % the 'ticklabel cs' for the current axis. + % It takes 1-2 arguments where the first is the coordinate on the + % ticklabel axis (between 0 and 1). The second is an optional shift orthogonal to + % the axis in direction of the outer normal. The minimum shift is + % the largest' ticklabels dimension. + % + % 2. Declare a local ANCHOR to align labels, the 'near ticklabel' + % anchor. + % + % Both things are not necessary - but they *can* be used. + \tikzdeclarecoordinatesystem{ticklabel}{\pgfplotspointticklabelcs[\pgfkeysvalueof{/pgfplots/#1label shift}]{#1}{##1}}% + \pgfplotsdeclareborderanchorforticklabelaxis{#1}{near ticklabel}% + % + \pgfkeysgetvalue{/tikz/sloped/.@cmd}\pgfplots@loc@TMPa + \pgfkeyslet{/tikz/sloped/orig/.@cmd}\pgfplots@loc@TMPa + \pgfkeysdef{/tikz/sloped}{\pgfkeysalso{/tikz/sloped like #1 axis}}% + % \node [/pgfplots/every axis label,% /pgfplots/every axis #1 label] {#2}; + \endgroup } + \def\pgfplots@show@title#1{% \node% [/pgfplots/every axis title] @@ -2021,7 +2914,7 @@ % #1: the 'a' axis on the oriented surface (the same as \pgfplotspointonorientedsurfaceA) % #2: the 'b' axis on the orentied surface (the same as \pgfplotspointonorientedsurfaceB) \def\pgfplots@drawaxis@innerlines@onorientedsurf#1#2#3{% - \ifnum\csname pgfplots@#1axislinesnum\endcsname=2 + \if2\csname pgfplots@#1axislinesnum\endcsname \draw[/pgfplots/every inner #1 axis line,% decorate,% #1discont,% @@ -2039,11 +2932,13 @@ % draw separate lines. This here is necessary if we want arrow heads. % % #1: the 'a' axis on the oriented surface (the same as \pgfplotspointonorientedsurfaceA) -% #2: the 'b' axis on the orentied surface (the same as \pgfplotspointonorientedsurfaceB) +% #2: the 'b' axis on the oriented surface (the same as \pgfplotspointonorientedsurfaceB) \def\pgfplots@drawaxis@outerlines@separate@onorientedsurf#1#2{% + \if2\csname pgfplots@#1axislinesnum\endcsname + % centered axis lines handled elsewhere. + \else \scope[/pgfplots/every outer #1 axis line, #1discont,decoration={pre length=\csname #1disstart\endcsname, post length=\csname #1disend\endcsname}] - \ifcase\csname pgfplots@#1axislinesnum\endcsname\relax \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% \draw decorate { \pgfextra @@ -2051,26 +2946,7 @@ \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#2min\endcsname}}% \endpgfextra }; - }{\relax}% - \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% - \draw decorate { - \pgfextra - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@#2max\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#2max\endcsname}}% - \endpgfextra - }; - }{\relax}% - \or - \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% - \draw decorate { - \pgfextra - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@#2min\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#2min\endcsname}}% - \endpgfextra - }; - }{\relax}% - \or - \or + }{}% \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% \draw decorate { \pgfextra @@ -2078,9 +2954,9 @@ \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#2max\endcsname}}% \endpgfextra }; - }{\relax}% - \fi + }{}% \endscope + \fi }% % This here is complicated: we try to create good edges and draw a @@ -2097,6 +2973,8 @@ \draw[ /pgfplots/every outer x axis line, % FIXME! these outer styles need much more attention :-( /pgfplots/every outer y axis line] + % FIXME : replace this here with basic layer! This should also + % allow closed paths: (\pgfplots@xmin, \pgfplots@ymin) \ifpgfplots@hide@y { (\pgfplots@xmin, \pgfplots@ymax) } @@ -2189,28 +3067,79 @@ \fi }% -\def\pgfplots@rememberplotspec#1{% - \pgfplotslistpushbackglobal{#1}\to\pgfplots@plotspeclist +\def\pgfplots@rememberplotspec@for@label{\pgfutil@ifnextchar[{\pgfplots@rememberplotspec@for@label@}{\pgfplots@rememberplotspec@for@label@[]}}% +\def\pgfplots@rememberplotspec@for@label@[#1]#2{% + \expandafter\gdef\csname pgfplots@last@plot@style@#1\endcsname{#2}% + \global\pgfplots@has@label@informationtrue +}% +\def\pgfplots@rememberplotspec{\pgfutil@ifnextchar[{\pgfplots@rememberplotspec@opt}{\pgfplots@rememberplotspec@opt[]}}% +\def\pgfplots@rememberplotspec@opt[#1]#2{% + \pgfplots@rememberplotspec@for@label[#1]{#2}% + \pgfplotslistpushbackglobal{#2}\to\pgfplots@plotspeclist } \def\pgfplots@getautoplotspec into#1{% - \pgfplotslistsize\autoplotspeclist\to\c@pgf@counta - \ifnum\c@pgf@counta=0 - \let#1=\pgfutil@empty + \begingroup + \let#1=\pgfutil@empty + \pgfkeysgetvalue{/pgfplots/cycle multi list/@dim}\pgfplots@cycle@dim + \ifnum\pgfplots@cycle@dim>0 + % use the 'cycle multi list' feature. + % + % it employs a scalar -> multiindex map like + % void fromScalar( size_t d, size_t scalar, size_t* Iout, const size_t* N ) + % { + % size_t ret=scalar; + % for( int i = d-1; i>=0; --i ) { + % Iout[i] = ret % N[i]; + % ret /= N[i]; + % } + % } + % to get the different indices into the cycle lists. + %-------------------------------------------------- + \c@pgf@counta=\pgfplots@cycle@dim + \c@pgf@countb=\pgfplots@numplots\relax + \advance\c@pgf@counta by-1 + \pgfplotsloop{% + \ifnum\c@pgf@counta<0 + \pgfplotsloopcontinuefalse + \else + \pgfplotsloopcontinuetrue + \fi + }{% + \pgfkeysgetvalue{/pgfplots/cycle multi list/@N\the\c@pgf@counta}\pgfplots@cycle@N + % compute list index: + \pgfplotsmathmodint{\c@pgf@countb}{\pgfplots@cycle@N}% + \divide\c@pgf@countb by \pgfplots@cycle@N\relax + % + \expandafter\pgfplots@getautoplotspec@ + \csname pgfp@cyclist@/pgfplots/cycle multi list/@list\the\c@pgf@counta @\endcsname + {\pgfplots@cycle@N}% + {\pgfmathresult}% + \t@pgfplots@toka=\expandafter{#1,}% + \t@pgfplots@tokb=\expandafter{\pgfplotsretval}% + \edef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \advance\c@pgf@counta by-1 + }% \else - \c@pgf@countb=\pgfplots@numplots - % offset modulo size: - \pgfutil@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 - \pgfutil@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}% + % normal cycle list: + \pgfplotslistsize\autoplotspeclist\to\c@pgf@countd + \pgfplots@getautoplotspec@{\autoplotspeclist}{\c@pgf@countd}{\pgfplots@numplots}% + \let#1=\pgfplotsretval + \fi + \pgfmath@smuggleone#1% + \endgroup +} +% #1: list name (macro!) +% #2: list size (integer register or value) +% #3: list element index +% +% defines \pgfplotsretval +\def\pgfplots@getautoplotspec@#1#2#3{% + \ifnum#2=0 + \let\pgfplotsretval=\pgfutil@empty + \else + \pgfplotsmathmodint{#3}{#2}% + \pgfplotslistselect\pgfmathresult\of#1\to\pgfplotsretval \fi } @@ -2290,38 +3219,31 @@ % #4: commands which should be executed after '#2 #3'. % \long\def\pgfplots@path@enqueue@coords#1#2#3#4{% - \ifpgfplots@draw@at@end - \pgfplotslistpushbackglobal{#1}{#2}{#3}{#4}\to\pgfplots@stored@plotlist - \else - \begingroup - #1#2#3#4% - \endgroup - \fi + \pgfplotslistpushbackglobal{#1}{#2}{#3}{#4}\to\pgfplots@stored@plotlist } -% The same as \pgfplots@path@enqueue@coords, but this here also stores -% \pgfplots@addplot@nonlegend@options -\long\def\pgfplots@addplot@enqueue@coords#1#2#3#4{% - \ifpgfplots@draw@at@end - \ifx\pgfplots@addplot@nonlegend@options\pgfutil@empty - \pgfplots@path@enqueue@coords{#1}{#2}{#3}{#4}% - \else - \expandafter - \pgfplots@path@enqueue@coords - \expandafter{% - \expandafter\pgfplotsset\expandafter{\pgfplots@addplot@nonlegend@options}% - #1}{#2}{#3}{#4}% - \fi - \else - \pgfplots@path@enqueue@coords{#1}{#2}{#3}{#4}% - \fi -} +% this was formerly slightly different than +% \pgfplots@path@enqueue@coords, but it is now the same. +\let\pgfplots@addplot@enqueue@coords=\pgfplots@path@enqueue@coords % Remembers the plotting command #1. \long\def\pgfplots@path@enqueue#1{% \pgfplots@path@enqueue@coords{}{}{#1}{}% } +% Use +%\begin{axis} +% \pgfplotsextra{ +% ... basic level commands or whatever... +% } +%\end{axis} +% to process the special commands by pgfplots. +% This is the same treatment as for TikZ \path commands: +% the commands will be processed as soon as the axis is finished- not +% before. +% +% In contrast to \path, \pgfplotsextra can contain any command(s). +\let\pgfplotsextra=\pgfplots@path@enqueue % Assigns a legend. @@ -2341,6 +3263,41 @@ \global\let\pgfplots@legend=\pgfplots@loc@TMPc } +\def\pgfplots@reverselegend{% + % Reverse \pgfplots@plotspeclist + \begingroup + \pgfplotslistnewempty\pgfplots@plotspeclist@reversed + \pgfplotslistforeachungrouped\pgfplots@plotspeclist\as\pgfplots@plotspeclisttmp{% + \expandafter\pgfplotslistpushfront\pgfplots@plotspeclisttmp\to\pgfplots@plotspeclist@reversed + }% + \global\let\pgfplots@plotspeclist=\pgfplots@plotspeclist@reversed + \let\pgfplots@legend@reversed=\relax + % + % Reverse \pgfplots@legend + \pgfplotslistnewempty\pgfplots@legend@reversed + \pgfplotslistforeachungrouped\pgfplots@legend\as\pgfplots@legendtmp{% + \expandafter\pgfplotslistpushfront\pgfplots@legendtmp\to\pgfplots@legend@reversed + }% + \global\let\pgfplots@legend=\pgfplots@legend@reversed + \endgroup +} + + +\def\pgfplots@addlegendentryexpanded{% + \pgfutil@ifnextchar[{% + \pgfplots@addlegendentryexpanded@opts + }{% + \pgfplots@addlegendentryexpanded@opts[]% + }% +} +\def\pgfplots@addlegendentryexpanded@opts[#1]#2{% + \begingroup + \let\protect=\noexpand + \edef\pgfplots@loc@TMPa{#2}% + \def\pgfplots@loc@TMPb{\pgfplots@addlegendentry@opts[#1]}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% + \endgroup +}% \def\pgfplots@addlegendentry{% \pgfutil@ifnextchar[{% @@ -2357,18 +3314,17 @@ \globaldefs=1 \pgfplotslistcheckempty\pgfplots@plotspeclist \ifpgfplotslistempty - \let\pgfplots@curplotlist=\pgfutil@empty + \let\pgfplots@curplotlist=\relax \else \pgfplotslistpopfront\pgfplots@plotspeclist\to\pgfplots@curplotlist + \pgfplotslistcheckempty\pgfplots@legend + \ifpgfplotslistempty + \let\pgfplots@curlegend=\pgfutil@empty + \else + \pgfplotslistpopfront\pgfplots@legend\to\pgfplots@curlegend + \fi \fi % - \pgfplotslistcheckempty\pgfplots@legend - \ifpgfplotslistempty - \let\pgfplots@curlegend=\pgfutil@empty - \else - \pgfplotslistpopfront\pgfplots@legend\to\pgfplots@curlegend - \fi - \advance\pgfplots@numplots by-1 }} \def\pgfplots@try@mirror@plot@handler{% @@ -2386,13 +3342,12 @@ \long\def\pgfplots@show@small@legendplots#1#2{ \begingroup - \def\pgfplots@loc@TMPb{#1}% - \ifx\pgfplots@loc@TMPb\pgfutil@empty - \else - \pgfqkeys{/pgfplots/search path for tikz}{#1}% - \fi - \pgfkeysvalueof{/pgfplots/legend image code/.@cmd}#2\pgfeov + \pgfplots@define@currentplotstyle@as{#1,#2}% + \scope[/tikz/current plot style]% this scoping construction allows plot styles to change 'legend image code'. + \pgfkeysvalueof{/pgfplots/legend image code/.@cmd}\pgfeov + \endscope \endgroup + %\pgfkeysvalueof{/pgfplots/legend image code/.@cmd}{/pgfplots/.cd,#1,#2}\pgfeov } \def\pgfplots@split@opts{% @@ -2426,6 +3381,9 @@ \fi \ifpgfplotslistempty \else + \ifpgfplots@reverse@legend + \pgfplots@reverselegend + \fi % % \begingroup @@ -2459,9 +3417,14 @@ \curcolumnNum=0 \maxcolumnCount=\pgfplots@legend@columns\relax % - \pgfutil@loop - \ifnum0<\pgfplots@numplots\relax + \pgfplotsloop{% \pgfplots@pop@next@legend + \ifpgfplotslistempty + \pgfplotsloopcontinuefalse + \else + \pgfplotsloopcontinuetrue + \fi + }{% \ifx\pgfplots@curlegend\pgfutil@empty \else \advance\curcolumnNum by1 @@ -2494,12 +3457,13 @@ \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\\}% \else \pgfplotslistcheckempty\pgfplots@legend - \ifnum\pgfplots@numplots=0 - \pgfplotslistemptytrue + \ifpgfplotslistempty + \else + \pgfplotslistcheckempty\pgfplots@plotspeclist \fi \ifpgfplotslistempty % Ok, either the legend list is empty or - % there are no more plots. + % there are no more plot specifications. % % Finalize matrix: \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\\}% @@ -2517,7 +3481,7 @@ \fi \expandafter\t@pgfplots@toka\expandafter{\pgfplots@glob@TMPa}% \fi - \pgfutil@repeat + }% \t@pgfplots@tokb={\matrix[/pgfplots/every axis legend]}% \xdef\pgfplots@glob@TMPa{% \noexpand\def\noexpand\plotnum{0}% @@ -2558,115 +3522,134 @@ % DEPRECATED. \def\logtologtentomacro#1#2{% - \pgfmathmultiply@{#1}\reciproclogten% + \pgfmathlogtologten@{#1}% \expandafter\skipsuffixzero\pgfmathresult|% \let#2=\pgfmathresult } % DEPRECATED. \def\logtologten#1{% - \pgfmathmultiply@{#1}\reciproclogten% + \pgfmathlogtologten@{#1}% \expandafter\skipsuffixzero\pgfmathresult|% \pgfmathresult } +\pgfkeysdef{/pgfplots/@enlargelimits/true}{% + \def\bool@pgfplots@loc@enlargelimits@min{1}% + \def\bool@pgfplots@loc@enlargelimits@max{1}% +}% +\pgfkeysdef{/pgfplots/@enlargelimits/false}{% + \def\bool@pgfplots@loc@enlargelimits@min{0}% + \def\bool@pgfplots@loc@enlargelimits@max{0}% +}% +\pgfkeysdef{/pgfplots/@enlargelimits/upper}{% + \def\bool@pgfplots@loc@enlargelimits@min{0}% + \def\bool@pgfplots@loc@enlargelimits@max{1}% +}% +\pgfkeysdef{/pgfplots/@enlargelimits/lower}{% + \def\bool@pgfplots@loc@enlargelimits@min{1}% + \def\bool@pgfplots@loc@enlargelimits@max{0}% +}% +\pgfkeysdef{/pgfplots/@enlargelimits/auto}{% + \def\bool@pgfplots@loc@enlargelimits@min{0}% + \def\bool@pgfplots@loc@enlargelimits@max{0}% + \def\pgfplots@loc@TMPa{0}% + \ifpgfplots@threedim + \if\pgfplots@enlargelimits@curaxis z% + \def\pgfplots@loc@TMPa{1}% + \fi + \else + \def\pgfplots@loc@TMPa{1}% + \fi + \if1\pgfplots@loc@TMPa + \pgfplots@if{pgfplots@autocompute@\pgfplots@enlargelimits@curaxis min}{% + \def\bool@pgfplots@loc@enlargelimits@min{1}% + }{}% + \pgfplots@if{pgfplots@autocompute@\pgfplots@enlargelimits@curaxis max}{% + \def\bool@pgfplots@loc@enlargelimits@max{1}% + }{}% + \fi +}% +\pgfkeysdef{/pgfplots/@enlargelimits/value}{% + \pgfmathparse{#1}% + \let\pgfplots@enlargelimits@relthresh=\pgfmathresult + \let\pgfplots@enlargelimits@absthresh=\pgfutil@empty +}% +\pgfkeysdef{/pgfplots/@enlargelimits/rel}{\pgfkeysalso{true,value={#1}}}% +\pgfkeysdef{/pgfplots/@enlargelimits/abs value}{% + \begingroup + \pgfutil@namelet{pgfplots@datascaletrafo@\pgfplots@enlargelimits@curaxis}{pgfplots@datascaletrafo@\pgfplots@enlargelimits@curaxis @noshift}% + \expandafter\csname pgfplotstransformcoordinate\pgfplots@enlargelimits@curaxis\endcsname{#1}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@enlargelimits@absthresh=\pgfmathresult + \let\pgfplots@enlargelimits@relthresh=\pgfutil@empty +}% +\pgfkeysdef{/pgfplots/@enlargelimits/abs}{\pgfkeysalso{true,abs value={#1}}}% +\pgfkeysdef{/pgfplots/@enlargelimits/.unknown}{\pgfkeysalso{true,value={\pgfkeyscurrentname}}}% + \def\pgfplots@enlarge@limit@ifconfigured#1{% - \pgfplots@enlargelimits@autofalse - \pgfplots@enlargelimitsfalse - \pgfplots@enlargelimits@rel@threshfalse + \begingroup + \def\bool@pgfplots@loc@enlargelimits@min{0}% + \def\bool@pgfplots@loc@enlargelimits@max{0}% + \def\pgfplots@enlargelimits@relthresh{0.1}% the default + \let\pgfplots@enlargelimits@absthresh=\pgfutil@empty + \def\pgfplots@enlargelimits@curaxis{#1}% + % \pgfkeysgetvalue{/pgfplots/enlarge #1 limits}{\pgfplots@loc@TMPa}% + \def\pgfplots@loc@TMPb{\pgfqkeys{/pgfplots/@enlargelimits}}% set the argument keys + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% % - \def\pgfplots@loc@TMPb{true}% - \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb - \pgfplots@enlargelimitstrue + \def\bool@pgfplots@loc@enlargeany{0}% + \if1\bool@pgfplots@loc@enlargelimits@min + \def\bool@pgfplots@loc@enlargeany{1}% \else - \def\pgfplots@loc@TMPb{false}% - \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb - \else - \def\pgfplots@loc@TMPb{auto}% - \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb - \pgfplots@enlargelimits@autotrue - \else - \begingroup - % try to read it as number: - \pgf@xa\pgfplots@loc@TMPa pt\relax - \endgroup - \pgfplots@enlargelimitstrue - \pgfplots@enlargelimits@rel@threshtrue - \fi + \if1\bool@pgfplots@loc@enlargelimits@max + \def\bool@pgfplots@loc@enlargeany{1}% \fi \fi - \expandafter\let\expandafter\ifpgfplots@autocompute@@@min\csname ifpgfplots@autocompute@#1min\endcsname - \expandafter\let\expandafter\ifpgfplots@autocompute@@@max\csname ifpgfplots@autocompute@#1max\endcsname - \ifpgfplots@enlargelimits - % relax the sizes. - % - % Idea: if the user chose his xmin,xmax tight to his data, - % this here will look better. + \if1\bool@pgfplots@loc@enlargeany \pgfplots@enlarge@limit@for{#1}% - \else - \ifpgfplots@enlargelimits@auto - %\ifpgfplots@hide@x - % there is no axis, so skip this enlargement (unless - % the user explizitly requests it) - % WHY!? - %\else - % FIXME : this here should be user-configurable! - \ifpgfplots@autocompute@@@min - \pgfplots@enlarge@limit@for{#1}% - \else - \ifpgfplots@autocompute@@@max - \pgfplots@enlarge@limit@for{#1}% - \fi - \fi - %\fi - \fi \fi + % assignments are made globally. + \endgroup } +% Helper method inside of \pgfplots@enlarge@limit@ifconfigured. +% +% It modifies '#1min' and '#1max' (globally!) according to the already prepared +% booleans. \def\pgfplots@enlarge@limit@for#1{% \begingroup - \expandafter\let\expandafter\pgfplots@@min\expandafter=\csname pgfplots@#1min\endcsname - \expandafter\let\expandafter\pgfplots@@max\expandafter=\csname pgfplots@#1max\endcsname - \expandafter\let\expandafter\ifpgfplots@autocompute@@@min\csname ifpgfplots@autocompute@#1min\endcsname - \expandafter\let\expandafter\ifpgfplots@autocompute@@@max\csname ifpgfplots@autocompute@#1max\endcsname - \ifpgfplots@enlargelimits@rel@thresh - \pgfkeysgetvalue{/pgfplots/enlarge #1 limits}{\enlargepercent}% + \expandafter\let\expandafter\pgfplots@@min\csname pgfplots@#1min\endcsname + \expandafter\let\expandafter\pgfplots@@max\csname pgfplots@#1max\endcsname + \ifx\pgfplots@enlargelimits@relthresh\pgfutil@empty + % we have an absolute enlarge value: + \let\enlargeabsolute=\pgfplots@enlargelimits@absthresh + \pgf@xb=\pgfplots@enlargelimits@absthresh pt \else - \def\enlargepercent{0.1}% FIXME : pack 10% as default into option 'enlargelimits' or so + % we have a relative enlarge value: + \pgfmathsubtract@\pgfplots@@max\pgfplots@@min% + \pgf@xa=\pgfmathresult pt + \pgf@xb=\pgfplots@enlargelimits@relthresh\pgf@xa + \edef\enlargeabsolute{\pgf@sys@tonumber{\pgf@xb}}% \fi - \pgfmathsubtract@\pgfplots@@max\pgfplots@@min% - \pgf@xa\pgfmathresult pt - \pgf@xb\enlargepercent\pgf@xa \ifdim\pgf@xb>0.001pt % the case with % enlargeabsolute ~= 0 % means that \pgfplots@@min ~= \pgfplots@@max. % It is handled in another method. - \edef\enlargeabsolute{\pgf@sys@tonumber{\pgf@xb}}% % - \ifpgfplots@enlargelimits@auto - \ifpgfplots@autocompute@@@min - \pgfmathsubtract@\pgfplots@@min\enlargeabsolute% - \let\pgfplots@@min=\pgfmathresult - \fi - \ifpgfplots@autocompute@@@max - \pgfmathadd@\pgfplots@@max\enlargeabsolute% - \let\pgfplots@@max=\pgfmathresult - \fi - \else - % compute xmin := xmin - enlargeabsolute + \if1\bool@pgfplots@loc@enlargelimits@min \pgfmathsubtract@\pgfplots@@min\enlargeabsolute% - \let\pgfplots@@min=\pgfmathresult + \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult + \fi + \if1\bool@pgfplots@loc@enlargelimits@max \pgfmathadd@\pgfplots@@max\enlargeabsolute% - \let\pgfplots@@max=\pgfmathresult + \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult \fi \fi - \xdef\pgfplots@glob@TMPa{\pgfplots@@min}% - \xdef\pgfplots@glob@TMPb{\pgfplots@@max}% \endgroup - \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfplots@glob@TMPa - \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfplots@glob@TMPb } @@ -2699,141 +3682,140 @@ % % Unit vectors will be scaled later. \def\pgfplots@check@and@apply@datatrafo@for#1{% - \expandafter\let\expandafter\if@datascaled@cur\csname ifpgfplots@apply@datatrafo@#1\endcsname - \if@datascaled@cur + \pgfplots@if{pgfplots@apply@datatrafo@#1}{% \pgfplots@letcsname pgfplots@#1min@unscaled@as@float={pgfplots@#1min}% \pgfplots@letcsname pgfplots@#1max@unscaled@as@float={pgfplots@#1max}% % initialise data scale transformation % T(x) = 10^{q-m} * x % \begingroup - \let\data@max@order=\c@pgf@counta - \let\data@cur@order=\c@pgf@countb - \let\data@dimen=\pgf@xa - \let\data@tmp=\pgf@xb - \let\data@dimen@order=\c@pgf@countc - \let\data@EXPONENT=\c@pgf@countd - \expandafter\let\expandafter\pgfplots@display@min@float\csname pgfplots@#1min\endcsname - \expandafter\let\expandafter\pgfplots@display@max@float\csname pgfplots@#1max\endcsname - \expandafter\let\expandafter\pgfplots@data@min@float\csname pgfplots@data@#1min\endcsname - \expandafter\let\expandafter\pgfplots@data@max@float\csname pgfplots@data@#1max\endcsname - \expandafter\let\expandafter\pgfplots@actual@trafo\csname pgfplots@datascaletrafo@#1\endcsname - \ifpgfplots@autocompute@all@limits - \else - \pgfplotsmathfloatmax{\pgfplots@display@max@float}{\pgfplots@data@max@float}% - \let\pgfplots@data@max@float=\pgfmathresult - \pgfplotsmathfloatmin{\pgfplots@display@min@float}{\pgfplots@data@min@float}% - \let\pgfplots@data@min@float=\pgfmathresult - \fi - % - % Step 1: compute 'm', the data order - \pgfplots@compute@number@order@for@trafo@isfloat - \pgfplots@data@min@float - \tocount\data@cur@order - % - \data@max@order=\data@cur@order - % - \pgfplots@compute@number@order@for@trafo@isfloat - \pgfplots@data@max@float - \tocount\data@cur@order - % - \ifnum\data@cur@order>\data@max@order + \let\data@max@order=\c@pgf@counta + \let\data@cur@order=\c@pgf@countb + \let\data@dimen=\pgf@xa + \let\data@tmp=\pgf@xb + \let\data@dimen@order=\c@pgf@countc + \let\data@EXPONENT=\c@pgf@countd + \expandafter\let\expandafter\pgfplots@display@min@float\csname pgfplots@#1min\endcsname + \expandafter\let\expandafter\pgfplots@display@max@float\csname pgfplots@#1max\endcsname + \expandafter\let\expandafter\pgfplots@data@min@float\csname pgfplots@data@#1min\endcsname + \expandafter\let\expandafter\pgfplots@data@max@float\csname pgfplots@data@#1max\endcsname + \expandafter\let\expandafter\pgfplots@actual@trafo\csname pgfplots@datascaletrafo@#1\endcsname + \ifpgfplots@autocompute@all@limits + \else + \pgfplotsmathfloatmax{\pgfplots@display@max@float}{\pgfplots@data@max@float}% + \let\pgfplots@data@max@float=\pgfmathresult + \pgfplotsmathfloatmin{\pgfplots@display@min@float}{\pgfplots@data@min@float}% + \let\pgfplots@data@min@float=\pgfmathresult + \fi + % + % Step 1: compute 'm', the data order + \pgfplots@compute@number@order@for@trafo@isfloat + \pgfplots@data@min@float + \tocount\data@cur@order + % \data@max@order=\data@cur@order - \fi - % - % Step 2: compute 'q', the #1-size of the axis. - \expandafter\ifx\csname pgfplots@#1\endcsname\pgfutil@empty - % We have 'width' or 'height'. % - % Use the order of these parameters. - \def\pgfplots@loc@TMPa{#1}% - \def\pgfplots@loc@TMPb{x}% - \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb - \data@dimen=\pgfplots@width\relax - \else - \def\pgfplots@loc@TMPb{y}% + \pgfplots@compute@number@order@for@trafo@isfloat + \pgfplots@data@max@float + \tocount\data@cur@order + % + \ifnum\data@cur@order>\data@max@order + \data@max@order=\data@cur@order + \fi + % + % Step 2: compute 'q', the #1-size of the axis. + \expandafter\ifx\csname pgfplots@#1\endcsname\pgfutil@empty + % We have 'width' or 'height'. + % + % Use the order of these parameters. + \def\pgfplots@loc@TMPa{#1}% + \def\pgfplots@loc@TMPb{x}% \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb - \data@dimen=\pgfplots@height\relax + \data@dimen=\pgfplots@width\relax + \else + \def\pgfplots@loc@TMPb{y}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \data@dimen=\pgfplots@height\relax + \fi \fi + \pgfplots@compute@number@order@for@trafo@isdimen + \data@dimen + \tocount\data@dimen@order + % This here is to avoid inaccuracies in the final + % axis rectangle size, see \pgfplots@initsizes: + %\advance\data@dimen@order by-1 + \else + % FIXME: + % we have either the 'x=1cm' or 'y=1cm' option! + % How should I initialise the trafo!? + \data@dimen@order=3 \fi - \pgfplots@compute@number@order@for@trafo@isdimen - \data@dimen - \tocount\data@dimen@order - % This here is to avoid inaccuracies in the final - % axis rectangle size, see \pgfplots@initsizes: - %\advance\data@dimen@order by-1 - \else - % FIXME: - % we have either the 'x=1cm' or 'y=1cm' option! - % How should I initialise the trafo!? - \data@dimen@order=3 - \fi - % - %\message{Direction #1: data max order=\the\data@max@order; data dimen order=\the\data@dimen@order. }% - \data@EXPONENT=\data@dimen@order - \advance\data@EXPONENT by-\data@max@order - % Now, I introduce a loop which shall avoid cancellation of - % significant digits. - % - % Harmless Example: - % if we have data shift = -3 and - % max = 2e6, min = 1e6, then max-min = 1e6; T(max)-T(min) = 1e3 which is ok. - % In this case, the loop won't change anything. - % - % Critical Example: - % if we have data shift = -3 and - % max = 1980, min = 1930 then - % T(max) = 1.98 and T(min) = 1.93 - % and thus T(max)-T(min) = 0.05 . - % Considering that this is the axis range - % in which tick labels and plot points need to be computed, we - % only have two or three digits left! That happens because the - % prefix '19' is common and is cancelled in the subtraction. - % Idea: while T(max)-T(min) < O(10^2) -> increase shift by +1 - % (and make sure that T(max) < MAX_VALID_TEX_NUMBER). - % - \pgfplots@loop@CONTINUEtrue - \expandafter\edef\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname{0}% - \pgfutil@loop - \expandafter\edef\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname{\the\data@EXPONENT}% - \pgfplots@actual@trafo{\pgfplots@data@min@float}% - \let\pgfplots@min@fixed=\pgfmathresult - \ifpgfplots@loop@CONTINUE - \pgfplots@actual@trafo{\pgfplots@data@max@float}% - \let\pgfplots@max@fixed=\pgfmathresult - \expandafter\data@tmp\pgfplots@max@fixed pt - %\message{Current trafo EXPONENT for #1 direction: \the\data@EXPONENT; original #1 data limits: [\pgfplots@data@min@float:\pgfplots@data@max@float]; current transformed #1 limits: [\pgfplots@min@fixed:\pgfplots@max@fixed]; cancellation check max-min running...}% - \ifdim\data@tmp<0pt - % I need absolute values here: - \multiply\data@tmp by-1\relax - \fi - \pgfmathsubtract@{\pgfplots@max@fixed}{\pgfplots@min@fixed}% - \expandafter\data@dimen\pgfmathresult pt - \pgfplots@loop@CONTINUEfalse - \ifdim\data@tmp<1500pt % a multiplication with '10' results in max = 15000 which is the upper limit. - \ifdim\data@dimen<100pt % I guess if max-min = O(100), we have quite good accuracy - \ifdim\data@dimen<0.0001pt - \else - \advance\data@EXPONENT by1 - \pgfplots@loop@CONTINUEtrue + % +%\message{Direction #1: data max order=\the\data@max@order; data dimen order=\the\data@dimen@order. }% + \data@EXPONENT=\data@dimen@order + \advance\data@EXPONENT by-\data@max@order + % Now, I introduce a loop which shall avoid cancellation of + % significant digits. + % + % Harmless Example: + % if we have data shift = -3 and + % max = 2e6, min = 1e6, then max-min = 1e6; T(max)-T(min) = 1e3 which is ok. + % In this case, the loop won't change anything. + % + % Critical Example: + % if we have data shift = -3 and + % max = 1980, min = 1930 then + % T(max) = 1.98 and T(min) = 1.93 + % and thus T(max)-T(min) = 0.05 . + % Considering that this is the axis range + % in which tick labels and plot points need to be computed, we + % only have two or three digits left! That happens because the + % prefix '19' is common and is cancelled in the subtraction. + % Idea: while T(max)-T(min) < O(10^2) -> increase shift by +1 + % (and make sure that T(max) < MAX_VALID_TEX_NUMBER). + % + \pgfplots@loop@CONTINUEtrue + \expandafter\edef\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname{0}% + \pgfutil@loop + \expandafter\edef\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname{\the\data@EXPONENT}% + \pgfplots@actual@trafo{\pgfplots@data@min@float}% + \let\pgfplots@min@fixed=\pgfmathresult + \ifpgfplots@loop@CONTINUE + \pgfplots@actual@trafo{\pgfplots@data@max@float}% + \let\pgfplots@max@fixed=\pgfmathresult + \expandafter\data@tmp\pgfplots@max@fixed pt +%\message{Current trafo EXPONENT for #1 direction: \the\data@EXPONENT; original #1 data limits: [\pgfplots@data@min@float:\pgfplots@data@max@float]; current transformed #1 limits: [\pgfplots@min@fixed:\pgfplots@max@fixed]; cancellation check max-min running...}% + \ifdim\data@tmp<0pt + % I need absolute values here: + \multiply\data@tmp by-1\relax + \fi + \pgfmathsubtract@{\pgfplots@max@fixed}{\pgfplots@min@fixed}% + \expandafter\data@dimen\pgfmathresult pt + \pgfplots@loop@CONTINUEfalse + \ifdim\data@tmp<1500pt % a multiplication with '10' results in max = 15000 which is the upper limit. + \ifdim\data@dimen<100pt % I guess if max-min = O(100), we have quite good accuracy + \ifdim\data@dimen<0.0001pt + \else + \advance\data@EXPONENT by1 + \pgfplots@loop@CONTINUEtrue + \fi \fi \fi - \fi - %-------------------------------------------------- - % \ifdim\data@dimen>1200pt% FIXME : is this here ok!? CHECK IT! - % \ifdim\data@dimen>7999pt - % \advance\data@EXPONENT by-2 - % \else - % \advance\data@EXPONENT by-1 - % \fi - % \pgfplots@loop@CONTINUEfalse - % \fi - %-------------------------------------------------- - \pgfutil@repeat - \xdef\pgfplots@glob@TMPa{\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname}% - \xdef\pgfplots@glob@TMPb{\pgfplots@min@fixed}% + %-------------------------------------------------- + % \ifdim\data@dimen>1200pt% FIXME : is this here ok!? CHECK IT! + % \ifdim\data@dimen>7999pt + % \advance\data@EXPONENT by-2 + % \else + % \advance\data@EXPONENT by-1 + % \fi + % \pgfplots@loop@CONTINUEfalse + % \fi + %-------------------------------------------------- + \pgfutil@repeat + \xdef\pgfplots@glob@TMPa{\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname}% + \xdef\pgfplots@glob@TMPb{\pgfplots@min@fixed}% \endgroup - %\message{Initialising the data scale transformation in direction #1 to 10^\pgfplots@glob@TMPa*#1 - \pgfplots@glob@TMPb...}% +%\message{Initialising the data scale transformation in direction #1 to 10^\pgfplots@glob@TMPa*#1 - \pgfplots@glob@TMPb...}% % COMPLETE INITIALISATION: \ifpgfplots@disabledatascaling % this here is a waste of time, I know it. One could really @@ -2849,15 +3831,15 @@ % ... and apply transformation to any user input % % Transform axis limits: - %\message{#1- display limits BEFORE data transformation: [\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname]}% +%\message{#1- display limits BEFORE data transformation: [\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname]}% \expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1min\endcsname}% \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult % \expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1max\endcsname}% \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult - %\message{#1- display limits after data transformation: [\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname]}% +%\message{#1- display limits after data transformation: [\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname]}% % Transform tick limits (if they are set): - %\message{#1- display tick limits BEFORE data transformation: [\csname pgfplots@#1tickmin\endcsname:\csname pgfplots@#1tickmax\endcsname]}% +%\message{#1- display tick limits BEFORE data transformation: [\csname pgfplots@#1tickmin\endcsname:\csname pgfplots@#1tickmax\endcsname]}% \expandafter\ifx\csname pgfplots@#1tickmin\endcsname\pgfutil@empty \else \expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1tickmin\endcsname}% @@ -2869,7 +3851,7 @@ \expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1tickmax\endcsname}% \expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult \fi - %\message{#1- display tick limits after data transformation: [\csname pgfplots@#1tickmin\endcsname:\csname pgfplots@#1tickmax\endcsname]}% +%\message{#1- display tick limits after data transformation: [\csname pgfplots@#1tickmin\endcsname:\csname pgfplots@#1tickmax\endcsname]}% % % Convert any user-specified ticks: \edef\pgfplots@loc@TMPa{\csname pgfplots@#1tick\endcsname}% @@ -2884,14 +3866,15 @@ % Since we have entered this method, we know that these % coordinate ARE ALREADY in floating point representation. \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@firstplot@coords@#1\endcsname - \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}% + \expandafter\pgfplotsutil@unify@short@csv@list\expandafter{\pgfplots@loc@TMPa}% + \t@pgfplots@toka=\expandafter{\pgfplotsretval}% \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}\the\t@pgfplots@tokc}% \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks@isfloat\pgfplots@loc@TMPa\to\pgfplots@loc@TMPc % clear structure: \expandafter\global\expandafter\let\csname pgfplots@firstplot@coords@#1\endcsname=\pgfutil@empty \else \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}% - %\message{Converting #1tick='\csname pgfplots@#1tick\endcsname'}% +%\message{Converting #1tick='\csname pgfplots@#1tick\endcsname'}% \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}\the\t@pgfplots@tokc}% \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\pgfplots@loc@TMPa\to\pgfplots@loc@TMPc \fi @@ -2910,17 +3893,20 @@ % % Transform any explicit axis unit scalings: % WILL BE DONE LATER! - \else + }{% + % case apply trafo == false: \expandafter\def\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname{0}% \def\pgfplots@loc@TMPb{data}% \expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfplots@loc@TMPb - \pgfplots@letcsname pgfplots@#1tick={pgfplots@firstplot@coords@#1}% + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@firstplot@coords@#1\endcsname + \expandafter\pgfplotsutil@unify@short@csv@list\expandafter{\pgfplots@loc@TMPa}% + \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplotsretval% % clear structure: \expandafter\global\expandafter\let\csname pgfplots@firstplot@coords@#1\endcsname=\pgfutil@empty \fi \expandafter\let\csname pgfplots@#1min@unscaled@as@float\endcsname=\pgfutil@empty \expandafter\let\csname pgfplots@#1max@unscaled@as@float\endcsname=\pgfutil@empty - \fi + }% } \newif\ifpgfplots@determinedefaultvalues@isuniform @@ -2929,7 +3915,7 @@ \def\pgfplots@handle@invalid@range{% % COMPLETELY EMPTY AXIS: - \pgfplots@warning{You have a plot with empty range. Replacing it with default and clearing plots.}% + \pgfplots@warning{You have an axis with empty range. Replacing it with a default range and clearing all plots.}% \ifpgfplots@xislinear \pgfmathfloatcreate{0}{0.0}{0}% \global\let\pgfplots@xmin=\pgfmathresult @@ -2941,8 +3927,6 @@ \gdef\pgfplots@xmin{0}% \gdef\pgfplots@xmax{1}% \fi - % unnecessary? they will be reset anyway because empty plots are - % recognised before any other axis limit routine \ifpgfplots@yislinear \pgfmathfloatcreate{0}{0.0}{0}% \global\let\pgfplots@ymin=\pgfmathresult @@ -3079,6 +4063,11 @@ % \pgfplots@set@default@size@options % + \ifpgfplots@threedim + \pgfplotsthreedimtrue + \else + \pgfplotsthreedimfalse + \fi % \pgfplots@check@and@apply@datatrafo@for x% \pgfplots@check@and@apply@datatrafo@for y% @@ -3124,13 +4113,18 @@ \pgfplots@zminortickstrue \fi \fi - \pgfplots@enlarge@limit@ifconfigured y - \pgfplots@avoid@empty@axis@range@for y% + \pgfplots@enlarge@limit@ifconfigured z + \pgfplots@avoid@empty@axis@range@for z% \fi % % \pgfplots@initsizes % + % + \pgfplots@BEGIN@prepare@description@styles + % + % + % \pgfplots@isuniformticktrue \pgfplots@determinedefaultvalues@needs@check@uniformticktrue \ifx\pgfplots@xtick\pgfutil@empty @@ -3149,26 +4143,33 @@ \pgfplots@xminorgridsfalse \fi % - \ifx\pgfplots@xticklabelaxisspec\pgfutil@empty - \ifnum\pgfplots@xtickposnum=3 % right - \def\pgfplots@xticklabelaxisspec{v10}% - \else - \def\pgfplots@xticklabelaxisspec{v00}% - \fi + % + \ifx\pgfplots@xticklabel@pos\pgfutil@empty + \def\pgfplots@xticklabel@pos{% + \if3\pgfplots@xtickposnum% right + u% + \else + l% + \fi + }% \fi - \ifx\pgfplots@yticklabelaxisspec\pgfutil@empty - \ifnum\pgfplots@ytickposnum=3 % right - \def\pgfplots@yticklabelaxisspec{1v0}% - \else - \def\pgfplots@yticklabelaxisspec{0v0}% - \fi + \ifx\pgfplots@yticklabel@pos\pgfutil@empty + \def\pgfplots@yticklabel@pos{% + \if3\pgfplots@ytickposnum% right + u% + \else + l% + \fi + }% \fi - \ifx\pgfplots@zticklabelaxisspec\pgfutil@empty - \ifnum\pgfplots@ztickposnum=3 % right - \def\pgfplots@zticklabelaxisspec{01v}% - \else - \def\pgfplots@zticklabelaxisspec{00v}% - \fi + \ifx\pgfplots@zticklabel@pos\pgfutil@empty + \def\pgfplots@zticklabel@pos{% + \if3\pgfplots@ztickposnum% right + u% + \else + l% + \fi + }% \fi % \ifx\pgfplots@xticklabel\pgfutil@empty @@ -3246,8 +4247,51 @@ % % \pgfplots@prepare@ZERO@coordinates + % + \pgfplotspoint@initialisation + % + \pgfplots@decide@which@figure@surfaces@are@drawn + % + \pgfplots@define@threedim@marks + % + \pgfplots@clippath@prepare + % + \pgfplots@ticklabel@maxtickdimen@reset x% + \pgfplots@ticklabel@maxtickdimen@reset y% + \pgfplots@ticklabel@maxtickdimen@reset z% } +% Defines \pgfmathresult to be the desired width without axis labels. +% +\def\pgfplots@initsizes@get@width@withoutlabels{% + \pgfplots@initsizes@handle@label@const{\pgfplots@width}{45pt}{width}% +} + +% Defines \pgfmathresult to be the desired height without axis labels. +\def\pgfplots@initsizes@get@height@withoutlabels{% + \pgfplots@initsizes@handle@label@const{\pgfplots@height}{45pt}{height}% +} +\def\pgfplots@initsizes@handle@label@const#1#2#3{% + \begingroup + \pgf@xa=#1\relax + % EXPECTED WIDTH = X = \pgfplots@width + % ACTUAL WIDTH = c + x * (xmax-xmin) + % where c is a CONSTANT (for the axis labels/tick labels). + % -> \pgfplots@tmpXscale = (X - c) / (x *(xmax-xmin)) + % + % \pgf@xa := X-c: + \ifpgfplots@scale@only@axis + \else + \advance\pgf@xa by-#2 % FIXME determine 'c' correctly! + \fi + \ifdim\pgf@xa<0pt + \pgfplots@error{Error: Plot #3 `#1' is too small. This can't be realised while maintaining constant size for labels. Sorry, label sizes are only approximate. You will need to adjust your #3.}% + \pgf@xa=0pt + \fi + \edef\pgfmathresult{\the\pgf@xa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% % Helper method for initsizes. % @@ -3263,22 +4307,15 @@ % #2: the output argument for the SCALE. \def\pgfplots@initsizes@getXscale#1\into#2{% \begingroup - \pgf@xa=\pgfplots@width\relax + \pgfplots@initsizes@get@width@withoutlabels % EXPECTED WIDTH = X = \pgfplots@width % ACTUAL WIDTH = c + x * (xmax-xmin) % where c is a CONSTANT (for the axis labels/tick labels). % -> \pgfplots@tmpXscale = (X - c) / (x *(xmax-xmin)) % % \pgf@xa := X-c: - \ifpgfplots@scale@only@axis - \else - \advance\pgf@xa by-45pt% FIXME determine 'c' correctly! - \fi - \ifdim\pgf@xa<0pt - \pgfplots@error{Error: Plot width `\pgfplots@width' is too small. This can't be realised while maintaining constant width for y-labels. Sorry, label width are only approximate. You will need to adjust your width.}% - \pgf@xa=0pt - \fi % \pgf@xb := x*(xmax-xmin): + \pgf@xa=\pgfmathresult\relax \pgf@xb=#1\relax \pgfmathlog@invoke@expanded\pgfmathdivide@{% {\pgf@sys@tonumber\pgf@xa}% @@ -3297,22 +4334,9 @@ % The same as \pgfplots@initsizes@getXscale, just for the height. \def\pgfplots@initsizes@getYscale#1\into#2{% \begingroup - \pgf@xa=\pgfplots@height\relax - % EXPECTED WIDTH = X = \pgfplots@width - % ACTUAL WIDTH = c + x * (xmax-xmin) - % where c is a CONSTANT (for the axis labels/tick labels). - % -> \pgfplots@tmpXscale = (X - c) / (x *(xmax-xmin)) - % - % \pgf@xa := X-c: - \ifpgfplots@scale@only@axis - \else - \advance\pgf@xa by-45pt\relax% FIXME determine 'c' correctly! - \fi - \ifdim\pgf@xa<0pt - \pgfplots@error{Error: Plot height `\pgfplots@height' is too small. This can't be realised while maintaining constant height for x-labels. Sorry, label heights are only approximate. You will need to adjust your height.}% - \pgf@xa=0pt - \fi + \pgfplots@initsizes@get@height@withoutlabels % \pgf@xb := y*(ymax-ymin): + \pgf@xa=\pgfmathresult\relax \pgf@xb=#1% \pgfmathlog@invoke@expanded\pgfmathdivide@{% {\pgf@sys@tonumber\pgf@xa}% @@ -3364,7 +4388,7 @@ \fi \fi \ifpgfplots@avoid@emptyrange@@range@is@approx@equal - \pgfplots@warning{Axis range for axis #1 is approximately equal; enlargeing it.}% + \pgfplots@warning{Axis range for axis #1 is approximately empty; enlargeing it.}% % the case \pgfplots@@min ~= \pgfplots@@max % % enlarge \pgfplots@@max and shrink \min: @@ -3477,6 +4501,18 @@ \pgfkeysgetvalue{/pgfplots/x}{\pgfplots@x}% \pgfkeysgetvalue{/pgfplots/y}{\pgfplots@y}% \pgfkeysgetvalue{/pgfplots/z}{\pgfplots@z}% + \pgfkeysgetvalue{/pgfplots/width}{\pgfplots@width}% + \pgfkeysgetvalue{/pgfplots/height}{\pgfplots@height}% + \ifx\pgfplots@width\pgfutil@empty + \else + \pgfmathparse{\pgfplots@width}% + \edef\pgfplots@width{\pgfmathresult pt}% + \fi + \ifx\pgfplots@height\pgfutil@empty + \else + \pgfmathparse{\pgfplots@height}% + \edef\pgfplots@height{\pgfmathresult pt}% + \fi % % CASES: % hasx := 'x' option non-empty @@ -3546,6 +4582,8 @@ \fi \fi \fi + \pgfkeyslet{/pgfplots/width}{\pgfplots@width}% + \pgfkeyslet{/pgfplots/height}{\pgfplots@height}% } % A helper method for \pgfplots@initsizes which @@ -3561,16 +4599,19 @@ % '1' if and only if the finally set vector is parallel to the #1 axis % of PGF, that means (x,0) for #1=x and (0,y) for #2=y. \def\pgfplots@initsizes@setunitvector#1#2#3#4{% + \pgfkeysgetvalue{/pgfplots/#1 dir/value}\pgfplots@loc@dirvalue \expandafter\let\expandafter\pgfplots@loc@TMPb\csname pgfplots@#1\endcsname - \expandafter\let\expandafter\if@cur@is@scaled\csname ifpgfplots@apply@datatrafo@#1\endcsname \ifx\pgfplots@loc@TMPb\pgfutil@empty \def#4{1}% we have (#1,0) or (0,#1) % %\message{Setting unitvector(#1) to auto-computed multiple of e_#2 ...}% \edef\pgfplots@loc@TMPa{#3}% + \if r\pgfplots@loc@dirvalue + \edef\pgfplots@loc@TMPa{-#3}% + \fi \begingroup - \pgf@xa=#3\relax - \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}% + \pgf@xa=#3\relax + \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}% \endgroup % FIXME : '\pgfplots@loc@TMPa' contains 'pt' leading to missing % character warning! @@ -3582,19 +4623,32 @@ \pgfmathabs@{\pgfplots@glob@TMPb}% \or \pgfsetzvec{\pgfqpoint{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPa}}% - \pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}% + \ifdim\pgfplots@loc@TMPa=0pt + \def\pgfmathresult{0}% + \else + \pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}% + \fi \fi % The numbers 1/||e_x|| and 1/||e_y|| are used by the tick % placement code to convert between logical and physical - % coordinates. FIXME is that accurate enough!? + % coordinates. \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% - \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + }% \else % Ok, we have a user-defined unit vector. % % That means we also need to apply the scaling trafo! % + \if r\pgfplots@loc@dirvalue + \def\pgfplots@loc@dirvalue{-}% + \else + \def\pgfplots@loc@dirvalue{}% + \fi % % 1. Check whether we have a complete vector of type (x,y): \expandafter\pgfutil@in@\expandafter(\expandafter{\pgfplots@loc@TMPb}% @@ -3604,38 +4658,49 @@ \def#4{0}% we DON'T have (#1,0) or (0,#1). At least I think so. % %\message{Setting unitvector(#1) to non-standard \csname pgfplots@#1\endcsname ...}% + % FIXME : that's wrong for 3D axes! \def\pgfplots@loc@TMPa(##1,##2){% \pgfmathparse{##1}% - \ifpgfplots@apply@datatrafo@x - \expandafter\pgfplots@inverse@datascaletrafo@tofixed@x@noshift\expandafter{\pgfmathresult}% - \fi \let\pgfplots@loc@TMPb=\pgfmathresult - % \pgfmathparse{##2}% - \ifpgfplots@apply@datatrafo@y - \expandafter\pgfplots@inverse@datascaletrafo@tofixed@y@noshift\expandafter{\pgfmathresult}% - \fi \let\pgfplots@loc@TMPc=\pgfmathresult - \csname pgfset#1vec\endcsname{\pgfqpoint{\pgfplots@loc@TMPb pt}{\pgfplots@loc@TMPc pt}}% + % + \pgfplots@if{pgfplots@apply@datatrafo@#1}{% + \csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname{\pgfplots@loc@TMPb}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname{\pgfplots@loc@TMPc}% + \let\pgfplots@loc@TMPc=\pgfmathresult + }{}% + \csname pgfset#1vec\endcsname{% + \pgfqpoint + {\pgfplots@loc@dirvalue\pgfplots@loc@TMPb pt} + {\pgfplots@loc@dirvalue\pgfplots@loc@TMPc pt}}% }% \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb% % \pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}% \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% - \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + }% \else % NO we simply have a scalar value. \def#4{1}% we have (#1,0) or (0,#1) %\message{Setting unitvector(#1) to \csname pgfplots@#1\endcsname * e_{#2}...}% - \if@cur@is@scaled + \pgfplots@if{pgfplots@apply@datatrafo@#1}{% \pgfmathparse{\csname pgfplots@#1\endcsname}% \expandafter\expandafter\csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname\expandafter{\pgfmathresult}% \edef\pgfplots@loc@TMPb{\pgfmathresult pt}% - \fi + }{\relax}% \begingroup - \pgf@xa=\pgfplots@loc@TMPb\relax - \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}% + \pgf@xa=\pgfplots@loc@TMPb\relax + \if r\pgfplots@loc@dirvalue + \multiply\pgf@xa by-1 + \fi + \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}% \endgroup \ifcase#2\relax \pgfsetxvec{\pgfqpoint{\pgfplots@loc@TMPb}{0pt}}% @@ -3645,13 +4710,22 @@ \pgfmathabs@{\pgfplots@glob@TMPb}% \or \pgfsetzvec{\pgfqpoint{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPb}}% - \pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}% + \ifdim\pgfplots@loc@TMPb=0pt + \def\pgfmathresult{0}% + \else + \pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}% + \fi \fi \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% - \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + \pgfplotsmath@ifzero{\pgfmathresult}{% + \expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}% + }{% + \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + }% \fi \fi +%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).}% }% % Applies the 'axis equal' feature. @@ -3731,7 +4805,7 @@ \global\let\pgfplots@glob@TMPb=\pgfmathresult % % If the datascaling transformation is active (which is almost - % every the case here), we need to respect it here. + % everytime the case here), we need to respect it here. % % We only need to respect the SCALING, translations (shifts) are % not interesting. @@ -3866,8 +4940,16 @@ % - final axis limits are given in transformed range % - \pgfplots@set@default@size@options has been invoked before % POSTCONDITION: -% - the current x- and y unit vectors are changed; -% - \pgfplots@[xy]coord{min,max}TEX are set +% - the current x,y and z unit vectors are defined properly; +% - the fast-access registers are initialised for the axis limits, +% - the following macros are assigned: +% \pgfplots@[xyz]@veclength +% \pgfplots@[xyz]@inverseveclength +% \pgfplotspointxaxis +% \pgfplotspointyaxis +% \pgfplotspointzaxis +% \pgfplotspointcenter +% \pgfplotspointminminmin % \def\pgfplots@initsizes{% % INIT. @@ -3930,18 +5012,39 @@ \pgfplotsqpointxy{\pgfplots@tmpXscale}{\pgfplots@tmpYscale}% \edef\pgfplots@tmpXscale{\the\pgf@x}% \edef\pgfplots@tmpYscale{\the\pgf@y}% - \def\pgfplots@tmpZscale{1pt}% - \ifx\pgfplots@view@pitch\pgfutil@empty + \pgfkeysgetvalue{/pgfplots/view/az}{\pgfplots@view@az}% + \pgfkeysgetvalue{/pgfplots/view/el}{\pgfplots@view@el}% + \ifpgfplots@threedim + \def\pgfplots@tmpZscale{1pt}% + \else + \def\pgfplots@tmpZscale{0pt}% + % FIXME + \let\pgfplots@view@el=\pgfutil@empty + \let\pgfplots@view@az=\pgfutil@empty + \def\pgfplots@view@dir@threedim@x{0}% + \def\pgfplots@view@dir@threedim@y{0}% + \def\pgfplots@view@dir@threedim@z{1}% + \fi + \ifx\pgfplots@view@az\pgfutil@empty + % FIXME : this does NOT work! it doesn't prepare the view@dir@threedim properly! \pgfplots@initsizes@setunitvector{x}{0}{\pgfplots@tmpXscale}{\pgfplots@tmp@xisaxisparallel}% \pgfplots@initsizes@setunitvector{y}{1}{\pgfplots@tmpYscale}{\pgfplots@tmp@yisaxisparallel}% \pgfplots@initsizes@setunitvector{z}{2}{\pgfplots@tmpZscale}{\pgfplots@loc@TMPc}% \else - \pgfplotssetaxesfrompitchyaw{\pgfplots@view@pitch}{\pgfplots@view@yaw}{\pgfplots@tmp@xisaxisparallel}% + \pgfplotssetaxesfromazel{\pgfplots@view@az}{\pgfplots@view@el}{\pgfplots@tmp@xisaxisparallel}% \if1\pgfplots@tmp@xisaxisparallel% \def\pgfplots@tmp@yisaxisparallel{1}% \fi \fi +%\message{Pgfplots debug: initialised unit vectors to x=(\the\pgf@xx,\the\pgf@xy), y=(\the\pgf@yx,\the\pgf@yy), z=(\the\pgf@zx,\the\pgf@zy). }% + % + \let\pgfplotsmathfloatviewdepthxyz@=\pgfplotsmathfloatviewdepthxyz@infigure + \let\pgfplotsmathviewdepthxyz@=\pgfplotsmathviewdepthxyz@infigure + % + \pgfplotsmath@ifzero{\pgfplots@x@veclength}{\pgfplots@hide@xtrue\pgfplots@shownothingof@xtrue}{}% + \pgfplotsmath@ifzero{\pgfplots@y@veclength}{\pgfplots@hide@ytrue\pgfplots@shownothingof@ytrue}{}% \ifpgfplots@threedim + \pgfplotsmath@ifzero{\pgfplots@z@veclength}{\pgfplots@hide@ztrue\pgfplots@shownothingof@ztrue}{}% \else \if1\pgfplots@tmp@xisaxisparallel% \if1\pgfplots@tmp@yisaxisparallel% @@ -3979,8 +5082,16 @@ % accurate. % \begingroup - \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}% - \xdef\pgfplotspointsouthwest{\noexpand\pgf@x=\the\pgf@x\noexpand\relax\noexpand\pgf@y=\the\pgf@y}% + \ifpgfplots@threedim + \def\pgfplotspointmaxminmin{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}% + \def\pgfplotspointminmaxmin{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}% + \else + \def\pgfplotspointmaxminmin{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}% + \def\pgfplotspointminmaxmin{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}% + \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}% + \fi + \xdef\pgfplotspointminminmin{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% % ATTENTION: I re-use registers here! Make sure they won't be % overwritten! \pgfpointdiff and \pgfplotsqpointxy are ok in this respect. \let\pgfplots@xcoordminTEX=\pgf@xb @@ -3988,48 +5099,77 @@ \pgfplots@xcoordminTEX=\pgf@x \pgfplots@ycoordminTEX=\pgf@y % - \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}% - \ifx\pgfplots@rectangle@width\pgfutil@empty - \def\pgfplots@tmp@xmax@ymin{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}% - \else - % this 'if' here should only make a difference of about - % 1-2pt, not more. - % - % and I am quite sure that this inaccuracy (and this - % work-around) only affects the - % final size, not the relative plot accuracy. - \pgf@x=\pgfplots@xcoordminTEX - \advance\pgf@x by\pgfplots@width - \edef\pgfplots@tmp@xmax@ymin{\noexpand\pgfqpoint{\the\pgf@x}{\noexpand\pgfplots@ycoordminTEX}}% - \fi - \ifx\pgfplots@rectangle@height\pgfutil@empty - \def\pgfplots@tmp@xmin@ymax{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}% - \else - \pgf@x=\pgfplots@ycoordminTEX - \advance\pgf@x\pgfplots@height - \edef\pgfplots@tmp@xmin@ymax{\noexpand\pgfqpoint{\noexpand\pgfplots@xcoordminTEX}{\the\pgf@x}}% - \fi + %-------------------------------------------------- + % FIXME : WHAT IS THIS HERE FOR? + % \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}% + % \ifx\pgfplots@rectangle@width\pgfutil@empty + % \def\pgfplots@tmp@xmax@ymin{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}% + % \else + % % this 'if' here should only make a difference of about + % % 1-2pt, not more. + % % + % % and I am quite sure that this inaccuracy (and this + % % work-around) only affects the + % % final size, not the relative plot accuracy. + % \pgf@x=\pgfplots@xcoordminTEX + % \advance\pgf@x by\pgfplots@width + % \edef\pgfplots@tmp@xmax@ymin{\noexpand\pgfqpoint{\the\pgf@x}{\noexpand\pgfplots@ycoordminTEX}}% + % \fi + % \ifx\pgfplots@rectangle@height\pgfutil@empty + % \def\pgfplots@tmp@xmin@ymax{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}% + % \else + % \pgf@x=\pgfplots@ycoordminTEX + % \advance\pgf@x\pgfplots@height + % \edef\pgfplots@tmp@xmin@ymax{\noexpand\pgfqpoint{\noexpand\pgfplots@xcoordminTEX}{\the\pgf@x}}% + % \fi + %-------------------------------------------------- \pgfpointdiff {\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@ycoordminTEX}} - {\pgfplots@tmp@xmax@ymin}% - \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\noexpand\pgf@y=\the\pgf@y}% + {\pgfplotspointmaxminmin}% + \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% \pgfmathveclen{\pgf@x}{\pgf@y}% \xdef\pgfplotspointxaxislength{\pgfmathresult pt}% % \pgfpointdiff {\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@ycoordminTEX}} - {\pgfplots@tmp@xmin@ymax}% - \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\noexpand\pgf@y=\the\pgf@y}% + {\pgfplotspointminmaxmin}% + \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% \pgfmathveclen{\pgf@x}{\pgf@y}% \xdef\pgfplotspointyaxislength{\pgfmathresult pt}% % \ifpgfplots@threedim \pgfpointdiff {\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@ycoordminTEX}} - {\pgfplotsqpointxy{\pgfplots@zmin}{\pgfplots@zmax}}% - \xdef\pgfplotspointzaxis{\noexpand\pgf@x=\the\pgf@x\noexpand\pgf@y=\the\pgf@y}% + {\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}% + \xdef\pgfplotspointzaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% \pgfmathveclen{\pgf@x}{\pgf@y}% \xdef\pgfplotspointzaxislength{\pgfmathresult pt}% + % + \pgfpointscale + {0.5}% + {\pgfplotspointxaxis + \pgf@xa=\pgf@x + \pgf@xb=\pgf@y + \pgfplotspointyaxis% + \advance\pgf@xa by\pgf@x + \advance\pgf@xb by\pgf@y + \pgfplotspointzaxis% + \advance\pgf@xa by\pgf@x + \advance\pgf@xb by\pgf@y + \pgf@x=\pgf@xa + \pgf@y=\pgf@xb + }% + \xdef\pgfplotspointcenter{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% + \else + \global\let\pgfplotspointzaxis=\pgfpointorigin + \gdef\pgfplotspointzaxislength{0pt}% + \pgfpointscale + {0.5}% + {\pgfpointadd + \pgfplotspointxaxis% + \pgfplotspointyaxis% + }% + \xdef\pgfplotspointcenter{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% \fi \endgroup } @@ -4040,50 +5180,47 @@ % See pgfplots@low@level@shape below. \pgfdeclareshape{pgfplots@low@level@shape@INNER}{% \nodeparts{image}% - \anchor{image}{% - \pgf@x=0pt - \pgf@y=0pt - }% - % - % - \anchor{center}{\pgfqpointxy{0.5}{0.5}}% - \anchor{north}{\pgfqpointxy{0.5}{1}}% - \anchor{north east}{\pgfqpointxy{1}{1}}% - \anchor{east}{\pgfqpointxy{1}{0.5}} - \anchor{south east}{\pgfqpointxy{1}{0}}% - \anchor{south}{\pgfqpointxy{0.5}{0}}% - \anchor{south west}{\pgfqpointxy{0}{0}}% - \anchor{west}{\pgfqpointxy{0}{0.5}}% - \anchor{north west}{\pgfqpointxy{0}{1}}% + \anchor{image}{\pgfpointorigin}% + % + % + \anchor{center}{\pgfplotsqpointdescriptionxy{0.5}{0.5}}% + \anchor{north}{\pgfplotsqpointdescriptionxy{0.5}{1}}% + \anchor{north east}{\pgfplotsqpointdescriptionxy{1}{1}}% + \anchor{east}{\pgfplotsqpointdescriptionxy{1}{0.5}} + \anchor{south east}{\pgfplotsqpointdescriptionxy{1}{0}}% + \anchor{south}{\pgfplotsqpointdescriptionxy{0.5}{0}}% + \anchor{south west}{\pgfplotsqpointdescriptionxy{0}{0}}% + \anchor{west}{\pgfplotsqpointdescriptionxy{0}{0.5}}% + \anchor{north west}{\pgfplotsqpointdescriptionxy{0}{1}}% %% - \anchor{origin}{\pgfplotspointORIGIN@tmp}% + \anchor{origin}{\pgfplotspointaxisorigin}% \anchor{above origin}{% \pgfpointintersectionoflines - {\pgfplotspointORIGIN@tmp} - {\pgfpointadd{\pgfplotspointORIGIN@tmp}{\pgfplotspointyaxis}} - {\pgfpointadd{\pgfqpointxy{0}{0}}{\pgfplotspointyaxis}} - {\pgfpointadd{\pgfpointadd{\pgfqpointxy{0}{0}}{\pgfplotspointyaxis}}{\pgfplotspointxaxis}}% + {\pgfplotspointaxisorigin} + {\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointyaxis}} + {\pgfplotsqpointdescriptionxy{0}{1}} + {\pgfplotsqpointdescriptionxy{1}{1}}% }% \anchor{left of origin}{% \pgfpointintersectionoflines - {\pgfplotspointORIGIN@tmp} - {\pgfpointadd{\pgfplotspointORIGIN@tmp}{\pgfpointscale{-1}{\pgfplotspointxaxis}}} - {\pgfqpointxy{0}{0}} - {\pgfpointadd{\pgfqpointxy{0}{0}}{\pgfplotspointyaxis}}% + {\pgfplotspointaxisorigin} + {\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointxaxis}} + {\pgfplotsqpointdescriptionxy{0}{0}} + {\pgfplotsqpointdescriptionxy{0}{1}}% }% \anchor{right of origin}{% \pgfpointintersectionoflines - {\pgfplotspointORIGIN@tmp} - {\pgfpointadd{\pgfplotspointORIGIN@tmp}{\pgfplotspointxaxis}} - {\pgfpointadd{\pgfqpointxy{0}{0}}{\pgfplotspointxaxis}} - {\pgfpointadd{\pgfpointadd{\pgfqpointxy{0}{0}}{\pgfplotspointxaxis}}{\pgfplotspointyaxis}}% + {\pgfplotspointaxisorigin} + {\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointxaxis}} + {\pgfplotsqpointdescriptionxy{1}{0}} + {\pgfplotsqpointdescriptionxy{1}{1}}% }% \anchor{below origin}{% \pgfpointintersectionoflines - {\pgfplotspointORIGIN@tmp} - {\pgfpointadd{\pgfplotspointORIGIN@tmp}{\pgfpointscale{-1}{\pgfplotspointyaxis}}} - {\pgfqpointxy{0}{0}} - {\pgfpointadd{\pgfqpointxy{0}{0}}{\pgfplotspointxaxis}}% + {\pgfplotspointaxisorigin} + {\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointyaxis}} + {\pgfplotsqpointdescriptionxy{0}{0}} + {\pgfplotsqpointdescriptionxy{1}{0}}% }% %% %% @@ -4111,10 +5248,9 @@ \savedanchor\lowerleftinnercorner{% \pgfqpoint{\pgfplots@savedanchor@inner@lowerleft@x\relax}{\pgfplots@savedanchor@inner@lowerleft@y\relax}% }% - \savedanchor\xaxisvec{\pgfplotspointxaxis}% - \savedanchor\yaxisvec{\pgfplotspointyaxis}% + \savedanchor\innerdiagonal{\pgfplotspointbbdiagonal}% \savedanchor\origin{% - \pgfqpoint{\pgfplots@ZERO@x\relax}{\pgfplots@ZERO@y\relax}% + \pgfplotspointaxisorigin }% % \nodeparts{image}% @@ -4127,43 +5263,45 @@ \anchor{center}{% \pgfpointadd {\lowerleftinnercorner}% - {\pgfpointscale{0.5}{\pgfpointadd{\xaxisvec}{\yaxisvec}}}% + {\pgfpointscale + {0.5} + {\innerdiagonal}}% }% \anchor{north}{% \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointadd{\yaxisvec}{\pgfpointscale{0.5}{\xaxisvec}}}% + {\lowerleftinnercorner} + {\innerdiagonal\divide\pgf@x by2 }% }% \anchor{north east}{% \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointadd{\yaxisvec}{\xaxisvec}}% + \lowerleftinnercorner + \innerdiagonal }% \anchor{east}{% \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointadd{\xaxisvec}{\pgfpointscale{0.5}{\yaxisvec}}}% + \lowerleftinnercorner + {\innerdiagonal\divide\pgf@y by2 }% }% \anchor{south east}{% \pgfpointadd - {\lowerleftinnercorner}% - {\xaxisvec}% + \lowerleftinnercorner + {\innerdiagonal\pgf@y=0sp }% }% \anchor{south}{% \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointscale{0.5}{\xaxisvec}}% + \lowerleftinnercorner + {\innerdiagonal\divide\pgf@x by2 \pgf@y=0sp }% }% \anchor{south west}{\lowerleftinnercorner}% \anchor{west}{% \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointscale{0.5}{\yaxisvec}}% - }% + \lowerleftinnercorner + {\innerdiagonal\pgf@x=0sp \divide\pgf@y by2 }% + } \anchor{north west}{% \pgfpointadd - {\lowerleftinnercorner}% - {\yaxisvec}% + \lowerleftinnercorner + {\innerdiagonal\pgf@x=0sp }% }% %% \anchor{origin}{% @@ -4172,30 +5310,30 @@ \anchor{above origin}{% \pgfpointintersectionoflines {\origin} - {\pgfpointadd{\origin}{\yaxisvec}} - {\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}} - {\pgfpointadd{\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}}{\xaxisvec}}% + {\pgfpointadd{\origin}{\innerdiagonal\pgf@x=0sp }} + {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\pgf@x=0sp }} + {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal}}% }% \anchor{left of origin}{% \pgfpointintersectionoflines {\origin} - {\pgfpointadd{\origin}{\pgfpointscale{-1}{\xaxisvec}}} + {\pgfpointadd{\origin}{\innerdiagonal\multiply\pgf@x by-1 \pgf@y=0sp }} {\lowerleftinnercorner} - {\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}}% + {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\pgf@x=0sp }}% }% \anchor{right of origin}{% \pgfpointintersectionoflines {\origin} - {\pgfpointadd{\origin}{\xaxisvec}} - {\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}} - {\pgfpointadd{\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}}{\yaxisvec}}% + {\pgfpointadd{\origin}{\innerdiagonal\pgf@y=0sp }} + {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\pgf@y=0sp }} + {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal}}% }% \anchor{below origin}{% \pgfpointintersectionoflines {\origin} - {\pgfpointadd{\origin}{\pgfpointscale{-1}{\yaxisvec}}} + {\pgfpointadd{\origin}{\innerdiagonal\pgf@x=0sp \multiply\pgf@y by-1 }} {\lowerleftinnercorner} - {\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}}% + {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\pgf@y=0sp }}% }% % %% @@ -4244,52 +5382,52 @@ \upperrightcorner \pgfutil@tempdima=\pgf@y \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointadd{\yaxisvec}{\pgfpointscale{0.5}{\xaxisvec}}}% + {\lowerleftinnercorner} + {\innerdiagonal\divide\pgf@x by2 }% \pgf@y=\pgfutil@tempdima }% \anchor{above north east}{% \upperrightcorner \pgfutil@tempdima=\pgf@y \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointadd{\yaxisvec}{\xaxisvec}}% + \lowerleftinnercorner + \innerdiagonal \pgf@y=\pgfutil@tempdima }% \anchor{right of north east}{% \upperrightcorner \pgfutil@tempdima=\pgf@x \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointadd{\yaxisvec}{\xaxisvec}}% + \lowerleftinnercorner + \innerdiagonal \pgf@x=\pgfutil@tempdima }% \anchor{right of east}{% \upperrightcorner \pgfutil@tempdima=\pgf@x \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointadd{\xaxisvec}{\pgfpointscale{0.5}{\yaxisvec}}}% + \lowerleftinnercorner + {\innerdiagonal\divide\pgf@y by2 }% \pgf@x=\pgfutil@tempdima }% \anchor{right of south east}{% \upperrightcorner \pgfutil@tempdima=\pgf@x \pgfpointadd - {\lowerleftinnercorner}% - {\xaxisvec}% + \lowerleftinnercorner + {\innerdiagonal\pgf@y=0sp }% \pgf@x=\pgfutil@tempdima }% \anchor{below south east}{% \pgfpointadd - {\lowerleftinnercorner}% - {\xaxisvec}% + \lowerleftinnercorner + {\innerdiagonal\pgf@y=0sp }% \pgf@y=0pt }% \anchor{below south}{% \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointscale{0.5}{\xaxisvec}}% + \lowerleftinnercorner + {\innerdiagonal\divide\pgf@x by2 \pgf@y=0sp }% \pgf@y=0pt }% \anchor{below south west}{% @@ -4302,22 +5440,22 @@ }% \anchor{left of west}{% \pgfpointadd - {\lowerleftinnercorner}% - {\pgfpointscale{0.5}{\yaxisvec}}% + \lowerleftinnercorner + {\innerdiagonal\pgf@x=0sp \divide\pgf@y by2 }% \pgf@x=0pt }% \anchor{left of north west}{% \pgfpointadd - {\lowerleftinnercorner}% - {\yaxisvec}% + \lowerleftinnercorner + {\innerdiagonal\pgf@x=0sp }% \pgf@x=0pt }% \anchor{above north west}{% \upperrightcorner \pgfutil@tempdima=\pgf@y \pgfpointadd - {\lowerleftinnercorner}% - {\yaxisvec}% + \lowerleftinnercorner + {\innerdiagonal\pgf@x=0sp }% \pgf@y=\pgfutil@tempdima }% %% @@ -4343,8 +5481,258 @@ \beforeforegroundpath{}% } -\def\pgfplots@draw@axis{% - % +\def\pgfplots@restore@deprecated@lowlevel@shape{% + \pgfutil@ifundefined{pgfplots@low@level@shape@deprecated@isdefined}{% + \gdef\pgfplots@low@level@shape@deprecated@isdefined{1}% + % + % all these assignments are global, so it is save to call this + % macro inside of scopes: + \pgfdeclareshape{pgfplots@low@level@shape@deprecated}{% + % The '(0,0)' point is the LOWER LEFT OUTER CORNER. + \savedanchor\upperrightcorner{ + \pgf@x=\wd\pgfnodepartimagebox + \pgf@y=\ht\pgfnodepartimagebox + }% + \savedanchor\lowerleftinnercorner{% + \pgfqpoint{\pgfplots@savedanchor@inner@lowerleft@x\relax}{\pgfplots@savedanchor@inner@lowerleft@y\relax}% + }% + \savedanchor\xaxisvec{\pgfplotspointxaxis}% + \savedanchor\yaxisvec{\pgfplotspointyaxis}% + \savedanchor\origin{% + \pgfplotspointaxisorigin + }% + % + \nodeparts{image}% + \anchor{image}{% + \pgf@x=0pt % + \pgf@y=0pt % + }% + % + % + \anchor{center}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointscale{0.5}{\pgfpointadd{\xaxisvec}{\yaxisvec}}}% + }% + \anchor{north}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointadd{\yaxisvec}{\pgfpointscale{0.5}{\xaxisvec}}}% + }% + \anchor{north east}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointadd{\yaxisvec}{\xaxisvec}}% + }% + \anchor{east}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointadd{\xaxisvec}{\pgfpointscale{0.5}{\yaxisvec}}}% + }% + \anchor{south east}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\xaxisvec}% + }% + \anchor{south}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointscale{0.5}{\xaxisvec}}% + }% + \anchor{south west}{\lowerleftinnercorner}% + \anchor{west}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointscale{0.5}{\yaxisvec}}% + }% + \anchor{north west}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\yaxisvec}% + }% + %% + \anchor{origin}{% + \origin + }% + \anchor{above origin}{% + \pgfpointintersectionoflines + {\origin} + {\pgfpointadd{\origin}{\yaxisvec}} + {\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}} + {\pgfpointadd{\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}}{\xaxisvec}}% + }% + \anchor{left of origin}{% + \pgfpointintersectionoflines + {\origin} + {\pgfpointadd{\origin}{\pgfpointscale{-1}{\xaxisvec}}} + {\lowerleftinnercorner} + {\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}}% + }% + \anchor{right of origin}{% + \pgfpointintersectionoflines + {\origin} + {\pgfpointadd{\origin}{\xaxisvec}} + {\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}} + {\pgfpointadd{\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}}{\yaxisvec}}% + }% + \anchor{below origin}{% + \pgfpointintersectionoflines + {\origin} + {\pgfpointadd{\origin}{\pgfpointscale{-1}{\yaxisvec}}} + {\lowerleftinnercorner} + {\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}}% + }% + % + %% + % + \anchor{outer north}{% + \upperrightcorner + \pgf@x=.5\pgf@x + }% + \anchor{outer north east}{\upperrightcorner}% + \anchor{outer east}{% + \upperrightcorner + \pgf@y=.5\pgf@y + }% + \anchor{outer south east}{% + \upperrightcorner + \pgf@y=0pt + }% + \anchor{outer south}{% + \upperrightcorner + \pgf@x=.5\pgf@x + \pgf@y=0pt + }% + \anchor{outer south west}{% + \pgf@x=0pt + \pgf@y=0pt + }% + \anchor{outer west}{% + \upperrightcorner + \pgf@x=0pt + \pgf@y=.5\pgf@y + }% + \anchor{outer north west}{% + \upperrightcorner + \pgf@x=0pt + }% + \anchor{outer center}{% + \upperrightcorner + \pgf@x=.5\pgf@x + \pgf@y=.5\pgf@y + }% + % + % + %% + %% + \anchor{above north}{% + \upperrightcorner + \pgfutil@tempdima=\pgf@y + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointadd{\yaxisvec}{\pgfpointscale{0.5}{\xaxisvec}}}% + \pgf@y=\pgfutil@tempdima + }% + \anchor{above north east}{% + \upperrightcorner + \pgfutil@tempdima=\pgf@y + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointadd{\yaxisvec}{\xaxisvec}}% + \pgf@y=\pgfutil@tempdima + }% + \anchor{right of north east}{% + \upperrightcorner + \pgfutil@tempdima=\pgf@x + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointadd{\yaxisvec}{\xaxisvec}}% + \pgf@x=\pgfutil@tempdima + }% + \anchor{right of east}{% + \upperrightcorner + \pgfutil@tempdima=\pgf@x + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointadd{\xaxisvec}{\pgfpointscale{0.5}{\yaxisvec}}}% + \pgf@x=\pgfutil@tempdima + }% + \anchor{right of south east}{% + \upperrightcorner + \pgfutil@tempdima=\pgf@x + \pgfpointadd + {\lowerleftinnercorner}% + {\xaxisvec}% + \pgf@x=\pgfutil@tempdima + }% + \anchor{below south east}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\xaxisvec}% + \pgf@y=0pt + }% + \anchor{below south}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointscale{0.5}{\xaxisvec}}% + \pgf@y=0pt + }% + \anchor{below south west}{% + \lowerleftinnercorner + \pgf@y=0pt + }% + \anchor{left of south west}{% + \lowerleftinnercorner + \pgf@x=0pt + }% + \anchor{left of west}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\pgfpointscale{0.5}{\yaxisvec}}% + \pgf@x=0pt + }% + \anchor{left of north west}{% + \pgfpointadd + {\lowerleftinnercorner}% + {\yaxisvec}% + \pgf@x=0pt + }% + \anchor{above north west}{% + \upperrightcorner + \pgfutil@tempdima=\pgf@y + \pgfpointadd + {\lowerleftinnercorner}% + {\yaxisvec}% + \pgf@y=\pgfutil@tempdima + }% + %% + %% + \anchorborder{% + % Call a function that computes a border point. Since this + % function will modify dimensions like \pgf@x, we must move them to + % other dimensions. + \pgfutil@tempdima=\pgf@x + \pgfutil@tempdimb=\pgf@y + \pgfpointborderrectangle% + {\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdimb}}% + {\upperrightcorner}% + }% + \backgroundpath{% + \pgfkeysvalueof{/pgfplots/@backgroundpath@hook/.@cmd}\pgfeov + \pgfpathrectangle{\pgfpointorigin}{\upperrightcorner}% + }% + \foregroundpath{}% + \behindbackgroundpath{}% + \beforebackgroundpath{}% + \behindforegroundpath{}% + \beforeforegroundpath{}% + }% + }{}% +}% + +% A command which has to be invoked BEFORE \pgfplots@draw@axis to +% prepare everything. +\def\pgfplots@draw@axis@pre{% % Preparation for axis lines and discontinuities: \pgfplots@drawaxis@lines@preparediscont@for{x}% \pgfplots@drawaxis@lines@preparediscont@for{y}% @@ -4354,16 +5742,13 @@ \ifpgfplots@threedim \pgfplots@separate@axis@linestrue \else - \ifnum\pgfplots@xaxislinesnum>0 + \if\pgfplots@xaxislinesnum0\else \pgfplots@separate@axis@linestrue \fi - \ifnum\pgfplots@yaxislinesnum>0 + \if\pgfplots@yaxislinesnum0\else \pgfplots@separate@axis@linestrue \fi \fi - % - \pgfplots@decide@which@figure@surfaces@are@drawn - % % compute tick position lists % \pgfplots@prepared@tick@positions@minor@x % and @@ -4378,78 +5763,275 @@ \ifpgfplots@hide@z\else \expandafter\pgfplots@prepare@tick@coordlists@for\expandafter z\expandafter{\pgfplots@ztick}% \fi - \ifcase\pgfplots@zaxislinesnum\relax + \fi +} + +% PRECONDITION: +% \pgfplots@draw@axis@pre has been called. +\def\pgfplots@draw@axis{% + % + % + % +%\message{Ok, I am now in pgfplots@draw@axis; ready to do work. Hide flags: hide x = \ifpgfplots@hide@x true\else false\fi; hide y = \ifpgfplots@hide@y true\else false\fi hide z = \ifpgfplots@hide@z true \else false \fi. Vector length: x = \pgfplots@x@veclength (1/x = \pgfplots@x@inverseveclength). y = \pgfplots@y@veclength (1/y = \pgfplots@y@inverseveclength) z = \pgfplots@z@veclength (1/z = \pgfplots@z@inverseveclength)}% + \ifpgfplots@threedim +%\if10 + \if2\pgfplots@zaxislinesnum + % axis z line*=center + \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@logical@ZERO@z}{2}% + \pgfplots@draw@axis@insurface@symmetric xyz + \else + % the other cases are handled in + % \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmin}{0}% - \pgfplots@draw@axis@insurface@symmetric xyz0 + \pgfplots@draw@axis@insurface@symmetric xyz % \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmax}{1}% - \pgfplots@draw@axis@insurface@symmetric xyz1 - \or - \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmin}{0}% - \pgfplots@draw@axis@insurface@symmetric xyz2 - \or - \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@logical@ZERO@z}{2}% - \pgfplots@draw@axis@insurface@symmetric xyz2 - \or - \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmax}{1}% - \pgfplots@draw@axis@insurface@symmetric xyz2 + \pgfplots@draw@axis@insurface@symmetric xyz \fi % - \ifcase\pgfplots@xaxislinesnum\relax - \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}% - \pgfplots@draw@axis@insurface@onlyticksandgrid yzx - \pgfplots@draw@axis@insurface zyx0 - % - \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmax}{1}% +%\fi\if10 + \if2\pgfplots@xaxislinesnum + % axis x line*=center + \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@logical@ZERO@x}{2}% \pgfplots@draw@axis@insurface@onlyticksandgrid yzx - \pgfplots@draw@axis@insurface zyx1 - \or + \pgfplots@draw@axis@insurface zyx + \else \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}% \pgfplots@draw@axis@insurface@onlyticksandgrid yzx - \pgfplots@draw@axis@insurface zyx0 - \or - \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@logical@ZERO@x}{2}% - \pgfplots@draw@axis@insurface@onlyticksandgrid yzx - \pgfplots@draw@axis@insurface zyx1 - \or + \pgfplots@draw@axis@insurface zyx + % \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmax}{1}% \pgfplots@draw@axis@insurface@onlyticksandgrid yzx - \pgfplots@draw@axis@insurface zyx1 + \pgfplots@draw@axis@insurface zyx \fi +%\fi\if10 % - \ifcase\pgfplots@yaxislinesnum\relax - \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}% - \pgfplots@draw@axis@insurface@onlyticksandgrid xzy - \pgfplots@draw@axis@insurface@onlyticksandgrid zxy - % - \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymax}{1}% + \if2\pgfplots@yaxislinesnum + \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@logical@ZERO@y}{2}% \pgfplots@draw@axis@insurface@onlyticksandgrid xzy \pgfplots@draw@axis@insurface@onlyticksandgrid zxy - \or + \else \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}% \pgfplots@draw@axis@insurface@onlyticksandgrid xzy \pgfplots@draw@axis@insurface@onlyticksandgrid zxy - \or - \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@logical@ZERO@y}{2}% - \pgfplots@draw@axis@insurface@onlyticksandgrid xzy - \pgfplots@draw@axis@insurface@onlyticksandgrid zxy - \or + % \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymax}{1}% \pgfplots@draw@axis@insurface@onlyticksandgrid xzy \pgfplots@draw@axis@insurface@onlyticksandgrid zxy \fi +%\fi \else % Just use the 2d-point commands (assuming Z=0) \let\pgfplotspointonorientedsurfaceabsetupforxyz=\pgfplotspointonorientedsurfaceabsetupforxy \let\pgfplotspointonorientedsurfaceabsetupforyxz=\pgfplotspointonorientedsurfaceabsetupforyx - \pgfplots@draw@axis@insurface@symmetric xyz2 + \pgfplots@draw@axis@insurface@symmetric xyz \fi }% +% The complement of \pgfplots@draw@axis which will ALWAYS be drawn on +% top of every thing else; it complements the rest. +% +% This implements only the 3d box=complete feature. +% +% PRECONDITION: +% \pgfplots@draw@axis@pre has been called. +\def\pgfplots@draw@axis@post{% + \ifpgfplots@threedim + \if0\pgfplots@threedimbox@choice + % 3d box=background + \else + \if0\pgfplots@xaxislinesnum + \else + \def\pgfplots@threedimbox@choice{0}% + \fi + \if0\pgfplots@yaxislinesnum + \else + \def\pgfplots@threedimbox@choice{0}% + \fi + \if0\pgfplots@zaxislinesnum + \else + \def\pgfplots@threedimbox@choice{0}% + \fi + \if\pgfplots@threedimbox@choice0% + \pgfplots@error{Sorry, your choice for '3d box' and 'axis x line' is incompatible.}% + \else + % 3d box=complete or complete* + \begingroup + \pgfplotsset{every 3d box foreground}% + \let\pgfplots@drawticklabels@onorientedsurf=\relax + \if2\pgfplots@threedimbox@choice + \def\pgfplots@ifgridlines@onorientedsurf@should@be@drawn##1##2{% + ##1% + }% + \else + \let\pgfplots@drawgridlines@onorientedsurf=\relax + \fi + % + \let\pgfplots@drawticklabels@onorientedsurf=\relax + % + % negate the meaning of this if: + \let\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@@ORIG=\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@% + \def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@##1##2##3{% + \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@@ORIG{##1}{##3}{##2}% + }% + % + % the following code is *almost* the same as if we would + % have called + % \pgfplots@draw@axis again. + % The difference is in the + % \pgfplotsifaxissurfaceisforeground checks. + % Furthermore, I have removed the case distinctions for + % the different axis line combinations. + %\if10 + % axis z line*=box + % + \pgfplotsifaxissurfaceisforeground{vv0}{% + \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmin}{0}% + \pgfplots@draw@axis@insurface@symmetric xyz + }{}% + % + \pgfplotsifaxissurfaceisforeground{vv1}{% + \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmax}{1}% + \pgfplots@draw@axis@insurface@symmetric xyz + }{}% + % + %\fi\if10 + % axis x line*=box + \pgfplotsifaxissurfaceisforeground{0vv}{% + \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}% + \pgfplots@draw@axis@insurface@onlyticksandgrid yzx + \pgfplots@draw@axis@insurface zyx + }{} + % + \pgfplotsifaxissurfaceisforeground{1vv}{% + \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmax}{1}% + \pgfplots@draw@axis@insurface@onlyticksandgrid yzx + \pgfplots@draw@axis@insurface zyx + }{} + %\fi\if11 + % + \pgfplotsifaxissurfaceisforeground{v0v}{% + \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}% + \pgfplots@draw@axis@insurface@onlyticksandgrid xzy + \pgfplots@draw@axis@insurface@onlyticksandgrid zxy + }{}% + % + \pgfplotsifaxissurfaceisforeground{v1v}{% + \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymax}{1}% + \pgfplots@draw@axis@insurface@onlyticksandgrid xzy + \pgfplots@draw@axis@insurface@onlyticksandgrid zxy + }{}% + %\fi + \endgroup + % end of 3d box=complete + \fi + \fi + \fi +}% + +\def\pgfplots@define@threedim@marks{% + \ifpgfplots@threedim + % FIXME : there is always the same arithmetics going on here. I could try to optimize it -- for fixed mark size. + \pgfdeclareplotmark{cube} + {% + \pgfplots@cube@gethalf@x + \let\pgfplots@cube@halfx=\pgfmathresult + \pgfplots@cube@gethalf@y + \let\pgfplots@cube@halfy=\pgfmathresult + \pgfplots@cube@gethalf@z + \let\pgfplots@cube@halfz=\pgfmathresult + % + \pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathclose + % + \pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathclose + % + \pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + % + \pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + % + \pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + % + \pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfusepathqstroke + % + }% + \pgfdeclareplotmark{cube*} + {% + \pgfplots@cube@gethalf@x + \let\pgfplots@cube@halfx=\pgfmathresult + \pgfplots@cube@gethalf@y + \let\pgfplots@cube@halfy=\pgfmathresult + \pgfplots@cube@gethalf@z + \let\pgfplots@cube@halfz=\pgfmathresult + % + \pgfplotsifaxissurfaceisforeground{0vv}{% + \pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathclose + \pgfusepathqfillstroke + }{% + \pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathclose + \pgfusepathqfillstroke + }% + \pgfplotsifaxissurfaceisforeground{v0v}{% + \pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathclose + \pgfusepathqfillstroke + }{% + \pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathclose + \pgfusepathqfillstroke + }% + \pgfplotsifaxissurfaceisforeground{vv0}{% + \pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}% + \pgfpathclose + \pgfusepathqfillstroke + }{% + \pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}% + \pgfpathclose + \pgfusepathqfillstroke + }% + }% + \else + \pgfdeclareplotmark{cube}{\pgfuseplotmark{square}}% + \pgfdeclareplotmark{cube*}{\pgfuseplotmark{square*}}% + \fi +} + % Defines booleans for every surface of the axis cube indicating % whether they shall be drawn or not. % -% For 2D, the only available surface is 'vv0' (x=variing; y=variing; z=zmin) +% For 2D, the only available surface is 'vv0' (x=varying; y=varying; z=zmin) % For 3D, there are surfaces % - 'vv0' 'vv1' % - 'v0v' 'v1v' @@ -4461,138 +6043,218 @@ % @PRECONDITION % % @POSTCONDITION -% for every available surface, a macro '\pgfplots@surfenabled@CCC' -% is defined to be either '0' or '1'. +% - for every available surface, a macro '\pgfplots@surfviewdepth@CCC' +% is defined to be either 'f' (foreground) or 'b' (background). % Thus, we don't have real TeX booleans, "only" those one-character % strings. +% There are high-level routines to check these flags. +% - every tick label position will be initialised, i.e. the macros +% \pgfplots@[xyz]ticklabelaxisspec +% will be initialised. % % ABOUT THE ALGORITHM: -% I find it really hard to decide exactly which surfaces shall be drawn. After -% all, PGF is 2D and notions like "above" are not possible. -% So, I resorted to an heuristic approach which will (hopefully) prove -% to be a good idea: +% Given \pgfplots@view@dir@threedim@[xyz], we know the view direction (in 3D!). +% Now, we compute the scalar products <n,(1,0,0)'> <n,(0,1,0)'> and +% <n,(0,0,1)'> between the view direction n and the unit vectors in 3D +% space. Of course, these scalar products are just specific components +% of n. Using the sign of the scalar product, we know whether n points +% roughly into the same or the opposite direction of each unit vector +% and we can deduce foreground and background side surfaces of the +% unit cube. The idea is: foreground surfaces won't be drawn, only +% background surfaces. % -% ASSUMPTION: -% 1. We have a right-handed-coordinate system. The heuristics here -% WILL fail in every other case. -% 2. The z-axis points to the top of the paper. -% Again, the heuristics WILL fail if that is not the case. -% Both assumptions happen to be reasonable for most cases. -% I will have to think about those cases where they are not -% reasonable. +% Given this knowledge, we can also deduce the default axes for tick +% labels. % -% Now, the heuristics ONLY CHECKS THE 'y' components of the the three -% basis vectors. Since per assumption (1.), z_y > 0, there remain only -% a handful of cases for x_y > 0, x_y <0, y_y > 0 and y_y <0. I have -% hard-coded good approaches for each of them below. +% The operation is relatively fast. \def\pgfplots@decide@which@figure@surfaces@are@drawn{% + \expandafter\def\csname pgfplots@surfviewdepth@2vv\endcsname{f}% + \expandafter\def\csname pgfplots@surfviewdepth@v2v\endcsname{f}% + \expandafter\def\csname pgfplots@surfviewdepth@vv2\endcsname{f}% \ifpgfplots@threedim - \begingroup - \gdef\pgfplots@glob@TMPa{% - % This here is the "fall-back" solution: simple enable - % every axis. - \expandafter\def\csname pgfplots@surfenabled@vv0\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@vv1\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@v0v\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@v1v\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@0vv\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@1vv\endcsname{1}% - }% - \let\xaxisy=\pgf@ya - \let\yaxisy=\pgf@yb - \let\zaxisy=\pgf@yc - \pgfplotspointxaxis - \xaxisy=\pgf@y - \pgfplotspointyaxis - \yaxisy=\pgf@y - \pgfplotspointzaxis - \zaxisy=\pgf@y - \ifdim\zaxisy>0pt - % CASE I : - \ifdim\xaxisy>0pt - \else - \ifdim\yaxisy>0pt - \else - \gdef\pgfplots@glob@TMPa{% - \expandafter\def\csname pgfplots@surfenabled@vv0\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@vv1\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@v0v\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@v1v\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@0vv\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@1vv\endcsname{0}% - % - \def\pgfplots@xticklabelaxisspec{v00}% - \def\pgfplots@yticklabelaxisspec{1v0}% - \def\pgfplots@zticklabelaxisspec{00v}% - }% - \fi + % respect reversed axes here. If I am not mistaken, it should + % be completely sufficient to flip signs here: + \ifdim\pgfplots@view@dir@threedim@x pt\if\pgfkeysvalueof{/pgfplots/x dir/value}n>\else<\fi0pt + \expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{f}% foreground + \expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{b}% background + \else + \expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{b}% + \expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{f}% + \fi + \ifdim\pgfplots@view@dir@threedim@y pt\if\pgfkeysvalueof{/pgfplots/y dir/value}n>\else<\fi0pt + \expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{f}% foreground + \expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{b}% background + \else + \expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{b}% + \expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{f}% + \fi + \ifdim\pgfplots@view@dir@threedim@z pt\if\pgfkeysvalueof{/pgfplots/z dir/value}n>\else<\fi0pt + \expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{f}% foreground + \expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{b}% background + \else + \expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{b}% + \expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{f}% + \fi + % + % + % Now, determine which axis line shall get tick labels. + % The strategie is as follows: + % - only lines on the convex hull of the 2D projected axis + % rectangle can get tick labels, + % - for each axis, there are two such choices in the general + % case, + % - for X and Y: prefer the one on the lower side. + % - for Z: prefer the one on the left hand side. + % + \pgfplotspointcenter + \edef\pgfplots@tmp@centerx{\the\pgf@x}% + \edef\pgfplots@tmp@centery{\the\pgf@y}% + % + \pgfplots@init@ticklabelaxisspecfor xy% + % + \pgfplots@init@ticklabelaxisspecfor yy% + % + \pgfplots@init@ticklabelaxisspecfor zx% + \else + % FIXME : it might be better to implement that stuff here + % implicilty using the 3D algorithms. + % + % this here is the only important one: + \expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{b}% + % + \expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{b}% + \expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{f}% + \expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{b}% + \expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{f}% + \expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{f}% + \def\pgfplotsifaxislineisonconvexhull##1##2##3{##2}% ALWAYS TRUE + \def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@##1##2##3{##2}% ALWAYS TRUE + % + \pgfplotspointcenter + \edef\pgfplots@tmp@centerx{\the\pgf@x}% + \edef\pgfplots@tmp@centery{\the\pgf@y}% + % + \pgfplots@init@ticklabelaxisspec@twodim@for xy% + % + \pgfplots@init@ticklabelaxisspec@twodim@for yx% + \fi +} + +% A helper method which is to be invoked ONLY inside of +% \pgfplots@decide@which@figure@surfaces@are@drawn. +% It does NOT work outside of it. +% +% It initialises the 'pgfplots@#1ticklabelaxisspec' macro according to +% the foreground/background situation of the axis and the '#1ticklabel pos' +% key. +% +% #1: the axis: x,y or z +% #2: either x or y. It refers to the PROJECTED coordinate which +% should be used to compare the 'lower' and 'upper' arguments of the +% |[xyz]ticklabel pos| key. +% +% PRECONDITION: +% \pgfplots@tmp@center[xy] is set. +% +% POSTCONDITION: +% - pgfplots@#1ticklabelaxisspec is set, +% - pgfplots@#1ticklabel@suggested@anchor is set +% +% @see also \pgfplots@init@ticklabelaxisspec@twodim@for +\def\pgfplots@init@ticklabelaxisspecfor#1#2{% + \if#1x% + \def\pgfplots@loc@to@threedim##1##2{v##1##2}% + \def\pgfplots@loc@axischar@for@first{y}% + \else + \if#1y% + \def\pgfplots@loc@to@threedim##1##2{##1v##2}% + \def\pgfplots@loc@axischar@for@first{x}% + \else + \def\pgfplots@loc@to@threedim##1##2{##1##2v}% + \def\pgfplots@loc@axischar@for@first{x}% + \fi + \fi + \pgfplotsifaxislineisonconvexhull{\pgfplots@loc@to@threedim 00}{% + % -> both, v00 or v11 are on CH. + % + % Decide whether the '{0.5}{0}{0}' point is above or below + % the {0.5}{0.5}{0.5} + % point. This '<' operation is based on the '#1ticklabel pos' + % key, the 2D projection of the axis and the argument '#2'. + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 00}% + \pgfqpointscale{0.5}{\csname pgfplotspoint#1axis\endcsname}% + \ifdim\csname pgf@#2\endcsname<\csname pgfplots@tmp@center#2\endcsname\relax + \if u\csname pgfplots@#1ticklabel@pos\endcsname + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 11}% \fi - % CASE II: - \ifdim\xaxisy<0pt - \else - \ifdim\yaxisy<0pt - \else - \gdef\pgfplots@glob@TMPa{% - \expandafter\def\csname pgfplots@surfenabled@vv0\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@vv1\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@v0v\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@v1v\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@0vv\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@1vv\endcsname{1}% - % - \def\pgfplots@xticklabelaxisspec{v00}% - \def\pgfplots@yticklabelaxisspec{0v0}% - \def\pgfplots@zticklabelaxisspec{01v}% - }% - \fi + \else + \if l\csname pgfplots@#1ticklabel@pos\endcsname + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 11}% \fi - % CASE III: - \ifdim\xaxisy<0pt - \else - \ifdim\yaxisy>0pt - \else - \gdef\pgfplots@glob@TMPa{% - \expandafter\def\csname pgfplots@surfenabled@vv0\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@vv1\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@v0v\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@v1v\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@0vv\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@1vv\endcsname{1}% - % - \def\pgfplots@xticklabelaxisspec{v10}% - \def\pgfplots@yticklabelaxisspec{0v0}% - \def\pgfplots@zticklabelaxisspec{11v}% - }% - \fi + \fi + }{% + % -> both, v01 or v10 are on CH + %-------------------------------------------------- + % \pgfplotsifaxislineisonconvexhull{\pgfplots@loc@to@threedim 01}{% FIXME : eliminate sanity assertion if possible + % }{% + % \pgfplots@error{INTERNAL ERROR}% + % }% + %-------------------------------------------------- + % Decide whether the '{0.5}{1}{0}' point is above or below + % the {0.5}{0.5}{0.5} point. Again, the '<' operation is based + % on the '#1ticklabel pos' key, the projection and #2. + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 10}% + % compute the middle point on \pgfplots@loc@to@threedim 10 + \pgfpointadd + {\csname pgfplotspoint\pgfplots@loc@axischar@for@first axis\endcsname} + {\pgfpointscale{0.5}{\csname pgfplotspoint#1axis\endcsname}}% + % + \ifdim\csname pgf@#2\endcsname<\csname pgfplots@tmp@center#2\endcsname\relax + \if u\csname pgfplots@#1ticklabel@pos\endcsname + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 01}% \fi - % CASE IV: - \ifdim\xaxisy>0pt - \else - \ifdim\yaxisy>0pt - \else - \gdef\pgfplots@glob@TMPa{% - \expandafter\def\csname pgfplots@surfenabled@vv0\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@vv1\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@v0v\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@v1v\endcsname{0}% - \expandafter\def\csname pgfplots@surfenabled@0vv\endcsname{1}% - \expandafter\def\csname pgfplots@surfenabled@1vv\endcsname{0}% - % - \def\pgfplots@xticklabelaxisspec{v10}% - \def\pgfplots@yticklabelaxisspec{1v0}% - \def\pgfplots@zticklabelaxisspec{10v}% - }% - \fi + \else + \if l\csname pgfplots@#1ticklabel@pos\endcsname + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 01}% \fi \fi - \endgroup - % and activate the macro: - \pgfplots@glob@TMPa + }% +}% +\def\pgfplots@init@ticklabelaxisspec@twodim@for#1#2{% + \if#1x% + \def\pgfplots@loc@to@threedim##1{v##10}% + \def\pgfplots@loc@axischar@for@first{y}% \else - \expandafter\def\csname pgfplots@surfenabled@vv0\endcsname{1}% - \def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn##1##2##3{##2}% ALWAYS TRUE + \def\pgfplots@loc@to@threedim##1{##1v0}% + \def\pgfplots@loc@axischar@for@first{x}% \fi -} + % Decide whether the '{0.5}{0}' point is above or below + % the {0.5}{0.5} + % point. This '<' operation is based on the '#1ticklabel pos' + % key, the 2D projection of the axis and the argument '#2'. + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 0}% + \pgfqpointscale{0.5}{\csname pgfplotspoint#1axis\endcsname}% + \ifdim\csname pgf@#2\endcsname<\csname pgfplots@tmp@center#2\endcsname\relax + \if u\csname pgfplots@#1ticklabel@pos\endcsname + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 1}% + \fi + \else + %-------------------------------------------------- + %FIXME : I have the impression that this here is DEPRECATED + % \if3\csname pgfplots@#1tickposnum\endcsname % is 'right' + % \expandafter\def\csname pgfplots@#1tickposnum\endcsname{1}% set to 'left' + % \else + % \if1\csname pgfplots@#1tickposnum\endcsname % is 'left' + % \expandafter\def\csname pgfplots@#1tickposnum\endcsname{3}% set to 'right' + % \fi + % \fi + %-------------------------------------------------- + \if l\csname pgfplots@#1ticklabel@pos\endcsname + \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 1}% + \fi + \fi +}% + % Processes every tick mark in direction #1 and draws tick lines, tick % labels, grid lines, axis lines and extra ticks. @@ -4600,13 +6262,7 @@ % #1 : the direction into which tick positions are processed. % #2 : the direction in which tick lines and grid lines shall be drawn. % #3 : the direction which is currently fixed. -% #4 : an integer used to decide whether tick LABELS shall be drawn. -% The following values are accepted: -% 0 : we are on the "left". So, draw tick labels if '#3ticklabel pos==left' -% 1 : we are on the "right". So, draw tick labels if '#3ticklabel pos==right' -% 2 : draw tick labels anyway. -% -\def\pgfplots@draw@axis@insurface#1#2#3#4{% +\def\pgfplots@draw@axis@insurface#1#2#3{% \pgfplots@if{pgfplots@hide@#1}{\relax}{% \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname \pgfplots@drawgridlines@onorientedsurf @@ -4618,18 +6274,20 @@ % \pgfplots@drawticklabels@onorientedsurf % - \expandafter\ifx\csname pgfplots@extra@#1tick\endcsname\pgfutil@empty + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname + \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@extra@xtick}% + \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}% \fi }% }% % A variant of \pgfplots@draw@axis@insurface which is equivalent to -% \pgfplots@draw@axis@insurface #1#2#3#4 -% \pgfplots@draw@axis@insurface #2#1#3#4 +% \pgfplots@draw@axis@insurface #1#2#3 +% \pgfplots@draw@axis@insurface #2#1#3 % with slightly optimized execution sequence. -\def\pgfplots@draw@axis@insurface@symmetric#1#2#3#4{% +\def\pgfplots@draw@axis@insurface@symmetric#1#2#3{% \pgfplots@if{pgfplots@hide@#1}{\relax}{% \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname \pgfplots@drawgridlines@onorientedsurf @@ -4676,17 +6334,19 @@ }% % \pgfplots@if{pgfplots@hide@#1}{\relax}{% - \expandafter\ifx\csname pgfplots@extra@#1tick\endcsname\pgfutil@empty + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname + \ifx\pgfplots@loc@TMPa\pgfutil@empty \else \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname - \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@extra@xtick}% + \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}% \fi }% \pgfplots@if{pgfplots@hide@#2}{\relax}{% - \expandafter\ifx\csname pgfplots@extra@#2tick\endcsname\pgfutil@empty + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#2tick\endcsname + \ifx\pgfplots@loc@TMPa\pgfutil@empty \else \csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname - \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@extra@ytick}% + \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}% \fi }% }% @@ -4696,9 +6356,53 @@ \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname \pgfplots@drawgridlines@onorientedsurf \pgfplots@drawticklines@onorientedsurf + % + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \begingroup + \let\pgfplots@drawticklabels@onorientedsurf=\relax + \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}% + \endgroup + \fi }% }% +% Handles the 'every 3d description' style. +% +% This requires a different type of attention than any other key -- +% because all other keys are set in a context where the dimension of +% the axis is unknown (it might be 2 or 3 dimensional). +% +% The idea is: +% Call \pgfplots@BEGIN@prepare@description@styles as soon as the +% dimension is fixed, but before any style changes of the user +% interface are applied. +% +% Example: +% \begin{axis}[xlabel style={}] +% will be processed here. The reason: 'every 3d description' will +% certainly use a different style for axis labels than the default 2d +% style. +% +% Thus, all style changes which are relevant for 'every 3d description' +% have NOT YET been processed (they have been appended to 'every axis'). +\def\pgfplots@BEGIN@prepare@description@styles{% + \ifpgfplots@threedim + \pgfplotsset{every 3d description,every 3d view {\pgfkeysvalueof{/pgfplots/view/az}}{\pgfkeysvalueof{/pgfplots/view/el}}/.try}% + \fi + \pgfkeysgetvalue{/pgfplots/.unknown/.@cmd}\pgfplots@BEGIN@prepare@description@styles@oldhandler + \pgfkeysdef{/pgfplots/.unknown}{}% ignore unknown keys here. + \pgfkeysactivatefamily{/pgfplots/style commands}% + \pgfkeysactivatefamily{/pgfplots/descriptions}% +%\pgfkeys{/pgfplots/every axis/.show code}% + \pgfplots@set@keys@from@tikz@style{every axis}% + \pgfkeysdeactivatefamily{/pgfplots/descriptions}% + \pgfkeysdeactivatefamily{/pgfplots/style commands}% + \pgfkeyslet{/pgfplots/.unknown/.@cmd}\pgfplots@BEGIN@prepare@description@styles@oldhandler +}% + \def\pgfplots@BEGIN@init@and@draw@axis{% \pgfplots@determinedefaultvalues \setbox\pgfnodepartimagebox=\hbox\bgroup\bgroup @@ -4707,27 +6411,260 @@ % set baseline for sub-picture to default value. % the baseline option will be applied to the OUTER picture. \pgfsetbaseline{\pgf@picminy}% + \begingroup + \pgfgettransformentries\aa\ab\ba\bb\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \xdef\pgfplots@savedtransformshift{% + \pgf@x=\pgfplots@loc@TMPa\space + \pgf@y=\pgfplots@loc@TMPb\space + }% + \xdef\pgfplots@glob@TMPa{{\aa}{\ab}{\ba}{\bb}}% + \endgroup + \expandafter\pgfsettransformentries\pgfplots@glob@TMPa{0pt}{0pt}% % + \pgfplots@draw@axis@pre \scope + % + \pgfkeysifdefined{/pgfplots/axis background/.@cmd}{% + \path[/pgfplots/axis background] \pgfextra{\pgfplots@clippath@install{}};% + }{}% + % \ifpgfplots@axis@on@top \else \pgfplots@draw@axis \fi % CLIPPING: - \pgfplots@clippath@prepare \ifpgfplots@clip - \pgfplots@clippath@install + \pgfplots@clippath@install{\pgfusepath{clip}}% \fi + \pgfplotspointbb@assertvaluesexist% } % Defines \pgfplots@clippath@install. % @PRECONDITION the axis limits must be ready. \def\pgfplots@clippath@prepare{% + \def\pgfplots@clippath@use@##1{% + \ifx\pgfplotspoint@bb@@@\relax + % remember the axis dimensions as well: + \ifdim\pgf@pathmaxx=-16000pt + \else + \begingroup + \pgf@xa=\pgf@pathmaxx + \advance\pgf@xa by-\pgf@pathminx + \pgf@ya=\pgf@pathmaxy + \advance\pgf@ya by-\pgf@pathminy + \xdef\pgfplots@glob@TMPa{{\the\pgf@pathminx}{\the\pgf@pathminy}{\the\pgf@xa}{\the\pgf@ya}}% + \endgroup + \global\let\pgfplotspoint@bb@@@=\pgfplots@glob@TMPa + \fi + \fi + ##1% + }% \ifpgfplots@threedim % FIXME : this can't be done in three dimensions. :-( % -> for 3d, I need to clip at least the 2d projection. - % FIXME : which path(s) do I need for 3d? - \let\pgfplots@clippath@install=\pgfutil@empty + % + % -> Identify the convex hull of the 2D projection: + \pgfplotsifaxissurfaceisforeground{0vv}{% + \pgfplotsifaxissurfaceisforeground{v0v}{% + \pgfplotsifaxissurfaceisforeground{vv0}{% + % ok. Do NOT use the intersection lines + % - 00v + % - 0v0 + % - v00 + % so, use + % 010 (01v) 011 + % 011 (0v1) 001 + % 001 (v01) 101 + % 101 (10v) 100 + % 100 (1v0) 110 + % 110 (v10) 011 (cycle) + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% + }{% + % foreground surfs: 0vv, v0v, vv1 + % + % ok. Do NOT use the intersection lines + % - 00v + % - 0v1 + % - v01 + % so, use + % 010 (01v) 011 + % 011 (v11) 111 + % 111 (1v1) 101 + % 101 (10v) 100 + % 100 (v00) 000 + % 000 (0v0) 010 (cycle) + \def\pgfplots@clippath@install##1{\relax% + \pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% + }% + }{% + \pgfplotsifaxissurfaceisforeground{vv0}{% + % foreground surfs: 0vv, v1v, vv0 + % + % ok. Do NOT use the intersection lines + % - 01v + % - 0v0 + % - v10 + % so, use + % 000 (00v) 001 + % 001 (0v1) 011 + % 011 (v11) 111 + % 111 (11v) 110 + % 110 (1v0) 100 + % 100 (v00) 000 (cycle) + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% + }{% + % foreground surfs: 0vv, v1v, vv1 + % + % ok. Do NOT use the intersection lines + % - 01v + % - 0v1 + % - v11 + % so, use + % 000 (00v) 001 + % 001 (v01) 101 + % 101 (1v1) 111 + % 111 (11v) 110 + % 110 (v10) 010 + % 010 (0v0) 000 (cycle) + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% + }% + }% + }{% + \pgfplotsifaxissurfaceisforeground{v0v}{% + \pgfplotsifaxissurfaceisforeground{vv0}{% + % foreground surfs: 1vv, v0v, vv0. + % + % Thus: DON'T use the intersection lines + % - 10v + % - 1v0 + % - v00 + % So, use + % 110 (11v) 111 + % 111 (1v1) 101 + % 101 (v01) 001 + % 001 (00v) 000 + % 000 (0v0) 010 + % 010 (v10) 110 (cycle) + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% + }{% + % foreground surfs: 1vv, v0v, vv1 + % Thus: DON'T use the intersection lines + % - 10v + % - 1v1 + % - v01 + % So, use + % 110 (11v) 111 + % 111 (v11) 011 + % 011 (0v1) 001 + % 001 (00v) 000 + % 000 (v00) 100 + % 100 (1v0) 110 (cycle) + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% + }% + }{% + \pgfplotsifaxissurfaceisforeground{vv0}{% + % foreground surfs: 1vv, v1v, vv0 + % Thus: DON'T use the intersection lines + % - 11v + % - 1v0 + % - v10 + % So, use + % 100 (10v) 101 + % 101 (1v1) 111 + % 111 (v11) 011 + % 011 (01v) 010 + % 010 (0v0) 000 + % 000 (v00) 100 (cycle) + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% + }{% + % foreground surfs: 1vv, v1v, vv1 + % Thus: DON'T use the intersection lines + % - 11v + % - 1v1 + % - v11 + % So, use + % 100 (10v) 101 + % 101 (v01) 001 + % 001 (0v1) 011 + % 011 (01v) 010 + % 010 (v10) 110 + % 110 (1v0) 100 (cycle) + \def\pgfplots@clippath@install##1{% + \pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}% + \pgfpathclose + \pgfplots@clippath@use@{##1}% + }% + }% + }% + }% + \else \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}% \edef\pgfplots@loc@TMPa{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% @@ -4742,29 +6679,72 @@ \toks1=\expandafter{\pgfplots@loc@TMPb}% \toks2=\expandafter{\pgfplots@loc@TMPc}% \toks3=\expandafter{\pgfplots@loc@TMPd}% - \xdef\pgfplots@glob@TMPa{% + \xdef\pgfplots@glob@TMPa##1{% \noexpand\pgfpathmoveto{\the\toks0 }% \noexpand\pgfpathlineto{\the\toks1 }% \noexpand\pgfpathlineto{\the\toks2 }% \noexpand\pgfpathlineto{\the\toks3 }% - \noexpand\pgfusepath{clip}% + \noexpand\pgfplots@clippath@use@{##1}% }% \endgroup \let\pgfplots@clippath@install=\pgfplots@glob@TMPa \fi + % FIXME : workaround clear path sizes at beginning! This shouldn't + % be necessary! + \expandafter\def + \expandafter\pgfplots@clippath@install + \expandafter##% + \expandafter1% + \expandafter{% + \expandafter\pgf@resetpathsizes + \pgfplots@clippath@install{##1}% + }% + \global\let\pgfplotspoint@bb@@@=\relax +}% +\def\pgfplotspointbb@assertvaluesexist{% + \ifx\pgfplotspoint@bb@@@\relax + % (RE)COMPUTE: + % + % Determine tight 2D bounding box for the axis as such: + \begingroup + \pgfinterruptboundingbox + \pgf@relevantforpicturesizetrue + \pgfplots@clippath@install{\pgfusepath{discard}} + \endpgfinterruptboundingbox + \endgroup + \fi +}% + +% Point commands which expand to the bounding box which contains at +% least the (projected) visible part of the axis +\def\pgfplotspointbblowerleft{% + \pgfplotspointbb@assertvaluesexist + \expandafter\pgfplotspointbblowerleft@\pgfplotspoint@bb@@@ +}% +\def\pgfplotspointbbupperright{% + \pgfpointadd{\pgfplotspointbblowerleft}{\pgfplotspointbbdiagonal}% +}% +\def\pgfplotspointbbdiagonal{% + \pgfplotspointbb@assertvaluesexist + \expandafter\pgfplotspointbbdiagonal@\pgfplotspoint@bb@@@ }% +\let\pgfplotspoint@bb@@@=\relax +\def\pgfplotspointbblowerleft@#1#2#3#4{\pgf@x=#1 \pgf@y=#2 }% +\def\pgfplotspointbbdiagonal@#1#2#3#4{\pgf@x=#3 \pgf@y=#4 }% -\def\pgfplots@clippath@install{% +% #1: a complete \pgfusepath command what to do with the clip path. +\def\pgfplots@clippath@install#1{% \pgfplots@error{Can't install a clippath here - the command has not yet been prepared.}% }% +% This is the counterpart for \pgfplots@BEGIN@init@and@draw@axis \def\pgfplots@END@init@and@draw@axis{% \endscope% % \ifpgfplots@axis@on@top \pgfplots@draw@axis - \else \fi + \pgfplots@draw@axis@post % % whats the better sequence for \ifpgfplots@axis@on@top and \ifpgfplots@clip@marker@paths !? % This here looks better, I think... markers should not be obscured by descriptions. @@ -4787,10 +6767,12 @@ } % Writes output to \pgfmathresult -\def\pgfplots@filter@input@ticks@with@log#1{% +% #1: the tick list (not a macro!) +% #2: the axis +\def\pgfplots@filter@input@ticks@with@log#1#2{% \let\pgfplots@glob@TMPa=\pgfutil@empty \foreach \pgfplots@loc@TMPb in {#1} {% - \expandafter\pgfmathlog@\expandafter{\pgfplots@loc@TMPb}% + \csname pgfplotsmathlog@#2@\endcsname{\pgfplots@loc@TMPb}% \ifx\pgfplots@glob@TMPa\pgfutil@empty \xdef\pgfplots@glob@TMPa{\pgfmathresult}% \else @@ -4816,13 +6798,25 @@ \let\pgfmathresult=\pgfplots@glob@TMPa } -\tikzdeclarecoordinatesystem{axis}{\pgfplots@evalute@tikz@coord@system@interface#1\pgfplots@coord@end} +\tikzdeclarecoordinatesystem{axis}{\edef\pgfplots@loc@TMPa{#1}\expandafter\pgfplots@evalute@tikz@coord@system@interface\pgfplots@loc@TMPa\pgfplots@coord@end} +\def\pgfplotspointaxisxy#1#2{\pgfplots@evalute@tikz@coord@system@interface#1,#2\pgfplots@coord@end}% +\def\pgfplotspointaxisxyz#1#2#3{\pgfplots@evalute@tikz@coord@system@interface#1,#2,#3\pgfplots@coord@end}% + +\tikzdeclarecoordinatesystem{rel axis}{\edef\pgfplots@loc@TMPa{#1}\expandafter\pgfplots@evalute@tikz@coord@system@interface@rel\pgfplots@loc@TMPa\pgfplots@coord@end} +\def\pgfplotspointrelaxisxy#1#2{\pgfplots@evalute@tikz@coord@system@interface@rel#1,#2\pgfplots@coord@end}% +\def\pgfplotspointrelaxisxyz#1#2#3{\pgfplots@evalute@tikz@coord@system@interface@rel#1,#2,#3\pgfplots@coord@end}% + +\tikzdeclarecoordinatesystem{axis description}{\edef\pgfplots@loc@TMPa{#1}\expandafter\pgfplots@evalute@tikz@coord@system@interface@axis@description\pgfplots@loc@TMPa\pgfplots@coord@end} +\def\pgfplots@evalute@tikz@coord@system@interface@axis@description#1,#2\pgfplots@coord@end{\pgfplotspointdescriptionxy{#1}{#2}} +\def\pgfplotstransformcoordinatex#1{\pgfplots@evalute@tikz@coord@system@interface@for{x}{#1}}% +\def\pgfplotstransformcoordinatey#1{\pgfplots@evalute@tikz@coord@system@interface@for{y}{#1}}% +\def\pgfplotstransformcoordinatez#1{\pgfplots@evalute@tikz@coord@system@interface@for{z}{#1}}% % Assigns \pgfmathresult := canvas coordinate (#2) for axis #1. \long\def\pgfplots@evalute@tikz@coord@system@interface@for#1#2{% \pgfkeysgetvalue{/pgfplots/#1 coord trafo/.@cmd}\pgfplots@loc@TMPc - \def\pgfmathresult{#2}% + \edef\pgfmathresult{#2}% \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key \else \expandafter\pgfplots@loc@TMPc\expandafter{\pgfmathresult}\pgfeov @@ -4842,15 +6836,95 @@ \begingroup \pgfplots@evalute@tikz@coord@system@interface@for{x}{#1}% \let\pgfplots@evaluate@tikz@coord@x=\pgfmathresult - \pgfplots@evalute@tikz@coord@system@interface@for{y}{#2}% + \edef\pgfplots@loc@TMPa{#2}% + \expandafter\pgfutil@in@\expandafter,\expandafter{\pgfplots@loc@TMPa}% + \ifpgfutil@in@ + \def\pgfplots@loc@TMPb##1,##2\pgfplots@EOI{% + \def\pgfplots@axiscs@y{##1}% + \def\pgfplots@axiscs@z{##2}% + }% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI + \pgfplots@evalute@tikz@coord@system@interface@for{y}{\pgfplots@axiscs@y}% + \let\pgfplots@evaluate@tikz@coord@y=\pgfmathresult + \pgfplots@evalute@tikz@coord@system@interface@for{z}{\pgfplots@axiscs@z}% + \let\pgfplots@evaluate@tikz@coord@z=\pgfmathresult + \else + \pgfplots@evalute@tikz@coord@system@interface@for{y}{#2}% + \let\pgfplots@evaluate@tikz@coord@y=\pgfmathresult + \let\pgfplots@evaluate@tikz@coord@z=\pgfutil@empty + \fi \xdef\pgfplots@glob@TMPa{\pgfplots@evaluate@tikz@coord@x}% - \xdef\pgfplots@glob@TMPb{\pgfmathresult}% + \xdef\pgfplots@glob@TMPb{\pgfplots@evaluate@tikz@coord@y}% + \xdef\pgfplots@glob@TMPc{\pgfplots@evaluate@tikz@coord@z}% \endgroup \ifx\pgfplots@glob@TMPc\pgfutil@empty \pgfplotsqpointxy{\pgfplots@glob@TMPa}{\pgfplots@glob@TMPb}% \else - \pgfplotsqpointxyz{\pgfplots@glob@TMPa}{\pgfplots@glob@TMPb}{\pgfplots@glob@TMPc}% FIXME: read 3D! + \pgfplotsqpointxyz{\pgfplots@glob@TMPa}{\pgfplots@glob@TMPb}{\pgfplots@glob@TMPc}% + \fi +} +\long\def\pgfplots@evalute@tikz@coord@system@interface@rel#1,#2\pgfplots@coord@end{% + \begingroup + \pgfkeys{/pgf/fpu=false}% + \pgfmathparse{#1}% + \let\pgfplots@axiscs@x=\pgfmathresult + \edef\pgfplots@loc@TMPa{#2}% + \expandafter\pgfutil@in@\expandafter,\expandafter{\pgfplots@loc@TMPa}% + \ifpgfutil@in@ + \def\pgfplots@loc@TMPb##1,##2\pgfplots@EOI{% + \pgfmathparse{##1}% + \let\pgfplots@axiscs@y=\pgfmathresult + \pgfmathparse{##2}% + \let\pgfplots@axiscs@z=\pgfmathresult + }% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI + \else + \pgfmathparse{#2}% + \let\pgfplots@axiscs@y=\pgfmathresult + \def\pgfplots@axiscs@z{}% + \fi + \pgfplotspointxaxis + \pgf@xx=\pgf@x + \pgf@xy=\pgf@y + % + \pgfplotspointyaxis + \pgf@yx=\pgf@x + \pgf@yy=\pgf@y + % + \ifpgfplots@allow@reversal@of@rel@axis@cs + \if\pgfkeysvalueof{/pgfplots/x dir/value}r% + \pgf@xa=-\pgfplots@axiscs@x pt + \advance\pgf@xa by1pt + \edef\pgfplots@axiscs@x{\pgf@sys@tonumber\pgf@xa}% + \fi + \if\pgfkeysvalueof{/pgfplots/y dir/value}r% + \pgf@xa=-\pgfplots@axiscs@y pt + \advance\pgf@xa by1pt + \edef\pgfplots@axiscs@y{\pgf@sys@tonumber\pgf@xa}% + \fi + \fi + % + \ifx\pgfplots@axiscs@z\pgfutil@empty + \pgfpointadd + {\pgfplotspointminminmin}% + {\pgfplotsqpointxy{\pgfplots@axiscs@x}{\pgfplots@axiscs@y}}% + \else + \ifpgfplots@allow@reversal@of@rel@axis@cs + \if\pgfkeysvalueof{/pgfplots/z dir/value}r% + \pgf@xa=-\pgfplots@axiscs@z pt + \advance\pgf@xa by1pt + \edef\pgfplots@axiscs@z{\pgf@sys@tonumber\pgf@xa}% + \fi + \fi + \pgfplotspointzaxis + \pgf@zx=\pgf@x + \pgf@zy=\pgf@y + \pgfpointadd + {\pgfplotspointminminmin}% + {\pgfplotsqpointxyz{\pgfplots@axiscs@x}{\pgfplots@axiscs@y}{\pgfplots@axiscs@z}}% \fi + \pgf@process{}% + \endgroup } % In case of (semi-) logplots, this command will @@ -4864,12 +6938,15 @@ % - the options have been set, but are not applied % % POSTCONDITION: -% - any user input for log-axis has been replaced by its log -% - coordinate filters to compute logs are installed +% - any user input has been parsed +% - any user input for log-axis has been replaced by its log if +% necessary +% - coordinate filters are prepared % % See also: % \pgfplots@check@and@apply@datatrafo@for \def\pgfplots@prepare@coord@filtering@for#1{% + \expandafter\let\csname pgfplotsmathlogtologten@#1@\endcsname=\pgfmathlogtologten@ \pgfkeysgetvalue{/pgfplots/#1 coord trafo/.@cmd}\pgfplots@loc@TMPc \expandafter\let\csname pgfplots@highlevel@trafo@#1\endcsname=\pgfplots@loc@TMPc \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key @@ -4921,6 +6998,7 @@ \else \def\pgfplots@loc@TMPb{data}% \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + % #1tick=data is handled elsewhere... \else \expandafter\pgfplots@filter@input@ticks@with@highleveltrafo\expandafter{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPc}% \expandafter\edef\csname pgfplots@#1tick\endcsname{\pgfmathresult}% @@ -4975,21 +7053,117 @@ \fi \fi \else + \expandafter\let\csname pgfplotsmathlog@#1@\endcsname=\pgfmathlog@ + \expandafter\let\csname pgfplotsmathlogi@#1\endcsname=\logi + \expandafter\let\csname pgfplotsmathlog@#1@float\endcsname=\pgfmathlog@float + \expandafter\let\csname pgfplots@log@scale@todisplaylog@#1\endcsname=\logten + \expandafter\let\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname=\reciproclogten + \expandafter\def\csname pgfplotsmathlogscale@#1\endcsname{1}% + \expandafter\def\csname pgfplotsmathlogscale@#1@inv\endcsname{1}% + % % This here could be done using a high level coord trafo as % well! However, I don't want to risk accidentally overwritten % keys, so I replicate it here. \pgfplots@if{pgfplots@disablelogfilter@#1}{\relax}{% + % Prepare the log to use for axis '#1'. + % + \pgfkeysgetvalue{/pgfplots/log basis #1}\pgfplots@loc@TMPa% + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % log basis x={} (initial setting:) + \else + % use a different basis. + % + % + \pgfmathlog@{\pgfplots@loc@TMPa}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfmathparse{1/\pgfplots@loc@TMPa}% + \expandafter\let\csname pgfplotsmathlogscale@#1\endcsname=\pgfplots@loc@TMPa + \expandafter\let\csname pgfplotsmathlogscale@#1@inv\endcsname=\pgfmathresult + % + \expandafter\edef\csname pgfplotsmathlog@#1@\endcsname##1{% + \noexpand\pgfmathlog@{##1}% + \noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty + \noexpand\else + \noexpand\expandafter\noexpand\pgfmath@basic@multiply@\noexpand\expandafter + {\noexpand\pgfmathresult}% + {\pgfmathresult}% + \noexpand\fi + }% + \expandafter\edef\csname pgfplotsmathlog@#1@float\endcsname##1{% + \noexpand\pgfmathlog@float{##1}% + \noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty + \noexpand\else + \noexpand\expandafter\noexpand\pgfmath@basic@multiply@\noexpand\expandafter + {\noexpand\pgfmathresult}% + {\pgfmathresult}% + \noexpand\fi + }% + % + % generate default ticks in the 'log basis', not base 10: + \expandafter\def\csname pgfplots@log@scale@todisplaylog@#1\endcsname{1}% + \expandafter\def\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname{1}% + \pgfplotsset{/pgfplots/log basis ticks=#1}% + % + % + \ifdim\pgfkeysvalueof{/pgfplots/log basis #1}pt=10pt + \else + \pgfplots@identify@log@minor@tick@posfalse + \csname pgfplots@#1minorticksfalse\endcsname + \csname pgfplots@#1minorgridsfalse\endcsname + \expandafter\def\csname pgfplots@#1minortickstrue\endcsname{\pgfplots@error{Sorry, minor ticks are not supported for this log basis.}}% + \expandafter\def\csname pgfplots@#1minorgridstrue\endcsname{\pgfplots@error{Sorry, minor grid lines are not supported for this log basis.}}% + \fi + \pgfkeysdef{/pgfplots/log basis #1}{\pgfplots@error{Sorry, you can't change 'log basis #1' in this context.}}% + % + % recompute logtologten for this axis: + \pgfmath@basic@multiply@{\reciproclogten}{\pgfplots@loc@TMPa}% + \expandafter\edef\csname pgfplotsmathlogtologten@#1@\endcsname##1{% + \noexpand\pgfmath@basic@multiply@{##1}{\pgfmathresult}% + }% + \begingroup + % recompute \logi for the new basis. + \dimen1=\logi1pt \dimen1=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen1 + \dimen2=\logi2pt \dimen2=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen2 + \dimen3=\logi3pt \dimen3=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen3 + \dimen4=\logi4pt \dimen4=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen4 + \dimen5=\logi5pt \dimen5=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen5 + \dimen6=\logi6pt \dimen6=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen6 + \dimen7=\logi7pt \dimen7=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen7 + \dimen8=\logi8pt \dimen8=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen8 + \dimen9=\logi9pt \dimen9=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen9 + \xdef\pgfplots@glob@TMPa##1{% + \noexpand\ifcase##1 + \noexpand\or0 + \noexpand\or\pgf@sys@tonumber{\dimen1 }% + \noexpand\or\pgf@sys@tonumber{\dimen2 }% + \noexpand\or\pgf@sys@tonumber{\dimen3 }% + \noexpand\or\pgf@sys@tonumber{\dimen4 }% + \noexpand\or\pgf@sys@tonumber{\dimen5 }% + \noexpand\or\pgf@sys@tonumber{\dimen6 }% + \noexpand\or\pgf@sys@tonumber{\dimen7 }% + \noexpand\or\pgf@sys@tonumber{\dimen8 }% + \noexpand\or\pgf@sys@tonumber{\dimen9 }% + \noexpand\fi + }% + \endgroup + \expandafter\let\csname pgfplotsmathlogi@#1\endcsname=\pgfplots@glob@TMPa + %%% + % Ok, now, I have prepared everything for the new + % log basis! + \fi + % % any user-specified axis limits: \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1min\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfmathlog@\expandafter{\pgfplots@loc@TMPa}% + \csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult \fi \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1max\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfmathlog@\expandafter{\pgfplots@loc@TMPa}% + \csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult \fi % @@ -4997,13 +7171,13 @@ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmin\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfmathlog@\expandafter{\pgfplots@loc@TMPa}% + \csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1tickmin\endcsname=\pgfmathresult \fi \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmax\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfmathlog@\expandafter{\pgfplots@loc@TMPa}% + \csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult \fi % @@ -5013,91 +7187,117 @@ \else \def\pgfplots@loc@TMPb{data}% \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + % #1tick=data is handled elsewhere... \else - \expandafter\pgfplots@filter@input@ticks@with@log\expandafter{\pgfplots@loc@TMPa}% + \expandafter\pgfplots@filter@input@ticks@with@log\expandafter{\pgfplots@loc@TMPa}{#1}% \expandafter\edef\csname pgfplots@#1tick\endcsname{\pgfmathresult}% \fi \fi \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfplots@filter@input@ticks@with@log\expandafter{\pgfplots@loc@TMPa}% + \expandafter\pgfplots@filter@input@ticks@with@log\expandafter{\pgfplots@loc@TMPa}{#1}% \expandafter\edef\csname pgfplots@extra@#1tick\endcsname{\pgfmathresult}% \fi % % append logarithm to prepare coord. % + \t@pgfplots@toka={% + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfplots@if{pgfplots@disablelogfilter@#1}{% + \pgfmathfloatparsenumber{\pgfmathresult}% + \expandafter\pgfmathfloat@decompose@F\pgfmathresult\relax\c@pgf@counta + \ifnum\c@pgf@counta>2 % this clears nan, inf and -inf points. + \let\pgfmathresult=\pgfutil@empty + \def\pgfplots@unbounded@dir{#1}% + \else + \pgfmathfloattofixed{\pgfmathresult}% + \fi + }{% + \csname pgfplotsmathlog@#1@\endcsname{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + % detect unbounded coords: + \def\pgfplots@unbounded@dir{#1}% + \fi + }% + \fi + }% \pgfkeysgetvalue{/pgfplots/#1 coord trafo/.@cmd}\pgfplots@loc@TMPc \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key - \expandafter\def\csname pgfplots@prepare@#1coord\endcsname##1{% - \edef\pgfmathresult{##1}% - \ifx\pgfmathresult\pgfutil@empty - \else - \pgfplots@if{pgfplots@disablelogfilter@#1}{% - \pgfmathfloatparsenumber{##1}% - \pgfmathfloattofixed{\pgfmathresult}% - }{% - \pgfmathlog@{##1}% - }% - \fi + \expandafter\edef\csname pgfplots@prepare@#1coord\endcsname##1{% + \noexpand\edef\noexpand\pgfmathresult{##1}% + \the\t@pgfplots@toka }% \else - % This is a bit complicated... but it works. - \t@pgfplots@toka=\expandafter\expandafter\expandafter{% + % This is a bit complicated... but it works: APPEND + % the log stuff to the existing prepare method. + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{% \csname pgfplots@prepare@#1coord\endcsname{##1}% - \edef\pgfmathresult{##1}% - \ifx\pgfmathresult\pgfutil@empty - \else - \pgfplots@if{pgfplots@disablelogfilter@#1}{% - \pgfmathfloatparsenumber{##1}% - \pgfmathfloattofixed{\pgfmathresult}% - }{% - \expandafter\pgfmathlog@\expandafter{\pgfmathresult}% - }% - \fi }% - \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka}% - \expandafter\def\expandafter\pgfplots@loc@TMPa\expandafter##\expandafter1\expandafter{\pgfplots@loc@TMPa}% - \expandafter\let\csname pgfplots@prepare@#1coord\endcsname=\pgfplots@loc@TMPa + \expandafter\edef\csname pgfplots@prepare@#1coord\endcsname##1{% + \the\t@pgfplots@tokb + \the\t@pgfplots@toka + }% \fi }% \fi } \def\pgfplots@create@axis@descriptions{% - \ifpgfplots@hide@x - \else - \pgfkeysgetvalue{/pgfplots/xlabel}{\pgfplots@label@}% - \ifx\pgfplots@label@\pgfutil@empty + \begingroup + % + \pgfplots@change@pgfpoints@to@descriptioncs + % + \ifpgfplots@hide@x \else - \pgfplots@show@label{x}{\pgfplots@label@}% + \ifpgfplots@units@use% + \pgfplots@show@label{x}{\pgfplots@label@units{x}}% + \else% + \pgfkeysgetvalue{/pgfplots/xlabel}{\pgfplots@label@}% + \ifx\pgfplots@label@\pgfutil@empty + \else + \pgfplots@show@label{x}{\pgfplots@label@}% + \fi + \fi \fi - \fi - \ifpgfplots@hide@y - \else - \pgfkeysgetvalue{/pgfplots/ylabel}{\pgfplots@label@}% - \ifx\pgfplots@label@\pgfutil@empty + \ifpgfplots@hide@y \else - \pgfplots@show@label{y}{\pgfplots@label@}% + \ifpgfplots@units@use% + \pgfplots@show@label{y}{\pgfplots@label@units{y}}% + \else% + \pgfkeysgetvalue{/pgfplots/ylabel}{\pgfplots@label@}% + \ifx\pgfplots@label@\pgfutil@empty + \else + \pgfplots@show@label{y}{\pgfplots@label@}% + \fi + \fi \fi - \fi - \ifpgfplots@threedim - \ifpgfplots@hide@z - \else - \pgfkeysgetvalue{/pgfplots/zlabel}{\pgfplots@label@}% - \ifx\pgfplots@label@\pgfutil@empty + \ifpgfplots@threedim + \ifpgfplots@hide@z \else - \pgfplots@show@label{z}{\pgfplots@label@}% + \ifpgfplots@units@use% + \pgfplots@show@label{z}{\pgfplots@label@units{z}}% + \else% + \pgfkeysgetvalue{/pgfplots/zlabel}{\pgfplots@label@}% + \ifx\pgfplots@label@\pgfutil@empty + \else + \pgfplots@show@label{z}{\pgfplots@label@}% + \fi + \fi \fi \fi - \fi - % - \pgfkeysgetvalue{/pgfplots/title}\pgfplots@loc@TMPa - \ifx\pgfplots@loc@TMPa\pgfutil@empty - \else - \expandafter\pgfplots@show@title\expandafter{\pgfplots@loc@TMPa}% - \fi - \pgfplots@createlegend + % + \pgfkeysgetvalue{/pgfplots/title}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \expandafter\pgfplots@show@title\expandafter{\pgfplots@loc@TMPa}% + \fi + \pgfplots@createlegend + % + \pgfkeysvalueof{/pgfplots/extra description/.@cmd}\pgfeov% + % + \endgroup } \def\pgfplots@datascaletrafo@undoshift@x#1{% @@ -5130,12 +7330,12 @@ % \pgfplots@datascaletrafo@fromfixed@x \def\pgfplots@datascaletrafo@x#1{% \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@x}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \pgfmathfloattofixed{\pgfmathresult}% \expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@x}% } \def\pgfplots@datascaletrafo@x@noshift#1{% \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@x}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \pgfmathfloattofixed{\pgfmathresult}% } % Overloaded function. @@ -5144,34 +7344,34 @@ % @see \pgfplots@datascaletrafo@x \def\pgfplots@datascaletrafo@fromfixed@x#1{% \pgfmathfloatparsenumber{#1}% - \expandafter\pgfplots@datascaletrafo@x\expandafter{\pgfmathresult}% + \pgfplots@datascaletrafo@x{\pgfmathresult}% } \def\pgfplots@datascaletrafo@y#1{% \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@y}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \pgfmathfloattofixed{\pgfmathresult}% \expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@y}% } \def\pgfplots@datascaletrafo@fromfixed@y#1{% \pgfmathfloatparsenumber{#1}% - \expandafter\pgfplots@datascaletrafo@y\expandafter{\pgfmathresult}% + \pgfplots@datascaletrafo@y{\pgfmathresult}% } \def\pgfplots@datascaletrafo@y@noshift#1{% \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@y}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \pgfmathfloattofixed{\pgfmathresult}% } \def\pgfplots@datascaletrafo@z#1{% \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@z}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \pgfmathfloattofixed{\pgfmathresult}% \expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@z}% } \def\pgfplots@datascaletrafo@fromfixed@z#1{% \pgfmathfloatparsenumber{#1}% - \expandafter\pgfplots@datascaletrafo@z\expandafter{\pgfmathresult}% + \pgfplots@datascaletrafo@z{\pgfmathresult}% } \def\pgfplots@datascaletrafo@z@noshift#1{% \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@z}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \pgfmathfloattofixed{\pgfmathresult}% } % INVERSE transformation x = T^{-1}( X ) @@ -5309,6 +7509,115 @@ \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% } +% Defines '#1' to be a macro which, upon execution, draws the color +% bar for the current axis. It also handles any required style +% inheritance and option preparation issues. +% +% The important thing is: the macro is expected to be invoked after +% the current TeX group (scope). Thus, the complete state is +% represented inside of '#1' (and maybe some global variables). +\def\pgfplots@colorbar@move@outside@scope@with@globalmacro#1{% + \pgfplotspointbbdiagonal + \edef\pgfplots@loc@TMPa{\the\pgf@x}% + \edef\pgfplots@loc@TMPb{\the\pgf@y}% + \pgfkeyslet{/pgfplots/parent axis width}{\pgfplots@loc@TMPa}% + \pgfkeyslet{/pgfplots/parent axis height}{\pgfplots@loc@TMPb}% + % + \pgfnodealias{parent axis}{current axis}% + % we have to do a lot of work to move *some* of the current + % settings out of the current TeX group: + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa + \expandafter\pgfplotscolormapserializetomacro\expandafter{\pgfplots@loc@TMPa}{\pgfplots@serializedcolormap}% + \toks0=\expandafter{\pgfplots@serializedcolormap}% + % + % FIXME : + % I would really prefer to find a different way to move these + % variables out of the current scope. But expansion lead to + % mistakes with '#' characters ... :-( + % I use these no-name globals in the hope they might be used + % in another place as well. + {\globaldefs=1 + \pgfkeysgetvalue{/pgfplots/colorbar/draw/.@cmd}\pgfplots@savedstyle@colorbar@draw + \pgfkeysgetvalue{/pgfplots/every colorbar/.@cmd}\pgfplots@savedstyle@colorbar + \pgfkeysgetvalue{/pgfplots/colorbar shift/.@cmd}\pgfplots@savedstyle@colorbarshift + \pgfkeysgetvalue{/pgfplots/every tick/.@cmd}\pgfplots@savedstyle@tick + \pgfkeysgetvalue{/pgfplots/every minor tick/.@cmd}\pgfplots@savedstyle@minortick + \pgfkeysgetvalue{/pgfplots/every major tick/.@cmd}\pgfplots@savedstyle@majortick + \pgfkeysgetvalue{/pgfplots/every axis grid/.@cmd}\pgfplots@savedstyle@grid + \pgfkeysgetvalue{/pgfplots/every minor grid/.@cmd}\pgfplots@savedstyle@minorgrid + \pgfkeysgetvalue{/pgfplots/every major grid/.@cmd}\pgfplots@savedstyle@majorgrid + \pgfkeysgetvalue{/pgfplots/every tick label/.@cmd}\pgfplots@savedstyle@ticklabel + \pgfkeysgetvalue{/pgfplots/every tick label/.@cmd}\pgfplots@savedstyle@ticklabel + }% + % + \xdef#1{% + \noexpand\begingroup + \the\toks0 % restore colormap definition + % restore relevant styles and variables: + \noexpand\pgfkeyslet{/pgfplots/colorbar/draw/.@cmd} {\noexpand\pgfplots@savedstyle@colorbar@draw}% + \noexpand\pgfkeyslet{/pgfplots/colorbar shift/.@cmd} {\noexpand\pgfplots@savedstyle@colorbarshift}% + \noexpand\pgfkeyslet{/pgfplots/every colorbar/.@cmd} {\noexpand\pgfplots@savedstyle@colorbar}% + \noexpand\pgfkeyslet{/pgfplots/every tick/.@cmd} {\noexpand\pgfplots@savedstyle@tick}% + \noexpand\pgfkeyslet{/pgfplots/every minor tick/.@cmd} {\noexpand\pgfplots@savedstyle@minortick}% + \noexpand\pgfkeyslet{/pgfplots/every major tick/.@cmd} {\noexpand\pgfplots@savedstyle@majortick}% + \noexpand\pgfkeyslet{/pgfplots/every axis grid/.@cmd} {\noexpand\pgfplots@savedstyle@grid}% + \noexpand\pgfkeyslet{/pgfplots/every minor grid/.@cmd} {\noexpand\pgfplots@savedstyle@minorgrid}% + \noexpand\pgfkeyslet{/pgfplots/every major grid/.@cmd} {\noexpand\pgfplots@savedstyle@majorgrid}% + \noexpand\pgfkeyslet{/pgfplots/every tick label/.@cmd} {\noexpand\pgfplots@savedstyle@ticklabel}% + \noexpand\pgfkeyssetvalue{/pgfplots/point meta min}{\pgfplots@axiswide@metamin}% + \noexpand\pgfkeyssetvalue{/pgfplots/point meta max}{\pgfplots@axiswide@metamax}% + \noexpand\pgfkeyssetvalue{/pgfplots/colormap name}{\pgfkeysvalueof{/pgfplots/colormap name}}% + \noexpand\pgfkeyssetvalue{/pgfplots/parent axis width}{\pgfkeysvalueof{/pgfplots/parent axis width}}% + \noexpand\pgfkeyssetvalue{/pgfplots/parent axis height}{\pgfkeysvalueof{/pgfplots/parent axis height}}% + \noexpand\pgfkeyssetvalue{/pgfplots/colorbar/width}{\pgfkeysvalueof{/pgfplots/colorbar/width}}% + \noexpand\pgfplots@colorbar@define@hook% + \noexpand\pgfkeysvalueof{/pgfplots/colorbar/draw/.@cmd}\noexpand\pgfeov + \noexpand\endgroup + \noexpand\pgfnodealias{current colorbar axis}{current axis}% + \noexpand\pgfnodealias{current axis}{parent axis}% + }% +}% +\let\pgfplots@colorbar@position@hook\relax +\def\pgfplots@colorbar@define@hook{% + \def\pgfplots@colorbar@position@hook{% + % I patch \pgfplots@at... + \let\pgfplots@at@orig=\pgfplots@at + % + % ... and I patch \pgfplotspointdescriptionxy (but only INSIDE + % of \pgfplots@at) ... + \let\pgfplotspointdescriptionxy@orig=\pgfplotspointdescriptionxy + \let\pgfplotsqpointdescriptionxy@orig=\pgfplotsqpointdescriptionxy + \def\pgfplots@colorbar@position@prepare@CS{% + % ... which needs to set up ONLY \pgfplotspoint@bb@@@, + % nothing more. + \pgfpointanchor{parent axis}{south west}% + \edef\pgfplotspoint@bb@@@{% + {\the\pgf@x}% + {\the\pgf@y}% + {\pgfkeysvalueof{/pgfplots/parent axis width}}% + {\pgfkeysvalueof{/pgfplots/parent axis height}}% + }% + }% + % + % Install replacements: + \def\pgfplots@at{% + \begingroup + \def\pgfplotspointdescriptionxy########1########2{% + \pgfplots@colorbar@position@prepare@CS + \pgfplotspointdescriptionxy@orig{########1}{########2}% + }% + \def\pgfplotsqpointdescriptionxy########1########2{% + \pgfplots@colorbar@position@prepare@CS + \pgfplotsqpointdescriptionxy@orig{########1}{########2}% + }% + \pgfplots@deprecated@anchorsfalse + \pgfplots@change@pgfpoints@to@descriptioncs + \pgf@process{\pgfplots@at@orig}% + \endgroup + }% + }% +}% + % Parses all options in #1 which are known in the currently active families. % % The result will be stored back into the TikZ-style named #1 without @@ -5360,26 +7669,34 @@ % #1: macro % #2: style name \long\def\pgfplots@append@keymacro@to@style#1#2{% - \t@pgfplots@toka={#2/.append style=}% - \t@pgfplots@tokb=\expandafter{#1}% - \edef\pgfplots@setkeys@TMP{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}% - \expandafter\pgfplotsset\expandafter{\pgfplots@setkeys@TMP}% + \ifx#1\pgfutil@empty + \else + \t@pgfplots@toka={#2/.append style=}% + \t@pgfplots@tokb=\expandafter{#1}% + \edef\pgfplots@setkeys@TMP{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}% + \expandafter\pgfplotsset\expandafter{\pgfplots@setkeys@TMP}% + \fi %\pgfplots@message{tikzstyle{#2}+=[#1]}% } % #1: macro % #2: style name \long\def\pgfplots@set@keymacro@to@style#1#2{% - \t@pgfplots@toka={#2/.style=}% - \t@pgfplots@tokb=\expandafter{#1}% - \edef\pgfplots@setkeys@TMP{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}% - \expandafter\pgfplotsset\expandafter{\pgfplots@setkeys@TMP}% + \ifx#1\pgfutil@empty + \pgfplotsset{#2/.code={{}}}% + \else + \t@pgfplots@toka={#2/.style=}% + \t@pgfplots@tokb=\expandafter{#1}% + \edef\pgfplots@setkeys@TMP{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}% + \expandafter\pgfplotsset\expandafter{\pgfplots@setkeys@TMP}% + \fi %\pgfplots@message{tikzstyle{#2}=[#1]}% } % backwards compatibility: \let\prettyprintnumber=\pgfmathprintnumber% + \def\pgfplots@set@options#1{% \pgfplots@bb@isactivetrue \pgfplots@curplot@threedimfalse @@ -5394,22 +7711,18 @@ % Temporarily assign families to 'name' and 'alias' options. % This allows to get the names - they should not be appended to % 'every axis'! - \pgfkeys{% - /tikz/name/.belongs to family=/pgfplots/naming commands, - /tikz/alias/.belongs to family=/pgfplots/naming commands, - % - % - /pgf/key filter handlers/append filtered to/.install key filter handler=\pgfplots@rmopts, - }% + \pgfkeyssetfamily{/tikz/name}{/pgfplots/naming commands}% + \pgfkeyssetfamily{/tikz/alias}{/pgfplots/naming commands}% + \pgfkeyssetfamily{/tikz/variable}{/pgfplots}% + \pgfkeysinstallkeyfilterhandler{/pgf/key filter handlers/append filtered to}{\pgfplots@rmopts}% + % \let\tikz@alias=\pgfutil@empty \let\tikz@fig@name=\pgfutil@empty % % Step 1: acquire ONLY 'xmode' and 'ymode' (necessary to decide % which axis style shall be loaded): \let\pgfplots@rmopts=\pgfutil@empty - \pgfkeysinstallkeyfilter - {/pgf/key filters/active families or no family} - {{/pgf/key filters/false}{/pgf/key filters/false}} + \pgfkeysinstallkeyfilter{/pgf/key filters/active families and known}{}% % \pgfqkeysactivatesinglefamilyandfilteroptions{/pgfplots/scale}% {/pgfplots} @@ -5418,14 +7731,10 @@ % % Step 2: parse any pgfplots options out of styles. \pgfkeysactivatefamily{/pgfplots/style commands}% - \pgfkeysinstallkeyfilter - {/pgf/key filters/active families or no family}% DEBUG} - {{/pgf/key filters/is descendant of=/pgfplots}% for keys without family - {/pgf/key filters/false}% for unknown keys - }% + \pgfkeysinstallkeyfilter{/pgf/key filters/active families or descendants of}{/pgfplots} % \pgfkeysactivatefamilies - {/pgfplots,/pgfplots/naming commands,/pgfplots/tick,/pgfplots/legend,/pgfplots/descriptions,/pgfplots/scale} + {/pgfplots,/pgfplots/naming commands,/pgfplots/tick,/pgfplots/legend,/pgfplots/scale}%/pgfplots/descriptions,} {\pgfplots@deactivefamiliescmd}% \pgfplots@set@keys@from@tikz@style{every axis}% \pgfkeysdeactivatefamily{/pgfplots/scale}% @@ -5487,16 +7796,22 @@ % be set in its context. % \pgfkeysactivatefamily{/pgfplots/legend}% + % this special treatmeant allows the (usually illegal construction) + % 'legend style={legend pos=outer north east}': + \pgfkeysdef{/pgfplots/every axis legend/.append style}{\pgfkeysalso{##1}}% + % \pgfplots@set@keys@from@tikz@style{every axis legend}% \pgfkeysdeactivatefamily{/pgfplots/legend}% % - % - \pgfkeysactivatefamily{/pgfplots/descriptions}% - \pgfplots@set@keys@from@tikz@style{every axis label}% - \pgfplots@set@keys@from@tikz@style{every axis x label}% - \pgfplots@set@keys@from@tikz@style{every axis y label}% - \pgfplots@set@keys@from@tikz@style{every axis title}% - \pgfkeysdeactivatefamily{/pgfplots/descriptions}% + % FIXME : VERIFY! + % If I am not mistaken, these statements are only useful to allow + % 'xlabel style={xlabel=$x$}' --- which is not intuitive anyway. + %\pgfkeysactivatefamily{/pgfplots/descriptions}% + % \pgfplots@set@keys@from@tikz@style{every axis label}% + % \pgfplots@set@keys@from@tikz@style{every axis x label}% + % \pgfplots@set@keys@from@tikz@style{every axis y label}% + % \pgfplots@set@keys@from@tikz@style{every axis title}% + %\pgfkeysdeactivatefamily{/pgfplots/descriptions}% % \pgfkeysactivatefamily{/pgfplots/tick}% \pgfplots@set@keys@from@tikz@style{every tick}% @@ -5513,18 +7828,21 @@ % \pgfkeysdeactivatefamily{/pgfplots}% %-------------------------------------------------- % - \pgfkeysactivatefamily{/pgfplots/descriptions}% + % Attention: do NOT set the description styles here! Setting them + % must be postponed until |every 3d description| has been set (to + % ensure that \axis[<options>] take higher precedence). + %\pgfkeysactivatefamily{/pgfplots/descriptions}% \pgfkeysactivatefamily{/pgfplots/tick}% \pgfplots@set@keys@from@tikz@style{every x tick label}% \pgfplots@set@keys@from@tikz@style{every y tick label}% \pgfplots@set@keys@from@tikz@style{every tick label}% \pgfkeysdeactivatefamily{/pgfplots/tick}% - \pgfkeysdeactivatefamily{/pgfplots/descriptions}% + %\pgfkeysdeactivatefamily{/pgfplots/descriptions}% % % Step 3: Set all remaining options of '#1'. They should have % highest precedence. \pgfkeysactivatefamilies - {/pgfplots,/pgfplots/tick,/pgfplots/legend,/pgfplots/descriptions}% + {/pgfplots,/pgfplots/tick,/pgfplots/legend}%,/pgfplots/descriptions}% {\pgfplots@deactivefamiliescmd}% \expandafter \pgfplots@set@keys@and@append@remaining@to@style @@ -5532,7 +7850,7 @@ {\pgfplots@remaining@input}% {every axis}% \pgfplots@deactivefamiliescmd -%\pgfkeysgetvalue{/tikz/every axis/.@cmd}\pgfplots@loc@TMPa +%\pgfkeysgetvalue{/pgfplots/every axis/.@cmd}\pgfplots@loc@TMPa %\message{every axis is now '\meaning\pgfplots@loc@TMPa'}% % \pgfkeysdeactivatefamily{/pgfplots/style commands}% @@ -5565,10 +7883,7 @@ \global\let\pgfplots@firstplot@coords@y=\pgfutil@empty \global\let\pgfplots@firstplot@coords@z=\pgfutil@empty \fi - \pgfkeysdef{/pgfplots/.unknown}{% - \let\pgfplots@searchname=\pgfkeyscurrentname - \pgfkeysalso{/tikz/\pgfplots@searchname={##1}}% - }% + \pgfkeysalso{/pgfplots/.search also=/tikz}% } \def\pgfplots@install@abbrev@commands{ @@ -5582,6 +7897,7 @@ \let\addplot=\pgfplots@addplot \let\plot=\addplot % + % \def\logten{2.3025851}% \def\reciproclogten{0.434294}% % @@ -5605,7 +7921,9 @@ }% % \let\legend=\pgfplots@command@legend + \let\addlegendimage=\pgfplots@rememberplotspec \let\addlegendentry=\pgfplots@addlegendentry + \let\addlegendentryexpanded=\pgfplots@addlegendentryexpanded } \def\pgfplots@environment{% @@ -5629,7 +7947,6 @@ \newif\ifpgfplots@apply@datatrafo@z \newif\ifpgfplots@apply@datatrafo \newif\ifpgfplots@datascaletrafo@initialised -\newif\ifpgfplots@draw@at@end % Extracts single components of an entry of % \pgfplots@stored@plotlist @@ -5657,20 +7974,28 @@ % The implementation for \label{foo} after \addplot. It allows to % \ref{foo} (it inserts the 'legend image code'). % +% With +% \addplot[scatter/classes={a={}}] ... ; +% \label[a]{my label} +% you can reference scatter/classes labels. +% % I only need to overwrite '\label'; the rest is done by LaTeX. % % THIS IS INCOMPATIBLE WITH plain TeX and ConTeXt! Don't use it, it % doesn't hurt. -\def\pgfplots@plot@label#1{% - \ifx\pgfplots@last@plot@style\pgfutil@empty - \pgfplots@error{Can't create \string\label{#1}: it needs to be called after \string\addplot.}% - \else +\def\pgfplots@plot@label{\pgfutil@ifnextchar[{\pgfplots@plot@label@}{\pgfplots@plot@label@[]}}% +\def\pgfplots@plot@label@[#1]#2{% + \ifpgfplots@has@label@information \begingroup % I'd like to get all options which are INDEPENDENT of % pgfplots. Idea: expand all /pgfplots-keys and collect % everything which belongs NOT to /pgfplots. This is the % completely expanded rest. At least, I hope so and it appears % to work. + % + % FIXME : this was a good approach before. Now, there ARE + % /pgfplots keys which should be maintained. So: maintain all + % of them! Why should that pose any problems? \pgfkeysinstallkeyfilter {/pgf/key filters/and} {{/pgf/key filters/is descendant of=/pgfplots}% @@ -5678,31 +8003,60 @@ \def\pgfplots@label@tikzopts{}% \pgfkeysinstallkeyfilterhandler{/pgf/key filter handlers/append filtered to}{\pgfplots@label@tikzopts}% \def\pgfplots@loc@TMPa{\pgfqkeysfiltered{/tikz}}% - \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@last@plot@style}% + \expandafter\let\expandafter\pgfplots@loc@TMPb\csname pgfplots@last@plot@style@#1\endcsname + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@loc@TMPb}% % \pgfkeysgetvalue{/pgfplots/every crossref picture/.@cmd}{\pgfplots@crossref@pic}% \pgfkeysgetvalue{/pgfplots/legend image code/.@cmd}{\pgfplots@curlegendcode}% \t@pgfplots@toka=\expandafter{\pgfplots@curlegendcode current plot style\pgfeov}% \t@pgfplots@tokb=\expandafter{\pgfplots@label@tikzopts}% \t@pgfplots@tokc=\expandafter{\pgfplots@crossref@pic\pgfeov}% - % 1. prepare /pgfplots/refstyle={#1}: + % 1. prepare /pgfplots/refstyle={#2}: + \if@filesw \immediate\write\@auxout{% \noexpand\expandafter\noexpand\gdef - \noexpand\csname pgfplots@labelstyle@#1\noexpand\endcsname{\the\t@pgfplots@tokb}% + \noexpand\csname pgfplots@labelstyle@#2\noexpand\endcsname{\the\t@pgfplots@tokb}% }% - % 2. prepare \ref{#1} and \pageref{#1}: + % 2. prepare \ref{#2} and \pageref{#2}: + % + % There are several nasty things to consider: + % a) macro expansion. I did not really understand what happens + % here... I only understand that it is enough if the new label + % makes it into the .aux file of latex. That is sufficient for + % me! So, I converted the label command to a string using the + % \meaning functionality. + % + % b) \protect . If the resulting \ref{} command occurs within + % a "moving argument" like \caption or so, we need to use + % proper '\protect'ion. + % + % this here is the low-level implementation of \ref{#2}. Write it into + % the .aux file: + \immediate\write\@auxout{% + \noexpand\expandafter\noexpand\gdef + \noexpand\csname pgfplots@show@ref@#2\noexpand\endcsname{% + \noexpand\begingroup + \noexpand\pgfplots@define@currentplotstyle@as{\the\t@pgfplots@tokb}% + \noexpand\pgfkeysdef{/pgfplots/every crossref picture}{\the\t@pgfplots@tokc}% + \noexpand\tikz[/pgfplots/every crossref picture]{\the\t@pgfplots@toka}% + \noexpand\endgroup% + }% + }% + \fi + % This here is the high-level implementation \ref{#2}. + % The \protect handles the cases of "moving arguments": \edef\pgfplots@loc@TMPa{% - \noexpand\begingroup - \noexpand\pgfkeysdef{/tikz/current plot style}{\noexpand\pgfkeysalso{\the\t@pgfplots@tokb}}% - \noexpand\pgfkeysdef{/pgfplots/every crossref picture}{\the\t@pgfplots@tokc}% - \noexpand\tikz[/pgfplots/every crossref picture]{\the\t@pgfplots@toka}% - \noexpand\endgroup% + \noexpand\expandafter + \noexpand\protect + \noexpand\csname pgfplots@show@ref@#2\noexpand\endcsname }% \pgfplots@command@to@string{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPa}% \global\let\pgfplots@glob@TMPb=\pgfplots@loc@TMPa \endgroup \let\@currentlabel=\pgfplots@glob@TMPb - \pgfplots@original@LaTeX@label{#1}% + \pgfplots@original@LaTeX@label{#2}% + \else + \pgfplots@error{Can't create \string\label{#2}: it needs to be called after \string\addplot.}% \fi }% @@ -5710,6 +8064,64 @@ \def\pgfplots@interruptdatabb{\pgfplots@bb@isactivefalse} \def\endpgfplots@interruptdatabb{\pgfplots@bb@isactivetrue} +% A helper method which defines +% `/tikz/current plot style' to be {#1} --- with properly set key +% search paths. +\def\pgfplots@define@currentplotstyle@as#1{% + \pgfkeysdef{/tikz/current plot style}{% + % make sure the search path is set. + % Inside of an axis, this is already ok. + \pgfkeysifdefined{/pgfplots/.unknown/.@cmd}% + {\relax}% search path in /pgfplots is already set + {% +%\message{DEBUG: re-initializing /pgfplots/.search also=/tikz in current plot style!}% + \pgfkeysalso{/pgfplots/.search also=/tikz}% + }% + % + % Make sure that + % \addplot[every mark/.append style={...}] + % or something like that is interpreted as /tikz/ key: + \pgfplots@invoke@pgfkeyscode{/handler config/full or existing/.@cmd}{}% restrict + % set both, pgfplots and tikz keys: + \pgfplotsset{#1}% + \pgfplots@invoke@pgfkeyscode{/handler config/all/.@cmd}{}% unrestrict + % + % remember these technical things: they will be + % reset in \draw, so we will need to re-activate + % them. + % The re-activation is done in 'every path' (see below). + % FIXME : is that portable!? + \pgfplots@assert@tikzinternal@exists{tikz@options}% + \pgfplots@assert@tikzinternal@exists{tikz@mode}% + \let\pgfplots@drawoptions=\tikz@options + \let\pgfplots@drawmodes=\tikz@mode + % + % As of February 22, the final plot processing uses + % foreach stored \addplot command : + % \scope[current plot style] + % <finalize coord stream> + % \draw <finalized coord stream> + % \endscope + % -> the problem: \draw reset the modes 'draw,fill' etc which + % have been set in \scope! + % -> ad-hoc-solution: + % restore the modes manually. + % + % This is done here. The \pgfplots@drawmodes is ONLY set + % inside of this scope, so we can check for that particular + % case: + \pgfkeys{/tikz/every path/.append code={% + \pgfutil@ifundefined{pgfplots@drawmodes}% + {\relax}% + {% + \let\tikz@mode=\pgfplots@drawmodes +% \let\tikz@options=\pgfplots@drawoptions + }% + }% + }% + }% +}% + % % \begin{axis}[#1] : % @@ -5735,6 +8147,7 @@ % - The same for 'max'. % - \pgfplots@invalidrange@[xyz]min % \pgfplots@invalidrange@[xyz]max +% \pgfplots@invalidrange@meta[max,min] % A value which is used for the axis limits before the % limit computation starts. % - \pgfplots@data@[xyz]min @@ -5750,9 +8163,13 @@ % in the original data range. % - \pgfplots@metamin % \pgfplots@metamax +% \pgfplots@axiswide@metamin +% \pgfplots@axiswide@metamax % - if meta data is active, these macros will contain the upper -% and lower bound for meta data. +% and lower bound for meta data, the first two on a per-plot +% basis the latter to globally for the complete axis. % - will be assigned globally. +% - meta data is ALWAYS collected in floating point. % - \pgfplots@numplots % - A count register indexing the current plot counter. Assigned % globally. @@ -5834,7 +8251,7 @@ % '1pt' here as well. \pgfsetxvec{\pgfqpoint{1pt}{0pt}}% \pgfsetyvec{\pgfqpoint{0pt}{1pt}}% - \pgfsetzvec{\pgfqpoint{1.2pt}{1.2pt}}% + \pgfsetzvec{\pgfqpoint{0pt}{0pt}}% % \pgfplots@set@options{#1}% % @@ -5846,9 +8263,9 @@ % -------------------- % Option preprocessing % -------------------- - \pgfplots@prepare@coord@filtering@for x - \pgfplots@prepare@coord@filtering@for y - \pgfplots@prepare@coord@filtering@for z + \pgfplots@prepare@coord@filtering@for x% + \pgfplots@prepare@coord@filtering@for y% + \pgfplots@prepare@coord@filtering@for z% \ifpgfplots@apply@datatrafo \pgfplots@datascaletrafo@initialisedfalse \else @@ -5882,6 +8299,10 @@ \def\pgfplots@invalidrange@zmin{16300}% \def\pgfplots@invalidrange@zmax{-16300}% \fi + \pgfmathfloatcreate{1}{1.0}{2147483645}% + \let\pgfplots@invalidrange@metamin=\pgfmathresult + \pgfmathfloatcreate{2}{1.0}{2147483645}% + \let\pgfplots@invalidrange@metamax=\pgfmathresult % % These numbers will ONLY be filled for linear axis! \global\let\pgfplots@data@xmin=\pgfplots@invalidrange@xmin @@ -5890,6 +8311,8 @@ \global\let\pgfplots@data@ymax=\pgfplots@invalidrange@ymax \global\let\pgfplots@data@zmin=\pgfplots@invalidrange@zmin \global\let\pgfplots@data@zmax=\pgfplots@invalidrange@zmax + \global\let\pgfplots@axiswide@metamin=\pgfplots@invalidrange@metamin + \global\let\pgfplots@axiswide@metamax=\pgfplots@invalidrange@metamax % \pgfplots@autocompute@all@limitstrue \ifx\pgfplots@xmin\pgfutil@empty @@ -5931,29 +8354,30 @@ \pgfplots@autocompute@all@limitsfalse \fi % + % check for axis-wide 'point meta min' : + \pgfkeysgetvalue{/pgfplots/point meta min}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\pgfplots@axiswide@metamin@autocompute{1}% + \else + \def\pgfplots@axiswide@metamin@autocompute{0}% + \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \global\let\pgfplots@axiswide@metamin=\pgfmathresult + \fi + \pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\pgfplots@axiswide@metamax@autocompute{1}% + \else + \def\pgfplots@axiswide@metamax@autocompute{0}% + \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \global\let\pgfplots@axiswide@metamax=\pgfmathresult + \fi + % % -------------------- % Start axis: - % either postponed to \end or directly. + % start survey phase! % -------------------- % - % Since I've introduced a public \numplots macro, I should - % make sure it's filled correctly. - % All versions from now on will store plots until \end{axis}: - \pgfplots@draw@at@endtrue - % - \ifpgfplots@collect@firstplot@astick - \pgfplots@draw@at@endtrue - \fi - \ifpgfplots@apply@datatrafo - % ALWAYS TRUE. This allows to use inline plots because the data - % scale transformation will be applied after I know that it should - % be disabled. - \pgfplots@draw@at@endtrue - \fi \ifpgfplots@stackedmode - % Stacked plots require special attention: they are drawn in - % REVERSE order. - \pgfplots@draw@at@endtrue \else % we have no stacked plots and thus no reversing. \pgfplots@stacked@reversefalse @@ -5963,18 +8387,14 @@ \let\pgfplots@original@LaTeX@label=\label \let\label=\pgfplots@plot@label }% - \global\let\pgfplots@last@plot@style=\pgfutil@empty + % + \global\pgfplots@has@label@informationfalse % % any \path command is invalid inside of an axis. % Use \axispath instead: \def\numplots{\the\pgfplots@numplots}% \let\path=\pgfplots@replacement@for@tikz@path \let\closedcycle=\pgfplots@path@closed@cycle - \ifpgfplots@draw@at@end - \else - \expandafter% remove the '\fi' - \pgfplots@BEGIN@init@and@draw@axis - \fi } % \end{axis} : @@ -5990,82 +8410,65 @@ \let\plot=\pgfplots@orig@plot % %\end{axis}: + % + % create a leight-weight 'current axis' node for anchor references + % (which may happen during both, the axis descriptions or any + % path/plot commands). + \pgfmultipartnode{pgfplots@low@level@shape@INNER}{image}{current axis}{\pgfusepath{discard}}% + % % -------------------- % All plotting commands have been read. % -> apply postponed drawing commands! % -------------------- - \ifpgfplots@draw@at@end% ALWAYS TRUE - this is obsolete - \def\pgfplots@nextcommand{% - \pgfplots@BEGIN@init@and@draw@axis - \pgfplots@stacked@initialise - \global\pgfplotslistnewempty\pgfplots@stored@markerlist + \pgfplots@BEGIN@init@and@draw@axis + \pgfplots@stacked@initialise + \pgfplots@install@local@bar@handlers + \global\pgfplotslistnewempty\pgfplots@stored@markerlist + \ifpgfplots@stacked@reverse + % This here applies any scaling trafos and assembles a + % NEW \pgfplots@stored@plotlist! + \pgfplots@stacked@finalize@stored@plots + \fi + \pgfplotslistforeach\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{% + \expandafter\pgfplots@stored@plotlist@EXTRACTENTRY\pgfplots@loc@TMPa +%\message{Processing stored plot with precommand '\meaning\pgfplots@stored@current@precmd'; pgfplots@plotcmd '\meaning\pgfplots@stored@current@cmd' postcommand '\meaning\pgfplots@stored@current@postcmd'}% + % The precmd sets all required variables needed to + % finalize a plot. + % @see the stream preparation routines. + \pgfplots@stored@current@precmd + \ifx\pgfplots@stored@current@cmd\pgfutil@empty + \pgfplots@stored@current@data% + \else + % this code here means we REALLY have a plotting + % command! + \scope[current plot style] % this does set BOTH pgfplots and tikz options. + % + % de-activate the FPU here! I fear its number + % format may cause errors when used in low-level + % routines. + \pgfkeys{/pgf/fpu=false}% + % \ifpgfplots@stacked@reverse - % This here applies any scaling trafos and assembles a - % NEW \pgfplots@stored@plotlist! - \pgfplots@stacked@finalize@stored@plots + % has already been processed above, in \pgfplots@stacked@finalize@stored@plots. + \pgfplots@stacked@draw@reversed@plot + \else + % modifies \pgfplots@stored@markerlist if necessary. + \expandafter\pgfplots@coord@stream@finalize@storedcoords@START\pgfplots@stored@current@data\pgfplots@EOI \fi - \pgfplotslistforeach\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{% - \expandafter\pgfplots@stored@plotlist@EXTRACTENTRY\pgfplots@loc@TMPa -%\message{Processing stored plot with precommand '\meaning\pgfplots@stored@current@precmd'; pgfplots@plotcmd '\meaning\pgfplots@stored@current@cmd' postcommand '\meaning\pgfplots@stored@current@postcmd'}% - % The precmd sets all required variables needed to - % finalize a plot. - % @see the stream preparation routines. - \ifx\pgfplots@stored@current@cmd\pgfutil@empty - \pgfplots@stored@current@precmd - \pgfplots@stored@current@data% - \else - % this code here means we REALLY have a plotting - % command! - \pgfplots@stored@current@precmd - % de-activate the FPU here! I fear its number - % format may cause errors when used in low-level - % routines. - \pgfkeys{/pgf/fpu=false}% - % - \ifpgfplots@stacked@reverse - % has already been processed above, in \pgfplots@stacked@finalize@stored@plots. - \pgfplots@stacked@draw@reversed@plot - \else - % modifies \pgfplots@stored@markerlist if necessary. - \expandafter\pgfplots@coord@stream@finalize@storedcoords@START\pgfplots@stored@current@data\pgfplots@EOI - \fi - \fi - \pgfplots@stored@current@postcmd - }% - \global\pgfplotslistnewempty\pgfplots@stored@plotlist% delete contents. - }% - \else - \let\pgfplots@nextcommand=\relax - \fi - \pgfplots@nextcommand + \endscope + \fi + \pgfplots@stored@current@postcmd + }% + \global\pgfplotslistnewempty\pgfplots@stored@plotlist% delete contents. + % \pgfplots@END@init@and@draw@axis % + \pgfplots@create@axis@descriptions % - \begingroup - % set coordinate system to (0,0) rectangle (1,1) for descriptions: - \pgftransformshift{\pgfplotspointsouthwest}% - % This here is a preparation macro for \pgfplots@low@level@shape@INNER. - % It applies the shift to the ORIGIN as well. - % It will ONLY be expanded if someone uses origin-anchors - % inside of axis descriptions. - \def\pgfplotspointORIGIN@tmp{% - \pgfpointdiff - {\pgfplotspointsouthwest}% - {\pgfqpoint{\pgfplots@ZERO@x}{\pgfplots@ZERO@y}}% - }% - \pgfsetxvec{\pgfplotspointxaxis}% - \pgfsetyvec{\pgfplotspointyaxis}% - % - % create a leight-weight 'current axis' node for anchor references. - \pgfmultipartnode{pgfplots@low@level@shape@INNER}{south west}{current axis}{\pgfusepath{discard}}% - % - \pgfplots@create@axis@descriptions - \pgfkeysvalueof{/pgfplots/extra description/.@cmd}\pgfeov% - \endgroup \endtikzpicture% \begingroup % Protocol sizes for the axis-shape. - % I fear that needs to be done globally, do avoid all those + % That needs to be done globally, do avoid all those % \endgroup's in and after \endpgfinterruptpicture ... \ifdim\pgf@picmaxx=-16000pt\relax% \pgf@picmaxx=0pt\relax% @@ -6077,7 +8480,11 @@ \xdef\pgfplots@saveddimen@picminx{\the\pgf@picminx}% \xdef\pgfplots@saveddimen@picminy{\the\pgf@picminy}% % - \pgfplotspointsouthwest + \ifpgfplots@deprecated@anchors + \pgfplotspointminminmin + \else + \pgfplotspointbblowerleft + \fi \pgf@xa=\pgf@x \advance\pgf@xa by-\pgf@picminx \xdef\pgfplots@savedanchor@inner@lowerleft@x{\the\pgf@xa}% @@ -6086,27 +8493,47 @@ \advance\pgf@xa by-\pgf@picminy \xdef\pgfplots@savedanchor@inner@lowerleft@y{\the\pgf@xa}% % - \pgf@xa=\pgfplots@ZERO@x - \advance\pgf@xa by-\pgf@picminx - \xdef\pgfplots@ZERO@x{\the\pgf@xa}% - % - \pgf@xa=\pgfplots@ZERO@y - \advance\pgf@xa by-\pgf@picminy - \xdef\pgfplots@ZERO@y{\the\pgf@xa}% + \pgfplotspointaxisorigin + \advance\pgf@x by-\pgf@picminx + \advance\pgf@y by-\pgf@picminy + \xdef\pgfplotspointaxisorigin{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}% \endgroup \endpgfinterruptpicture \egroup\egroup% end of pgfnodepartimagebox % \let\tikz@fig@name=\pgfplots@fig@name \tikz@fig@mustbenamed + % + % restore any shift transformations provided to an axis. + % These would be lost otherwise. + \pgftransformshift{\pgfplots@savedtransformshift}% + % + % allow positioning of colorbars with this hook. + % It is \relax unless this here is a color bar axis. + % Its intention is to re-define `\pgfplots@at': + \pgfplots@colorbar@position@hook% + % \pgftransformshift{\pgfplots@at}% - \pgfmultipartnode{pgfplots@low@level@shape}{\pgfplots@anchorname}{\tikz@fig@name}{\pgfusepath{discard}}% + % + \ifpgfplots@deprecated@anchors + \pgfplots@restore@deprecated@lowlevel@shape + \pgfmultipartnode{pgfplots@low@level@shape@deprecated}{\pgfplots@anchorname}{\tikz@fig@name}{\pgfusepath{discard}}% + \else + \pgfmultipartnode{pgfplots@low@level@shape}{\pgfplots@anchorname}{\tikz@fig@name}{\pgfusepath{discard}}% + \fi \pgfplots@fig@alias \pgfnodealias{current axis}{\tikz@fig@name}% % \pgfplots@finally@correct@child@node@positions \pgfplots@stacked@finalize + % + \ifpgfplots@colorbar + \pgfplots@colorbar@move@outside@scope@with@globalmacro{\pgfplots@glob@TMPa}% + \else + \global\let\pgfplots@glob@TMPa=\relax + \fi \endgroup + \pgfplots@glob@TMPa } % Now, we need to process all named nodes inside of our @@ -6171,7 +8598,7 @@ \def\pgfplots@environment@axis{% \pgfutil@ifnextchar[{\pgfplots@@environment@axis}{\pgfplots@@environment@axis[]}% } -\let\endpgfplots@environment@axis=\endpgfplots@environment@opt +\def\endpgfplots@environment@axis{\endpgfplots@environment@opt} \def\pgfplots@@environment@axis[#1]{% \pgfplots@environment@opt[/pgfplots/xmode=linear,/pgfplots/ymode=linear,#1]% } @@ -6179,7 +8606,7 @@ \def\pgfplots@environment@semilogxaxis{% \pgfutil@ifnextchar[{\pgfplots@@environment@semilogxaxis}{\pgfplots@@environment@semilogxaxis[]}% } -\let\endpgfplots@environment@semilogxaxis=\endpgfplots@environment@opt +\def\endpgfplots@environment@semilogxaxis{\endpgfplots@environment@opt} \def\pgfplots@@environment@semilogxaxis[#1]{% \pgfplots@environment@opt[/pgfplots/xmode=log,/pgfplots/ymode=linear,#1]% } @@ -6187,7 +8614,7 @@ \def\pgfplots@environment@semilogyaxis{% \pgfutil@ifnextchar[{\pgfplots@@environment@semilogyaxis}{\pgfplots@@environment@semilogyaxis[]}% } -\let\endpgfplots@environment@semilogyaxis=\endpgfplots@environment@opt +\def\endpgfplots@environment@semilogyaxis{\endpgfplots@environment@opt} \def\pgfplots@@environment@semilogyaxis[#1]{% \pgfplots@environment@opt[/pgfplots/xmode=linear,/pgfplots/ymode=log,#1]% } @@ -6195,7 +8622,7 @@ \def\pgfplots@environment@loglogaxis{% \pgfutil@ifnextchar[{\pgfplots@@environment@loglogaxis}{\pgfplots@@environment@loglogaxis[]}% } -\let\endpgfplots@environment@loglogaxis=\endpgfplots@environment@opt +\def\endpgfplots@environment@loglogaxis{\endpgfplots@environment@opt} \def\pgfplots@@environment@loglogaxis[#1]{% \pgfplots@environment@opt[/pgfplots/xmode=log,/pgfplots/ymode=log,#1]% } diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex index 7d08f6667cb..e69591d0683 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex @@ -30,6 +30,215 @@ % - single coordinate processing +% To be called inside of an axis as soon as the axis is ready and all +% point commands can be invoked. +\def\pgfplotspoint@initialisation{% + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@v00\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@v01\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@v10\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@v11\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@0v0\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@0v1\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@1v0\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@1v1\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@00v\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@01v\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@10v\endcsname\relax + \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@11v\endcsname\relax + % + % Installs e_x, e_y and e_z such that (0,0) is the 'south west' + % anchor of the axis and (1,1) the 'north east'. + % It is used inside of descriptions. + \def\pgfplots@install@description@xyzvec{% + % this here is also used in color bars! + \ifpgfplots@deprecated@anchors + \pgfpointadd{\pgfplotspointxaxis}{\pgfplotspointyaxis}% + \else + \pgfplotspointbbdiagonal + \fi + \pgf@xx=\pgf@x + \pgf@xy=0pt + \pgf@yx=0pt + \pgf@yy=\pgf@y + \pgf@zx=0pt + \pgf@zy=0pt + }% + \let\pgfpointxy@orig=\pgfpointxy + \let\pgfqpointxy@orig=\pgfqpointxy + \let\pgfpointxyz@orig=\pgfpointxyz + \let\pgfqpointxyz@orig=\pgfqpointxyz + % + % A point command such that (0,0) is the 'south west' and (1,1) + % the 'north east' point of an axis. + \def\pgfplotspointdescriptionxy##1##2{% + \pgf@process{% + \pgfplots@install@description@xyzvec + \pgfpointadd + {\ifpgfplots@deprecated@anchors + \pgfplotspointminminmin + \else + \pgfplotspointbblowerleft + \fi}% + {\pgfpointxy@orig{##1}{##2}}% + %I use the '@orig' variant here because descriptions may + %\let\pgfpointxy=\pgfplotspointdescriptionxy + }% + }% + % the 'q' variant: + \def\pgfplotsqpointdescriptionxy##1##2{% + \pgf@process{% + \pgfplots@install@description@xyzvec + \pgfpointadd + {\ifpgfplots@deprecated@anchors + \pgfplotspointminminmin + \else + \pgfplotspointbblowerleft + \fi}% + {\pgfqpointxy@orig{##1}{##2}}% + }% + }% + \edef\pgfplotspointunitx{\pgf@x=\the\pgf@xx\space\pgf@y=\the\pgf@xy\space}% + \edef\pgfplotspointunity{\pgf@x=\the\pgf@yx\space\pgf@y=\the\pgf@yy\space}% + \let\pgfplotsunitxlength=\pgfplots@x@veclength + \let\pgfplotsunitylength=\pgfplots@y@veclength + \let\pgfplotsunitxinvlength=\pgfplots@x@inverseveclength + \let\pgfplotsunityinvlength=\pgfplots@y@inverseveclength + \ifpgfplots@threedim + \edef\pgfplotspointunitz{\pgf@x=\the\pgf@zx\space\pgf@y=\the\pgf@zy\space}% + \let\pgfplotsunitzlength=\pgfplots@z@veclength + \let\pgfplotsunitzinvlength=\pgfplots@z@inverseveclength + \fi + % + % declare the '[xyz]ticklabel cs' + \tikzdeclarecoordinatesystem{xticklabel}{\pgfplotspointticklabelcs{x}{##1}}% + \tikzdeclarecoordinatesystem{yticklabel}{\pgfplotspointticklabelcs{y}{##1}}% + \tikzdeclarecoordinatesystem{zticklabel}{\pgfplotspointticklabelcs{z}{##1}}% + % + % does also declare the 'near xticklabel*' variants. + \pgfplotsdeclareborderanchorforticklabelaxis{x}{near xticklabel}% + \pgfplotsdeclareborderanchorforticklabelaxis{y}{near yticklabel}% + \pgfplotsdeclareborderanchorforticklabelaxis{z}{near zticklabel}% + % + \pgfkeysdef{/tikz/sloped like x axis}{\tikz@addtransform{\pgfplotstransformtoaxisdirection{x}}}% + \pgfkeysdef{/tikz/sloped like y axis}{\tikz@addtransform{\pgfplotstransformtoaxisdirection{y}}}% + \pgfkeysdef{/tikz/sloped like z axis}{\tikz@addtransform{\pgfplotstransformtoaxisdirection{z}}}% + % +}% + +% The idea here is the following: +% +% 1. A point coordinate (<x>,<y>) without units should use +% relative axis coordinate system. +% +% 2. Any other point coordinate should not be altered. +% +% Former versions installed a shift and changed e_x, e_y and +% e_z. However, that was misleading as it disabled point 2). +% So, my idea here is to replace \pgfpointxy and \pgfqpointxy +% such that they install the correct coordinate system before +% doing anything else. +\def\pgfplots@change@pgfpoints@to@descriptioncs{% + % + \let\pgfpointxy=\pgfplotspointdescriptionxy + \let\pgfqpointxy=\pgfplotsqpointdescriptionxy + % e_z is zero, so the xyz variants ignore z: + \def\pgfpointxyz##1##2##3{\pgfpointxy{##1}{##2}}% + \def\pgfqpointxyz##1##2##3{\pgfqpointxy{##1}{##2}}% + % +}% + +% \pgfplotspointticklabelcs{<axis>}{<coordinate>} +% or +% \pgfplotspointticklabelcs[<default shift>]{<axis>}{<coordinate>} +% +% Yields a point in the '<axis>ticklabel cs'. +% +% The 'xticklabel cs' is a coordinate system which expects either one +% or two coordinates. The first is the coordinate on the axis where +% x tick label will be placed (or would be placed). The first +% coordinate '0' means the lower aixs site and the value '1' the upper +% range. The second (optional) coordinate of 'xticklabel cs' is a +% shift in direction of the outer normal vector of the axis. The +% minimum shift is the largest' tick labels dimensions. If the second +% argument is omitted, the <default shift> will be used (0pt if this +% argument has been omitted as well). +% +% \pgfplotspointticklabelcs#1#2: +% #1 is the axis (either x,y or z) +% #2 is the coordinate (either <relative coord> or <relative coord>,<shift>) +% +% @see \pgfplotsvalueoflargesttickdimen +% +% This command actually boils down to a +% \pgfplotsqpointoutsideofticklabelaxisrel +% invocation which. Thus, you *can* get the *same* effect by using +% basic level commands -- and you are not restricted to the tick label +% axis. +% @see \pgfplotsqpointoutsideofaxisrel +\def\pgfplotspointticklabelcs{\pgfutil@ifnextchar[% + {\pgfplotspointticklabelcs@opt}% + {\pgfplotspointticklabelcs@opt[0pt]}% +}% +\def\pgfplotspointticklabelcs@opt[#1]#2#3{% + \pgfutil@in@{,}{#3}% + \ifpgfutil@in@ + \edef\pgfplots@loc@TMPa{#3}% + \else + \edef\pgfplots@loc@TMPa{#3,#1}% + \fi + \def\pgfplots@loc@TMPb##1,##2\relax{% + % invoke + % \pgfplotsqpointoutsideofticklabelaxisrel{#2}{##1}{ticklabel dimen + ##2}: + \begingroup + \pgfmathparse{##2}% + \pgf@xa=\pgfmathresult pt\relax + \advance\pgf@xa by\pgfplotsvalueoflargesttickdimen{#2} %<- keep this space! + \xdef\pgfplots@glob@TMPa{\pgf@sys@tonumber\pgf@xa}% + \endgroup + \def\pgfplots@loc@TMPa{\pgfplotsqpointoutsideofticklabelaxisrel{#2}{##1}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@glob@TMPa}% + }% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\relax +}% + + +% Converts a dimen (with unit!) to a corresponding x, y or z +% coordinate. +% The result will be written to \pgfmathresult (without units). +% +% It is possible to use the result within the \pointxyz command(s). +% +% #1: the axis (x,y or z) +% #2: the dimen +% +% example: +% \pgfplotsconvertunittocoordinate{x}{5pt} +\def\pgfplotsconvertunittocoordinate#1#2{% + \begingroup + \pgf@xa=#2\relax + \pgf@xa=\csname pgfplots@#1@inverseveclength\endcsname\pgf@xa + \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% This is the same as using \pgfplotsconvertunittocoordinate for each +% component #1, #2 and #3. The results are directly communicated to +% \pgfplotsqpointxyz. +% +% Expects #1, #2 and #3 to be numbers with units and issues a \pgfplotsqpointxyz +\def\pgfplotsqpointxyzabsolutesize#1#2#3{% + \begingroup + \pgf@xa=#1\relax + \pgf@xa=\pgfplots@x@inverseveclength\pgf@xa + \pgf@xb=#2\relax + \pgf@xb=\pgfplots@y@inverseveclength\pgf@xb + \pgf@ya=#3\relax + \pgf@ya=\pgfplots@z@inverseveclength\pgf@ya + \xdef\pgfplots@glob@TMPa{{\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@ya}}% + \endgroup + \expandafter\pgfplotsqpointxyz\pgfplots@glob@TMPa +}% % Denotes a point in a twodimensional hyperplane. The hyperplane is % one of the six planes of the threedimensional axis cube. @@ -44,19 +253,26 @@ % \pgfplotspointonorientedsurfaceN. % % Example: -% \pgfplotspointonorientedsurfaceabsetupforxyz{0} +% \pgfplotspointonorientedsurfaceabsetupforxyz +% \pgfplotspointonorientedsurfaceabsetupforsetz{<lower z limit>}{0} +% % -> % \pgfplotspointonorientedsurfaceA = x % \pgfplotspointonorientedsurfaceB = y % \pgfplotspointonorientedsurfaceN = z -% \pgfplotspointonorientedsurfaceab{3}{4} = \pgfqpointxyz{3}{4}{0} +% \pgfplotspointonorientedsurfacespec = {ab0} +% \pgfplotspointonorientedsurfacespecunordered = {vv0} +% \pgfplotspointonorientedsurfaceab{3}{4} =\pgfqpointxyz{3}{4}{<lower z limit>} % -% \pgfplotspointonorientedsurfaceabsetupforyxz{0} +% \pgfplotspointonorientedsurfaceabsetupforyxz +% \pgfplotspointonorientedsurfaceabsetupforsetz{<lower z limit>}{0} % -> % \pgfplotspointonorientedsurfaceA = y % \pgfplotspointonorientedsurfaceB = x % \pgfplotspointonorientedsurfaceN = z -% \pgfplotspointonorientedsurfaceab{3}{4} = \pgfqpointxyz{4}{3}{0} +% \pgfplotspointonorientedsurfacespec = {ba0} +% \pgfplotspointonorientedsurfacespecunordered = {vv0} +% \pgfplotspointonorientedsurfaceab{3}{4} =\pgfqpointxyz{4}{3}{<lower z limit>} % % @see \pgfplotspointonorientedsurfaceabsetupforxyz \def\pgfplotspointonorientedsurfaceab#1#2{% @@ -86,6 +302,12 @@ % The distinction 'v in {a,b}' is eliminated. \def\pgfplotspointonorientedsurfacespecunordered{}% +% As \pgfplotspointonorientedsurfacespec, this macro contains +% information about the current oriented surface: it contains the +% fixed symbol '0', '1' or '2' describing the only direction which is +% fixed. +\def\pgfplotspointonorientedsurfacespecsymbol{\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol} + % Initialises \pgfplotspointonorientedsurfaceab such that 'a' is the x % axis and 'b' is the y axis and the z coordinate has been fixed with % \pgfplotspointonorientedsurfaceabsetupforsetz{}. @@ -187,6 +409,18 @@ }% +% Assuming we have an oriented surface installed, this command defines +% \pgfplotsretval to be the three-char-string such that the 'a' axis +% if the oriented surface takes value '#1', the 'b' axis of the +% oriented surface takes '#2' and the remaining axis has its fixed +% symbol anyway. +\def\pgfplotspointonorientedsurfaceabtolinespec#1#2{% + \expandafter\pgfplotspointonorientedsurfaceabtolinespec@a\pgfplotspointonorientedsurfacespec\relax#1% + \expandafter\pgfplotspointonorientedsurfaceabtolinespec@b\pgfplotsretval\relax#2% +}% +\def\pgfplotspointonorientedsurfaceabtolinespec@a#1a#2\relax#3{\edef\pgfplotsretval{#1#3#2}} +\def\pgfplotspointonorientedsurfaceabtolinespec@b#1b#2\relax#3{\edef\pgfplotsretval{#1#3#2}} + % Assuming that an oriented surface has been initialised, say 'a0b', % we have the following possible axis lines which can be drawn: % - b=0: 'v00' @@ -194,9 +428,27 @@ % - b=2: 'v02' % % To check which of them should be drawn, this macro here converts 'a' -% to 'v' and 'b' to '#1'. +% to 'v' and 'b' to '#1'. The remaining possible character will be +% copied as-is. % % The resulting three-character-string is written into '#2'. +% +% #1 : the replacement value which will be inserted instead of 'b' in +% the currently active oriented surface. +% #2 : the macro which will contain the output axis line specification +% (three-char-string). +% +% Example: +% \pgfplotspointonorientedsurfaceabsetupforxyz +% \pgfplotspointonorientedsurfaceabsetupforsetz{<lower z limit>}{0} +% -> the oriented surface is 'ab0' +% ... +% \pgfplotspointonorientedsurfaceabgetcontainedaxisline{0}\pgfplotsretval +% -> \pgfplotsretval = 'v00' +% \pgfplotspointonorientedsurfaceabgetcontainedaxisline{1}\pgfplotsretval +% -> \pgfplotsretval = 'v10' +% \pgfplotspointonorientedsurfaceabgetcontainedaxisline{2}\pgfplotsretval +% -> \pgfplotsretval = 'v20' \def\pgfplotspointonorientedsurfaceabgetcontainedaxisline#1#2{% \expandafter\pgfplotspointonorientedsurfaceabgetcontainedaxisline@\pgfplotspointonorientedsurfacespec\relax{#1}% \let#2=\pgfplots@loc@TMPa @@ -252,6 +504,106 @@ \fi }% +% Executes code '#2' if the axis surface denoted by the +% three-character-string '#1' is a foreground surface and code '#3' if +% the surface '#1' is a background surface. +% +% #1: a three-char-string with the keys +% 'v' = 'varying', +% '0' = 'lower axis limit', +% '1' = 'upper axis limit'. +% The string 'v0v' means that x and z are varying in that surface +% and 'y' is fixed to the lower axis limit. +% #2: code to execute if '#1' is foreground. +% #3: code to execute if '#1' is background. +\def\pgfplotsifaxissurfaceisforeground#1#2#3{% + \pgfutil@ifundefined{pgfplots@surfviewdepth@#1}{% + \pgfplots@error{\string\pgfplotsifaxissurfaceisforeground{#1}: undefined three-character-string '#1' provided.}% + #3% + }{% + \if f\csname pgfplots@surfviewdepth@#1\endcsname #2\else #3\fi + }% +}% + +% As \pgfplotsifaxissurfaceisforeground, but for axis lines. +% +% #1: a three-character string with the same keys as in +% \pgfplotsifaxissurfaceisforeground. However, there should be only +% one varying direction as we are dealing with an axis line. +% #2: code to execute if '#1' is foreground. +% #3: code to execute if '#1' is background. +% +\def\pgfplotsifaxislineisforeground#1#2#3{% + \pgfplotsgetadjacentsurfsforaxisline#1\to\pgfplots@loc@TMPb\pgfplots@loc@TMPc + \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPb}{% + #2% + }{% + \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPc}{% + #2% + }{% + #3% + }% + }% +}% +% Executes code '#2' if the axis surface denoted by the +% three-char-string '#1' is on the convex hull of the projected axis +% cube or code '#3' if that is not the case. +% +% The arguments are the same as for \pgfplotsifaxislineisforeground: +% #1: a three-character string with the same keys as in +% \pgfplotsifaxissurfaceisforeground. However, there should be only +% one varying direction as we are dealing with an axis line. +% #2: code to execute if '#1' is foreground. +% #3: code to execute if '#1' is background. +\def\pgfplotsifaxislineisonconvexhull#1#2#3{% + \pgfplotsgetadjacentsurfsforaxisline#1\to\pgfplots@loc@TMPb\pgfplots@loc@TMPc + % '#1' is on the convex hull if ONE of the adjacent surfs is + % foreground and the other one is background. + \pgfplots@loc@tmpfalse + \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPb}{% + \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPc}{% + }{% + \pgfplots@loc@tmptrue + }% + }{% + }% + \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPb}{% + }{% + \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPc}{% + \pgfplots@loc@tmptrue + }{% + }% + }% + \ifpgfplots@loc@tmp #2\else #3\fi +}% + +% Returns either '' (empty) or '-' (minus) for each of the two variing sides of the +% oriented surface described by #1. +% +% The output value #2 = '' means that the positive b axis points to +% the direction of the convex hull of the projected figure. +% +% The output value #2 = '-' means that the NEGATIVE b axis points to +% the direction of the convex hull of the projected figure. +% +% The output value #3 is also either '' or '-'. It refers to the +% direction of the 'n' axis of the surface which points to the convex +% hull of the projected figure. +% +% The returned values are used to decide how to align tick labels such +% that they are always outside of the convex hull of the projected +% axis. +% +% #1: three characters denoting an oriented surface. +% #2: a macro name. Will be filled either with '' (empty string) or +% '-', encoding the direction of the 'b' axis of surface #1 which +% points to the convex hull. +% #3: a macro name. It takes the same values as '#2', but it refers to +% the 'n' axis of surface #1. +\def\pgfplotsgetdirectionstoconvexhullforsurf#1#2#3{% + \pgfplotsgetdirectionstoconvexhullforsurf@#1\relax{#2}{#3}% +} + % Executes code '#2' if the axis line with 'b=#1' on the current % oriented surface shall be drawn. % If that is not the case, the code '#3' will be executed. @@ -264,24 +616,79 @@ % \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{draw it!}{\relax} % will check whether the line '10v' shall be drawn. % +% The check is based on +% 1. foreground/background flags +% 2. the current configuration of the axis lines key(s) +% % @see \pgfplotspointonorientedsurfaceabgetcontainedaxisline +\def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn#1#2#3{% + \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@{#1}{% + \edef\pgfplots@loc@TMPe{\csname pgfplots@\pgfplotspointonorientedsurfaceA axislinesnum\endcsname}% + \if0\pgfplots@loc@TMPe + % boxed axis lines + #2% + \else + \if2\pgfplots@loc@TMPe + % centered axis lines + #2% + \else + % either the 'left' or 'right' positioned cases. + % These have exactly one line which is the one where + % tick labels will be placed. And this, in turn, is + % already known, even for 3D. Check if we have it: + \pgfplotspointonorientedsurfaceabtolinespec v#1% + \edef\pgfplots@loc@TMPe{\csname pgfplots@\pgfplotspointonorientedsurfaceA ticklabelaxisspec\endcsname}% + \ifx\pgfplots@loc@TMPe\pgfplotsretval + #2% + \else + #3% + \fi + \fi + \fi + }{% + #3% + }% +}% + +% A sub-part of \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn +% which is /only/ based on foreground/background flags. % % @ATTENTION : this command will be always true for the 2D case. (it % will be overwritten, see \pgfplots@decide@which@figure@surfaces@are@drawn) -\def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn#1#2#3{% +\def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@#1#2#3{% \pgfplotspointonorientedsurfaceabgetcontainedaxisline#1\pgfplots@loc@TMPc \pgfplotsgetadjacentsurfsforaxisline\pgfplots@loc@TMPc\to\pgfplots@loc@TMPb\pgfplots@loc@TMPc - \if1\csname pgfplots@surfenabled@\pgfplots@loc@TMPb\endcsname - #2% - \else - \if1\csname pgfplots@surfenabled@\pgfplots@loc@TMPc\endcsname - #2% - \else + \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPb}{% + \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPc}{% #3% - \fi - \fi + }{% + #2% + }% + }{% + #2% + }% }% +% Similar to \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn, +% this thing here execute '#1' if grid lines on the currently +% initialised oriented surfaces shall be drawn and '#2' if not. +% +% This does only handle foreground/background issues; it has NOTHING +% to do with the actual checks if grid lines are active or not. +\def\pgfplots@ifgridlines@onorientedsurf@should@be@drawn#1#2{% + % grid lines shall be drawn + % if and only if BOTH adjacent axis lines shall be drawn: + \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% + % remark: this is ALWAYS true for 2D plots. + \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% + #1% + }{% + #2% + }% + }{% + #2% + }% +}% % Checks whether the line specified by a three-character-string '#1' % is inside of the currently set-up oriented surface. @@ -351,7 +758,7 @@ % string. Can be '0v1' or 'vv0' or so (see above). % #2 a surface, also encoded as three character string. Maybe % oriented. -% #3 The return value is encoded as integer into the macro #3 as +% #3 The return value is encoded as char into the macro #3 as % described in \pgfplotspointonorientedsurfaceabmatchaxisline: % '#3' will be EMPTY if '#1' is NOT in '#2'. % '#3' will be NON-EMPTY if '#1' IS in '#2'. @@ -427,113 +834,643 @@ \fi }% -% Takes Pitch '#1' and Yaw '#2' (both in degrees) and computes +% Provides a point on an arbitrary axis (identified by a +% three-character-string) which can take any value on that axis and +% which is shifted in the direction of the outer normal vector. +% +% #1: a three-character-string denoting the desired axis +% #2: the coordinate on that axis (the coordinate for the 'v' +% direction in '#1'). It needs to be given as it would be supplied to +% an \addplot or 'axis cs' coordinate; any logs or data +% transformations will be applied. +% #3: the distance (a dimension) describing how much we should move +% away from that axis. This points to the outside normal vector of the +% axis cube. +% +% @see \pgfplotsqpointoutsideofticklabelaxis +% +% If, in addition, the boolean \ifpgfslopedattime is true, the same +% transformations which would have been applied by +% \pgftransformlineattime will be applied, that means the 'sloped' +% feature of tikz is applied. FIXME : is that up-to-date!? +% +% @see \pgftransformlineattime -- it is quite similar. +\def\pgfplotsqpointoutsideofaxis#1#2#3{% + \begingroup + \def\pgfplotspointoutsideofaxis@plug@trafo##1##2{\csname pgfplotstransformcoordinate##1\endcsname{##2}}% + \let\pgfplotspointoutsideofaxis@plug@getlimit=\pgfplotspointoutsideofaxis@getlimit@ + \edef\pgfplots@loc@TMPa{#1}% + \expandafter\pgfplotspointoutsideofaxis@\pgfplots@loc@TMPa\relax{#2}{#3}% +}% + +% A variant of \pgfplotsqpointoutsideofaxis with relative values for +% #2. +% That means +% '#2 = 0' === lower axis limit +% and +% '#2 = 1' === upper axis limit. +\def\pgfplotsqpointoutsideofaxisrel#1#2#3{% + \begingroup + \def\pgfplotspointoutsideofaxis@plug@trafo##1##2{% + \begingroup + % compute ##1min + ##2 * (##1max - ##1min) : + % + \afterassignment\pgfplots@gobble@until@relax + \pgf@xa=##2pt\relax + \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xa}% + % + \pgf@xa=\csname pgfplots@##1min\endcsname pt % + \pgf@xb=\csname pgfplots@##1max\endcsname pt % + \pgf@xc=\pgf@xb + \ifpgfplots@allow@reversal@of@rel@axis@cs + \if\pgfkeysvalueof{/pgfplots/##1 dir/value}r% + % reverse: exchange min and max. + \pgf@xb=\pgf@xa + \pgf@xa=\pgf@xc + \pgf@xc=\pgf@xb + \fi + \fi + \advance\pgf@xc by-\pgf@xa + \pgf@xc=\pgfplots@loc@TMPa\pgf@xc + \advance\pgf@xc by\pgf@xa + \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xc}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + }% + \let\pgfplotspointoutsideofaxis@plug@getlimit=\pgfplotspointoutsideofaxis@getlimit@ + \edef\pgfplots@loc@TMPa{#1}% + \expandafter\pgfplotspointoutsideofaxis@\pgfplots@loc@TMPa\relax{#2}{#3}% +}% + +% A variant of \pgfplotsqpointoutsideofaxis which accepts transformed +% values for '#2' (i.e. any data transformations and logs are already +% applied). +\def\pgfplotsqpointoutsideofaxistransformed#1#2#3{% + \begingroup + \def\pgfplotspointoutsideofaxis@plug@trafo##1##2{\def\pgfmathresult{##2}}% + \let\pgfplotspointoutsideofaxis@plug@getlimit=\pgfplotspointoutsideofaxis@getlimit@ + \edef\pgfplots@loc@TMPa{#1}% + \expandafter\pgfplotspointoutsideofaxis@\pgfplots@loc@TMPa\relax{#2}{#3}% +}% + +% Computes the unit outer normal vector of the axis identified by a +% three-character-string '#1'. +% +% This is the same normal vector which is used inside of +% \pgfplotsqpointoutsideofaxis and its variants. +% +% The output of this command will be cached and re-used during the +% lifetime of an axis. +% +% The returned normal vector has length 1 (computed with +% \pgfpointnormalised). +\def\pgfplotspointouternormalvectorofaxis#1{% + \expandafter\ifx\csname pgfplotspointouternormalvectorofaxis@cache@#1\endcsname\relax + \begingroup + \edef\pgfplots@loc@TMPa{#1}% + \expandafter\pgfplotspointouternormalvectorofaxis@\pgfplots@loc@TMPa\relax% + % \endgroup in \pgfplotspointouternormalvectorofaxis@. + \expandafter\xdef\csname pgfplotspointouternormalvectorofaxis@cache@#1\endcsname{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% + \else + \csname pgfplotspointouternormalvectorofaxis@cache@#1\endcsname + \fi +}% + +% FIXME : this doesn't work if one of the three characters is '2' (for +% center) +\def\pgfplotspointouternormalvectorofaxis@#1#2#3\relax{% + \if v#1% + \def\pgfplots@loc@point@orthogonal@to@v##1##2{% + \pgfplotsqpointxyz{0}{##1}{##2}% + }% + \def\pgfplots@loc@char@for@baxis{#2}% + \def\pgfplots@loc@char@for@naxis{#3}% + \def\pgfplots@loc@baxis{y}% + \def\pgfplots@loc@naxis{z}% + \else + \if v#2% + \def\pgfplots@loc@point@orthogonal@to@v##1##2{% + \pgfplotsqpointxyz{##1}{0}{##2}% + }% + \def\pgfplots@loc@char@for@baxis{#1}% + \def\pgfplots@loc@char@for@naxis{#3}% + \def\pgfplots@loc@baxis{x}% + \def\pgfplots@loc@naxis{z}% + \else + \def\pgfplots@loc@point@orthogonal@to@v##1##2{% + \pgfplotsqpointxyz{##1}{##2}{0}% + }% + \def\pgfplots@loc@char@for@baxis{#1}% + \def\pgfplots@loc@char@for@naxis{#2}% + \def\pgfplots@loc@baxis{x}% + \def\pgfplots@loc@naxis{y}% + \fi + \fi + \if0\pgfplots@loc@char@for@baxis% + % this means : the '##1' direction of the surface + % orthogonal to the 'v' vector is on the lower axis + % limit. Since I need a vector pointing to the OUTSIDE of + % the axis, I need sign = -1 + \def\pgfplots@loc@baxissign{-}% + \else + % in this case, the OUTSIDE area requires a plus sign - the b + % axis already points to the inside. + \def\pgfplots@loc@baxissign{+}% + \fi + \pgfplotsmath@ifzero{\csname pgfplots@\pgfplots@loc@baxis @veclength\endcsname}{% + \def\pgfplots@loc@baxissign{0}% + \def\pgfplots@loc@baxisscale{0}% + }{% + \edef\pgfplots@loc@baxisscale{\pgfplots@loc@baxissign\csname pgfplots@\pgfplots@loc@baxis @inverseveclength\endcsname}% + }% + % + % Now the same game for the other axis: + \if0\pgfplots@loc@char@for@naxis% + % this means : the '##2' direction of the surface + % orthogonal to the 'v' vector is on the lower axis + % limit. Since I need a vector pointing to the OUTSIDE of + % the axis, I need sign = -1 + \def\pgfplots@loc@naxissign{-}% + \else + % in this case, the OUTSIDE area requires a plus sign - the n + % axis already points to the inside. + \def\pgfplots@loc@naxissign{+}% + \fi + \pgfplotsmath@ifzero{\csname pgfplots@\pgfplots@loc@naxis @veclength\endcsname}{% + \def\pgfplots@loc@naxissign{0}% + \def\pgfplots@loc@naxisscale{0}% + }{% + \edef\pgfplots@loc@naxisscale{\pgfplots@loc@naxissign\csname pgfplots@\pgfplots@loc@naxis @inverseveclength\endcsname}% + }% + % + % Ok, compute and normalize the vector: + \pgf@process{% + \pgfpointnormalised + {\pgfplots@loc@point@orthogonal@to@v{\pgfplots@loc@baxisscale}{\pgfplots@loc@naxisscale}}% + }% + \endgroup +}% + +% very-low-level internal routine. Never invoke it directly. +% @PRECONDITION: +% an \begingroup has been opened. +% @POSTCONDITION +% an \endgroup has been closed and \pgf@x and \pgf@y are assigned. +% +% This grouping stuff has the intention to keep the "plug" things +% local. +% +% #1#2#3 are the three characters for the line, delimited by \relax. +% #4: the argument supplied as coordinate on that axis. +% #5: the shift along the outer unit normal. +\def\pgfplotspointoutsideofaxis@#1#2#3\relax#4#5{% + \if v#1% + \def\pgfplots@loc@point@orthogonal@to@v{% + \pgfplotspointoutsideofaxis@plug@trafo{x}{#4}\let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotspointoutsideofaxis@plug@getlimit{y}{#2}\let\pgfplots@loc@TMPb=\pgfmathresult + \ifpgfplots@threedim + \pgfplotspointoutsideofaxis@plug@getlimit{z}{#3}\let\pgfplots@loc@TMPc=\pgfmathresult + \else + \def\pgfplots@loc@TMPc{0}% + \fi + \pgfplotsqpointxyz{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}% + }% + \else + \if v#2% + \def\pgfplots@loc@point@orthogonal@to@v{% + \pgfplotspointoutsideofaxis@plug@trafo{y}{#4}\let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotspointoutsideofaxis@plug@getlimit{x}{#1}\let\pgfplots@loc@TMPb=\pgfmathresult + \ifpgfplots@threedim + \pgfplotspointoutsideofaxis@plug@getlimit{z}{#3}\let\pgfplots@loc@TMPc=\pgfmathresult + \else + \def\pgfplots@loc@TMPc{0}% + \fi + \pgfplotsqpointxyz{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPc}% + }% + \else + \def\pgfplots@loc@point@orthogonal@to@v{% + \ifpgfplots@threedim + \pgfplotspointoutsideofaxis@plug@trafo{z}{#4}\let\pgfplots@loc@TMPa=\pgfmathresult + \else + \def\pgfplots@loc@TMPa{0}% + \fi + \pgfplotspointoutsideofaxis@plug@getlimit{x}{#1}\let\pgfplots@loc@TMPb=\pgfmathresult + \pgfplotspointoutsideofaxis@plug@getlimit{y}{#2}\let\pgfplots@loc@TMPc=\pgfmathresult + \pgfplotsqpointxyz{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}{\pgfplots@loc@TMPa}% + }% + \fi + \fi + % + % read dimen argument #5: + \afterassignment\pgfplots@gobble@until@relax + \pgf@xa=#5pt\relax + \edef\pgfplots@loc@distalong@normal{\pgf@sys@tonumber\pgf@xa}% + % + % + \pgf@process{% + \pgfpointadd + {\pgfplots@loc@point@orthogonal@to@v} + {% + \pgfqpointscale + {\pgfplots@loc@distalong@normal}% + {\pgfplotspointouternormalvectorofaxis{#1#2#3}}% + }% + }% + \endgroup +}% + +% Helper method for \pgfplotsqpointoutsideofaxis and its variants. +% #1: an axis (x,y or z) +% #2: one of '0', '1' or '2' where +% 0 == add lower #1 axis limit, +% 1 == add upper #1 axis limit, +% 2 == add nothing. +% #3: the value to add. +\def\pgfplotspointoutsideofaxis@getlimit@#1#2{% + \if#20% + \expandafter\let\expandafter\pgfmathresult\csname pgfplots@#1min\endcsname + \else + \if#21% + \expandafter\let\expandafter\pgfmathresult\csname pgfplots@#1max\endcsname + \fi + \fi +}% + +% Installs a rotation transformation matrix such that labels or +% whatever are aligned precisely in direction of one of the two/three +% coordinate directions. +% +% #1: the coordinate direction (one of x,y or z) +% +% The code is pretty much the same as \pgftransformlineattime, except +% that the computation is considerably simpler as axis directions are +% a well known quantity. +% +% This command assumes \ifpgfallowupsidedownattime = false and +% \ifpgfresetnontranslationattime = true +\def\pgfplotstransformtoaxisdirection#1{% + \pgftransformresetnontranslations + % + % compute unit length vector pointing into the direction of + % '#1#2#3': + \pgfqpointscale{\csname pgfplotsunit#1invlength\endcsname}{\csname pgfplotspointunit#1\endcsname}% + % + % do not allow upside down labels: + \ifdim\pgf@x<0pt% + \pgf@x=-\pgf@x% + \pgf@y=-\pgf@y% + \fi% + % + \pgf@ya=-\pgf@y% + % set up rotation matrix + % [ cos(alpha) sin(alpha); + % -sin(alpha) cos(alpha) ] + % where cos(alpha) = n_x and sin(alpha) = n_y: + \pgftransformcm% + {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}% + {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}% +} + +% Adds a further, temporary anchor to every node which will be +% processed. The anchor will be named '#3'. It is placed such that +% 1. the node's center is on a line in direction of the inwards normal +% vector of the axis line denoted by '#2' and the 'at' position of the node, +% 2. the node does not intrude the axis. +% +% #1: either x,y or z the direction which varies +% #2: a three-char-string uniquely identifying the axis line. +% The parameter '#1' is redundand: it is the same as the 'v' +% character in '#2'. +% #3: the newly defined achor name. +% +% @see \pgfplotsdeclareborderanchorforticklabelaxis +\def\pgfplotsdeclareborderanchorforaxis#1#2#3{% + % + % + \pgfdeclaregenericanchor{#3}{% + \begingroup + \pgfutil@ifundefined{pgfreferencednodename}{% + % use given transformation matrix. + }{% + \ifx\pgfreferencednodename\pgfutil@empty + % just use the given transformation matrix - we are + % typesetting an unlabeled node. + \else + \pgfsettransform{\csname pgf@sh@nt@\pgfreferencednodename\endcsname}% + \fi + }% + % I only need to apply the trafo matrix to direction vectors. Eliminate + % shifts. + \pgf@pt@x=0pt + \pgf@pt@y=0pt + % + % I'll apply the inverse transformation matrix to direction + % vectors. To ensure the relative position of these vectors + % and the anchors of the node, I have to invert the matrix: + \pgftransforminvert + % + % + % This here is the normal direction (points to the axis) + \pgfqpointscale{-1}{\pgfplotspointouternormalvectorofaxis{#2}}% + % + % we apply the inverse CM onto it here: + \pgf@pos@transform\pgf@x\pgf@y + \edef\pgfplots@tmp@normaldir{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% + % + % Now: + % auto-determine the canonical (north, north east etc) anchor + % at which the node touches the axis (remember: the axis is to + % be found in direction of the normal vector). If we choose + % this anchor, we *won't* penetrate the axis! + % + % This is a heuristicial procedure. + % + \def\pgfplots@thresh{0.17pt }% 80 degrees + %\def\pgfplots@thresh{0.3pt }% + %\def\pgfplots@thresh{0.707pt }% 45 degrees + \ifdim\pgf@y>0pt + \ifdim\pgf@y>\pgfplots@thresh + % only north anchor + \def\pgfplots@ycomp{north}% + \else + \def\pgfplots@ycomp{}% + \fi + \else + \ifdim\pgf@y<-\pgfplots@thresh + \def\pgfplots@ycomp{south}% + % south anchor + \else + \def\pgfplots@ycomp{}% + \fi + \fi + \ifdim\pgf@x>0pt + \ifdim\pgf@x>\pgfplots@thresh + \def\pgfplots@xcomp{east}% + \else + \def\pgfplots@xcomp{}% + \fi + \else + \ifdim\pgf@x<-\pgfplots@thresh + \def\pgfplots@xcomp{west}% + \else + \def\pgfplots@xcomp{}% + \fi + \fi + \edef\pgfplots@anchor{% + \pgfplots@ycomp + \ifx\pgfplots@ycomp\pgfutil@empty + \else + \ifx\pgfplots@xcomp\pgfutil@empty + \else + \space + \fi + \fi + \pgfplots@xcomp}% + % + % + % Now, I'd like the 'center' of the node on one line with the + % 'at={}' coordinate at which it shall be placed! + % This can be done as follows: + % + % Now, compute two lines: + % 1. a line parallel to the #1 axis which goes + % through our recently identified anchor, + % { x = x_a + r_1 * (#1 axis direction) + % 2. a line from center in direction of the normal, + % { x = x_c + r_2 n, r in R } + % + % Calculate the intersection point and return it! This + % involves a lot of arithmetics :-( + % + % compute (unit#1 - normal): + \pgfplots@tmp@normaldir + \pgf@xb=\pgf@x + \pgf@yb=\pgf@y + % + % and the axis direction (in fact, I use -axis dir. But that + % doesn't matter). + % Scale unit vector to length 1 to improve conditioning: + \pgfqpointscale + {\csname pgfplotsunit#1invlength\endcsname} + {\csname pgfplotspointunit#1\endcsname}% + \pgf@pos@transform\pgf@x\pgf@y + % + \edef\pgfplots@LEQ{% + % solve linear system + {\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@x}% + {\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@y}% + }% + % + % apply inverse matrix to right-hand-side (and compute RHS): + \pgf@sh@reanchor{##1}{center}% + \edef\pgfplots@loc@center{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% + \pgfpointdiff% {<start>}{<end>} -> computes <end> - <start> + {\pgfplots@loc@center}% + {\pgf@sh@reanchor{##1}{\pgfplots@anchor}}% + \edef\pgfplots@RHS{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}% + % + \pgfutilsolvetwotwoleq{\pgfplots@LEQ}{\pgfplots@RHS}% + \def\pgfplots@extract####1####2{% + \def\pgfplots@r{####1}% + }% + \expandafter\pgfplots@extract\pgfmathresult + % GOT IT! + % + % compute x_c + r*n: + \pgfpointadd + {\pgfplots@loc@center}% + {\pgfqpointscale{\pgfplots@r}{\pgfplots@tmp@normaldir}}% +%\message{==========>>>>>>>>>> I got finally (\the\pgf@x,\the\pgf@y). <<<<<<<<<===================}% + \pgf@process{}% <- transport outside of group + \endgroup + }% + % + % This variant will ALWAYS be placed on the boundary of the node. + % It is deprecated, I am keeping it for some time.... + \pgfdeclaregenericanchor{#3*}{% + \csname pgf@anchor@##1@border\endcsname{% + \pgf@process{% + % + % I want to rotate the node FIRST, then + % I'd like to get the boundary anchor! + % + % My idea: apply the INVERSE transformation + % matrix, then compute the boundary anchor. + % + % As soon as pgf draws the node, the + % transformation matrix will be applied and + % everything is fine. + \pgfutil@ifundefined{pgfreferencednodename}{% + % use given transformation matrix. + }{% + \ifx\pgfreferencednodename\pgfutil@empty + % just use the given transformation matrix - we are + % typesetting an unlabeled node. + \else + \pgfsettransform{\csname pgf@sh@nt@\pgfreferencednodename\endcsname}% + \fi + }% + \pgftransforminvert + % + % This here is the anchor as such. + \pgfqpointscale{-1}{\pgfplotspointouternormalvectorofaxis{#2}}% + % + \pgf@pos@transform\pgf@x\pgf@y + }% + }% + }% +}% + +% Takes azimuth (horizontal angle) '#1' and elongation (vertical +% angle) '#2' (both in degrees) and computes % x,y and z vectors which define the view in the direction % defined by '#1' and '#2'. % -% 'Pitch' means a rotation around the viewport's x axis. 'Yaw' means +% 'azimuth' means a rotation around the viewport's x axis. 'elongation' means % a rotation around the original coordinate system's z axis. % % The method works by computing -% Az = [ cos(yaw) -sin(yaw) 0; ... -% sin(yaw) cos(yaw) 0; ... +% Az = [ cos(azimuth) -sin(azimuth) 0; ... +% sin(azimuth) cos(azimuth) 0; ... % 0 0 1 ]; +% +% % Ax = [ 1 0 0; ... -% 0 cos(pitch) -sin(pitch) ;... -% 0 sin(pitch) cos(pitch) ]; -% v= Ax * Az; +% 0 cos(elevation) -sin(elevation) ;... +% 0 sin(elevation) cos(elevation) ]; % +% v= Ax * Az; % = [ ... -% cosy -siny cosp siny sinp; ... -% siny cosy cosp -sinp cosy; ... -% 0 sinp cosp ]; +% cosaz -sinaz cosel sinaz sinel; ... +% sinaz cosaz cosel -sinel cosaz; ... +% 0 sinel cosel ]; % -% Then, we use the rotated XY plane as viewport, that means -% xvec = v * [1 0 0]' -% yvec = v * [0 1 0]' +% Then, we use the rotated XZ plane as viewport, that means +% xvec = v * [1 0 0]' = <first column of v> +% zvec = v * [0 0 1]' = <third column of v> % and we define the projection onto the twodimensional surface -% spanned by 'xvec' and 'yvec' as -% P( q ) = [ q^T xvec, q^T yvec ]' +% spanned by 'xvec' and 'zvec' as +% P( q ) = [ q^T xvec, q^T zvec ]' % for q in R^3. % As a consequence, we compute the three unit vectors as % x = P( [1 0 0] ) +% = [ cosaz, sinaz sinel ]' % y = P( [0 1 0] ) +% = [ sinaz, -sinel cosaz ]' % z = P( [0 0 1] ) -% and get thus in matlab notation: +% = [ 0, cosel]' % -% proj = 1:2; -% x = v(1,proj); -% y = v(2,proj); -% z = v(3,proj); +% Furthermore, the 3D view vector which points into the direction of the view +% is +% n = v * [0 1 0 ]' = <second column of v> = [-sinaz cosel, cosaz cosel, sinel]' +% because the normal view point was the XZ plane with y as its normal +% vector. +% The 3D vector n is returned by this routine as well - it is +% necessary for some kind of z buffering (determining what is +% foreground and what is background). % % INPUT: -% - #1 : pitch -% - #2 : yaw +% - #1 : azimuth ("yaw") +% - #2 : elevation ("pitch") % OUTPUT: % - #3 : a macro which will be set to '1' if and only if -% the viewport is the standard XY axis (i.e. pitch=0,yaw=0). +% the viewport is the standard XY axis (i.e. azimuth=0, elevation=90). % - [xyz] vectors, % \pgfplots@[xyz]@veclength, % \pgfplots@[xyz]@inverseveclength % are set properly -\def\pgfplotssetaxesfrompitchyaw#1#2#3{% +% \pgfplots@view@dir@threedim@[xyz] will contain the three components +% of 'n' (without the suffix 'pt', but in units of 'pt'). +\def\pgfplotssetaxesfromazel#1#2#3{% \begingroup \pgfmathsin@{#1}% - \let\sinp=\pgfmathresult - \pgfmathsin@{#2}% - \let\siny=\pgfmathresult + \let\sinaz=\pgfmathresult \pgfmathcos@{#1}% - \let\cosp=\pgfmathresult - \pgfmathcos@{#2}% - \let\cosy=\pgfmathresult + \let\cosaz=\pgfmathresult + \pgfmathsin@{-#2}% + \let\sinel=\pgfmathresult + \pgfmathcos@{-#2}% + \let\cosel=\pgfmathresult % x: - \pgfmathmultiply@{\siny}{-1}% - \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\cosp}% - \xdef\pgfplots@glob@TMPa{\noexpand\pgfqpoint{\cosy pt}{\pgfmathresult pt}}% + \pgfmathmultiply@{\sinaz}{\sinel}% + \xdef\pgfplots@glob@TMPa{\noexpand\pgfqpoint{\cosaz pt}{\pgfmathresult pt}}% % y: - \pgfmathmultiply@{\cosy}{\cosp}% - \xdef\pgfplots@glob@TMPb{\noexpand\pgfqpoint{\siny pt}{\pgfmathresult pt}}% + \pgfmathmultiply@{-\sinel}{\cosaz}% + \xdef\pgfplots@glob@TMPb{\noexpand\pgfqpoint{\sinaz pt}{\pgfmathresult pt}}% % z: - \xdef\pgfplots@glob@TMPc{\noexpand\pgfqpoint{0pt}{\sinp pt}}% + \xdef\pgfplots@glob@TMPc{\noexpand\pgfqpoint{0pt}{\cosel pt}}% + % + \pgfkeysgetvalue{/pgfplots/x dir/value}\pgfplots@loc@dirvalue@x + \pgfkeysgetvalue{/pgfplots/y dir/value}\pgfplots@loc@dirvalue@y + \pgfkeysgetvalue{/pgfplots/z dir/value}\pgfplots@loc@dirvalue@z + \if r\pgfplots@loc@dirvalue@x + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% + \xdef\pgfplots@glob@TMPa{\noexpand\pgfqpointscale{-1}{\the\t@pgfplots@toka}}% + \fi + \if r\pgfplots@loc@dirvalue@y + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPb}% + \xdef\pgfplots@glob@TMPb{\noexpand\pgfqpointscale{-1}{\the\t@pgfplots@toka}}% + \fi + \if r\pgfplots@loc@dirvalue@z + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPc}% + \xdef\pgfplots@glob@TMPc{\noexpand\pgfqpointscale{-1}{\the\t@pgfplots@toka}}% + \fi + % + \def\pgfplots@extract@plot@box@ratio##1##2##3##4\pgfplots@EOI{% + \pgfmathparse{##1}\let\pgfplots@plotboxratio@x=\pgfmathresult + \pgfmathparse{##2}\let\pgfplots@plotboxratio@y=\pgfmathresult + \pgfmathparse{##3}\let\pgfplots@plotboxratio@z=\pgfmathresult + }% + \pgfkeysgetvalue{/pgfplots/plot box ratio}\pgfplots@loc@TMPa + \expandafter\pgfplots@extract@plot@box@ratio\pgfplots@loc@TMPa{1}{1}{1}\pgfplots@EOI + \ifdim\pgfplots@plotboxratio@x pt=1pt + \else + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% + \xdef\pgfplots@glob@TMPa{\noexpand\pgfqpointscale{\pgfplots@plotboxratio@x}{\the\t@pgfplots@toka}}% + \fi + \ifdim\pgfplots@plotboxratio@y pt=1pt + \else + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPb}% + \xdef\pgfplots@glob@TMPb{\noexpand\pgfqpointscale{\pgfplots@plotboxratio@y}{\the\t@pgfplots@toka}}% + \fi + \ifdim\pgfplots@plotboxratio@z pt=1pt + \else + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPc}% + \xdef\pgfplots@glob@TMPc{\noexpand\pgfqpointscale{\pgfplots@plotboxratio@z}{\the\t@pgfplots@toka}}% + \fi + % + % n (3D!) + \pgfmathmultiply@{-\sinaz}{\cosel}% + \let\pgfmathresultNx=\pgfmathresult + \pgfmathmultiply@{\cosaz}{\cosel}% + \xdef\pgfplots@glob@TMPd{{\pgfmathresultNx}{\pgfmathresult}{\sinel}}% \endgroup -\message{Setting x,y and z from {#1}{#2} to x = \meaning\pgfplots@glob@TMPa, y = \meaning\pgfplots@glob@TMPb, z = \meaning\pgfplots@glob@TMPc...}% +%\message{Setting x,y and z from {#1}{#2} to x = \meaning\pgfplots@glob@TMPa, y = \meaning\pgfplots@glob@TMPb, z = \meaning\pgfplots@glob@TMPc...n = \pgfplots@glob@TMPd.}% \pgfsetxvec{\pgfplots@glob@TMPa}% \pgfsetyvec{\pgfplots@glob@TMPb}% \pgfsetzvec{\pgfplots@glob@TMPc}% + \def\pgfplots@loc@TMPa##1##2##3{% + \def\pgfplots@view@dir@threedim@x{##1}% + \def\pgfplots@view@dir@threedim@y{##2}% + \def\pgfplots@view@dir@threedim@z{##3}% + }% + \expandafter\pgfplots@loc@TMPa\pgfplots@glob@TMPd\relax \def#3{0}% - \def\pgfplots@x@veclength{1.0}% - \def\pgfplots@y@veclength{1.0}% - \def\pgfplots@z@veclength{1.0}% - \def\pgfplots@x@inverseveclength{1.0}% - \def\pgfplots@y@inverseveclength{1.0}% - \def\pgfplots@z@inverseveclength{1.0}% -\iftrue - \pgfplots@scaleaxes@to@BB{\pgfplots@width}{\pgfplots@height}% FIXME : width and height is wrong: labels missing -\else - % FIXME : - \def\pgfplots@x@veclength{200}% - \pgfmathreciprocal@{\pgfplots@x@veclength}% - \let\pgfplots@x@inverseveclength=\pgfmathresult - \def\pgfplots@y@veclength{200}% - \pgfmathreciprocal@{\pgfplots@y@veclength}% - \let\pgfplots@y@inverseveclength=\pgfmathresult - \def\pgfplots@z@veclength{200}% - \pgfmathreciprocal@{\pgfplots@z@veclength}% - \let\pgfplots@z@inverseveclength=\pgfmathresult - \pgfsetxvec{\pgfpointscale{\pgfplots@x@veclength}{\pgfplots@glob@TMPa}}% - \pgfsetyvec{\pgfpointscale{\pgfplots@y@veclength}{\pgfplots@glob@TMPb}}% - \pgfsetzvec{\pgfpointscale{\pgfplots@z@veclength}{\pgfplots@glob@TMPc}}% -\fi -\message{After scaling: - x = (\the\pgf@xx,\the\pgf@xy), - y = (\the\pgf@yx,\the\pgf@yy), - z = (\the\pgf@zx,\the\pgf@zy).}% + \pgfplots@initsizes@get@width@withoutlabels + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplots@initsizes@get@height@withoutlabels + \edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}{\pgfmathresult}}% + \expandafter\pgfplots@scaleaxes@to@BB\pgfplots@loc@TMPa +%\message{After scaling: +% x = (\the\pgf@xx,\the\pgf@xy), +% y = (\the\pgf@yx,\the\pgf@yy), +% z = (\the\pgf@zx,\the\pgf@zy).}% }% % Takes the current PGF x,y and z unit vectors and scales them such % that the bounding box of the final image has width #1 and height #2. % -% The length of the input vectors is important for the 3D case: it +% The relative length of the input vectors is important for the 3D case: it % will be scaled as-is. % % PRECONDITION @@ -555,7 +1492,8 @@ \def\pgfplots@scaleaxes@to@BB#1#2{% \begingroup \pgfinterruptboundingbox - % STEP 1: compute the bounding box for UNITS: + % STEP 1: compute the bounding box for UNITS. We just need the + % relative sizes: \ifpgfplots@threedim \pgfpathmoveto{\pgfqpointxyz000}% \pgfpathmoveto{\pgfqpointxyz001}% @@ -579,7 +1517,7 @@ \advance\pgf@xb by-\pgf@pathminy \pgf@ya=#1\relax \pgf@yb=#2\relax -\message{PGFPLOTS: the current unit vectors result in a UNIT BB of (\the\pgf@xa,\the\pgf@xb). Scaling it to (\the\pgf@ya,\the\pgf@yb)...}% +%\message{PGFPLOTS: the current unit vectors result in a UNIT BB of (\the\pgf@xa,\the\pgf@xb). Scaling it to (\the\pgf@ya,\the\pgf@yb)...}% % STEP 2: compute the scales for x and y such % that the UNIT-BB will have size #1,#2: \pgfplotsutil@edef@invoke\pgfmathdivide@{% @@ -597,18 +1535,18 @@ \pgfusepath{discard}% \endpgfinterruptboundingbox \endgroup -\message{got scalex = \pgfplots@glob@TMPa\space and scaley = \pgfplots@glob@TMPb.}% +%\message{got scalex = \pgfplots@glob@TMPa\space and scaley = \pgfplots@glob@TMPb.}% \pgfmathsubtract@{\pgfplots@xmax}{\pgfplots@xmin}% - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% -\message{and 1/(xmax-xmin) = 1/(\pgfplots@xmax-\pgfplots@xmin) = \pgfmathresult.}% + \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% +%\message{and 1/(xmax-xmin) = 1/(\pgfplots@xmax-\pgfplots@xmin) = \pgfmathresult.}% \pgf@xx=\pgfplots@glob@TMPa\pgf@xx \pgf@xy=\pgfplots@glob@TMPb\pgf@xy \pgf@xx=\pgfmathresult\pgf@xx \pgf@xy=\pgfmathresult\pgf@xy % \pgfmathsubtract@{\pgfplots@ymax}{\pgfplots@ymin}% - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% -\message{and 1/(ymay-ymin) = 1/(\pgfplots@ymax-\pgfplots@ymin) = \pgfmathresult.}% + \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% +%\message{and 1/(ymay-ymin) = 1/(\pgfplots@ymax-\pgfplots@ymin) = \pgfmathresult.}% \pgf@yx=\pgfplots@glob@TMPa\pgf@yx \pgf@yy=\pgfplots@glob@TMPb\pgf@yy \pgf@yx=\pgfmathresult\pgf@yx @@ -616,8 +1554,8 @@ % \ifpgfplots@threedim \pgfmathsubtract@{\pgfplots@zmax}{\pgfplots@zmin}% - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% -\message{and 1/(zmaz-zmin) = 1/(\pgfplots@zmax-\pgfplots@zmin) = \pgfmathresult.}% + \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% +%\message{and 1/(zmaz-zmin) = 1/(\pgfplots@zmax-\pgfplots@zmin) = \pgfmathresult.}% \pgf@zx=\pgfplots@glob@TMPa\pgf@zx \pgf@zy=\pgfplots@glob@TMPb\pgf@zy \pgf@zx=\pgfmathresult\pgf@zx @@ -632,7 +1570,12 @@ {\pgf@sys@tonumber\pgf@xy}% }% \let\pgfplots@x@veclength=\pgfmathresult - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \pgfplotsmath@ifzero{\pgfplots@x@veclength}{% + \def\pgfmathresult{infty}% + % this case will be caught in \pgfplots@initsizes + }{% + \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% + }% \let\pgfplots@x@inverseveclength=\pgfmathresult % \pgfplotsutil@edef@invoke\pgfmathveclen@{% @@ -640,7 +1583,12 @@ {\pgf@sys@tonumber\pgf@yy}% }% \let\pgfplots@y@veclength=\pgfmathresult - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \pgfplotsmath@ifzero{\pgfplots@y@veclength}{% + \def\pgfmathresult{infty}% + % this case will be caught in \pgfplots@initsizes + }{% + \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% + }% \let\pgfplots@y@inverseveclength=\pgfmathresult % \ifpgfplots@threedim @@ -649,12 +1597,162 @@ {\pgf@sys@tonumber\pgf@zy}% }% \let\pgfplots@z@veclength=\pgfmathresult - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \pgfplotsmath@ifzero{\pgfplots@z@veclength}{% + \def\pgfmathresult{infty}% + % this case will be caught in \pgfplots@initsizes + }{% + \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% + }% \let\pgfplots@z@inverseveclength=\pgfmathresult \fi }% +% #1 the name of an input method for point meta. It must have been +% declared by \pgfplotsdeclarepointmetasource first. +% #2 any arguments supplied by the user (maybe empty). +\def\pgfplotssetpointmetainput#1#2{% + \csname pgfpmeta@#1@initfor\endcsname{#2}% + % + \edef\pgfplotspointmetainputhandler{#1}% +}% + +% Expands to the current value of 'point meta'. +\def\pgfplotspointmetainputhandler{} + +% Declares a routine which can be used to get point meta input. +% +% Such a routine is invoked in a context where point coordinates are +% processed, i.e. during 'plot coordinates', 'plot table' or the like. +% +% The routine is called `#1'. It consists of several methods: +% - \csname pgfpmeta@#1@assign\endcsname{} +% During the survey phase, this macro is expected to assign +% \pgfplots@current@point@meta +% This method should prepare everything which is needed to invoke +% the postprocessors, i.e. it prepares the input for point meta +% transformations to [0,1000] or the scatter plot things. In other +% words: if it is a numeric input method, it should return a +% floating point number. +% It is allowed to return an empty string to say "there is no point +% meta". +% PRECONDITION for '@assign': +% - the coordinate input method has already assigned its +% '\pgfplots@current@point@meta' (probably as raw input string). +% - the other input coordinates are already read. +% POSTCONDITION for '@assign': +% - \pgfplots@current@point@meta is ready for use: +% - EITHER a parsed floating point number +% - OR an empty string, +% - OR a symbolic string (if #3=symbolic) +% The default implementation is +% \let\pgfplots@current@point@meta=\pgfutil@empty +% +% - \csname pgfpmeta@#1@issymbolic\endcsname -> expands to either '1' or '0' +% A numeric source will be processed numerically, i.e. the final map +% to [0,1000] will be initialised and meta limits will be updated. +% A symbolic input routine won't be processed. +% Default is '0' +% +% - \csname pgfpmeta@#1@explicitinput\endcsname -> expands to either +% '1' or '0'. In case '1', it expects explicit input from the +% coordinate input routines. For example, 'plot file' will look for +% further input after the x,y,z coordinates. +% Default is '0' +% +% - \csname pgfpmeta@#1@initfor\endcsname##1{....} +% a macro used to initialise the point meta source when it is +% selected. +% This macro body is invoked by pgfplots when someone types +% 'point meta=x' -> will invoke 'pgfpmeta@x@initfor{}'. +% The first argument to initfor can be supplied by the user. +% PRECONDITION for 'initfor': +% - it will be invoked just before +% '\pgfplotspointmetainputhandler' will be changed. +% Default is to do nothing. +% +% #1: the name of the input routine. +% #2: a sequence of key-value pairs which can be used to overwrite +% 'assign', 'initfor' or the other components. +% See the definitions below for examples. +\def\pgfplotsdeclarepointmetasource#1#2{% + \expandafter\def\csname pgfpmeta@#1@assign\endcsname{\let\pgfplots@current@point@meta=\pgfutil@empty}% + \expandafter\def\csname pgfpmeta@#1@initfor\endcsname##1{}% + \expandafter\def\csname pgfpmeta@#1@issymbolic\endcsname{0}% + \expandafter\def\csname pgfpmeta@#1@explicitinput\endcsname{0}% + \edef\pgfplotsdeclarepointmetasource@{#1}% + \pgfqkeys{/pgfplots/@declare point meta src}{#2}% +}% +\pgfqkeys{/pgfplots/@declare point meta src}{% + assign/.code= + {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @assign\endcsname{#1}},% + initfor/.code= + {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @initfor\endcsname##1{#1}},% + issymbolic/.code= + {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @issymbolic\endcsname{#1}},% + explicitinput/.code= + {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @explicitinput\endcsname{#1}},% +}% + +% An empty one. This is simple to check with +% \ifx\pgfplotspointmetainputhandler\pgfutil@empty: +\pgfplotsdeclarepointmetasource{}{} +\pgfplotsdeclarepointmetasource{x}{assign={% + \let\pgfplots@current@point@meta=\pgfplots@current@point@x + \ifpgfplots@xislinear + \else + \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% + \let\pgfplots@current@point@meta=\pgfmathresult + \fi}} +\pgfplotsdeclarepointmetasource{y}{assign={% + \let\pgfplots@current@point@meta=\pgfplots@current@point@y + \ifpgfplots@yislinear + \else + \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% + \let\pgfplots@current@point@meta=\pgfmathresult + \fi}} +\pgfplotsdeclarepointmetasource{z}{assign={% + \let\pgfplots@current@point@meta=\pgfplots@current@point@z + \ifpgfplots@zislinear + \else + \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% + \let\pgfplots@current@point@meta=\pgfmathresult + \fi}} + +\pgfplotsdeclarepointmetasource{explicit}{% + assign={% + \ifx\pgfplots@current@point@meta\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% + \let\pgfplots@current@point@meta=\pgfmathresult + \fi + }, + explicitinput=1% +}% +\pgfplotsdeclarepointmetasource{explicit symbolic}{% + assign={},% no math, simply collect. + explicitinput=1,% + issymbolic=1% +}% + +\pgfplotsdeclarepointmetasource{expr}{% + assign={% + \csname pgfpmeta@\pgfpmeta@expr@origchoice @assign\endcsname + % + \pgfkeysgetvalue{/pgfplots/point meta/expr}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfmathparse{\pgfplots@loc@TMPa}% + \let\pgfplots@current@point@meta=\pgfmathresult + \fi + },% + initfor={% + \pgfkeyssetvalue{/pgfplots/point meta/expr}{#1}% + \let\pgfpmeta@expr@origchoice\pgfplotspointmetainputhandler + }, +}% +\pgfkeyssetvalue{/pgfplots/point meta/expr}{}% + % Internal stream methods. % % Please overwrite @@ -699,21 +1797,104 @@ % \pgfplots@current@point@meta \def\pgfplots@coord@stream@coord{% \pgfplots@coord@stream@coord@% - % FIXME : needs to be updated for 3D - % FIXME : reduce \if's \ifx\pgfplots@current@point@x\pgfutil@empty + % only one \if is enough as ONE empty coordinate results all + % others to be reset as well. \else - \ifx\pgfplots@current@point@y\pgfutil@empty + \ifpgfplots@coord@stream@isfirst + \global\let\pgfplots@currentplot@firstcoord@x=\pgfplots@current@point@x + \global\let\pgfplots@currentplot@firstcoord@y=\pgfplots@current@point@y + \global\let\pgfplots@currentplot@firstcoord@z=\pgfplots@current@point@z + \global\pgfplots@coord@stream@isfirstfalse + \fi + \global\let\pgfplots@currentplot@lastcoord@x=\pgfplots@current@point@x + \global\let\pgfplots@currentplot@lastcoord@y=\pgfplots@current@point@y + \global\let\pgfplots@currentplot@lastcoord@z=\pgfplots@current@point@z + \fi +}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Scanline management. The idea is to allow a simple syntax +% to provide matrix input - by means of scanlines. +% +% An empty line in 'addplot coordinates {}' indicates the end of a +% scan line. Similarly, an empty line in 'addplot file' or 'table' +% also indicates the end of a scan line. +% +% The following methods allow to update the scanline computation. +% +% Usage: +% +% \pgfplotsscanlinelengthinitzero +% +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinecomplete +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinecomplete +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinelengthincrease +% \pgfplotsscanlinecomplete +% +% \pgfplotsscanlinelengthcleanup +% +% Now, \pgfplotsscanlinelength expands to either +% a) a negative number in which case there is no +% unique scanline length. +% More precisely, -1 means "there was no end-of-scanline marker" +% -2 means "there where end-of-scanline markers, but the scanlines +% had different lengths. +% b) the scanline length. +\def\pgfplotsscanlinelengthinitzero{% + \c@pgfplots@scanlineindex=0 + \def\pgfplots@scanlinelength{-1}% +} +\def\pgfplotsscanlinelengthincrease{% + \advance\c@pgfplots@scanlineindex by1 +} +\def\pgfplotsscanlinecomplete{% + \ifnum\pgfplots@scanlinelength>0 + \ifnum\c@pgfplots@scanlineindex=0 + % + % \pgfplotsscanlinecomplete + % \pgfplotsscanlinecomplete + % \pgfplotsscanlinecomplete + % should have the same effect as a single statement. Do + % nothing here. \else - \ifpgfplots@coord@stream@isfirst - \global\let\pgfplots@currentplot@firstcoord@x=\pgfplots@current@point@x - \global\let\pgfplots@currentplot@firstcoord@y=\pgfplots@current@point@y - \global\pgfplots@coord@stream@isfirstfalse + \ifnum\pgfplots@scanlinelength=\c@pgfplots@scanlineindex\relax + \else +%\message{Found inconsistent scan line length: \pgfplots@scanlinelength\space vs. \the\c@pgfplots@scanlineindex\space near line \pgfplotstablelineno.}% + % special marker which means 'inconsistent scan line length found' + \def\pgfplots@scanlinelength{-2}% \fi - \global\let\pgfplots@currentplot@lastcoord@x=\pgfplots@current@point@x - \global\let\pgfplots@currentplot@lastcoord@y=\pgfplots@current@point@y \fi + \else + \ifnum\pgfplots@scanlinelength=-2 + \else + \edef\pgfplots@scanlinelength{\the\c@pgfplots@scanlineindex}% + \fi + \fi + \c@pgfplots@scanlineindex=0 +} +\def\pgfplotsscanlinelengthcleanup{% + \ifnum\c@pgfplots@scanlineindex=0 + % I assume the last scan line is already complete. + \else + \pgfplotsscanlinecomplete \fi + \let\pgfplotsscanlinelength=\pgfplots@scanlinelength +} +\def\pgfplotsscanlinedisablechanges{% + \let\pgfplotsscanlinecomplete=\relax + \let\pgfplotsscanlinelengthincreas=\relax + \let\pgfplotsscanlinelengthcleanup=\relax + \let\pgfplotsscanlinelengthinitzero=\relax }% % Initialises @@ -723,18 +1904,34 @@ % such that a following coordinate stream is processed properly. The % following coordinate stream may come from different input methods. % +% This coordinate stream is the first time a coordinate will be +% reported and processed by pgfplots. The task of this first pass is +% to +% - compute and update any axis limits, +% - collect and prepare ranges for color data, +% - handle stacked plots and error bars, +% - store the complete state of the plot's preprocessing in an +% internal datastructure for later completion. +% This involves a serialization of all processed points (i.e. the +% generation of a long coordinate list) +% +% Any \addplot command should issue \pgfplots@PREPARE@COORD@STREAM +% eventually. +% % Arguments: -% #1: all options of \addplot[...] (the plot style) -% #2: any trailing path commands after the 'plot' command as such, +% #1: any trailing path commands after the 'plot' command as such, % for example \addplot plot coordinates {...} -- (0,0); -% would yield #2 =' -- (0,0)' +% would yield #1 =' -- (0,0)' % % PRECONDITION: % - needs to be called inside of \addplot. +% - \pgfplots@addplot@survey@@optionlist contains the <options> +% provided to \addplot (all of them, including automatically +% determined ones) % % REMARK: % The following code is permissable: -% \pgfplots@PREPARE@COORD@STREAM{..}{...} +% \pgfplots@PREPARE@COORD@STREAM{...} % \pgfplots@coord@stream@start % ... % \pgfplots@coord@stream@coord @@ -751,123 +1948,18 @@ % - recorded error bar commands: local, % - what about stacked plot stuff: appears to be a combination % of local/global. +% - all that will be serialized and written into +% \pgfplots@stored@plotlist in \pgfplots@coord@stream@end. +% This list is global, so, if I am not mistaken, the scoping +% level of the complete stream operation from setup to @end can +% be as deep as necessary - as long as all operations have the +% same level of scoping. % -\long\def\pgfplots@PREPARE@COORD@STREAM#1#2{% +\long\def\pgfplots@PREPARE@COORD@STREAM#1{% \ifpgfplots@curplot@threedim \global\pgfplots@threedimtrue \fi - \def\pgfplots@coord@stream@start@{% - \pgfplotsapplistXXnewempty - \ifpgfplots@errorbars@enabled - \pgfplots@streamerrorbar@recordto{\pgfplots@recordederrorbar}% - \pgfplots@streamerrorbarstart - \else - \let\pgfplots@recordederrorbar=\pgfutil@empty - \fi - \ifpgfplots@stackedmode - \pgfplots@stacked@beginplot - \fi - % - %\let\pgfplots@coord@stream@recorded=\pgfutil@empty - % - \pgfplots@perpointmeta@usesfloattrue - % %%%%%%%%%%%%%% - % - % Define \pgfplots@set@perpointmeta properly: - \ifcase\pgfplots@perpointmeta@choice - % disabled. - \def\pgfplots@set@perpointmeta{% - \let\pgfplots@current@point@meta=\pgfutil@empty - }% - \or - % point meta/x - \def\pgfplots@set@perpointmeta{% - \let\pgfplots@current@point@meta=\pgfplots@current@point@x - }% - \ifpgfplots@xislinear - \else - \pgfplots@perpointmeta@usesfloatfalse - \fi - \or - % point meta/y - \def\pgfplots@set@perpointmeta{% - \let\pgfplots@current@point@meta=\pgfplots@current@point@y - }% - \ifpgfplots@yislinear - \else - \pgfplots@perpointmeta@usesfloatfalse - \fi - \or - % point meta/z - \def\pgfplots@set@perpointmeta{% - \let\pgfplots@current@point@meta=\pgfplots@current@point@z - }% - \ifpgfplots@zislinear - \else - \pgfplots@perpointmeta@usesfloatfalse - \fi - \or - % point meta/explicit : parse the information found - % somewhere: - \def\pgfplots@set@perpointmeta{% - \ifx\pgfplots@current@point@meta\pgfutil@empty - \else - \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% - \fi - \let\pgfplots@current@point@meta=\pgfmathresult - }% - \or - % point meta/explicit symbolic : simply collect the - % information, no math. - \def\pgfplots@set@perpointmeta{}% - \fi - \ifnum\pgfplots@perpointmeta@choice=0 - \global\let\pgfplots@metamin=\pgfutil@empty - \global\let\pgfplots@metamax=\pgfutil@empty - \else - \ifnum\pgfplots@perpointmeta@choice=5 - \global\let\pgfplots@metamin=\pgfutil@empty - \global\let\pgfplots@metamax=\pgfutil@empty - \else - % We need to work with per point meta data. - % So, also compute the data range on a per-stream basis! - % These limits are important later. - \ifpgfplots@perpointmeta@usesfloat - \pgfmathfloatcreate{1}{1.0}{2147483645}% - \let\pgfplots@invalidrange@metamin=\pgfmathresult - \pgfmathfloatcreate{2}{1.0}{2147483645}% - \let\pgfplots@invalidrange@metamax=\pgfmathresult - \global\let\pgfplots@metamin=\pgfplots@invalidrange@metamin - \global\let\pgfplots@metamax=\pgfplots@invalidrange@metamax - \expandafter\def\expandafter\pgfplots@set@perpointmeta\expandafter{% - \pgfplots@set@perpointmeta - \ifx\pgfplots@current@point@meta\pgfutil@empty - \else - \pgfplotsmathfloatmin{\pgfplots@metamin}{\pgfplots@current@point@meta}% - \global\let\pgfplots@metamin=\pgfmathresult - \pgfplotsmathfloatmax{\pgfplots@metamax}{\pgfplots@current@point@meta}% - \global\let\pgfplots@metamax=\pgfmathresult - \fi - }% - \else - \def\pgfplots@invalidrange@metamin{16300}% - \def\pgfplots@invalidrange@metamax{-16300}% - \global\let\pgfplots@metamin=\pgfplots@invalidrange@metamin - \global\let\pgfplots@metamax=\pgfplots@invalidrange@metamax - \expandafter\def\expandafter\pgfplots@set@perpointmeta\expandafter{% - \pgfplots@set@perpointmeta - \ifx\pgfplots@current@point@meta\pgfutil@empty - \else - \pgfplotsmathmin{\pgfplots@metamin}{\pgfplots@current@point@meta}% - \global\let\pgfplots@metamin=\pgfmathresult - \pgfplotsmathmax{\pgfplots@metamax}{\pgfplots@current@point@meta}% - \global\let\pgfplots@metamax=\pgfmathresult - \fi - }% - \fi - \fi - \fi - }% + % \begingroup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \let\E=\noexpand @@ -967,7 +2059,6 @@ \fi \fi \ifpgfplots@curplot@threedim - \else \ifpgfplots@autocompute@zmin \else \ifpgfplots@zislinear @@ -1092,7 +2183,7 @@ %\E\pgfplots@message{Updated limits: (\E\pgfplots@xmin,\E\pgfplots@ymin) rectangle (\E\pgfplots@xmax,\E\pgfplots@ymax).}% %\E\tracingmacros=0\E\tracingcommands=0 }% -%\message{Assembled update-limits macro to {\meaning\pgfplots@update@limits@for@one@point}}% +%\message{Assembled update-limits \ifpgfplots@curplot@threedim 3D\else 2D\fi macro to {\meaning\pgfplots@update@limits@for@one@point}}% \ifpgfplots@bb@isactive \else % we are inside of @@ -1107,7 +2198,7 @@ % This here is the MAIN code of \pgfplots@process@one@point . % It is inserted below into the right, into one of two prepared % places. - \def\pgfplots@loc@TMPa{% + \def\pgfplots@loc@surveypoint{% \ifpgfplots@apply@datatrafo \ifpgfplots@datascaletrafo@initialised % apply data transformation directly. @@ -1153,18 +2244,11 @@ % \pgfplots@current@point@[xy] % \pgfplots@current@point@[xy]@error % \pgfplots@current@point@[xy]@unfiltered - \E\pgfplots@process@errorbar@for% + \E\pgfplots@PREPARE@errorbar@process@x% + \E\pgfplots@PREPARE@errorbar@process@y% + \E\pgfplots@PREPARE@errorbar@process@z% \fi % - % Store normalized point for list: - % We need - % xi,yi,zi,mi; - % where zi and mi may be empty. mi is the per-point meta - % information. It is used for per-coordinate marker - % modifications (like colormaps for scatter plots). - \E\edef\E\pgfplots@loc@TMPa{\E\pgfplots@current@point@x,\E\pgfplots@current@point@y,\E\pgfplots@current@point@z,\E\pgfplots@current@point@meta;}% - \E\expandafter\E\pgfplotsapplistXXpushback\E\expandafter{\E\pgfplots@loc@TMPa}% - % \ifpgfplots@collect@firstplot@astick \ifnum\pgfplots@numplots=0 \E\ifx\E\pgfplots@firstplot@coords@x\E\pgfutil@empty @@ -1190,6 +2274,17 @@ \fi \fi \fi + % + }% + \def\pgfplots@loc@performserizalization{% + % Store normalized point for list: + % We need + % xi,yi,zi,mi; + % where zi and mi may be empty. mi is the per-point meta + % information. It is used for per-coordinate marker + % modifications (like colormaps for scatter plots). + \E\edef\E\pgfplots@loc@TMPa{\E\pgfplots@current@point@x,\E\pgfplots@current@point@y,\E\pgfplots@current@point@z,\E\pgfplots@current@point@meta;}% + \E\expandafter\E\pgfplotsapplistXXpushback\E\expandafter{\E\pgfplots@loc@TMPa}% }% % The following code assembles the command which is executed for % each coordinate. @@ -1201,12 +2296,13 @@ % \pgfplots@current@point@[xyz] % \pgfplots@current@point@[xyz]@error (if in argument list) \xdef\pgfplots@process@one@point{% - % These things are necessary for error bars: + % These things are necessary for error bars and are available + % as public results in math parser invocations (for meta and + % filters) \E\let\E\pgfplots@current@point@x@unfiltered=\E\pgfplots@current@point@x \E\let\E\pgfplots@current@point@y@unfiltered=\E\pgfplots@current@point@y - \ifpgfplots@curplot@threedim \E\let\E\pgfplots@current@point@z@unfiltered=\E\pgfplots@current@point@z - \fi + \E\def\E\pgfplots@unbounded@dir{}% % \E\pgfplots@prepare@xcoord{\E\pgfplots@current@point@x}% \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{x}% @@ -1216,13 +2312,25 @@ \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{y}% \E\let\E\pgfplots@current@point@y=\E\pgfmathresult % + \ifpgfplots@curplot@threedim + \E\pgfplots@prepare@zcoord{\E\pgfplots@current@point@z}% + \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{z}% + \E\let\E\pgfplots@current@point@z=\E\pgfmathresult + \fi + % + \E\pgfplots@invoke@filter@xyz + % \ifpgfplots@xislinear + % NOTE: this handling of unbounded coords in the case of + % LOG coords is performed directly by + % \pgfplots@prepare@ycoord! \E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty \E\else \E\pgfmathfloatparsenumber{\E\pgfplots@current@point@x}% \E\expandafter\E\pgfmathfloat@decompose@F\E\pgfmathresult\E\relax\E\c@pgf@counta - \E\ifnum\E\c@pgf@counta>2 + \E\ifnum\E\c@pgf@counta>2 % this clears nan, inf and -inf points. \E\let\E\pgfplots@current@point@x=\E\pgfutil@empty + \E\def\E\pgfplots@unbounded@dir{x}% \E\else \E\let\E\pgfplots@current@point@x=\E\pgfmathresult \E\fi @@ -1236,6 +2344,7 @@ \E\expandafter\E\pgfmathfloat@decompose@F\E\pgfmathresult\E\relax\E\c@pgf@counta \E\ifnum\E\c@pgf@counta>2 \E\let\E\pgfplots@current@point@y=\E\pgfutil@empty + \E\def\E\pgfplots@unbounded@dir{y}% \E\else \E\let\E\pgfplots@current@point@y=\E\pgfmathresult \E\fi @@ -1243,10 +2352,6 @@ \fi % \ifpgfplots@curplot@threedim - \E\let\E\pgfplots@current@point@z@unfiltered=\E\pgfplots@current@point@z - \E\pgfplots@prepare@zcoord{\E\pgfplots@current@point@z}% - \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{z}% - \E\let\E\pgfplots@current@point@z=\E\pgfmathresult % \ifpgfplots@zislinear \E\ifx\E\pgfplots@current@point@z\E\pgfutil@empty @@ -1255,6 +2360,7 @@ \E\expandafter\E\pgfmathfloat@decompose@F\E\pgfmathresult\E\relax\E\c@pgf@counta \E\ifnum\E\c@pgf@counta>2 \E\let\E\pgfplots@current@point@z=\E\pgfutil@empty + \E\def\E\pgfplots@unbounded@dir{z}% \E\else \E\let\E\pgfplots@current@point@z=\E\pgfmathresult \E\fi @@ -1262,157 +2368,879 @@ \fi \fi % + % check if coordinates are bounded: + \E\pgfplots@loc@tmptrue \E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty - \ifpgfplots@warn@for@filter@discards - \E\pgfplots@message{NOTE: coordinate (\E\pgfplots@current@point@x@unfiltered,\E\pgfplots@current@point@y@unfiltered\ifpgfplots@curplot@threedim,\E\pgfplots@current@point@z@unfiltered\fi) has been dropped because of the x-coordinate filter.}% - \fi + \E\pgfplots@loc@tmpfalse \E\else \E\ifx\E\pgfplots@current@point@y\E\pgfutil@empty - \ifpgfplots@warn@for@filter@discards - \E\pgfplots@message{NOTE: coordinate (\E\pgfplots@current@point@x@unfiltered,\E\pgfplots@current@point@y@unfiltered\ifpgfplots@curplot@threedim,\E\pgfplots@current@point@z@unfiltered\fi) has been dropped because of the y-coordinate filter.}% - \fi + \E\pgfplots@loc@tmpfalse \E\else \ifpgfplots@curplot@threedim \E\ifx\E\pgfplots@current@point@z\E\pgfutil@empty - \ifpgfplots@warn@for@filter@discards - \E\pgfplots@message{NOTE: coordinate (\E\pgfplots@current@point@x@unfiltered,\E\pgfplots@current@point@y@unfiltered,\E\pgfplots@current@point@z@unfiltered) has been dropped because of the z-coordinate filter.}% - \fi - \E\else - % insert the main 3d code here: - \pgfplots@loc@TMPa + \E\pgfplots@loc@tmpfalse \E\fi - \else - % insert the main 2d code here: - \pgfplots@loc@TMPa \fi \E\fi \E\fi % + \E\ifpgfplots@loc@tmp + % coordinate is bounded AND non-empty, ok. + % insert the main 2d/3d code here: + \pgfplots@loc@surveypoint + \pgfplots@loc@performserizalization + \E\else + % make ALL empty to simplify special case checking: + \E\let\E\pgfplots@current@point@x=\E\pgfutil@empty + \E\let\E\pgfplots@current@point@y=\E\pgfutil@empty + \E\let\E\pgfplots@current@point@z=\E\pgfutil@empty + % check whether we have UNBOUNDED or just unfiltered + % coords: + \if\pgfplots@unbounded@handler d% unbounded coords=discard + \ifpgfplots@warn@for@filter@discards + \E\pgfplots@message{% + NOTE: coordinate (\E\pgfplots@current@point@x@unfiltered,\E\pgfplots@current@point@y@unfiltered\ifpgfplots@curplot@threedim,\E\pgfplots@current@point@z@unfiltered\fi) + has been dropped because + \E\ifx\E\pgfplots@unbounded@dir\E\pgfutil@empty + of a coordinate filter. + \E\else + it is unbounded (in \E\pgfplots@unbounded@dir). + \E\fi + }% + \fi + \else + % unbounded coords=jump + \E\ifx\E\pgfplots@unbounded@dir\E\pgfutil@empty + \ifpgfplots@warn@for@filter@discards + \E\pgfplots@message{% + NOTE: coordinate (\E\pgfplots@current@point@x@unfiltered,\E\pgfplots@current@point@y@unfiltered\ifpgfplots@curplot@threedim,\E\pgfplots@current@point@z@unfiltered\fi) + has been dropped because of a coordinate filter. + }% + \fi + \E\else + \pgfplots@loc@performserizalization + \E\fi + \fi + \E\fi + % % increase \pgfplots@current@point@coordindex: - \E\begingroup - \E\c@pgf@counta=\E\pgfplots@current@point@coordindex - \E\advance\E\c@pgf@counta by1\E\relax - \E\xdef\E\pgfplots@glob@TMPc{\E\the\E\c@pgf@counta}% - \E\endgroup - \E\let\E\pgfplots@current@point@coordindex=\E\pgfplots@glob@TMPc + \E\advance\E\c@pgfplots@coordindex by1 }% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endgroup %\message{Prepared macro \string\pgfplots@update@limits@for@one@point: {\meaning\pgfplots@update@limits@for@one@point}}% %\message{Prepared macro \string\pgfplots@process@one@point: {\meaning\pgfplots@process@one@point}}% + % + \let\pgfplots@coord@stream@start@=\pgfplots@PREPARE@COORD@STREAM@start@ \let\pgfplots@coord@stream@coord@=\pgfplots@process@one@point + \def\pgfplots@coord@stream@end@{\pgfplots@PREPARE@COORD@STREAM@end@{#1}}% +}% + +% The \pgfplots@coord@stream@start@ routine used inside of +% \pgfplots@PREPARE@COORD@STREAM. +% +% It prepares everything for the first pass through all input +% coordinates. +\def\pgfplots@PREPARE@COORD@STREAM@start@{% + % The current implementation of pgfplots stores the preprocessed + % coordinate stream into a long list of coordinates. + % Since macro append is an expensive operation, it uses the highly + % optimized 'applistXX' structure: + \pgfplotsapplistXXnewempty % - \def\pgfplots@coord@stream@end@{% - \ifpgfplots@autocompute@all@limits - \global\let\pgfplots@data@xmin=\pgfplots@xmin - \global\let\pgfplots@data@xmax=\pgfplots@xmax - \global\let\pgfplots@data@ymin=\pgfplots@ymin - \global\let\pgfplots@data@ymax=\pgfplots@ymax - \global\let\pgfplots@data@zmin=\pgfplots@zmin - \global\let\pgfplots@data@zmax=\pgfplots@zmax + % + \ifpgfplots@errorbars@enabled + % prepare error bar processing. + % + % The actual implementation stores every final drawing command + % into a list. + % + % Prepare that list: + \pgfplots@streamerrorbar@recordto{\pgfplots@recordederrorbar}% + \pgfplots@streamerrorbarstart + % + % Now, prepare the coordinate processing for errorbars: + \pgfplots@PREPARE@errorbar@processing@in@dir x% + \pgfplots@PREPARE@errorbar@processing@in@dir y% + \ifpgfplots@curplot@threedim + \pgfplots@PREPARE@errorbar@processing@in@dir z% + \else + \let\pgfplots@PREPARE@errorbar@process@z=\relax \fi - \ifpgfplots@errorbars@enabled - \pgfplots@streamerrorbarend + \else + \let\pgfplots@recordederrorbar=\pgfutil@empty + \fi + \ifpgfplots@stackedmode + \pgfplots@stacked@beginplot + \fi + % + % Inside of math expressions, 'x', 'y' and 'z' expand to the + % current x,y and z coords respectively. Introduce these (and some + % more) shortcuts: + \pgfplotsmathdeclarepseudoconstant{x}{\let\pgfmathresult=\pgfplots@current@point@x}% + \pgfplotsmathdeclarepseudoconstant{y}{\let\pgfmathresult=\pgfplots@current@point@y}% + \pgfplotsmathdeclarepseudoconstant{z}{\let\pgfmathresult=\pgfplots@current@point@z}% + \pgfplotsmathdeclarepseudoconstant{rawx}{\let\pgfmathresult=\pgfplots@current@point@x@unfiltered}% + \pgfplotsmathdeclarepseudoconstant{rawy}{\let\pgfmathresult=\pgfplots@current@point@y@unfiltered}% + \pgfplotsmathdeclarepseudoconstant{rawz}{\let\pgfmathresult=\pgfplots@current@point@z@unfiltered}% + \pgfplotsmathdeclarepseudoconstant{meta}{% + \let\pgfmathresult=\pgfplots@current@point@meta + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloatcreate{0}{0.0}{0}% \fi - \ifpgfplots@stackedmode - \pgfplots@stacked@endplot + }% + % + % %%%%%%%%%%%%%% + % + % Define \pgfplots@set@perpointmeta properly: + \def\pgfplots@set@perpointmeta{% + \csname pgfpmeta@\pgfplotspointmetainputhandler @assign\endcsname + }% + \if0\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname + % We need to work with per point meta data. + % So, also compute the data range on a per-plot basis! + % These limits are important later. + \pgfkeysgetvalue{/pgfplots/point meta min}\pgfplots@metamin + \t@pgfplots@tokb={}% + \ifx\pgfplots@metamin\pgfutil@empty + \global\let\pgfplots@metamin=\pgfplots@invalidrange@metamin + \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb + \pgfplotsmathfloatmin{\pgfplots@metamin}{\pgfplots@current@point@meta}% + \global\let\pgfplots@metamin=\pgfmathresult + }% + \else + \pgfmathfloatparsenumber{\pgfplots@metamin}% + \global\let\pgfplots@metamin=\pgfmathresult \fi - \ifpgfplots@coord@stream@isfirst - \pgfplots@warning{the current plot has no coordinates (left?)}% - \fi -% \else - % Idea: use - % \scope[plot specification] - % <any paths for error bars> - % \endscope - % \draw plot coordinates {...}; - % to share plot specifications between error bars and plot - % coordinates. Unfortunately, it is NOT sufficient to use - % \tikzset{#1} - \ifpgfplots@curplot@isirrelevant - \edef\pgfplots@addplot@preoptionsTMP{/pgfplots/every axis plot,/pgfplots/every forget plot/.try}% + \pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots@metamax + \ifx\pgfplots@metamax\pgfutil@empty + \global\let\pgfplots@metamax=\pgfplots@invalidrange@metamax + \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb + \pgfplotsmathfloatmax{\pgfplots@metamax}{\pgfplots@current@point@meta}% + \global\let\pgfplots@metamax=\pgfmathresult + }% + \else + \pgfmathfloatparsenumber{\pgfplots@metamax}% + \global\let\pgfplots@metamax=\pgfmathresult + \fi + % + \t@pgfplots@toka=\expandafter{\pgfplots@set@perpointmeta}% + \edef\pgfplots@set@perpointmeta{% + \the\t@pgfplots@toka + \noexpand\ifx\noexpand\pgfplots@current@point@meta\noexpand\pgfutil@empty + \noexpand\else + \the\t@pgfplots@tokb + \noexpand\fi + }% + \else + % there is no point meta: + \global\let\pgfplots@metamin=\pgfutil@empty + \global\let\pgfplots@metamax=\pgfutil@empty + \fi +}% +% This is the \pgfplots@coord@stream@end@ routine which is invoked by +% \pgfplots@PREPARE@COORD@STREAM. +% +% It finalizes the first pass through the input coordinates and +% remembers the preprocessed \addplot command. +% +% Technical note: The parameters provided to +% \pgfplots@PREPARE@COORD@STREAM +% are needed here. This doesn't fit directly into the framework of +% coordinate streams, see \pgfplots@PREPARE@COORD@STREAM how this +% invocation works. +% +% #1,#2: see \pgfplots@PREPARE@COORD@STREAM +\def\pgfplots@PREPARE@COORD@STREAM@end@#1{% + \ifx\pgfplots@metamin\pgfutil@empty + \else + \if\pgfplots@axiswide@metamin@autocompute1% + \pgfplotsmathfloatmin{\pgfplots@axiswide@metamin}{\pgfplots@metamin}% + \global\let\pgfplots@axiswide@metamin=\pgfmathresult + \fi + \if\pgfplots@axiswide@metamax@autocompute1% + \pgfplotsmathfloatmax{\pgfplots@axiswide@metamax}{\pgfplots@metamax}% + \global\let\pgfplots@axiswide@metamax=\pgfmathresult + \fi + \fi + \ifpgfplots@autocompute@all@limits + \global\let\pgfplots@data@xmin=\pgfplots@xmin + \global\let\pgfplots@data@xmax=\pgfplots@xmax + \global\let\pgfplots@data@ymin=\pgfplots@ymin + \global\let\pgfplots@data@ymax=\pgfplots@ymax + \global\let\pgfplots@data@zmin=\pgfplots@zmin + \global\let\pgfplots@data@zmax=\pgfplots@zmax + \fi + \ifpgfplots@errorbars@enabled + \pgfplots@streamerrorbarend + \fi + \ifpgfplots@stackedmode + \pgfplots@stacked@endplot + \fi + \ifpgfplots@coord@stream@isfirst + \pgfplots@warning{the current plot has no coordinates (or all have been filtered away)}% + \else + % Idea: use + % \scope[plot specification] + % <any paths for error bars> + % \endscope + % \draw plot coordinates {...}; + % to share plot specifications between error bars and plot + % coordinates. Unfortunately, it is NOT sufficient to use + % \tikzset + \pgfkeyssetvalue{/pgfplots/mesh/num points}{\pgfplots@current@point@coordindex}% + \pgfplotspreparemeshkeydefaults% + \pgfplots@PREPARE@COORD@STREAM@end@determinecoordsorting x% + \pgfplots@PREPARE@COORD@STREAM@end@determinecoordsorting y% + \ifpgfplots@curplot@isirrelevant + % for \label commands: + \expandafter\pgfplots@rememberplotspec@for@label\expandafter{\pgfplots@addplot@survey@@optionlist}% + \else + \expandafter\pgfplots@rememberplotspec\expandafter{\pgfplots@addplot@survey@@optionlist}% + \fi + % warning: rememberplotspec calls list macros which + % overwrite \t@pgfplots@toka + \t@pgfplots@toka=\expandafter{\pgfplots@addplot@survey@@optionlist}% + % ATTENTION: do NOT call list macros from here on! + % + \ifpgfplots@datascaletrafo@initialised + \pgfplots@addplot@get@named@startendpoints@command\pgfplots@loc@TMPa + \t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}% + \else + \t@pgfplots@tokc={}% + \fi + % SERIALIZE RESULT: + % + % everything which has been accumulated so far (including the + % preprocessed coordinates) will be serialized into the + % structure \pgfplots@stored@plotlist (globally). + % + % assemble a \pgfplots@addplot@enqueue@coords command ... + % BEGIN HERE ... + % vvvvvvvvvv + \xdef\pgfplots@glob@TMPa{% + \noexpand\pgfplots@addplot@enqueue@coords + {% precommand(s): + \expandafter\noexpand\csname pgfplots@curplot@threedim\ifpgfplots@curplot@threedim true\else false\fi\endcsname + \noexpand\def\noexpand\plotnum{\the\pgfplots@numplots}% + \noexpand\def\noexpand\numcoords{\pgfplots@current@point@coordindex}% + % \pgfplots@current@point@coordindex will always contain the current index. + % Maybe overwritten if not provided using \c@pgfplots@coordindex. + \noexpand\def\noexpand\pgfplots@current@point@coordindex{\noexpand\the\noexpand\c@pgfplots@coordindex}% + \noexpand\def\noexpand\coordindex{\noexpand\pgfplots@current@point@coordindex}% valid inside of \addplot + % + % save the possibly prepare/adjusted plot + % variables [FIXME: move after \pgfplots@define@currentplotstyle@as ?]: + \noexpand\pgfkeyssetvalue{/pgfplots/samples}{\pgfplots@plot@samples}% + \noexpand\pgfkeyssetvalue{/pgfplots/domain}{\pgfplots@plot@domain}% + \noexpand\pgfkeyssetvalue{/pgfplots/samples at}{\pgfplots@plot@samples@at}% + \noexpand\pgfkeyssetvalue{/pgfplots/mesh/rows}{\pgfkeysvalueof{/pgfplots/mesh/rows}}% + \noexpand\pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/mesh/cols}}% + % either '+' or '-' : + \noexpand\pgfkeyssetvalue{/pgfplots/x coord sorting}{\pgfkeysvalueof{/pgfplots/x coord sorting}}% + \noexpand\pgfkeyssetvalue{/pgfplots/y coord sorting}{\pgfkeysvalueof{/pgfplots/y coord sorting}}% + % + \noexpand\pgfplots@initzerolevelhandler + \the\t@pgfplots@tokc% named start/end points (if already available) + \noexpand\pgfplots@define@currentplotstyle@as{\the\t@pgfplots@toka}% remember 'current plot style' + % per-point meta data ranges which apply only to + % this plot: + \noexpand\xdef\noexpand\pgfplots@metamin{\pgfplots@metamin}% + \noexpand\xdef\noexpand\pgfplots@metamax{\pgfplots@metamax}% + \noexpand\def\noexpand\pgfplotspointmetainputhandler{\pgfplotspointmetainputhandler}% + }% + {% draw command: + \noexpand\draw% + }% + }% + \pgfplotsapplistXXlet\pgfplots@coord@stream@recorded + \pgfplotsapplistXXclear + \t@pgfplots@tokc=\expandafter{\pgfplots@coord@stream@recorded}% + \t@pgfplots@tokb={#1;}% + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% + \xdef\pgfplots@glob@TMPa{% + \the\t@pgfplots@toka + {% coordinates which need to be processed in \endaxis. + % See + % \pgfplots@coord@stream@finalize@storedcoords@START + normalized coordinates {\the\t@pgfplots@tokc}\the\t@pgfplots@tokb + }% + }% + % + % Ok, now assemble the POST COMMANDS. Error bar + % commands will be append here (if any) + \ifx\pgfplots@recordederrorbar\pgfutil@empty + \pgfplots@glob@TMPa + {% + % Post commands are empty here. + }% + \else + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% + \t@pgfplots@tokb=\expandafter{\pgfplots@recordederrorbar}% + \def\pgfplots@loc@TMPb{% + \noexpand\pgfplots@errorbars@finishwithstyleoptions[current plot style]{\the\t@pgfplots@tokb}% + }% + \xdef\pgfplots@glob@TMPa{ + \the\t@pgfplots@toka + { + % Post commands: append error bar commands. + \pgfplots@loc@TMPb + }% + }% + \pgfplots@glob@TMPa + \fi + %^^^^^^^^^^^^ ... END of \pgfplots@addplot@enqueue@coords HERE + \fi + \pgfplots@end@plot +}% + +% PRECONDITION: must be called inside of +% \pgfplots@PREPARE@COORD@STREAM@end@. +% +% POSTCONDITION: +% assigns '/pgfplots/#1 coord sorting=[+-]' +% i.e. whether #1 (x or y or z) coordinates are in ascending (+) ordering or in +% descending order (-). +\def\pgfplots@PREPARE@COORD@STREAM@end@determinecoordsorting#1{% + \pgfplots@if{pgfplots@#1islinear}{% + \pgfmathfloatlessthan@ + {\csname pgfplots@currentplot@firstcoord@#1\endcsname} + {\csname pgfplots@currentplot@lastcoord@#1\endcsname}% + }{% + \pgfplotsmathlessthan + {\csname pgfplots@currentplot@firstcoord@#1\endcsname} + {\csname pgfplots@currentplot@lastcoord@#1\endcsname}% + }% + \ifpgfmathfloatcomparison + \pgfkeyssetvalue{/pgfplots/#1 coord sorting}{+}% + \else + \pgfkeyssetvalue{/pgfplots/#1 coord sorting}{-}% + \fi +}% + +% Assigns default values to 'rows' and 'cols' in case +% their values are empty. +% +% PRECONDITION: +% The values of +% - '/pgfplots/mesh/rows' +% - '/pgfplots/mesh/cols' +% - '/pgfplots/mesh/num points' +% - \pgfplotsscanlinelength +% - '/pgfplots/mesh/ordering' +% are assigned properly. +% +% POSTCONDITION: +% 'rows' and 'cols' now incorporates \pgfplotsscanlinelength if +% their values had been empty. However, there may still be empty +% values. +% +% @see \pgfplotsautocompletemeshkeys +\def\pgfplotspreparemeshkeydefaults{% + \pgfplots@autocomplete@meshkeys0% +}% + +% Completes and sanitizes 'mesh/rows' and 'mesh/cols' such that they +% have useful integer values afterwards. +% +% This method works similarly to \pgfplotspreparemeshkeydefaults. +% However, it really completes values and issues error messages if +% that proves to be impossible. +% +% PRECONDITION: +% The values of +% - '/pgfplots/mesh/rows' +% - '/pgfplots/mesh/cols' +% - '/pgfplots/mesh/num points' +% - '/pgfplots/mesh/ordering' +% are assigned properly. +% If +% - \pgfplotsscanlinelength +% exists and is positive, it may also be used. +% +% POSTCONDITION: +% 'rows' and 'cols' have useful integer values. +\def\pgfplotsautocompletemeshkeys{% + \pgfplots@autocomplete@meshkeys1% +}% +\def\pgfplots@autocomplete@meshkeys#1{% + \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsplothandlermesh@rows + \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsplothandlermesh@cols + \pgfkeysgetvalue{/pgfplots/mesh/num points}\pgfplotsplothandlermesh@numpoints + \edef\pgfplotsplothandlermesh@numpoints{\pgfplotsplothandlermesh@numpoints}% + \edef\pgfplotsplothandlermesh@cols{\pgfplotsplothandlermesh@cols}% + \edef\pgfplotsplothandlermesh@rows{\pgfplotsplothandlermesh@rows}% + \ifpgfplots@curplot@threedim + \ifx\pgfplotsplothandlermesh@rows\pgfutil@empty + \ifx\pgfplotsplothandlermesh@cols\pgfutil@empty + \pgfutil@ifundefined{pgfplotsscanlinelength}{\def\pgfplotsscanlinelength{-1}}{}% + \ifpgfplots@scanline@verbose + \ifnum\pgfplotsscanlinelength>0 + % we have scanlinelength set! Use it: + \message{PGFPlots: Scanline length is \pgfplotsscanlinelength.}% + \else + \ifnum\pgfplotsscanlinelength=-2 + \message{PGFPlots: Scanline length could not be determined as multiple, different scan line lengths have been found.}% + \else + \message{PGFPlots: No end-of-scanline marker found in input stream.}% + \fi + \fi + \fi + \ifnum\pgfplotsscanlinelength>0 + % we have scanlinelength set! Use it: + \if\pgfplots@plot@mesh@ordering0% + % ordering = x varies= rowwise -> scanline is cols! + \edef\pgfplotsplothandlermesh@cols{\pgfplotsscanlinelength}% + \else + % ordering = y varies = colwise: scanline is rows! + \edef\pgfplotsplothandlermesh@rows{\pgfplotsscanlinelength}% + \fi + \else + \if1#1% + % try to get reasonable values: + \ifx\pgfplotsplothandlermesh@numpoints\pgfutil@empty + \pgfplots@error{Sorry, 'plot mesh' needs either '[mesh/rows=<N>]' or '[mesh/cols=<N>]' set - or at least '[mesh/num points=<N>]'. But it did not find any of them...}% + \def\pgfplotsplothandlermesh@cols{5}% + \def\pgfplotsplothandlermesh@rows{5}% + \else + % We don't have rows/cols. Well, try using + % sqrt(num points) for both of them! + \ifnum\pgfplotsplothandlermesh@numpoints<16380 + \pgfmath@basic@sqrt@{\pgfplotsplothandlermesh@numpoints}% + \else + \pgfmathfloatparsenumber{\pgfplotsplothandlermesh@numpoints}% + \pgfmathfloatsqrt@{\pgfmathresult}% + \pgfmathfloattofixed{\pgfmathresult}% + \fi + \begingroup + % Try whether this rows*rows yields numpoints: + \afterassignment\pgfplots@gobble@until@relax + \c@pgf@counta=\pgfmathresult\relax + \c@pgf@countb=\c@pgf@counta + \multiply\c@pgf@counta by\c@pgf@counta + \def\pgfplotsretval{1}% + \ifnum\c@pgf@counta=\pgfplotsplothandlermesh@numpoints\relax + % ok, rows*rows = numpoints. + \xdef\pgfplots@glob@TMPa{\the\c@pgf@countb}% + \else + % oh. Did not work. Check for rounding errors: + \c@pgf@counta=\c@pgf@countb + \advance\c@pgf@counta by1 + \c@pgf@countb=\c@pgf@counta + \multiply\c@pgf@counta by\c@pgf@counta + \ifnum\c@pgf@counta=\pgfplotsplothandlermesh@numpoints + % ok, (rows+1)*(rows+1) = numpoints. + \xdef\pgfplots@glob@TMPa{\the\c@pgf@countb}% + \else + % no... did not work. num points doesn't + % appear to be a squared number. + \def\pgfplotsretval{0}% + \xdef\pgfplots@glob@TMPa{5}% + \fi + \fi + \if\pgfplotsretval1 + \pgfplots@warning{% + 'plot mesh' did not find '[mesh/rows=<N>]' or '[mesh/cols=<N>]'. + Assuming [mesh/rows=\pgfplots@glob@TMPa,mesh/cols=\pgfplots@glob@TMPa] + as sqrt(num points) = sqrt(\pgfplotsplothandlermesh@numpoints) [ = \pgfmathresult].}% + \else + \pgfplots@error{Sorry, 'plot mesh' needs either '[mesh/rows=<N>]' or '[mesh/cols=<N>]' set, + but it did not find any of them. + I also tried rows = sqrt(num points) = sqrt(\pgfplotsplothandlermesh@numpoints) = \pgfmathresult\space without success.}% + \fi + \endgroup + \let\pgfplotsplothandlermesh@rows=\pgfplots@glob@TMPa + \let\pgfplotsplothandlermesh@cols=\pgfplots@glob@TMPa + \fi + \else + % #1=0 -> leave them empty. + \fi + \fi + \fi + \fi + \if1#1% + \ifx\pgfplotsplothandlermesh@rows\pgfutil@empty + \ifx\pgfplotsplothandlermesh@cols\pgfutil@empty + \else + % Compute 'rows' out of 'num points' and 'cols': + \ifx\pgfplotsplothandlermesh@numpoints\pgfutil@empty + \pgfplots@error{Sorry, matrix input needs a valid '[mesh/num points=<N>]' variable if only one of '[mesh/rows=<N>]' or '[mesh/cols=<N>]' is given.}% + \def\pgfplotsplothandlermesh@numpoints{100}% + \fi + \begingroup + \c@pgf@counta=\pgfplotsplothandlermesh@numpoints\relax + \divide\c@pgf@counta by\pgfplotsplothandlermesh@cols\relax + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \let\pgfplotsplothandlermesh@rows=\pgfplots@glob@TMPa + \fi \else - \edef\pgfplots@addplot@preoptionsTMP{/pgfplots/every axis plot,/pgfplots/every axis plot no \the\pgfplots@numplots/.try}% - \expandafter\pgfplots@rememberplotspec\expandafter{\pgfplots@addplot@preoptionsTMP,#1,/pgfplots/every axis plot post}% - \fi - % warning: rememberplotspec calls list macros which - % overwrite \t@pgfplots@toka - \t@pgfplots@toka=\expandafter{\pgfplots@addplot@preoptionsTMP,#1,/pgfplots/every axis plot post}% - \xdef\pgfplots@last@plot@style{\the\t@pgfplots@toka}% store it for \label commands. - % ATTENTION: do NOT call list macros from here on! + \ifx\pgfplotsplothandlermesh@cols\pgfutil@empty + % Compute 'cols' out of 'num points' and 'rows': + \ifx\pgfplotsplothandlermesh@numpoints\pgfutil@empty + \pgfplots@error{Sorry, matrix input needs a valid '[mesh/num points=<N>]' variable if only one of '[mesh/cols=<N>]' or '[mesh/rows=<N>]' is given.}% + \def\pgfplotsplothandlermesh@numpoints{100}% + \fi + \begingroup + \c@pgf@counta=\pgfplotsplothandlermesh@numpoints\relax + \divide\c@pgf@counta by\pgfplotsplothandlermesh@rows\relax + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \endgroup + \let\pgfplotsplothandlermesh@cols=\pgfplots@glob@TMPa + \fi + \fi + \ifx\pgfplotsplothandlermesh@numpoints\pgfutil@empty + \c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@rows\relax + \multiply\c@pgfplots@scanlineindex by \pgfplotsplothandlermesh@cols\relax + \edef\pgfplotsplothandlermesh@numpoints{\the\c@pgfplots@scanlineindex}% + \fi % - \ifpgfplots@datascaletrafo@initialised - \pgfplots@addplot@get@named@startendpoints@command\pgfplots@loc@TMPa - \t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}% + \c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@rows\relax + \multiply\c@pgfplots@scanlineindex by\pgfplotsplothandlermesh@cols\relax + \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@numpoints\relax \else - \t@pgfplots@tokc={}% - \fi - % assembe a \pgfplots@addplot@enqueue@coords command ... - % BEGIN HERE ... - % vvvvvvvvvv - \xdef\pgfplots@glob@TMPa{% - \noexpand\pgfplots@addplot@enqueue@coords - {% precommand(s): - \expandafter\noexpand\csname pgfplots@curplot@threedim\ifpgfplots@curplot@threedim true\else false\fi\endcsname - \noexpand\def\noexpand\plotnum{\the\pgfplots@numplots}% - \noexpand\pgfplots@initzerolevelhandler - \the\t@pgfplots@tokc% named start/end points (if already available) - \noexpand\pgfkeysdef{/tikz/current plot style}{\noexpand\pgfkeysalso{\the\t@pgfplots@toka}}% - % per-point meta data ranges: - \noexpand\xdef\noexpand\pgfplots@metamin{\pgfplots@metamin}% - \noexpand\xdef\noexpand\pgfplots@metamax{\pgfplots@metamax}% - \ifpgfplots@perpointmeta@usesfloat - \noexpand\pgfplots@perpointmeta@usesfloattrue + \ifcase\pgfplots@mesh@checkmode\relax + % mesh/check=false + \def\pgfplots@loc@TMPa##1{}% + \or + % mesh/check=warning + \def\pgfplots@loc@TMPa##1{\pgfplots@warning{##1}}% + \or + % mesh/check=error + \def\pgfplots@loc@TMPa##1{\pgfplots@error{##1}}% + \fi + \pgfplots@loc@TMPa{the arguments of [mesh/rows=\pgfplotsplothandlermesh@rows,mesh/cols=\pgfplotsplothandlermesh@cols] assume \the\c@pgfplots@scanlineindex\space points, but I got actually N = \pgfplotsplothandlermesh@numpoints\space points! The data matrix appears to be incomplete or overcomplete!? [Use mesh/check=false to disable this message]}% + \fi + \fi + \else + % 2d visualization has no mesh: + \edef\pgfplotsplothandlermesh@rows{\pgfplotsplothandlermesh@numpoints}% + \def\pgfplotsplothandlermesh@cols{1}% + \fi + % + \def\pgfplots@loc@TMPa{\pgfkeyssetvalue{/pgfplots/mesh/rows}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotsplothandlermesh@rows}% + \def\pgfplots@loc@TMPa{\pgfkeyssetvalue{/pgfplots/mesh/cols}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotsplothandlermesh@cols}% +}% + +% Prepares a macro \pgfplots@PREPARE@process@errorbar@for@dir##1 +% which can then be used to process error bars. The macro will be +% \relax if error bars are disabled for #1. +% +% #1: either x, y or z. +% +% POSTCONDITION: +% the macro \pgfplots@PREPARE@errorbar@process@#1 will be defined. +% It is supposed to be used inside of the pgfplots streaming methods +% and depends on the arguments +% \pgfplots@current@point@[xyz] +% \pgfplots@current@point@[xyz]@unfiltered +% \pgfplots@current@point@[xyz]@error +% The '@unfilterered' arguments are needed for log plots. I do not +% want to compute exp(current@point@[xyz]) again. +\def\pgfplots@PREPARE@errorbar@processing@in@dir#1{% + \if0\csname pgfplots@errorbars@#1direction\endcsname + % no error bars. Ok. Do nothing here. + \expandafter\let\csname pgfplots@PREPARE@errorbar@process@#1\endcsname=\relax + \else + % + % Prepare a macro which invokes + % \pgfplots@streamerrorbarcoords. + % + % This involves to assign point coordinates in the correct + % ordering; prepare that: + \if x#1% + \ifpgfplots@curplot@threedim + \t@pgfplots@toka={% + {(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)}% + {(\pgfplots@error@coord,\pgfplots@current@point@y,\pgfplots@current@point@z)} + }% + \else + \t@pgfplots@toka={% + {(\pgfplots@current@point@x,\pgfplots@current@point@y)}% + {(\pgfplots@error@coord,\pgfplots@current@point@y)} + }% + \fi + \else + \if y#1% + \ifpgfplots@curplot@threedim + \t@pgfplots@toka={% + {(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)}% + {(\pgfplots@current@point@x,\pgfplots@error@coord,\pgfplots@current@point@z)} + }% + \else + \t@pgfplots@toka={% + {(\pgfplots@current@point@x,\pgfplots@current@point@y)}% + {(\pgfplots@current@point@x,\pgfplots@error@coord)} + }% + \fi + \else + \t@pgfplots@toka={% + {(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)}% + {(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@error@coord)} + }% + \fi + \fi + \begingroup + % no, assemble the macro which will invoke + % \pgfplots@streamerrorbarcoords: + \let\E=\noexpand + \expandafter\xdef\csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname{% + \E\ifx\E\pgfplots@error@coord\E\pgfutil@empty + \E\else + \E\let\E\pgfplots@current@point@@old\expandafter\E\csname pgfplots@current@point@#1\endcsname + \E\let\expandafter\E\csname pgfplots@current@point@#1\endcsname=\E\pgfplots@error@coord + \E\pgfplots@update@limits@for@one@point + \E\let\expandafter\E\csname pgfplots@current@point@#1\endcsname=\E\pgfplots@current@point@@old + \E\edef\E\pgfplots@loc@TMPa{\the\t@pgfplots@toka}% + \E\expandafter\E\pgfplots@streamerrorbarcoords\E\pgfplots@loc@TMPa + \E\fi + }% + \endgroup + % + % The routine which is invoked for every reported input + % coordinate is \pgfplots@process@errorbar@for. + % + % This here prepares its helper macros for direction '#1': + \pgfplots@if{pgfplots@#1islinear}{% + \ifcase\csname pgfplots@errorbars@#1mode\endcsname\relax + % fixed absolute error. + \pgfmathfloatparsenumber{\csname pgfplots@errorbars@#1fixed\endcsname}% + \expandafter\let\csname pgfplots@error@coord@#1\endcsname=\pgfmathresult + \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% + \if +##1% + \pgfmathfloatadd@ + {\csname pgfplots@current@point@#1\endcsname}% + {\csname pgfplots@error@coord@#1\endcsname}% \else - \noexpand\pgfplots@perpointmeta@usesfloatfalse + \pgfmathfloatsubtract@ + {\csname pgfplots@current@point@#1\endcsname}% + {\csname pgfplots@error@coord@#1\endcsname}% \fi - \noexpand\def\noexpand\pgfplots@perpointmeta@choice{\pgfplots@perpointmeta@choice}% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname }% - {% draw command: - \noexpand\draw% + \or% fixed relative error: + \pgfmathfloatparsenumber{\csname pgfplots@errorbars@#1rel\endcsname}% + \let\pgfplots@loc@TMPb=\pgfmathresult + % + % +1: + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfplots@loc@TMPa=\pgfmathresult + % + % Prepare '1 + err': + \pgfmathfloatadd@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% + \expandafter\let\csname pgfplots@error@coord@#1@+\endcsname=\pgfmathresult + % + % Prepare '1 - err': + \pgfmathfloatsubtract@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% + \expandafter\let\csname pgfplots@error@coord@#1@-\endcsname=\pgfmathresult + % + \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% + \pgfmathfloatmultiply@ + {\csname pgfplots@current@point@#1\endcsname} + {\csname pgfplots@error@coord@#1@##1\endcsname}% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname }% - }% - \pgfplotsapplistXXlet\pgfplots@coord@stream@recorded - \pgfplotsapplistXXclear - \t@pgfplots@tokc=\expandafter{\pgfplots@coord@stream@recorded}% - \t@pgfplots@tokb={#2;}% - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% - \xdef\pgfplots@glob@TMPa{% - \the\t@pgfplots@toka - {% coordinates which need to be processed in \endaxis. - % See - % \pgfplots@coord@stream@finalize@storedcoords@START - normalized coordinates {\the\t@pgfplots@tokc}\the\t@pgfplots@tokb + \or% explicit absolute: + \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% + \edef\pgfplots@error@coord{\csname pgfplots@current@point@#1@error\endcsname}% + \ifx\pgfplots@error@coord\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfplots@error@coord}% + \let\pgfplots@error@coord=\pgfmathresult + % remember result here - will be used in case + % of '+' AND '-' error bars: + \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult + \if +##1% + \pgfmathfloatadd@ + {\csname pgfplots@current@point@#1\endcsname}% + {\pgfplots@error@coord}% + \else + \pgfmathfloatsubtract@ + {\csname pgfplots@current@point@#1\endcsname}% + {\pgfplots@error@coord}% + \fi + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + \fi }% - }% + \or% explicit relative: + \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% + \edef\pgfplots@error@coord{\csname pgfplots@current@point@#1@error\endcsname}% + \ifx\pgfplots@error@coord\pgfutil@empty + \else + \pgfmathparse{1##1\pgfplots@error@coord}% + \let\pgfplots@error@coord=\pgfmathresult + \pgfmathfloatmultiply@ + {\csname pgfplots@current@point@#1\endcsname} + {\pgfplots@error@coord}% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + \fi + }% + \fi + }{% + % LOGARITHMIC scaling. All errors are interpreted as + % log(x +- e_x) + % or + % log( x*(1+-e_x) ) % - % Ok, now assemble the POST COMMANDS. Error bar - % commands will be append here (if any) - \ifx\pgfplots@recordederrorbar\pgfutil@empty - \pgfplots@glob@TMPa - {% - % Post commands are empty here. - }% - \else - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% - \t@pgfplots@tokb=\expandafter{\pgfplots@recordederrorbar}% - \def\pgfplots@loc@TMPb{% - \noexpand\pgfplots@errorbars@finishwithstyleoptions[current plot style]{\the\t@pgfplots@tokb}% + % That means any input argument is + % given in log base e and in fixed point. + % Furthermore, we expect the '@unfiltered' keys to be + % present (I don't want to apply 'exp' again!). + % + \ifcase\csname pgfplots@errorbars@#1mode\endcsname + % fixed absolute, log( x +- e_x ) + \pgfmathfloatparsenumber{\csname pgfplots@errorbars@#1fixed\endcsname}% + \expandafter\let\csname pgfplots@error@coord@#1\endcsname=\pgfmathresult + \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% + \pgfmathfloatparsenumber{\csname pgfplots@current@point@#1@unfiltered\endcsname}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \if +##1% + \pgfmathfloatadd@ + {\pgfplots@loc@TMPa}% + {\csname pgfplots@error@coord@#1\endcsname}% + \else + \pgfmathfloatsubtract@ + {\pgfplots@loc@TMPa}% + {\csname pgfplots@error@coord@#1\endcsname}% + \fi + \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname }% - \xdef\pgfplots@glob@TMPa{ - \the\t@pgfplots@toka - { - % Post commands: append error bar commands. - \pgfplots@loc@TMPb - }% + \or% fixed relative, log( x ( 1+-e_x ) ) = log(x) + log(1+-e_x) + \pgfmathfloatparsenumber{\csname pgfplots@errorbars@#1rel\endcsname}% + \let\pgfplots@loc@TMPb=\pgfmathresult + % + % +1: + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfplots@loc@TMPa=\pgfmathresult + % + % Prepare '1 + err': + \pgfmathfloatadd@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% + \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + % 1 + err <= 0 and log(1+err) is undefined: + \pgfmathfloattofixed{\pgfplots@loc@TMPb}% + \pgfplots@error{Sorry, log(1+\pgfmathresult) is undefined. Please provide a different argument for '/pgfplots/error bar/#1 fixed relative'.}% + \let\pgfmathresult=\pgfutil@empty + \fi + \expandafter\let\csname pgfplots@error@coord@#1@+\endcsname=\pgfmathresult + % + % Prepare '1 - err': + \pgfmathfloatsubtract@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% + \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% + \ifx\pgfmathresult\pgfutil@empty + % 1 + err <= 0 and log(1+err) is undefined: + \pgfmathfloattofixed{\pgfplots@loc@TMPb}% + \pgfplots@error{Sorry, log(1-\pgfmathresult) is undefined. Please provide a different argument for '/pgfplots/error bar/#1 fixed relative'.}% + \let\pgfmathresult=\pgfutil@empty + \fi + \expandafter\let\csname pgfplots@error@coord@#1@-\endcsname=\pgfmathresult + % + \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% + \expandafter\ifx\csname pgfplots@current@point@#1@##1\endcsname\pgfutil@empty + \else + \pgfmath@basic@add@ + {\csname pgfplots@current@point@#1\endcsname} + {\csname pgfplots@error@coord@#1@##1\endcsname}% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + \fi + }% + \or% explicit absolute + % log( x +- e_x ) + \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% + \edef\pgfplots@error@coord{\csname pgfplots@current@point@#1@error\endcsname}% + \ifx\pgfplots@error@coord\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfplots@error@coord}% + \let\pgfplots@error@coord=\pgfmathresult + % remember result here - will be used in case + % of '+' AND '-' error bars: + \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult + \pgfmathfloatparsenumber{\csname pgfplots@current@point@#1@unfiltered\endcsname}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \if +##1% + \pgfmathfloatadd@ + {\pgfplots@loc@TMPa}% + {\pgfplots@error@coord}% + \else + \pgfmathfloatsubtract@ + {\pgfplots@loc@TMPa}% + {\pgfplots@error@coord}% + \fi + \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + \fi }% - \pgfplots@glob@TMPa + % + \or% explicit relative: + % log( x ( 1+-e_x ) ) = log(x) + log(1+-e_x) + \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% + \edef\pgfplots@error@coord{\csname pgfplots@current@point@#1@error\endcsname}% + \ifx\pgfplots@error@coord\pgfutil@empty + \else + \pgfmathfloatparsenumber{\pgfplots@error@coord}% + \let\pgfplots@error@coord=\pgfmathresult + % remember result here - will be used in case + % of '+' AND '-' error bars: + \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult + % + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \if +##1% + \pgfmathfloatadd@ + {\pgfplots@loc@TMPa}% + {\pgfplots@error@coord}% + \else + \pgfmathfloatsubtract@ + {\pgfplots@loc@TMPa}% + {\pgfplots@error@coord}% + \fi + \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% + \let\pgfplots@error@coord=\pgfmathresult + \ifx\pgfplots@error@coord\pgfutil@empty + % -> log( <= 0 ) -> do nothing. + \else + \pgfmath@basic@add@ + {\csname pgfplots@current@point@#1\endcsname} + {\pgfplots@error@coord}% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + \fi + \fi + }% + % \fi - %^^^^^^^^^^^^ ... END of \pgfplots@addplot@enqueue@coords HERE -% \fi - \pgfplots@end@plot - }% -}% + }% + \ifcase\csname pgfplots@errorbars@#1direction\endcsname + % none + \or + % plus + \expandafter\edef\csname pgfplots@PREPARE@errorbar@process@#1\endcsname{% + \expandafter\noexpand\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname+% + }% + \or + % minus + \expandafter\edef\csname pgfplots@PREPARE@errorbar@process@#1\endcsname{% + \expandafter\noexpand\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname-% + }% + \or + % both + \expandafter\edef\csname pgfplots@PREPARE@errorbar@process@#1\endcsname{% + \expandafter\noexpand\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname+% + \expandafter\noexpand\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname-% + }% + \fi + \fi +} % Defines the linear transformation macro \pgfplots@perpointmeta@trafo, % @@ -1422,63 +3250,126 @@ % The trafo will be skipped if there is no such data. % % The trafo is expected to prepare meta information before it is used -% as input to \pgfplotscolormapfind. Thus, the 10^k is chosen to be +% as input to \pgfplotscolormapaccess (or +% \pgfplotscolormapdefinemappedcolor). Thus, the 10^k is chosen to be % the same as \pgfplotscolormaprange (which is 1000 per default). % -% If there is now data range (for example because meta information is +% If there is no data range (for example because meta information is % not available or is not of numeric type), the trafo will simply % copy the input argument symbolically. \def\pgfplots@perpointmeta@preparetrafo{% - \ifx\pgfplots@metamax\pgfutil@empty - \def\pgfplots@perpointmeta@trafo##1{\def\pgfmathresult{##1}}% - \def\pgfplots@perpointmeta@traforange{0:0}% - \else - % The transformation is - % - % phi(m) = ( m- meta_min) * 1000/ (meta_max-meta_min). - % - % -> precompute the scaling factor! - \ifpgfplots@perpointmeta@usesfloat - \edef\pgfplots@loc@TMPa{\pgfplotscolormaprange}% - \ifnum\pgfplots@loc@TMPa=1000 - \else - \pgfplots@error{LOGIC ERROR: sorry, I have hard-coded the assumption \string\pgfplotscolormaprange = 1000, but now it is \pgfplots@loc@TMPa.}% + \let\pgfplots@current@point@meta=\pgfutil@empty + \pgfutil@ifundefined{pgfplots@metamax}{\let\pgfplots@metamax=\pgfutil@empty}{} + \ifpgfplots@warn@for@filter@discards + \global\let\pgfplots@perpointmeta@unboundedwarning@stop=\relax + \def\pgfplots@perpointmeta@unboundedwarning##1{% + \ifx\pgfplots@perpointmeta@unboundedwarning@stop\relax + \begingroup + \pgfmathfloattofixed{##1}% + \pgfplots@warning{The per point meta data `\pgfmathresult' (##1) (and probably others as well) is unbounded - using the minimum value instead.}% + \endgroup + \gdef\pgfplots@perpointmeta@unboundedwarning@stop{1}% \fi - \pgfmathfloatsubtract@{\pgfplots@metamax}{\pgfplots@metamin}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \pgfmathfloatcreate{1}{1.0}{3}% - \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPa}% - \let\pgfplots@perpointmeta@trafo@factor=\pgfmathresult - % - % Now, setup the trafo as such. - % It assigns \pgfmathresult (in fixed point). + }% + \else + \def\pgfplots@perpointmeta@unboundedwarning##1{}% + \fi + \if m\pgfplots@colormap@access + % colormap access=map + \ifx\pgfplots@metamax\pgfutil@empty \def\pgfplots@perpointmeta@trafo##1{% - \pgfmathfloatsubtract@{##1}{\pgfplots@metamin}% - \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}% - \expandafter\pgfmathfloattofixed@\expandafter{\pgfmathresult}% + \pgfmathfloatiffinite{##1}{% + \pgfmathfloattofixed@{##1}% + }{% + \def\pgfmathresult{0}% + \pgfplots@perpointmeta@unboundedwarning{##1}% + }% }% - % Expands to the transformation range as 'a:b': \def\pgfplots@perpointmeta@traforange{0:1000}% + \edef\pgfplotspointmetarange{0:1000}% \else + % The transformation is + % + % phi(m) = ( m- meta_min) * 1000/ (meta_max-meta_min). + % + % -> precompute the scaling factor! \edef\pgfplots@loc@TMPa{\pgfplotscolormaprange}% \ifnum\pgfplots@loc@TMPa=1000 \else \pgfplots@error{LOGIC ERROR: sorry, I have hard-coded the assumption \string\pgfplotscolormaprange = 1000, but now it is \pgfplots@loc@TMPa.}% \fi - \pgfmathsubtract@{\pgfplots@metamax}{\pgfplots@metamin}% + \if\pgfplots@perpointmeta@rel@choice0% + % point meta rel=axis wide: + \edef\pgfplotspointmetarange{\pgfplots@axiswide@metamin:\pgfplots@axiswide@metamax}% + % Now, prepare the trafo as such. + % It assigns \pgfmathresult (in fixed point). + \def\pgfplots@perpointmeta@trafo##1{% + \pgfmathfloatiffinite{##1}{% + \pgfmathfloatsubtract@{##1}{\pgfplots@axiswide@metamin}% + \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}% + \expandafter\pgfmathfloattofixed@\expandafter{\pgfmathresult}% + }{% + \def\pgfmathresult{0}% + \pgfplots@perpointmeta@unboundedwarning{##1}% + }% + }% + \pgfmathfloatsubtract@{\pgfplots@axiswide@metamax}{\pgfplots@axiswide@metamin}% + \else + % point meta rel=per plot: + \edef\pgfplotspointmetarange{\pgfplots@metamin:\pgfplots@metamax}% + % Now, prepare the trafo as such. + % It assigns \pgfmathresult (in fixed point). + \def\pgfplots@perpointmeta@trafo##1{% + \pgfmathfloatiffinite{##1}{% + \pgfmathfloatsubtract@{##1}{\pgfplots@metamin}% + \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}% + \expandafter\pgfmathfloattofixed@\expandafter{\pgfmathresult}% + }{% + \def\pgfmathresult{0}% + \pgfplots@perpointmeta@unboundedwarning{##1}% + }% + }% + \pgfmathfloatsubtract@{\pgfplots@metamax}{\pgfplots@metamin}% + \fi \let\pgfplots@loc@TMPa=\pgfmathresult - \expandafter\pgfmathdivide@\expandafter{\pgfplotscolormaprange}{\pgfplots@loc@TMPa}% + \pgfmathfloatcreate{1}{1.0}{3}% + \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPa}% \let\pgfplots@perpointmeta@trafo@factor=\pgfmathresult % - % Now, setup the trafo as such. - % It assigns \pgfmathresult (in fixed point). - \def\pgfplots@perpointmeta@trafo##1{% - \pgfmathsubtract@{##1}{\pgfplots@metamin}% - \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}% - }% % Expands to the transformation range as 'a:b': \def\pgfplots@perpointmeta@traforange{0:1000}% \fi + \else + % colormap access=direct + \def\pgfplots@perpointmeta@trafo##1{ + \pgfmathfloatiffinite{##1}{% + \pgfmathfloattofixed@{##1}% + }{% + \def\pgfmathresult{0}% + \pgfplots@perpointmeta@unboundedwarning{##1}% + }% + }% + \def\pgfplots@perpointmeta@traforange{0:0}% + \edef\pgfplotspointmetarange{\pgfplots@metamin:\pgfplots@metamax}% + \fi + \edef\pgfplotspointmetatransformedrange{\pgfplots@perpointmeta@traforange}% +}% +\def\pgfplots@perpointmeta@trafo@APPLY{% + \ifx\pgfplots@current@point@meta\pgfutil@empty% + \pgfplots@error{could not access the 'point meta' (used for example by scatter plots and color maps). Maybe you need to add '\string\addplot[point meta=y]' or something like that?}% + \pgfmathfloatcreate{1}{1.0}{0}% + \let\pgfplotspointmeta=\pgfmathresult + \def\pgfplotspointmetatransformed{1.0}% + \else + % prepare arguments: + \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname + \let\pgfplotspointmeta=\pgfplots@current@point@meta + \let\pgfplotspointmetatransformed=\pgfplotspointmeta + \else + \let\pgfplotspointmeta=\pgfplots@current@point@meta + \pgfplots@perpointmeta@trafo{\pgfplotspointmeta}% + \let\pgfplotspointmetatransformed=\pgfmathresult + \fi \fi }% @@ -1504,7 +3395,9 @@ % The per-point meta is not implemented yet. \long\def\pgfplots@coord@stream@foreach#1{% \pgfplots@coord@stream@start + \pgfplotsscanlinelengthinitzero \pgfplots@foreach@plot@coord@ITERATE#1\pgfplots@EOI% + \pgfplotsscanlinelengthcleanup \pgfplots@coord@stream@end }% @@ -1518,9 +3411,11 @@ \pgfplots@foreach@plot@coord@FINISH% }{% \pgfutil@ifnextchar\par{% + \pgfplotsscanlinecomplete \pgfplots@foreach@plot@coord@ITERATE@gobbleone }{% \pgfutil@ifnextchar({% + \pgfplotsscanlinelengthincrease \pgfplots@foreach@plot@coord@NEXT% }{% \pgfplots@foreach@plot@coord@error @@ -1533,8 +3428,13 @@ }% \long\def\pgfplots@foreach@plot@coord@ITERATE@gobbleone#1{\pgfplots@foreach@plot@coord@ITERATE}% \def\pgfplots@foreach@plot@coord@NEXT(#1,#2){% - \def\pgfplots@current@point@x{#1}% - \def\pgfplots@current@point@y{#2}% + \ifpgfplots@plot@coords@mathparser + \pgfmathparse{#1}\let\pgfplots@current@point@x=\pgfmathresult + \pgfmathparse{#2}\let\pgfplots@current@point@y=\pgfmathresult + \else + \def\pgfplots@current@point@x{#1}% + \def\pgfplots@current@point@y{#2}% + \fi \pgfutil@ifnextchar+{% \pgfplots@foreach@plot@coord@NEXT@WITH@ERRORRANGE% }{% @@ -1559,8 +3459,13 @@ \pgfplots@foreach@plot@coord@NEXT@WITH@ERRORRANGE@% } \def\pgfplots@foreach@plot@coord@NEXT@WITH@ERRORRANGE@#1,#2){% - \def\pgfplots@current@point@x@error{#1}% - \def\pgfplots@current@point@y@error{#2}% + \ifpgfplots@plot@coords@mathparser + \pgfmathparse{#1}\let\pgfplots@current@point@x@error=\pgfmathresult + \pgfmathparse{#2}\let\pgfplots@current@point@y@error=\pgfmathresult + \else + \def\pgfplots@current@point@x@error{#1}% + \def\pgfplots@current@point@y@error{#2}% + \fi \pgfutil@ifnextchar[{% \pgfplots@foreach@plot@coord@NEXT@meta }{% @@ -1576,7 +3481,9 @@ % The same for three dim coords: \long\def\pgfplots@coord@stream@foreach@threedim#1{% \pgfplots@coord@stream@start + \pgfplotsscanlinelengthinitzero \pgfplots@foreach@plot@coord@threedim@ITERATE#1\pgfplots@EOI% + \pgfplotsscanlinelengthcleanup \pgfplots@coord@stream@end }% \def\pgfplots@foreach@plot@coord@threedim@ITERATE{% @@ -1584,9 +3491,11 @@ \pgfplots@foreach@plot@coord@FINISH% }{% \pgfutil@ifnextchar\par{% + \pgfplotsscanlinecomplete \pgfplots@foreach@plot@coord@threedim@ITERATE@gobbleone }{% \pgfutil@ifnextchar({% + \pgfplotsscanlinelengthincrease \pgfplots@foreach@plot@coord@threedim@NEXT% }{% \pgfplots@foreach@plot@coord@error @@ -1596,9 +3505,15 @@ } \long\def\pgfplots@foreach@plot@coord@threedim@ITERATE@gobbleone#1{\pgfplots@foreach@plot@coord@threedim@ITERATE}% \def\pgfplots@foreach@plot@coord@threedim@NEXT(#1,#2,#3){% - \def\pgfplots@current@point@x{#1}% - \def\pgfplots@current@point@y{#2}% - \def\pgfplots@current@point@z{#3}% + \ifpgfplots@plot@coords@mathparser + \pgfmathparse{#1}\let\pgfplots@current@point@x=\pgfmathresult + \pgfmathparse{#2}\let\pgfplots@current@point@y=\pgfmathresult + \pgfmathparse{#3}\let\pgfplots@current@point@z=\pgfmathresult + \else + \def\pgfplots@current@point@x{#1}% + \def\pgfplots@current@point@y{#2}% + \def\pgfplots@current@point@z{#3}% + \fi \pgfutil@ifnextchar+{% \pgfplots@foreach@plot@coord@threedim@NEXT@WITH@ERRORRANGE% }{% @@ -1624,9 +3539,15 @@ \pgfplots@foreach@plot@coord@threedim@NEXT@WITH@ERRORRANGE@% } \def\pgfplots@foreach@plot@coord@threedim@NEXT@WITH@ERRORRANGE@#1,#2,#3){% - \def\pgfplots@current@point@x@error{#1}% - \def\pgfplots@current@point@y@error{#2}% - \def\pgfplots@current@point@z@error{#3}% + \ifpgfplots@plot@coords@mathparser + \pgfmathparse{#1}\let\pgfplots@current@point@x@error=\pgfmathresult + \pgfmathparse{#2}\let\pgfplots@current@point@y@error=\pgfmathresult + \pgfmathparse{#3}\let\pgfplots@current@point@z@error=\pgfmathresult + \else + \def\pgfplots@current@point@x@error{#1}% + \def\pgfplots@current@point@y@error{#2}% + \def\pgfplots@current@point@z@error{#3}% + \fi \pgfutil@ifnextchar[{% \pgfplots@foreach@plot@coord@threedim@NEXT@meta }{% @@ -1746,7 +3667,7 @@ } \long\def\pgfplots@addplotimplAPPEND+[{% - \expandafter\pgfplots@addplotimpl\expandafter[\nextplotspec, + \expandafter\pgfplots@addplotimpl\expandafter[\nextplotspec,% } \long\def\pgfplots@addplotimpl[#1]{% @@ -1768,6 +3689,10 @@ \def\pgfplots@addplotimpl@plot@withoptions#1[#2]{ \begingroup% <-- This groups ends in \pgfplots@end@plot % + % make sure it is reset, just in case it is not supported by the + % input method. + \pgfplotsscanlinelengthinitzero + % \pgfutil@ifnextchar c{% \pgfplots@addplotimpl@coordinates{#1}{#2}plot }{% @@ -1775,8 +3700,8 @@ \pgfplots@addplotimpl@f{#1}{#2}% }{% \pgfutil@ifnextchar t{% - \pgfplots@start@plot@with@behavioroptions{#2}% - \pgfplots@addplotimpl@table{#1}% + \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2}% + \pgfplots@addplotimpl@table{#1,#2}% }{% \pgfutil@ifnextchar ({% \pgfplots@addplotimpl@expression{#1}{#2}% @@ -1790,8 +3715,13 @@ \pgfutil@ifnextchar g{% \pgfplots@addplotimpl@g{#1}{#2}% }{% - \pgfplots@error{Sorry, the supplied plot command is unknown or unsupported by pgfplots! Ignoring it.}% - \pgfplots@gobble@until@semicolon + \pgfutil@ifnextchar s{% + \pgfplots@addplotimpl@shell{#1}{#2}% + }{% + + \pgfplots@error{Sorry, the supplied plot command is unknown or unsupported by pgfplots! Ignoring it.}% + \pgfplots@gobble@until@semicolon + }% }% }% }% @@ -1810,6 +3740,85 @@ \def\pgfplots@gobble@until@semicolon#1;{} +% PRECONDITION: +% the key-value sets have all been set in the current scope. +% +% POSTCONDITION: +% 1. the following macros are initialised and sanitized: +% \pgfplots@plot@domain +% \pgfplots@plot@ydomain (will be set to \pgfplots@plot@domain if empty) +% \pgfplots@plot@samples@at +% \pgfplots@plot@samples@y (will be set to the x variant if empty) +% \tikz@plot@var +% \pgfplots@plot@var@nonmacro +% \pgfplots@plot@var@y +% \pgfplots@plot@var@y@nonmacro +% 2. the following key-value things are set: +% /pgfplots/mesh/rows +% /pgfplots/mesh/cols +% /pgfplots/samples y (will contain a value ) +% 3. the macro +% \b@pgfplots@should@sample@LINE +% will be +% \def\b@pgfplots@should@sample@LINE{1} +% if the expression plotter should sample a line +% and +% \def\b@pgfplots@should@sample@LINE{0} +% if it should samples a mesh. +\def\pgfplots@plot@expression@preparekeys{% + \pgfkeysgetvalue{/pgfplots/domain}\pgfplots@plot@domain + \pgfkeysgetvalue{/pgfplots/samples y}\pgfplots@plot@samples@y + \pgfkeysgetvalue{/pgfplots/samples at}\pgfplots@plot@samples@at + \pgfkeysgetvalue{/pgfplots/variable y}\pgfplots@plot@var@y + % + % \tikz@plot@var is '\x' be default: + \pgfplots@gettikzinternal@keyval{variable}{tikz@plot@var}{\x}% + % + {% + \escapechar=-1 + \xdef\pgfplots@glob@TMPa{\expandafter\string\tikz@plot@var}% + \xdef\pgfplots@glob@TMPb{\expandafter\string\pgfplots@plot@var@y}% + }% + % \pgfplots@plot@var@nonmacro is the value '\tikz@plot@var' + % without the '\', i.e. 'x' by default: + \let\pgfplots@plot@var@nonmacro=\pgfplots@glob@TMPa + \let\pgfplots@plot@var@y@nonmacro=\pgfplots@glob@TMPb + % + % Check if we have to sample a line. + \def\b@pgfplots@should@sample@LINE{0}% + \ifpgfplots@curplot@threedim + \pgfkeysgetvalue{/pgfplots/y domain}{\pgfplots@plot@ydomain}% + \edef\pgfplots@plot@ydomain{\pgfplots@plot@ydomain}% + \def\pgfplots@loc@TMPa{0:0}% + \ifx\pgfplots@plot@ydomain\pgfplots@loc@TMPa + \def\b@pgfplots@should@sample@LINE{1}% + \fi + \ifx\pgfplots@plot@ydomain\pgfutil@empty + \let\pgfplots@plot@ydomain=\pgfplots@plot@domain + \pgfkeyssetvalue{/pgfplots/y domain}{\pgfkeysvalueof{/pgfplots/domain}}% + \fi + \ifx\pgfplots@plot@samples@y\pgfutil@empty + \else + \ifnum\pgfplots@plot@samples@y<2 + \def\b@pgfplots@should@sample@LINE{1}% + \fi + \fi + \else + \def\b@pgfplots@should@sample@LINE{1}% + \fi + \ifx\pgfplots@plot@samples@y\pgfutil@empty + \pgfkeyssetvalue{/pgfplots/samples y}{\pgfkeysvalueof{/pgfplots/samples}}% + \pgfkeysgetvalue{/pgfplots/samples y}\pgfplots@plot@samples@y + \fi + % + \pgfkeyssetvalue{/pgfplots/mesh/rows}{\pgfkeysvalueof{/pgfplots/samples y}}% + \pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/samples}}% + \if1\b@pgfplots@should@sample@LINE + \pgfkeyssetvalue{/pgfplots/mesh/cols}{1}% + \fi + % +}% + % Plot expression. It invokes the pgf math parser and a customized % pgfplots point sampling routine. Combined with the 'fixed point % library' of pgf, it results in highly accurate plots. @@ -1818,18 +3827,10 @@ \long\def\pgfplots@addplotimpl@expression#1#2(#3,#4)#5;{\pgfplots@addplotimpl@expression@{#1}{#2}{#3}{#4}{#5}}% % \addplot[#1] [#2] (#3,#4) #5; \long\def\pgfplots@addplotimpl@expression@#1#2#3#4#5{% - \ifpgfplots@usefpu - \def\pgfplots@loc@TMPa{/pgf/fpu=true}% - \else - \let\pgfplots@loc@TMPa=\pgfutil@empty - \fi - \expandafter\pgfplots@start@plot@with@behavioroptions\expandafter{\pgfplots@loc@TMPa,#2}% - \pgfplots@PREPARE@COORD@STREAM{#1}{#5}% + \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2,/pgfplots/mesh/ordering/x varies}% + \pgfplots@plot@expression@preparekeys % - \pgfplots@validate@plot@domain@arguments - \pgfkeysgetvalue{/pgfplots/domain}\pgfplots@plot@domain - \pgfkeysgetvalue{/pgfplots/samples at}\pgfplots@plot@samples@at - \pgfplots@gettikzinternal@keyval{variable}{tikz@plot@var}{\x}% + \pgfplots@PREPARE@COORD@STREAM{#5}% % % Determine whether the x range is parameterized or uniform and % prepare a macro which assigns \pgfplots@current@point@x: @@ -1858,52 +3859,52 @@ }% \fi % - % Define a "function" x which sets \pgfmathresult := \x : - \pgfutil@ifundefined{pgfmathdeclarefunction}{% - % We have PGF 2.00 : - \def\pgfmath@parsefunction@x{\edef\pgfmathresult{\tikz@plot@var}\pgfmath@postfunction}% - \def\pgfmath@parsefunction@y{\let\pgfmathresult=\y\pgfmath@postfunction}% - }{% - % We have PGF > 2.00 : - \pgfmathdeclarefunction{x}{0}{\edef\pgfmathresult{\tikz@plot@var}}% - \pgfmathdeclarefunction{y}{0}{\let\pgfmathresult=\y}% - }% % % Now, prepare the loops. % % I am using \pgfplotsforeachungrouped in favor of % \foreach because \foreach does NOT allow extended - % precision. Besided, \pgfplotsforeachungrouped avoids + % precision. Besides, \pgfplotsforeachungrouped avoids % scoping problems. % \ifpgfplots@curplot@threedim - \pgfkeysgetvalue{/pgfplots/y domain}{\pgfplots@plot@ydomain}% \def\pgfplots@addplotimpl@expression@split@yz##1,##2\pgfplots@EOI{% \def\pgfplots@addplotimpl@expression@yEXPR{##1}% \def\pgfplots@addplotimpl@expression@zEXPR{##2}% }% \pgfplots@addplotimpl@expression@split@yz#4\pgfplots@EOI% - \ifx\pgfplots@plot@ydomain\pgfutil@empty - \def\pgfplots@plot@ydomain{0:0}% - \fi - \ifx\pgfplots@plot@samples@at\pgfutil@empty - % we don't have 'samples at' -> use domain! - \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@domain\relax - \let\pgfplots@loc@TMPa=\pgfplotslocretval + % + % we don't have 'samples at' for 3D plots -> use domain! + \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@domain\relax{\pgfplots@plot@samples}% + \let\pgfplots@expression@xdomain=\pgfplotsretval + % + \if0\b@pgfplots@should@sample@LINE + % Samples twodimensionally (a lattice): + \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@ydomain\relax{\pgfplots@plot@samples@y}% + \let\pgfplots@expression@ydomain=\pgfplotsretval + % + % Assemble a + % \pgfplots@plot@data##1 -> + % \foreach \y in {-5,-4.6,...,5} {##1}; + % \foreach \x in {-5,-4.6,...,5} + % macro: + \edef\pgfplots@plot@data##1{% + \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\pgfplots@plot@var@y in {\pgfplots@expression@ydomain} + {\noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@expression@xdomain} {##1}}}% \else - % use 'samples at': - \let\pgfplots@loc@TMPa=\pgfplots@plot@samples@at + % sample a line: + \def\pgfplots@plot@ydomain{0:0}% + \edef\pgfplots@plot@data##1{% + \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@expression@xdomain} {##1}}% + % + % If we have (\x,\y,f(x)), use (\x,0,f(x)) instead and + % suppress the error message which would occur for \y. + \expandafter\pgfplotsutilifstringequal\expandafter{\pgfplots@addplotimpl@expression@yEXPR}{\pgfplots@plot@var@y}{% + \def\pgfplots@addplotimpl@expression@yEXPR{0}% + }{% + \expandafter\edef\pgfplots@plot@var@y{\pgfplots@plot@var@y@nonmacro}% this provides an error message, see above. + }% \fi - \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@ydomain\relax - \let\pgfplots@loc@TMPb=\pgfplotslocretval - % Assemble a - % \pgfplots@plot@data##1 -> - % \foreach \x in {-5,-4.6,...,5} - % \foreach \y in {-5,-4.6,...,5} {##1}; - % macro: - \edef\pgfplots@plot@data##1{% - \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@loc@TMPa} - {\noexpand\pgfplotsforeachungrouped\noexpand\y in {\pgfplots@loc@TMPb} {##1}}}% \else % Assemble a % \pgfplots@plot@data##1 -> \foreach \x in {-5,-4.6,...,5} {##1} macro: @@ -1927,7 +3928,7 @@ \if\pgfplots@samples@logarithmically1% % sample logarithmically: \edef\pgfplots@plot@data##1{% - \noexpand\pgfplotsforeachlogarithmicungrouped + \noexpand\pgfplotsforeachlogarithmicungrouped[\pgfplots@plot@samples] \expandafter\noexpand\tikz@plot@var/\noexpand\pgfplots@current@point@x@log in {\pgfplots@plot@domain} {##1}}% % we have a logarithmic sampling sequence, @@ -1953,8 +3954,8 @@ \else \ifx\pgfplots@plot@samples@at\pgfutil@empty % we don't have 'samples at' -> use domain! - \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@domain\relax - \let\pgfplots@loc@TMPa=\pgfplotslocretval + \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@domain\relax{\pgfplots@plot@samples}% + \let\pgfplots@loc@TMPa=\pgfplotsretval \else % use 'samples at': \let\pgfplots@loc@TMPa=\pgfplots@plot@samples@at @@ -1962,12 +3963,43 @@ \edef\pgfplots@plot@data##1{ \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@loc@TMPa} {##1}}% \fi - \def\y{0}% + \expandafter\def\pgfplots@plot@var@y{0}% \def\pgfplots@addplotimpl@expression@yEXPR{#4}% \def\pgfplots@current@point@z{}% \fi + % + % START: + % (NOTE: this does also define 'x', 'y', and 'z' math + % expressions!) \pgfplots@coord@stream@start + % + % create a backup of the 'x' and 'y' math expressions which + % have been defined in \pgfplots@coord@stream@start: + \let\pgfplots@addplotimpl@expression@pseudoconst@old@x=\pgfmathx@ + \let\pgfplots@addplotimpl@expression@pseudoconst@old@y=\pgfmathy@ + % + % Prepare 'x' and 'y' as pseudo constants in expressions: + \gdef\pgfplots@noy@error{% + \pgfplots@error{Sorry, you can't use 'y' in this context. PGFPlots expected to sample a line, not a mesh. Please use the [mesh] option combined with [samples y>0] and [domain y!=0:0] to indicate a twodimensional input domain}% + \global\let\pgfplots@noy@error=\relax + }% + % Define a "function" x which sets \pgfmathresult := \x : + \pgfplotsmathdeclarepseudoconstant{\pgfplots@plot@var@nonmacro}{\edef\pgfmathresult{\tikz@plot@var}}% + \if0\b@pgfplots@should@sample@LINE + % surface: + \pgfplotsmathdeclarepseudoconstant{\pgfplots@plot@var@y@nonmacro}{\edef\pgfmathresult{\pgfplots@plot@var@y}}% + \else + \pgfplotsmathdeclarepseudoconstant{\pgfplots@plot@var@y@nonmacro}{\pgfplots@noy@error\def\pgfmathresult{0.0}}% + \fi + % remember them here: + \let\pgfplots@addplotimpl@expression@pseudoconst@x=\pgfmathx@ + \let\pgfplots@addplotimpl@expression@pseudoconst@y=\pgfmathy@ + % + % \pgfplots@plot@data{% + \let\pgfmathx@=\pgfplots@addplotimpl@expression@pseudoconst@x + \let\pgfmathy@=\pgfplots@addplotimpl@expression@pseudoconst@y + % eval expressions: \pgfplots@addplotimpl@expression@prepare@x% \pgfmathparse{\pgfplots@addplotimpl@expression@yEXPR}% \let\pgfplots@current@point@y=\pgfmathresult @@ -1975,6 +4007,11 @@ \pgfmathparse{\pgfplots@addplotimpl@expression@zEXPR}% \let\pgfplots@current@point@z=\pgfmathresult \fi + % restore 'x' and 'y': + \let\pgfmathx@=\pgfplots@addplotimpl@expression@pseudoconst@old@x + \let\pgfmathy@=\pgfplots@addplotimpl@expression@pseudoconst@old@y + % + % process coords as usual: \pgfplots@coord@stream@coord }% \pgfplots@coord@stream@end @@ -1983,8 +4020,22 @@ \long\def\pgfplots@addplotimpl@expression@curly#1#2#3#4;{\pgfplots@addplotimpl@expression@curly@{#1}{#2}{#3}{#4}}% \long\def\pgfplots@addplotimpl@expression@curly@#1#2#3#4{% \pgfplots@gettikzinternal@keyval{variable}{tikz@plot@var}{\x}% - \def\pgfplots@loc@TMPa{\pgfplots@addplotimpl@expression@{#1}{#2}}% - \expandafter\pgfplots@loc@TMPa\expandafter{\tikz@plot@var}{#3}{#4}% + \ifpgfplots@curplot@threedim + \t@pgfplots@toka={,#3}% + \def\pgfplots@loc@TMPa{\pgfplots@addplotimpl@expression@{#1}{#2}}% + % the \pgfplots@plot@var@y will expand to the current value of + % '/pgfplots/variable y'. + % Keep it this way, \pgfplots@addplotimpl@expression@ checks + % for that special string. + \edef\pgfplots@loc@TMPb{% + {\expandafter\noexpand\tikz@plot@var}% + {\noexpand\pgfplots@plot@var@y\the\t@pgfplots@toka}% + }% + \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb{#4}% + \else + \def\pgfplots@loc@TMPa{\pgfplots@addplotimpl@expression@{#1}{#2}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\tikz@plot@var}{#3}{#4}% + \fi }% % \addplot[#1] [#2] expression[#3] {#4} #5; \def\pgfplots@addplotimpl@expression@e#1#2expression{% @@ -2025,15 +4076,7 @@ % |\addplot gnuplot| is an alias to |\addplot function| \def\pgfplots@addplotimpl@gnuplot#1#2nuplot{\pgfplots@addplotimpl@function{#1}{#2}unction}% -% \addplot[<style options>] -% plot[<behavior opts>] -% function[<further behavior opts>] -% {gnuplot code} -% #3; -% #1: args of \addplot[...] -% #2: optional arguments after function[] -% #3: gnuplot code to generate coordinates -% #4: trailing path commands until ';' +% \addplot[#1] plot[#2] function[#3] {#4} #5; \def\pgfplots@addplotimpl@function#1#2unction{% \pgfutil@ifnextchar[{% \pgfplots@addplotimpl@function@opt{#1}{#2}% @@ -2044,28 +4087,34 @@ \def\pgfplots@addplotimpl@function@opt#1#2[#3]#4#5;{\pgfplots@addplotimpl@function@opt@{#1}{#2}{#3}{#4}{#5}}% % \addplot[#1] [#2] function[#3] {#4} #5; \def\pgfplots@addplotimpl@function@opt@#1#2#3#4#5{% - \pgfplots@start@plot@with@behavioroptions{% - #2,#3}% + % FIXME : what about the key search paths if the user changes + % them!? + \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2,/pgfplots/.cd,#3,/pgfplots/mesh/ordering/x varies}% + % \pgfplots@gettikzinternal@keyval{prefix}{tikz@plot@prefix}{\jobname.}% \pgfplots@gettikzinternal@keyval{id}{tikz@plot@id}{pgf-plot}% \pgfplots@gettikzinternal@keyval{raw gnuplot}{iftikz@plot@raw@gnuplot}{\iffalse}% \pgfplots@gettikzinternal@keyval{parametric}{iftikz@plot@parametric}{\iffalse}% - \pgfplots@validate@plot@domain@arguments - \pgfkeysgetvalue{/pgfplots/domain}\pgfplots@plot@domain - \pgfkeysgetvalue{/pgfplots/y domain}{\pgfplots@plot@ydomain}% - \ifx\pgfplots@plot@domain\pgfutil@empty - % this is a potential problem: 'plot gnuplot' doesn't support - % the 'samples at' framework which should be in effect now. - % -> acquire the /tikz/domain value! - \pgfplots@gettikzinternal@keyval{domain}{tikz@plot@domain}{-5:5}% - \let\pgfplots@plot@domain=\tikz@plot@domain - \fi % - \def\pgfplots@plot@filename{\tikz@plot@prefix\tikz@plot@id}% + \pgfplots@plot@expression@preparekeys + % + % FIXME: what with 'samples at'!? + \edef\pgfplots@plot@filename{\tikz@plot@prefix\tikz@plot@id}% + % \def\pgfplots@addplotimpl@gnuplotresult@isthreedim@withtwocoords{0}% + % + \edef\pgfplots@gnuplotcode{#4}% + \ifpgfplots@translategnuplot + \def\pgfplots@loc@TMPa{\pgfplotsutilstrreplace{^}{**}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@gnuplotcode}% + \let\pgfplots@gnuplotcode=\pgfplotsretval + \fi + % + % \iftikz@plot@raw@gnuplot% - \def\pgfplots@plot@data{\pgfplotgnuplot[\pgfplots@plot@filename]{#4}}% + \def\pgfplots@plot@data{\pgfplotgnuplot[\pgfplots@plot@filename]{\pgfplots@gnuplotcode}}% \else% + % collect logs: \def\pgfplots@gnuplot@logdirs{}% \ifpgfplots@xislinear \else @@ -2084,42 +4133,94 @@ \fi \pgfplots@disablelogfilter@xtrue \pgfplots@disablelogfilter@ytrue - \ifpgfplots@curplot@threedim - \ifx\pgfplots@plot@ydomain\pgfutil@empty - \pgfplots@error{Sorry, '\string\addplot3 plot function{}' can't be processed correctly because 'y domain' is empty.}% - \def\pgfplots@plot@ydomain{0:1}% + \ifpgfplots@curplot@threedim + \if1\b@pgfplots@should@sample@LINE + \pgfplots@error{Sorry, I do not know how to sample 3D LINE plots with gnuplot... I only know 2D line and 3D mesh. You may want to help the author of pgfplots to improve this feature.}% \fi \fi \def\pgfplots@plot@data{\pgfplotgnuplot[\pgfplots@plot@filename]{% \pgfplots@gnuplot@format; - set samples \pgfkeysvalueof{/pgfplots/samples}; + set samples \pgfkeysvalueof{/pgfplots/samples}\if0\b@pgfplots@should@sample@LINE, \pgfkeysvalueof{/pgfplots/samples y}\fi; \ifx\pgfplots@gnuplot@logdirs\pgfutil@empty \else set logscale \pgfplots@gnuplot@logdirs\space 2.71828182845905; \fi \iftikz@plot@parametric set parametric;\fi \ifpgfplots@curplot@threedim - splot [x=\pgfplots@plot@domain] [y=\pgfplots@plot@ydomain] #4;% + \if0\b@pgfplots@should@sample@LINE + % Samples twodimensionally (a lattice): + % and the isosamples thing confuses me. + set isosamples \pgfkeysvalueof{/pgfplots/samples}\if0\b@pgfplots@should@sample@LINE, \pgfkeysvalueof{/pgfplots/samples y}\fi; + splot [x=\pgfplots@plot@domain] [y=\pgfplots@plot@ydomain] \pgfplots@gnuplotcode;% + \else + % *should* sample a line, but I don't know how. + splot [x=\pgfplots@plot@domain] \pgfplots@gnuplotcode;% + \fi \else - plot [x=\pgfplots@plot@domain] #4;% + plot [x=\pgfplots@plot@domain] \pgfplots@gnuplotcode;% \fi }}% \fi% - \def\pgfplotxyfile{\pgfplots@addplotimpl@gnuplotresult{#1}{#5}}% + \def\pgfplotxyfile{\pgfplots@addplotimpl@gnuplotresult{#5}}% + \pgfplots@plot@data + \let\pgfplotxyfile=\pgfplots@backupof@pgfplotxyfile +}% + +\def\pgfplots@addplotimpl@gnuplotresult#1#2{% + \begingroup + \openin\r@pgfplots@reada=#2 + \ifeof\r@pgfplots@reada + \pgfplots@error{Sorry, the gnuplot-result file '#2' could not be found. Maybe you need to enable the shell-escape feature? For pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnuplot <file>.gnuplot' manually on the respective gnuplot file.}% + \aftergroup\pgfplots@loop@CONTINUEfalse + \else + \aftergroup\pgfplots@loop@CONTINUEtrue + \fi + \closein\r@pgfplots@reada + \endgroup + \ifpgfplots@loop@CONTINUE + % Now, invoke 'plot file'. + % + % I invoke the private '@opt@' method because the semicolon ';' + % character may cause problems due to catcode mismatches. + % *sigh*. + \pgfplots@addplotimpl@file@opt@@{}{}{#2}{#1}% this does not invoke the \pgfplots@start@plot@with@behavioroptions method. + \else + \expandafter\pgfplots@end@plot + \fi +} + +% \addplot[#1] plot[#2] shell[#3] {#4} #5; +\def\pgfplots@addplotimpl@shell#1#2shell{% + \pgfutil@ifnextchar[{% + \pgfplots@addplotimpl@shell@opt{#1}{#2}% + }{% + \pgfplots@addplotimpl@shell@opt{#1}{#2}[]% + }% +}% +\def\pgfplots@addplotimpl@shell@opt#1#2[#3]#4#5;{\pgfplots@addplotimpl@shell@opt@{#1}{#2}{#3}{#4}{#5}}% +% \addplot[#1] [#2] shell[#3] {#4} #5; +\def\pgfplots@addplotimpl@shell@opt@#1#2#3#4#5{% + \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2,/pgfplots/.cd,#3}% + \pgfplots@gettikzinternal@keyval{prefix}{tikz@plot@prefix}{\jobname.}% + \pgfplots@gettikzinternal@keyval{id}{tikz@plot@id}{pgf-shell}% + % + \def\pgfplots@plot@filename{\tikz@plot@prefix\tikz@plot@id}% + \def\pgfplots@plot@data{\pgfshell[\pgfplots@plot@filename]{#4}\pgfplotxyfile{\pgfplots@plot@filename.out}}% + \def\pgfplotxyfile{\pgfplots@addplotimpl@shellresult{#5}}% \pgfplots@plot@data \let\pgfplotxyfile=\pgfplots@backupof@pgfplotxyfile }% -\def\pgfplots@addplotimpl@gnuplotresult#1#2#3{% +\def\pgfplots@addplotimpl@shellresult#1#2{% \begingroup - \openin1=#3 - \ifeof1 - \pgfplots@error{Sorry, the gnuplot-result file '#3' could not be found. Maybe you need to enable the shell-escape feature? For pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnuplot <file>.gnuplot' manually on the respective gnuplot file.}% + \openin\r@pgfplots@reada=#2 + \ifeof\r@pgfplots@reada + \pgfplots@error{Sorry, the shell-result file '#2' could not be found. Maybe you need to enable the shell-escape feature? For pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> sh <file>.sh > <file>.out' manually on the respective shell file.}% \aftergroup\pgfplots@loop@CONTINUEfalse \else \aftergroup\pgfplots@loop@CONTINUEtrue \fi - \closein1 + \closein\r@pgfplots@reada \endgroup \ifpgfplots@loop@CONTINUE % Now, invoke 'plot file'. @@ -2127,7 +4228,7 @@ % I invoke the private '@opt@' method because the semicolon ';' % character may cause problems due to catcode mismatches. % *sigh*. - \pgfplots@addplotimpl@file@opt@@{#1}{}{#3}{#2}% + \pgfplots@addplotimpl@file@opt@@{}{}{#2}{#1}% \else \expandafter\pgfplots@end@plot \fi @@ -2145,8 +4246,10 @@ % \addplot[#1] [#2] file[#3] {#4} #5; \def\pgfplots@addplotimpl@file@opt#1#2[#3]#4#5;{\pgfplots@addplotimpl@file@opt@{#1}{#2}{#3}{#4}{#5}}% \def\pgfplots@addplotimpl@file@opt@#1#2#3#4#5{% - \pgfplots@start@plot@with@behavioroptions{#2}% - \pgfplots@addplotimpl@file@opt@@{#1}{#3}{#4}{#5}% + % invoke this here - allows to share the 'plot file' impl with + % 'plot gnuplot'. + \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2}% + \pgfplots@addplotimpl@file@opt@@{#1,#2}{#3}{#4}{#5}% } \def\pgfplots@addplotimpl@file@opt@@#1#2#3#4{% \begingroup @@ -2155,42 +4258,37 @@ \else \pgfqkeys{/pgfplots/plot file}{#2}% \fi - \pgfplots@PREPARE@COORD@STREAM{#1}{#4}% + \pgfplots@PREPARE@COORD@STREAM{#4}% \pgfplots@coord@stream@start + \pgfplotsscanlinelengthinitzero \pgfplots@logfileopen{#3}% - \openin1=#3 - \ifeof1 - \pgfplots@warning{sorry, plot file{#3} could not be opened!?}% + \openin\r@pgfplots@reada=#3 + \ifeof\r@pgfplots@reada + \pgfplots@error{sorry, plot file{#3} could not be opened}% \else \let\pgfplots@current@point@x@error=\pgfutil@empty \let\pgfplots@current@point@y@error=\pgfutil@empty \let\pgfplots@current@point@z@error=\pgfutil@empty + \let\pgfplots@current@point@meta=\pgfutil@empty \ifpgfplots@curplot@threedim \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@threedim - \ifnum\pgfplots@perpointmeta@choice=4 + \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @explicitinput\endcsname \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@threedim@andmeta - \else - \ifnum\pgfplots@perpointmeta@choice=5 - \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@threedim@andmeta - \fi \fi \else \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@twodim - \ifnum\pgfplots@perpointmeta@choice=4 + \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @explicitinput\endcsname \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@twodim@andmeta - \else - \ifnum\pgfplots@perpointmeta@choice=5 - \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@twodim@andmeta - \fi \fi \fi \pgfplots@addplotimpl@file@readall \fi + \pgfplotsscanlinelengthcleanup \pgfplots@coord@stream@end \endgroup }% \def\pgfplots@addplotimpl@file@readall{% - \read1 to\pgfplots@file@LINE + \read\r@pgfplots@reada to\pgfplots@file@LINE \expandafter\pgfplotstableread@checkspecial@line\pgfplots@file@LINE\pgfplotstable@EOI \ifpgfplotstableread@skipline \else @@ -2198,10 +4296,11 @@ % Silently skip first data row, assuming it is a header. \pgfplots@plot@file@skipfirstfalse \else - \expandafter\pgfplots@addplotimpl@file@parsesingle\pgfplots@file@LINE\pgfplots@EOI + \pgfplotsscanlinelengthincrease + \expandafter\pgfplots@addplotimpl@file@parsesingle\pgfplots@file@LINE 0 0 0 0 0\pgfplots@EOI \fi \fi - \ifeof1 + \ifeof\r@pgfplots@reada \else \expandafter \pgfplots@addplotimpl@file@readall @@ -2244,8 +4343,13 @@ % \addplot[#1] plot[#2] graphics[#3] {#4} #5; \def\pgfplots@addplotimpl@graphics@#1#2[#3]#4#5;{\pgfplots@addplotimpl@graphics@@{#1}{#2}{#3}{#4}{#5}}% \def\pgfplots@addplotimpl@graphics@@#1#2#3#4#5{% - \pgfplots@start@plot@with@behavioroptions{#2,/pgfplots/plot graphics/.cd,#3,/pgfplots/plot graphics/src={#4}}% - \pgfplots@PREPARE@COORD@STREAM{#1,/pgfplots/plot graphics,/tikz/mark=}{#5}% + \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2,% + /pgfplots/plot graphics,% + /pgfplots/plot graphics/.cd,% + #3,% + /pgfplots/plot graphics/src={#4},% + /tikz/mark=}% + \pgfplots@PREPARE@COORD@STREAM{#5}% \pgfplots@coord@stream@start \pgfkeysgetvalue{/pgfplots/plot graphics/xmin}{\pgfplots@current@point@x}% \pgfkeysgetvalue{/pgfplots/plot graphics/ymin}{\pgfplots@current@point@y}% @@ -2278,6 +4382,55 @@ +% \addplot[#1] table[#2] [from] {<\macro>} #4; +% or +% \addplot[#1] table[#2] {<filename>} #4; +% +% The distinction between <\macro> and <filename> is done +% automatically. +% +% Input options can be provided in '#2' using +% - column names, +% for example '/pgfplots/table/x=firstcol' or just 'x=firstcol' +% +% - column indices, +% for example '/pgfplots/table/x index=3' or just 'x index=3' +% +% - expressions involving any of the table's data cells in the +% currently processed cell, +% for example '/pgfplots/table/x expr={\columnx * \columny + \thisrow{columnxxx}/2}' +% During expr, the following (non-exhaustive) list of macros is +% available: +% - \columnx, \columny, \columnz, \columnmeta, \columnerrorx, +% \columnerrory, \columnerrorz +% Provide access to the cell content which would be used without +% 'expr'. +% The first three access the input coordinate columns, \meta the meta column +% (if any) and the last three the error data (if any). +% +% That means it is allowed to provide both, 'x' and 'x expr': +% 'x expr' can use the (old) value stored in 'x'. the final x +% coordinate will be that returned of 'x expr'. +% +% - \coordindex +% +% - \lineno (physical line numbers including comments etc) +% +% - \thisrow{<colname>} +% allows access to any columns. +% +% - \getthisrow{<colname>}{<\macro>} +% this is a fragile command! Don't use it directly inside of +% a math expression, prefer \thisrow. +% +% The FPU will be used to evaluate any expressions. +% +% @REMARKS the implementation for '* expr' differs for the '<\macro>' +% and '<filename>' input types: +% - for '{<filename>}', only the current row is available. +% - for '{<\macro>}', the `create on use' framework of the table +% package is used - with all its features, including comfortable +% access to the previous and next row and accumulation features. \def\pgfplots@addplotimpl@table#1table{% \pgfutil@ifnextchar[{% \pgfplots@addplotimpl@table@getopts{#1}% @@ -2287,10 +4440,14 @@ }% \def\pgfplots@addplotimpl@table@getopts#1[#2]{% - \pgfutil@ifnextchar f{% - \pgfplots@addplotimpl@table@fromstructure{#1}{#2}% + \pgfutil@ifnextchar s{% + \pgfplots@addplotimpl@table@fromshell{#1}{#2}% }{% - \pgfplots@addplotimpl@table@fromfile{#1}{#2}% + \pgfutil@ifnextchar f{% + \pgfplots@addplotimpl@table@fromstructure{#1}{#2}% + }{% + \pgfplots@addplotimpl@table@fromfile{#1}{#2}% + }% }% } @@ -2320,6 +4477,7 @@ \pgfplots@addplotimpl@table@installkeypath \pgfplotstableset{#2}% \begingroup + \pgfplotstablegetscanlinelength{#3}{\pgfplotsscanlinelength}% % FIXME : this thing here has runtime O(N^2) ! % I fear it is faster to simply reload the data .... !? % @@ -2334,36 +4492,56 @@ \pgfkeysgetvalue{/pgfplots/table/z index}{\pgfplots@plot@tbl@zindex}% \pgfkeysgetvalue{/pgfplots/table/meta}{\pgfplots@plot@tbl@meta}% \pgfkeysgetvalue{/pgfplots/table/meta index}{\pgfplots@plot@tbl@metaindex}% + % \ifx\pgfplots@plot@tbl@x\pgfutil@empty - \pgfplotstablegetcolumnbyindex\pgfplots@plot@tbl@xindex\of\pgfplots@table\to\addplot@tbl@x - \else - \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@x\of\pgfplots@table\to\addplot@tbl@x + \pgfplotstablegetcolumnnamebyindex\pgfplots@plot@tbl@xindex\of\pgfplots@table\to\pgfplots@plot@tbl@x \fi \ifx\pgfplots@plot@tbl@y\pgfutil@empty - \pgfplotstablegetcolumnbyindex\pgfplots@plot@tbl@yindex\of\pgfplots@table\to\addplot@tbl@y - \else - \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@y\of\pgfplots@table\to\addplot@tbl@y + \pgfplotstablegetcolumnnamebyindex\pgfplots@plot@tbl@yindex\of\pgfplots@table\to\pgfplots@plot@tbl@y \fi \ifpgfplots@curplot@threedim \ifx\pgfplots@plot@tbl@z\pgfutil@empty - \pgfplotstablegetcolumnbyindex\pgfplots@plot@tbl@zindex\of\pgfplots@table\to\addplot@tbl@z - \else - \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@z\of\pgfplots@table\to\addplot@tbl@z + \pgfplotstablegetcolumnnamebyindex\pgfplots@plot@tbl@zindex\of\pgfplots@table\to\pgfplots@plot@tbl@z \fi \fi - \let\addplot@tbl@meta=\pgfutil@empty \ifx\pgfplots@plot@tbl@meta\pgfutil@empty \ifx\pgfplots@plot@tbl@metaindex\pgfutil@empty \else - \pgfplotstablegetcolumnbyindex\pgfplots@plot@tbl@metaindex\of\pgfplots@table\to\addplot@tbl@meta + \pgfplotstablegetcolumnnamebyindex\pgfplots@plot@tbl@metaindex\of\pgfplots@table\to\pgfplots@plot@tbl@meta \fi + \fi + % + % + % high level user interface functions: + \def\coordindex{\pgfplotstablerow}% + \let\lineno=\coordindex% is the same here + % + % modify \pgfplots@plot@tbl@{x,y,z,meta} if there are + % corresponding '#1 expr' statements: + \pgfplots@addplotimpl@table@fromstructure@prepareexpr@for x\columnx% + \pgfplots@addplotimpl@table@fromstructure@prepareexpr@for y\columny% + \pgfplots@addplotimpl@table@fromstructure@prepareexpr@for {meta}\columnmeta% + \ifpgfplots@curplot@threedim + \pgfplots@addplotimpl@table@fromstructure@prepareexpr@for z\columnz% + \fi + % + \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@x\of\pgfplots@table\to\addplot@tbl@x + \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@y\of\pgfplots@table\to\addplot@tbl@y + \ifpgfplots@curplot@threedim + \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@z\of\pgfplots@table\to\addplot@tbl@z + \fi + % + \let\addplot@tbl@meta=\pgfutil@empty + \ifx\pgfplots@plot@tbl@meta\pgfutil@empty \else \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@meta\of\pgfplots@table\to\addplot@tbl@meta \fi % + % + \let\addplot@tbl@error@x=\pgfutil@empty + \let\addplot@tbl@error@y=\pgfutil@empty + \let\addplot@tbl@error@z=\pgfutil@empty \ifpgfplots@errorbars@enabled - \let\addplot@tbl@error@x=\pgfutil@empty - \let\addplot@tbl@error@z=\pgfutil@empty \pgfkeysgetvalue{/pgfplots/table/x error index}\pgfplots@plot@tbl@error@xindex \pgfkeysgetvalue{/pgfplots/table/x error}\pgfplots@plot@tbl@error@x \pgfkeysgetvalue{/pgfplots/table/y error index}\pgfplots@plot@tbl@error@yindex @@ -2373,39 +4551,57 @@ \ifx\pgfplots@plot@tbl@error@x\pgfutil@empty \ifx\pgfplots@plot@tbl@error@xindex\pgfutil@empty \else - \pgfplotstablegetcolumnbyindex\pgfplots@plot@tbl@error@xindex\of\pgfplots@table\to\addplot@tbl@error@x + \pgfplotstablegetcolumnnamebyindex\pgfplots@plot@tbl@error@xindex\of\pgfplots@table\to\pgfplots@plot@tbl@error@x \fi - \else - \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@error@x\of\pgfplots@table\to\addplot@tbl@error@x \fi + % \ifx\pgfplots@plot@tbl@error@y\pgfutil@empty \ifx\pgfplots@plot@tbl@error@yindex\pgfutil@empty \else - \pgfplotstablegetcolumnbyindex\pgfplots@plot@tbl@error@yindex\of\pgfplots@table\to\addplot@tbl@error@y + \pgfplotstablegetcolumnnamebyindex\pgfplots@plot@tbl@error@yindex\of\pgfplots@table\to\pgfplots@plot@tbl@error@y \fi - \else - \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@error@y\of\pgfplots@table\to\addplot@tbl@error@y \fi + % \ifpgfplots@curplot@threedim \ifx\pgfplots@plot@tbl@error@z\pgfutil@empty \ifx\pgfplots@plot@tbl@error@zindex\pgfutil@empty \else - \pgfplotstablegetcolumnbyindex\pgfplots@plot@tbl@error@zindex\of\pgfplots@table\to\addplot@tbl@error@z + \pgfplotstablegetcolumnnamebyindex\pgfplots@plot@tbl@error@zindex\of\pgfplots@table\to\pgfplots@plot@tbl@error@z \fi - \else - \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@error@z\of\pgfplots@table\to\addplot@tbl@error@z \fi + \else + \let\pgfplots@plot@tbl@error@z=\pgfutil@empty \fi - \fi - % - \ifpgfplots@errorbars@enabled + % + % modify \pgfplots@plot@tbl@{x error,y error,z error} if there are + % corresponding '#1 expr' statements: + \pgfplots@addplotimpl@table@fromstructure@prepareexpr@for {x error}\columnerrorx% + \pgfplots@addplotimpl@table@fromstructure@prepareexpr@for {y error}\columnerrory% + \ifpgfplots@curplot@threedim + \pgfplots@addplotimpl@table@fromstructure@prepareexpr@for {z error}\columnerrorz% + \fi + % + % now: load the columns: + \ifx\pgfplots@plot@tbl@error@x\pgfutil@empty + \else + \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@error@x\of\pgfplots@table\to\addplot@tbl@error@x + \fi + \ifx\pgfplots@plot@tbl@error@y\pgfutil@empty + \else + \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@error@y\of\pgfplots@table\to\addplot@tbl@error@y + \fi + \ifx\pgfplots@plot@tbl@error@z\pgfutil@empty + \else + \pgfplotstablegetcolumnbyname\pgfplots@plot@tbl@error@z\of\pgfplots@table\to\addplot@tbl@error@z + \fi + % \else \let\pgfplots@current@point@x@error=\pgfutil@empty \let\pgfplots@current@point@y@error=\pgfutil@empty \let\pgfplots@current@point@z@error=\pgfutil@empty \fi - \let\pgfplots@current@point@meta=\pgfutil@empty - \pgfplots@PREPARE@COORD@STREAM{#1}{#4}% + % + \pgfplots@PREPARE@COORD@STREAM{#4}% \pgfplots@coord@stream@start \pgfutil@loop \pgfplotslistcheckempty\addplot@tbl@x @@ -2443,22 +4639,62 @@ \else \pgfplotslistpopfront\addplot@tbl@error@y\to\pgfplots@current@point@y@error \fi - \ifpgfplots@errorbars@enabled - \ifx\addplot@tbl@error@z\pgfutil@empty - \let\pgfplots@current@point@z@error=\pgfutil@empty - \else - \pgfplotslistpopfront\addplot@tbl@error@z\to\pgfplots@current@point@z@error - \fi + \ifx\addplot@tbl@error@z\pgfutil@empty + \let\pgfplots@current@point@z@error=\pgfutil@empty + \else + \pgfplotslistpopfront\addplot@tbl@error@z\to\pgfplots@current@point@z@error \fi - \pgfplots@coord@stream@coord - \else - \pgfplots@coord@stream@coord \fi + \pgfplots@coord@stream@coord \pgfutil@repeat \pgfplots@coord@stream@end + \pgfmath@smuggleone\pgfplotsscanlinelength \endgroup } +% A private helper macro which initialises the '#1 expr' keys for plot +% table from structure. +% +% PRECONDITION: +% \pgfplots@plot@tbl@#1 contains the column name which would be used +% if '#1 expr' is empty. +% +% POSTCONDITION: +% \pgfplots@plot@tbl@#1 will be CHANGED to use the 'expr' column (a +% temporary name). +% The old value of \pgfplots@plot@tbl@#1 is available as column +% alias. +% the high level user interface command '#2' will be set correctly. +\def\pgfplots@addplotimpl@table@fromstructure@prepareexpr@for#1#2{% + % get old column name into a register: + \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname pgfplots@plot@tbl@#1\endcsname}% + % + % high level user interface command: + \edef#2{\noexpand\thisrow{\the\t@pgfplots@tokb}}% + % + \pgfkeysgetvalue{/pgfplots/table/#1 expr}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + % get expression into register: + \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}% + % + % + % assemble pgfkeys statement which expands the names above + % just one time: + \edef\pgfplots@loc@TMPa{% + /pgfplots/table/create on use/#1expr@tempcol/.style={% + /pgfplots/table/create col/expr={\the\t@pgfplots@toka}% + },% + /pgfplots/table/alias/#1/.initial={\the\t@pgfplots@tokb}% + }% + \expandafter\pgfkeysalso\expandafter{\pgfplots@loc@TMPa}% + % + % tell `plot table' which column should be used for '#1': the + % temporary column. + \expandafter\def\csname pgfplots@plot@tbl@#1\endcsname{#1expr@tempcol}% + \fi +}% + % \addplot[#1] table[#2] {#3} #4; % @@ -2471,6 +4707,7 @@ % #2: arguments to table[...] % #3: the argument of plot table{...} % #4: trailing path arguments after plot table{...}#4; +% \long\def\pgfplots@addplotimpl@table@fromfile#1#2#3#4;{\pgfplots@addplotimpl@table@startprocessing{#1}{#2}{#3}{#4}}% % \addplot[#1] table[#2] {#3} {#4}; \long\def\pgfplots@addplotimpl@table@fromfile@#1#2#3#4{% @@ -2485,165 +4722,292 @@ % \pgfplots@addplotimpl@table@fromstructure{#1}{}from{\pgfplots@table}{#4};% % \endgroup %-------------------------------------------------- - \begingroup + %\begingroup \ifpgfplots@addplotimpl@readcompletely \pgfplotstableread{#3}\pgfplots@table \pgfplots@addplotimpl@table@fromstructure@{#1}{}{\pgfplots@table}{#4}% - \endgroup + % \pgfmath@smuggleone\pgfplotsscanlinelength + % \endgroup + % \pgfplotsscanlinedisablechanges \else \pgfplotsapplistXXglobalnewempty - \pgfkeysgetvalue{/pgfplots/table/x}{\pgfplots@plot@tbl@x}% - \pgfkeysgetvalue{/pgfplots/table/x index}{\pgfplots@plot@tbl@xindex}% - \pgfkeysgetvalue{/pgfplots/table/y}{\pgfplots@plot@tbl@y}% - \pgfkeysgetvalue{/pgfplots/table/y index}{\pgfplots@plot@tbl@yindex}% - \pgfkeysgetvalue{/pgfplots/table/z}{\pgfplots@plot@tbl@z}% - \pgfkeysgetvalue{/pgfplots/table/z index}{\pgfplots@plot@tbl@zindex}% - \pgfkeysgetvalue{/pgfplots/table/meta}{\pgfplots@plot@tbl@meta}% - \pgfkeysgetvalue{/pgfplots/table/meta index}{\pgfplots@plot@tbl@metaindex}% + % + % these data pointers will be prepared to allow fast access + % into the current row while we read rows succesively from + % disk. + % Note: their initialisation must be postponed until + % \pgfplotstableread is running - otherwise, we can't query + % pointers into the table. See below. \let\pgfplots@table@PTR@x=\pgfutil@empty \let\pgfplots@table@PTR@y=\pgfutil@empty \let\pgfplots@table@PTR@z=\pgfutil@empty \let\pgfplots@table@PTR@meta=\pgfutil@empty + % + % \let\pgfplots@current@point@meta=\pgfutil@empty \let\pgfplots@current@point@z=\pgfutil@empty + % + % high level user interface functions: + \def\lineno{\pgfplotstablelineno}% + \def\columnx{\pgfplotstablereadvalueofptr{\pgfplots@table@PTR@x}}% + \def\columny{\pgfplotstablereadvalueofptr{\pgfplots@table@PTR@y}}% + \def\columnz{\pgfplotstablereadvalueofptr{\pgfplots@table@PTR@z}}% + \def\columnmeta{\pgfplotstablereadvalueofptr{\pgfplots@table@PTR@meta}}% + % + \pgfplots@PREPARE@COORD@STREAM{#4}% + \pgfplots@coord@stream@start \ifpgfplots@errorbars@enabled + % more fast-access pointers for error data: \let\pgfplots@table@ERRPTR@x=\pgfutil@empty \let\pgfplots@table@ERRPTR@y=\pgfutil@empty \let\pgfplots@table@ERRPTR@z=\pgfutil@empty - \pgfkeysgetvalue{/pgfplots/table/x error index}\pgfplots@plot@tbl@error@xindex - \pgfkeysgetvalue{/pgfplots/table/x error}\pgfplots@plot@tbl@error@x - \pgfkeysgetvalue{/pgfplots/table/y error index}\pgfplots@plot@tbl@error@yindex - \pgfkeysgetvalue{/pgfplots/table/y error}\pgfplots@plot@tbl@error@y - \pgfkeysgetvalue{/pgfplots/table/z error index}\pgfplots@plot@tbl@error@zindex - \pgfkeysgetvalue{/pgfplots/table/z error}\pgfplots@plot@tbl@error@z - \pgfplotstableread{#3} to listener\pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL + % + % prepare: + \let\pgfplots@current@point@x@error=\pgfutil@empty + \let\pgfplots@current@point@y@error=\pgfutil@empty + \let\pgfplots@current@point@z@error=\pgfutil@empty + % + % high level user interface functions: + \def\columnerrorx{\pgfplotstablereadvalueofptr{\pgfplots@table@ERRPTR@x}}% + \def\columnerrory{\pgfplotstablereadvalueofptr{\pgfplots@table@ERRPTR@y}}% + \def\columnerrorz{\pgfplotstablereadvalueofptr{\pgfplots@table@ERRPTR@z}}% + % + \pgfplotstableread*{#3} to listener\pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL \else - \pgfplotstableread{#3} to listener\pgfplots@addplotimpl@table@fromfile@listener@COLLECTNORMALIZED + \pgfplotstableread*{#3} to listener\pgfplots@addplotimpl@table@fromfile@listener@COLLECTNORMALIZED \fi - \endgroup + \pgfplots@coord@stream@end + % FIXME : i'd be glad if I could save this group: check why not + % perhaps because \pgfplotstableread uses several pgf + % variables? + %\pgfmath@smuggleone\pgfplotsscanlinelength + %\endgroup + %\pgfplotsscanlinedisablechanges % - \pgfplots@PREPARE@COORD@STREAM{#1}{#4}% - \pgfplotsapplistXXgloballet\pgfplots@coordlist - \pgfplotsapplistXXglobalclear - \ifpgfplots@errorbars@enabled - \ifpgfplots@curplot@threedim - \expandafter\pgfplots@coord@stream@foreach@threedim\expandafter{\pgfplots@coordlist}%% - \else - \expandafter\pgfplots@coord@stream@foreach\expandafter{\pgfplots@coordlist}%% - \fi - \else + %\pgfplots@PREPARE@COORD@STREAM{#4}% + %\pgfplotsapplistXXgloballet\pgfplots@coordlist + %\pgfplotsapplistXXglobalclear + %\ifpgfplots@errorbars@enabled + % \pgfplots@plot@coords@mathparserfalse + % \ifpgfplots@curplot@threedim + % \expandafter\pgfplots@coord@stream@foreach@threedim\expandafter{\pgfplots@coordlist}%% + % \else + % \expandafter\pgfplots@coord@stream@foreach\expandafter{\pgfplots@coordlist}%% + % \fi + %\else % this here is the usual case; it is faster than the error bar % stuff. - \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@coordlist}% - \fi + % \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@coordlist}% + %\fi \fi } \def\pgfplots@addplotimpl@table@fromfile@listener@COLLECTNORMALIZED{% \pgfplots@addplotimpl@table@fromfile@listener@ - \edef\pgfplots@current@point{% - \pgfplots@current@point@x,% - \pgfplots@current@point@y,% - \pgfplots@current@point@z,% - \pgfplots@current@point@meta% - ;% - }% - \expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfplots@current@point}% + \pgfplots@coord@stream@coord } -\def\pgfplots@addplotimpl@table@fromfile@listener@{% - \ifx\pgfplots@table@PTR@x\pgfutil@empty - % this here is only evaluated ONCE. - \ifx\pgfplots@plot@tbl@x\pgfutil@empty - \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@xindex}{\pgfplots@table@PTR@x}% +\def\pgfplots@addplotimpl@table@fromfile@listener@PREPARE{% + % this here is only evaluated ONCE. + \pgfkeysgetvalue{/pgfplots/table/x}{\pgfplots@plot@tbl@x}% + \pgfkeysgetvalue{/pgfplots/table/x index}{\pgfplots@plot@tbl@xindex}% + \pgfkeysgetvalue{/pgfplots/table/y}{\pgfplots@plot@tbl@y}% + \pgfkeysgetvalue{/pgfplots/table/y index}{\pgfplots@plot@tbl@yindex}% + \pgfkeysgetvalue{/pgfplots/table/z}{\pgfplots@plot@tbl@z}% + \pgfkeysgetvalue{/pgfplots/table/z index}{\pgfplots@plot@tbl@zindex}% + \pgfkeysgetvalue{/pgfplots/table/meta}{\pgfplots@plot@tbl@meta}% + \pgfkeysgetvalue{/pgfplots/table/meta index}{\pgfplots@plot@tbl@metaindex}% + % + \pgfkeysgetvalue{/pgfplots/table/x expr}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\pgfplots@dereferencepointer@and@ASSIGN@x{% + \pgfplotstablereadevalptr\pgfplots@table@PTR@x\pgfplots@current@point@x + }% + \else + \def\pgfplots@dereferencepointer@and@ASSIGN@x{% + \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/x expr}}% + \let\pgfplots@current@point@x=\pgfmathresult + }% + \fi + % + \pgfkeysgetvalue{/pgfplots/table/y expr}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\pgfplots@dereferencepointer@and@ASSIGN@y{% + \pgfplotstablereadevalptr\pgfplots@table@PTR@y\pgfplots@current@point@y + }% + \else + \def\pgfplots@dereferencepointer@and@ASSIGN@y{% + \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/y expr}}% + \let\pgfplots@current@point@y=\pgfmathresult + }% + \fi + % + \ifx\pgfplots@plot@tbl@x\pgfutil@empty + \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@xindex}{\pgfplots@table@PTR@x}% + \else + \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@x}{\pgfplots@table@PTR@x}% + \fi + \ifx\pgfplots@plot@tbl@y\pgfutil@empty + \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@yindex}{\pgfplots@table@PTR@y}% + \else + \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@y}{\pgfplots@table@PTR@y}% + \fi + \ifpgfplots@curplot@threedim + % + \pgfkeysgetvalue{/pgfplots/table/z expr}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \def\pgfplots@dereferencepointer@and@ASSIGN@z{% + \pgfplotstablereadevalptr\pgfplots@table@PTR@z\pgfplots@current@point@z + }% \else - \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@x}{\pgfplots@table@PTR@x}% + \def\pgfplots@dereferencepointer@and@ASSIGN@z{% + \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/z expr}}% + \let\pgfplots@current@point@z=\pgfmathresult + }% \fi - \ifx\pgfplots@plot@tbl@y\pgfutil@empty - \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@yindex}{\pgfplots@table@PTR@y}% + \ifx\pgfplots@plot@tbl@z\pgfutil@empty + \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@zindex}{\pgfplots@table@PTR@z}% \else - \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@y}{\pgfplots@table@PTR@y}% - \fi - \ifpgfplots@curplot@threedim - \ifx\pgfplots@plot@tbl@z\pgfutil@empty - \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@zindex}{\pgfplots@table@PTR@z}% - \else - \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@z}{\pgfplots@table@PTR@z}% - \fi + \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@z}{\pgfplots@table@PTR@z}% \fi - \ifx\pgfplots@plot@tbl@meta\pgfutil@empty - \ifx\pgfplots@plot@tbl@metaindex\pgfutil@empty - \else - \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@metaindex}{\pgfplots@table@PTR@meta}% - \fi + \else + \let\pgfplots@dereferencepointer@and@ASSIGN@z=\relax + \fi + % + % + \def\pgfplots@dereferencepointer@and@ASSIGN@meta{% + \pgfplotstablereadevalptr\pgfplots@table@PTR@meta\pgfplots@current@point@meta + }% + \ifx\pgfplots@plot@tbl@meta\pgfutil@empty + \ifx\pgfplots@plot@tbl@metaindex\pgfutil@empty + \let\pgfplots@dereferencepointer@and@ASSIGN@meta=\relax \else - \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@meta}{\pgfplots@table@PTR@meta}% + \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@metaindex}{\pgfplots@table@PTR@meta}% \fi + \else + \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@meta}{\pgfplots@table@PTR@meta}% \fi - \pgfplotstablereadevalptr\pgfplots@table@PTR@x\pgfplots@current@point@x - \pgfplotstablereadevalptr\pgfplots@table@PTR@y\pgfplots@current@point@y - \ifpgfplots@curplot@threedim - \pgfplotstablereadevalptr\pgfplots@table@PTR@z\pgfplots@current@point@z - \fi - \ifx\pgfplots@table@PTR@meta\pgfutil@empty + \pgfkeysgetvalue{/pgfplots/table/meta expr}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \pgfplotstablereadevalptr\pgfplots@table@PTR@meta\pgfplots@current@point@meta + \def\pgfplots@dereferencepointer@and@ASSIGN@meta{% + \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/meta expr}}% + \let\pgfplots@current@point@meta=\pgfmathresult + }% \fi + \let\pgfplots@addplotimpl@table@fromfile@listener@PREPARE=\relax }% -\def\pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL{% - \pgfplots@addplotimpl@table@fromfile@listener@ +\def\pgfplots@addplotimpl@table@fromfile@listener@{% + \pgfplots@addplotimpl@table@fromfile@listener@PREPARE + \pgfplots@dereferencepointer@and@ASSIGN@x + \pgfplots@dereferencepointer@and@ASSIGN@y + \pgfplots@dereferencepointer@and@ASSIGN@z + \pgfplots@dereferencepointer@and@ASSIGN@meta +}% +\def\pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare{% + % this here is only evaluated ONCE. + \pgfkeysgetvalue{/pgfplots/table/x error index}\pgfplots@plot@tbl@error@xindex + \pgfkeysgetvalue{/pgfplots/table/x error}\pgfplots@plot@tbl@error@x + \pgfkeysgetvalue{/pgfplots/table/y error index}\pgfplots@plot@tbl@error@yindex + \pgfkeysgetvalue{/pgfplots/table/y error}\pgfplots@plot@tbl@error@y + \pgfkeysgetvalue{/pgfplots/table/z error index}\pgfplots@plot@tbl@error@zindex + \pgfkeysgetvalue{/pgfplots/table/z error}\pgfplots@plot@tbl@error@z % - \ifx\pgfplots@table@ERRPTR@x\pgfutil@empty - % this here is only evaluated ONCE. - \ifx\pgfplots@plot@tbl@error@x\pgfutil@empty - \ifx\pgfplots@plot@tbl@error@xindex\pgfutil@empty - \let\pgfplots@table@ERRPTR@x=\relax% - \else - \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@error@xindex}{\pgfplots@table@ERRPTR@x}% - \fi + \def\pgfplots@table@ERRPTR@x{x error}% + \def\pgfplots@table@ERRPTR@y{y error}% + \def\pgfplots@table@ERRPTR@z{z error}% + % + \def\pgfplots@dereferencepointer@and@ASSIGN@error@x{% + \pgfplotstablereadevalptr\pgfplots@table@ERRPTR@x\pgfplots@current@point@x@error + }% + \def\pgfplots@dereferencepointer@and@ASSIGN@error@y{% + \pgfplotstablereadevalptr\pgfplots@table@ERRPTR@y\pgfplots@current@point@y@error + }% + \def\pgfplots@dereferencepointer@and@ASSIGN@error@z{% + \pgfplotstablereadevalptr\pgfplots@table@ERRPTR@z\pgfplots@current@point@z@error + }% + % + \ifx\pgfplots@plot@tbl@error@x\pgfutil@empty + \ifx\pgfplots@plot@tbl@error@xindex\pgfutil@empty + \let\pgfplots@table@ERRPTR@x=\relax% + \let\pgfplots@dereferencepointer@and@ASSIGN@error@x=\relax \else - \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@error@x}{\pgfplots@table@ERRPTR@x}% + \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@error@xindex}{\pgfplots@table@ERRPTR@x}% \fi - \ifx\pgfplots@plot@tbl@error@y\pgfutil@empty - \ifx\pgfplots@plot@tbl@error@yindex\pgfutil@empty - \let\pgfplots@table@ERRPTR@y=\relax% - \else - \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@error@yindex}{\pgfplots@table@ERRPTR@y}% - \fi + \else + \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@error@x}{\pgfplots@table@ERRPTR@x}% + \fi + % + \pgfkeysgetvalue{/pgfplots/table/x error expr}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \def\pgfplots@dereferencepointer@and@ASSIGN@error@x{% + \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/x error expr}}% + \let\pgfplots@current@point@x@error=\pgfmathresult + }% + \fi + % + % + \ifx\pgfplots@plot@tbl@error@y\pgfutil@empty + \ifx\pgfplots@plot@tbl@error@yindex\pgfutil@empty + \let\pgfplots@table@ERRPTR@y=\relax% + \let\pgfplots@dereferencepointer@and@ASSIGN@error@y=\relax \else - \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@error@y}{\pgfplots@table@ERRPTR@y}% - \fi - \ifpgfplots@curplot@threedim - \ifx\pgfplots@plot@tbl@error@z\pgfutil@empty - \ifx\pgfplots@plot@tbl@error@zindex\pgfutil@empty - \let\pgfplots@table@ERRPTR@z=\relax% - \else - \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@error@zindex}{\pgfplots@table@ERRPTR@z}% - \fi - \else - \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@error@z}{\pgfplots@table@ERRPTR@z}% - \fi + \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@error@yindex}{\pgfplots@table@ERRPTR@y}% \fi - \fi - \ifx\relax\pgfplots@table@ERRPTR@x - \let\pgfplots@current@point@x@error=\pgfutil@empty \else - \pgfplotstablereadevalptr\pgfplots@table@ERRPTR@x\pgfplots@current@point@x@error + \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@error@y}{\pgfplots@table@ERRPTR@y}% \fi - \ifx\relax\pgfplots@table@ERRPTR@y - \let\pgfplots@current@point@y@error=\pgfutil@empty + % + \pgfkeysgetvalue{/pgfplots/table/y error expr}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \pgfplotstablereadevalptr\pgfplots@table@ERRPTR@y\pgfplots@current@point@y@error + \def\pgfplots@dereferencepointer@and@ASSIGN@error@y{% + \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/y error expr}}% + \let\pgfplots@current@point@y@error=\pgfmathresult + }% \fi + % + % \ifpgfplots@curplot@threedim - \ifx\relax\pgfplots@table@ERRPTR@z - \let\pgfplots@current@point@z@error=\pgfutil@empty + \ifx\pgfplots@plot@tbl@error@z\pgfutil@empty + \ifx\pgfplots@plot@tbl@error@zindex\pgfutil@empty + \let\pgfplots@table@ERRPTR@z=\relax% + \let\pgfplots@dereferencepointer@and@ASSIGN@error@z=\relax + \else + \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@error@zindex}{\pgfplots@table@ERRPTR@z}% + \fi \else - \pgfplotstablereadevalptr\pgfplots@table@ERRPTR@z\pgfplots@current@point@z@error + \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@error@z}{\pgfplots@table@ERRPTR@z}% \fi - \edef\pgfplots@current@point{(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)+-(\pgfplots@current@point@x@error,\pgfplots@current@point@y@error,\pgfplots@current@point@z@error) [\pgfplots@current@point@meta]}% + % + \pgfkeysgetvalue{/pgfplots/table/z error expr}{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \def\pgfplots@dereferencepointer@and@ASSIGN@error@z{% + \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/z error expr}}% + \let\pgfplots@current@point@z@error=\pgfmathresult + }% + \fi + % + % \else - \edef\pgfplots@current@point{(\pgfplots@current@point@x,\pgfplots@current@point@y)+-(\pgfplots@current@point@x@error,\pgfplots@current@point@y@error) [\pgfplots@current@point@meta]}% + \let\pgfplots@dereferencepointer@and@ASSIGN@error@z=\relax + \fi + \let\pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare=\relax +} +\def\pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL{% + \pgfplots@addplotimpl@table@fromfile@listener@ + \pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare + % + \pgfplots@dereferencepointer@and@ASSIGN@error@x + \pgfplots@dereferencepointer@and@ASSIGN@error@y + \ifpgfplots@curplot@threedim + \pgfplots@dereferencepointer@and@ASSIGN@error@z + %\edef\pgfplots@current@point{(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)+-(\pgfplots@current@point@x@error,\pgfplots@current@point@y@error,\pgfplots@current@point@z@error) [\pgfplots@current@point@meta]}% + %\else + %\edef\pgfplots@current@point{(\pgfplots@current@point@x,\pgfplots@current@point@y)+-(\pgfplots@current@point@x@error,\pgfplots@current@point@y@error) [\pgfplots@current@point@meta]}% \fi - \expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfplots@current@point}% + \pgfplots@coord@stream@coord + %\expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfplots@current@point}% }% \def\pgfplots@addplotimpl@table@installkeypath{% \pgfkeysdef{/pgfplots/table/.unknown}{% @@ -2652,35 +5016,140 @@ }% }% +% \addplot[#1] table[#2] shell{#3} #4; +% +% #1: arguments to \addplot[...] +% #2: arguments to table[...] +% #3: the argument of plot table shell{...} +% #4: trailing path arguments after plot table shell{...}#4; +\long\def\pgfplots@addplotimpl@table@fromshell#1#2shell#3#4;{% + \pgfplots@gettikzinternal@keyval{prefix}{tikz@plot@prefix}{\jobname.}% + \pgfplots@gettikzinternal@keyval{id}{tikz@plot@id}{pgf-shell}% + % + \def\pgfplots@plot@filename{\tikz@plot@prefix\tikz@plot@id}% + \pgfshell[\pgfplots@plot@filename]{#3}\pgfplots@addplotimpl@table@fromfile{#1}{#2}{\pgfplots@plot@filename.out}#4;% +}% + +% A common routine which resets internal data structures for the +% survey phase, i.e. it is the shared implementation for all \addplot +% variations. +% +% It takes all options which are provided to \addplot, sets them (at +% least partially) and remembers them for the command serialization. +% % #1: arguments to \addplot plot[#1] % -> these are called 'behavior' options in the manual; they are set % immediately. +% +% PRECONDITION: +% \pgfplots@addplotimpl@plot@withoptions has already been invoked +% +% POSTCONDITION: +% - internal datastructures are initialised (coordinate indexing, fpu) +% - all keys which are required for the current plot are determined +% (and set if necessary). +% They are stored into +% \pgfplots@addplot@survey@@optionlist. +% \def\pgfplots@start@plot@with@behavioroptions#1{% %\begingroup%<-- has been moved to \pgfplots@addplotimpl@plot@withoptions - \def\pgfplots@current@point@coordindex{0}% can be used inside of coordinate filters. + \c@pgfplots@coordindex=0 + \def\pgfplots@current@point@coordindex{\the\c@pgfplots@coordindex}% can be used inside of coordinate filters. \def\coordindex{\pgfplots@current@point@coordindex}% valid inside of \addplot - \ifx\pgfplots@execute@at@begin@plot\pgfutil@empty - \else - \pgfplots@execute@at@begin@plot + \ifpgfplots@usefpu + \pgfkeys{/pgf/fpu=true}% \fi - \let\pgfplots@addplot@nonlegend@options=\pgfutil@empty - \pgfplots@process@behavioroptions{#1}% + \def\pgfplots@addplot@running{1}% + % % these styles may contain behavior options (error bars, % samples,... ) activate them! + % + % As of february 20, 2009, #1 will contain BOTH, /pgfplots + % and /tikz options. The /tikz ones are primarily for drawing + % and are UNIMPORTANT at this stage of processing. + % In fact, transparency etc. will only confuse everything. + % + % So: ignore them and set only /pgfplots keys here: + % This may actually redefine styles, for example + % \addplot[every mark/.append style={}] will use + % /pgfplots/every mark/.append style. + % But that doesn't hurt here. + % + % there are some exceptions like /tikz/id etc. These + % exceptions need special styles in the /pgfplots root - or I + % need to change the .unknown handler. See the available + % compatibility styles! + % + \pgfkeysdef{/pgfplots/.unknown}{% +%\message{In \string\addplot[#1]: I am silently ignoring key `\pgfkeyscurrentkeyRAW' during the preparation phase.}% + }% + % + % it is possible that '#1' contains 'forget plot'. So, we need to + % set the options before checking + % \ifpgfplots@curplot@isirrelevant: + \pgfplotsset{/pgfplots/every axis plot,#1}% + % + % hooks: + \pgfkeysvalueof{/pgfplots/execute at begin plot@@}% + \pgfkeysvalueof{/pgfplots/execute at begin plot}% + % \ifpgfplots@curplot@isirrelevant - \pgfplotsset{/pgfplots/every axis plot,/pgfplots/every forget plot/.try}% + \def\pgfplots@addplot@survey@@optionlist{/pgfplots/every axis plot,/pgfplots/every forget plot}% + \pgfplotsset{/pgfplots/every forget plot,/pgfplots/every axis plot post}% \else - \pgfplotsset{/pgfplots/every axis plot,/pgfplots/every axis plot no \the\pgfplots@numplots/.try}% + \edef\pgfplots@addplot@survey@@optionlist{/pgfplots/every axis plot,/pgfplots/every axis plot no \the\pgfplots@numplots/.try}% + \pgfplotsset{/pgfplots/every axis plot no \the\pgfplots@numplots/.try,/pgfplots/every axis plot post}% \fi + \expandafter\def\expandafter\pgfplots@addplot@survey@@optionlist\expandafter{\pgfplots@addplot@survey@@optionlist,% + #1,/pgfplots/.cd,/pgfplots/every axis plot post}% + \pgfplots@validate@plot@domain@arguments } -\def\pgfplots@process@behavioroptions#1{% - \def\pgfplots@loc@TMPa{#1}% - \ifx\pgfplots@loc@TMPa\pgfutil@empty - \else - \expandafter\def\expandafter\pgfplots@addplot@nonlegend@options\expandafter{% - \pgfplots@addplot@nonlegend@options,#1}% - \pgfplotsset{#1}% - \fi + + +% This is a backwards-compatibility method to ensure that +% \axis[ybar] +% and +% \addplot[ybar] +% work as documented. +% +% The problem: earlier versions used /pgfplots/ybar for the global +% setting and /tikz/ybar for the local one. Now, both contexts yield +% /pgfplots/ybar in contradiction to the manual. +% +% So, this macro install special handlers to restore the old setting. +\def\pgfplots@install@local@bar@handlers{% + \pgfkeysgetvalue{/pgfplots/xbar/.@cmd}\pgfplotskeys@orig@xbar + \pgfkeysgetvalue{/pgfplots/ybar/.@cmd}\pgfplotskeys@orig@xbar + \pgfkeysgetvalue{/pgfplots/xbar interval/.@cmd}\pgfplotskeys@orig@xbari + \pgfkeysgetvalue{/pgfplots/ybar interval/.@cmd}\pgfplotskeys@orig@ybari + \pgfkeysdef{/pgfplots/xbar}{% + \ifpgfkeysaddeddefaultpath + \pgfkeysalso{/tikz/xbar}% + \else + \pgfplotskeys@orig@xbar##1\pgfeov + \fi + }% + \pgfkeysdef{/pgfplots/ybar}{% + \ifpgfkeysaddeddefaultpath + \pgfkeysalso{/tikz/ybar}% + \else + \pgfplotskeys@orig@ybar##1\pgfeov + \fi + }% + \pgfkeysdef{/pgfplots/xbar interval}{% + \ifpgfkeysaddeddefaultpath + \pgfkeysalso{/tikz/xbar interval}% + \else + \pgfplotskeys@orig@xbari##1\pgfeov + \fi + }% + \pgfkeysdef{/pgfplots/ybar interval}{% + \ifpgfkeysaddeddefaultpath + \pgfkeysalso{/tikz/ybar interval}% + \else + \pgfplotskeys@orig@ybari##1\pgfeov + \fi + }% }% \def\pgfplots@end@plot{% @@ -2688,7 +5157,8 @@ \else \global\advance\pgfplots@numplots by1\relax% \fi - \pgfplots@execute@at@end@plot + \pgfkeysvalueof{/pgfplots/execute at end plot@@}% + \pgfkeysvalueof{/pgfplots/execute at end plot}% \endgroup%<-- close the \begingroup of \pgfplots@addplotimpl@plot@withoptions } @@ -2696,10 +5166,8 @@ \long\def\pgfplots@addplotimpl@coordinates#1#2plot coordinates#3#4;{\pgfplots@addplotimpl@coordinates@{#1}{#2}{#3}{#4}}% % \addplot[#1] [#2] coordinates {#3} #4; \long\def\pgfplots@addplotimpl@coordinates@#1#2#3#4{% -%\tracingmacros=2\tracingcommands=2 -%\pgfplots@message{processing plots coords with trailing path '#4'}% - \pgfplots@start@plot@with@behavioroptions{#2}% - \pgfplots@PREPARE@COORD@STREAM{#1}{#4}% + \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2}% + \pgfplots@PREPARE@COORD@STREAM{#4}% \ifpgfplots@curplot@threedim \pgfplots@coord@stream@foreach@threedim{#3}% \else @@ -2785,11 +5253,26 @@ \def\pgfplots@invoke@filter#1#2{% \pgfkeysvalueof{/pgfplots/#2 filter/.@cmd}#1\pgfeov% }% +\def\pgfplots@invoke@filter@xyz{% + \pgfkeysgetvalue{/pgfplots/filter point/.@cmd}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key + \else + \pgfkeyslet{/data point/x}\pgfplots@current@point@x + \pgfkeyslet{/data point/y}\pgfplots@current@point@y + \pgfkeyslet{/data point/z}\pgfplots@current@point@z + \pgfplots@loc@TMPa\pgfeov% + \pgfkeysgetvalue{/data point/x}\pgfplots@current@point@x + \pgfkeysgetvalue{/data point/y}\pgfplots@current@point@y + \pgfkeysgetvalue{/data point/z}\pgfplots@current@point@z + \fi% +}% % this is a convenience macro to save storage in the long coordinate % lists. \def\pgfplots@stream#1#2{\pgfplotstreampoint{\pgfqpoint{#1}{#2}}} +\def\pgfplots@stream@#1#2#3{\def\pgfplots@current@point@coordindex{#1}\pgfplots@stream{#2}{#3}} \def\pgfplots@stream@withmeta#1#2#3{\def\pgfplots@current@point@meta{#3}\pgfplotstreampoint{\pgfqpoint{#1}{#2}}} +\def\pgfplots@stream@withmeta@#1#2#3#4{\def\pgfplots@current@point@coordindex{#1}\pgfplots@stream@withmeta{#2}{#3}{#4}} \newif\ifpgfplots@record@marker@stream % Takes a sequence of PREPARED coordinates which are given in floating @@ -2808,17 +5291,21 @@ % Init the plot handlers: \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}% + \def\pgfplots@loc@TMPa{0}% <-- if (collectmark positions) \ifpgfplots@scatterplotenabled - \ifx\tikz@plot@mark\pgfutil@empty - \pgfplots@warning{I am confused: A scatter plot with 'mark=none'? This may need attention...?}% - \fi + \def\pgfplots@loc@TMPa{1}% collect mark positions even if 'mark=none'! scatter might not even use markers. \fi - % \ifx\tikz@plot@mark\pgfutil@empty + \else + \def\pgfplots@loc@TMPa{1}% + \fi + % + \if\pgfplots@loc@TMPa0% % mark=none : no need to waste time collecting marker % positions. \pgfplots@record@marker@streamfalse \else + % we need markers. \ifx\pgfplots@basiclevel@plothandler\pgfplothandlerdiscard \ifpgfplots@clip@marker@paths % only marks: draw markers directly; no need for the @@ -2855,14 +5342,7 @@ \pgfplotsapplistXXpushback{\pgfplotstreamstart}% %\gdef#1{\pgfplotstreamstart}% \fi - % Define \pgfplots@process@perpointmeta properly: - \ifnum\pgfplots@perpointmeta@choice=0 - % disabled. - \def\pgfplots@process@perpointmeta{% - \let\pgfplots@current@point@meta=\pgfutil@empty - }% - \else - \fi + \c@pgfplots@coordindex=0 }% \def\pgfplots@coord@stream@end@{% \ifpgfplots@apply@datatrafo @@ -2886,16 +5366,17 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pgfplots@coord@stream@INIT@finalize@storedcoords@prepare@scaletrafomacro % - % Will be inserted in one of two possible places below: - \def\pgfplots@loc@TMPa{% - \ifnum\pgfplots@perpointmeta@choice=0 + % Will be inserted in one of two possible places below (to collect + % marker positions) + \def\pgfplots@visualize@performserizalization{% + \ifx\pgfplotspointmetainputhandler\pgfutil@empty % we don't have per-point meta data. Nothing special to % do: - \E\edef\E\pgfmathresult{\E\noexpand\E\pgfplots@stream{\E\the\E\pgf@x}{\E\the\E\pgf@y}}% + \E\edef\E\pgfmathresult{\E\noexpand\E\pgfplots@stream@{\E\the\E\c@pgfplots@coordindex}{\E\the\E\pgf@x}{\E\the\E\pgf@y}}% \E\expandafter\E\pgfplotsapplistXXpushback\E\expandafter{\E\pgfmathresult}% \else % Ok, then we need to process the meta data as well: - \E\edef\E\pgfmathresult{\E\noexpand\E\pgfplots@stream@withmeta{\E\the\E\pgf@x}{\E\the\E\pgf@y}{\E\pgfplots@current@point@meta}}% + \E\edef\E\pgfmathresult{\E\noexpand\E\pgfplots@stream@withmeta@{\E\the\E\c@pgfplots@coordindex}{\E\the\E\pgf@x}{\E\the\E\pgf@y}{\E\pgfplots@current@point@meta}}% \E\expandafter\E\pgfplotsapplistXXpushback\E\expandafter{\E\pgfmathresult}% \fi }% @@ -2934,11 +5415,11 @@ \E\else \E\ifdim\E\pgf@yb>\E\pgfplots@zmax@reg \E\else - \pgfplots@loc@TMPa + \pgfplots@visualize@performserizalization \E\fi \E\fi \else - \pgfplots@loc@TMPa + \pgfplots@visualize@performserizalization \fi \E\fi \E\fi @@ -2946,6 +5427,7 @@ \E\fi \fi \E\pgfplotstreampoint{}% it will simply take \pgf@x and \pgf@y! + \advance\c@pgfplots@coordindex by1 }% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endgroup @@ -2962,9 +5444,24 @@ \pgfplots@coord@stream@finalize@currentpt }% \fi + \if\pgfplots@unbounded@handler j% unbounded coords=jump + \t@pgfplots@tokb=\expandafter{\pgfplots@coord@stream@coord@}% + \edef\pgfplots@coord@stream@coord@{% + \noexpand\ifx\noexpand\pgfplots@current@point@x\noexpand\pgfutil@empty + \noexpand\pgfplots@plothandler@unbounded@visualize@jump + \noexpand\else + \the\t@pgfplots@tokb + \noexpand\fi + }% + \fi % } +\def\pgfplots@plothandler@unbounded@visualize@jump{% + \pgfplotstreamend + \pgfplotstreamstart +}% + % Defines an optimized and matching \pgfplots@apply@data@scaletrafo@to@one@point % during the coordinate finalization step in \end{axis}. \def\pgfplots@coord@stream@INIT@finalize@storedcoords@prepare@scaletrafomacro{% @@ -2997,7 +5494,7 @@ % arithmetics are applied. \E\pgfplots@stacked@getnextzerolevelpoint \E\pgfplots@stacked@finishpoint% - \E\pgfplots@stacked@rememberzerolevelpoint@for@next@plot{(\E\pgfplots@current@point@x,\E\pgfplots@current@point@y)}% + \E\pgfplots@stacked@rememberzerolevelpoint@for@next@plot{(\E\pgfplots@current@point@x,\E\pgfplots@current@point@y\ifpgfplots@threedim,\E\pgfplots@current@point@z\fi)}% \fi % \t@pgfplots@tokc=\expandafter{\pgfplots@data@scaletrafo@result}% % \edef\pgfplots@data@scaletrafo@result{\the\t@pgfplots@tokc(\pgfplots@current@point@x,\pgfplots@current@point@y)}% @@ -3008,15 +5505,23 @@ \def\pgfplots@addplot@get@named@startendpoints@command#1{% \ifpgfplots@coord@stream@isfirst - \edef#1{% - \noexpand\pgfcoordinate{current plot begin}{\noexpand\pgfqpoint{\pgfplots@ZERO@x}{\pgfplots@ZERO@y}}% - \noexpand\pgfcoordinate{current plot end}{\noexpand\pgfqpoint{\pgfplots@ZERO@x}{\pgfplots@ZERO@y}}% + % empty plot. + \def#1{% + \pgfcoordinate{current plot begin}{\pgfplotspointaxisorigin}% + \pgfcoordinate{current plot end}{\pgfplotspointaxisorigin}% }% \else - \edef#1{% - \noexpand\pgfcoordinate{current plot begin}{\noexpand\pgfplotsqpointxy{\pgfplots@currentplot@firstcoord@x}{\pgfplots@currentplot@firstcoord@y}}% - \noexpand\pgfcoordinate{current plot end}{\noexpand\pgfplotsqpointxy{\pgfplots@currentplot@lastcoord@x}{\pgfplots@currentplot@lastcoord@y}}% - }% + \ifpgfplots@curplot@threedim + \edef#1{% + \noexpand\pgfcoordinate{current plot begin}{\noexpand\pgfplotsqpointxyz{\pgfplots@currentplot@firstcoord@x}{\pgfplots@currentplot@firstcoord@y}{\pgfplots@currentplot@firstcoord@z}}% + \noexpand\pgfcoordinate{current plot end}{\noexpand\pgfplotsqpointxyz{\pgfplots@currentplot@lastcoord@x}{\pgfplots@currentplot@lastcoord@y}{\pgfplots@currentplot@lastcoord@z}}% + }% + \else + \edef#1{% + \noexpand\pgfcoordinate{current plot begin}{\noexpand\pgfplotsqpointxy{\pgfplots@currentplot@firstcoord@x}{\pgfplots@currentplot@firstcoord@y}}% + \noexpand\pgfcoordinate{current plot end}{\noexpand\pgfplotsqpointxy{\pgfplots@currentplot@lastcoord@x}{\pgfplots@currentplot@lastcoord@y}}% + }% + \fi \fi }% @@ -3025,12 +5530,19 @@ % state of the \ifpgfplots@apply@datatrafo boolean) % \long\def\pgfplots@coord@stream@finalize@storedcoords@START normalized coordinates #1#2;\pgfplots@EOI{% + \ifpgfplots@threedim + \pgfplots@apply@zbuffer{#1}% + \let\pgfplots@coord@stream@finalize@storedcoords@START@coords=\pgfplotsglobalretval + \global\let\pgfplotsglobalretval=\relax + \else + \def\pgfplots@coord@stream@finalize@storedcoords@START@coords{#1}% + \fi \pgfplots@assert@tikzinternal@exists{tikz@make@last@position}% - \pgfplots@stored@current@cmd[current plot style] + \pgfplots@stored@current@cmd%[current plot style] <--- options are already set \pgfextra \tikzset{every plot/.try}% \pgfplots@coord@stream@INIT@finalize@storedcoords\pgfplots@recorded@marker@stream% - \pgfplots@coord@stream@foreach@NORMALIZED{#1}% + \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@coord@stream@finalize@storedcoords@START@coords}% \pgfutil@ifundefined{pgfplotlastpoint}{}{% \tikz@make@last@position{\pgfplotlastpoint}% }% @@ -3041,8 +5553,7 @@ \ifpgfplots@clip@marker@paths % Draw markers on top of the plot lines: % - % FIXME: inefficient! Use \scope to set variables of 'current plot style' !? - \pgfplots@stored@current@cmd[current plot style] + \pgfplots@stored@current@cmd%[current plot style] <--- options are already set \pgfextra \pgfplots@install@plotmark@handler \pgfplots@recorded@marker@stream @@ -3077,12 +5588,7 @@ % \noexpand\xdef\noexpand\pgfplots@metamin{\pgfplots@metamin}% \noexpand\xdef\noexpand\pgfplots@metamax{\pgfplots@metamax}% - \ifpgfplots@perpointmeta@usesfloat - \noexpand\pgfplots@perpointmeta@usesfloattrue - \else - \noexpand\pgfplots@perpointmeta@usesfloatfalse - \fi - \noexpand\def\noexpand\pgfplots@perpointmeta@choice{\pgfplots@perpointmeta@choice}% + \noexpand\def\noexpand\pgfplotspointmetainputhandler{\pgfplotspointmetainputhandler}% % \the\t@pgfplots@tokb \noexpand\pgfextra @@ -3097,8 +5603,6 @@ }% \def\pgfplots@install@plotmark@handler{% - \pgfplots@assert@tikzinternal@exists{tikz@options}% - \pgfplots@assert@tikzinternal@exists{tikz@mode}% % note: I can't check on tikz@transform because it can be '\relax'. \pgfplots@gettikzinternal@keyval{mark indices}{tikz@mark@list}{}% \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}% @@ -3148,20 +5652,9 @@ % the docs for details). % % Prepare arguments for '@pre/@post' macros: - \edef\pgfplotspointmetarange{\pgfplots@metamin:\pgfplots@metamax}% - \edef\pgfplotspointmetatransformedrange{\pgfplots@perpointmeta@traforange}% \t@pgfplots@toka={% \begingroup - \pgfutil@ifundefined{pgfplots@current@point@meta}{% - \pgfplots@error{'scatter' could not access its data source. Maybe you need to add '\string\addplot\space plot[scatter src=y]' or something like that?}% - \pgfmathfloatcreate{1}{1.0}{0}% - \def\pgfplotspointmetatransformed{1.0}% - }{% - % prepare arguments: - \let\pgfplotspointmeta=\pgfplots@current@point@meta - \pgfplots@perpointmeta@trafo{\pgfplotspointmeta}% - \let\pgfplotspointmetatransformed=\pgfmathresult - }% + \pgfplots@perpointmeta@trafo@APPLY \pgfkeysvalueof{/pgfplots/scatter/@pre marker code/.@cmd}\pgfeov }% \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}% @@ -3217,186 +5710,53 @@ \def\pgfplots@loc@TMPb{\pgfkeysvalueof{/pgfplots/error bars/draw error bar/.@cmd}}% \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfeov } +\def\pgfplots@errorbar@draw@float@threedim(#1,#2,#3)(#4,#5,#6){% + \ifpgfplots@apply@datatrafo@x + \pgfplots@datascaletrafo@x{#1}% + \let\pgfplots@xarg=\pgfmathresult% + \pgfplots@datascaletrafo@x{#4}% + \let\pgfplots@error@xarg=\pgfmathresult% + \else + \def\pgfplots@xarg{#1}% + \def\pgfplots@error@xarg{#4}% + \fi + \ifpgfplots@apply@datatrafo@y + \pgfplots@datascaletrafo@y{#2}% + \let\pgfplots@yarg=\pgfmathresult% + \pgfplots@datascaletrafo@y{#5}% + \let\pgfplots@error@yarg=\pgfmathresult% + \else + \def\pgfplots@yarg{#2}% + \def\pgfplots@error@yarg{#5}% + \fi + \ifpgfplots@apply@datatrafo@z + \pgfplots@datascaletrafo@z{#3}% + \let\pgfplots@zarg=\pgfmathresult% + \pgfplots@datascaletrafo@z{#6}% + \let\pgfplots@error@zarg=\pgfmathresult% + \else + \def\pgfplots@zarg{#3}% + \def\pgfplots@error@zarg{#6}% + \fi + \edef\pgfplots@loc@TMPa{{(\pgfplots@xarg,\pgfplots@yarg,\pgfplots@zarg)}{(\pgfplots@error@xarg,\pgfplots@error@yarg,\pgfplots@error@zarg)}}% + \def\pgfplots@loc@TMPb{\pgfkeysvalueof{/pgfplots/error bars/draw error bar/.@cmd}}% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfeov +} \def\pgfplots@errorbar@draw#1#2{% \begingroup \ifpgfplots@apply@datatrafo - \pgfplots@errorbar@draw@float#1#2 + \ifpgfplots@curplot@threedim + \pgfplots@errorbar@draw@float@threedim#1#2% + \else + \pgfplots@errorbar@draw@float#1#2% + \fi \else \pgfkeysvalueof{/pgfplots/error bars/draw error bar/.@cmd}{#1}{#2}\pgfeov% \fi \endgroup }% -% Arguments: -% \pgfplots@current@point@[xyz] -% \pgfplots@current@point@[xyz]@unfiltered -% \pgfplots@current@point@[xyz]@error (if in argument list) -% Also provides UNFILTERED arguments x and y . These are use -% in case of logplots, because we may need to compute log( x + e_x ) -% or log( y + e_y ). -\def\pgfplots@process@errorbar@for{% -% \begingroup - \edef\pgfplots@xarg{\pgfplots@current@point@x}% - \edef\pgfplots@yarg{\pgfplots@current@point@y}% - \let\pgfplots@xarg@unfiltered\pgfplots@current@point@x@unfiltered% - \let\pgfplots@yarg@unfiltered\pgfplots@current@point@y@unfiltered% - \edef\pgfplots@error@xarg{\pgfplots@current@point@x@error}% - \edef\pgfplots@error@yarg{\pgfplots@current@point@y@error}% - \def\pgfplots@loc@TMPa{0}% - \ifx\pgfplots@loc@TMPa\pgfplots@error@xarg - \let\pgfplots@error@xarg=\pgfutil@empty - \fi - \ifx\pgfplots@loc@TMPa\pgfplots@error@yarg - \let\pgfplots@error@yarg=\pgfutil@empty - \fi - % FIXME : INEFFICIENT! This code here does every computation - % multiple times! - \ifcase\pgfplots@errorbars@xdirection - \or - \pgfplots@process@errorbar@@for{x}{+}1% - \or - \pgfplots@process@errorbar@@for{x}{-}2% - \or - \pgfplots@process@errorbar@@for{x}{+}1% - \pgfplots@process@errorbar@@for{x}{-}2% - \fi - \ifcase\pgfplots@errorbars@ydirection - \or - \pgfplots@process@errorbar@@for{y}{+}1% - \or - \pgfplots@process@errorbar@@for{y}{-}2% - \or - \pgfplots@process@errorbar@@for{y}{+}1% - \pgfplots@process@errorbar@@for{y}{-}2% - \fi - % Restore macros which may have been overwritten: - \let\pgfplots@current@point@x=\pgfplots@xarg - \let\pgfplots@current@point@y=\pgfplots@yarg -% \endgroup -} - -% #1: either 'x' or 'y' -% #2: either '+' or '-' -% #3: an integer representing the argument #2. It is '1' if #2='+' -% and '2' is #2 = '-'. -\def\pgfplots@process@errorbar@@for#1#2#3{% - \csname ifpgfplots@#1islinear\endcsname - \edef\pgfplots@error@src{\csname pgfplots@#1arg\endcsname}% - \ifcase\csname pgfplots@errorbars@#1mode\endcsname - % fixed absolute error. - \edef\pgfplots@error@coord{\csname pgfplots@errorbars@#1fixed\endcsname}% - \pgfmathfloatparsenumber{\pgfplots@error@coord}% - \let\pgfplots@error@coord=\pgfmathresult - \ifnum#3=1 - \pgfmathfloatadd@{\pgfplots@error@src}{\pgfplots@error@coord}% - \else - \pgfmathfloatsubtract@{\pgfplots@error@src}{\pgfplots@error@coord}% - \fi - \let\pgfplots@error@coord=\pgfmathresult - \or% fixed relative error: - \pgfmathparse{(1#2\csname pgfplots@errorbars@#1rel\endcsname)}% - \let\pgfplots@error@coord=\pgfmathresult - \pgfmathfloatmultiplyfixed@{\pgfplots@error@src}{\pgfplots@error@coord}% - \let\pgfplots@error@coord=\pgfmathresult - \or% explicit absolute: - \edef\pgfplots@error@coord{\csname pgfplots@error@#1arg\endcsname}% - \ifx\pgfplots@error@coord\pgfutil@empty - \else - \pgfmathfloatparsenumber{\pgfplots@error@coord}% - \let\pgfplots@error@coord=\pgfmathresult - \ifnum#3=1 - \pgfmathfloatadd@{\pgfplots@error@src}{\pgfplots@error@coord}% - \else - \pgfmathfloatsubtract@{\pgfplots@error@src}{\pgfplots@error@coord}% - \fi - \let\pgfplots@error@coord=\pgfmathresult - \fi - \or% explicit relative: - \edef\pgfplots@error@coord{\csname pgfplots@error@#1arg\endcsname}% - \ifx\pgfplots@error@coord\pgfutil@empty - \else - \pgfmathparse{(1#2\pgfplots@error@coord)}% - \let\pgfplots@error@coord=\pgfmathresult - \pgfmathfloatmultiplyfixed@{\pgfplots@error@src}{\pgfplots@error@coord}% - \let\pgfplots@error@coord=\pgfmathresult - \fi - \fi - \else - % LOGARITHMIC scaling. All errors are interpreted as - % log(x +- e_x) - % or - % log( x*(1+-e_x) ) - \ifcase\csname pgfplots@errorbars@#1mode\endcsname - % fixed absolute, log( x +- e_x ) - \edef\pgfplots@error@src{\csname pgfplots@#1arg@unfiltered\endcsname}% - \edef\pgfplots@error@coord{\csname pgfplots@errorbars@#1fixed\endcsname}% - \pgfmathfloatparsenumber{\pgfplots@error@coord}% - \let\pgfplots@error@coord=\pgfmathresult - \pgfmathfloatparsenumber{\pgfplots@error@src}% - \let\pgfplots@error@src=\pgfmathresult - \ifnum#3=1 - \pgfmathfloatadd@{\pgfplots@error@src}{\pgfplots@error@coord}% - \else - \pgfmathfloatsubtract@{\pgfplots@error@src}{\pgfplots@error@coord}% - \fi - \pgfmathlog@float{\pgfmathresult}% - \let\pgfplots@error@coord=\pgfmathresult - \or% fixed relative, log( x ( 1+-e_x ) ) = log(x) + log(1+-e_x) - \edef\pgfplots@error@src{\csname pgfplots@#1arg\endcsname}% - \pgfmathparse{\pgfplots@error@src + ln(1#2\csname pgfplots@errorbars@#1rel\endcsname)}% - \let\pgfplots@error@coord=\pgfmathresult% - \or% explicit absolute - \edef\pgfplots@error@src{\csname pgfplots@#1arg@unfiltered\endcsname}% - \edef\pgfplots@error@coord{\csname pgfplots@error@#1arg\endcsname}% - \ifx\pgfplots@error@coord\pgfutil@empty - \else - \pgfmathfloatparsenumber{\pgfplots@error@coord}% - \let\pgfplots@error@coord=\pgfmathresult - \pgfmathfloatparsenumber{\pgfplots@error@src}% - \let\pgfplots@error@src=\pgfmathresult - \ifnum#3=1 - \pgfmathfloatadd@{\pgfplots@error@src}{\pgfplots@error@coord}% - \else - \pgfmathfloatsubtract@{\pgfplots@error@src}{\pgfplots@error@coord}% - \fi - \pgfmathlog@float{\pgfmathresult}% - \let\pgfplots@error@coord=\pgfmathresult - \fi - \or% explicit relative: - \edef\pgfplots@error@src{\csname pgfplots@#1arg\endcsname}% - \edef\pgfplots@error@coord{\csname pgfplots@error@#1arg\endcsname}% - \ifx\pgfplots@error@coord\pgfutil@empty - \else - \pgfmathparse{\pgfplots@error@src + ln(1#2 \pgfplots@error@coord)}% - \let\pgfplots@error@coord=\pgfmathresult% - \fi - \fi - \fi - \ifx\pgfplots@error@coord\pgfutil@empty - \else - \def\pgfplots@loc@TMPa{#1}% - \def\pgfplots@loc@TMPb{x}% - \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb - \let\pgfplots@current@point@x=\pgfplots@error@coord - \let\pgfplots@current@point@y=\pgfplots@yarg - \pgfplots@update@limits@for@one@point - \edef\pgfplots@loc@TMPa{% - {(\pgfplots@xarg,\pgfplots@yarg)}% - {(\pgfplots@error@coord,\pgfplots@yarg)}% - }% - \else - \let\pgfplots@current@point@x=\pgfplots@xarg - \let\pgfplots@current@point@y=\pgfplots@error@coord - \pgfplots@update@limits@for@one@point - \edef\pgfplots@loc@TMPa{% - {(\pgfplots@xarg,\pgfplots@yarg)}% - {(\pgfplots@xarg,\pgfplots@error@coord)}% - }% - \fi - \expandafter\pgfplots@streamerrorbarcoords\pgfplots@loc@TMPa - \fi -} % This routine is called at the begin of every plot. % It initialises a zero level stream. % @@ -3416,8 +5776,9 @@ % coordinates. \pgfplots@stacked@initzerolevelhandler \else - \pgfplotxzerolevelstreamconstant{\pgfplots@ZERO@x}% - \pgfplotyzerolevelstreamconstant{\pgfplots@ZERO@y}% + \pgfplotspointaxisorigin + \expandafter\pgfplotxzerolevelstreamconstant\expandafter{\the\pgf@x}% + \expandafter\pgfplotyzerolevelstreamconstant\expandafter{\the\pgf@y}% \fi } @@ -3430,26 +5791,32 @@ \def\pgfplots@prepare@ZERO@coordinates{% \ifpgfplots@xislinear \ifpgfplots@apply@datatrafo@x - \pgfplots@datascaletrafo@fromfixed@x{0}% + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfplots@datascaletrafo@x{\pgfmathresult}% \global\let\pgfplots@logical@ZERO@x=\pgfmathresult \else \gdef\pgfplots@logical@ZERO@x{0}% \fi \pgfplotsmathmax{\pgfplots@logical@ZERO@x}{\pgfplots@xmin}% \global\let\pgfplots@logical@ZERO@x=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@x}{\pgfplots@xmax}% + \global\let\pgfplots@logical@ZERO@x=\pgfmathresult \else \global\let\pgfplots@logical@ZERO@x=\pgfplots@xmin% \fi % \ifpgfplots@yislinear \ifpgfplots@apply@datatrafo@y - \pgfplots@datascaletrafo@fromfixed@y{0}% + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfplots@datascaletrafo@y{\pgfmathresult}% \global\let\pgfplots@logical@ZERO@y=\pgfmathresult \else \gdef\pgfplots@logical@ZERO@y{0}% \fi \pgfplotsmathmax{\pgfplots@logical@ZERO@y}{\pgfplots@ymin}% \global\let\pgfplots@logical@ZERO@y=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@y}{\pgfplots@ymax}% + \global\let\pgfplots@logical@ZERO@y=\pgfmathresult \else \global\let\pgfplots@logical@ZERO@y=\pgfplots@ymin% \fi @@ -3457,20 +5824,22 @@ \ifpgfplots@threedim \ifpgfplots@zislinear \ifpgfplots@apply@datatrafo@z - \pgfplots@datascaletrafo@fromfixed@z{0}% + \pgfmathfloatcreate{0}{0.0}{0}% + \pgfplots@datascaletrafo@z{\pgfmathresult}% \global\let\pgfplots@logical@ZERO@z=\pgfmathresult \else \gdef\pgfplots@logical@ZERO@z{0}% \fi \pgfplotsmathmax{\pgfplots@logical@ZERO@z}{\pgfplots@zmin}% \global\let\pgfplots@logical@ZERO@z=\pgfmathresult + \pgfplotsmathmin{\pgfplots@logical@ZERO@z}{\pgfplots@zmax}% + \global\let\pgfplots@logical@ZERO@z=\pgfmathresult \else \global\let\pgfplots@logical@ZERO@z=\pgfplots@zmin% \fi \fi % % - \pgfinterruptboundingbox% \ifpgfplots@threedim \pgfplotsqpointxyz{\pgfplots@logical@ZERO@x}{\pgfplots@logical@ZERO@y}{\pgfplots@logical@ZERO@z}% \else @@ -3478,11 +5847,15 @@ \fi \xdef\pgfplots@ZERO@x{\the\pgf@x}% \xdef\pgfplots@ZERO@y{\the\pgf@y}% - \endpgfinterruptboundingbox% + \xdef\pgfplotspointaxisorigin{\noexpand\pgf@x=\pgfplots@ZERO@x\space\noexpand\pgf@y=\pgfplots@ZERO@y\space}% }% +% the low-level Tikz command which realizes 'plot graphics'. +% +% It's current state is described by some pgfkeys options and two +% coordinates. \def\pgfplotsplothandlergraphics{% \def\pgf@plotstreamstart{% \global\let\pgfplots@plot@handler@graphics@bb@first=\pgfutil@empty @@ -3490,6 +5863,9 @@ \global\let\pgf@plotstreampoint=\pgfplots@plot@handler@graphics@collectbb% \global\let\pgf@plotstreamspecial=\pgfutil@gobble% \global\let\pgf@plotstreamend=\pgfplots@plot@handler@graphics@finish% + \def\pgfplots@plothandler@unbounded@visualize@jump{% + \pgfplots@error{Sorry, plot graphics does not support 'unbounded coords=jump'.}% + }% }% }% \def\pgfplots@plot@handler@graphics@collectbb#1{% @@ -3516,20 +5892,1145 @@ \pgfplots@error{Error using 'plot graphics': I got too few coordinates! I expected the lower left and upper right corners!}% \xdef\pgfplots@plot@handler@graphics@bb@second{\noexpand\pgfqpoint{0pt}{0pt}}% \fi - \pgfpointdiff{\pgfplots@plot@handler@graphics@bb@first}{\pgfplots@plot@handler@graphics@bb@second}% - \edef\pgfplots@loc@TMPa{\the\pgf@x}% width - \edef\pgfplots@loc@TMPb{\the\pgf@y}% height + \begingroup + % determine the lower left / upper right corners. + \pgfplots@plot@handler@graphics@bb@first + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfplots@plot@handler@graphics@bb@second + \pgf@xb=\pgf@x + \pgf@yb=\pgf@y + % + % xc,yc = lower left corner + % x,y = upper right + \ifdim\pgf@xa<\pgf@xb + \pgf@xc=\pgf@xa + \pgf@x=\pgf@xb + \else + \pgf@xc=\pgf@xb + \pgf@x=\pgf@xa + \fi + \ifdim\pgf@ya<\pgf@yb + \pgf@yc=\pgf@ya + \pgf@y=\pgf@yb + \else + \pgf@yc=\pgf@yb + \pgf@y=\pgf@ya + \fi + \advance\pgf@x by-\pgf@xc + \advance\pgf@y by-\pgf@yc + \edef\pgfplots@plot@handler@graphics@DRAW@{% + \noexpand\pgfplots@invoke@pgfkeyscode{/pgfplots/plot graphics/lowlevel draw/.@cmd}{% + {\the\pgf@x}% width + {\the\pgf@y}% height + }% + }% + \pgf@x=\pgf@xc + \pgf@y=\pgf@yc + \pgftransformshift{}% + \node[/pgfplots/plot graphics/node] {% + \pgfplots@plot@handler@graphics@DRAW@ + };% + \endgroup +}% +% initial value for /pgfplots/plots graphics/lowlevel draw: +\def\pgfplots@plot@handler@graphics@DRAW#1#2{% \pgfkeysgetvalue{/pgfplots/plot graphics/includegraphics}{\pgfplots@loc@TMPc}% \pgfkeysgetvalue{/pgfplots/plot graphics/src}{\pgfplots@loc@TMPd}% \ifx\pgfplots@loc@TMPd\pgfutil@empty \pgfplots@error{Error using 'plot graphics': I don't have a graphics file name! Please set the '/pgfplots/plot graphics/src' key to the image file name. Skipping this plot.}% \else + \expandafter\includegraphics\expandafter[\pgfplots@loc@TMPc,width=#1,height=#2]{\pgfplots@loc@TMPd}% + \fi +}% + + + +% The low-level tikz plot handler for 3D mesh and surface plots. +% +% It expects +% a) a coordinate stream which is a linearized matrix, iterated either +% rowwise or column wise, +% b) the current set of options in /pgfplots/mesh/. +% +% +% ATTENTION: +% this handler is NOT as general as the others. In particular, it +% can't be interrupted by TeX groups: every single statement, +% starting with streamstart and ending with stream end, must be in +% the same scope! +% +% As a consequence, you can't use this handler inside of (all) TikZ +% input streams. Try it out. It will work in pgfplots, however. +% +% Furthermore, it relies on a couple of pgfplots macros. This may +% change in future versions. +% It relies on: +% - \ifpgfplots@curplot@threedim +% - \pgfplots@current@point@meta +% -> it also invokes \pgfplots@perpointmeta@preparetrafo and its +% @APPLY counterpart which checks for +% - \pgfplots@metamax +% If you use it outside of pgfplots, use +% \global\let\pgfplots@metamax=\pgfutil@empty +% This is can be used without an initialised +% pgfplots axes - as long as \pgfplots@current@point@meta is in +% the range [0,1000]. +% - for the case 'shader=interp', a bounding box must be established +% before the plot is finished. This must be done using +% \def\pgfplotspointbbupperright{\pgfqpointxyz{2}{2}{0.9}} +% \def\pgfplotspointbblowerleft {\pgfqpointxyz{0}{0}{0.1}} +% or something like that. +% +% Besides these internals, it also relies on all public /pgfplots +% configuration keys related to mesh/surface plots. +% +% Please note that the 'z buffer' feature will not work without +% pgfplots (especially the z buffer=sort feature). +% +% Here is an example which compiles without a pgfplots axes: +% ---------------------------------------------------------- +% \begin{tikzpicture} +% \scope[ +% /pgfplots/.cd, +% surf, +% shader=faceted, +% mesh/rows=4, +% mesh/cols=4, +% mesh/num points=, +% /tikz/x={(0.44237cm,-0.07439cm)}, +% /tikz/y={(0.30942cm,0.23932cm)}, +% /tikz/z={(0.0cm,1.5cm)}, +% ] +% \makeatletter +% +% \global\let\pgfplots@metamax=\pgfutil@empty +% \pgfplots@curplot@threedimtrue +% +% \pgfplotsplothandlermesh +% \pgfplotstreamstart +% +% \def\rangea{0.21}% +% \def\rangeb{0.9}% +% +% \pgfmathparse{1000/(\rangeb-\rangea)} +% \let\factor=\pgfmathresult +% +% \def\simplecoordinate(#1,#2,#3){% +% \pgfmathparse{\factor*(#3 - \rangea)}% +% \let\pgfplots@current@point@meta=\pgfmathresult +% \pgfplotstreampoint{\pgfqpointxyz{#1}{#2}{#3}}% +% }% +% % for the case 'shaer=interp': +% \def\pgfplotspointbbupperright{\pgfqpointxyz{2}{2}{0.9}} +% \def\pgfplotspointbblowerleft {\pgfqpointxyz{0}{0}{0.1}} +% +% \simplecoordinate(0,3,0.7) +% \simplecoordinate(1,3,0.5) +% \simplecoordinate(2,3,0.58) +% \simplecoordinate(3,3,0.9) +% +% \simplecoordinate(0,2,0.68) +% \simplecoordinate(1,2,0.22) +% \simplecoordinate(2,2,0.25) +% \simplecoordinate(3,2,0.4) +% +% \simplecoordinate(0,1,0.6) +% \simplecoordinate(1,1,0.3) +% \simplecoordinate(2,1,0.21) +% \simplecoordinate(3,1,0.3) +% +% \simplecoordinate(0,0,0.8) +% \simplecoordinate(1,0,0.56) +% \simplecoordinate(2,0,0.5) +% \simplecoordinate(3,0,0.75) +% +% +% \pgfplotstreamend +% \pgfusepath{stroke} +% +% \endscope +% \end{tikzpicture} +% ---------------------------------------------------------- +% END OF EXAMPLE +% -> see also the legend image for mesh plots. +% +\def\pgfplotsplothandlermesh{% + \def\pgf@plotstreamstart{% +% \scope + \pgfplotsautocompletemeshkeys% + \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsplothandlermesh@rows + \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsplothandlermesh@cols + \pgfkeysgetvalue{/pgfplots/mesh/num points}\pgfplotsplothandlermesh@numpoints + % + \pgfutil@ifundefined{pgfplots@drawmodes}{% + \let\pgfplots@drawmodes=\tikz@mode + \let\pgfplots@drawoptions=\tikz@options + }{}% + % + \def\pgfplotsplothandlermesh@ONEDIMMODE{0}% + \ifnum\pgfplotsplothandlermesh@cols=1 + \def\pgfplotsplothandlermesh@ONEDIMMODE{1}% + \fi + \ifnum\pgfplotsplothandlermesh@rows=1 + \def\pgfplotsplothandlermesh@ONEDIMMODE{1}% + \fi + % + % + % Prepare color data source: + \ifx\pgfplotspointmetainputhandler\pgfutil@empty% + % oh. There is no color data!? Well... then use a constant + % color. + % + % This activates tikz colors: + %\tikz@options + \def\pgfplotsplothandlermesh@preparedrawforcurrent{% + \pgfplots@drawoptions + }% + \else + % Ok, we have color data. + % + % Prepare: + \pgfplots@perpointmeta@preparetrafo + \def\pgfplotsplothandlermesh@preparedrawforcurrent{% + \pgfplotscolormapdefinemappedcolor{\pgfplotsplothandlermesh@shader@cellcolor}% +% \pgfplotsplothandlermesh@setcolor{mapped color}% + % This activates tikz colors: +%\message{executing \meaning\pgfplots@drawoptions'}% + %\tikz@options + \pgfplots@drawoptions + }% + % + % Acquire the values for \tikz@mode@* [used for faceted] + \pgfplots@drawmodes + % + % Now, process the 'shader' key here: + \if\pgfplotsplothandlermesh@ONEDIMMODE1 + \def\pgfplots@meshmode{m}% 'mesh' + \fi + \if\pgfplots@meshmode m% mesh + % this is processed by the 'shader=flat' code below. + \def\pgfplotsplothandlermesh@shader{0}% 'flat' + \fi + \if\pgfplotsplothandlermesh@shader2% 'shader=interp' + \pgflibrarysurfshadingifactive + {}% + {% + \pgfutil@ifundefined{pgfplotsplothandlermesh@shader@warning}{% + \pgfplots@error{Sorry, surface shading (shader=interp) is NOT available for the selected driver `\pgfsysdriver'. I will use 'shader=flat' if you continue now}% + \gdef\pgfplotsplothandlermesh@shader@warning{x}% + }{}% + \def\pgfplotsplothandlermesh@shader{0}% + }% + \fi + \if\pgfplotsplothandlermesh@zbuffer@choice4% 'z buffer=sort': + \if\pgfplotsplothandlermesh@shader2% 'shader=interp' + \pgfplots@error{Sorry, 'shader=interp' does not support 'z buffer=sort'. If you continue now, 'shader=flat' will be used.}% + \def\pgfplotsplothandlermesh@shader{0}% 'flat' + \fi + \fi + \ifnum\pgfplotsplothandlermesh@shader<2 + % 0 == 'flat' + % 1 == 'faceted' + \if\pgfplotsplothandlermesh@flatmode c% 'flat corner': + % + % use colordata of ONE corner point. That's easy, not + % much to do. + \let\pgfplotsplothandlermesh@unpack=\pgfplotsplothandlermesh@unpack@corner + \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@preparedrawforcurrent}% + \t@pgfplots@tokb={% + \pgfplots@perpointmeta@trafo@APPLY + \let\pgfplotsplothandlermesh@shader@cellcolor=\pgfplotspointmetatransformed}% + \edef\pgfplotsplothandlermesh@preparedrawforcurrent{% + \the\t@pgfplots@tokb + \the\t@pgfplots@toka + }% + \else + % 'flat mean': + % + % use colordata as mean of all corners for shading. + \let\pgfplotsplothandlermesh@unpack=\pgfplotsplothandlermesh@unpack@mean@accum + \global\pgfplots@tmpa=0pt + \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@preparedrawforcurrent}% + \if\pgfplotsplothandlermesh@ONEDIMMODE0 + \t@pgfplots@tokb={\global\divide\pgfplots@tmpa by4 }% + \else + \t@pgfplots@tokb={\global\divide\pgfplots@tmpa by2 }% + \fi + \t@pgfplots@tokc={% + \edef\pgfplotsplothandlermesh@shader@cellcolor{\pgf@sys@tonumber\pgfplots@tmpa}% + \global\pgfplots@tmpa=0pt }% + \edef\pgfplotsplothandlermesh@preparedrawforcurrent{% + \the\t@pgfplots@tokb + \the\t@pgfplots@tokc + \the\t@pgfplots@toka + }% + \fi + \if\pgfplots@meshmode m% + % 'mesh' plot: stroke only and use the 'flat' code + % here just to define the color for each mesh + % segment. + \let\pgfplotsplothandlermesh@usepath=\pgfusepathqstroke + \else + % 'surf' plot: + \let\pgfplotsplothandlermesh@usepath=\pgfusepathqfillstroke + % the distinction between 'faceted' and 'flat' is + % technical: it is just the default draw color. + % + % 'flat,draw=black' is the same as 'faceted'. + \if\pgfplotsplothandlermesh@shader1% faceted + % make sure there is a the correct color. + \expandafter\def\expandafter\pgfplots@drawoptions\expandafter{% + \pgfplots@drawoptions + \pgfsetstrokecolor{\pgfkeysvalueof{/pgfplots/faceted color}}% + }% + \fi + \fi + \else + % 'shader=2': 'interp': + % very simple: defer work to surf library. Only + % provide the mapped colordata. + % + % This won't be used for mesh plots, neither in one + % nor in two dimensions. + \pgfkeyssetvalue{/pgfplots/surf shading/north east corner}{\pgfplotspointbbupperright}% + \pgfkeyssetvalue{/pgfplots/surf shading/south west corner}{\pgfplotspointbblowerleft}% + \pgfkeyssetvalue{/pgfplots/surf shading/anchor}{\pgfpointorigin}% + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa + \expandafter\pgfplotscolormaptopdffunction\expandafter{\pgfplots@loc@TMPa}% + \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsretval + \let\pgfplotsplothandlermesh@unpack=\relax % unused. + \let\pgfplotsplothandlermesh@preparedrawforcurrent=\relax + \pgfkeyslet{/pgfplots/surf shading/cols}\pgfplotsplothandlermesh@cols + \if\pgfplots@plot@mesh@ordering0% + % ordering=x varies: + \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@shader@interp% + \else + % colwise: + % + % The low level shader NEEDS rowwise ordering. So, we need to transpose the data matrix. + % As usual in TeX, we should save macros as much as possible. I guess we NEED at least one macro for each matrix row. + % Idea: + % while we iterate colwise through the input data, accumulate row vectors. + % Then, process the row vectors. + % Since vectors are expensive (in terms of number of macros), we use fast "append" lists instead of vectors. + \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@shader@interp@incremental@transpose% + % + % init all required row vectors: + \c@pgfplots@scanlineindex=0 + \pgfutil@loop + \ifnum\c@pgfplots@scanlineindex<\pgfplotsplothandlermesh@rows\relax + \expandafter\pgfplotsapplistXnewempty\csname pgfp@transprow@\the\c@pgfplots@scanlineindex\endcsname% + \advance\c@pgfplots@scanlineindex by1 + \pgfutil@repeat + %\pgfkeyslet{/pgfplots/surf shading/cols}\pgfplotsplothandlermesh@rows + %\pgfplots@error{Sorry, the 'shader=interp' does not yet support 'mesh/ordering=colwise'... You can continue now, but the plot will be transposed.}% + \fi + \pgfplotslibrarysurfstreamstart + \let\pgfplotsplothandlermesh@usepath=\pgfusepathqfill + \fi + \fi + % PREPARE THE STREAM PROCESSING: + \def\pgfplots@plothandler@unbounded@visualize@jump{% + \pgfplotstreampoint{\pgf@x=-16000.0pt \pgf@y=-16000.0pt }% + }% + \def\pgfplotsplothandlermesh@check@unbounded####1####2\relax{% + \ifdim####1=-16000pt + \pgfplots@loc@tmpfalse + \fi + }% + \if\pgfplotsplothandlermesh@ONEDIMMODE1% + % Special case: 1D mesh processing + \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@ONEDIM@draw% + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotsplothandlermesh@finish% + \let\pgfplotsplothandlermesh@draw@element=\pgfplotsplothandlermesh@draw@element@line + \def\pgfplotsplothandlermesh@process@element{% + \pgfplotsplothandlermesh@draw@element + \pgfplotsplothandlermesh@i + \pgfplotsplothandlermesh@im + }% + \if\pgfplots@unbounded@handler j% + % unbounded coords=jump: + % append checks for unbounded coords to + % \pgfplotsplothandlermesh@process@element + \t@pgfplots@tokb={% + \pgfplots@loc@tmptrue + \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@i\relax + \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@im\relax + }% + \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@process@element}% + \edef\pgfplotsplothandlermesh@process@element{% + \the\t@pgfplots@tokb + \noexpand\ifpgfplots@loc@tmp + \the\t@pgfplots@toka + \noexpand\fi + }% + \fi + \if\pgfplotsplothandlermesh@zbuffer@choice4% + % z buffer=sort: + % create a z buffer: + % the z buffer contains elements {<view depth>}{{<pt1>}{<pt2>}{<pt3>}{<pt4>}} + \pgfplotsarraynewempty\pgfplots@zbuffer@local + % + % and collect each point into the z buffer: + \def\pgfplotsplothandlermesh@process@element{% + \pgfplotsmathviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% FIXME relies on pgfplots macros + % assemble array element: + \edef\pgfplots@loc@TMPa{% + {\pgfmathresult}% + {% + {\pgfplotsplothandlermesh@i}% + {\pgfplotsplothandlermesh@im}% + }% + }% + \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPa\to\pgfplots@zbuffer@local + }% + \fi + \else + % ok, normal 2D mesh processing: + % + % And now finally: initialise the conversion from + % LINEARIZED COORD STREAM -> DATA MATRIX: + \if\pgfplots@plot@mesh@ordering0% + % x varies (=rowwise): + \let\pgfplotsplothandlermesh@scanlinelength=\pgfplotsplothandlermesh@cols + \else + % y varies (=colwise): + \let\pgfplotsplothandlermesh@scanlinelength=\pgfplotsplothandlermesh@rows + \fi + \def\pgfplotsplothandlermesh@process@element{% + \pgfplotsplothandlermesh@draw@element + \pgfplotsplothandlermesh@im@jm + \pgfplotsplothandlermesh@im@j + \pgfplotsplothandlermesh@i@j + \pgfplotsplothandlermesh@i@jm + }% + % Init memory: + \c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax + \advance\c@pgfplots@scanlineindex by1 + \pgfplotsdequenewempty{lastscanline}\capacity{\the\c@pgfplots@scanlineindex}% + % + \if2\pgfplotsplothandlermesh@shader + % shader=interp does not support z buffer=sort. + % It also has its own \pgf@plotstreampoint method, see + % above. + \def\pgfplots@plothandler@unbounded@visualize@jump{% + \pgfplots@error{Sorry, shader=interp does not support 'unbounded coords=jump'. Please use 'shader=flat' for this case.}% + }% + \else + \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@fillscanline% + \if\pgfplotsplothandlermesh@zbuffer@choice4% + % z buffer=sort: + % create a z buffer: + % the z buffer contains elements {<view depth>}{{<pt1>}{<pt2>}{<pt3>}{<pt4>}} + \pgfplotsarraynewempty\pgfplots@zbuffer@local + % + % and collect each point into the z buffer + % (instead of drawing it): + \def\pgfplotsplothandlermesh@process@element{% + \pgfplotsmathviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% FIXME relies on pgfplots macros + % assemble array element: + \edef\pgfplots@loc@TMPa{% + {\pgfmathresult}% + {% + {\pgfplotsplothandlermesh@im@jm}% + {\pgfplotsplothandlermesh@im@j}% + {\pgfplotsplothandlermesh@i@j}% + {\pgfplotsplothandlermesh@i@jm}% + }% + }% + \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPa\to\pgfplots@zbuffer@local + }% + \fi + \if\pgfplots@unbounded@handler j% + % unbounded coords=jump: + % append checks for unbounded coords to + % \pgfplotsplothandlermesh@process@element + \t@pgfplots@tokb={% + \pgfplots@loc@tmptrue + \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@i@j\relax + \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@i@jm\relax + \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@im@j\relax + \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@im@jm\relax + }% + \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@process@element}% + \edef\pgfplotsplothandlermesh@process@element{% + \the\t@pgfplots@tokb + \noexpand\ifpgfplots@loc@tmp + \the\t@pgfplots@toka + \noexpand\fi + }% + \fi + \fi + % + \global\let\pgf@plotstreamspecial=\pgfutil@gobble% + \global\let\pgf@plotstreamend=\pgfplotsplothandlermesh@finish% + \let\pgfplotsplothandlermesh@draw@element=\pgfplotsplothandlermesh@draw@element@rectangle + \fi + \c@pgfplots@scanlineindex=0 + }% +}% + +\long\def\pgfplotsplothandlermesh@defaultlegend@img#1{% + \scope[% + #1, + /pgfplots/mesh/rows=3, + /pgfplots/mesh/cols=3, + /pgfplots/mesh/num points=, + /tikz/x={(0.44237cm,-0.07439cm)}, + /tikz/y={(0.30942cm,0.23932cm)}, + /tikz/z={(0.0cm,1.5cm)}, + scale=0.4, + yshift=-0.7cm, + ] + \let\pgfplots@metamax=\pgfutil@empty + \pgfplots@curplot@threedimtrue + + \pgfplotsplothandlermesh + \pgfplotstreamstart + + \def\rangea{0.21}% + \def\rangeb{0.7}% + + \pgfmathparse{1000/(\rangeb-\rangea)} + \let\factor=\pgfmathresult + + \pgfutil@ifundefined{pgfqpointxyz@orig}{% + \let\pgfqpointxyz@orig=\pgfqpointxyz + }{}% + % + \def\simplecoordinate(##1,##2,##3){% + \pgfmathparse{\factor*(##3 - \rangea)}% + \pgfmathfloatparsenumber\pgfmathresult + \let\pgfplots@current@point@meta=\pgfmathresult + % pgfplots changes \pgfqpointxyz to + % \pgfplotspointdescriptionxy inside of legends, so use the + % '@orig' point command: + \pgfplotstreampoint{\pgfqpointxyz@orig{##1}{##2}{##3}}% + }% + % for the case 'shader=interp': + \def\pgfplotspointbbupperright{\pgfqpointxyz@orig{2}{2}{0.9}} + \def\pgfplotspointbblowerleft {\pgfqpointxyz@orig{0}{0}{0.1}} + + \simplecoordinate(0,2,0.7) + \simplecoordinate(1,2,0.5) + \simplecoordinate(2,2,0.43) + + \simplecoordinate(0,1,0.68) + \simplecoordinate(1,1,0.4) + \simplecoordinate(2,1,0.25) + + \simplecoordinate(0,0,0.6) + \simplecoordinate(1,0,0.35) + \simplecoordinate(2,0,0.21) + + \pgfplotstreamend + \pgfusepath{stroke} + \endscope +}% + +\def\pgfplotsplothandlermesh@finish{% + \ifnum\pgfplotsplothandlermesh@shader=2 + % shader=interp: + \ifx\pgf@plotstreampoint\pgfplotsplothandlermesh@shader@interp@incremental@transpose% + % This is the case for 'mesh/ordering=colwise'. We need to finish the transpose procedure: + \pgfplotsplothandlermesh@shader@interp@transpose@finish + \fi + \pgfplotslibrarysurfstreamend + \pgfplotslibrarysurfdrawinpicture + \else + \if\pgfplotsplothandlermesh@zbuffer@choice4% + % z buffer=sort: + % process the z buffer: + \pgfkeyslet{/pgfplots/array/iflessthan/.@cmd}\pgfplotsplothandlermesh@zbuffer@sort@iflessthen + \pgfkeysdef{/pgfplots/array/unscope pre}{% + \pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{% + \expandafter\pgfplotsplothandlermesh@draw@zbufferelement\curelem% + }% + }% + \pgfkeysdef{/pgfplots/array/unscope post}{}% + \pgfplotsarraysort\pgfplots@zbuffer@local + \fi + \fi +% \endscope +}% + +% the pgf@plotstreampoint routine for the first scan line: +\def\pgfplotsplothandlermesh@fillscanline#1{% + \pgf@process{#1}% + \edef\pgfplotsplothandlermesh@i@j{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}}% + \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@i@j\to{lastscanline}% + \advance\c@pgfplots@scanlineindex by1 + \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax + % second line! + \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@draw%% + \c@pgfplots@scanlineindex=0 + \fi +}% + +% This is the pgf@plotstreampoint for all scan lines starting with the +% second. +% +% We perform +% for i = 1 to rows (note the 1! 0 would be the first row) +% for j = 0 to cols +% get (i-1, j) from front of deque // remember: i: rows, j : cols. We iterate rowwise. +% push (i,j) to back of deque +% if j > 0 +% draw +% (i-1,j-1) [from last iteration] -- (i-1,j) [from deque] +% -- ( i,j-1) [from last iteration] -- ( i,j) [from #1] +% endif +% let (i-1,j-1) := (i-1,j) // for next iteration +% let ( i,j-1) := ( i,j) // for next iteration +% end +% end +% +% This is a SWEEP through the data matrix. +\def\pgfplotsplothandlermesh@draw#1{% + % NOTATION: + % 'im == (i-1)' + % 'jm == (j-1)' + \pgf@process{#1}% + \edef\pgfplotsplothandlermesh@i@j{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}}% FIXME relies on pgfplots macros +%\message{##\the\c@pgfplots@scanlineindex: prepare rectangle with corner \meaning\pgfplotsplothandlermesh@i@j.}% + \pgfplotsdequepopfront{lastscanline}\to\pgfplotsplothandlermesh@im@j + \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@i@j\to{lastscanline}% + \ifnum\c@pgfplots@scanlineindex>0 + \pgfplotsplothandlermesh@process@element + \fi + \let\pgfplotsplothandlermesh@im@jm=\pgfplotsplothandlermesh@im@j + \let\pgfplotsplothandlermesh@i@jm=\pgfplotsplothandlermesh@i@j + \advance\c@pgfplots@scanlineindex by1 + \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax + \c@pgfplots@scanlineindex=0 + \fi +}% +\def\pgfplotsplothandlermesh@shader@interp#1{% + \pgfplots@perpointmeta@trafo@APPLY + \pgfplotslibrarysurfstreamcoord{#1}{\pgfplotspointmetatransformed}% +}% +\def\pgfplotsplothandlermesh@shader@interp@incremental@transpose#1{% + \pgfplots@perpointmeta@trafo@APPLY + \pgf@process{#1}% + \edef\pgfplotsplothandlermesh@i{\noexpand\pgfplotsplothandlermesh@shader@interp@next{\the\pgf@x}{\the\pgf@y}{\pgfplotspointmetatransformed}}% + % + % Store the postprocessed point into the appropriate row vector: + \def\pgfplots@loc@TMPa{\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplotsplothandlermesh@i}\to} + \expandafter\pgfplots@loc@TMPa\csname pgfp@transprow@\the\c@pgfplots@scanlineindex\endcsname% + % + \advance\c@pgfplots@scanlineindex by1 + \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax + \c@pgfplots@scanlineindex=0 + \fi +}% +\def\pgfplotsplothandlermesh@shader@interp@transpose@finish{% + % Now, "execute" each row vector: + \def\pgfplotsplothandlermesh@shader@interp@next##1##2##3{% + \pgfplotslibrarysurfstreamcoord{\pgf@x=##1 \pgf@y=##2 }{##3}% + }% + \c@pgfplots@scanlineindex=0 + \pgfutil@loop + \ifnum\c@pgfplots@scanlineindex<\pgfplotsplothandlermesh@rows\relax + \expandafter\pgfplotsapplistXlet\expandafter\pgfplots@loc@TMPa\expandafter=\csname pgfp@transprow@\the\c@pgfplots@scanlineindex\endcsname% + \expandafter\pgfplotsapplistXnewempty\csname pgfp@transprow@\the\c@pgfplots@scanlineindex\endcsname% clear + % execute the row: + \pgfplots@loc@TMPa + \advance\c@pgfplots@scanlineindex by1 + \pgfutil@repeat +}% + +\def\pgfplotsplothandlermesh@draw@zbufferelement#1#2{% + \pgfplotsplothandlermesh@draw@element#2\relax +}% +% a possible value for \pgfplotsplothandlermesh@draw@element +\def\pgfplotsplothandlermesh@draw@element@line#1#2{% + \pgfpathmoveto{\expandafter\pgfplotsplothandlermesh@unpack#1}% + \pgfpathlineto{\expandafter\pgfplotsplothandlermesh@unpack#2}% + \pgfplotsplothandlermesh@preparedrawforcurrent + \pgfplotsplothandlermesh@usepath +}% +% a possible value for \pgfplotsplothandlermesh@draw@element +\def\pgfplotsplothandlermesh@draw@element@rectangle#1#2#3#4{% + \pgfpathmoveto{\expandafter\pgfplotsplothandlermesh@unpack#1}% + \pgfpathlineto{\expandafter\pgfplotsplothandlermesh@unpack#2}% + \pgfpathlineto{\expandafter\pgfplotsplothandlermesh@unpack#3}% + \pgfpathlineto{\expandafter\pgfplotsplothandlermesh@unpack#4}% + \pgfplotsplothandlermesh@preparedrawforcurrent + \pgfpathclose + \pgfplotsplothandlermesh@usepath +}% + +\def\pgfplotsplothandlermesh@zbuffer@sort@iflessthen#1#2#3#4\pgfeov{% + \edef\pgfplots@loc@TMPa{#1}% + \expandafter\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@\pgfplots@loc@TMPa\relax + \let\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@a=\pgfmathresult + \edef\pgfplots@loc@TMPb{#2}% + \expandafter\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@\pgfplots@loc@TMPb\relax + \let\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@b=\pgfmathresult + \ifdim\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@b pt<\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@a pt% + #3\relax + \else + #4\relax + \fi +}% +\def\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@#1#2{% + \def\pgfmathresult{#1}% +}% + +% #1: projected x coord +% #2: projected y coord +% #3: per point meta (if any) +\def\pgfplotsplothandlermesh@unpack@corner#1#2#3{% + \pgf@x=#1\relax + \pgf@y=#2\relax +}% +\def\pgfplotsplothandlermesh@unpack@mean@accum#1#2#3{% + \pgf@x=#1\relax + \pgf@y=#2\relax + \def\pgfplots@current@point@meta{#3}% + \pgfplots@perpointmeta@trafo@APPLY + \global\advance\pgfplots@tmpa by\pgfplotspointmetatransformed pt +}% +% same as above, just for one dim plots (rows == 1 || cols==1) +\def\pgfplotsplothandlermesh@ONEDIM@draw#1{% + \pgf@process{#1}% + \edef\pgfplotsplothandlermesh@i{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}}% + \ifnum\c@pgfplots@scanlineindex>0 + \pgfplotsplothandlermesh@process@element + \fi + \let\pgfplotsplothandlermesh@im=\pgfplotsplothandlermesh@i + \advance\c@pgfplots@scanlineindex by1 +}% + +% #1: a normalized coordinate stream. +% +% Output: a normalized coordinate stream in \pgfplotsglobalretval. +\def\pgfplots@apply@zbuffer#1{% + \ifcase\pgfplotsplothandlermesh@zbuffer@choice\relax + % none. + \gdef\pgfplotsglobalretval{#1}% + \or + % reverse x seq: only for 'mesh' + \if\pgfplots@meshmode n% + \pgfplots@error{Sorry, `/pgfplots/z buffer=reverse x seq' can only be used for mesh/surf plots.}% + \gdef\pgfplotsglobalretval{#1}% + \else + \pgfplotsautocompletemeshkeys + \if\pgfplots@plot@mesh@ordering0% + % ordering = rowwise -> scanline is cols! + \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsscanlinelength + \pgfplots@apply@zbuffer@reversescanline{#1}% + \else + % ordering = colwise: scanline is rows! + \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsscanlinelength + \pgfplots@apply@zbuffer@reversetransposed{#1}% + \fi + \fi + \or + % reverse y seq: only for 'mesh' + \if\pgfplots@meshmode n% + \pgfplots@error{Sorry, `/pgfplots/z buffer=reverse y seq' can only be used for mesh/surf plots.}% + \gdef\pgfplotsglobalretval{#1}% + \else + \pgfplotsautocompletemeshkeys + \if\pgfplots@plot@mesh@ordering0% + % ordering = rowwise -> scanline is cols! + \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsscanlinelength + \pgfplots@apply@zbuffer@reversetransposed{#1}% + \else + % ordering = colwise: scanline is rows! + \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsscanlinelength + \pgfplots@apply@zbuffer@reversescanline{#1}% + \fi + \fi + \or + % reverse xy seq: + \begingroup + \def\pgfplots@coord@stream@start{% + \pgfplotsprependlistXnewempty{reversed}% + }% + \def\pgfplots@coord@stream@coord{% + \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z,\pgfplots@current@point@meta;}% + \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@loc@TMPa}\to{reversed}% + }% + \def\pgfplots@coord@stream@end{% + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversed}% + \pgfplotsprependlistXnewempty{reversed}% clear it + \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa + }% + \pgfplots@coord@stream@foreach@NORMALIZED{#1}% + \endgroup + \or + % sort. + \if\pgfplots@meshmode n% + \begingroup + \def\pgfplots@coord@stream@start{% + \pgfplotsarraynewempty\pgfplots@zbuffer@local + \pgfplotsarrayresize\pgfplots@zbuffer@local{\numcoords}% + \c@pgfplots@scanlineindex=0 + \def\pgfplots@zbuffer@local@SETCUR####1{% + \expandafter\pgfplotsarrayset\c@pgfplots@scanlineindex\of\pgfplots@zbuffer@local\to{####1}% + }% + }% + \def\pgfplots@coord@stream@coord{% + \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z,\pgfplots@current@point@meta;}% + \expandafter\pgfplots@zbuffer@local@SETCUR\expandafter{\pgfplots@loc@TMPa}% + \advance\c@pgfplots@scanlineindex by1 + }% + \def\pgfplots@coord@stream@end{% + \ifnum\c@pgfplots@scanlineindex=\numcoords + \else + \pgfplotsarrayresize\pgfplots@zbuffer@local{\c@pgfplots@scanlineindex}% + \fi + \pgfkeyslet{/pgfplots/array/iflessthan/.@cmd}\pgfplots@apply@zbuffer@SORT@iflessthan + \pgfkeysdef{/pgfplots/array/unscope pre}{% + \pgfplotsapplistXnewempty{\pgfp@sortedlist}% + \pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{% + \expandafter\pgfplotsapplistXpushback\curelem\to{\pgfp@sortedlist}% + }% + \pgfplotsapplistXlet\pgfplots@loc@TMPa={\pgfp@sortedlist}% + \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa + }% + \pgfkeysdef{/pgfplots/array/unscope post}{}% + \pgfplotsarraysort\pgfplots@zbuffer@local + }% + \pgfplots@coord@stream@foreach@NORMALIZED{#1}% + \endgroup + \else + % meshmode handles sort separately! + \gdef\pgfplotsglobalretval{#1}% + \fi + \or + % z buffer=auto + % + % I can decide for each axis if coordinate reversal is + % necessary. + % Idea: check if axis side planes are on foreground or not (a + % very simple task)! I + % only need to know whether [xy] coordinates are sorted + % ascending or descending. This information is already ready. + % \begingroup - \pgftransformshift{\pgfplots@plot@handler@graphics@bb@first}% - \node[/pgfplots/plot graphics/node,rectangle] {% - \expandafter\includegraphics\expandafter[\pgfplots@loc@TMPc,width=\pgfplots@loc@TMPa,height=\pgfplots@loc@TMPb]{\pgfplots@loc@TMPd}% - };% + \if+\pgfkeysvalueof{/pgfplots/x coord sorting}% + \def\pgfplots@minmaxvalue@x{0}% + \else + \def\pgfplots@minmaxvalue@x{0}% + \fi + \if+\pgfkeysvalueof{/pgfplots/y coord sorting}% + \def\pgfplots@minmaxvalue@y{0}% + \else + \def\pgfplots@minmaxvalue@y{1}% + \fi + \pgfplotsifaxissurfaceisforeground{\pgfplots@minmaxvalue@x vv}{% + \def\pgfplots@reverse@x{1}% + }{% + \def\pgfplots@reverse@x{0}% + }% + \pgfplotsifaxissurfaceisforeground{v\pgfplots@minmaxvalue@y v}{% + \def\pgfplots@reverse@y{1}% + }{% + \def\pgfplots@reverse@y{0}% + }% + \if1\pgfplots@reverse@x + \if1\pgfplots@reverse@y + \pgfkeys{/pgfplots/z buffer=reverse xy seq}% + \else + \pgfkeys{/pgfplots/z buffer=reverse x seq}% + \fi + \else + \if1\pgfplots@reverse@y + \pgfkeys{/pgfplots/z buffer=reverse y seq}% + \else + \pgfkeys{/pgfplots/z buffer=none}% + \fi + \fi +%\message{z buffer=auto mode chose z buffer= \ifcase\pgfplotsplothandlermesh@zbuffer@choice NONE \or reverse x seq \or reverse y seq \or reverse xy seq \or sort\or default \fi. mesh ordering = \ifcase\pgfplots@plot@mesh@ordering x varies/rowwise\or y varies/colwise\fi}% + % 'z buffer' is no longer 'auto' now: + \pgfplots@apply@zbuffer{#1}% \endgroup + \or + % z buffer=default. + \if\pgfplots@meshmode n% + % mesh mode deactivated! + \gdef\pgfplotsglobalretval{#1}% + \else + % mesh=true + \begingroup + \pgfkeysalso{/pgfplots/z buffer=auto}% + \pgfplots@apply@zbuffer{#1}% + \endgroup + \fi \fi }% +% Defines \pgfplotsglobalretval (globally) to be a partial reversion of the +% (normalized) 2d coordinate sequence '#1'. +% +% In other words, the normalized coordinate sequence '#1' is visited +% linearly and while we go, each scanline is reversed. The result is +% collected into \pgfplotsglobalretval. +% +% This implements the 'z buffer=reverse x seq' feature for +% ordering=y varies. +% +% PRECONDITION: +% \pgfplotsscanlinelength contains the scanline length +% POSTCONDITION: +% \pgfplotsglobalretval contains the partial reversion. +\def\pgfplots@apply@zbuffer@reversescanline#1{% + \begingroup + \def\pgfplots@coord@stream@start{% + \pgfplotsprependlistXnewempty{reversedscanline}% + \c@pgfplots@scanlineindex=0 + \pgfplotsapplistXnewempty{\resultlist}% + }% + \def\pgfplots@coord@stream@coord{% + \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z,\pgfplots@current@point@meta;}% + \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@loc@TMPa}\to{reversedscanline}% + \advance\c@pgfplots@scanlineindex by1 + \ifnum\c@pgfplots@scanlineindex=\pgfplotsscanlinelength\relax + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversedscanline}% + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPa}\to\resultlist + \pgfplotsprependlistXnewempty{reversedscanline}% + \c@pgfplots@scanlineindex=0 + \fi + }% + \def\pgfplots@coord@stream@end{% + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversedscanline}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplots@zbuffer@error + \fi + \pgfplotsapplistXlet\pgfplots@loc@TMPa={\resultlist}% + \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa + }% + \pgfplots@coord@stream@foreach@NORMALIZED{#1}% +%\message{I have performed partial reversion of '#1' and got '\pgfplotsglobalretval'!}% + \endgroup +}% + +% A very similar method of \pgfplots@apply@zbuffer@reversescanline, +% but this one keeps everything inside of each scanline in the +% original ordering, and reverses the ordering in which whole +% scanlines occur. +\def\pgfplots@apply@zbuffer@reversetransposed#1{% + \begingroup + \def\pgfplots@coord@stream@start{% + \pgfplotsapplistXnewempty{\scanline}% + \c@pgfplots@scanlineindex=0 + \pgfplotsprependlistXnewempty{resultlist}% + }% + \def\pgfplots@coord@stream@coord{% + \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z,\pgfplots@current@point@meta;}% + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPa}\to{\scanline}% + \advance\c@pgfplots@scanlineindex by1 + \ifnum\c@pgfplots@scanlineindex=\pgfplotsscanlinelength\relax + \pgfplotsapplistXlet\pgfplots@loc@TMPa={\scanline}% + \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@loc@TMPa}\to{resultlist} + \pgfplotsapplistXnewempty{\scanline}% + \c@pgfplots@scanlineindex=0 + \fi + }% + \def\pgfplots@coord@stream@end{% + \pgfplotsapplistXlet\pgfplots@loc@TMPa={\scanline}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplots@zbuffer@error + \fi + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={resultlist}% + \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa + }% + \pgfplots@coord@stream@foreach@NORMALIZED{#1}% +%\message{I have performed partial reversion of '#1' and got '\pgfplotsglobalretval'!}% + \endgroup +}% +\def\pgfplots@zbuffer@error{% + \pgfplots@error{An internal error occured during z buffer reorderings: the rows/cols where not balanced! I have rows= \pgfkeysvalueof{/pgfplots/mesh/rows}, cols=\pgfkeysvalueof{/pgfplots/mesh/cols}. If this happens to be wrong, you might want to provide rows and cols manually.}% +} + +% A special '<' operation which returns true if the point coordinate +% '#1' is BEHIND #2 with respect to the current 3D view. +\def\pgfplots@apply@zbuffer@SORT@iflessthan#1#2#3#4\pgfeov{% + \edef\pgfplots@loc@TMPa{#1}% + \expandafter\pgfplots@apply@zbuffer@SORT@iflessthan@\pgfplots@loc@TMPa\relax + \let\pgfplots@apply@zbuffer@SORT@iflessthan@a=\pgfmathresult + \edef\pgfplots@loc@TMPb{#2}% + \expandafter\pgfplots@apply@zbuffer@SORT@iflessthan@\pgfplots@loc@TMPb\relax + \let\pgfplots@apply@zbuffer@SORT@iflessthan@b=\pgfmathresult + \pgfmathfloatlessthan@{\pgfplots@apply@zbuffer@SORT@iflessthan@b}{\pgfplots@apply@zbuffer@SORT@iflessthan@a}% + \ifpgfmathfloatcomparison + #3\relax + \else + #4\relax + \fi +}% + +% returns the view depth of the provided serialized coordinate into +% \pgfmathresult +% +% FIXME : relies on the internal repr in +% \pgfplots@coord@stream@foreach@NORMALIZED : +\def\pgfplots@apply@zbuffer@SORT@iflessthan@#1,#2,#3,#4;{% + \pgfplotsmathfloatviewdepthxyz{#1}{#2}{#3}% +}% + +% Defines \pgfmathresult to be the view depth of a three component +% vector. The third component will be used if and only if the boolean +% \ifpgfplots@curplot@threedim is true. +% The return value will be assigned in floating point. +% +% The arguments need to be numbers (will be parsed with +% \pgfmathfloatparsenumber). +% @see \pgfplotsmathviewdepthxyz +\def\pgfplotsmathfloatviewdepthxyz#1#2#3{% + \pgfmathfloatparsenumber{#1}\let\pgfplots@loc@TMPa=\pgfmathresult + \pgfmathfloatparsenumber{#2}\let\pgfplots@loc@TMPb=\pgfmathresult + \pgfmathfloatparsenumber{#3}\let\pgfplots@loc@TMPc=\pgfmathresult + \edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}}% + \expandafter\pgfplotsmathfloatviewdepthxyz@\pgfplots@loc@TMPa +}% + +\def\pgfplotsmathfloatviewdepthxyz@#1#2#3{% + \pgfplots@error{Sorry, you can't use \string\pgfplotsmathfloatviewdepthxyz\space in this context.}% +}% +\def\pgfplotsmathfloatviewdepthxyz@infigure#1#2#3{% + \pgfmathfloatmultiplyfixed@{#1}{\pgfplots@view@dir@threedim@x}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfmathfloatmultiplyfixed@{#2}{\pgfplots@view@dir@threedim@y}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfmathfloatadd@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \ifpgfplots@curplot@threedim + \pgfmathfloatmultiplyfixed@{#3}{\pgfplots@view@dir@threedim@z}% + \let\pgfplots@loc@TMPc=\pgfmathresult + \pgfmathfloatadd@{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \fi + \let\pgfmathresult=\pgfplots@loc@TMPb +}% + +% Similar to \pgfplotsmathfloatviewdepthxyz, but this always relies on +% fixed point arithmetics. +\def\pgfplotsmathviewdepthxyz#1#2#3{\pgfplotsmathviewdepthxyz@{#1}{#2}{#3}} +\def\pgfplotsmathviewdepthxyz@#1#2#3{% + \pgfplots@error{Sorry, you can't use \string\pgfplotsmathviewdepthxyz\space in this context.}% +} +\def\pgfplotsmathviewdepthxyz@infigure#1#2#3{% + \pgfmath@basic@multiply@{#1}{\pgfplots@view@dir@threedim@x}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfmath@basic@multiply@{#2}{\pgfplots@view@dir@threedim@y}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfmath@basic@add@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \ifpgfplots@curplot@threedim + \pgfmath@basic@multiply@{#3}{\pgfplots@view@dir@threedim@z}% + \let\pgfplots@loc@TMPc=\pgfmathresult + \pgfmath@basic@add@{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \fi + \let\pgfmathresult=\pgfplots@loc@TMPb +}% + + +% Evaluate shell commands. +% +% #1 = filename prefix for .sh and .out files (optional, +% default is \jobname) +% #2 = shell command text +% +% Description: +% +% This command will write the command text to a file called +% #1.sh. Then it calls sh (using the \write18 mechanism) to +% execute the file and redirect the output to a file called +% #1.out. +% In contrast to pgfplotgnuplot the result has to be read +% from #1.out later using \pgfplotxyfile. (This allows +% using the function from within the plot table functions +% as well.) +% +% Example: +% +% \pgfplothandlerlineto +% \pgfshell[\jobname]{cat table.dat} +% \pgfplotxyfile{\jobname.out} + +\pgfutil@ifundefined{w@pgf@writea}{% + \csname newwrite\endcsname\pgf@shellwrite +}{% + \let\pgf@shellwrite=\w@pgf@writea +} +\newif\ifpgf@resample@shell + +\def\pgfshell{\pgfutil@ifnextchar[{\pgf@shell}{\pgf@shell[\jobname]}}%} +\def\pgf@shell[#1]#2{% + \pgf@resample@shelltrue% + % Check, whether it is up-to-date + \openin\pgfutil@inputcheck=#1.sh + \ifeof\pgfutil@inputcheck% + \else% + \read\pgfutil@inputcheck to\pgf@shell@line% + \edef\pgf@plot@code{#2\space}% + \ifx\pgf@plot@code\pgf@shell@line% + \openin\pgfutil@inputcheck=#1.out + \ifeof\pgfutil@inputcheck% + \else% + \pgf@resample@shellfalse + \fi% + \fi% + \fi + \ifpgf@resample@shell% + \immediate\openout\pgf@shellwrite=#1.sh + \immediate\write\pgf@shellwrite{#2}% + \immediate\closeout\pgf@shellwrite% + \immediate\write18{sh #1.sh > #1.out} + \fi% +} +% Used inside of /pgfplots/scatter/classes : +\def\pgfplots@scatter@classes@pre@marker@code{% + \pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% + \let\pgfplots@loc@TMPa=\pgfplotspointmeta + % + % ups - no styles available? Maybe something went + % wrong with the 'scatter src' key. Check whether it + % was accidentally a numerical style: + \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname + \else + % ok, be fault tolerant and round to an integer: + \pgfmathfloattofixed{\pgfplotspointmeta}% + \begingroup + \pgfkeys{/pgf/number format/precision=0}% + \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplotspointmeta=\pgfmathresult + \fi + % now, check again: + \pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% + % still not possible? Then, try truncating the + % number to an integer. + \expandafter\pgfutil@in@\expandafter.\expandafter{\pgfplotspointmeta}% + \ifpgfutil@in@ + \def\pgfplots@loc@TMPb##1.##2\relax{\def\pgfplotspointmeta{##1}}% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\relax + \fi + % now, check again: + \pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% + \pgfutil@ifundefined{pgfp@scatter@WARNING@\pgfplotspointmeta}{% + \pgfplots@warning{scatter/classes: can't find class for '\pgfplotspointmeta'!? Please make sure you have specified 'scatter src=explicit symbolic'. Ignoring class '\pgfplotspointmeta' (this message will not come again).}% + \expandafter\gdef\csname pgfp@scatter@WARNING@\pgfplotspointmeta\endcsname{ALREADY CHECKED}% + }{}% + \def\pgfplots@loc@TMPa{}% + }{% + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname + }% + }{% + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname + }% + }{% + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname + }% + \expandafter\scope\expandafter[\pgfplots@loc@TMPa]% +}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex index b5aaadc42dc..026a1c83f78 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex @@ -36,6 +36,62 @@ \pgfplots@error{It seems your version of PGF/Tikz is older than 2.00. Unfortunately, pgfplots requires at least version 2.00 ... you may need to update your TeX-Distribution or install PGF manually, sorry}% }{\relax} +% Throws exception `#1' with arguments `#2'. +% +% #1 : the exception name +% #2: all what comes after the exception name is considered to be argument +% (or arguments) for the exception '#1'. +% the \pgfeov is IMPORTANT as it delimits the argument. +% +% Note that all standard pgfplots exceptions provide a feature to +% exchange the error message text: define \pgfplotsexceptionmsg +% set a replacement. +\def\pgfplotsthrow#1#2\pgfeov{% + \pgfkeysvalueof{/pgfplots/exception/#1/.@cmd}#2\pgfeov +}% +\pgfkeys{ + % #1: the argument which should have been assigned. + % #2: an error message. + /pgfplots/exception/invalid argument/.code 2 args={% + \ifx\pgfplotsexceptionmsg\relax + \pgfplots@error{#2}% + \else + \pgfplots@error{\pgfplotsexceptionmsg}% + \fi + \let#1=\pgfutil@empty + },% + % #1: the argument which should have been assigned. + % #2: an error message. + /pgfplots/exception/no such element/.code 2 args={% + \ifx\pgfplotsexceptionmsg\relax + \pgfplots@error{#2}% + \else + \pgfplots@error{\pgfplotsexceptionmsg}% + \fi + \let#1=\pgfutil@empty + },% + % #1: an error message + /pgfplots/exception/unsupported operation/.code={% + \ifx\pgfplotsexceptionmsg\relax + \pgfplots@error{#1}% + \else + \pgfplots@error{\pgfplotsexceptionmsg}% + \fi + },% + % #1: the argument which should have been assigned. + % #2: the file name + % #3: the error message + /pgfplots/exception/no such table file/.code args={#1#2#3}{% + \ifx\pgfplotsexceptionmsg\relax + \pgfplots@error{#3}% + \else + \pgfplots@error{\pgfplotsexceptionmsg}% + \fi + \let#1=\relax + }, +} +\let\pgfplotsexceptionmsg=\relax + \def\pgfplots@EOI{\pgfplots@EOI}% \newif\ifpgfplots@loc@tmp @@ -43,6 +99,13 @@ \newtoks\t@pgfplots@tokb \newtoks\t@pgfplots@tokc \newdimen\pgfplots@tmpa +\newcount\c@pgfplots@coordindex +\newcount\c@pgfplots@scanlineindex +\pgfutil@ifundefined{r@pgf@reada}{% + \csname newread\endcsname\r@pgfplots@reada +}{% + \let\r@pgfplots@reada=\r@pgf@reada +} % use these macros for GLOBAL temporary assignments. % you can NEVER rely on their values unless you know exactly what you are doing. @@ -58,20 +121,14 @@ % Invokes code #2 if file '#1' exists and #3 if not. -\def\pgfplots@iffileexists#1#2#3{% - \begingroup - \openin1=#1 - \ifeof1 - \xdef\pgfplots@glob@TMPa{0}% - \else - \closein1 - \xdef\pgfplots@glob@TMPa{1}% - \fi - \endgroup - \if1\pgfplots@glob@TMPa - #2% +\long\def\pgfplots@iffileexists#1#2#3{% + \openin\r@pgfplots@reada=#1 + \ifeof\r@pgfplots@reada + #3\relax \else - #3% + \closein\r@pgfplots@reada + #2\relax \fi } +\let\pgfplotsiffileexists=\pgfplots@iffileexists \endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.stackedplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex index 14b81c1a7c4..b0e18b0bf06 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.stackedplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex @@ -82,6 +82,7 @@ % Needs to be called before the first call to % \pgfplots@stacked@beginplot. \def\pgfplots@stacked@initialise{% + \gdef\pgfplots@stacked@coordcount{-1}% \pgfplots@stacked@isfirstplottrue \pgfplots@stacked@isinitialisedtrue }% @@ -101,7 +102,7 @@ % \pgfplots@stacked@zerolevelpoint@[xy]. % % ATTENTION: call \pgfplots@stacked@initialise before the first call -% to beginplot! +% of beginplot! \def\pgfplots@stacked@beginplot{% %\message{pgfplots@stacked@beginplot: PLOT STARTED.}% \ifpgfplots@stacked@isinitialised @@ -115,6 +116,7 @@ \global\pgfplotslistnewempty\pgfplots@stacked@zerolevellist \def\pgfplots@stacked@zerolevelpoint@x{0}% \def\pgfplots@stacked@zerolevelpoint@y{0}% + \def\pgfplots@stacked@zerolevelpoint@z{0}% % only work with float if its really necessary - for % example if the scaling trafo which maps to pgfmath is % not yet initialised. @@ -128,35 +130,41 @@ \pgfmathfloatcreate{0}{0.0}{0}% \let\pgfplots@stacked@zerolevelpoint@y=\pgfmathresult \fi - \fi - \def\pgfplots@stacked@getnextzerolevelpoint{}% will remain constant anyway. - \ifpgfplots@curplot@threedim - \def\pgfplots@stacked@zerolevelpoint@z{0}% - \ifpgfplots@datascaletrafo@initialised - \else + \ifpgfplots@threedim \ifpgfplots@zislinear \pgfmathfloatcreate{0}{0.0}{0}% \let\pgfplots@stacked@zerolevelpoint@z=\pgfmathresult \fi \fi \fi + \def\pgfplots@stacked@getnextzerolevelpoint{}% will remain constant anyway. \else {\globaldefs=1 \pgfplotslistcopy\pgfplots@stacked@nextzerolevellist\to\pgfplots@stacked@zerolevellist }% - \ifpgfplots@curplot@threedim + \ifpgfplots@threedim \def\pgfplots@stacked@getnextzerolevelpoint{% - {\globaldefs=1 - \pgfplotslistpopfront\pgfplots@stacked@zerolevellist\to\pgfmathresult - }% - \expandafter\pgfplots@stacked@parsezerolevelpoint@threedim\pgfmathresult\relax + \pgfplotslistcheckempty\pgfplots@stacked@zerolevellist + \ifpgfplotslistempty + \pgfplots@stacked@wrong@count@error + \else + {\globaldefs=1 + \pgfplotslistpopfront\pgfplots@stacked@zerolevellist\to\pgfmathresult + }% + \expandafter\pgfplots@stacked@parsezerolevelpoint@threedim\pgfmathresult\relax + \fi }% \else \def\pgfplots@stacked@getnextzerolevelpoint{% - {\globaldefs=1 - \pgfplotslistpopfront\pgfplots@stacked@zerolevellist\to\pgfmathresult - }% - \expandafter\pgfplots@stacked@parsezerolevelpoint\pgfmathresult\relax + \pgfplotslistcheckempty\pgfplots@stacked@zerolevellist + \ifpgfplotslistempty + \pgfplots@stacked@wrong@count@error + \else + {\globaldefs=1 + \pgfplotslistpopfront\pgfplots@stacked@zerolevellist\to\pgfmathresult + }% + \expandafter\pgfplots@stacked@parsezerolevelpoint\pgfmathresult\relax + \fi }% \fi \fi @@ -173,10 +181,19 @@ \def\pgfplots@stacked@zerolevelpoint@z{#3}% } +\def\pgfplots@stacked@wrong@count@error{% + \pgfplots@error{Sorry, pgfplots expects stacked plots to have exactly the same number of coordinates. Unfortunately, I encountered at plot with DIFFERENT NUMBERS OF COORDINATES. Please verify that 1. no point has been dropped by coordinate filters (for example log(0) or so) and 2. all plots have the same number of coordinates.}% +}% + \def\pgfplots@stacked@endplot{% \ifpgfplots@stacked@isfirstplot \let\pgfplots@stacked@closedcycle@impl=\pgfplots@path@closed@cycle@std \else + \pgfplotslistcheckempty\pgfplots@stacked@zerolevellist + \ifpgfplotslistempty + \else + \pgfplots@stacked@wrong@count@error + \fi \t@pgfplots@tokc=\expandafter{\pgfplots@stacked@closedcycle@impl}% \edef\pgfplots@stacked@closedcycle@impl{% [mark=none,/utils/exec=\noexpand\pgfplots@try@mirror@plot@handler] @@ -243,9 +260,9 @@ \def\pgfplots@stacked@preparepoint@inmacro{% \pgfplots@stacked@getnextzerolevelpoint \ifpgfplots@stacked@plus - \let\pgfplots@stacked@op=\pgfmathadd@ + \let\pgfplots@stacked@op=\pgfmath@basic@add@ \else - \let\pgfplots@stacked@op=\pgfmathsubtract@ + \let\pgfplots@stacked@op=\pgfmath@basic@subtract@ \fi \pgfplots@if{pgfplots@\pgfplots@stacked@dir islinear}{% \ifpgfplots@datascaletrafo@initialised @@ -263,8 +280,12 @@ {\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname}}% \pgfplots@loc@TMPa \expandafter\let\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname=\pgfmathresult - \ifpgfplots@curplot@threedim - \pgfplots@stacked@rememberzerolevelpoint@for@next@plot{(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)}% + \ifpgfplots@threedim + \ifpgfplots@curplot@threedim + \pgfplots@stacked@rememberzerolevelpoint@for@next@plot{(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)}% + \else + \pgfplots@stacked@rememberzerolevelpoint@for@next@plot{(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@logical@ZERO@z)}% + \fi \else \pgfplots@stacked@rememberzerolevelpoint@for@next@plot{(\pgfplots@current@point@x,\pgfplots@current@point@y)}% \fi @@ -457,7 +478,7 @@ % \pgfplots@stacked@finalize@stored@coords@START % and draws the plot (and markers). \def\pgfplots@stacked@draw@reversed@plot{% - \pgfplots@stored@current@cmd[current plot style] + \pgfplots@stored@current@cmd% [current plot style] <---- keys are already set \pgfextra \tikzset{every plot/.try}% \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler @@ -476,7 +497,7 @@ \else \ifpgfplots@clip@marker@paths \scope% make sure that 'fill opacity' and 'dotted' styles remain local! - \pgfplots@stored@current@cmd[current plot style] + \pgfplots@stored@current@cmd%[current plot style] <---- keys are already set \pgfextra \pgfplots@install@plotmark@handler \pgfplots@recorded@marker@stream diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex index d953f779f01..416d888a511 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex @@ -211,12 +211,15 @@ } % x-axis tick labels for #1th tick -% #1: the axis (x or y) +% #1: the axis (x,y or z) % #2: the value % #3,#4: coordinates for \pgfplotspointonorientedsurfaceab % #5: ticknumber -\def\pgfplots@show@ticklabel#1#2(#3,#4)#5{{% +\def\pgfplots@show@ticklabel#1#2(#3,#4)#5{% + \begingroup% \csname ifpgfplots@#1ticklabel@interval\endcsname + % Special case for the INTERVAL feature: + % we have to do additional work here. \pgfmathparse{#3}% \edef\pgfplots@show@ticklabel@coord@x@new{\pgfmathresult}% \pgfmathparse{#4}% @@ -231,15 +234,13 @@ % 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}% + \pgfmathparse{0.5*(\pgfplots@show@ticklabel@coord@x + \pgfplots@show@ticklabel@coord@x@new)}% + \let\pgfplots@show@ticklabel@coord@x=\pgfmathresult% + \pgfmathparse{0.5*(\pgfplots@show@ticklabel@coord@y + \pgfplots@show@ticklabel@coord@y@new)}% + \let\pgfplots@show@ticklabel@coord@y=\pgfmathresult% \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)}% - \begingroup - \pgftransformshift{\pgfplotspointonorientedsurfaceab{\pgfplots@show@ticklabel@coord@x}{\pgfplots@show@ticklabel@coord@y}}% - \node at (0pt,0pt) {\csname pgfplots@#1ticklabel\endcsname};% - \endgroup + \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceab{\pgfplots@show@ticklabel@coord@x}{\pgfplots@show@ticklabel@coord@y}}% \fi \xdef\pgfplots@show@ticklabel@LASTTICK{% \noexpand\def\noexpand\pgfplots@show@ticklabel@tick{\nexttick}% @@ -250,76 +251,216 @@ \else \let\ticknum=#5\relax% \pgfplots@show@ticklabel@{#1}{#2}% + \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceab{#3}{#4}}% + \fi + \endgroup +} + +% #1: the axis (x,y or z) +% #2: the location where to place it. +\def\pgfplots@show@ticklabel@@#1#2{% + % Typeset the label! + \pgfinterruptboundingbox + % What makes this complicated is the 'ticklabel cs' feature. + % What we need is to compute the MAXIMUM LENGTH over each tick + % label IN DIRECTION OF THE OUTER NORMAL. + % + % This needs to + % 1. enable bounding box computation even in case of + % 'overlay', + % 2. projection of the bounding box in direction of the outer + % normal, + % 3. update of the bounding box if 'overlay' is not active. \begingroup - \pgftransformshift{\pgfplotspointonorientedsurfaceab{#3}{#4}}% -% -%-------------------------------------------------- -% \iffalse -% %\iftrue -% % The following code is experimental and contains automatically -% % aligned tick labels (especially for 3D axes). It's not quite -% % finished. -% % -% %\tracingmacros=2\tracingcommands=2 -% \message{HIER}% -% \if x\pgfplotspointonorientedsurfaceB -% \if y\pgfplotspointonorientedsurfaceN -% \def\pgfplotspointonorientedsurfbN##1##2{\pgfplotsqpointxyz{##1}{##2}{0}}% -% \else% N == z: -% \def\pgfplotspointonorientedsurfbN##1##2{\pgfplotsqpointxyz{##1}{0}{##2}}% -% \fi -% \else -% \if y\pgfplotspointonorientedsurfaceB -% \if x\pgfplotspointonorientedsurfaceN -% \def\pgfplotspointonorientedsurfbN##1##2{\pgfplotsqpointxyz{##2}{##1}{0}}% -% \else% N == z: -% \def\pgfplotspointonorientedsurfbN##1##2{\pgfplotsqpointxyz{0}{##1}{##2}}% -% \fi -% \else -% % B == z -% \if y\pgfplotspointonorientedsurfaceN -% \def\pgfplotspointonorientedsurfbN##1##2{\pgfplotsqpointxyz{0}{##2}{##1}}% -% \else% N == x: -% \def\pgfplotspointonorientedsurfbN##1##2{\pgfplotsqpointxyz{##2}{0}{##1}}% -% \fi -% \fi -% \fi -% %\message{a == \pgfplotspointonorientedsurfaceA, b == \pgfplotspointonorientedsurfaceB, N == \pgfplotspointonorientedsurfaceN. zeug=\meaning\pgfplotspointonorientedsurfbN.}% -% \if0\pgfplots@ticklabelside -% % this means : the 'b' axis of the surface is on the lower axis -% % limit. Since we want tick labels OUTSIDE of the axis, we need -% % sign = -1. -% \def\pgfplots@loc@TMPa{-}% -% \else -% % in this case, we the OUTSIDE area requires a plus sign - the b -% % axis already points to the outside. -% \def\pgfplots@loc@TMPa{}% -% \fi -% \if0\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol -% % same as before: the N axis is on the lower axis limit. -% % So: sign -1 -% \def\pgfplots@loc@TMPb{-}% -% \else -% \def\pgfplots@loc@TMPb{}% -% \fi -% \pgfmathparse{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname * \pgfplots@loc@TMPa 0.2cm}% -% \let\pgfplots@loc@TMPa=\pgfmathresult -% \pgfmathparse{\csname pgfplots@\pgfplotspointonorientedsurfaceN @inverseveclength\endcsname * \pgfplots@loc@TMPb 0.2cm}% -% \let\pgfplots@loc@TMPb=\pgfmathresult -% %-------------------------------------------------- -% % \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}% -% % \pgfpathlineto{\pgfplotspointonorientedsurfbN{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}}% -% % \pgfusepath{stroke} -% %-------------------------------------------------- -% \pgftransformshift{\pgfplotspointonorientedsurfbN{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}}% -% \tikzset{every node/.append style={anchor=center}}% -% \fi -%-------------------------------------------------- -% - \node at (0pt,0pt) {\csname pgfplots@#1ticklabel\endcsname};% + % + % prepare step (1.): + \pgfkeysalso{% + /tikz/every node/.append code={% + \ifpgf@relevantforpicturesize + \gdef\pgfplots@show@ticklabel@@update@BB{1}% + \else + \gdef\pgfplots@show@ticklabel@@update@BB{0}% + \fi + \pgf@relevantforpicturesizetrue + }% + }% + % + % Compute and remember the position '#2': + \pgf@process{#2}% + \edef\pgfplots@ticklabel@at@x{\the\pgf@x}% + \edef\pgfplots@ticklabel@at@y{\the\pgf@y}% + % + % ok, generate the label! + \node at (\pgfplots@ticklabel@at@x,\pgfplots@ticklabel@at@y) {\csname pgfplots@#1ticklabel\endcsname};% + % + % compute the label's dimensions, step (2.): + \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath + {#1} + {\pgf@x=\pgfplots@ticklabel@at@x\space\pgf@y=\pgfplots@ticklabel@at@y\space}%% + % + % prepare step (3.): update of bounding box: + \if\pgfplots@show@ticklabel@@update@BB1% + \xdef\pgfplots@glob@TMPa{% + \pgf@xa=\the\pgf@picminx\space + \pgf@xb=\the\pgf@picminy\space + \pgf@ya=\the\pgf@picmaxx\space + \pgf@yb=\the\pgf@picmaxy\space + \noexpand\pgf@protocolsizes{\pgf@xa}{\pgf@xb}% + \noexpand\pgf@protocolsizes{\pgf@ya}{\pgf@yb}% + \noexpand\pgf@resetpathsizes + }% + \else + \global\let\pgfplots@glob@TMPa=\relax + \fi \endgroup + \endpgfinterruptboundingbox + \begingroup + \pgfplots@glob@TMPa + \endgroup +}% + +% TICK LABEL DIMENSION CONTROL +% +% The following framework is supposed to accumulate the value for +% \pgfplotsvalueoflargesttickdimen. +% +% It works like this: +% +% \pgfplots@ticklabel@maxtickdimen@reset{#1} +% \pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec{#1}{<normal vector>} +% ... +% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} +% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} +% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} +% ... +% \pgfplots@ticklabel@maxtickdimen@finish{#1} +% +% -> then, \pgfplotsvalueoflargesttickdimen expands to the largest +% distance from a tick's coordinate to its tick label bounding box in +% direction of the outer normal vector. +\def\pgfplots@ticklabel@maxtickdimen@reset#1{% + \expandafter\gdef\csname pgfplots@maxtickdimen@#1\endcsname{0pt}% + \expandafter\gdef\csname pgfplots@maxtickdimen@extrashift@#1\endcsname{0pt}% +}% + +% Adds the extra shift '#2' along the normal vector for axis '#1'. +\def\pgfplots@ticklabel@maxtickdimen@extrashift#1#2{% + \begingroup + \afterassignment\pgfplots@gobble@until@relax + \pgf@xa=#2pt\relax + \advance\pgf@xa by\csname pgfplots@maxtickdimen@extrashift@#1\endcsname\relax + \expandafter\xdef\csname pgfplots@maxtickdimen@extrashift@#1\endcsname{\the\pgf@xa}% + \endgroup +} + +% Finalizes the maxtickdimen computation. +% +% This applies any extra shifts (including '#1ticklabel shift'). +\def\pgfplots@ticklabel@maxtickdimen@finish#1{% + \pgfkeysgetvalue{/pgfplots/#1ticklabel shift}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \pgfplots@ticklabel@maxtickdimen@extrashift{#1}{\pgfkeysvalueof{/pgfplots/#1ticklabel shift}}% \fi -}} + \begingroup + \pgf@xa=\csname pgfplots@maxtickdimen@extrashift@#1\endcsname\relax + \advance\pgf@xa by \csname pgfplots@maxtickdimen@#1\endcsname\relax + \expandafter\xdef\csname pgfplots@maxtickdimen@#1\endcsname{\the\pgf@xa}% + \endgroup +}% +% +% #1: the axis (x,y or z) +% #2: the normal vector +\def\pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec#1#2{% + \pgf@process{#2}% + \edef\pgfplots@loc@vector@to@outside{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% + % Identify the corner point of the ticklabel bounding box which + % shall be used: + \ifdim\pgf@x>0sp + \ifdim\pgf@y>0sp + % NORTH EAST + \def\pgfplots@loc@ticklabel@bb@corner{\pgf@x=\pgf@picmaxx\pgf@y=\pgf@picmaxy}% + \else + % SOUTH EAST + \def\pgfplots@loc@ticklabel@bb@corner{\pgf@x=\pgf@picmaxx\pgf@y=\pgf@picminy}% + \fi + \else + \ifdim\pgf@y>0sp + % NORTH WEST + \def\pgfplots@loc@ticklabel@bb@corner{\pgf@x=\pgf@picminx\pgf@y=\pgf@picmaxy}% + \else + % SOUTH WEST + \def\pgfplots@loc@ticklabel@bb@corner{\pgf@x=\pgf@picminx\pgf@y=\pgf@picminy}% + \fi + \fi +}% + +% #1: the axis (x,y or z) +% #2: the point from where dimension shall be computed (the 'at' +% argument of the tick label) +\def\pgfplots@ticklabel@maxtickdimen@updateforcurrentpath#1#2{% + \pgfplotsscalarproductofvectors + {\pgfplots@loc@vector@to@outside}% + {\pgfpointdiff + {#2}% + {\pgfplots@loc@ticklabel@bb@corner}}% + \ifdim\pgf@x>\csname pgfplots@maxtickdimen@#1\endcsname\relax + \expandafter\xdef\csname pgfplots@maxtickdimen@#1\endcsname{\the\pgf@x}% + \fi +}% + +% Expands to the largest distance of a tick position to its tick label +% bounding box in direction of the outer unit normal vector. +% +% It does also include the value of the 'ticklabel shift' key. +% +% This function assumes that +% \pgfplots@ticklabel@maxtickdimen@reset{#1} +% \pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec{#1}{<normal vector>} +% ... +% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} +% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} +% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} +% ... +% \pgfplots@ticklabel@maxtickdimen@finish{#1} +% has been invoked completely. +% +% #1: either x,y or z. It denotes the axis for which the ticks are +% requested. +\def\pgfplotsvalueoflargesttickdimen#1{% + \csname pgfplots@maxtickdimen@#1\endcsname +}% + +% Just like \pgfplotsqpointoutsideofaxis, but this one here uses the +% axis on which tick labels will be drawn. +% +% #1: one of x, y or z. +% #2: the coordinate on the tick axis designated by '#1'. +% #3: a scale (a dimen) in which the point is moved in direction of +% the outward normal vector of the axis. +% +% @see \pgfplotsqpointoutsideofaxis +\def\pgfplotsqpointoutsideofticklabelaxis#1#2#3{% + \pgfplotsqpointoutsideofaxis{\csname pgfplots@#1ticklabelaxisspec\endcsname}{#2}{#3}% +}% +\def\pgfplotsqpointoutsideofticklabelaxisrel#1#2#3{% + \pgfplotsqpointoutsideofaxisrel{\csname pgfplots@#1ticklabelaxisspec\endcsname}{#2}{#3}% +}% +\def\pgfplotsqpointoutsideofticklabelaxistransformed#1#2#3{% + \pgfplotsqpointoutsideofaxistransformed{\csname pgfplots@#1ticklabelaxisspec\endcsname}{#2}{#3}% +}% + +% Expands to the three-character-identification for the axis +% containing tick labels for axis #1. +% +% #1: either x, y or z. +\def\pgfplotsticklabelaxisspec#1{\csname pgfplots@#1ticklabelaxisspec\endcsname}% + +% The unit outer normal vector for axis #1. +% #1: one of x, y or z. +\def\pgfplotspointouternormalvectorofticklabelaxis#1{% + \pgfplotspointouternormalvectorofaxis{\csname pgfplots@#1ticklabelaxisspec\endcsname}% +} % Defines \tick by applying any necessary math to the (possibly % transformed) tick value #2. @@ -397,32 +538,55 @@ % Check if a label does not cross the x-axis \def\pgfplots@ytick@check@tickshow{% \pgfplots@tickshowtrue - \ifnum\pgfplots@yaxislinesnum=2 % + \if\pgfplots@yaxislinesnum2% center \ifcase\pgfplots@xaxislinesnum\relax - \ifdim\pgfplots@tmpa=\pgfplots@ymin@reg\relax - \pgfplots@tickshowfalse - \fi - \ifdim\pgfplots@tmpa=\pgfplots@ymax@reg\relax - \pgfplots@tickshowfalse - \fi + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@ymin@reg} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@ymax@reg} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% \or - \ifdim\pgfplots@tmpa=\pgfplots@ymin@reg\relax - \pgfplots@tickshowfalse - \fi + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@ymin@reg} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{% + }% \or - \ifdim\pgfplots@tmpa=\pgfplots@logical@ZERO@y pt - \pgfplots@tickshowfalse - \fi + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@logical@ZERO@y pt} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% \or - \ifdim\pgfplots@tmpa=\pgfplots@ymax@reg\relax - \pgfplots@tickshowfalse - \fi + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@ymax@reg} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% \fi \fi } \def\pgfplots@ztick@check@tickshow{% \pgfplots@tickshowtrue - % FIXME + \if\pgfplots@zaxislinesnum2% center + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@logical@ZERO@z pt} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% + \fi }% % Fills the macros @@ -438,7 +602,11 @@ % #2 : the current tick width % \def\pgfplots@prepare@tick@offsets@for@#1#2{% + % FIXME : this stuff was ok for 2D. + % For 3D, it works only for the cases of boxed axes or centered + % axis lines. \ifcase\csname pgfplots@#1tickposnum\endcsname\relax + % both %(\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt) \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% @@ -453,6 +621,7 @@ \pgfmathsubtract@{\pgfplots@tick@beg@b}{#2}% \let\pgfplots@tick@end@b=\pgfmathresult% \or + % left % (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% @@ -460,20 +629,22 @@ \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% \let\pgfplots@tick@end@a=\pgfmathresult \or + % center % (\pgfplots@ZERO@x -\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); \pgfmathsubtract@{\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB \endcsname}{\pgfplots@tick@offset}% \let\pgfplots@tick@beg@a=\pgfmathresult \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% \let\pgfplots@tick@end@a=\pgfmathresult% \or + % right % (\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#2, 0pt); - \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% - \pgfmathadd@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathsubtract@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult% + \edef\pgfplots@tick@beg@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% + \pgfmathadd@{\pgfplots@tick@beg@b}{\pgfplots@tick@offset}% + \let\pgfplots@tick@beg@b=\pgfmathresult + \pgfmathsubtract@{\pgfplots@tick@beg@b}{#2}% + \let\pgfplots@tick@end@b=\pgfmathresult% \else - % FALL BACK + % FALL BACK. never used, I guess? % (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% @@ -522,11 +693,9 @@ \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key \else \edef\pgfplots@tick@scale@labels{\noexpand\pgfplots@invoke@pgfkeyscode{/pgfplots/#1tick scale label code/.@cmd}{\pgfplots@glob@TMPa}}% - \pgftransformshift{\pgfplotspointsouthwest}% - \pgfsetxvec{\pgfplotspointxaxis}% - \pgfsetyvec{\pgfplotspointyaxis}% - % FIXME : do I need the fix for 'current axis.origin' - % here!? + % + \pgfplots@change@pgfpoints@to@descriptioncs + % \node[% /pgfplots/every tick label,% /pgfplots/every #1 tick label,% @@ -544,26 +713,41 @@ % This is just a special case for centered axis lines. \def\pgfplots@xtick@check@tickshow{% \pgfplots@tickshowtrue - \ifnum\pgfplots@xaxislinesnum=2 % + \if\pgfplots@xaxislinesnum2% center \ifcase\pgfplots@yaxislinesnum\relax - \ifdim\pgfplots@tmpa=\pgfplots@xmin@reg\relax - \pgfplots@tickshowfalse - \fi - \ifdim\pgfplots@tmpa=\pgfplots@xmax@reg\relax - \pgfplots@tickshowfalse - \fi + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@xmin@reg} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@xmax@reg} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% \or - \ifdim\pgfplots@tmpa=\pgfplots@xmin@reg\relax - \pgfplots@tickshowfalse - \fi + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@xmin@reg} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% \or - \ifdim\pgfplots@tmpa=\pgfplots@logical@ZERO@x pt % - \pgfplots@tickshowfalse - \fi + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@logical@ZERO@x pt} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% \or - \ifdim\pgfplots@tmpa=\pgfplots@xmax@reg\relax - \pgfplots@tickshowfalse - \fi + \pgfplotsmath@ifapproxequal@dim + {\pgfplots@tmpa}{\pgfplots@xmax@reg} + {\pgfplots@loc@tick@placement@tolerance} + {% + \pgfplots@tickshowfalse + }{}% \fi \fi } @@ -584,12 +768,13 @@ \begingroup \def\pgfplots@scaled@ticks@x@choice{0}% \def\pgfplots@scaled@ticks@y@choice{0}% + \def\pgfplots@scaled@ticks@z@choice{0}% \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}% - \expandafter\pgfplots@prepare@tick@coordlists@for\pgfplotspointonorientedsurfaceA{#2}% + \pgfplots@prepare@tick@coordlists@for{#1}{#2}% \pgfplots@drawgridlines@onorientedsurf% \pgfplots@drawticklines@onorientedsurf% \pgfplots@drawticklabels@onorientedsurf% @@ -611,6 +796,12 @@ % - \pgfplots@determinedefaultvalues has been executed. % That means particularly that \pgfplots@[xy][min,max] are available in TeX point % range (after datascaling and logs). +% POSTCONDITION: +% - the lists +% \pgfplots@prepared@tick@positions@major@x +% \pgfplots@prepared@tick@positions@major@tickindices@x +% \pgfplots@prepared@tick@positions@minor@x +% are ready. \def\pgfplots@prepare@tick@coordlists@for#1#2{% \begingroup \expandafter\let\expandafter\ifpgfplots@islinear\csname ifpgfplots@#1islinear\endcsname @@ -620,7 +811,17 @@ % 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@major@tickindices \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@minor + % + \afterassignment\pgfplots@gobble@until@relax + \pgfplots@tmpa=\pgfkeysvalueof{/pgfplots/#1tick placement tolerance}pt\relax + \pgfplots@tmpa=\csname pgfplots@#1@inverseveclength\endcsname\pgfplots@tmpa + \edef\pgfplots@loc@tick@placement@tolerance{\the\pgfplots@tmpa}% + % + \advance\csname pgfplots@#1min@reg\endcsname by-\pgfplots@tmpa + \advance\csname pgfplots@#1max@reg\endcsname by\pgfplots@tmpa + % \edef\pgfplots@loc@TMPa{#2}% \ifx\pgfplots@loc@TMPa\pgfutil@empty \else @@ -672,7 +873,10 @@ \fi % % + \gdef\pgfplots@glob@TMPa{0}% \foreach \x in {#2} {% + \let\pgfplots@ticknum=\pgfplots@glob@TMPa + % \pgfplots@tmpa=\x pt % \csname pgfplots@#1tick@check@tickshow\endcsname \pgfplots@checktickminmax @@ -683,6 +887,7 @@ \ifdim\pgfplots@tmpa>\csname pgfplots@#1max@reg\endcsname \else \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@major + \expandafter\pgfplotslistpushbackglobal\pgfplots@ticknum\to\pgfplots@prepared@tick@positions@major@tickindices \fi \fi \fi @@ -696,7 +901,7 @@ \pgfplots@tmpa=\pgfplots@minor@tick@dist pt % \pgfplots@tmpa=\pgfplots@i\pgfplots@tmpa \else - \pgfplots@tmpa=\logi\pgfplots@i pt % + \pgfplots@tmpa=\csname pgfplotsmathlogi@#1\endcsname\pgfplots@i pt % \fi \edef\pgfmathresult{\the\pgfplots@tmpa}% \pgfmath@smuggleone\pgfmathresult @@ -716,12 +921,17 @@ \fi }% \fi + \pgfplotsutil@advancestringcounter\pgfplots@ticknum + % carry \ticknum outside of this scope: + \global\let\pgfplots@glob@TMPa=\pgfplots@ticknum }% \fi \endgroup \expandafter\let\csname pgfplots@prepared@tick@positions@minor@#1\endcsname=\pgfplots@prepared@tick@positions@minor \expandafter\let\csname pgfplots@prepared@tick@positions@major@#1\endcsname=\pgfplots@prepared@tick@positions@major + \expandafter\let\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname=\pgfplots@prepared@tick@positions@major@tickindices \global\let\pgfplots@prepared@tick@positions@major=\relax + \global\let\pgfplots@prepared@tick@positions@major@tickindices=\relax \global\let\pgfplots@prepared@tick@positions@minor=\relax }% @@ -740,65 +950,53 @@ \expandafter\pgfplots@drawgridlines@onorientedsurf@\pgfplotspointonorientedsurfaceA }% \def\pgfplots@drawgridlines@onorientedsurf@#1{% - \begingroup - \expandafter\let\expandafter\ifpgfplots@major\csname ifpgfplots@#1majorgrids\endcsname - \expandafter\let\expandafter\ifpgfplots@minor\csname ifpgfplots@#1minorgrids\endcsname - % grid lines shall be drawn - % if and only if BOTH adjacent axis lines shall be drawn: - \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% - % remark: this is ALWAYS true for 2D plots. - \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% - \def\pgfplots@drawgridlines@onorientedsurf@OK{1}% - }{% - \def\pgfplots@drawgridlines@onorientedsurf@OK{0}% - }% + \pgfplots@if{pgfplots@shownothingof@\pgfplotspointonorientedsurfaceB}{% + \relax }{% - \def\pgfplots@drawgridlines@onorientedsurf@OK{0}% - }% - \if1\pgfplots@drawgridlines@onorientedsurf@OK - \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 - \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1 - \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{% - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\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{% - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% - }% - \endpgfextra; + \begingroup + \pgfplots@ifgridlines@onorientedsurf@should@be@drawn{% + \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 + \pgfplots@if{pgfplots@#1majorgrids}{\pgfplots@loop@CONTINUEtrue}{}% + \pgfplots@if{pgfplots@#1minorgrids}{\pgfplots@loop@CONTINUEtrue}{}% + \ifpgfplots@loop@CONTINUE + \scope + \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1 + % + \pgfplots@if{pgfplots@#1minorgrids}{% + \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{% + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% + }% + \endpgfextra; + }{}% + % + \pgfplots@if{pgfplots@#1majorgrids}{% + \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{% + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% + }% + \endpgfextra; + }{}% + % + \endscope \fi - \endscope - \fi - \fi - \endgroup + }{}% + \endgroup + }% } % Draws ticks on the currently active "oriented surface". @@ -847,6 +1045,8 @@ \begingroup \pgf@xa=5cm \edef\pgfplots@loc@TMPc{\pgf@sys@tonumber{\pgf@xa}}% + % the case ||e_b|| == 0 should never happen here! Should be + % caught before entering this routine. \pgfmathmultiply@{\pgfplots@loc@TMPc}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@loc@LENGTH=\pgfmathresult \pgfmathsubtract@{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}{\pgfplots@loc@LENGTH}% @@ -863,168 +1063,217 @@ }% \def\pgfplots@drawticklines@onorientedsurf@#1{% - \scope - \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% - \def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{1}% - }{% - \def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{0}% - }% - \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% - \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{1}% + \pgfplots@if{pgfplots@shownothingof@\pgfplotspointonorientedsurfaceB}{% + \relax }{% - \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% - }% - \begingroup - % Assemble the \pgfplots@drawticklines@for@placecomputedtick - % command. - \let\E=\noexpand - \xdef\pgfplots@drawticklines@for@placecomputedtick{% - \if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1% - \E\pgfpathmoveto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@beg@a}}% - \E\pgfpathlineto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@end@a}}% - \fi - \if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1% - \ifnum\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname=0\relax - \E\pgfpathmoveto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@beg@b}}% - \E\pgfpathlineto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@end@b}}% + \scope + \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% + \def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{1}% + }{% + \def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{0}% + }% + \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% + \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{1}% + }{% + \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% + }% + \if\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}r% + % local special handling for reversed axes: exchange + % meaning of 'left' and 'right' here. + % + % the rest of the pgfplots code does that automatically because + % there, tickposnum is relevant to determine the axes + % which contains tick labels. And this algorithm checks + % for reversed axes implicitly. + % + \if1\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname + \expandafter\def\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname{3}% + \else + \if3\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname + \expandafter\def\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname{1}% \fi \fi - }% - \endgroup - \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 - \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1 - \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 - \pgfmathmultiply@{\pgfplots@tickwidth@}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% - \let\pgfplots@tickwidth@=\pgfmathresult - \let\pgfplots@tickwidth=\pgfmathresult - \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 - \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@tickwidth@}% - \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% - \pgfplots@drawticklines@for@placecomputedtick - }% - \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 - \pgfmathmultiply@{\pgfplots@subtickwidth@}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% - \let\pgfplots@subtickwidth@=\pgfmathresult - \let\pgfplots@subtickwidth=\pgfmathresult - \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax - \def\pgfplots@tick@offset{0}% + \ifcase\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname\relax + % both \or - \let\pgfplots@tick@offset=\pgfplots@subtickwidth@% + % lower + \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% \or - \pgfmathmultiply@{0.5}{\pgfplots@subtickwidth@}% - \let\pgfplots@tick@offset=\pgfmathresult% + % center + \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% + \or + % upper + \def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{0}% + \else + % never used? + \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% \fi - \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@subtickwidth@}% - \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{% - \pgfplots@drawticklines@for@placecomputedtick - }% - \endpgfextra; - \fi - \endscope + \begingroup + % Assemble the \pgfplots@drawticklines@for@placecomputedtick + % command. + \let\E=\noexpand + \xdef\pgfplots@drawticklines@for@placecomputedtick{% + \if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1% + \E\pgfpathmoveto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@beg@a}}% + \E\pgfpathlineto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@end@a}}% + \fi + \if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1% + \E\pgfpathmoveto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@beg@b}}% + \E\pgfpathlineto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@end@b}}% + \fi + }% + \endgroup + \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@drawtickgridlines@INSTALLCLIP@onorientedsurf#1 + % + \pgfplots@if{pgfplots@#1minorticks}{% + \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 + \pgfmathmultiply@{\pgfplots@subtickwidth@}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% + \let\pgfplots@subtickwidth@=\pgfmathresult + \let\pgfplots@subtickwidth=\pgfmathresult + \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 + \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@subtickwidth@}% + \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{% + \pgfplots@drawticklines@for@placecomputedtick + }% + \endpgfextra; + }{}% + % + \pgfplots@if{pgfplots@#1majorticks}{% + \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 + \pgfmathmultiply@{\pgfplots@tickwidth@}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% + \let\pgfplots@tickwidth@=\pgfmathresult + \let\pgfplots@tickwidth=\pgfmathresult + \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 + \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@tickwidth@}% + \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% + \pgfplots@drawticklines@for@placecomputedtick + }% + \endpgfextra; + }{}% + % + \endscope + }% } -% Draws tick labels at the A positions of the currently set oriented +% Draws tick labels at the positions of the currently set oriented % surface. % % Tick positions are taken out of the already precomputed list % \pgfplots@prepared@tick@positions@major@... % +% For 2D axes, this task is relatively simple: +% we iterate through every prepared major tick position and place a +% tick label. Open points, however, are the question whether to use +% the RIGHT or the LEFT axis line on the current oriented surface: +% +% direction 'b' (second oriented) +% |-------------------------| +% | | +% | | +% | |direction 'a' (first oriented) +% | | +% | | +% | | +% |-------------------------| +% Left Right +% +% Given the axis line which shall contain the labels, we have to +% decide how to align the tick label nodes: on the left or on the +% right? Of course, we want to align them such that they are "outside" +% of the figure! That's simple as well: "Left axis line => outside +% means left", "Right axis line => outside means right". +% +% That's all, basically. +% +% For 3D axes, all these points are basically ... the same! +% Now it can happen that the current oriented surface shall +% not contain ANY tick label. In that case, we do nothing. +% Furthermore, the "outside" direction (i.e. the anchoring of the +% label nodes) is a little bit more difficult. +% +% % See \pgfplots@drawticklines@onorientedsurf@ for a description of the % oriented surface. -% -% #1 : the verbatim axis name (either 'x' or 'y') \def\pgfplots@drawticklabels@onorientedsurf{% \expandafter\pgfplots@drawticklabels@onorientedsurf@\pgfplotspointonorientedsurfaceA } \def\pgfplots@drawticklabels@onorientedsurf@#1{% \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 + % check whether + % - we need to place tick labels on the LEFT side, + % - we need to place tick labels on the RIGHT side, + % - we don't need tick labels for the current surface at all: \pgfplotspointonorientedsurfaceabmatchaxisline{\csname pgfplots@#1ticklabelaxisspec\endcsname}{\pgfplots@ticklabelside}% \ifx\pgfplots@ticklabelside\pgfutil@empty % SKIP. The current oriented surface shall not get tick labels % for #1. \else - \ifpgfplots@major - \ifpgfplots@islinear + \pgfplots@if{pgfplots@#1majorticks}{% + \pgfplots@if{pgfplots@#1islinear}{% \pgfplots@init@scaled@tick@for{#1}% - \fi + }{\relax}% \begingroup - \if\pgfplotspointonorientedsurfaceB x - \def\pgfplots@tickposchoicea{\tikzset{right}}% - \def\pgfplots@tickposchoiceb{\tikzset{left}}% - \else - \if\pgfplotspointonorientedsurfaceB y - \def\pgfplots@tickposchoicea{\tikzset{above}}% - \def\pgfplots@tickposchoiceb{\tikzset{below}}% - \else - \def\pgfplots@tickposchoicea{\tikzset{anchor=north east}}% - \def\pgfplots@tickposchoiceb{\tikzset{anchor=south east}}% - \fi - \fi + \pgfkeysalso{/tikz/every node/.append style={/pgfplots/every tick label,/pgfplots/every #1 tick label}}% + \pgfplots@drawticklabels@onorientedsurf@prepareanchor#1% % - \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 - \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% - \let\pgfplots@tick@offset=\pgfmathresult - %-------------------------------------------------- - % \ifnum\csname pgfplots@#1ticklabelaxisspec\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@#1ticklabelaxisspec\endcsname - % \fi - % \ifcase\pgfplots@tmpposnum\relax - % \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname% - % \or - % \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname% - % \or - % \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB\endcsname% - % \or - % \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname% - % \fi - %-------------------------------------------------- - \ifnum\csname pgfplots@#1axislinesnum\endcsname=2 % Centered axis lines? + \pgfplotsmath@ifzero{\csname pgfplots@\pgfplotspointonorientedsurfaceB @veclength\endcsname}{% + \def\pgfplots@tick@offset{0}% + }{% + \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 + \pgfplots@ticklabel@maxtickdimen@extrashift{#1}{\pgfplots@tick@offset}% + \pgfmathmultiply@{\pgfplots@tick@offset}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% + \let\pgfplots@tick@offset=\pgfmathresult + }% + % + \if2\csname pgfplots@#1axislinesnum\endcsname % Centered axis lines? \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB\endcsname% % FIXME : that stuff here does not respect % '[xyz]tickpos num' keys! \pgfplots@tickposchoiceb + \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}% + % special handling for reversed axes. + \pgfmathmultiply{-1}{\pgfplots@tick@offset}% + \let\pgfplots@tick@offset=\pgfmathresult + \fi \pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% \else \if0\pgfplots@ticklabelside @@ -1037,6 +1286,7 @@ \pgfplots@tickposchoicea \pgfmathadd@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% \else + % Should never happen. \pgfplots@error{Internal logic error during tick label placement (got placement character '\pgfplots@ticklabelside'). Please report this as a bug or verify your input arguments to #1ticklabel pos.}% \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname% @@ -1046,27 +1296,134 @@ \fi \fi % + % make sure the \pgfmathlogtologten method works even for + % non-standard 'log basis #1': + \expandafter\let\expandafter\pgfmathlogtologten@\csname pgfplotsmathlogtologten@#1@\endcsname + % \let\pgfplots@tick@origin=\pgfmathresult% - \def\pgfplots@ticknum{0}% \xdef\pgfplots@show@ticklabel@LASTTICK{}% \pgfplotslistforeachungrouped\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% + \expandafter\pgfplotslistpopfront\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname\to\pgfplots@ticknum \pgfplots@show@ticklabel {#1}{\pgfplots@curtickpos}(\pgfplots@curtickpos,\pgfplots@tick@origin)% {\pgfplots@ticknum}% - \begingroup - \c@pgf@counta=\pgfplots@ticknum\relax - \advance\c@pgf@counta by1 - \edef\pgfplots@ticknum{\the\c@pgf@counta}% - \pgfmath@smuggleone\pgfplots@ticknum - \endgroup }% + \pgfplots@ticklabel@maxtickdimen@finish{#1}% \endgroup \pgfplots@draw@tick@scale@label@for #1% - \fi + }% + {\relax}% if...@major==false \fi \endgroup } +% This here does the main work for any tick label ANCHORING. +% +% FIXME : the new 'near ticklabel' anchors are now the default method +% to place tick labels. +% +% This feature here can be used to disable this anchoring, i.e. set +% 'ticklabel anchor=tikz' to use a stupid heuristics. +% +% There are actually two choices: +% Choice 1: near ticklabel +% This choice places tick labels fully automatic outside of the +% figure, all on a line which is parallel to the axis which +% contains the corresponding tick labels. +% +% Since we are currently working on a restricted surface, we have +% three direction related to that surface: +% 'a': this is the direction in which tick positions are known. +% 'b': the 'orthogonal' axis to 'a' which is also in the surface. +% 'n': the surface normal. +% Now, the idea for tick labels is to place them at +% SCALE_b * b + SCALE_n * n, +% where the SCALE_[bn] numbers are choosen such that the label is +% outside of the axis. +% +% The offset is simply added to the transformation matrix (as a +% shift). +% +% Choice 2: tikz. +% This is more or less a backwards compatibility feature. It does +% not change the transformation matrix. It simply sets the 'at' key +% of each node to the tick position and prepares the correct anchors +% for the TikZ '\node' commands. +% That's all here. +% +% PRECONDITION: +% - called inside of \pgfplots@drawticklabels@onorientedsurf@ +% POSTCONDITION: +% - defines +% - \pgfplots@tickposchoicea +% if called, sets keys such that tick labels are RIGHT (TOP) of +% the axis, +% +% - \pgfplots@tickposchoiceb +% if called, sets keys such that tick labels are LEFT +% (BOTTOM) of the axis, +\def\pgfplots@drawticklabels@onorientedsurf@prepareanchor#1{% + \if\csname pgfplots@ticklabel@anchor@#1\endcsname0% + % auto is the same as 'near ticklabel': + \expandafter\def\csname pgfplots@ticklabel@anchor@#1\endcsname{1}% + \fi + \ifcase\csname pgfplots@ticklabel@anchor@#1\endcsname% + % 0: doesn't happen, see above. + \or + % 1: near ticklabel. + % The following code contains automatically + % aligned tick labels (especially for 3D axes). + % see the manual for the |near ticklabel| anchors. + \pgfkeys{/tikz/anchor=near #1ticklabel}% + % + % process the (optional) ticklabel distance: + \begingroup + \pgfkeysgetvalue{/pgfplots/#1ticklabel shift}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \afterassignment\pgfplots@gobble@until@relax + \pgf@xa=\pgfkeysvalueof{/pgfplots/#1ticklabel shift}pt\relax + \multiply\pgf@xa by-1 % the direction vector points to the INSIDE. the shift should have opposite sign. + \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup + \let\pgfplots@loc@TMPc=\pgfmathresult + \ifx\pgfplots@loc@TMPc\pgfutil@empty + \else + \pgftransformshift{% + \pgfplotspointouternormalvectorofticklabelaxis{#1}% + \pgfqpointscale{-\pgfplots@loc@TMPc}{}% + }% + \fi + % + % these things are irrelevant here: + \let\pgfplots@tickposchoicea=\pgfutil@empty + \let\pgfplots@tickposchoiceb=\pgfutil@empty + \or + % 2: tikz. + % We simply prepare the default anchor. + % Actually, this code is just for backwards compatibility - + % there may be people who prefer to set anchors. The + % 'near ticklabel' implementation is much more general, however. + \if\pgfplotspointonorientedsurfaceB x + \def\pgfplots@tickposchoicea{\tikzset{right}}% + \def\pgfplots@tickposchoiceb{\tikzset{left}}% + \else + \if\pgfplotspointonorientedsurfaceB y + \def\pgfplots@tickposchoicea{\tikzset{above}}% + \def\pgfplots@tickposchoiceb{\tikzset{below}}% + \else + \def\pgfplots@tickposchoicea{\tikzset{anchor=north east}}% + \def\pgfplots@tickposchoiceb{\tikzset{anchor=south east}}% + \fi + \fi + \fi + \pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec + {#1}% + {\pgfplotspointouternormalvectorofticklabelaxis{#1}}% +}% + \newif\ifpgfplots@checkuniform@isfirst % Checks whether the argument to xtick or ytick is a UNIFORM tick % sequence. @@ -1153,10 +1510,14 @@ % helper method which computes log10*\x foreach \x in {#1}. % The result will be \xdef'ed into #2. -\def\pgfplots@compute@tick@times@logten#1\to#2{% +% +% #1: the ticks +% #2: the output macro +% #3: the axis +\def\pgfplots@compute@tick@times@logten#1\to#2#3{% \global\let#2=\pgfutil@empty \foreach \pgfplots@loc@TMPb in {#1} {% - \pgfmathmultiply@\pgfplots@loc@TMPb\logten% + \pgfmathmultiply@{\pgfplots@loc@TMPb}{\csname pgfplots@log@scale@todisplaylog@#3\endcsname}% \ifx#2\pgfutil@empty \xdef#2{\pgfmathresult}% \else @@ -1253,24 +1614,25 @@ % \let\desirednumticks=\c@pgf@countd \let\Wr=\pgf@xc - \Wr=\csname pgfplotspoint#1axislength\endcsname + \Wr=\csname pgfplotspoint#1axislength\endcsname\relax % r = max place without ticks in pt -> choose desirednumticks >= W/r - \expandafter\expandafter\divide\Wr\axisdefaulttickwidth - \pgfmathsetcount{\desirednumticks}{\Wr}% + \divide\Wr by\axisdefaulttickwidth\relax + \afterassignment\pgfplots@gobble@until@relax + \desirednumticks=\the\Wr\relax \advance\desirednumticks by1 \csname ifpgfplots@#1islinear\endcsname - \expandafter\ifnum\axisdefaulttryminticks>\desirednumticks - \desirednumticks=\axisdefaulttryminticks + \ifnum\axisdefaulttryminticks>\desirednumticks\relax + \desirednumticks=\axisdefaulttryminticks\relax \fi \else - \expandafter\ifnum\pgfplots@default@try@minticks@log>\desirednumticks + \ifnum\pgfplots@default@try@minticks@log>\desirednumticks\relax \desirednumticks=\pgfplots@default@try@minticks@log\relax \fi \expandafter\ifx\csname pgfplots@#1tickten\endcsname\pgfutil@empty \else % log plot and tickten-option: provide special processing. \edef\pgfplots@loc@TMPa{\csname pgfplots@#1tickten\endcsname}% - \expandafter\pgfplots@compute@tick@times@logten\pgfplots@loc@TMPa\to\pgfplots@glob@TMPa + \expandafter\pgfplots@compute@tick@times@logten\pgfplots@loc@TMPa\to\pgfplots@glob@TMPa{#1}% \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa \fi \fi @@ -1283,15 +1645,15 @@ \let\MAX=\pgf@ya \let\MIN=\pgf@yb % compute step size 'H': - \expandafter\MAX\csname pgfplots@#1max\endcsname pt + \expandafter\MAX\csname pgfplots@#1max\endcsname pt % \advance\MAX by0.001pt % avoid round errors %\expandafter\MIN\the\c@pgf@counta pt - \expandafter\MIN\csname pgfplots@#1min\endcsname pt + \expandafter\MIN\csname pgfplots@#1min\endcsname pt % \H=\MAX \advance\H by-\MIN %\message{Axis limit #1: [\the\MIN:\the\MAX], diff = \the\H.}% \c@pgf@counta=\desirednumticks - \advance\c@pgf@counta by-1 + \advance\c@pgf@counta by-1 % \divide\H by\c@pgf@counta %\message{determining ticks for #1-axis: Wr := (width/max space between ticks) = \the\Wr, desirednumticks=max(\axisdefaulttryminticks, trunc(Wr)) = \the\desirednumticks, H#1=(axis range/(desirednumticks-1)) = \the\H}% % @@ -1366,10 +1728,10 @@ \fi % % And, since we have used finite precision, I is most - % likely to large. So: subtract one H. In the worst + % likely to be large. So: subtract one H. In the worst % case, this produces one tick position too much (but % it won't be printed). - \advance\MIN by-\H + \advance\MIN by-\H\relax \else % CASE LOG AXIS % @@ -1377,7 +1739,7 @@ % % And prefer j=1 if that is possible (otherwise minor % ticks are not useful). - \pgfmathmultiply@{\Hmacro}{\reciproclogten}% + \pgfmathmultiply@{\Hmacro}{\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname}% \let\Hmacrobaseten=\pgfmathresult \expandafter\H\pgfmathresult pt %\message{ [ H / log(10) = \pgfmathresult ]}% @@ -1399,7 +1761,7 @@ \pgfplots@isuniformtickfalse \fi %\message{final H=\pgf@sys@tonumber{\H} * log(10)}% - \H=\logten\H\relax + \H=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\H\relax % Now, we want to activate the Tick set % {lowest, lowest+H, ..., highest} % @@ -1412,14 +1774,14 @@ \MINH=\MIN % % and compute I and I*log(10) here: - \expandafter\MIN\reciproclogten\MIN\relax + \MIN=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname\MIN\relax \edef\pgfmathresult{\pgf@sys@tonumber{\MIN}}% \pgfmathsetcount{\c@pgf@counta}{\pgfmathresult}% \ifdim\MIN<0pt % the truncation rounds TOWARDS 0 which is not what I want. \advance\c@pgf@counta by-1 \fi - \expandafter\MIN\logten pt + \MIN=\csname pgfplots@log@scale@todisplaylog@#1\endcsname pt \multiply\MIN by\c@pgf@counta \ifpgfplots@isuniformtick \else @@ -1449,7 +1811,7 @@ \advance\MINH by-\H % \ifdim\MINH<0pt - \expandafter\advance\expandafter\MIN\logten pt + \advance\MIN \csname pgfplots@log@scale@todisplaylog@#1\endcsname pt \fi \fi \fi @@ -1464,94 +1826,112 @@ % MIN < ORIGMIN by construction (ok, MIN <= ORIGMIN by % construction, but I don't care about this case). % So: check only the second condition. + \def\pgfplots@tick@returnval@ready{0}% \pgfplots@tmpa=\MINH \advance\pgfplots@tmpa by\H \ifdim\MAX<\pgfplots@tmpa - \aftergroup\pgfplots@isuniformtickfalse - % ok, do something special. - % - % The idea is now to place ticks at - % 10^{i*h} with properly choosen 'h'. - % - % So: apply basically the SAME code as above for linear - % axis, just everything log 10! And keep in mind that all - % coordinates are actually given as natural logarithms. - \expandafter\MIN\csname pgfplots@#1min\endcsname pt - \H=\MAX - \advance\H by-\MIN - \H=\reciproclogten\H + \pgfplots@if{pgfplots@#1islinear}{% + \def\pgfplots@tick@returnval@ready{1}% + \begingroup + \c@pgf@counta=\axisdefaulttryminticks\relax + \advance\c@pgf@counta by1 + \edef\axisdefaulttryminticks{\the\c@pgf@counta}% +%\message{**TOO FEW TICK LABELS. RECURSION with try min ticks=\axisdefaulttryminticks.**}% + % recurse. + \pgfplots@assign@default@tick@foraxis{#1}% + \expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfplots@#1tick\endcsname + \expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPb\csname pgfplots@tick@distance@#1\endcsname + \endgroup + }{% + \aftergroup\pgfplots@isuniformtickfalse + % ok, do something special. + % + % The idea is now to place ticks at + % 10^{i*h} with properly choosen 'h'. + % + % So: apply basically the SAME code as above for linear + % axis, just everything log 10! And keep in mind that all + % coordinates are actually given as natural logarithms. + \expandafter\MIN\csname pgfplots@#1min\endcsname pt + \H=\MAX + \advance\H by-\MIN + \H=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname\H %\message{Axis limit #1: [\the\MIN:\the\MAX], diff/log(10) = \the\H.}% - \c@pgf@counta=\desirednumticks\relax - \advance\c@pgf@counta by-1 - \ifnum\c@pgf@counta>2 - % subtract one more. This algorithm here produces more - % ticks than the normal one which is designed for 10^i + \c@pgf@counta=\desirednumticks\relax \advance\c@pgf@counta by-1 - \fi - \divide\H by\c@pgf@counta\relax -%\message{determining ticks for #1-axis: Wr := (width/max space between ticks) = \the\Wr, desirednumticks=max(\axisdefaulttryminticks, trunc(Wr)) = \the\desirednumticks, H#1=(axis range/(desirednumticks-1)) = \the\H}% - % - % SEARCH for the NEXT FEASABLE H. - \edef\Hmacro{\pgf@sys@tonumber\H}% - \pgfmathfloatparsenumber{\Hmacro}% - \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E - % Determine properly snapped mantisse... - \ifdim\H<2pt - \ifdim\H<1.5pt - \H=1.0pt - \else - \H=2.0pt + \ifnum\c@pgf@counta>2 + % subtract one more. This algorithm here produces more + % ticks than the normal one which is designed for 10^i + \advance\c@pgf@counta by-1 \fi - \else - \ifdim\H<4.9999pt - \ifdim\H<3.5pt - \H=2.0pt\relax + \divide\H by\c@pgf@counta\relax +%\message{determining ticks for #1-axis: Wr := (width/max space between ticks) = \the\Wr, desirednumticks=max(\axisdefaulttryminticks, trunc(Wr)) = \the\desirednumticks, H#1=(axis range/(desirednumticks-1)) = \the\H}% + % + % SEARCH for the NEXT FEASABLE H. + \edef\Hmacro{\pgf@sys@tonumber\H}% + \pgfmathfloatparsenumber{\Hmacro}% + \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E + % Determine properly snapped mantisse... + \ifdim\H<2pt + \ifdim\H<1.5pt + \H=1.0pt \else - \H=5.0pt\relax + \H=2.0pt \fi \else - \ifdim\H<7.5pt - \H=5.0pt\relax + \ifdim\H<4.9999pt + \ifdim\H<3.5pt + \H=2.0pt\relax + \else + \H=5.0pt\relax + \fi \else - \H=1.0pt\relax - \advance\pgfmathfloat@a@E by1 + \ifdim\H<7.5pt + \H=5.0pt\relax + \else + \H=1.0pt\relax + \advance\pgfmathfloat@a@E by1 + \fi \fi \fi - \fi - \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgf@sys@tonumber{\H}}{\the\pgfmathfloat@a@E}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% - \let\Hmacro=\pgfmathresult - \H=\Hmacro pt % - % Ok, our step size h for 10^{i*h} is ready! + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgf@sys@tonumber{\H}}{\the\pgfmathfloat@a@E}% + \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \let\Hmacro=\pgfmathresult + \H=\Hmacro pt % + % Ok, our step size h for 10^{i*h} is ready! %\message{determined step size 10^{\Hmacro}}% - % Now, we want to activate the Tick set {10^{i*H}, i in \Z} - % compute I such that - % 10^{min} = 10^{I * H + rest}; |rest| < H - % -> I = round(xmin/H) - % -> MIN = I * H - % BUT EVERYTHING to log(10) basis! - \MIN=\reciproclogten\MIN\relax - \pgfmathlog@invoke@expanded\pgfmathdivide@{% - {\pgf@sys@tonumber\MIN}% - {\Hmacro}% + % Now, we want to activate the Tick set {10^{i*H}, i in \Z} + % compute I such that + % 10^{min} = 10^{I * H + rest}; |rest| < H + % -> I = round(xmin/H) + % -> MIN = I * H + % BUT EVERYTHING to log(10) basis! + \MIN=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname \MIN\relax + \pgfmathlog@invoke@expanded\pgfmathdivide@{% + {\pgf@sys@tonumber\MIN}% + {\Hmacro}% + }% + \pgfmathsetcount{\c@pgf@counta}{\pgfmathresult}% + \ifdim\MIN<0pt + % the truncation rounds TOWARDS 0 which is not what I want. + \advance\c@pgf@counta by-1 + \fi + \MIN=\H\relax + \multiply\MIN by\c@pgf@counta\relax + % + % convert back to basis 'e': + \MIN=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\MIN\relax + \H=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\H\relax + \MINH=\MIN\relax + \advance\MINH by\H\relax }% - \pgfmathsetcount{\c@pgf@counta}{\pgfmathresult}% - \ifdim\MIN<0pt - % the truncation rounds TOWARDS 0 which is not what I want. - \advance\c@pgf@counta by-1 - \fi - \MIN=\H\relax - \multiply\MIN by\c@pgf@counta\relax - % - % convert back to basis 'e': - \MIN=\logten\MIN\relax - \H=\logten\H\relax - \MINH=\MIN\relax - \advance\MINH by\H\relax \fi -%\pgfplots@message{final H=\the\H.}% - \xdef\pgfplots@glob@TMPa{\pgf@sys@tonumber{\MIN},\pgf@sys@tonumber{\MINH},...,\pgf@sys@tonumber{\MAX}}% - \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\H}}% +%\message{final H=\the\H.}% + \if0\pgfplots@tick@returnval@ready + \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\H}}% + \advance\MAX by0.5\H % avoid rounding inaccuracies: + \xdef\pgfplots@glob@TMPa{\pgf@sys@tonumber{\MIN},\pgf@sys@tonumber{\MINH},...,\pgf@sys@tonumber{\MAX}}% + \fi \aftergroup\pgfplots@determinedefaultvalues@needs@check@uniformtickfalse \else \expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfplots@#1tick\endcsname @@ -1561,7 +1941,7 @@ \endgroup \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa \expandafter\let\csname pgfplots@tick@distance@#1\endcsname=\pgfplots@glob@TMPb -%\pgfplots@message{pgfplots.sty: #1tick set to \csname pgfplots@#1tick\endcsname [#1min=\csname pgfplots@#1min\endcsname, #1max=\csname pgfplots@#1max\endcsname].}% +%\message{pgfplots.sty: #1tick set to \csname pgfplots@#1tick\endcsname [#1min=\csname pgfplots@#1min\endcsname, #1max=\csname pgfplots@#1max\endcsname].}% } % Helper method for @@ -1600,3 +1980,26 @@ }% % }% + +% Adds a further, temporary anchor to every node which will be +% processed. The anchor will be named '#2'. It is placed such that +% 1. the node's center is on a line in direction of the inwards normal +% vector of the #1 ticklabel axis and the 'at' position of the node, +% 2. the node does not intrude the axis. +% +% In effect, one of the node's standard anchors (north, east, ... ) +% will be placed on the line +% \draw[blue,thick,->] (xticklabel cs:0,0) -- (xticklabel cs:1,0); +% +% This command is identical to calling +% \pgfplotsdeclareborderanchorforaxis{#1}{<three-char-string-of-#1-ticklabel-axis>}{#2} +% +% @REMARKS: +% - it is -by no means- necessary that any ticks or tick labels are +% drawn or defined for this method. +% - in fact, tick labels use such an anchor (the 'near #1ticklabel' +% anchor is defined in this way) +\def\pgfplotsdeclareborderanchorforticklabelaxis#1#2{% + \pgfplotsdeclareborderanchorforaxis{#1}{\pgfplotsticklabelaxisspec{#1}}{#2}% +} + diff --git a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvips.def b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvips.def new file mode 100644 index 00000000000..b45b779e003 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvips.def @@ -0,0 +1,109 @@ +%-------------------------------------------- +% $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/sys/pgflibrarysurfshading.pgfsys-dvips.def,v 1.1 2009/06/11 07:14:52 ludewich Exp $ +% +% 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + + +\def\pgfplotslibrarysurf@initstream{% + \if\pgfplotslibrarysurf@bytespercoordinate4% + \pgfplots@warning{************** The generated postscript file may not be compatible with all viewers. Consider using \string\pgfplotsset{surf shading/precision=postscript} for improved compatibility. Or: convert it to pdf, that will work correctly. **************}% + \fi + % binary doesn't work due to limitations of DVI. + % We NEED an ASCII encoding. + % + \def\pgfplotslibrarysurf@filter@encode{ASCIIHexEncode}% + \def\pgfplotslibrarysurf@filter@decode{ASCIIHexDecode}% +}% + +% The lowlevel call for surface shadings. It uses a pattern type 2 +% dictionary as fill color and has thus several things to do. +% +% It appears the dvips implementation is simpler than the pdftex +% implementation - I did not need to adjust the matrix (don't know +% why). +\def\pgfplotslibrarysurfdraw{% + \pgfpicture + \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa% + \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa + \pgfpathrectanglecorners + {\pgfplotslibrarysurf@corner@sw} + {\pgfplotslibrarysurf@corner@ne}% + \pgfusepath{fill}% + \endpgfpicture + \leavevmode% ?? +} + +% To be used inside of a pgfpicture. +% +% #1: a macro name. The contents of this macro needs to be written +% into the pdf pattern dictionary contained in the pdf resources of +% the current context. The current context is either the current page +% or an xform object. +% +% +\def\pgfplotssys@do@surfshading@fillpaths#1{% +%http://www.ghostscript.com/pipermail/gs-devel/2002-September/005763.html +%http://www.tek-tips.com/viewthread.cfm?qid=1183719&page=4 +% \pgf@process{\pgfpointdiff{\pgfplotslibrarysurf@corner@sw}{\pgfkeysvalueof{/pgfplots/surf shading/anchor}}}% +% \pgf@sys@bp@correct\pgf@x% +% \pgf@sys@bp@correct\pgf@y% + \pgfsys@invoke{% + << + %/Type /Pattern + /PatternType 2 + /Shading + << + /ShadingType 5 + /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space + /BitsPerComponent 16 % Note: this here is the reason why I can't use ASCII85Decode + /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols} + /ColorSpace /DeviceRGB + /Decode [\pgfplotslibrarysurf@decode] + /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap} + /DataSource + currentfile + % direct binary output not possible: DVI + % doesn't support it (?) + %<< /EODCount \pgfplotslibrarysurf@binarystream@len\space /EODString () >> /SubFileDecode filter + % not completely implemented : + %/ASCII85Decode filter + % works: + /ASCIIHexDecode filter + /ReusableStreamDecode filter + \pgfplotslibrarysurf@binarystream + %\csname pgfp@bin@126\endcsname% tilde ~> is end-of-input indicator for ASCII85Decode + > % end-of-input indicator for ASCIIHexDecode + >> + >> [ 1 0 0 1 0 0 ] makepattern setpattern + % I don't know why I don't need the shifts here !? But it + % appears to work, so never mind. +% >> [ 1 0 0 1 \pgf@sys@tonumber\pgf@x\space \pgf@sys@tonumber\pgf@y ] makepattern setpattern + % 'setpattern' is a shortcut for changing the colorspace and + % the color to pattern. + }% +} + +\endinput +% vi: ft=tex diff --git a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def new file mode 100644 index 00000000000..63ec517b963 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def @@ -0,0 +1,118 @@ +%-------------------------------------------- +% $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/sys/pgflibrarysurfshading.pgfsys-pdftex.def,v 1.1 2009/06/11 07:14:52 ludewich Exp $ +% +% 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + + +% The lowlevel call for surface shadings. It uses a pattern type 2 +% dictionary as fill color and has thus several things to do. This is +% a little bit more complicated than using the '/sh' operator (as +% other pgf shadings do): the surface shading must be positioned +% exactly at the requested coordinates, otherwise it is quite useless. +% +% Since shadings are *not* affected by changes in the canvas +% transformation matrix (shifts, rotations etc), it is necessary to +% pack the shading into a separate xform object which is then rotated +% and translated correctly. +% +% There is just one more transformation necessary: the shift inside of +% the xform. This shift is done using changes in the canvas +% transformation matrix and it is UNDONE in the /Matrix argument of +% the pattern dictionary. This last step can't be done with the /sh +% operator which is why I am using pattern dictionaries. +\def\pgfplotslibrarysurfdraw{% + \begingroup + \setbox\pgfutil@tempboxa=\hbox{% + \pgfpicture + \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa% + \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa + \pgfpathrectanglecorners + {\pgfplotslibrarysurf@corner@sw} + {\pgfplotslibrarysurf@corner@ne}% + \pgfusepath{fill}% + \endpgfpicture + }% + \pdfxform resources{ + /Pattern << \pgfplots@glob@TMPa >> % write the pattern resource dictionary + }\pgfutil@tempboxa + \leavevmode + \pdfrefxform\pdflastxform + \endgroup +} + +% To be used inside of a pgfpicture. +% +% #1: a macro name. The contents of this macro needs to be written +% into the pdf pattern dictionary contained in the pdf resources of +% the current context. The current context is either the current page +% or an xform object. +% +% +\def\pgfplotssys@do@surfshading@fillpaths#1{% + \immediate\pdfobj stream attr {% + % stream length will be computed automatically + /ShadingType 5 + /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space + /BitsPerComponent 16 + /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols} + /ColorSpace /DeviceRGB + /Decode [\pgfplotslibrarysurf@decode] + /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap} + \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty + \else + /Filter /\pgfplotslibrarysurf@filter@decode\space + \fi + } {% + \pgfplotslibrarysurf@binarystream + }% + \edef\pgfplots@loc@TMPa{\the\pdflastobj}% + \pgf@process{\pgfpointdiff{\pgfplotslibrarysurf@corner@sw}{\pgfkeysvalueof{/pgfplots/surf shading/anchor}}}% + \pgf@sys@bp@correct\pgf@x% + \pgf@sys@bp@correct\pgf@y% + \immediate\pdfobj {<< + /Type /Pattern + /PatternType 2 +% /Matrix [\pgf@pt@aa\space\pgf@pt@ab\space\pgf@pt@ba\space\pgf@pt@bb\space\pgf@sys@tonumber\pgf@pt@x\space\pgf@sys@tonumber\pgf@pt@y] + % FIXME: INCORPORATE TIKZ CM + /Matrix [1 0 0 1 \pgf@sys@tonumber\pgf@x\space \pgf@sys@tonumber\pgf@y] %226.533 518.141] + %-------------------------------------------------- + % /ExtGState + % << + % /LW 2 + % /OP true + % /OPM 1 + % >> + %-------------------------------------------------- + /Shading \pgfplots@loc@TMPa\space 0 R + >>}% + \edef#1{% + /pgfpatPlotsurface\pgfplotslibrarysurf@count\space \the\pdflastobj\space 0 R + }% + \pgfsys@setpatterncolored{Plotsurface\pgfplotslibrarysurf@count}% + \pgfplotsutil@advancestringcounter@global\pgfplotslibrarysurf@count +} + +\endinput +% vi: ft=tex diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsbinary.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsbinary.code.tex new file mode 100644 index 00000000000..7229bc36d58 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsbinary.code.tex @@ -0,0 +1,802 @@ +%-------------------------------------------- +% $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/util/pgfplotsbinary.code.tex,v 1.13 2009/07/21 18:18:48 ludewich Exp $ +% +% 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 <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +% This file provides a self-contained package which does only need +% pgfkeys. +% +% It provides a method to convert TeX numbers (integers and +% dimensions) into binary format (macros with catcode 11 or 12). +% + +\edef\pgfplotsbinaryatcode{\the\catcode`\@ } +\catcode`\@=11 + +\begingroup +% prepare ONE-BYTE conversion [0-255] -> binary character: +\count0=0 +\catcode`\^^00=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^00}\advance\count0 by1 +\catcode`\^^01=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^01}\advance\count0 by1 +\catcode`\^^02=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^02}\advance\count0 by1 +\catcode`\^^03=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^03}\advance\count0 by1 +\catcode`\^^04=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^04}\advance\count0 by1 +\catcode`\^^05=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^05}\advance\count0 by1 +\catcode`\^^06=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^06}\advance\count0 by1 +\catcode`\^^07=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^07}\advance\count0 by1 +\catcode`\^^08=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^08}\advance\count0 by1 +\begingroup +\catcode`\^^09=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^09}\endgroup\advance\count0 by1 +\begingroup +\catcode`\^^0a=12\expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^0a}\endgroup\advance\count0 by1 +\begingroup +\catcode`\^^0b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^0b}\endgroup\advance\count0 by1 +\catcode`\^^0c=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^0c}\advance\count0 by1 +\begingroup +\catcode`\^^0d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^0d}\endgroup\advance\count0 by1 +\catcode`\^^0e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^0e}\advance\count0 by1 +\catcode`\^^0f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^0f}\advance\count0 by1 +\catcode`\^^10=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^10}\advance\count0 by1 +\catcode`\^^11=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^11}\advance\count0 by1 +\catcode`\^^12=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^12}\advance\count0 by1 +\catcode`\^^13=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^13}\advance\count0 by1 +\catcode`\^^14=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^14}\advance\count0 by1 +\catcode`\^^15=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^15}\advance\count0 by1 +\catcode`\^^16=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^16}\advance\count0 by1 +\catcode`\^^17=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^17}\advance\count0 by1 +\catcode`\^^18=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^18}\advance\count0 by1 +\catcode`\^^19=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^19}\advance\count0 by1 +\catcode`\^^1a=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^1a}\advance\count0 by1 +\catcode`\^^1b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^1b}\advance\count0 by1 +\catcode`\^^1c=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^1c}\advance\count0 by1 +\catcode`\^^1d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^1d}\advance\count0 by1 +\catcode`\^^1e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^1e}\advance\count0 by1 +\catcode`\^^1f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^1f}\advance\count0 by1 +\begingroup +\catcode`\^^20=12^^I\expandafter\xdef\csname^^Ipgfp@bin@\the\count0^^I\endcsname{^^20}\endgroup\advance\count0 by1 +\catcode`\^^21=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^21}\advance\count0 by1 +\catcode`\^^22=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^22}\advance\count0 by1 +\catcode`\^^23=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^23}\advance\count0 by1 +\catcode`\^^24=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^24}\advance\count0 by1 +\catcode`\^^25=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^25}\advance\count0 by1 +\catcode`\^^26=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^26}\advance\count0 by1 +\catcode`\^^27=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^27}\advance\count0 by1 +\catcode`\^^28=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^28}\advance\count0 by1 +\catcode`\^^29=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^29}\advance\count0 by1 +\catcode`\^^2a=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^2a}\advance\count0 by1 +\catcode`\^^2b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^2b}\advance\count0 by1 +\catcode`\^^2c=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^2c}\advance\count0 by1 +\catcode`\^^2d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^2d}\advance\count0 by1 +\catcode`\^^2e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^2e}\advance\count0 by1 +\catcode`\^^2f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^2f}\advance\count0 by1 +\catcode`\^^30=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^30}\advance\count0 by1 +\catcode`\^^31=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^31}\advance\count0 by1 +\catcode`\^^32=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^32}\advance\count0 by1 +\catcode`\^^33=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^33}\advance\count0 by1 +\catcode`\^^34=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^34}\advance\count0 by1 +\catcode`\^^35=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^35}\advance\count0 by1 +\catcode`\^^36=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^36}\advance\count0 by1 +\catcode`\^^37=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^37}\advance\count0 by1 +\catcode`\^^38=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^38}\advance\count0 by1 +\catcode`\^^39=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^39}\advance\count0 by1 +\catcode`\^^3a=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^3a}\advance\count0 by1 +\catcode`\^^3b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^3b}\advance\count0 by1 +\catcode`\^^3c=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^3c}\advance\count0 by1 +\catcode`\^^3d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^3d}\advance\count0 by1 +\catcode`\^^3e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^3e}\advance\count0 by1 +\catcode`\^^3f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^3f}\advance\count0 by1 +\catcode`\^^40=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^40}\advance\count0 by1 +\catcode`\^^41=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^41}\advance\count0 by1 +\catcode`\^^42=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^42}\advance\count0 by1 +\catcode`\^^43=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^43}\advance\count0 by1 +\catcode`\^^44=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^44}\advance\count0 by1 +\catcode`\^^45=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^45}\advance\count0 by1 +\catcode`\^^46=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^46}\advance\count0 by1 +\catcode`\^^47=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^47}\advance\count0 by1 +\catcode`\^^48=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^48}\advance\count0 by1 +\catcode`\^^49=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^49}\advance\count0 by1 +\catcode`\^^4a=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^4a}\advance\count0 by1 +\catcode`\^^4b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^4b}\advance\count0 by1 +\catcode`\^^4c=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^4c}\advance\count0 by1 +\catcode`\^^4d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^4d}\advance\count0 by1 +\catcode`\^^4e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^4e}\advance\count0 by1 +\catcode`\^^4f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^4f}\advance\count0 by1 +\catcode`\^^50=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^50}\advance\count0 by1 +\catcode`\^^51=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^51}\advance\count0 by1 +\catcode`\^^52=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^52}\advance\count0 by1 +\catcode`\^^53=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^53}\advance\count0 by1 +\catcode`\^^54=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^54}\advance\count0 by1 +\catcode`\^^55=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^55}\advance\count0 by1 +\catcode`\^^56=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^56}\advance\count0 by1 +\catcode`\^^57=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^57}\advance\count0 by1 +\catcode`\^^58=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^58}\advance\count0 by1 +\catcode`\^^59=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^59}\advance\count0 by1 +\catcode`\^^5a=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^5a}\advance\count0 by1 +\catcode`\^^5b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^5b}\advance\count0 by1 +\begingroup +\catcode`\|=0 +\catcode`\\=12 |expandafter|xdef|csname pgfp@bin@|the|count0 |endcsname{^^5c}|endgroup\advance\count0 by1 +\catcode`\^^5d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^5d}\advance\count0 by1 +\begingroup +\catcode`\^^5e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^}\endgroup\advance\count0 by1 +\catcode`\^^5f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^5f}\advance\count0 by1 +\catcode`\^^60=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^60}\advance\count0 by1 +\catcode`\^^61=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^61}\advance\count0 by1 +\catcode`\^^62=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^62}\advance\count0 by1 +\catcode`\^^63=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^63}\advance\count0 by1 +\catcode`\^^64=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^64}\advance\count0 by1 +\catcode`\^^65=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^65}\advance\count0 by1 +\catcode`\^^66=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^66}\advance\count0 by1 +\catcode`\^^67=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^67}\advance\count0 by1 +\catcode`\^^68=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^68}\advance\count0 by1 +\catcode`\^^69=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^69}\advance\count0 by1 +\catcode`\^^6a=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^6a}\advance\count0 by1 +\catcode`\^^6b=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^6b}\advance\count0 by1 +\catcode`\^^6c=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^6c}\advance\count0 by1 +\catcode`\^^6d=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^6d}\advance\count0 by1 +\catcode`\^^6e=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^6e}\advance\count0 by1 +\catcode`\^^6f=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^6f}\advance\count0 by1 +\catcode`\^^70=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^70}\advance\count0 by1 +\catcode`\^^71=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^71}\advance\count0 by1 +\catcode`\^^72=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^72}\advance\count0 by1 +\catcode`\^^73=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^73}\advance\count0 by1 +\catcode`\^^74=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^74}\advance\count0 by1 +\catcode`\^^75=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^75}\advance\count0 by1 +\catcode`\^^76=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^76}\advance\count0 by1 +\catcode`\^^77=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^77}\advance\count0 by1 +\catcode`\^^78=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^78}\advance\count0 by1 +\catcode`\^^79=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^79}\advance\count0 by1 +\catcode`\^^7a=11 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^7a}\advance\count0 by1 +\begingroup +\catcode`\q=1 +\catcode`\^^7b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname q^^7b}\endgroup\advance\count0 by1 +\catcode`\^^7c=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^7c}\advance\count0 by1 +\begingroup +\catcode`\q=2 +\catcode`\^^7d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^7dq\endgroup\advance\count0 by1 +\catcode`\^^7e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^7e}\advance\count0 by1 +\catcode`\^^7f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^7f}\advance\count0 by1 +\catcode`\^^80=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^80}\advance\count0 by1 +\catcode`\^^81=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^81}\advance\count0 by1 +\catcode`\^^82=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^82}\advance\count0 by1 +\catcode`\^^83=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^83}\advance\count0 by1 +\catcode`\^^84=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^84}\advance\count0 by1 +\catcode`\^^85=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^85}\advance\count0 by1 +\catcode`\^^86=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^86}\advance\count0 by1 +\catcode`\^^87=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^87}\advance\count0 by1 +\catcode`\^^88=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^88}\advance\count0 by1 +\catcode`\^^89=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^89}\advance\count0 by1 +\catcode`\^^8a=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^8a}\advance\count0 by1 +\catcode`\^^8b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^8b}\advance\count0 by1 +\catcode`\^^8c=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^8c}\advance\count0 by1 +\catcode`\^^8d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^8d}\advance\count0 by1 +\catcode`\^^8e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^8e}\advance\count0 by1 +\catcode`\^^8f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^8f}\advance\count0 by1 +\catcode`\^^90=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^90}\advance\count0 by1 +\catcode`\^^91=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^91}\advance\count0 by1 +\catcode`\^^92=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^92}\advance\count0 by1 +\catcode`\^^93=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^93}\advance\count0 by1 +\catcode`\^^94=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^94}\advance\count0 by1 +\catcode`\^^95=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^95}\advance\count0 by1 +\catcode`\^^96=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^96}\advance\count0 by1 +\catcode`\^^97=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^97}\advance\count0 by1 +\catcode`\^^98=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^98}\advance\count0 by1 +\catcode`\^^99=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^99}\advance\count0 by1 +\catcode`\^^9a=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^9a}\advance\count0 by1 +\catcode`\^^9b=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^9b}\advance\count0 by1 +\catcode`\^^9c=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^9c}\advance\count0 by1 +\catcode`\^^9d=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^9d}\advance\count0 by1 +\catcode`\^^9e=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^9e}\advance\count0 by1 +\catcode`\^^9f=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^9f}\advance\count0 by1 +\catcode`\^^a0=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a0}\advance\count0 by1 +\catcode`\^^a1=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a1}\advance\count0 by1 +\catcode`\^^a2=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a2}\advance\count0 by1 +\catcode`\^^a3=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a3}\advance\count0 by1 +\catcode`\^^a4=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a4}\advance\count0 by1 +\catcode`\^^a5=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a5}\advance\count0 by1 +\catcode`\^^a6=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a6}\advance\count0 by1 +\catcode`\^^a7=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a7}\advance\count0 by1 +\catcode`\^^a8=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a8}\advance\count0 by1 +\catcode`\^^a9=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^a9}\advance\count0 by1 +\catcode`\^^aa=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^aa}\advance\count0 by1 +\catcode`\^^ab=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ab}\advance\count0 by1 +\catcode`\^^ac=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ac}\advance\count0 by1 +\catcode`\^^ad=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ad}\advance\count0 by1 +\catcode`\^^ae=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ae}\advance\count0 by1 +\catcode`\^^af=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^af}\advance\count0 by1 +\catcode`\^^b0=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b0}\advance\count0 by1 +\catcode`\^^b1=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b1}\advance\count0 by1 +\catcode`\^^b2=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b2}\advance\count0 by1 +\catcode`\^^b3=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b3}\advance\count0 by1 +\catcode`\^^b4=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b4}\advance\count0 by1 +\catcode`\^^b5=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b5}\advance\count0 by1 +\catcode`\^^b6=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b6}\advance\count0 by1 +\catcode`\^^b7=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b7}\advance\count0 by1 +\catcode`\^^b8=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b8}\advance\count0 by1 +\catcode`\^^b9=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^b9}\advance\count0 by1 +\catcode`\^^ba=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ba}\advance\count0 by1 +\catcode`\^^bb=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^bb}\advance\count0 by1 +\catcode`\^^bc=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^bc}\advance\count0 by1 +\catcode`\^^bd=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^bd}\advance\count0 by1 +\catcode`\^^be=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^be}\advance\count0 by1 +\catcode`\^^bf=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^bf}\advance\count0 by1 +\catcode`\^^c0=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c0}\advance\count0 by1 +\catcode`\^^c1=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c1}\advance\count0 by1 +\catcode`\^^c2=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c2}\advance\count0 by1 +\catcode`\^^c3=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c3}\advance\count0 by1 +\catcode`\^^c4=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c4}\advance\count0 by1 +\catcode`\^^c5=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c5}\advance\count0 by1 +\catcode`\^^c6=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c6}\advance\count0 by1 +\catcode`\^^c7=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c7}\advance\count0 by1 +\catcode`\^^c8=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c8}\advance\count0 by1 +\catcode`\^^c9=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^c9}\advance\count0 by1 +\catcode`\^^ca=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ca}\advance\count0 by1 +\catcode`\^^cb=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^cb}\advance\count0 by1 +\catcode`\^^cc=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^cc}\advance\count0 by1 +\catcode`\^^cd=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^cd}\advance\count0 by1 +\catcode`\^^ce=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ce}\advance\count0 by1 +\catcode`\^^cf=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^cf}\advance\count0 by1 +\catcode`\^^d0=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d0}\advance\count0 by1 +\catcode`\^^d1=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d1}\advance\count0 by1 +\catcode`\^^d2=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d2}\advance\count0 by1 +\catcode`\^^d3=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d3}\advance\count0 by1 +\catcode`\^^d4=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d4}\advance\count0 by1 +\catcode`\^^d5=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d5}\advance\count0 by1 +\catcode`\^^d6=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d6}\advance\count0 by1 +\catcode`\^^d7=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d7}\advance\count0 by1 +\catcode`\^^d8=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d8}\advance\count0 by1 +\catcode`\^^d9=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^d9}\advance\count0 by1 +\catcode`\^^da=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^da}\advance\count0 by1 +\catcode`\^^db=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^db}\advance\count0 by1 +\catcode`\^^dc=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^dc}\advance\count0 by1 +\catcode`\^^dd=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^dd}\advance\count0 by1 +\catcode`\^^de=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^de}\advance\count0 by1 +\catcode`\^^df=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^df}\advance\count0 by1 +\catcode`\^^e0=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e0}\advance\count0 by1 +\catcode`\^^e1=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e1}\advance\count0 by1 +\catcode`\^^e2=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e2}\advance\count0 by1 +\catcode`\^^e3=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e3}\advance\count0 by1 +\catcode`\^^e4=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e4}\advance\count0 by1 +\catcode`\^^e5=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e5}\advance\count0 by1 +\catcode`\^^e6=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e6}\advance\count0 by1 +\catcode`\^^e7=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e7}\advance\count0 by1 +\catcode`\^^e8=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e8}\advance\count0 by1 +\catcode`\^^e9=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^e9}\advance\count0 by1 +\catcode`\^^ea=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ea}\advance\count0 by1 +\catcode`\^^eb=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^eb}\advance\count0 by1 +\catcode`\^^ec=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ec}\advance\count0 by1 +\catcode`\^^ed=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ed}\advance\count0 by1 +\catcode`\^^ee=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ee}\advance\count0 by1 +\catcode`\^^ef=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ef}\advance\count0 by1 +\catcode`\^^f0=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f0}\advance\count0 by1 +\catcode`\^^f1=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f1}\advance\count0 by1 +\catcode`\^^f2=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f2}\advance\count0 by1 +\catcode`\^^f3=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f3}\advance\count0 by1 +\catcode`\^^f4=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f4}\advance\count0 by1 +\catcode`\^^f5=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f5}\advance\count0 by1 +\catcode`\^^f6=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f6}\advance\count0 by1 +\catcode`\^^f7=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f7}\advance\count0 by1 +\catcode`\^^f8=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f8}\advance\count0 by1 +\catcode`\^^f9=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^f9}\advance\count0 by1 +\catcode`\^^fa=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^fa}\advance\count0 by1 +\catcode`\^^fb=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^fb}\advance\count0 by1 +\catcode`\^^fc=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^fc}\advance\count0 by1 +\catcode`\^^fd=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^fd}\advance\count0 by1 +\catcode`\^^fe=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^fe}\advance\count0 by1 +\catcode`\^^ff=12 \expandafter\xdef\csname pgfp@bin@\the\count0 \endcsname{^^ff}\advance\count0 by1 +\ifnum\count0=256 +\else + \pgfplots@error{Internal logic Error: initialisation failed. I have only \the\count0\space bytes initialised.} +\fi +\endgroup + +% Returns a single character (with catcode 11 or 12), which has the +% binary code '#1'. +% +% #1 is a number between 0 and 255 (inclusive). +\def\pgfplotscharno#1{\csname pgfp@bin@#1\endcsname}% + + +\def\pgfplotsbinary@apphighorderbytes@BIGENDIAN#1{\xdef\pgfplotsbinaryresult{#1\pgfplotsbinaryresult}}% +\def\pgfplotsbinary@apphighorderbytes@LITTLEENDIAN#1{\xdef\pgfplotsbinaryresult{\pgfplotsbinaryresult#1}}% + +\def\pgfplotsbinaryencode@badic@unsigned@PAD@LITTLEENDIAN{% + % pad with zeros: + \ifcase\c@pgfplotsbin@byteno + % ok. + \or + % one byte missing. + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST}% + \or + % two bytes missing. + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO@HIGHEST}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO@HIGHEST}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO@HIGHEST}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO@HIGHEST}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO@HIGHEST}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO@HIGHEST}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO@HIGHEST}% + \else + \pgfplots@error{Sorry, I can't process byte no \the\c@pgfplotsbin@byteno... you may need to change bytes=\pgfplotsbinary@bytes.}% + \fi +}% +\def\pgfplotsbinaryencode@badic@unsigned@PAD@BIGENDIAN{% + % pad with zeros: + \ifcase\c@pgfplotsbin@byteno + % ok. + \or + % one byte missing. + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST}% + \or + % two bytes missing. + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST\pgfplotsbinary@ZERO}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO}% + \or + \pgfplotsbinary@apphighorderbytes{\pgfplotsbinary@ZERO@HIGHEST\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO}% + \else + \pgfplots@error{Sorry, I can't process byte no \the\c@pgfplotsbin@byteno... you may need to change bytes=\pgfplotsbinary@bytes.}% + \fi +}% + +\expandafter\def\csname pgfplotsbinarysetbytes@1\endcsname{% + \def\pgfplotsbinary@add@signed@largest@absolute{\advance\c@pgfplotsbin@input by 127 }% + \def\pgfplotsbinaryencodesignedmaplinearly@prepare{% + % warning: \pgfplotsbinary@bytes is NOT necessarily 1 (ASCII + % encoding features) + \c@pgfplotsbin@byteno=\pgfplotsbinary@bytes\relax + \c@pgfplotsbin@basis=\pgfplotsbinary@basis\relax + \divide\c@pgfplotsbin@input by16909320 % ~= (2^31-1) / (2^(8*1-1) -1) + }% +}% +\expandafter\def\csname pgfplotsbinarysetbytes@2\endcsname{% + \def\pgfplotsbinary@add@signed@largest@absolute{\advance\c@pgfplotsbin@input by 32767 }% + \def\pgfplotsbinaryencodesignedmaplinearly@prepare{% + \c@pgfplotsbin@byteno=\pgfplotsbinary@bytes\relax + \c@pgfplotsbin@basis=\pgfplotsbinary@basis\relax + \divide\c@pgfplotsbin@input by65538 % ~= (2^31-1) / (2^(8*2-1) -1) + }% +}% +\expandafter\def\csname pgfplotsbinarysetbytes@3\endcsname{% + \def\pgfplotsbinary@add@signed@largest@absolute{\advance\c@pgfplotsbin@input by 8388607 }% + \def\pgfplotsbinaryencodesignedmaplinearly@prepare{% + \c@pgfplotsbin@byteno=\pgfplotsbinary@bytes\relax + \c@pgfplotsbin@basis=\pgfplotsbinary@basis\relax + \divide\c@pgfplotsbin@input by256 % ~= (2^31-1) / (2^(8*3-1) -1) + }% +}% +\expandafter\def\csname pgfplotsbinarysetbytes@4\endcsname{% + \def\pgfplotsbinary@add@signed@largest@absolute{% + \advance\c@pgfplotsbin@input by 2147483647 % this is the *absolute* largest int that TeX can handle. + }% + \def\pgfplotsbinaryencodesignedmaplinearly@prepare{% + \c@pgfplotsbin@byteno=\pgfplotsbinary@bytes\relax + \c@pgfplotsbin@basis=\pgfplotsbinary@basis\relax + }% +}% +\def\pgfplotsbinarysetbytes@@{% + \def\pgfplotsbinaryencodesignedmaplinearly@prepare{% + \c@pgfplotsbin@byteno=\pgfplotsbinary@bytes\relax + \c@pgfplotsbin@basis=\pgfplotsbinary@basis\relax + \pgfplots@error{Sorry, but I can't perform \string\pgfplotsbinaryencodesignedmaplinearly\space for bytes=\pgfplotsbinary@bytes\space yet... bytes=4 is the maximum.}% + }% + \def\pgfplotsbinary@add@signed@largest@absolute{ + \advance\c@pgfplotsbin@input by 2147483647 + }% +}% +\expandafter\let\csname pgfplotsbinary@bytes@5\endcsname=\pgfplotsbinarysetbytes@@ +\expandafter\let\csname pgfplotsbinary@bytes@6\endcsname=\pgfplotsbinarysetbytes@@ +\expandafter\let\csname pgfplotsbinary@bytes@7\endcsname=\pgfplotsbinarysetbytes@@ +\expandafter\let\csname pgfplotsbinary@bytes@8\endcsname=\pgfplotsbinarysetbytes@@ + +\pgfqkeys{/pgfplots/bin}{% + % ordering not yet implemented; uses always BIG ENDIAN. + ordering/.is choice,% + ordering/big endian/.code={% + \def\pgfplotsbinary@byteorder{0}% + \let\pgfplotsbinary@apphighorderbytes=\pgfplotsbinary@apphighorderbytes@BIGENDIAN + \let\pgfplotsbinaryencode@badic@unsigned@PAD=\pgfplotsbinaryencode@badic@unsigned@PAD@BIGENDIAN + },% + ordering/net/.style={/pgfplots/bin/ordering/big endian},% + ordering/little endian/.code={% + \def\pgfplotsbinary@byteorder{1}% + \let\pgfplotsbinary@apphighorderbytes=\pgfplotsbinary@apphighorderbytes@LITTLEENDIAN + \let\pgfplotsbinaryencode@badic@unsigned@PAD=\pgfplotsbinaryencode@badic@unsigned@PAD@LITTLEENDIAN + }, + ordering/big endian,% + % + % The standard method - it results in binary encoded numbers. + binary encoding/.code={% + \expandafter\let\expandafter\pgfplotsbinary@ZERO\csname pgfp@bin@0\endcsname + \expandafter\let\expandafter\pgfplotsbinary@ZERO@LINEARMAP\csname pgfp@bin@128\endcsname + \let\pgfplotsbinary@ZERO@HIGHEST=\pgfplotsbinary@ZERO + \def\pgfplotsbinary@basis{256}% + \let\pgfplotsbinary@hook=\relax + \def\pgfplotsbinary@hook@signed@linearmap{% + \ifnum\c@pgfplotsbin@byteno=0 + \advance\c@pgfplotsbin@input by128 + \ifnum\c@pgfplotsbin@input>255 + \pgfplots@error{Sorry, there are not enough bytes to store the current number. I tried to write \the\c@pgfplotsbin@input...}% + \fi + \fi + }% + \def\pgfplotsbinarysetbytes##1{% + \pgfutil@ifundefined{pgfplotsbinarysetbytes@##1}{% + \pgfplots@error{Sorry, I can't write binary output with '##1' bytes yet...}% + }{% + \edef\pgfplotsbinary@bytes{##1}% + \csname pgfplotsbinarysetbytes@##1\endcsname + }% + }% + },% + % + % This applies 'binary encoding' and encodes the resulting bytes + % in Hex. It corresponds to the ASCIIHexEncode in postscript or + % pdf. + % Please note that 'bytes' sets the number of binary bytes - the + % actual encoding length is exactly twice as large. + ASCIIHexEncode/.code={% + \expandafter\let\expandafter\pgfplotsbinary@ZERO\csname pgfp@bin@48\endcsname + \expandafter\let\expandafter\pgfplotsbinary@ZERO@LINEARMAP\csname pgfp@bin@56\endcsname + \let\pgfplotsbinary@ZERO@HIGHEST=\pgfplotsbinary@ZERO + \pgfkeysalso{/pgfplots/bin/ordering/big endian}% + \def\pgfplotsbinary@basis{16}% + \def\pgfplotsbinary@hook@hex{% + \ifnum\c@pgfplotsbin@input<10 + \advance\c@pgfplotsbin@input by48 + \else + \advance\c@pgfplotsbin@input by55 + \fi + }% + \let\pgfplotsbinary@hook=\pgfplotsbinary@hook@hex + \def\pgfplotsbinary@hook@signed@linearmap{% + \ifnum\c@pgfplotsbin@byteno=0 + \advance\c@pgfplotsbin@input by8 + \ifnum\c@pgfplotsbin@input>16 + \pgfplots@error{Sorry, there are not enough bytes to store the current number. I tried to write \the\c@pgfplotsbin@input...}% + \fi + \fi + \pgfplotsbinary@hook@hex + }% + \def\pgfplotsbinarysetbytes##1{% + \pgfutil@ifundefined{pgfplotsbinarysetbytes@##1}{% + \pgfplots@error{Sorry, I can't write binary output with '##1' bytes yet...}% + }{% + \csname pgfplotsbinarysetbytes@##1\endcsname + \begingroup + \count0=##1\relax + \multiply\count0 by2 + \xdef\pgfplotsbinary@glob@TMP{\the\count0 }% + \endgroup + \let\pgfplotsbinary@bytes=\pgfplotsbinary@glob@TMP + }% + }% + },% + % + % + % This applies 'binary encoding' and encodes the resulting bytes + % using a base 85 encoding. It corresponds to the ASCII85Encode in postscript or + % pdf. + % Handle this method with care - it works just for ONE number, not for a stream of + % numbers as in pdf. Therefore, it might not be useful at all. + % Please note that 'bytes' will be ignored; ASCII85Encode assumes + % 4 binary bytes and uses 5 bytes to encode them. + % + % @ATTENTION bytes is ALWAYS 4, regardless of the setting of + % 'bytes'! + ASCII85Encode/.code={% + \expandafter\let\expandafter\pgfplotsbinary@ZERO\csname pgfp@bin@33\endcsname + \expandafter\let\expandafter\pgfplotsbinary@ZERO@LINEARMAP\csname pgfp@bin@42\endcsname + \let\pgfplotsbinary@ZERO@HIGHEST=\pgfplotsbinary@ZERO + \pgfkeysalso{/pgfplots/bin/ordering/big endian}% + \edef\pgfplotsbinary@ASCII@specialzero{\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO\pgfplotsbinary@ZERO}% + \expandafter\def\expandafter\pgfplotsbinaryencode@badic@unsigned@PAD\expandafter{% + \pgfplotsbinaryencode@badic@unsigned@PAD + \ifx\pgfplotsbinaryresult\pgfplotsbinary@ASCII@specialzero + % PDF standard: 0 is encoded as 'z': + \gdef\pgfplotsbinaryresult{z}% + \fi + }% + \def\pgfplotsbinary@basis{85}% + \def\pgfplotsbinary@hook{% + \advance\c@pgfplotsbin@input by33 + }% + \def\pgfplotsbinary@hook@signed@linearmap{% + \advance\c@pgfplotsbin@input by33 + \ifnum\c@pgfplotsbin@byteno=0 + \advance\c@pgfplotsbin@input by42 + \ifnum\c@pgfplotsbin@input>85 + \pgfplots@error{Sorry, there are not enough bytes to store the current number. I tried to write \the\c@pgfplotsbin@input...}% + \fi + \fi + }% + % I know, that does only work efficiently if bytes=4 for every + % encoded number. + \def\pgfplotsbinarysetbytes##1{% + \def\pgfplotsbinary@bytes{5}% + \csname pgfplotsbinarysetbytes@4\endcsname + }% + \pgfplotsbinarysetbytes4% + },% + binary encoding,% + % + bytes/.code={\pgfplotsbinarysetbytes{#1}},% + bytes=4, + % + % Irreversibly change to VERBATIM output for debugging: + debug mode/.code={% + \let\pgfplotsbinary@apphighorderbytes@ORIG=\pgfplotsbinary@apphighorderbytes + \def\pgfplotsbinary@ZERO{[Pad-0]}% + \let\pgfplotsbinary@ZERO@HIGHEST=\pgfplotsbinary@ZERO + \def\pgfplotsbinary@ZERO@LINEARMAP{[Pad-128]}% + \def\pgfplotsbinary@apphighorderbytes##1{% + \pgfutil@ifnextchar\csname{% + \pgfplotsbinary@apphighorderbytes@DEBUG@csname + }{% + \pgfplotsbinary@apphighorderbytes@DEBUG@normal + }% + ##1\relax + }% + },% + % Write pdf objects in binary form. This does only work with + % pdftex, and its output is only useful in conjunction with + % \pdfcompresslevel=0 + % and a text editor. + % Usage: + % \pgfkeys{/pgfplots/bin/debug to pdf={\pgfplotsbinaryencodeunsigned}{1,2,3,...,16}} + % + % works only with pdftex + debug to pdf/.code 2 args={% + \foreach \num in {#2} {% + #1{\num}% + \immediate \pdfobj stream attr { + /Decimal \num\space + /Routine (\string#1) + } {% + \pgfplotsbinaryresult + }% + }% + },% +} + + + +\def\pgfplotsbinary@apphighorderbytes@DEBUG@csname \csname pgfp@bin@#1\endcsname\relax{% + \pgfplotsbinary@apphighorderbytes@ORIG{[#1]}% +}% +\def\pgfplotsbinary@apphighorderbytes@DEBUG@normal#1\relax{% + \pgfplotsbinary@apphighorderbytes@ORIG{#1}% +}% + +%\pgfkeys{/pgfplots/bin/debug mode} + + +\countdef\c@pgfplotsbin@input=0 +\countdef\c@pgfplotsbin@tmpa=1 +\countdef\c@pgfplotsbin@tmpb=2 +\countdef\c@pgfplotsbin@byteno=3 +\countdef\c@pgfplotsbin@basis=4 +\def\pgfplotsbinaryempty{} + +%-------------------------------------------------- +% input: unsigned int x, b, n; +% output: unsigned int y[n]; +% for (i=0; i<n; i++) y[i] = 0; +% i=0; +% while (x > 0) +% { y[i] = x % b; /* entspricht x mod b */ +% x = x / b; /* ganzzahlige Division */ +% i++; +% } +%-------------------------------------------------- +% with x = #1 +% b = basis +% will store stuff into \pgfplotsbinaryresult in binary format +% +% PRECONDITION: +% - \pgfplotsbinaryresult= empty! +% - \c@pgfplotsbin@byteno=\pgfplotsbinary@bytes +\def\pgfplotsbinaryencode@badic@unsigned@{% + \ifnum\c@pgfplotsbin@input>0 + \c@pgfplotsbin@tmpa=\c@pgfplotsbin@input + \divide\c@pgfplotsbin@tmpa by\c@pgfplotsbin@basis\relax + \c@pgfplotsbin@tmpb=\c@pgfplotsbin@tmpa\relax + \multiply\c@pgfplotsbin@tmpa by\c@pgfplotsbin@basis\relax + \advance\c@pgfplotsbin@input by -\c@pgfplotsbin@tmpa\relax + \advance\c@pgfplotsbin@byteno by-1 + \pgfplotsbinary@hook% hooks for modifications. + \pgfplotsbinary@apphighorderbytes{\csname pgfp@bin@\the\c@pgfplotsbin@input\endcsname}% + \c@pgfplotsbin@input=\c@pgfplotsbin@tmpb +%\message{RESULT SO FAR byte no \the\c@pgfplotsbin@byteno: \pgfplotsbinaryresult}% + \expandafter\pgfplotsbinaryencode@badic@unsigned@ + \else + \pgfplotsbinaryencode@badic@unsigned@PAD +%\message{RESULT SO FAR byte no \the\c@pgfplotsbin@byteno: \pgfplotsbinaryresult}% + \fi +}% + + +% Defines \pgfplotsbinaryresult to be the binary representation of an +% unsigned integer. +% +% The representation will use unsigned dual number representation. +% +% The assignment to \pgfplotsbinaryresult will be globally. +% #1: an unsigned integer. It won't be transformed in any way, so make +% sure it fits into the configured number of bytes. It is an error if +% the number is too large or too small. Please note that only unsigned +% numbers are supported with this method. +% +% FIXME : fix > 2^30 +\def\pgfplotsbinaryencodeunsigned#1{% + \begingroup + \global\let\pgfplotsbinaryresult=\pgfplotsbinaryempty + \c@pgfplotsbin@input=#1 % + \c@pgfplotsbin@byteno=\pgfplotsbinary@bytes\relax + \c@pgfplotsbin@basis=\pgfplotsbinary@basis\relax + \pgfplotsbinaryencode@badic@unsigned@% + \endgroup +}% + +% An implementation for signed integers which maps the signed integer linearly into +% the unsigned data range before it proceeds. +% +% The idea is thus, to first introduce a linear mapping +% +% phi : [- smallest_possible, +largest_possible ] -> [0, 256^bytes-1 ] +% +% A signed integer in TeX is in [ - (2^31-1), 2^31-1 ]. +% Thus, we should map +% +% phi : [ -(2^31-1), 2^31-1 ] -> [ 0, 2^32-1 ]. +% +% A simpler case is to employ the symmetry in TeX's registers and +% leave one out, i.e. to map to 2^32-2: +% +% phi : [ -(2^31-1), 2^31-1 ] -> [ 0, 2^32-2 ]. +% +% Then, +% +% phi(x) = ( x + 2^31 -1 ) / (2^31-1 + 2^31-1) * (2^32-2) = x+ 2^31-1. +% +% The same map phi(x) = x + 2^31 -1 with target space [0, 2^32-1 ] +% could be realized with the input space [- (2^31-1), 2^31 ]. +% +% I am using this encoding procedure, phi(x) = x + 2^31 -1. +% +% As a consequence, the binary pattern FF FF FF FF does never occur as +% result of the mapping. +% +% To invert the mapping (i.e. to decode the result), set up the unique +% linear map +% +% psi : [ 0, 2^32-1 ] -> [ -(2^31-1), 2^31 ]. +% +% Then, psi( phi(x) ) = x and the decoding procedure is correct. +% +% This doesn't need TeX register arithmetics on the whole range. +% +% REMARK: the whole operation does also work if bytes<4 (i.e. we have +% less than 32 bits in the target range). In this case, the mapping is +% phi : [ -(2^31-1), 2^31-1 ] -> [ 0, 2^{8*bytes}-1 ] +% and a further, *lossy* quantization still will be applied. The +% quantization step is an integer division performed in signed number +% arithmetics (i.e. it is symmetric around 0). +\def\pgfplotsbinaryencodesignedmaplinearly#1{% + \begingroup + \global\let\pgfplotsbinaryresult=\pgfplotsbinaryempty + \c@pgfplotsbin@input=#1 % + \pgfplotsbinaryencodesignedmaplinearly@prepare + \ifnum\c@pgfplotsbin@input<0 + % compute + 2^31 - 1 + \pgfplotsbinary@add@signed@largest@absolute + \else + % change zero padding such that positive numbers + % get the EFFECT of + 2^31. + \let\pgfplotsbinary@ZERO@HIGHEST=\pgfplotsbinary@ZERO@LINEARMAP + \let\pgfplotsbinary@hook=\pgfplotsbinary@hook@signed@linearmap + % and compute the -1 explicitly here: + \advance\c@pgfplotsbin@input by-1 + \fi + \pgfplotsbinaryencode@badic@unsigned@% + \endgroup +}% + +% Encodes a dimen (like 1pt or \dimen0) in binary form. +% +% The encoding works by mapping #1 linearly into the allowed integer +% range using a quantization technique to respect the (possibly) +% restricted number of bytes. +% +% The implementation is fast and uses only integer arithmetics. +% It relies on \pgfplotsbinaryencodesignedmaplinearly and a scale. +% +% So, what we do is to setup a linear map into binary range with k +% bytes. The range of a TeX dimen is precisely (in units of pt) +% [ -(2^30-1) / 2^16, (2^30 -1) / 2^16 ] = [-16383.99998, 16383.99998] +% +% Thus, for an input dimen x, we set up the mapping +% phi(x) = 2^16 * x * 2 +% which maps +% phi: [ -(2^30-1) / 2^16, (2^30-1) / 2^16 ] -> [-(2^31 -2), 2^31-2]. +% +% I simply use the \pgfplotsbinaryencodesignedmaplinearly to process +% this further. To simplify the computation, I simply compute +% phi_signed( phi(x) ), +% where phi_signed denotes an application of +% \pgfplotsbinaryencodesignedmaplinearly: +% phi_signed( y ) = y +2^31 -1, +% phi_signed( phi(x) ) = 2^16 * 2 * x + 2^31 - 1. +% This is NOT a linear map to [0,2^32-1] as promised. +% But, we can setup an inverse transformation PHI (which is linear) anyway +% such that +% PHI( phi_signed(phi(x)) ) = x +% and that's all I want. Do do that, we use the unique linear decoder map +% PHI : [ 0,2^32-1 ] -> [ -16383.999992, 16384 ]. +% +% This is not exacty the input range of before, but using it results +% in a proper decoder. The difference is due to the non-unique zero +% representation in TeX's arithmetics. +% +% +% REMARK: the whole operation does also work if bytes<4 (i.e. we have +% less than 32 bits in the target range). In this case, a further +% *lossy* quantization step is applied in phi_signed. The inverse +% transformations are the same, however. See +% \pgfplotsbinaryencodesignedmaplinearly for details about the +% quantization step (or try it out). +% + % + %% DEBUG NOTE: This mapping appears to work correctly according to + %% my tests. + %% For bc -l test codes: + %% ibase=16; + %% -4000 + 809658FA. / (2^20) * 8000 +\def\pgfplotsbinaryencodedimenmaplinearly#1{% + \begingroup + \dimen0=#1\relax + \c@pgfplotsbin@input=\dimen0 + \multiply\c@pgfplotsbin@input by2 +%\message{LOWLEVEL ENCODING '\the\c@pgfplotsbin@input' with linear map}% + \pgfplotsbinaryencodesignedmaplinearly\c@pgfplotsbin@input + \endgroup +}% + +\catcode`\@=\pgfplotsbinaryatcode +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex index f92bde8428f..290fbfe9292 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex @@ -1,5 +1,5 @@ %-------------------------------------------- -% $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/util/pgfplotscolormap.code.tex,v 1.10 2009/02/13 21:00:47 ludewich Exp $ +% $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/util/pgfplotscolormap.code.tex,v 1.15 2009/07/21 18:18:48 ludewich Exp $ % % Package pgfplots % @@ -28,32 +28,43 @@ % This package relies on pgfplots temporary registers and its array % data structure. +% Internal structure: +% the colormap data structure consists of +% - an array 'pgfpl@cm@#1' of RGB color triples, +% - numbers 'pgfpl@cm@#1@h' and 'pgfpl@cm@#1@invh' for the mesh width +% and inverse mesh width. % Creates a new colormap. % % #1 : the name of the color map as string (not as macro). -% #2 : a <color specification> as is expected for a colormap. +% #2 : a <color specification> as is expected for a shading spec of +% pgf. However, the format allows a little bit more freedom: +% - it supports 'rgb255' in addition to pgf, +% - the length is not required (defaults to 1cm for the first and to +% the last length+h for all others). +% - the semicolons can be omitted. % -% Example: \pgfplots@createcolormap{my map}{rgb(0cm)=(1,0,0); rgb(1cm)=(0,1,0); rgb255(1.5cm)=(128,5,255); rgb(2cm)=(0,0,1); gray(3cm)=(3); color(4cm)=(green); } -\def\pgfplotscreatecolormap#{% - \pgfplots@createcolormap -} +% Example: +% \pgfplotscreatecolormap{my map}{rgb(0cm)=(1,0,0); rgb(1cm)=(0,1,0); rgb255(1.5cm)=(128,5,255); rgb(2cm)=(0,0,1); gray(3cm)=(3); color(4cm)=(green); } +% \pgfplotscreatecolormap{my map}{color=(green); color=(red); color=(blue); color=(yellow)} +\def\pgfplotscreatecolormap#{\pgfplots@createcolormap}% \def\pgfplots@createcolormap#1#2{% \edef\pgfplots@createcolormap@name{pgfpl@cm@#1}% \expandafter\pgfplotsarraynewempty\expandafter{\pgfplots@createcolormap@name}% \def\pgfplots@createcolormap@MIN{0}% NORMALIZATION: assume that lower-end is 0pt. - \let\pgfplots@createcolormap@H=\pgfutil@empty \def\pgfplots@createcolormap@MAX{0}% To be computed. \let\pgfplots@createcolormap@LAST=\pgfplots@createcolormap@MIN % PARSE IT: - \pgfplots@createcolormap@#2] + \edef\pgfplots@loc@TMPa{#2}% + % this does also init @H: + \expandafter\pgfplots@createcolormap@startloop\pgfplots@loc@TMPa\pgfplots@EOI \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}% % sanity checking: \expandafter\pgfplotsarraysizetomacro\expandafter{\pgfplots@createcolormap@name}\to\pgfplots@loc@TMPa \ifcase\pgfplots@loc@TMPa\relax - \pgfplots@error{Sorry, you need to provide at least the two end points of a colormap.}% + \pgfplots@error{Sorry, you need to provide at least two points of a colormap.}% \or - \pgfplots@error{Sorry, you need to provide at least the two end points of a colormap.}% + \pgfplots@error{Sorry, you need to provide at least two points of a colormap.}% \fi % Map the input range [0pt,MAX] linearly to [0,1000] \pgfmathdivide@{\pgfplotscolormaprange}{\pgfplots@createcolormap@MAX}% @@ -65,8 +76,22 @@ \expandafter\let\csname\pgfplots@createcolormap@name @invh\endcsname=\pgfmathresult %\pgfplots@colormap@showdebuginfofor{#1}% } +\def\pgfplots@createcolormap@seth[#1]{% + \pgfmathparse{#1}% + \let\pgfplots@createcolormap@H=\pgfmathresult + \pgfplots@createcolormap@ +}% + +\def\pgfplots@createcolormap@startloop{% + \pgfutil@ifnextchar[% + {\pgfplots@createcolormap@seth}% + {% + \let\pgfplots@createcolormap@H=\pgfutil@empty + \pgfplots@createcolormap@ + }% +}% \def\pgfplots@createcolormap@{% - \pgfutil@ifnextchar]{\pgfutil@gobble}%done! + \pgfutil@ifnextchar\pgfplots@EOI{\pgfutil@gobble}%done! {% \pgfutil@ifnextchar;{\pgfplots@createcolormap@grabsemicolon}% {% @@ -87,15 +112,38 @@ \def\pgfplots@createcolormap@grabsemicolon;{\pgfplots@createcolormap@}% { - \catcode`\;=\active + \catcode`\;=13 \gdef\pgfplots@createcolormap@grabsemicolon@active;{\pgfplots@createcolormap@}% } +\def\pgfplots@createcolormap@next{% + \pgfutil@ifnextchar({% + \pgfplots@createcolormap@next@ + }{% + % determine next step size automatically: + \ifx\pgfplots@createcolormap@H\pgfutil@empty + \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}% + \ifpgfplotsarrayempty + % first: + \def\pgfmathresult{0sp}% + \else + % second: + \def\pgfmathresult{1cm}% + \fi + \else + % not first: + \pgfmathadd@\pgfplots@createcolormap@LAST\pgfplots@createcolormap@H + \fi + \expandafter\pgfplots@createcolormap@next@\expandafter(\pgfmathresult)% + }% +}% + \def\pgfplots@createcolormap@grabrgb rgb{ \pgfutil@ifnextchar2{% \pgfplots@createcolormap@grabrgb@two@five@five }{% - \pgfplots@createcolormap@grabrgb@ + \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabrgb@ + \pgfplots@createcolormap@next }% } \def\pgfplots@createcolormap@grabrgb@(#1)=(#2,#3,#4){% @@ -104,7 +152,11 @@ \def\pgfplots@createcolormap@grabrgb@two@five@five@rescale#1{% \pgfmath@basic@multiply@{0.003921568}{#1}% }% -\def\pgfplots@createcolormap@grabrgb@two@five@five255(#1)=(#2,#3,#4){% +\def\pgfplots@createcolormap@grabrgb@two@five@five255{% + \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabrgb@two@five@five@ + \pgfplots@createcolormap@next +} +\def\pgfplots@createcolormap@grabrgb@two@five@five@(#1)=(#2,#3,#4){% \pgfplots@createcolormap@grabrgb@two@five@five@rescale{#2}% \let\pgfplots@loc@TMPa=\pgfmathresult \pgfplots@createcolormap@grabrgb@two@five@five@rescale{#3}% @@ -114,15 +166,23 @@ \edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfmathresult}}% \expandafter\pgfplots@loc@TMPc\pgfplots@loc@TMPa \pgfplots@createcolormap@} -\def\pgfplots@createcolormap@grabgray gray(#1)=(#2){% +\def\pgfplots@createcolormap@grabgray gray{% + \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabgray@ + \pgfplots@createcolormap@next +}% +\def\pgfplots@createcolormap@grabgray@(#1)=(#2){% \pgfplots@createcolormap@nextRGB{#1}{#2}{#2}{#2}% \pgfplots@createcolormap@} -\def\pgfplots@createcolormap@grabcolor color(#1)=(#2){% +\def\pgfplots@createcolormap@grabcolor color{% + \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabcolor@ + \pgfplots@createcolormap@next +}% +\def\pgfplots@createcolormap@grabcolor@(#1)=(#2){% \pgfutil@colorlet{pgf@tempcol}{#2}% \pgfutil@extractcolorspec{pgf@tempcol}{\pgf@tempcolor}% \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}% - \expandafter\pgfplots@createcolormap@grabcolor@\pgf@rgbcolor\relax{#1}}% -\def\pgfplots@createcolormap@grabcolor@#1,#2,#3\relax#4{% + \expandafter\pgfplots@createcolormap@grabcolor@@\pgf@rgbcolor\relax{#1}}% +\def\pgfplots@createcolormap@grabcolor@@#1,#2,#3\relax#4{% \pgfplots@createcolormap@nextRGB{#4}{#1}{#2}{#3}% \pgfplots@createcolormap@} \def\pgfplots@createcolormap@rgbrangeexception#1#2#3{% @@ -150,7 +210,7 @@ \ifdim#4pt>1pt \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}% \fi - % Process 'h': + % compute 'h': \pgfmathparse{#1}% \let\pgfplots@createcolormap@MAX=\pgfmathresult \expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@createcolormap@LAST}% @@ -173,13 +233,58 @@ \pgfmathapproxequalto@{\pgfplots@createcolormap@H}{\pgfplots@createcolormap@H@cur}% \ifpgfmathcomparison \else - \pgfplots@error{Sorry, non-uniform colormaps are not yet implemented. Please maintain a uniform distance before offset #1 (in this case, I expected h = \pgfplots@createcolormap@H pt).}% + \pgfmathdivide@{\pgfplots@createcolormap@H@cur}{\pgfplots@createcolormap@H}% + % after this group, \pgfmathresult is + % - empty if no reinterpolation is possible, + % - non-empty if reinterpolation IS possible. In this + % case, it contains the integer multiple of H. + \begingroup + \afterassignment\pgfplots@createcolormap@nextRGB@consider@reinterpolation + \c@pgf@counta=\pgfmathresult\relax + \pgfmath@smuggleone\pgfmathresult + \endgroup + \if\pgfmathresult\pgfutil@empty + % I can't do that yet. + \pgfplots@error{Sorry, non-uniform colormaps are only partially implemented, yet: the provided points must be multiples of the mesh width h=\pgfplots@createcolormap@H pt. Perhaps it helps to provide the mesh widths as argument as in {<name>}{[1cm] <color arguments>}?}% + \else + \let\pgfplots@loc@TMPb=\pgfmathresult + % interpolate missing values using the already fixed H. + % This interpolation procedure is stupid because it works + % only in forward direction - but it works at least. + % For the backwards direction, you can provide the + % meshwidth explicitly at + % \pgfplotscreatecolormap[h]{}{} + \pgfplotsforeachungrouped \c@pgfplots@createcolormap in {1,2,...,\pgfplots@loc@TMPb} {% + \ifdim\c@pgfplots@createcolormap pt=\pgfplots@loc@TMPb pt + % omit the last. + \else + \pgfmathparse{\pgfplots@createcolormap@lastR + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #2 - \pgfplots@createcolormap@lastR )}% + \let\pgfplots@createcolormap@nextR=\pgfmathresult + \pgfmathparse{\pgfplots@createcolormap@lastG + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #3 - \pgfplots@createcolormap@lastG )}% + \let\pgfplots@createcolormap@nextG=\pgfmathresult + \pgfmathparse{\pgfplots@createcolormap@lastB + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #4 - \pgfplots@createcolormap@lastB )}% + % + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplotsarraypushback{\pgfplots@createcolormap@nextR,\pgfplots@createcolormap@nextG,\pgfmathresult}% + \noexpand\to}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}% + \fi + }% + \fi \fi \fi - % - % Append values: \def\pgfplots@loc@TMPa{\pgfplotsarraypushback{#2,#3,#4}\to}% \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}% + \edef\pgfplots@createcolormap@lastR{#2}% + \edef\pgfplots@createcolormap@lastG{#3}% + \edef\pgfplots@createcolormap@lastB{#4}% +}% +\def\pgfplots@createcolormap@nextRGB@consider@reinterpolation#1\relax{% + \ifdim#1pt<0.0005pt + \edef\pgfmathresult{\the\c@pgf@counta}% + \else + \let\pgfmathresult=\pgfutil@empty + \fi }% % Shows debug info about colormap #1 into the console. @@ -200,9 +305,111 @@ \endgroup } +% Copies the contents of the colormap named '#1' into a macro '#2'. +% Invocation of the macro will then re-create the colormap. +% +% #1: color map name +% #2: a macro name +\def\pgfplotscolormapserializetomacro#1#2{% + \begingroup + \pgfplotslistnewempty\pgfplots@serialize@list + \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\elem{% + \expandafter\pgfplotslistpushback\elem\to\pgfplots@serialize@list + }% + \toks0={\expandafter\def\csname pgfpl@cm@#1@h\endcsname}% + \toks1={\expandafter\def\csname pgfpl@cm@#1@invh\endcsname}% + \toks2={% + \pgfplotsarraynewempty{pgfpl@cm@#1}% + \pgfplotslistforeachungrouped\pgfplots@loc@TMPa\as\pgfplots@loc@TMPb{% + \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPb\to{pgfpl@cm@#1}% + }% + }% + \toks3=\expandafter{\pgfplots@serialize@list}% + \t@pgfplots@toka=\expandafter{\pgfplots@serialize@list}% + \xdef\pgfplots@glob@TMPa{% + \the\toks0 {\csname pgfpl@cm@#1@h\endcsname}% + \the\toks1 {\csname pgfpl@cm@#1@invh\endcsname}% + \noexpand\def\noexpand\pgfplots@loc@TMPa{\the\toks3 }% + \the\toks2 + }% + \endgroup + \let#2=\pgfplots@glob@TMPa +}% + +% this is a CONSTANT! Do NOT change it! +% Just read it -- just in case \pgfplotscolormaptopdffunction will use +% a different upper bound in the future. +\def\pgfplotscolormappdfmax{1}% + +% Writes a PDF function of /FunctionType 3 to \pgfplotsretval +% +% The /Domain argument will be set to [ 0 \pgfplotscolormappdfmax ] and bounds will be +% computed accordingly. +% +% #1: the colormap +\def\pgfplotscolormaptopdffunction#1{% + \begingroup + \gdef\pgfplotsretval{% + << + /FunctionType 3 + /Domain [0 \pgfplotscolormappdfmax] + % /Range [0 1 0 1 0 1] % INCOMPATIBLE WITH ACROBAT 6.0 ! + /Functions [ + }% + \c@pgf@counta=0 + \c@pgf@countb=\pgfplotsarraysizeof{pgfpl@cm@#1} % + \advance\c@pgf@countb by-1 + \def\pgfplots@loc@TMPa{}% + \def\pgfplots@loc@TMPb{}% + \def\pgfplots@loc@TMPc{}% + \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\cdata{% + \edef\cdata{\expandafter\pgfplotscolormaptopdffunction@convertcdata\cdata\relax}% + \ifnum\c@pgf@counta>0 + \t@pgfplots@toka=\expandafter{\pgfplotsretval}% + \xdef\pgfplotsretval{% + \the\t@pgfplots@toka + << + /FunctionType 2 + /Domain [0 \pgfplotscolormappdfmax] + /C0 [\pgfplots@loc@TMPa] /C1 [\cdata] /N 1 + >> + }% + \ifnum\c@pgf@counta<\c@pgf@countb\relax + \pgf@xa=\csname pgfpl@cm@#1@h\endcsname pt + \multiply\pgf@xa by\c@pgf@counta\relax + \divide\pgf@xa by1000 % we want [ 0 1 ] not [0 1000] as domain + \edef\pgfplots@loc@TMPb{\pgfplots@loc@TMPb\space \pgf@sys@tonumber\pgf@xa}% + \fi + \edef\pgfplots@loc@TMPc{\pgfplots@loc@TMPc\space 0 1}% + \fi + \let\pgfplots@loc@TMPa=\cdata + \advance\c@pgf@counta by1 + }% + \t@pgfplots@toka=\expandafter{\pgfplotsretval}% + \xdef\pgfplotsretval{% + \the\t@pgfplots@toka + ] + /Bounds [\pgfplots@loc@TMPb] + /Encode [\pgfplots@loc@TMPc] + >> + }% + \endgroup +}% +\def\pgfplotscolormaptopdffunction@convertcdata#1,#2,#3\relax{#1 #2 #3}% + % Invokes '#2' if a color map named '#1' exists and '#3' if no such color map exists. \def\pgfplotscolormapifdefined#1#2#3{\pgfplotsarrayifdefined{pgfpl@cm@#1}{#2}{#3}}% +\def\pgfplotscolormapassertexists#1{% + \pgfplotscolormapifdefined{#1}{}{% + \pgfutil@ifundefined{pgfplotscolormap@errorissued@#1}{% + \pgfplots@error{The colormap `#1' is undefined! Maybe you misspelled it?}% + }{}% + \expandafter\gdef\csname pgfplotscolormap@errorissued@#1\endcsname{1}% + \pgfplotscreatecolormap{#1}{color(0cm)=(blue); color(1cm)=(yellow)}% + }% +} + % Convert a colormap into a PGF shading's color specification for use % in \pgfdeclare*shading. % @@ -218,6 +425,7 @@ % % \pgfuseshading{myshadingA} \def\pgfplotscolormaptoshadingspec#1#2#3{% + \pgfplotscolormapassertexists{#1}% \begingroup \pgfmathparse{#2}% \expandafter\pgfmathdivide@\expandafter{\pgfmathresult}{\pgfplotscolormaprange}% @@ -226,12 +434,12 @@ \pgf@ya=\pgfmathresult pt \c@pgf@counta=0 \let#3=\pgfutil@empty - \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\pgfplots@loc@TMPa{% + \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\pgfplotscolormaptoshadingspec@TMP{% \ifnum\c@pgf@counta=0 - \edef\pgfplots@loc@TMPc{rgb(0pt)=(\pgfplots@loc@TMPa)}% + \edef\pgfplots@loc@TMPc{rgb(0pt)=(\pgfplotscolormaptoshadingspec@TMP)}% \else \pgf@yb=\c@pgf@counta\pgf@ya - \edef\pgfplots@loc@TMPc{rgb(\the\pgf@yb)=(\pgfplots@loc@TMPa)}% + \edef\pgfplots@loc@TMPc{rgb(\the\pgf@yb)=(\pgfplotscolormaptoshadingspec@TMP)}% \fi \ifx#3\pgfutil@empty \t@pgfplots@toka={}% @@ -246,6 +454,16 @@ \endgroup }% +% The same as \pgfplotscolormaptoshadingspec, but this here yields the +% *reversed* sequence. +\def\pgfplotscolormapreversedtoshadingspec#1#2#3{% + \begingroup + \let\pgfplotsarrayforeachungrouped=\pgfplotsarrayforeachreversedungrouped + \pgfplotscolormaptoshadingspec{#1}{#2}{#3}% + \pgfmath@smuggleone#3% + \endgroup +}% + % Expands to the transformed range's right end of every colormap. The left % end is fixed to '0'. @@ -275,6 +493,7 @@ }% }% \def\pgfplotscolormapfind@precomputed[#1:#2][#3]#4#5{% + \pgfplotscolormapassertexists{#5}% \begingroup % Step 0: compute #3 if it is missing and write it into % \pgfplots@loc@TMPa. @@ -286,12 +505,25 @@ \let\pgfplots@loc@TMPa=\pgfmathresult \fi %\message{mapping '#4' into colormap '#5' ... }% - % Step 1: perform lookup. Map #4 into the colormap's range - % using the linear trafo - % phi(#4) = ( #4 - #1 ) / (#2-#1) * colormaprange(#5). - % This, determine the INTERVAL number into which #4 falls. - \pgfmathsubtract@{#4}{#1}% - \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPa}% + \def\pgfplots@loc@samerange{0:1000}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@samerange + % we have phi(#4) = #4 because #4 in [0:1000]. + \def\pgfmathresult{#4}% + \else + % Step 1: perform lookup. Map #4 into the colormap's range + % using the linear trafo + % phi(#4) = ( #4 - #1 ) / (#2-#1) * colormaprange(#5). + % This, determine the INTERVAL number into which #4 falls. + \pgfmathsubtract@{#4}{#1}% + \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPa}% + \fi + \ifdim\pgfmathresult pt<0pt + \def\pgfmathresult{0}% + \else + \ifdim\pgfmathresult pt>1000pt + \def\pgfmathresult{1000}% + \fi + \fi \let\pgfplotscolormapfind@transformedx=\pgfmathresult \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\csname pgfpl@cm@#5@invh\endcsname}% \let\pgfplotscolormapfind@transformedx@divh=\pgfmathresult @@ -345,5 +577,68 @@ \edef\pgfmathresult{\RED,\GREEN,\BLUE}% }% +% Performs a direct color access into color map '#2' using an index +% '#1'. +% +% #1: an index in the range 0 ... len(#2)-1. +% If it does not match, it will be pruned. If #1 is a real number, it +% will be truncated. +% #2: a color map name. +% +% The resulting RGB value will be written to \pgfmathresult. +\def\pgfplotscolormapgetindex#1#2{% + \pgfplotscolormapassertexists{#2}% + \begingroup + \afterassignment\pgfplots@gobble@until@relax + \c@pgf@counta=#1\relax + \ifnum\c@pgf@counta<0 + \c@pgf@counta=0 + \else + \pgfplotsarraysizetomacro{pgfpl@cm@#2}\to\pgfplotscolormapgetindex@ + \ifnum\c@pgf@counta<\pgfplotscolormapgetindex@\relax + \else + \c@pgf@counta=\pgfplotscolormapgetindex@\relax + \advance\c@pgf@counta by-1 + \fi + \fi + \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#2}\to\pgfmathresult + \pgfmath@smuggleone\pgfmathresult + \endgroup +} +% Invokes either \pgfplotscolormapfind or \pgfplotscolormapgetindex, +% depending on the value of '/pgfplots/colormap access'. +\def\pgfplotscolormapaccess[#1:#2]{% + \pgfutil@ifnextchar[{% + \pgfplotscolormapaccess@precomputed[#1:#2]% + }{% + \pgfplotscolormapaccess@precomputed[#1:#2][]% + }% +} +\def\pgfplotscolormapaccess@precomputed[#1:#2][#3]#4#5{% + \if m\pgfplots@colormap@access + \pgfplotscolormapfind@precomputed[#1:#2][#3]{#4}{#5}% + \else + \pgfplotscolormapgetindex{#4}{#5}% + \fi +}% + +\pgfutil@definecolor{mapped color}{rgb}{0,0,0}% make sure this color exists. It will be overwritten if needed. \pgfplotscreatecolormap{hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)} + + +% Defines the 'mapped color' on the basis of +% the current color map. +% +% #1: is the value which should be mapped into the color map; it +% is expected in the range [0,1000] (like point meta). +\def\pgfplotscolormapdefinemappedcolor#1{% + \expandafter\pgfplotscolormapaccess\expandafter[\pgfplotspointmetatransformedrange] + [1.0] + {#1} + {\pgfkeysvalueof{/pgfplots/colormap name}} +%\message{Color for current point is RGB '\pgfmathresult' (determined using meta 'phi(\pgfplotspointmeta) = \pgfplotspointmetatransformed')}% + \def\pgfplots@loc@TMPb{\pgfutil@definecolor{mapped color}{rgb}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}% +}% + diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex index 68d640693cf..97260a1dae9 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex @@ -30,6 +30,9 @@ /pgfplots/use fpu=true, } +% only useful inside of \ifx (equals only itsself) +\def\pgfplots@EOI{\pgfplots@EOI}% + % Produces an \aftergroup statement for each single token in #1. % % ATTENTION: you *can't* use braces inside of '#1'! @@ -52,21 +55,11 @@ % Assigns list contents #2 to a list macro #1. % % The list contents may be provided in one of two formats: -% a) in the (deprecated) list format 'first\\second\\thirst\\' +% a) in the list format 'first\\second\\thirst\\' % or % b) in the PGF foreach list format 'first,second,third'. \def\pgfplots@assign@list#1#2{% - \def\pgfplots@TMP{#2}% - \ifx\pgfplots@TMP\pgfutil@empty - \pgfplotslistnewempty#1% - \else - \pgfplots@check@backwards@compatible@list@format #2\\\pgfplots@EOI - \ifpgfplots@is@old@list@format - \pgfplotslistnew#1{#2}% - \else - \pgfplots@foreach@to@list{#2}\to#1 - \fi - \fi + \pgfplotslistnew#1{#2}% }% % Sets the boolean \ifpgfplots@is@old@list@format to true if and only @@ -166,22 +159,45 @@ \def\pgfplots@command@to@string#1#2{% \expandafter\pgfplots@command@to@string@@\meaning#1\pgfplots@EOI{#2}% }% -{ -\let\CATCODE=\catcode -\CATCODE`\:=12 -\CATCODE`\-=12 -\CATCODE`\>=12 -\CATCODE`\m=12 -\CATCODE`\a=12 -\CATCODE`\c=12 -\CATCODE`\r=12 -\CATCODE`\o=12 -\xdef\pgfplts@glb@TMP{macro:->}% -} -\expandafter\def\expandafter\pgfplots@command@to@string@@\pgfplts@glb@TMP#1\pgfplots@EOI#2{% +\xdef\pgfplots@glob@TMPa{\meaning\pgfutil@empty}% +\expandafter\def\expandafter\pgfplots@command@to@string@@\pgfplots@glob@TMPa#1\pgfplots@EOI#2{% \def#2{#1}% }% +% Defines \pgfplotsretval to be '#1' but without leading and trailing +% spaces. +\def\pgfplotsutil@trim#1{% + \pgfkeys@spdef\pgfplotsretval{#1}% +}% + +% Invokes '#2' if the token(s) '#1' are actually are defined control +% sequence and '#3' if not. +% +% This method accepts different values '#1' than \pgfutil@ifundefined. +% It is indended to autodetect values provided in the user interface +% (ui), +% that means '#1' can be anything. But I still like to know whether it +% is a control sequence. +% +% \pgfplotsutil@ifdefinedui{\table} -> yes if \table is defined. +% \pgfplotsutil@ifdefinedui{\csname abc\endcsname} -> no +% \pgfplotsutil@ifdefinedui{a_file_name} -> no +\def\pgfplotsutil@ifdefinedui#1#2#3{% + \def\pgfplotsutil@@arg@ifdefined{#1}% + \pgfplots@command@to@string\pgfplotsutil@@arg@ifdefined\pgfplotsutil@@arg@ifdefined + \expandafter\pgfplotsutil@trim\expandafter{\pgfplotsutil@@arg@ifdefined}% + \pgfutil@ifundefined{\pgfplotsretval}{#3}{#2}% +}% +% The same as \pgfplotsutil@ifdefinedui but appends the suffix '#2' to +% '#1' after '#1' has been normalized. +% It invokes '#3' if '#1#2' is defined and '#4' if not. +\def\pgfplotsutil@ifdefinedui@withsuffix#1#2#3#4{% + \def\pgfplotsutil@@arg@ifdefined{#1}% + \pgfplots@command@to@string\pgfplotsutil@@arg@ifdefined\pgfplotsutil@@arg@ifdefined + \expandafter\pgfplotsutil@trim\expandafter{\pgfplotsutil@@arg@ifdefined}% + \pgfutil@ifundefined{\pgfplotsretval #2}{#4}{#3}% +}% + % Writes the command name of '#1' without the leading backslash to % macro #2. \def\pgfplotsutil@getcommandname#1#2{% @@ -210,6 +226,46 @@ \fi }% +% Executes '#2' if the number '#1' is zero and '#3' if not. +% Example: +% \pgfplotsmath@ifzero{0}{It's zero!}{It's not zero} +% \pgfplotsmath@ifzero{0.0}{It's zero!}{It's not zero} +% +% The argument must be assignable to a TeX dimension as 'pt', but +% without units. +\def\pgfplotsmath@ifzero#1#2#3{% + \begingroup + \pgf@xa=#1pt + \ifdim\pgf@xa=0pt + \gdef\pgfplots@glob@TMPa{#2}% + \else + \gdef\pgfplots@glob@TMPa{#3}% + \fi + \endgroup + \pgfplots@glob@TMPa +}% + +% Invokes code `#4' if |#1 - #2| <= #3 and `#5' if not. +% +% #1,#2 are dimension (registers or numbers) with unit. +% #3: absolute thresold (dimen) +\def\pgfplotsmath@ifapproxequal@dim#1#2#3#4#5{% + \begingroup + \pgf@xa=#1\relax + \pgf@xb=#2\relax + \advance\pgf@xa by-\pgf@xb + \ifdim\pgf@xa<0pt + \multiply\pgf@xa by-1 + \fi + \ifdim\pgf@xa>#3\relax + \gdef\pgfplots@glob@TMPa{#5}% + \else + \gdef\pgfplots@glob@TMPa{#4}% + \fi + \endgroup + \pgfplots@glob@TMPa +} + \def\pgfplotsmathmin#1#2{% \ifdim#1 pt<#2 pt \edef\pgfmathresult{#1}% @@ -274,6 +330,19 @@ \endgroup }% +% defines \pgf@x to be the scalar product between points #1 and #2 +% #1, #2 are pgfpoint commands +\def\pgfplotsscalarproductofvectors#1#2{% + \begingroup + \pgf@process{#1}% + \edef\pgfplots@scalarprod@a{\pgf@sys@tonumber\pgf@x}% + \edef\pgfplots@scalarprod@b{\pgf@sys@tonumber\pgf@y}% + \pgf@process{#2}% + \pgf@x=\pgfplots@scalarprod@a\pgf@x + \advance\pgf@x by\pgfplots@scalarprod@b\pgf@y + \global\pgf@x=\pgf@x + \endgroup +}% % converts a comma-separated list (PGF foreach) to my internal list % structure. @@ -287,14 +356,39 @@ \pgfplotslistcopy\pgfplots@glob@TMPa\to#2\relax } + +% Removes duplicates in a comma separated list and creates a new list +% into the macro \pgfplotsretval. The list doesn't need to be sorted, +% but it should not contain too much elements as the runtime for this +% simple method is quadratic. +% +% #1: a CSV list. +% Assigns \pgfplotsretval +\def\pgfplotsutil@unify@short@csv@list#1{% + \begingroup + \def\pgfplotsretval{}% + \pgfplotsutilforeachcommasep{#1}\as\pgfplots@unify@cur{% + \pgfutil@ifundefined{pgfp@unify@\pgfplots@unify@cur @@@}{% + \expandafter\def\csname pgfp@unify@\pgfplots@unify@cur @@@\endcsname{1}% + \ifx\pgfplotsretval\pgfutil@empty + \let\pgfplotsretval=\pgfplots@unify@cur% + \else + \t@pgfplots@toka=\expandafter{\pgfplotsretval}% + \t@pgfplots@tokb=\expandafter{\pgfplots@unify@cur}% + \edef\pgfplotsretval{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% + \fi + }{}% + }% + \pgfmath@smuggleone\pgfplotsretval + \endgroup +}% + % 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 + \pgfkeysvalueof{#1}#2\pgfeov } - % Usage: % \pgfplots@letcsname pgfplots@xtick={pgfplots@kram@x} % -> invokes \csname ... \endcsname for both args. @@ -324,19 +418,19 @@ % Takes a domain as input and generates a foreach argument which % samples from the domain. -% Writes the result to \pgfplotslocretval +% Writes the result to \pgfplotsretval % INPUT: % #1:#2 the domain -% /pgfplots/samples the number of samples +% #3: the number of samples % OUTPUT: -% \pgfplotslocretval a foreach specification. -\def\pgfplots@domain@to@foreach#1:#2\relax{% +% \pgfplotsretval a foreach specification. +\def\pgfplots@domain@to@foreach#1:#2\relax#3{% \pgfmathparse{#1}% \let\pgfplots@loc@TMPa=\pgfmathresult% \pgfmathparse{#2}% \let\pgfplots@loc@TMPb=\pgfmathresult% - \pgfmathparse{\pgfplots@loc@TMPa+(\pgfplots@loc@TMPb-\pgfplots@loc@TMPa)/(\pgfkeysvalueof{/pgfplots/samples}-1)}% - \edef\pgfplotslocretval{\pgfplots@loc@TMPa,\pgfmathresult,...,\pgfplots@loc@TMPb}% + \pgfmathparse{\pgfplots@loc@TMPa+(\pgfplots@loc@TMPb-\pgfplots@loc@TMPa)/(#3-1)}% + \edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfmathresult,...,\pgfplots@loc@TMPb}% } { @@ -366,15 +460,33 @@ }% }% +% Invokes '#3' for every element in the comma separated list '#1'. +% during '#3', the macro '#2' will be set to the current list element. +% +% In contrast to \foreach of tikz, this processing is NOT scoped by +% TeX groups. However, it can be nested. +% +% Please note that no trimming of white spaces is performed. +% +% This is the (accidentally) the same as \pgfplotsforeachentryinCSV. +\long\def\pgfplotsutilforeachcommasep#1\as#2#3{% + \pgfplotsforeachentryinCSVisterminated@loop{#2}{#3}#1,\pgfplots@EOI +}% % Usage: % \pgfplotsforeachentryinCSV{\value}{1,2,3,4.5,6.7,10}{The value is \value\par} % % The loop is ungrouped. +% +% This is the same as \pgfplotsutilforeachcommasep, I must have been +% sleeping somehow. +% +% @see \pgfplotsutilforeachcommasep +% @see \pgfplotsforeachentryinCSVisterminated +% @see \pgfplotsforeachungrouped +% This loop can be nested. \long\def\pgfplotsforeachentryinCSV#1#2#3{% - \def\pgfplotsforeachentryinCSV@{#1}% - \long\def\pgfplotsforeachentryinCSV@@{#3}% - \pgfplotsforeachentryinCSV@loop#2,\pgfplots@EOI + \pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2,\pgfplots@EOI }% % A variant of \pgfplotsforeachentryinCSV where a trailing comma % indicates the end of input. @@ -384,25 +496,32 @@ % ^ % % It is permissable to provide an empty list (without trailing comma) +% +% This loop can be nested. \long\def\pgfplotsforeachentryinCSVisterminated#1#2#3{% - \def\pgfplotsforeachentryinCSV@{#1}% - \long\def\pgfplotsforeachentryinCSV@@{#3}% - \pgfplotsforeachentryinCSV@loop#2\pgfplots@EOI + \pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2\pgfplots@EOI }% -\def\pgfplotsforeachentryinCSV@loop{% +% #1 : the loop macro +% #2 : the loop BODY +% #3 : the loop LIST +% (note the different sequence) +\long\def\pgfplotsforeachentryinCSVisterminated@loop#1#2{% \pgfutil@ifnextchar\pgfplots@EOI{% \pgfutil@gobble }{% - \pgfplotsforeachentryinCSV@next + \pgfplotsforeachentryinCSV@next{#1}{#2}% }% }% -\def\pgfplotsforeachentryinCSV@next#1,{% - \expandafter\def\pgfplotsforeachentryinCSV@{#1}% - \pgfplotsforeachentryinCSV@@ - \pgfplotsforeachentryinCSV@loop +\long\def\pgfplotsforeachentryinCSV@next#1#2#3,{% + \def#1{#3}% + #2\relax + \pgfplotsforeachentryinCSVisterminated@loop{#1}{#2}% }% +% Discards any token up to (and including) \relax. +\def\pgfplots@gobble@until@relax#1\relax{}% + % A (simple) replacement for \foreach which % 1. does NOT scope the argument % 2. allows to use PGF Math routines for loops ( '...' notation) @@ -412,102 +531,88 @@ % \pgfplotsforeachungrouped \x in {1,2,3,4,5} {<code>} % % Some details: -% - If #2 is a UNIFORM SAMPLING RANGE, the algorithm is supposed to be -% most effective. -% - If \pgfmathadd@ is the standard PGF math version of \pgfmathadd@, -% we use fast TeX dimensions for any loops. Otherwise, \pgfmathadd@ -% is used (assuming it has been replaced and should be used. +% 1. If #2 is a UNIFORM SAMPLING RANGE, the algorithm is supposed to be +% most effective. This is considered to be the case for the syntax +% \pgfplotsforeachungrouped \x in {1,2,...,8}. +% 2. If case (1.) is not used, \foreach \x in {#2} {} is invoked to +% generate a temporary list. Afterwards, this list is invoked without +% scopes. % +% This loop *can* be nested. \def\pgfplotsforeachungrouped#1{\pgfplotsforeachungrouped@{#1}}% \long\def\pgfplotsforeachungrouped@#1in #2#3{% \pgfplotsforeachungrouped@isuniform{#2}% \ifpgfplots@loc@tmp - \pgfplotsforeachungroupeduniform@#1{#2}{#3}% + \pgfplotsforeachungroupeduniform@{#1}#2\relax{#3}% \else \pgfplotsforeachungroupednonuniform@#1{#2}{#3}% \fi } \let\pgfplots@original@pgfmathadd@=\pgfmathadd@ -\long\def\pgfplotsforeachungroupeduniform@#1#2#3{% - \pgfplotsforeachungroupeduniform@@{#1}#2\relax{#3}% -} -\long\def\pgfplotsforeachungroupeduniform@@#1#2,#3,...,#4\relax#5{% +\long\def\pgfplotsforeachungroupeduniform@#1#2,#3,...,#4\relax#5{% % Compute mesh width! \pgfmathparse{#2}% \let\pgfplots@foreach@loc@TMPa=\pgfmathresult \pgfmathparse{#3}% \let\pgfplots@foreach@loc@TMPb=\pgfmathresult \pgfmathsubtract@{\pgfplots@foreach@loc@TMPb}{\pgfplots@foreach@loc@TMPa}% - \ifx\pgfmathadd@\pgfplots@original@pgfmathadd@ - % perform manual restoration of local variables: - \edef\pgfplots@foreach@loc@TMPd{% - \noexpand\pgf@xa=\the\pgf@xa\noexpand\relax - \noexpand\pgf@xb=\the\pgf@xb\noexpand\relax - \noexpand\pgf@ya=\the\pgf@ya\noexpand\relax - }% - % mesh width: - \pgf@ya=\pgfmathresult pt - % the loop will run while ( NOT <cur> \pgfplots@foreach@loc@cmp <last> ) - \ifdim\pgf@ya<0pt - \def\pgfplots@foreach@loc@cmp{<}% - \else - \def\pgfplots@foreach@loc@cmp{>}% - \fi - % - \pgfmathparse{#4}% - \let\pgfplots@foreach@loc@TMPb=\pgfmathresult - \pgf@xa=\pgfplots@foreach@loc@TMPa pt - \pgf@xb=\pgfplots@foreach@loc@TMPb pt - \long\def\pgfplots@foreach@loc@TMPc{#5}% - % - \pgfutil@loop - \ifdim\pgf@xa \pgfplots@foreach@loc@cmp \pgf@xb\relax - \pgfplots@loc@tmpfalse - \else - \pgfplots@loc@tmptrue - \fi - \ifpgfplots@loc@tmp - \edef#1{\pgf@sys@tonumber{\pgf@xa}}% - \pgfplots@foreach@loc@TMPc\relax - \advance\pgf@xa by\pgf@ya\relax - \pgfutil@repeat - % ok, restore them: - \pgfplots@foreach@loc@TMPd + % Use \pgfmath engine for the loop: + % mesh width: + \let\pgfplots@foreach@loc@meshwidth=\pgfmathresult + \pgfmathparse{0}% invoke the parser - in case the fpu is active. + \pgfmathlessthan@{\pgfplots@foreach@loc@meshwidth}{\pgfmathresult}% + % the loop will run while ( NOT \pgfplots@foreach@loc@cmp{<cur>}{<last>} ) + \ifdim\pgfmathresult pt=1pt + \def\pgfplots@foreach@loc@cmp{\pgfmathlessthan@}% \else - % Use \pgfmath engine for the loop: - \edef\pgfplots@foreach@loc@TMPd{% - \noexpand\pgf@xa=\the\pgf@xa\noexpand\relax - }% - % mesh width: - \let\pgfplots@foreach@loc@meshwidth=\pgfmathresult - \pgfmathparse{0}% invoke the parser - in case the fpu is active. - \pgfmathlessthan@{\pgfplots@foreach@loc@meshwidth}{\pgfmathresult}% - \pgf@xa=\pgfmathresult pt - % the loop will run while ( NOT \pgfplots@foreach@loc@cmp{<cur>}{<last>} ) - \ifdim\pgf@xa=1pt - \let\pgfplots@foreach@loc@cmp=\pgfmathlessthan@ + \def\pgfplots@foreach@loc@cmp{\pgfmathgreaterthan@}% + \fi + % + \pgfmathparse{#4 + 0.5*\pgfplots@foreach@loc@meshwidth}% + \let\pgfplots@foreach@loc@TMPb=\pgfmathresult + % + \t@pgfplots@toka={#5}% + % to allow nesting without additional TeX groups of + % \pgfplotsforeachungroupeduniform, I introduce this loop + % structure here which does not need ANY state macro: + \edef\pgfplots@foreach@loc@TMPc{% + \noexpand\pgfplotsforeachungroupeduniform@loop@mathengine + {\expandafter\noexpand\pgfplots@foreach@loc@cmp}% #1= comparison fct + {\pgfplots@foreach@loc@TMPa}% #2 =lower limit (ITERATES) + {\pgfplots@foreach@loc@TMPb}% #3 = upper limit + {\noexpand#1}% #4 = the loop macro name + {\pgfplots@foreach@loc@meshwidth}% #5 = h + {\the\t@pgfplots@toka}% #6 = the code to invoke + }% + \pgfplots@foreach@loc@TMPc +}% +\long\def\pgfplotsforeachungroupeduniform@loop@mathengine#1#2#3#4#5#6{% + #1{#2}{#3}% + \ifdim\pgfmathresult pt=0pt + \pgfutil@in@{.0\relax}{#2\relax}% + \ifpgfutil@in@ + \def\pgfplotsforeach@loc@TMP##1.0\relax{% + \def#4{##1}% + }% + \pgfplotsforeach@loc@TMP#2\relax \else - \let\pgfplots@foreach@loc@cmp=\pgfmathgreaterthan@ + \def#4{#2}% \fi - % - \pgfmathparse{#4}% - \let\pgfplots@foreach@loc@TMPb=\pgfmathresult - \long\def\pgfplots@foreach@loc@TMPc{#5}% - % - \pgfutil@loop - \pgfplots@foreach@loc@cmp{\pgfplots@foreach@loc@TMPa}{\pgfplots@foreach@loc@TMPb}% - \pgf@xa=\pgfmathresult pt - \ifdim\pgf@xa=0pt - \let#1=\pgfplots@foreach@loc@TMPa% - \pgfplots@foreach@loc@TMPc\relax - \pgfmathadd@{\pgfplots@foreach@loc@TMPa}{\pgfplots@foreach@loc@meshwidth}% - \let\pgfplots@foreach@loc@TMPa=\pgfmathresult - \pgfutil@repeat - % ok, restore them: - \pgfplots@foreach@loc@TMPd + #6\relax + \pgfmathadd@{#2}{#5}% + \t@pgfplots@toka={{#1}}% + \t@pgfplots@tokb=\expandafter{\pgfmathresult}% + \t@pgfplots@tokc={{#3}{#4}{#5}{#6}}% + % loop! + \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungroupeduniform@loop@mathengine + \the\t@pgfplots@toka + {\the\t@pgfplots@tokb}% + \the\t@pgfplots@tokc}% + \expandafter\pgfplots@loc@TMPa \fi }% + \long\def\pgfplotsforeachungroupednonuniform@#1#2#3{% \pgfplotsapplistXXglobalnewempty \foreach\pgfplots@foreach@loc@TMPa in {#2} {% @@ -521,7 +626,7 @@ }% } -% Sets \ifpgfplots@loc@tmp to something true if and only if '#1' is of the form +% Sets \ifpgfplots@loc@tmp to true if and only if '#1' is of the form % #1 = <number1>,<number2>,...,<number3>. \def\pgfplotsforeachungrouped@isuniform#1{% \edef\pgfplots@foreach@loc@TMPa{#1}% @@ -545,6 +650,41 @@ \fi }% +% A variant of \pgfplotsforeachungrouped ( or \foreach ) which +% *invokes* with #1 set to the current iterate. +% +% Example: +% \pgfplotsinvokeforeach{a,b,c,d} +% {\pgfkeys{key #1/.style={otherstyle #1}}} +% -> will invoke +% \pgfkeys{key a/.style={otherstyle a}} +% \pgfkeys{key b/.style={otherstyle b}} +% \pgfkeys{key c/.style={otherstyle c}} +% \pgfkeys{key d/.style={otherstyle d}} +% Note that \pgfplotsforeachungrouped \d in {a,b,c,d} +% {\pgfkeys{key \d/.style={}}} +% would not work: +% \pgfkeys{key a/.style={otherstyle \d}} +% \pgfkeys{key b/.style={otherstyle \d}} +% \pgfkeys{key c/.style={otherstyle \d}} +% \pgfkeys{key d/.style={otherstyle \d}} +% such an application would need expansion control. +% +% #1: the iterates. Can be any argument as you would supply it to +% \foreach, for example \foreach \x in {1,2,...,10} +% -> #1 = {1,2,...,10} +% #2: the loop body. It can contain the parameter string '#1' which +% will be set to each element in the iterates list in turn. +% +% This method is actually just a light-weight adapter around +% \pgfplotsforeachungrouped. +\long\def\pgfplotsinvokeforeach#1#2{% + \long\def\pgfplotsinvokeforeach@@##1{#2}% + \pgfplotsforeachungrouped \pgfplotsinvokeforeach@ in {#1} {% + \expandafter\pgfplotsinvokeforeach@@\expandafter{\pgfplotsinvokeforeach@}% + }% +} + % Allows to provide an output routine for % \pgfplotsforeachlogarithmicungrouped which changes the number format % of \pgfmathresult. @@ -557,7 +697,7 @@ \def\pgfplotsforeachlogarithmicungrouped@finalizeresult{#1}% } -% \pgfplotsforeachlogarithmicungrouped \x/\logx in {a:b} {#3} +% \pgfplotsforeachlogarithmicungrouped[<samples>] \x/\logx in {a:b} {#3} % % samples \x between a and b using a logarithmic scale. % @@ -568,19 +708,20 @@ % configured otherwise with \pgfplotsforeachlogarithmicsetoutput, % see above. % -\def\pgfplotsforeachlogarithmicungrouped#1/#2{\pgfplotsforeachlogarithmicungrouped@{#1}{#2}}% -\long\def\pgfplotsforeachlogarithmicungrouped@#1#2in #3#4{% +% FIXME : THIS CAN'T BE NESTED YET! +\def\pgfplotsforeachlogarithmicungrouped[#1]#2/#3{\pgfplotsforeachlogarithmicungrouped@[#1]{#2}{#3}}% +\long\def\pgfplotsforeachlogarithmicungrouped@[#1]#2#3in #4#5{% % define % \pgfplots@foreach@loc@TMPd = N in fixed point % \pgfplots@foreach@loc@TMPc = N-1 in float : - \pgfkeysgetvalue{/pgfplots/samples}{\pgfplots@plot@samples} + \edef\pgfplots@plot@samples@@{#1}% \pgfmathfloatcreate{1}{1.0}{0}% \let\pgfplots@foreach@loc@TMPa=\pgfmathresult - \pgfmathfloatparsenumber{\pgfplots@plot@samples}% + \pgfmathfloatparsenumber{\pgfplots@plot@samples@@}% \expandafter\pgfmathfloatsubtract@\expandafter{\pgfmathresult}{\pgfplots@foreach@loc@TMPa}% \let\pgfplots@foreach@loc@TMPc=\pgfmathresult % - \edef\pgfplots@loc@TMPb{#3}% + \edef\pgfplots@loc@TMPb{#4}% \expandafter\pgfplotsforeachlogarithmicungrouped@readdomain\pgfplots@loc@TMPb\relax % compute mesh width into \pgfplots@foreach@loc@TMPc: % \pgfplots@foreach@loc@TMPc := h := ( log(xmax) - log(xmin) ) / (N-1) @@ -592,20 +733,20 @@ \edef\pgfplots@foreach@loc@TMPd{% \noexpand\c@pgf@counta=\the\c@pgf@counta\noexpand\relax }% - \long\def\pgfplots@foreach@loc@TMPf{#4}% + \long\def\pgfplots@foreach@loc@TMPf{#5}% \c@pgf@counta=0 \pgfutil@loop - \ifnum\c@pgf@counta<\pgfplots@plot@samples + \ifnum\c@pgf@counta<\pgfplots@plot@samples@@ % compute exp(log(min) + i * h) \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgf@counta}% \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@foreach@loc@TMPc}% \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfplots@foreach@loc@TMPa}% \let\pgfplots@loc@TMPa=\pgfmathresult \pgfplotsforeachlogarithmicungrouped@finalizeresult% - \let#2=\pgfmathresult + \let#3=\pgfmathresult \pgfmathfloatexp@{\pgfplots@loc@TMPa}% \pgfplotsforeachlogarithmicungrouped@finalizeresult% - \let#1=\pgfmathresult + \let#2=\pgfmathresult % % ok, invoke it! % -> store \c@pgf@counta before doing so. We need to scope @@ -659,6 +800,28 @@ \expandafter#1\pgfutil@edef@invoke@ } +% defines \pgfmathresult to be the INTEGER result of (#1 mod #2). +% +% \pgfplotsmathmod{2}{4} -> 2 +% \pgfplotsmathmod{9}{5} -> 4 +\def\pgfplotsmathmodint#1#2{% + \begingroup + \c@pgf@counta=#2\relax + \c@pgf@countb=#1\relax + \c@pgf@countc=\c@pgf@countb + \ifnum\c@pgf@counta=0 + \pgfplots@error{Can't compute \the\c@pgf@countb\space mod \the\c@pgf@counta\space -- this yields division by zero (second argument is zero)!}% + \edef\pgfmathresult{#1}% + \else + \divide\c@pgf@countc by\c@pgf@counta + \multiply\c@pgf@countc by\c@pgf@counta + \advance\c@pgf@countb by-\c@pgf@countc + \edef\pgfmathresult{\the\c@pgf@countb}% + \fi + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + % Advances a number stored in a macro and writes the result back into % the macro. % #1 is a macro containing a number. @@ -670,10 +833,95 @@ \pgfmath@smuggleone#1% \endgroup }% +\def\pgfplotsutil@advancestringcounter@global#1{% + \begingroup + \c@pgf@counta=#1\relax + \advance\c@pgf@counta by1 + \xdef#1{\the\c@pgf@counta}% + \endgroup +}% + +\newif\ifpgfplotsloopcontinue + +% A loop construct which invokes '#1' and continues the loop if the +% boolean \ifpgfplotsloopcontinue is true and stops if it is false. +% +% #1: a statement which is expected to set \ifpgfplotsloopcontinue +% #2: the loop body. +\def\pgfplotsloop#1#2{% + #1\relax + \ifpgfplotsloopcontinue + #2\relax + \def\pgfplotsloop@{\pgfplotsloop{#1}{#2}}% + \expandafter\pgfplotsloop@ + \fi +}% + +\pgfutil@ifundefined{pgfmathdeclarefunction}{% + % BACKWARDS COMPATIBILITY: We have PGF 2.00 : + \def\pgfplotsmathdeclarepseudoconstant#1#2{% + \t@pgfplots@toka=\expandafter{\csname pgfmath#1@\endcsname}% + \t@pgfplots@tokb={\pgfmath@postfunction}% + \expandafter\edef\csname pgfmath@parsefunction@#1\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + \expandafter\edef\csname pgfmath#1\endcsname{\the\t@pgfplots@toka}% + \expandafter\def\csname pgfmath#1@\endcsname{#2}% + }% + \let\pgfplotsmathredeclarepseudoconstant=\pgfplotsmathdeclarepseudoconstant +}{% + \def\pgfplotsmathdeclarepseudoconstant#1#2{% + \pgfmathdeclarefunction*{#1}{0}{#2}% + }% + \def\pgfplotsmathredeclarepseudoconstant#1#2{% + \pgfmathredeclarefunction{#1}{#2}% + }% +}% + + +% Usage: +% \pgfplotsutilstrreplace{<token>}{<replacement>}{<string>} +% +% -> will assign the modified string into \pgfplotsretval. +% +% #1: the string to search (one or more tokens) +% #2: zero, one or more tokens which will be inserted instead of '#1'. +% #3: the string to search in +\long\def\pgfplotsutilstrreplace#1#2#3{% + \def\pgfplotsretval{}% + \long\def\pgfplotsutil@search@and@replace@@##1#1##2\pgfplots@EOI{% + \expandafter\def\expandafter\pgfplotsretval\expandafter{\pgfplotsretval ##1#2}% + \pgfplotsutil@search@and@replace@loop{#1}{##2}% + }% + \pgfplotsutil@search@and@replace@loop{#1}{#3}% +} +\long\def\pgfplotsutil@search@and@replace@loop#1#2{% + \pgfutil@in@{#1}{#2}% + \ifpgfutil@in@ + \def\pgfplots@loc@TMPa{\pgfplotsutil@search@and@replace@@ #2\pgfplots@EOI}% + \else + \expandafter\def\expandafter\pgfplotsretval\expandafter{\pgfplotsretval #2}% + \let\pgfplots@loc@TMPa=\relax + \fi + \pgfplots@loc@TMPa +}% + +% strcmp: invokes #3 if #1=#2 (top level expansion only) and it +% invokes #4 if #1!=#2. +\long\def\pgfplotsutilifstringequal#1#2#3#4{% + \def\pgfplotsifstringequal@{#1}% + \def\pgfplotsifstringequal@@{#2}% + \ifx\pgfplotsifstringequal@\pgfplotsifstringequal@@ #3\else #4\fi +}% + +% this command is in pgfplotscore.code.tex: +% \pgfplotsiffileexists \input pgfplotsliststructure.code.tex \input pgfplotsliststructureext.code.tex \input pgfplotsarray.code.tex \input pgfplotstable.code.tex +\input pgfplotsdeque.code.tex +\input pgfplotsbinary.code.tex + +\usepgfplotslibrary{surfshading} \endinput |