summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/util
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/util')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsbinary.code.tex802
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex357
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex510
3 files changed, 1507 insertions, 162 deletions
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