summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/pgfplots/tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/pgfplots/tex')
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/binary.lua41
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/bugtracker.sty429
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/colormap.lua156
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/functions.lua651
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/meshplothandler.lua294
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/parser.lua504
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibraryfillbetween.code.tex1265
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.colorbrewer.code.tex4149
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.colortol.code.tex766
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.code.tex638
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-dvipdfmx.def179
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-dvips.def114
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-luatex.def168
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def30
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def162
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-xetex.def30
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.assert.code.tex50
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.assert.sty2
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.code.tex12647
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.errorbars.code.tex608
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.lua45
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.markers.code.tex367
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.paths.code.tex71
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.revision.tex15
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.scaling.code.tex3399
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.sty155
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplots.tex50
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsarray.code.tex733
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsbinary.code.tex603
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsbinary.data.code.tex291
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotscolor.code.tex630
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotscolormap.code.tex2500
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotscoordprocessing.code.tex9721
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotscore.code.tex465
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsdeque.code.tex125
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotslibrary.code.tex94
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsliststructure.code.tex440
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsliststructureext.code.tex615
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsmatrix.code.tex544
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsmeshplothandler.code.tex3528
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsmeshplotimage.code.tex545
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_leq.code.tex279
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_loader.code.tex361
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_misc.code.tex885
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex567
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcoreimage.code.tex584
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcorelayers.code.tex217
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcorescopes.code.tex607
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfkeys.code.tex1067
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex1041
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex2326
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex1190
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryluamath.code.tex559
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex1141
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.code.tex90
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex450
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex1119
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmathfloat.code.tex2665
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfutil-common-lists.tex184
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzexternal.sty163
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzexternalshared.code.tex1732
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex133
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_trig_format.code.tex380
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsplothandlers.code.tex3083
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsstackedplots.code.tex688
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotssysgeneric.code.tex84
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotstable.code.tex3014
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotstable.coltype.code.tex93
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotstable.sty39
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotstable.tex38
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotstableshared.code.tex2111
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotstexio.lua500
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsticks.code.tex2585
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.code.tex2203
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.lua139
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.verb.code.tex97
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfregressiontest.sty159
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/pgfsys-luatexpatch.def441
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/plothandler.lua998
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/statistics.lua400
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/streamer.lua195
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/t-pgfplots.tex81
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/t-pgfplotstable.tex41
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarycolorbrewer.code.tex536
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarycolortol.code.tex277
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarydateplot.code.tex24
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarydecorations.softclip.code.tex517
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibraryfillbetween.code.tex577
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.clickable.code.tex1393
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.colormaps.code.tex359
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.dateplot.code.tex270
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.decorations.softclip.code.tex36
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.external.code.tex131
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.fillbetween.code.tex240
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.groupplots.code.tex530
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.patchplots.code.tex2723
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.polar.code.tex799
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.smithchart.code.tex1678
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.statistics.code.tex1221
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.ternary.code.tex928
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.units.code.tex224
-rw-r--r--graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplotsclickable.code.tex24
102 files changed, 95035 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/pgfplots/tex/binary.lua b/graphics/pgf/contrib/pgfplots/tex/binary.lua
new file mode 100644
index 0000000000..74c04b7409
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/binary.lua
@@ -0,0 +1,41 @@
+
+-- Attention: functions in this file are part of the backend driver.
+-- They are supposed to work back with Lua 5.1 .
+-- Note that most of the 'lua backend' requires Lua 5.2 (currently)
+
+pgfplotsGetLuaBinaryStringFromCharIndicesChunkSize = 7000;
+
+if unpack == nil then
+ -- LUA 0.76 renamed unpack to table.unpack
+ pgfplotsUnpack = table.unpack;
+else
+ pgfplotsUnpack = unpack;
+end
+
+-- Takes a table containing an arbitrary number of integers in the range 0..255 and converts it
+-- into a binary stream of the corresponding binary chars.
+--
+-- @param charIndices a table containing 0...N arguments; each in the range 0..255
+--
+-- @return a string containing binary content, one byte for each input integer.
+function pgfplotsGetLuaBinaryStringFromCharIndices(charIndices)
+ -- unpack extracts only the indices (we can't provide a table to string.char).
+ -- note that pdf.immediateobj has been designed to avoid sanity checking for invalid UTF strings -
+ -- in other words: it accepts binary strings.
+ --
+ -- unfortunately, this here fails for huge input tables:
+ -- pgfplotsretval=string.char(unpack(charIndices));
+ -- we have to create it incrementally using chunks:
+ local len = #charIndices;
+ local chunkSize = pgfplotsGetLuaBinaryStringFromCharIndicesChunkSize;
+ local buf = {};
+ -- ok, append all full chunks of chunkSize first:
+ local numFullChunks = math.floor(len/chunkSize);
+ for i = 0, numFullChunks-1, 1 do
+ table.insert(buf, string.char(pgfplotsUnpack(charIndices, 1+i*chunkSize, (i+1)*chunkSize)));
+ end
+ -- append the rest:
+ table.insert(buf, string.char(pgfplotsUnpack(charIndices, 1+numFullChunks*chunkSize)));
+ return table.concat(buf);
+end
+
diff --git a/graphics/pgf/contrib/pgfplots/tex/bugtracker.sty b/graphics/pgf/contrib/pgfplots/tex/bugtracker.sty
new file mode 100644
index 0000000000..9de0d1ea4a
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/bugtracker.sty
@@ -0,0 +1,429 @@
+%--------------------------------------------------
+% Provides a simple, text-based bug tracker.
+%
+% Idea: simply write a text-todo list into a tex file, and write
+% trivial support macros which allow to provide priorities, status
+% flags and sorting capabilities. Sort key:
+% (section,isactive,priority). Can be processed with pgfplotstable.
+% Could also support the codeexample environment of pgfmanual.
+% -> Advantages:
+% - simple human readable text files (I like that!)
+% - independent of any tool
+% - can be sorted
+% UI:
+% \begin{feature}[<status>][prio=<num>]
+% <text>
+% \end{feature}
+%
+% \begin{bug}[<status>][prio=<num>]
+% <text>
+% \end{bug}
+% Idea: collect *all* entries in one huge array, then sort this array, then
+% typeset the result. Should work reasonably, I guess. If it is too slow,
+% typeset directly.
+%--------------------------------------------------
+%
+\ProvidesPackage{bugtracker}[2010/07/23 Version 0.1]
+
+\RequirePackage{pgfplotstable}
+\RequirePackage{listings}
+\RequirePackage{hyperref}
+
+\ifx\scantokens\@undefined
+ \PackageError{pgfmanual-macros}{You need to use extended latex
+ (elatex) or (pdfelatex) to process this document}{}
+\fi
+
+\def\bugtracker@init@items{%
+}%
+
+{
+\catcode`\[=1
+\catcode`\]=2
+\catcode`\{=12
+\catcode`\}=12
+\gdef\bugtracker@lbrace[{]
+\gdef\bugtracker@rbrace[}]
+]
+{
+\catcode`\|=0
+|catcode`\\=12
+|gdef|bugtracker@bslash{\}
+}
+
+% #1: the environment (item) name
+% #2: the sort order (an integer)
+\def\declarebugtrackeritem#1#2{%
+ \expandafter\def\expandafter\bugtracker@init@items\expandafter{%
+ \bugtracker@init@items
+ \expandafter\gdef\csname c@bugtracker@#1\endcsname{0}%
+ }%
+ \expandafter\edef\csname bugtracker@end@#1\endcsname{\bugtracker@bslash end\bugtracker@lbrace #1\bugtracker@rbrace}%
+ \expandafter\def\csname #1\endcsname{\bugtracker@collect{#1}}%
+ \expandafter\def\csname end#1\endcsname{\relax}%
+ \pgfkeyssetvalue{/bugtracker/sort order/#1}{#2}%
+}%
+
+\newif\ifbugtracker@sort
+
+\newenvironment{bugtracker}{%
+ \let\bugtracker@enqueue=\bugtracker@enqueue@ACTIVE
+ \pgfplotsarraynewemptyglobal\bugtrackeritems
+}{%
+ \ifbugtracker@sort
+ \begingroup
+ \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\bugtracker@iflessthan
+ \pgfkeysdef{/pgfplots/array/unscope pre}{\bugtracker@typeset}%
+ \pgfkeysdef{/pgfplots/array/unscope post}{}%
+ \pgfplotsarraysort\bugtrackeritems
+ \endgroup
+ \else
+ \bugtracker@typeset
+ \fi
+}%
+
+\def\bugtrackerset{\pgfqkeys{/bugtracker}}%
+
+
+\def\bugtracker@collect#1{%
+ \pgfutil@ifnextchar[{%
+ \bugtracker@collect@status{#1}%
+ }{%
+ \bugtracker@collect@status{#1}[open]%
+ }%
+}%
+\def\bugtracker@collect@status#1[#2]{%
+ \pgfutil@ifnextchar[{%
+ \bugtracker@collect@status@opt{#1}[#2]%
+ }{%
+ \bugtracker@collect@status@opt{#1}[#2][]%
+ }%
+}%
+\def\bugtracker@collect@status@opt#1[#2][#3]{%
+ \begingroup
+ \bugtrackerset{#2,#3}%
+ \expandafter\let\expandafter\bugtracker@temp\csname bugtracker@end@#1\endcsname
+ \expandafter\long\expandafter\def\expandafter\bugtracker@collect@until\expandafter##\expandafter1\bugtracker@temp{\bugtracker@enqueue{#1}{##1}}%
+ \bugtracker@prepare@collect
+ \bugtracker@collect@until
+}%
+
+
+\def\bugtracker@prepare@collect{%
+ \def\do##1{\catcode`##1=12 }\dospecials
+ \catcode`\^^M=12
+ \catcode`\^^J=12
+ \catcode`\^^I=12
+}%
+
+\def\bugtracker@restore@catcodes{%
+ \catcode`\^^M=5
+ \catcode`\^^J=10
+ \catcode`\^^I=10
+ % this is important to get \scantokens to work: otherwise, it will
+ % eat up the ^^M chars:
+ \endlinechar=`\^^M
+ \newlinechar=\endlinechar
+}%
+
+\long\def\bugtracker@enqueue#1#2{%
+ \edef\bugtracker@status@order{\pgfkeysvalueof{/bugtracker/status order/\bugtracker@status}}%
+ \ifx\bugtracker@status@order\pgfutil@empty
+ % status order/<status name>={} --> do not display it!
+ \else
+ \toks0={#2}%
+ % some of these values are used during the sort procedure; that's
+ % why they are not simply a list of keys. Perhaps they should
+ % still be a list of keys...
+ \edef\bugtracker@entry{{#1}{\bugtracker@status}{\pgfkeysvalueof{/bugtracker/prio}}{\the\toks0}{\the\inputlineno}{\pgfkeysvalueof{/bugtracker/epic}}}%
+ \expandafter\pgfplotsarraypushbackglobal\expandafter{\bugtracker@entry}\to\bugtrackeritems
+ \fi
+ \endgroup
+ \end{#1}%
+}%
+\let\bugtracker@enqueue@ACTIVE=\bugtracker@enqueue
+\long\def\bugtracker@enqueue#1#2{%
+ \PackageError{bugtracker}{Sorry, bug tracker elements can only be used inside of \string\begin{bugtracker} ... \string\end{bugtracker}. Discarding this element}{}%
+}%
+
+\long\def\bugtracker@unpack#1#2#3#4#5#6{%
+ \bugtrackerset{name={#1},status=#2,prio=#3,source line={#5},epic={#6}}%
+ \def\bugtracker@content{#4}%
+}%
+
+\long\def\bugtracker@unpack@sorting#1#2#3#4#5#6{%
+ \edef\bugtracker@name {\pgfkeysvalueof{/bugtracker/sort order/#1}}%
+ \edef\bugtracker@status{\pgfkeysvalueof{/bugtracker/status order/#2}}%
+ \def\bugtracker@prio{#3}%
+ \def\bugtracker@source{#5}%
+}%
+\def\bugtracker@iflessthan#1#2#3#4\pgfeov{%
+ \expandafter\bugtracker@unpack@sorting#1%
+ \let\bugtracker@nameA=\bugtracker@name
+ \let\bugtracker@statusA=\bugtracker@status
+ \let\bugtracker@prioA=\bugtracker@prio
+ \let\bugtracker@sourceA=\bugtracker@source
+ %
+ \expandafter\bugtracker@unpack@sorting#2%
+ %
+ \def\bugtracker@lt{0}%
+ \ifnum\bugtracker@nameA<\bugtracker@name
+ \def\bugtracker@lt{1}%
+ \else
+ \ifnum\bugtracker@nameA=\bugtracker@name
+ \ifnum\bugtracker@statusA<\bugtracker@status
+ \def\bugtracker@lt{1}%
+ \else
+ \ifnum\bugtracker@statusA=\bugtracker@status
+ \ifnum\bugtracker@prioA>\bugtracker@prio
+ \def\bugtracker@lt{1}%
+ \else
+ \ifnum\bugtracker@prioA=\bugtracker@prio
+ \ifnum\bugtracker@sourceA<\bugtracker@source
+ \def\bugtracker@lt{1}%
+ %\else
+ %\ifnum\bugtracker@sourceA=\bugtracker@source
+ %\fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \if1\bugtracker@lt #3\else #4\fi
+}%
+
+
+\long\def\bugtracker@typeset@#1#2{%
+ \pgfkeysvalueof{/bugtracker/typeset/.@cmd}{#1}{#2}\pgfeov
+}%
+
+\def\bugtracker@typeset{%
+ \let\minimal=\bugtracker@minimal@env
+ \def\endminimal{\relax}%
+ %
+ \pgfkeysvalueof{/bugtracker/font}%
+ \bugtracker@init@items
+ \gdef\bugtracker@isfirst{1}%
+ \pgfplotsarrayforeach\bugtrackeritems\as\entry{%
+ \if1\bugtracker@isfirst
+ \else
+ \vskip\pgfkeysvalueof{/bugtracker/vskip}
+ \fi
+ \expandafter\bugtracker@unpack\entry
+ %
+ \edef\c@bugtracker{\csname c@bugtracker@\pgfkeysvalueof{/bugtracker/name}\endcsname}%
+ \expandafter\pgfplotsutil@advancestringcounter@global\csname c@bugtracker@\pgfkeysvalueof{/bugtracker/name}\endcsname
+ %
+ \message{bugtracker: processing \jobname.tex:\pgfkeysvalueof{/bugtracker/source line}...^^J}%
+ \begingroup
+ \bugtracker@restore@catcodes
+ \expandafter\bugtracker@typeset@\expandafter{\expandafter\scantokens\expandafter{\bugtracker@content}}{\c@bugtracker}%%
+ \endgroup
+ \gdef\bugtracker@isfirst{0}%
+ }%
+}%
+
+\bugtrackerset{
+ sort/.is if=bugtracker@sort,
+ sort=true,
+ name/.initial=,
+ typeset name/.code={%
+ \pgfkeysifdefined{/bugtracker/name text/#1}{%
+ \pgfkeysvalueof{/bugtracker/name text/#1}%
+ }{%
+ #1%
+ }%
+ },
+ prio/.initial=5,
+ epic/.initial=,
+ source line/.initial=,
+ status/.is choice,
+ status/open/.code= {\def\bugtracker@status{open}},
+ status/closed/.code= {\def\bugtracker@status{closed}},
+ status/cancelled/.code= {\def\bugtracker@status{cancelled}},
+ status/partially/.code= {\def\bugtracker@status{partially}},
+ status/-/.style= {/bugtracker/status/open},
+ status/+/.style= {/bugtracker/status/closed},
+ status/X/.style= {/bugtracker/status/cancelled},
+ status=open,
+ % status order/<statusname>/.initial=int . Empty means:
+ % do not display it at all.
+ status order/open/.initial=0,
+ status order/closed/.initial=,%10,
+ status order/cancelled/.initial=7,
+ status order/partially/.initial=1,
+ shell escape/.initial=-shell-escape,
+ prefix/.initial=\jobname-,
+ file ext/.initial=pdf,
+ system call/.initial={pdflatex \bugtracker@checkshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"},
+ vskip/.initial=\baselineskip,
+ font/.initial={%
+ \parindent=0pt
+ \raggedright
+ },
+ % #1: a running index.
+ typeset id/.code={%
+ \begin{minipage}[t]{3cm}%
+ \raggedleft
+ %[\##1]\par
+ {\ttfamily \jobname.tex:\pgfkeysvalueof{/bugtracker/source line}}
+ \end{minipage}
+ },
+ typeset/.code 2 args={%
+ \noindent
+ \paragraph{%
+ \protect\llap{\normalfont\scriptsize \protect\bugtrackerset{/bugtracker/typeset id=#2}\hspace{2em}}%
+ \protect\bugtrackerset{/bugtracker/typeset name={\pgfkeysvalueof{/bugtracker/name}}}
+ % \##2
+ }
+ [\bugtracker@status, Priority \pgfkeysvalueof{/bugtracker/prio}, Epic `\pgfkeysvalueof{/bugtracker/epic}']
+ \vskip4pt
+ {%
+ \noindent
+ \parskip=\baselineskip
+ #1%
+ \par
+ }%
+ %{\scriptsize Entry in {\ttfamily \jobname.tex:\pgfkeysvalueof{/bugtracker/source line}}}%
+ },%
+ typeset minimal/.code={%
+ \ifvmode
+ \noindent
+ \fi
+ \href{file:\bugtracker@minimal@filename@}{[\textcolor{blue}{see \texttt{\filename}}]}%
+ \bugtracker@minimal@typeset@{#1}%
+ },
+ .unknown/.code={%
+ \edef\bugtracker@tempkey{\noexpand\pgfkeysalso{/bugtracker/status=\pgfkeyscurrentname}}%
+ \bugtracker@tempkey
+ },
+}
+
+\declarebugtrackeritem{feature}{10}
+\declarebugtrackeritem{bug}{5}
+\declarebugtrackeritem{doctodo}{0}
+
+\bugtrackerset{
+ name text/feature/.initial=Feature Proposal,
+ name text/bug/.initial=Bug,
+ name text/doctodo/.initial=Documentation Todo,
+}
+
+
+\lstdefinestyle{minimalexample}{
+ basicstyle=\ttfamily\footnotesize,
+ columns=fullflexible,
+}
+
+
+% a
+% \begin{minimal}
+% \end{minimal}
+% environment which is executed automatically :
+\newcount\c@bugtracker@minimal
+\c@bugtracker@minimal=0
+
+\def\bugtracker@minimal@env{%
+ \begingroup
+ \bugtracker@prepare@collect
+ \bugtracker@minimal@collect
+}%
+\expandafter\edef\csname bugtracker@temp\endcsname{\bugtracker@bslash end\bugtracker@lbrace minimal\bugtracker@rbrace}%
+\expandafter\long\expandafter\def\expandafter\bugtracker@minimal@collect\expandafter#\expandafter1\bugtracker@temp{%
+ \endgroup
+ \edef\bugtracker@minimal@filename{\pgfkeysvalueof{/bugtracker/prefix}\the\c@bugtracker@minimal}%
+ \edef\bugtracker@minimal@filename@{\bugtracker@minimal@filename.\pgfkeysvalueof{/bugtracker/file ext}}%
+ \global\advance\c@bugtracker@minimal by1
+ %
+ \IfFileExists{\bugtracker@minimal@filename@}{}{%
+ \bugtracker@minimal@create{#1}%
+ }%
+ \bugtracker@minimal@typeset{#1}%
+ \end{minimal}%
+}%
+\long\def\bugtracker@minimal@typeset#1{%
+ \begingroup
+ \pgfplotscommandtostring\bugtracker@minimal@filename@\filename
+ \bugtracker@restore@catcodes
+ \edef\bugtracker@temp##1{%
+ \bugtracker@bslash begin{lstlisting}[style=minimalexample]%
+ ##1%
+ \bugtracker@bslash end{lstlisting}%
+ }%
+ \def\bugtracker@temp@##1{\pgfkeysvalueof{/bugtracker/typeset minimal/.@cmd}{##1}\pgfeov}%
+ \expandafter\bugtracker@temp@\expandafter{\bugtracker@temp{#1}}%
+ \endgroup
+}%
+\long\def\bugtracker@minimal@typeset@#1{%
+ \scantokens{#1}%
+}%
+\long\def\bugtracker@minimal@create#1{%
+ %
+ \immediate\openout\w@pgf@writea=\bugtracker@minimal@filename\relax
+ \immediate\write\w@pgf@writea{#1}%
+ \immediate\closeout\w@pgf@writea
+ %
+ \bugtracker@assemble@systemcall\bugtracker@minimal@filename\bugtracker@temp
+\message{Issuing system-call^^J$ \bugtracker@temp^^J}%
+ \immediate\write18{\bugtracker@temp}%
+ \IfFileExists{\bugtracker@minimal@filename@}{}{%
+ \PackageError{bugtracker}{Sorry, the system call '\bugtracker@temp' did NOT result in a usable output file '\bugtracker@minimal@filename@' (adjust '/bugtracker/file ext' if needed). 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 '\bugtracker@minimal@filename.log'}{}%
+ }%
+}
+
+{
+\catcode`\"=12
+\catcode`\'=12
+\catcode`\;=12
+\catcode`\&=12
+\catcode`\-=12
+\xdef\bugtracker@normal@dq{"}
+\xdef\bugtracker@normal@sq{'}
+\xdef\bugtracker@normal@semic{;}
+\xdef\bugtracker@normal@and{&}
+\xdef\bugtracker@normal@dash{-}
+\catcode`\"=13
+\catcode`\'=13
+\catcode`\;=13
+\catcode`\&=13
+\catcode`\-=13
+\gdef\bugtracker@activate@normal@dq{\let"=\bugtracker@normal@dq}
+\gdef\bugtracker@activate@normal@sq{\let'=\bugtracker@normal@sq}
+\gdef\bugtracker@activate@normal@semic{\let;=\bugtracker@normal@semic}
+\gdef\bugtracker@activate@normal@and{\let&=\bugtracker@normal@and}
+\gdef\bugtracker@activate@normal@dash{\let-=\bugtracker@normal@dash}
+\catcode`\|=0
+\catcode`\\=12
+|xdef|bugtracker@normal@backslash{\}%
+}
+% Creates the '/bugtracker/system call' command as string and
+% returns it into the (global!) macro #2.
+% #1: the output file name
+% #2: the global return value macro
+%
+\def\bugtracker@assemble@systemcall#1#2{%
+ \begingroup
+ \def\image{#1}%
+ \let\texsource=\image
+ \ifnum\the\catcode`\"=13 \bugtracker@activate@normal@dq\fi
+ \ifnum\the\catcode`\'=13 \bugtracker@activate@normal@sq\fi
+ \ifnum\the\catcode`\;=13 \bugtracker@activate@normal@semic\fi
+ \ifnum\the\catcode`\-=13 \bugtracker@activate@normal@dash\fi
+ \let\\=\bugtracker@normal@backslash
+ \xdef#2{\pgfkeysvalueof{/bugtracker/system call}}%
+ \endgroup
+}%
+
+\pgfutil@ifundefined{pdfshellescape}{%
+ \def\bugtracker@checkshellescape{}%
+}{%
+ \ifnum\pdfshellescape=1
+ \def\bugtracker@checkshellescape{\pgfkeysvalueof{/bugtracker/shell escape}\space}%
+ \else
+ \def\bugtracker@checkshellescape{}%
+ \fi
+}%
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/colormap.lua b/graphics/pgf/contrib/pgfplots/tex/colormap.lua
new file mode 100644
index 0000000000..73cbb2c894
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/colormap.lua
@@ -0,0 +1,156 @@
+--
+-- This file contains parts of pgfplotscolormap.code.tex
+--
+
+local math=math
+local pgfplotsmath = pgfplots.pgfplotsmath
+local io=io
+local type=type
+local tostring=tostring
+local error=error
+local table=table
+
+do
+-- all globals will be read from/defined in pgfplots:
+local _ENV = pgfplots
+
+local pgftonumber = pgfluamathfunctions.tonumber
+-----------------------------------
+
+ColorSpace = newClass()
+function ColorSpace:constructor(numComponents)
+ self.numComponents=numComponents
+end
+
+rgb = ColorSpace.new(3)
+cmyk = ColorSpace.new(4)
+gray = ColorSpace.new(1)
+
+
+ColorMap = newClass()
+
+ColorMap.range =1000
+
+-- h: mesh width between adjacent values
+-- colorspace: an instance of ColorSpace
+-- values: an array (1-based table) with color components. Each color component is supposed to be a table with K entries where K is colorspace:numComponents
+-- positions: either an empty array (in which case the colormap is uniform) or one position per value. Positions are in [0,1000]
+-- scaleOrderZ the specific scaling factor used for 'colormap access=const' (or negative or the empty string if this is disabled)
+function ColorMap:constructor( h, colorspace, values, positions, scaleOrderZ)
+ if not h or not colorspace or not positions or not values then error("arguments must not be nil")end
+
+ self.name = name
+ self.h = h
+ self.invh = 1/h
+ self.colorspace = colorspace
+ self.values = values
+ self.pos = positions
+ self:setScaleOrderZ(scaleOrderZ)
+
+ local numComponents = self.colorspace.numComponents
+ for i = 1,#self.values do
+ local value = self.values[i]
+ if #value ~= numComponents then
+ error("Some value has an unexpected number of color components, expected " .. self.colorspace.numComponents .. " but was ".. #value);
+ end
+ end
+end
+
+function ColorMap:isUniform()
+ if #self.pos == 0 then
+ return true
+ else
+ return false
+ end
+end
+
+function ColorMap:setScaleOrderZ(scaleOrderZ)
+ if type(scaleOrderZ) == "number" then
+ self.scaleOrderZ = scaleOrderZ
+ elseif #scaleOrderZ == 0 or type(scaleOrderZ) == "string" and scaleOrderZ == "h" then
+ -- special case which means "h"
+ self.scaleOrderZ = "h"
+ else
+ self.scaleOrderZ = pgftonumber(scaleOrderZ)
+ end
+end
+
+function ColorMap:_transform(inMin, inMax, x)
+ local transformed
+ if inMin == 0 and inMax == ColorMap.range then
+ transformed = x
+ else
+ local scale = ColorMap.range / (inMax - inMin)
+
+ transformed = (x - inMin) * scale
+ end
+ transformed = math.max(0, transformed)
+ transformed = math.min(ColorMap.range, transformed)
+ return transformed
+end
+
+function ColorMap:findPrecomputed(inMin, inMax, x)
+ local transformed = self:_transform(inMin, inMax, x)
+
+ local divh = transformed * self.invh
+ local intervalno = math.floor(divh)
+ local factor = divh - intervalno
+ local factor_two = 1-factor
+
+
+ -- Step 2: interpolate the desired RGB value using vector valued interpolation on the identified interval
+ if intervalno+1 == #self.values then
+ -- ah- we are at the right end!
+ return self.values[#self.values]
+ end
+
+ local left = self.values[intervalno+1]
+ local right = self.values[intervalno+2]
+ if not left or not right then error("Internal error: the color map does not have enough values for interval no " .. intervalno )end
+
+ local result = {}
+ for i = 1,self.colorspace.numComponents do
+ local result_i = factor_two * left[i] + factor * right[i]
+
+ result[i] = result_i
+ end
+
+ return result
+end
+
+function ColorMap:findPiecewiseConst(inMin, inMax, x)
+ -- see docs in \pgfplotscolormapfindpiecewiseconst@precomputed@ for details
+
+ local transformed = self:_transform(inMin, inMax, x)
+ local intervalno =-1
+ if self:isUniform() then
+ if self.scaleOrderZ == "h" then
+ invh = self.invh + 0.001
+ else
+ -- disable the extra interval
+ invh = self.invh
+ end
+
+ local divh = transformed * invh
+ intervalno = math.floor(divh)
+ else
+ -- FIXME : IMPLEMENT
+ end
+
+ if intervalno+1 == #self.values then
+ -- we have artificially increased the "h" (see the comments
+ -- above) -- meaning that this 'if' can happen.
+ -- ->Map the rightmost point to the rightmost interval:
+ return self.values[#self.values]
+ end
+ return self.values[intervalno+1]
+end
+
+-----------------------------------
+
+-- global registry of all colormaps.
+-- Key: colormap name
+-- Value: an instance of ColorMap
+ColorMaps = {}
+
+end
diff --git a/graphics/pgf/contrib/pgfplots/tex/functions.lua b/graphics/pgf/contrib/pgfplots/tex/functions.lua
new file mode 100644
index 0000000000..d8d32997e3
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/functions.lua
@@ -0,0 +1,651 @@
+--------------------------------------------------------------------------------------------------
+------ 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
+------
+--
+-- Support for the contents of this file will NOT be done by the PGF/TikZ team.
+-- Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+-- with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+-- This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+----------------------------------------------------------------------------------------------------
+-- Date of this copy: Mi 6. Jan 11:32:04 CET 2016 ---
+
+
+
+-- Copyright 2011 by Christophe Jorssen
+--
+-- 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.
+--
+-- $Id: functions.lua,v 1.3 2015/05/10 20:34:13 cfeuersaenger Exp $
+--
+
+local pgfluamathfunctions = pgfluamathfunctions or {}
+
+-- Maps function names to their function.
+--
+-- Note that this allows to register functions which are not in pgfluamathfunctions.
+--
+-- Note that the string keys are not necessarily the same as the function
+-- names. In particular, the math expression "not(1,1)" will execute notPGF(1,1)
+--
+-- Note that each function which is added to pgfluamathfunctions will _automatically_ be inserted into this map, see __newindex.
+-- (I fear it will not be erased directly...)
+pgfluamathfunctions.stringToFunctionMap = {}
+
+local newFunctionAllocatedCallback = function(table,key,value)
+ local keyName = tostring(key):gsub("PGF","")
+ if not value then
+ stringToFunctionMap[keyName] = nil
+ elseif type(value) == 'function' then
+ -- remember it, and strip PGF suffix (i.e. remember 'not' instead of 'notPGF')
+ pgfluamathfunctions.stringToFunctionMap[keyName] = value
+ end
+ rawset(table,key,value)
+end
+
+setmetatable(pgfluamathfunctions, { __newindex = newFunctionAllocatedCallback })
+
+local mathabs, mathacos, mathasin = math.abs, math.acos, math.asin
+local mathatan, mathceil = math.atan, math.ceil
+local mathcos, mathdeg = math.cos, math.deg
+local mathexp, mathfloor, mathfmod = math.exp, math.floor, math.fmod
+local mathlog, mathmax = math.log, math.max
+local mathmin, mathpi = math.min, math.pi
+local mathrad, mathrandom = math.rad, math.random
+local mathrandomseed, mathsin = math.randomseed, math.sin
+local mathsqrt = math.sqrt
+local mathtan = math.tan
+
+local trigFormatToRadians = mathrad
+
+local radiansToTrigFormat = mathdeg
+
+pgfluamathfunctions.TrigFormat = { 'deg', 'rad' }
+pgfluamathfunctions.stringToFunctionMap["TrigFormat"] = nil
+
+-- choice is one of the valid choices in TrigFormat.
+function pgfluamathfunctions.setTrigFormat(choice)
+ if choice == 'deg' then
+ trigFormatToRadians = mathrad
+ radiansToTrigFormat = mathdeg
+ elseif choice == 'rad' then
+ local identity = function(x) return x end
+ trigFormatToRadians = identity
+ radiansToTrigFormat = identity
+ else
+ error("The argument '" .. tostring(choice) .. "' is no valid choice for setTrigFormat.")
+ end
+end
+pgfluamathfunctions.stringToFunctionMap["setTrigFormat"] = nil
+
+pgfluamathfunctions.setRandomSeed = mathrandomseed
+pgfluamathfunctions.stringToFunctionMap["setRandomSeed"] = nil
+
+-------------------------------------------
+
+function pgfluamathfunctions.add(x,y)
+ return x+y
+end
+
+function pgfluamathfunctions.subtract(x,y)
+ return x-y
+end
+
+function pgfluamathfunctions.neg(x)
+ return -x
+end
+
+function pgfluamathfunctions.multiply(x,y)
+ return x*y
+end
+
+function pgfluamathfunctions.veclen(x,y)
+ return mathsqrt(x*x+y*y)
+end
+
+function pgfluamathfunctions.divide(x,y)
+ return x/y
+end
+
+function pgfluamathfunctions.div(x,y)
+ return mathfloor(x/y)
+end
+
+function pgfluamathfunctions.pow(x,y)
+ -- do not use math.pow -- it is deprecated as of LUA 5.3
+ return x^y
+end
+
+function pgfluamathfunctions.factorial(x)
+-- TODO: x must be an integer
+ if x == 0 then
+ return 1
+ else
+ return x * pgfluamathfunctions.factorial(x-1)
+ end
+end
+
+function pgfluamathfunctions.ifthenelse(x,y,z)
+ if x~= 0 then
+ return y
+ else
+ return z
+ end
+end
+
+function pgfluamathfunctions.equal(x,y)
+ if x == y then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.greater(x,y)
+ if x > y then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.less(x,y)
+ if x < y then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.min(x,y)
+ return mathmin(x,y)
+end
+
+function pgfluamathfunctions.max(x,y)
+ return mathmax(x,y)
+end
+
+function pgfluamathfunctions.notequal(x,y)
+ if x ~= y then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.notless(x,y)
+ if x >= y then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.notgreater(x,y)
+ if x <= y then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.andPGF(x,y)
+ if (x ~= 0) and (y ~= 0) then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.orPGF(x,y)
+ if (x ~= 0) or (y ~= 0) then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.notPGF(x)
+ if x == 0 then
+ return 1
+ else
+ return 0
+ end
+end
+
+function pgfluamathfunctions.pi()
+ return mathpi
+end
+
+function pgfluamathfunctions.e()
+ return mathexp(1)
+end
+
+function pgfluamathfunctions.abs(x)
+ return mathabs(x)
+end
+
+function pgfluamathfunctions.floor(x)
+ return mathfloor(x)
+end
+
+function pgfluamathfunctions.ceil(x)
+ return mathceil(x)
+end
+
+function pgfluamathfunctions.exp(x)
+ return mathexp(x)
+end
+
+function pgfluamathfunctions.ln(x)
+ return mathlog(x)
+end
+
+local logOf10 = mathlog(10)
+function pgfluamathfunctions.log10(x)
+ return mathlog(x) / logOf10
+end
+
+local logOf2 = mathlog(2)
+function pgfluamathfunctions.log2(x)
+ return mathlog(x) / logOf2
+end
+
+function pgfluamathfunctions.sqrt(x)
+ return mathsqrt(x)
+end
+
+function pgfluamathfunctions.sign(x)
+ if x < 0 then
+ return -1.0
+ elseif x == 0 then
+ return 0.0
+ else
+ return 1.0
+ end
+end
+function pgfluamathfunctions.real(x)
+ -- "ensure that x contains a decimal point" is kind of a no-op here, isn't it!?
+ return x
+end
+
+function pgfluamathfunctions.rnd()
+ return mathrandom()
+end
+
+function pgfluamathfunctions.rand()
+ return -1 + mathrandom() *2
+end
+
+function pgfluamathfunctions.random(x,y)
+ if x == nil and y == nil then
+ return mathrandom()
+ elseif y == nil then
+ return mathrandom(x)
+ else
+ return mathrandom(x,y)
+ end
+end
+
+function pgfluamathfunctions.deg(x)
+ return mathdeg(x)
+end
+
+function pgfluamathfunctions.rad(x)
+ return mathrad(x)
+end
+
+function pgfluamathfunctions.round(x)
+ if x<0 then
+ return -mathfloor(mathabs(x)+0.5)
+ else
+ return mathfloor(x + 0.5)
+ end
+end
+
+function pgfluamathfunctions.gcd(a, b)
+ if b == 0 then
+ return a
+ else
+ return pgfluamathfunctions.gcd(b, a%b)
+ end
+end
+
+function pgfluamathfunctions.isprime(a)
+ local ifisprime = true
+ if a == 1 then
+ ifisprime = false
+ elseif a == 2 then
+ ifisprime = true
+-- if a > 2 then
+ else
+ local i, imax = 2, mathceil(mathsqrt(a)) + 1
+ while ifisprime and (i < imax) do
+ if pgfluamathfunctions.gcd(a,i) ~= 1 then
+ ifisprime = false
+ end
+ i = i + 1
+ end
+ end
+ if ifisprime then
+ return 1
+ else
+ return 0
+ end
+end
+
+
+function pgfluamathfunctions.split_braces_to_explist(s)
+ -- (Thanks to mpg and zappathustra from fctt)
+ -- Make unpack available whatever lua version is used
+ -- (unpack in lua 5.1 table.unpack in lua 5.2)
+ local unpack = table.unpack or unpack
+ local t = {}
+ for i in s:gmatch('%b{}') do
+ table.insert(t, tonumber(i:sub(2, -2)))
+ end
+ return unpack(t)
+end
+
+function pgfluamathfunctions.split_braces_to_table(s)
+ local t = {}
+ for i in s:gmatch('%b{}') do
+ table.insert(t, tonumber(i:sub(2, -2)))
+ end
+ return t
+end
+
+function pgfluamathfunctions.mathtrue()
+ return 1.0
+end
+pgfluamathfunctions.stringToFunctionMap["true"] = pgfluamathfunctions.mathtrue
+
+function pgfluamathfunctions.mathfalse()
+ return 0.0
+end
+pgfluamathfunctions.stringToFunctionMap["false"] = pgfluamathfunctions.mathfalse
+
+function pgfluamathfunctions.frac(a)
+ -- should be positive, apparently
+ return mathabs(a - pgfluamathfunctions.int(a))
+end
+
+function pgfluamathfunctions.int(a)
+ if a < 0 then
+ return -mathfloor(mathabs(a))
+ else
+ return mathfloor(a)
+ end
+end
+
+function pgfluamathfunctions.iseven(a)
+ if (a % 2) == 0 then
+ return 1.0
+ else
+ return 0.0
+ end
+end
+
+function pgfluamathfunctions.isodd(a)
+ if (a % 2) == 0 then
+ return 0.0
+ else
+ return 1.0
+ end
+end
+
+function pgfluamathfunctions.mod(x,y)
+ if x/y < 0 then
+ return -(mathabs(x)%mathabs(y))
+ else
+ return mathabs(x)%mathabs(y)
+ end
+end
+
+function pgfluamathfunctions.Mod(x,y)
+ local tmp = pgfluamathfunctions.mod(x,y)
+ if tmp < 0 then
+ tmp = tmp + y
+ end
+ return tmp
+end
+
+function pgfluamathfunctions.Sin(x)
+ return mathsin(trigFormatToRadians(x))
+end
+pgfluamathfunctions.sin=pgfluamathfunctions.Sin
+
+
+function pgfluamathfunctions.cosh(x)
+ -- math.cosh is deprecated as of LUA 5.3 . reimplement it:
+ return 0.5* (mathexp(x) + mathexp(-x))
+end
+function pgfluamathfunctions.sinh(x)
+ -- math.sinh is deprecated as of LUA 5.3 . reimplement it:
+ return 0.5* (mathexp(x) - mathexp(-x))
+end
+
+local sinh = pgfluamathfunctions.sinh
+local cosh = pgfluamathfunctions.cosh
+function pgfluamathfunctions.tanh(x)
+ -- math.tanh is deprecated as of LUA 5.3 . reimplement it:
+ return sinh(x)/cosh(x)
+end
+
+function pgfluamathfunctions.Cos(x)
+ return mathcos(trigFormatToRadians(x))
+end
+pgfluamathfunctions.cos=pgfluamathfunctions.Cos
+
+function pgfluamathfunctions.Tan(x)
+ return mathtan(trigFormatToRadians(x))
+end
+pgfluamathfunctions.tan=pgfluamathfunctions.Tan
+
+function pgfluamathfunctions.aSin(x)
+ return radiansToTrigFormat(mathasin(x))
+end
+pgfluamathfunctions.asin=pgfluamathfunctions.aSin
+
+function pgfluamathfunctions.aCos(x)
+ return radiansToTrigFormat(mathacos(x))
+end
+pgfluamathfunctions.acos=pgfluamathfunctions.aCos
+
+function pgfluamathfunctions.aTan(x)
+ return radiansToTrigFormat(mathatan(x))
+end
+pgfluamathfunctions.atan=pgfluamathfunctions.aTan
+
+local mathatan2
+if math.atan2 == nil then
+ -- math.atan2 has been deprecated since LUA 5.3
+ mathatan2 = function (y,x) return mathatan(y,x) end
+else
+ mathatan2 = math.atan2
+end
+
+function pgfluamathfunctions.aTan2(y,x)
+ return radiansToTrigFormat(mathatan2(y,x))
+end
+pgfluamathfunctions.atan2=pgfluamathfunctions.aTan2
+pgfluamathfunctions.atantwo=pgfluamathfunctions.aTan2
+
+function pgfluamathfunctions.cot(x)
+ return pgfluamathfunctions.cos(x) / pgfluamathfunctions.sin(x)
+end
+function pgfluamathfunctions.sec(x)
+ return 1 / pgfluamathfunctions.cos(x)
+end
+function pgfluamathfunctions.cosec(x)
+ return 1 / pgfluamathfunctions.sin(x)
+end
+
+function pgfluamathfunctions.pointnormalised (pgfx, pgfy)
+ local pgfx_normalised, pgfy_normalised
+ if pgfx == 0. and pgfy == 0. then
+ -- Orginal pgf macro gives this result
+ tex.dimen['pgf@x'] = "0pt"
+ tex.dimen['pgf@y'] = "1pt"
+ else
+ pgfx_normalised = pgfx/math.sqrt(pgfx^2 + pgfy^2)
+ pgfx_normalised = pgfx_normalised - pgfx_normalised%0.00001
+ pgfy_normalised = pgfy/math.sqrt(pgfx^2 + pgfy^2)
+ pgfy_normalised = pgfy_normalised - pgfy_normalised%0.00001
+ tex.dimen['pgf@x'] = tostring(pgfx_normalised) .. "pt"
+ tex.dimen['pgf@y'] = tostring(pgfy_normalised) .. "pt"
+ end
+ return nil
+end
+
+local isnan = function(x)
+ return x ~= x
+end
+
+pgfluamathfunctions.isnan = isnan
+
+local infty = 1/0
+pgfluamathfunctions.infty = infty
+
+local nan = math.sqrt(-1)
+pgfluamathfunctions.nan = nan
+
+local stringlen = string.len
+local globaltonumber = tonumber
+local stringsub=string.sub
+local stringformat = string.format
+local stringsub = string.sub
+
+-- like tonumber(x), but it also accepts nan, inf, infty, and the TeX FPU format
+function pgfluamathfunctions.tonumber(x)
+ if type(x) == 'number' then return x end
+ if not x then return x end
+
+ local len = stringlen(x)
+ local result = globaltonumber(x)
+ if not result then
+ if len >2 and stringsub(x,2,2) == 'Y' and stringsub(x,len,len) == ']' then
+ -- Ah - some TeX FPU input of the form 1Y1.0e3] . OK. transform it
+ local flag = stringsub(x,1,1)
+ if flag == '0' then
+ -- ah, 0.0
+ result = 0.0
+ elseif flag == '1' then
+ result = globaltonumber(stringsub(x,3, len-1))
+ elseif flag == '2' then
+ result = globaltonumber("-" .. stringsub(x,3, len-1))
+ elseif flag == '3' then
+ result = nan
+ elseif flag == '4' then
+ result = infty
+ elseif flag == '5' then
+ result = -infty
+ end
+ else
+ local lower = x:lower()
+ if lower == 'nan' then
+ result = nan
+ elseif lower == "-nan" then
+ result = nan
+ elseif lower == 'inf' or lower == 'infty' then
+ result = infty
+ elseif lower == '-inf' or lower == '-infty' then
+ result = -infty
+ end
+ end
+ end
+
+ return result
+end
+
+local stringlen = string.len
+local globaltonumber = tonumber
+local stringformat = string.format
+local stringsub = string.sub
+local stringfind = string.find
+local stringbyte = string.byte
+local NULL_CHAR = string.byte("0",1)
+
+local function discardTrailingZeros(x)
+ local result = x
+ -- printf is too stupid: I would like to have
+ -- 1. a fast method
+ -- 2. a reliable method
+ -- 3. full precision of x
+ -- 4. a fixed point representation
+ -- the 'f' modifier has trailing zeros (stupid!)
+ -- the 'g' modified can switch to scientific notation (no-go!)
+ local periodOff = stringfind(result, '.',1,true)
+ if periodOff ~= nil then
+ -- strip trailing zeros
+ local chars = { stringbyte(result,1,#result) };
+ local lastNonZero = #chars
+ for i = #chars, periodOff, -1 do
+ if chars[i] ~= NULL_CHAR then lastNonZero=i; break; end
+ end
+ if lastNonZero ~= #chars then
+ -- Ah: we had at least one trailing zero.
+ -- discard all but the last.
+ lastNonZero = mathmax(periodOff+1,lastNonZero)
+ end
+ result = stringsub(result, 1, lastNonZero)
+ end
+ return result;
+end
+
+local function discardTrailingZerosFromMantissa(x)
+ local mantissaStart = stringfind(x, "e")
+
+ local mantissa = stringsub(x,1,mantissaStart-1)
+ local exponent = stringsub(x,mantissaStart)
+
+ return discardTrailingZeros(mantissa) .. exponent
+end
+
+
+-- a helper function which has no catcode issues when communicating with TeX:
+function pgfluamathfunctions.tostringfixed(x)
+ if x == nil then
+ return ""
+ end
+
+ return discardTrailingZeros(stringformat("%f", x))
+end
+
+-- converts an input number to a string which is accepted by the TeX FPU
+function pgfluamathfunctions.toTeXstring(x)
+ local result = ""
+ if x ~= nil then
+ if x == infty then result = "4Y0.0e0]"
+ elseif x == -infty then result = "5Y0.0e0]"
+ elseif isnan(x) then result = "3Y0.0e0]"
+ elseif x == 0 then result = "0Y0.0e0]"
+ else
+ result = discardTrailingZerosFromMantissa(stringformat("%.10e", x))
+ if x > 0 then
+ result = "1Y" .. result .. "]"
+ else
+ result = "2Y" .. stringsub(result,2) .. "]"
+ end
+ end
+ end
+ return result
+end
+
+return pgfluamathfunctions
diff --git a/graphics/pgf/contrib/pgfplots/tex/meshplothandler.lua b/graphics/pgf/contrib/pgfplots/tex/meshplothandler.lua
new file mode 100644
index 0000000000..dba97aaf35
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/meshplothandler.lua
@@ -0,0 +1,294 @@
+-- This file has dependencies to BOTH, the TeX part of pgfplots and the LUA part.
+-- It is the only LUA component with this property.
+--
+-- Its purpose is to encapsulate the communication between TeX and LUA in a central LUA file
+
+local pgfplotsmath = pgfplots.pgfplotsmath
+local error=error
+local table=table
+local string=string
+local tostring=tostring
+local type=type
+local io=io
+
+do
+-- all globals will be read from/defined in pgfplots:
+local _ENV = pgfplots
+
+
+-------------------------------------------------------
+-- A patch type.
+-- @see \pgfplotsdeclarepatchclass
+
+PatchType = newClass()
+
+function PatchType:constructor(name, numVertices)
+ self.name = name
+ self.numVertices = numVertices
+end
+
+function PatchType:__tostring()
+ return self.name
+end
+
+function PatchType:newPatch(coords)
+ return Patch.new(self,coords)
+end
+
+LinePatchType = newClassExtends(PatchType)
+
+function LinePatchType:constructor()
+ PatchType.constructor(self, "line", 2)
+end
+
+TrianglePatchType = newClassExtends(PatchType)
+
+function TrianglePatchType:constructor()
+ PatchType.constructor(self, "triangle", 3)
+end
+
+
+RectanglePatchType = newClassExtends(PatchType)
+
+function RectanglePatchType:constructor()
+ PatchType.constructor(self, "rectangle", 4)
+end
+
+-------------------------------------------------------
+--
+-- a single patch.
+-- @see \pgfplotsdeclarepatchclass
+
+Patch = newClass()
+
+function Patch:constructor(patchtype, coords)
+ if not patchtype or not coords then error("arguments must not be nil") end
+ if #coords ~= patchtype.numVertices then error("Unexpected number of coordinates provided; expected " .. tostring(patchtype.numVertices) .. " but got " .. tostring(#coords)) end
+
+ self.patchtype = patchtype
+ self.coords = coords
+end
+
+-------------------------------------------------------
+-- Replicates \pgfplotsplothandlermesh (to some extend)
+MeshPlothandler = newClassExtends(Plothandler)
+
+function MeshPlothandler:constructor(axis, pointmetainputhandler)
+ Plothandler.constructor(self,"mesh", axis, pointmetainputhandler)
+end
+
+-- see \pgfplot@apply@zbuffer
+function MeshPlothandler:reverseScanline(scanLineLength)
+ local coords = self.coords
+ local tmp
+ local scanlineOff
+ local numScanLines = #coords / scanLineLength
+ for scanline = 0,numScanLines-1,1 do
+ scanlineOff = scanline * scanLineLength
+ local reverseindex = scanlineOff + scanLineLength
+ for i = 0,scanLineLength/2-1,1 do
+ tmp = coords[1+scanlineOff+i]
+ coords[1+scanlineOff+i] = coords[reverseindex]
+ coords[reverseindex] = tmp
+
+ reverseindex = reverseindex-1
+ end
+ end
+end
+
+-- see \pgfplot@apply@zbuffer
+function MeshPlothandler:reverseTransposed(scanLineLength)
+ local coords = self.coords
+ local tmp
+ local scanlineOff
+ local numScanLines = #coords / scanLineLength
+ local reverseScanline = numScanLines-1
+ for scanline = 0,numScanLines/2-1,1 do
+ scanlineOff = 1+scanline * scanLineLength
+ reverseScanlineOff = 1+reverseScanline * scanLineLength
+ for i = 0,scanLineLength-1 do
+ tmp = coords[scanlineOff+i]
+ coords[scanlineOff+i] = coords[reverseScanlineOff+i]
+ coords[reverseScanlineOff+i] = tmp
+ end
+
+ reverseScanline = reverseScanline-1
+ end
+end
+
+-- see \pgfplot@apply@zbuffer
+function MeshPlothandler:reverseStream()
+ local coords = self.coords
+ local tmp
+ local reverseindex = #coords
+ for i = 1,#coords/2 do
+ tmp = coords[i]
+ coords[i] = coords[reverseindex]
+ coords[reverseindex] = tmp
+ reverseindex = reverseindex-1
+ end
+end
+
+
+
+-------------------------------------------------------
+--
+-- The (LUA!) visualizer for patch plots. It prepares stuff such that TeX only needs to work with lowlevel driver (PGF) streams.
+--
+
+MeshVisualizer = newClassExtends(PlotVisualizer)
+
+local COORDINATE_VALUE_OF_JUMPS = -16000
+local meshVisualizerTagEmptyCoordinates = function(pt)
+ pt.pgfXY= { COORDINATE_VALUE_OF_JUMPS, COORDINATE_VALUE_OF_JUMPS }
+ pt.x = { COORDINATE_VALUE_OF_JUMPS, COORDINATE_VALUE_OF_JUMPS, COORDINATE_VALUE_OF_JUMPS }
+end
+
+function MeshVisualizer:constructor(sourcePlotHandler, patchType, rows, cols, isXVariesOrdering, isMatrixInput, isMatrixOutput, isZBufferSort)
+ PlotVisualizer.constructor(self,sourcePlotHandler)
+ self.patchType = patchType
+ self.isMatrixInput = isMatrixInput
+ self.isMatrixOutput = isMatrixOutput
+ self.isZBufferSort = isZBufferSort
+ self.rows = rows
+ self.cols = cols
+ self.isXVariesOrdering =isXVariesOrdering
+
+ self.isOneDimMode= false
+ self.scanLineLength =-1
+ if isMatrixInput then
+ -- isOneDimMode is ONLY interesting for matrix input
+ if cols <= 1 or rows <=1 then
+ self.isOneDimMode = true
+ self.patchType = LinePatchType.new()
+ -- this is not yet implemented (and cannot happen since the TeX call does catch this)
+ error("UNSUPPORTED OPERATION EXCEPTION")
+ end
+
+ if isXVariesOrdering then
+ -- x varies (=rowwise)
+ self.scanLineLength = cols
+ else
+ -- y varies (=colwise)
+ self.scanLineLength = rows
+ end
+
+ self.notifyJump = meshVisualizerTagEmptyCoordinates
+ else
+ -- disable any special handling
+ self.isXVariesOrdering = true
+ end
+
+ -- log("initialized MeshVisualizer with " .. tostring(sourcePlotHandler) .. ", " .. tostring(patchType) .. ", isMatrixInput = " .. tostring(isMatrixInput) .. ", isMatrixOutput = " .. tostring(isMatrixOutput) .. ", isZBufferSort = " .. tostring(isZBufferSort) .. " rows = " ..tostring(rows) .. " cols = " ..tostring(cols) .. " is x varies=" .. tostring(isXVariesOrdering))
+end
+
+function MeshVisualizer:getVisualizationOutput()
+ local result = PlotVisualizer.getVisualizationOutput(self)
+
+ if self.isMatrixInput and not self.isMatrixOutput then
+ result = self:decodeIntoPatches(result)
+ end
+
+ if self.isZBufferSort then
+ result = self:applyZBufferSort(result)
+ end
+
+ return result
+end
+
+-- @param coords an array of Coord
+function MeshVisualizer:applyZBufferSort(coords)
+ -- in order to sort this thing, we need to compute the sort key (view depth) for each coord.
+ -- furthermore, each list entry must be single patch... that means we need a (huge?) temporary table.
+
+ local patchType = self.patchType
+ local numVertices = patchType.numVertices
+
+ if (#coords % numVertices) ~= 0 then error("Got an unexpected number of input coordinates: each patch has " .. tostring(numVertices) .. " vertices, but the number of coords " .. tostring(#coords) .. " is no multiple of this number") end
+ local numPatches = #coords / numVertices
+
+ -- STEP 1: compute an array of patches.
+ local patches = {}
+ local off=1
+ for i = 1,numPatches do
+ local patchCoords = {}
+ for j = 1,numVertices do
+ local pt = coords[off]
+ off = off+1
+ patchCoords[j] = pt
+ end
+ local patch = patchType:newPatch(patchCoords)
+ patches[i] = patch
+ end
+ if off ~= 1+#coords then error("Internal error: not all coordinates are part of patches (got " .. tostring(off) .. "/" .. tostring(#coords) ..")") end
+
+ -- STEP 2: assign the sort key: the "element depth".
+ --
+ -- the "element depth" is defined to be the MEAN of all
+ -- vertex depths.
+ -- And since the mean is 1/n * sum_{i=1}^n V_i, we can
+ -- directly omit the 1/n --- it is the same for every
+ -- vertex anyway, and we only want to compare the depth
+ -- values.
+ local axis = self.axis
+ local getVertexDepth = axis.getVertexDepth
+ for i=1,numPatches do
+ local patch = patches[i]
+ local patchcoords = patch.coords
+
+ local sumOfVertexDepth = 0
+ for j = 1,numVertices do
+ local vertex = patchcoords[j]
+
+ local vertexDepth = getVertexDepth(axis,vertex)
+
+ sumOfVertexDepth = sumOfVertexDepth + vertexDepth
+ end
+ patch.elementDepth = sumOfVertexDepth
+ end
+
+ -- STEP 3: SORT.
+ local comparator = function(patchA, patchB)
+ return patchA.elementDepth > patchB.elementDepth
+ end
+ table.sort(patches, comparator)
+
+ -- STEP 4: convert back into a list (in-place).
+ local off = 1
+ for i=1,numPatches do
+ local patch = patches[i]
+ local patchcoords = patch.coords
+ for j = 1,numVertices do
+ coords[off] = patchcoords[j]
+ off = off+1
+ end
+ end
+ if off ~= 1+#coords then error("Internal error: not all coordinates are part of patches (got " .. tostring(off) .. "/" .. tostring(#coords) ..")") end
+
+ return coords
+end
+
+function MeshVisualizer:decodeIntoPatches(coords)
+ local result = {}
+
+ local scanLineLength = self.scanLineLength
+ local length = #coords
+
+ local i = scanLineLength
+ while i < length do
+ local im = i-scanLineLength
+
+ for j = 2,scanLineLength do
+ table.insert(result, coords[im+j-1]) -- (i-1,j-1)
+ table.insert(result, coords[im+j]) -- (i-1,j )
+ table.insert(result, coords[i+j]) -- (i ,j )
+ table.insert(result, coords[i+j-1]) -- (i ,j-1)
+ end
+
+ i = i + scanLineLength
+ end
+
+ return result
+end
+
+end
diff --git a/graphics/pgf/contrib/pgfplots/tex/parser.lua b/graphics/pgf/contrib/pgfplots/tex/parser.lua
new file mode 100644
index 0000000000..072ac05854
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/parser.lua
@@ -0,0 +1,504 @@
+--------------------------------------------------------------------------------------------------
+------ 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
+------
+--
+-- Support for the contents of this file will NOT be done by the PGF/TikZ team.
+-- Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+-- with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+-- This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+----------------------------------------------------------------------------------------------------
+-- Date of this copy: Mi 6. Jan 11:32:04 CET 2016 ---
+
+
+
+-- Copyright 2011 by Christophe Jorssen and Mark Wibrow
+-- Copyright 2014 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.
+--
+-- $Id: parser.lua,v 1.3 2015/11/28 17:20:49 cfeuersaenger Exp $
+--
+-- usage:
+--
+-- pgfluamathparser = require("pgfplotsoldpgfsupp.luamath.parser")
+--
+-- local result = pgfluamathparser.pgfmathparse("1+ 2*4^2")
+--
+-- This LUA class has a direct backend in \pgfuselibrary{luamath}, see the documentation of that TeX package.
+
+local pgfluamathparser = pgfluamathparser or {}
+
+pgfluamathfunctions = require("pgfplotsoldpgfsupp.luamath.functions")
+
+-- lpeg is always present in luatex
+local lpeg = require("lpeg")
+
+local S, P, R = lpeg.S, lpeg.P, lpeg.R
+local C, Cc, Ct = lpeg.C, lpeg.Cc, lpeg.Ct
+local Cf, Cg, Cs = lpeg.Cf, lpeg.Cg, lpeg.Cs
+local V = lpeg.V
+local match = lpeg.match
+
+local space_pattern = S(" \n\r\t")^0
+local tex_unit =
+ P('pt') + P('mm') + P('cm') + P('in') +
+ -- while valid units, the font-depending ones need special attention... move them to the TeX side. For now.
+ -- P('ex') + P('em') +
+ P('bp') + P('pc') +
+ P('dd') + P('cc') + P('sp');
+
+local one_digit_pattern = R("09")
+local positive_integer_pattern = one_digit_pattern^1
+-- FIXME : it might be a better idea to remove '-' from all number_patterns! Instead, rely on the prefix operator 'neg' to implement negative numbers.
+-- Is that wise? It is certainly less efficient...
+local integer_pattern = S("+-")^-1 * positive_integer_pattern
+-- Valid positive decimals are |xxx.xxx|, |.xxx| and |xxx.|
+local positive_integer_or_decimal_pattern = positive_integer_pattern * ( P(".") * one_digit_pattern^0)^-1 +
+ (P(".") * one_digit_pattern^1)
+local integer_or_decimal_pattern = S("+-")^-1 * positive_integer_or_decimal_pattern
+local fpu_pattern = R"05" * P"Y" * positive_integer_or_decimal_pattern * P"e" * S("+-")^-1 * R("09")^1 * P"]"
+local unbounded_pattern = P"inf" + P"INF" + P"nan" + P"NaN" + P"Inf"
+local number_pattern = C(unbounded_pattern + fpu_pattern + integer_or_decimal_pattern * (S"eE" * integer_pattern + C(tex_unit))^-1)
+
+local underscore_pattern = P("_")
+
+local letter_pattern = R("az","AZ")
+local alphanum__pattern = letter_pattern + one_digit_pattern + underscore_pattern
+
+local identifier_pattern = letter_pattern^1 * alphanum__pattern^0
+
+local openparen_pattern = P("(") * space_pattern
+local closeparen_pattern = P(")")
+local opencurlybrace_pattern = P("{")
+local closecurlybrace_pattern = P("}")
+local openbrace_pattern = P("[")
+local closebrace_pattern = P("]")
+
+-- hm. what about '\\' or '\%' ?
+-- accept \pgf@x, \count0, \dimen42, \c@pgf@counta, \wd0, \ht0, \dp 0
+local controlsequence_pattern = P"\\" * C( (R("az","AZ") + P"@")^1) * space_pattern* C( R"09"^0 )
+
+-- local string = P('"') * C((1 - P('"'))^0) * P('"')
+
+local comma_pattern = P(",") * space_pattern
+
+
+----------------
+local TermOp = C(S("+-")) * space_pattern
+local EqualityOp = C( P"==" + P"!=" ) * space_pattern
+local RelationalOp = C( P"<=" + P">=" + P"<" + P">" ) * space_pattern
+local FactorOp = C(S("*/")) * space_pattern
+
+-- Grammar
+local Exp, Term, Factor = V"Exp", V"Term", V"Factor"
+local Prefix = V"Prefix"
+local Postfix = V"Postfix"
+
+
+
+local function eval (v1, op, v2)
+ if (op == "+") then return v1 + v2
+ elseif (op == "-") then return v1 - v2
+ elseif (op == "*") then return v1 * v2
+ elseif (op == "/") then return v1 / v2
+ else
+ error("This function must not be invoked for operator "..op)
+ end
+end
+
+local pgfStringToFunctionMap = pgfluamathfunctions.stringToFunctionMap
+local function function_eval(name, ... )
+ local f = pgfStringToFunctionMap[name]
+ if not f then
+ error("Function '" .. name .. "' is undefined (did not find pgfluamathfunctions."..name .." (looked into pgfluamathfunctions.stringToFunctionMap))")
+ end
+ -- FIXME: validate signature
+ return f(...)
+end
+
+
+local func =
+ (C(identifier_pattern) * space_pattern * openparen_pattern * Exp * (comma_pattern * Exp)^0 * closeparen_pattern) / function_eval;
+
+local functionWithoutArg = identifier_pattern / function_eval
+
+-- this is what can occur as exponent after '^'.
+-- I have the impression that the priorities could be implemented in a better way than this... but it seems to work.
+local pow_exponent =
+ -- allows 2^-4, 2^1e4, 2^2
+ -- FIXME : why not 2^1e2 ?
+ Cg(C(integer_or_decimal_pattern)
+ -- 2^pi, 2^multiply(2,2)
+ + Cg(func+functionWithoutArg)
+ -- 2^(2+2)
+ + openparen_pattern * Exp * closeparen_pattern )
+
+local function prefix_eval(op, x)
+ if op == "-" then
+ return pgfluamathfunctions.neg(x)
+ elseif op == "!" then
+ return pgfluamathfunctions.notPGF(x)
+ else
+ error("This function must not be invoked for operator "..op)
+ end
+end
+
+
+local prefix_operator = C( S"-!" )
+local prefix_operator_pattern = (prefix_operator * space_pattern * Cg(Prefix) ) / prefix_eval
+
+-- apparently, we need to distinghuish between <expr> ! and <expr> != <expr2>:
+local postfix_operator = C( S"r!" - P"!=" ) + C(P"^") * space_pattern * pow_exponent
+
+
+local ternary_eval = pgfluamathfunctions.ifthenelse
+
+local factorial_eval = pgfluamathfunctions.factorial
+local deg = pgfluamathfunctions.deg
+local pow_eval = pgfluamathfunctions.pow
+
+-- @param prefix the argument before the postfix operator.
+-- @param op either nil or the postfix operator
+-- @param arg either nil or the (mandatory) argument for 'op'
+local function postfix_eval(prefix, op, arg)
+ local result
+ if op == nil then
+ result = prefix
+ elseif op == "r" then
+ if arg then error("parser setup error: expected nil argument") end
+ result = deg(prefix)
+ elseif op == "!" then
+ if arg then error("parser setup error: expected nil argument") end
+ result = factorial_eval(prefix)
+ elseif op == "^" then
+ if not arg then error("parser setup error: ^ with its argument") end
+ result = pow_eval(prefix, arg)
+ else
+ error("Parser setup error: " .. tostring(op) .. " unexpected in this context")
+ end
+ return result
+end
+
+local function equality_eval(v1, op, v2)
+ local fct
+ if (op == "==") then fct = pgfluamathfunctions.equal
+ elseif (op == "!=") then fct = pgfluamathfunctions.notequal
+ else
+ error("This function must not be invoked for operator "..op)
+ end
+ return fct(v1,v2)
+end
+local function relational_eval(v1, op, v2)
+ local fct
+ if (op == "<") then fct = pgfluamathfunctions.less
+ elseif (op == ">") then fct = pgfluamathfunctions.greater
+ elseif (op == ">=") then fct = pgfluamathfunctions.notless
+ elseif (op == "<=") then fct = pgfluamathfunctions.notgreater
+ else
+ error("This function must not be invoked for operator "..op)
+ end
+ return fct(v1,v2)
+end
+
+-- @return either the box property or nil
+-- @param cs "wd", "ht", or "dp"
+-- @param intSuffix some integer
+local function get_tex_box(cs, intSuffix)
+ -- assume get_tex_box is only called when a dimension is required.
+ local result
+ pgfluamathparser.units_declared = true
+ local box =tex.box[tonumber(intSuffix)]
+ if not box then error("There is no box " .. intSuffix) end
+ if cs == "wd" then
+ result = box.width / 65536
+ elseif cs == "ht" then
+ result = box.height / 65536
+ elseif cs == "dp" then
+ result = box.depth / 65536
+ else
+ result = nil
+ end
+ return result
+end
+
+
+local function controlsequence_eval(cs, intSuffix)
+ local result
+ if intSuffix and #intSuffix >0 then
+ if cs == "count" then
+ result= pgfluamathparser.get_tex_count(intSuffix)
+ elseif cs == "dimen" then
+ result= pgfluamathparser.get_tex_dimen(intSuffix)
+ else
+ result = get_tex_box(cs,intSuffix)
+ if not result then
+ -- this can happen - we cannot expand \chardef'ed boxes here.
+ -- this will be done by the TeX part
+ error('I do not know/support the TeX register "\\' .. cs .. '"')
+ end
+ end
+ else
+ result = pgfluamathparser.get_tex_register(cs)
+ end
+ return result
+end
+
+pgfluamathparser.units_declared = false
+function pgfluamathparser.get_tex_register(register)
+ -- register is a string which could be a count or a dimen.
+ if pcall(tex.getcount, register) then
+ return tex.count[register]
+ elseif pcall(tex.getdimen, register) then
+ pgfluamathparser.units_declared = true
+ return tex.dimen[register] / 65536 -- return in points.
+ else
+ error('I do not know the TeX register "' .. register .. '"')
+ return nil
+ end
+
+end
+
+function pgfluamathparser.get_tex_count(count)
+ -- count is expected to be a number
+ return tex.count[tonumber(count)]
+end
+
+function pgfluamathparser.get_tex_dimen(dimen)
+ -- dimen is expected to be a number
+ pgfluamathparser.units_declared = true
+ return tex.dimen[tonumber(dimen)] / 65536
+end
+
+function pgfluamathparser.get_tex_sp(dimension)
+ -- dimension should be a string
+ pgfluamathparser.units_declared = true
+ return tex.sp(dimension) / 65536
+end
+
+
+local initialRule = V"initial"
+
+local Summand = V"Summand"
+local Relational = V"Relational"
+local Equality = V"Equality"
+local LogicalOr = V"LogicalOr"
+local LogicalAnd = V"LogicalAnd"
+
+local pgftonumber = pgfluamathfunctions.tonumber
+local tonumber_withunit = pgfluamathparser.get_tex_sp
+local function number_optional_units_eval(x, unit)
+ if not unit then
+ return pgftonumber(x)
+ else
+ return tonumber_withunit(x)
+ end
+end
+
+-- @param scale the number.
+-- @param controlsequence either nil in which case just the number must be returned or a control sequence
+-- @see controlsequence_eval
+local function scaled_controlsequence_eval(scale, controlsequence, intSuffix)
+ if controlsequence==nil then
+ return scale
+ else
+ return scale * controlsequence_eval(controlsequence, intSuffix)
+ end
+end
+
+-- Grammar
+--
+-- for me:
+-- - use '/' to evaluate all expressions which contain a _constant_ number of captures.
+-- - use Cf to evaluate expressions which contain a _dynamic_ number of captures
+--
+-- see unittest_luamathparser.tex for tons of examples
+local G = P{ "initialRule",
+ initialRule = space_pattern* Exp * -1;
+ -- ternary operator (or chained ternary operators):
+ -- FIXME : is this chaining a good idea!?
+ Exp = Cf( LogicalOr * Cg(P"?" * space_pattern * LogicalOr * P":" *space_pattern * LogicalOr )^0, ternary_eval) ;
+ LogicalOr = Cf(LogicalAnd * (P"||" * space_pattern * LogicalAnd)^0, pgfluamathfunctions.orPGF);
+ LogicalAnd = Cf(Equality * (P"&&" * space_pattern * Equality)^0, pgfluamathfunctions.andPGF);
+ Equality = Cf(Relational * Cg(EqualityOp * Relational)^0, equality_eval);
+ Relational = Cf(Summand * Cg(RelationalOp * Summand)^0, relational_eval);
+ Summand = Cf(Term * Cg(TermOp * Term)^0, eval) ;
+ Term = Cf(Prefix * Cg(FactorOp * Prefix)^0, eval);
+ Prefix = prefix_operator_pattern + Postfix;
+ -- this calls 'postfix_eval' with nil arguments if it is no postfix operation.. but that does not hurt (right?)
+ Postfix = Factor * (postfix_operator * space_pattern)^-1 / postfix_eval;
+ Factor =
+ (
+ number_pattern / number_optional_units_eval *
+ -- this construction will evaluate number_pattern with 'number_optional_units_eval' FIRST.
+ -- also accept '0.5 \pgf@x' here:
+ space_pattern *controlsequence_pattern^-1 / scaled_controlsequence_eval
+ + func
+ + functionWithoutArg
+ + openparen_pattern * Exp * closeparen_pattern
+ + controlsequence_pattern / controlsequence_eval
+ ) *space_pattern
+ ;
+}
+
+-- does not reset units_declared.
+local function pgfmathparseinternal(str)
+ local result = match(G,str)
+ if result == nil then
+ error("The string '" .. str .. "' is no valid PGF math expression. Please check for syntax errors.")
+ end
+ return result
+end
+
+
+-- This is the math parser function in this module.
+--
+-- @param str a string like "1+1" which is accepted by the PGF math language
+-- @return the result of the expression.
+--
+-- Throws an error if the string is no valid expression.
+function pgfluamathparser.pgfmathparse(str)
+ pgfluamathparser.units_declared = false
+
+ return pgfmathparseinternal(str)
+end
+
+local pgfmathparse = pgfluamathparser.pgfmathparse
+local tostringfixed = pgfluamathfunctions.tostringfixed
+local tostringfpu = pgfluamathfunctions.toTeXstring
+
+local tmpFunctionArgumentPrefix = "tmpVar"
+local stackOfLocalFunctions = {}
+
+-- This is a backend for PGF's 'declare function'.
+-- \tikzset{declare function={mu(\x,\i)=\x^\i;}}
+-- will boil down to
+-- pgfluamathparser.declareExpressionFunction("mu", 2, "#1^#2")
+--
+-- The local function will be pushed on a stack of known local functions and is
+-- available until popLocalExpressionFunction() is called. TeX will call this using
+-- \aftergroup.
+--
+-- @param name the name of the new function
+-- @param numArgs the number of arguments
+-- @param expression an expression containing #1, ... #n where n is numArgs
+--
+-- ATTENTION: local functions behave DIFFERENTLY in LUA!
+-- In LUA, local variables are not expanded whereas TeX expands them.
+-- The difference is
+--
+-- declare function={mu1(\x,\i)=\x^\i;}
+-- \pgfmathparse{mu1(-5,2)} --> -25
+-- \pgfluamathparse{mu1(-5,2)} --> 25
+--
+-- x = -5
+-- \pgfmathparse{mu1(x,2)} --> 25
+-- \pgfluamathparse{mu1(x,2)} --> 25
+--
+-- In an early prototype, I simulated TeX's expansion to fix the first case (successfully).
+-- BUT: that "simulated expansion" broke the second case because LUA will evaluate "x" and hand -5 to the local function.
+-- I decided to keep it as is. Perhaps we should fix PGF's expansion approach in TeX (which is ugly anyway)
+function pgfluamathparser.pushLocalExpressionFunction(name, numArgs, expression)
+ -- now we have "tmpVar1^tmpVar2" instead of "#1^#2"
+ local normalizedExpr = expression:gsub("#", tmpFunctionArgumentPrefix)
+ local restores = {}
+ local tmpVars = {}
+ for i=1,numArgs do
+ local tmpVar = tmpFunctionArgumentPrefix .. tostring(i)
+ tmpVars[i] = tmpVar
+ end
+
+ local newFunction = function(...)
+ local args = table.pack(...)
+
+ -- define "tmpVar1" ... "tmpVarN" to return args[i].
+ -- Of course, we need to restore "tmpVar<i>" after we return!
+ for i=1,numArgs do
+ local tmpVar = tmpVars[i]
+ local value = args[i]
+ restores[i] = pgfStringToFunctionMap[tmpVar]
+ pgfStringToFunctionMap[tmpVar] = function () return value end
+ end
+
+ -- parse our expression.
+
+ -- FIXME : this here is an attempt to mess around with "units_declared".
+ -- It would be better to call pgfmathparse and introduce some
+ -- semaphore to check if pgfmathparse is a nested call-- in this case, it should
+ -- not reset units_declared. But there is no "finally" block and pcall is crap (looses stack trace).
+ local success,result = pcall(pgfmathparseinternal, normalizedExpr)
+
+ -- remove 'tmpVar1', ... from the function table:
+ for i=1,numArgs do
+ local tmpVar = tmpVars[i]
+ pgfStringToFunctionMap[tmpVar] = restores[i]
+ end
+
+ if success==false then error(result) end
+ return result
+ end
+ table.insert(stackOfLocalFunctions, name)
+ pgfStringToFunctionMap[name] = newFunction
+end
+
+function pgfluamathparser.popLocalExpressionFunction()
+ local name = stackOfLocalFunctions[#stackOfLocalFunctions]
+ pgfStringToFunctionMap[name] = nil
+ -- this removes the last element:
+ table.remove(stackOfLocalFunctions)
+end
+
+
+-- A Utility function which simplifies the interaction with the TeX code
+-- @param expression the input expression (string)
+-- @param outputFormatChoice 0 if the result should be a fixed point number, 1 if it should be in FPU format
+-- @param showErrorMessage (boolean) true if any error should be displayed, false if errors should simply result in an invocation of TeX's parser (the default)
+--
+-- it defines \pgfmathresult and \ifpgfmathunitsdeclared
+function pgfluamathparser.texCallParser(expression, outputFormatChoice, showErrorMessage)
+ local success, result
+ if showErrorMessage then
+ result = pgfmathparse(expression)
+ success = true
+ else
+ success, result = pcall(pgfmathparse, expression)
+ end
+
+ if success and result then
+ local result_str
+ if outputFormatChoice == 0 then
+ -- luamath/output format=fixed
+ result_str = tostringfixed(result)
+ else
+ -- luamath/output format=fixed
+ result_str = tostringfpu(result)
+ end
+ tex.sprint("\\def\\pgfmathresult{" .. result_str .. "}")
+ if pgfluamathparser.units_declared then
+ tex.sprint("\\pgfmathunitsdeclaredtrue")
+ else
+ tex.sprint("\\pgfmathunitsdeclaredfalse")
+ end
+ else
+ tex.sprint("\\def\\pgfmathresult{}")
+ tex.sprint("\\pgfmathunitsdeclaredfalse")
+ end
+end
+
+return pgfluamathparser
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgflibraryfillbetween.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgflibraryfillbetween.code.tex
new file mode 100644
index 0000000000..d17fff3e2f
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibraryfillbetween.code.tex
@@ -0,0 +1,1265 @@
+% Copyright 2013 by Christian Feuersaenger
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Free Documentation License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+
+\usepgflibrary{intersections}
+
+\pgfutil@IfUndefined{pgf@intersections@version}{%
+ \input pgfplotsoldpgfsupp_pgflibraryintersections.code.tex
+}{%
+}%
+
+% FIXME : ARCHITECTURE VIOLATION: REQUIRES
+% \usetikzlibrary{decorations.softclip}
+%
+%\usepgfmodule{decorations}
+
+\newif\ifpgfpathfillbetween@split
+
+\pgfkeys{%
+ /pgf/fill between/reverse/.is choice,
+ /pgf/fill between/reverse/.default=true,
+ /pgf/fill between/reverse/false/.code=\def\pgfpathfillbetween@reverse@mode{0},%
+ /pgf/fill between/reverse/true/.code=\def\pgfpathfillbetween@reverse@mode{1},%
+ %
+ % checks the coordinates of the first two path instructions as heuristics:
+ /pgf/fill between/reverse/auto/.code=\def\pgfpathfillbetween@reverse@mode{2},%
+ /pgf/fill between/reverse/auto,
+ /pgf/fill between/inner moveto/.is choice,
+ /pgf/fill between/inner moveto/connect/.code=\def\pgfpathfillbetween@inner@moveto{1},
+ /pgf/fill between/inner moveto/keep/.code=\def\pgfpathfillbetween@inner@moveto{2},
+ /pgf/fill between/inner moveto/connect,
+ %
+ % split=true allows to generate individual result paths for every
+ % region induced by the intersection points. Example:
+ % "color positive region in red and negative region in green".
+ % The case split=false results in just one output path
+ % (simpler+faster, but of course less powerful).
+ /pgf/fill between/split/.is if=pgfpathfillbetween@split,
+ /pgf/fill between/split/.default=true,
+ %
+ % Used to report results. This is mainly useful in conjunction
+ % with split=true: each result segment will be streamed.
+ %
+ % Results are reported in the sequence
+ % begin
+ % next ready
+ % next ready
+ % ...
+ % end
+ %
+ % 'begin' has one arguments: the number of following single
+ % streams.
+ /pgf/fill between/result stream/begin/.code=,%
+ %
+ % 'next ready' has macro arguments, but the macro \pgfretval
+ % contains the lowlevel path as result (i.e. you can write
+ % \pgfsetpath\pgfretval to activate it).
+ /pgf/fill between/result stream/next ready/.code={
+ \pgfaddpathandBB{\pgfretval}%
+ },%
+ %
+ % 'end' has no arguments.
+ /pgf/fill between/result stream/end/.code=,%
+ %
+ /pgf/fill between/omit empty segments/.is choice,
+ /pgf/fill between/omit empty segments/.default=true,
+ /pgf/fill between/omit empty segments/false/.code=\def\pgfpathfillbetween@omit@empty@segments{0},%
+ /pgf/fill between/omit empty segments/true/.code=\def\pgfpathfillbetween@omit@empty@segments{1},%
+ /pgf/fill between/omit empty segments/true,
+}%
+
+% \pgfpathfillbetween[<options>]{<first path>}{<second path>}
+%
+% Generates a new path consisting of the "fill between" of the two arguments.
+% #1: optional arguments with /pgf/fill between prefix
+% #2: a macro containing the first path. More precisely, it is supposed to be a return value of \pgfgetpath.
+% #3: a macro containing the second path (in a format understood by \pgfsetpath). It is supposed to be a return value of \pgfgetpath.
+\def\pgfpathfillbetween{\pgfutil@ifnextchar[{\pgfpathfillbetween@opt}{\pgfpathfillbetween@opt[]}}%
+\def\pgfpathfillbetween@opt[#1]#2#3{%
+ \begingroup
+ \pgfqkeys{/pgf/fill between}{#1}%
+ %
+ % remove any special round-corner-tokens:
+ \pgfprocessround{#2}{#2}%
+ \pgfprocessround{#3}{#3}%
+ %
+ \if1\pgfpathfillbetween@inner@moveto
+ % inner moveto=connect:
+ \pgfpathfillbetween@connect@inner@movetos#2%
+ \pgfpathfillbetween@connect@inner@movetos#3%
+ \fi
+ %
+ \if2\pgfpathfillbetween@reverse@mode
+ % reverse=auto
+ \expandafter\pgfpathfillbetween@heuristics@get@direction#2\pgf@stop
+ \let\pgfpath@filled@dir@first=\pgfretval
+ \expandafter\pgfpathfillbetween@heuristics@get@direction#3\pgf@stop
+ \let\pgfpath@filled@dir@second=\pgfretval
+ %
+ \ifx\pgfpath@filled@dir@first\pgfpath@filled@dir@second
+ % Ok, they (seem to) have the same direction. Reverse one of them:
+ \def\pgfpathfillbetween@reverse@mode{1}%
+ \else
+ \def\pgfpathfillbetween@reverse@mode{0}%
+ \fi
+ \fi
+ %
+ % softclip, if configured (no-op otherwise):
+ \pgfpathcomputesoftclippath{#2}{\pgfpathfillbetween@softclip@A}\let#2=\pgfretval%
+ \pgfpathcomputesoftclippath{#3}{\pgfpathfillbetween@softclip@B}\let#3=\pgfretval%
+ %
+ \ifx#2\pgfutil@empty
+ \ifx\pgfpathfillbetween@softclip@A\pgfutil@empty
+ \pgfpathfillbetween@warning{first}%
+ \else
+ \pgfpathfillbetween@warning{soft-clipped first}%
+ \fi
+ \else
+ \ifx#3\pgfutil@empty
+ \ifx\pgfpathfillbetween@softclip@B\pgfutil@empty
+ \pgfpathfillbetween@warning{second}%
+ \else
+ \pgfpathfillbetween@warning{soft-clipped second}%
+ \fi
+ \else
+ %
+ \ifpgfpathfillbetween@split
+ \pgfpathfillbetween@compute@splitted{#2}{#3}%
+ \else
+ \pgfkeys{/pgf/fill between/result stream/begin=1}%
+ \pgfpathfillbetween@compute{#2}{#3}%
+ \pgfpathfillbetween@invoke{result stream/next ready}%
+ \pgfpathfillbetween@invoke{result stream/end}%
+ \fi
+ \fi
+ \fi
+ %
+ %
+ \endgroup
+}%
+
+\def\pgfpathfillbetween@warning#1{%
+ \pgfwarning{fill between skipped: the #1 input path is empty.}%
+}%
+
+% Replaces all 'moveto' operations inside of the soft path '#1' by
+% 'lineto'. This excludes the first moveto.
+%
+% The motivation is that fillbetween should ignore inner movetos.
+%
+% UPDATE: it turned out that replacing inner movetos is necessary, but
+% not sufficient. Now, this macro does more:
+% - it replaces isolated inner movetos by lineto
+% - if two successive inner movetos occur, it throws away the first
+% one replaces the second by lineto
+% - if one or more trailing movetos occur in a path, these will be
+% thrown away.
+\def\pgfpathfillbetween@connect@inner@movetos#1{%
+ \expandafter\pgfpathfillbetween@connect@inner@movetos@#1\pgf@stop%
+ \let#1=\pgfretval
+}
+\def\pgfpathfillbetween@connect@inner@movetos@#1#2\pgf@stop{%
+ \ifx#1\pgfsyssoftpath@movetotoken
+ \pgfpathfillbetween@connect@inner@movetos@@{#2}%
+ \expandafter\def\expandafter\pgfretval\expandafter{\expandafter\pgfsyssoftpath@movetotoken\pgfretval}%
+ \else
+ \pgfpathfillbetween@connect@inner@movetos@@{#1#2}%
+ \fi
+}%
+
+% Substitute all movetotokens by linetotokens.
+%
+% In addition, it should *deduplicate* movetos, i.e.
+% "moveto{<x>}{<y}moveto{<x2>}{<y2>}"
+% -> "moveto{<x2>}{<y2>}"
+%
+% and: trailing movetos should be discarded.
+\def\pgfpathfillbetween@connect@inner@movetos@@#1{%
+ % this implementation is derived from \pgfutilstrreplace - it does
+ % almost the same as
+ % s/\pgfsyssoftpath@movetotoken/pgfsyssoftpath@linetotoken/g
+ % -> but with the extra additions of deduplication and trailing
+ % moveto removal.
+ \def\pgfretval{}%
+ \pgfpathfillbetween@search@and@replace@loop{#1}%
+}
+\def\pgfpathfillbetween@connect@inner@moveto@foundit@#1\pgfsyssoftpath@movetotoken#2#3#4{%
+ \ifx#4\pgf@EOI
+ % ah - a trailing moveto.
+ % In this case, we remember all until the moveto, but we omit
+ % the trailing moveto and its arguments.
+ \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #1}%
+ %
+ % ... and stop searching.
+ \let\pgf@loc@TMPa\relax
+ \else
+ \ifx#4\pgfsyssoftpath@movetotoken
+ % DEDUPLICATE: we have at least two successive movetos.
+ % silently skip the first moveto and its arguments and go on
+ % with the second moveto.
+ \def\pgf@loc@TMPa{\pgfpathfillbetween@connect@inner@moveto@foundit@#1\pgfsyssoftpath@movetotoken}%
+ \else
+ % substitute it by a lineto.
+ \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #1\pgfsyssoftpath@linetotoken{#2}{#3}}%
+ %
+ % ... continue the standard loop which skips over paths
+ % until the next moveto. Remember to re-insert '#4':
+ \def\pgf@loc@TMPa{\pgfpathfillbetween@connect@inner@moveto@foundit@@ #4}%
+ \fi
+ \fi
+ \pgf@loc@TMPa
+}%
+\def\pgfpathfillbetween@connect@inner@moveto@foundit@@#1\pgf@EOI{%
+ \pgfpathfillbetween@search@and@replace@loop{#1}%
+}%
+
+\def\pgfpathfillbetween@search@and@replace@loop#1{%
+ \pgfutil@in@{\pgfsyssoftpath@movetotoken}{#1}%
+ \ifpgfutil@in@
+ \def\pgf@loc@TMPa{\pgfpathfillbetween@connect@inner@moveto@foundit@ #1\pgf@EOI}%
+ \else
+ \expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #1}%
+ \let\pgf@loc@TMPa=\relax
+ \fi
+ \pgf@loc@TMPa
+}%
+
+\def\pgfpathfillbetween@invoke#1{\pgfkeysvalueof{/pgf/fill between/#1/.@cmd}\pgfeov}
+
+\def\pgfpathfillbetween@replace@first@moveto#1#2\pgf@stop{%
+ \ifx#1\pgfsyssoftpath@movetotoken
+ \def\pgfretval{\pgfsyssoftpath@linetotoken #2}%
+ \else
+ \def\pgfretval{#1#2}%
+ \fi
+}%
+
+\def\pgfpathfillbetween@compute@splitted#1#2{%
+ % 0. normalize path sequences.
+ % ATTENTION : there are implicit assumptions on the INTERNAL ORDER of the two paths!
+ % This implementation needs to loop over them synchronously, i.e. it processes
+ % the 0.th segment of a and the 0th of b,
+ % the 1.th segment of a and the 1th of b,
+ % and so on. Here, "i th segment" implies a sort order in ascending x direction.
+ % This is, however, a weakness of \pgfintersectionofpaths - it does not really support this kind of sorting.
+ %
+ % I work around this by restricting the implementation to the "common use-cases", i.e. to two plots of functions which do not intersect themselves (i.e. to "functions" in the original sense). This will probably (almost surely) fail for parametric functions or circles.
+ %
+ \if0\pgfpathfillbetween@reverse@mode
+ % reverse=false
+ %
+ % This means one plot is in direction '+' and one in '-', i.e.
+ % a: x ---> x ---> x
+ % b: x <--- x <--- x
+ %
+ % However, we have the implicit assumption that both paths can be processed synchronously, i.e. that they have the SAME direction.
+ % To this end, we have to reverse one of them here (since \pgfintersectionofpaths does not automatically sort results in a suitable way):
+ %
+ \pgf@reverse@path{#2}%
+ \let#2=\pgfretval
+ %
+ % However, we need to re-reverse the individual segments later-on...
+ % So: set 'reverse=true'. Will be respected when assembling the splitted segments...
+ \def\pgfpathfillbetween@reverse@mode{1}%
+ \fi
+ %
+ % 1. compute intersection points:
+ \pgf@intersect@sort@by@second@pathfalse
+ %
+ % FIXME : do we want to sort by time!? That might be needed for curvetos ... ?
+ \pgf@intersect@sortfalse
+ \pgfintersectionofpaths%
+ {%
+ \pgfsetpath#1%
+ }%
+ {%
+ \pgfsetpath#2%
+ }%
+ %
+ % FIXME : computing the intersections is fine... but it would be
+ % even finer to report the resulting points back to tikz!
+ % -> call the *tikz* intersection lib through some sort of callback!?
+ %
+ % 2. split the first involved path into the
+ % segments induced by the intersection points:
+ \pgfcomputeintersectionsegments{1}%
+ \let\pgfpathfilled@a@segments=\pgfretval
+%
+ % 2. split the second involved path into the
+ % segments induced by the intersection points:
+ \pgfcomputeintersectionsegments{2}%
+ \let\pgfpathfilled@b@segments=\pgfretval
+ %
+ \ifnum\pgfpathfilled@a@segments=\pgfpathfilled@b@segments\relax
+ \else
+ \pgferror{Illegal internal state encountered: the number segments induced by the intersection points of the two paths DIFFER between the first and the second path: first path has \pgfpathfilled@a@segments\space whereas the second has \pgfpathfilled@b@segments.}%
+ \fi
+ %
+ % STEP 1: find out if there are empty segments. Numerical
+ % inaccuracies occasionally result in such segments; we silently
+ % skip them.
+ \def\c@pgfpathfilled@nonemptysegments{0}%
+ \def\c@pgfpathfilled@counter{0}%
+ \pgfmathloop
+ \ifnum\c@pgfpathfilled@counter<\pgfpathfilled@a@segments\relax
+ \expandafter\let\expandafter\pgf@loc@path@a\csname pgf@intersect@path@split@a@\c@pgfpathfilled@counter\endcsname
+ \expandafter\let\expandafter\pgf@loc@path@b\csname pgf@intersect@path@split@b@\c@pgfpathfilled@counter\endcsname
+ %
+ \if1\pgfpathfillbetween@omit@empty@segments
+ \pgfpathfillbetween@compute@checkempty{\pgf@loc@path@a}%
+ % A segment is empty if BOTH of its input segments are empty:
+ \if1\pgfretval
+ \pgfpathfillbetween@compute@checkempty{\pgf@loc@path@b}%
+ \if1\pgfretval
+ \pgfutil@IfUndefined{pgfplots@log}{}{%
+ \pgfplots@log4{fillbetween: skipping empty intersection segment no \c@pgfpathfilled@counter}%
+ }%
+ \expandafter\def\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname{1}%
+ \else
+ \expandafter\def\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname{0}%
+ \pgfutil@advancestringcounter\c@pgfpathfilled@nonemptysegments
+ \fi
+ \else
+ \expandafter\def\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname{0}%
+ \pgfutil@advancestringcounter\c@pgfpathfilled@nonemptysegments
+ \fi
+ \else
+ \expandafter\def\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname{0}%
+ \pgfutil@advancestringcounter\c@pgfpathfilled@nonemptysegments
+ \fi
+ %
+ \pgfutil@advancestringcounter\c@pgfpathfilled@counter
+ \repeatpgfmathloop
+ %
+ \ifnum\c@pgfpathfilled@nonemptysegments=0
+ \else
+ \pgfkeys{/pgf/fill between/result stream/begin=\c@pgfpathfilled@nonemptysegments}%
+ % Recombine the pairs of segments (a_i, b_i), i = 0,..., N-1 in a
+ % filled way:
+ \def\c@pgfpathfilled@counter{0}%
+ \pgfmathloop
+ \ifnum\c@pgfpathfilled@counter<\pgfpathfilled@a@segments\relax
+ \if0\csname pgf@interset@path@empty@\c@pgfpathfilled@counter\endcsname
+ \expandafter\let\expandafter\pgf@loc@path@a\csname pgf@intersect@path@split@a@\c@pgfpathfilled@counter\endcsname
+ \expandafter\let\expandafter\pgf@loc@path@b\csname pgf@intersect@path@split@b@\c@pgfpathfilled@counter\endcsname
+ %
+ \pgfpathfillbetween@compute{\pgf@loc@path@a}{\pgf@loc@path@b}%
+ % report to the result stream. It knows how to deal with it:
+ \pgfpathfillbetween@invoke{result stream/next ready}%
+ %
+ \fi
+ \pgfutil@advancestringcounter\c@pgfpathfilled@counter
+ \repeatpgfmathloop
+ \pgfpathfillbetween@invoke{result stream/end}%
+ \fi
+}
+
+\def\pgflibraryfillbetweenemptysegmenttolerance{1pt}
+
+\def\pgfpathfillbetween@compute@checkempty#1{%
+ \def\pgfretval{0}%
+ \pgf@compute@BB{#1}%
+ \advance\pgf@xb by-\pgf@xa
+ \advance\pgf@yb by-\pgf@ya
+ % if one of the dimensions is empty, the segment is empty:
+ \ifdim\pgf@xb<\pgflibraryfillbetweenemptysegmenttolerance\relax
+ \def\pgfretval{1}%
+ \fi
+ \ifdim\pgf@yb<\pgflibraryfillbetweenemptysegmenttolerance\relax
+ \def\pgfretval{1}%
+ \fi
+}
+
+\def\pgfpathfillbetween@compute#1#2{%
+%\message{Combination of ^^J \meaning#1\space and ^^J \meaning#2...^^J}%
+ %
+ \if1\pgfpathfillbetween@reverse@mode
+ % reverse=true
+ %
+ % Ok, then reverse one of the paths. We choose the second one as that is easier to debug.
+ % FIXME : might make sense to determine which one is shorter...
+ \pgf@reverse@path{#2}%
+ \let#2=\pgfretval
+ \fi
+ %
+ % FIXME: what should I do if I have closed paths!? What is the
+ % expected behavior!? I know that the combination of two closed
+ % paths should probably be used as is, perhaps with even-odd-rule.
+ % This here should do the job.
+ %
+ % NOTE: I believe the 'split' fails to work with closed paths.
+ \pgfpathfillbetween@contains@closepathtoken{#1}%
+ \let\b@pgfpathfillbetween@contains@close@a=\pgfretval
+ \pgfpathfillbetween@contains@closepathtoken{#2}%
+ \let\b@pgfpathfillbetween@contains@close@b=\pgfretval
+ %
+ \def\b@pgfpathfillbetween@contains@close{0}%
+ \if1\b@pgfpathfillbetween@contains@close@b
+ \def\b@pgfpathfillbetween@contains@close{1}%
+ \fi
+ \if1\b@pgfpathfillbetween@contains@close@a
+ \def\b@pgfpathfillbetween@contains@close{1}%
+ \fi
+ %
+ \if0\b@pgfpathfillbetween@contains@close@b
+ \expandafter\pgfpathfillbetween@replace@first@moveto#2\pgf@stop
+ \let#2=\pgfretval
+ \fi
+ %
+ \t@pgf@toka=\expandafter{#1}%
+ \t@pgf@tokb=\expandafter{#2}%
+ %
+ \if0\b@pgfpathfillbetween@contains@close
+ % we need to close the resulting combined path, otherwise decorations will look strange:
+ \expandafter\pgfpathfillbetween@get@first@coord#1\pgf@stop
+ \t@pgf@tokc=\expandafter{\expandafter\pgfsyssoftpath@closepathtoken\pgfretval}%
+ \else
+ \t@pgf@tokc={}%
+ \fi
+ %
+ \edef\pgfretval{\the\t@pgf@toka\the\t@pgf@tokb\the\t@pgf@tokc}%
+ %
+%\message{^^J = \meaning\pgfretval^^J}%
+ % that's it.
+}
+
+% #1 a macro containing a softpath
+% OUTPUT:
+% \pgfretval = 1 if the path contains \pgfsyssoftpath@closepathtoken
+% and 0 otherwise.
+\def\pgfpathfillbetween@contains@closepathtoken#1{%
+ \expandafter\pgfutil@in@\expandafter\pgfsyssoftpath@closepathtoken\expandafter{#1}%
+ \ifpgfutil@in@
+ \def\pgfretval{1}%
+ \else
+ \def\pgfretval{0}%
+ \fi
+}
+
+\def\pgfpathfillbetween@get@first@coord#1#2#3#4\pgf@stop{%
+ \def\pgfretval{{#2}{#3}}%
+}%
+
+% assigns the bounding box of path #1 to
+% (pgf@xa , pgf@ya) = (minx,miny)
+% (pgf@xb , pgf@yb) = (maxx,maxy)
+\def\pgf@compute@BB#1{%
+ \begingroup
+ \dimendef\pgf@pathmaxx=0 %
+ \dimendef\pgf@pathminx=1 %
+ \dimendef\pgf@pathmaxy=2 %
+ \dimendef\pgf@pathminy=3 %
+ \pgf@pathmaxx=-16000pt\relax%
+ \pgf@pathminx=16000pt\relax%
+ \pgf@pathmaxy=-16000pt\relax%
+ \pgf@pathminy=16000pt\relax%
+ \let\pgf@protocolsizes=\pgf@compute@BB@protocol@sizes
+ \expandafter\pgfsetpath@loop#1\pgf@stop
+ \xdef\pgf@marshal{%
+ \pgf@xa=\the\pgf@pathminx\relax
+ \pgf@ya=\the\pgf@pathminy\relax
+ \pgf@xb=\the\pgf@pathmaxx\relax
+ \pgf@yb=\the\pgf@pathmaxy\relax
+ }%
+ \endgroup
+ \pgf@marshal
+}%
+\def\pgf@compute@BB@protocol@sizes#1#2{%
+ \ifdim#1<\pgf@pathminx\pgf@pathminx#1\fi%
+ \ifdim#1>\pgf@pathmaxx\pgf@pathmaxx#1\fi%
+ \ifdim#2<\pgf@pathminy\pgf@pathminy#2\fi%
+ \ifdim#2>\pgf@pathmaxy\pgf@pathmaxy#2\fi%
+}
+
+% A utility function like \pgfsetpath which calls \pgfsetpath *and* protocols
+% the size of each path segment (i.e. compute the bounding box).
+%
+% #1 a macro containing a softpath (i.e. something returned by
+% \pgfgetpath)
+%
+% SIDE--EFFECT: defines \pgfpointlastofsetpath to be the last point of path #1
+\def\pgfsetpathandBB#1{%
+ \let\pgfpointlastofsetpath=\pgfutil@empty
+ \expandafter\pgfsetpath@loop#1\pgf@stop
+ %
+ \pgfsetpath{#1}%
+}%
+
+% Like \pgfsetpathandBB, but this here *appends* to the existing
+% softpath.
+%
+% #1 a macro containing a softpath (i.e. something returned by
+% \pgfgetpath)
+% SIDE--EFFECT: defines \pgfpointlastofsetpath to be the last point of path #1
+\def\pgfaddpathandBB#1{%
+ \let\pgfpointlastofsetpath=\pgfutil@empty
+ \expandafter\pgfsetpath@loop#1\pgf@stop
+ \pgfaddpath#1%
+}
+
+% Like \pgfsetpath, but this here *appends* to the existing
+% softpath.
+%
+% #1 a macro containing a softpath (i.e. something returned by
+% \pgfgetpath)
+\def\pgfaddpath#1{%
+ % append to any previous path elements:
+ \pgfgetpath\pgf@temp
+ \t@pgf@tokc=\expandafter{\pgf@temp}%
+ \t@pgf@toka=\expandafter{#1}%
+ \edef\pgfretval{\the\t@pgf@tokc\the\t@pgf@toka}%
+ \pgfsetpath{\pgfretval}%
+}
+
+% Takes a softpath on input, replaces its first moveto by a lineto,
+% and returns it as softpath.
+% #1: a macro containing a softpath (i.e. the result of \pgfgetpath)
+%
+% On output, \pgfretval contains a modified path.
+\def\pgfpathreplacefirstmoveto#1{%
+ \ifx#1\pgfutil@empty
+ \let\pgfretval=#1%
+ \else
+ \expandafter\pgfpathfillbetween@replace@first@moveto#1\pgf@stop
+ \fi
+}
+
+% Defines \pgfretval to be '+' if the path's direction is "ascending"
+% and "-" otherwise.
+%
+% Here, "ascending" means that its first two coordinates have
+% ascending X coordinates. If the X coordinates are equal, the Y
+% coordinates are used instead.
+\def\pgfpathfillbetween@heuristics@get@direction#1#2#3{%
+ \pgfutil@ifnextchar\pgf@stop{%
+ % wow. it has just one path element... we can do nothing.
+ \def\pgfretval{+}%
+ \pgfutil@gobble
+ }{%
+ \pgfpathfillbetween@heuristics@get@direction@{#1}{#2}{#3}%
+ }%
+}%
+
+% example: \pgfsyssoftpath@movetotoken{#2}{#3}\pgfsyssoftpath@linetotoken{#5}{#6}#7\pgf@stop
+% example:
+% \pgfsyssoftpath@movetotoken{#2}{#3}
+% \pgfsyssoftpath@curvetosupportatoken{<x>}{<y>}
+% \pgfsyssoftpath@curvetosupportbtoken{<x>}{<y>}
+% \pgfsyssoftpath@curvetotoken{<x>}{<y>}\pgf@stop
+\def\pgfpathfillbetween@heuristics@get@direction@#1#2#3#4#5#6#7\pgf@stop{%
+ \def\pgf@temp{#4}%
+ \def\pgf@tempb{\pgfsyssoftpath@curvetosupportatoken}%
+ \ifx\pgf@temp\pgf@tempb
+ % Ah - a curveto! Use the end-point for the heuristics.
+ \pgfpathfillbetween@heuristics@get@direction@curveto #1{#2}{#3}#4{#5}{#6}#7\pgf@stop
+ \else
+ % Ok, assume it is line to (or its variants):
+ \pgfpathfillbetween@heuristics@get@direction@@{#2}{#3}{#5}{#6}%
+ \fi
+}%
+
+\def\pgfpathfillbetween@heuristics@get@direction@curveto#1#2#3\pgfsyssoftpath@curvetosupportatoken#4\pgfsyssoftpath@curvetotoken#5#6#7\pgf@stop{%
+ \pgfpathfillbetween@heuristics@get@direction@@{#2}{#3}{#5}{#6}%
+}%
+
+% #1: x1
+% #2: y1
+% #3: x2
+% #4: y2
+\def\pgfpathfillbetween@heuristics@get@direction@@#1#2#3#4{%
+ \edef\pgfretval{%
+ \ifdim #1<#3\space
+ +%
+ \else
+ \ifdim #1=#3\space
+ \ifdim #2<#4\space
+ +%
+ \else
+ -%
+ \fi
+ \else
+ -%
+ \fi
+ \fi
+ }%
+}
+
+% Accumulates the path's bounding box, the last moveto, and the last
+% coord.
+\def\pgfsetpath@loop#1{%
+ \ifx#1\pgf@stop%
+ \let\pgfsetpathBB@protocolsizesnext=\relax%
+ \else%
+ \ifx#1\pgfsyssoftpath@movetotoken%
+ \let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@moveto%
+ \else%
+ \ifx#1\pgfsyssoftpath@linetotoken%
+ \let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@simple%
+ \else%
+ \ifx#1\pgfsyssoftpath@closepathtoken%
+ \let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@simple%
+ \else%
+ \ifx#1\pgfsyssoftpath@curvetosupportatoken%
+ \let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@curveto%
+ \else%
+ \ifx#1\pgfsyssoftpath@rectcornertoken%
+ \let\pgfsetpathBB@protocolsizesnext=\pgfsetpathBB@protocolsizestoken@rect%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \pgfsetpathBB@protocolsizesnext}
+
+\def\pgfsetpathBB@protocol@lastmoveto#1#2{%
+ \gdef\pgfsyssoftpath@lastmoveto{{#1}{#2}}%
+}
+
+\def\pgfsetpathBB@protocolsizestoken@moveto#1#2{%
+ % required for --cycle, among others:
+ \pgfsetpathBB@protocol@lastmoveto{#1}{#2}%
+ \pgfsetpathBB@protocolsizestoken@simple{#1}{#2}%
+}
+\def\pgfsetpathBB@protocolsizestoken@simple#1#2{%
+ \def\pgfpointlastofsetpath{\pgfqpoint{#1}{#2}}%
+ \pgf@protocolsizes{#1}{#2}%
+ \pgfsetpath@loop%
+}
+
+\def\pgfsetpathBB@protocolsizestoken@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{%
+ \def\pgfpointlastofsetpath{\pgfqpoint{#5}{#6}}%
+ \pgf@protocolsizes{#1}{#2}%
+ \pgf@protocolsizes{#3}{#4}%
+ \pgf@protocolsizes{#5}{#6}%
+ \pgfsetpath@loop
+}
+
+\def\pgfsetpathBB@protocolsizestoken@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{%
+ \pgf@protocolsizes{#1}{#2}%
+ \pgf@xa=#1\relax%
+ \advance\pgf@xa by#3\relax%
+ \pgf@ya=#2\relax%
+ \advance\pgf@ya by#4\relax%
+ \pgf@protocolsizes{\pgf@xa}{\pgf@ya}%
+ \pgfsetpath@loop
+}%
+
+% Defines \pgfretval to be the reversed path of #1.
+%
+% #1 is supposed to be a macro containing a path without rounding specials (i.e. a result
+% of \pgfprocessround)
+\def\pgfcomputereversepath#1{%
+ % unfortunately, this is already used by internal macros...
+ \pgf@reverse@path#1%
+}%
+\def\pgf@reverse@path#1{%
+ % ATTENTION: this here is a special implementation which
+ % operates directly on softpaths. It does not make use of \pgf@decorate@inputsegmentobjects@reverse (reverse path decoration)
+ % because (a) decorations require their own special format and (b)
+ % this implementation is faster (both with respect to runtime asymptotics and runtime constant).
+ \def\pgf@reverse@first@type{}%
+ \def\pgf@reverse@last@pt{}%
+ \def\b@pgf@reversepath@last@is@close{0}%
+ \pgfprependlistnewempty{pgfretval}%
+ \let\pgfreverse@iterate=\pgfreverse@checkfirst@then
+ \expandafter\pgf@reverse@loop#1\pgf@stop
+ %
+ \if 0\b@pgf@reversepath@last@is@close%
+ \expandafter\pgfreverse@prepend@last\expandafter{\pgf@reverse@first@type}{x}{x}%
+ \else
+ % as soon as a closepathtoken is encountered, the associated
+ % moveto is processed right away.
+ %
+ % FIXME : I doubt that the implementation works if more than
+ % one closepathtoken is in here ...
+ \fi
+ \pgfprependlistlet\pgfretval={pgfretval}%
+ %
+}%
+
+\def\pgf@reverse@loop#1{%
+ \ifx#1\pgf@stop%
+ \let\pgfreverse@next=\relax%
+ \else%
+ \def\b@pgf@reversepath@last@is@close{0}%
+ \ifx#1\pgfsyssoftpath@movetotoken%
+ \let\pgfreverse@next=\pgfreverse@token@moveto%
+ \else%
+ \ifx#1\pgfsyssoftpath@linetotoken%
+ \let\pgfreverse@next=\pgfreverse@token@lineto%
+ \else%
+ \ifx#1\pgfsyssoftpath@closepathtoken%
+ \let\pgfreverse@next=\pgfreverse@token@close%
+ \else%
+ \ifx#1\pgfsyssoftpath@curvetosupportatoken%
+ \let\pgfreverse@next=\pgfreverse@token@curveto%
+ \else%
+ \ifx#1\pgfsyssoftpath@rectcornertoken%
+ \let\pgfreverse@next=\pgfreverse@token@rect%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \pgfreverse@next}
+
+\def\pgfreverse@checkfirst@then#1{%
+ \def\pgf@reverse@first@type{#1}%
+ \let\pgfreverse@iterate=\pgfutil@gobble
+}%
+
+\def\pgfreverse@prepend@last#1#2#3{%
+ \ifx\pgf@reverse@last@pt\pgfutil@empty
+ \else
+ \t@pgf@toka={#1}%
+ \t@pgf@tokb=\expandafter{\pgf@reverse@last@pt}%
+ \edef\pgf@marshal{\the\t@pgf@toka\the\t@pgf@tokb}%
+ \expandafter\pgfprependlistpushfront\pgf@marshal\to{pgfretval}%
+ \fi
+ \def\pgf@reverse@last@pt{{#2}{#3}}%
+}%
+
+\def\pgfreverse@token@moveto#1#2{%
+ \pgfreverse@iterate{\pgfsyssoftpath@movetotoken}%
+ \pgfreverse@prepend@last\pgfsyssoftpath@movetotoken{#1}{#2}%
+ \pgf@reverse@loop%
+}
+
+\def\pgfreverse@token@lineto#1#2{%
+ \pgfreverse@iterate{\pgfsyssoftpath@linetotoken}%
+ \pgfreverse@prepend@last\pgfsyssoftpath@linetotoken{#1}{#2}%
+ \pgf@reverse@loop
+}
+\def\pgfreverse@token@close#1#2{%
+ % close tokens are complicated: they always correspond to the most
+ % recent moveto token.
+ %
+ % First: remember that the last encountered token was 'close': if
+ % this is the lastmost token, we must not insert a final moveto.
+ \def\b@pgf@reversepath@last@is@close{1}%
+ %
+ % Second: *append*
+ % \pgfsyssoftpath@closepathtoken{<lastx>}{<lasty>}.
+ %
+ % Appending is unsupported by the prepend-list, so we have to
+ % terminate it, append, and reinitialize it with the result:
+ \pgfprependlistlet\pgfretval={pgfretval}%
+ \t@pgf@toka=\expandafter{\pgfretval}%
+ \t@pgf@tokb={\pgfsyssoftpath@closepathtoken}%
+ \t@pgf@tokc=\expandafter{\pgf@reverse@last@pt}%
+ \edef\pgf@marshal{\the\t@pgf@toka\the\t@pgf@tokb\the\t@pgf@tokc}%
+ %
+ % ... create a new list with the result:
+ \pgfprependlistnewempty{pgfretval}%
+ \expandafter\pgfprependlistpushfront\pgf@marshal\to{pgfretval}%
+ %
+ % and prepend a moveto.
+ \pgfreverse@prepend@last\pgfsyssoftpath@movetotoken{#1}{#2}%
+ %
+ \pgf@reverse@loop
+}
+
+\def\pgfreverse@token@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{%
+ \pgfreverse@iterate{\pgfsyssoftpath@curvetosupportatoken{#1}{#2}\pgfsyssoftpath@curvetosupportbtoken{#3}{#4}\pgfsyssoftpath@curvetotoken}%
+ \pgfreverse@prepend@last{\pgfsyssoftpath@curvetosupportatoken{#3}{#4}\pgfsyssoftpath@curvetosupportbtoken{#1}{#2}\pgfsyssoftpath@curvetotoken}{#5}{#6}%
+ \pgf@reverse@loop
+}
+
+\def\pgfreverse@token@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{%
+ % FIXME: UNTESTED
+ \pgf@xa=#1\relax%
+ \advance\pgf@xa by#3\relax%
+ \pgf@ya=#2\relax%
+ \advance\pgf@ya by#4\relax%
+ \edef\pgf@marshal{%
+ \noexpand\pgfsyssoftpath@movetotoken
+ {%
+ {#1}{#2}%
+ \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{#2}%
+ \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{\the\pgf@ya}%
+ \noexpand\pgfsyssoftpath@linetotoken{#1}{\the\pgf@ya}%
+ \noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}%
+ }%
+ }%
+ \pgfreverse@iterate\pgfsyssoftpath@movetotoken
+ \edef\pgf@reverse@last@pt{{#1}{#2}}%
+ \expandafter\pgf@reverse@loop\pgf@marshal%
+}
+
+% ----------------------------------------
+% Given that some intersections have been computed already (and are in
+% the current scope), this command computes the intersection segments
+% for one of the input arguments.
+%
+% On output, both \pgfretval and \pgfintersectionsegments contain the number of computed segments. The
+% segments as such can be accessed via \pgfgetintersectionsegmentpath.
+%
+% #1 : should be '1' if the FIRST argument of
+% \pgfintersectionofpaths should be used and '2' the SECOND
+% argument of \pgfintersectionofpaths should be used on input.
+%
+% EXAMPLE:
+%
+% \def\inputValue{%
+% \pgfsyssoftpath@movetotoken {56.90549pt}{0.0pt}%
+% \pgfsyssoftpath@linetotoken {85.35823pt}{28.45274pt}%
+% \pgfsyssoftpath@linetotoken {113.81097pt}{0.0pt}%
+% \pgfsyssoftpath@linetotoken {142.26372pt}{28.45274pt}%
+% \pgfsyssoftpath@linetotoken {170.71646pt}{0.0pt}%
+% }
+%
+% \pgfpointintersectionsolution{1}%
+% \pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{71.13918pt, 14.2278pt}{solution 1}
+% \pgfpointintersectionsolution{2}%
+% \pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{99.59497pt, 14.2278pt}{solution 2}
+% \pgfpointintersectionsolution{3}%
+% \pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{128.05057pt, 14.2278pt}{solution 3}
+% \pgfpointintersectionsolution{4}%
+% \pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{156.50636pt, 14.2278pt}{solution 4}
+%
+%
+% \pgfcomputeintersectionsegments{1}%
+%
+% \message{OUTPUT: \meaning\pgfretval^^J}%
+% \expandafter\def\csname expected@a@0\endcsname{%
+% \pgfsyssoftpath@movetotoken {56.90549pt}{0.0pt}%
+% \pgfsyssoftpath@linetotoken{71.13918pt}{14.2278pt}%
+% }
+% \expandafter\def\csname expected@a@1\endcsname{%
+% \pgfsyssoftpath@movetotoken{71.13918pt}{14.2278pt}%
+% \pgfsyssoftpath@linetotoken {85.35823pt}{28.45274pt}%
+% \pgfsyssoftpath@linetotoken{99.59497pt}{14.2278pt}%
+% }
+% \expandafter\def\csname expected@a@2\endcsname{%
+% \pgfsyssoftpath@movetotoken{99.59497pt}{14.2278pt}%
+% \pgfsyssoftpath@linetotoken {113.81097pt}{0.0pt}%
+% \pgfsyssoftpath@linetotoken{128.05057pt}{14.2278pt}%
+% }
+% \expandafter\def\csname expected@a@3\endcsname{%
+% \pgfsyssoftpath@movetotoken{128.05057pt}{14.2278pt}%
+% \pgfsyssoftpath@linetotoken {142.26372pt}{28.45274pt}%
+% \pgfsyssoftpath@linetotoken{156.50636pt}{14.2278pt}%
+% }
+% \expandafter\def\csname expected@a@4\endcsname{%
+% \pgfsyssoftpath@movetotoken{156.50636pt}{14.2278pt}%
+% \pgfsyssoftpath@linetotoken {170.71646pt}{0.0pt}%
+% }
+% %
+\def\pgfcomputeintersectionsegments#1{%
+ \pgfcomputeintersectionsegments@set@src{#1}%
+ \ifnum\pgfintersectionsolutions=0 %
+ \pgfutil@namelet{pgf@intersect@path@split@\pgf@insert@intersections@src @0}{pgf@intersect@path@\pgf@insert@intersections@src}%
+ \def\pgfretval{0}%
+ \else
+ %
+ % This algorithm *relies* on an increasing sort order. Sort
+ % them:
+ \pgfintersectionsolutionsortbytime@@%
+ %
+ %
+ \pgfapplistnewempty{pgfretval@tmp}%
+ \def\pgf@insert@cursolution{1}%
+ \def\c@pgf@path@result{0}%
+ \let\c@pgf@path@segment=\c@pgf@countd
+ \let\c@pgf@path@segment@trg=\c@pgf@countc
+ \c@pgf@path@segment=0 %
+ \pgf@fillbetween@get@time@off{\pgf@insert@intersections@src}{\pgf@insert@cursolution}%
+ \c@pgf@path@segment@trg=\pgfretval\relax
+ %
+ \pgfutil@namelet{pgf@loc@TMPa}{pgf@intersect@path@\pgf@insert@intersections@src}%
+ \expandafter\pgf@insert@intersections@loop\pgf@loc@TMPa\pgf@stop
+ %
+ \pgfapplistlet\pgf@loc@TMPa={pgfretval@tmp}%
+ \expandafter\let\csname pgf@intersect@path@split@\pgf@insert@intersections@src @\c@pgf@path@result\endcsname=\pgf@loc@TMPa%
+ \pgfutil@advancestringcounter\c@pgf@path@result%
+ \let\pgfretval=\c@pgf@path@result%
+ \fi
+ \let\pgfintersectionsegments=\pgfretval
+}%
+
+% Defines \pgfretval to contain the desired path segment as softpath.
+%
+% @see \pgfsetpath
+% @see \pgfsetpathandBB
+% @see \pgfaddpathandBB
+%
+% #1: the value '1' if results for the FIRST argument of
+% \pgfintersectionofpaths are requested or '2' if results for the
+% SECOND path are requested (compare \pgfcomputeintersectionsegments).
+% #2: the segment index (a number 0<= #2 < numbersegments).
+% The number of segments is \pgfintersectionsegments
+\def\pgfgetintersectionsegmentpath#1#2{%
+ \pgfcomputeintersectionsegments@set@src{#1}%
+ \pgfmathparse{#2}%
+ \afterassignment\pgfcomputeintersectionsegments@set@src@gobble
+ \c@pgf@countc=\pgfmathresult\relax%
+ \ifnum\c@pgf@countc<0
+ \advance\c@pgf@countc by \pgfintersectionsegments\relax
+ \fi
+ \expandafter\let\expandafter\pgfretval\csname pgf@intersect@path@split@\pgf@insert@intersections@src @\the\c@pgf@countc\endcsname
+ \ifx\pgfretval\relax
+ \pgferror{There is no intersection segment '#2' in path '#1'}%
+ \fi
+}%
+\def\pgfcomputeintersectionsegments@set@src@gobble#1\relax{}
+
+\def\pgfcomputeintersectionsegments@set@src#1{%
+ \ifcase#1\relax
+ % 0
+ \pgferror{illegal argument supplied.}
+ \or
+ \def\pgf@insert@intersections@src{a}%
+ \or
+ \def\pgf@insert@intersections@src{b}%
+ \else
+ \pgferror{illegal argument supplied.}
+ \fi
+}%
+
+\def\pgfintersectionsolutionsortbytime@@{%
+ % this is an O(n^2) sort method. It might suffice provided that
+ % the number of intersections is small... and it is the same
+ % runtime as that of the intersection lib as such (which is, in
+ % fact, worse).
+ %
+ % Note that this bubble-sort-approach has the benefit that if the
+ % input sequence *is* actually sorted, that it will have no effect
+ % at all (linear time).
+ \pgf@intersect@solutions@sortfinishtrue%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter<\pgfintersectionsolutions\relax%
+ \pgfutil@tempcnta=\pgfmathcounter%
+ \advance\pgfutil@tempcnta by1\relax%
+ %
+ % acquire the sort keys...
+ \pgfintersectiongetsolutiontimes{\pgfmathcounter}{\pgf@loc@tmp@A@a}{\pgf@loc@tmp@A@b}%
+ \pgfintersectiongetsolutiontimes{\the\pgfutil@tempcnta}{\pgf@loc@tmp@B@a}{\pgf@loc@tmp@B@b}%
+ %
+ \ifdim\csname pgf@loc@tmp@A@\pgf@insert@intersections@src\endcsname pt>%
+ \csname pgf@loc@tmp@B@\pgf@insert@intersections@src\endcsname pt\relax%
+ \pgf@intersect@solutions@sortfinishfalse%
+ %
+ \pgfintersectionsolutionsortbytime@swap{pgfpoint@intersect@solution@\pgfmathcounter}%
+ {pgfpoint@intersect@solution@\the\pgfutil@tempcnta}%
+ %
+ \pgfintersectionsolutionsortbytime@swap{pgf@intersect@solution@props@\pgfmathcounter}%
+ {pgf@intersect@solution@props@\the\pgfutil@tempcnta}%
+ \fi%
+ \repeatpgfmathloop%
+ \ifpgf@intersect@solutions@sortfinish%
+ \else%
+ \expandafter\pgfintersectionsolutionsortbytime@@%
+ \fi%
+}
+
+
+% #1: either 'a' or 'b', depending on the required part
+% #2: the solution index (starting with 1)
+% Defines \pgfretval to contain the result.
+\def\pgf@fillbetween@get@time@off#1#2{%
+ \pgfintersectiongetsolutionsegmentindices{#2}{\pgf@temp@a}{\pgf@temp@b}%
+ \edef\pgfretval{\csname pgf@temp@#1\endcsname}%
+}%
+
+% ----------------------------------------------------------------------------------
+
+
+% Splits a Bezier curve at a designated time 't'
+% using decasteljau
+%--------------------------------------------------
+% Point lerp(float t, Point A, Point B) {
+% return A*(1-t) + B*t; // + and * overloaded for Points
+% }
+%
+% void split(t, Point P[4], Point L[4], Point R[4]) {
+% Point P01 = lerp(t, P[0], P[1]);
+% Point P12 = lerp(t, P[1], P[2]);
+% Point P23 = lerp(t, P[2], P[3]);
+% Point P012 = lerp(t, P01, P12);
+% Point P123 = lerp(t, P12, P13);
+% Point Q = lerp(t, P012, P123);
+% L[0] = P[0]; L[1] = P01; L[2] = P012; L[3] = Q;
+% R[0] = Q;
+% R[1] = P123; R[2] = P23; R[3] = P[3];
+% }
+%--------------------------------------------------
+% INPUT:
+% #1: a value in the range [0,1] which determines the split point
+% #2,#3,#4,#5: the points of the curve, each of the form {<x>}{<y>}
+%
+% OUTPUT:
+% \pgfretval@L{{<A>}{<B>}{<C>}{<D>}}
+% \pgfretval@R{{<A>}{<B>}{<C>}{<D>}}
+%
+% @see \pgf@split@curveto@softpaths
+\def\pgf@split@curveto#1#2#3#4#5{%
+ \begingroup
+ \pgf@xa=-#1pt %
+ \advance\pgf@xa by1pt %
+ \edef\pgf@split@one@m@t{\pgf@sys@tonumber\pgf@xa}%
+ %
+ \pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{#2}{#3}%
+ \pgf@split@curveto@tomacro\pgf@split@curveto@p@AB
+ %
+ \pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{#3}{#4}%
+ \pgf@split@curveto@tomacro\pgf@split@curveto@p@BC
+ %
+ \pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{#4}{#5}%
+ \pgf@split@curveto@tomacro\pgf@split@curveto@p@CD
+ %
+ \pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{\pgf@split@curveto@p@AB}{\pgf@split@curveto@p@BC}%
+ \pgf@split@curveto@tomacro\pgf@split@curveto@p@ABC
+ %
+ \pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{\pgf@split@curveto@p@BC}{\pgf@split@curveto@p@CD}%
+ \pgf@split@curveto@tomacro\pgf@split@curveto@p@BCD
+ %
+ \pgf@split@curveto@lerp{#1}{\pgf@split@one@m@t}{\pgf@split@curveto@p@ABC}{\pgf@split@curveto@p@BCD}%
+ \pgf@split@curveto@tomacro\pgf@split@curveto@p@Q
+ %
+ \xdef\pgf@marshal{%
+ \edef\noexpand\pgfretval@L{{#2}{\pgf@split@curveto@p@AB}{\pgf@split@curveto@p@ABC}{\pgf@split@curveto@p@Q}}%
+ \edef\noexpand\pgfretval@R{{\pgf@split@curveto@p@Q}{\pgf@split@curveto@p@BCD}{\pgf@split@curveto@p@CD}{#5}}%
+ }%
+ \endgroup
+ \pgf@marshal
+}
+
+% Splits a Bezier curve at a designated time 't'
+%
+% This variants takes a part of a softpath as input:
+%
+% #1: a curveto- a macro containing a softpath of the form
+% <x><y>\pgfsyssoftpath@curvetosupportatoken<x><y>\pgfsyssoftpath@curvetosupportbtoken<x><y>\pgfsyssoftpath@curvetotoken<x><y>
+% #2: t in [0,1]
+%
+% OUTPUT: \pgfretval@L contains the LEFT segment (in the same softpath format) and \pgfretval@R contains the RIGHT segment (in the softpath format), \pgfretval contains the intersection point (i.e. the point evaluated at 't')
+\def\pgf@split@curveto@softpaths#1#2{%
+ \expandafter\pgf@split@curveto@softpaths@#1{#2}%
+}
+
+\def\pgf@split@curveto@softpaths@#1#2\pgfsyssoftpath@curvetosupportatoken#3#4\pgfsyssoftpath@curvetosupportbtoken#5#6\pgfsyssoftpath@curvetotoken#7#8#9{%
+ \pgf@split@curveto{#9}%
+ {{#1}{#2}}%
+ {{#3}{#4}}%
+ {{#5}{#6}}%
+ {{#7}{#8}}%
+ \expandafter\pgf@split@curveto@softpaths@@\pgfretval@L\pgfretval@L
+ \expandafter\pgf@split@curveto@softpaths@@\pgfretval@R\pgfretval@R
+}%
+
+\def\pgf@split@curveto@softpaths@@#1#2#3#4#5{%
+ % we can silently omit the moveto component.
+ \def#5{\pgfsyssoftpath@curvetosupportatoken#2\pgfsyssoftpath@curvetosupportbtoken#3\pgfsyssoftpath@curvetotoken#4}%
+ \def\pgfretval{#1}%
+}%
+
+% ----------------------------------------------------------------------------------
+
+% defines \pgf@x, \pgf@y to be A*(1-t) + B*t
+% #1: the scalar value 't' in [0,1]
+% #2: the scalar value '1-t' in [0,1]
+% #3: a 2d point 'A' of the form {<x>}{<y>}
+% #4: a 2d point 'B' of the form {<x>}{<y>}
+\def\pgf@split@curveto@lerp#1#2#3#4{%
+ \pgfpointadd
+ {\pgfqpointscale{#2}{\expandafter\pgfqpoint#3}}%
+ {\pgfqpointscale{#1}{\expandafter\pgfqpoint#4}}%
+}%
+
+\def\pgf@split@curveto@tomacro#1{%
+ \edef#1{{\the\pgf@x}{\the\pgf@y}}%
+}
+
+
+\def\pgfcomputeintersectionsegments@@{%
+%\message{processing segment \the\c@pgf@path@segment\space (current solution \pgf@insert@cursolution/\pgfintersectionsolutions; target segment \the\c@pgf@path@segment@trg, currentxy \pgfinsert@intersect@tok@currentxy, lastxy \pgfinsert@intersect@tok@lastxy)^^J}%
+ \pgfmathloop
+ % we need to loop: it is fully acceptable if more than one
+ % solution is on the same segment.
+ \ifnum\c@pgf@path@segment=\c@pgf@path@segment@trg
+ %
+ \pgf@insert@intersections@split@segment
+ \expandafter\pgfapplistpushback\pgfretval\to{pgfretval@tmp}%
+ %
+ %
+ % report the current result segment!
+ \pgfapplistlet\pgf@loc@TMPa={pgfretval@tmp}%
+ \expandafter\let\csname pgf@intersect@path@split@\pgf@insert@intersections@src @\c@pgf@path@result\endcsname=\pgf@loc@TMPa%
+ \pgfutil@advancestringcounter\c@pgf@path@result%
+ % ... and start a new result segment. Keep in mind that it
+ % should start with a moveto:
+ \pgfapplistnewempty{pgfretval@tmp}%
+ \csname pgfpoint@intersect@solution@\pgf@insert@cursolution\endcsname%
+ \edef\pgf@loc@TMPa{\noexpand\pgfsyssoftpath@movetotoken{\the\pgf@x}{\the\pgf@y}}%
+ \expandafter\pgfapplistpushback\pgf@loc@TMPa\to{pgfretval@tmp}%
+ %
+ %
+ % OK, iterate:
+ \ifnum\pgf@insert@cursolution=\pgfintersectionsolutions\relax
+ % collect all remaining ones:
+ \c@pgf@path@segment@trg=10000000 %
+ \else
+ \pgfutil@advancestringcounter\pgf@insert@cursolution
+ \pgf@fillbetween@get@time@off{\pgf@insert@intersections@src}{\pgf@insert@cursolution}%
+ \c@pgf@path@segment@trg=\pgfretval\relax
+ \fi
+ \repeatpgfmathloop
+ \expandafter\pgfapplistpushback\pgfinsert@intersect@tok\to{pgfretval@tmp}%
+ \let\pgfinsert@intersect@tok@lastxy=\pgfinsert@intersect@tok@currentxy
+ \advance\c@pgf@path@segment by1 %
+}%
+
+% INPUT:
+% - \pgfinsert@intersect@tok@type is the current type (one of \pgfsyssoftpath@linetotoken or \pgfsyssoftpath@curvetotoken)
+% - \pgf@insert@cursolution is the current intersection index
+% - \pgfinsert@intersect@tok is the current path segment. On output, it is the *remaining* path segment.
+% - \pgfinsert@intersect@tok@lastxy the (x,y) coordinates of the last seen coordinate.
+%
+% OUTPUT:
+% - \pgfretval the segment which has been splitted off. It will be appended to the result.
+% - \pgfinsert@intersect@tok the remaining path segment which is to be processed
+% - \pgfinsert@intersect@tok@lastxy the (x,y) coordinates of the last seen coordinate which is to be processed.
+\def\pgf@insert@intersections@split@segment{%
+ \ifx\pgfinsert@intersect@tok@type\pgfsyssoftpath@linetotoken
+ \csname pgfpoint@intersect@solution@\pgf@insert@cursolution\endcsname%
+ \edef\pgfretval{\noexpand\pgfsyssoftpath@linetotoken{\the\pgf@x}{\the\pgf@y}}%
+ % ... and keep \pgfinsert@intersect@tok at its current value (it is \pgfsyssoftpath@linetotoken{<next x>}{<next y>})
+ \else
+ \ifx\pgfinsert@intersect@tok@type\pgfsyssoftpath@curvetotoken
+ % Ah; a curveto. That's more involved!
+ % First, get the time offset of the current intersection:
+ %
+ % Get the global time:
+ \pgfintersectiongetsolutiontimes{\pgf@insert@cursolution}{\pgf@split@it@time@a}{\pgf@split@it@time@b}%
+ % Get time at the beginning of the current solution segment:
+ \pgfintersectiongetsolutionsegmentindices{\pgf@insert@cursolution}{\pgf@split@it@timeoff@a}{\pgf@split@it@timeoff@b}%
+ % compute local time within the current solution segment:
+ \pgf@xa=\csname pgf@split@it@time@\pgf@insert@intersections@src\endcsname pt %
+ \advance\pgf@xa by-\csname pgf@split@it@timeoff@\pgf@insert@intersections@src\endcsname pt %
+ \edef\pgf@split@it@time{\pgf@sys@tonumber\pgf@xa}%
+ %
+ \let\pgf@split@it@start=\pgfinsert@intersect@tok@lastxy
+ % we have to insert the last XY coordinates:
+ \t@pgf@toka=\expandafter{\pgf@split@it@start}%
+ \t@pgf@tokb=\expandafter{\pgfinsert@intersect@tok}%
+ \edef\pgf@temp{\the\t@pgf@toka\the\t@pgf@tokb}%
+ % Split into TWO curveto operations!
+ \pgf@split@curveto@softpaths{\pgf@temp}{\pgf@split@it@time}%
+ % ok, the first returned sub-curveto is the result of this method...
+ \let\pgfretval=\pgfretval@L
+ % ... and the second is the "remainder" which is still to be processed.
+ \let\pgfinsert@intersect@tok=\pgfretval@R
+ \else
+ \pgferror{Unsupported path type \meaning\pgfinsert@intersect@tok@type. Cannot process these paths.}%
+ \fi
+ \fi
+ %
+ \csname pgfpoint@intersect@solution@\pgf@insert@cursolution\endcsname%
+ \edef\pgfinsert@intersect@tok@lastxy{{\the\pgf@x}{\the\pgf@y}}%
+}%
+
+\def\pgf@insert@intersections@loop#1{%
+ \ifx#1\pgf@stop%
+ \let\pgfinsert@intersect@tok\pgfutil@empty%
+ \let\pgfinsert@intersect@tok@type\pgfutil@empty
+ \pgfcomputeintersectionsegments@@%
+ \let\pgfinsert@intersect@next=\relax%
+ \else%
+ \ifx#1\pgfsyssoftpath@movetotoken%
+ \let\pgfinsert@intersect@next=\pgfinsert@intersect@token@moveto%
+ \else%
+ \ifx#1\pgfsyssoftpath@linetotoken%
+ \let\pgfinsert@intersect@next=\pgfinsert@intersect@token@lineto%
+ \else%
+ \ifx#1\pgfsyssoftpath@closepathtoken%
+ \let\pgfinsert@intersect@next=\pgfinsert@intersect@token@close%
+ \else%
+ \ifx#1\pgfsyssoftpath@curvetosupportatoken%
+ \let\pgfinsert@intersect@next=\pgfinsert@intersect@token@curveto%
+ \else%
+ \ifx#1\pgfsyssoftpath@rectcornertoken%
+ \let\pgfinsert@intersect@next=\pgfinsert@intersect@token@rect%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \pgfinsert@intersect@next}
+
+\def\pgfinsert@intersect@token@moveto#1#2{%
+ \def\pgfinsert@intersect@tok{\pgfsyssoftpath@movetotoken{#1}{#2}}%
+ \let\pgfinsert@intersect@tok@type\pgfsyssoftpath@movetotoken
+ \def\pgfinsert@intersect@tok@lastxy{{#1}{#2}}%
+ \expandafter\pgfapplistpushback\pgfinsert@intersect@tok\to{pgfretval@tmp}%
+ \pgf@insert@intersections@loop%
+}
+
+\def\pgfinsert@intersect@token@lineto#1#2{%
+ \def\pgfinsert@intersect@tok{\pgfsyssoftpath@linetotoken{#1}{#2}}%
+ \let\pgfinsert@intersect@tok@type\pgfsyssoftpath@linetotoken
+ \def\pgfinsert@intersect@tok@currentxy{{#1}{#2}}%
+ \pgfcomputeintersectionsegments@@%
+ \pgf@insert@intersections@loop
+}
+\def\pgfinsert@intersect@token@close#1#2{%
+ \def\pgfinsert@intersect@tok{\pgfsyssoftpath@closepathtoken{#1}{#2}}%
+ \let\pgfinsert@intersect@tok@type\pgfsyssoftpath@linetotoken
+ \def\pgfinsert@intersect@tok@currentxy{{#1}{#2}}%
+ \pgfcomputeintersectionsegments@@%
+ \pgf@insert@intersections@loop
+}
+
+\def\pgfinsert@intersect@token@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{%
+ \def\pgfinsert@intersect@tok{\pgfsyssoftpath@curvetosupportatoken{#1}{#2}\pgfsyssoftpath@curvetosupportbtoken{#3}{#4}\pgfsyssoftpath@curvetotoken{#5}{#6}}%
+ \let\pgfinsert@intersect@tok@type\pgfsyssoftpath@curvetotoken
+ \def\pgfinsert@intersect@tok@currentxy{{#5}{#6}}%
+ \pgfcomputeintersectionsegments@@%
+ \pgf@insert@intersections@loop
+}
+
+\def\pgfinsert@intersect@token@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{%
+ \pgf@xa=#1\relax%
+ \advance\pgf@xa by#3\relax%
+ \pgf@ya=#2\relax%
+ \advance\pgf@ya by#4\relax%
+ \edef\pgf@marshal{%
+ \noexpand\pgfsyssoftpath@movetotoken{#1}{#2}%
+ \noexpand\pgfsyssoftpath@linetotoken{#1}{\the\pgf@ya}%
+ \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{\the\pgf@ya}%
+ \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{#2}%
+ \noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}%
+ }%
+ \expandafter\pgf@insert@intersections@loop\pgf@marshal%
+}
+
+
+% #1: a macro containing the clip path. More precisely, it is supposed to be a return value of \pgfgetpath.
+\def\pgffillbetweensetsoftclippathfirst#1{%
+ \let\pgfpathfillbetween@softclip@A=#1%
+}%
+
+% #1: a macro containing the clip path. More precisely, it is supposed to be a return value of \pgfgetpath.
+\def\pgffillbetweensetsoftclippathsecond#1{%
+ \let\pgfpathfillbetween@softclip@B=#1%
+}%
+
+% #1: a macro containing the clip path. More precisely, it is supposed to be a return value of \pgfgetpath.
+\def\pgffillbetweensetsoftclippath#1{%
+ \pgffillbetweensetsoftclippathfirst{#1}%
+ \pgffillbetweensetsoftclippathsecond{#1}%
+}
+
+% Default: no clip paths
+\pgffillbetweensetsoftclippathfirst{\pgfutil@empty}
+\pgffillbetweensetsoftclippathsecond{\pgfutil@empty}
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.colorbrewer.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.colorbrewer.code.tex
new file mode 100644
index 0000000000..11a3547c04
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.colorbrewer.code.tex
@@ -0,0 +1,4149 @@
+
+% load all colors for the `colormap's and `cycle list's
+\usetikzlibrary{colorbrewer}
+
+% define `colormap's and `cycle list's
+\pgfplotsset{
+ /pgfplots/@@brewer set cycle list/.code={%
+ \pgfkeysalso{/pgfplots/ensure colormap={/pgfplots/colormap/#1},/pgfplots/cycle list name=#1}%
+ },
+ /pgfplots/colormap/YlGn-3/.style={
+ colormap={YlGn-3}{
+ color=(YlGn-C);
+ color=(YlGn-F);
+ color=(YlGn-I);
+ },
+ cycle list/.define={YlGn-3}{[of colormap=YlGn-3]},
+ },
+ /pgfplots/cycle list/YlGn-3/.style={/pgfplots/@@brewer set cycle list={YlGn-3}},
+ %
+ /pgfplots/colormap/YlGn-4/.style={
+ colormap={YlGn-4}{
+ color=(YlGn-B);
+ color=(YlGn-E);
+ color=(YlGn-G);
+ color=(YlGn-J);
+ },
+ cycle list/.define={YlGn-4}{[of colormap=YlGn-4]},
+ },
+ /pgfplots/cycle list/YlGn-4/.style={/pgfplots/@@brewer set cycle list={YlGn-4}},
+ %
+ /pgfplots/colormap/YlGn-5/.style={
+ colormap={YlGn-5}{
+ color=(YlGn-B);
+ color=(YlGn-E);
+ color=(YlGn-G);
+ color=(YlGn-I);
+ color=(YlGn-K);
+ },
+ cycle list/.define={YlGn-5}{[of colormap=YlGn-5]},
+ },
+ /pgfplots/cycle list/YlGn-5/.style={/pgfplots/@@brewer set cycle list={YlGn-5}},
+ %
+ /pgfplots/colormap/YlGn-6/.style={
+ colormap={YlGn-6}{
+ color=(YlGn-B);
+ color=(YlGn-D);
+ color=(YlGn-F);
+ color=(YlGn-G);
+ color=(YlGn-I);
+ color=(YlGn-K);
+ },
+ cycle list/.define={YlGn-6}{[of colormap=YlGn-6]},
+ },
+ /pgfplots/cycle list/YlGn-6/.style={/pgfplots/@@brewer set cycle list={YlGn-6}},
+ %
+ /pgfplots/colormap/YlGn-7/.style={
+ colormap={YlGn-7}{
+ color=(YlGn-B);
+ color=(YlGn-D);
+ color=(YlGn-F);
+ color=(YlGn-G);
+ color=(YlGn-H);
+ color=(YlGn-J);
+ color=(YlGn-L);
+ },
+ cycle list/.define={YlGn-7}{[of colormap=YlGn-7]},
+ },
+ /pgfplots/cycle list/YlGn-7/.style={/pgfplots/@@brewer set cycle list={YlGn-7}},
+ %
+ /pgfplots/colormap/YlGn-8/.style={
+ colormap={YlGn-8}{
+ color=(YlGn-A);
+ color=(YlGn-C);
+ color=(YlGn-D);
+ color=(YlGn-F);
+ color=(YlGn-G);
+ color=(YlGn-H);
+ color=(YlGn-J);
+ color=(YlGn-L);
+ },
+ cycle list/.define={YlGn-8}{[of colormap=YlGn-8]},
+ },
+ /pgfplots/cycle list/YlGn-8/.style={/pgfplots/@@brewer set cycle list={YlGn-8}},
+ %
+ /pgfplots/colormap/YlGn-9/.style={
+ colormap={YlGn-9}{
+ color=(YlGn-A);
+ color=(YlGn-C);
+ color=(YlGn-D);
+ color=(YlGn-F);
+ color=(YlGn-G);
+ color=(YlGn-H);
+ color=(YlGn-J);
+ color=(YlGn-K);
+ color=(YlGn-M);
+ },
+ cycle list/.define={YlGn-9}{[of colormap=YlGn-9]},
+ },
+ /pgfplots/cycle list/YlGn-9/.style={/pgfplots/@@brewer set cycle list={YlGn-9}},
+ %
+ /pgfplots/colormap/YlGnBu-3/.style={
+ colormap={YlGnBu-3}{
+ color=(YlGnBu-C);
+ color=(YlGnBu-F);
+ color=(YlGnBu-I);
+ },
+ cycle list/.define={YlGnBu-3}{[of colormap=YlGnBu-3]},
+ },
+ /pgfplots/cycle list/YlGnBu-3/.style={/pgfplots/@@brewer set cycle list={YlGnBu-3}},
+ %
+ /pgfplots/colormap/YlGnBu-4/.style={
+ colormap={YlGnBu-4}{
+ color=(YlGnBu-B);
+ color=(YlGnBu-E);
+ color=(YlGnBu-G);
+ color=(YlGnBu-J);
+ },
+ cycle list/.define={YlGnBu-4}{[of colormap=YlGnBu-4]},
+ },
+ /pgfplots/cycle list/YlGnBu-4/.style={/pgfplots/@@brewer set cycle list={YlGnBu-4}},
+ %
+ /pgfplots/colormap/YlGnBu-5/.style={
+ colormap={YlGnBu-5}{
+ color=(YlGnBu-B);
+ color=(YlGnBu-E);
+ color=(YlGnBu-G);
+ color=(YlGnBu-I);
+ color=(YlGnBu-K);
+ },
+ cycle list/.define={YlGnBu-5}{[of colormap=YlGnBu-5]},
+ },
+ /pgfplots/cycle list/YlGnBu-5/.style={/pgfplots/@@brewer set cycle list={YlGnBu-5}},
+ %
+ /pgfplots/colormap/YlGnBu-6/.style={
+ colormap={YlGnBu-6}{
+ color=(YlGnBu-B);
+ color=(YlGnBu-D);
+ color=(YlGnBu-F);
+ color=(YlGnBu-G);
+ color=(YlGnBu-I);
+ color=(YlGnBu-K);
+ },
+ cycle list/.define={YlGnBu-6}{[of colormap=YlGnBu-6]},
+ },
+ /pgfplots/cycle list/YlGnBu-6/.style={/pgfplots/@@brewer set cycle list={YlGnBu-6}},
+ %
+ /pgfplots/colormap/YlGnBu-7/.style={
+ colormap={YlGnBu-7}{
+ color=(YlGnBu-B);
+ color=(YlGnBu-D);
+ color=(YlGnBu-F);
+ color=(YlGnBu-G);
+ color=(YlGnBu-H);
+ color=(YlGnBu-J);
+ color=(YlGnBu-L);
+ },
+ cycle list/.define={YlGnBu-7}{[of colormap=YlGnBu-7]},
+ },
+ /pgfplots/cycle list/YlGnBu-7/.style={/pgfplots/@@brewer set cycle list={YlGnBu-7}},
+ %
+ /pgfplots/colormap/YlGnBu-8/.style={
+ colormap={YlGnBu-8}{
+ color=(YlGnBu-A);
+ color=(YlGnBu-C);
+ color=(YlGnBu-D);
+ color=(YlGnBu-F);
+ color=(YlGnBu-G);
+ color=(YlGnBu-H);
+ color=(YlGnBu-J);
+ color=(YlGnBu-L);
+ },
+ cycle list/.define={YlGnBu-8}{[of colormap=YlGnBu-8]},
+ },
+ /pgfplots/cycle list/YlGnBu-8/.style={/pgfplots/@@brewer set cycle list={YlGnBu-8}},
+ %
+ /pgfplots/colormap/YlGnBu-9/.style={
+ colormap={YlGnBu-9}{
+ color=(YlGnBu-A);
+ color=(YlGnBu-C);
+ color=(YlGnBu-D);
+ color=(YlGnBu-F);
+ color=(YlGnBu-G);
+ color=(YlGnBu-H);
+ color=(YlGnBu-J);
+ color=(YlGnBu-K);
+ color=(YlGnBu-M);
+ },
+ cycle list/.define={YlGnBu-9}{[of colormap=YlGnBu-9]},
+ },
+ /pgfplots/cycle list/YlGnBu-9/.style={/pgfplots/@@brewer set cycle list={YlGnBu-9}},
+ %
+ /pgfplots/colormap/GnBu-3/.style={
+ colormap={GnBu-3}{
+ color=(GnBu-C);
+ color=(GnBu-F);
+ color=(GnBu-I);
+ },
+ cycle list/.define={GnBu-3}{[of colormap=GnBu-3]},
+ },
+ /pgfplots/cycle list/GnBu-3/.style={/pgfplots/@@brewer set cycle list={GnBu-3}},
+ %
+ /pgfplots/colormap/GnBu-4/.style={
+ colormap={GnBu-4}{
+ color=(GnBu-B);
+ color=(GnBu-E);
+ color=(GnBu-G);
+ color=(GnBu-J);
+ },
+ cycle list/.define={GnBu-4}{[of colormap=GnBu-4]},
+ },
+ /pgfplots/cycle list/GnBu-4/.style={/pgfplots/@@brewer set cycle list={GnBu-4}},
+ %
+ /pgfplots/colormap/GnBu-5/.style={
+ colormap={GnBu-5}{
+ color=(GnBu-B);
+ color=(GnBu-E);
+ color=(GnBu-G);
+ color=(GnBu-I);
+ color=(GnBu-K);
+ },
+ cycle list/.define={GnBu-5}{[of colormap=GnBu-5]},
+ },
+ /pgfplots/cycle list/GnBu-5/.style={/pgfplots/@@brewer set cycle list={GnBu-5}},
+ %
+ /pgfplots/colormap/GnBu-6/.style={
+ colormap={GnBu-6}{
+ color=(GnBu-B);
+ color=(GnBu-D);
+ color=(GnBu-F);
+ color=(GnBu-G);
+ color=(GnBu-I);
+ color=(GnBu-K);
+ },
+ cycle list/.define={GnBu-6}{[of colormap=GnBu-6]},
+ },
+ /pgfplots/cycle list/GnBu-6/.style={/pgfplots/@@brewer set cycle list={GnBu-6}},
+ %
+ /pgfplots/colormap/GnBu-7/.style={
+ colormap={GnBu-7}{
+ color=(GnBu-B);
+ color=(GnBu-D);
+ color=(GnBu-F);
+ color=(GnBu-G);
+ color=(GnBu-H);
+ color=(GnBu-J);
+ color=(GnBu-L);
+ },
+ cycle list/.define={GnBu-7}{[of colormap=GnBu-7]},
+ },
+ /pgfplots/cycle list/GnBu-7/.style={/pgfplots/@@brewer set cycle list={GnBu-7}},
+ %
+ /pgfplots/colormap/GnBu-8/.style={
+ colormap={GnBu-8}{
+ color=(GnBu-A);
+ color=(GnBu-C);
+ color=(GnBu-D);
+ color=(GnBu-F);
+ color=(GnBu-G);
+ color=(GnBu-H);
+ color=(GnBu-J);
+ color=(GnBu-L);
+ },
+ cycle list/.define={GnBu-8}{[of colormap=GnBu-8]},
+ },
+ /pgfplots/cycle list/GnBu-8/.style={/pgfplots/@@brewer set cycle list={GnBu-8}},
+ %
+ /pgfplots/colormap/GnBu-9/.style={
+ colormap={GnBu-9}{
+ color=(GnBu-A);
+ color=(GnBu-C);
+ color=(GnBu-D);
+ color=(GnBu-F);
+ color=(GnBu-G);
+ color=(GnBu-H);
+ color=(GnBu-J);
+ color=(GnBu-K);
+ color=(GnBu-M);
+ },
+ cycle list/.define={GnBu-9}{[of colormap=GnBu-9]},
+ },
+ /pgfplots/cycle list/GnBu-9/.style={/pgfplots/@@brewer set cycle list={GnBu-9}},
+ %
+ /pgfplots/colormap/BuGn-3/.style={
+ colormap={BuGn-3}{
+ color=(BuGn-C);
+ color=(BuGn-F);
+ color=(BuGn-I);
+ },
+ cycle list/.define={BuGn-3}{[of colormap=BuGn-3]},
+ },
+ /pgfplots/cycle list/BuGn-3/.style={/pgfplots/@@brewer set cycle list={BuGn-3}},
+ %
+ /pgfplots/colormap/BuGn-4/.style={
+ colormap={BuGn-4}{
+ color=(BuGn-B);
+ color=(BuGn-E);
+ color=(BuGn-G);
+ color=(BuGn-J);
+ },
+ cycle list/.define={BuGn-4}{[of colormap=BuGn-4]},
+ },
+ /pgfplots/cycle list/BuGn-4/.style={/pgfplots/@@brewer set cycle list={BuGn-4}},
+ %
+ /pgfplots/colormap/BuGn-5/.style={
+ colormap={BuGn-5}{
+ color=(BuGn-B);
+ color=(BuGn-E);
+ color=(BuGn-G);
+ color=(BuGn-I);
+ color=(BuGn-K);
+ },
+ cycle list/.define={BuGn-5}{[of colormap=BuGn-5]},
+ },
+ /pgfplots/cycle list/BuGn-5/.style={/pgfplots/@@brewer set cycle list={BuGn-5}},
+ %
+ /pgfplots/colormap/BuGn-6/.style={
+ colormap={BuGn-6}{
+ color=(BuGn-B);
+ color=(BuGn-D);
+ color=(BuGn-F);
+ color=(BuGn-G);
+ color=(BuGn-I);
+ color=(BuGn-K);
+ },
+ cycle list/.define={BuGn-6}{[of colormap=BuGn-6]},
+ },
+ /pgfplots/cycle list/BuGn-6/.style={/pgfplots/@@brewer set cycle list={BuGn-6}},
+ %
+ /pgfplots/colormap/BuGn-7/.style={
+ colormap={BuGn-7}{
+ color=(BuGn-B);
+ color=(BuGn-D);
+ color=(BuGn-F);
+ color=(BuGn-G);
+ color=(BuGn-H);
+ color=(BuGn-J);
+ color=(BuGn-L);
+ },
+ cycle list/.define={BuGn-7}{[of colormap=BuGn-7]},
+ },
+ /pgfplots/cycle list/BuGn-7/.style={/pgfplots/@@brewer set cycle list={BuGn-7}},
+ %
+ /pgfplots/colormap/BuGn-8/.style={
+ colormap={BuGn-8}{
+ color=(BuGn-A);
+ color=(BuGn-C);
+ color=(BuGn-D);
+ color=(BuGn-F);
+ color=(BuGn-G);
+ color=(BuGn-H);
+ color=(BuGn-J);
+ color=(BuGn-L);
+ },
+ cycle list/.define={BuGn-8}{[of colormap=BuGn-8]},
+ },
+ /pgfplots/cycle list/BuGn-8/.style={/pgfplots/@@brewer set cycle list={BuGn-8}},
+ %
+ /pgfplots/colormap/BuGn-9/.style={
+ colormap={BuGn-9}{
+ color=(BuGn-A);
+ color=(BuGn-C);
+ color=(BuGn-D);
+ color=(BuGn-F);
+ color=(BuGn-G);
+ color=(BuGn-H);
+ color=(BuGn-J);
+ color=(BuGn-K);
+ color=(BuGn-M);
+ },
+ cycle list/.define={BuGn-9}{[of colormap=BuGn-9]},
+ },
+ /pgfplots/cycle list/BuGn-9/.style={/pgfplots/@@brewer set cycle list={BuGn-9}},
+ %
+ /pgfplots/colormap/PuBuGn-3/.style={
+ colormap={PuBuGn-3}{
+ color=(PuBuGn-C);
+ color=(PuBuGn-F);
+ color=(PuBuGn-I);
+ },
+ cycle list/.define={PuBuGn-3}{[of colormap=PuBuGn-3]},
+ },
+ /pgfplots/cycle list/PuBuGn-3/.style={/pgfplots/@@brewer set cycle list={PuBuGn-3}},
+ %
+ /pgfplots/colormap/PuBuGn-4/.style={
+ colormap={PuBuGn-4}{
+ color=(PuBuGn-B);
+ color=(PuBuGn-E);
+ color=(PuBuGn-G);
+ color=(PuBuGn-J);
+ },
+ cycle list/.define={PuBuGn-4}{[of colormap=PuBuGn-4]},
+ },
+ /pgfplots/cycle list/PuBuGn-4/.style={/pgfplots/@@brewer set cycle list={PuBuGn-4}},
+ %
+ /pgfplots/colormap/PuBuGn-5/.style={
+ colormap={PuBuGn-5}{
+ color=(PuBuGn-B);
+ color=(PuBuGn-E);
+ color=(PuBuGn-G);
+ color=(PuBuGn-I);
+ color=(PuBuGn-K);
+ },
+ cycle list/.define={PuBuGn-5}{[of colormap=PuBuGn-5]},
+ },
+ /pgfplots/cycle list/PuBuGn-5/.style={/pgfplots/@@brewer set cycle list={PuBuGn-5}},
+ %
+ /pgfplots/colormap/PuBuGn-6/.style={
+ colormap={PuBuGn-6}{
+ color=(PuBuGn-B);
+ color=(PuBuGn-D);
+ color=(PuBuGn-F);
+ color=(PuBuGn-G);
+ color=(PuBuGn-I);
+ color=(PuBuGn-K);
+ },
+ cycle list/.define={PuBuGn-6}{[of colormap=PuBuGn-6]},
+ },
+ /pgfplots/cycle list/PuBuGn-6/.style={/pgfplots/@@brewer set cycle list={PuBuGn-6}},
+ %
+ /pgfplots/colormap/PuBuGn-7/.style={
+ colormap={PuBuGn-7}{
+ color=(PuBuGn-B);
+ color=(PuBuGn-D);
+ color=(PuBuGn-F);
+ color=(PuBuGn-G);
+ color=(PuBuGn-H);
+ color=(PuBuGn-J);
+ color=(PuBuGn-L);
+ },
+ cycle list/.define={PuBuGn-7}{[of colormap=PuBuGn-7]},
+ },
+ /pgfplots/cycle list/PuBuGn-7/.style={/pgfplots/@@brewer set cycle list={PuBuGn-7}},
+ %
+ /pgfplots/colormap/PuBuGn-8/.style={
+ colormap={PuBuGn-8}{
+ color=(PuBuGn-A);
+ color=(PuBuGn-C);
+ color=(PuBuGn-D);
+ color=(PuBuGn-F);
+ color=(PuBuGn-G);
+ color=(PuBuGn-H);
+ color=(PuBuGn-J);
+ color=(PuBuGn-L);
+ },
+ cycle list/.define={PuBuGn-8}{[of colormap=PuBuGn-8]},
+ },
+ /pgfplots/cycle list/PuBuGn-8/.style={/pgfplots/@@brewer set cycle list={PuBuGn-8}},
+ %
+ /pgfplots/colormap/PuBuGn-9/.style={
+ colormap={PuBuGn-9}{
+ color=(PuBuGn-A);
+ color=(PuBuGn-C);
+ color=(PuBuGn-D);
+ color=(PuBuGn-F);
+ color=(PuBuGn-G);
+ color=(PuBuGn-H);
+ color=(PuBuGn-J);
+ color=(PuBuGn-K);
+ color=(PuBuGn-M);
+ },
+ cycle list/.define={PuBuGn-9}{[of colormap=PuBuGn-9]},
+ },
+ /pgfplots/cycle list/PuBuGn-9/.style={/pgfplots/@@brewer set cycle list={PuBuGn-9}},
+ %
+ /pgfplots/colormap/PuBu-3/.style={
+ colormap={PuBu-3}{
+ color=(PuBu-C);
+ color=(PuBu-F);
+ color=(PuBu-I);
+ },
+ cycle list/.define={PuBu-3}{[of colormap=PuBu-3]},
+ },
+ /pgfplots/cycle list/PuBu-3/.style={/pgfplots/@@brewer set cycle list={PuBu-3}},
+ %
+ /pgfplots/colormap/PuBu-4/.style={
+ colormap={PuBu-4}{
+ color=(PuBu-B);
+ color=(PuBu-E);
+ color=(PuBu-G);
+ color=(PuBu-J);
+ },
+ cycle list/.define={PuBu-4}{[of colormap=PuBu-4]},
+ },
+ /pgfplots/cycle list/PuBu-4/.style={/pgfplots/@@brewer set cycle list={PuBu-4}},
+ %
+ /pgfplots/colormap/PuBu-5/.style={
+ colormap={PuBu-5}{
+ color=(PuBu-B);
+ color=(PuBu-E);
+ color=(PuBu-G);
+ color=(PuBu-I);
+ color=(PuBu-K);
+ },
+ cycle list/.define={PuBu-5}{[of colormap=PuBu-5]},
+ },
+ /pgfplots/cycle list/PuBu-5/.style={/pgfplots/@@brewer set cycle list={PuBu-5}},
+ %
+ /pgfplots/colormap/PuBu-6/.style={
+ colormap={PuBu-6}{
+ color=(PuBu-B);
+ color=(PuBu-D);
+ color=(PuBu-F);
+ color=(PuBu-G);
+ color=(PuBu-I);
+ color=(PuBu-K);
+ },
+ cycle list/.define={PuBu-6}{[of colormap=PuBu-6]},
+ },
+ /pgfplots/cycle list/PuBu-6/.style={/pgfplots/@@brewer set cycle list={PuBu-6}},
+ %
+ /pgfplots/colormap/PuBu-7/.style={
+ colormap={PuBu-7}{
+ color=(PuBu-B);
+ color=(PuBu-D);
+ color=(PuBu-F);
+ color=(PuBu-G);
+ color=(PuBu-H);
+ color=(PuBu-J);
+ color=(PuBu-L);
+ },
+ cycle list/.define={PuBu-7}{[of colormap=PuBu-7]},
+ },
+ /pgfplots/cycle list/PuBu-7/.style={/pgfplots/@@brewer set cycle list={PuBu-7}},
+ %
+ /pgfplots/colormap/PuBu-8/.style={
+ colormap={PuBu-8}{
+ color=(PuBu-A);
+ color=(PuBu-C);
+ color=(PuBu-D);
+ color=(PuBu-F);
+ color=(PuBu-G);
+ color=(PuBu-H);
+ color=(PuBu-J);
+ color=(PuBu-L);
+ },
+ cycle list/.define={PuBu-8}{[of colormap=PuBu-8]},
+ },
+ /pgfplots/cycle list/PuBu-8/.style={/pgfplots/@@brewer set cycle list={PuBu-8}},
+ %
+ /pgfplots/colormap/PuBu-9/.style={
+ colormap={PuBu-9}{
+ color=(PuBu-A);
+ color=(PuBu-C);
+ color=(PuBu-D);
+ color=(PuBu-F);
+ color=(PuBu-G);
+ color=(PuBu-H);
+ color=(PuBu-J);
+ color=(PuBu-K);
+ color=(PuBu-M);
+ },
+ cycle list/.define={PuBu-9}{[of colormap=PuBu-9]},
+ },
+ /pgfplots/cycle list/PuBu-9/.style={/pgfplots/@@brewer set cycle list={PuBu-9}},
+ %
+ /pgfplots/colormap/BuPu-3/.style={
+ colormap={BuPu-3}{
+ color=(BuPu-C);
+ color=(BuPu-F);
+ color=(BuPu-I);
+ },
+ cycle list/.define={BuPu-3}{[of colormap=BuPu-3]},
+ },
+ /pgfplots/cycle list/BuPu-3/.style={/pgfplots/@@brewer set cycle list={BuPu-3}},
+ %
+ /pgfplots/colormap/BuPu-4/.style={
+ colormap={BuPu-4}{
+ color=(BuPu-B);
+ color=(BuPu-E);
+ color=(BuPu-G);
+ color=(BuPu-J);
+ },
+ cycle list/.define={BuPu-4}{[of colormap=BuPu-4]},
+ },
+ /pgfplots/cycle list/BuPu-4/.style={/pgfplots/@@brewer set cycle list={BuPu-4}},
+ %
+ /pgfplots/colormap/BuPu-5/.style={
+ colormap={BuPu-5}{
+ color=(BuPu-B);
+ color=(BuPu-E);
+ color=(BuPu-G);
+ color=(BuPu-I);
+ color=(BuPu-K);
+ },
+ cycle list/.define={BuPu-5}{[of colormap=BuPu-5]},
+ },
+ /pgfplots/cycle list/BuPu-5/.style={/pgfplots/@@brewer set cycle list={BuPu-5}},
+ %
+ /pgfplots/colormap/BuPu-6/.style={
+ colormap={BuPu-6}{
+ color=(BuPu-B);
+ color=(BuPu-D);
+ color=(BuPu-F);
+ color=(BuPu-G);
+ color=(BuPu-I);
+ color=(BuPu-K);
+ },
+ cycle list/.define={BuPu-6}{[of colormap=BuPu-6]},
+ },
+ /pgfplots/cycle list/BuPu-6/.style={/pgfplots/@@brewer set cycle list={BuPu-6}},
+ %
+ /pgfplots/colormap/BuPu-7/.style={
+ colormap={BuPu-7}{
+ color=(BuPu-B);
+ color=(BuPu-D);
+ color=(BuPu-F);
+ color=(BuPu-G);
+ color=(BuPu-H);
+ color=(BuPu-J);
+ color=(BuPu-L);
+ },
+ cycle list/.define={BuPu-7}{[of colormap=BuPu-7]},
+ },
+ /pgfplots/cycle list/BuPu-7/.style={/pgfplots/@@brewer set cycle list={BuPu-7}},
+ %
+ /pgfplots/colormap/BuPu-8/.style={
+ colormap={BuPu-8}{
+ color=(BuPu-A);
+ color=(BuPu-C);
+ color=(BuPu-D);
+ color=(BuPu-F);
+ color=(BuPu-G);
+ color=(BuPu-H);
+ color=(BuPu-J);
+ color=(BuPu-L);
+ },
+ cycle list/.define={BuPu-8}{[of colormap=BuPu-8]},
+ },
+ /pgfplots/cycle list/BuPu-8/.style={/pgfplots/@@brewer set cycle list={BuPu-8}},
+ %
+ /pgfplots/colormap/BuPu-9/.style={
+ colormap={BuPu-9}{
+ color=(BuPu-A);
+ color=(BuPu-C);
+ color=(BuPu-D);
+ color=(BuPu-F);
+ color=(BuPu-G);
+ color=(BuPu-H);
+ color=(BuPu-J);
+ color=(BuPu-K);
+ color=(BuPu-M);
+ },
+ cycle list/.define={BuPu-9}{[of colormap=BuPu-9]},
+ },
+ /pgfplots/cycle list/BuPu-9/.style={/pgfplots/@@brewer set cycle list={BuPu-9}},
+ %
+ /pgfplots/colormap/RdPu-3/.style={
+ colormap={RdPu-3}{
+ color=(RdPu-C);
+ color=(RdPu-F);
+ color=(RdPu-I);
+ },
+ cycle list/.define={RdPu-3}{[of colormap=RdPu-3]},
+ },
+ /pgfplots/cycle list/RdPu-3/.style={/pgfplots/@@brewer set cycle list={RdPu-3}},
+ %
+ /pgfplots/colormap/RdPu-4/.style={
+ colormap={RdPu-4}{
+ color=(RdPu-B);
+ color=(RdPu-E);
+ color=(RdPu-G);
+ color=(RdPu-J);
+ },
+ cycle list/.define={RdPu-4}{[of colormap=RdPu-4]},
+ },
+ /pgfplots/cycle list/RdPu-4/.style={/pgfplots/@@brewer set cycle list={RdPu-4}},
+ %
+ /pgfplots/colormap/RdPu-5/.style={
+ colormap={RdPu-5}{
+ color=(RdPu-B);
+ color=(RdPu-E);
+ color=(RdPu-G);
+ color=(RdPu-I);
+ color=(RdPu-K);
+ },
+ cycle list/.define={RdPu-5}{[of colormap=RdPu-5]},
+ },
+ /pgfplots/cycle list/RdPu-5/.style={/pgfplots/@@brewer set cycle list={RdPu-5}},
+ %
+ /pgfplots/colormap/RdPu-6/.style={
+ colormap={RdPu-6}{
+ color=(RdPu-B);
+ color=(RdPu-D);
+ color=(RdPu-F);
+ color=(RdPu-G);
+ color=(RdPu-I);
+ color=(RdPu-K);
+ },
+ cycle list/.define={RdPu-6}{[of colormap=RdPu-6]},
+ },
+ /pgfplots/cycle list/RdPu-6/.style={/pgfplots/@@brewer set cycle list={RdPu-6}},
+ %
+ /pgfplots/colormap/RdPu-7/.style={
+ colormap={RdPu-7}{
+ color=(RdPu-B);
+ color=(RdPu-D);
+ color=(RdPu-F);
+ color=(RdPu-G);
+ color=(RdPu-H);
+ color=(RdPu-J);
+ color=(RdPu-L);
+ },
+ cycle list/.define={RdPu-7}{[of colormap=RdPu-7]},
+ },
+ /pgfplots/cycle list/RdPu-7/.style={/pgfplots/@@brewer set cycle list={RdPu-7}},
+ %
+ /pgfplots/colormap/RdPu-8/.style={
+ colormap={RdPu-8}{
+ color=(RdPu-A);
+ color=(RdPu-C);
+ color=(RdPu-D);
+ color=(RdPu-F);
+ color=(RdPu-G);
+ color=(RdPu-H);
+ color=(RdPu-J);
+ color=(RdPu-L);
+ },
+ cycle list/.define={RdPu-8}{[of colormap=RdPu-8]},
+ },
+ /pgfplots/cycle list/RdPu-8/.style={/pgfplots/@@brewer set cycle list={RdPu-8}},
+ %
+ /pgfplots/colormap/RdPu-9/.style={
+ colormap={RdPu-9}{
+ color=(RdPu-A);
+ color=(RdPu-C);
+ color=(RdPu-D);
+ color=(RdPu-F);
+ color=(RdPu-G);
+ color=(RdPu-H);
+ color=(RdPu-J);
+ color=(RdPu-K);
+ color=(RdPu-M);
+ },
+ cycle list/.define={RdPu-9}{[of colormap=RdPu-9]},
+ },
+ /pgfplots/cycle list/RdPu-9/.style={/pgfplots/@@brewer set cycle list={RdPu-9}},
+ %
+ /pgfplots/colormap/PuRd-3/.style={
+ colormap={PuRd-3}{
+ color=(PuRd-C);
+ color=(PuRd-F);
+ color=(PuRd-I);
+ },
+ cycle list/.define={PuRd-3}{[of colormap=PuRd-3]},
+ },
+ /pgfplots/cycle list/PuRd-3/.style={/pgfplots/@@brewer set cycle list={PuRd-3}},
+ %
+ /pgfplots/colormap/PuRd-4/.style={
+ colormap={PuRd-4}{
+ color=(PuRd-B);
+ color=(PuRd-E);
+ color=(PuRd-G);
+ color=(PuRd-J);
+ },
+ cycle list/.define={PuRd-4}{[of colormap=PuRd-4]},
+ },
+ /pgfplots/cycle list/PuRd-4/.style={/pgfplots/@@brewer set cycle list={PuRd-4}},
+ %
+ /pgfplots/colormap/PuRd-5/.style={
+ colormap={PuRd-5}{
+ color=(PuRd-B);
+ color=(PuRd-E);
+ color=(PuRd-G);
+ color=(PuRd-I);
+ color=(PuRd-K);
+ },
+ cycle list/.define={PuRd-5}{[of colormap=PuRd-5]},
+ },
+ /pgfplots/cycle list/PuRd-5/.style={/pgfplots/@@brewer set cycle list={PuRd-5}},
+ %
+ /pgfplots/colormap/PuRd-6/.style={
+ colormap={PuRd-6}{
+ color=(PuRd-B);
+ color=(PuRd-D);
+ color=(PuRd-F);
+ color=(PuRd-G);
+ color=(PuRd-I);
+ color=(PuRd-K);
+ },
+ cycle list/.define={PuRd-6}{[of colormap=PuRd-6]},
+ },
+ /pgfplots/cycle list/PuRd-6/.style={/pgfplots/@@brewer set cycle list={PuRd-6}},
+ %
+ /pgfplots/colormap/PuRd-7/.style={
+ colormap={PuRd-7}{
+ color=(PuRd-B);
+ color=(PuRd-D);
+ color=(PuRd-F);
+ color=(PuRd-G);
+ color=(PuRd-H);
+ color=(PuRd-J);
+ color=(PuRd-L);
+ },
+ cycle list/.define={PuRd-7}{[of colormap=PuRd-7]},
+ },
+ /pgfplots/cycle list/PuRd-7/.style={/pgfplots/@@brewer set cycle list={PuRd-7}},
+ %
+ /pgfplots/colormap/PuRd-8/.style={
+ colormap={PuRd-8}{
+ color=(PuRd-A);
+ color=(PuRd-C);
+ color=(PuRd-D);
+ color=(PuRd-F);
+ color=(PuRd-G);
+ color=(PuRd-H);
+ color=(PuRd-J);
+ color=(PuRd-L);
+ },
+ cycle list/.define={PuRd-8}{[of colormap=PuRd-8]},
+ },
+ /pgfplots/cycle list/PuRd-8/.style={/pgfplots/@@brewer set cycle list={PuRd-8}},
+ %
+ /pgfplots/colormap/PuRd-9/.style={
+ colormap={PuRd-9}{
+ color=(PuRd-A);
+ color=(PuRd-C);
+ color=(PuRd-D);
+ color=(PuRd-F);
+ color=(PuRd-G);
+ color=(PuRd-H);
+ color=(PuRd-J);
+ color=(PuRd-K);
+ color=(PuRd-M);
+ },
+ cycle list/.define={PuRd-9}{[of colormap=PuRd-9]},
+ },
+ /pgfplots/cycle list/PuRd-9/.style={/pgfplots/@@brewer set cycle list={PuRd-9}},
+ %
+ /pgfplots/colormap/OrRd-3/.style={
+ colormap={OrRd-3}{
+ color=(OrRd-C);
+ color=(OrRd-F);
+ color=(OrRd-I);
+ },
+ cycle list/.define={OrRd-3}{[of colormap=OrRd-3]},
+ },
+ /pgfplots/cycle list/OrRd-3/.style={/pgfplots/@@brewer set cycle list={OrRd-3}},
+ %
+ /pgfplots/colormap/OrRd-4/.style={
+ colormap={OrRd-4}{
+ color=(OrRd-B);
+ color=(OrRd-E);
+ color=(OrRd-G);
+ color=(OrRd-J);
+ },
+ cycle list/.define={OrRd-4}{[of colormap=OrRd-4]},
+ },
+ /pgfplots/cycle list/OrRd-4/.style={/pgfplots/@@brewer set cycle list={OrRd-4}},
+ %
+ /pgfplots/colormap/OrRd-5/.style={
+ colormap={OrRd-5}{
+ color=(OrRd-B);
+ color=(OrRd-E);
+ color=(OrRd-G);
+ color=(OrRd-I);
+ color=(OrRd-K);
+ },
+ cycle list/.define={OrRd-5}{[of colormap=OrRd-5]},
+ },
+ /pgfplots/cycle list/OrRd-5/.style={/pgfplots/@@brewer set cycle list={OrRd-5}},
+ %
+ /pgfplots/colormap/OrRd-6/.style={
+ colormap={OrRd-6}{
+ color=(OrRd-B);
+ color=(OrRd-D);
+ color=(OrRd-F);
+ color=(OrRd-G);
+ color=(OrRd-I);
+ color=(OrRd-K);
+ },
+ cycle list/.define={OrRd-6}{[of colormap=OrRd-6]},
+ },
+ /pgfplots/cycle list/OrRd-6/.style={/pgfplots/@@brewer set cycle list={OrRd-6}},
+ %
+ /pgfplots/colormap/OrRd-7/.style={
+ colormap={OrRd-7}{
+ color=(OrRd-B);
+ color=(OrRd-D);
+ color=(OrRd-F);
+ color=(OrRd-G);
+ color=(OrRd-H);
+ color=(OrRd-J);
+ color=(OrRd-L);
+ },
+ cycle list/.define={OrRd-7}{[of colormap=OrRd-7]},
+ },
+ /pgfplots/cycle list/OrRd-7/.style={/pgfplots/@@brewer set cycle list={OrRd-7}},
+ %
+ /pgfplots/colormap/OrRd-8/.style={
+ colormap={OrRd-8}{
+ color=(OrRd-A);
+ color=(OrRd-C);
+ color=(OrRd-D);
+ color=(OrRd-F);
+ color=(OrRd-G);
+ color=(OrRd-H);
+ color=(OrRd-J);
+ color=(OrRd-L);
+ },
+ cycle list/.define={OrRd-8}{[of colormap=OrRd-8]},
+ },
+ /pgfplots/cycle list/OrRd-8/.style={/pgfplots/@@brewer set cycle list={OrRd-8}},
+ %
+ /pgfplots/colormap/OrRd-9/.style={
+ colormap={OrRd-9}{
+ color=(OrRd-A);
+ color=(OrRd-C);
+ color=(OrRd-D);
+ color=(OrRd-F);
+ color=(OrRd-G);
+ color=(OrRd-H);
+ color=(OrRd-J);
+ color=(OrRd-K);
+ color=(OrRd-M);
+ },
+ cycle list/.define={OrRd-9}{[of colormap=OrRd-9]},
+ },
+ /pgfplots/cycle list/OrRd-9/.style={/pgfplots/@@brewer set cycle list={OrRd-9}},
+ %
+ /pgfplots/colormap/YlOrRd-3/.style={
+ colormap={YlOrRd-3}{
+ color=(YlOrRd-C);
+ color=(YlOrRd-F);
+ color=(YlOrRd-I);
+ },
+ cycle list/.define={YlOrRd-3}{[of colormap=YlOrRd-3]},
+ },
+ /pgfplots/cycle list/YlOrRd-3/.style={/pgfplots/@@brewer set cycle list={YlOrRd-3}},
+ %
+ /pgfplots/colormap/YlOrRd-4/.style={
+ colormap={YlOrRd-4}{
+ color=(YlOrRd-B);
+ color=(YlOrRd-E);
+ color=(YlOrRd-G);
+ color=(YlOrRd-J);
+ },
+ cycle list/.define={YlOrRd-4}{[of colormap=YlOrRd-4]},
+ },
+ /pgfplots/cycle list/YlOrRd-4/.style={/pgfplots/@@brewer set cycle list={YlOrRd-4}},
+ %
+ /pgfplots/colormap/YlOrRd-5/.style={
+ colormap={YlOrRd-5}{
+ color=(YlOrRd-B);
+ color=(YlOrRd-E);
+ color=(YlOrRd-G);
+ color=(YlOrRd-I);
+ color=(YlOrRd-K);
+ },
+ cycle list/.define={YlOrRd-5}{[of colormap=YlOrRd-5]},
+ },
+ /pgfplots/cycle list/YlOrRd-5/.style={/pgfplots/@@brewer set cycle list={YlOrRd-5}},
+ %
+ /pgfplots/colormap/YlOrRd-6/.style={
+ colormap={YlOrRd-6}{
+ color=(YlOrRd-B);
+ color=(YlOrRd-D);
+ color=(YlOrRd-F);
+ color=(YlOrRd-G);
+ color=(YlOrRd-I);
+ color=(YlOrRd-K);
+ },
+ cycle list/.define={YlOrRd-6}{[of colormap=YlOrRd-6]},
+ },
+ /pgfplots/cycle list/YlOrRd-6/.style={/pgfplots/@@brewer set cycle list={YlOrRd-6}},
+ %
+ /pgfplots/colormap/YlOrRd-7/.style={
+ colormap={YlOrRd-7}{
+ color=(YlOrRd-B);
+ color=(YlOrRd-D);
+ color=(YlOrRd-F);
+ color=(YlOrRd-G);
+ color=(YlOrRd-H);
+ color=(YlOrRd-J);
+ color=(YlOrRd-L);
+ },
+ cycle list/.define={YlOrRd-7}{[of colormap=YlOrRd-7]},
+ },
+ /pgfplots/cycle list/YlOrRd-7/.style={/pgfplots/@@brewer set cycle list={YlOrRd-7}},
+ %
+ /pgfplots/colormap/YlOrRd-8/.style={
+ colormap={YlOrRd-8}{
+ color=(YlOrRd-A);
+ color=(YlOrRd-C);
+ color=(YlOrRd-D);
+ color=(YlOrRd-F);
+ color=(YlOrRd-G);
+ color=(YlOrRd-H);
+ color=(YlOrRd-J);
+ color=(YlOrRd-L);
+ },
+ cycle list/.define={YlOrRd-8}{[of colormap=YlOrRd-8]},
+ },
+ /pgfplots/cycle list/YlOrRd-8/.style={/pgfplots/@@brewer set cycle list={YlOrRd-8}},
+ %
+ /pgfplots/colormap/YlOrRd-9/.style={
+ colormap={YlOrRd-9}{
+ color=(YlOrRd-A);
+ color=(YlOrRd-C);
+ color=(YlOrRd-D);
+ color=(YlOrRd-F);
+ color=(YlOrRd-G);
+ color=(YlOrRd-H);
+ color=(YlOrRd-J);
+ color=(YlOrRd-K);
+ color=(YlOrRd-M);
+ },
+ cycle list/.define={YlOrRd-9}{[of colormap=YlOrRd-9]},
+ },
+ /pgfplots/cycle list/YlOrRd-9/.style={/pgfplots/@@brewer set cycle list={YlOrRd-9}},
+ %
+ /pgfplots/colormap/YlOrBr-3/.style={
+ colormap={YlOrBr-3}{
+ color=(YlOrBr-C);
+ color=(YlOrBr-F);
+ color=(YlOrBr-I);
+ },
+ cycle list/.define={YlOrBr-3}{[of colormap=YlOrBr-3]},
+ },
+ /pgfplots/cycle list/YlOrBr-3/.style={/pgfplots/@@brewer set cycle list={YlOrBr-3}},
+ %
+ /pgfplots/colormap/YlOrBr-4/.style={
+ colormap={YlOrBr-4}{
+ color=(YlOrBr-B);
+ color=(YlOrBr-E);
+ color=(YlOrBr-G);
+ color=(YlOrBr-J);
+ },
+ cycle list/.define={YlOrBr-4}{[of colormap=YlOrBr-4]},
+ },
+ /pgfplots/cycle list/YlOrBr-4/.style={/pgfplots/@@brewer set cycle list={YlOrBr-4}},
+ %
+ /pgfplots/colormap/YlOrBr-5/.style={
+ colormap={YlOrBr-5}{
+ color=(YlOrBr-B);
+ color=(YlOrBr-E);
+ color=(YlOrBr-G);
+ color=(YlOrBr-I);
+ color=(YlOrBr-K);
+ },
+ cycle list/.define={YlOrBr-5}{[of colormap=YlOrBr-5]},
+ },
+ /pgfplots/cycle list/YlOrBr-5/.style={/pgfplots/@@brewer set cycle list={YlOrBr-5}},
+ %
+ /pgfplots/colormap/YlOrBr-6/.style={
+ colormap={YlOrBr-6}{
+ color=(YlOrBr-B);
+ color=(YlOrBr-D);
+ color=(YlOrBr-F);
+ color=(YlOrBr-G);
+ color=(YlOrBr-I);
+ color=(YlOrBr-K);
+ },
+ cycle list/.define={YlOrBr-6}{[of colormap=YlOrBr-6]},
+ },
+ /pgfplots/cycle list/YlOrBr-6/.style={/pgfplots/@@brewer set cycle list={YlOrBr-6}},
+ %
+ /pgfplots/colormap/YlOrBr-7/.style={
+ colormap={YlOrBr-7}{
+ color=(YlOrBr-B);
+ color=(YlOrBr-D);
+ color=(YlOrBr-F);
+ color=(YlOrBr-G);
+ color=(YlOrBr-H);
+ color=(YlOrBr-J);
+ color=(YlOrBr-L);
+ },
+ cycle list/.define={YlOrBr-7}{[of colormap=YlOrBr-7]},
+ },
+ /pgfplots/cycle list/YlOrBr-7/.style={/pgfplots/@@brewer set cycle list={YlOrBr-7}},
+ %
+ /pgfplots/colormap/YlOrBr-8/.style={
+ colormap={YlOrBr-8}{
+ color=(YlOrBr-A);
+ color=(YlOrBr-C);
+ color=(YlOrBr-D);
+ color=(YlOrBr-F);
+ color=(YlOrBr-G);
+ color=(YlOrBr-H);
+ color=(YlOrBr-J);
+ color=(YlOrBr-L);
+ },
+ cycle list/.define={YlOrBr-8}{[of colormap=YlOrBr-8]},
+ },
+ /pgfplots/cycle list/YlOrBr-8/.style={/pgfplots/@@brewer set cycle list={YlOrBr-8}},
+ %
+ /pgfplots/colormap/YlOrBr-9/.style={
+ colormap={YlOrBr-9}{
+ color=(YlOrBr-A);
+ color=(YlOrBr-C);
+ color=(YlOrBr-D);
+ color=(YlOrBr-F);
+ color=(YlOrBr-G);
+ color=(YlOrBr-H);
+ color=(YlOrBr-J);
+ color=(YlOrBr-K);
+ color=(YlOrBr-M);
+ },
+ cycle list/.define={YlOrBr-9}{[of colormap=YlOrBr-9]},
+ },
+ /pgfplots/cycle list/YlOrBr-9/.style={/pgfplots/@@brewer set cycle list={YlOrBr-9}},
+ %
+ /pgfplots/colormap/Purples-3/.style={
+ colormap={Purples-3}{
+ color=(Purples-C);
+ color=(Purples-F);
+ color=(Purples-I);
+ },
+ cycle list/.define={Purples-3}{[of colormap=Purples-3]},
+ },
+ /pgfplots/cycle list/Purples-3/.style={/pgfplots/@@brewer set cycle list={Purples-3}},
+ %
+ /pgfplots/colormap/Purples-4/.style={
+ colormap={Purples-4}{
+ color=(Purples-B);
+ color=(Purples-E);
+ color=(Purples-G);
+ color=(Purples-J);
+ },
+ cycle list/.define={Purples-4}{[of colormap=Purples-4]},
+ },
+ /pgfplots/cycle list/Purples-4/.style={/pgfplots/@@brewer set cycle list={Purples-4}},
+ %
+ /pgfplots/colormap/Purples-5/.style={
+ colormap={Purples-5}{
+ color=(Purples-B);
+ color=(Purples-E);
+ color=(Purples-G);
+ color=(Purples-I);
+ color=(Purples-K);
+ },
+ cycle list/.define={Purples-5}{[of colormap=Purples-5]},
+ },
+ /pgfplots/cycle list/Purples-5/.style={/pgfplots/@@brewer set cycle list={Purples-5}},
+ %
+ /pgfplots/colormap/Purples-6/.style={
+ colormap={Purples-6}{
+ color=(Purples-B);
+ color=(Purples-D);
+ color=(Purples-F);
+ color=(Purples-G);
+ color=(Purples-I);
+ color=(Purples-K);
+ },
+ cycle list/.define={Purples-6}{[of colormap=Purples-6]},
+ },
+ /pgfplots/cycle list/Purples-6/.style={/pgfplots/@@brewer set cycle list={Purples-6}},
+ %
+ /pgfplots/colormap/Purples-7/.style={
+ colormap={Purples-7}{
+ color=(Purples-B);
+ color=(Purples-D);
+ color=(Purples-F);
+ color=(Purples-G);
+ color=(Purples-H);
+ color=(Purples-J);
+ color=(Purples-L);
+ },
+ cycle list/.define={Purples-7}{[of colormap=Purples-7]},
+ },
+ /pgfplots/cycle list/Purples-7/.style={/pgfplots/@@brewer set cycle list={Purples-7}},
+ %
+ /pgfplots/colormap/Purples-8/.style={
+ colormap={Purples-8}{
+ color=(Purples-A);
+ color=(Purples-C);
+ color=(Purples-D);
+ color=(Purples-F);
+ color=(Purples-G);
+ color=(Purples-H);
+ color=(Purples-J);
+ color=(Purples-L);
+ },
+ cycle list/.define={Purples-8}{[of colormap=Purples-8]},
+ },
+ /pgfplots/cycle list/Purples-8/.style={/pgfplots/@@brewer set cycle list={Purples-8}},
+ %
+ /pgfplots/colormap/Purples-9/.style={
+ colormap={Purples-9}{
+ color=(Purples-A);
+ color=(Purples-C);
+ color=(Purples-D);
+ color=(Purples-F);
+ color=(Purples-G);
+ color=(Purples-H);
+ color=(Purples-J);
+ color=(Purples-K);
+ color=(Purples-M);
+ },
+ cycle list/.define={Purples-9}{[of colormap=Purples-9]},
+ },
+ /pgfplots/cycle list/Purples-9/.style={/pgfplots/@@brewer set cycle list={Purples-9}},
+ %
+ /pgfplots/colormap/Blues-3/.style={
+ colormap={Blues-3}{
+ color=(Blues-C);
+ color=(Blues-F);
+ color=(Blues-I);
+ },
+ cycle list/.define={Blues-3}{[of colormap=Blues-3]},
+ },
+ /pgfplots/cycle list/Blues-3/.style={/pgfplots/@@brewer set cycle list={Blues-3}},
+ %
+ /pgfplots/colormap/Blues-4/.style={
+ colormap={Blues-4}{
+ color=(Blues-B);
+ color=(Blues-E);
+ color=(Blues-G);
+ color=(Blues-J);
+ },
+ cycle list/.define={Blues-4}{[of colormap=Blues-4]},
+ },
+ /pgfplots/cycle list/Blues-4/.style={/pgfplots/@@brewer set cycle list={Blues-4}},
+ %
+ /pgfplots/colormap/Blues-5/.style={
+ colormap={Blues-5}{
+ color=(Blues-B);
+ color=(Blues-E);
+ color=(Blues-G);
+ color=(Blues-I);
+ color=(Blues-K);
+ },
+ cycle list/.define={Blues-5}{[of colormap=Blues-5]},
+ },
+ /pgfplots/cycle list/Blues-5/.style={/pgfplots/@@brewer set cycle list={Blues-5}},
+ %
+ /pgfplots/colormap/Blues-6/.style={
+ colormap={Blues-6}{
+ color=(Blues-B);
+ color=(Blues-D);
+ color=(Blues-F);
+ color=(Blues-G);
+ color=(Blues-I);
+ color=(Blues-K);
+ },
+ cycle list/.define={Blues-6}{[of colormap=Blues-6]},
+ },
+ /pgfplots/cycle list/Blues-6/.style={/pgfplots/@@brewer set cycle list={Blues-6}},
+ %
+ /pgfplots/colormap/Blues-7/.style={
+ colormap={Blues-7}{
+ color=(Blues-B);
+ color=(Blues-D);
+ color=(Blues-F);
+ color=(Blues-G);
+ color=(Blues-H);
+ color=(Blues-J);
+ color=(Blues-L);
+ },
+ cycle list/.define={Blues-7}{[of colormap=Blues-7]},
+ },
+ /pgfplots/cycle list/Blues-7/.style={/pgfplots/@@brewer set cycle list={Blues-7}},
+ %
+ /pgfplots/colormap/Blues-8/.style={
+ colormap={Blues-8}{
+ color=(Blues-A);
+ color=(Blues-C);
+ color=(Blues-D);
+ color=(Blues-F);
+ color=(Blues-G);
+ color=(Blues-H);
+ color=(Blues-J);
+ color=(Blues-L);
+ },
+ cycle list/.define={Blues-8}{[of colormap=Blues-8]},
+ },
+ /pgfplots/cycle list/Blues-8/.style={/pgfplots/@@brewer set cycle list={Blues-8}},
+ %
+ /pgfplots/colormap/Blues-9/.style={
+ colormap={Blues-9}{
+ color=(Blues-A);
+ color=(Blues-C);
+ color=(Blues-D);
+ color=(Blues-F);
+ color=(Blues-G);
+ color=(Blues-H);
+ color=(Blues-J);
+ color=(Blues-K);
+ color=(Blues-M);
+ },
+ cycle list/.define={Blues-9}{[of colormap=Blues-9]},
+ },
+ /pgfplots/cycle list/Blues-9/.style={/pgfplots/@@brewer set cycle list={Blues-9}},
+ %
+ /pgfplots/colormap/Greens-3/.style={
+ colormap={Greens-3}{
+ color=(Greens-C);
+ color=(Greens-F);
+ color=(Greens-I);
+ },
+ cycle list/.define={Greens-3}{[of colormap=Greens-3]},
+ },
+ /pgfplots/cycle list/Greens-3/.style={/pgfplots/@@brewer set cycle list={Greens-3}},
+ %
+ /pgfplots/colormap/Greens-4/.style={
+ colormap={Greens-4}{
+ color=(Greens-B);
+ color=(Greens-E);
+ color=(Greens-G);
+ color=(Greens-J);
+ },
+ cycle list/.define={Greens-4}{[of colormap=Greens-4]},
+ },
+ /pgfplots/cycle list/Greens-4/.style={/pgfplots/@@brewer set cycle list={Greens-4}},
+ %
+ /pgfplots/colormap/Greens-5/.style={
+ colormap={Greens-5}{
+ color=(Greens-B);
+ color=(Greens-E);
+ color=(Greens-G);
+ color=(Greens-I);
+ color=(Greens-K);
+ },
+ cycle list/.define={Greens-5}{[of colormap=Greens-5]},
+ },
+ /pgfplots/cycle list/Greens-5/.style={/pgfplots/@@brewer set cycle list={Greens-5}},
+ %
+ /pgfplots/colormap/Greens-6/.style={
+ colormap={Greens-6}{
+ color=(Greens-B);
+ color=(Greens-D);
+ color=(Greens-F);
+ color=(Greens-G);
+ color=(Greens-I);
+ color=(Greens-K);
+ },
+ cycle list/.define={Greens-6}{[of colormap=Greens-6]},
+ },
+ /pgfplots/cycle list/Greens-6/.style={/pgfplots/@@brewer set cycle list={Greens-6}},
+ %
+ /pgfplots/colormap/Greens-7/.style={
+ colormap={Greens-7}{
+ color=(Greens-B);
+ color=(Greens-D);
+ color=(Greens-F);
+ color=(Greens-G);
+ color=(Greens-H);
+ color=(Greens-J);
+ color=(Greens-L);
+ },
+ cycle list/.define={Greens-7}{[of colormap=Greens-7]},
+ },
+ /pgfplots/cycle list/Greens-7/.style={/pgfplots/@@brewer set cycle list={Greens-7}},
+ %
+ /pgfplots/colormap/Greens-8/.style={
+ colormap={Greens-8}{
+ color=(Greens-A);
+ color=(Greens-C);
+ color=(Greens-D);
+ color=(Greens-F);
+ color=(Greens-G);
+ color=(Greens-H);
+ color=(Greens-J);
+ color=(Greens-L);
+ },
+ cycle list/.define={Greens-8}{[of colormap=Greens-8]},
+ },
+ /pgfplots/cycle list/Greens-8/.style={/pgfplots/@@brewer set cycle list={Greens-8}},
+ %
+ /pgfplots/colormap/Greens-9/.style={
+ colormap={Greens-9}{
+ color=(Greens-A);
+ color=(Greens-C);
+ color=(Greens-D);
+ color=(Greens-F);
+ color=(Greens-G);
+ color=(Greens-H);
+ color=(Greens-J);
+ color=(Greens-K);
+ color=(Greens-M);
+ },
+ cycle list/.define={Greens-9}{[of colormap=Greens-9]},
+ },
+ /pgfplots/cycle list/Greens-9/.style={/pgfplots/@@brewer set cycle list={Greens-9}},
+ %
+ /pgfplots/colormap/Oranges-3/.style={
+ colormap={Oranges-3}{
+ color=(Oranges-C);
+ color=(Oranges-F);
+ color=(Oranges-I);
+ },
+ cycle list/.define={Oranges-3}{[of colormap=Oranges-3]},
+ },
+ /pgfplots/cycle list/Oranges-3/.style={/pgfplots/@@brewer set cycle list={Oranges-3}},
+ %
+ /pgfplots/colormap/Oranges-4/.style={
+ colormap={Oranges-4}{
+ color=(Oranges-B);
+ color=(Oranges-E);
+ color=(Oranges-G);
+ color=(Oranges-J);
+ },
+ cycle list/.define={Oranges-4}{[of colormap=Oranges-4]},
+ },
+ /pgfplots/cycle list/Oranges-4/.style={/pgfplots/@@brewer set cycle list={Oranges-4}},
+ %
+ /pgfplots/colormap/Oranges-5/.style={
+ colormap={Oranges-5}{
+ color=(Oranges-B);
+ color=(Oranges-E);
+ color=(Oranges-G);
+ color=(Oranges-I);
+ color=(Oranges-K);
+ },
+ cycle list/.define={Oranges-5}{[of colormap=Oranges-5]},
+ },
+ /pgfplots/cycle list/Oranges-5/.style={/pgfplots/@@brewer set cycle list={Oranges-5}},
+ %
+ /pgfplots/colormap/Oranges-6/.style={
+ colormap={Oranges-6}{
+ color=(Oranges-B);
+ color=(Oranges-D);
+ color=(Oranges-F);
+ color=(Oranges-G);
+ color=(Oranges-I);
+ color=(Oranges-K);
+ },
+ cycle list/.define={Oranges-6}{[of colormap=Oranges-6]},
+ },
+ /pgfplots/cycle list/Oranges-6/.style={/pgfplots/@@brewer set cycle list={Oranges-6}},
+ %
+ /pgfplots/colormap/Oranges-7/.style={
+ colormap={Oranges-7}{
+ color=(Oranges-B);
+ color=(Oranges-D);
+ color=(Oranges-F);
+ color=(Oranges-G);
+ color=(Oranges-H);
+ color=(Oranges-J);
+ color=(Oranges-L);
+ },
+ cycle list/.define={Oranges-7}{[of colormap=Oranges-7]},
+ },
+ /pgfplots/cycle list/Oranges-7/.style={/pgfplots/@@brewer set cycle list={Oranges-7}},
+ %
+ /pgfplots/colormap/Oranges-8/.style={
+ colormap={Oranges-8}{
+ color=(Oranges-A);
+ color=(Oranges-C);
+ color=(Oranges-D);
+ color=(Oranges-F);
+ color=(Oranges-G);
+ color=(Oranges-H);
+ color=(Oranges-J);
+ color=(Oranges-L);
+ },
+ cycle list/.define={Oranges-8}{[of colormap=Oranges-8]},
+ },
+ /pgfplots/cycle list/Oranges-8/.style={/pgfplots/@@brewer set cycle list={Oranges-8}},
+ %
+ /pgfplots/colormap/Oranges-9/.style={
+ colormap={Oranges-9}{
+ color=(Oranges-A);
+ color=(Oranges-C);
+ color=(Oranges-D);
+ color=(Oranges-F);
+ color=(Oranges-G);
+ color=(Oranges-H);
+ color=(Oranges-J);
+ color=(Oranges-K);
+ color=(Oranges-M);
+ },
+ cycle list/.define={Oranges-9}{[of colormap=Oranges-9]},
+ },
+ /pgfplots/cycle list/Oranges-9/.style={/pgfplots/@@brewer set cycle list={Oranges-9}},
+ %
+ /pgfplots/colormap/Reds-3/.style={
+ colormap={Reds-3}{
+ color=(Reds-C);
+ color=(Reds-F);
+ color=(Reds-I);
+ },
+ cycle list/.define={Reds-3}{[of colormap=Reds-3]},
+ },
+ /pgfplots/cycle list/Reds-3/.style={/pgfplots/@@brewer set cycle list={Reds-3}},
+ %
+ /pgfplots/colormap/Reds-4/.style={
+ colormap={Reds-4}{
+ color=(Reds-B);
+ color=(Reds-E);
+ color=(Reds-G);
+ color=(Reds-J);
+ },
+ cycle list/.define={Reds-4}{[of colormap=Reds-4]},
+ },
+ /pgfplots/cycle list/Reds-4/.style={/pgfplots/@@brewer set cycle list={Reds-4}},
+ %
+ /pgfplots/colormap/Reds-5/.style={
+ colormap={Reds-5}{
+ color=(Reds-B);
+ color=(Reds-E);
+ color=(Reds-G);
+ color=(Reds-I);
+ color=(Reds-K);
+ },
+ cycle list/.define={Reds-5}{[of colormap=Reds-5]},
+ },
+ /pgfplots/cycle list/Reds-5/.style={/pgfplots/@@brewer set cycle list={Reds-5}},
+ %
+ /pgfplots/colormap/Reds-6/.style={
+ colormap={Reds-6}{
+ color=(Reds-B);
+ color=(Reds-D);
+ color=(Reds-F);
+ color=(Reds-G);
+ color=(Reds-I);
+ color=(Reds-K);
+ },
+ cycle list/.define={Reds-6}{[of colormap=Reds-6]},
+ },
+ /pgfplots/cycle list/Reds-6/.style={/pgfplots/@@brewer set cycle list={Reds-6}},
+ %
+ /pgfplots/colormap/Reds-7/.style={
+ colormap={Reds-7}{
+ color=(Reds-B);
+ color=(Reds-D);
+ color=(Reds-F);
+ color=(Reds-G);
+ color=(Reds-H);
+ color=(Reds-J);
+ color=(Reds-L);
+ },
+ cycle list/.define={Reds-7}{[of colormap=Reds-7]},
+ },
+ /pgfplots/cycle list/Reds-7/.style={/pgfplots/@@brewer set cycle list={Reds-7}},
+ %
+ /pgfplots/colormap/Reds-8/.style={
+ colormap={Reds-8}{
+ color=(Reds-A);
+ color=(Reds-C);
+ color=(Reds-D);
+ color=(Reds-F);
+ color=(Reds-G);
+ color=(Reds-H);
+ color=(Reds-J);
+ color=(Reds-L);
+ },
+ cycle list/.define={Reds-8}{[of colormap=Reds-8]},
+ },
+ /pgfplots/cycle list/Reds-8/.style={/pgfplots/@@brewer set cycle list={Reds-8}},
+ %
+ /pgfplots/colormap/Reds-9/.style={
+ colormap={Reds-9}{
+ color=(Reds-A);
+ color=(Reds-C);
+ color=(Reds-D);
+ color=(Reds-F);
+ color=(Reds-G);
+ color=(Reds-H);
+ color=(Reds-J);
+ color=(Reds-K);
+ color=(Reds-M);
+ },
+ cycle list/.define={Reds-9}{[of colormap=Reds-9]},
+ },
+ /pgfplots/cycle list/Reds-9/.style={/pgfplots/@@brewer set cycle list={Reds-9}},
+ %
+ /pgfplots/colormap/Greys-3/.style={
+ colormap={Greys-3}{
+ color=(Greys-C);
+ color=(Greys-F);
+ color=(Greys-I);
+ },
+ cycle list/.define={Greys-3}{[of colormap=Greys-3]},
+ },
+ /pgfplots/cycle list/Greys-3/.style={/pgfplots/@@brewer set cycle list={Greys-3}},
+ %
+ /pgfplots/colormap/Greys-4/.style={
+ colormap={Greys-4}{
+ color=(Greys-B);
+ color=(Greys-E);
+ color=(Greys-G);
+ color=(Greys-J);
+ },
+ cycle list/.define={Greys-4}{[of colormap=Greys-4]},
+ },
+ /pgfplots/cycle list/Greys-4/.style={/pgfplots/@@brewer set cycle list={Greys-4}},
+ %
+ /pgfplots/colormap/Greys-5/.style={
+ colormap={Greys-5}{
+ color=(Greys-B);
+ color=(Greys-E);
+ color=(Greys-G);
+ color=(Greys-I);
+ color=(Greys-K);
+ },
+ cycle list/.define={Greys-5}{[of colormap=Greys-5]},
+ },
+ /pgfplots/cycle list/Greys-5/.style={/pgfplots/@@brewer set cycle list={Greys-5}},
+ %
+ /pgfplots/colormap/Greys-6/.style={
+ colormap={Greys-6}{
+ color=(Greys-B);
+ color=(Greys-D);
+ color=(Greys-F);
+ color=(Greys-G);
+ color=(Greys-I);
+ color=(Greys-K);
+ },
+ cycle list/.define={Greys-6}{[of colormap=Greys-6]},
+ },
+ /pgfplots/cycle list/Greys-6/.style={/pgfplots/@@brewer set cycle list={Greys-6}},
+ %
+ /pgfplots/colormap/Greys-7/.style={
+ colormap={Greys-7}{
+ color=(Greys-B);
+ color=(Greys-D);
+ color=(Greys-F);
+ color=(Greys-G);
+ color=(Greys-H);
+ color=(Greys-J);
+ color=(Greys-L);
+ },
+ cycle list/.define={Greys-7}{[of colormap=Greys-7]},
+ },
+ /pgfplots/cycle list/Greys-7/.style={/pgfplots/@@brewer set cycle list={Greys-7}},
+ %
+ /pgfplots/colormap/Greys-8/.style={
+ colormap={Greys-8}{
+ color=(Greys-A);
+ color=(Greys-C);
+ color=(Greys-D);
+ color=(Greys-F);
+ color=(Greys-G);
+ color=(Greys-H);
+ color=(Greys-J);
+ color=(Greys-L);
+ },
+ cycle list/.define={Greys-8}{[of colormap=Greys-8]},
+ },
+ /pgfplots/cycle list/Greys-8/.style={/pgfplots/@@brewer set cycle list={Greys-8}},
+ %
+ /pgfplots/colormap/Greys-9/.style={
+ colormap={Greys-9}{
+ color=(Greys-A);
+ color=(Greys-C);
+ color=(Greys-D);
+ color=(Greys-F);
+ color=(Greys-G);
+ color=(Greys-H);
+ color=(Greys-J);
+ color=(Greys-K);
+ color=(Greys-M);
+ },
+ cycle list/.define={Greys-9}{[of colormap=Greys-9]},
+ },
+ /pgfplots/cycle list/Greys-9/.style={/pgfplots/@@brewer set cycle list={Greys-9}},
+ %
+ % ===========================================================================
+ /pgfplots/colormap/PuOr-3/.style={
+ colormap={PuOr-3}{
+ color=(PuOr-E);
+ color=(PuOr-H);
+ color=(PuOr-K);
+ },
+ cycle list/.define={PuOr-3}{[of colormap=PuOr-3]},
+ },
+ /pgfplots/cycle list/PuOr-3/.style={/pgfplots/@@brewer set cycle list={PuOr-3}},
+ %
+ /pgfplots/colormap/PuOr-4/.style={
+ colormap={PuOr-4}{
+ color=(PuOr-C);
+ color=(PuOr-F);
+ color=(PuOr-J);
+ color=(PuOr-M);
+ },
+ cycle list/.define={PuOr-4}{[of colormap=PuOr-4]},
+ },
+ /pgfplots/cycle list/PuOr-4/.style={/pgfplots/@@brewer set cycle list={PuOr-4}},
+ %
+ /pgfplots/colormap/PuOr-5/.style={
+ colormap={PuOr-5}{
+ color=(PuOr-C);
+ color=(PuOr-F);
+ color=(PuOr-H);
+ color=(PuOr-J);
+ color=(PuOr-M);
+ },
+ cycle list/.define={PuOr-5}{[of colormap=PuOr-5]},
+ },
+ /pgfplots/cycle list/PuOr-5/.style={/pgfplots/@@brewer set cycle list={PuOr-5}},
+ %
+ /pgfplots/colormap/PuOr-6/.style={
+ colormap={PuOr-6}{
+ color=(PuOr-B);
+ color=(PuOr-E);
+ color=(PuOr-G);
+ color=(PuOr-I);
+ color=(PuOr-K);
+ color=(PuOr-N);
+ },
+ cycle list/.define={PuOr-6}{[of colormap=PuOr-6]},
+ },
+ /pgfplots/cycle list/PuOr-6/.style={/pgfplots/@@brewer set cycle list={PuOr-6}},
+ %
+ /pgfplots/colormap/PuOr-7/.style={
+ colormap={PuOr-7}{
+ color=(PuOr-B);
+ color=(PuOr-E);
+ color=(PuOr-G);
+ color=(PuOr-H);
+ color=(PuOr-I);
+ color=(PuOr-K);
+ color=(PuOr-N);
+ },
+ cycle list/.define={PuOr-7}{[of colormap=PuOr-7]},
+ },
+ /pgfplots/cycle list/PuOr-7/.style={/pgfplots/@@brewer set cycle list={PuOr-7}},
+ %
+ /pgfplots/colormap/PuOr-8/.style={
+ colormap={PuOr-8}{
+ color=(PuOr-B);
+ color=(PuOr-D);
+ color=(PuOr-F);
+ color=(PuOr-G);
+ color=(PuOr-I);
+ color=(PuOr-J);
+ color=(PuOr-L);
+ color=(PuOr-N);
+ },
+ cycle list/.define={PuOr-8}{[of colormap=PuOr-8]},
+ },
+ /pgfplots/cycle list/PuOr-8/.style={/pgfplots/@@brewer set cycle list={PuOr-8}},
+ %
+ /pgfplots/colormap/PuOr-9/.style={
+ colormap={PuOr-9}{
+ color=(PuOr-B);
+ color=(PuOr-D);
+ color=(PuOr-F);
+ color=(PuOr-G);
+ color=(PuOr-H);
+ color=(PuOr-I);
+ color=(PuOr-J);
+ color=(PuOr-L);
+ color=(PuOr-N);
+ },
+ cycle list/.define={PuOr-9}{[of colormap=PuOr-9]},
+ },
+ /pgfplots/cycle list/PuOr-9/.style={/pgfplots/@@brewer set cycle list={PuOr-9}},
+ %
+ /pgfplots/colormap/PuOr-10/.style={
+ colormap={PuOr-10}{
+ color=(PuOr-A);
+ color=(PuOr-B);
+ color=(PuOr-D);
+ color=(PuOr-F);
+ color=(PuOr-G);
+ color=(PuOr-I);
+ color=(PuOr-J);
+ color=(PuOr-L);
+ color=(PuOr-N);
+ color=(PuOr-O);
+ },
+ cycle list/.define={PuOr-10}{[of colormap=PuOr-10]},
+ },
+ /pgfplots/cycle list/PuOr-10/.style={/pgfplots/@@brewer set cycle list={PuOr-10}},
+ %
+ /pgfplots/colormap/PuOr-11/.style={
+ colormap={PuOr-11}{
+ color=(PuOr-A);
+ color=(PuOr-B);
+ color=(PuOr-D);
+ color=(PuOr-F);
+ color=(PuOr-G);
+ color=(PuOr-H);
+ color=(PuOr-I);
+ color=(PuOr-J);
+ color=(PuOr-L);
+ color=(PuOr-N);
+ color=(PuOr-O);
+ },
+ cycle list/.define={PuOr-11}{[of colormap=PuOr-11]},
+ },
+ /pgfplots/cycle list/PuOr-11/.style={/pgfplots/@@brewer set cycle list={PuOr-11}},
+ %
+ /pgfplots/colormap/BrBG-3/.style={
+ colormap={BrBG-3}{
+ color=(BrBG-E);
+ color=(BrBG-H);
+ color=(BrBG-K);
+ },
+ cycle list/.define={BrBG-3}{[of colormap=BrBG-3]},
+ },
+ /pgfplots/cycle list/BrBG-3/.style={/pgfplots/@@brewer set cycle list={BrBG-3}},
+ %
+ /pgfplots/colormap/BrBG-4/.style={
+ colormap={BrBG-4}{
+ color=(BrBG-C);
+ color=(BrBG-F);
+ color=(BrBG-J);
+ color=(BrBG-M);
+ },
+ cycle list/.define={BrBG-4}{[of colormap=BrBG-4]},
+ },
+ /pgfplots/cycle list/BrBG-4/.style={/pgfplots/@@brewer set cycle list={BrBG-4}},
+ %
+ /pgfplots/colormap/BrBG-5/.style={
+ colormap={BrBG-5}{
+ color=(BrBG-C);
+ color=(BrBG-F);
+ color=(BrBG-H);
+ color=(BrBG-J);
+ color=(BrBG-M);
+ },
+ cycle list/.define={BrBG-5}{[of colormap=BrBG-5]},
+ },
+ /pgfplots/cycle list/BrBG-5/.style={/pgfplots/@@brewer set cycle list={BrBG-5}},
+ %
+ /pgfplots/colormap/BrBG-6/.style={
+ colormap={BrBG-6}{
+ color=(BrBG-B);
+ color=(BrBG-E);
+ color=(BrBG-G);
+ color=(BrBG-I);
+ color=(BrBG-K);
+ color=(BrBG-N);
+ },
+ cycle list/.define={BrBG-6}{[of colormap=BrBG-6]},
+ },
+ /pgfplots/cycle list/BrBG-6/.style={/pgfplots/@@brewer set cycle list={BrBG-6}},
+ %
+ /pgfplots/colormap/BrBG-7/.style={
+ colormap={BrBG-7}{
+ color=(BrBG-B);
+ color=(BrBG-E);
+ color=(BrBG-G);
+ color=(BrBG-H);
+ color=(BrBG-I);
+ color=(BrBG-K);
+ color=(BrBG-N);
+ },
+ cycle list/.define={BrBG-7}{[of colormap=BrBG-7]},
+ },
+ /pgfplots/cycle list/BrBG-7/.style={/pgfplots/@@brewer set cycle list={BrBG-7}},
+ %
+ /pgfplots/colormap/BrBG-8/.style={
+ colormap={BrBG-8}{
+ color=(BrBG-B);
+ color=(BrBG-D);
+ color=(BrBG-F);
+ color=(BrBG-G);
+ color=(BrBG-I);
+ color=(BrBG-J);
+ color=(BrBG-L);
+ color=(BrBG-N);
+ },
+ cycle list/.define={BrBG-8}{[of colormap=BrBG-8]},
+ },
+ /pgfplots/cycle list/BrBG-8/.style={/pgfplots/@@brewer set cycle list={BrBG-8}},
+ %
+ /pgfplots/colormap/BrBG-9/.style={
+ colormap={BrBG-9}{
+ color=(BrBG-B);
+ color=(BrBG-D);
+ color=(BrBG-F);
+ color=(BrBG-G);
+ color=(BrBG-H);
+ color=(BrBG-I);
+ color=(BrBG-J);
+ color=(BrBG-L);
+ color=(BrBG-N);
+ },
+ cycle list/.define={BrBG-9}{[of colormap=BrBG-9]},
+ },
+ /pgfplots/cycle list/BrBG-9/.style={/pgfplots/@@brewer set cycle list={BrBG-9}},
+ %
+ /pgfplots/colormap/BrBG-10/.style={
+ colormap={BrBG-10}{
+ color=(BrBG-A);
+ color=(BrBG-B);
+ color=(BrBG-D);
+ color=(BrBG-F);
+ color=(BrBG-G);
+ color=(BrBG-I);
+ color=(BrBG-J);
+ color=(BrBG-L);
+ color=(BrBG-N);
+ color=(BrBG-O);
+ },
+ cycle list/.define={BrBG-10}{[of colormap=BrBG-10]},
+ },
+ /pgfplots/cycle list/BrBG-10/.style={/pgfplots/@@brewer set cycle list={BrBG-10}},
+ %
+ /pgfplots/colormap/BrBG-11/.style={
+ colormap={BrBG-11}{
+ color=(BrBG-A);
+ color=(BrBG-B);
+ color=(BrBG-D);
+ color=(BrBG-F);
+ color=(BrBG-G);
+ color=(BrBG-H);
+ color=(BrBG-I);
+ color=(BrBG-J);
+ color=(BrBG-L);
+ color=(BrBG-N);
+ color=(BrBG-O);
+ },
+ cycle list/.define={BrBG-11}{[of colormap=BrBG-11]},
+ },
+ /pgfplots/cycle list/BrBG-11/.style={/pgfplots/@@brewer set cycle list={BrBG-11}},
+ %
+ /pgfplots/colormap/PRGn-3/.style={
+ colormap={PRGn-3}{
+ color=(PRGn-E);
+ color=(PRGn-H);
+ color=(PRGn-K);
+ },
+ cycle list/.define={PRGn-3}{[of colormap=PRGn-3]},
+ },
+ /pgfplots/cycle list/PRGn-3/.style={/pgfplots/@@brewer set cycle list={PRGn-3}},
+ %
+ /pgfplots/colormap/PRGn-4/.style={
+ colormap={PRGn-4}{
+ color=(PRGn-C);
+ color=(PRGn-F);
+ color=(PRGn-J);
+ color=(PRGn-M);
+ },
+ cycle list/.define={PRGn-4}{[of colormap=PRGn-4]},
+ },
+ /pgfplots/cycle list/PRGn-4/.style={/pgfplots/@@brewer set cycle list={PRGn-4}},
+ %
+ /pgfplots/colormap/PRGn-5/.style={
+ colormap={PRGn-5}{
+ color=(PRGn-C);
+ color=(PRGn-F);
+ color=(PRGn-H);
+ color=(PRGn-J);
+ color=(PRGn-M);
+ },
+ cycle list/.define={PRGn-5}{[of colormap=PRGn-5]},
+ },
+ /pgfplots/cycle list/PRGn-5/.style={/pgfplots/@@brewer set cycle list={PRGn-5}},
+ %
+ /pgfplots/colormap/PRGn-6/.style={
+ colormap={PRGn-6}{
+ color=(PRGn-B);
+ color=(PRGn-E);
+ color=(PRGn-G);
+ color=(PRGn-I);
+ color=(PRGn-K);
+ color=(PRGn-N);
+ },
+ cycle list/.define={PRGn-6}{[of colormap=PRGn-6]},
+ },
+ /pgfplots/cycle list/PRGn-6/.style={/pgfplots/@@brewer set cycle list={PRGn-6}},
+ %
+ /pgfplots/colormap/PRGn-7/.style={
+ colormap={PRGn-7}{
+ color=(PRGn-B);
+ color=(PRGn-E);
+ color=(PRGn-G);
+ color=(PRGn-H);
+ color=(PRGn-I);
+ color=(PRGn-K);
+ color=(PRGn-N);
+ },
+ cycle list/.define={PRGn-7}{[of colormap=PRGn-7]},
+ },
+ /pgfplots/cycle list/PRGn-7/.style={/pgfplots/@@brewer set cycle list={PRGn-7}},
+ %
+ /pgfplots/colormap/PRGn-8/.style={
+ colormap={PRGn-8}{
+ color=(PRGn-B);
+ color=(PRGn-D);
+ color=(PRGn-F);
+ color=(PRGn-G);
+ color=(PRGn-I);
+ color=(PRGn-J);
+ color=(PRGn-L);
+ color=(PRGn-N);
+ },
+ cycle list/.define={PRGn-8}{[of colormap=PRGn-8]},
+ },
+ /pgfplots/cycle list/PRGn-8/.style={/pgfplots/@@brewer set cycle list={PRGn-8}},
+ %
+ /pgfplots/colormap/PRGn-9/.style={
+ colormap={PRGn-9}{
+ color=(PRGn-B);
+ color=(PRGn-D);
+ color=(PRGn-F);
+ color=(PRGn-G);
+ color=(PRGn-H);
+ color=(PRGn-I);
+ color=(PRGn-J);
+ color=(PRGn-L);
+ color=(PRGn-N);
+ },
+ cycle list/.define={PRGn-9}{[of colormap=PRGn-9]},
+ },
+ /pgfplots/cycle list/PRGn-9/.style={/pgfplots/@@brewer set cycle list={PRGn-9}},
+ %
+ /pgfplots/colormap/PRGn-10/.style={
+ colormap={PRGn-10}{
+ color=(PRGn-A);
+ color=(PRGn-B);
+ color=(PRGn-D);
+ color=(PRGn-F);
+ color=(PRGn-G);
+ color=(PRGn-I);
+ color=(PRGn-J);
+ color=(PRGn-L);
+ color=(PRGn-N);
+ color=(PRGn-O);
+ },
+ cycle list/.define={PRGn-10}{[of colormap=PRGn-10]},
+ },
+ /pgfplots/cycle list/PRGn-10/.style={/pgfplots/@@brewer set cycle list={PRGn-10}},
+ %
+ /pgfplots/colormap/PRGn-11/.style={
+ colormap={PRGn-11}{
+ color=(PRGn-A);
+ color=(PRGn-B);
+ color=(PRGn-D);
+ color=(PRGn-F);
+ color=(PRGn-G);
+ color=(PRGn-H);
+ color=(PRGn-I);
+ color=(PRGn-J);
+ color=(PRGn-L);
+ color=(PRGn-N);
+ color=(PRGn-O);
+ },
+ cycle list/.define={PRGn-11}{[of colormap=PRGn-11]},
+ },
+ /pgfplots/cycle list/PRGn-11/.style={/pgfplots/@@brewer set cycle list={PRGn-11}},
+ %
+ /pgfplots/colormap/PiYG-3/.style={
+ colormap={PiYG-3}{
+ color=(PiYG-E);
+ color=(PiYG-H);
+ color=(PiYG-K);
+ },
+ cycle list/.define={PiYG-3}{[of colormap=PiYG-3]},
+ },
+ /pgfplots/cycle list/PiYG-3/.style={/pgfplots/@@brewer set cycle list={PiYG-3}},
+ %
+ /pgfplots/colormap/PiYG-4/.style={
+ colormap={PiYG-4}{
+ color=(PiYG-C);
+ color=(PiYG-F);
+ color=(PiYG-J);
+ color=(PiYG-M);
+ },
+ cycle list/.define={PiYG-4}{[of colormap=PiYG-4]},
+ },
+ /pgfplots/cycle list/PiYG-4/.style={/pgfplots/@@brewer set cycle list={PiYG-4}},
+ %
+ /pgfplots/colormap/PiYG-5/.style={
+ colormap={PiYG-5}{
+ color=(PiYG-C);
+ color=(PiYG-F);
+ color=(PiYG-H);
+ color=(PiYG-J);
+ color=(PiYG-M);
+ },
+ cycle list/.define={PiYG-5}{[of colormap=PiYG-5]},
+ },
+ /pgfplots/cycle list/PiYG-5/.style={/pgfplots/@@brewer set cycle list={PiYG-5}},
+ %
+ /pgfplots/colormap/PiYG-6/.style={
+ colormap={PiYG-6}{
+ color=(PiYG-B);
+ color=(PiYG-E);
+ color=(PiYG-G);
+ color=(PiYG-I);
+ color=(PiYG-K);
+ color=(PiYG-N);
+ },
+ cycle list/.define={PiYG-6}{[of colormap=PiYG-6]},
+ },
+ /pgfplots/cycle list/PiYG-6/.style={/pgfplots/@@brewer set cycle list={PiYG-6}},
+ %
+ /pgfplots/colormap/PiYG-7/.style={
+ colormap={PiYG-7}{
+ color=(PiYG-B);
+ color=(PiYG-E);
+ color=(PiYG-G);
+ color=(PiYG-H);
+ color=(PiYG-I);
+ color=(PiYG-K);
+ color=(PiYG-N);
+ },
+ cycle list/.define={PiYG-7}{[of colormap=PiYG-7]},
+ },
+ /pgfplots/cycle list/PiYG-7/.style={/pgfplots/@@brewer set cycle list={PiYG-7}},
+ %
+ /pgfplots/colormap/PiYG-8/.style={
+ colormap={PiYG-8}{
+ color=(PiYG-B);
+ color=(PiYG-D);
+ color=(PiYG-F);
+ color=(PiYG-G);
+ color=(PiYG-I);
+ color=(PiYG-J);
+ color=(PiYG-L);
+ color=(PiYG-N);
+ },
+ cycle list/.define={PiYG-8}{[of colormap=PiYG-8]},
+ },
+ /pgfplots/cycle list/PiYG-8/.style={/pgfplots/@@brewer set cycle list={PiYG-8}},
+ %
+ /pgfplots/colormap/PiYG-9/.style={
+ colormap={PiYG-9}{
+ color=(PiYG-B);
+ color=(PiYG-D);
+ color=(PiYG-F);
+ color=(PiYG-G);
+ color=(PiYG-H);
+ color=(PiYG-I);
+ color=(PiYG-J);
+ color=(PiYG-L);
+ color=(PiYG-N);
+ },
+ cycle list/.define={PiYG-9}{[of colormap=PiYG-9]},
+ },
+ /pgfplots/cycle list/PiYG-9/.style={/pgfplots/@@brewer set cycle list={PiYG-9}},
+ %
+ /pgfplots/colormap/PiYG-10/.style={
+ colormap={PiYG-10}{
+ color=(PiYG-A);
+ color=(PiYG-B);
+ color=(PiYG-D);
+ color=(PiYG-F);
+ color=(PiYG-G);
+ color=(PiYG-I);
+ color=(PiYG-J);
+ color=(PiYG-L);
+ color=(PiYG-N);
+ color=(PiYG-O);
+ },
+ cycle list/.define={PiYG-10}{[of colormap=PiYG-10]},
+ },
+ /pgfplots/cycle list/PiYG-10/.style={/pgfplots/@@brewer set cycle list={PiYG-10}},
+ %
+ /pgfplots/colormap/PiYG-11/.style={
+ colormap={PiYG-11}{
+ color=(PiYG-A);
+ color=(PiYG-B);
+ color=(PiYG-D);
+ color=(PiYG-F);
+ color=(PiYG-G);
+ color=(PiYG-H);
+ color=(PiYG-I);
+ color=(PiYG-J);
+ color=(PiYG-L);
+ color=(PiYG-N);
+ color=(PiYG-O);
+ },
+ cycle list/.define={PiYG-11}{[of colormap=PiYG-11]},
+ },
+ /pgfplots/cycle list/PiYG-11/.style={/pgfplots/@@brewer set cycle list={PiYG-11}},
+ %
+ /pgfplots/colormap/RdBu-3/.style={
+ colormap={RdBu-3}{
+ color=(RdBu-E);
+ color=(RdBu-H);
+ color=(RdBu-K);
+ },
+ cycle list/.define={RdBu-3}{[of colormap=RdBu-3]},
+ },
+ /pgfplots/cycle list/RdBu-3/.style={/pgfplots/@@brewer set cycle list={RdBu-3}},
+ %
+ /pgfplots/colormap/RdBu-4/.style={
+ colormap={RdBu-4}{
+ color=(RdBu-C);
+ color=(RdBu-F);
+ color=(RdBu-J);
+ color=(RdBu-M);
+ },
+ cycle list/.define={RdBu-4}{[of colormap=RdBu-4]},
+ },
+ /pgfplots/cycle list/RdBu-4/.style={/pgfplots/@@brewer set cycle list={RdBu-4}},
+ %
+ /pgfplots/colormap/RdBu-5/.style={
+ colormap={RdBu-5}{
+ color=(RdBu-C);
+ color=(RdBu-F);
+ color=(RdBu-H);
+ color=(RdBu-J);
+ color=(RdBu-M);
+ },
+ cycle list/.define={RdBu-5}{[of colormap=RdBu-5]},
+ },
+ /pgfplots/cycle list/RdBu-5/.style={/pgfplots/@@brewer set cycle list={RdBu-5}},
+ %
+ /pgfplots/colormap/RdBu-6/.style={
+ colormap={RdBu-6}{
+ color=(RdBu-B);
+ color=(RdBu-E);
+ color=(RdBu-G);
+ color=(RdBu-I);
+ color=(RdBu-K);
+ color=(RdBu-N);
+ },
+ cycle list/.define={RdBu-6}{[of colormap=RdBu-6]},
+ },
+ /pgfplots/cycle list/RdBu-6/.style={/pgfplots/@@brewer set cycle list={RdBu-6}},
+ %
+ /pgfplots/colormap/RdBu-7/.style={
+ colormap={RdBu-7}{
+ color=(RdBu-B);
+ color=(RdBu-E);
+ color=(RdBu-G);
+ color=(RdBu-H);
+ color=(RdBu-I);
+ color=(RdBu-K);
+ color=(RdBu-N);
+ },
+ cycle list/.define={RdBu-7}{[of colormap=RdBu-7]},
+ },
+ /pgfplots/cycle list/RdBu-7/.style={/pgfplots/@@brewer set cycle list={RdBu-7}},
+ %
+ /pgfplots/colormap/RdBu-8/.style={
+ colormap={RdBu-8}{
+ color=(RdBu-B);
+ color=(RdBu-D);
+ color=(RdBu-F);
+ color=(RdBu-G);
+ color=(RdBu-I);
+ color=(RdBu-J);
+ color=(RdBu-L);
+ color=(RdBu-N);
+ },
+ cycle list/.define={RdBu-8}{[of colormap=RdBu-8]},
+ },
+ /pgfplots/cycle list/RdBu-8/.style={/pgfplots/@@brewer set cycle list={RdBu-8}},
+ %
+ /pgfplots/colormap/RdBu-9/.style={
+ colormap={RdBu-9}{
+ color=(RdBu-B);
+ color=(RdBu-D);
+ color=(RdBu-F);
+ color=(RdBu-G);
+ color=(RdBu-H);
+ color=(RdBu-I);
+ color=(RdBu-J);
+ color=(RdBu-L);
+ color=(RdBu-N);
+ },
+ cycle list/.define={RdBu-9}{[of colormap=RdBu-9]},
+ },
+ /pgfplots/cycle list/RdBu-9/.style={/pgfplots/@@brewer set cycle list={RdBu-9}},
+ %
+ /pgfplots/colormap/RdBu-10/.style={
+ colormap={RdBu-10}{
+ color=(RdBu-A);
+ color=(RdBu-B);
+ color=(RdBu-D);
+ color=(RdBu-F);
+ color=(RdBu-G);
+ color=(RdBu-I);
+ color=(RdBu-J);
+ color=(RdBu-L);
+ color=(RdBu-N);
+ color=(RdBu-O);
+ },
+ cycle list/.define={RdBu-10}{[of colormap=RdBu-10]},
+ },
+ /pgfplots/cycle list/RdBu-10/.style={/pgfplots/@@brewer set cycle list={RdBu-10}},
+ %
+ /pgfplots/colormap/RdBu-11/.style={
+ colormap={RdBu-11}{
+ color=(RdBu-A);
+ color=(RdBu-B);
+ color=(RdBu-D);
+ color=(RdBu-F);
+ color=(RdBu-G);
+ color=(RdBu-H);
+ color=(RdBu-I);
+ color=(RdBu-J);
+ color=(RdBu-L);
+ color=(RdBu-N);
+ color=(RdBu-O);
+ },
+ cycle list/.define={RdBu-11}{[of colormap=RdBu-11]},
+ },
+ /pgfplots/cycle list/RdBu-11/.style={/pgfplots/@@brewer set cycle list={RdBu-11}},
+ %
+ /pgfplots/colormap/RdGy-3/.style={
+ colormap={RdGy-3}{
+ color=(RdGy-E);
+ color=(RdGy-H);
+ color=(RdGy-K);
+ },
+ cycle list/.define={RdGy-3}{[of colormap=RdGy-3]},
+ },
+ /pgfplots/cycle list/RdGy-3/.style={/pgfplots/@@brewer set cycle list={RdGy-3}},
+ %
+ /pgfplots/colormap/RdGy-4/.style={
+ colormap={RdGy-4}{
+ color=(RdGy-C);
+ color=(RdGy-F);
+ color=(RdGy-J);
+ color=(RdGy-M);
+ },
+ cycle list/.define={RdGy-4}{[of colormap=RdGy-4]},
+ },
+ /pgfplots/cycle list/RdGy-4/.style={/pgfplots/@@brewer set cycle list={RdGy-4}},
+ %
+ /pgfplots/colormap/RdGy-5/.style={
+ colormap={RdGy-5}{
+ color=(RdGy-C);
+ color=(RdGy-F);
+ color=(RdGy-H);
+ color=(RdGy-J);
+ color=(RdGy-M);
+ },
+ cycle list/.define={RdGy-5}{[of colormap=RdGy-5]},
+ },
+ /pgfplots/cycle list/RdGy-5/.style={/pgfplots/@@brewer set cycle list={RdGy-5}},
+ %
+ /pgfplots/colormap/RdGy-6/.style={
+ colormap={RdGy-6}{
+ color=(RdGy-B);
+ color=(RdGy-E);
+ color=(RdGy-G);
+ color=(RdGy-I);
+ color=(RdGy-K);
+ color=(RdGy-N);
+ },
+ cycle list/.define={RdGy-6}{[of colormap=RdGy-6]},
+ },
+ /pgfplots/cycle list/RdGy-6/.style={/pgfplots/@@brewer set cycle list={RdGy-6}},
+ %
+ /pgfplots/colormap/RdGy-7/.style={
+ colormap={RdGy-7}{
+ color=(RdGy-B);
+ color=(RdGy-E);
+ color=(RdGy-G);
+ color=(RdGy-H);
+ color=(RdGy-I);
+ color=(RdGy-K);
+ color=(RdGy-N);
+ },
+ cycle list/.define={RdGy-7}{[of colormap=RdGy-7]},
+ },
+ /pgfplots/cycle list/RdGy-7/.style={/pgfplots/@@brewer set cycle list={RdGy-7}},
+ %
+ /pgfplots/colormap/RdGy-8/.style={
+ colormap={RdGy-8}{
+ color=(RdGy-B);
+ color=(RdGy-D);
+ color=(RdGy-F);
+ color=(RdGy-G);
+ color=(RdGy-I);
+ color=(RdGy-J);
+ color=(RdGy-L);
+ color=(RdGy-N);
+ },
+ cycle list/.define={RdGy-8}{[of colormap=RdGy-8]},
+ },
+ /pgfplots/cycle list/RdGy-8/.style={/pgfplots/@@brewer set cycle list={RdGy-8}},
+ %
+ /pgfplots/colormap/RdGy-9/.style={
+ colormap={RdGy-9}{
+ color=(RdGy-B);
+ color=(RdGy-D);
+ color=(RdGy-F);
+ color=(RdGy-G);
+ color=(RdGy-H);
+ color=(RdGy-I);
+ color=(RdGy-J);
+ color=(RdGy-L);
+ color=(RdGy-N);
+ },
+ cycle list/.define={RdGy-9}{[of colormap=RdGy-9]},
+ },
+ /pgfplots/cycle list/RdGy-9/.style={/pgfplots/@@brewer set cycle list={RdGy-9}},
+ %
+ /pgfplots/colormap/RdGy-10/.style={
+ colormap={RdGy-10}{
+ color=(RdGy-A);
+ color=(RdGy-B);
+ color=(RdGy-D);
+ color=(RdGy-F);
+ color=(RdGy-G);
+ color=(RdGy-I);
+ color=(RdGy-J);
+ color=(RdGy-L);
+ color=(RdGy-N);
+ color=(RdGy-O);
+ },
+ cycle list/.define={RdGy-10}{[of colormap=RdGy-10]},
+ },
+ /pgfplots/cycle list/RdGy-10/.style={/pgfplots/@@brewer set cycle list={RdGy-10}},
+ %
+ /pgfplots/colormap/RdGy-11/.style={
+ colormap={RdGy-11}{
+ color=(RdGy-A);
+ color=(RdGy-B);
+ color=(RdGy-D);
+ color=(RdGy-F);
+ color=(RdGy-G);
+ color=(RdGy-H);
+ color=(RdGy-I);
+ color=(RdGy-J);
+ color=(RdGy-L);
+ color=(RdGy-N);
+ color=(RdGy-O);
+ },
+ cycle list/.define={RdGy-11}{[of colormap=RdGy-11]},
+ },
+ /pgfplots/cycle list/RdGy-11/.style={/pgfplots/@@brewer set cycle list={RdGy-11}},
+ %
+ /pgfplots/colormap/RdYlBu-3/.style={
+ colormap={RdYlBu-3}{
+ color=(RdYlBu-E);
+ color=(RdYlBu-H);
+ color=(RdYlBu-K);
+ },
+ cycle list/.define={RdYlBu-3}{[of colormap=RdYlBu-3]},
+ },
+ /pgfplots/cycle list/RdYlBu-3/.style={/pgfplots/@@brewer set cycle list={RdYlBu-3}},
+ %
+ /pgfplots/colormap/RdYlBu-4/.style={
+ colormap={RdYlBu-4}{
+ color=(RdYlBu-C);
+ color=(RdYlBu-F);
+ color=(RdYlBu-J);
+ color=(RdYlBu-M);
+ },
+ cycle list/.define={RdYlBu-4}{[of colormap=RdYlBu-4]},
+ },
+ /pgfplots/cycle list/RdYlBu-4/.style={/pgfplots/@@brewer set cycle list={RdYlBu-4}},
+ %
+ /pgfplots/colormap/RdYlBu-5/.style={
+ colormap={RdYlBu-5}{
+ color=(RdYlBu-C);
+ color=(RdYlBu-F);
+ color=(RdYlBu-H);
+ color=(RdYlBu-J);
+ color=(RdYlBu-M);
+ },
+ cycle list/.define={RdYlBu-5}{[of colormap=RdYlBu-5]},
+ },
+ /pgfplots/cycle list/RdYlBu-5/.style={/pgfplots/@@brewer set cycle list={RdYlBu-5}},
+ %
+ /pgfplots/colormap/RdYlBu-6/.style={
+ colormap={RdYlBu-6}{
+ color=(RdYlBu-B);
+ color=(RdYlBu-E);
+ color=(RdYlBu-G);
+ color=(RdYlBu-I);
+ color=(RdYlBu-K);
+ color=(RdYlBu-N);
+ },
+ cycle list/.define={RdYlBu-6}{[of colormap=RdYlBu-6]},
+ },
+ /pgfplots/cycle list/RdYlBu-6/.style={/pgfplots/@@brewer set cycle list={RdYlBu-6}},
+ %
+ /pgfplots/colormap/RdYlBu-7/.style={
+ colormap={RdYlBu-7}{
+ color=(RdYlBu-B);
+ color=(RdYlBu-E);
+ color=(RdYlBu-G);
+ color=(RdYlBu-H);
+ color=(RdYlBu-I);
+ color=(RdYlBu-K);
+ color=(RdYlBu-N);
+ },
+ cycle list/.define={RdYlBu-7}{[of colormap=RdYlBu-7]},
+ },
+ /pgfplots/cycle list/RdYlBu-7/.style={/pgfplots/@@brewer set cycle list={RdYlBu-7}},
+ %
+ /pgfplots/colormap/RdYlBu-8/.style={
+ colormap={RdYlBu-8}{
+ color=(RdYlBu-B);
+ color=(RdYlBu-D);
+ color=(RdYlBu-F);
+ color=(RdYlBu-G);
+ color=(RdYlBu-I);
+ color=(RdYlBu-J);
+ color=(RdYlBu-L);
+ color=(RdYlBu-N);
+ },
+ cycle list/.define={RdYlBu-8}{[of colormap=RdYlBu-8]},
+ },
+ /pgfplots/cycle list/RdYlBu-8/.style={/pgfplots/@@brewer set cycle list={RdYlBu-8}},
+ %
+ /pgfplots/colormap/RdYlBu-9/.style={
+ colormap={RdYlBu-9}{
+ color=(RdYlBu-B);
+ color=(RdYlBu-D);
+ color=(RdYlBu-F);
+ color=(RdYlBu-G);
+ color=(RdYlBu-H);
+ color=(RdYlBu-I);
+ color=(RdYlBu-J);
+ color=(RdYlBu-L);
+ color=(RdYlBu-N);
+ },
+ cycle list/.define={RdYlBu-9}{[of colormap=RdYlBu-9]},
+ },
+ /pgfplots/cycle list/RdYlBu-9/.style={/pgfplots/@@brewer set cycle list={RdYlBu-9}},
+ %
+ /pgfplots/colormap/RdYlBu-10/.style={
+ colormap={RdYlBu-10}{
+ color=(RdYlBu-A);
+ color=(RdYlBu-B);
+ color=(RdYlBu-D);
+ color=(RdYlBu-F);
+ color=(RdYlBu-G);
+ color=(RdYlBu-I);
+ color=(RdYlBu-J);
+ color=(RdYlBu-L);
+ color=(RdYlBu-N);
+ color=(RdYlBu-O);
+ },
+ cycle list/.define={RdYlBu-10}{[of colormap=RdYlBu-10]},
+ },
+ /pgfplots/cycle list/RdYlBu-10/.style={/pgfplots/@@brewer set cycle list={RdYlBu-10}},
+ %
+ /pgfplots/colormap/RdYlBu-11/.style={
+ colormap={RdYlBu-11}{
+ color=(RdYlBu-A);
+ color=(RdYlBu-B);
+ color=(RdYlBu-D);
+ color=(RdYlBu-F);
+ color=(RdYlBu-G);
+ color=(RdYlBu-H);
+ color=(RdYlBu-I);
+ color=(RdYlBu-J);
+ color=(RdYlBu-L);
+ color=(RdYlBu-N);
+ color=(RdYlBu-O);
+ },
+ cycle list/.define={RdYlBu-11}{[of colormap=RdYlBu-11]},
+ },
+ /pgfplots/cycle list/RdYlBu-11/.style={/pgfplots/@@brewer set cycle list={RdYlBu-11}},
+ %
+ /pgfplots/colormap/Spectral-3/.style={
+ colormap={Spectral-3}{
+ color=(Spectral-E);
+ color=(Spectral-H);
+ color=(Spectral-K);
+ },
+ cycle list/.define={Spectral-3}{[of colormap=Spectral-3]},
+ },
+ /pgfplots/cycle list/Spectral-3/.style={/pgfplots/@@brewer set cycle list={Spectral-3}},
+ %
+ /pgfplots/colormap/Spectral-4/.style={
+ colormap={Spectral-4}{
+ color=(Spectral-C);
+ color=(Spectral-F);
+ color=(Spectral-J);
+ color=(Spectral-M);
+ },
+ cycle list/.define={Spectral-4}{[of colormap=Spectral-4]},
+ },
+ /pgfplots/cycle list/Spectral-4/.style={/pgfplots/@@brewer set cycle list={Spectral-4}},
+ %
+ /pgfplots/colormap/Spectral-5/.style={
+ colormap={Spectral-5}{
+ color=(Spectral-C);
+ color=(Spectral-F);
+ color=(Spectral-H);
+ color=(Spectral-J);
+ color=(Spectral-M);
+ },
+ cycle list/.define={Spectral-5}{[of colormap=Spectral-5]},
+ },
+ /pgfplots/cycle list/Spectral-5/.style={/pgfplots/@@brewer set cycle list={Spectral-5}},
+ %
+ /pgfplots/colormap/Spectral-6/.style={
+ colormap={Spectral-6}{
+ color=(Spectral-B);
+ color=(Spectral-E);
+ color=(Spectral-G);
+ color=(Spectral-I);
+ color=(Spectral-K);
+ color=(Spectral-N);
+ },
+ cycle list/.define={Spectral-6}{[of colormap=Spectral-6]},
+ },
+ /pgfplots/cycle list/Spectral-6/.style={/pgfplots/@@brewer set cycle list={Spectral-6}},
+ %
+ /pgfplots/colormap/Spectral-7/.style={
+ colormap={Spectral-7}{
+ color=(Spectral-B);
+ color=(Spectral-E);
+ color=(Spectral-G);
+ color=(Spectral-H);
+ color=(Spectral-I);
+ color=(Spectral-K);
+ color=(Spectral-N);
+ },
+ cycle list/.define={Spectral-7}{[of colormap=Spectral-7]},
+ },
+ /pgfplots/cycle list/Spectral-7/.style={/pgfplots/@@brewer set cycle list={Spectral-7}},
+ %
+ /pgfplots/colormap/Spectral-8/.style={
+ colormap={Spectral-8}{
+ color=(Spectral-B);
+ color=(Spectral-D);
+ color=(Spectral-F);
+ color=(Spectral-G);
+ color=(Spectral-I);
+ color=(Spectral-J);
+ color=(Spectral-L);
+ color=(Spectral-N);
+ },
+ cycle list/.define={Spectral-8}{[of colormap=Spectral-8]},
+ },
+ /pgfplots/cycle list/Spectral-8/.style={/pgfplots/@@brewer set cycle list={Spectral-8}},
+ %
+ /pgfplots/colormap/Spectral-9/.style={
+ colormap={Spectral-9}{
+ color=(Spectral-B);
+ color=(Spectral-D);
+ color=(Spectral-F);
+ color=(Spectral-G);
+ color=(Spectral-H);
+ color=(Spectral-I);
+ color=(Spectral-J);
+ color=(Spectral-L);
+ color=(Spectral-N);
+ },
+ cycle list/.define={Spectral-9}{[of colormap=Spectral-9]},
+ },
+ /pgfplots/cycle list/Spectral-9/.style={/pgfplots/@@brewer set cycle list={Spectral-9}},
+ %
+ /pgfplots/colormap/Spectral-10/.style={
+ colormap={Spectral-10}{
+ color=(Spectral-A);
+ color=(Spectral-B);
+ color=(Spectral-D);
+ color=(Spectral-F);
+ color=(Spectral-G);
+ color=(Spectral-I);
+ color=(Spectral-J);
+ color=(Spectral-L);
+ color=(Spectral-N);
+ color=(Spectral-O);
+ },
+ cycle list/.define={Spectral-10}{[of colormap=Spectral-10]},
+ },
+ /pgfplots/cycle list/Spectral-10/.style={/pgfplots/@@brewer set cycle list={Spectral-10}},
+ %
+ /pgfplots/colormap/Spectral-11/.style={
+ colormap={Spectral-11}{
+ color=(Spectral-A);
+ color=(Spectral-B);
+ color=(Spectral-D);
+ color=(Spectral-F);
+ color=(Spectral-G);
+ color=(Spectral-H);
+ color=(Spectral-I);
+ color=(Spectral-J);
+ color=(Spectral-L);
+ color=(Spectral-N);
+ color=(Spectral-O);
+ },
+ cycle list/.define={Spectral-11}{[of colormap=Spectral-11]},
+ },
+ /pgfplots/cycle list/Spectral-11/.style={/pgfplots/@@brewer set cycle list={Spectral-11}},
+ %
+ /pgfplots/colormap/RdYlGn-3/.style={
+ colormap={RdYlGn-3}{
+ color=(RdYlGn-E);
+ color=(RdYlGn-H);
+ color=(RdYlGn-K);
+ },
+ cycle list/.define={RdYlGn-3}{[of colormap=RdYlGn-3]},
+ },
+ /pgfplots/cycle list/RdYlGn-3/.style={/pgfplots/@@brewer set cycle list={RdYlGn-3}},
+ %
+ /pgfplots/colormap/RdYlGn-4/.style={
+ colormap={RdYlGn-4}{
+ color=(RdYlGn-C);
+ color=(RdYlGn-F);
+ color=(RdYlGn-J);
+ color=(RdYlGn-M);
+ },
+ cycle list/.define={RdYlGn-4}{[of colormap=RdYlGn-4]},
+ },
+ /pgfplots/cycle list/RdYlGn-4/.style={/pgfplots/@@brewer set cycle list={RdYlGn-4}},
+ %
+ /pgfplots/colormap/RdYlGn-5/.style={
+ colormap={RdYlGn-5}{
+ color=(RdYlGn-C);
+ color=(RdYlGn-F);
+ color=(RdYlGn-H);
+ color=(RdYlGn-J);
+ color=(RdYlGn-M);
+ },
+ cycle list/.define={RdYlGn-5}{[of colormap=RdYlGn-5]},
+ },
+ /pgfplots/cycle list/RdYlGn-5/.style={/pgfplots/@@brewer set cycle list={RdYlGn-5}},
+ %
+ /pgfplots/colormap/RdYlGn-6/.style={
+ colormap={RdYlGn-6}{
+ color=(RdYlGn-B);
+ color=(RdYlGn-E);
+ color=(RdYlGn-G);
+ color=(RdYlGn-I);
+ color=(RdYlGn-K);
+ color=(RdYlGn-N);
+ },
+ cycle list/.define={RdYlGn-6}{[of colormap=RdYlGn-6]},
+ },
+ /pgfplots/cycle list/RdYlGn-6/.style={/pgfplots/@@brewer set cycle list={RdYlGn-6}},
+ %
+ /pgfplots/colormap/RdYlGn-7/.style={
+ colormap={RdYlGn-7}{
+ color=(RdYlGn-B);
+ color=(RdYlGn-E);
+ color=(RdYlGn-G);
+ color=(RdYlGn-H);
+ color=(RdYlGn-I);
+ color=(RdYlGn-K);
+ color=(RdYlGn-N);
+ },
+ cycle list/.define={RdYlGn-7}{[of colormap=RdYlGn-7]},
+ },
+ /pgfplots/cycle list/RdYlGn-7/.style={/pgfplots/@@brewer set cycle list={RdYlGn-7}},
+ %
+ /pgfplots/colormap/RdYlGn-8/.style={
+ colormap={RdYlGn-8}{
+ color=(RdYlGn-B);
+ color=(RdYlGn-D);
+ color=(RdYlGn-F);
+ color=(RdYlGn-G);
+ color=(RdYlGn-I);
+ color=(RdYlGn-J);
+ color=(RdYlGn-L);
+ color=(RdYlGn-N);
+ },
+ cycle list/.define={RdYlGn-8}{[of colormap=RdYlGn-8]},
+ },
+ /pgfplots/cycle list/RdYlGn-8/.style={/pgfplots/@@brewer set cycle list={RdYlGn-8}},
+ %
+ /pgfplots/colormap/RdYlGn-9/.style={
+ colormap={RdYlGn-9}{
+ color=(RdYlGn-B);
+ color=(RdYlGn-D);
+ color=(RdYlGn-F);
+ color=(RdYlGn-G);
+ color=(RdYlGn-H);
+ color=(RdYlGn-I);
+ color=(RdYlGn-J);
+ color=(RdYlGn-L);
+ color=(RdYlGn-N);
+ },
+ cycle list/.define={RdYlGn-9}{[of colormap=RdYlGn-9]},
+ },
+ /pgfplots/cycle list/RdYlGn-9/.style={/pgfplots/@@brewer set cycle list={RdYlGn-9}},
+ %
+ /pgfplots/colormap/RdYlGn-10/.style={
+ colormap={RdYlGn-10}{
+ color=(RdYlGn-A);
+ color=(RdYlGn-B);
+ color=(RdYlGn-D);
+ color=(RdYlGn-F);
+ color=(RdYlGn-G);
+ color=(RdYlGn-I);
+ color=(RdYlGn-J);
+ color=(RdYlGn-L);
+ color=(RdYlGn-N);
+ color=(RdYlGn-O);
+ },
+ cycle list/.define={RdYlGn-10}{[of colormap=RdYlGn-10]},
+ },
+ /pgfplots/cycle list/RdYlGn-10/.style={/pgfplots/@@brewer set cycle list={RdYlGn-10}},
+ %
+ /pgfplots/colormap/RdYlGn-11/.style={
+ colormap={RdYlGn-11}{
+ color=(RdYlGn-A);
+ color=(RdYlGn-B);
+ color=(RdYlGn-D);
+ color=(RdYlGn-F);
+ color=(RdYlGn-G);
+ color=(RdYlGn-H);
+ color=(RdYlGn-I);
+ color=(RdYlGn-J);
+ color=(RdYlGn-L);
+ color=(RdYlGn-N);
+ color=(RdYlGn-O);
+ },
+ cycle list/.define={RdYlGn-11}{[of colormap=RdYlGn-11]},
+ },
+ /pgfplots/cycle list/RdYlGn-11/.style={/pgfplots/@@brewer set cycle list={RdYlGn-11}},
+ %
+ % ===========================================================================
+ /pgfplots/colormap/Set3-3/.style={
+ colormap={Set3-3}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ },
+ cycle list/.define={Set3-3}{[of colormap=Set3-3]},
+ },
+ /pgfplots/cycle list/Set3-3/.style={/pgfplots/@@brewer set cycle list={Set3-3}},
+ %
+ /pgfplots/colormap/Set3-4/.style={
+ colormap={Set3-4}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ },
+ cycle list/.define={Set3-4}{[of colormap=Set3-4]},
+ },
+ /pgfplots/cycle list/Set3-4/.style={/pgfplots/@@brewer set cycle list={Set3-4}},
+ %
+ /pgfplots/colormap/Set3-5/.style={
+ colormap={Set3-5}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ },
+ cycle list/.define={Set3-5}{[of colormap=Set3-5]},
+ },
+ /pgfplots/cycle list/Set3-5/.style={/pgfplots/@@brewer set cycle list={Set3-5}},
+ %
+ /pgfplots/colormap/Set3-6/.style={
+ colormap={Set3-6}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ color=(Set3-F);
+ },
+ cycle list/.define={Set3-6}{[of colormap=Set3-6]},
+ },
+ /pgfplots/cycle list/Set3-6/.style={/pgfplots/@@brewer set cycle list={Set3-6}},
+ %
+ /pgfplots/colormap/Set3-7/.style={
+ colormap={Set3-7}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ color=(Set3-F);
+ color=(Set3-G);
+ },
+ cycle list/.define={Set3-7}{[of colormap=Set3-7]},
+ },
+ /pgfplots/cycle list/Set3-7/.style={/pgfplots/@@brewer set cycle list={Set3-7}},
+ %
+ /pgfplots/colormap/Set3-8/.style={
+ colormap={Set3-8}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ color=(Set3-F);
+ color=(Set3-G);
+ color=(Set3-H);
+ },
+ cycle list/.define={Set3-8}{[of colormap=Set3-8]},
+ },
+ /pgfplots/cycle list/Set3-8/.style={/pgfplots/@@brewer set cycle list={Set3-8}},
+ %
+ /pgfplots/colormap/Set3-9/.style={
+ colormap={Set3-9}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ color=(Set3-F);
+ color=(Set3-G);
+ color=(Set3-H);
+ color=(Set3-I);
+ },
+ cycle list/.define={Set3-9}{[of colormap=Set3-9]},
+ },
+ /pgfplots/cycle list/Set3-9/.style={/pgfplots/@@brewer set cycle list={Set3-9}},
+ %
+ /pgfplots/colormap/Set3-10/.style={
+ colormap={Set3-10}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ color=(Set3-F);
+ color=(Set3-G);
+ color=(Set3-H);
+ color=(Set3-I);
+ color=(Set3-J);
+ },
+ cycle list/.define={Set3-10}{[of colormap=Set3-10]},
+ },
+ /pgfplots/cycle list/Set3-10/.style={/pgfplots/@@brewer set cycle list={Set3-10}},
+ %
+ /pgfplots/colormap/Set3-11/.style={
+ colormap={Set3-11}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ color=(Set3-F);
+ color=(Set3-G);
+ color=(Set3-H);
+ color=(Set3-I);
+ color=(Set3-J);
+ color=(Set3-K);
+ },
+ cycle list/.define={Set3-11}{[of colormap=Set3-11]},
+ },
+ /pgfplots/cycle list/Set3-11/.style={/pgfplots/@@brewer set cycle list={Set3-11}},
+ %
+ /pgfplots/colormap/Set3-12/.style={
+ colormap={Set3-12}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ color=(Set3-F);
+ color=(Set3-G);
+ color=(Set3-H);
+ color=(Set3-I);
+ color=(Set3-J);
+ color=(Set3-K);
+ color=(Set3-L);
+ },
+ cycle list/.define={Set3-12}{[of colormap=Set3-12]},
+ },
+ /pgfplots/cycle list/Set3-12/.style={/pgfplots/@@brewer set cycle list={Set3-12}},
+ %
+ /pgfplots/colormap/Pastel1-3/.style={
+ colormap={Pastel1-3}{
+ color=(Pastel1-A);
+ color=(Pastel1-B);
+ color=(Pastel1-C);
+ },
+ cycle list/.define={Pastel1-3}{[of colormap=Pastel1-3]},
+ },
+ /pgfplots/cycle list/Pastel1-3/.style={/pgfplots/@@brewer set cycle list={Pastel1-3}},
+ %
+ /pgfplots/colormap/Pastel1-4/.style={
+ colormap={Pastel1-4}{
+ color=(Pastel1-A);
+ color=(Pastel1-B);
+ color=(Pastel1-C);
+ color=(Pastel1-D);
+ },
+ cycle list/.define={Pastel1-4}{[of colormap=Pastel1-4]},
+ },
+ /pgfplots/cycle list/Pastel1-4/.style={/pgfplots/@@brewer set cycle list={Pastel1-4}},
+ %
+ /pgfplots/colormap/Pastel1-5/.style={
+ colormap={Pastel1-5}{
+ color=(Pastel1-A);
+ color=(Pastel1-B);
+ color=(Pastel1-C);
+ color=(Pastel1-D);
+ color=(Pastel1-E);
+ },
+ cycle list/.define={Pastel1-5}{[of colormap=Pastel1-5]},
+ },
+ /pgfplots/cycle list/Pastel1-5/.style={/pgfplots/@@brewer set cycle list={Pastel1-5}},
+ %
+ /pgfplots/colormap/Pastel1-6/.style={
+ colormap={Pastel1-6}{
+ color=(Pastel1-A);
+ color=(Pastel1-B);
+ color=(Pastel1-C);
+ color=(Pastel1-D);
+ color=(Pastel1-E);
+ color=(Pastel1-F);
+ },
+ cycle list/.define={Pastel1-6}{[of colormap=Pastel1-6]},
+ },
+ /pgfplots/cycle list/Pastel1-6/.style={/pgfplots/@@brewer set cycle list={Pastel1-6}},
+ %
+ /pgfplots/colormap/Pastel1-7/.style={
+ colormap={Pastel1-7}{
+ color=(Pastel1-A);
+ color=(Pastel1-B);
+ color=(Pastel1-C);
+ color=(Pastel1-D);
+ color=(Pastel1-E);
+ color=(Pastel1-F);
+ color=(Pastel1-G);
+ },
+ cycle list/.define={Pastel1-7}{[of colormap=Pastel1-7]},
+ },
+ /pgfplots/cycle list/Pastel1-7/.style={/pgfplots/@@brewer set cycle list={Pastel1-7}},
+ %
+ /pgfplots/colormap/Pastel1-8/.style={
+ colormap={Pastel1-8}{
+ color=(Pastel1-A);
+ color=(Pastel1-B);
+ color=(Pastel1-C);
+ color=(Pastel1-D);
+ color=(Pastel1-E);
+ color=(Pastel1-F);
+ color=(Pastel1-G);
+ color=(Pastel1-H);
+ },
+ cycle list/.define={Pastel1-8}{[of colormap=Pastel1-8]},
+ },
+ /pgfplots/cycle list/Pastel1-8/.style={/pgfplots/@@brewer set cycle list={Pastel1-8}},
+ %
+ /pgfplots/colormap/Pastel1-9/.style={
+ colormap={Pastel1-9}{
+ color=(Pastel1-A);
+ color=(Pastel1-B);
+ color=(Pastel1-C);
+ color=(Pastel1-D);
+ color=(Pastel1-E);
+ color=(Pastel1-F);
+ color=(Pastel1-G);
+ color=(Pastel1-H);
+ color=(Pastel1-I);
+ },
+ cycle list/.define={Pastel1-9}{[of colormap=Pastel1-9]},
+ },
+ /pgfplots/cycle list/Pastel1-9/.style={/pgfplots/@@brewer set cycle list={Pastel1-9}},
+ %
+ /pgfplots/colormap/Set1-3/.style={
+ colormap={Set1-3}{
+ color=(Set1-A);
+ color=(Set1-B);
+ color=(Set1-C);
+ },
+ cycle list/.define={Set1-3}{[of colormap=Set1-3]},
+ },
+ /pgfplots/cycle list/Set1-3/.style={/pgfplots/@@brewer set cycle list={Set1-3}},
+ %
+ /pgfplots/colormap/Set1-4/.style={
+ colormap={Set1-4}{
+ color=(Set1-A);
+ color=(Set1-B);
+ color=(Set1-C);
+ color=(Set1-D);
+ },
+ cycle list/.define={Set1-4}{[of colormap=Set1-4]},
+ },
+ /pgfplots/cycle list/Set1-4/.style={/pgfplots/@@brewer set cycle list={Set1-4}},
+ %
+ /pgfplots/colormap/Set1-5/.style={
+ colormap={Set1-5}{
+ color=(Set1-A);
+ color=(Set1-B);
+ color=(Set1-C);
+ color=(Set1-D);
+ color=(Set1-E);
+ },
+ cycle list/.define={Set1-5}{[of colormap=Set1-5]},
+ },
+ /pgfplots/cycle list/Set1-5/.style={/pgfplots/@@brewer set cycle list={Set1-5}},
+ %
+ /pgfplots/colormap/Set1-6/.style={
+ colormap={Set1-6}{
+ color=(Set1-A);
+ color=(Set1-B);
+ color=(Set1-C);
+ color=(Set1-D);
+ color=(Set1-E);
+ color=(Set1-F);
+ },
+ cycle list/.define={Set1-6}{[of colormap=Set1-6]},
+ },
+ /pgfplots/cycle list/Set1-6/.style={/pgfplots/@@brewer set cycle list={Set1-6}},
+ %
+ /pgfplots/colormap/Set1-7/.style={
+ colormap={Set1-7}{
+ color=(Set1-A);
+ color=(Set1-B);
+ color=(Set1-C);
+ color=(Set1-D);
+ color=(Set1-E);
+ color=(Set1-F);
+ color=(Set1-G);
+ },
+ cycle list/.define={Set1-7}{[of colormap=Set1-7]},
+ },
+ /pgfplots/cycle list/Set1-7/.style={/pgfplots/@@brewer set cycle list={Set1-7}},
+ %
+ /pgfplots/colormap/Set1-8/.style={
+ colormap={Set1-8}{
+ color=(Set1-A);
+ color=(Set1-B);
+ color=(Set1-C);
+ color=(Set1-D);
+ color=(Set1-E);
+ color=(Set1-F);
+ color=(Set1-G);
+ color=(Set1-H);
+ },
+ cycle list/.define={Set1-8}{[of colormap=Set1-8]},
+ },
+ /pgfplots/cycle list/Set1-8/.style={/pgfplots/@@brewer set cycle list={Set1-8}},
+ %
+ /pgfplots/colormap/Set1-9/.style={
+ colormap={Set1-9}{
+ color=(Set1-A);
+ color=(Set1-B);
+ color=(Set1-C);
+ color=(Set1-D);
+ color=(Set1-E);
+ color=(Set1-F);
+ color=(Set1-G);
+ color=(Set1-H);
+ color=(Set1-I);
+ },
+ cycle list/.define={Set1-9}{[of colormap=Set1-9]},
+ },
+ /pgfplots/cycle list/Set1-9/.style={/pgfplots/@@brewer set cycle list={Set1-9}},
+ %
+ /pgfplots/colormap/Pastel2-3/.style={
+ colormap={Pastel2-3}{
+ color=(Pastel2-A);
+ color=(Pastel2-B);
+ color=(Pastel2-C);
+ },
+ cycle list/.define={Pastel2-3}{[of colormap=Pastel2-3]},
+ },
+ /pgfplots/cycle list/Pastel2-3/.style={/pgfplots/@@brewer set cycle list={Pastel2-3}},
+ %
+ /pgfplots/colormap/Pastel2-4/.style={
+ colormap={Pastel2-4}{
+ color=(Pastel2-A);
+ color=(Pastel2-B);
+ color=(Pastel2-C);
+ color=(Pastel2-D);
+ },
+ cycle list/.define={Pastel2-4}{[of colormap=Pastel2-4]},
+ },
+ /pgfplots/cycle list/Pastel2-4/.style={/pgfplots/@@brewer set cycle list={Pastel2-4}},
+ %
+ /pgfplots/colormap/Pastel2-5/.style={
+ colormap={Pastel2-5}{
+ color=(Pastel2-A);
+ color=(Pastel2-B);
+ color=(Pastel2-C);
+ color=(Pastel2-D);
+ color=(Pastel2-E);
+ },
+ cycle list/.define={Pastel2-5}{[of colormap=Pastel2-5]},
+ },
+ /pgfplots/cycle list/Pastel2-5/.style={/pgfplots/@@brewer set cycle list={Pastel2-5}},
+ %
+ /pgfplots/colormap/Pastel2-6/.style={
+ colormap={Pastel2-6}{
+ color=(Pastel2-A);
+ color=(Pastel2-B);
+ color=(Pastel2-C);
+ color=(Pastel2-D);
+ color=(Pastel2-E);
+ color=(Pastel2-F);
+ },
+ cycle list/.define={Pastel2-6}{[of colormap=Pastel2-6]},
+ },
+ /pgfplots/cycle list/Pastel2-6/.style={/pgfplots/@@brewer set cycle list={Pastel2-6}},
+ %
+ /pgfplots/colormap/Pastel2-7/.style={
+ colormap={Pastel2-7}{
+ color=(Pastel2-A);
+ color=(Pastel2-B);
+ color=(Pastel2-C);
+ color=(Pastel2-D);
+ color=(Pastel2-E);
+ color=(Pastel2-F);
+ color=(Pastel2-G);
+ },
+ cycle list/.define={Pastel2-7}{[of colormap=Pastel2-7]},
+ },
+ /pgfplots/cycle list/Pastel2-7/.style={/pgfplots/@@brewer set cycle list={Pastel2-7}},
+ %
+ /pgfplots/colormap/Pastel2-8/.style={
+ colormap={Pastel2-8}{
+ color=(Pastel2-A);
+ color=(Pastel2-B);
+ color=(Pastel2-C);
+ color=(Pastel2-D);
+ color=(Pastel2-E);
+ color=(Pastel2-F);
+ color=(Pastel2-G);
+ color=(Pastel2-H);
+ },
+ cycle list/.define={Pastel2-8}{[of colormap=Pastel2-8]},
+ },
+ /pgfplots/cycle list/Pastel2-8/.style={/pgfplots/@@brewer set cycle list={Pastel2-8}},
+ %
+ /pgfplots/colormap/Set2-3/.style={
+ colormap={Set2-3}{
+ color=(Set2-A);
+ color=(Set2-B);
+ color=(Set2-C);
+ },
+ cycle list/.define={Set2-3}{[of colormap=Set2-3]},
+ },
+ /pgfplots/cycle list/Set2-3/.style={/pgfplots/@@brewer set cycle list={Set2-3}},
+ %
+ /pgfplots/colormap/Set2-4/.style={
+ colormap={Set2-4}{
+ color=(Set2-A);
+ color=(Set2-B);
+ color=(Set2-C);
+ color=(Set2-D);
+ },
+ cycle list/.define={Set2-4}{[of colormap=Set2-4]},
+ },
+ /pgfplots/cycle list/Set2-4/.style={/pgfplots/@@brewer set cycle list={Set2-4}},
+ %
+ /pgfplots/colormap/Set2-5/.style={
+ colormap={Set2-5}{
+ color=(Set2-A);
+ color=(Set2-B);
+ color=(Set2-C);
+ color=(Set2-D);
+ color=(Set2-E);
+ },
+ cycle list/.define={Set2-5}{[of colormap=Set2-5]},
+ },
+ /pgfplots/cycle list/Set2-5/.style={/pgfplots/@@brewer set cycle list={Set2-5}},
+ %
+ /pgfplots/colormap/Set2-6/.style={
+ colormap={Set2-6}{
+ color=(Set2-A);
+ color=(Set2-B);
+ color=(Set2-C);
+ color=(Set2-D);
+ color=(Set2-E);
+ color=(Set2-F);
+ },
+ cycle list/.define={Set2-6}{[of colormap=Set2-6]},
+ },
+ /pgfplots/cycle list/Set2-6/.style={/pgfplots/@@brewer set cycle list={Set2-6}},
+ %
+ /pgfplots/colormap/Set2-7/.style={
+ colormap={Set2-7}{
+ color=(Set2-A);
+ color=(Set2-B);
+ color=(Set2-C);
+ color=(Set2-D);
+ color=(Set2-E);
+ color=(Set2-F);
+ color=(Set2-G);
+ },
+ cycle list/.define={Set2-7}{[of colormap=Set2-7]},
+ },
+ /pgfplots/cycle list/Set2-7/.style={/pgfplots/@@brewer set cycle list={Set2-7}},
+ %
+ /pgfplots/colormap/Set2-8/.style={
+ colormap={Set2-8}{
+ color=(Set2-A);
+ color=(Set2-B);
+ color=(Set2-C);
+ color=(Set2-D);
+ color=(Set2-E);
+ color=(Set2-F);
+ color=(Set2-G);
+ color=(Set2-H);
+ },
+ cycle list/.define={Set2-8}{[of colormap=Set2-8]},
+ },
+ /pgfplots/cycle list/Set2-8/.style={/pgfplots/@@brewer set cycle list={Set2-8}},
+ %
+ /pgfplots/colormap/Dark2-3/.style={
+ colormap={Dark2-3}{
+ color=(Dark2-A);
+ color=(Dark2-B);
+ color=(Dark2-C);
+ },
+ cycle list/.define={Dark2-3}{[of colormap=Dark2-3]},
+ },
+ /pgfplots/cycle list/Dark2-3/.style={/pgfplots/@@brewer set cycle list={Dark2-3}},
+ %
+ /pgfplots/colormap/Dark2-4/.style={
+ colormap={Dark2-4}{
+ color=(Dark2-A);
+ color=(Dark2-B);
+ color=(Dark2-C);
+ color=(Dark2-D);
+ },
+ cycle list/.define={Dark2-4}{[of colormap=Dark2-4]},
+ },
+ /pgfplots/cycle list/Dark2-4/.style={/pgfplots/@@brewer set cycle list={Dark2-4}},
+ %
+ /pgfplots/colormap/Dark2-5/.style={
+ colormap={Dark2-5}{
+ color=(Dark2-A);
+ color=(Dark2-B);
+ color=(Dark2-C);
+ color=(Dark2-D);
+ color=(Dark2-E);
+ },
+ cycle list/.define={Dark2-5}{[of colormap=Dark2-5]},
+ },
+ /pgfplots/cycle list/Dark2-5/.style={/pgfplots/@@brewer set cycle list={Dark2-5}},
+ %
+ /pgfplots/colormap/Dark2-6/.style={
+ colormap={Dark2-6}{
+ color=(Dark2-A);
+ color=(Dark2-B);
+ color=(Dark2-C);
+ color=(Dark2-D);
+ color=(Dark2-E);
+ color=(Dark2-F);
+ },
+ cycle list/.define={Dark2-6}{[of colormap=Dark2-6]},
+ },
+ /pgfplots/cycle list/Dark2-6/.style={/pgfplots/@@brewer set cycle list={Dark2-6}},
+ %
+ /pgfplots/colormap/Dark2-7/.style={
+ colormap={Dark2-7}{
+ color=(Dark2-A);
+ color=(Dark2-B);
+ color=(Dark2-C);
+ color=(Dark2-D);
+ color=(Dark2-E);
+ color=(Dark2-F);
+ color=(Dark2-G);
+ },
+ cycle list/.define={Dark2-7}{[of colormap=Dark2-7]},
+ },
+ /pgfplots/cycle list/Dark2-7/.style={/pgfplots/@@brewer set cycle list={Dark2-7}},
+ %
+ /pgfplots/colormap/Dark2-8/.style={
+ colormap={Dark2-8}{
+ color=(Dark2-A);
+ color=(Dark2-B);
+ color=(Dark2-C);
+ color=(Dark2-D);
+ color=(Dark2-E);
+ color=(Dark2-F);
+ color=(Dark2-G);
+ color=(Dark2-H);
+ },
+ cycle list/.define={Dark2-8}{[of colormap=Dark2-8]},
+ },
+ /pgfplots/cycle list/Dark2-8/.style={/pgfplots/@@brewer set cycle list={Dark2-8}},
+ %
+ /pgfplots/colormap/Paired-3/.style={
+ colormap={Paired-3}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ },
+ cycle list/.define={Paired-3}{[of colormap=Paired-3]},
+ },
+ /pgfplots/cycle list/Paired-3/.style={/pgfplots/@@brewer set cycle list={Paired-3}},
+ %
+ /pgfplots/colormap/Paired-4/.style={
+ colormap={Paired-4}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ },
+ cycle list/.define={Paired-4}{[of colormap=Paired-4]},
+ },
+ /pgfplots/cycle list/Paired-4/.style={/pgfplots/@@brewer set cycle list={Paired-4}},
+ %
+ /pgfplots/colormap/Paired-5/.style={
+ colormap={Paired-5}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ },
+ cycle list/.define={Paired-5}{[of colormap=Paired-5]},
+ },
+ /pgfplots/cycle list/Paired-5/.style={/pgfplots/@@brewer set cycle list={Paired-5}},
+ %
+ /pgfplots/colormap/Paired-6/.style={
+ colormap={Paired-6}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ color=(Paired-F);
+ },
+ cycle list/.define={Paired-6}{[of colormap=Paired-6]},
+ },
+ /pgfplots/cycle list/Paired-6/.style={/pgfplots/@@brewer set cycle list={Paired-6}},
+ %
+ /pgfplots/colormap/Paired-7/.style={
+ colormap={Paired-7}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ color=(Paired-F);
+ color=(Paired-G);
+ },
+ cycle list/.define={Paired-7}{[of colormap=Paired-7]},
+ },
+ /pgfplots/cycle list/Paired-7/.style={/pgfplots/@@brewer set cycle list={Paired-7}},
+ %
+ /pgfplots/colormap/Paired-8/.style={
+ colormap={Paired-8}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ color=(Paired-F);
+ color=(Paired-G);
+ color=(Paired-H);
+ },
+ cycle list/.define={Paired-8}{[of colormap=Paired-8]},
+ },
+ /pgfplots/cycle list/Paired-8/.style={/pgfplots/@@brewer set cycle list={Paired-8}},
+ %
+ /pgfplots/colormap/Paired-9/.style={
+ colormap={Paired-9}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ color=(Paired-F);
+ color=(Paired-G);
+ color=(Paired-H);
+ color=(Paired-I);
+ },
+ cycle list/.define={Paired-9}{[of colormap=Paired-9]},
+ },
+ /pgfplots/cycle list/Paired-9/.style={/pgfplots/@@brewer set cycle list={Paired-9}},
+ %
+ /pgfplots/colormap/Paired-10/.style={
+ colormap={Paired-10}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ color=(Paired-F);
+ color=(Paired-G);
+ color=(Paired-H);
+ color=(Paired-I);
+ color=(Paired-J);
+ },
+ cycle list/.define={Paired-10}{[of colormap=Paired-10]},
+ },
+ /pgfplots/cycle list/Paired-10/.style={/pgfplots/@@brewer set cycle list={Paired-10}},
+ %
+ /pgfplots/colormap/Paired-11/.style={
+ colormap={Paired-11}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ color=(Paired-F);
+ color=(Paired-G);
+ color=(Paired-H);
+ color=(Paired-I);
+ color=(Paired-J);
+ color=(Paired-K);
+ },
+ cycle list/.define={Paired-11}{[of colormap=Paired-11]},
+ },
+ /pgfplots/cycle list/Paired-11/.style={/pgfplots/@@brewer set cycle list={Paired-11}},
+ %
+ /pgfplots/colormap/Paired-12/.style={
+ colormap={Paired-12}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ color=(Paired-F);
+ color=(Paired-G);
+ color=(Paired-H);
+ color=(Paired-I);
+ color=(Paired-J);
+ color=(Paired-K);
+ color=(Paired-L);
+ },
+ cycle list/.define={Paired-12}{[of colormap=Paired-12]},
+ },
+ /pgfplots/cycle list/Paired-12/.style={/pgfplots/@@brewer set cycle list={Paired-12}},
+ %
+ /pgfplots/colormap/Accent-3/.style={
+ colormap={Accent-3}{
+ color=(Accent-A);
+ color=(Accent-B);
+ color=(Accent-C);
+ },
+ cycle list/.define={Accent-3}{[of colormap=Accent-3]},
+ },
+ /pgfplots/cycle list/Accent-3/.style={/pgfplots/@@brewer set cycle list={Accent-3}},
+ %
+ /pgfplots/colormap/Accent-4/.style={
+ colormap={Accent-4}{
+ color=(Accent-A);
+ color=(Accent-B);
+ color=(Accent-C);
+ color=(Accent-D);
+ },
+ cycle list/.define={Accent-4}{[of colormap=Accent-4]},
+ },
+ /pgfplots/cycle list/Accent-4/.style={/pgfplots/@@brewer set cycle list={Accent-4}},
+ %
+ /pgfplots/colormap/Accent-5/.style={
+ colormap={Accent-5}{
+ color=(Accent-A);
+ color=(Accent-B);
+ color=(Accent-C);
+ color=(Accent-D);
+ color=(Accent-E);
+ },
+ cycle list/.define={Accent-5}{[of colormap=Accent-5]},
+ },
+ /pgfplots/cycle list/Accent-5/.style={/pgfplots/@@brewer set cycle list={Accent-5}},
+ %
+ /pgfplots/colormap/Accent-6/.style={
+ colormap={Accent-6}{
+ color=(Accent-A);
+ color=(Accent-B);
+ color=(Accent-C);
+ color=(Accent-D);
+ color=(Accent-E);
+ color=(Accent-F);
+ },
+ cycle list/.define={Accent-6}{[of colormap=Accent-6]},
+ },
+ /pgfplots/cycle list/Accent-6/.style={/pgfplots/@@brewer set cycle list={Accent-6}},
+ %
+ /pgfplots/colormap/Accent-7/.style={
+ colormap={Accent-7}{
+ color=(Accent-A);
+ color=(Accent-B);
+ color=(Accent-C);
+ color=(Accent-D);
+ color=(Accent-E);
+ color=(Accent-F);
+ color=(Accent-G);
+ },
+ cycle list/.define={Accent-7}{[of colormap=Accent-7]},
+ },
+ /pgfplots/cycle list/Accent-7/.style={/pgfplots/@@brewer set cycle list={Accent-7}},
+ %
+ /pgfplots/colormap/Accent-8/.style={
+ colormap={Accent-8}{
+ color=(Accent-A);
+ color=(Accent-B);
+ color=(Accent-C);
+ color=(Accent-D);
+ color=(Accent-E);
+ color=(Accent-F);
+ color=(Accent-G);
+ color=(Accent-H);
+ },
+ cycle list/.define={Accent-8}{[of colormap=Accent-8]},
+ },
+ /pgfplots/cycle list/Accent-8/.style={/pgfplots/@@brewer set cycle list={Accent-8}},
+ %
+}
+
+% define additional colormap styles for "continuous" colorbars
+% (then one doesn't have to guess the maximum number of classes)
+\pgfplotsset{
+ /pgfplots/colormap/YlGn/.style={
+ colormap={YlGn}{
+ color=(YlGn-A);
+ color=(YlGn-C);
+ color=(YlGn-D);
+ color=(YlGn-F);
+ color=(YlGn-G);
+ color=(YlGn-H);
+ color=(YlGn-J);
+ color=(YlGn-K);
+ color=(YlGn-M);
+ },
+ cycle list/.define={YlGn}{[of colormap=YlGn]},
+ },
+ /pgfplots/cycle list/YlGn/.style={/pgfplots/@@brewer set cycle list={YlGn}},
+ %
+ /pgfplots/colormap/YlGnBu/.style={
+ colormap={YlGnBu}{
+ color=(YlGnBu-A);
+ color=(YlGnBu-C);
+ color=(YlGnBu-D);
+ color=(YlGnBu-F);
+ color=(YlGnBu-G);
+ color=(YlGnBu-H);
+ color=(YlGnBu-J);
+ color=(YlGnBu-K);
+ color=(YlGnBu-M);
+ },
+ cycle list/.define={YlGnBu}{[of colormap=YlGnBu]},
+ },
+ /pgfplots/cycle list/YlGnBu/.style={/pgfplots/@@brewer set cycle list={YlGnBu}},
+ %
+ /pgfplots/colormap/GnBu/.style={
+ colormap={GnBu}{
+ color=(GnBu-A);
+ color=(GnBu-C);
+ color=(GnBu-D);
+ color=(GnBu-F);
+ color=(GnBu-G);
+ color=(GnBu-H);
+ color=(GnBu-J);
+ color=(GnBu-K);
+ color=(GnBu-M);
+ },
+ cycle list/.define={GnBu}{[of colormap=GnBu]},
+ },
+ /pgfplots/cycle list/GnBu/.style={/pgfplots/@@brewer set cycle list={GnBu}},
+ %
+ /pgfplots/colormap/BuGn/.style={
+ colormap={BuGn}{
+ color=(BuGn-A);
+ color=(BuGn-C);
+ color=(BuGn-D);
+ color=(BuGn-F);
+ color=(BuGn-G);
+ color=(BuGn-H);
+ color=(BuGn-J);
+ color=(BuGn-K);
+ color=(BuGn-M);
+ },
+ cycle list/.define={BuGn}{[of colormap=BuGn]},
+ },
+ /pgfplots/cycle list/BuGn/.style={/pgfplots/@@brewer set cycle list={BuGn}},
+ %
+ /pgfplots/colormap/PuBuGn/.style={
+ colormap={PuBuGn}{
+ color=(PuBuGn-A);
+ color=(PuBuGn-C);
+ color=(PuBuGn-D);
+ color=(PuBuGn-F);
+ color=(PuBuGn-G);
+ color=(PuBuGn-H);
+ color=(PuBuGn-J);
+ color=(PuBuGn-K);
+ color=(PuBuGn-M);
+ },
+ cycle list/.define={PuBuGn}{[of colormap=PuBuGn]},
+ },
+ /pgfplots/cycle list/PuBuGn/.style={/pgfplots/@@brewer set cycle list={PuBuGn}},
+ %
+ /pgfplots/colormap/PuBu/.style={
+ colormap={PuBu}{
+ color=(PuBu-A);
+ color=(PuBu-C);
+ color=(PuBu-D);
+ color=(PuBu-F);
+ color=(PuBu-G);
+ color=(PuBu-H);
+ color=(PuBu-J);
+ color=(PuBu-K);
+ color=(PuBu-M);
+ },
+ cycle list/.define={PuBu}{[of colormap=PuBu]},
+ },
+ /pgfplots/cycle list/PuBu/.style={/pgfplots/@@brewer set cycle list={PuBu}},
+ %
+ /pgfplots/colormap/BuPu/.style={
+ colormap={BuPu}{
+ color=(BuPu-A);
+ color=(BuPu-C);
+ color=(BuPu-D);
+ color=(BuPu-F);
+ color=(BuPu-G);
+ color=(BuPu-H);
+ color=(BuPu-J);
+ color=(BuPu-K);
+ color=(BuPu-M);
+ },
+ cycle list/.define={BuPu}{[of colormap=BuPu]},
+ },
+ /pgfplots/cycle list/BuPu/.style={/pgfplots/@@brewer set cycle list={BuPu}},
+ %
+ /pgfplots/colormap/RdPu/.style={
+ colormap={RdPu}{
+ color=(RdPu-A);
+ color=(RdPu-C);
+ color=(RdPu-D);
+ color=(RdPu-F);
+ color=(RdPu-G);
+ color=(RdPu-H);
+ color=(RdPu-J);
+ color=(RdPu-K);
+ color=(RdPu-M);
+ },
+ cycle list/.define={RdPu}{[of colormap=RdPu]},
+ },
+ /pgfplots/cycle list/RdPu/.style={/pgfplots/@@brewer set cycle list={RdPu}},
+ %
+ /pgfplots/colormap/PuRd/.style={
+ colormap={PuRd}{
+ color=(PuRd-A);
+ color=(PuRd-C);
+ color=(PuRd-D);
+ color=(PuRd-F);
+ color=(PuRd-G);
+ color=(PuRd-H);
+ color=(PuRd-J);
+ color=(PuRd-K);
+ color=(PuRd-M);
+ },
+ cycle list/.define={PuRd}{[of colormap=PuRd]},
+ },
+ /pgfplots/cycle list/PuRd/.style={/pgfplots/@@brewer set cycle list={PuRd}},
+ %
+ /pgfplots/colormap/OrRd/.style={
+ colormap={OrRd}{
+ color=(OrRd-A);
+ color=(OrRd-C);
+ color=(OrRd-D);
+ color=(OrRd-F);
+ color=(OrRd-G);
+ color=(OrRd-H);
+ color=(OrRd-J);
+ color=(OrRd-K);
+ color=(OrRd-M);
+ },
+ cycle list/.define={OrRd}{[of colormap=OrRd]},
+ },
+ /pgfplots/cycle list/OrRd/.style={/pgfplots/@@brewer set cycle list={OrRd}},
+ %
+ /pgfplots/colormap/YlOrRd/.style={
+ colormap={YlOrRd}{
+ color=(YlOrRd-A);
+ color=(YlOrRd-C);
+ color=(YlOrRd-D);
+ color=(YlOrRd-F);
+ color=(YlOrRd-G);
+ color=(YlOrRd-H);
+ color=(YlOrRd-J);
+ color=(YlOrRd-K);
+ color=(YlOrRd-M);
+ },
+ cycle list/.define={YlOrRd}{[of colormap=YlOrRd]},
+ },
+ /pgfplots/cycle list/YlOrRd/.style={/pgfplots/@@brewer set cycle list={YlOrRd}},
+ %
+ /pgfplots/colormap/YlOrBr/.style={
+ colormap={YlOrBr}{
+ color=(YlOrBr-A);
+ color=(YlOrBr-C);
+ color=(YlOrBr-D);
+ color=(YlOrBr-F);
+ color=(YlOrBr-G);
+ color=(YlOrBr-H);
+ color=(YlOrBr-J);
+ color=(YlOrBr-K);
+ color=(YlOrBr-M);
+ },
+ cycle list/.define={YlOrBr}{[of colormap=YlOrBr]},
+ },
+ /pgfplots/cycle list/YlOrBr/.style={/pgfplots/@@brewer set cycle list={YlOrBr}},
+ %
+ /pgfplots/colormap/Purples/.style={
+ colormap={Purples}{
+ color=(Purples-A);
+ color=(Purples-C);
+ color=(Purples-D);
+ color=(Purples-F);
+ color=(Purples-G);
+ color=(Purples-H);
+ color=(Purples-J);
+ color=(Purples-K);
+ color=(Purples-M);
+ },
+ cycle list/.define={Purples}{[of colormap=Purples]},
+ },
+ /pgfplots/cycle list/Purples/.style={/pgfplots/@@brewer set cycle list={Purples}},
+ %
+ /pgfplots/colormap/Blues/.style={
+ colormap={Blues}{
+ color=(Blues-A);
+ color=(Blues-C);
+ color=(Blues-D);
+ color=(Blues-F);
+ color=(Blues-G);
+ color=(Blues-H);
+ color=(Blues-J);
+ color=(Blues-K);
+ color=(Blues-M);
+ },
+ cycle list/.define={Blues}{[of colormap=Blues]},
+ },
+ /pgfplots/cycle list/Blues/.style={/pgfplots/@@brewer set cycle list={Blues}},
+ %
+ /pgfplots/colormap/Greens/.style={
+ colormap={Greens}{
+ color=(Greens-A);
+ color=(Greens-C);
+ color=(Greens-D);
+ color=(Greens-F);
+ color=(Greens-G);
+ color=(Greens-H);
+ color=(Greens-J);
+ color=(Greens-K);
+ color=(Greens-M);
+ },
+ cycle list/.define={Greens}{[of colormap=Greens]},
+ },
+ /pgfplots/cycle list/Greens/.style={/pgfplots/@@brewer set cycle list={Greens}},
+ %
+ /pgfplots/colormap/Oranges/.style={
+ colormap={Oranges}{
+ color=(Oranges-A);
+ color=(Oranges-C);
+ color=(Oranges-D);
+ color=(Oranges-F);
+ color=(Oranges-G);
+ color=(Oranges-H);
+ color=(Oranges-J);
+ color=(Oranges-K);
+ color=(Oranges-M);
+ },
+ cycle list/.define={Oranges}{[of colormap=Oranges]},
+ },
+ /pgfplots/cycle list/Oranges/.style={/pgfplots/@@brewer set cycle list={Oranges}},
+ %
+ /pgfplots/colormap/Reds/.style={
+ colormap={Reds}{
+ color=(Reds-A);
+ color=(Reds-C);
+ color=(Reds-D);
+ color=(Reds-F);
+ color=(Reds-G);
+ color=(Reds-H);
+ color=(Reds-J);
+ color=(Reds-K);
+ color=(Reds-M);
+ },
+ cycle list/.define={Reds}{[of colormap=Reds]},
+ },
+ /pgfplots/cycle list/Reds/.style={/pgfplots/@@brewer set cycle list={Reds}},
+ %
+ /pgfplots/colormap/Greys/.style={
+ colormap={Greys}{
+ color=(Greys-A);
+ color=(Greys-C);
+ color=(Greys-D);
+ color=(Greys-F);
+ color=(Greys-G);
+ color=(Greys-H);
+ color=(Greys-J);
+ color=(Greys-K);
+ color=(Greys-M);
+ },
+ cycle list/.define={Greys}{[of colormap=Greys]},
+ },
+ /pgfplots/cycle list/Greys/.style={/pgfplots/@@brewer set cycle list={Greys}},
+ %
+ % ===========================================================================
+ /pgfplots/colormap/PuOr/.style={
+ colormap={PuOr}{
+ color=(PuOr-A);
+ color=(PuOr-B);
+ color=(PuOr-D);
+ color=(PuOr-F);
+ color=(PuOr-G);
+ color=(PuOr-H);
+ color=(PuOr-I);
+ color=(PuOr-J);
+ color=(PuOr-L);
+ color=(PuOr-N);
+ color=(PuOr-O);
+ },
+ cycle list/.define={PuOr}{[of colormap=PuOr]},
+ },
+ /pgfplots/cycle list/PuOr/.style={/pgfplots/@@brewer set cycle list={PuOr}},
+ %
+ /pgfplots/colormap/BrBG/.style={
+ colormap={BrBG}{
+ color=(BrBG-A);
+ color=(BrBG-B);
+ color=(BrBG-D);
+ color=(BrBG-F);
+ color=(BrBG-G);
+ color=(BrBG-H);
+ color=(BrBG-I);
+ color=(BrBG-J);
+ color=(BrBG-L);
+ color=(BrBG-N);
+ color=(BrBG-O);
+ },
+ cycle list/.define={BrBG}{[of colormap=BrBG]},
+ },
+ /pgfplots/cycle list/BrBG/.style={/pgfplots/@@brewer set cycle list={BrBG}},
+ %
+ /pgfplots/colormap/PRGn/.style={
+ colormap={PRGn}{
+ color=(PRGn-A);
+ color=(PRGn-B);
+ color=(PRGn-D);
+ color=(PRGn-F);
+ color=(PRGn-G);
+ color=(PRGn-H);
+ color=(PRGn-I);
+ color=(PRGn-J);
+ color=(PRGn-L);
+ color=(PRGn-N);
+ color=(PRGn-O);
+ },
+ cycle list/.define={PRGn}{[of colormap=PRGn]},
+ },
+ /pgfplots/cycle list/PRGn/.style={/pgfplots/@@brewer set cycle list={PRGn}},
+ %
+ /pgfplots/colormap/PiYG/.style={
+ colormap={PiYG}{
+ color=(PiYG-A);
+ color=(PiYG-B);
+ color=(PiYG-D);
+ color=(PiYG-F);
+ color=(PiYG-G);
+ color=(PiYG-H);
+ color=(PiYG-I);
+ color=(PiYG-J);
+ color=(PiYG-L);
+ color=(PiYG-N);
+ color=(PiYG-O);
+ },
+ cycle list/.define={PiYG}{[of colormap=PiYG]},
+ },
+ /pgfplots/cycle list/PiYG/.style={/pgfplots/@@brewer set cycle list={PiYG}},
+ %
+ /pgfplots/colormap/RdBu/.style={
+ colormap={RdBu}{
+ color=(RdBu-A);
+ color=(RdBu-B);
+ color=(RdBu-D);
+ color=(RdBu-F);
+ color=(RdBu-G);
+ color=(RdBu-H);
+ color=(RdBu-I);
+ color=(RdBu-J);
+ color=(RdBu-L);
+ color=(RdBu-N);
+ color=(RdBu-O);
+ },
+ cycle list/.define={RdBu}{[of colormap=RdBu]},
+ },
+ /pgfplots/cycle list/RdBu/.style={/pgfplots/@@brewer set cycle list={RdBu}},
+ %
+ /pgfplots/colormap/RdGy/.style={
+ colormap={RdGy}{
+ color=(RdGy-A);
+ color=(RdGy-B);
+ color=(RdGy-D);
+ color=(RdGy-F);
+ color=(RdGy-G);
+ color=(RdGy-H);
+ color=(RdGy-I);
+ color=(RdGy-J);
+ color=(RdGy-L);
+ color=(RdGy-N);
+ color=(RdGy-O);
+ },
+ cycle list/.define={RdGy}{[of colormap=RdGy]},
+ },
+ /pgfplots/cycle list/RdGy/.style={/pgfplots/@@brewer set cycle list={RdGy}},
+ %
+ /pgfplots/colormap/RdYlBu/.style={
+ colormap={RdYlBu}{
+ color=(RdYlBu-A);
+ color=(RdYlBu-B);
+ color=(RdYlBu-D);
+ color=(RdYlBu-F);
+ color=(RdYlBu-G);
+ color=(RdYlBu-H);
+ color=(RdYlBu-I);
+ color=(RdYlBu-J);
+ color=(RdYlBu-L);
+ color=(RdYlBu-N);
+ color=(RdYlBu-O);
+ },
+ cycle list/.define={RdYlBu}{[of colormap=RdYlBu]},
+ },
+ /pgfplots/cycle list/RdYlBu/.style={/pgfplots/@@brewer set cycle list={RdYlBu}},
+ %
+ /pgfplots/colormap/Spectral/.style={
+ colormap={Spectral}{
+ color=(Spectral-A);
+ color=(Spectral-B);
+ color=(Spectral-D);
+ color=(Spectral-F);
+ color=(Spectral-G);
+ color=(Spectral-H);
+ color=(Spectral-I);
+ color=(Spectral-J);
+ color=(Spectral-L);
+ color=(Spectral-N);
+ color=(Spectral-O);
+ },
+ cycle list/.define={Spectral}{[of colormap=Spectral]},
+ },
+ /pgfplots/cycle list/Spectral/.style={/pgfplots/@@brewer set cycle list={Spectral}},
+ %
+ /pgfplots/colormap/RdYlGn/.style={
+ colormap={RdYlGn}{
+ color=(RdYlGn-A);
+ color=(RdYlGn-B);
+ color=(RdYlGn-D);
+ color=(RdYlGn-F);
+ color=(RdYlGn-G);
+ color=(RdYlGn-H);
+ color=(RdYlGn-I);
+ color=(RdYlGn-J);
+ color=(RdYlGn-L);
+ color=(RdYlGn-N);
+ color=(RdYlGn-O);
+ },
+ cycle list/.define={RdYlGn}{[of colormap=RdYlGn]},
+ },
+ /pgfplots/cycle list/RdYlGn/.style={/pgfplots/@@brewer set cycle list={RdYlGn}},
+ %
+}
+
+% define additional colormap styles for "qualitative" cycle lists
+% (because colors are always the same on the same index and so one doesn't have
+% to choose a number for the cycle lists)
+\pgfplotsset{
+ /pgfplots/colormap/Set3/.style={
+ colormap={Set3}{
+ color=(Set3-A);
+ color=(Set3-B);
+ color=(Set3-C);
+ color=(Set3-D);
+ color=(Set3-E);
+ color=(Set3-F);
+ color=(Set3-G);
+ color=(Set3-H);
+ color=(Set3-I);
+ color=(Set3-J);
+ color=(Set3-K);
+ color=(Set3-L);
+ },
+ cycle list/.define={Set3}{[of colormap=Set3]},
+ },
+ /pgfplots/cycle list/Set3/.style={/pgfplots/@@brewer set cycle list={Set3}},
+ %
+ /pgfplots/colormap/Pastel1/.style={
+ colormap={Pastel1}{
+ color=(Pastel1-A);
+ color=(Pastel1-B);
+ color=(Pastel1-C);
+ color=(Pastel1-D);
+ color=(Pastel1-E);
+ color=(Pastel1-F);
+ color=(Pastel1-G);
+ color=(Pastel1-H);
+ color=(Pastel1-I);
+ },
+ cycle list/.define={Pastel1}{[of colormap=Pastel1]},
+ },
+ /pgfplots/cycle list/Pastel1/.style={/pgfplots/@@brewer set cycle list={Pastel1}},
+ %
+ /pgfplots/colormap/Set1/.style={
+ colormap={Set1}{
+ color=(Set1-A);
+ color=(Set1-B);
+ color=(Set1-C);
+ color=(Set1-D);
+ color=(Set1-E);
+ color=(Set1-F);
+ color=(Set1-G);
+ color=(Set1-H);
+ color=(Set1-I);
+ },
+ cycle list/.define={Set1}{[of colormap=Set1]},
+ },
+ /pgfplots/cycle list/Set1/.style={/pgfplots/@@brewer set cycle list={Set1}},
+ %
+ /pgfplots/colormap/Pastel2/.style={
+ colormap={Pastel2}{
+ color=(Pastel2-A);
+ color=(Pastel2-B);
+ color=(Pastel2-C);
+ color=(Pastel2-D);
+ color=(Pastel2-E);
+ color=(Pastel2-F);
+ color=(Pastel2-G);
+ color=(Pastel2-H);
+ },
+ cycle list/.define={Pastel2}{[of colormap=Pastel2]},
+ },
+ /pgfplots/cycle list/Pastel2/.style={/pgfplots/@@brewer set cycle list={Pastel2}},
+ %
+ /pgfplots/colormap/Set2/.style={
+ colormap={Set2}{
+ color=(Set2-A);
+ color=(Set2-B);
+ color=(Set2-C);
+ color=(Set2-D);
+ color=(Set2-E);
+ color=(Set2-F);
+ color=(Set2-G);
+ color=(Set2-H);
+ },
+ cycle list/.define={Set2}{[of colormap=Set2]},
+ },
+ /pgfplots/cycle list/Set2/.style={/pgfplots/@@brewer set cycle list={Set2}},
+ %
+ /pgfplots/colormap/Dark2/.style={
+ colormap={Dark2}{
+ color=(Dark2-A);
+ color=(Dark2-B);
+ color=(Dark2-C);
+ color=(Dark2-D);
+ color=(Dark2-E);
+ color=(Dark2-F);
+ color=(Dark2-G);
+ color=(Dark2-H);
+ },
+ cycle list/.define={Dark2}{[of colormap=Dark2]},
+ },
+ /pgfplots/cycle list/Dark2/.style={/pgfplots/@@brewer set cycle list={Dark2}},
+ %
+ /pgfplots/colormap/Paired/.style={
+ colormap={Paired}{
+ color=(Paired-A);
+ color=(Paired-B);
+ color=(Paired-C);
+ color=(Paired-D);
+ color=(Paired-E);
+ color=(Paired-F);
+ color=(Paired-G);
+ color=(Paired-H);
+ color=(Paired-I);
+ color=(Paired-J);
+ color=(Paired-K);
+ color=(Paired-L);
+ },
+ cycle list/.define={Paired}{[of colormap=Paired]},
+ },
+ /pgfplots/cycle list/Paired/.style={/pgfplots/@@brewer set cycle list={Paired}},
+ %
+ /pgfplots/colormap/Accent/.style={
+ colormap={Accent}{
+ color=(Accent-A);
+ color=(Accent-B);
+ color=(Accent-C);
+ color=(Accent-D);
+ color=(Accent-E);
+ color=(Accent-F);
+ color=(Accent-G);
+ color=(Accent-H);
+ },
+ cycle list/.define={Accent}{[of colormap=Accent]},
+ },
+ /pgfplots/cycle list/Accent/.style={/pgfplots/@@brewer set cycle list={Accent}},
+ %
+}
+
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.colortol.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.colortol.code.tex
new file mode 100644
index 0000000000..e83d62a70f
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.colortol.code.tex
@@ -0,0 +1,766 @@
+
+% load all colors for the `colormap's and `cycle list's
+\usetikzlibrary{colortol}
+
+% define `colormap's
+\pgfplotsset{
+ /pgfplots/@@colortol set cycle list/.code={%
+ \pgfkeysalso{
+ /pgfplots/ensure colormap={/pgfplots/colormap/#1},
+ /pgfplots/cycle list name=#1,
+ },
+ },
+ % -----------------------------------
+ % define "the" palette I colormap, which is just an alias for
+ % the colormap `colortol-P1-9'
+ /pgfplots/colormap/colortol-P1/.style={
+ colormap={colortol-P1}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-D);
+ color=(colortol-P1-E);
+ color=(colortol-P1-F);
+ color=(colortol-P1-G);
+ color=(colortol-P1-H);
+ color=(colortol-P1-I);
+ color=(colortol-P1-L);
+ color=(colortol-P1-M);
+ },
+ cycle list/.define={colortol-P1}{[of colormap=colortol-P1]},
+ },
+ /pgfplots/cycle list/colortol-P1/.style={/pgfplots/@@colortol set cycle list={colortol-P1}},
+ %
+ % -----------------------------------
+ % define (other) palette I colormaps
+ /pgfplots/colormap/colortol-P1-3/.style={
+ colormap={colortol-P1-3}{
+ color=(colortol-P1-B);
+ color=(colortol-P1-H);
+ color=(colortol-P1-J);
+ },
+ cycle list/.define={colortol-P1-3}{[of colormap=colortol-P1-3]},
+ },
+ /pgfplots/cycle list/colortol-P1-3/.style={/pgfplots/@@colortol set cycle list={colortol-P1-3}},
+ %
+ /pgfplots/colormap/colortol-P1-4/.style={
+ colormap={colortol-P1-4}{
+ color=(colortol-P1-B);
+ color=(colortol-P1-F);
+ color=(colortol-P1-H);
+ color=(colortol-P1-J);
+ },
+ cycle list/.define={colortol-P1-4}{[of colormap=colortol-P1-4]},
+ },
+ /pgfplots/cycle list/colortol-P1-4/.style={/pgfplots/@@colortol set cycle list={colortol-P1-4}},
+ %
+ /pgfplots/colormap/colortol-P1-5/.style={
+ colormap={colortol-P1-5}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-D);
+ color=(colortol-P1-F);
+ color=(colortol-P1-H);
+ color=(colortol-P1-J);
+ },
+ cycle list/.define={colortol-P1-5}{[of colormap=colortol-P1-5]},
+ },
+ /pgfplots/cycle list/colortol-P1-5/.style={/pgfplots/@@colortol set cycle list={colortol-P1-5}},
+ %
+ /pgfplots/colormap/colortol-P1-6/.style={
+ colormap={colortol-P1-6}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-D);
+ color=(colortol-P1-F);
+ color=(colortol-P1-H);
+ color=(colortol-P1-J);
+ color=(colortol-P1-M);
+ },
+ cycle list/.define={colortol-P1-6}{[of colormap=colortol-P1-6]},
+ },
+ /pgfplots/cycle list/colortol-P1-6/.style={/pgfplots/@@colortol set cycle list={colortol-P1-6}},
+ %
+ /pgfplots/colormap/colortol-P1-7/.style={
+ colormap={colortol-P1-7}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-D);
+ color=(colortol-P1-E);
+ color=(colortol-P1-F);
+ color=(colortol-P1-H);
+ color=(colortol-P1-J);
+ color=(colortol-P1-M);
+ },
+ cycle list/.define={colortol-P1-7}{[of colormap=colortol-P1-7]},
+ },
+ /pgfplots/cycle list/colortol-P1-7/.style={/pgfplots/@@colortol set cycle list={colortol-P1-7}},
+ %
+ /pgfplots/colormap/colortol-P1-8/.style={
+ colormap={colortol-P1-8}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-D);
+ color=(colortol-P1-E);
+ color=(colortol-P1-F);
+ color=(colortol-P1-G);
+ color=(colortol-P1-H);
+ color=(colortol-P1-J);
+ color=(colortol-P1-M);
+ },
+ cycle list/.define={colortol-P1-8}{[of colormap=colortol-P1-8]},
+ },
+ /pgfplots/cycle list/colortol-P1-8/.style={/pgfplots/@@colortol set cycle list={colortol-P1-8}},
+ %
+ /pgfplots/colormap/colortol-P1-9/.style={
+ colormap={colortol-P1-9}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-D);
+ color=(colortol-P1-E);
+ color=(colortol-P1-F);
+ color=(colortol-P1-G);
+ color=(colortol-P1-H);
+ color=(colortol-P1-J);
+ color=(colortol-P1-L);
+ color=(colortol-P1-M);
+ },
+ cycle list/.define={colortol-P1-9}{[of colormap=colortol-P1-9]},
+ },
+ /pgfplots/cycle list/colortol-P1-9/.style={/pgfplots/@@colortol set cycle list={colortol-P1-9}},
+ %
+ /pgfplots/colormap/colortol-P1-10/.style={
+ colormap={colortol-P1-10}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-D);
+ color=(colortol-P1-E);
+ color=(colortol-P1-F);
+ color=(colortol-P1-G);
+ color=(colortol-P1-H);
+ color=(colortol-P1-I);
+ color=(colortol-P1-J);
+ color=(colortol-P1-L);
+ color=(colortol-P1-M);
+ },
+ cycle list/.define={colortol-P1-10}{[of colormap=colortol-P1-10]},
+ },
+ /pgfplots/cycle list/colortol-P1-10/.style={/pgfplots/@@colortol set cycle list={colortol-P1-10}},
+ %
+ /pgfplots/colormap/colortol-P1-11/.style={
+ colormap={colortol-P1-11}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-C);
+ color=(colortol-P1-D);
+ color=(colortol-P1-E);
+ color=(colortol-P1-F);
+ color=(colortol-P1-G);
+ color=(colortol-P1-H);
+ color=(colortol-P1-I);
+ color=(colortol-P1-J);
+ color=(colortol-P1-L);
+ color=(colortol-P1-M);
+ },
+ cycle list/.define={colortol-P1-11}{[of colormap=colortol-P1-11]},
+ },
+ /pgfplots/cycle list/colortol-P1-11/.style={/pgfplots/@@colortol set cycle list={colortol-P1-11}},
+ %
+ /pgfplots/colormap/colortol-P1-12/.style={
+ colormap={colortol-P1-12}{
+ color=(colortol-P1-A);
+ color=(colortol-P1-C);
+ color=(colortol-P1-D);
+ color=(colortol-P1-E);
+ color=(colortol-P1-F);
+ color=(colortol-P1-G);
+ color=(colortol-P1-H);
+ color=(colortol-P1-I);
+ color=(colortol-P1-J);
+ color=(colortol-P1-K);
+ color=(colortol-P1-L);
+ color=(colortol-P1-M);
+ },
+ cycle list/.define={colortol-P1-12}{[of colormap=colortol-P1-12]},
+ },
+ /pgfplots/cycle list/colortol-P1-12/.style={/pgfplots/@@colortol set cycle list={colortol-P1-12}},
+ %
+ % -----------------------------------
+ % define palette II colormaps
+ /pgfplots/colormap/colortol-P2light/.style={
+ colormap={colortol-P2light}{
+ color=(colortol-P2light-A);
+ color=(colortol-P2light-B);
+ color=(colortol-P2light-C);
+ color=(colortol-P2light-D);
+ color=(colortol-P2light-E);
+ color=(colortol-P2light-F);
+ color=(colortol-P2light-G);
+ },
+ cycle list/.define={colortol-P2light}{[of colormap=colortol-P2light]},
+ },
+ /pgfplots/cycle list/colortol-P2light/.style={/pgfplots/@@colortol set cycle list={colortol-P2light}},
+ %
+ /pgfplots/colormap/colortol-P2/.style={
+ colormap={colortol-P2}{
+ color=(colortol-P2-A);
+ color=(colortol-P2-B);
+ color=(colortol-P2-C);
+ color=(colortol-P2-D);
+ color=(colortol-P2-E);
+ color=(colortol-P2-F);
+ color=(colortol-P2-G);
+ },
+ cycle list/.define={colortol-P2}{[of colormap=colortol-P2]},
+ },
+ /pgfplots/cycle list/colortol-P2/.style={/pgfplots/@@colortol set cycle list={colortol-P2}},
+ %
+ /pgfplots/colormap/colortol-P2dark/.style={
+ colormap={colortol-P2dark}{
+ color=(colortol-P2dark-A);
+ color=(colortol-P2dark-B);
+ color=(colortol-P2dark-C);
+ color=(colortol-P2dark-D);
+ color=(colortol-P2dark-E);
+ color=(colortol-P2dark-F);
+ color=(colortol-P2dark-G);
+ },
+ cycle list/.define={colortol-P2dark}{[of colormap=colortol-P2dark]},
+ },
+ /pgfplots/cycle list/colortol-P2dark/.style={/pgfplots/@@colortol set cycle list={colortol-P2dark}},
+ %
+ % -----------------------------------
+ % define palette III colormap, which is just an alias for
+ % the colormap `colortol-P3-5+'
+ /pgfplots/colormap/colortol-P3/.style={
+ colormap={colortol-P3}{
+ color=(colortol-P3-blue),
+ color=(colortol-P3-cyan),
+ color=(colortol-P3-green),
+ color=(colortol-P3-yellow),
+ color=(colortol-P3-red),
+ color=(colortol-P3-pink),
+ },
+ cycle list/.define={colortol-P3}{[of colormap=colortol-P3]},
+ },
+ /pgfplots/cycle list/colortol-P3/.style={/pgfplots/@@colortol set cycle list={colortol-P3}},
+ %
+ % -----------------------------------
+ % define (other) palette III colormaps
+ /pgfplots/colormap/colortol-P3-4-/.style={
+ colormap={colortol-P3-4-}{
+ color=(colortol-P3-blue),
+ color=(colortol-P3-red),
+ color=(colortol-P3-green),
+ color=(colortol-P3-yellow),
+ },
+ cycle list/.define={colortol-P3-4-}{[of colormap=colortol-P3-4-]},
+ },
+ /pgfplots/cycle list/colortol-P3-4-/.style={/pgfplots/@@colortol set cycle list={colortol-P3-4-}},
+ %
+ /pgfplots/colormap/colortol-P3-5+/.style={
+ colormap={colortol-P3-5+}{
+ color=(colortol-P3-blue),
+ color=(colortol-P3-cyan),
+ color=(colortol-P3-green),
+ color=(colortol-P3-yellow),
+ color=(colortol-P3-red),
+ color=(colortol-P3-pink),
+ },
+ cycle list/.define={colortol-P3-5+}{[of colormap=colortol-P3-5+]},
+ },
+ /pgfplots/cycle list/colortol-P3-5+/.style={/pgfplots/@@colortol set cycle list={colortol-P3-5+}},
+ %
+ % ===================================
+ % define colormaps for sequential data
+ /pgfplots/colormap/colortol-seq-3/.style={
+ colormap={colortol-seq-3}{
+ color=(colortol-seq-C);
+ color=(colortol-seq-F);
+ color=(colortol-seq-I);
+ },
+ cycle list/.define={colortol-seq-3}{[of colormap=colortol-seq-3]},
+ },
+ /pgfplots/cycle list/colortol-seq-3/.style={/pgfplots/@@colortol set cycle list={colortol-seq-3}},
+ %
+ /pgfplots/colormap/colortol-seq-4/.style={
+ colormap={colortol-seq-4}{
+ color=(colortol-seq-B);
+ color=(colortol-seq-E);
+ color=(colortol-seq-G);
+ color=(colortol-seq-J);
+ },
+ cycle list/.define={colortol-seq-4}{[of colormap=colortol-seq-4]},
+ },
+ /pgfplots/cycle list/colortol-seq-4/.style={/pgfplots/@@colortol set cycle list={colortol-seq-4}},
+ %
+ /pgfplots/colormap/colortol-seq-5/.style={
+ colormap={colortol-seq-5}{
+ color=(colortol-seq-B);
+ color=(colortol-seq-E);
+ color=(colortol-seq-G);
+ color=(colortol-seq-I);
+ color=(colortol-seq-K);
+ },
+ cycle list/.define={colortol-seq-5}{[of colormap=colortol-seq-5]},
+ },
+ /pgfplots/cycle list/colortol-seq-5/.style={/pgfplots/@@colortol set cycle list={colortol-seq-5}},
+ %
+ /pgfplots/colormap/colortol-seq-6/.style={
+ colormap={colortol-seq-6}{
+ color=(colortol-seq-B);
+ color=(colortol-seq-D);
+ color=(colortol-seq-F);
+ color=(colortol-seq-G);
+ color=(colortol-seq-I);
+ color=(colortol-seq-K);
+ },
+ cycle list/.define={colortol-seq-6}{[of colormap=colortol-seq-6]},
+ },
+ /pgfplots/cycle list/colortol-seq-6/.style={/pgfplots/@@colortol set cycle list={colortol-seq-6}},
+ %
+ /pgfplots/colormap/colortol-seq-7/.style={
+ colormap={colortol-seq-7}{
+ color=(colortol-seq-B);
+ color=(colortol-seq-D);
+ color=(colortol-seq-F);
+ color=(colortol-seq-G);
+ color=(colortol-seq-H);
+ color=(colortol-seq-J);
+ color=(colortol-seq-L);
+ },
+ cycle list/.define={colortol-seq-7}{[of colormap=colortol-seq-7]},
+ },
+ /pgfplots/cycle list/colortol-seq-7/.style={/pgfplots/@@colortol set cycle list={colortol-seq-7}},
+ %
+ /pgfplots/colormap/colortol-seq-8/.style={
+ colormap={colortol-seq-8}{
+ color=(colortol-seq-A);
+ color=(colortol-seq-C);
+ color=(colortol-seq-D);
+ color=(colortol-seq-F);
+ color=(colortol-seq-G);
+ color=(colortol-seq-H);
+ color=(colortol-seq-J);
+ color=(colortol-seq-L);
+ },
+ cycle list/.define={colortol-seq-8}{[of colormap=colortol-seq-8]},
+ },
+ /pgfplots/cycle list/colortol-seq-8/.style={/pgfplots/@@colortol set cycle list={colortol-seq-8}},
+ %
+ /pgfplots/colormap/colortol-seq-9/.style={
+ colormap={colortol-seq-9}{
+ color=(colortol-seq-A);
+ color=(colortol-seq-C);
+ color=(colortol-seq-D);
+ color=(colortol-seq-F);
+ color=(colortol-seq-G);
+ color=(colortol-seq-H);
+ color=(colortol-seq-J);
+ color=(colortol-seq-K);
+ color=(colortol-seq-M);
+ },
+ cycle list/.define={colortol-seq-9}{[of colormap=colortol-seq-9]},
+ },
+ /pgfplots/cycle list/colortol-seq-9/.style={/pgfplots/@@colortol set cycle list={colortol-seq-9}},
+ %
+ % -----------------------------------
+ % define colormaps for diverging data
+ /pgfplots/colormap/colortol-div-3/.style={
+ colormap={colortol-div-3}{
+ color=(colortol-div-E);
+ color=(colortol-div-H);
+ color=(colortol-div-K);
+ },
+ cycle list/.define={colortol-div-3}{[of colormap=colortol-div-3]},
+ },
+ /pgfplots/cycle list/colortol-div-3/.style={/pgfplots/@@colortol set cycle list={colortol-div-3}},
+ %
+ /pgfplots/colormap/colortol-div-4/.style={
+ colormap={colortol-div-4}{
+ color=(colortol-div-A);
+ color=(colortol-div-F);
+ color=(colortol-div-J);
+ color=(colortol-div-N);
+ },
+ cycle list/.define={colortol-div-4}{[of colormap=colortol-div-4]},
+ },
+ /pgfplots/cycle list/colortol-div-4/.style={/pgfplots/@@colortol set cycle list={colortol-div-4}},
+ %
+ /pgfplots/colormap/colortol-div-5/.style={
+ colormap={colortol-div-5}{
+ color=(colortol-div-A);
+ color=(colortol-div-F);
+ color=(colortol-div-H);
+ color=(colortol-div-J);
+ color=(colortol-div-N);
+ },
+ cycle list/.define={colortol-div-5}{[of colormap=colortol-div-5]},
+ },
+ /pgfplots/cycle list/colortol-div-5/.style={/pgfplots/@@colortol set cycle list={colortol-div-5}},
+ %
+ /pgfplots/colormap/colortol-div-6/.style={
+ colormap={colortol-div-6}{
+ color=(colortol-div-C);
+ color=(colortol-div-E);
+ color=(colortol-div-G);
+ color=(colortol-div-I);
+ color=(colortol-div-K);
+ color=(colortol-div-M);
+ },
+ cycle list/.define={colortol-div-6}{[of colormap=colortol-div-6]},
+ },
+ /pgfplots/cycle list/colortol-div-6/.style={/pgfplots/@@colortol set cycle list={colortol-div-6}},
+ %
+ /pgfplots/colormap/colortol-div-7/.style={
+ colormap={colortol-div-7}{
+ color=(colortol-div-C);
+ color=(colortol-div-E);
+ color=(colortol-div-G);
+ color=(colortol-div-H);
+ color=(colortol-div-I);
+ color=(colortol-div-K);
+ color=(colortol-div-M);
+ },
+ cycle list/.define={colortol-div-7}{[of colormap=colortol-div-7]},
+ },
+ /pgfplots/cycle list/colortol-div-7/.style={/pgfplots/@@colortol set cycle list={colortol-div-7}},
+ %
+ /pgfplots/colormap/colortol-div-8/.style={
+ colormap={colortol-div-8}{
+ color=(colortol-div-C);
+ color=(colortol-div-D);
+ color=(colortol-div-F);
+ color=(colortol-div-G);
+ color=(colortol-div-I);
+ color=(colortol-div-J);
+ color=(colortol-div-L);
+ color=(colortol-div-M);
+ },
+ cycle list/.define={colortol-div-8}{[of colormap=colortol-div-8]},
+ },
+ /pgfplots/cycle list/colortol-div-8/.style={/pgfplots/@@colortol set cycle list={colortol-div-8}},
+ %
+ /pgfplots/colormap/colortol-div-9/.style={
+ colormap={colortol-div-9}{
+ color=(colortol-div-C);
+ color=(colortol-div-D);
+ color=(colortol-div-F);
+ color=(colortol-div-G);
+ color=(colortol-div-H);
+ color=(colortol-div-I);
+ color=(colortol-div-J);
+ color=(colortol-div-L);
+ color=(colortol-div-M);
+ },
+ cycle list/.define={colortol-div-9}{[of colormap=colortol-div-9]},
+ },
+ /pgfplots/cycle list/colortol-div-9/.style={/pgfplots/@@colortol set cycle list={colortol-div-9}},
+ %
+ /pgfplots/colormap/colortol-div-10/.style={
+ colormap={colortol-div-10}{
+ color=(colortol-div-B);
+ color=(colortol-div-C);
+ color=(colortol-div-D);
+ color=(colortol-div-F);
+ color=(colortol-div-G);
+ color=(colortol-div-I);
+ color=(colortol-div-J);
+ color=(colortol-div-L);
+ color=(colortol-div-M);
+ color=(colortol-div-O);
+ },
+ cycle list/.define={colortol-div-10}{[of colormap=colortol-div-10]},
+ },
+ /pgfplots/cycle list/colortol-div-10/.style={/pgfplots/@@colortol set cycle list={colortol-div-10}},
+ %
+ /pgfplots/colormap/colortol-div-11/.style={
+ colormap={colortol-div-11}{
+ color=(colortol-div-B);
+ color=(colortol-div-C);
+ color=(colortol-div-D);
+ color=(colortol-div-F);
+ color=(colortol-div-G);
+ color=(colortol-div-H);
+ color=(colortol-div-I);
+ color=(colortol-div-J);
+ color=(colortol-div-L);
+ color=(colortol-div-M);
+ color=(colortol-div-O);
+ },
+ cycle list/.define={colortol-div-11}{[of colormap=colortol-div-11]},
+ },
+ /pgfplots/cycle list/colortol-div-11/.style={/pgfplots/@@colortol set cycle list={colortol-div-11}},
+ %
+ % -----------------
+ /pgfplots/colormap/colortol-div2/.style={
+ colormap={colortol-div2}{
+ color=(colortol-div2-A);
+ color=(colortol-div2-B);
+ color=(colortol-div2-C);
+ color=(colortol-div2-D);
+ color=(colortol-div2-E);
+ color=(colortol-div2-F);
+ color=(colortol-div2-G);
+ color=(colortol-div2-H);
+ color=(colortol-div2-I);
+ },
+ cycle list/.define={colortol-div2}{[of colormap=colortol-div2]},
+ },
+ /pgfplots/cycle list/colortol-div2/.style={/pgfplots/@@colortol set cycle list={colortol-div2}},
+ %
+ /pgfplots/colormap/colortol-div3/.style={
+ colormap={colortol-div3}{
+ color=(colortol-div3-A);
+ color=(colortol-div3-B);
+ color=(colortol-div3-C);
+ color=(colortol-div3-D);
+ color=(colortol-div3-E);
+ color=(colortol-div3-F);
+ color=(colortol-div3-G);
+ color=(colortol-div3-H);
+ color=(colortol-div3-I);
+ },
+ cycle list/.define={colortol-div3}{[of colormap=colortol-div3]},
+ },
+ /pgfplots/cycle list/colortol-div3/.style={/pgfplots/@@colortol set cycle list={colortol-div3}},
+ %
+ % ===================================
+ % define rainbow colormaps
+ /pgfplots/colormap/colortol-rainbow-4/.style={
+ colormap={colortol-rainbow-4}{
+ color=(colortol-rainbow-F);
+ color=(colortol-rainbow-W);
+ color=(colortol-rainbow-AQ);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-4}{[of colormap=colortol-rainbow-4]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-4/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-4}},
+ %
+ /pgfplots/colormap/colortol-rainbow-5/.style={
+ colormap={colortol-rainbow-5}{
+ color=(colortol-rainbow-F);
+ color=(colortol-rainbow-T);
+ color=(colortol-rainbow-AD);
+ color=(colortol-rainbow-AS);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-5}{[of colormap=colortol-rainbow-5]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-5/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-5}},
+ %
+ /pgfplots/colormap/colortol-rainbow-6/.style={
+ colormap={colortol-rainbow-6}{
+ color=(colortol-rainbow-F);
+ color=(colortol-rainbow-Q);
+ color=(colortol-rainbow-AA);
+ color=(colortol-rainbow-AK);
+ color=(colortol-rainbow-AV);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-6}{[of colormap=colortol-rainbow-6]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-6/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-6}},
+ %
+ /pgfplots/colormap/colortol-rainbow-7/.style={
+ colormap={colortol-rainbow-7}{
+ color=(colortol-rainbow-A);
+ color=(colortol-rainbow-J);
+ color=(colortol-rainbow-U);
+ color=(colortol-rainbow-AB);
+ color=(colortol-rainbow-AM);
+ color=(colortol-rainbow-AW);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-7}{[of colormap=colortol-rainbow-7]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-7/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-7}},
+ %
+ /pgfplots/colormap/colortol-rainbow-8/.style={
+ colormap={colortol-rainbow-8}{
+ color=(colortol-rainbow-A);
+ color=(colortol-rainbow-I);
+ color=(colortol-rainbow-R);
+ color=(colortol-rainbow-Y);
+ color=(colortol-rainbow-AG);
+ color=(colortol-rainbow-AO);
+ color=(colortol-rainbow-AX);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-8}{[of colormap=colortol-rainbow-8]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-8/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-8}},
+ %
+ /pgfplots/colormap/colortol-rainbow-9/.style={
+ colormap={colortol-rainbow-9}{
+ color=(colortol-rainbow-A);
+ color=(colortol-rainbow-H);
+ color=(colortol-rainbow-N);
+ color=(colortol-rainbow-W);
+ color=(colortol-rainbow-AB);
+ color=(colortol-rainbow-AI);
+ color=(colortol-rainbow-AR);
+ color=(colortol-rainbow-AY);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-9}{[of colormap=colortol-rainbow-9]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-9/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-9}},
+ %
+ /pgfplots/colormap/colortol-rainbow-10/.style={
+ colormap={colortol-rainbow-10}{
+ color=(colortol-rainbow-A);
+ color=(colortol-rainbow-G);
+ color=(colortol-rainbow-M);
+ color=(colortol-rainbow-T);
+ color=(colortol-rainbow-Z);
+ color=(colortol-rainbow-AF);
+ color=(colortol-rainbow-AL);
+ color=(colortol-rainbow-AS);
+ color=(colortol-rainbow-AZ);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-10}{[of colormap=colortol-rainbow-10]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-10/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-10}},
+ %
+ /pgfplots/colormap/colortol-rainbow-11/.style={
+ colormap={colortol-rainbow-11}{
+ color=(colortol-rainbow-A);
+ color=(colortol-rainbow-F);
+ color=(colortol-rainbow-L);
+ color=(colortol-rainbow-S);
+ color=(colortol-rainbow-X);
+ color=(colortol-rainbow-AC);
+ color=(colortol-rainbow-AH);
+ color=(colortol-rainbow-AN);
+ color=(colortol-rainbow-AT);
+ color=(colortol-rainbow-BA);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-11}{[of colormap=colortol-rainbow-11]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-11/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-11}},
+ %
+ /pgfplots/colormap/colortol-rainbow-12/.style={
+ colormap={colortol-rainbow-12}{
+ color=(colortol-rainbow-A);
+ color=(colortol-rainbow-E);
+ color=(colortol-rainbow-K);
+ color=(colortol-rainbow-P);
+ color=(colortol-rainbow-V);
+ color=(colortol-rainbow-AA);
+ color=(colortol-rainbow-AE);
+ color=(colortol-rainbow-AJ);
+ color=(colortol-rainbow-AP);
+ color=(colortol-rainbow-AU);
+ color=(colortol-rainbow-AB);
+ color=(colortol-rainbow-AD);
+ },
+ cycle list/.define={colortol-rainbow-12}{[of colormap=colortol-rainbow-12]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-12/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-12}},
+ %
+ /pgfplots/colormap/colortol-rainbow-14/.style={
+ colormap={colortol-rainbow-14}{
+ color=(colortol-rainbow-B);
+ color=(colortol-rainbow-C);
+ color=(colortol-rainbow-D);
+ color=(colortol-rainbow-AF);
+ color=(colortol-rainbow-O);
+ color=(colortol-rainbow-AG);
+ color=(colortol-rainbow-AH);
+ color=(colortol-rainbow-AI);
+ color=(colortol-rainbow-AJ);
+ color=(colortol-rainbow-AK);
+ color=(colortol-rainbow-AL);
+ color=(colortol-rainbow-AM);
+ color=(colortol-rainbow-AC);
+ color=(colortol-rainbow-AE);
+ },
+ cycle list/.define={colortol-rainbow-14}{[of colormap=colortol-rainbow-14]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-14/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-14}},
+ %
+ % -----------------------------------
+ % define continuous rainbow colormap
+ /pgfplots/colormap/colortol-rainbow-cont/.style={
+ colormap={colortol-rainbow-cont}{
+ color=(colortol-rainbow-cont-A);
+ color=(colortol-rainbow-cont-B);
+ color=(colortol-rainbow-cont-C);
+ color=(colortol-rainbow-cont-D);
+ color=(colortol-rainbow-cont-E);
+ color=(colortol-rainbow-cont-F);
+ color=(colortol-rainbow-cont-G);
+ color=(colortol-rainbow-cont-H);
+ color=(colortol-rainbow-cont-I);
+ color=(colortol-rainbow-cont-J);
+ color=(colortol-rainbow-cont-K);
+ color=(colortol-rainbow-cont-L);
+ color=(colortol-rainbow-cont-M);
+ color=(colortol-rainbow-cont-N);
+ color=(colortol-rainbow-cont-O);
+ color=(colortol-rainbow-cont-P);
+ color=(colortol-rainbow-cont-Q);
+ color=(colortol-rainbow-cont-R);
+ color=(colortol-rainbow-cont-S);
+ color=(colortol-rainbow-cont-T);
+ color=(colortol-rainbow-cont-U);
+ color=(colortol-rainbow-cont-V);
+ color=(colortol-rainbow-cont-W);
+ color=(colortol-rainbow-cont-X);
+ color=(colortol-rainbow-cont-Y);
+ },
+ cycle list/.define={colortol-rainbow-cont}{[of colormap=colortol-rainbow-cont]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-cont/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-cont}},
+ %
+ % -----------------
+ /pgfplots/colormap/colortol-rainbow-ext-low/.style={
+ colormap={colortol-rainbow-ext-low}{
+ color=(colortol-rainbow-ext-low-A),
+ color=(colortol-rainbow-ext-low-B),
+ color=(colortol-rainbow-ext-low-C),
+ color=(colortol-rainbow-ext-low-D),
+ color=(colortol-rainbow-ext-low-E),
+ color=(colortol-rainbow-ext-low-F),
+ color=(colortol-rainbow-ext-low-G),
+ color=(colortol-rainbow-ext-low-H),
+ },
+ cycle list/.define={colortol-rainbow-ext-low}{[of colormap=colortol-rainbow-ext-low]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-ext-low/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-ext-low}},
+ %
+ /pgfplots/colormap/colortol-rainbow-cont/.style={
+ colormap={colortol-rainbow-cont}{
+ color=(colortol-rainbow-ext-A),
+ color=(colortol-rainbow-ext-B),
+ color=(colortol-rainbow-ext-C),
+ color=(colortol-rainbow-ext-D),
+ color=(colortol-rainbow-ext-E),
+ color=(colortol-rainbow-ext-F),
+ color=(colortol-rainbow-ext-G),
+ color=(colortol-rainbow-ext-H),
+ color=(colortol-rainbow-ext-I),
+ color=(colortol-rainbow-ext-J),
+ color=(colortol-rainbow-ext-K),
+ color=(colortol-rainbow-ext-L),
+ color=(colortol-rainbow-ext-M),
+ color=(colortol-rainbow-ext-N),
+ color=(colortol-rainbow-ext-O),
+ color=(colortol-rainbow-ext-P),
+ color=(colortol-rainbow-ext-Q),
+ color=(colortol-rainbow-ext-R),
+ color=(colortol-rainbow-ext-S),
+ color=(colortol-rainbow-ext-T),
+ color=(colortol-rainbow-ext-U),
+ color=(colortol-rainbow-ext-V),
+ },
+ cycle list/.define={colortol-rainbow-ext}{[of colormap=colortol-rainbow-ext]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-ext/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-ext}},
+ %
+ /pgfplots/colormap/colortol-rainbow-ext-high/.style={
+ colormap={colortol-rainbow-ext-high}{
+ color=(colortol-rainbow-ext-high-A),
+ color=(colortol-rainbow-ext-high-B),
+ color=(colortol-rainbow-ext-high-C),
+ color=(colortol-rainbow-ext-high-D),
+ },
+ cycle list/.define={colortol-rainbow-ext-high}{[of colormap=colortol-rainbow-ext-high]},
+ },
+ /pgfplots/cycle list/colortol-rainbow-ext-high/.style={/pgfplots/@@colortol set cycle list={colortol-rainbow-ext-high}},
+}
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.code.tex
new file mode 100644
index 0000000000..82fdfd6861
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.code.tex
@@ -0,0 +1,638 @@
+%--------------------------------------------
+%
+% 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-2012 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
+% }%
+%--------------------------------------------------
+
+
+\newif\ifpgfplotslibrarysurf@updatebb
+\newif\ifpgfplotslibrarysurf@usecolormap
+\pgfplotslibrarysurf@updatebbtrue
+
+\pgfkeys{%
+ /pgfplots/surf shading/anchor/.initial=\pgfpointorigin,%
+ /pgfplots/surf shading/shading type/.initial=5,% triangles in form of lattice
+ %
+ % If this is true, the embedding picture's bounding box will be updated using
+ % the shading's bounding box.
+ % This bounding box may be (highly!) inaccurate for coons shadings and tensor product shadings.
+ % The 'patch' plot handler disables it and takes control over it explicitly (using interpolation
+ % points rather than bezier control points).
+ /pgfplots/surf shading/update BB/.is if=pgfplotslibrarysurf@updatebb,
+ %
+ % can only have values '' (empty) for binary encoding or
+ % ASCIIHexEncode for base 16 encoding. Use this if some driver
+ % cannot produce binary encoding. This is undocumented; for use in
+ % emergency only.
+ /pgfplots/surf shading/pdf stream filter/.initial=,%
+ %
+ /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,%
+ % columns:
+ /pgfplots/surf shading/cols/.initial=,%
+ /pgfplots/surf shading/colorspace/.initial=rgb,% rgb or cmyk or gray
+ %
+ % the colormap. If this key is empty, we assume that individual
+ % color components are provided for EVERY vertex for which cdata
+ % is expected.
+ /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
+ >>
+ }%
+ },%
+ /pgfplots/surf shading/debug text/.initial=\the\c@pgfplotslibrarysurf@no,
+ /pgfplots/surf shading/every debug coord/.style={
+ circle,
+ draw,
+ fill=yellow,
+ },
+ /pgfplots/surf shading/debug/.is choice,
+ /pgfplots/surf shading/debug/false/.code={%
+ \let\pgfplotslibrarysurfprocesscoordinate=\pgfplotslibrarysurfprocesscoordinate@orig
+ \let\pgfplotslibrarysurfusepath=\pgfplotslibrarysurfusepath@orig
+ },
+ /pgfplots/surf shading/debug/true/.code={%
+ \let\pgfplotslibrarysurfprocesscoordinate=\pgfplotslibrarysurfprocesscoordinate@debug
+ \def\pgfplotslibrarysurfusepath{\pgfusepath{stroke,fill}}
+ },
+ /pgfplots/surf shading/debug/.default=true,
+}%
+
+\def\pgfplotslibrarysurf@corner@sw{\pgfplots@error{This is unavailable until \string\pgfplotslibrarysurfstreamend}}
+\let\pgfplotslibrarysurf@corner@ne\pgfplotslibrarysurf@corner@sw
+
+% parametric colors (colormap) are always in [0,1000]. I
+% 2 bytes suffice for that range.
+\def\pgfplotslibrarysurf@bytespercomponent{2}%
+\def\pgfplotslibrarysurf@bitspercomponent{16}%
+
+\def\pgfplotslibrarysurf@decode{%
+ -16383.999992 16384 % see the docs of \pgfplotsbinaryencodedimenmaplinearly
+ -16383.999992 16384 %
+ \pgfplotslibrarysurf@decode@colors
+}%
+\def\pgfplotslibrarysurf@decode@colors@colormap{%
+ 0 \pgfplotscolormappdfmax % map [0,2^BitsPerComponent-1] linearly to [0 1] for parametric color data
+}%
+\def\pgfplotslibrarysurf@decode@colors@explicit@one@component{%
+ % this is just one component for explicit color data.
+ % it will be replicated for every color component.
+ 0 1 % the target value for color component values.
+}%
+
+\def\pgfplotslibrarysurf@count{0}%
+\newcount\c@pgfplotslibrarysurf@no
+
+% driver specific:
+\def\pgfplotslibrarysurf@initstream{%
+ \edef\pgfplots@loc@TMPa{\pgfkeysvalueof{/pgfplots/surf shading/pdf stream filter}}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \let\pgfplotslibrarysurf@filter@encode=\pgfplots@loc@TMPa
+ \let\pgfplotslibrarysurf@filter@decode=\pgfplotslibrarysurf@filter@encode
+ \fi
+}
+
+\def\pgfplotslibrarysurf@advancestreamlen#1{}%
+
+\def\pgfplotslibrarysurfstreamstart{%
+ \pgfplotslibrarysurfstreamstart@init@colors
+ \pgfkeysgetvalue{/pgfplots/surf shading/shading type}\pgfplotslibrarysurf@type
+ \pgfplotsapplistXglobalnewempty\pgfplotslibrarysurf@binarystream@accum
+ \pgfplotslibrarysurf@initstream
+ \ifx\pgfplotslibrarysurf@filter@encode\pgfutil@empty
+ \def\pgfplotslibrarysurf@filter@encode{binary encoding}%
+ \fi
+ \pgfkeysalso{/pgfplots/bin/\pgfplotslibrarysurf@filter@encode}%
+ %
+ \pgfplotsbinarysetbytes1%
+ \pgfplotsbinaryencodeunsigned{0}% use this method - it respects any special encodings.
+ \let\pgfplots@loc@TMPa=\pgfplotsbinaryresult
+ \ifcase\pgfplotslibrarysurf@type\relax
+ % 0
+ \pgfplotslibrarysurf@initstream@wrongtype
+ \or% 1
+ \pgfplotslibrarysurf@initstream@wrongtype
+ \or% 2
+ \pgfplotslibrarysurf@initstream@wrongtype
+ \or% 3
+ \or% 4
+ % ok, triangle meshes.
+ \let\pgfplotslibrarysurf@edgeflag=\pgfplots@loc@TMPa
+ \or% 5 triangles in lattice form. disable edge flag:
+ \let\pgfplotslibrarysurf@edgeflag=\pgfutil@empty
+ \or% 6 coons patches:
+ \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty
+ \global\c@pgfplotslibrarysurf@no=0
+ \def\pgfplotslibrarysurf@cubicpatch@numverts{12}%
+ \let\pgfplotslibrarysurfstreamcoord=\pgfplotslibrarysurfstreamcoord@cubicpatch
+ \let\pgfplotslibrarysurf@edgeflag=\pgfplots@loc@TMPa
+ \or% 7 full tensor product cubic bezier patches:
+ \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty
+ \global\c@pgfplotslibrarysurf@no=0
+ \def\pgfplotslibrarysurf@cubicpatch@numverts{16}%
+ \let\pgfplotslibrarysurfstreamcoord=\pgfplotslibrarysurfstreamcoord@cubicpatch
+ \let\pgfplotslibrarysurf@edgeflag=\pgfplots@loc@TMPa
+ \else
+ \pgfplotslibrarysurf@initstream@wrongtype
+ \fi
+ %
+ %
+ % we want to establish a bounding box for THIS shading only! Otherwise the pdf XFORM might have a larger bounding box than we want. Is that ok here? Or does it hurt somewhere?
+ \pgf@getpathsizes{\pgfplots@loc@TMPa}%
+ \global\let\pgfplotslibrarysurf@pathsizes@before=\pgfplots@loc@TMPa
+}%
+
+
+\def\pgfplotslibrarysurfstreamstart@init@colors{%
+ %
+ \pgfkeysgetvalue{/pgfplots/surf shading/colormap}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfplotslibrarysurf@usecolormapfalse
+ \else
+ \pgfplotslibrarysurf@usecolormaptrue
+ \fi
+ %
+ \ifpgfplotslibrarysurf@usecolormap
+ \let\pgfplotslibrarysurf@decode@colors=\pgfplotslibrarysurf@decode@colors@colormap
+ \else
+ \pgfplotscolorspacegetcomponents{\pgfkeysvalueof{/pgfplots/surf shading/colorspace}}%
+ \c@pgf@counta=0 %
+ \c@pgf@countb=\pgfplotsretval\relax
+ %
+ \def\pgfplotslibrarysurf@decode@colors{}%
+ \pgfplotslibrarysurf@decode@colors@loop
+ \fi
+ %
+ \pgfplotslibrarysurf@translate@colorspace
+ \let\pgfplotslibrarysurf@colorspace=\pgfplotsretval
+}%
+
+\def\pgfplotslibrarysurf@decode@colors@loop{%
+ \ifnum\c@pgf@counta<\c@pgf@countb
+ %
+ \edef\pgfplotslibrarysurf@decode@colors{%
+ \pgfplotslibrarysurf@decode@colors
+ \pgfplotslibrarysurf@decode@colors@explicit@one@component
+ }%
+ \advance\c@pgf@counta by1 %
+ %
+ \expandafter\pgfplotslibrarysurf@decode@colors@loop
+ \fi
+}%
+
+\def\pgfplotslibrarysurf@initstream@wrongtype{%
+ \pgfplots@error{CRITICAL: shader=interp: got unsupported pdf shading type '\pgfplotslibrarysurf@type'. This may corrupt your pdf!}%
+}%
+\def\pgfplotslibrarysurfstreamend{%
+ \pgfplotsapplistXgloballet\pgfplotslibrarysurf@binarystream=\pgfplotslibrarysurf@binarystream@accum
+ \pgfplotsapplistXglobalnewempty\pgfplotslibrarysurf@binarystream@accum
+ %
+ \pgfplotslibrarysurfstreamend@set@BB
+}
+
+\def\pgfplotslibrarysurfdraw{%
+ \ifx\pgfplotslibrarysurf@binarystream\pgfutil@empty
+ \else
+ \pgfplotslibrarysurfdraw@sys
+ \fi
+}%
+
+\def\pgfplotslibrarysurfstreamend@set@BB{%
+ \xdef\pgfplotslibrarysurf@corner@sw{%
+ \global\pgf@x=\the\pgf@pathminx\space
+ \global\pgf@y=\the\pgf@pathminy\space
+ }%
+ \xdef\pgfplotslibrarysurf@corner@ne{%
+ \global\pgf@x=\the\pgf@pathmaxx\space
+ \global\pgf@y=\the\pgf@pathmaxy\space
+ }%
+ \pgf@setpathsizes\pgfplotslibrarysurf@pathsizes@before
+}%
+
+% ATTENTION: see also \pgfplotslibrarysurfstreamcoord@cubicpatch
+% #1: a pgf point.
+% #2: a color coordinate in the range [0,1000]
+\def\pgfplotslibrarysurfstreamcoord#1#2{%
+ \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercoordinate%
+ \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercoordinate}%
+ \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercoordinate}%
+ %\pgf@process{#1}% this here causes `{retaining \pgf@x}' messages and pollutes the save stack! Avoid it. See \tracingrestores=2
+ \pgfplotslibrarysurfprocesscoordinate{#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@xa=\pgf@x
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgfplotsbinaryencodedimenmaplinearly\pgf@xa
+%\message{POINT \the\c@pgfplots@scanlineindex: ENCODING(x=\the\pgf@x)=\pgfplotsbinaryresult.}\advance\c@pgfplots@scanlineindex by1
+ \t@pgfplots@toka=\expandafter{\pgfplotsbinaryresult}%
+ \pgf@ya=\pgf@y
+ \pgf@sys@bp@correct\pgf@ya%
+ \pgfplotsbinaryencodedimenmaplinearly\pgf@ya
+%\message{ENCODING(y=\the\pgf@y)=\pgfplotsbinaryresult.}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsbinaryresult}%
+ %
+ \pgfplotslibrarysurf@encode@cdata{#2}%
+%\message{\pgfplotsbinaryresult.}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotsbinaryresult}%
+ \ifx\pgfplotslibrarysurf@edgeflag\pgfutil@empty
+ \else
+ % for shading type 4, the edge flag is given for EVERY
+ % coordinate (unlike all other shading types).
+ \pgfplotslibrarysurf@advancestreamlen{1}%
+ \fi
+ \edef\pgfplots@loc@TMPa{\pgfplotslibrarysurf@edgeflag\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \expandafter\pgfplotsapplistXglobalpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum
+}
+
+% defines \pgfplotsbinaryresult to contain the result of a CDATA
+% entry and advances the stream counters.
+\def\pgfplotslibrarysurf@encode@cdata#1{%
+ \ifpgfplotslibrarysurf@usecolormap
+ \pgfplotslibrarysurf@map@to@FFF@colormap{#1}%
+ \else
+ % oh. No cdata. Ok, then encode stuff individually!
+ % We expect data of the form
+ % {<comma-separated-components>}
+ \edef\pgfplots@loc@TMPa{#1}%
+ \def\pgfplotsretval{}%
+ \expandafter\pgfplotslibrarysurf@encode@cdata@loop\pgfplots@loc@TMPa,,%
+ \global\let\pgfplotsbinaryresult=\pgfplotsretval
+ \fi
+}
+
+\def\pgfplotslibrarysurf@encode@cdata@loop#1,{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ %
+ %
+ \pgfplotslibrarysurf@map@to@FFF@component{#1}%
+ \edef\pgfplotsretval{\pgfplotsretval\pgfplotsbinaryresult}%
+ %
+ %
+ % continue loop:
+ \expandafter\pgfplotslibrarysurf@encode@cdata@loop
+ \fi
+}%
+
+% Defines \pgfplotsbinaryresult
+\def\pgfplotslibrarysurf@map@to@FFF@colormap#1{%
+ \begingroup
+ % read fixed point input (in the range [0,1000]).
+ \pgf@xa=#1pt %
+ % 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)=}%
+ \endgroup
+ \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercomponent%
+ \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa
+ \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercomponent}%
+}
+
+% Defines \pgfplotsbinaryresult
+\def\pgfplotslibrarysurf@map@to@FFF@component#1{%
+ \begingroup
+ % read fixed point input (in the range [0,1]).
+ \pgf@xa=#1pt %
+ % convert to integer (= *65536):
+ \c@pgf@counta=\pgf@xa
+ % provide map [0,1] -> [0,2^16-1]
+ % well, there is nothing to do! it was in [0,1], we multiplied by 65536 implicitly... that's it.
+ %
+ % 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)=}%
+ \endgroup
+ \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercomponent%
+ \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa
+ \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercomponent}%
+}
+
+\def\pgfplotslibrarysurf@translate@colorspace{%
+ \pgfkeysgetvalue{/pgfplots/surf shading/colorspace}\pgfplots@loc@TMPd
+ \edef\pgfplots@loc@TMPd{\pgfplots@loc@TMPd}%
+ \def\pgfplots@loc@TMPa{rgb}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd
+ \def\pgfplotsretval{RGB}%
+ \else
+ \def\pgfplots@loc@TMPa{cmyk}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd
+ \def\pgfplotsretval{CMYK}%
+ \else
+ \def\pgfplots@loc@TMPa{cmy}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd
+ \def\pgfplotsretval{CMY}%
+ \else
+ \def\pgfplots@loc@TMPa{gray}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPd
+ \def\pgfplotsretval{Gray}%
+ \else
+ \pgfplots@error{Sorry, the 'surfshading' lib failed to recognise the choice '/pgfplots/surf shading/colorspace=\pgfplots@loc@TMPd'... maybe you misspelled it?}%
+ \def\pgfplotsretval{RGB}%
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+
+\def\pgfplotslibrarysurfusepath{\pgfusepath{fill}}
+\let\pgfplotslibrarysurfusepath@orig=\pgfplotslibrarysurfusepath
+
+% We DO want to protocol the size of the shading. In fact, we NEED a
+% bounding box which contains the whole shading, otherwise it will be
+% clipped. More precisely, it will be packed into a pdf XForm object
+% and that appears to need a correct bounding box.
+%
+% But we do NOT want to update the picture's bounding box, only that
+% of the pdf XForm. The picture's bounding box will be updated as soon
+% as we *use* the shading anyway (in
+% \pgfplotslibrarysurfdrawinpicture). This here takes care of that detail:
+\def\pgfplotslibrarysurf@protocolsizes@#1#2{%
+ \ifpgf@relevantforpicturesize
+ \pgfplots@loc@tmptrue
+ \else
+ \pgfplots@loc@tmpfalse
+ \fi
+ \pgf@relevantforpicturesizefalse
+ \pgf@protocolsizes{#1}{#2}%
+ \ifpgfplots@loc@tmp
+ \pgf@relevantforpicturesizetrue
+ \fi
+}%
+
+\def\pgfplotslibrarysurfprocesscoordinate#1{%
+ #1\relax%
+ \pgfplotslibrarysurf@protocolsizes@{\pgf@x}{\pgf@y}%
+}%
+\let\pgfplotslibrarysurfprocesscoordinate@orig=\pgfplotslibrarysurfprocesscoordinate%
+
+\def\pgfplotslibrarysurfprocesscoordinate@debug#1{%
+ \pgfinterruptpath
+ \scope
+ \pgftransformshift{#1}%
+ \node[/pgfplots/surf shading/every debug coord] at (0pt,0pt) {\pgfkeysvalueof{/pgfplots/surf shading/debug text}};%
+ \endscope
+ \endpgfinterruptpath
+ #1\relax%
+ \pgfplotslibrarysurf@protocolsizes@{\pgf@x}{\pgf@y}%
+}%
+
+% ATTENTION: see also \pgfplotslibrarysurfstreamcoord
+% special routine for coons type patches and cubic tensor product type
+% patches. It has FIRST all vertices,
+% THEN the cdata. Furthermore, it only has 4 CDATA points, but a total
+% of 12 vertices.
+%
+% #1: a pgf point.
+% #2: a color coordinate in the range [0,1000]
+\def\pgfplotslibrarysurfstreamcoord@cubicpatch#1#2{%
+ \pgfplotsbinarysetbytes\pgfplotslibrarysurf@bytespercoordinate%
+ \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercoordinate}%
+ \pgfplotslibrarysurf@advancestreamlen{\pgfplotslibrarysurf@bytespercoordinate}%
+ %\pgf@process{#1}% this here causes `{retaining \pgf@x}' messages and pollutes the save stack! Avoid it. See \tracingrestores=2
+ \pgfplotslibrarysurfprocesscoordinate{#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@xa=\pgf@x
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgfplotsbinaryencodedimenmaplinearly\pgf@xa
+%\message{POINT \the\c@pgfplots@scanlineindex: ENCODING(x=\the\pgf@x)=\pgfplotsbinaryresult.}\advance\c@pgfplots@scanlineindex by1
+ \t@pgfplots@toka=\expandafter{\pgfplotsbinaryresult}%
+ \pgf@ya=\pgf@y
+ \pgf@sys@bp@correct\pgf@ya%
+ \pgfplotsbinaryencodedimenmaplinearly\pgf@ya
+%\message{ENCODING(y=\the\pgf@y)=\pgfplotsbinaryresult.}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsbinaryresult}%
+ \def\pgfplotslibrarysurf@cubicpatch@hascdata{0}%
+ \ifnum\c@pgfplotslibrarysurf@no=0
+ \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}%
+ % prepend edge flag. it is a new patch.
+ \t@pgfplots@toka=\expandafter{\expandafter\pgfplotslibrarysurf@edgeflag\the\t@pgfplots@toka}%
+ \pgfplotslibrarysurf@advancestreamlen{1}%
+ \else
+ \ifnum\c@pgfplotslibrarysurf@no=3
+ \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}%
+ \else
+ \ifnum\c@pgfplotslibrarysurf@no=6
+ \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}%
+ \else
+ \ifnum\c@pgfplotslibrarysurf@no=9
+ \def\pgfplotslibrarysurf@cubicpatch@hascdata{1}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \if1\pgfplotslibrarysurf@cubicpatch@hascdata
+ %
+ \pgfplotslibrarysurf@encode@cdata{#2}%
+ %\message{\pgfplotsbinaryresult.}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotslibrarysurf@cubicpatch@cdata}%
+ \xdef\pgfplotslibrarysurf@cubicpatch@cdata{%
+ \the\t@pgfplots@tokc
+ \pgfplotsbinaryresult
+ }%
+ \fi
+ \global\advance\c@pgfplotslibrarysurf@no by1
+ %
+ \ifnum\pgfplotslibrarysurf@cubicpatch@numverts=\c@pgfplotslibrarysurf@no %finalize patch.
+ \t@pgfplots@tokc=\expandafter{\pgfplotslibrarysurf@cubicpatch@cdata}%
+ \global\let\pgfplotslibrarysurf@cubicpatch@cdata=\pgfutil@empty
+ \global\c@pgfplotslibrarysurf@no=0
+ \else
+ \t@pgfplots@tokc={}%
+ \fi
+ % edge flag is already in \t@pgfplots@toka (if this is the first
+ % vertex)
+ \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \expandafter\pgfplotsapplistXglobalpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum
+}
+
+\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
+ % this statement will modify both the picture's BB and the path's BB
+ % unless we take control.
+ %
+ % Note that the path's BB will eventually be updated into the
+ % picture's BB as well (meaning that 'overlay' is of no use inside
+ % of this group).
+ %
+ % Implement the 'surf shading/update BB' functionality here:
+ \let\pgfplots@@protocolsizes=\pgf@protocolsizes
+ \ifpgfplotslibrarysurf@updatebb
+ \else
+ % NO update to any BB. this implies 'overlay'
+ % *and* disables updates to the path's BB.
+ \def\pgf@protocolsizes##1##2{\relax}%
+ \fi
+ \pgftext[at=\pgfplotslibrarysurf@corner@sw,left,bottom] {%
+ \begingroup
+ % inside of this box, we *always* need bounding boxes.
+ % restore functionality.
+ \let\pgf@protocolsizes=\pgfplots@@protocolsizes
+ \pgfplotslibrarysurfdraw
+ \endgroup
+% 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@sys{%
+ \pgfplots@error{Sorry, surfshading (shader=interp) is NOT available for the selected driver `\pgfsysdriver'.}%
+ }%
+ \def\pgflibrarysurfshadingifactive#1#2{#2}%
+}
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-dvipdfmx.def b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-dvipdfmx.def
new file mode 100644
index 0000000000..4ef45fea3b
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-dvipdfmx.def
@@ -0,0 +1,179 @@
+%--------------------------------------------
+%
+% 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-2012 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/>.
+%
+%--------------------------------------------
+
+\newcount\c@pgfplotslibrarysurf@streamlen
+
+\def\pgfplotslibrarysurf@initstream{%
+ % binary doesn't work due to limitations of DVI.
+ % We NEED an ASCII encoding.
+ %
+ \def\pgfplotslibrarysurf@filter@encode{ASCIIHexEncode}%
+ \def\pgfplotslibrarysurf@filter@decode{ASCIIHexDecode}%
+ \global\c@pgfplotslibrarysurf@streamlen=0 %
+}%
+
+\def\pgfplotslibrarysurf@advancestreamlen#1{%
+ \global\advance\c@pgfplotslibrarysurf@streamlen by#1\relax
+}%
+
+% 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@sys{%
+ \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}%
+ \pgfplotslibrarysurfusepath
+ \endpgfpicture
+ }%
+ %
+ % NOTE : this code was broken due to some driver in pgf. I fixed
+ % that and brought the fix with pgfplots.
+ %
+ % for some reason, dvipdfmx requires to move the XObject
+ % declaration out of the current stream.
+ % Perhaps I should rephrase and say that for some reason, this appears to be
+ % unnecessary for pdftex.
+ %
+ % FIXME : this might have N^2 time due to "box-append"!
+ \pgfutil@insertatbegincurrentpagefrombox
+ {%
+ \special{pdf: bxobj @pgfplotsX\pgfplotslibrarysurf@count\space
+ width \the\wd\pgfutil@tempboxa\space height \the\ht\pgfutil@tempboxa}%
+ \special{pdf: put @resources
+ % write the pattern resource dictionary of the XObject
+ % (only!):
+ << /Pattern << \pgfplots@glob@TMPa >> >>
+ }%
+ %
+ % no need to add the pattern to the page's resource list!
+ % we do not need this:
+ %\pgfutil@addpdfresource@patterns{\pgfplots@glob@TMPa}%
+ \leavevmode
+ \box\pgfutil@tempboxa
+ \special{pdf: exobj}%
+ }%
+ \endgroup
+ \special{pdf: uxobj @pgfplotsX\pgfplotslibrarysurf@count\space}%
+ \pgfplotsutil@advancestringcounter@global\pgfplotslibrarysurf@count
+}
+
+% 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{%
+ % it contain the BINARY bytes. But it is ASCII encoded, see docs of ASCIIHexEncode.
+ \global\multiply\c@pgfplotslibrarysurf@streamlen by2 %
+ %
+ \def\pgfplots@loc@TMPa{%
+ % stream length will be computed automatically
+ /ShadingType \pgfplotslibrarysurf@type\space
+ /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space
+ /BitsPerComponent \pgfplotslibrarysurf@bitspercomponent\space
+ \if5\pgfplotslibrarysurf@type
+ /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols}
+ \else
+ /BitsPerFlag 8
+ \fi
+ /ColorSpace /Device\pgfplotslibrarysurf@colorspace
+ /Decode [\pgfplotslibrarysurf@decode]
+ \ifpgfplotslibrarysurf@usecolormap
+ /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap}
+ \fi
+ \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
+ \else
+ /Filter /\pgfplotslibrarysurf@filter@decode\space
+ \fi
+ /Length \the\c@pgfplotslibrarysurf@streamlen
+ }%
+ %
+ \pgf@process{\pgfpointdiff{\pgfplotslibrarysurf@corner@sw}{\pgfkeysvalueof{/pgfplots/surf shading/anchor}}}%
+ \pgf@sys@bp@correct\pgf@x%
+ \pgf@sys@bp@correct\pgf@y%
+ %
+ %\noexpand\pgfutil@insertatbegincurrentpagefrombox
+ {%
+ \special{pdf: object @pgfplotsShading\pgfplotslibrarysurf@count\space << \pgfplots@loc@TMPa >>
+ stream^^J%
+ \pgfplotslibrarysurf@binarystream
+ endstream
+ }%
+ \special{pdf: close @pgfplotsShading\pgfplotslibrarysurf@count\space }%
+ \special{pdf: object @pgfplotsPattern\pgfplotslibrarysurf@count\space <<
+ /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 @pgfplotsShading\pgfplotslibrarysurf@count
+ >>
+ }%
+ \special{pdf: close @pgfplotsPattern\pgfplotslibrarysurf@count\space }%
+ }%
+ \edef#1{%
+ /pgfplotsSurface\pgfplotslibrarysurf@count\space @pgfplotsPattern\pgfplotslibrarysurf@count
+ }%
+ %
+ % I inlined \pgfsys@setpatterncolored here because it appears to be
+ % natural - and in order to bring this driver to PGF 2.00 (which
+ % would fail otherwise)
+ \pgfsysprotocol@literal{/Pattern cs /pgfplotsSurface\pgfplotslibrarysurf@count\space scn}%
+}
+
+\endinput
+% vi: ft=tex
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-dvips.def b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-dvips.def
new file mode 100644
index 0000000000..69db3f9dbe
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-dvips.def
@@ -0,0 +1,114 @@
+%--------------------------------------------
+%
+% 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@sys{%
+ \pgfpicture
+ \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa%
+ \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa
+ \pgfpathrectanglecorners
+ {\pgfplotslibrarysurf@corner@sw}
+ {\pgfplotslibrarysurf@corner@ne}%
+ \pgfplotslibrarysurfusepath
+ \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 \pgfplotslibrarysurf@type\space
+ /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space
+ /BitsPerComponent \pgfplotslibrarysurf@bitspercomponent\space % Note: this here is the reason why I can't use ASCII85Decode
+ \if5\pgfplotslibrarysurf@type
+ /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols}
+ \else
+ /BitsPerFlag 8
+ \fi
+ /ColorSpace /Device\pgfplotslibrarysurf@colorspace
+ /Decode [\pgfplotslibrarysurf@decode]
+ \ifpgfplotslibrarysurf@usecolormap
+ /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap}
+ \fi
+ /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/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-luatex.def b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-luatex.def
new file mode 100644
index 0000000000..0046daadae
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-luatex.def
@@ -0,0 +1,168 @@
+%--------------------------------------------
+% $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/>.
+%
+%--------------------------------------------
+
+\ifnum\luatexversion<95
+ \immediate\write-1{luatex driver of pgfplots: detected lua version \the\luatexversion; falling back to old pdftex driver^^J}%
+ \input pgflibrarypgfplots.surfshading.pgfsys-pdftex.def
+ \expandafter\endinput
+\fi
+
+
+% 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@sys{%
+ \begingroup
+ %\pgfinterruptpicture% needed?
+ \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}%
+ \pgfplotslibrarysurfusepath
+ \endpgfpicture
+ }%
+ \immediate\saveboxresource resources{
+ /Pattern << \pgfplots@glob@TMPa >> % write the pattern resource dictionary
+ }\pgfutil@tempboxa
+ \leavevmode
+ \useboxresource\lastsavedboxresourceindex
+ %\endpgfinterruptpicture
+ \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{%
+ \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
+ \else
+ % Unfortunately, there is a bug in pdftex/luatex: if we
+ % provide a /Filter as attr, and pdftex compresses the stream,
+ % it overwrites the /Filter argument -- and the viewer cannot
+ % decode the stream. We have to deactivate compression here:
+ \pdfvariable compresslevel=0
+ \fi
+ \def\pgfplots@loc@TMPa{%
+ % stream length will be computed automatically
+ /ShadingType \pgfplotslibrarysurf@type\space
+ /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space
+ /BitsPerComponent \pgfplotslibrarysurf@bitspercomponent\space
+ \if5\pgfplotslibrarysurf@type
+ /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols}
+ \else
+ /BitsPerFlag 8
+ \fi
+ /ColorSpace /Device\pgfplotslibrarysurf@colorspace
+ /Decode [\pgfplotslibrarysurf@decode]
+ \ifpgfplotslibrarysurf@usecolormap
+ /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap}
+ \fi
+ \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
+ \else
+ /Filter /\pgfplotslibrarysurf@filter@decode\space
+ \fi
+ }%
+ %
+ % \pgfplots@loc@TMPb := final boolean luaBinaryEncoding;
+ \pgfutil@IfUndefined{directlua}{%
+ \def\pgfplots@loc@TMPb{0}%
+ }{%
+ \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
+ % ah - we have binary encoding (the standard).
+ \def\pgfplots@loc@TMPb{1}%
+ \else
+ % ah - base 16 ASCII encoding:
+ \def\pgfplots@loc@TMPb{0}%
+ \fi
+ }%
+ \if0\pgfplots@loc@TMPb
+ % no lua binary encoding. Use standard pdftex operations:
+ \immediate\pdfextension obj stream attr {%
+ \pgfplots@loc@TMPa
+ } {%
+ \pgfplotslibrarysurf@binarystream
+ }%
+ \edef\pgfplots@loc@TMPa{\the\numexpr\pdffeedback lastobj\relax}%
+ \else
+ % special handling for luatex binary encoding (see docs for \pgfplotsbinarytoluabinary):
+ \pgfplotsbinarytoluabinary{\pgfplotslibrarysurf@binarystream}%
+ \edef\pgfplots@loc@TMPa{%
+ \directlua{%
+ tex.print(pdf.immediateobj(\pgfplotsDQ stream\pgfplotsDQ , pgfplotsretval, \pgfplotsDQ \pgfplots@loc@TMPa\pgfplotsDQ ));
+ pgfplotsretval=nil;
+ }%
+ }%
+ \fi
+ \pgf@process{\pgfpointdiff{\pgfplotslibrarysurf@corner@sw}{\pgfkeysvalueof{/pgfplots/surf shading/anchor}}}%
+ \pgf@sys@bp@correct\pgf@x%
+ \pgf@sys@bp@correct\pgf@y%
+ \immediate\pdfextension obj {<<
+ /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\numexpr\pdffeedback lastobj\relax\space 0 R
+ }%
+ \pgfsys@setpatterncolored{Plotsurface\pgfplotslibrarysurf@count}%
+ \pgfplotsutil@advancestringcounter@global\pgfplotslibrarysurf@count
+}
+
+\endinput
+% vi: ft=tex
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def
new file mode 100644
index 0000000000..6c78ddf966
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def
@@ -0,0 +1,30 @@
+%--------------------------------------------
+%
+% 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-2012 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/>.
+%
+%--------------------------------------------
+
+\input pgflibrarypgfplots.surfshading.pgfsys-luatex.def
+
+\endinput
+% vi: ft=tex
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def
new file mode 100644
index 0000000000..a56f50ec72
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def
@@ -0,0 +1,162 @@
+%--------------------------------------------
+% $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@sys{%
+ \begingroup
+ %\pgfinterruptpicture% needed?
+ \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}%
+ \pgfplotslibrarysurfusepath
+ \endpgfpicture
+ }%
+ \immediate\pdfxform resources{
+ /Pattern << \pgfplots@glob@TMPa >> % write the pattern resource dictionary
+ }\pgfutil@tempboxa
+ \leavevmode
+ \pdfrefxform\pdflastxform
+ %\endpgfinterruptpicture
+ \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{%
+ \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
+ \else
+ % Unfortunately, there is a bug in pdftex/luatex: if we
+ % provide a /Filter as attr, and pdftex compresses the stream,
+ % it overwrites the /Filter argument -- and the viewer cannot
+ % decode the stream. We have to deactivate compression here:
+ \pdfcompresslevel=0
+ \fi
+ \def\pgfplots@loc@TMPa{%
+ % stream length will be computed automatically
+ /ShadingType \pgfplotslibrarysurf@type\space
+ /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space
+ /BitsPerComponent \pgfplotslibrarysurf@bitspercomponent\space
+ \if5\pgfplotslibrarysurf@type
+ /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols}
+ \else
+ /BitsPerFlag 8
+ \fi
+ /ColorSpace /Device\pgfplotslibrarysurf@colorspace
+ /Decode [\pgfplotslibrarysurf@decode]
+ \ifpgfplotslibrarysurf@usecolormap
+ /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap}
+ \fi
+ \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
+ \else
+ /Filter /\pgfplotslibrarysurf@filter@decode\space
+ \fi
+ %/AntiAlias \space true
+ }%
+ %
+ % \pgfplots@loc@TMPb := final boolean luaBinaryEncoding;
+ \pgfutil@IfUndefined{directlua}{%
+ \def\pgfplots@loc@TMPb{0}%
+ }{%
+ \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty
+ % ah - we have binary encoding (the standard).
+ \def\pgfplots@loc@TMPb{1}%
+ \else
+ % ah - base 16 ASCII encoding:
+ \def\pgfplots@loc@TMPb{0}%
+ \fi
+ }%
+ \if0\pgfplots@loc@TMPb
+ % no lua binary encoding. Use standard pdftex operations:
+ \immediate\pdfobj stream attr {%
+ \pgfplots@loc@TMPa
+ } {%
+ \pgfplotslibrarysurf@binarystream
+ }%
+ \edef\pgfplots@loc@TMPa{\the\pdflastobj}%
+ \else
+ % special handling for luatex binary encoding (see docs for \pgfplotsbinarytoluabinary):
+ \pgfplotsbinarytoluabinary{\pgfplotslibrarysurf@binarystream}%
+ \edef\pgfplots@loc@TMPa{%
+ \directlua{%
+ tex.print(pdf.immediateobj(\pgfplotsDQ stream\pgfplotsDQ , pgfplotsretval, \pgfplotsDQ \pgfplots@loc@TMPa\pgfplotsDQ ));
+ pgfplotsretval=nil;
+ }%
+ }%
+ \fi
+ \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/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-xetex.def b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-xetex.def
new file mode 100644
index 0000000000..1f9245b276
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgflibrarypgfplots.surfshading.pgfsys-xetex.def
@@ -0,0 +1,30 @@
+%--------------------------------------------
+%
+% 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-2012 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/>.
+%
+%--------------------------------------------
+
+\input pgflibrarypgfplots.surfshading.pgfsys-dvipdfmx.def
+
+\endinput
+% vi: ft=tex
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.assert.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplots.assert.code.tex
new file mode 100644
index 0000000000..7ca9e48a74
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.assert.code.tex
@@ -0,0 +1,50 @@
+
+% Token-wise equals; will expand arguments with \edef
+% #1: expected
+% #2: actual
+% #3: message
+\def\pgfplotsassertequalstok#1#2#3{%
+ \edef\pgfplots@assert@a{#1}%
+ \edef\pgfplots@assert@b{#2}%
+ \pgfplotscommandtostring\pgfplots@assert@a\pgfplots@assert@a
+ \pgfplotscommandtostring\pgfplots@assert@b\pgfplots@assert@b
+ \ifx\pgfplots@assert@a\pgfplots@assert@b
+ \else
+ \pgfplotsassertfail{#3 ^^Jexpected '#1'^^J but was '#2'}%
+ \fi
+}%
+
+% Token-wise equals of two MACROS; no expansion
+% #1: expected
+% #2: actual
+% #3: message
+\def\pgfplotsassertequalstoknoexpand#1#2#3{%
+ \ifx#1#2%
+ \else
+ \pgfplotsassertfail{#3 expected ^^J '\meaning#1' but was ^^J '\meaning#2'}%
+ \fi
+}%
+
+\def\pgfplotsassertfail#1{%
+ \pgfplots@error{Assertion failed: #1}%
+}%
+
+% Float-equals
+% #1: expected
+% #2: actual
+% #3: message
+\def\pgfplotsassertequalsfloat#1#2#3{%
+ \edef\pgfplots@assert@a{#1}%
+ \edef\pgfplots@assert@b{#2}%
+ %
+ \pgfmathfloatparsenumber{\pgfplots@assert@a}%
+ \let\pgfplots@assert@a\pgfmathresult
+ %
+ \pgfmathfloatparsenumber{\pgfplots@assert@b}%
+ \let\pgfplots@assert@b\pgfmathresult
+ %
+ \pgfmathfloatifapproxequalrel{\pgfplots@assert@a}{\pgfplots@assert@b}{%
+ }{%
+ \pgfplotsassertfail{#3 ^^Jexpected '#1'^^J but was '#2'}%
+ }%
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.assert.sty b/graphics/pgf/contrib/pgfplots/tex/pgfplots.assert.sty
new file mode 100644
index 0000000000..431c582a62
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.assert.sty
@@ -0,0 +1,2 @@
+
+\input pgfplots.assert.code.tex
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplots.code.tex
new file mode 100644
index 0000000000..f534dc47e8
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.code.tex
@@ -0,0 +1,12647 @@
+%--------------------------------------------
+%
+% 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-2013 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/>.
+%
+%--------------------------------------------
+
+\edef\pgfplots@oldcatcodesemicolon{\the\catcode`\;}%
+\edef\pgfplots@oldcatcodedoublequote{\the\catcode`\"}%
+\catcode`\;=12
+\catcode`\"=12
+
+\input pgfplotscore.code.tex
+\input pgfplotslibrary.code.tex
+\input pgfplotsoldpgfsupp_loader.code.tex
+\input pgfplotsutil.code.tex
+\input pgfplotscolormap.code.tex
+\input pgfplotsstackedplots.code.tex
+\input pgfplotsplothandlers.code.tex
+\input pgfplots.scaling.code.tex
+\input pgfplotscoordprocessing.code.tex
+\input pgfplots.errorbars.code.tex
+\input pgfplots.markers.code.tex
+\input pgfplotsticks.code.tex
+\input pgfplots.paths.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@reverse@legend
+\newif\ifpgfplots@transpose@legend
+\newif\ifpgfplots@allow@reversal@of@rel@axis@cs
+\newif\ifpgfplots@scanline@verbose
+\newif\ifpgfplots@plot@graphics@autoadjustaxis
+\newif\ifpgfplots@scaleuniformly@warning
+\newif\ifpgfplots@hide@obscured@xtick
+\newif\ifpgfplots@hide@obscured@ytick
+\newif\ifpgfplots@hide@obscured@ztick
+\newif\ifpgfplots@enable@tick@line@clipping
+\newcount\pgfplots@numplots
+\newdimen\pgfplots@xmin@reg
+\newdimen\pgfplots@xmax@reg
+\newdimen\pgfplots@ymin@reg
+\newdimen\pgfplots@ymax@reg
+\newdimen\pgfplots@zmin@reg
+\newdimen\pgfplots@zmax@reg
+\newif\ifpgfplots@warn@for@filter@discards
+\newif\ifpgfplots@isuniformtick
+\newif\ifpgfplotsplothandlermesh@patch@type@sampling
+\newif\ifpgfplots@clip@limits@compatmode
+\newif\ifpgfplots@clip@limits@x
+\newif\ifpgfplots@clip@limits@y
+\newif\ifpgfplots@clip@limits@z
+\newif\ifpgfplots@clip
+\newif\ifpgfplots@plot@coords@mathparser
+\pgfplots@plot@coords@mathparsertrue
+\newif\ifpgfplots@enlargelimits
+\newif\ifpgfplots@enlargelimits@respect@figure@size
+\pgfplots@enlargelimits@respect@figure@sizetrue
+\newif\ifpgfplots@enlargelimits@rel@thresh
+\newif\ifpgfplots@enlargelimits@auto
+\newif\ifpgfplots@tickshow
+\newif\ifpgfplots@scatterplotenabled
+\newif\ifpgfplots@xminorticks
+\newif\ifpgfplots@xmajorticks
+\newif\ifpgfplots@yminorticks
+\newif\ifpgfplots@ymajorticks
+\newif\ifpgfplots@zminorticks
+\newif\ifpgfplots@zmajorticks
+\newif\ifpgfplots@xminorgrids
+\newif\ifpgfplots@xmajorgrids
+\newif\ifpgfplots@yminorgrids
+\newif\ifpgfplots@ymajorgrids
+\newif\ifpgfplots@zminorgrids
+\newif\ifpgfplots@zmajorgrids
+\newif\ifpgfplots@clip@marker@paths
+\newif\ifpgfplots@axis@on@top
+\newif\ifpgfplots@separate@axis@lines
+\newif\ifpgfplots@identify@log@minor@tick@pos
+\newif\ifpgfplots@disablelogfilter@x
+\newif\ifpgfplots@disablelogfilter@y
+\newif\ifpgfplots@disablelogfilter@z
+\newif\ifpgfplots@disabledatascaling
+\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
+\newif\ifpgfplots@xticklabel@interval
+\newif\ifpgfplots@yticklabel@interval
+\newif\ifpgfplots@zticklabel@interval
+\newif\ifpgfplots@stacked@reverse
+\newif\ifpgfplots@stacked@plus
+\newif\ifpgfplots@stacked@ignores@zero
+\newif\ifpgfplots@plot@file@skipfirst
+\newif\ifpgfplots@threedim
+\newif\ifpgfplots@curplot@threedim
+\newif\ifpgfplotsthreedim
+\newif\ifpgfplots@curplot@isirrelevant
+\newif\ifpgfplots@colorbar
+\newif\ifpgfplots@deprecated@anchors
+\newif\ifpgfplots@translategnuplot
+\pgfplots@translategnuplottrue
+\let\pgfnodepartimagebox=\pgfnodeparttextbox
+\newif\ifpgfplotsplothandlermesh@internaldepth
+\newif\ifpgfplotsplothandlermesh@hide@refined@edges
+\newif\ifpgfplots@has@cell@picture
+\newif\ifpgfplots@substitute@pgfpoint
+\newif\ifpgfplots@LUA@backend@supported
+\newif\ifpgfplots@threedim@log@sampling
+
+\newif\ifpgfplots@collect@firstplot@astick
+\newif\ifpgfplots@units@use
+
+\def\pgfplots@errorbars@xdirection{0}% pre-init, see below
+\def\pgfplots@errorbars@ydirection{0}%
+\def\pgfplots@errorbars@zdirection{0}%
+
+\def\axisdefaultwidth{240pt}
+\def\axisdefaultheight{207pt}
+
+\def\pgfplotsifaxisthreedim#1#2{\ifpgfplots@threedim #1\else #2\fi}%
+\def\pgfplotsifcurplotthreedim#1#2{\ifpgfplots@curplot@threedim #1\else #2\fi}%
+
+% 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@}{%
+ \pgfkeysifdefined{/pgfplots/cycle list/\string#1/.@cmd}{%
+ \pgfplotsthrow{cycle list instantiation needed}{#1}\pgfeov
+ % note that we cannot instantiate it lazily at this point :-(
+ }{}%
+ #3%
+ }{%
+ #2%
+ }%
+}%
+
+\def\pgfplots@label@upgrade@warning{%
+ \ifpgfplots@threedim
+ \pgfplotswarning{center lines upgrade required}\pgfeov%
+ \global\let\pgfplots@label@upgrade@warning=\relax
+ \fi
+}%
+
+% Creates a named plot cycle list.
+%
+% #1: the name of the final list. Can be used in 'cycle list name'
+% #2: the list entries.
+% It accepts the following formats:
+% \pgfplotscreateplotcyclelist{name}{[of colormap]}%
+% \pgfplotscreateplotcyclelist{name}{[of colormap=<colormap name>]}%
+% \pgfplotscreateplotcyclelist{name}{[colors of colormap={<list> of <colormap name>}]}%
+% \pgfplotscreateplotcyclelist{name}{[indices of colormap={<list> of <colormap name>}]}%
+% \pgfplotscreateplotcyclelist{name}{[* of colormap as it is also available inside of colormap definitions]}
+% \pgfplotscreateplotcyclelist{name}{comma-separated-list}
+% \pgfplotscreateplotcyclelist{name}{'\\'-separated list(requires the last item to be terminated by '\\')}
+\def\pgfplotscreateplotcyclelist#1#2{%
+ \pgfplotscreateplotcyclelist@check@specials{#1}{#2}#2\pgfplots@EOI%
+}%
+
+\def\pgfplotscreateplotcyclelist@check@specials#1#2{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotscreateplotcyclelist@check@specials@{#1}%
+ }{%
+ \pgfplotscreateplotcyclelist@check@specials@@{#1}{#2}%
+ }%
+}%
+\def\pgfplotscreateplotcyclelist@check@specials@#1[#2]{%
+ % the 'of colormap' feature uses the very same functionality as
+ % the related functionality in colormap definitions.
+ % We only replace two routines:
+ %
+ \begingroup
+ \let\pgfplots@createcolormap@special@process@single@define=\pgfplots@createcolormap@special@process@single@define@CYCLE
+ \let\pgfplots@createcolormap@special@process@list@separator=\pgfplots@createcolormap@special@process@list@separator@CYCLE
+ \pgfplots@of@colormap@getresult{#2}%
+ \global\let\pgfplots@glob@TMPa=\pgfplotsretval
+ \endgroup
+ %
+ \t@pgfplots@tokb={#1}%
+ \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplotscreateplotcyclelist{\the\t@pgfplots@tokb}{\the\t@pgfplots@toka}}%
+%\message{#2->^^J \meaning\pgfplots@loc@TMPa^^J}%
+ \pgfplots@loc@TMPa
+ %
+ % FIXME implement:
+ %--------------------------------------------------
+ % \ifnum\pgfplots@glob@TMPb>\pgfkeysvalueof{/pgfplots/@cycle/max size} %
+ % % cycle lists have quadratic runtime. Use small ones!
+ % \pgfplotswarning{cycle list size limit reached}\pgfeov
+ % \breakforeach
+ % \fi
+ %--------------------------------------------------
+ %
+ \pgfutil@ifnextchar\pgfplots@EOI{%
+ \pgfplots@gobble@until@EOI
+ }{%
+ \pgfplotscreateplotcyclelist@check@specials@gobble@error{#2}%
+ }%
+}%
+
+\def\pgfplotscreateplotcyclelist@check@specials@gobble@error#1#2\pgfplots@EOI{%
+ \t@pgfplots@tokb={[#1]}%
+ \t@pgfplots@toka={#2}%
+ \pgfplots@error{Encountered unexpected characters '\the\t@pgfplots@toka' after option '\the\t@pgfplots@tokb' in cycle list definition}%
+}%
+\def\pgfplotscreateplotcyclelist@check@specials@@#1#2#3\pgfplots@EOI{%
+ \expandafter\pgfplots@assign@list\csname pgfp@cyclist@\string#1@\endcsname{#2}%
+}
+
+\pgfqkeys{/pgfplots/@cycle}{%
+ max size/.initial=80,
+}
+
+\pgfplotscreateplotcyclelist{black white}{%
+ every mark/.append style={fill=gray},mark=*\\%
+ every mark/.append style={fill=gray},mark=square*\\%
+ every mark/.append style={fill=gray},mark=otimes*\\%
+ mark=star\\%
+ every mark/.append style={fill=gray},mark=diamond*\\%
+ densely dashed,every mark/.append style={solid,fill=gray},mark=*\\%
+ densely dashed,every mark/.append style={solid,fill=gray},mark=square*\\%
+ densely dashed,every mark/.append style={solid,fill=gray},mark=otimes*\\%
+ densely dashed,every mark/.append style={solid},mark=star\\%
+ densely dashed,every mark/.append style={solid,fill=gray},mark=diamond*\\%
+}
+
+\pgfplotscreateplotcyclelist{color}{%
+ blue,every mark/.append style={fill=blue!80!black},mark=*\\%
+ red,every mark/.append style={fill=red!80!black},mark=square*\\%
+ brown!60!black,every mark/.append style={fill=brown!80!black},mark=otimes*\\%
+ black,mark=star\\%
+ blue,every mark/.append style={fill=blue!80!black},mark=diamond*\\%
+ red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=*\\%
+ brown!60!black,densely dashed,every mark/.append style={solid,fill=brown!80!black},mark=square*\\%
+ black,densely dashed,every mark/.append style={solid,fill=gray},mark=otimes*\\%
+ blue,densely dashed,mark=star,every mark/.append style=solid\\%
+ red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=diamond*\\%
+}
+\pgfplotscreateplotcyclelist{linestyles}{solid,dashed,dotted}
+\pgfplotscreateplotcyclelist{linestyles*}{solid,dashed,dotted,dashdotted,dashdotdotted}
+\pgfplotscreateplotcyclelist{color list}{red,blue,black,yellow,brown,teal,orange,violet,cyan,green!70!black,magenta,gray}
+\pgfplotscreateplotcyclelist{mark list}{%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=square*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=triangle*\\%
+ every mark/.append style={solid},mark=star\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=diamond*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill!40},mark=otimes*\\%
+ every mark/.append style={solid},mark=|\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=pentagon*\\%
+ every mark/.append style={solid},mark=text,text mark=p\\%
+ every mark/.append style={solid},mark=text,text mark=a\\%
+}
+\pgfplotscreateplotcyclelist{mark list*}{%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=square*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=triangle*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=halfsquare*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=pentagon*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=halfcircle*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill,rotate=180},mark=halfdiamond*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill!40},mark=otimes*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=diamond*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=halfsquare right*\\%
+ every mark/.append style={solid,fill=\pgfplots@mark@list@fill},mark=halfsquare left*\\%
+}
+\def\pgfplots@mark@list@fill{\pgfkeysvalueof{/pgfplots/mark list fill}}
+\let\pgfplotsmarklistfill=\pgfplots@mark@list@fill
+\pgfplotscreateplotcyclelist{exotic}{%
+ teal,every mark/.append style={fill=teal!80!black},mark=*\\%
+ orange,every mark/.append style={fill=orange!80!black},mark=square*\\%
+ cyan!60!black,every mark/.append style={fill=cyan!80!black},mark=otimes*\\%
+ red!70!white,mark=star\\%
+ lime!80!black,every mark/.append style={fill=lime},mark=diamond*\\%
+ red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=*\\%
+ yellow!60!black,densely dashed,every mark/.append style={solid,fill=yellow!80!black},mark=square*\\%
+ black,every mark/.append style={solid,fill=gray},mark=otimes*\\%
+ blue,densely dashed,mark=star,every mark/.append style=solid\\%
+ red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=diamond*\\%
+}
+
+
+% backwards compatibility:
+\let\pgfcreateplotcyclelist=\pgfplotscreateplotcyclelist
+\pgfplots@letcsname{pgfp@cyclist@\string\blackwhiteplotspeclist @}={pgfp@cyclist@black white@}%
+\pgfplots@letcsname{pgfp@cyclist@\string\coloredplotspeclist @}={pgfp@cyclist@color@}%
+%%%%
+
+\def\pgfplotsdeprecatedstylecheck#1{%
+ \pgfkeysifdefined{#1/.@cmd}{%
+ \begingroup
+ \edef\pgfkeyscurrentkey{#1}%
+ \pgfkeyssplitpath
+ \pgfplots@warning{Loading deprecated style option
+ \pgfkeyscurrentpath/\pgfkeyscurrentname.
+ Please replace '\string\tikzstyle{\pgfkeyscurrentname}'
+ with '\string\pgfplotsset{\pgfkeyscurrentname/.style={}}'
+ (or '\string\pgfplotsset{\pgfkeyscurrentname/.append style={}}').}%
+ \endgroup
+ \pgfkeysvalueof{#1/.@cmd}\pgfeov
+ }{}%
+}%
+
+\def\pgfplots@scaled@ticks@setargs#1#2{%
+ \pgfutil@in@{:}{#2}%
+ \ifpgfutil@in@
+ \pgfplots@scaled@ticks@setargs@{#1}#2\pgfplots@EOI
+ \else
+ \expandafter\pgfutil@in@\expandafter{\pgfplots@activecolon}{#2}%
+ \ifpgfutil@in@
+ \pgfplots@scaled@ticks@setargs@active{#1}#2\pgfplots@EOI
+ \else
+ \pgfkeysalso{/pgfplots/scaled #1 ticks/#2}%
+ \fi
+ \fi
+}%
+\def\pgfplots@scaled@ticks@setargs@#1#2:#3\pgfplots@EOI{%
+ \pgfkeysalso{/pgfplots/scaled #1 ticks/#2=#3}%
+}
+
+{
+ \catcode`\:=\active
+ \gdef\pgfplots@scaled@ticks@setargs@active#1#2:#3\pgfplots@EOI{%
+ \pgfkeysalso{/pgfplots/scaled #1 ticks/#2=#3}%
+ }
+}
+
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@center\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@south west\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@south\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@south east\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@east\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@north east\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@north\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@north west\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@west\endcsname{1}
+\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@baseline\endcsname{1}
+
+% 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
+ % =lower
+ \else
+ \def\pgfplots@loc@TMPb{upper}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % = upper
+ \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{u}%
+ \else
+ \def\pgfplots@loc@TMPb{default}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % = default
+ \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{}%
+ \else
+ \def\pgfplots@loc@TMPb{left}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % = left [ alias for 'lower' ]
+ \else
+ \def\pgfplots@loc@TMPb{right}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % = right [ alias for 'upper' ]
+ \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{u}%
+ \else
+ \def\pgfplots@loc@TMPb{bottom}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % = bottom [ alias for 'lower' ]
+ \else
+ \def\pgfplots@loc@TMPb{top}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % = top [ alias for 'upper' ]
+ \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
+ \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@{}%
+ \pgfkeysinterruptkeyfilter
+ \pgfplots@cycle@multi@list@#1\nextlist\pgfplots@cycle@multi@list@EOI
+ \endpgfkeysinterruptkeyfilter
+}%
+\def\pgfplots@cycle@multi@list@#1\nextlist{%
+ \pgfkeys@spdef\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
+ % this deals with control sequences inside of #1:
+ \pgfplots@command@to@string\pgfplots@loc@TMPa\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}^^J}%
+ \pgfplotsutil@advancestringcounter\pgfplots@loc@TMPb
+ \fi
+ %
+ \pgfutil@ifnextchar{\pgfplots@cycle@multi@list@EOI}{%
+ \pgfplots@cycle@multi@list@finalize
+ }{%
+ \pgfplots@cycle@multi@list@
+ }%
+}%
+
+\def\pgfplots@colormap@catcodemagic{colormap}
+\pgfplots@command@to@string\pgfplots@colormap@catcodemagic\pgfplots@colormap@catcodemagic
+
+% 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}%
+ \pgfplots@loc@tmptrue
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\pgfutil@in@\expandafter{\pgfplots@colormap@catcodemagic}{#1}%
+ \ifpgfutil@in@
+ % ups! This is actually one of
+ % [of colormap]
+ % [colors of colormap={...}]
+ % [indices of colormap={...}]
+ % which define a single cycle list! This is not what we aim
+ % for. Abort
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \pgfplots@loc@tmpfalse
+ \else
+ \pgfplots@cycle@multi@list@findnamed@@#1 \pgfplots@EOI
+ \fi
+ \fi
+ %
+ \ifpgfplots@loc@tmp
+ \pgfplotsifcyclelistexists{#2}{%
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@cyclist@\string#2@\endcsname%
+ }{%
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ }%
+ \fi
+}
+% #1: <elements> (an integer)
+\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@
+ \c@pgf@countd=0 %
+ \c@pgf@counta=0 %
+ \pgfplotsloop{%
+ \ifnum\c@pgf@counta<\pgfplots@loc@TMPb\relax
+ \pgfplotsloopcontinuetrue
+ \else
+ \pgfplotsloopcontinuefalse
+ \fi
+ }{%
+ \pgfkeysgetvalue{/pgfplots/cycle multi list/@N\the\c@pgf@counta}\pgfplots@cycle@N
+ \ifnum\c@pgf@countd<\pgfplots@cycle@N\relax
+ \c@pgf@countd=\pgfplots@cycle@N\relax
+ \fi
+ \advance\c@pgf@counta by1
+ }%
+ \edef\pgfplots@loc@TMPd{\the\c@pgf@countd}%
+ \pgfkeyslet{/pgfplots/cycle multi list/@maxlen}\pgfplots@loc@TMPd
+%\message{cycle multi list/@maxlen=\pgfplots@loc@TMPd^^J}%
+}%
+
+\def\pgfplots@pgfkeys@set@point@meta@value#1{%
+ %
+ \pgfutil@in@{=}{#1}%
+ \ifpgfutil@in@
+ \def\pgfplots@loc@TMPa##1=##2\pgfplots@EOI{%
+ % remove spaces from ##1 and ##2:
+ \pgfkeys@spdef\pgfplots@loc@TMPa{##1}%
+ \pgfkeys@spdef\pgfplots@loc@TMPb{##2}%
+ %
+ % check if the argument is known:
+ \pgfkeysifdefined{/pgfplots/point meta/\pgfplots@loc@TMPa/.@cmd}{%
+ \def\pgfplots@loc@TMPc{%
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/\pgfplots@loc@TMPa/.@cmd}%
+ }%
+ \expandafter\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPb}%
+ }{%
+ % oh, then it will be a math expression.
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/expr/.@cmd}{#1}%
+ }%
+ }%
+ % disassemble key'='value:
+ \pgfplots@loc@TMPa#1\pgfplots@EOI
+ \else
+ % the following code allows
+ % 'point meta=\thisrow{xcol}' even though
+ % \thisrow might be undefined in the context where keys are set.
+ % I convert the argument to a string.
+ \def\pgfplots@loc@TMPa{#1}%
+ \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ %
+ \pgfkeysifdefined{/pgfplots/point meta/\pgfplots@loc@TMPb/.@cmd}{%
+ % ok, use it!
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/\pgfplots@loc@TMPb/.@cmd}{}%
+ }{%
+ % oh, then it will be a math expression.
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/expr/.@cmd}{#1}%
+ }%
+ \fi
+ %
+ %
+}%
+
+\def\pgfplots@color@of@colormap@parse#1{%
+ \pgfutil@in@{of }{#1}%
+ \ifpgfutil@in@
+ \pgfplots@color@of@colormap@parse@in#1\pgfplots@EOI
+ \else
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@color@of@colormap@name
+ \edef\pgfplots@color@of@colormap@value{#1}%
+ \fi
+}%
+\def\pgfplots@color@of@colormap@parse@in#1of #2\pgfplots@EOI{%
+ \pgfkeys@spdef\pgfplots@color@of@colormap@value{#1}%
+ \edef\pgfplots@color@of@colormap@value{\pgfplots@color@of@colormap@value}%
+ \pgfkeys@spdef\pgfplots@color@of@colormap@name{#2}%
+}
+% defines
+% - \pgfmathresult to be the resulting color.
+% - \pgfplots@color@of@colormap@name the name of the colormap
+\def\pgfplots@color@of@colormap@define#1{%
+ \pgfplots@color@of@colormap@parse{#1}%
+ %
+ \pgfplotscolormapifdefined{\pgfplots@color@of@colormap@name}{}{%
+ % hm... the colormap does not exist? Perhaps someone used '4 of colormap/cool'. Try to define it!
+ \pgfkeysifdefined{/pgfplots/\pgfplots@color@of@colormap@name/.@cmd}{%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@color@of@colormap@name@old
+ \pgfplotsset{\pgfplots@color@of@colormap@name}%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@color@of@colormap@name
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplots@color@of@colormap@name@old
+ }{%
+ % let it run into an error...
+ }%
+ }%
+ %
+ \if m\pgfplots@color@of@colormap@access
+ % colormap access=map
+ \expandafter\pgfplotscolormapfind\expandafter[\pgfplotspointmetatransformedrange]%
+ {\pgfplots@color@of@colormap@value}%
+ {\pgfplots@color@of@colormap@name}%
+ \else
+ \if c\pgfplots@color@of@colormap@access
+ % colormap access=piecewise constant
+ \expandafter\pgfplotscolormapfindpiecewiseconst\expandafter[\pgfplotspointmetatransformedrange]%
+ {\pgfplots@color@of@colormap@value}%
+ {\pgfplots@color@of@colormap@name}%
+ \else
+ % colormap access=direct
+ \pgfplotscolormapgetindex{\pgfplots@color@of@colormap@value}{\pgfplots@color@of@colormap@name}%
+ \fi
+ \fi
+}%
+
+\def\pgfplots@createcolormap@special@process@list@separator@CYCLE{\\}%
+\def\pgfplots@createcolormap@special@process@single@define@CYCLE{%
+ \edef\pgfplotsretval{%
+ /tikz/color/.define=%
+ {.}%
+ {\csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}%
+ {\pgfmathresult},%
+ /tikz/color=.,%
+ }%
+}%
+\def\pgfplots@color@of@colormap#1{%
+ \begingroup
+ \def\pgfplots@createcolormap@special@process@single@define{%
+ \edef\pgfplotsretval{%
+ \noexpand\pgfutil@definecolor{.}{\csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}{\pgfmathresult}%
+ }%
+ \let\pgfplots@createcolormap@special@process@single@define=\relax
+ }%
+ \pgfplots@of@colormap@getresult{#1}%
+ \global\let\pgfplots@glob@TMPa=\pgfplotsretval
+ \endgroup
+ \pgfplots@glob@TMPa
+ \tikzset{color=.}%
+ %\pgfplots@color@of@colormap@define{#1}%
+ %\def\pgfplots@loc@TMPb{\pgfutil@definecolor{.}{\csname pgfpl@cm@\pgfplots@color@of@colormap@name @colspace\endcsname}}%
+ %\expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}%
+ %\tikzset{color=.}%
+}
+
+\newif\ifpgfplots@stackedmode
+
+\newif\ifpgfplotsplothandlermesh@shownormals
+
+\pgfkeys{%
+ % <key name>/.define layer set={<layer list>}{<style definition>}
+ /handlers/.define layer set/.code 2 args={%
+ \pgfkeyssetvalue{\pgfkeyscurrentpath/list}{#1}%
+ \pgfkeysdef{\pgfkeyscurrentpath}{\pgfkeysalso{#2}}%
+ }%
+}
+
+\newif\ifpgfplots@LUA@fail@on@TeX@fallback
+\def\pgfplots@LUA@loglevel@info{4}
+\def\pgfplots@LUA@loglevel@debug{5}
+
+\pgfkeys{%
+ /pgfplots/search path for tikz/.search also={/tikz,/pgfplots},
+ /pgfplots/.is family,
+ /pgfplots/scale/.is family,
+ /pgfplots/legend/.is family,
+ /pgfplots/tick/.is family,
+ /pgfplots/axis/.is family,
+ /pgfplots/descriptions/.is family,
+ /pgfplots/style commands/.is family,
+ /pgfplots/naming commands/.is family,
+ /pgfplots/shared with tikz/.is family,
+ /pgfplots/error bars/.is family,
+ %
+ % pgfplots uses the following (implicit) layers:
+ % context: & associated layer name: \\
+ % background path & axis background \\
+ % grid lines & axis grid \\
+ % tick lines & axis ticks \\
+ % axis lines & axis lines \\
+ % tick labels & axis tick labels \\
+ % plots & main \\
+ % axis descriptions & axis descriptions \\
+ % plot marks & (see 'mark layer')\\
+ % the 'axis on top' key will change that order by moving all plot- and mark-related paths upwards (they are drawn earlier).
+ % None of these layers is mandatory; each can be omitted.
+ % The magic layer name 'discard' can be used as /dev/null layer.
+ %
+ % the <layer set name> must be defined
+ % set layers={<layer set name>}
+ /pgfplots/set layers/.code={%
+ \def\pgfplots@loc@TMPa{#1}%
+ \def\pgfplots@loc@TMPb{none}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \pgfkeysalso{%
+ /pgfplots/activate layers=false,
+ /pgfplots/set layers*={},
+ }%
+ \else
+ \pgfkeysalso{%
+ /pgfplots/activate layers=true,
+ /pgfplots/set layers*={#1},
+ }%
+ \pgfplotsifinaxis{%
+ \pgfkeysalso{/pgfplots/cell picture=if necessary}%
+ }{%
+ % we wrote it outside of an axis. In this case, we can
+ % assume that it prepares multiple axis - which
+ % REQUIRES to disable cell pictures.
+ \pgfkeysalso{/pgfplots/cell picture=false}%
+ }%
+ \fi
+ },
+ % 'activate layers=false' is the same as 'set layers=none'.
+ % However, 'activate layers=true' does not work unless a 'set layers'
+ % has been installed as well.
+ /pgfplots/activate layers/.is if=pgfplots@layered@graphics,
+ /pgfplots/activate layers/.default=true,
+ /pgfplots/set layers*/.code=\pgfplots@key@set@layers{#1},
+ /pgfplots/set layers*/.default={/pgfplots/layers/standard},
+ /pgfplots/@set layers arg/.initial=,
+ /pgfplots/layers/.search also=/pgfplots,
+ /pgfplots/layers/standard/.define layer set={axis background,axis grid,axis ticks,axis lines,axis tick labels,pre main,main,axis descriptions,axis foreground}{
+ grid style= {/pgfplots/on layer=axis grid},
+ tick style= {/pgfplots/on layer=axis ticks},
+ axis line style= {/pgfplots/on layer=axis lines},
+ label style= {/pgfplots/on layer=axis descriptions},
+ legend style= {/pgfplots/on layer=axis descriptions},
+ title style= {/pgfplots/on layer=axis descriptions},
+ colorbar style= {/pgfplots/on layer=axis descriptions},
+ ticklabel style= {/pgfplots/on layer=axis tick labels},
+ axis background@ style={/pgfplots/on layer=axis background},
+ 3d box foreground style={/pgfplots/on layer=axis foreground},
+ },
+ /pgfplots/layers/axis on top/.define layer set={axis background,pre main,main,axis grid,axis ticks,axis lines,axis tick labels,axis descriptions,axis foreground}{
+ /pgfplots/layers/standard
+ },
+ /pgfplots/on layer/.initial=,
+ % mark layer can be 'auto', 'like plot', or a layer name.
+ /pgfplots/mark layer/.initial=,
+ /pgfplots/lua backend/.is if=pgfplots@LUA@backend@supported,
+ /pgfplots/lua backend/.default=true,
+ %
+ /pgfplots/lua debug/.code={%
+ \pgfqkeys{/pgfplots/lua debug}{#1}%
+ },
+ /pgfplots/lua debug/false/.style={/pgfplots/lua debug/off},%
+ /pgfplots/lua debug/off/.code={%
+ \def\pgfplots@LUA@backend@debugmode{off}%
+ \def\pgfplots@LUA@loglevel@debug{5}%
+ \def\pgfplots@LUA@loglevel@info{4}%
+ \pgfplots@LUA@fail@on@TeX@fallbackfalse
+ },
+ /pgfplots/lua debug/off and silent/.code={%
+ \def\pgfplots@LUA@backend@debugmode{off and silent}%
+ \def\pgfplots@LUA@loglevel@debug{5}%
+ \def\pgfplots@LUA@loglevel@info{5}%
+ \pgfplots@LUA@fail@on@TeX@fallbackfalse
+ },
+ %
+ /pgfplots/lua debug/verbose/.code={%
+ \def\pgfplots@LUA@backend@debugmode{verbose}%
+ \def\pgfplots@LUA@loglevel@debug{4}%
+ \def\pgfplots@LUA@loglevel@info{4}%
+ \pgfplots@LUA@fail@on@TeX@fallbackfalse
+ },
+ /pgfplots/lua debug/trace/.code={%
+ \let\pgfplotsutil@directlua=\pgfplotsutil@directlua@trace
+ },%
+ /pgfplots/lua debug/compileerror/.code={%
+ \def\pgfplots@LUA@backend@debugmode{compileerror}%
+ \def\pgfplots@LUA@loglevel@debug{4}%
+ \def\pgfplots@LUA@loglevel@info{4}%
+ \pgfplots@LUA@fail@on@TeX@fallbacktrue
+ },
+ /pgfplots/lua debug/.default=verbose,
+ /pgfplots/lua debug=off,
+ /pgfplots/every axis/.style={},
+ /pgfplots/every axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis}},
+ /pgfplots/every axis/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every axis post/.style={},
+ /pgfplots/every axis post/.belongs to family=/pgfplots/scale,
+ /pgfplots/every semilogx axis/.style={},
+ /pgfplots/every semilogx axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every semilogx axis}},
+ /pgfplots/every semilogx axis/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every semilogy axis/.style={},
+ /pgfplots/every semilogy axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every semilogy axis}},
+ /pgfplots/every semilogy axis/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every loglog axis/.style={},
+ /pgfplots/every loglog axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every loglog axis}},
+ /pgfplots/every loglog axis/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every linear axis/.style={},
+ /pgfplots/every linear axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every linear axis}},
+ /pgfplots/every linear axis/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every axis plot/.style={},
+ /pgfplots/every axis plot/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis plot}},
+ /pgfplots/every axis plot/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every axis plot except legend/.style={},
+ /pgfplots/every axis plot except legend/.belongs to family=/pgfplots/style commands,
+ /pgfplots/axis plot except legend style/.style={/pgfplots/every axis plot except legend/.append style={#1}},
+ /pgfplots/every axis plot post/.style={},
+ /pgfplots/every axis plot post/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis plot}},
+ /pgfplots/trig format plots/.is choice,
+ /pgfplots/trig format plots/deg/.code={\def\pgfplots@set@trig@format@plots{\pgfkeys{/pgf/trig format=deg}}},%
+ /pgfplots/trig format plots/rad/.code={\def\pgfplots@set@trig@format@plots{\pgfkeys{/pgf/trig format=rad}}},%
+ /pgfplots/trig format plots/default/.code={\let\pgfplots@set@trig@format@plots=\relax},%
+ /pgfplots/trig format plots/default,
+ /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/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/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,-0.3em)},/pgfplots/near ticklabel align=outside,anchor=near yticklabel opposite,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/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/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/title shift/.code={\pgfplots@error{Sorry, there is no 'title shift' option. Consider using 'title style={yshift=...}' (or the low level 'every axis title shift' which works only together with the initial 'every axis title' style)}},%
+ /pgfplots/every axis title shift/.initial=6pt,
+ /pgfplots/every axis title/.style={at={(0.5,1)},above,yshift=\pgfkeysvalueof{/pgfplots/every axis title shift}},
+ /pgfplots/every axis title/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis title}},
+ /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,
+ /pgfplots/every inner x axis line/.style={},
+ /pgfplots/every inner y axis line/.style={},
+ /pgfplots/every inner z axis line/.style={},
+ /pgfplots/every outer x axis line/.style={},
+ /pgfplots/every outer y axis line/.style={},
+ /pgfplots/every outer z axis line/.style={},
+ /pgfplots/x axis line style/.style={
+ /pgfplots/every outer x axis line/.append style={#1},
+ /pgfplots/every inner x axis line/.append style={#1},
+ },
+ /pgfplots/y axis line style/.style={
+ /pgfplots/every outer y axis line/.append style={#1},
+ /pgfplots/every inner y axis line/.append style={#1},
+ },
+ /pgfplots/z axis line style/.style={
+ /pgfplots/every outer z axis line/.append style={#1},
+ /pgfplots/every inner z axis line/.append style={#1},
+ },
+ /pgfplots/outer axis line style/.style={
+ /pgfplots/every outer x axis line/.append style={#1},
+ /pgfplots/every outer y axis line/.append style={#1},%
+ /pgfplots/every outer z axis line/.append style={#1}%
+ },
+ /pgfplots/inner axis line style/.style={
+ /pgfplots/every inner x axis line/.append style={#1},
+ /pgfplots/every inner y axis line/.append style={#1},%
+ /pgfplots/every inner z axis line/.append style={#1}%
+ },
+ /pgfplots/axis line style/.style={
+ /pgfplots/inner axis line style={#1},
+ /pgfplots/outer axis line style={#1}%
+ },
+ /pgfplots/separate axis lines/.is if=pgfplots@separate@axis@lines,
+ /pgfplots/separate axis lines/.default=true,
+ /pgfplots/every minor tick/.style={},
+ /pgfplots/every minor tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor tick}},
+ /pgfplots/every minor tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every major tick/.style={},
+ /pgfplots/every major tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major tick}},
+ /pgfplots/every major tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every x tick/.style={},
+ /pgfplots/every x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every x tick}},
+ /pgfplots/every x tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every minor x tick/.style={},
+ /pgfplots/every minor x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor x tick}},
+ /pgfplots/every minor x tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every major x tick/.style={},
+ /pgfplots/every major x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major x tick}},
+ /pgfplots/every major x tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every y tick/.style={},
+ /pgfplots/every y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every y tick}},
+ /pgfplots/every y tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every minor y tick/.style={},
+ /pgfplots/every minor y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor y tick}},
+ /pgfplots/every minor y tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every major y tick/.style={},
+ /pgfplots/every major y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major y tick}},
+ /pgfplots/every major y tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every z tick/.style={},
+ /pgfplots/every z tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every z tick}},
+ /pgfplots/every z tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every minor z tick/.style={},
+ /pgfplots/every minor z tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor z tick}},
+ /pgfplots/every minor z tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every major z tick/.style={},
+ /pgfplots/every major z tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major z tick}},
+ /pgfplots/every major z tick/.belongs to family=/pgfplots/style commands,
+ %/pgfplots/every axis grid/.style={help lines},
+ /pgfplots/every axis grid/.style={thin,black!25},
+ /pgfplots/every axis grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis grid}},
+ /pgfplots/every axis grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every minor grid/.style={},
+ /pgfplots/every minor grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor grid}},
+ /pgfplots/every minor grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every major grid/.style={},
+ /pgfplots/every major grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major grid}},
+ /pgfplots/every major grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every axis x grid/.style={},
+ /pgfplots/every axis x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis x grid}},
+ /pgfplots/every axis x grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every minor x grid/.style={},
+ /pgfplots/every minor x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor x grid}},
+ /pgfplots/every minor x grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every major x grid/.style={},
+ /pgfplots/every major x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major x grid}},
+ /pgfplots/every major x grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every axis y grid/.style={},
+ /pgfplots/every axis y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis y grid}},
+ /pgfplots/every axis y grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every minor y grid/.style={},
+ /pgfplots/every minor y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor y grid}},
+ /pgfplots/every minor y grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every major y grid/.style={},
+ /pgfplots/every major y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major y grid}},
+ /pgfplots/every major y grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every axis z grid/.style={},
+ /pgfplots/every axis z grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis z grid}},
+ /pgfplots/every axis z grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every minor z grid/.style={},
+ /pgfplots/every minor z grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor z grid}},
+ /pgfplots/every minor z grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every major z grid/.style={},
+ /pgfplots/every major z grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major z grid}},
+ /pgfplots/every major z grid/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every tick label/.style={},
+ /pgfplots/every tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every tick label}},
+ /pgfplots/every tick label/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every x tick label/.style={},
+ /pgfplots/every x tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every x tick label}},
+ /pgfplots/every x tick label/.belongs to family=/pgfplots/style commands,
+ /pgfplots/every extra x tick/.style={
+ /pgfplots/log identify minor tick positions=true,
+ /pgfplots/hide obscured x ticks=false,
+ },
+ /pgfplots/every extra x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every extra x tick}},
+ /pgfplots/every extra x tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/extra x tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/extra x tick style/.code={%
+ \pgfkeysalso{/pgfplots/every extra x tick/.append style={#1}}%
+ },
+ /pgfplots/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/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,
+ /pgfplots/every extra y tick/.style={
+ /pgfplots/log identify minor tick positions=true,
+ /pgfplots/hide obscured y ticks=false,
+ },
+ /pgfplots/every extra y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every extra y tick}},
+ /pgfplots/every extra y tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/extra y tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/extra y tick style/.code={%
+ \pgfkeysalso{/pgfplots/every extra y tick/.append style={#1}}%
+ },
+ /pgfplots/every y tick scale label/.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/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,
+ /pgfplots/every extra z tick/.style={
+ /pgfplots/log identify minor tick positions=true,
+ /pgfplots/hide obscured z ticks=false,
+ },
+ /pgfplots/every extra z tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every extra z tick}},
+ /pgfplots/every extra z tick/.belongs to family=/pgfplots/style commands,
+ /pgfplots/extra z tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/extra z tick style/.code={%
+ \pgfkeysalso{/pgfplots/every extra z tick/.append style={#1}}%
+ },
+ % FIXME : this is replicated in 'axis z line=box'!
+ /pgfplots/every z tick scale label/.style={at={(zticklabel* cs:1.2,-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},
+ anchor=north east,%
+ shape=rectangle,%
+ fill=white,%
+ draw=black,
+ at={(0.98,0.98)},
+ },
+ /pgfplots/every axis legend/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis legend}},
+ /pgfplots/every axis legend/.belongs to family=/pgfplots/style commands,
+ %
+ % axis type:
+ /pgfplots/axis type/.initial=rectangle,
+ /pgfplots/axis type/.belongs to family=/pgfplots/scale,
+ /pgfplots/@expected axis cs/.initial=cart,
+ /pgfplots/every rectangle axis/.style={},
+ %
+ % see \pgfplotsdefinecstransform{<from>}{<to>}{<code>}
+ /pgfplots/data cs/.initial=cart,% the coordinate system of provided data. Will be transformed to the axis' internal coordinate system (@expected axis cs).
+ %
+ % Colorbar interface:
+ /pgfplots/colorbar/.is if=pgfplots@colorbar,
+ /pgfplots/colorbar/.default=true,
+ /pgfplots/colorbar to label/.style={/pgfplots/colorbar to name={#1}},
+ /pgfplots/colorbar to name/.initial=,
+ /pgfplots/colorbar source/.code={\pgfplots@error{Sorry, you can only set `colorbar source' inside of \string\addplot\space (or a cycle list)}},
+ /pgfplots/colorbar source/.default=true,
+ /pgfplots/colorbar pos*/.initial=,% one of 'rltb' (right, left, top, bottom). for internal use, to handle checks.
+ /pgfplots/every colorbar global/.style={
+ data cs=cart,
+ axis on top,
+ title=,
+ xlabel=,
+ ylabel=,
+ zlabel=,
+ legend entries=,
+ grid=none,
+ enlargelimits=false,
+ scale only axis,
+ xtick=,
+ xticklabel=,
+ ytick=,
+ yticklabel=,
+ zmin=,
+ zmax=,
+ },
+ /pgfplots/colorbar right/.style={%
+ /pgfplots/colorbar=true,
+ /pgfplots/colorbar pos*=r,
+ /pgfplots/colorbar shift/.style={xshift=0.3cm},
+ /pgfplots/every colorbar/.style={%
+ /pgfplots/every colorbar global,
+ at={(parent axis.right of north east)},
+ anchor=north west,
+ xmin=0,
+ xmax=1,
+ ymin=\pgfkeysvalueof{/pgfplots/point meta min},
+ ymax=\pgfkeysvalueof{/pgfplots/point meta max},
+ height=\pgfkeysvalueof{/pgfplots/parent axis height},%
+ width=\pgfkeysvalueof{/pgfplots/colorbar/width},
+ xtick=\empty,
+ yticklabel pos=right,% ATTENTION: I check for this setting in 'colorbar sampled line', see below!
+ colorbar vertical/lowlevel,
+ }%
+ },%
+ /pgfplots/colorbar left/.style={%
+ /pgfplots/colorbar right,
+ /pgfplots/colorbar pos*=l,
+ /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,% ATTENTION: I check for this setting in 'colorbar sampled line', see below!
+ }%
+ },%
+ /pgfplots/colorbar horizontal/.style={%
+ /pgfplots/colorbar=true,
+ /pgfplots/colorbar pos*=b,
+ /pgfplots/colorbar shift/.style={yshift=-0.3cm},
+ /pgfplots/every colorbar/.style={%
+ /pgfplots/every colorbar global,
+ at={(parent axis.below south west)},
+ anchor=north west,
+ ymin=0,
+ ymax=1,
+ xmin=\pgfkeysvalueof{/pgfplots/point meta min},
+ xmax=\pgfkeysvalueof{/pgfplots/point meta max},
+ width=\pgfkeysvalueof{/pgfplots/parent axis width},%
+ height=\pgfkeysvalueof{/pgfplots/colorbar/width},
+ xticklabel pos=left,
+ ytick=\empty,
+ colorbar horizontal/lowlevel,
+ }%
+ },%
+ %
+ % this here used to be the default up to (and including) pgfplots 1.13.
+ % But it does not support the following use cases:
+ % * 'colormap access=const',
+ % * 'colorbar style={ytick=data}}'
+ % * CMYK shadings
+ % -> deprecated.
+ /pgfplots/colorbar pgfshading/.style={%
+ /pgfplots/colorbar,
+ /pgfplots/colorbar/draw/.code={%
+ \axis[every colorbar,colorbar shift,colorbar=false]
+ \pgfkeysvalueof{/pgfplots/colorbar addplot}%
+ \endaxis
+ },%
+ % 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={%
+ /pgfplots/colorbar addplot=\addplot graphics {};,
+ plot graphics/xmin=0,%
+ plot graphics/xmax=1,
+ plot graphics/ymin=\pgfkeysvalueof{/pgfplots/point meta min},
+ plot graphics/ymax=\pgfkeysvalueof{/pgfplots/point meta max},
+ 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={%
+ /pgfplots/colorbar addplot=\addplot graphics {};,
+ plot graphics/ymin=0,%
+ plot graphics/ymax=1,
+ plot graphics/xmin=\pgfkeysvalueof{/pgfplots/point meta min},
+ plot graphics/xmax=\pgfkeysvalueof{/pgfplots/point meta max},
+ 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 addplot/.initial=\pgfplots@error{COLORBAR SYSTEM UNDEFINED},
+ /pgfplots/colorbar/draw/.code={\pgfplots@error{COLORBAR SYSTEM UNDEFINED}},
+ % --> the default is now 'colorbar sampled', see below:
+ %
+ % instantiate SOME defaults:
+ /pgfplots/colorbar right,
+ /pgfplots/colorbar=false,
+ %
+ /pgfplots/colorbar style/.style={/pgfplots/every colorbar/.append style={#1}},
+ /pgfplots/colorbar/width/.initial=0.5cm,
+ % see \pgfplotscolorbardrawstandalone
+ /pgfplots/colorbar/standalone draw/.code={%
+ \pgfplots@colorbar@get@rid@of@at@parent@axis
+ \pgfplots@colorbar@draw@
+ },
+ /pgfplots/every colorbar sampled line/.style={help lines},
+ /pgfplots/colorbar sampled line style/.style={/pgfplots/every colorbar sampled line/.append style={#1}},
+ /pgfplots/colorbar sampled line/.style={%
+ colorbar,
+ /pgfplots/colorbar/draw/.code={%
+ \axis[
+ cycle list={#1\\},
+ domain=\pgfkeysvalueof{/pgfplots/point meta min}:\pgfkeysvalueof{/pgfplots/point meta max},
+ every colorbar,colorbar shift,colorbar=false]
+ \pgfkeysvalueof{/pgfplots/colorbar addplot}%
+ \endaxis
+ },%
+ /pgfplots/colorbar horizontal/lowlevel/.code={%
+ \pgfkeysgetvalue{/pgfplots/colorbar pos*}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \def\pgfplots@loc@TMPa{b}%
+ \fi
+ \if b\pgfplots@loc@TMPa
+ \pgfkeysalso{axis x line*=bottom}% DEFAULT.
+ \else
+ \pgfkeysalso{axis x line*=top}%
+ \fi
+ \pgfkeysalso{%
+ y axis line style={/pgfplots/every colorbar sampled line},
+ /pgfplots/colorbar addplot={\addplot {0.5};},
+ point meta=x,
+ }%
+ },%
+ /pgfplots/colorbar vertical/lowlevel/.code={%
+ \pgfkeysgetvalue{/pgfplots/colorbar pos*}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \def\pgfplots@loc@TMPa{r}%
+ \fi
+ \if l\pgfplots@loc@TMPa
+ \pgfkeysalso{axis y line*=left}%
+ \else
+ \pgfkeysalso{axis y line*=right}% DEFAULT
+ \fi
+ \pgfkeysalso{%
+ x axis line style={/pgfplots/every colorbar sampled line},
+ /pgfplots/colorbar addplot={\addplot (0.5,x);},
+ point meta=y,
+ }%
+ },%
+ },%
+ /pgfplots/colorbar sampled line/.default={scatter,only marks},
+ %
+ /pgfplots/colorbar as palette/.style={
+ colorbar sampled={
+ surf,
+ colormap access=direct,
+ shader=flat corner,
+ samples=\pgfplotscolormapsizeof
+ {\pgfkeysvalueof{/pgfplots/colormap name}}+1,
+ },
+ colorbar style={
+ point meta min=0,
+ point meta max=\pgfplotscolormapsizeof
+ {\pgfkeysvalueof{/pgfplots/colormap name}},
+ },
+ },
+ %
+ % A style which display exactly 1 tick label for each distinct color. It is similar to 'colorbar as palette'.
+ % It is useful for non-uniform colormaps
+ /pgfplots/colorbar as legend/.style={
+ /pgfplots/colorbar sampled={},%
+ /pgfplots/colorbar style={%
+ % FIXME: these styles could make use of some tuning ...
+ ticklabel style={/pgf/number format/precision=3,/pgf/number format/relative*=3},
+ },
+ /pgfplots/colorbar horizontal/lowlevel/.append code={%
+ \def\pgfplots@colorbar@as@legend@orientation{x}%
+ },
+ /pgfplots/colorbar vertical/lowlevel/.append code={%
+ \def\pgfplots@colorbar@as@legend@orientation{y}%
+ },
+ %
+ % ensure that our values
+ % \pgfplots@colorbar@as@legend@orientation are available while
+ % pgfplots processes the key filtering - otherwise we get
+ % "undefined keys" below
+ /pgfplots/colorbar horizontal/lowlevel/.belongs to family=/pgfplots/scale,
+ /pgfplots/colorbar vertical/lowlevel/.belongs to family=/pgfplots/scale,
+ %
+ /pgfplots/colorbar/draw/.add code={%
+ \begingroup
+ \pgfkeys{/pgf/fpu}%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@CM
+ \begingroup
+ \pgfplotsset{every colorbar}%
+ \pgfmath@smuggleone\pgfplots@colorbar@as@legend@orientation
+ \endgroup
+ \pgfplotscolormapgetpositions[{\pgfkeysvalueof{/pgfplots/point meta min}}:{\pgfkeysvalueof{/pgfplots/point meta max}}]{\pgfplots@CM}%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplotsarraynew\noexpand\positions{\pgfplotsretval}%
+ }%
+ \pgfplots@loc@TMPa
+ %
+ \c@pgf@countd=\pgfplotscolormaplastindexof{\pgfplots@CM}\relax
+ \edef\pgfplots@colorcount{\the\c@pgf@countd}%
+ \advance\c@pgf@countd by-1 %
+ % XXX : this here is tailored for use with
+ % * 'colormap access=const' and
+ % * 'sample for=const'
+ % where the last color is redundant and must not be
+ % displayed in 'colorbar as legend' --> make it more
+ % general!
+ \edef\pgfplots@colorcount@minus@one{\the\c@pgf@countd}%
+ %
+ % accumulate a list of formatted positions into this
+ % variable:
+ \def\pgfplots@loc@TMPc{}%
+ \pgfplotsforeachungrouped \x in {0,...,\pgfplots@colorcount} {%
+ \pgfplotsarrayselect{\x}\of\positions\to\pgfplotsretval
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfmathprintnumber{\pgfplotsretval}}
+ \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPc}%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}%
+ \edef\pgfplots@loc@TMPc{\the\t@pgfplots@toka \the\t@pgfplots@tokb,}%
+ }%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPc}%
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\pgfplotsset{%
+ % this FORGETS the colormap positions intentionally...
+ colormap={@temp@CM}{indices of colormap={0,...,\pgfplots@colorcount@minus@one of \pgfplots@CM}},
+ % ... and normalizes the number range.
+ point meta min=0,point meta max=1000,
+ colorbar style={
+ surf,shader=interp,
+ colormap access=const,
+ \pgfplots@colorbar@as@legend@orientation tick=data,
+ % here we add the positions back into the
+ % tick label:
+ \pgfplots@colorbar@as@legend@orientation ticklabels={\the\t@pgfplots@tokb},
+ },
+ }%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+ }{%
+ % no 'append' section
+ },%
+ },
+ %
+ /pgfplots/colorbar sampled/.style={%
+ /pgfplots/colorbar,
+ /pgfplots/colorbar/draw/.code={%
+ \axis[
+ view={0}{90},
+ cycle list={#1\\},
+ domain=\pgfkeysvalueof{/pgfplots/point meta min}:\pgfkeysvalueof{/pgfplots/point meta max},
+ samples y=2,
+ domain y=0:1,
+ every colorbar,
+ zmin=0,zmax=1,
+ colorbar shift,colorbar=false]
+ \pgfkeysvalueof{/pgfplots/colorbar addplot}%
+ \endaxis
+ },%
+ /pgfplots/colorbar horizontal/lowlevel/.style={%
+ /pgfplots/colorbar addplot={\addplot3 {0};},
+ point meta=x,
+ },%
+ /pgfplots/colorbar vertical/lowlevel/.style={%
+ /pgfplots/colorbar addplot={\addplot3 (y,x,0);},
+ point meta=y,
+ },%
+ },%
+ /pgfplots/colorbar sampled/.default={surf,mark=none,shader=flat},
+% tick options:
+ /pgfplots/xticklabel/.store in= \pgfplots@xticklabel,
+ /pgfplots/xticklabel/.belongs to family=/pgfplots/tick,
+ /pgfplots/xticklabel=,
+ /pgfplots/xticklabels/.belongs to family=/pgfplots/tick,
+ /pgfplots/xticklabels/.code={%
+ \pgfplotslistnew\pgfplots@xticklabels{#1}%
+ \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={%
+ \pgfplotslistnew\pgfplots@yticklabels{#1}%
+ \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=,
+ /pgfplots/zticklabels/.belongs to family=/pgfplots/tick,
+ /pgfplots/zticklabels/.code={%
+ \pgfplotslistnew\pgfplots@zticklabels{#1}%
+ \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=,
+ /pgfplots/x tick label as interval/.is if=pgfplots@xticklabel@interval,
+ /pgfplots/x tick label as interval/.default=true,
+ /pgfplots/x tick label as interval/.belongs to family=/pgfplots/tick,
+ /pgfplots/y tick label as interval/.is if=pgfplots@yticklabel@interval,
+ /pgfplots/y tick label as interval/.default=true,
+ /pgfplots/y tick label as interval/.belongs to family=/pgfplots/tick,
+ /pgfplots/z tick label as interval/.is if=pgfplots@zticklabel@interval,
+ /pgfplots/z tick label as interval/.default=true,
+ /pgfplots/z tick label as interval/.belongs to family=/pgfplots/tick,
+ /pgfplots/extra x tick label/.store in= \pgfplots@extra@xticklabel,
+ /pgfplots/extra x tick label/.belongs to family=/pgfplots/tick,
+ /pgfplots/extra x tick label=,
+ /pgfplots/extra x tick labels/.belongs to family=/pgfplots/tick,
+ /pgfplots/extra x tick labels/.code={%
+ \pgfplotslistnew\pgfplots@extra@xticklabels{#1}%
+ \let\pgfplots@extra@xticklabel=\pgfplots@user@extra@ticklabel@list@x
+ },
+ /pgfplots/extra y tick labels/.code={%
+ \pgfplotslistnew\pgfplots@extra@yticklabels{#1}%
+ \let\pgfplots@extra@yticklabel=\pgfplots@user@extra@ticklabel@list@y
+ },
+ /pgfplots/extra z tick labels/.code={%
+ \pgfplotslistnew\pgfplots@extra@zticklabels{#1}%
+ \let\pgfplots@extra@zticklabel=\pgfplots@user@extra@ticklabel@list@z
+ },
+ /pgfplots/xtick/.store in= \pgfplots@xtick,
+ /pgfplots/xtick/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtick=,
+ /pgfplots/extra x ticks/.store in=\pgfplots@extra@xtick,
+ /pgfplots/extra x ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/extra x ticks=,
+ /pgfplots/xtickten/.store in= \pgfplots@xtickten,
+ /pgfplots/xtickten/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtickten=,
+ /pgfplots/extra y tick label/.store in= \pgfplots@extra@yticklabel,
+ /pgfplots/extra y tick label/.belongs to family=/pgfplots/tick,
+ /pgfplots/extra y tick label=,
+ /pgfplots/ytick/.store in= \pgfplots@ytick,
+ /pgfplots/ytick/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick=,
+ /pgfplots/extra y ticks/.store in=\pgfplots@extra@ytick,
+ /pgfplots/extra y ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/extra y ticks=,
+ /pgfplots/ytickten/.store in= \pgfplots@ytickten,
+ /pgfplots/ytickten/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytickten=,
+ /pgfplots/extra z tick label/.store in= \pgfplots@extra@zticklabel,
+ /pgfplots/extra z tick label/.belongs to family=/pgfplots/tick,
+ /pgfplots/extra z tick label=,
+ /pgfplots/ztick/.store in= \pgfplots@ztick,
+ /pgfplots/ztick/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick=,
+ /pgfplots/extra z ticks/.store in=\pgfplots@extra@ztick,
+ /pgfplots/extra z ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/extra z ticks=,
+ /pgfplots/ztickten/.store in= \pgfplots@ztickten,
+ /pgfplots/ztickten/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztickten=,
+ /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={$\pgfkeysvalueof{/pgfplots/tick scale binop} 10^{#1}$},
+ /pgfplots/ytick scale label code/.belongs to family=/pgfplots/tick,
+ /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},
+ /pgfplots/ytick scale label code={#1}%
+ /pgfplots/ztick scale label code={#1}%
+ },%
+ /pgfplots/scaled x ticks/.code={\pgfplots@scaled@ticks@setargs{x}{#1}},
+ /pgfplots/scaled x ticks/false/.code= {\def\pgfplots@scaled@ticks@x@choice{0}},
+ /pgfplots/scaled x ticks/true/.code= {\def\pgfplots@scaled@ticks@x@choice{1}},
+ /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={$\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}}},
+ /pgfplots/scaled x ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/scaled x ticks=true,
+ /pgfplots/scaled y ticks/.code={\pgfplots@scaled@ticks@setargs{y}{#1}},
+ /pgfplots/scaled y ticks/false/.code= {\def\pgfplots@scaled@ticks@y@choice{0}},
+ /pgfplots/scaled y ticks/true/.code= {\def\pgfplots@scaled@ticks@y@choice{1}},
+ /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={$\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}}},
+ /pgfplots/scaled y ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/scaled y ticks=true,
+ /pgfplots/scaled z ticks/.code={\pgfplots@scaled@ticks@setargs{z}{#1}},
+ /pgfplots/scaled z ticks/false/.code= {\def\pgfplots@scaled@ticks@z@choice{0}},
+ /pgfplots/scaled z ticks/true/.code= {\def\pgfplots@scaled@ticks@z@choice{1}},
+ /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={$\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}}},
+ /pgfplots/scaled z ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/scaled z ticks=true,
+ /pgfplots/scaled ticks/.style={%
+ /pgfplots/scaled x ticks=#1,
+ /pgfplots/scaled y ticks=#1,
+ /pgfplots/scaled z ticks=#1
+ },
+ /pgfplots/scale ticks above exponent/.store in= \pgfplots@scale@ticks@above@exponent,
+ /pgfplots/scale ticks above exponent/.belongs to family=/pgfplots/tick,
+ /pgfplots/scale ticks above exponent=3,
+ /pgfplots/scale ticks below exponent/.store in= \pgfplots@scale@ticks@below@exponent,
+ /pgfplots/scale ticks below exponent/.belongs to family=/pgfplots/tick,
+ /pgfplots/scale ticks below exponent=-1,
+ /pgfplots/minor x tick num/.initial=0,
+ /pgfplots/minor x tick num/.belongs to family=/pgfplots/tick,
+ /pgfplots/minor y tick num/.initial=0,
+ /pgfplots/minor y tick num/.belongs to family=/pgfplots/tick,
+ /pgfplots/minor z tick num/.initial=0,
+ /pgfplots/minor z tick num/.belongs to family=/pgfplots/tick,
+ /pgfplots/minor tick num/.style={
+ /pgfplots/minor x tick num=#1,
+ /pgfplots/minor y tick num=#1,
+ /pgfplots/minor z tick num=#1,
+ },
+ /pgfplots/minor tick num/.belongs to family=/pgfplots/tick,
+ /pgfplots/minor xtick/.initial=,
+ /pgfplots/minor xtick/.belongs to family=/pgfplots/tick,
+ /pgfplots/minor ytick/.initial=,
+ /pgfplots/minor ytick/.belongs to family=/pgfplots/tick,
+ /pgfplots/minor ztick/.initial=,
+ /pgfplots/minor ztick/.belongs to family=/pgfplots/tick,
+ /pgfplots/minor tick/.style={
+ /pgfplots/minor xtick={#1},
+ /pgfplots/minor ytick={#1},
+ /pgfplots/minor ztick={#1},
+ },
+ /pgfplots/minor tick/.belongs to family=/pgfplots/tick,
+ %
+ /pgfplots/subtickwidth/.style= {/pgfplots/minor tick length={#1}},
+ /pgfplots/tickwidth/.style= {/pgfplots/major tick length={#1}},
+ /pgfplots/minor tick length/.belongs to family=/pgfplots/tick,
+ /pgfplots/minor tick length/.initial=0.1cm,
+ /pgfplots/major tick length/.belongs to family=/pgfplots/tick,
+ /pgfplots/major tick length/.initial=0.15cm,
+ %
+ /pgfplots/xtick distance/.initial=,
+ /pgfplots/ytick distance/.initial=,
+ /pgfplots/ztick distance/.initial=,
+ /pgfplots/max space between ticks/.estore in=\axisdefaulttickwidth,
+ /pgfplots/max space between ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/max space between ticks=35,% the maximum space between adjacent ticks (in pt, but don't specify the unit 'pt')
+ /pgfplots/try min ticks/.estore in= \axisdefaulttryminticks,
+ /pgfplots/try min ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/try min ticks=4,
+ /pgfplots/try min ticks log/.estore in= \pgfplots@default@try@minticks@log,
+ /pgfplots/try min ticks log/.belongs to family=/pgfplots/tick,
+ /pgfplots/try min ticks log=3,
+ /pgfplots/log 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={%
+ \begingroup
+ \pgfmathlogtologten@{#1}%
+ \ifpgfplots@identify@log@minor@tick@pos
+ \expandafter\pgfplots@is@log@tick@a@minor@tick@pos\pgfmathresult\relax%
+ \else
+ \pgfplots@log@tick@isminor@tick@posfalse
+ \fi
+ \ifpgfplots@log@tick@isminor@tick@pos
+ \pgfmathprintnumber[sci]{\pgfmathresult}%
+ \else
+ \pgfkeysalso{/pgfplots/log plot exponent style,/pgfplots/log base 10 number format code=\pgfmathresult}%
+ \fi
+ \endgroup
+ },
+ /pgfplots/log number format code/.belongs to family=/pgfplots/tick,
+ /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}}$},
+ %
+ % #1= number formatting options
+ /pgfplots/log ticks with fixed point/.style={
+ /pgfplots/log number format basis/.code 2 args={
+ \begingroup
+ \edef\pgfplots@exponent{##2}%
+ \pgfkeysalso{/pgf/fpu}%
+ % configure the style to avoid crap like
+ % 10,000.2 or 0.000999937 :
+ \pgfqkeys{/pgf/number format}{%
+ % it is rounded relative to its (individual!) order of
+ % magnitude:
+ fixed relative,
+ % ... and with three digits relative to its order of
+ % magnitude. This should avoid rounding problems
+ % since it is applied to each tick number
+ % individually.
+ precision=3,
+ }%
+ \ifdim##1pt=10pt
+ \def\pgfplots@baselog{2.30258509299405}%
+ \else
+ \pgfmathparse{ln(##1)}%
+ \let\pgfplots@baselog=\pgfmathresult
+ \fi
+ \pgfmathparse{exp(\pgfplots@exponent*\pgfplots@baselog)}%
+ \pgfmathprintnumber[#1]\pgfmathresult
+ \endgroup
+ },
+ },
+ % 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,
+ /pgfplots/xtick pos/left/.code ={\def\pgfplots@xtickposnum{1}},
+ /pgfplots/xtick pos/left/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtick pos/right/.code ={\def\pgfplots@xtickposnum{3}},
+ /pgfplots/xtick pos/right/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtick pos/both/.code ={\def\pgfplots@xtickposnum{0}},
+ /pgfplots/xtick pos/both/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtick pos=both,
+ /pgfplots/ytick pos/.is choice,
+ /pgfplots/ytick pos/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick pos/left/.code ={\def\pgfplots@ytickposnum{1}},
+ /pgfplots/ytick pos/left/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick pos/right/.code ={\def\pgfplots@ytickposnum{3}},
+ /pgfplots/ytick pos/right/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick pos/both/.code ={\def\pgfplots@ytickposnum{0}},
+ /pgfplots/ytick pos/both/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick pos=both,
+ /pgfplots/ztick pos/.is choice,
+ /pgfplots/ztick pos/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick pos/left/.code ={\def\pgfplots@ztickposnum{1}},
+ /pgfplots/ztick pos/left/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick pos/right/.code ={\def\pgfplots@ztickposnum{3}},
+ /pgfplots/ztick pos/right/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick pos/both/.code ={\def\pgfplots@ztickposnum{0}},
+ /pgfplots/ztick pos/both/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick pos=both,
+ /pgfplots/tickpos/.style={
+ /pgfplots/xtick pos={#1},
+ /pgfplots/ytick pos={#1},
+ /pgfplots/ztick pos={#1}
+ },
+ /pgfplots/tickpos/.belongs to family=/pgfplots/tick,
+ /pgfplots/tick pos/.style={/pgfplots/tickpos={#1}},
+% sets the tick LABEL position, \pgfplots@[xy]ticklabel@pos
+% to one of
+% 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,
+ /pgfplots/yticklabel pos/.code={\pgfplots@setkey@ticklabelpos{y}{#1}},
+ /pgfplots/yticklabel pos/.belongs to family=/pgfplots/tick,
+ /pgfplots/yticklabel pos=default,
+ /pgfplots/zticklabel pos/.code={\pgfplots@setkey@ticklabelpos{z}{#1}},
+ /pgfplots/zticklabel pos/.belongs to family=/pgfplots/tick,
+ /pgfplots/zticklabel pos=default,
+ /pgfplots/ticklabelpos/.style={/pgfplots/ticklabel pos={#1}},
+ /pgfplots/ticklabel pos/.style={
+ /pgfplots/xticklabel pos={#1},
+ /pgfplots/yticklabel 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
+% center=2
+ /pgfplots/xtick align/.is choice,
+ /pgfplots/xtick align/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtick align/inside/.code ={\def\pgfplots@xtickalignnum{0}},
+ /pgfplots/xtick align/inside/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtick align/outside/.code ={\def\pgfplots@xtickalignnum{1}},
+ /pgfplots/xtick align/outside/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtick align/center/.code ={\def\pgfplots@xtickalignnum{2}},
+ /pgfplots/xtick align/center/.belongs to family=/pgfplots/tick,
+ /pgfplots/xtick align=inside,
+ /pgfplots/ytick align/.is choice,
+ /pgfplots/ytick align/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick align/inside/.code ={\def\pgfplots@ytickalignnum{0}},
+ /pgfplots/ytick align/inside/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick align/outside/.code ={\def\pgfplots@ytickalignnum{1}},
+ /pgfplots/ytick align/outside/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick align/center/.code ={\def\pgfplots@ytickalignnum{2}},
+ /pgfplots/ytick align/center/.belongs to family=/pgfplots/tick,
+ /pgfplots/ytick align=inside,
+ /pgfplots/ztick align/.is choice,
+ /pgfplots/ztick align/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick align/inside/.code ={\def\pgfplots@ztickalignnum{0}},
+ /pgfplots/ztick align/inside/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick align/outside/.code ={\def\pgfplots@ztickalignnum{1}},
+ /pgfplots/ztick align/outside/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick align/center/.code ={\def\pgfplots@ztickalignnum{2}},
+ /pgfplots/ztick align/center/.belongs to family=/pgfplots/tick,
+ /pgfplots/ztick align=inside,
+ /pgfplots/tick align/.belongs to family=/pgfplots/tick,
+ /pgfplots/tick align/.style={%
+ /pgfplots/xtick align=#1,
+ /pgfplots/ytick align=#1,
+ /pgfplots/ztick align=#1,
+ },%
+% 'axis' options:
+ /pgfplots/anchor/.belongs to family=/pgfplots,
+ /pgfplots/anchor/.store in= \pgfplots@anchorname,
+ /pgfplots/anchor=south west,
+ %
+ % will be evaluated for *every* 'near ticklabel' anchor:
+ /pgfplots/near ticklabel align/.is choice,
+ /pgfplots/near ticklabel align/inside/.code= \def\pgfplots@borderanchor@align{0},
+ /pgfplots/near ticklabel align/center/.code= \def\pgfplots@borderanchor@align{1},
+ /pgfplots/near ticklabel align/outside/.code=\def\pgfplots@borderanchor@align{2},
+ /pgfplots/near ticklabel align/center,
+ %
+ /tikz/near ticklabel at/.style={/pgfplots/near ticklabel at=#1},
+ /pgfplots/near ticklabel at/.initial=,
+ %
+ /pgfplots/cell picture/.is choice,
+ /pgfplots/cell picture/false/.code=\def\pgfplots@cell@picture@mode{0},
+ /pgfplots/cell picture/true/.code=\def\pgfplots@cell@picture@mode{1},
+ /pgfplots/cell picture/if necessary/.code=\def\pgfplots@cell@picture@mode{2},
+ /pgfplots/cell picture/true, % backwards compatibility
+ /pgfplots/log origin x/.is choice,
+ /pgfplots/log origin x/infty/.code={\def\pgfplots@log@origin@choice@x{0}},
+ /pgfplots/log origin x/0/.code={\def\pgfplots@log@origin@choice@x{1}},
+ /pgfplots/log origin y/.is choice,
+ /pgfplots/log origin y/infty/.code={\def\pgfplots@log@origin@choice@y{0}},
+ /pgfplots/log origin y/0/.code={\def\pgfplots@log@origin@choice@y{1}},
+ /pgfplots/log origin z/.is choice,
+ /pgfplots/log origin z/infty/.code={\def\pgfplots@log@origin@choice@z{0}},
+ /pgfplots/log origin z/0/.code={\def\pgfplots@log@origin@choice@z{1}},
+ /pgfplots/log origin/.style={%
+ /pgfplots/log origin x={#1},
+ /pgfplots/log origin y={#1},
+ /pgfplots/log origin z={#1},
+ },
+ /pgfplots/log origin=0,
+% tick options:
+ /pgfplots/ticks/.is choice,
+ /pgfplots/ticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/ticks/none/.belongs to family=/pgfplots/tick,
+ /pgfplots/ticks/none/.code={%
+ \pgfplots@xminorticksfalse
+ \pgfplots@yminorticksfalse
+ \pgfplots@zminorticksfalse
+ \pgfplots@xmajorticksfalse
+ \pgfplots@ymajorticksfalse
+ \pgfplots@zmajorticksfalse
+ },
+ /pgfplots/ticks/major/.belongs to family=/pgfplots/tick,
+ /pgfplots/ticks/major/.code={%
+ \pgfplots@xminorticksfalse
+ \pgfplots@yminorticksfalse
+ \pgfplots@zminorticksfalse
+ \pgfplots@xmajortickstrue
+ \pgfplots@ymajortickstrue
+ \pgfplots@zmajortickstrue
+ },
+ /pgfplots/ticks/minor/.belongs to family=/pgfplots/tick,
+ /pgfplots/ticks/minor/.code={%
+ \pgfplots@xminortickstrue
+ \pgfplots@yminortickstrue
+ \pgfplots@zminortickstrue
+ \pgfplots@xmajorticksfalse
+ \pgfplots@ymajorticksfalse
+ \pgfplots@zmajorticksfalse
+ },
+ /pgfplots/ticks/both/.belongs to family=/pgfplots/tick,
+ /pgfplots/ticks/both/.code={%
+ \pgfplots@xminortickstrue
+ \pgfplots@yminortickstrue
+ \pgfplots@zminortickstrue
+ \pgfplots@xmajortickstrue
+ \pgfplots@ymajortickstrue
+ \pgfplots@zmajortickstrue
+ },
+ /pgfplots/ticks=both,
+ /pgfplots/grid/.is choice,
+ /pgfplots/grid/.belongs to family=/pgfplots/tick,
+ /pgfplots/grid/none/.belongs to family=/pgfplots/tick,
+ /pgfplots/grid/none/.code={%
+ \pgfplots@xminorgridsfalse
+ \pgfplots@yminorgridsfalse
+ \pgfplots@zminorgridsfalse
+ \pgfplots@xmajorgridsfalse
+ \pgfplots@ymajorgridsfalse
+ \pgfplots@zmajorgridsfalse
+ },
+ /pgfplots/grid/major/.belongs to family=/pgfplots/tick,
+ /pgfplots/grid/major/.code={%
+ \pgfplots@xminorgridsfalse
+ \pgfplots@yminorgridsfalse
+ \pgfplots@zminorgridsfalse
+ \pgfplots@xmajorgridstrue
+ \pgfplots@ymajorgridstrue
+ \pgfplots@zmajorgridstrue
+ },
+ /pgfplots/grid/minor/.belongs to family=/pgfplots/tick,
+ /pgfplots/grid/minor/.code={%
+ \pgfplots@xminorgridstrue
+ \pgfplots@yminorgridstrue
+ \pgfplots@zminorgridstrue
+ \pgfplots@xmajorgridsfalse
+ \pgfplots@ymajorgridsfalse
+ \pgfplots@zmajorgridsfalse
+ },
+ /pgfplots/grid/both/.belongs to family=/pgfplots/tick,
+ /pgfplots/grid/both/.code={%
+ \pgfplots@xminorgridstrue
+ \pgfplots@yminorgridstrue
+ \pgfplots@zminorgridstrue
+ \pgfplots@xmajorgridstrue
+ \pgfplots@ymajorgridstrue
+ \pgfplots@zmajorgridstrue
+ },
+ /pgfplots/grid=none,
+ /pgfplots/grid/.default=major,
+ /pgfplots/xminorticks/.is if=pgfplots@xminorticks,
+ /pgfplots/xminorticks/.default=true,
+ /pgfplots/xminorticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/xmajorticks/.is if=pgfplots@xmajorticks,
+ /pgfplots/xmajorticks/.default=true,
+ /pgfplots/xmajorticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/yminorticks/.is if=pgfplots@yminorticks,
+ /pgfplots/yminorticks/.default=true,
+ /pgfplots/yminorticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/ymajorticks/.is if=pgfplots@ymajorticks,
+ /pgfplots/ymajorticks/.default=true,
+ /pgfplots/ymajorticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/zminorticks/.is if=pgfplots@zminorticks,
+ /pgfplots/zminorticks/.default=true,
+ /pgfplots/zminorticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/zmajorticks/.is if=pgfplots@zmajorticks,
+ /pgfplots/zmajorticks/.default=true,
+ /pgfplots/zmajorticks/.belongs to family=/pgfplots/tick,
+ /pgfplots/xminorgrids/.is if=pgfplots@xminorgrids,
+ /pgfplots/xminorgrids/.default=true,
+ /pgfplots/xminorgrids/.belongs to family=/pgfplots/tick,
+ /pgfplots/xmajorgrids/.is if=pgfplots@xmajorgrids,
+ /pgfplots/xmajorgrids/.default=true,
+ /pgfplots/xmajorgrids/.belongs to family=/pgfplots/tick,
+ /pgfplots/yminorgrids/.is if=pgfplots@yminorgrids,
+ /pgfplots/yminorgrids/.default=true,
+ /pgfplots/yminorgrids/.belongs to family=/pgfplots/tick,
+ /pgfplots/ymajorgrids/.is if=pgfplots@ymajorgrids,
+ /pgfplots/ymajorgrids/.default=true,
+ /pgfplots/ymajorgrids/.belongs to family=/pgfplots/tick,
+ /pgfplots/zminorgrids/.is if=pgfplots@zminorgrids,
+ /pgfplots/zminorgrids/.default=true,
+ /pgfplots/zminorgrids/.belongs to family=/pgfplots/tick,
+ /pgfplots/zmajorgrids/.is if=pgfplots@zmajorgrids,
+ /pgfplots/zmajorgrids/.default=true,
+ /pgfplots/zmajorgrids/.belongs to family=/pgfplots/tick,
+% legend options:
+ /pgfplots/legend entries/.initial={},
+ /pgfplots/legend entries/.belongs to family=/pgfplots/legend,
+ /pgfplots/legend to label/.style={/pgfplots/legend to name={#1}},
+ /pgfplots/legend to name/.initial=,%
+ /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 cell align/.is choice,
+ /pgfplots/legend cell align/left/.style= {/pgfplots/legend style={cells={anchor=west}}},
+ /pgfplots/legend cell align/right/.style= {/pgfplots/legend style={cells={anchor=east}}},
+ /pgfplots/legend cell align/center/.style= {/pgfplots/legend style={cells={anchor=center}}},
+ /pgfplots/legend columns/.store in=\pgfplots@legend@columns,
+ /pgfplots/legend columns/.belongs to family=/pgfplots/legend,
+ /pgfplots/legend columns=1,
+ /pgfplots/legend plot pos/.is choice,
+ /pgfplots/legend plot pos/.belongs to family=/pgfplots/legend,
+ /pgfplots/legend plot pos/left/.code= {\def\pgfplots@legend@plot@pos{0}},
+ /pgfplots/legend plot pos/left/.belongs to family=/pgfplots/legend,
+ /pgfplots/legend plot pos/right/.code= {\def\pgfplots@legend@plot@pos{1}},
+ /pgfplots/legend plot pos/right/.belongs to family=/pgfplots/legend,
+ /pgfplots/legend plot pos/none/.code= {\def\pgfplots@legend@plot@pos{2}},
+ /pgfplots/legend plot pos/none/.belongs to family=/pgfplots/legend,
+ /pgfplots/legend plot pos=left,
+ /pgfplots/every legend image post/.code={},%
+ /pgfplots/legend image post style/.style={/pgfplots/every legend image post/.append style={#1}},
+ /pgfplots/empty legend/.style={/pgfplots/legend image code/.code=},
+ /pgfplots/line legend/.style={%
+ /pgfplots/legend image code/.code={%
+ \draw[%
+ /pgfplots/mesh=false,%
+ % reset bar options. This is to address the strange
+ % backwards compatibility handling implemented by
+ % \pgfplots@install@local@bar@handlers (see its docs).
+ % This should not hurt at all since 'line legend' is
+ % unsuitable for bar plots anyway.
+ bar width=3pt,%
+ bar shift=0pt,%
+ %
+ mark repeat=2,%
+ mark phase=2,##1]
+ plot coordinates {
+ (0cm,0cm)
+ (0.3cm,0cm)
+ (0.6cm,0cm)%
+ };%
+ }%
+ },
+ /pgfplots/line legend/.style/.code={\pgfplots@error{This style is supposed to be constant.}},%
+ /pgfplots/line legend/.append style/.code={\pgfplots@error{This style is supposed to be constant.}},%
+ /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,
+ /pgfplots/transpose legend/.is if=pgfplots@transpose@legend,
+ /pgfplots/transpose legend/.default=true,
+ /pgfplots/legend transposed/.style={transpose legend=#1},
+ /pgfplots/legend reversed/.style={reverse legend=#1},
+% axis description options:
+ /pgfplots/title/.initial=,
+ /pgfplots/xlabel/.initial=,
+ /pgfplots/ylabel/.initial=,
+ /pgfplots/zlabel/.initial=,
+ /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/extra description/.code=,
+% axis options:
+ /pgfplots/at/.code={%
+ \pgfplots@assert@tikzinternal@exists{tikz@scan@one@point}%
+ \tikz@scan@one@point\pgfplots@set@at#1},
+ /pgfplots/at/.belongs to family=/pgfplots,
+ /pgfplots/trim axis left/.code={%
+ \pgfutil@ifundefined{pgfsettrimleft}{%
+ \pgfplots@error{Sorry, the 'trim axis left' requires a more recent PGF version.}%
+ }{%
+ \pgfkeysalso{/tikz/trim left=(current axis.south west)}%
+ }%
+ },%
+ /tikz/trim axis left/.style={/pgfplots/trim axis left},
+ /pgfplots/trim axis right/.code={%
+ \pgfutil@ifundefined{pgfsettrimleft}{%
+ \pgfplots@error{Sorry, the 'trim axis right' requires a more recent PGF version.}%
+ }{%
+ \pgfkeysalso{/tikz/trim right=(current axis.south east)}%
+ }%
+ },%
+ /tikz/trim axis right/.style={/pgfplots/trim axis right},
+ /pgfplots/clip limits compat/.is if=pgfplots@clip@limits@compatmode,
+ /pgfplots/clip limits if compat/.code={
+ \ifpgfplots@clip@limits@compatmode
+ \else
+ \pgfkeysalso{#1}%
+ \fi
+ },
+ /pgfplots/clip xlimits/.is if=pgfplots@clip@limits@x,
+ /pgfplots/clip xlimits/.default=true,
+ /pgfplots/clip ylimits/.is if=pgfplots@clip@limits@y,
+ /pgfplots/clip ylimits/.default=true,
+ /pgfplots/clip zlimits/.is if=pgfplots@clip@limits@z,
+ /pgfplots/clip zlimits/.default=true,
+ /pgfplots/clip limits/.style={
+ /pgfplots/clip xlimits={#1},%
+ /pgfplots/clip ylimits={#1},%
+ /pgfplots/clip zlimits={#1},%
+ },
+ /pgfplots/clip limits=true,
+ %/pgfplots/clip limits/.belongs to family=/pgfplots,
+ /pgfplots/clip/.is if=pgfplots@clip,
+ /pgfplots/clip/.default=true,
+ /pgfplots/clip=true,
+ /pgfplots/clip mode/.is choice,
+ /pgfplots/clip mode/global/.code= \def\pgfplots@clipmode{1},
+ % this choice is implemented partially only (only for plots, not for
+ % graphical elements):
+ /pgfplots/clip mode/individual/.code= \def\pgfplots@clipmode{2},
+ /pgfplots/clip mode=global,
+ /pgfplots/clip bounding box/.is choice,
+ /pgfplots/clip bounding box/default tikz/.code=\def\pgfplots@clip@BB@mode{0},
+ /pgfplots/clip bounding box/upper bound/.code=\def\pgfplots@clip@BB@mode{1},
+ /pgfplots/clip bounding box=default tikz, % the compat stuff. this is for backw. compat.
+ % will be used if it exists:
+ /pgfplots/axis background/.style={},
+ /pgfplots/axis background style/.style={/pgfplots/axis background/.append style={#1}},
+ %
+ % the 'axis background@' style is an optimization: it will only be
+ % used if 'axis background' is non-empty.
+ % The motivation is that once 'axis background' is non-empty, a
+ % background path will be generated whereas the 'axis background@'
+ % style can be changed at will.
+ /pgfplots/axis background@/.style={},
+ /pgfplots/axis background@ style/.style={/pgfplots/axis background@/.append style={#1}},
+ %
+ % 2d: 'unit vector ratio=2 1 is relative to y axis (x is twice as large as y)
+ % 3d: 'unit vector ratio=2 2 1 is relative to z axis (x and y are both twice as large as z)
+ % missing values are assumed to be 1.
+ /pgfplots/unit vector ratio/.initial=,% empty means 'disable rescale'.
+ /pgfplots/unit vector ratio axis/.initial=,% DEBUG. This is the reference axis which won't be scaled down. This key might vanish.
+ /pgfplots/unit vector ratio*/.style={%
+ /pgfplots/unit vector ratio={#1},
+ /pgfplots/unit rescale keep size=false,
+ },
+ /pgfplots/unit rescale keep size/.is choice,
+ /pgfplots/unit rescale keep size/true/.code={\def\pgfplots@unit@vector@rescale@keep@size{1}},
+ /pgfplots/unit rescale keep size/false/.code={\def\pgfplots@unit@vector@rescale@keep@size{0}},
+ /pgfplots/unit rescale keep size/unless limits declared/.code={\def\pgfplots@unit@vector@rescale@keep@size{2}},
+ /pgfplots/unit rescale keep size/.default=true,
+ /pgfplots/unit rescale keep size=unless limits declared,
+ /pgfplots/axis equal/.is choice,
+ /pgfplots/axis equal/true/.style={
+ /pgfplots/unit vector ratio=1 1 1,
+ /pgfplots/unit rescale keep size=true
+ },
+ /pgfplots/axis equal/false/.style={
+ /pgfplots/unit vector ratio=,
+ },
+ /pgfplots/axis equal/.default=true,
+ /pgfplots/axis equal image/.is choice,
+ /pgfplots/axis equal image/true/.style={%
+ /pgfplots/unit vector ratio=1 1 1,
+ /pgfplots/unit rescale keep size=false
+ },
+ /pgfplots/axis equal image/false/.style={%
+ /pgfplots/unit vector ratio=,
+ },
+ /pgfplots/axis equal image/.default=true,
+ /pgfplots/xmin/.initial=,
+ /pgfplots/xmax/.initial=,
+ /pgfplots/ymin/.initial=,
+ /pgfplots/ymax/.initial=,
+ /pgfplots/zmin/.initial=,
+ /pgfplots/zmax/.initial=,
+ /pgfplots/min/.style={xmin={#1},ymin={#1},zmin={#1}},
+ /pgfplots/max/.style={xmax={#1},ymax={#1},zmax={#1}},
+ /pgfplots/xtickmin/.initial=,
+ /pgfplots/xtickmax/.initial=,
+ /pgfplots/ytickmin/.initial=,
+ /pgfplots/ytickmax/.initial=,
+ /pgfplots/ztickmin/.initial=,
+ /pgfplots/ztickmax/.initial=,
+ /pgfplots/stack plots/.is choice,
+ /pgfplots/stack plots/.belongs to family=/pgfplots,
+ /pgfplots/stack plots/x/.code={\def\pgfplots@stacked@dir{x}\pgfplots@stackedmodetrue},
+ /pgfplots/stack plots/x/.belongs to family=/pgfplots,
+ /pgfplots/stack plots/y/.code={\def\pgfplots@stacked@dir{y}\pgfplots@stackedmodetrue},
+ /pgfplots/stack plots/y/.belongs to family=/pgfplots,
+ /pgfplots/stack plots/z/.code={\def\pgfplots@stacked@dir{z}\pgfplots@stackedmodetrue},
+ /pgfplots/stack plots/z/.belongs to family=/pgfplots,
+ /pgfplots/stack plots/false/.code={\pgfplots@stackedmodefalse},
+ /pgfplots/stack plots/false/.belongs to family=/pgfplots,
+ /pgfplots/stack plots=false,
+ /pgfplots/stack negative/.is choice,
+ /pgfplots/stack negative/on previous/.code={\def\pgfplots@stacked@negative@mode{P}},
+ /pgfplots/stack negative/separate/.code={\def\pgfplots@stacked@negative@mode{S}},
+ /pgfplots/stack negative/on previous,
+ /pgfplots/reverse stacked plots/.is if=pgfplots@stacked@reverse,
+ /pgfplots/reverse stacked plots/.belongs to family=/pgfplots,
+ /pgfplots/reverse stacked plots/.default=true,
+ /pgfplots/reverse stacked plots=true,
+ /pgfplots/stack dir/.is choice,
+ /pgfplots/stack dir/.belongs to family=/pgfplots,
+ /pgfplots/stack dir/plus/.code={\pgfplots@stacked@plustrue},
+ /pgfplots/stack dir/plus/.belongs to family=/pgfplots,
+ /pgfplots/stack dir/minus/.code={\pgfplots@stacked@plusfalse},
+ /pgfplots/stack dir/minus/.belongs to family=/pgfplots,
+ /pgfplots/stack dir=plus,
+ /pgfplots/stacked ignores zero/.is if=pgfplots@stacked@ignores@zero,
+ /pgfplots/stacked ignores zero/.default=true,
+ %
+ % The purpose of the following key is to control the case 'stacked ignores zero=true'
+ % (it has no effect if 'stacked ignores zero=false').
+ % The feature "stacked ignores zero" is active *if and only if*
+ % 1. stacked ignores zero=true and
+ % 2. stacked ignores zero/<phasename>=true
+ % Valid <phasename>s are 'default', 'markers', 'errorbars'.
+ /pgfplots/stacked ignores zero/\pgfplotsaxis@visphase@name@default/.initial=true,
+ /pgfplots/stacked ignores zero/\pgfplotsaxis@visphase@name@markers/.initial=true,
+ /pgfplots/stacked ignores zero/\pgfplotsaxis@visphase@name@errorbars/.initial=false,
+ /pgfplots/filter discard warning/.is if=pgfplots@warn@for@filter@discards,
+ /pgfplots/filter discard warning=true,
+ /pgfplots/pre filter/.code={},
+ /pgfplots/x filter/.code={},
+ /pgfplots/x filter/.belongs to family=/pgfplots,
+ /pgfplots/y filter/.code={},
+ /pgfplots/y filter/.belongs to family=/pgfplots,
+ /pgfplots/z filter/.code={},
+ /pgfplots/z filter/.belongs to family=/pgfplots,
+ /pgfplots/filter point/.code=,
+ /pgfplots/x filter/.expression/.code=\pgfplots@install@filter@expression{x filter}{#1},
+ /pgfplots/y filter/.expression/.code=\pgfplots@install@filter@expression{y filter}{#1},
+ /pgfplots/z filter/.expression/.code=\pgfplots@install@filter@expression{z filter}{#1},
+ /pgfplots/x filter/.append expression/.code=\pgfplots@install@filter@expression@append{x filter}{#1},
+ /pgfplots/y filter/.append expression/.code=\pgfplots@install@filter@expression@append{y filter}{#1},
+ /pgfplots/z filter/.append expression/.code=\pgfplots@install@filter@expression@append{z filter}{#1},
+ /pgfplots/restrict x to domain/.style={/pgfplots/@restrict to domain={x}{}{#1}{0}},%
+ /pgfplots/restrict y to domain/.style={/pgfplots/@restrict to domain={y}{}{#1}{0}},%
+ /pgfplots/restrict z to domain/.style={/pgfplots/@restrict to domain={z}{}{#1}{0}},%
+ /pgfplots/restrict expr to domain/.style 2 args={/pgfplots/@restrict to domain={x}{#1}{#2}{0}},%
+ /pgfplots/restrict x to domain*/.style={/pgfplots/@restrict to domain={x}{}{#1}{1}},%
+ /pgfplots/restrict y to domain*/.style={/pgfplots/@restrict to domain={y}{}{#1}{1}},%
+ /pgfplots/restrict z to domain*/.style={/pgfplots/@restrict to domain={z}{}{#1}{1}},%
+ /pgfplots/restrict expr to domain*/.style 2 args={/pgfplots/@restrict to domain={x}{#1}{#2}{1}},%
+ % '#1': the filter to install (like 'x', 'y', or even 'hist/data')
+ % '#2': a mathematical expression (or empty)
+ % '#3': the interval. must be numeric currently, and of the form min:max
+ % '#4': bAssignLimits=0|1. if #4=1, any coordinate outside of the
+ % allowed domain will take the domain boundary as value. If #4=0,
+ % any coordinate outside of the allowed domain will get 'inf' or
+ % '-inf'.
+ /pgfplots/@restrict to domain/.code args={#1#2#3#4}{%
+ \if0#4%
+ \pgfkeysalso{/pgfplots/unbounded coords=jump}%
+ \fi
+ % when invoked, ##1 and ##2 will be floats:
+ \def\pgfplots@loc@TMPb##1:##2\relax{%
+ \pgfkeysalso{%
+ /pgfplots/#1 filter/.append code={%
+ \pgfplots@warn@if@log@basis@unset{#1}{domain restriction}%
+ \let\pgfplots@restrict@to@domain@orig=\pgfmathresult
+ \ifx\pgfmathresult\pgfutil@empty
+ % the input value is empty... skip it!
+ \else
+ \def\pgfplots@restrict@to@domain@tmp{#2}%
+ \ifx\pgfplots@restrict@to@domain@tmp\pgfutil@empty
+ % we don't have an expression.
+ \else
+ % evaluate the expression!
+ \pgfmathparse{#2}%
+ \fi
+ \pgfplotscoordmath{default}{parsenumber}{\pgfmathresult}%
+ \let\pgfplots@restrict@to@domain@tmp=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{if less than}
+ {\pgfplots@restrict@to@domain@tmp}{##1}% ##1 is the lower argument
+ {%
+ \edef\pgfmathresult{\if0#4inf\else ##1\fi}%
+ }{%
+ \pgfplotscoordmath{default}{if less than}
+ {##2}{\pgfplots@restrict@to@domain@tmp}
+ {\edef\pgfmathresult{\if0#4-inf\else ##2\fi}}
+ {\let\pgfmathresult=\pgfplots@restrict@to@domain@orig}%
+ }%
+ \fi
+ }%
+ }%
+ }%
+ % when invoked, ##1 and ##2 will be the user-supplied args.
+ \def\pgfplots@loc@TMPc##1:##2\relax{%
+ \pgfplotscoordmath{default}{parsenumber}{##1}%
+ \let\pgfplots@rangea=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{##2}%
+ \edef\pgfplots@loc@TMPc{\pgfplots@rangea:\pgfmathresult}%
+ \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPc\relax
+ }%
+ \edef\pgfplots@loc@TMPa{#3}%
+ \expandafter\pgfplots@loc@TMPc\pgfplots@loc@TMPa\relax
+ },%
+ % -> keeps only the nth point, all other ones will get ''.
+ /pgfplots/each nth point/.style={/pgfplots/each nth point*={x}{#1}},%
+ % #1: the filter name: x, y, z, or something exotic like hist/data
+ % #2: the N of 'each nth'
+ /pgfplots/each nth point*/.style 2 args={%
+ /pgfplots/#1 filter/.append code={%
+ \ifnum\coordindex=0
+ \def\c@pgfplots@eachnthpoint@xfilter{0}%
+ \edef\c@pgfplots@eachnthpoint@xfilter@cmp{#2}%
+ \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/skip coords between index*={x}{#1}{#2}},%
+ % #1: the filter name
+ % #2,#3: from 'skip coords between index'
+ /pgfplots/skip coords between index*/.style n args={3}{%
+ /pgfplots/#1 filter/.append code={%
+ \ifnum\coordindex<#2\relax
+ \else
+ \ifnum\coordindex<#3\relax
+ \let\pgfmathresult=\pgfutil@empty
+ \fi
+ \fi}
+ },
+ /pgfplots/translate gnuplot/.is if=pgfplots@translategnuplot,
+ /pgfplots/gnuplot writes logscale/.is choice,
+ /pgfplots/gnuplot writes logscale/true/.code={\gdef\pgfplots@gnuplot@logscale@writes@log{1}},%
+ /pgfplots/gnuplot writes logscale/false/.code={\gdef\pgfplots@gnuplot@logscale@writes@log{0}},%
+ /pgfplots/parametric/var 2d/.initial={\u,\v},
+ /pgfplots/parametric/var 1d/.initial=\t,
+ /pgfplots/xfilter/.initial=,% DEPRECATED
+ /pgfplots/yfilter/.initial=,% DEPRECATED
+ /pgfplots/zfilter/.initial=,% DEPRECATED
+ % interpretation:
+ % if 'samples at'==empty && 'domain' == empty
+ % use tikz option processing!
+ % else if 'samples at' == empty
+ % use 'domain'
+ % 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/samples at colormap pos/.code={%
+ \pgfplots@colorbar@positions@to@samplesat
+ },
+ /pgfplots/variable/.code={\pgfkeysalso{/tikz/variable={#1}}},
+ /pgfplots/variable y/.initial=\y,%
+ /pgfplots/sample dim/.initial=auto,
+ % and provide aliases in the '/pgfplots/' tree to avoid
+ % search path problems just for the following options:
+ /pgfplots/name/.code={\pgfkeysalso{/tikz/name={#1}}},
+ /pgfplots/overlay/.code={\pgfkeysalso{/tikz/overlay={#1}}},
+ /pgfplots/alias/.code={\pgfkeysalso{/tikz/alias={#1}}},
+ /pgfplots/id/.code={\pgfkeysalso{/tikz/id={#1}}},
+ /pgfplots/prefix/.code={\pgfkeysalso{/tikz/prefix={#1}}},
+ /pgfplots/raw gnuplot/.code={\pgfkeysalso{/tikz/raw gnuplot={#1}}},
+ /pgfplots/parametric/.code={\pgfkeysalso{/tikz/parametric={#1}}},%
+ %
+ /pgfplots/width/.initial=,%
+ /pgfplots/width/.belongs to family=/pgfplots,
+ /pgfplots/height/.initial=,%
+ /pgfplots/height/.belongs to family=/pgfplots,
+ /pgfplots/execute at begin plot/.initial=,
+ /pgfplots/execute at begin plot visualization/.initial=,
+ /pgfplots/execute at begin plot@@/.initial=,% an internal variant
+ /pgfplots/execute at end plot/.initial=,
+ /pgfplots/execute at end plot visualization/.initial=,
+ /pgfplots/execute at end plot@@/.initial=,% an internal variant
+ /pgfplots/execute at end survey/.initial=,%
+ /pgfplots/execute at begin axis/.initial=,
+ /pgfplots/execute at begin axis@@/.initial=,% an internal variant
+ /pgfplots/execute at end axis/.initial=,
+ /pgfplots/execute at end axis@@/.initial=,% an internal variant
+ /pgfplots/execute for finished point/.initial=,
+ /pgfplots/before end axis/.code=,
+ /pgfplots/after end axis/.code=,
+ /pgfplots/enlarge x limits/.initial=auto,
+ /pgfplots/enlarge x limits/.default=true,
+ /pgfplots/enlarge y limits/.initial=auto,
+ /pgfplots/enlarge y limits/.default=true,
+ /pgfplots/enlarge z limits/.initial=auto,
+ /pgfplots/enlarge z limits/.default=true,
+ /pgfplots/enlargelimits/.style={%
+ /pgfplots/enlarge x limits={#1},%
+ /pgfplots/enlarge y limits={#1},%
+ /pgfplots/enlarge z limits={#1},%
+ },%
+ /pgfplots/enlargelimits/.default=true,
+ /pgfplots/enlargelimits respects figure size/.is if=pgfplots@enlargelimits@respect@figure@size,
+ /pgfplots/update limits/.is if=pgfplots@bb@isactive,
+ /pgfplots/x/.initial=,% is implicitly set by 'width' and/or '\axisdefaultwidth'
+ /pgfplots/x/.belongs to family=/pgfplots,
+ /pgfplots/y/.initial=,% is implicitly set by 'width' and/or '\axisdefaultwidth'
+ /pgfplots/y/.belongs to family=/pgfplots,
+ /pgfplots/z/.initial=,
+ /pgfplots/z/.belongs to family=/pgfplots,
+ /pgfplots/view dir/.initial=,% DEBUG
+ /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/x post scale/.initial=,
+ /pgfplots/y post scale/.initial=,
+ /pgfplots/z post scale/.initial=,
+ /pgfplots/scale/.style={%
+ /pgfplots/x post scale={#1},%
+ /pgfplots/y post scale={#1},%
+ /pgfplots/z post scale={#1},%
+ },
+ /pgfplots/scale mode/.is choice,
+ /pgfplots/scale mode/auto/.code={\def\pgfplots@scale@mode@choice{0}},
+ /pgfplots/scale mode/none/.code={\def\pgfplots@scale@mode@choice{1}},
+ /pgfplots/scale mode/stretch to fill/.code={\def\pgfplots@scale@mode@choice{2}},
+ /pgfplots/scale mode/scale uniformly/.code={\def\pgfplots@scale@mode@choice{3}},
+ /pgfplots/scale mode/auto,
+ /pgfplots/scale uniformly strategy/.is choice,
+ % chooses one of the other choices depending on the target
+ % width/height:
+ /pgfplots/scale uniformly strategy/auto/.code= {\def\pgfplots@scaleuniformly@choice{0}},
+ % scales units only, but does not compensate limits:
+ /pgfplots/scale uniformly strategy/units only/.code= {\def\pgfplots@scaleuniformly@choice{1}},
+ % changes only vertical limits, no horizontal limits:
+ /pgfplots/scale uniformly strategy/change vertical limits/.code= {\def\pgfplots@scaleuniformly@choice{2}},
+ % changes X and Y limits, but not Z limits - adjusts scale accordingly:
+ /pgfplots/scale uniformly strategy/change horizontal limits/.code= {\def\pgfplots@scaleuniformly@choice{3}},
+ /pgfplots/scale uniformly strategy/auto,
+ /pgfplots/scale uniformly warning/.is if=pgfplots@scaleuniformly@warning,
+ /pgfplots/scale uniformly warning=false,
+ % number of iterations for the nonlinear method involved
+ /pgfplots/scale uniformly strategy iter/.initial=9,
+ /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/.define/.code 2 args={%
+ \pgfplotscreateplotcyclelist{#1}{#2}%
+ },
+ /pgfplots/cycle list/.style={%
+ /pgfplots/cycle list/.define={@internal@}{#1},%
+ /pgfplots/cycle list name={@internal@}%
+ },
+ /pgfplots/cycle list/.belongs to family=/pgfplots,
+ /pgfplots/cycle list name/.code={%
+ \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,
+ /pgfplots/cycle list shift/.initial=,
+ /pgfplots/mark list fill/.initial=.!80!black,
+ % 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={%
+ \def\pgfplots@cycle@multi@list@sequence{L}% [L]exicographical
+ \pgfplots@cycle@multi@list{#1}%
+ },
+ /pgfplots/cycle multi list/.belongs to family=/pgfplots,
+ /pgfplots/cycle multiindex list/.code={%
+ \def\pgfplots@cycle@multi@list@sequence{M}% [M]ultiindex
+ \def\pgfplots@cycle@multi@list@repeat{A}% [A]ll
+ \pgfplots@cycle@multi@list{#1}%
+ },
+ /pgfplots/cycle multiindex list/.belongs to family=/pgfplots,
+ /pgfplots/cycle multiindex* list/.code={%
+ \def\pgfplots@cycle@multi@list@sequence{M}% [M]ultiindex
+ \def\pgfplots@cycle@multi@list@repeat{S}% [S]ingle
+ \pgfplots@cycle@multi@list{#1}%
+ },
+ /pgfplots/cycle multiindex* list/.belongs to family=/pgfplots,
+ % #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/@maxlen/.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/.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={%
+ \pgfkeysalso{/pgfplots/every axis x label/.append style={#1}}%
+ },
+ /pgfplots/y label style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/y label style/.code={%
+ \pgfkeysalso{/pgfplots/every axis y label/.append style={#1}}%
+ },
+ /pgfplots/z label style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/z label style/.code={%
+ \pgfkeysalso{/pgfplots/every axis z label/.append style={#1}}%
+ },
+ /pgfplots/title style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/title style/.code={%
+ \pgfkeysalso{/pgfplots/every axis title/.append style={#1}}%
+ },
+ /pgfplots/tick label style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/tick label style/.code={%
+ \pgfkeysalso{/pgfplots/every tick label/.append style={#1}}%
+ },
+ /pgfplots/x tick label style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/x tick label style/.code={%
+ \pgfkeysalso{/pgfplots/every x tick label/.append style={#1}}%
+ },
+ /pgfplots/y tick label style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/y tick label style/.code={%
+ \pgfkeysalso{/pgfplots/every y tick label/.append style={#1}}%
+ },
+ /pgfplots/z tick label style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/z tick label style/.code={%
+ \pgfkeysalso{/pgfplots/every z tick label/.append style={#1}}%
+ },
+ /pgfplots/x tick scale label style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/x tick scale label style/.code={%
+ \pgfkeysalso{/pgfplots/every x 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 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 tick scale label/.append style={#1}}%
+ },
+ /pgfplots/tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/tick style/.code={%
+ \pgfkeysalso{/pgfplots/every tick/.append style={#1}}%
+ },
+ /pgfplots/minor tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/minor tick style/.code={%
+ \pgfkeysalso{/pgfplots/every minor tick/.append style={#1}}%
+ },
+ /pgfplots/major tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/major tick style/.code={%
+ \pgfkeysalso{/pgfplots/every major tick/.append style={#1}}%
+ },
+ /pgfplots/x tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/x tick style/.code={%
+ \pgfkeysalso{/pgfplots/every x tick/.append style={#1}}%
+ },
+ /pgfplots/minor x tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/minor x tick style/.code={%
+ \pgfkeysalso{/pgfplots/every minor x tick/.append style={#1}}%
+ },
+ /pgfplots/major x tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/major x tick style/.code={%
+ \pgfkeysalso{/pgfplots/every major x tick/.append style={#1}}%
+ },
+ /pgfplots/y tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/y tick style/.code={%
+ \pgfkeysalso{/pgfplots/every y tick/.append style={#1}}%
+ },
+ /pgfplots/minor y tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/minor y tick style/.code={%
+ \pgfkeysalso{/pgfplots/every minor y tick/.append style={#1}}%
+ },
+ /pgfplots/major y tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/major y tick style/.code={%
+ \pgfkeysalso{/pgfplots/every major y tick/.append style={#1}}%
+ },
+ /pgfplots/z tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/z tick style/.code={%
+ \pgfkeysalso{/pgfplots/every z tick/.append style={#1}}%
+ },
+ /pgfplots/minor z tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/minor z tick style/.code={%
+ \pgfkeysalso{/pgfplots/every minor z tick/.append style={#1}}%
+ },
+ /pgfplots/major z tick style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/major z tick style/.code={%
+ \pgfkeysalso{/pgfplots/every major z tick/.append style={#1}}%
+ },
+ /pgfplots/grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/grid style/.code={%
+ \pgfkeysalso{/pgfplots/every axis grid/.append style={#1}}%
+ },
+ /pgfplots/minor grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/minor grid style/.code={%
+ \pgfkeysalso{/pgfplots/every minor grid/.append style={#1}}%
+ },
+ /pgfplots/major grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/major grid style/.code={%
+ \pgfkeysalso{/pgfplots/every major grid/.append style={#1}}%
+ },
+ /pgfplots/x grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/x grid style/.code={%
+ \pgfkeysalso{/pgfplots/every axis x grid/.append style={#1}}%
+ },
+ /pgfplots/minor x grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/minor x grid style/.code={%
+ \pgfkeysalso{/pgfplots/every minor x grid/.append style={#1}}%
+ },
+ /pgfplots/major x grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/major x grid style/.code={%
+ \pgfkeysalso{/pgfplots/every major x grid/.append style={#1}}%
+ },
+ /pgfplots/y grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/y grid style/.code={%
+ \pgfkeysalso{/pgfplots/every axis y grid/.append style={#1}}%
+ },
+ /pgfplots/minor y grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/minor y grid style/.code={%
+ \pgfkeysalso{/pgfplots/every minor y grid/.append style={#1}}%
+ },
+ /pgfplots/major y grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/major y grid style/.code={%
+ \pgfkeysalso{/pgfplots/every major y grid/.append style={#1}}%
+ },
+ /pgfplots/z grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/z grid style/.code={%
+ \pgfkeysalso{/pgfplots/every axis z grid/.append style={#1}}%
+ },
+ /pgfplots/minor z grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/minor z grid style/.code={%
+ \pgfkeysalso{/pgfplots/every minor z grid/.append style={#1}}%
+ },
+ /pgfplots/major z grid style/.belongs to family=/pgfplots/style commands,
+ /pgfplots/major z grid style/.code={%
+ \pgfkeysalso{/pgfplots/every major z grid/.append style={#1}}%
+ },
+ /pgfplots/disablelogfilter x/.is if=pgfplots@disablelogfilter@x,
+ /pgfplots/disablelogfilter x/.default=true,
+ /pgfplots/disablelogfilter y/.is if=pgfplots@disablelogfilter@y,
+ /pgfplots/disablelogfilter y/.default=true,
+ /pgfplots/disablelogfilter z/.is if=pgfplots@disablelogfilter@z,
+ /pgfplots/disablelogfilter z/.default=true,
+ /pgfplots/disablelogfilter/.style={
+ /pgfplots/disablelogfilter x=#1,
+ /pgfplots/disablelogfilter y=#1,
+ /pgfplots/disablelogfilter z=#1,
+ },
+ /pgfplots/disabledatascaling/.is if=pgfplots@disabledatascaling,
+ /pgfplots/disabledatascaling/.default=true,
+ /pgfplots/disabledatascaling/.belongs to family=/pgfplots,
+ /pgfplots/disabledatascaling=false,
+ /pgfplots/hide x axis/.is if=pgfplots@hide@x,
+ /pgfplots/hide x axis/.default=true,
+ /pgfplots/hide x axis=false,
+ /pgfplots/hide y axis/.is if=pgfplots@hide@y,
+ /pgfplots/hide y axis/.default=true,
+ /pgfplots/hide y axis=false,
+ /pgfplots/hide z axis/.is if=pgfplots@hide@z,
+ /pgfplots/hide z axis/.default=true,
+ /pgfplots/hide z axis=false,
+ /pgfplots/hide axis/.style={%
+ /pgfplots/hide x axis=#1,
+ /pgfplots/hide y axis=#1,
+ /pgfplots/hide z axis=#1,
+ },
+ /pgfplots/hide axis/.default=true,
+ /pgfplots/every non boxed x axis/.style={%
+ xtick align=center,
+ enlarge x limits=false,
+ x axis line style={-stealth}
+ },
+ /pgfplots/every non boxed y axis/.style={%
+ ytick align=center,
+ enlarge y limits=false,
+ y axis line style={-stealth}
+ },
+ /pgfplots/every non boxed z axis/.style={%
+ ztick align=center,
+ enlarge z limits=false,
+ z axis line style={-stealth}
+ },
+ /pgfplots/every boxed x axis/.style={},
+ /pgfplots/every boxed y axis/.style={},
+ /pgfplots/every boxed z axis/.style={},
+% /pgfplots/hide axis/.belongs to family=/pgfplots,
+ %
+ /pgfplots/axis x line shift/.initial=,
+ /pgfplots/axis y line shift/.initial=,
+ /pgfplots/axis z line shift/.initial=,
+ /pgfplots/axis line shift/.style={%
+ /pgfplots/axis x line shift={#1},%
+ /pgfplots/axis y line shift={#1},%
+ /pgfplots/axis z line shift={#1},%
+ },%
+ %
+% sets \pgfplots@xaxislinesnum to
+% box=0
+% bottom=1
+% middle=2 ( aliased with center )
+% top=3
+ /pgfplots/axis x line*/.is choice,
+ /pgfplots/axis x line*/box/.code ={\def\pgfplots@xaxislinesnum{0}\def\pgfplots@xtickposnum{0}},
+ /pgfplots/axis x line*/bottom/.code ={\def\pgfplots@xaxislinesnum{1}\def\pgfplots@xtickposnum{1}\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}\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,
+ %
+% sets \pgfplots@yaxislinesnum to
+% box=0
+% left=1
+% center=2 ( aliased with middle )
+% right=3
+ /pgfplots/axis y line*/.is choice,
+ /pgfplots/axis y line*/box/.code ={\def\pgfplots@yaxislinesnum{0}\def\pgfplots@ytickposnum{0}},
+ /pgfplots/axis y line*/left/.code ={\def\pgfplots@yaxislinesnum{1}\def\pgfplots@ytickposnum{1}\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}\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,
+ %
+%
+% sets \pgfplots@zaxislinesnum to
+% box=0
+% left=1
+% center=2 ( aliased with middle )
+% 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}\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}\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 x line/.is choice,
+ /pgfplots/axis y line/.is choice,
+ /pgfplots/axis z line/.is choice,
+ /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/compat/axis line style pre 1.8/.style={%
+ % ALL INSIDE OF THIS STYLE IS DEPRECATED.
+ /pgfplots/axis x line/box/.style ={
+ /pgfplots/axis x line*/box,
+ /pgfplots/every boxed x axis
+ },
+ /pgfplots/axis x line/bottom/.style ={
+ /pgfplots/axis x line*/bottom,
+ /pgfplots/every non boxed x axis
+ },
+ /pgfplots/axis x line/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}}%
+ \else
+ \pgfkeysalso{/pgfplots/every axis x label/.style={at={(current axis.right of origin)},anchor=south east}}%
+ \fi
+ \pgfkeysalso{/pgfplots/every axis x label/.append code={\pgfplots@label@upgrade@warning}}%
+ \pgfkeysalso{/pgfplots/axis x line*/middle,
+ /pgfplots/every non boxed x axis}%
+ },
+ /pgfplots/axis x line/center/.style ={/pgfplots/axis x line/middle},
+ /pgfplots/axis x line/right/.style={/pgfplots/axis x line/top},%
+ /pgfplots/axis x line/top/.code ={
+ \ifnum\pgfplots@yaxislinesnum=2 % if 'axis y line==center' then
+ \pgfkeysalso{
+ /pgfplots/every axis y label/.style={at={(current axis.below origin)},anchor=south west}}%
+ \fi
+ \pgfkeysalso{%
+ /pgfplots/axis x line*/top,
+ /pgfplots/every axis x label/.style={at={(0.5,1)},anchor=south,yshift=15pt},
+ /pgfplots/every non boxed x axis}%
+ },
+ /pgfplots/axis x line/none/.style ={axis x line*/none,hide x axis},
+ %
+ % Y :
+ /pgfplots/axis y line/box/.style ={
+ /pgfplots/axis y line*/box,
+ /pgfplots/every boxed y axis
+ },
+ /pgfplots/axis y line/left/.style ={
+ /pgfplots/axis y line*/left,
+ /pgfplots/every non boxed y axis
+ },
+ /pgfplots/axis y line/center/.code ={
+ \ifnum\pgfplots@xaxislinesnum=3 % if 'axis x line==top' then
+ \pgfkeysalso{%
+ /pgfplots/every axis y label/.style={at={(current axis.below origin)},anchor=south west}}%
+ \else
+ \pgfkeysalso{%
+ /pgfplots/every axis y label/.style={at={(current axis.above origin)},anchor=north west}}%
+ \fi
+ \pgfkeysalso{/pgfplots/every axis y label/.append code={\pgfplots@label@upgrade@warning}}%
+ \pgfkeysalso{%
+ /pgfplots/axis y line*/center,
+ /pgfplots/every non boxed y axis}%
+ },
+ /pgfplots/axis y line/middle/.style ={/pgfplots/axis y line/center},
+ /pgfplots/axis y line/right/.code ={%
+ \ifnum\pgfplots@xaxislinesnum=2
+ \pgfkeysalso{every axis x label/.style={at={(current axis.left of origin)},anchor=south west}}%
+ \fi
+ \pgfkeysalso{
+ axis y line*/right,
+ %every axis y label/.style={at={(1,1)},anchor=north west,xshift=15pt},
+ % 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
+ }%
+ },%
+ /pgfplots/axis y line/none/.style ={axis y line*/none,hide y axis},
+ %
+ %
+ % Z :
+ %
+ /pgfplots/axis z line/box/.style ={
+ /pgfplots/axis z line*/box,
+ /pgfplots/every boxed z axis
+ },
+ /pgfplots/axis z line/left/.style ={
+ /pgfplots/axis z line*/left,
+ /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
+ \pgfkeysalso{%
+ /pgfplots/every axis z label/.style={at={(current axis.above origin)},anchor=north west}}%
+ % \fi
+ \pgfkeysalso{/pgfplots/every axis z label/.append code={\pgfplots@label@upgrade@warning}}%
+ \pgfkeysalso{%
+ /pgfplots/axis z line*/center,
+ /pgfplots/every non boxed z axis}%
+ },
+ /pgfplots/axis z line/middle/.style ={/pgfplots/axis z line/center},
+ /pgfplots/axis z line/right/.code ={%
+ \ifnum\pgfplots@xaxislinesnum=2
+ \pgfkeysalso{every axis x label/.style={at={(current axis.left of origin)},anchor=south west}}%
+ \fi
+ \pgfkeysalso{
+ axis 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/axis z line/none/.style ={axis z line*/none,hide z axis},
+ },
+ /pgfplots/compat/axis line style post 1.8/.style={%
+ /pgfplots/axis x line/box/.style ={
+ /pgfplots/axis x line*/box,
+ /pgfplots/xlabel near ticks,
+ /pgfplots/every boxed x axis
+ },
+ /pgfplots/axis x line/bottom/.style ={
+ /pgfplots/axis x line*/bottom,
+ /pgfplots/every non boxed x axis
+ },
+ /pgfplots/axis x line/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={
+ /pgfplots/near ticklabel align=inside,at={(ticklabel* cs:0)},anchor=near ticklabel opposite}}%
+ \else
+ \pgfkeysalso{/pgfplots/every axis x label/.style={
+ /pgfplots/near ticklabel align=inside,at={(ticklabel* cs:1)},anchor=near ticklabel opposite}}%
+ \fi
+ \pgfkeysalso{/pgfplots/axis x line*/middle,
+ /pgfplots/every x tick scale label/.code={%
+ \ifpgfplotsthreedim
+ \pgfkeysalso{at={(xticklabel* cs:1.03)},/pgfplots/near ticklabel align=outside,anchor=near xticklabel}%
+ \else
+ \pgfkeysalso{at={(xticklabel cs:0.9,5pt)},anchor=near xticklabel,inner sep=0pt}%
+ \fi
+ },%
+ /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{/pgfplots/every axis y label/.style={
+ /pgfplots/near ticklabel align=inside,at={(ticklabel* cs:0)},anchor=near ticklabel opposite}}%
+ \fi
+ \pgfkeysalso{%
+ /pgfplots/axis x line*/top,
+ /pgfplots/every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},%
+ /pgfplots/every y tick scale label/.style={at={(yticklabel cs:0)},anchor=near yticklabel},
+ /pgfplots/every non boxed x axis}%
+ },
+ /pgfplots/axis x line/none/.style ={axis x line*/none,hide x axis},
+ %
+ % Y :
+ /pgfplots/axis y line/box/.style ={
+ /pgfplots/axis y line*/box,
+ /pgfplots/ylabel near ticks,
+ /pgfplots/every boxed y axis
+ },
+ /pgfplots/axis y line/left/.style ={
+ /pgfplots/axis y line*/left,
+ /pgfplots/every non boxed y axis
+ },
+ /pgfplots/axis y line/center/.code ={
+ \ifnum\pgfplots@xaxislinesnum=3 % if 'axis x line==top' then
+ \pgfkeysalso{%
+ /pgfplots/every axis y label/.style={
+ /pgfplots/near ticklabel align=outside,at={(ticklabel* cs:0)},anchor=near ticklabel opposite}}%
+ \else
+ \pgfkeysalso{%
+ /pgfplots/every axis y label/.style={
+ /pgfplots/near ticklabel align=inside,at={(ticklabel* cs:1)},anchor=near ticklabel opposite}}%
+ \fi
+ \pgfkeysalso{%
+ /pgfplots/axis y line*/center,
+ /pgfplots/every y tick scale label/.code={%
+ \ifpgfplotsthreedim
+ \pgfkeysalso{at={(yticklabel* cs:1.03)},/pgfplots/near ticklabel align=outside,anchor=near yticklabel}%
+ \else
+ \pgfkeysalso{at={(yticklabel* cs:1.03,-0.3em)},/pgfplots/near ticklabel align=outside,anchor=near yticklabel opposite,inner sep=0pt}%
+ \fi
+ },%
+ /pgfplots/every non boxed y axis}%
+ },
+ /pgfplots/axis y line/middle/.style ={/pgfplots/axis y line/center},
+ /pgfplots/axis y line/right/.code ={%
+ \ifnum\pgfplots@xaxislinesnum=2
+ \pgfkeysalso{
+ /pgfplots/every axis x label/.style={
+ /pgfplots/near ticklabel align=outside,at={(ticklabel* cs:0)},anchor=near ticklabel opposite}}%
+ \fi
+ \pgfkeysalso{
+ axis y line*/right,
+ /pgfplots/every axis y label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel,
+ /utils/exec={%
+ \ifpgfplotsthreedim\else \pgfkeysalso{rotate=90}\fi
+ },%
+ },
+ /pgfplots/every y tick scale label/.code={
+ \ifpgfplotsthreedim
+ \pgfkeysalso{at={(yticklabel cs:0)},anchor=near yticklabel}%
+ \else
+ \pgfkeysalso{at={(yticklabel cs:1)},anchor=near yticklabel}%
+ \fi
+ },%
+ /pgfplots/every non boxed y axis
+ }%
+ },%
+ /pgfplots/axis y line/none/.style ={axis y line*/none,hide y axis},
+ %
+ %
+ % Z :
+ %
+ /pgfplots/axis z line/box/.style ={
+ /pgfplots/axis z line*/box,
+ /pgfplots/every axis z label/.style={at={(ticklabel cs:0.5)},rotate=90, anchor=near ticklabel},
+ /pgfplots/every z tick scale label/.style={at={(zticklabel* cs:1.2,-0.3em)},anchor=near zticklabel,inner sep=0pt},
+ /pgfplots/every boxed z axis
+ },
+ /pgfplots/axis z line/left/.style ={
+ /pgfplots/axis z line*/left,
+ /pgfplots/every non boxed z axis
+ },
+ /pgfplots/axis z line/center/.code ={
+ \pgfkeysalso{%
+ /pgfplots/every axis z label/.style={
+ /pgfplots/near ticklabel align=inside,at={(ticklabel* cs:1)},anchor=near ticklabel opposite}}%
+ \pgfkeysalso{%
+ /pgfplots/axis z line*/center,
+ /pgfplots/every non boxed z axis}%
+ },
+ /pgfplots/axis z line/middle/.style ={/pgfplots/axis z line/center},
+ /pgfplots/axis z line/right/.code ={%
+ \ifnum\pgfplots@xaxislinesnum=2
+ \pgfkeysalso{
+ /pgfplots/every axis z label/.style={
+ /pgfplots/near ticklabel align=outside,at={(ticklabel* cs:0)},anchor=near ticklabel opposite}}%
+ \fi
+ \pgfkeysalso{
+ axis z line*/right,
+ every axis z label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel,rotate=90},
+ /pgfplots/every z tick scale label/.style={at={(zticklabel cs:0)},anchor=near zticklabel},
+ /pgfplots/every non boxed z axis
+ }%
+ },%
+ /pgfplots/axis z line/none/.style ={axis z line*/none,hide z axis},
+ },
+ %
+ /pgfplots/hide obscured x ticks/.is if=pgfplots@hide@obscured@xtick,
+ /pgfplots/hide obscured y ticks/.is if=pgfplots@hide@obscured@ytick,
+ /pgfplots/hide obscured z ticks/.is if=pgfplots@hide@obscured@ztick,
+ /pgfplots/hide obscured x ticks=true,
+ /pgfplots/hide obscured y ticks=true,
+ /pgfplots/hide obscured z ticks=true,
+ %
+ /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
+% open = 2
+ /pgfplots/axis x discontinuity/.is choice,
+ /pgfplots/axis x discontinuity/none/.code ={\def\pgfplots@xaxisdiscontnum{0}},
+ /pgfplots/axis x discontinuity/crunch/.code ={\def\pgfplots@xaxisdiscontnum{1}},
+ /pgfplots/axis x discontinuity/parallel/.code ={\def\pgfplots@xaxisdiscontnum{2}},
+ /pgfplots/axis x discontinuity=none,
+% set \pgfplots@yaxisdiscontnum
+% none = 0
+% crunch = 1
+% open = 2
+ /pgfplots/axis y discontinuity/.is choice,
+ /pgfplots/axis y discontinuity/none/.code ={\def\pgfplots@yaxisdiscontnum{0}},
+ /pgfplots/axis y discontinuity/crunch/.code ={\def\pgfplots@yaxisdiscontnum{1}},
+ /pgfplots/axis y discontinuity/parallel/.code ={\def\pgfplots@yaxisdiscontnum{2}},
+ /pgfplots/axis y discontinuity=none,
+% set \pgfplots@yaxisdiscontnum
+% none = 0
+% crunch = 1
+% open = 2
+ /pgfplots/axis z discontinuity/.is choice,
+ /pgfplots/axis z discontinuity/none/.code ={\def\pgfplots@zaxisdiscontnum{0}},
+ /pgfplots/axis z discontinuity/crunch/.code ={\def\pgfplots@zaxisdiscontnum{1}},
+ /pgfplots/axis z discontinuity/parallel/.code ={\def\pgfplots@zaxisdiscontnum{2}},
+ /pgfplots/axis z discontinuity=none,
+ /pgfplots/scale only axis/.is if=pgfplots@scale@only@axis,
+ /pgfplots/scale only axis/.default=true,
+ /pgfplots/scale only axis=false,
+% sets \pgfplots@xislinear to
+% normal=true
+% log=false
+ /pgfplots/xmode/.is choice,
+ /pgfplots/xmode/.belongs to family=/pgfplots/scale,
+ /pgfplots/xmode/normal/.code={\pgfplots@xislineartrue},
+ /pgfplots/xmode/normal/.belongs to family=/pgfplots/scale,
+ /pgfplots/xmode/linear/.code={\pgfplots@xislineartrue},
+ /pgfplots/xmode/linear/.belongs to family=/pgfplots/scale,
+ /pgfplots/xmode/log/.code={\pgfplots@xislinearfalse},
+ /pgfplots/xmode/log/.belongs to family=/pgfplots/scale,
+ /pgfplots/xmode=linear,
+ /pgfplots/ymode/.is choice,
+ /pgfplots/ymode/.belongs to family=/pgfplots/scale,
+ /pgfplots/ymode/normal/.code={\pgfplots@yislineartrue},
+ /pgfplots/ymode/normal/.belongs to family=/pgfplots/scale,
+ /pgfplots/ymode/linear/.code={\pgfplots@yislineartrue},
+ /pgfplots/ymode/linear/.belongs to family=/pgfplots/scale,
+ /pgfplots/ymode/log/.code={\pgfplots@yislinearfalse},
+ /pgfplots/ymode/log/.belongs to family=/pgfplots/scale,
+ /pgfplots/ymode=linear,
+ /pgfplots/zmode/.is choice,
+ /pgfplots/zmode/.belongs to family=/pgfplots/scale,
+ /pgfplots/zmode/normal/.code={\pgfplots@zislineartrue},
+ /pgfplots/zmode/normal/.belongs to family=/pgfplots/scale,
+ /pgfplots/zmode/linear/.code={\pgfplots@zislineartrue},
+ /pgfplots/zmode/linear/.belongs to family=/pgfplots/scale,
+ /pgfplots/zmode/log/.code={\pgfplots@zislinearfalse},
+ /pgfplots/zmode/log/.belongs to family=/pgfplots/scale,
+ /pgfplots/zmode=linear,
+ /pgfplots/error bars/x fixed/.code= \def\pgfplots@errorbars@xfixed{#1}\def\pgfplots@errorbars@xmode{0},
+ /pgfplots/error bars/x fixed relative/.code= \def\pgfplots@errorbars@xrel{#1}\def\pgfplots@errorbars@xmode{1},
+ /pgfplots/error bars/x explicit/.code= \def\pgfplots@errorbars@xmode{2},
+ /pgfplots/error bars/x explicit relative/.code= \def\pgfplots@errorbars@xmode{3},
+ /pgfplots/error bars/x fixed relative=0,
+ /pgfplots/error bars/x fixed=0,
+ /pgfplots/error bars/y fixed/.code= \def\pgfplots@errorbars@yfixed{#1}\def\pgfplots@errorbars@ymode{0},
+ /pgfplots/error bars/y fixed relative/.code= \def\pgfplots@errorbars@yrel{#1}\def\pgfplots@errorbars@ymode{1},
+ /pgfplots/error bars/y explicit/.code= \def\pgfplots@errorbars@ymode{2},
+ /pgfplots/error bars/y explicit relative/.code= \def\pgfplots@errorbars@ymode{3},
+ /pgfplots/error bars/y fixed relative=0,
+ /pgfplots/error bars/y fixed=0,
+ /pgfplots/error bars/z fixed/.code= \def\pgfplots@errorbars@zfixed{#1}\def\pgfplots@errorbars@zmode{0},
+ /pgfplots/error bars/z fixed relative/.code= \def\pgfplots@errorbars@zrel{#1}\def\pgfplots@errorbars@zmode{1},
+ /pgfplots/error bars/z explicit/.code= \def\pgfplots@errorbars@zmode{2},
+ /pgfplots/error bars/z explicit relative/.code= \def\pgfplots@errorbars@zmode{3},
+ /pgfplots/error bars/z fixed relative=0,
+ /pgfplots/error bars/z fixed=0,
+ /pgfplots/error bars/x dir/.is choice,
+ /pgfplots/error bars/x dir/none/.code={%
+ \def\pgfplots@errorbars@xdirection{0}%
+ \ifnum\pgfplots@errorbars@ydirection=0
+ \ifnum\pgfplots@errorbars@zdirection=0
+ \pgfplots@errorbars@enabledfalse
+ \fi
+ \fi
+ },
+ /pgfplots/error bars/x dir/plus/.code= \def\pgfplots@errorbars@xdirection{1}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/x dir/minus/.code= \def\pgfplots@errorbars@xdirection{2}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/x dir/both/.code= \def\pgfplots@errorbars@xdirection{3}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/x dir=none,
+ /pgfplots/error bars/y dir/.is choice,
+ /pgfplots/error bars/y dir/none/.code={%
+ \def\pgfplots@errorbars@ydirection{0}%
+ \ifnum\pgfplots@errorbars@xdirection=0
+ \ifnum\pgfplots@errorbars@zdirection=0
+ \pgfplots@errorbars@enabledfalse
+ \fi
+ \fi
+ },
+ /pgfplots/error bars/y dir/plus/.code= \def\pgfplots@errorbars@ydirection{1}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/y dir/minus/.code= \def\pgfplots@errorbars@ydirection{2}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/y dir/both/.code= \def\pgfplots@errorbars@ydirection{3}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/y dir=none,
+ /pgfplots/error bars/z dir/.is choice,
+ /pgfplots/error bars/z dir/none/.code={%
+ \def\pgfplots@errorbars@zdirection{0}%
+ \ifnum\pgfplots@errorbars@xdirection=0
+ \ifnum\pgfplots@errorbars@ydirection=0
+ \pgfplots@errorbars@enabledfalse
+ \fi
+ \fi
+ },
+ /pgfplots/error bars/z dir/plus/.code= \def\pgfplots@errorbars@zdirection{1}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/z dir/minus/.code= \def\pgfplots@errorbars@zdirection{2}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/z dir/both/.code= \def\pgfplots@errorbars@zdirection{3}\pgfplots@errorbars@enabledtrue,
+ /pgfplots/error bars/z dir=none,
+ /pgfplots/error bars/error mark/.initial={-},
+ /pgfplots/error bars/error mark options/.initial={rotate=90},
+ /pgfplots/error bars/error bar style/.code={%
+ \pgfkeysalso{/pgfplots/every error bar/.append style={#1}}%
+ },
+ /pgfplots/every error bar/.style={thin},
+ /pgfplots/every error bar/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every error bar}},
+ /pgfplots/error bars/allow name path/.is if=pgfplots@error@bars@allow@name@path,
+ /pgfplots/error bars/draw error bar/.code 2 args={%
+%\message{/pgfplots/error bars/draw error bar: working with '#1' -- '#2'.}%
+ \pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}%
+ \pgfkeysgetvalue{/pgfplots/error bars/error mark options}{\pgfplotserrorbarsmarkopts}%
+ \draw #1 -- #2 node[pos=1,sloped,allow upside down] {%
+ \expandafter\tikz\expandafter[\pgfplotserrorbarsmarkopts]{%
+ \expandafter\pgfuseplotmark\expandafter{\pgfplotserrorbarsmark}%
+ \pgfusepath{stroke}}%
+ };
+ },
+ /pgfplots/every node near coord/.style={},
+ /pgfplots/nodes near coords style/.style={/pgfplots/every node near coord/.append style={#1}},
+ /pgfplots/node near coords style/.style={/pgfplots/every node near coord/.append style={#1}},
+ /pgfplots/node near coord style/.style={/pgfplots/every node near coord/.append style={#1}},
+ %
+ % Replaces the 'nodes near coords' CONFIGURATION by its default
+ % settings. It does NOT activate 'nodes near coords'.
+ /pgfplots/nodes near coords defaults/.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
+ \def\pgfplots@loc@TMPa{x}%
+ \ifx\pgfplotspointmetainputhandler\pgfplots@loc@TMPa%
+ % 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
+ \pgfplotscoordmath{meta}{if is}{\pgfplotspointmeta}{-}{%
+ % \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
+ \pgfplotscoordmath{meta}{if is}{\pgfplotspointmeta}{-}{%
+ % \pgfplotspointmeta < 0
+ \def\pgfplots@nodes@near@coords@align{below}%
+ }{%
+ % \pgfplotspointmeta >= 0
+ \def\pgfplots@nodes@near@coords@align{above}%
+ }%
+ \fi
+ \else
+ \pgfutil@ifundefined{pgfplots@nodesnearcoordsalign@isanchor@\pgfplots@nodes@near@coords@align}
+ {}%
+ {%
+ \t@pgfplots@toka=\expandafter{\pgfplots@nodes@near@coords@align}%
+ \edef\pgfplots@nodes@near@coords@align{anchor=\the\t@pgfplots@toka}%
+ }%
+ \fi
+ \fi
+ % ok, place the node.
+ \expandafter\node\expandafter[\pgfplots@nodes@near@coords@align,%
+ /pgfplots/every node near coord]
+ {%
+ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname%
+ % point meta=explicit symbolic
+ % do not 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/nodes near coords defaults,
+ %
+ %
+ /pgfplots/nodes near coords bar offset/.initial=0.5,
+ %
+ % Replaces the 'nodes near coords' CONFIGURATION by one suitable
+ % for xbar stacked
+ /pgfplots/nodes near coords xbar stacked configuration/.style={
+ /pgfplots/nodes near coords defaults,
+ /pgfplots/nodes near coords*/.add code={%
+ \pgfkeysalso{
+ /pgfplots/set point meta if empty=rawx,%
+ }%
+ }{%
+ \pgfkeysalso{%
+ /pgfplots/scatter/position/absolute,
+ /pgfplots/scatter/@post marker code/.add code={
+ \pgfplotspointgetnormalizedcoordinates
+ \pgfplotspointgetnormalizedzerolevelcoordinates
+ \pgfkeysgetvalue{/pgfplots/nodes near coords bar offset}\pgfplots@nodes@near@coords@bar@offset
+ \tikzset{
+ every node/.append style={%
+ at={(normalized axis cs:%
+ { (\pgfplots@nodes@near@coords@bar@offset) *\pgfkeysvalueof{/data point/x}
+ +(1-\pgfplots@nodes@near@coords@bar@offset)*\pgfkeysvalueof{/data point/zero/x}},%
+ \pgfkeysvalueof{/data point/y})%
+ }%
+ }
+ }%
+ }{},%
+ }%
+ },
+ /pgfplots/nodes near coords align={%
+ anchor=center,
+ },
+ %
+ % ... just in case someone uses xbar stacked together with
+ % 'bar shift':
+ /pgfplots/every node near coord/.append style={%
+ /pgfplots/every node near coord bar shift=y,
+ /pgfplots/every node near coord bar shift/.code=,
+ },%
+ },
+ %
+ /pgfplots/every node near coord bar shift/.style={#1shift={\pgfplotbarshift}},%
+ %
+ % Replaces the 'nodes near coords' CONFIGURATION by one suitable
+ % for ybar stacked
+ /pgfplots/nodes near coords ybar stacked configuration/.style={
+ /pgfplots/nodes near coords defaults,
+ /pgfplots/nodes near coords*/.add code={%
+ \pgfkeysalso{
+ /pgfplots/set point meta if empty=rawy,%
+ }%
+ }{%
+ \pgfkeysalso{%
+ /pgfplots/scatter/position/absolute,
+ /pgfplots/scatter/@post marker code/.add code={
+ \pgfplotspointgetnormalizedcoordinates
+ \pgfplotspointgetnormalizedzerolevelcoordinates
+ \pgfkeysgetvalue{/pgfplots/nodes near coords bar offset}\pgfplots@nodes@near@coords@bar@offset
+ \tikzset{
+ every node/.append style={%
+ at={(normalized axis cs:%
+ \pgfkeysvalueof{/data point/x},%
+ { (\pgfplots@nodes@near@coords@bar@offset) *\pgfkeysvalueof{/data point/y}
+ +(1-\pgfplots@nodes@near@coords@bar@offset)*\pgfkeysvalueof{/data point/zero/y}})%
+ }%
+ }
+ }%
+ }{},%
+ }%
+ },
+ /pgfplots/nodes near coords align={%
+ anchor=center,
+ },
+ %
+ % ... just in case someone uses ybar stacked together with
+ % 'bar shift':
+ /pgfplots/every node near coord/.append style={%
+ /pgfplots/every node near coord bar shift=x,
+ /pgfplots/every node near coord bar shift/.code=,
+ },%
+ },
+ %
+ %
+ %
+ /pgfplots/scatter explicit color/.style 2 args={%
+ /pgfplots/scatter/@pre marker code/.code=,%
+ /pgfplots/scatter/@post marker code/.code=,%
+ /pgfplots/scatter explicit color*={#1}{#2},%
+ },%
+ /pgfplots/scatter explicit color*/.style 2 args={%
+ /pgfplots/point meta=explicit symbolic,
+ /pgfplots/scatter/true*,%
+ /pgfplots/scatter/@pre marker code/.append code={%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfutil@definecolor{mapped color}{#1}{\pgfplotspointmeta}}%
+ \pgfplots@loc@TMPa
+ \scope[#2]%
+ },%
+ /pgfplots/scatter/@post marker code/.prefix code={%
+ \endscope
+ },%
+ },
+ /pgfplots/scatter rgb/.style={%
+ /pgfplots/scatter/@pre marker code/.code=,%
+ /pgfplots/scatter/@post marker code/.code=,%
+ /pgfplots/scatter rgb*={#1},%
+ },
+ /pgfplots/scatter rgb*/.style={/pgfplots/scatter explicit color*={rgb}{#1}},
+ /pgfplots/scatter rgb*/.default={draw=mapped color!80!black,fill=mapped color},
+ %
+ /pgfplots/scatter cmyk/.style={%
+ /pgfplots/scatter/@pre marker code/.code=,%
+ /pgfplots/scatter/@post marker code/.code=,%
+ /pgfplots/scatter cmyk*={#1},%
+ },
+ /pgfplots/scatter cmyk*/.style={/pgfplots/scatter explicit color*={cmyk}{#1}},
+ /pgfplots/scatter cmyk*/.default={draw=mapped color!80!black,fill=mapped color},
+ %
+ /pgfplots/visualization depends on/list/.initial=,%
+ /pgfplots/visualization depends on/.style={%
+ /pgfplots/visualization depends on/list/.add={}{,{#1}}%
+ },
+ /pgfplots/bar cycle list/.style={/pgfplots/cycle list={%
+ {blue,fill=blue!30!white,mark=none},%
+ {red,fill=red!30!white,mark=none},%
+ {brown!60!black,fill=brown!30!white,mark=none},%
+ {black,fill=gray,mark=none},%
+ {violet!80!black,fill=violet,mark=none},%
+ {green,fill=green!80!black,mark=none}%
+ }
+ },
+ /pgfplots/area cycle list/.style={bar cycle list},
+ /pgfplots/area legend/.style={%
+ /pgfplots/legend image code/.code={%
+ \draw[##1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
+ }%
+ },
+ /pgfplots/area style/.style={%
+ area cycle list,
+ area legend,
+ axis on top,
+ },
+ /pgfplots/ybar 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/single ybar legend/.style={
+ /pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,bar width=6pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0pt,0.8em)};},
+ },
+ %
+ % A style which shifts bars automatically such that they are
+ % adjacent to each other. It applies to bars of the same type
+ % only.
+ % #1: the space between adjacent bars
+ /pgfplots/bar shift auto/.style={%
+ /pgf/bar shift={%
+ % total width = n*w + (n-1)*skip
+ % -> subtract half for centering
+ -0.5*(\numplotsofactualtype*\pgfplotbarwidth + (\numplotsofactualtype-1)*(#1)) +
+ % the '0.5*w' is for centering
+ (.5+\plotnumofactualtype)*\pgfplotbarwidth + \plotnumofactualtype*(#1)},%
+ },
+ /pgfplots/bar shift auto/.default={2pt},%
+ %
+ %
+ % FIXME : never tested so far
+ % #1: width
+ % #2: separation space
+ /pgfplots/plot yshift auto/.style 2 args={/pgfplots/plot shift auto={y}{#1}{#2}},%
+ /pgfplots/plot xshift auto/.style 2 args={/pgfplots/plot shift auto={x}{#1}{#2}},%
+ /pgfplots/plot shift auto/.style args={#1#2#3}{%
+ /pgfplots/axis plot except legend style={%
+ #1shift={%
+ % total width = n*w + (n-1)*skip
+ % -> subtract half for centering
+ -0.5*(\numplotsofactualtype*(#1) + (\numplotsofactualtype-1)*(#2)) +
+ % the '0.5*w' is for centering
+ (.5+\plotnumofactualtype)*(#1) + \plotnumofactualtype*(#2)%
+ },%
+ },
+ },
+ /pgfplots/ybar/.style={
+ bar direction=y,
+ bar cycle list,
+ xtick align=outside,
+ ybar legend,
+ clip limits if compat={clip ylimits=false},
+ /pgfplots/set point meta if empty=f(x),%
+ /pgfplots/bar shift auto={#1},
+ /pgfplots/error bars/draw error bar/.code 2 args={%
+% FIXME: simplify this code! It is just a replication of the default error stuff together with an xshift!
+ \pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}%
+ \pgfkeysgetvalue{/pgfplots/error bars/error mark options}{\pgfplotserrorbarsmarkopts}%
+ \draw[xshift={\pgfplotbarshift}]
+ ##1 -- ##2 node[pos=1,sloped,allow upside down] {%
+ \expandafter\tikz\expandafter[\pgfplotserrorbarsmarkopts]{%
+ \expandafter\pgfuseplotmark\expandafter{\pgfplotserrorbarsmark}%
+ \pgfusepath{stroke}}%
+ };
+ },%
+ /pgfplots/every node near coord/.append style={%
+ /pgfplots/every node near coord bar shift=x,
+ /pgfplots/every node near coord bar shift/.code=,
+ },%
+ /tikz/ybar,
+ },
+ /pgfplots/ybar/.default=2pt,
+ /pgfplots/xbar legend/.style={
+ /pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0.8em,0cm) (0.6em,2*\pgfplotbarwidth)};},
+ },
+ /pgfplots/single xbar legend/.style={
+ /pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,bar width=6pt,yshift=0.2ex,bar shift=0pt] plot coordinates {(0.8em,0pt)};},
+ },
+ /pgfplots/bar direction/.is choice,
+ /pgfplots/bar direction/auto/.code=\def\pgfplots@bar@direction@choice{a},%
+ /pgfplots/bar direction/x/.code=\def\pgfplots@bar@direction@choice{x},%
+ /pgfplots/bar direction/y/.code=\def\pgfplots@bar@direction@choice{y},%
+ /pgfplots/bar direction=auto,
+ %
+ /pgfplots/xbar/.style={
+ bar direction=x,
+ bar cycle list,
+ ytick align=outside,
+ clip limits if compat={clip xlimits=false},
+ /pgfplots/xbar legend,
+ /pgfplots/set point meta if empty=x,%
+ /pgfplots/bar shift auto={#1},
+ /pgfplots/error bars/draw error bar/.code 2 args={%
+% FIXME: simplify this code! It is just a replication of the default error stuff together with an xshift!
+ \pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}%
+ \pgfkeysgetvalue{/pgfplots/error bars/error mark options}{\pgfplotserrorbarsmarkopts}%
+ \draw[yshift={\pgfplotbarshift}]
+ ##1 -- ##2 node[pos=1,sloped,allow upside down] {%
+ \expandafter\tikz\expandafter[\pgfplotserrorbarsmarkopts]{%
+ \expandafter\pgfuseplotmark\expandafter{\pgfplotserrorbarsmark}%
+ \pgfusepath{stroke}}%
+ };
+ },%
+ /pgfplots/every node near coord/.append style={%
+ /pgfplots/every node near coord bar shift=y,
+ /pgfplots/every node near coord bar shift/.code=,
+ },%
+ /tikz/xbar,
+ },
+ /pgfplots/xbar/.default=2pt,
+ /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={%
+ bar direction=y,
+ /pgfplots/set point meta if empty=f(x),%
+ bar cycle list,
+ x tick label as interval,
+ xmajorgrids,
+ clip limits if compat={clip ylimits=false},
+ xtick align=outside,
+ xtick=data,
+ ybar interval legend,
+ bar interval width={#1/\numplotsofactualtype},
+ bar interval shift={(\plotnumofactualtype+0.5)/\numplotsofactualtype},
+ /tikz/ybar interval,
+ },
+ /pgfplots/ybar interval/.default=1,
+ /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={%
+ bar direction=x,
+ /pgfplots/set point meta if empty=x,%
+ bar cycle list,
+ y tick label as interval,
+ ytick=data,
+ ymajorgrids,
+ ytick align=outside,
+ xbar interval legend,
+ clip limits if compat={clip xlimits=false},
+ bar interval width={#1/\numplotsofactualtype},
+ bar interval shift={(\plotnumofactualtype+0.5)/\numplotsofactualtype},
+ /tikz/xbar interval,
+ },
+ /pgfplots/xbar interval/.default=1,
+ /pgfplots/stacked since 1.9/.code={},
+ /pgfplots/stacked since 1.13/.code=,
+ /pgfplots/xbar stacked/.style={
+ bar direction=x,
+ bar cycle list,
+ single xbar legend,
+ clip limits if compat={clip xlimits=false},
+ stack plots=x,
+ stack dir=#1,
+ /tikz/xbar,
+ stacked since 1.9,
+ activate nodes near coords xbar stacked,
+ stacked since 1.13,
+ },
+ /pgfplots/xbar stacked/.default=plus,
+ /pgfplots/ybar stacked/.style={
+ bar direction=y,
+ bar cycle list,
+ single ybar legend,
+ clip limits if compat={clip ylimits=false},
+ stack plots=y,
+ stack dir=#1,
+ /tikz/ybar,
+ stacked since 1.9,
+ activate nodes near coords ybar stacked,
+ stacked since 1.13,
+ },
+ /pgfplots/ybar stacked/.default=plus,
+ /pgfplots/xbar interval stacked/.style={
+ bar direction=x,
+ /pgfplots/set point meta if empty=x,%
+ bar cycle list,
+ clip limits if compat={clip xlimits=false},
+ single xbar legend,
+ stack plots=x,
+ stack dir=#1,
+ /tikz/xbar interval,
+ stacked since 1.13,
+ },
+ /pgfplots/xbar interval stacked/.default=plus,
+ /pgfplots/ybar interval stacked/.style={
+ bar direction=y,
+ /pgfplots/set point meta if empty=f(x),%
+ bar cycle list,
+ single ybar legend,
+ clip limits if compat={clip ylimits=false},
+ stack plots=y,
+ stack dir=#1,
+ /tikz/ybar interval,
+ stacked since 1.13,
+ },
+ /pgfplots/ybar interval stacked/.default=plus,
+ /pgfplots/yticklabel interval boundaries/.style={%
+ y tick label as interval,
+ yticklabel={$\pgfmathprintnumber{\tick}$ -- $\pgfmathprintnumber{\nexttick}$}
+ },
+ /pgfplots/xticklabel interval boundaries/.style={%
+ x tick label as interval,
+ xticklabel={$\pgfmathprintnumber{\tick}$ -- $\pgfmathprintnumber{\nexttick}$}
+ },
+ /pgfplots/plot file/skip first/.is if=pgfplots@plot@file@skipfirst,
+ /pgfplots/plot file/skip first/.default=true,
+ /pgfplots/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=,
+ /pgfplots/plot graphics/includegraphics cmd/.initial=\includegraphics,
+ /pgfplots/plot graphics/xmin/.initial=,
+ /pgfplots/plot graphics/xmax/.initial=,
+ /pgfplots/plot graphics/ymin/.initial=,
+ /pgfplots/plot graphics/ymax/.initial=,
+ /pgfplots/plot graphics/zmin/.initial=,
+ /pgfplots/plot graphics/zmax/.initial=,
+ %
+ % a) to provide a bounding box: points={(0,1) (0,2)}
+ % or b) to squeeze the graphics into internal image coordinates:
+ % points={(0,1,0) => (0,4) (0,0,1) => (40,600)}
+ % or c) both of them.
+ /pgfplots/plot graphics/points/.initial=,
+ /pgfplots/plot graphics/auto adjust axis/.is if=pgfplots@plot@graphics@autoadjustaxis,
+ /pgfplots/plot graphics/auto adjust axis=true,
+ /pgfplots/plot graphics/snap z/.initial=0.02,
+ % possible values: debug=<empty>|false|true|visual
+ /pgfplots/plot graphics/debug/.initial=,
+ /pgfplots/plot graphics/debug/.default=true,
+ /pgfplots/plot graphics/squeeze tol/.initial=2pt,
+ %
+ % this command key should defined \pgfmathresult to be
+ % \pgfmathresult -> {{<wd>}{<ht>}}
+ % where <wd> is the natural width of the input image and
+ % <ht> is the natural height.
+ % The input image file name is available as 'plot graphics/src'.
+ % The default implementation invoked 'lowlevel draw={}{}' and
+ % measures the resulting dimensions.
+ /pgfplots/plot graphics/lowlevel get natural size/.code={%
+ \pgfplots@plot@handler@graphics@getnaturalsize
+ },
+ /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,
+ outer sep=0pt,
+ every node/.style={},
+ anchor=south west,
+ at={(0pt,0pt)},
+ rectangle
+ },
+ /tikz/pos segment/.initial=,
+ % empty line=none|auto|scanline|nan|jump
+ % nan and jump is the same.
+ /pgfplots/empty line/.initial=auto,
+ % '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
+ \pgfplots@perpointmeta@expandtrue
+ \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/patch/.code={%
+ \pgfkeysalso{/pgfplots/surf=#1,/pgfplots/mesh input=patches,/pgfplots/every patch}%
+ },%
+ %
+ /pgfplots/mesh/color input/.is choice,
+ /pgfplots/mesh/color input/colormap/.code=\def\pgfplotsplothandlermesh@colorinput{0},%
+ /pgfplots/mesh/color input/explicit/.code={%
+ \def\pgfplotsplothandlermesh@colorinput{1}%
+ \def\pgfplotsplothandlermesh@colorinput@mathparse{0}%
+ %
+ \pgfplotsaxisifhaspointmeta{%
+ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname
+ % ok.
+ \else
+ % oh. the point meta is numeric, i.e. it will be
+ % mapped. Change to symbolic for explicit color input:
+ \pgfkeysalso{/pgfplots/point meta/explicit symbolic}%
+ \fi
+ }{%
+ % there is no point meta. Set it to "reasonable" defaults:
+ \pgfkeysalso{/pgfplots/point meta/explicit symbolic}%
+ }%
+ \pgfplots@perpointmeta@expandtrue
+ },%
+ /pgfplots/mesh/color input/explicit mathparse/.code={%
+ \pgfkeysalso{/pgfplots/mesh/color input/explicit}%
+ \def\pgfplotsplothandlermesh@colorinput@mathparse{1}%
+ \pgfplots@perpointmeta@expandtrue
+ },%
+ /pgfplots/mesh/color input=colormap,
+ %
+ /pgfplots/mesh/colorspace explicit color output/.initial=rgb,
+ /pgfplots/mesh/colorspace explicit color input/.initial=rgb,
+ %
+ /pgfplots/every patch/.style={miter limit=1},
+ /pgfplots/patch table/value/.initial=,
+ /pgfplots/patch table/.code={
+ \pgfkeyssetvalue{/pgfplots/patch table/value}{#1}%
+ \pgfplotsplothandlermesh@patchtable@hascdatafalse
+ },
+ /pgfplots/patch table with point meta/.code={%
+ \pgfkeyssetvalue{/pgfplots/patch table/value}{#1}%
+ \pgfplotsplothandlermesh@patchtable@hascdatatrue
+ \pgfplotsplothandlermesh@patchtable@cdata@individualfalse
+ \pgfkeysalso{/pgfplots/point meta/explicit}%
+ },
+ /pgfplots/patch table with individual point meta/.code={%
+ \pgfkeyssetvalue{/pgfplots/patch table/value}{#1}%
+ \pgfplotsplothandlermesh@patchtable@hascdatatrue
+ \pgfplotsplothandlermesh@patchtable@cdata@individualtrue
+ \pgfkeysalso{/pgfplots/point meta/explicit}%
+ },
+ /pgfplots/patch type/.initial=,
+ /pgfplots/patch type sampling/.is if=pgfplotsplothandlermesh@patch@type@sampling,
+ /pgfplots/patch internal depth/.is if=pgfplotsplothandlermesh@internaldepth,
+ /pgfplots/patch internal depth=true,
+ /pgfplots/patch to triangles/.is choice,
+ /pgfplots/patch to triangles/false/.code= {\def\pgfplotsplothandlermesh@triangulate{0}},
+ /pgfplots/patch to triangles/true/.code= {\def\pgfplotsplothandlermesh@triangulate{1}},
+ /pgfplots/patch to triangles/true with edges/.code= {\def\pgfplotsplothandlermesh@triangulate{2}},
+ /pgfplots/patch to triangles=false,
+ /pgfplots/patch to triangles/.default=true,
+ /pgfplots/mesh input/.is choice,
+ /pgfplots/mesh input/lattice/.code= {\def\pgfplotsplothandlermesh@matrixinput{1}},
+ /pgfplots/mesh input/patches/.code= {\def\pgfplotsplothandlermesh@matrixinput{0}},
+ /pgfplots/mesh input/image/.code= {\def\pgfplotsplothandlermesh@matrixinput{2}},
+ /pgfplots/mesh input/lattice,
+ /pgfplots/patch refines/.initial=0,
+ /pgfplots/hide refined edges/.is if=pgfplotsplothandlermesh@hide@refined@edges,
+ /pgfplots/hide refined edges/.default=true,
+ /pgfplots/mesh/refines/.style={/pgfplots/patch refines={#1}},
+ /pgfplots/mesh/rows/.initial=,
+ /pgfplots/mesh/cols/.initial=,
+ /pgfplots/mesh/scanline verbose/.is if=pgfplots@scanline@verbose,%
+ /pgfplots/mesh/scanline verbose/.default=true,
+ %
+ % this is currently only a debug feature. Perhaps it will never
+ % reach production state because of the lacking z buffering for
+ % this technique.
+ /pgfplots/mesh/show normals/.is if=pgfplotsplothandlermesh@shownormals,
+ /pgfplots/mesh/show normals/.default=true,
+ /pgfplots/mesh/show normals length factor/.initial=50,
+ %
+ /pgfplots/late options/.code={%
+ \pgfplotssetlateoptions{#1}%
+ },
+ %
+ /pgfplots/matrix plot/.style={%
+ /pgfplots/late options={%
+ /pgfplots/y dir=reverse,
+ /pgfplots/axis on top,
+ },
+ %
+ /pgfplots/matrix plot*,
+ },
+ /pgfplots/matrix plot*/.style={%
+ /pgfplots/surf,
+ /pgfplots/mesh input=image,
+ /pgfplots/shader=flat corner,
+ /pgfplots/z buffer=none,
+ },
+ /pgfplots/imagesc/.style={/pgfplots/matrix plot},%
+ /pgfplots/imagesc*/.style={/pgfplots/matrix plot*},%
+ %
+ /pgfplots/every patch normal/.style={-stealth,red},
+ %
+ /pgfplots/mesh/interior colormap/.code 2 args={%
+ \pgfplotscreatecolormap{#1}{#2}%
+ \pgfkeysalso{/pgfplots/mesh/interior colormap name=#1}%
+ },
+ /pgfplots/mesh/interior colormap name/.initial=,
+ /pgfplots/mesh/interior colormap thresh/.initial=0,
+ /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 interp/.code={\def\pgfplotsplothandlermesh@shader{3}},
+ /pgfplots/shader/faceted,
+ /pgfplots/faceted color/.initial=mapped color!80!black,
+ /pgfplots/marker layer/.initial=auto,
+ /pgfplots/clip marker paths/.is if=pgfplots@clip@marker@paths,
+ /pgfplots/clip marker paths/.default=true,
+ /pgfplots/axis on top/.is if=pgfplots@axis@on@top,
+ /pgfplots/axis on top/.default=true,
+ /pgfplots/invoke before crossref tikzpicture/.initial={%
+ \expandafter\ifx\csname tikzappendtofigurename\endcsname\relax
+ \else
+ \begingroup
+ \tikzappendtofigurename{_crossref}%
+ \fi
+ },
+ /pgfplots/invoke after crossref tikzpicture/.initial={%
+ \expandafter\ifx\csname tikzappendtofigurename\endcsname\relax
+ \else
+ \endgroup
+ \fi
+ },%
+ /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={},
+ %
+ /pgfplots/symbolic coords/magic prefix/.initial={[normalized]},
+ % #1 : the coordinate in question. Can be x,y,z, or even hist/data
+ % or similar constructs.
+ % #2 : {<symbol1>,<symbol2>,....<symboln>}
+ /pgfplots/symbolic coords/.code 2 args={%
+ \expandafter\pgfplotsarraynew\csname pgfplots@symbolic@coords@#1@inverse\endcsname{#2}%
+ \expandafter\pgfplotsarrayforeachungrouped\csname pgfplots@symbolic@coords@#1@inverse\endcsname\as\pgfplots@loc@TMPa{%
+ \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPa
+% \message{Defining symb coords \pgfplots@loc@TMPa^^J}%
+ \expandafter\edef\csname pgfp@symb@coords@#1@\pgfplots@loc@TMPa\endcsname{\pgfplotsarrayforeachindex}%
+ }%
+ \pgfkeysgetvalue{/pgfplots/symbolic coords/magic prefix}\pgfplots@symb@magic@prefix
+ \pgfkeysdef{/pgfplots/#1 coord trafo}{%
+ \expandafter\pgfplotsutilifstartswith\expandafter{\pgfplots@symb@magic@prefix}{##1}{%
+ % Ah - something like [normalized]1.5
+ % we need to assign the suffix 1.5:
+ \edef\pgfmathresult{\pgfplotsretval}%
+ }{%
+ % ensure that special (unexpandable) characters are
+ % preserved:
+ \def\pgfplots@loc@TMPa{##1}%
+ \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPa
+ \pgfutil@ifundefined{pgfp@symb@coords@#1@\pgfplots@loc@TMPa}{%
+ \t@pgfplots@toka={##1}%
+ \t@pgfplots@tokb={#2}%
+ \pgfplots@error{Sorry, the input coordinate `\the\t@pgfplots@toka' has not been defined with 'symbolic #1 coords={\the\t@pgfplots@tokb}... Maybe it has been misspelled? Or did you mean something like \pgfplots@symb@magic@prefix\the\t@pgfplots@toka?}%
+ \def\pgfmathresult{0}%
+ }{%
+ \edef\pgfmathresult{\csname pgfp@symb@coords@#1@\pgfplots@loc@TMPa\endcsname}%
+ }%
+ }%
+%\message{#1 coord trafo{\pgfplots@loc@TMPa} --> \pgfmathresult^^J}%
+ }%
+ \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
+ \edef\pgfplots@loc@TMPa{\expandafter\pgfplotsarraysizeof\csname pgfplots@symbolic@coords@#1@inverse\endcsname}%
+ \count1=\pgfplots@loc@TMPa\relax
+ \ifnum\count0<\count1
+ \else
+ \count0=\count1
+ \advance\count0 by-1
+ \fi
+ \fi
+ \expandafter\pgfplotsarrayselect\expandafter\count\expandafter0\expandafter\of\csname pgfplots@symbolic@coords@#1@inverse\endcsname\to\pgfmathresult
+%\message{#1 coord inv trafo{##1} -->\the\count0 --> \meaning\pgfmathresult^^J}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ }%
+ \pgfkeysifdefined{/pgfplots/#1ticklabel/.@cmd}{%
+ \pgfkeysalso{%
+ /pgfplots/#1ticklabel={\pgfplots@ticklabel@typeset@arg\tick},%
+ /pgfplots/scaled #1 ticks=false,%
+ /pgfplots/plot coordinates/math parser=false,%
+ }%
+ }{%
+ % OK. The style can be used for other coordinates as well
+ % (like hist/data)
+ }%
+ %
+ \pgfkeysifdefined{/pgfplots/#1 is expr}{%
+ \pgfkeyssetvalue{/pgfplots/#1 is expr}{0}%
+ }{}%
+ %
+ % Allow a callback (optional)
+ \pgfkeysifdefined{/pgfplots/#1/@execute on coord trafo changed/.@cmd}{%
+ \pgfkeysalso {/pgfplots/#1/@execute on coord trafo changed}%
+ }{}%
+ },%
+ /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={%
+ \pgfplots@pgfkeys@set@point@meta@value{#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/expr/.code={\pgfplotssetpointmetainput{expr}{#1}},%
+ /pgfplots/point meta/explicit/.code={\pgfplotssetpointmetainput{explicit}{}},%
+ /pgfplots/point meta/explicit symbolic/.code={\pgfplotssetpointmetainput{explicit symbolic}{}},%
+ /pgfplots/point meta/f(x)/.code={\pgfplotssetpointmetainput{f(x)}{}},%
+ /pgfplots/point meta/TeX code/.code={\pgfplotssetpointmetainput{TeX code}{#1}},%
+ /pgfplots/point meta/TeX code/.value required,
+ /pgfplots/point meta/TeX code symbolic/.code={\pgfplotssetpointmetainput{TeX code symbolic}{#1}},%
+ /pgfplots/point meta/TeX code symbolic/.value required,
+ /pgfplots/point meta/symbolic/.style={/pgfplots/point meta/TeX code symbolic={\edef\pgfplotspointmeta{#1}}},
+ /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/point meta/expand/.is if=pgfplots@perpointmeta@expand,
+ /pgfplots/point meta/expand=false,
+ %
+ /pgfplots/colormap name/.initial=hot,
+ /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/piecewise constant/.code={\def\pgfplots@colormap@access{c}},%
+ /pgfplots/colormap access/piecewise const/.code= {\def\pgfplots@colormap@access{c}},%
+ /pgfplots/colormap access/const/.code= {\def\pgfplots@colormap@access{c}},%
+ /pgfplots/colormap access/piecewise linear/.style={/pgfplots/colormap access/map},
+ /pgfplots/colormap access/map,%
+ %/pgfplots/colormap default colorspace/.initial=auto,% declared in pgfplotscolormap.code.tex
+ /pgfplots/colormap/.code 2 args={%
+ \pgfplotscreatecolormap{#1}{#2}%
+ \pgfkeysalso{/pgfplots/colormap name=#1}%
+ },
+ %
+ % #1: a style name like '/pgfplots/colormap/hot'
+ /pgfplots/ensure colormap/.code={%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@ensure@old@cm
+ \pgfkeysalso{#1}%
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplots@ensure@old@cm
+ },
+ % a backwards compatibility switch:
+ /pgfplots/colormap uniform/.is choice,
+ /pgfplots/colormap uniform/always/.code={\def\pgfplots@colormap@uniform@choice{0}},
+ /pgfplots/colormap uniform/if requested/.code={\def\pgfplots@colormap@uniform@choice{1}},
+ /pgfplots/colormap uniform/always,
+ %
+ % #1: a number X with 0<= x <=0.9 which defines the relative size
+ % of the extra interval used for 'colormap access=piecewise constant'
+ % The value #1=0 disables the extra interval.
+ /pgfplots/colormap access/extra interval width/.code={%
+ \pgfplotscolormapsetadditionalintervalwidth{\pgfkeysvalueof{/pgfplots/colormap name}}{#1}%
+ },
+ %
+ /pgfplots/colormap/hot/.style={
+ % attention: copied from pgfplots.colormap.code.tex:
+ /pgfplots/colormap={hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)}
+ },
+ /pgfplots/colormap/viridis/.style={%
+ /pgfplots/colormap={viridis}{%
+ rgb=(0.267,0.00487,0.32942)
+ rgb=(0.28192,0.08966,0.41241)
+ rgb=(0.28026,0.1657,0.4765)
+ rgb=(0.26366,0.23763,0.51877)
+ rgb=(0.23744,0.3052,0.54192)
+ rgb=(0.20862,0.36775,0.55267)
+ rgb=(0.18225,0.42618,0.55711)
+ rgb=(0.1592,0.48224,0.55807)
+ rgb=(0.13777,0.53749,0.5549)
+ rgb=(0.12115,0.59274,0.54465)
+ rgb=(0.12808,0.64775,0.5235)
+ rgb=(0.18065,0.7014,0.48819)
+ rgb=(0.27415,0.75198,0.4366)
+ rgb=(0.39517,0.79747,0.36775)
+ rgb=(0.53561,0.83578,0.2819)
+ rgb=(0.68895,0.86545,0.18272)
+ rgb=(0.84557,0.88733,0.0997)
+ rgb=(0.99324,0.90616,0.14394)
+ }%
+ },
+ % instantiate viridis such that it is in memory by default:
+ /pgfplots/colormap/viridis,
+ % ... but reuse hot since it is used to be the default since the
+ % beginning:
+ /pgfplots/colormap name=hot,
+ %
+ /pgfplots/colormap/hot2/.style={
+ /pgfplots/colormap={hot2}{[1cm]rgb255(0cm)=(0,0,0) rgb255(3cm)=(255,0,0) rgb255(6cm)=(255,255,0) rgb255(8cm)=(255,255,255)}
+ },
+ /pgfplots/colormap/bluered/.style={
+ /pgfplots/colormap={bluered}{rgb255(0cm)=(0,0,180); rgb255(1cm)=(0,255,255); rgb255(2cm)=(100,255,0); rgb255(3cm)=(255,255,0); rgb255(4cm)=(255,0,0); rgb255(5cm)=(128,0,0)}
+ },
+ /pgfplots/colormap/cool/.style={
+ /pgfplots/colormap={cool}{rgb255(0cm)=(255,255,255); rgb255(1cm)=(0,128,255); rgb255(2cm)=(255,0,255)}
+ },
+ /pgfplots/colormap/greenyellow/.style={
+ /pgfplots/colormap={greenyellow}{rgb255(0cm)=(0,128,0); rgb255(1cm)=(255,255,0)}
+ },
+ /pgfplots/colormap/redyellow/.style={
+ /pgfplots/colormap={redyellow}{rgb255(0cm)=(255,0,0); rgb255(1cm)=(255,255,0)}
+ },
+ /pgfplots/colormap/blackwhite/.style={
+ /pgfplots/colormap={blackwhite}{gray(0cm)=(0); gray(1cm)=(1)}
+ },
+ /pgfplots/colormap/violet/.style={
+ /pgfplots/colormap={violet}{rgb255=(25,25,122) color=(white) rgb255=(238,140,238)}
+ },
+ /pgfplots/colormap/jet/.style={
+ /pgfplots/colormap={jet}{rgb255(0cm)=(0,0,128) rgb255(1cm)=(0,0,255) rgb255(3cm)=(0,255,255) rgb255(5cm)=(255,255,0) rgb255(7cm)=(255,0,0) rgb255(8cm)=(128,0,0)}
+ },
+ %
+ % color of colormap={300}
+ % color of colormap={300 of viridis}
+ /pgfplots/color of colormap/.code={%
+ \pgfplots@color@of@colormap{color of colormap={#1}}%
+ },%
+ /tikz/color of colormap/.style={/pgfplots/color of colormap={#1}},
+ % const color of colormap={300}
+ % const color of colormap={300 of viridis}
+ /pgfplots/const color of colormap/.code={%
+ \pgfplots@color@of@colormap{const color of colormap={#1}}%
+ },%
+ /tikz/color of colormap/.style={/pgfplots/color of colormap={#1}},
+ % index of colormap={4}
+ % index of colormap={4 of viridis}
+ /pgfplots/index of colormap/.code={%
+ \pgfplots@color@of@colormap{index of colormap={#1}}%
+ },%
+ /tikz/index of colormap/.style={/pgfplots/index of colormap={#1}},
+ %
+ % #1: the target color name
+ % #2: the color space (like 'rgb')
+ % #3: the color components
+ /tikz/color/.define/.code args={#1#2#3}{%
+ \pgfutil@definecolor{#1}{#2}{#3}%
+ },
+ %
+ %%
+ /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}%
+ \ifx\tikz@plot@mark\pgfplots@loc@TMPa
+ % this here happens only in older versions of pgf.
+ \pgfqkeys{/tikz}{mark=*}%
+ \else
+ \ifx\tikz@plot@mark\pgfutil@empty
+ \pgfqkeys{/tikz}{mark=*}%
+ \fi
+ \fi
+ },
+ /pgfplots/scatter/.default=true,
+ /pgfplots/scatter src/.style={/pgfplots/point meta={#1}},
+ /tikz/scatter/.style={/pgfplots/scatter=#1},
+ %
+ % ARGUMENTS: the macros
+ % - \pgfplotspointmeta
+ % - \pgfplotspointmetarange
+ % - \pgfplotspointmetatransformed
+ % - \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/position/.is choice,
+ /pgfplots/scatter/position/absolute/.code={\def\pgfplots@scatter@position{a}},
+ /pgfplots/scatter/position/relative/.code={\def\pgfplots@scatter@position{r}},
+ /pgfplots/scatter/position=relative,
+ /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/.prefix code={\endscope}
+ },
+ /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/.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!
+ \def\pgfplots@loc@TMPa##1=##2\pgfplots@EEOI{%
+ \expandafter\def\csname pgfp@scatter@class@##1\endcsname{##2}%
+ }%
+ \pgfplotsforeachentryinCSV{\pgfplots@loc@TMPb}{#1}{%
+ \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb\pgfplots@EEOI
+ }%
+ %
+ \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@
+ % 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
+ \fi
+ }%
+ }%
+ },
+ /pgfplots/refstyle/.code={%
+ \pgfutil@ifundefined{pgfplots@labelstyle@#1}{%
+ \G@refundefinedtrue
+ \@latex@warning{Reference `#1' on page \thepage \space undefined}%
+ }{%
+ \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfplots@labelstyle@#1\endcsname}%
+ \expandafter\pgfkeysalso\expandafter{\the\t@pgfplots@toka}%
+ }%
+ },%
+ /pgfplots/forget plot/.is if=pgfplots@curplot@isirrelevant,
+ /pgfplots/forget plot/.default=true,
+ /pgfplots/normalsize/.style={
+ /pgfplots/width=240pt,
+ /pgfplots/height=207pt,
+ /pgfplots/max space between ticks=35,
+ },
+ /pgfplots/small/.style={
+ width=6.5cm,
+ height=,
+ tick label style={font=\footnotesize},
+ label style={font=\small},
+ max space between ticks=25,
+ },
+ /pgfplots/footnotesize/.style={
+ width=5cm,
+ height=,
+ legend style={font=\footnotesize},
+ tick label style={font=\footnotesize},
+ label style={font=\small},
+ title style={font=\small},
+ every axis title shift=0pt,
+ max space between ticks=15,
+ every mark/.append style={mark size=8},
+ major tick length=0.1cm,
+ minor tick length=0.066cm,
+ },
+ /pgfplots/tiny/.style={
+ width=4cm,
+ height=,
+ legend style={font=\tiny},
+ tick label style={font=\tiny},
+ label style={font=\tiny},
+ title style={font=\footnotesize},
+ every axis title shift=0pt,
+ max space between ticks=12,
+ every mark/.append style={mark size=6},
+ major tick length=0.1cm,
+ minor tick length=0.066cm,
+ every legend image post/.append style={scale=0.8},
+ },
+ /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/3d log sampling/.is if=pgfplots@threedim@log@sampling,
+ %
+ /pgfplots/trig format/.style={/pgf/trig format={#1}},
+ /pgfplots/xtick placement tolerance/.initial=0.05pt,
+ /pgfplots/ytick placement tolerance/.initial=0.05pt,
+ /pgfplots/ztick placement tolerance/.initial=0.05pt,
+ %
+ /pgfplots/correct polar positioning/.is choice,
+ /pgfplots/correct polar positioning/true/.code={\def\b@pgfplots@polaraxis@fix@positioning{1}},
+ /pgfplots/correct polar positioning/false/.code={\def\b@pgfplots@polaraxis@fix@positioning{0}},
+ %
+ /pgfplots/correct shader flat/.is choice,
+ /pgfplots/correct shader flat/true/.code={\def\b@pgfplots@correct@shader@flat{1}},
+ /pgfplots/correct shader flat/false/.code={\def\b@pgfplots@correct@shader@flat{0}},
+ %
+ /pgfplots/correct sampling/.is choice,
+ /pgfplots/correct sampling/true/.code={\let\pgfplotsforeachungroupeduniform@loop@mathengine=\pgfplotsforeachungroupeduniform@loop@mathengine@precise},
+ /pgfplots/correct sampling/false/.code={\let\pgfplotsforeachungroupeduniform@loop@mathengine=\pgfplotsforeachungroupeduniform@loop@mathengine@legacy},
+ %
+ /pgfplots/compat/anchors/.is choice,
+ /pgfplots/compat/anchors/pre 1.3/.code={%
+ \pgfplots@deprecated@anchorstrue
+ \pgfkeysalso{/pgfplots/correct polar positioning=false}%
+ },
+ /pgfplots/compat/anchors/1.3/.code= {%
+ \pgfplots@deprecated@anchorsfalse
+ \pgfkeysalso{/pgfplots/correct polar positioning=false}%
+ },%
+ /pgfplots/compat/anchors/1.4/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.5/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.5.1/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.6/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.7/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.8/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.9/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.10/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.11/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.12/.style= {/pgfplots/compat/anchors/1.3},%
+ /pgfplots/compat/anchors/1.13/.style= {/pgfplots/compat/anchors/1.3,/pgfplots/correct polar positioning=true},%
+ /pgfplots/compat/anchors/1.14/.style= {/pgfplots/compat/anchors/1.13},%
+ /pgfplots/compat/anchors/1.15/.style= {/pgfplots/compat/anchors/1.13},%
+ /pgfplots/compat/anchors/1.16/.style= {/pgfplots/compat/anchors/1.13},%
+ /pgfplots/compat/anchors/default/.style={/pgfplots/compat/anchors/1.3},%
+ %
+ /pgfplots/compat/empty line/.is choice,
+ /pgfplots/compat/empty line/pre 1.3/.code={\pgfplots@emptyline@compattrue},% FIXME: WAS \global
+ /pgfplots/compat/empty line/1.3/.style= {/pgfplots/compat/empty line/pre 1.3},%
+ /pgfplots/compat/empty line/1.4/.code= {\pgfplots@emptyline@compatfalse},%
+ /pgfplots/compat/empty line/1.5/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.5.1/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.6/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.7/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.8/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.9/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.10/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.11/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.12/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.13/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.14/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.15/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/1.16/.style= {/pgfplots/compat/empty line/1.4},%
+ /pgfplots/compat/empty line/default/.style= {/pgfplots/compat/empty line/1.4},%
+ %
+ /pgfplots/compat/path replacement/.is choice,
+ /pgfplots/compat/path replacement/pre 1.3/.code= {\pgfplots@path@replace@ellipsefalse},
+ /pgfplots/compat/path replacement/1.3/.style= {/pgfplots/compat/path replacement/pre 1.3},%
+ /pgfplots/compat/path replacement/1.4/.style= {/pgfplots/compat/path replacement/pre 1.3},
+ /pgfplots/compat/path replacement/1.5/.style= {/pgfplots/compat/path replacement/pre 1.3},%
+ /pgfplots/compat/path replacement/1.5.1/.code= {\pgfplots@path@replace@ellipsetrue},%
+ /pgfplots/compat/path replacement/1.6/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.7/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.8/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.9/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.10/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.11/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.12/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.13/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.14/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.15/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/1.16/.style= {/pgfplots/compat/path replacement/1.5.1},
+ /pgfplots/compat/path replacement/default/.style= {/pgfplots/compat/path replacement/pre 1.3},%
+ %
+ /pgfplots/compat/pgfpoint substitution/.is choice,
+ /pgfplots/compat/pgfpoint substitution/pre 1.3/.code= {\pgfplots@substitute@pgfpointfalse},
+ /pgfplots/compat/pgfpoint substitution/1.3/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},%
+ /pgfplots/compat/pgfpoint substitution/1.4/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},
+ /pgfplots/compat/pgfpoint substitution/1.5/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},%
+ /pgfplots/compat/pgfpoint substitution/1.5.1/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},%
+ /pgfplots/compat/pgfpoint substitution/1.6/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},
+ /pgfplots/compat/pgfpoint substitution/1.7/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},
+ /pgfplots/compat/pgfpoint substitution/1.8/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},
+ /pgfplots/compat/pgfpoint substitution/1.9/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},
+ /pgfplots/compat/pgfpoint substitution/1.10/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},
+ /pgfplots/compat/pgfpoint substitution/1.11/.code= {\pgfplots@substitute@pgfpointtrue},
+ /pgfplots/compat/pgfpoint substitution/1.12/.style= {/pgfplots/compat/pgfpoint substitution/1.11},
+ /pgfplots/compat/pgfpoint substitution/1.13/.style= {/pgfplots/compat/pgfpoint substitution/1.11},
+ /pgfplots/compat/pgfpoint substitution/1.14/.style= {/pgfplots/compat/pgfpoint substitution/1.11},
+ /pgfplots/compat/pgfpoint substitution/1.15/.style= {/pgfplots/compat/pgfpoint substitution/1.11},
+ /pgfplots/compat/pgfpoint substitution/1.16/.style= {/pgfplots/compat/pgfpoint substitution/1.11},
+ /pgfplots/compat/pgfpoint substitution/default/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},%
+ %ellipse/.is if=pgfplots@path@replace@ellipse,
+ %
+ /pgfplots/compat/labels/.is choice,
+ /pgfplots/compat/labels/pre 1.3/.style={%
+ /pgfplots/compat/axis line style pre 1.8,
+ /pgfplots/xlabel absolute,
+ /pgfplots/ylabel absolute},%
+ /pgfplots/compat/labels/1.3/.style={%
+ /pgfplots/compat/axis line style pre 1.8,
+ /pgfplots/xlabel near ticks,
+ /pgfplots/ylabel near ticks},%
+ /pgfplots/compat/labels/1.4/.style= {/pgfplots/compat/labels/1.3},%
+ /pgfplots/compat/labels/1.5/.style= {/pgfplots/compat/labels/1.3},%
+ /pgfplots/compat/labels/1.5.1/.style= {/pgfplots/compat/labels/1.3},%
+ /pgfplots/compat/labels/1.6/.style= {/pgfplots/compat/labels/1.3},%
+ /pgfplots/compat/labels/1.7/.style= {/pgfplots/compat/labels/1.3},%
+ /pgfplots/compat/labels/1.8/.style= {
+ /pgfplots/compat/labels/1.3,
+ /pgfplots/compat/axis line style post 1.8,
+ },%
+ /pgfplots/compat/labels/1.9/.style= {/pgfplots/compat/labels/1.8},%
+ /pgfplots/compat/labels/1.10/.style= {/pgfplots/compat/labels/1.8},%
+ /pgfplots/compat/labels/1.11/.style= {/pgfplots/compat/labels/1.8},%
+ /pgfplots/compat/labels/1.12/.style= {/pgfplots/compat/labels/1.8},%
+ /pgfplots/compat/labels/1.13/.style= {/pgfplots/compat/labels/1.8},%
+ /pgfplots/compat/labels/1.14/.style= {/pgfplots/compat/labels/1.8},%
+ /pgfplots/compat/labels/1.15/.style= {/pgfplots/compat/labels/1.8},%
+ /pgfplots/compat/labels/1.16/.style= {/pgfplots/compat/labels/1.8},%
+ /pgfplots/compat/labels/default/.style= {/pgfplots/compat/labels/pre 1.3},% maintain backwards compatibility
+ %
+ /pgfplots/compat/bar nodes/.is choice,
+ /pgfplots/compat/bar nodes/pre 1.3/.style={%
+ /pgfplots/stacked since 1.9/.style={
+ /pgfplots/stacked ignores zero=false,% backwards compatible.
+ },%
+ /pgfplots/stacked since 1.13/.style={
+ /pgfplots/stack negative=on previous,% backwards compatible.
+ },%
+ %
+ % empty - early versions did not know anything about them.
+ % But people might have arrived at suitable work-arounds; do
+ % not destroy their work.
+ /pgfplots/activate nodes near coords xbar stacked/.style={%
+ /pgfplots/set point meta if empty=f(x),%
+ },%
+ /pgfplots/activate nodes near coords ybar stacked/.code={%
+ /pgfplots/set point meta if empty=f(x),%
+ },%
+ },%
+ /pgfplots/compat/bar nodes/1.3/.style= {/pgfplots/compat/bar nodes/pre 1.3},%
+ /pgfplots/compat/bar nodes/1.4/.style= {/pgfplots/compat/bar nodes/pre 1.3},%
+ /pgfplots/compat/bar nodes/1.5/.style= {/pgfplots/compat/bar nodes/pre 1.3},%
+ /pgfplots/compat/bar nodes/1.5.1/.style= {/pgfplots/compat/bar nodes/pre 1.3},%
+ /pgfplots/compat/bar nodes/1.6/.style= {/pgfplots/compat/bar nodes/pre 1.3},%
+ /pgfplots/compat/bar nodes/1.7/.style= {/pgfplots/compat/bar nodes/pre 1.3},%
+ /pgfplots/compat/bar nodes/1.8/.style= {/pgfplots/compat/bar nodes/pre 1.3},%
+ /pgfplots/compat/bar nodes/1.9/.style= {
+ /pgfplots/stacked since 1.9/.style={
+ /pgfplots/stacked ignores zero=true,%
+ },
+ /pgfplots/stacked since 1.13/.style={
+ /pgfplots/stack negative=on previous,% backwards compatible.
+ },%
+ /pgfplots/activate nodes near coords xbar stacked/.style={
+ /pgfplots/nodes near coords xbar stacked configuration,
+ },
+ /pgfplots/activate nodes near coords ybar stacked/.style={
+ /pgfplots/nodes near coords ybar stacked configuration,
+ },
+ },%
+ /pgfplots/compat/bar nodes/1.10/.style= {/pgfplots/compat/bar nodes/1.9},%
+ /pgfplots/compat/bar nodes/1.11/.style= {/pgfplots/compat/bar nodes/1.9},%
+ /pgfplots/compat/bar nodes/1.12/.style= {/pgfplots/compat/bar nodes/1.9},%
+ /pgfplots/compat/bar nodes/1.13/.style= {
+ /pgfplots/compat/bar nodes/1.9,
+ /pgfplots/stacked since 1.13/.style={
+ /pgfplots/stack negative=separate,
+ },%
+ },%
+ /pgfplots/compat/bar nodes/1.14/.style= {/pgfplots/compat/bar nodes/1.13},%
+ /pgfplots/compat/bar nodes/1.15/.style= {/pgfplots/compat/bar nodes/1.13},%
+ /pgfplots/compat/bar nodes/1.16/.style= {/pgfplots/compat/bar nodes/1.13},%
+ /pgfplots/compat/bar nodes/default/.style= {/pgfplots/compat/bar nodes/pre 1.3},% maintain backwards compatibility
+ /pgfplots/compat/bar nodes/default,
+ %
+ % search for the \pgfplots@compat@scaling@coordmath -- using float
+ % is much more accurate. But it changes the spacing slightly.
+ /pgfplots/compat/scaling/.is choice,
+ /pgfplots/compat/scaling/pre 1.3/.code={%
+ \def\pgfplots@compat@scaling@zunitfix@enable{0}%
+ \def\pgfplots@compat@scaling@coordmath{pgfbasic}%
+ \def\pgfplots@compat@scaling@coordmath@final{pgfbasic}%
+ },
+ /pgfplots/compat/scaling/1.3/.style={/pgfplots/compat/scaling/pre 1.3},
+ /pgfplots/compat/scaling/1.4/.code={%
+ \def\pgfplots@compat@scaling@zunitfix@enable{1}%
+ \def\pgfplots@compat@scaling@coordmath{float}%
+ \def\pgfplots@compat@scaling@coordmath@final{pgfbasic}%
+ },
+ /pgfplots/compat/scaling/1.5/.style={/pgfplots/compat/scaling/1.4},
+ /pgfplots/compat/scaling/1.5.1/.style={/pgfplots/compat/scaling/1.4},
+ /pgfplots/compat/scaling/1.6/.code={%
+ \def\pgfplots@compat@scaling@zunitfix@enable{1}%
+ \def\pgfplots@compat@scaling@coordmath{float}%
+ \def\pgfplots@compat@scaling@coordmath@final{float}%
+ },
+ /pgfplots/compat/scaling/1.7/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.8/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.9/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.10/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.11/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.12/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.13/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.14/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.15/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/1.16/.style={/pgfplots/compat/scaling/1.6},
+ /pgfplots/compat/scaling/default/.style={/pgfplots/compat/scaling/1.4},
+ %
+ /pgfplots/compat/scale mode/.is choice,
+ /pgfplots/compat/scale mode/pre 1.3/.code=\def\pgfplots@compat@scale@mode@compatible@mode{1},%
+ /pgfplots/compat/scale mode/1.3/.style= {/pgfplots/compat/scale mode/pre 1.3},
+ /pgfplots/compat/scale mode/1.4/.style= {/pgfplots/compat/scale mode/pre 1.3},
+ /pgfplots/compat/scale mode/1.5/.style= {/pgfplots/compat/scale mode/pre 1.3},
+ /pgfplots/compat/scale mode/1.5.1/.style= {/pgfplots/compat/scale mode/pre 1.3},
+ /pgfplots/compat/scale mode/1.6/.code=\def\pgfplots@compat@scale@mode@compatible@mode{0},
+ /pgfplots/compat/scale mode/1.7/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.8/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.9/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.10/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.11/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.12/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.13/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.14/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.15/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/1.16/.style={/pgfplots/compat/scale mode/1.6},
+ /pgfplots/compat/scale mode/default/.style={/pgfplots/compat/scale mode/1.5},
+ %
+ %
+ /pgfplots/compat/plot3graphics/.is choice,
+ /pgfplots/compat/plot3graphics/pre 1.3/.style= {/pgfplots/compat/plot3graphics/1.5},
+ /pgfplots/compat/plot3graphics/1.3/.style= {/pgfplots/compat/plot3graphics/1.5},
+ /pgfplots/compat/plot3graphics/1.4/.style= {/pgfplots/compat/plot3graphics/1.5},%
+ /pgfplots/compat/plot3graphics/1.5/.code= {\def\b@pgfplots@compat@plot@graphics@threedim{1}},%
+ /pgfplots/compat/plot3graphics/1.5.1/.style= {/pgfplots/compat/plot3graphics/1.5},%
+ /pgfplots/compat/plot3graphics/1.6/.code= {\def\b@pgfplots@compat@plot@graphics@threedim{2}},%
+ /pgfplots/compat/plot3graphics/1.7/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.8/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.9/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.10/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.11/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.12/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.13/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.14/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.15/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/1.16/.style= {/pgfplots/compat/plot3graphics/1.6},%
+ /pgfplots/compat/plot3graphics/default/.style= {/pgfplots/compat/plot3graphics/1.5},%
+ %
+ % ATTENTION: there is a compatibility issue which slipped through
+ % the quality assurance: if tick labels where generated in scientific notation
+ % (NOT log tick labels; these are special), and the numbers were
+ % negative, the spacing changed as follows:
+ % pre 1.3: - 1*10^5 (binary minus sign)
+ % 1.3: - 1*10^5 (binary minus sign)
+ % 1.4: - 1*10^5 (binary minus sign)
+ % 1.5: -1*10^5 (unary minus sign - correct!)
+ % 1.6: -1*10^5 (unary minus sign - correct!)
+ % This is (was) a bug in the PGF number printer which has been
+ % fixed in the meantime; it occurred only if
+ % $\pgfmathprintnumber{-1e5}$ was used (i.e. with the '$' signs).
+ % Unfortunately, version 1.5 has been released without realizing
+ % the changes; I detected them right before the release of 1.6.
+ % Consequently, I cannot introduce compatibity switches without
+ % loosing compatibility.
+ %
+ % I chose to keep the correct unary minus sign. If you ever want
+ % to revert to the old version in order to keep spacing intact, use
+ %
+ % \pgfkeys{/pgf/compat/number printer=2.10}
+ %
+ % Risk: the size of such tick labels changed and the
+ % figure has been moved somewhat.
+ %
+ % Sorry.
+ %
+ /pgfplots/compat/bar width by units/.is choice,
+ /pgfplots/compat/bar width by units/pre 1.3/.code= {\def\b@pgfplots@compat@bar@width@units{1}},%
+ /pgfplots/compat/bar width by units/1.3/.style= {/pgfplots/compat/bar width by units/pre 1.3},
+ /pgfplots/compat/bar width by units/1.4/.style= {/pgfplots/compat/bar width by units/pre 1.3},%
+ /pgfplots/compat/bar width by units/1.5/.style= {/pgfplots/compat/bar width by units/pre 1.3},%
+ /pgfplots/compat/bar width by units/1.5.1/.style= {/pgfplots/compat/bar width by units/pre 1.3},%
+ /pgfplots/compat/bar width by units/1.6/.style= {/pgfplots/compat/bar width by units/pre 1.3},%
+ /pgfplots/compat/bar width by units/1.7/.code= {\def\b@pgfplots@compat@bar@width@units{0}},%
+ /pgfplots/compat/bar width by units/1.8/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/1.9/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/1.10/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/1.11/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/1.12/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/1.13/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/1.14/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/1.15/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/1.16/.style= {/pgfplots/compat/bar width by units/1.7},
+ /pgfplots/compat/bar width by units/default/.style={/pgfplots/compat/bar width by units/pre 1.3},
+ %
+ /pgfplots/compat/BB/.is choice,
+ /pgfplots/compat/BB/pre 1.3/.style={/pgfplots/clip bounding box=default tikz},%
+ /pgfplots/compat/BB/1.3/.style= {/pgfplots/compat/BB/pre 1.3},
+ /pgfplots/compat/BB/1.4/.style= {/pgfplots/compat/BB/pre 1.3},%
+ /pgfplots/compat/BB/1.5/.style= {/pgfplots/compat/BB/pre 1.3},%
+ /pgfplots/compat/BB/1.5.1/.style= {/pgfplots/compat/BB/pre 1.3},%
+ /pgfplots/compat/BB/1.6/.style= {/pgfplots/compat/BB/pre 1.3},%
+ /pgfplots/compat/BB/1.7/.style= {/pgfplots/compat/BB/pre 1.3},%
+ /pgfplots/compat/BB/1.8/.style= {/pgfplots/clip bounding box=upper bound},%
+ /pgfplots/compat/BB/1.9/.style= {/pgfplots/compat/BB/1.8},%
+ /pgfplots/compat/BB/1.10/.style= {/pgfplots/compat/BB/1.8},%
+ /pgfplots/compat/BB/1.11/.style= {/pgfplots/compat/BB/1.8},%
+ /pgfplots/compat/BB/1.12/.style= {/pgfplots/compat/BB/1.8},%
+ /pgfplots/compat/BB/1.13/.style= {/pgfplots/compat/BB/1.8},%
+ /pgfplots/compat/BB/1.14/.style= {/pgfplots/compat/BB/1.8},%
+ /pgfplots/compat/BB/1.15/.style= {/pgfplots/compat/BB/1.8},%
+ /pgfplots/compat/BB/1.16/.style= {/pgfplots/compat/BB/1.8},%
+ /pgfplots/compat/BB/default/.style={/pgfplots/compat/BB/pre 1.3},
+ %
+ /pgfplots/compat/general/.is choice,
+ /pgfplots/compat/general/pre 1.3/.style={
+ /pgfplots/log origin=infty,
+ /pgfplots/enable tick line clipping=true,
+ /pgfplots/correct shader flat=false,
+ /pgfplots/correct sampling=false,
+ /pgfplots/lua backend=false,
+ /pgfplots/colormap uniform=always,
+ /pgfplots/compat/library hook={statistics}{/pgfplots/boxplot/estimator=legacy,/pgfplots/boxplot/ensure mark=false},
+ /pgfplots/colorbar pgfshading,
+ /pgfplots/colorbar=false,
+ /pgfplots/3d log sampling=false,
+ /pgfplots/clip limits compat=true,
+ },%
+ /pgfplots/compat/general/1.3/.style= {/pgfplots/compat/general/pre 1.3},
+ /pgfplots/compat/general/1.4/.style= {/pgfplots/compat/general/pre 1.3},%
+ /pgfplots/compat/general/1.5/.style= {
+ /pgfplots/compat/general/pre 1.3,
+ /pgfplots/log origin=0,
+ /pgfplots/enable tick line clipping=true,
+ },%
+ /pgfplots/compat/general/1.5.1/.style= {/pgfplots/compat/general/1.5},%
+ /pgfplots/compat/general/1.6/.style= {/pgfplots/compat/general/1.5},%
+ /pgfplots/compat/general/1.7/.style= {/pgfplots/compat/general/1.5},%
+ /pgfplots/compat/general/1.8/.style= {/pgfplots/compat/general/1.5},%
+ /pgfplots/compat/general/1.9/.style= {/pgfplots/compat/general/1.5},%
+ /pgfplots/compat/general/1.10/.style= {/pgfplots/compat/general/1.5},%
+ /pgfplots/compat/general/1.11/.style= {
+ /pgfplots/compat/general/1.5,
+ /pgfplots/enable tick line clipping=false,
+ },%
+ /pgfplots/compat/general/1.12/.style= {
+ /pgfplots/compat/general/1.11,
+ /pgfplots/lua backend,
+ /pgfplots/compat/library hook={statistics}{/pgfplots/boxplot/estimator=Excel,/pgfplots/boxplot/ensure mark=true},
+ },%
+ /pgfplots/compat/general/1.13/.style= {%
+ /pgfplots/compat/general/1.12,
+ /pgfplots/correct shader flat=true,
+ /pgfplots/correct sampling=true,
+ /pgfplots/colormap uniform=always,
+ },%
+ /pgfplots/compat/general/1.14/.style= {%
+ /pgfplots/compat/general/1.13,
+ /pgfplots/colormap uniform=if requested,
+ % no -- do _not_ activate that here: it is correct and
+ % simplifies the code, but many viewers (pdf.js, evince,
+ % sumatrapdf) are better off with pgfshadings:
+ %/pgfplots/colorbar sampled={surf,shader=interp,samples=2},
+ %/pgfplots/colorbar=false,
+ },%
+ /pgfplots/compat/general/1.15/.style= {%
+ /pgfplots/compat/general/1.14,
+ /pgfplots/3d log sampling=true, % FIXME finish this feature: see unittest_log_sampling_3d
+ /pgfplots/clip limits compat=false,
+ },%
+ /pgfplots/compat/general/1.16/.style= {/pgfplots/compat/general/1.15},%
+ /pgfplots/compat/general/default/.style={/pgfplots/compat/general/1.11},
+ %
+ /pgfplots/enable tick line clipping/.is if=pgfplots@enable@tick@line@clipping,
+ /pgfplots/enable tick line clipping/.default=true,
+ %
+ /pgfplots/default typeset ticklabel/.style={
+ /pgfplots/typeset ticklabel/.code={##1},
+ },
+ /pgfplots/default typeset ticklabel,
+ /pgfplots/typeset ticklabels with strut/.style={
+ /pgfplots/typeset ticklabel/.code={\strut ##1},
+ },
+ %
+ %
+ /pgfplots/compat/show suggested version/.is if=pgfplots@show@suggested@version,
+ /pgfplots/compat/show suggested version=true,
+ /pgfplots/compat/current/.initial=,
+ /pgfplots/compat/mostrecent/.initial=1.16,
+ /utils/exec={%
+ \pgfplotsutilforeachcommasep{%
+ /pgfplots/compat/current,%
+ /pgfplots/compat/anchors,%
+ /pgfplots/compat/labels,%
+ /pgfplots/compat/empty line,%
+ /pgfplots/compat/scaling,%
+ /pgfplots/compat/scale mode,%
+ /pgfplots/compat/general,%
+ /pgfplots/compat/BB,%
+ /pgfplots/compat/path replacement,%
+ /pgfplots/compat/plot3graphics,%
+ /pgfplots/compat/bar width by units,%
+ /pgfplots/compat/bar nodes,%
+ /pgfplots/compat/pgfpoint substitution,%
+ }\as\pgfplots@glob@TMPa{%
+ \ifx\pgfplots@glob@TMPa\pgfutil@empty
+ \else
+ \edef\pgfplots@glob@TMPb{%
+ \noexpand\pgfkeysdef{\pgfplots@glob@TMPa/newest}{%
+ \noexpand\pgfkeysalso{%
+ \pgfplots@glob@TMPa/\pgfkeysvalueof{/pgfplots/compat/mostrecent}%
+ }%
+ }%
+ }%
+ \pgfplots@glob@TMPb
+ \fi
+ }%
+ },
+ /pgfplots/compat/.code={%
+ \def\pgfplots@glob@TMPa{newest}%
+ \edef\pgfplots@glob@TMPb{#1}%
+ \ifx\pgfplots@glob@TMPb\pgfplots@glob@TMPa
+ \edef\pgfplots@glob@TMPa{\noexpand\pgfkeysalso{/pgfplots/compat=\pgfkeysvalueof{/pgfplots/compat/mostrecent}}}%
+ \pgfplots@glob@TMPa
+ \else
+ \pgfkeysifdefined{/pgfplots/compat/general/#1/.@cmd}{%
+ \pgfkeysalso{%
+ % ATTENTION: *every* /pgfplots/compat/ setting needs to accept
+ % the same choices due to this construction:
+ /pgfplots/compat/current=#1,% remember the value
+ /pgfplots/compat/anchors=#1,%
+ /pgfplots/compat/labels=#1,%
+ /pgfplots/compat/empty line=#1,%
+ /pgfplots/compat/scaling=#1,%
+ /pgfplots/compat/scale mode=#1,%
+ /pgfplots/compat/general=#1,%
+ /pgfplots/compat/BB=#1,%
+ /pgfplots/compat/path replacement=#1,%
+ /pgfplots/compat/plot3graphics=#1,%
+ /pgfplots/compat/bar width by units=#1,%
+ /pgfplots/compat/bar nodes=#1,%
+ /pgfplots/compat/pgfpoint substitution=#1,%
+ }%
+ }{%
+ \pgfplots@error{Sorry, 'compat=#1' is unknown in this context. Please use at most 'compat=\pgfkeysvalueof{/pgfplots/compat/mostrecent}'}%
+ }%
+ \fi
+ },%
+ /pgfplots/compat/.default=pre 1.3,% this is used if you type '\pgfplotsset{compat}' without value
+ /pgfplots/compat=default,% this is the initial config.
+ %
+ /pgfplots/show outer normals/.style={%
+ extra description/.append code={
+ \def\length{15}
+ \def\pgfplots@@draw@normal####1####2{%
+ \pgfpathmoveto{####1}
+ \pgfpathlineto{%
+ \pgfpointadd
+ {####1}
+ {\pgfqpointscale{\length}{\pgfplotspointouternormalvectorofticklabelaxis{####2}}}%
+ }%
+ }%
+ \draw[->,blue] \pgfextra{\pgfplots@@draw@normal{#1}{x}};
+ \draw[->,blue] \pgfextra{\pgfplots@@draw@normal{\pgfplotsqpointoutsideofticklabelaxisrel{x}{1}{0}}{x}};
+ \draw[->,red] \pgfextra{\pgfplots@@draw@normal{#1}{y}};
+ \draw[->,red] \pgfextra{\pgfplots@@draw@normal{\pgfplotsqpointoutsideofticklabelaxisrel{y}{1}{0}}{y}};
+ \ifpgfplots@threedim
+ \draw[->,black] \pgfextra{\pgfplots@@draw@normal{#1}{z}};
+ \draw[->,black] \pgfextra{\pgfplots@@draw@normal{\pgfplotsqpointoutsideofticklabelaxisrel{z}{1}{0}}{z}};
+ \fi
+ },
+ },
+ /pgfplots/show outer normals/.default={%
+ \ifpgfplots@threedim
+ \pgfplotspointrelaxisxy{-0.03}{-0.03}%
+ \else
+ \pgfplotspointrelaxisxyz{-0.03}{-0.03}{-0.03}%
+ \fi
+ },
+ /pgfplots/profiler/.code={%
+ \pgfutil@ifundefined{pgfprofilenew}{%
+ \usepgflibrary{profiler}%
+ }{}%
+ \pgfprofilenewforenvironment[all axes]{pgfplots@environment@opt}%
+ \pgfprofilesetrel{all axes}%
+ \pgfprofilenewforcommand[pgfkeys variants]{\pgfkeys}{1}%
+ \pgfprofilenewforcommand[pgfkeys variants]{\pgfqkeys}{2}%
+ \pgfprofilenewforcommand[pgfkeys variants]{\pgfkeysalso}{1}%
+ \pgfprofilenewforcommand[pgfkeys variants]{\pgfkeysfiltered}{1}%
+ \pgfprofilenewforcommand[pgfkeys variants]{\pgfqkeysfiltered}{2}%
+ \pgfprofilenewforcommand[pgfkeys variants]{\pgfkeysalsofiltered}{1}%
+ \pgfprofilenewforcommand[pgfplotsapplistXX handling]{\pgfplotsapplistXXpushback}{1}%
+ \pgfprofilenewforcommand[pgfplotsapplistXX handling]{\pgfplotsapplistXXflushbuffers}{0}%
+ \pgfprofilenewforcommandpattern
+ [pgfplots(app|prepend)listX handling]{\pgfplotsapplistXpushback}{##1\to##2}{{##1}\to{##2}}%
+ \pgfprofilenewforcommand
+ [pgfplots(app|prepend)listX handling]{\pgfplotsapplistXflushbuffers}{1}%
+ \pgfprofilenewforcommandpattern
+ [pgfplots(app|prepend)listX handling]{\pgfplotsprependlistXpushfront}{##1\to##2}{{##1}\to{##2}}%
+ \pgfprofilenewforcommand
+ [pgfplots(app|prepend)listX handling]{\pgfplotsprependlistXflushbuffers}{1}%
+ \pgfprofilenewforcommand
+ [pgfsys buffer]{\pgfsyssoftpath@addtocurrentpath}{1}%
+ \pgfprofilenewforcommand
+ [pgfsys buffer]{\pgfsyssoftpath@flushcurrentpath}{0}%
+ \pgfprofilenewforcommand[math parser (basic)]{\pgfmathparse}{1}%
+ \pgfprofilenewforcommand[math parser (fpu)]{\pgfmathfloatparse@}{1}%
+ \pgfprofilenewforcommand[math: division (basic)]{\pgfmathdivide@}{2}%
+ \pgfprofilenewforcommand[math: division (basic)]{\pgfmath@basic@divide@}{2}%
+ \pgfprofilenewforcommand[near ticklabel anchors]{\pgfplots@borderanchor@for@axis}{3}%
+ \pgfprofilenewforcommand[ticklabel cs]{\pgfplotspointticklabelcs}{2}%
+ % \pgfprofilenewforcommand[binary conversion]{\pgfplotsbinaryencodeunsigned}{1}%
+ % \pgfprofilenewforcommand[binary conversion]{\pgfplotsbinaryencodesignedmaplinearly}{1}%
+ % \pgfprofilenewforcommand[binary conversion]{\pgfplotsbinaryencodedimenmaplinearly}{1}%
+ },%
+}
+
+\def\pgfplots@glob@TMPa#1{%
+ \pgfkeys{%
+ /pgfplots/#1tick pos/lower/.style={/pgfplots/#1tick pos=left},
+ /pgfplots/#1tick pos/bottom/.style={/pgfplots/#1tick pos=left},
+ /pgfplots/#1tick pos/upper/.style={/pgfplots/#1tick pos=right},
+ /pgfplots/#1tick pos/top/.style={/pgfplots/#1tick pos=right},
+ }%
+}%
+\pgfplots@glob@TMPa x%
+\pgfplots@glob@TMPa y%
+\pgfplots@glob@TMPa z%
+
+\def\pgfplots@ticklabel@typeset@arg#1{\pgfkeysvalueof{/pgfplots/typeset ticklabel/.@cmd}{#1}\pgfeov}%
+
+% backwards compatibility:
+\def\pgfplots@tickwidth{\pgfkeysvalueof{/pgfplots/major tick length}}%
+\def\pgfplots@subtickwidth{\pgfkeysvalueof{/pgfplots/minor tick length}}%
+
+\begingroup
+\pgfkeys{/pgfplots/colorbar pgfshading}
+\pgfkeysgetvalue{/pgfplots/colorbar/draw/.@cmd}\pgfplots@loc@TMPa
+\global\let\pgfplots@colorbar@draw@legacyimpl=\pgfplots@loc@TMPa
+\endgroup
+
+% call
+% \pgfkeyslet{.../.@cmd}\pgfplots@cant@set@in@this@context
+% to replace a key with a generic error message.
+\def\pgfplots@cant@set@in@this@context#1\pgfeov{\pgfplots@cant@set@in@this@context@}
+\def\pgfplots@cant@set@in@this@context@{%
+ \pgfplotsthrow{unsupported operation}{Sorry, you can't change `\pgfkeyscurrentkeyRAW' in this context. Maybe you need to provide it as \string\begin{axis}[\pgfkeyscurrentkeyRAW=...] ?}\pgfeov
+}
+
+
+{
+\pgfkeysdef{/empty}{}%
+\pgfkeysgetvalue{/empty/.@cmd}\pgfplots@loc@TMPa
+\global\let\pgfplots@empty@command@key=\pgfplots@loc@TMPa
+%
+\pgfkeys{/empty/.style={}}%
+\pgfkeysgetvalue{/empty/.@cmd}\pgfplots@loc@TMPa
+\global\let\pgfplots@empty@style@key=\pgfplots@loc@TMPa
+}
+
+% Only define if it is undefined. It may be possible that related libraries
+% habe been loaded before pgfplots.
+\pgfkeysifdefined{/pgfplots/@backgroundpath@hook/.@cmd}{\relax}{%
+ \pgfkeysdef{/pgfplots/@backgroundpath@hook}{}%
+}
+
+\def\pgfplots@cmdkey@alias#1=#2;{%
+ \pgfkeysgetvalue{/pgfplots/#2/.@cmd}\pgfplots@glob@TMPa
+ \pgfkeyslet{/pgfplots/#1/.@cmd}\pgfplots@glob@TMPa
+}%
+\pgfplots@cmdkey@alias xlabel style=x label style;
+\pgfplots@cmdkey@alias ylabel style=y label style;
+\pgfplots@cmdkey@alias zlabel style=z label style;
+\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;
+\pgfplots@cmdkey@alias ytick style=y tick style;
+\pgfplots@cmdkey@alias ztick style=z tick style;
+
+
+% A backwards compatibility method which works as follows:
+% if any user specified arguments exist for the 'domain' or 'samples
+% at' or 'samples' keys, nothing is done.
+%
+% It these keys are empty, we switch to backwards compatibility mode
+% and acquire the key settings from tikz.
+%
+% This allows something like
+% \begin{tikzpicture}[samples=70,domain=1:5]
+% \begin{axis}
+% \addplot {x^2};
+% \end{axis}
+% \end{tikzpicture}
+%
+% POSTCONDITION:
+% - \pgfplots@plot@domain = value of '/pgfplots/domain',
+% - \pgfplots@plot@samples@at = the value of '/pgfplots/samples at',
+% - \pgfplots@plot@samples = value of '/pgfplots/samples',
+% the values after any backwards compatibility issues will be used.
+\def\pgfplots@validate@plot@domain@arguments{%
+ \pgfkeysgetvalue{/pgfplots/samples}\pgfplots@plot@samples
+ \ifx\pgfplots@plot@samples\pgfutil@empty
+ \pgfplots@gettikzinternal@keyval{samples}{tikz@plot@samples}{25}%
+ \let\pgfplots@plot@samples=\tikz@plot@samples
+ \def\pgfplots@loc@TMPa{0}% <- whether the tikz backw. compatibility shall resample
+ \else
+ \def\pgfplots@loc@TMPa{1}%
+ \fi
+ %
+ \pgfplotscoordmath{default}{parse int}{\pgfplots@plot@samples}%
+ \let\pgfplots@plot@samples=\pgfmathresult
+ \pgfkeyslet{/pgfplots/samples}{\pgfplots@plot@samples}%
+ %
+ \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.
+ \tikzset{%
+ /pgf/fpu/output format=fixed,% seems as if /tikz/samples calls register arithmetics.
+ samples=\pgfplots@plot@samples,
+ /pgf/fpu/output format=float,%
+ }%
+ \fi
+ \pgfplots@gettikzinternal@keyval{samples at}{tikz@plot@samplesat}{-5,-4.6,...,5}%
+ %
+ % check if it was a domain. This simplifies LUA code:
+ \pgfplotsforeachtodomain{\tikz@plot@samplesat}%
+ \ifx\pgfplotsretval\pgfutil@empty
+ \pgfkeyslet{/pgfplots/samples at}{\tikz@plot@samplesat}%
+ \let\pgfplots@plot@samples@at=\tikz@plot@samplesat
+ \else
+ \let\pgfplots@plot@domain=\pgfplotsretval
+ \let\pgfplots@plot@samples=\pgfplotsretvalb
+ \pgfkeyslet{/pgfplots/samples}{\pgfplots@plot@samples}%
+ \fi
+ \else
+ % routines should use \pgfplots@plot@samples@at.
+ \fi
+ \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}}%
+
+
+% DEPRECATED
+\long\def\axispreset#1{%
+ \pgfplotsset{every axis/.append style={#1}}%
+}
+% DEPRECATED
+\long\def\legendpreset#1{%
+ \pgfplots@error{Sorry, legendpreset is now deprecated, along with the legend options text width and font. Legends are now TikZ-matrizes which provide better alignment and can be placed horizontally. See the manual for details.}%
+}
+
+% #1: axis (x, y, or z)
+% #2: display name of context information
+\def\pgfplots@warn@if@log@basis@unset#1#2{%
+ \pgfplots@if{pgfplots@#1islinear}{%
+ }{%
+ \pgfplots@warn@if@log@basis@unset@{#1}{#2}%
+ }%
+}%
+\def\pgfplots@warn@if@log@basis@unset@#1#2{%
+ \pgfkeysgetvalue{/pgfplots/log basis #1}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfplotswarning{log basis required}{#1}{#2}\pgfeov
+ \fi
+ \gdef\pgfplots@warn@if@log@basis@unset##1##2{}%
+}%
+
+
+% #1 axis (x or y)
+% #2 the label
+\long\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}}%
+ \tikzdeclarecoordinatesystem{ticklabel*}{\pgfplotspointticklabelnoshiftcs{#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={##1}}}%
+ %
+ \node
+ [/pgfplots/every axis label,%
+ /pgfplots/every axis #1 label]
+ {#2};
+ \endgroup
+}
+
+
+\long\def\pgfplots@show@title#1{%
+ \node%
+ [/pgfplots/every axis title]
+ {#1};
+}
+
+
+% 'inner' means lines which pass through the origin (i.e. lines which
+% are not on the outer bounding box). In other words: this has an
+% effect if and only if 'axis #1 lines=center'
+%
+% #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{%
+ \if2\csname pgfplots@#1axislinesnum\endcsname
+ \pgfplotsgetlayerforstyle{%
+ every inner #1 axis line,
+ }%
+ \pgfplotsonlayer{\pgfplotsretval}{inner #1 axis line}%
+ %
+ \draw[/pgfplots/every inner #1 axis line,%
+ decorate,%
+ #1discont,%
+ decoration={%
+ % these keys appears to be checked via an \ifx on
+ % '0pt'. Make sure that this \ifx works by means of
+ % the expand twice construction:
+ pre length/.expand twice=\csname #1disstart\endcsname,%
+ post length/.expand twice=\csname #1disend\endcsname%
+ }]
+ \pgfextra
+ \csname pgfplotspointonorientedsurfaceabsetupforset#3\endcsname{\csname pgfplots@logical@ZERO@#3\endcsname}{2}%
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v2%
+ \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}%
+ \endpgfextra
+ ;
+ %
+ \endpgfplotsonlayer
+ \fi
+}%
+
+% Draws outer axis lines, i.e. those which are on the bounding box.
+% This has an effect if and only if axis #1 lines!=center.
+%
+%
+% Ok, we don't mind whether edges with thick lines look ugly. We just
+% draw separate lines. This here is necessary if we want arrow heads.
+%
+% #1: the 'a' axis on the oriented surface (the same as \pgfplotspointonorientedsurfaceA)
+% #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
+ \def\pgfplots@drawaxis@outerlines@separate@onorientedsurf@opts{%
+ /pgfplots/every outer #1 axis line,
+ #1discont,decoration={pre length/.expand twice=\csname #1disstart\endcsname, post length/.expand twice=\csname #1disend\endcsname}%
+ }%
+ \pgfplotsgetlayerforstyle{%
+ every outer #1 axis line,
+ }%
+ \pgfplotsonlayer{\pgfplotsretval}{outer #1 axis line}%
+ %
+ \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{%
+ \expandafter\draw\expandafter[\pgfplots@drawaxis@outerlines@separate@onorientedsurf@opts] decorate {
+ \pgfextra
+ % exchange roles of A <-> B axes:
+ \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}%
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf 0v%
+ \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2min\endcsname}%
+ \endpgfextra
+ };
+ }{}%
+ \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{%
+ \expandafter\draw\expandafter[\pgfplots@drawaxis@outerlines@separate@onorientedsurf@opts] decorate {
+ \pgfextra
+ % exchange roles of A <-> B axes:
+ \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}%
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf 1v%
+ \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2max\endcsname}%
+ \endpgfextra
+ };
+ }{}%
+ %
+ \endpgfplotsonlayer
+ \fi
+}%
+
+% This here is complicated: we try to create good edges and draw a
+% SINGLE path for the partial or complete rectangle
+%
+% -----
+% | |
+% | |
+% -----
+%
+% ATTENTION: this thing is used IF AND ONLY IF d=2 and the axis is
+% drawn as box.
+\def\pgfplots@drawaxis@outerlines@cycledpath{%
+ \pgfplots@loc@tmptrue
+ \ifpgfplots@hide@x
+ \ifpgfplots@hide@y
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+\ifpgfplots@loc@tmp
+ \pgfplotsgetlayerforstyle{%
+ every outer x axis line,
+ every outer y axis line,
+ }%
+ \pgfplotsonlayer{\pgfplotsretval}{boxed axis line}%
+ %
+ \draw[
+ /pgfplots/every outer x axis line, % using these outer styles is only useful in conjunction with 'separate axis lines=true'
+ /pgfplots/every outer y axis line]
+ \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}}\endpgfextra
+\ifpgfplots@hide@y
+ { \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}\endpgfextra }
+\else
+ decorate [ydiscont,decoration={pre length=\ydisstart, post length=\ydisend}]
+ % { -- (\pgfplots@xmin, \pgfplots@ymax) }
+ { \pgfextra\pgfpathlineto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}\endpgfextra }
+\fi
+\ifpgfplots@hide@x
+ %{ (\pgfplots@xmax, \pgfplots@ymax) }
+ { \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}\endpgfextra }
+\else
+ decorate [xdiscont,decoration={pre length=\xdisstart, post length=\xdisend}]
+ %{ -- (\pgfplots@xmax, \pgfplots@ymax) }
+ { \pgfextra\pgfpathlineto{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}\endpgfextra }
+\fi
+\ifpgfplots@hide@y
+ %{ (\pgfplots@xmax, \pgfplots@ymin) }
+ { \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}\endpgfextra }
+\else
+ decorate [ydiscont,decoration={pre length=\ydisend, post length=\ydisstart}]
+ %{ -- (\pgfplots@xmax, \pgfplots@ymin) }
+ { \pgfextra\pgfpathlineto{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}\endpgfextra }
+\fi
+\ifpgfplots@hide@x
+ %{ (\pgfplots@xmin, \pgfplots@ymin) }
+ { \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}}\endpgfextra }
+\else
+ decorate [xdiscont,decoration={pre length=\xdisend, post length=\xdisstart}]
+ %{ -- (\pgfplots@xmin, \pgfplots@ymin) }
+ { \pgfextra\pgfpathlineto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}}\endpgfextra }
+\fi
+ % make sure that we do not have any of the axis discontinuities
+ % here - they should not be closed.
+ \if0\pgfplots@xaxisdiscontnum
+ \if0\pgfplots@yaxisdiscontnum
+ -- cycle
+ \fi
+ \fi
+ ;%
+ %
+ \endpgfplotsonlayer
+\fi
+}%
+
+% Assigns the macros
+% #1disstart
+% #1disend
+% and the key /tikz/#1discont for use in the axis line routines.
+%
+% #1 : either x or y.
+\def\pgfplots@drawaxis@lines@preparediscont@for#1{%
+ \ifnum\csname pgfplots@#1axisdiscontnum\endcsname>0
+ \begingroup
+ % this group employs several temporary dimension registers
+ % and is therefor scoped:
+ \let\disstart=\pgf@ya
+ \let\disend=\pgf@yb
+ \disend=\csname pgfplots@#1max@reg\endcsname
+ \advance\disend by -\csname pgfplots@#1min@reg\endcsname
+ \disend=\csname pgfplots@#1@veclength\endcsname\disend
+ \ifcase\csname pgfplots@#1axisdiscontnum\endcsname\relax
+ % has already been checked above.
+ \or
+ \def\discontstyle{decoration={zigzag,segment length=12pt, amplitude=4pt}}%
+ \advance \disend by -16pt
+ \or
+ \def\discontstyle{decoration={ticks,segment length=4pt, amplitude=8pt}}%
+ \advance \disend by -8pt
+ \fi
+ \pgfplotscoordmath{#1}{datascaletrafo get params}%
+ % if #1max + shift < 0pt (shift is 0 without the scaling trafo)
+ \ifdim\csname pgfplots@#1max@reg\endcsname<-\pgfplotsretvalb pt
+ % swap start and end
+ \disstart=\disend
+ \disend=4pt
+ \else
+ \disstart=4pt
+ \fi
+ % carry local computations outside of group:
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\expandafter\noexpand\csname #1disstart\endcsname{\the\disstart}%
+ \noexpand\def\expandafter\noexpand\csname #1disend\endcsname{\the\disend}%
+ \noexpand\pgfkeysdef{/tikz/#1discont}{\noexpand\pgfkeysalso{\discontstyle}}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+ \else
+ \expandafter\def\csname #1disstart\endcsname{0pt}%
+ \expandafter\def\csname #1disend\endcsname{0pt}%
+ \pgfkeyslet{/tikz/#1discont}=\pgfutil@empty
+ \fi
+}%
+
+\def\pgfplots@rememberplotspec@for@label{\pgfplotsutil@ifnextchar[{\pgfplots@rememberplotspec@for@label@}{\pgfplots@rememberplotspec@for@label@[]}}%
+\def\pgfplots@rememberplotspec@for@label@[#1]#2{%
+ \t@pgfplots@tokc={#2}% this token register stuff allows '#' inside of '#2'
+ \expandafter\xdef\csname pgfplots@last@plot@style@#1\endcsname{\the\t@pgfplots@tokc}%
+ \global\pgfplots@has@label@informationtrue
+}%
+\def\pgfplots@rememberplotspec{\pgfplotsutil@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{%
+ \begingroup
+ \let#1=\pgfutil@empty
+ \pgfkeysgetvalue{/pgfplots/cycle multi list/@dim}\pgfplots@cycle@dim
+ %
+ \let\pgfplots@listindex=\pgfplots@numplots
+ \pgfkeysgetvalue{/pgfplots/cycle list shift}\pgfplots@listindex@shift
+ \ifx\pgfplots@listindex@shift\pgfutil@empty
+ \else
+ \c@pgf@counta=\pgfplots@listindex\relax
+ \advance\c@pgf@counta by\pgfplots@listindex@shift\relax
+ \ifnum\c@pgf@counta<0
+ \c@pgf@counta=-\c@pgf@counta
+ \fi
+ \edef\pgfplots@listindex{\the\c@pgf@counta}%
+ \fi
+ \ifnum\pgfplots@cycle@dim>0
+ \if L\pgfplots@cycle@multi@list@sequence
+ % 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\relax
+ \c@pgf@countb=\pgfplots@listindex\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
+ \if M\pgfplots@cycle@multi@list@sequence
+ %
+ % take the i'th element of each sub-list where i
+ % =\pgfplots@listindex
+ \if A\pgfplots@cycle@multi@list@repeat
+ % 'cycle multiindex list'
+ %
+ % ensure that we respect the maxlen of the list:
+ \pgfplotsmathmodint{\pgfplots@listindex}{\pgfkeysvalueof{/pgfplots/cycle multi list/@maxlen}}%
+ \let\pgfplots@listindex=\pgfmathresult
+ \def\pgfplots@cycle@multi@list@cur##1{%
+ \ifnum\pgfplots@listindex<\pgfplots@cycle@N\relax
+ ##1%
+ \fi
+ }%
+ %
+ \else
+ % 'cycle multiindex* list':
+ \def\pgfplots@cycle@multi@list@cur##1{%
+ ##1%
+ }%
+ \fi
+ %
+ \c@pgf@counta=0
+ \pgfplotsloop{%
+ \ifnum\c@pgf@counta<\pgfplots@cycle@dim\relax
+ \pgfplotsloopcontinuetrue
+ \else
+ \pgfplotsloopcontinuefalse
+ \fi
+ }{%
+ \pgfkeysgetvalue{/pgfplots/cycle multi list/@N\the\c@pgf@counta}\pgfplots@cycle@N
+ \pgfplots@cycle@multi@list@cur{%
+ \expandafter\pgfplots@getautoplotspec@
+ \csname pgfp@cyclist@/pgfplots/cycle multi list/@list\the\c@pgf@counta @\endcsname
+ {\pgfplots@cycle@N}%
+ {\pgfplots@listindex}%
+ \t@pgfplots@toka=\expandafter{#1,}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsretval}%
+ \edef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ }%
+ \advance\c@pgf@counta by1
+ }%
+ \else
+ \pgfplots@error{Internal error: expected 'L' or 'M', not '\pgfplots@cycle@multi@list@sequence'}%
+ \fi
+ \fi
+ \else
+ % normal cycle list:
+ \pgfplotslistsize\autoplotspeclist\to\c@pgf@countd
+ \pgfplots@getautoplotspec@{\autoplotspeclist}{\c@pgf@countd}{\pgfplots@listindex}%
+ \let#1=\pgfplotsretval
+ \fi
+%\message{[plot \the\pgfplots@numplots]: Returning options list \meaning#1^^J}%
+ \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
+}
+
+
+\long\def\pgfplots@path#1;{%
+ \pgfplots@path@enqueue{#1;}%
+}
+
+% This thing here shall be used to replace any '\path' where \axispath
+% shall be used.
+\long\def\pgfplots@replacement@for@tikz@path#1;{%
+ \axispath\path#1;%
+}
+\def\pgfplots@replacement@for@scope{\pgfutil@ifnextchar[{\pgfplots@replacement@for@scope@}{\pgfplots@replacement@for@scope@[]}}%
+\long\def\pgfplots@replacement@for@scope@[#1]{%
+ \pgfplotsextra{\scope[#1]}%
+ \begingroup
+ % I need to apply anything which might be relevant for \addplot
+ % here.
+ % But I do NOT want \scope since this might already affect the low
+ % level output.
+ %
+ % This here works:
+ % 1. set them to activate plot handlers and parameters like
+ % samples and domain:
+ \tikzset{#1}%
+ %
+ % 2. we need to remember all these options inside of
+ % 'current plot style' -- otherwise, they would not appear
+ % inside of legend images and markers.
+ \pgfplotssurveyphaseaddoptionsbeforesurveybegins{#1}%
+}%
+\def\pgfplots@replacement@for@endscope{%
+ \endgroup
+ \pgfplotsextra{\endscope}%
+}%
+
+\def\pgfplots@replacement@for@onlayer#1{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplots@replacement@for@onlayer@{#1}%
+}
+\def\pgfplots@replacement@for@onlayer@#1{%
+ \pgfplotsextra{\pgfonlayer{#1}}%
+}%
+\def\pgfplots@replacement@for@endonlayer{\pgfplotsextra{\endpgfonlayer}}%
+
+{
+ % A block which handles active semicolons.
+ %
+ % ATTENTION: this block does only work if
+ % \pgfplots@addplotimpl.... changes are reflected here!
+ %
+ \catcode`\;=\active
+ \globaldefs=1
+ % 'AS' == 'active semicolon'
+ \def\pgfplots@path@AS#1;{\pgfplots@path@enqueue{#1;}}%
+ \long\def\pgfplots@replacement@for@tikz@path@AS#1;{%
+ \axispath\path#1;%
+ }%
+ \pgfplots@appendto@activesemicolon@switcher{%
+ \let\pgfplots@path=\pgfplots@path@AS
+ \let\pgfplots@replacement@for@tikz@path=\pgfplots@replacement@for@tikz@path@AS
+ }%
+}
+
+
+% Will be available as \closedcycle command inside of an axis.
+%
+% It closes the current plot by drawing lines to the last "zero
+% level".
+%
+% That means the current plot is connected orthogonally with the
+% x-axis, allowing fill commands.
+%
+% For stacked plots, \closedcycle is special (it connects with the
+% previous \addplot command).
+%
+% Example:
+% \addplot coordinates {(3,0.5) (4,2) (5,1)} \closedcycle;
+\def\pgfplots@path@closed@cycle{%
+ \ifpgfplots@stackedmode
+ \pgfplots@stacked@path@closed@cycle
+ \else
+ \pgfplots@path@closed@cycle@std
+ \fi
+}
+\def\pgfplots@path@closed@cycle@std{%
+ |- (perpendicular cs:
+ vertical line through={(current plot begin)},
+ horizontal line through={(\pgfplots@ZERO@x,\pgfplots@ZERO@y)})
+ -- cycle
+}%
+
+% Remembers the plotting command #2 and '#3=plot coordinates {...} ...';
+% for later postprocessing of the coordinates.
+%
+% #1: pre-commands which should be executed before issueing the plotting
+% command #2 #3.
+% #2: the drawing-command.
+% - If #2 is NOT '\pgfutil@empty', we expect #3 to contain only
+% EXPANDABLE DATA.
+% That's important for postponed floating point arithmetics in #3.
+% - If #2='\pgfutil@empty', we don't make any assumption about #3
+% and process it as-is.
+%
+% #3: the plot data. If #2 is empty, this can be any command.
+%
+% #4: commands which should be executed after '#2 #3'.
+%
+\long\def\pgfplots@path@enqueue@coords#1#2#3#4{%
+ \begingroup
+ \def\pgfplots@loc@TMPa{#2}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \def\pgfplots@stored@current@precmd{#1}%
+ \def\pgfplots@stored@current@cmd{#2}%
+ \def\pgfplots@stored@current@data{#3}%
+ \def\pgfplots@stored@current@postcmd{#4}%
+ \ifx\pgfplots@stored@current@precmd\pgfutil@empty
+ \else
+ \pgfplots@wrong@plotlist@format@error
+ \fi
+ \ifx\pgfplots@stored@current@postcmd\pgfutil@empty
+ \else
+ \pgfplots@wrong@plotlist@format@error
+ \fi
+ \pgfplotslistpushbackglobal{#1}{#2}{#3}{#4}\to\pgfplots@stored@plotlist
+ \else
+ \pgfkeysgetvalue{/pgfplots/execute at begin plot visualization}\pgfplots@loc@TMPa
+ \pgfkeysgetvalue{/pgfplots/execute at end plot visualization}\pgfplots@loc@TMPb
+ \t@pgfplots@toka={#1}%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}%
+ \t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPb}%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfkeyssetvalue{/pgfplots/execute at begin plot visualization}{\the\t@pgfplots@tokb}%
+ \noexpand\pgfkeyssetvalue{/pgfplots/execute at end plot visualization}{\the\t@pgfplots@tokc}%
+ \the\t@pgfplots@toka
+ }%
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@loc@TMPa}{#2}{#3}{#4}\to\pgfplots@stored@plotlist
+ \fi
+ \endgroup
+}
+\def\pgfplots@wrong@plotlist@format@error{%
+ \pgfplots@error{Internal logic error: someone used \string \pgfplots@path@enqueue@coords\space in an unexpected way: if the second argument is empty, ONLY the third argument should be non-empty.^^J I found: pre command (1st arg): \meaning\pgfplots@stored@current@precmd;^^J command (2nd arg): \meaning\pgfplots@stored@current@cmd;^^J data (3rd arg): \meaning\pgfplots@stored@current@data^^J; post cmd (4th arg): \meaning\pgfplots@stored@current@postcmd^^J}%
+}%
+
+% 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).
+%
+% Syntax: either
+% \pgfplotsextra{<argument>}
+% or
+% \pgfplotsextra <argument> \endpgfplotsextra
+\def\pgfplotsextra{%
+ \pgfutil@ifnextchar\bgroup{\pgfplots@path@enqueue}{\pgfplotsextra@}%
+}%
+\long\def\pgfplotsextra@#1\endpgfplotsextra{\pgfplots@path@enqueue{#1}}%
+
+
+% Assigns a legend.
+% Syntax:
+% \legend{entry 1\\entry2\\entry3}
+\def\pgfplots@command@legend{
+ \pgfutil@ifnextchar[{%
+ \pgfplots@error{Sorry, legend options are now deprecated. Legends are now TikZ-matrizes which provide better alignment and can be placed horizontally. See the manual for details.}%
+ \pgfplots@command@legend@impl
+ }{%
+ \pgfplots@command@legend@impl
+ }%
+}
+
+\def\pgfplots@command@legend@impl#1{%
+ \pgfplots@assign@list\pgfplots@loc@TMPc{#1}%
+ \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@transposelegend{%
+ \ifnum\pgfplots@legend@columns>1
+ \begingroup
+ \pgfplots@transposelegend@
+ \let\pgfplots@legend@columns=\c@pgfplots@row@end
+ \pgfmath@smuggleone\pgfplots@legend@columns
+ \endgroup
+ \fi
+}
+\def\pgfplots@transposelegend@{%
+ \let\c@pgfplots@row=\c@pgf@countb
+ \let\c@pgfplots@col=\c@pgf@countc
+ \let\c@pgfplots@no=\c@pgf@countd
+ \c@pgfplots@row=0
+ \c@pgfplots@col=0
+ \c@pgfplots@no=0
+ \pgfplotslistforeachungrouped\pgfplots@legend\as\entry{%
+ \expandafter\let\csname m@pgfplots@\the\c@pgfplots@row,\the\c@pgfplots@col\endcsname=\entry
+ \advance\c@pgfplots@col by1
+ \ifnum\pgfplots@legend@columns=\c@pgfplots@col\relax
+ \c@pgfplots@col=0
+ \advance\c@pgfplots@row by1
+ \fi
+ \advance\c@pgfplots@no by1
+ }%
+ \ifnum\c@pgfplots@col=0
+ \else
+ \advance\c@pgfplots@row by1
+ \fi
+ \edef\c@pgfplots@row@end{\the\c@pgfplots@row}%
+ \edef\c@pgfplots@no@leg{\the\c@pgfplots@no}%
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \c@pgfplots@row=0
+ \c@pgfplots@col=0
+ \c@pgfplots@no=0
+ \pgfplotslistforeachungrouped\pgfplots@plotspeclist\as\entry{%
+ \expandafter\let\csname m@pgfplots@img@\the\c@pgfplots@row,\the\c@pgfplots@col\endcsname=\entry
+ \advance\c@pgfplots@col by1
+ \ifnum\pgfplots@legend@columns=\c@pgfplots@col\relax
+ \c@pgfplots@col=0
+ \advance\c@pgfplots@row by1
+ \fi
+ \advance\c@pgfplots@no by1
+ }%
+ \ifnum\c@pgfplots@col=0
+ \else
+ \advance\c@pgfplots@row by1
+ \fi
+ \ifnum\c@pgfplots@row<\c@pgfplots@row@end
+ \edef\c@pgfplots@row@end{\the\c@pgfplots@row}%
+ \fi
+ \ifnum\c@pgfplots@no<\c@pgfplots@no@leg
+ \edef\c@pgfplots@no@leg{\the\c@pgfplots@no}%
+ \fi
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \c@pgfplots@col=0
+ \global\pgfplotslistnewempty\pgfplots@legend%
+ \global\pgfplotslistnewempty\pgfplots@plotspeclist%
+ \pgfplotsloop{%
+ \ifnum\pgfplots@legend@columns=\c@pgfplots@col
+ \pgfplotsloopcontinuefalse
+ \else
+ \pgfplotsloopcontinuetrue
+ \fi
+ }{%
+ \c@pgfplots@row=0
+ \pgfplotsloop{%
+ \ifnum\c@pgfplots@row@end=\c@pgfplots@row
+ \pgfplotsloopcontinuefalse
+ \else
+ \pgfplotsloopcontinuetrue
+ \fi
+ }{%
+ \pgfutil@ifundefined{m@pgfplots@\the\c@pgfplots@row,\the\c@pgfplots@col}{%
+ }{%
+ \pgfutil@ifundefined{m@pgfplots@img@\the\c@pgfplots@row,\the\c@pgfplots@col}{%
+ }{%
+ \expandafter\let\expandafter\pgfplots@legendtmp\csname m@pgfplots@\the\c@pgfplots@row,\the\c@pgfplots@col\endcsname
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@legendtmp}\to\pgfplots@legend%
+ %
+ \expandafter\let\expandafter\pgfplots@legendtmp\csname m@pgfplots@img@\the\c@pgfplots@row,\the\c@pgfplots@col\endcsname
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@legendtmp}\to\pgfplots@plotspeclist%
+ }%
+ }%
+ \advance\c@pgfplots@row by1
+ }%
+ \advance\c@pgfplots@col by1
+ }%
+}%
+
+
+\def\pgfplots@addlegendentryexpanded{%
+ \pgfutil@ifnextchar[{%
+ \pgfplots@addlegendentryexpanded@opts
+ }{%
+ \pgfplots@addlegendentryexpanded@opts[]%
+ }%
+}
+\long\def\pgfplots@addlegendentryexpanded@opts[#1]#2{%
+ \begingroup
+ \let\protect=\noexpand
+ \long\edef\pgfplots@loc@TMPa{#2}%
+ \def\pgfplots@loc@TMPb{\pgfplots@addlegendentry@opts[#1]}%
+ \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}%
+ \endgroup
+}%
+
+\def\pgfplots@addlegendimage{\pgfutil@ifnextchar[{\pgfplots@addlegendimage@opt}{\pgfplots@addlegendimage@opt[]}}%
+\def\pgfplots@addlegendimage@opt[#1]#2{%
+ \pgfplots@rememberplotspec[#1]{/pgfplots/every axis plot,#2,/pgfplots/.cd,/pgfplots/every axis plot post}%
+}%
+
+% This implements \addlegendentry
+\def\pgfplots@addlegendentry{%
+ \pgfutil@ifnextchar[{%
+ \pgfplots@addlegendentry@opts
+ }{%
+ \pgfplots@addlegendentry@opts[]%
+ }%
+}
+\long\def\pgfplots@addlegendentry@opts[#1]#2{%
+ \pgfplotslistpushbackglobal[#1]#2\to\pgfplots@legend
+}
+
+\def\pgfplots@pop@next@legend{{%
+ \globaldefs=1
+ \pgfplotslistcheckempty\pgfplots@plotspeclist
+ \ifpgfplotslistempty
+ \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
+ %
+}}
+
+\def\pgfplots@try@mirror@plot@handler{%
+ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
+ % this method assigns '\tikz@plot@handler'.
+ % That's ok and does not introduce incompatibilities.
+ \ifx\pgfplots@basiclevel@plothandler\pgfplothandlerconstantlineto
+ \let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkright
+ \else
+ \ifx\pgfplots@basiclevel@plothandler\pgfplothandlerconstantlinetomarkright
+ \let\tikz@plot@handler=\pgfplothandlerconstantlineto
+ \fi
+ \fi
+}
+
+% #1: DEPRECATED. Unused.
+% #2: plot style
+\long\def\pgfplots@show@small@legendplots#1#2{%
+ \begingroup
+ \pgfplots@define@currentplotstyle@as{#1,#2}%
+ \pgfplots@restore@state@before@legend@style
+ \scope[/tikz/current plot style,/pgfplots/every legend image post]% 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
+}
+
+% A work-around method to undo the 'every axis legend' style.
+%
+% It is called within legend's cell pictures in order to undo global
+% settings like stroke colors or the-like.
+\def\pgfplots@restore@state@before@legend@style{%
+ \pgfsetfillcolor{black}%
+ % disable the transformations of pgfplots. This is only used by
+ % pgfplots-specific plot handlers which work only if used inside
+ % of an axis... disable it.
+ \def\pgfplotsaxisvisphasetransformcoordinate##1##2##3{}%
+}%
+
+\def\pgfplots@split@opts{%
+ \pgfutil@ifnextchar[{%
+ \pgfplots@split@opts@opts
+ }{%
+ \pgfplots@split@opts@opts[]%
+ }%
+}
+\long\def\pgfplots@split@opts@opts[#1]#2\pgfplots@result@to#3#4{%
+ \long\def#3{#2}%
+ \long\def#4{#1}%
+}
+
+% Typesets a legend node.
+%
+% It will either typeset a previously computed legend (which needs to be
+% stored in the macro \pgfplots@already@computed@legend@node)
+%
+% or it creates a legend, stores the commands into the macro named
+% above and typesets it.
+\def\pgfplots@createlegend{%
+ \pgfkeysgetvalue{/pgfplots/legend to name}\pgfplots@createlegend@toname
+ \ifx\pgfplots@already@computed@legend@node\pgfutil@empty
+ \pgfplotslistcheckempty\pgfplots@legend
+ \ifpgfplotslistempty
+ % No legend commands appeared in the document. So,
+ % consider the key:
+ \pgfkeysgetvalue{/pgfplots/legend entries}\pgfplots@legend
+ \expandafter\pgfplots@assign@list\expandafter\pgfplots@legend\expandafter{\pgfplots@legend}%
+ \pgfplotslistcheckempty\pgfplots@legend
+ \fi
+%\message{Legend: \meaning\pgfplots@legend^^J}%
+ \ifpgfplotslistempty
+ \else
+ \ifpgfplots@reverse@legend
+ \pgfplots@reverselegend
+ \fi
+ \ifpgfplots@transpose@legend
+ \pgfplots@transposelegend
+ \fi
+ %
+ %
+ \begingroup
+ \ifx\pgfplots@createlegend@toname\pgfutil@empty
+ % ok, draw legend.
+ \def\pgfplots@createlegend@prepareimage@to##1{%
+ \t@pgfplots@tokc=\expandafter{\pgfplots@curplotlist}%
+ \edef##1{\noexpand\pgfplots@show@small@legendplots{}{\the\t@pgfplots@tokc}}%
+ }%
+ \else
+ % export legend instead of drawing it.
+ \def\pgfplots@createlegend@prepareimage@to##1{%
+ \t@pgfplots@tokc=\expandafter{\pgfplots@curplotlist}%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplots@export@legend@image@to@macro{\the\t@pgfplots@tokc}{}}%
+ \pgfplots@loc@TMPa
+ \let##1=\pgfplotsretval
+ }%
+ \fi
+ % assemble a
+ % \matrix {
+ % small plot & legend1\\
+ % small plot & legend2\\
+ % ...
+ % };
+ % command [and using the 'legend columns' option]
+ %
+ % \t@pgfplots@toka={
+ % small plot & legend1\\
+ % small plot & legend2\\
+ % ...
+ % }
+ % ( I have allocated the token registers in my
+ % liststructure.sty)
+ %
+ % \global\def\pgfplots@glob@TMPa{
+ % \matrix {
+ % \TOKL@TA
+ % };
+ % }
+ % -> finally, \pgfplots@glob@TMPa will contain the complete command.
+ \t@pgfplots@toka={}%
+ \let\curcolumnNum=\c@pgf@counta
+ \let\maxcolumnCount=\c@pgf@countb
+ \let\legendplotpos=\c@pgf@countc
+ \legendplotpos\expandafter=\pgfplots@legend@plot@pos
+ \curcolumnNum=0
+ \maxcolumnCount=\pgfplots@legend@columns\relax
+ %
+ \pgfplotsloop{%
+ \pgfplots@pop@next@legend
+ \ifpgfplotslistempty
+ \pgfplotsloopcontinuefalse
+ \else
+ \pgfplotsloopcontinuetrue
+ \fi
+ }{%
+ \ifx\pgfplots@curlegend\pgfutil@empty
+ \else
+ \advance\curcolumnNum by1
+ \begingroup
+ % \pgfplots@curlegend@opts are any options for
+ % this single legend text, provided as
+ % \addlegendentry[<options>]{<text>}
+ % or
+ % legend entries={...,[<options>]<text>, ....}
+ \expandafter\pgfplots@split@opts\pgfplots@curlegend\pgfplots@result@to{\pgfplots@curlegend}{\pgfplots@curlegend@opts}%
+ \pgfplots@createlegend@prepareimage@to{\pgfplotsretval}%
+ %
+ \t@pgfplots@tokb=\expandafter{\pgfplots@curlegend@opts}%
+ \t@pgfplots@tokc=\expandafter{\pgfplots@curlegend}%
+ %
+ % prepare the \node[<options>] {<text>} into \t@pgfplots@tokc
+ \edef\pgfplots@loc@TMPa{\noexpand\node[\the\t@pgfplots@tokb]{\the\t@pgfplots@tokc};}%
+ \t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}%
+ %
+ % and the legend image into \t@pgfplots@tokb:
+ \t@pgfplots@tokb=\expandafter{\pgfplotsretval}%
+ % ok. Now, the
+ % - 'b' register contains the IMAGE and
+ % - 'c' register contains the TEXT
+ \ifcase\legendplotpos
+ % legend plot pos=left
+ \edef\pgfplots@matrixentry{%
+ \the\t@pgfplots@tokb
+ \noexpand\pgfmatrixnextcell
+ \the\t@pgfplots@tokc%
+ }%
+ \or
+ % legend plot pos=right
+ \edef\pgfplots@matrixentry{%
+ \the\t@pgfplots@tokc%
+ \noexpand\pgfmatrixnextcell
+ \the\t@pgfplots@tokb
+ }%
+ \or
+ % legend plot pos=none
+ \edef\pgfplots@matrixentry{%
+ \the\t@pgfplots@tokc%
+ }%
+ \fi
+ % copy it back to 'b' register:
+ \t@pgfplots@tokb=\expandafter{\pgfplots@matrixentry}%
+ %
+ \ifnum\curcolumnNum=\maxcolumnCount
+ \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\\}%
+ \else
+ \pgfplotslistcheckempty\pgfplots@legend
+ \ifpgfplotslistempty
+ \else
+ \pgfplotslistcheckempty\pgfplots@plotspeclist
+ \fi
+ \ifpgfplotslistempty
+ % Ok, either the legend list is empty or
+ % there are no more plot specifications.
+ %
+ % Finalize matrix:
+ \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\\}%
+ \else
+ \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\pgfmatrixnextcell}%
+ \fi
+ \fi
+ \xdef\pgfplots@glob@TMPa{%
+ \the\t@pgfplots@toka
+ \the\t@pgfplots@tokb
+ }%
+ \endgroup
+ \ifnum\curcolumnNum=\maxcolumnCount
+ \curcolumnNum=0
+ \fi
+ \expandafter\t@pgfplots@toka\expandafter{\pgfplots@glob@TMPa}%
+ \fi
+ }%
+ \t@pgfplots@tokb={\matrix[/pgfplots/every axis legend]}%
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand\plotnum{0}%
+ \noexpand\def\noexpand\plotnumofactualtype{0}%
+ \the\t@pgfplots@tokb {%
+ \the\t@pgfplots@toka
+ };%
+ }%
+ \endgroup
+ \let\pgfplots@already@computed@legend@node=\pgfplots@glob@TMPa
+ \fi
+ \fi
+ \ifx\pgfplots@createlegend@toname\pgfutil@empty
+ % DRAW:
+ \pgfplotsgetlayerforstyle{every axis legend}%
+ \pgfplotsonlayer\pgfplotsretval{legend style}%
+ \pgfplots@already@computed@legend@node
+ \endpgfplotsonlayer
+ \else
+ % apply the 'legend to name' feature:
+ %
+ % store legend contents:
+ %
+ \t@pgfplots@toka=\expandafter{\pgfplots@already@computed@legend@node}%
+ \pgfkeysgetvalue{/pgfplots/every axis legend/.@cmd}\pgfplots@loc@TMPa
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa\pgfeov}%
+ %
+ \pgfplots@assemble@ref@picture
+ {\pgfplots@legend@to@name}
+ {\tikz[/pgfplots/every legend to name picture/.try]{\pgfplots@legend@to@name}}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotsretval}%
+ %
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/every legend image post/.@cmd}\pgfplots@loc@TMPa
+ % steal \toks0 temporarily. Within this group, it won't be
+ % used by any LaTeX code:
+ \toks0=\expandafter{\pgfplots@loc@TMPa\pgfeov}%
+ %
+ \expandafter\xdef\csname pgfplots@legend@to@name@\pgfplots@createlegend@toname\endcsname{%
+ \noexpand\begingroup
+ \noexpand\def\noexpand\pgfplots@legend@to@name{%
+ \noexpand\pgfkeysdef{/pgfplots/every axis legend}{\the\t@pgfplots@tokb}%
+ \noexpand\pgfkeysdef{/pgfplots/every legend image post}{\the\toks0 }%
+ \noexpand\def\noexpand\numplots{\numplots}%
+ \the\t@pgfplots@toka
+ }%
+ \the\t@pgfplots@tokc
+ \noexpand\endgroup
+ }%
+ \endgroup
+ \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfplots@legend@to@name@\pgfplots@createlegend@toname\endcsname}%
+ \pgfplots@auxwrite{%
+ \noexpand\expandafter
+ \noexpand\gdef
+ \noexpand\csname pgfplots@legend@to@name@\pgfplots@createlegend@toname\noexpand\endcsname%
+ {\the\t@pgfplots@toka}%
+ }%
+ \begingroup
+ %
+ % make sure \ref{<legendname>} works:
+ \pgfplots@label{\pgfplots@createlegend@toname}{pgfplots@legend@to@name@}%
+ \endgroup
+ \fi
+}
+
+\pgfutil@IfUndefined{AtBeginDocument}{}{%
+ \AtBeginDocument{%
+ \let\pgfplots@original@LaTeX@label@loadtime=\label
+ }%
+}
+
+% Defines a new \label{#1}. When \ref{#1} is used, the code
+% \csname #3#2\endcsname
+% will be invoked.
+% \pgfplots@label[<optional prefix>]{<label name>}{<command prefix>}
+% invokes
+% \label<optional prefix>{<label name>}
+\def\pgfplots@label{\pgfutil@ifnextchar[{\pgfplots@label@@}{\pgfplots@label@@[]}}%
+\def\pgfplots@label@@[#1]#2#3{%
+ \begingroup
+ \edef\@currentlabel{%
+ \string\expandafter
+ \string\protect
+ \string\csname\space #3#2\string\endcsname
+ }%
+ \pgfutil@IfUndefined{hyper@makecurrent}{}{%
+ \hyper@makecurrent{pgfplotslink}%
+ \hyper@anchorstart{\@currentHref}{}\hyper@anchorend
+ \pgfplotsutil@advancestringcounter@global\c@pgfplots@label
+ }%
+ %
+ \pgfplots@label@configure@package@workarounds
+ %
+ \pgfutil@IfUndefined{label}{%
+ }{%
+ \def\pgfplots@loc@TMPa{\label #1}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{#2}% the \expandafter is a convenience method; the name should be expandable anyway
+ }%
+ \endgroup
+}%
+\gdef\c@pgfplots@label{0}%
+\def\theHpgfplotslink{\theHsection.\c@pgfplots@label}%
+
+\def\pgfplots@label@configure@package@workarounds{%
+ % this is a work-around to support the memoir class (it overwrites
+ % \label in sub
+ \let\sf@@memsub@label=\pgfplots@original@LaTeX@label@loadtime
+ %
+ \ifx\label\mcaption@label
+ % this is a work-around to support the mcaption class: it
+ % simply remembers the label name and invokes \label later-on.
+ % This appears to be wrong in this context: I want to generate
+ % a pgfplots label.
+ %
+ % If someone writes \label{fig:one}, that label will be
+ % redeclared in the margin - which appears to be correct. And
+ % that will still work.
+ %
+ % This here will activate pgfplots' labels:
+ \let\label=\pgfplots@original@LaTeX@label@loadtime
+ \fi
+}
+
+% this is deprecated. Use \ref{#1} instead.
+\def\pgfplotslegendfromname#1{%
+ \pgfplots@texdist@protect\pgfplotslegendfromname@{#1}%
+}%
+\def\pgfplotslegendfromname@#1{%
+ \pgfutil@IfUndefined{pgfplots@legend@to@name@#1}{%
+ \pgfutil@IfUndefined{ref}{%
+ \pgfplotswarning{no such legend to name}{#1}\pgfeov
+ \string\pgfplotslegendfromname{#1}: ??%
+ }{%
+ \ref{\string\pgfplotslegendfromname{#1}}%
+ }%
+ }{%
+ \csname pgfplots@legend@to@name@#1\endcsname
+ }%
+}%
+% this is deprecated. Use \ref{#1} instead.
+\def\pgfplotscolorbarfromname#1{%
+ \pgfplots@texdist@protect\pgfplotscolorbarfromname@{#1}%
+}%
+\def\pgfplotscolorbarfromname@#1{%
+ \pgfutil@IfUndefined{pgfplots@colorbar@to@name@#1}{%
+ \pgfutil@IfUndefined{ref}{%
+ \pgfplotswarning{no such colorbar to name}{#1}\pgfeov
+ \string\pgfplotscolorbarfromname{#1}: ??%
+ }{%
+ \ref{\string\pgfplotscolorbarfromname{#1}}%
+ }%
+ }{%
+ \csname pgfplots@colorbar@to@name@#1\endcsname
+ }%
+}%
+
+\def\pgfplotsplotfromname#1{%
+ \pgfplots@texdist@protect\pgfplotsplotfromname@{#1}%
+}%
+\def\pgfplotsplotfromname@#1{%
+ \pgfutil@IfUndefined{pgfplots@show@ref@#1}{%
+ \pgfutil@IfUndefined{ref}{%
+ \pgfplotswarning{no such addplot label}{#1}\pgfeov
+ \string\pgfplotsplotfromname{#1}: ??%
+ }{%
+ \ref{\string\pgfplotsplotfromname{#1}}%
+ }%
+ }{%
+ \csname pgfplots@show@ref@#1\endcsname
+ }%
+}%
+
+\def\pgfplots@ifintikzpicture#1#2{%
+ \ifpgfpicture #1\else #2\fi
+}%
+
+% DEPRECATED.
+\def\skipsuffixzero#1.#2|{
+ {%
+ \def\pgfplots@loc@TMPa{#2}%
+ \def\pgfplots@loc@TMPb{0}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \global\def\pgfmathresult{#1}%
+ \else
+ \global\def\pgfmathresult{#1.#2}%
+ \fi
+ }%
+}
+
+\def\pgfmathlogtologten#1{%
+ \pgfmathparse{#1}%
+ \expandafter\pgfmathlogtologten@\expandafter{\pgfmathresult}%
+}
+
+% Simply divides #1 by log(10).
+% ATTENTION: in order to implement per-axis log basis, this will be
+% OVERWRITTEN in pgfplotsticks.code.tex !
+\def\pgfmathlogtologten@#1{%
+ \pgfmathmultiply@{#1}\reciproclogten%
+}%
+
+% DEPRECATED.
+\def\logtologtentomacro#1#2{%
+ \pgfmathlogtologten@{#1}%
+ \expandafter\skipsuffixzero\pgfmathresult|%
+ \let#2=\pgfmathresult
+}
+
+% DEPRECATED.
+\def\logtologten#1{%
+ \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
+}%
+
+\def\pgfplots@enlargelimits@rel@unitserror#1{%
+ \pgfplots@error{enlarge limits only supports values with units for 'abs=#1' and/or 'abs value=#1'. Ignoring unit}%
+}%
+\pgfkeysdef{/pgfplots/@enlargelimits/value}{%
+ \pgfmathparse{#1}%
+ \ifpgfmathunitsdeclared
+ \pgfplots@enlargelimits@rel@unitserror{#1}%
+ \fi
+ \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
+ \ifpgfplots@usefpu
+ \pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
+ \fi
+ \pgfmathparse{#1}%
+ \xdef\pgfplots@glob@TMPa{%
+ \ifpgfmathunitsdeclared
+ \noexpand\pgfmathunitsdeclaredtrue
+ \else
+ \noexpand\pgfmathunitsdeclaredfalse
+ \fi
+ \noexpand\def\noexpand\pgfmathresult{\pgfmathresult}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+ \ifpgfmathunitsdeclared
+ \edef\pgfplots@enlargelimits@absdimension{\pgfmathresult pt}%
+ \let\pgfplots@enlargelimits@absthresh=\pgfutil@empty
+ \else
+ \let\pgfplots@enlargelimits@absdimension=\pgfutil@empty
+ \csname pgfplotstransformdirection\pgfplots@enlargelimits@curaxis\endcsname{\pgfmathresult}%
+ \let\pgfplots@enlargelimits@absthresh=\pgfmathresult
+ \fi
+ \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{%
+ \begingroup
+ % ATTENTION: this uses similar access patterns as
+ % \pgfplots@enlarge@limit@by@dimension
+ \def\bool@pgfplots@loc@enlargelimits@min{0}%
+ \def\bool@pgfplots@loc@enlargelimits@max{0}%
+ %
+ % we can either enlarge
+ % ... using a relative limit (like 0.1 -> 10%)
+ \def\pgfplots@enlargelimits@relthresh{0.1}% the default
+ % ...or an absolute limit ( like 4 units)
+ \let\pgfplots@enlargelimits@absthresh=\pgfutil@empty
+ % or an absolute dimension (like 1cm).
+ %
+ % Relative and absolute values are relatively simple: we only need to compute and
+ % add the changes to the already existing limits. The value with
+ % an absolute dimension is surprisingly complicated.
+ %
+ % The problem is: enlargelimits has to be computed before the
+ % image has been scaled into its final size. This is not merely a
+ % technical problem; this is how one wants it to be!
+ %
+ % The solution taken here is to communicate such an absolute
+ % dimension to the scaling routines. The scaling routines will
+ % handle the case; we don't change limits here.
+ %
+ \let\pgfplots@enlargelimits@absdimension=\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\bool@pgfplots@loc@enlargeany{0}%
+ \if1\bool@pgfplots@loc@enlargelimits@min
+ \def\bool@pgfplots@loc@enlargeany{1}%
+ \else
+ \if1\bool@pgfplots@loc@enlargelimits@max
+ \def\bool@pgfplots@loc@enlargeany{1}%
+ \fi
+ \fi
+ \if1\bool@pgfplots@loc@enlargeany
+ \pgfplots@enlarge@limit@for{#1}%
+ \fi
+ \global\let\pgfplots@glob@TMPa=\bool@pgfplots@loc@enlargeany
+ % limits assignments are made globally.
+ \xdef\pgfplots@glob@TMPb{%
+ \noexpand\pgfplots@enlargelimits@remember@abs@dimension{#1}%
+ {\bool@pgfplots@loc@enlargelimits@min}%
+ {\bool@pgfplots@loc@enlargelimits@max}%
+ {\pgfplots@enlargelimits@absdimension}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPb
+ \if1\pgfplots@glob@TMPa
+ \pgfplots@visphase@notify@changeofcanvaslimits{#1}%
+ \fi
+}
+
+% Reconfigures the scaling routines such that following calls to
+% \pgfplots@scaleaxes@to@BB@ will enlarge the limit for a specific
+% axis by an absolute dimension.
+%
+% This enlargement is different from standard limit enlargement:
+% Standart limit enlargement is typically applied (and finished) long
+% before the scaling routines start. In fact, the result of
+% enlargelimits is typically the input argument for the scaling
+% (compare the pgfplots manual (pdf)).
+%
+% This here needs a different treatment because "enlarge x limits={abs=1cm}"
+% has to be applied AFTER the scaling is complete. To this end, it is
+% applied as the very last scaling step. It is applied after any post
+% scales, and it only modifies axis limits.
+%
+% #1: x,y, or z
+% #2: 1 if the lower limit shall be enlarged, 0 if not
+% #3: 1 if the upper limit shall be enlarged, 0 if not
+% #4: some absolute dimension (like 1cm) by which we want to enlarge
+% axis limits.
+\def\pgfplots@enlargelimits@remember@abs@dimension#1#2#3#4{%
+ \expandafter\edef\csname pgfplots@enlargelimits@absdimension@#1\endcsname{#4}%
+ \expandafter\edef\csname pgfplots@enlargelimits@absdimension@#1@minmax\endcsname{{#2}{#3}}%
+}%
+\let\pgfplots@enlargelimits@absdimension@x=\pgfutil@empty
+\let\pgfplots@enlargelimits@absdimension@y=\pgfutil@empty
+\let\pgfplots@enlargelimits@absdimension@z=\pgfutil@empty
+
+% Called as soon as the scaling is completely set up and any
+% "enlarge #1 limits={abs=1cm}"
+% enlargements shall be done, i.e. enlargement by unit.
+%
+% #1: x,y, or z
+\def\pgfplots@scaling@apply@enlargelimits@by@dimension#1{%
+ \expandafter\ifx\csname pgfplots@enlargelimits@absdimension@#1\endcsname\pgfutil@empty
+ \else
+ \pgfplotsconvertunittocoordinate{#1}{\csname pgfplots@enlargelimits@absdimension@#1\endcsname}%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplots@enlarge@limit@by@dimension{#1}
+ \csname pgfplots@enlargelimits@absdimension@#1@minmax\endcsname
+ {\pgfmathresult}%
+ }%
+ \pgfplots@loc@TMPa
+ \fi
+}%
+
+
+% PRECONDITION:
+% 1. width/height are set
+% 2. the unit vectors point indicate whether the axis is a standard
+% box or some skewed plot (their precise direction and magnitude is
+% irrelevant)
+% 3. the enlargelimits code has already evaluated the case
+% "enlargelimits={abs=1cm}"
+%
+% POSTCONDITION:
+% width and/or height might be modified
+\def\pgfplots@scaling@changewidthheight@for@enlargelimits@by@dimension{%
+ \ifpgfplots@enlargelimits@respect@figure@size
+ %
+ % decide if we need to do anything at all, i.e. if there IS
+ % some option 'enlarge * limits={abs=1cm}' :
+ \pgfplots@loc@tmpfalse
+ \ifx\pgfplots@enlargelimits@absdimension@x\pgfutil@empty
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifx\pgfplots@enlargelimits@absdimension@y\pgfutil@empty
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifx\pgfplots@enlargelimits@absdimension@z\pgfutil@empty
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ %
+ \ifpgfplots@loc@tmp
+ \def\pgfplotsretval{}%
+ % ok. We encountered an option 'enlarge * limits={abs=1cm}' for at least one axis.
+ % and we WANT to keep 'width', 'height'.
+ %
+ % This is not quite trivial because in order to compute
+ % enlarge-by-dimension, we NEED the unit vectors. But the
+ % unit vectors need the limits - a nonlinear problem.
+ %
+ % Since this here is not really a common use-case, I
+ % decided to implement a heuristics which works in most
+ % common cases: for standard 2d axes. It might fail for
+ % skewed axes and it will probably fail for 3d axes.
+ %
+ % My idea is to change width and/or height BEFORE the unit
+ % vectors have been computed.
+ %
+ % First: check if we HAVE a standard 2d axis.
+ \pgfplots@loc@tmpfalse
+ \ifpgfplots@threedim
+ \else
+ \ifdim\pgf@xx=0sp %
+ \else
+ \ifdim\pgf@xy=0sp %
+ \ifdim\pgf@yx=0sp %
+ \ifdim\pgf@yy=0sp %
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ %
+ \ifpgfplots@loc@tmp
+ \def\pgfplots@loc@TMPc{{1}{1}}%
+ %
+ % ah - we really *have* a standard boxed axis.
+ % Compute
+ % newwidth = width - enlargevalue
+ % newheight = height - enlargevalue
+ %
+ % newwidth will be stored in \pgfplots@loc@TMPa
+ % and newheight in \pgfplots@loc@TMPb
+ \ifx\pgfplots@enlargelimits@absdimension@x\pgfutil@empty
+ \let\pgfplots@loc@TMPa=\pgfplots@width
+ \else
+ \ifx\pgfplots@enlargelimits@absdimension@x@minmax\pgfplots@loc@TMPc
+ \def\pgfmathresult{2}%
+ \else
+ \def\pgfmathresult{1}%
+ \fi
+ \pgfmathparse{\pgfplots@width - \pgfmathresult * \pgfplots@enlargelimits@absdimension@x}%
+ \edef\pgfplots@loc@TMPa{\pgfmathresult pt}%
+ \fi
+ %
+ \ifx\pgfplots@enlargelimits@absdimension@y\pgfutil@empty
+ \let\pgfplots@loc@TMPb=\pgfplots@height
+ \else
+ \ifx\pgfplots@enlargelimits@absdimension@y@minmax\pgfplots@loc@TMPc
+ \def\pgfmathresult{2}%
+ \else
+ \def\pgfmathresult{1}%
+ \fi
+ \pgfmathparse{\pgfplots@height - \pgfmathresult * \pgfplots@enlargelimits@absdimension@y}%
+ \edef\pgfplots@loc@TMPb{\pgfmathresult pt}%
+ \fi
+ %
+ % OK. if( newwidth>0 && newheight>0 ), we can proceed.
+ \pgfplots@loc@tmpfalse
+ \ifdim\pgfplots@loc@TMPa>10pt %
+ \ifdim\pgfplots@loc@TMPb>10pt %
+ \pgfplots@loc@tmptrue
+ \fi
+ \fi
+ \ifpgfplots@loc@tmp
+ % Ah: newheight>0 && newheight>0 . Good.
+ \let\pgfplots@width=\pgfplots@loc@TMPa
+ \let\pgfplots@height=\pgfplots@loc@TMPb
+ \else
+ \def\pgfplotsretval{enlarge value are bigger than old picture size}%
+ \fi
+ \else
+ \def\pgfplotsretval{size adjust is unavailable for non-standard axes}%
+ \fi
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \pgfplotswarning{enlargelimits respects figure size failed}\pgfeov%
+ \fi
+ \fi
+ \fi
+}
+
+% this here applies changes required for 'enlarge #1 limits={abs=1cm}', i.e.
+% for the case of numbers with units.
+%
+% The main difference is that it is applied AFTER the scaling of the
+% axis is complete.
+%
+% #1: x,y,or z
+% #2: 1 if lower limit shall be changed
+% #3: 1 if upper limit shall be changed
+% #4: the absolute value
+\def\pgfplots@enlarge@limit@by@dimension#1#2#3#4{%
+ \begingroup
+ % ATTENTION: this uses similar access patterns as
+ % \pgfplots@enlarge@limit@ifconfigured
+ \def\bool@pgfplots@loc@enlargelimits@min{#2}%
+ \def\bool@pgfplots@loc@enlargelimits@max{#3}%
+ %
+ \let\pgfplots@enlargelimits@relthresh=\pgfutil@empty
+ \def\pgfplots@enlargelimits@absthresh{#4}
+ \def\pgfplots@enlargelimits@curaxis{#1}%
+ %
+ \def\bool@pgfplots@loc@enlargeany{0}%
+ \if1\bool@pgfplots@loc@enlargelimits@min
+ \def\bool@pgfplots@loc@enlargeany{1}%
+ \else
+ \if1\bool@pgfplots@loc@enlargelimits@max
+ \def\bool@pgfplots@loc@enlargeany{1}%
+ \fi
+ \fi
+ \if1\bool@pgfplots@loc@enlargeany
+ \pgfplots@enlarge@limit@for{#1}%
+ \fi
+ \global\let\pgfplots@glob@TMPa=\bool@pgfplots@loc@enlargeany
+ % limits assignments are made globally.
+ \endgroup
+ \if1\pgfplots@glob@TMPa
+ \pgfplots@visphase@notify@changeofcanvaslimits{#1}%
+ \fi
+}
+
+
+% 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\csname pgfplots@#1min\endcsname
+ \expandafter\let\expandafter\pgfplots@@max\csname pgfplots@#1max\endcsname
+ \ifx\pgfplots@enlargelimits@relthresh\pgfutil@empty
+ \ifx\pgfplots@enlargelimits@absthresh\pgfutil@empty
+ % ups. No enlargement!? OK, can happen for 'abs=1cm' ...
+ % numbers with unit are processed later (after the scaling
+ % is set up)
+ \pgf@xb=0pt %
+ \else
+ % we have an absolute enlarge value:
+ \let\enlargeabsolute=\pgfplots@enlargelimits@absthresh
+ \pgf@xb=\pgfplots@enlargelimits@absthresh pt
+ \fi
+ \else
+ % 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
+ \ifdim\pgf@xb>0.001pt
+ % the case with
+ % enlargeabsolute ~= 0
+ % means that \pgfplots@@min ~= \pgfplots@@max.
+ % It is handled in another method.
+ %
+ \if1\bool@pgfplots@loc@enlargelimits@min
+ \pgfmathsubtract@\pgfplots@@min\enlargeabsolute%
+ \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
+ \fi
+ \if1\bool@pgfplots@loc@enlargelimits@max
+ \pgfmathadd@\pgfplots@@max\enlargeabsolute%
+ \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
+ \fi
+ \fi
+ \endgroup
+}
+
+
+% Initialises the data scale transformation and applies it to any
+% user specified options.
+%
+% PRECONDITION:
+% - all axis limits are already transformed
+% - \pgfplots@set@default@size@options has been called before
+% - the scaling transformation for direction x is set up
+% (\pgfplots@set@optimal@datatrafo@for@),
+% POSTCONDITION:
+% - any user input (like ticks and tick labels)
+% EXCEPT unit vectors will reflect the changes.
+%
+% Unit vectors will be scaled later.
+% @see \pgfplots@apply@datatrafo@to@axis@limits
+\def\pgfplots@check@and@apply@datatrafo@for#1{%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ % Transform axis limits: ALREADY DONE.
+ %
+ % Transform tick limits (if they are set):
+%\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
+ \pgfplotscoordmath{#1}{datascaletrafo}{\csname pgfplots@#1tickmin\endcsname}%
+ \expandafter\global\expandafter\let\csname pgfplots@#1tickmin\endcsname=\pgfmathresult
+ \fi
+ %
+ \expandafter\ifx\csname pgfplots@#1tickmax\endcsname\pgfutil@empty
+ \else
+ \pgfplotscoordmath{#1}{datascaletrafo}{\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]}%
+ %
+ % Convert any user-specified ticks:
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@#1tick\endcsname}%
+ % this here should also work with 'xtick=\empty', the "No tick" command.
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPb{data}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % we have #1tick = data
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@firstplot@coords@#1\endcsname}%
+ \expandafter\pgfplotsutil@unify@short@csv@list\expandafter{\pgfplots@loc@TMPa}%
+ \let\pgfplots@loc@TMPa=\pgfplotsretval
+ \fi
+%\message{Converting #1tick='\csname pgfplots@#1tick\endcsname'}%
+ \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\expandafter{\pgfplots@loc@TMPa}%
+ {\pgfplotscoordmath{#1}{datascaletrafo}}%
+ \to\pgfplots@loc@TMPc
+ \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@loc@TMPc
+ \fi
+ %
+ % Convert any extra-ticks, see above.
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@extra@#1tick\endcsname}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \edef\pgfplots@loc@TMPa{{\csname pgfplots@extra@#1tick\endcsname}}%
+ \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\pgfplots@loc@TMPa
+ {\pgfplotscoordmath{#1}{datascaletrafo}}%
+ \to\pgfplots@loc@TMPc
+ \expandafter\let\csname pgfplots@extra@#1tick\endcsname=\pgfplots@loc@TMPc
+ \fi
+ %
+ % Convert any minor tick lists in the same way.
+ \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPb{data}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % we have #1tick = data
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@firstplot@coords@#1\endcsname}%
+ \expandafter\pgfplotsutil@unify@short@csv@list\expandafter{\pgfplots@loc@TMPa}%
+ \let\pgfplots@loc@TMPa=\pgfplotsretval
+ \fi
+ \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\expandafter{\pgfplots@loc@TMPa}%
+ {\pgfplotscoordmath{#1}{datascaletrafo}}%
+ \to\pgfplots@loc@TMPc
+ \pgfkeyslet{/pgfplots/minor #1tick}\pgfplots@loc@TMPc
+ \fi
+ %
+ % Transform any explicit axis unit scalings: ALREADY DONE
+ }{%
+ % case apply trafo == false:
+ \def\pgfplots@loc@TMPb{data}%
+ \expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfplots@loc@TMPb
+ \edef\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%
+ \fi
+ \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPb{data}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@firstplot@coords@#1\endcsname}%
+ \expandafter\pgfplotsutil@unify@short@csv@list\expandafter{\pgfplots@loc@TMPa}%
+ \pgfkeyslet{/pgfplots/minor #1tick}\pgfplotsretval
+ \fi
+ \fi
+ }%
+}
+
+\newif\ifpgfplots@determinedefaultvalues@isuniform
+\newif\ifpgfplots@determinedefaultvalues@needs@check@uniformtick
+\newif\ifpgfplots@limits@are@computed
+
+\def\pgfplots@handle@invalid@range@defaultlimits{%
+ \pgfplotscoordmath{x}{parsenumber}{0}%
+ \global\let\pgfplots@xmin=\pgfmathresult
+ \pgfplotscoordmath{x}{parsenumber}{1}%
+ \global\let\pgfplots@xmax=\pgfmathresult
+ \global\let\pgfplots@data@xmin=\pgfplots@xmin
+ \global\let\pgfplots@data@xmax=\pgfplots@xmax
+ %
+ \pgfplotscoordmath{y}{parsenumber}{0}%
+ \global\let\pgfplots@ymin=\pgfmathresult
+ \pgfplotscoordmath{y}{parsenumber}{1}%
+ \global\let\pgfplots@ymax=\pgfmathresult
+ \global\let\pgfplots@data@ymin=\pgfplots@ymin
+ \global\let\pgfplots@data@ymax=\pgfplots@ymax
+}
+\def\pgfplots@handle@invalid@range{%
+ % COMPLETELY EMPTY AXIS:
+ \pgfplotswarning{empty range cleared axis}\pgfplots@loc@TMPa\pgfeov
+ \pgfplots@handle@invalid@range@defaultlimits
+ %
+ \pgfplots@threedimfalse
+ \def\pgfplots@xtick{}%
+ \def\pgfplots@ytick{}%
+ \def\pgfplots@extra@xtick{}%
+ \def\pgfplots@extra@ytick{}%
+ \def\pgfplots@xtickten{}%
+ \def\pgfplots@ytickten{}%
+ % clear all plots!
+ \pgfplots@init@cleared@structures
+}
+\def\pgfplots@check@invalid@range{%
+ \pgfplots@limits@are@computedtrue
+ \def\pgfplots@loc@TMPa{}%
+ \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin
+ \pgfplots@limits@are@computedfalse
+ \edef\pgfplots@loc@TMPa{x}%
+ \fi
+ \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax
+ \pgfplots@limits@are@computedfalse
+ \edef\pgfplots@loc@TMPa{x}%
+ \fi
+ \ifx\pgfplots@ymin\pgfplots@invalidrange@ymin
+ \pgfplots@limits@are@computedfalse
+ \edef\pgfplots@loc@TMPa{y}%
+ \fi
+ \ifx\pgfplots@ymax\pgfplots@invalidrange@ymax
+ \pgfplots@limits@are@computedfalse
+ \edef\pgfplots@loc@TMPa{y}%
+ \fi
+ \ifpgfplots@threedim
+ \ifx\pgfplots@zmin\pgfplots@invalidrange@zmin
+ \pgfplots@limits@are@computedfalse
+ \edef\pgfplots@loc@TMPa{z}%
+ \fi
+ \ifx\pgfplots@zmax\pgfplots@invalidrange@zmax
+ \pgfplots@limits@are@computedfalse
+ \edef\pgfplots@loc@TMPa{z}%
+ \fi
+ \fi
+ \ifpgfplots@limits@are@computed
+ \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmin
+ \global\let\pgfplots@data@xmin=\pgfplots@xmin
+ \fi
+ \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmax
+ \global\let\pgfplots@data@xmax=\pgfplots@xmax
+ \fi
+ \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymin
+ \global\let\pgfplots@data@ymin=\pgfplots@ymin
+ \fi
+ \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymax
+ \global\let\pgfplots@data@ymax=\pgfplots@ymax
+ \fi
+ \ifx\pgfplots@data@zmin\pgfplots@invalidrange@zmin
+ \global\let\pgfplots@data@zmin=\pgfplots@zmin
+ \fi
+ \ifx\pgfplots@data@zmin\pgfplots@invalidrange@zmax
+ \global\let\pgfplots@data@zmax=\pgfplots@zmax
+ \fi
+ \ifpgfplots@clip@limits@x
+ \else
+ % there is a rare change that min > max.
+ % Handle that ...
+ \pgfplotscoordmath{x}{min}{\pgfplots@xmin}{\pgfplots@xmax}%
+ \global\let\pgfplots@xmin=\pgfmathresult
+ \pgfplotscoordmath{x}{max}{\pgfplots@xmin}{\pgfplots@xmax}%
+ \global\let\pgfplots@xmax=\pgfmathresult
+ \fi
+ \ifpgfplots@clip@limits@y
+ \else
+ %
+ \pgfplotscoordmath{y}{min}{\pgfplots@ymin}{\pgfplots@ymax}%
+ \global\let\pgfplots@ymin=\pgfmathresult
+ \pgfplotscoordmath{y}{max}{\pgfplots@ymin}{\pgfplots@ymax}%
+ \global\let\pgfplots@ymax=\pgfmathresult
+ \fi
+ \ifpgfplots@clip@limits@z
+ \else
+ %
+ \ifpgfplots@threedim
+ \pgfplotscoordmath{z}{min}{\pgfplots@zmin}{\pgfplots@zmax}%
+ \global\let\pgfplots@zmin=\pgfmathresult
+ \pgfplotscoordmath{z}{max}{\pgfplots@zmin}{\pgfplots@zmax}%
+ \global\let\pgfplots@zmax=\pgfmathresult
+ \fi
+ \fi
+ \else
+ \pgfplots@handle@invalid@range
+ \fi
+}%
+
+
+% This method finishes the accumulated information of axis limits and
+% all internal flag fields.
+%
+% PRECONDITION:
+% - all plots are finally finished; axis and data limits are known.
+%
+% POSTCONDITION:
+% - the scaling transformation is set-up and applied to all user
+% inputs and axis limits.
+% - the \pgfplots@[xy][min,max] variables and associated TeX
+% registers are set up and final. They should not be changed
+% afterwards.
+% - any tick lists etc. are final.
+%
+\def\pgfplots@determinedefaultvalues{%
+ \pgfplots@check@invalid@range
+ %
+%\message{untransformed: x = [\pgfplots@xmin:\pgfplots@xmax] y = [\pgfplots@ymin:\pgfplots@ymax]. }%
+ %
+ %
+ \pgfplots@set@default@size@options
+ %
+ \ifpgfplots@threedim
+ \pgfplotsthreedimtrue
+ \else
+ \pgfplotsthreedimfalse
+ \fi
+ %
+ \pgfplots@set@optimal@datatrafos@allaxes
+ %
+ % Now, the data scaling has been set up.
+ % However, it may need to be changed if axis equal and/or unit
+ % vector ratio changes the axis limits considerably. If so, it
+ % will be done in \pgfplots@initsizes
+ \pgfplots@apply@datatrafo@to@axis@limits x%
+ \pgfplots@apply@datatrafo@to@axis@limits y%
+ \ifpgfplots@threedim
+ \pgfplots@apply@datatrafo@to@axis@limits z%
+ \fi
+ %
+ \pgfplots@datascaletrafo@initialisedtrue
+%\message{transformed: x = [\pgfplots@xmin:\pgfplots@xmax] y = [\pgfplots@ymin:\pgfplots@ymax].}%
+ %
+ % From now on, we can always work with pgfmath.
+ % We simply need to apply the data scaling trafo before doing so.
+ \pgfplots@enlarge@limit@ifconfigured x
+ \pgfplots@avoid@empty@axis@range@for x%
+ %
+ \pgfplots@enlarge@limit@ifconfigured y
+ \pgfplots@avoid@empty@axis@range@for y%
+
+ \ifpgfplots@threedim
+ \pgfplots@enlarge@limit@ifconfigured z
+ \pgfplots@avoid@empty@axis@range@for z%
+ \fi
+ %
+ \pgfplots@initsizes
+ %
+ \pgfplots@check@and@apply@datatrafo@for x%
+ \pgfplots@check@and@apply@datatrafo@for y%
+ \ifpgfplots@threedim
+ \pgfplots@check@and@apply@datatrafo@for z%
+ \fi
+ % clear structure:
+ \global\let\pgfplots@firstplot@coords@x=\pgfutil@empty
+ \global\let\pgfplots@firstplot@coords@y=\pgfutil@empty
+ \global\let\pgfplots@firstplot@coords@z=\pgfutil@empty
+ %
+ \pgfplots@limits@ready
+ %
+ \pgfplots@set@options@after@survey1%
+ %
+ \pgfplotspoint@initialisation
+ %
+ %
+ \pgfplots@BEGIN@prepare@description@styles
+ %
+ %
+ \pgfplots@init@ticks@for x%
+ \pgfplots@init@ticks@for y%
+ \ifpgfplots@threedim
+ \pgfplots@init@ticks@for z%
+ \fi
+ \pgfplots@init@ticks@ready
+ %
+ %
+ \pgfplots@prepare@ZERO@coordinates
+ %
+ \pgfplots@decide@which@figure@surfaces@are@drawn
+ \pgfplots@init@ticklabelaxisspec
+ %
+ \pgfplots@define@threedim@marks
+ %
+ \pgfplots@clippath@prepare
+ %
+ \pgfplots@ticklabel@maxtickdimen@reset x%
+ \pgfplots@ticklabel@maxtickdimen@reset y%
+ \pgfplots@ticklabel@maxtickdimen@reset z%
+ %
+ \pgfplots@init@axis@shift
+}
+
+% executes '#2' if 'axis #1 line shift' is set and '#3' if not.
+\def\pgfplots@if@has@axis@shift#1#2#3{%
+ \pgfkeysgetvalue{/pgfplots/axis #1 line shift}\pgfplots@loc@TMPb
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ #3%
+ \else
+ #2%
+ \fi
+}%
+
+\def\pgfplots@init@axis@shift{%
+ \pgfplotsforeachentryinCSV{\pgfplots@loc@TMPa}{x,y,z}{%
+ % check if 'axis #1 line shift' is set and non-zero.
+ \expandafter\pgfplots@if@has@axis@shift\pgfplots@loc@TMPa{%
+ \pgfkeysgetvalue{/pgfplots/axis \pgfplots@loc@TMPa\space line shift}\pgfplots@loc@TMPb
+ \pgfmathparse{\pgfplots@loc@TMPb}%
+ \ifdim\pgfmathresult pt=0pt
+ \def\pgfplots@loc@TMPb{}%
+ \else
+ \ifpgfmathunitsdeclared
+ \else
+ \ifpgfplots@threedim
+ % ... I do not know which axis unit should be
+ % used here.
+ \pgfplots@error{Cannot process 'axis \pgfplots@loc@TMPa\space line shift=\pgfplots@loc@TMPb': please provide a dimension like 10pt. Shifting by axis units is only implemented for 2d axes}%
+ \else
+ % Ah - a shift by axis units.
+ % Ok, then determine the correct axis and
+ % compute the shift.
+ %
+ % This works because the outer normal is the
+ % same as one of the axes.
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \if x\pgfplots@loc@TMPa
+ \pgfplotstransformdirectiony{\pgfplots@loc@TMPb}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotsqpointxy{0}{\pgfplots@loc@TMPb}%
+ \else
+ \pgfplotstransformdirectionx{\pgfplots@loc@TMPb}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotsqpointxy{\pgfplots@loc@TMPb}{0}%
+ \fi
+ \pgfmathveclen@{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}%
+ \ifdim\pgfplots@loc@TMPb pt<0sp
+ % we have lost the sign... restore it.
+ \edef\pgfmathresult{-\pgfmathresult}%
+ \fi
+ \fi
+ \fi
+ %
+ \edef\pgfplots@loc@TMPb{\pgfmathresult}% NO unit here
+ \if z\pgfplots@loc@TMPa
+ \ifpgfplots@threedim
+ \pgfplots@separate@axis@linestrue
+ \fi
+ \else
+ \pgfplots@separate@axis@linestrue
+ \fi
+ \fi
+ %
+ % normalize the value - no need to parse it over and over again:
+ \pgfkeyslet{/pgfplots/axis \pgfplots@loc@TMPa\space line shift}\pgfplots@loc@TMPb
+ }{}%
+ }%
+}%
+
+\def\pgfplots@init@ticks@ready{}%
+\def\pgfplots@init@ticks@for#1{%
+ \pgfplots@isuniformticktrue
+ \pgfplots@determinedefaultvalues@needs@check@uniformticktrue
+ \expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfutil@empty
+ \pgfplots@assign@default@tick@foraxis{#1}%
+ \fi
+ \ifpgfplots@determinedefaultvalues@needs@check@uniformtick
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname
+ \edef\pgfplots@loc@TMPb{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ % there are no ticks left.
+ \pgfplots@isuniformtickfalse
+ \else
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \def\pgfplots@loc@TMPb{\expandafter\pgfplots@checkisuniformLINEARtick\expandafter{\pgfplots@loc@TMPa}}%
+ \expandafter\pgfplots@loc@TMPb\csname pgfplots@tick@distance@#1\endcsname%
+ }{%
+ \expandafter\pgfplots@checkisuniformLOGtick\expandafter{\pgfplots@loc@TMPa}%
+ }%
+ \fi
+ \fi
+ \pgfplots@check@for@minor@ticks{#1}%
+ \ifpgfplots@isuniformtick
+ \else
+ \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPb
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \csname pgfplots@#1minorticksfalse\endcsname
+ \csname pgfplots@#1minorgridsfalse\endcsname
+ \fi
+ \fi
+ %
+ \expandafter\ifx\csname pgfplots@#1ticklabel\endcsname\pgfutil@empty
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \expandafter\def\csname pgfplots@#1ticklabel\endcsname{\axisdefaultticklabel}%
+ }{%
+ \expandafter\def\csname pgfplots@#1ticklabel\endcsname{\axisdefaultticklabellog}%
+ }%
+ \fi
+ \expandafter\ifx\csname pgfplots@extra@#1ticklabel\endcsname\pgfutil@empty
+ \pgfutil@namelet{pgfplots@loc@TMPa}{pgfplots@#1ticklabel}%
+ \pgfutil@namelet{pgfplots@loc@TMPb}{pgfplots@user@ticklabel@list@#1}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % Ah - someone used '#1ticklabels' (or its friends).
+ % these are bound to specific positions and make no sense in this context.
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \expandafter\def\csname pgfplots@extra@#1ticklabel\endcsname{\axisdefaultticklabel}%
+ }{%
+ \expandafter\def\csname pgfplots@extra@#1ticklabel\endcsname{\axisdefaultticklabellog}%
+ }%
+ \else
+ % inherit the global argument of '#1ticklabel' -- it will probably contain generic code to
+ % typeset labels at any positions.
+ % The "probably" is a buest-guess, though...
+ \pgfutil@namelet{pgfplots@extra@#1ticklabel}{pgfplots@#1ticklabel}%
+ \fi
+ \fi
+ %
+ \if0\csname pgfplots@#1axislinesnum\endcsname\else
+ % axis x line* != box
+ \expandafter\let\csname pgfplots@#1ticklabel@pos\endcsname=\pgfutil@empty
+ \fi
+ \expandafter\ifx\csname pgfplots@#1ticklabel@pos\endcsname\pgfutil@empty
+ \expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{%
+ \if3\csname pgfplots@#1tickposnum\endcsname% right
+ u%
+ \else
+ l%
+ \fi
+ }%
+ \fi
+}%
+
+\def\pgfplots@check@for@minor@ticks#1{%
+ \pgfkeysgetvalue{/pgfplots/minor #1 tick num}\pgfplots@loc@TMPa
+ \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPb
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \ifnum\pgfplots@loc@TMPa=0\relax
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \csname pgfplots@#1minorticksfalse\endcsname
+ \csname pgfplots@#1minorgridsfalse\endcsname
+ \fi
+ \else
+ \csname pgfplots@#1minortickstrue\endcsname
+ \fi
+ }{%
+ }%
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \else
+ \csname pgfplots@#1minortickstrue\endcsname
+ \fi
+}
+
+% Invoked as soon as all axis limits are ready and final (in TeX
+% number range, all data scaling is applied at this point).
+\def\pgfplots@limits@ready{%
+ \pgfplots@limits@ready@tostring{x}{min}%
+ \pgfplots@limits@ready@tostring{x}{max}%
+ \pgfplots@limits@ready@tostring{y}{min}%
+ \pgfplots@limits@ready@tostring{y}{max}%
+ \ifpgfplots@threedim
+ \pgfplots@limits@ready@tostring{z}{min}%
+ \pgfplots@limits@ready@tostring{z}{max}%
+ \fi
+}%
+
+% write a limit into /pgfplots/#1#2
+% #1: either x,y or z
+% #2: either 'min' or 'max'
+%
+% \pgfplots@limits@ready@tostring{x}{min}
+\def\pgfplots@limits@ready@tostring#1#2{%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplotscoordmath{#1}{datascaletrafo inverse}{\csname pgfplots@#1#2\endcsname}%
+ }{%
+ \edef\pgfmathresult{\csname pgfplots@#1#2\endcsname}%
+ }%
+ \pgfplotscoordmath{#1}{tostring}{\pgfmathresult}%
+ \pgfkeyslet{/pgfplots/#1#2}\pgfmathresult
+ % this runs \pgfkeyslet{/pgfplots/xmin}\pgfmathresult
+}%
+
+
+\newif\ifpgfplots@avoid@emptyrange@@range@is@approx@equal
+% Checks whether axis limits in coordinate #1 are approximately equal.
+%
+% If that is the case, force a non-zero width of the range.
+%
+\def\pgfplots@avoid@empty@axis@range@for#1{%
+ % Check if axis limits are empty:
+ \begingroup
+ \expandafter\let\expandafter\if@cur@is@scaled\csname ifpgfplots@apply@datatrafo@#1\endcsname
+ \expandafter\let\expandafter\pgfplots@@min\csname pgfplots@#1min\endcsname
+ \expandafter\let\expandafter\pgfplots@@max\csname pgfplots@#1max\endcsname
+ \let\min@d=\pgf@xa
+ \let\max@d=\pgf@xb
+ \let\diff=\pgf@xc
+ \expandafter\min@d\pgfplots@@min pt %
+ \expandafter\max@d\pgfplots@@max pt %
+ \diff=\max@d
+ \advance\diff by-\min@d
+ % FIXME : I need a RELATIVE check here!
+ % but: real number point division is expensive
+ \if@cur@is@scaled
+ % this here should be sufficient because the axis
+ % has absolute values of order O( 10^3 ) or so.
+ \ifdim\diff<0.0001pt
+ \pgfplots@avoid@emptyrange@@range@is@approx@equaltrue
+ \fi
+ \else
+ % there is no data scaling, so I should be much more defensive
+ % with absolute thresholds...
+ \ifdim\diff<0.0001pt
+ \pgfplots@avoid@emptyrange@@range@is@approx@equaltrue
+ \fi
+ \fi
+ \ifpgfplots@avoid@emptyrange@@range@is@approx@equal
+ \begingroup
+ \pgfplotscoordmath{#1}{datascaletrafo inverse to fixed}{\csname pgfplots@#1min\endcsname}%
+ \let\pgfplots@min=\pgfmathresult
+ \pgfplotscoordmath{#1}{datascaletrafo inverse to fixed}{\csname pgfplots@#1max\endcsname}%
+ \let\pgfplots@max=\pgfmathresult
+ \pgfplotswarning{approx empty range enlarged}{#1}{\pgfplots@min}{\pgfplots@max}\pgfeov
+ \endgroup
+ % the case \pgfplots@@min ~= \pgfplots@@max
+ %
+ % enlarge \pgfplots@@max and shrink \min:
+ \ifdim\max@d<0pt%
+ \ifdim\max@d<-1pt%
+ \max@d=0.8\max@d
+ \min@d=1.2\min@d
+ \else
+ \advance\max@d by-1pt%
+ \advance\min@d by1pt%
+ \fi
+ \else
+ \ifdim\max@d>1pt%
+ \max@d=1.2\max@d
+ \min@d=0.8\min@d
+ \else
+ \ifdim\max@d=0pt%
+ \if@cur@is@scaled
+ \expandafter\let\expandafter\min@unscaled\csname pgfplots@#1min@unscaled@as@float\endcsname
+ \expandafter\let\expandafter\max@unscaled\csname pgfplots@#1max@unscaled@as@float\endcsname
+ % **sigh**. That's really work.
+ %
+ % This here happens ALWAYS if min == max for
+ % linear axis because the scaling
+ % transformation will result in T(min) = T(max) = 0
+ %
+ % -> we need to enlarge limits in floating
+ % point arithmetics.
+ %
+ \pgfplotscoordmath{#1}{parsenumber}{0}%
+ \let\pgfplotsmath@zero=\pgfmathresult
+ %
+ \ifx\max@unscaled\pgfplotsmath@zero
+ % max == 0
+ \pgfplotscoordmath{#1}{parsenumber}{1}%
+ \let\max@unscaled=\pgfmathresult
+ \pgfplotscoordmath{#1}{parsenumber}{-1}%
+ \let\min@unscaled=\pgfmathresult
+ \else
+ %
+ \pgfplotscoordmath{#1}{parsenumber}{1.2}%
+ \let\pgfplotsmath@scalea=\pgfmathresult
+ \pgfplotscoordmath{#1}{parsenumber}{8e-1}%
+ \let\pgfplotsmath@scaleb=\pgfmathresult
+ %
+ \pgfplotscoordmath{#1}{if less than}
+ {\pgfplotsmath@zero}{\max@unscaled}%
+ {%
+ % 0 < max
+ \pgfplotscoordmath{#1}{op}{multiply}
+ {{\max@unscaled}{\pgfplotsmath@scalea}}%
+ \let\max@unscaled=\pgfmathresult
+ \pgfplotscoordmath{#1}{op}{multiply}
+ {{\min@unscaled}{\pgfplotsmath@scaleb}}%
+ \let\min@unscaled=\pgfmathresult
+ }%
+ {%
+ \pgfplotscoordmath{#1}{op}{multiply}
+ {{\max@unscaled}{\pgfplotsmath@scaleb}}%
+ \let\max@unscaled=\pgfmathresult
+ \pgfplotscoordmath{#1}{op}{multiply}
+ {{\min@unscaled}{\pgfplotsmath@scalea}}%
+ \let\min@unscaled=\pgfmathresult
+ }%
+ \fi
+ \pgfplotscoordmath{#1}{datascaletrafo}{\min@unscaled}%
+ \let\pgfplots@@min=\pgfmathresult
+ \pgfplotscoordmath{#1}{datascaletrafo}{\max@unscaled}%
+ \let\pgfplots@@max=\pgfmathresult
+ \min@d=\pgfplots@@min pt
+ \max@d=\pgfplots@@max pt
+ \else
+ \advance\max@d by1pt
+ \advance\min@d by-1pt
+ \fi
+ \else
+ \advance\max@d by1pt
+ \advance\min@d by-1pt
+ \fi
+ \fi
+ \fi
+ \xdef\pgfplots@glob@TMPa{\pgf@sys@tonumber{\min@d}}%
+ \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\max@d}}%
+%\pgfplots@message{ -> #1 = \pgfplots@glob@TMPa : \pgfplots@glob@TMPb;}%
+ \else
+ \global\let\pgfplots@glob@TMPa=\pgfplots@@min%
+ \global\let\pgfplots@glob@TMPb=\pgfplots@@max%
+ \fi
+ \endgroup
+ \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfplots@glob@TMPa
+ \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfplots@glob@TMPb
+}
+
+
+% should be invoked whenever \pgfplots@#1min or \pgfplots@#1max have
+% been changed during the visualization phase (for example, axis equal
+% or enlargelimits)
+\def\pgfplots@visphase@notify@changeofcanvaslimits#1{%
+ \csname pgfplots@#1min@reg\endcsname=\csname pgfplots@#1min\endcsname pt %
+ \csname pgfplots@#1max@reg\endcsname=\csname pgfplots@#1max\endcsname pt %
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplotscoordmath{#1}{datascaletrafo inverse}{\csname pgfplots@#1min\endcsname}%
+ \expandafter\let\csname pgfplots@#1min@unscaled@as@float\endcsname=\pgfmathresult
+ \pgfplotscoordmath{#1}{datascaletrafo inverse}{\csname pgfplots@#1max\endcsname}%
+ \expandafter\let\csname pgfplots@#1max@unscaled@as@float\endcsname=\pgfmathresult
+ }{}%
+}%
+
+% Invokes #3 if ||D_#1||_CANVAS < ||D_#2||_CANVAS and #4 if that is not the case.
+% Here D_x = (1,0,0) , D_y = (0,1,0) and D_z=(0,0,1).
+%
+% Due to the data scaling transformation,
+% ||D_a|| = || T(1) * e_a||
+% where e_x, e_y, e_z are the lowlevel, transformed unit vectors.
+% We have
+% ||D_a|| = T(1) * veclen_a.
+% Note that the shift in T is not of interest, we only deal with
+% T_a(x) = 10^{s_a} x.
+%
+% Thus, this routine invokes #3 if
+% ( 10^{s1} * veclen1 < 10^{s2} * veclen2 )
+% <=>
+% ( 10^{s1-s2} * veclen1 < veclen2 ).
+%
+% Here s1/s2 are the respective scales of the data scaling
+% transformation.
+%
+% If the condition is false, '#4' is invoked.
+\def\pgfplots@if@unitveclenlessthan@untransformed#1#2#3#4{%
+ \def\pgfplots@loc@TMPa{0}%
+ \def\pgfplots@loc@TMPb{0}%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplots@letcsname{pgfplots@loc@TMPa}={pgfplots@data@scale@trafo@EXPONENT@#1}%
+ }{}%
+ \pgfplots@if{pgfplots@apply@datatrafo@#2}{%
+ \pgfplots@letcsname{pgfplots@loc@TMPb}={pgfplots@data@scale@trafo@EXPONENT@#2}%
+ }{}%
+ \begingroup
+%\message{[comparison: [#1] < [#2]: 10^\pgfplots@loc@TMPa\space * \csname pgfplots@#1@veclength\endcsname < 10^\pgfplots@loc@TMPb\space * \csname pgfplots@#2@veclength\endcsname]^^J}%
+ \pgf@xb=\csname pgfplots@#2@veclength\endcsname pt
+ %
+ \c@pgf@counta=\pgfplots@loc@TMPa
+ \advance\c@pgf@counta by-\pgfplots@loc@TMPb
+ %
+ \ifnum\c@pgf@counta=0
+ \pgf@xa=\csname pgfplots@#1@veclength\endcsname pt
+ \else
+ \pgfplotsmathmultiplypowten@{\csname pgfplots@#1@veclength\endcsname}{\c@pgf@counta}%
+ \pgf@xa=\pgfmathresult pt
+ \fi
+ %
+ \ifdim\pgf@xa<\pgf@xb
+ \gdef\pgfplots@glob@TMPc{1}%
+ \else
+ \gdef\pgfplots@glob@TMPc{0}%
+ \fi
+ \endgroup
+ \if1\pgfplots@glob@TMPc #3\else #4\fi
+}%
+
+
+\def\pgfplots@low@level@shape@INNER@define{%
+ \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}{\pgfplotspointaxisorigin}%
+ \anchor{above origin}{%
+ \pgfpointintersectionoflines
+ {\pgfplotspointaxisorigin}
+ {\pgfpointadd
+ {\pgfplotspointaxisorigin}%
+ {\pgfplotspointyaxis
+ \pgfplots@assert@not@zero{\pgf@y}{y axis has eyy=0; cannot compute above origin anchor}%
+ }%
+ }%
+ {\pgfplotsqpointdescriptionxy{0}{1}}
+ {\pgfplotsqpointdescriptionxy{1}{1}}%
+ }%
+ \anchor{left of origin}{%
+ \pgfpointintersectionoflines
+ {\pgfplotspointaxisorigin}
+ {\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointxaxis}}
+ {\pgfplotsqpointdescriptionxy{0}{0}}
+ {\pgfplotsqpointdescriptionxy{0}{1}}%
+ }%
+ \anchor{right of origin}{%
+ \pgfpointintersectionoflines
+ {\pgfplotspointaxisorigin}
+ {\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointxaxis}}
+ {\pgfplotsqpointdescriptionxy{1}{0}}
+ {\pgfplotsqpointdescriptionxy{1}{1}}%
+ }%
+ \anchor{below origin}{%
+ \pgfpointintersectionoflines
+ {\pgfplotspointaxisorigin}
+ {\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointyaxis}}
+ {\pgfplotsqpointdescriptionxy{0}{0}}
+ {\pgfplotsqpointdescriptionxy{1}{0}}%
+ }%
+}
+
+% This here is a low-weight node. It can ONLY be used during axis
+% descriptions and is completely useless otherwise.
+%
+% See pgfplots@low@level@shape below.
+\pgfdeclareshape{pgfplots@low@level@shape@INNER}{%
+ \nodeparts{image}%
+ %%
+ %%
+ \pgfplots@low@level@shape@INNER@define
+ %%
+ %%
+ \anchorborder{}%
+ \backgroundpath{}%
+ \foregroundpath{}%
+ \behindbackgroundpath{}%
+ \beforebackgroundpath{}%
+ \behindforegroundpath{}%
+ \beforeforegroundpath{}%
+}
+
+% This is the main axis shape.
+%
+% It has one node part, which is the complete image. It provides a lot
+% of anchors.
+\pgfdeclareshape{pgfplots@low@level@shape}{%
+ % The '(0,0)' point is the LOWER LEFT OUTER CORNER.
+ \savedanchor\upperrightcorner{%
+ \pgfplotspointupperrightcorner
+ }%
+ \savedanchor\lowerleftinnercorner{%
+ \pgfplotspointlowerleftinnercorner%
+ }%
+ \savedanchor\innerdiagonal{\pgfplotspointbbdiagonal}%
+ \savedanchor\origin{%
+ \pgfplotspointaxisorigin
+ }%
+ %
+ \nodeparts{image}%
+ \anchor{image}{%
+ \global\pgf@x=0pt %
+ \global\pgf@y=0pt %
+ }%
+ %
+ \anchor{center}{%
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\pgfpointscale
+ {0.5}
+ {\innerdiagonal}}%
+ }%
+ \anchor{north}{%
+ \pgfpointadd
+ {\lowerleftinnercorner}
+ {\innerdiagonal\global\divide\pgf@x by2 }%
+ }%
+ \anchor{north east}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ \innerdiagonal
+ }%
+ \anchor{east}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\divide\pgf@y by2 }%
+ }%
+ \anchor{south east}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\pgf@y=0sp }%
+ }%
+ \anchor{south}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\divide\pgf@x by2 \global\pgf@y=0sp }%
+ }%
+ \anchor{south west}{\lowerleftinnercorner}%
+ \anchor{west}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\pgf@x=0sp \global\divide\pgf@y by2 }%
+ }
+ \anchor{north west}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\pgf@x=0sp }%
+ }%
+ %%
+ \anchor{origin}{%
+ \origin
+ }%
+ \anchor{above origin}{%
+ \pgfpointintersectionoflines
+ {\origin}
+ {\pgfpointadd{\origin}{%
+ \innerdiagonal\global\pgf@x=0sp
+ \pgfplots@assert@not@zero{\pgf@y}{y axis has eyy=0; cannot compute above origin anchor}%
+ }%
+ }%
+ {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\global\pgf@x=0sp }}
+ {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal}}%
+ }%
+ \anchor{left of origin}{%
+ \pgfpointintersectionoflines
+ {\origin}
+ {\pgfpointadd{\origin}{\innerdiagonal\global\multiply\pgf@x by-1 \global\pgf@y=0sp }}
+ {\lowerleftinnercorner}
+ {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\global\pgf@x=0sp }}%
+ }%
+ \anchor{right of origin}{%
+ \pgfpointintersectionoflines
+ {\origin}
+ {\pgfpointadd{\origin}{\innerdiagonal\global\pgf@y=0sp }}
+ {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\global\pgf@y=0sp }}
+ {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal}}%
+ }%
+ \anchor{below origin}{%
+ \pgfpointintersectionoflines
+ {\origin}
+ {\pgfpointadd{\origin}{\innerdiagonal\global\pgf@x=0sp \global\multiply\pgf@y by-1 }}
+ {\lowerleftinnercorner}
+ {\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\global\pgf@y=0sp }}%
+ }%
+ %
+ %%
+ %
+ \anchor{outer north}{%
+ \upperrightcorner
+ \global\pgf@x=.5\pgf@x
+ }%
+ \anchor{outer north east}{\upperrightcorner}%
+ \anchor{outer east}{%
+ \upperrightcorner
+ \global\pgf@y=.5\pgf@y
+ }%
+ \anchor{outer south east}{%
+ \upperrightcorner
+ \global\pgf@y=0pt
+ }%
+ \anchor{outer south}{%
+ \upperrightcorner
+ \global\pgf@x=.5\pgf@x
+ \global\pgf@y=0pt
+ }%
+ \anchor{outer south west}{%
+ \global\pgf@x=0pt
+ \global\pgf@y=0pt
+ }%
+ \anchor{outer west}{%
+ \upperrightcorner
+ \global\pgf@x=0pt
+ \global\pgf@y=.5\pgf@y
+ }%
+ \anchor{outer north west}{%
+ \upperrightcorner
+ \global\pgf@x=0pt
+ }%
+ \anchor{outer center}{%
+ \upperrightcorner
+ \global\pgf@x=.5\pgf@x
+ \global\pgf@y=.5\pgf@y
+ }%
+ %
+ %
+ %%
+ %%
+ \anchor{above north}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@y
+ \pgfpointadd
+ {\lowerleftinnercorner}
+ {\innerdiagonal\divide\pgf@x by2 }%
+ \global\pgf@y=\pgfutil@tempdima
+ }%
+ \anchor{above north east}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@y
+ \pgfpointadd
+ \lowerleftinnercorner
+ \innerdiagonal
+ \global\pgf@y=\pgfutil@tempdima
+ }%
+ \anchor{right of north east}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@x
+ \pgfpointadd
+ \lowerleftinnercorner
+ \innerdiagonal
+ \global\pgf@x=\pgfutil@tempdima
+ }%
+ \anchor{right of east}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@x
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\divide\pgf@y by2 }%
+ \global\pgf@x=\pgfutil@tempdima
+ }%
+ \anchor{right of south east}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@x
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\pgf@y=0sp }%
+ \global\pgf@x=\pgfutil@tempdima
+ }%
+ \anchor{below south east}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\pgf@y=0sp }%
+ \global\pgf@y=0pt
+ }%
+ \anchor{below south}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\divide\pgf@x by2 \global\pgf@y=0sp }%
+ \pgf@y=0pt
+ }%
+ \anchor{below south west}{%
+ \lowerleftinnercorner
+ \global\pgf@y=0pt
+ }%
+ \anchor{left of south west}{%
+ \lowerleftinnercorner
+ \global\pgf@x=0pt
+ }%
+ \anchor{left of west}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\pgf@x=0sp \global\divide\pgf@y by2 }%
+ \global\pgf@x=0pt
+ }%
+ \anchor{left of north west}{%
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\pgf@x=0sp }%
+ \global\pgf@x=0pt
+ }%
+ \anchor{above north west}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@y
+ \pgfpointadd
+ \lowerleftinnercorner
+ {\innerdiagonal\global\pgf@x=0sp }%
+ \global\pgf@y=\pgfutil@tempdima
+ }%
+ %%
+ %%
+ \anchorborder{%
+ % remember the input coords:
+ \edef\pgfplots@loc@TMPa{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ %
+ % I want to use \pgfpointborderrectangle which expects that
+ % (0,0) is the CENTER.
+ % Ok, then: shift it:
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\pgfpointscale
+ {0.5}
+ {\innerdiagonal}}%
+ \edef\pgfplots@loc@center{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ \pgfpointadd{%
+ \pgfpointborderrectangle%
+ {\pgfplots@loc@TMPa}%
+ {\pgfpointscale
+ {0.5}
+ {\innerdiagonal}}%
+ }{%
+ % and add the center to undo the local shift:
+ \pgfplots@loc@center
+ }%
+ }%
+ \backgroundpath{%
+ \pgfkeysvalueof{/pgfplots/@backgroundpath@hook/.@cmd}\pgfeov
+ \pgfpathrectangle{\pgfpointorigin}{\upperrightcorner}%
+ }%
+ \foregroundpath{}%
+ \behindbackgroundpath{}%
+ \beforebackgroundpath{}%
+ \behindforegroundpath{}%
+ \beforeforegroundpath{}%
+}
+
+\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{
+ % FIXME : is this correct?
+ \pgfplotspointupperrightcorner
+ %\global\pgf@x=\wd\pgfnodepartimagebox
+ %\global\pgf@y=\ht\pgfnodepartimagebox
+ }%
+ \savedanchor\lowerleftinnercorner{%
+ \pgfplotspointlowerleftinnercorner%
+ }%
+ \savedanchor\xaxisvec{\pgfplotspointxaxis}%
+ \savedanchor\yaxisvec{\pgfplotspointyaxis}%
+ \savedanchor\origin{%
+ \pgfplotspointaxisorigin
+ }%
+ %
+ \nodeparts{image}%
+ \anchor{image}{%
+ \global\pgf@x=0pt %
+ \global\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
+ \global\pgf@x=.5\pgf@x
+ }%
+ \anchor{outer north east}{\upperrightcorner}%
+ \anchor{outer east}{%
+ \upperrightcorner
+ \global\pgf@y=.5\pgf@y
+ }%
+ \anchor{outer south east}{%
+ \upperrightcorner
+ \global\pgf@y=0pt
+ }%
+ \anchor{outer south}{%
+ \upperrightcorner
+ \global\pgf@x=.5\pgf@x
+ \global\pgf@y=0pt
+ }%
+ \anchor{outer south west}{%
+ \global\pgf@x=0pt
+ \global\pgf@y=0pt
+ }%
+ \anchor{outer west}{%
+ \upperrightcorner
+ \global\pgf@x=0pt
+ \global\pgf@y=.5\pgf@y
+ }%
+ \anchor{outer north west}{%
+ \upperrightcorner
+ \global\pgf@x=0pt
+ }%
+ \anchor{outer center}{%
+ \upperrightcorner
+ \global\pgf@x=.5\pgf@x
+ \global\pgf@y=.5\pgf@y
+ }%
+ %
+ %
+ %%
+ %%
+ \anchor{above north}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@y
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\pgfpointadd{\yaxisvec}{\pgfpointscale{0.5}{\xaxisvec}}}%
+ \global\pgf@y=\pgfutil@tempdima
+ }%
+ \anchor{above north east}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@y
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\pgfpointadd{\yaxisvec}{\xaxisvec}}%
+ \global\pgf@y=\pgfutil@tempdima
+ }%
+ \anchor{right of north east}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@x
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\pgfpointadd{\yaxisvec}{\xaxisvec}}%
+ \global\pgf@x=\pgfutil@tempdima
+ }%
+ \anchor{right of east}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@x
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\pgfpointadd{\xaxisvec}{\pgfpointscale{0.5}{\yaxisvec}}}%
+ \global\pgf@x=\pgfutil@tempdima
+ }%
+ \anchor{right of south east}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@x
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\xaxisvec}%
+ \global\pgf@x=\pgfutil@tempdima
+ }%
+ \anchor{below south east}{%
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\xaxisvec}%
+ \global\pgf@y=0pt
+ }%
+ \anchor{below south}{%
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\pgfpointscale{0.5}{\xaxisvec}}%
+ \global\pgf@y=0pt
+ }%
+ \anchor{below south west}{%
+ \lowerleftinnercorner
+ \global\pgf@y=0pt
+ }%
+ \anchor{left of south west}{%
+ \lowerleftinnercorner
+ \global\pgf@x=0pt
+ }%
+ \anchor{left of west}{%
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\pgfpointscale{0.5}{\yaxisvec}}%
+ \global\pgf@x=0pt
+ }%
+ \anchor{left of north west}{%
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\yaxisvec}%
+ \global\pgf@x=0pt
+ }%
+ \anchor{above north west}{%
+ \upperrightcorner
+ \pgfutil@tempdima=\pgf@y
+ \pgfpointadd
+ {\lowerleftinnercorner}%
+ {\yaxisvec}%
+ \global\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{}%
+ }%
+ }{}%
+}%
+
+
+% Defines a new axis type `#1' with initialization code `#2'.
+%
+% The name #1 will be available as value for 'axis type=#1' and
+% furthermore, an environment '\begin{#1axis}' will be available.
+%
+% For ConTeXt, the \start#1axis and \stop#1axis commands will be
+% available.
+%
+% #1: the axis type name
+% #2: initialization TeX code.
+%
+% OPTIONAL: you can provide the expected axis coordinate system in
+% square brackets.
+%
+% \pgfplotsdefineaxistype{rectangle}{...}
+% \pgfplotsdefineaxistype[polar]{polar}{...}
+\def\pgfplotsdefineaxistype{\pgfutil@ifnextchar[{\pgfplotsdefineaxistype@}{\pgfplotsdefineaxistype@[cart]}}%
+\def\pgfplotsdefineaxistype@[#1]#2#3{%
+ \expandafter\def\csname pgfplots@axistype@#2\endcsname{%
+ \pgfkeyssetvalue{/pgfplots/@expected axis cs}{#1}%
+ #3%
+ }%
+ \expandafter\def\csname pgfplots@environment@#2axis\endcsname{%
+ \pgfutil@ifnextchar[%
+ {\csname pgfplots@environment@#2axis@\endcsname}%
+ {\csname pgfplots@environment@#2axis@\endcsname[]}%
+ }%
+ \expandafter\long\expandafter\def\csname pgfplots@environment@#2axis@\endcsname[##1]{%
+ \begin{axis}[%
+ ##1,%
+ data cs=#1,% assume that coordinates provided by \addplot are in the correct coordsystem
+ axis type=#2% active the correct axis type
+ ]%
+ }%
+ \expandafter\def\csname endpgfplots@environment@#2axis\endcsname{\end{axis}}%
+ \edef\pgfplots@glob@TMPc{\expandafter\noexpand\csname #2axis\endcsname\expandafter\noexpand\csname pgfplots@environment@#2axis\endcsname}%
+ \expandafter
+ \tikzaddtikzonlycommandshortcutlet\pgfplots@glob@TMPc
+ %
+ \edef\pgfplots@glob@TMPc{\expandafter\noexpand\csname end#2axis\endcsname\expandafter\noexpand\csname endpgfplots@environment@#2axis\endcsname}%
+ \expandafter
+ \tikzaddtikzonlycommandshortcutlet\pgfplots@glob@TMPc
+ %
+ % ConTeXt compatibility:
+ \t@pgfplots@toka=\expandafter{\csname #2axis\endcsname}%
+ \t@pgfplots@tokb=\expandafter{\csname end#2axis\endcsname}%
+ \expandafter\edef\csname start#2axis\endcsname{\the\t@pgfplots@toka}%
+ \expandafter\edef\csname stop#2axis\endcsname{\the\t@pgfplots@tokb}%
+}%
+
+\def\pgfplotssetaxistype#1{%
+ \pgfutil@IfUndefined{pgfplots@axistype@#1}{%
+ \pgfplots@error{Sorry, 'axis type=#1' is unknown. Maybe you need to load a proper library first or you misspelled the name? Ignoring it}%
+ }{%
+ \csname pgfplots@axistype@#1\endcsname
+ }%
+}%
+
+% 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}%
+ \ifpgfplots@threedim
+ \pgfplots@drawaxis@lines@preparediscont@for{z}%
+ \fi
+ \ifpgfplots@threedim
+ \pgfplots@separate@axis@linestrue
+ \else
+ \if\pgfplots@xaxislinesnum0\else
+ \pgfplots@separate@axis@linestrue
+ \fi
+ \if\pgfplots@yaxislinesnum0\else
+ \pgfplots@separate@axis@linestrue
+ \fi
+ \fi
+ % compute tick position lists
+ % \pgfplots@prepared@tick@positions@minor@x
+ % and
+ % \pgfplots@prepared@tick@positions@major@x
+ \ifpgfplots@hide@x\else
+ \expandafter\pgfplots@prepare@tick@coordlists@for\expandafter x\expandafter{\pgfplots@xtick}%
+ \fi
+ \ifpgfplots@hide@y\else
+ \expandafter\pgfplots@prepare@tick@coordlists@for\expandafter y\expandafter{\pgfplots@ytick}%
+ \fi
+ \ifpgfplots@threedim
+ \ifpgfplots@hide@z\else
+ \expandafter\pgfplots@prepare@tick@coordlists@for\expandafter z\expandafter{\pgfplots@ztick}%
+ \fi
+ \fi
+}
+
+\def\pgfplots@draw@axis@is@prepared{}%
+
+% 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 xyz
+ %
+ \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmax}{1}%
+ \pgfplots@draw@axis@insurface@symmetric xyz
+ \fi
+ %
+%\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 zyx
+ \else
+ \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}%
+ \pgfplots@draw@axis@insurface@onlyticksandgrid yzx
+ \pgfplots@draw@axis@insurface zyx
+ %
+ \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmax}{1}%
+ \pgfplots@draw@axis@insurface@onlyticksandgrid yzx
+ \pgfplots@draw@axis@insurface zyx
+ \fi
+%\fi\if10
+ %
+ \if2\pgfplots@yaxislinesnum
+ \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@logical@ZERO@y}{2}%
+ \pgfplots@draw@axis@insurface@onlyticksandgrid xzy
+ \pgfplots@draw@axis@insurface@onlyticksandgrid zxy
+ \else
+ \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}%
+ \pgfplots@draw@axis@insurface@onlyticksandgrid xzy
+ \pgfplots@draw@axis@insurface@onlyticksandgrid zxy
+ %
+ \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\pgfplotspointonorientedsurfaceabsetupfor@@xyz=\pgfplotspointonorientedsurfaceabsetupfor@@xy
+ \let\pgfplotspointonorientedsurfaceabsetupfor@@yxz=\pgfplotspointonorientedsurfaceabsetupfor@@yx
+ \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*
+ \pgfplotsgetlayerforstyle{every 3d box foreground}%
+ \pgfplotsonlayer{\pgfplotsretval}{every 3d box foreground}%
+ \begingroup
+ \pgfplots@layered@graphicsfalse% no distinction of layers here.
+ \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
+ \endpgfplotsonlayer
+ % 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=varying; y=varying; z=zmin)
+% For 3D, there are surfaces
+% - 'vv0' 'vv1'
+% - 'v0v' 'v1v'
+% ' '0vv' '1vv'
+%
+% @see \pgfplotspointonorientedsurfaceabmatchaxisline for details
+% about those three-character ids.
+%
+% @PRECONDITION
+%
+% @POSTCONDITION
+% - 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:
+% Given \pgfplots@view@dir@threedim, 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.
+%
+% Given this knowledge, we can also deduce the default axes for tick
+% labels.
+%
+% 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
+ \pgfplotsmathvectortocomponents\pgfplots@view@dir@threedim{pgfplots@loc@}{default}%
+ % respect reversed axes here. If I am not mistaken, it should
+ % be completely sufficient to flip signs here:
+ \pgfplotscoordmath{default}{if is}{\pgfplots@loc@x}{\if\pgfkeysvalueof{/pgfplots/x dir/value}n+\else-\fi}{%
+ \expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{f}% foreground
+ \expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{b}% background
+ }{%
+ \expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{b}%
+ \expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{f}%
+ }%
+ \pgfplotscoordmath{default}{if is}{\pgfplots@loc@y}{\if\pgfkeysvalueof{/pgfplots/y dir/value}n+\else-\fi}{%
+ \expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{f}% foreground
+ \expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{b}% background
+ }{%
+ \expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{b}%
+ \expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{f}%
+ }%
+ \pgfplotscoordmath{default}{if is}{\pgfplots@loc@z}{\if\pgfkeysvalueof{/pgfplots/z dir/value}n+\else-\fi}{%
+ \expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{f}% foreground
+ \expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{b}% background
+ }{%
+ \expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{b}%
+ \expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{f}%
+ }%
+ \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
+ %
+ \fi
+}
+
+% Initialises the 'pgfplots@[xyz]ticklabelaxisspecs' macro according to
+% the foreground/background situation of the axis and the '[xyz]ticklabel pos'
+% keys.
+\def\pgfplots@init@ticklabelaxisspec{%
+ \ifpgfplots@threedim
+ %
+ %
+ % Now, determine which axis line shall get tick labels.
+ % The strategy 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
+ \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@init@ticklabelaxisspec.
+% 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,
+%
+% @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
+ %
+ % First, compute stuff as if we had a box. Ignore the "center"
+ % styles with a single axis line for now.
+ %
+ \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
+ \else
+ \if l\csname pgfplots@#1ticklabel@pos\endcsname
+ \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 11}%
+ \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
+ \else
+ \if l\csname pgfplots@#1ticklabel@pos\endcsname
+ \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 01}%
+ \fi
+ \fi
+ }%
+ %
+ % Now, adapt result to "center" styles:
+ \if2\csname pgfplots@#1axislinesnum\endcsname
+ % axis #1 lines=center .
+ %
+ \expandafter\edef\csname pgfplots@#1ticklabelaxisspec@box\endcsname{\csname pgfplots@#1ticklabelaxisspec\endcsname}%
+ %
+ % well, for 3d, this implies that all others also have
+ % "center". And since "0" == lower, "1" == upper", "2" ==
+ % center, we have to use center:
+ \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 22}%
+ \fi
+}%
+\def\pgfplots@init@ticklabelaxisspec@twodim@for#1#2{%
+ % First, compute stuff as if we had a box. Ignore the "center"
+ % styles with a single axis line for now.
+ %
+ \if#1x%
+ \def\pgfplots@loc@to@threedim##1{v##10}%
+ \def\pgfplots@loc@axischar@for@first{y}%
+ \else
+ \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
+ %
+ % Now, adapt result to "center" styles:
+ \if2\csname pgfplots@#1axislinesnum\endcsname
+ % axis #1 lines=center .
+ %
+ \expandafter\edef\csname pgfplots@#1ticklabelaxisspec@box\endcsname{\csname pgfplots@#1ticklabelaxisspec\endcsname}%
+ %
+ % well, for 3d, this implies that all others also have
+ % "center". And since "0" == lower, "1" == upper", "2" ==
+ % center, we have to use center:
+ \expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 2}%
+ \fi
+}%
+
+
+% Processes every tick mark in direction #1 and draws tick lines, tick
+% labels, grid lines, axis lines and extra ticks.
+%
+% #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.
+\def\pgfplots@draw@axis@insurface#1#2#3{%
+ \pgfplots@if{pgfplots@hide@#1}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \pgfplots@drawgridlines@onorientedsurf
+ %
+ \pgfplots@drawticklines@onorientedsurf
+ %
+ \pgfplots@drawaxis@outerlines@separate@onorientedsurf#1#2%
+ \pgfplots@drawaxis@innerlines@onorientedsurf#1#2#3%
+ %
+ \pgfplots@drawticklabels@onorientedsurf
+ %
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \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
+% \pgfplots@draw@axis@insurface #2#1#3
+% with slightly optimized execution sequence.
+\def\pgfplots@draw@axis@insurface@symmetric#1#2#3{%
+ \pgfplots@if{pgfplots@hide@#1}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \pgfplots@drawgridlines@onorientedsurf
+ }%
+ \pgfplots@if{pgfplots@hide@#2}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #2#1#3%
+ \pgfplots@drawgridlines@onorientedsurf
+ }%
+ %
+ \pgfplots@if{pgfplots@hide@#1}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \pgfplots@drawticklines@onorientedsurf
+ }%
+ \pgfplots@if{pgfplots@hide@#2}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #2#1#3%
+ \pgfplots@drawticklines@onorientedsurf
+ }%
+ %
+ \ifpgfplots@separate@axis@lines
+ \pgfplots@if{pgfplots@hide@#1}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \pgfplots@drawaxis@outerlines@separate@onorientedsurf#1#2%
+ \pgfplots@drawaxis@innerlines@onorientedsurf#1#2#3%
+ }%
+ %
+ \pgfplots@if{pgfplots@hide@#2}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #2#1#3%
+ \pgfplots@drawaxis@outerlines@separate@onorientedsurf#2#1%
+ \pgfplots@drawaxis@innerlines@onorientedsurf#2#1#3%
+ }%
+ \else
+ % this happens if and only if d=2 and the axis lines are drawn
+ % as box.
+ \pgfplots@drawaxis@outerlines@cycledpath
+ \fi
+ %
+ \pgfplots@if{pgfplots@hide@#1}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \pgfplots@drawticklabels@onorientedsurf
+ }%
+ \pgfplots@if{pgfplots@hide@#2}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #2#1#3%
+ \pgfplots@drawticklabels@onorientedsurf
+ }%
+ %
+ \pgfplots@if{pgfplots@hide@#1}{\relax}{%
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}%
+ \fi
+ }%
+ \pgfplots@if{pgfplots@hide@#2}{\relax}{%
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#2tick\endcsname
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotspointonorientedsurfaceabsetupfor #2#1#3%
+ \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}%
+ \fi
+ }%
+}%
+
+\def\pgfplots@draw@axis@insurface@onlyticksandgrid#1#2#3{%
+ \pgfplots@if{pgfplots@hide@#1}{\relax}{%
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \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
+ \pgfplotspointonorientedsurfaceabsetupfor #1#2#3%
+ \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
+}%
+
+\newif\ifpgfplots@layered@graphics
+
+
+% Shortcut for '\pgfplotsset{set layers={#1}}'.
+%
+% USAGE:
+% 1. \pgfplotssetlayers{<layer config name>} (one declared with /.define layer set)
+% 2. \pgfplotssetlayers (no braces)
+% 3. \pgfplotssetlayers{<comma-separated-list-of-layers>}
+%
+% This command immediately installs a \pgfsetlayers command. It also prepares following axes.
+% ATTENTION: this might affect tikzpictures as well.
+%
+\def\pgfplotssetlayers{%
+ \pgfutil@ifnextchar\bgroup{\pgfplotssetlayers@}{\pgfplotsset{set layers}}%
+}%
+\def\pgfplotssetlayers@#1{%
+ \pgfplotsset{set layers={#1}}%
+}%
+
+% This method checks if '#1' is a well-known layer set. If that is the case, the layer set is initialized.
+% If there is no such layer set, #1 is assumed to be a comma-separated-list of layer names.
+% These layers are defined if they do not exist already.
+%
+% POSTCONDITION:
+% - a \pgfsetlayers{<list>} is issued (immediately)
+% - '/pgfplots/@set layers arg' is defined such that any following axes can initialized their layers.
+\def\pgfplots@key@set@layers#1{%
+ %
+ % auto detect if '#1' is a defined layer set:
+ \pgfkeysifdefined{#1/list}{%
+ \def\pgfkeyscurrentname{#1}%
+ }{%
+ \pgfkeysifdefined{/pgfplots/layers/#1/list}{%
+ \edef\pgfkeyscurrentname{/pgfplots/layers/#1}%
+ }{%
+ \let\pgfkeyscurrentname\pgfutil@empty
+ }%
+ }%
+ \ifx\pgfkeyscurrentname\pgfutil@empty
+ % OK. The argument is NO layer set configuration.
+ \pgfplots@key@set@layers@{#1}%
+ \pgfkeyslet{/pgfplots/@set layers arg}\pgfutil@empty%
+ \else
+ % OK, The argument is the key name of some '/.define layer set' key.
+ % Remember it for later and initialize the layers:
+ \pgfkeyslet{/pgfplots/@set layers arg}\pgfkeyscurrentname%
+ \pgfkeysgetvalue{\pgfkeyscurrentname/list}\pgfplots@loc@TMPa
+ \expandafter\pgfplots@key@set@layers@\expandafter{\pgfplots@loc@TMPa}%
+ \fi
+}
+% a simple method which (immediately) invokes \pgfsetlayers{#1}.
+%
+% The only difference is that it creates missing layers on-the-fly.
+\def\pgfplots@key@set@layers@#1{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % DEFAULT.
+ \pgfsetlayers{main}%
+ \else
+ \def\pgfplots@loc@TMPb{false}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % "use layers=false"
+ \pgfsetlayers{main}%
+ \else
+ \def\pgfplots@loc@TMPb{main}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % "use layers=main"
+ \pgfsetlayers{main}%
+ \else
+ % declare all layers, and collect the normalised list
+ % into \pgfplots@loc@TMPd
+ \def\pgfplots@loc@TMPd{}%
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots@loc@TMPa}\as\pgfplots@loc@TMPa{%
+ % normalize argument:
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \expandafter\pgfplotsutil@trim\expandafter{\pgfplots@loc@TMPa}%
+ \let\pgfplots@loc@TMPa=\pgfplotsretval
+ %
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPb{main}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \else
+ \expandafter\pgfdeclarelayer\expandafter{\pgfplots@loc@TMPa}%
+ \fi
+ \edef\pgfplots@loc@TMPd{\ifx\pgfplots@loc@TMPd\pgfutil@empty\else\pgfplots@loc@TMPd,\fi\pgfplots@loc@TMPa}%
+ \fi
+ }%
+ % activate layers:
+ \pgfplots@log3{Setting layers '\pgfplots@loc@TMPd'...}%
+ \expandafter\pgfsetlayers\expandafter{\pgfplots@loc@TMPd}%
+ \fi
+ \fi
+ \fi
+}%
+
+\def\pgfplots@prepare@layered@graphics{%
+ % check if there are no layers at all.
+ \ifpgfplots@layered@graphics
+ \pgfutil@IfUndefined{pgf@layerlist}{%
+ }{%
+ \ifx\pgf@layerlist\pgfutil@empty
+ \pgfplots@layered@graphicsfalse
+ \else
+ \def\pgfplots@loc@TMPa{main}%
+ \ifx\pgf@layerlist\pgfplots@loc@TMPa
+ \pgfplots@layered@graphicsfalse
+ \fi
+ \fi
+ }%
+ \fi
+}%
+
+% #2: context information (for improved error recovery), optional
+\def\pgfplotsonlayer#1{%
+ \pgfutil@ifnextchar\bgroup{\pgfplotsonlayer@{#1}}{\pgfplotsonlayer@{#1}{}}%
+}
+\def\pgfplotsonlayer@#1#2{%
+ \begingroup
+ \def\b@pgfplotsonlayer@started{0}%
+ \ifpgfplots@layered@graphics
+ \edef\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \def\b@pgfplotsonlayer@started{1}%
+ \pgfonlayer{#1}%
+ \fi
+ \fi
+}%
+\def\endpgfplotsonlayer{%
+ \ifpgfplots@layered@graphics
+ \if1\b@pgfplotsonlayer@started
+ \endpgfonlayer
+ \fi
+ \fi
+ \endgroup
+}%
+
+
+% Searches for the layers of a (set of) style name(s).
+%
+% #1 is a style name like 'every major grid'. It can also be a list of
+% style names.
+%
+% The last "on layer" key found in these styles will be used here.
+%
+% Note that the "on layer" keys have already been extracted in during
+% the key filtering procedure.
+\def\pgfplotsgetlayerforstyle#1{%
+ \let\pgfplotsretval=\pgfutil@empty
+ \ifpgfplots@layered@graphics
+ % this here is the return value:
+ \let\pgfplots@loc@TMPc=\pgfutil@empty
+ %
+ % search list:
+ \pgfplotsutilforeachcommasep{#1}\as\pgfplots@loc@TMPa{%
+ \pgfkeysifdefined{/pgfplots/layers for styles/\pgfplots@loc@TMPa}{%
+ % oh, good: I have already processed the requested
+ % style, and I already know if it has a particular
+ % layer.
+ \pgfkeysgetvalue{/pgfplots/layers for styles/\pgfplots@loc@TMPa}\pgfplots@loc@TMPb
+ }{%
+ % hm. Ok, then process the style. Throw everything
+ % away, keep only the layer.
+ \begingroup
+ \pgfkeyslet{/pgfplots/on layer}\pgfutil@empty
+ \pgfkeysdef{/handlers/.unknown}{}% do nothing
+ \pgfkeysdef{/tikz/.unknown}{}% also, do nothing.
+ \pgfplotsset{#1}% let's hope this works with unknown keys...
+ \pgfkeysgetvalue{/pgfplots/on layer}\pgfplots@loc@TMPb
+ \pgfmath@smuggleone\pgfplots@loc@TMPb
+ \endgroup
+ }%
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \else
+ % update return value:
+ \let\pgfplots@loc@TMPc=\pgfplots@loc@TMPb
+ \fi
+ }%
+ \let\pgfplotsretval=\pgfplots@loc@TMPc
+%\message{\string\pgfplotsgetlayerforstyle{#1} = '\pgfplotsretval'^^J}%
+ \fi
+}%
+
+% The purpose of this method is to check for the cases where no cell picture is necessary.
+% The idea behind this anchor is to insert the axis DIRECTLY into the embedding tikzpicture, without
+% a posteriori shifting.
+%
+% A posteriori shifting == anchors whose dimensions are not fixed
+% until the complete axis has been "typeset".
+%
+% Disabling the cell picture will still prepare ALL anchors correctly,
+% but it disables many of the anchor choices when it comes to the
+% alignment of the current axis (in other words: other node can align
+% using the anchors of this axis, but this axis cannot be aligned based on its anchors).
+%
+% The motivation for this feature is to implement multi-axis support together with layered graphics.
+%
+% The 'cell picture=false' feature may be interesting for SVG export as
+% well.
+\def\pgfplots@prepare@cell@picture{%
+ \pgfplots@ifcellpicture@required{%
+ \pgfplots@has@cell@picturetrue
+ }{%
+ % cell picture=false or cell picture=if necessary
+ %
+ % anchor processing is special in this case! The standard
+ % anchor processing uses a posteriori shifts. This feature
+ % here REQUIRES a priori shifts.
+ % Prepare special handling for these shifts:
+ \pgfplots@has@cell@picturefalse
+ \edef\pgfplots@anchorname@internal{\pgfplots@anchorname}%
+ %
+ % FIXME : do we need to renormalize this here? apparently
+ % not...
+ %\def\pgfplots@anchorname{image}%
+ %
+ \let\pgfplots@BEGIN@cell@picture=\pgfplots@BEGIN@cell@picture@DISABLED
+ \let\pgfplots@END@cell@picture=\pgfplots@END@cell@picture@DISABLED
+ \def\pgfplots@add@named@child@node##1{}% do nothing here
+ \let\pgfplots@finally@correct@child@node@positions=\relax
+ %
+ % translate the coordinate system before the 'current axis'
+ % node is generated.
+ \expandafter\def\expandafter\pgfplots@beforenode\expandafter{\pgfplots@beforenode
+ \setbox\pgfnodepartimagebox=\hbox{}%
+ }%
+ }%
+}
+
+\long\def\pgfplots@ifcellpicture@required#1#2{%
+ \if1\pgfplots@cell@picture@mode
+ % cell picture=true
+ #1\relax
+ \else
+ % cell picture=false | cell picture=if necessary
+ \edef\pgfplots@shapename{pgfplots@low@level@shape@INNER}%
+ \pgfutil@IfUndefined{pgf@anchor@\pgfplots@shapename @\pgfplots@anchorname}{%
+ % we need to compute the anchor a posteriorily.
+ \if0\pgfplots@cell@picture@mode
+ % cell picture=false is forbidden here...
+ \pgfplots@error{Sorry, 'cell picture=false' is UNSUPPORTED for 'anchor=\pgfplots@anchorname'.}%
+ \fi
+ \if2\pgfplots@cell@picture@mode
+ \pgfplots@log5{'cell picture=if necessary' resulted in 'cell picture=true'}%
+ \fi
+ #1\relax
+ }{%
+ \if2\pgfplots@cell@picture@mode
+ \pgfplots@log5{'cell picture=if necessary' resulted in 'cell picture=false'}%
+ \fi
+ % OK, an a priori anchor is available - we do not really need
+ % a cell picture and this is compatible with the input
+ % options:
+ #2\relax
+ }%
+ \fi
+}%
+
+\def\pgfplots@define@preliminary@current@axis@node{%
+ \begingroup
+ \pgfplots@sys@beforenode
+ % 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}}%
+ \endgroup
+}%
+
+\def\pgfplots@BEGIN@cell@picture[#1]{%
+ %
+ \pgfplots@define@preliminary@current@axis@node
+ %
+ \pgfplotsutil@BEGIN@cell@picture[#1]%
+}%
+\def\pgfplotsutil@BEGIN@cell@picture[#1]{%
+ \setbox\pgfnodepartimagebox=\hbox\bgroup\bgroup
+ \pgfinterruptpicture
+ \tikzpicture[#1]%
+ % set baseline for sub-picture to default value.
+ % the baseline option will be applied to the OUTER picture.
+ \pgfsetbaseline{\pgf@picminy}%
+ \pgfutil@ifundefined{pgfsettrimleft}{}{%
+ \pgfsettrimleft{\pgf@picminx}%
+ \pgfsettrimright{\pgf@picmaxx}%
+ }%
+ \begingroup
+ \pgfgettransformentries\aa\ab\ba\bb\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \xdef\pgfplots@savedtransformshift{%
+ \global\pgf@x=\pgfplots@loc@TMPa\space
+ \global\pgf@y=\pgfplots@loc@TMPb\space
+ }%
+ \xdef\pgfplots@glob@TMPa{{\aa}{\ab}{\ba}{\bb}}%
+ \endgroup
+ \expandafter\pgfsettransformentries\pgfplots@glob@TMPa{0pt}{0pt}%
+}
+
+\def\pgfplotsutil@END@cell@picture#1{%
+ \xdef\pgfplots@cell@picture@remembered{%
+ \ifpgfrememberpicturepositiononpage
+ \noexpand\pgfrememberpicturepositiononpagetrue
+ \else
+ \noexpand\pgfrememberpicturepositiononpagefalse
+ \fi
+ }%
+ \xdef\pgfplots@cell@pictureid{\pgfpictureid}%
+ \endtikzpicture%
+ \begingroup
+ \ifdim\pgf@picmaxx=-16000pt\relax%
+ \pgf@picmaxx=0pt\relax%
+ \pgf@picminx=0pt\relax%
+ \pgf@picmaxy=0pt\relax%
+ \pgf@picminy=0pt\relax%
+ \fi%
+ #1%
+ \endgroup
+ \endpgfinterruptpicture
+ \egroup\egroup% end of pgfnodepartimagebox
+ %
+ % 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}%
+ %
+}%
+\def\pgfplots@END@cell@picture{%
+ \pgfplotsutil@END@cell@picture{\pgfplots@END@cell@picture@preparepoints}%
+}%
+
+\def\pgfplots@END@cell@picture@preparepoints{%
+ % Protocol sizes for the axis-shape.
+ % That needs to be done globally, do avoid all those
+ % \endgroup's in and after \endpgfinterruptpicture ...
+ %
+ %
+ % \pgfplotspointorigininternal:
+ % used for anchor=<some node inside of the axis> and for
+ % 'cell picture=true' in order to correct remembered node positions:
+ \xdef\pgfplotspointorigininternal{\global\pgf@x=\the\pgf@picminx\space\global\pgf@y=\the\pgf@picminy\space}%
+ %
+ \ifpgfplots@deprecated@anchors
+ \pgfplotspointminminmin
+ \else
+ \pgfplotspointbblowerleft
+ \fi
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgf@pos@transform\pgf@xa\pgf@ya
+ \advance\pgf@xa by-\pgf@picminx
+ \advance\pgf@ya by-\pgf@picminy
+ \xdef\pgfplotspointlowerleftinnercorner{%
+ \global\pgf@x=\the\pgf@xa\space
+ \global\pgf@y=\the\pgf@ya\space
+ }%
+ %
+ \global\pgf@x=\pgf@picmaxx
+ \global\pgf@y=\pgf@picmaxy
+ \global\advance\pgf@x by-\pgf@picminx
+ \global\advance\pgf@y by-\pgf@picminy
+ \xdef\pgfplotspointupperrightcorner{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfplotspointaxisorigin
+ \pgf@pos@transform\pgf@x\pgf@y
+ \global\advance\pgf@x by-\pgf@picminx
+ \global\advance\pgf@y by-\pgf@picminy
+ \xdef\pgfplotspointaxisorigin{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+}
+
+% this here is essentially the same as
+% \pgfpointanchor{current axis}{#1}
+% but it does not need a node.
+\def\pgfplotspointdescriptionbyanchor#1{%
+ \begingroup
+ \edef\pgfplotspointdescriptionbyanchor@{#1}%
+ \gdef\pgfplots@glob@TMPa{0}%
+ % do a linear search through all anchors of
+ % shape pgfplots@low@level@shape@INNER :
+ \def\anchor##1##2{%
+ \def\pgfplots@loc@TMPa{##1}%
+ \ifx\pgfplots@loc@TMPa\pgfplotspointdescriptionbyanchor@
+ \pgf@process{##2}%
+ \gdef\pgfplots@glob@TMPa{1}%
+ \fi
+ }%
+ \pgfplots@low@level@shape@INNER@define
+ \if0\pgfplots@glob@TMPa
+ \pgfplots@error{The anchor '#1' is unsupported in this context.}%
+ \fi
+ \endgroup
+}%
+
+\def\pgfplots@BEGIN@cell@picture@DISABLED[#1]{%
+ \begingroup
+ \pgfinterruptboundingbox
+ %
+ %
+ % 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%
+ %
+ % prepare a priori anchor transformation (see
+ % \pgfplots@prepare@cell@picture for details):
+ % FIXME : \pgfplotspointdescriptionbyanchor invokes
+ % \pgfplotsqpointdescriptionxy{<x>}{<y>} -- but it is not
+ % merely a direction, it uses an offset. Is that correct!?
+ \pgfqpointscale{-1}{\pgfplotspointdescriptionbyanchor{\pgfplots@anchorname@internal}}%
+ \xdef\pgfplots@anchor@expanded{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ %
+ \scope[%
+ /utils/exec={%
+ % seems that \scope requires this complicated
+ % formulation:
+ \tikz@addtransform{%
+ \pgftransformshift{\pgfplots@cell@picture@DISABLED@shifts}%
+ }%
+ },%
+ #1,%
+ ]%
+ \pgfplots@define@preliminary@current@axis@node
+}%
+\def\pgfplots@END@cell@picture@DISABLED{%
+ \pgfplots@END@cell@picture@preparepoints%
+ \endscope%
+ \endpgfinterruptboundingbox
+ \endgroup
+ \global\let\pgfplots@cell@picture@remembered=\relax
+ \global\let\pgfplots@cell@pictureid=\pgfutil@empty
+ %
+ % we need to re-add these trafos here since the \scope of the
+ % "not-cell-picture" is closed. But not the anchor which has to be
+ % handled by \pgfmultipartnode. See
+ % \pgfplots@cell@picture@DISABLED@shifts
+ \pgftransformshift{\pgfplots@at}%
+}%
+
+\def\pgfplots@cell@picture@DISABLED@shifts{%
+ \pgfpointadd{\pgfplots@at}{\pgfplots@anchor@expanded}%
+}%
+
+\def\pgfplots@BEGIN@init@and@draw@axis{%
+ %
+ %
+ \pgfplots@draw@axis@pre
+ \pgfplots@draw@axis@is@prepared
+ \scope
+ %
+ \pgfkeysgetvalue{/pgfplots/axis background/.@cmd}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfplots@empty@style@key
+ \else
+ \pgfplotsgetlayerforstyle{/pgfplots/axis background,/pgfplots/axis background@}%
+ \pgfplotsonlayer{\pgfplotsretval}{axis background}%
+ \path[/pgfplots/axis background,/pgfplots/axis background@] \pgfextra{\pgfplots@clippath@install{}};%
+ \endpgfplotsonlayer
+ \fi
+ %
+ \ifpgfplots@axis@on@top
+ \else
+ \pgfplots@draw@axis
+ \fi
+ % CLIPPING:
+ \ifpgfplots@clip
+ \if1\pgfplots@clipmode
+ % 'clip=true' and 'clip/mode=global':
+ \pgfplots@clippath@install{\pgfusepath{clip}}%
+ \fi
+ \fi
+ \pgfplotspointbb@assertvaluesexist%
+}
+
+% something which is invoked after a clippath segment is complete.
+% #1 should be something like \pgfusepath{clip}
+\def\pgfplots@clippath@use@#1{%
+ \ifx\pgfplotspoint@bb@@@\relax
+ % remember the axis dimensions:
+ \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%
+}%
+\def\pgfplots@clippath@prepare@for@axistype{%
+ \ifpgfplots@threedim
+ % FIXME : this can't be done in three dimensions. :-(
+ % -> for 3d, I need to clip at least the 2d projection.
+ %
+ % -> 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{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}%
+ \edef\pgfplots@loc@TMPb{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}%
+ \edef\pgfplots@loc@TMPc{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}%
+ \edef\pgfplots@loc@TMPd{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ \begingroup
+ \toks0=\expandafter{\pgfplots@loc@TMPa}%
+ \toks1=\expandafter{\pgfplots@loc@TMPb}%
+ \toks2=\expandafter{\pgfplots@loc@TMPc}%
+ \toks3=\expandafter{\pgfplots@loc@TMPd}%
+ \xdef\pgfplots@glob@TMPa##1{%
+ \noexpand\pgfpathmoveto{\the\toks0 }%
+ \noexpand\pgfpathlineto{\the\toks1 }%
+ \noexpand\pgfpathlineto{\the\toks2 }%
+ \noexpand\pgfpathlineto{\the\toks3 }%
+ \noexpand\pgfpathclose
+ \noexpand\pgfplots@clippath@use@{##1}%
+ }%
+ \endgroup
+ \let\pgfplots@clippath@install=\pgfplots@glob@TMPa
+ \fi
+}%
+% Defines \pgfplots@clippath@install.
+% @PRECONDITION the axis limits must be ready.
+\def\pgfplots@clippath@prepare{%
+ \pgfplots@clippath@prepare@for@axistype
+ % now, the \pgfplots@clippath@install routine should be ready.
+ %
+ % it is used to compute the bounding box. prepare that:
+ \global\let\pgfplotspoint@bb@@@=\relax
+ %
+ % Now, I SET the clip path temporarily and record the low level
+ % protocol.
+ % This low level protocol is used to create a highly optimized
+ % clip path routine; it will be used quite often.
+ %
+ \let\pgfplots@clippath@install@pathcmd=\pgfplots@clippath@install
+ \iffalse
+ % FIXME : this was an idea to optimize the installation of the
+ % clip path (cache the protocolled version). FIX IT
+ %
+ \pgf@resetpathsizes% FIXME: this here should not be necessary!
+ \pgfsysprotocol@getcurrentprotocol\pgfplots@loc@TMPa%
+ \begingroup
+ % when I do this work, I can as well compute the bounding
+ % box (done in \pgfplots@clippath@use@)
+ \pgfinterruptboundingbox
+ \pgf@relevantforpicturesizetrue
+ %
+ \pgfsysprotocol@bufferedtrue%
+ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
+ % \pgfplots@clippath@install@pathcmd{\pgfusepath{clip}}%
+ \pgfsysprotocol@getcurrentprotocol\pgfplots@loc@TMPa%
+ \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa
+ \endpgfinterruptboundingbox
+ \endgroup
+ \let\pgfplots@clippath@install@clip@protocolled=\pgfplots@glob@TMPa
+ \pgfsysprotocol@setcurrentprotocol\pgfplots@loc@TMPa%
+ \fi
+ %
+ % Replace \pgfplots@clippath@install by one which makes use of the
+ % optimized version (if ##1=\pgfusepath{clip})
+ \def\pgfplots@clippath@install##1{%
+ \def\pgfplots@loc@TMPa{##1}%
+ \let\pgfplots@clippath@install@aftergroup=\pgfutil@empty
+ % the 'clip' path has been precomputed because it is often
+ % used: FIXME: unfinished, see above
+ %\expandafter\pgfsys@invoke\expandafter{\pgfplots@clippath@install@clip@protocolled}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@clippath@install@test
+ \if0\pgfplots@clip@BB@mode
+ % clip bounding box=default tikz
+ \else
+ % clip bounding box=upper bound
+ %
+ % do NOT take the clip path into account for the bounding
+ % box! That is very strange when you hide the axis.
+ %
+ % note that we do not need it: the path's BB will be
+ % extracted anyway by this BB code.
+ %
+ % However, we will use the clip path's BB as
+ % *upper bound* - but only after the paths in the
+ % current scope have been completed.
+ % The implementation of this upper bound is hooked
+ % into '\endscope':
+ \edef\pgfplots@clippath@install@aftergroup{%
+ \ifpgf@relevantforpicturesize
+ \noexpand\pgf@relevantforpicturesizetrue
+ \else
+ \noexpand\pgf@relevantforpicturesizefalse
+ \fi
+ \noexpand\pgfplots@clippath@install@BB@upper@bound
+ }%
+ \pgf@relevantforpicturesizefalse
+ %
+ \fi
+ \fi
+ \pgf@resetpathsizes% FIXME: this here should not be necessary!
+ \pgfplots@clippath@install@pathcmd{##1}%
+ \pgfplots@clippath@install@aftergroup
+ }%
+ %
+}%
+\def\pgfplots@clippath@install@test{\pgfusepath{clip}}%
+
+% This is the main part of the implementation for
+% 'clip bounding box=upper bound' : it collects the bounding box of everything inside of
+% the clipped area. Then in the associated \endscope, it clips that bounding box to the expected
+% clip path -- and protocols that size.
+\def\pgfplots@clippath@install@BB@upper@bound{%
+ \tikzset{
+ execute at end scope=\pgfplots@clippath@install@BB@update,
+ %
+ % no special handling for nested scopes:
+ % unnecessary; tikz handles that on its own:
+ %execute at begin scope=\let\pgfplots@clippath@install@BB@update=\relax,
+ }%
+ \pgfinterruptboundingbox
+ % count everything in the current scope into a separate bounding box
+}%
+
+\def\pgfplots@clippath@install@BB@update{%
+ % we are inside of \endscope.
+ %
+ % this here is the BB of the current scope!
+ % More precisely: in *the* scope in which we started the clip
+ % path, not in nested scopes.
+ %
+ \ifdim\pgf@picminx=16000pt %
+ \xdef\pgfplots@glob@TMPa{}%
+ \else
+ \xdef\pgfplots@glob@TMPa{%
+ {\the\pgf@picminx}%
+ {\the\pgf@picminy}%
+ {\the\pgf@picmaxx}%
+ {\the\pgf@picmaxy}%
+ }%
+ \fi
+ \endpgfinterruptboundingbox
+ \ifx\pgfplots@glob@TMPa\pgfutil@empty
+ \else
+ \expandafter\pgfplots@clippath@install@BB@update@\pgfplots@glob@TMPa
+ \fi
+}%
+
+\def\pgfplots@clippath@install@BB@update@#1#2#3#4{%
+ \pgfqpoint{#1}{#2}%
+ \pgfplots@clip@to@clippath%
+ \pgf@protocolsizes{\pgf@x}{\pgf@y}%
+ %
+ \pgfqpoint{#3}{#4}%
+ \pgfplots@clip@to@clippath%
+ \pgf@protocolsizes{\pgf@x}{\pgf@y}%
+}%
+
+\def\pgfplots@clip@to@clippath{%
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \begingroup\pgf@process{\pgfplotspointbblowerleft\pgf@pos@transform\pgf@x\pgf@y}\endgroup%
+ \ifdim\pgf@xa<\pgf@x \pgf@xa=\pgf@x \fi
+ \ifdim\pgf@ya<\pgf@y \pgf@ya=\pgf@y \fi
+ %
+ \begingroup\pgf@process{\pgfplotspointbbupperright\pgf@pos@transform\pgf@x\pgf@y}\endgroup
+ \ifdim\pgf@xa>\pgf@x \pgf@xa=\pgf@x \fi
+ \ifdim\pgf@ya>\pgf@y \pgf@ya=\pgf@y \fi
+ %
+ \pgfqpoint{\pgf@xa}{\pgf@ya}%
+}%
+
+
+\def\pgfplotspointbb@assertvaluesexist{%
+ \ifx\pgfplotspoint@bb@@@\relax
+ % (RE)COMPUTE:
+ %
+ % Determine tight 2D bounding box for the axis as such:
+ \begingroup
+ % hm. seems as if it is sufficient to set
+ % \pgf@relevantforpicturesizefalse. but it does not hurt; I
+ % will see to it eventually. Perhaps.
+ \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{\global\pgf@x=#1 \global\pgf@y=#2 }%
+\def\pgfplotspointbbdiagonal@#1#2#3#4{\global\pgf@x=#3 \global\pgf@y=#4 }%
+
+% #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.}%
+}%
+
+
+% Generates a path representing the outline of the axis.
+% Example:
+%
+% \pgfplotspathaxisoutline
+% \pgfusepath{clip}
+\def\pgfplotspathaxisoutline{%
+ \pgfplots@clippath@install{}%
+}%
+
+% 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
+ \fi
+ \pgfplots@draw@axis@post
+ %
+ \pgfplots@markers@visphase@after@axis
+ \global\pgfplotslistnewempty\pgfplots@stored@plotlist% delete contents.
+ %
+ \begingroup
+ \pgfkeysvalueof{/pgfplots/after end axis/.@cmd}\pgfeov%
+ \endgroup
+ %
+}
+
+% Writes output to \pgfmathresult
+% #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} {%
+ \pgfplotscoordmath{float}{parse}{\pgfplots@loc@TMPb}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ %
+ \pgfplotscoordmath{#2}{log}{\pgfplots@loc@TMPb}%
+ \ifx\pgfplots@glob@TMPa\pgfutil@empty
+ \xdef\pgfplots@glob@TMPa{\pgfmathresult}%
+ \else
+ \xdef\pgfplots@glob@TMPa{\pgfplots@glob@TMPa,\pgfmathresult}%
+ \fi
+ }%
+ \let\pgfmathresult=\pgfplots@glob@TMPa
+}
+
+% Writes output to \pgfmathresult
+% #1: the input ticks
+% #2: the transformation command key as macro
+\def\pgfplots@filter@input@ticks@with@highleveltrafo#1#2{%
+ \let\pgfplots@glob@TMPa=\pgfutil@empty
+ \foreach \pgfplots@loc@TMPb in {#1} {%
+ \expandafter#2\expandafter{\pgfplots@loc@TMPb}\pgfeov%
+ \ifx\pgfplots@glob@TMPa\pgfutil@empty
+ \xdef\pgfplots@glob@TMPa{\pgfmathresult}%
+ \else
+ \xdef\pgfplots@glob@TMPa{\pgfplots@glob@TMPa,\pgfmathresult}%
+ \fi
+ }%
+ \let\pgfmathresult=\pgfplots@glob@TMPa
+}
+
+% definition of 'axis cs':
+\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}%
+\def\pgfplotsqpointaxisxy#1#2{%
+ \edef\pgfplotspointaxis@restore{%
+ \ifpgfplots@plot@coords@mathparser
+ \noexpand\pgfplots@plot@coords@mathparsertrue
+ \else
+ \noexpand\pgfplots@plot@coords@mathparserfalse
+ \fi
+ }%
+ \pgfplots@plot@coords@mathparserfalse
+ %
+ \pgfplotspointaxisxy{#1}{#2}%
+ %
+ \pgfplotspointaxis@restore
+}
+\def\pgfplotsqpointaxisxyz#1#2#3{%
+ \edef\pgfplotspointaxis@restore{%
+ \ifpgfplots@plot@coords@mathparser
+ \noexpand\pgfplots@plot@coords@mathparsertrue
+ \else
+ \noexpand\pgfplots@plot@coords@mathparserfalse
+ \fi
+ }%
+ \pgfplots@plot@coords@mathparserfalse
+ %
+ \pgfplotspointaxisxyz{#1}{#2}{#3}%
+ %
+ \pgfplotspointaxis@restore
+}
+
+% definition of 'normalized axis cs':
+\tikzdeclarecoordinatesystem{normalized axis}{\edef\pgfplots@loc@TMPa{#1}\expandafter\pgfplots@evalute@tikz@coord@system@interface@normalized\pgfplots@loc@TMPa,\pgfplots@coord@end}
+\def\pgfplotspointnormalizedaxisxy#1#2{\pgfplots@evalute@tikz@coord@system@interface@normalized{#1},{#2},\pgfplots@coord@end}%
+\def\pgfplotspointnormalizedaxisxyz#1#2#3{\pgfplots@evalute@tikz@coord@system@interface@normalized{#1},{#2},{#3},\pgfplots@coord@end}%
+
+\tikzdeclarecoordinatesystem{axis direction}{%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplots@evalute@tikz@coord@system@interface[ noshift]%
+ #1,\noexpand\pgfplots@coord@end
+ }%
+ \pgfplots@loc@TMPa
+}
+\def\pgfplotspointaxisdirectionxy#1#2{\pgfplots@evalute@tikz@coord@system@interface[ noshift]{#1},{#2},\pgfplots@coord@end}%
+\def\pgfplotspointaxisdirectionxyz#1#2#3{\pgfplots@evalute@tikz@coord@system@interface[ noshift]{#1},{#2},{#3},\pgfplots@coord@end}%
+
+% rel axis cs:
+\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}%
+
+% axis description cs:
+\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}}%
+
+\def\pgfplotstransformdirectionx#1{\pgfplots@evalute@tikz@coord@system@interface@for[ noshift]{x}{#1}}%
+\def\pgfplotstransformdirectiony#1{\pgfplots@evalute@tikz@coord@system@interface@for[ noshift]{y}{#1}}%
+\def\pgfplotstransformdirectionz#1{\pgfplots@evalute@tikz@coord@system@interface@for[ noshift]{z}{#1}}%
+
+\def\pgfplots@declare@mathfunctions{%
+ \pgfmathdeclarefunction{transformdirectionx}{1}{\pgfplotstransformdirectionx{##1}}%
+ \pgfmathdeclarefunction{transformdirectiony}{1}{\pgfplotstransformdirectiony{##1}}%
+ \pgfmathdeclarefunction{transformdirectionz}{1}{\pgfplotstransformdirectionz{##1}}%
+ %
+ \pgfmathdeclarefunction{transformcoordinatex}{1}{\pgfplotstransformcoordinatex{##1}}%
+ \pgfmathdeclarefunction{transformcoordinatey}{1}{\pgfplotstransformcoordinatey{##1}}%
+ \pgfmathdeclarefunction{transformcoordinatez}{1}{\pgfplotstransformcoordinatez{##1}}%
+}%
+
+% Assigns \pgfmathresult := canvas coordinate (#3) for axis #2.
+%
+% A "canvas coordinate" here means an argument for \pgfplotsqpointxyz.
+%
+% #1: a command suffix which will be handed over to the datascale
+% #2: an axis (x,y, or z)
+% #3: the high-level coordinate which should be transformed
+% trafo (typically an empty string)
+\long\def\pgfplots@evalute@tikz@coord@system@interface@for[#1]#2#3{%
+ \pgfkeysgetvalue{/pgfplots/#2 coord trafo/.@cmd}\pgfplots@loc@TMPc
+ \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key
+ \edef\pgfmathresult{#3}% do not expand it - might contain unexpandable input for coord trafo.
+ \else
+ \pgfplots@loc@TMPc{#3}\pgfeov
+ \fi
+ \ifpgfplots@plot@coords@mathparser
+ \pgfplotscoordmath{default}{parse}{\pgfmathresult}%
+ \fi
+ \let\pgfplots@loc@TMPc=\pgfmathresult% FIXME: is that necessary? I doubt it... but just to make sure...
+ \csname ifpgfplots@#2islinear\endcsname
+ \pgfplotscoordmath{#2}{parsenumber}{\pgfplots@loc@TMPc}%
+ \pgfplots@if{pgfplots@apply@datatrafo@#2}{%
+ \pgfplotscoordmath{#2}{datascaletrafo#1}{\pgfmathresult}%
+ }{}%
+ \else
+ \pgfplotscoordmath{#2}{log}{\pgfplots@loc@TMPc}%
+ \fi
+}
+
+\long\def\pgfplots@evalute@tikz@coord@system@interface@for@normalized[#1]#2#3{%
+ \edef\pgfmathresult{#3}%
+ \pgfplotscoordmath{default}{parse}{\pgfmathresult}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult% FIXME: is that necessary? I doubt it... but just to make sure...
+ \pgfplotscoordmath{#2}{parsenumber}{\pgfplots@loc@TMPc}%
+ \csname ifpgfplots@#2islinear\endcsname
+ \pgfplots@if{pgfplots@apply@datatrafo@#2}{%
+ \pgfplotscoordmath{#2}{datascaletrafo#1}{\pgfmathresult}%
+ }{}%
+ \else
+ % OK, assume it *is* in the normalized format.
+ \fi
+}
+
+\def\pgfplots@evalute@tikz@coord@system@interface{%
+ \begingroup
+ \pgfutil@ifnextchar[%
+ {\pgfplots@evalute@tikz@coord@system@interface@x}%
+ {\pgfplots@evalute@tikz@coord@system@interface@x[]}%
+}
+\def\pgfplots@evalute@tikz@coord@system@interface@x[#1]#2,{%
+ \def\pgfplots@evaluate@tikz@coord@opts{#1}%
+ \def\pgfplots@evaluate@tikz@coord@x{#2}%
+ \pgfplots@evalute@tikz@coord@system@interface@xy%
+}%
+
+\def\pgfplots@evalute@tikz@coord@system@interface@xy#1,{%
+ \def\pgfplots@evaluate@tikz@coord@y{#1}%
+ \pgfutil@ifnextchar\pgfplots@coord@end{%
+ % ah - we have no Z component. ok.
+ \let\pgfplots@evaluate@tikz@coord@z\pgfutil@empty
+ % jump to the end of the state machine:
+ \pgfplots@evalute@tikz@coord@system@interface@@@@@
+ }{%
+ \pgfplots@evalute@tikz@coord@system@interface@xyz
+ }%
+}%
+
+\def\pgfplots@evalute@tikz@coord@system@interface@xyz#1,{%
+ \def\pgfplots@evaluate@tikz@coord@z{#1}%
+ \pgfplots@evalute@tikz@coord@system@interface@@@@@
+}%
+
+% equals only itsself in \ifx:
+\def\pgfplots@coord@end{\pgfplots@coord@end}
+
+\long\def\pgfplots@evalute@tikz@coord@system@interface@@@@@#1\pgfplots@coord@end{%
+ %\begingroup <--- has already been opened at the beginning of the state machine
+ \pgfplots@evalute@tikz@coord@system@interface@tocoords[\pgfplots@evaluate@tikz@coord@opts]%
+ \xdef\pgfplots@glob@TMPa{\pgfplots@evaluate@tikz@coord@x}%
+ \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}%
+ \fi
+}
+
+% Defines \pgfplots@evaluate@tikz@coord@[xyz]
+\def\pgfplots@evalute@tikz@coord@system@interface@tocoords[#1]{%
+ \def\pgfplots@evalute@tikz@coord@@##1##2{%
+ \pgfplots@evalute@tikz@coord@system@interface@for[#1]{##2}{##1}%
+ }%
+ \expandafter\pgfplots@evalute@tikz@coord@@\expandafter{\pgfplots@evaluate@tikz@coord@x}{x}%
+ \let\pgfplots@evaluate@tikz@coord@x=\pgfmathresult
+ \expandafter\pgfplots@evalute@tikz@coord@@\expandafter{\pgfplots@evaluate@tikz@coord@y}{y}%
+ \let\pgfplots@evaluate@tikz@coord@y=\pgfmathresult
+ %
+ \ifx\pgfplots@evaluate@tikz@coord@z\pgfutil@empty
+ \else
+ \expandafter\pgfplots@evalute@tikz@coord@@\expandafter{\pgfplots@evaluate@tikz@coord@z}{z}%
+ \let\pgfplots@evaluate@tikz@coord@z=\pgfmathresult
+ \fi
+}%
+
+\def\pgfplots@evalute@tikz@coord@system@interface@rel{%
+ \begingroup
+ \let\pgfplots@evalute@tikz@coord@system@interface@@@@@=\pgfplots@evalute@tikz@coord@system@interface@@@@@rel
+ \pgfutil@ifnextchar[%
+ {\pgfplots@evalute@tikz@coord@system@interface@x}%
+ {\pgfplots@evalute@tikz@coord@system@interface@x[]}%
+}
+
+\long\def\pgfplots@evalute@tikz@coord@system@interface@@@@@rel#1\pgfplots@coord@end{%
+ %\begingroup <--- has already been opened at the beginning of the state machine
+ \pgfkeys{/pgf/fpu=false}%
+ \pgfmathparse{\pgfplots@evaluate@tikz@coord@x}%
+ \let\pgfplots@evaluate@tikz@coord@x=\pgfmathresult
+ \pgfmathparse{\pgfplots@evaluate@tikz@coord@y}%
+ \let\pgfplots@evaluate@tikz@coord@y=\pgfmathresult
+ \ifx\pgfplots@evaluate@tikz@coord@z\pgfutil@empty
+ \else
+ \pgfmathparse{\pgfplots@evaluate@tikz@coord@z}%
+ \let\pgfplots@evaluate@tikz@coord@z=\pgfmathresult
+ \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@evaluate@tikz@coord@x pt
+ \advance\pgf@xa by1pt
+ \edef\pgfplots@evaluate@tikz@coord@x{\pgf@sys@tonumber\pgf@xa}%
+ \fi
+ \if\pgfkeysvalueof{/pgfplots/y dir/value}r%
+ \pgf@xa=-\pgfplots@evaluate@tikz@coord@y pt
+ \advance\pgf@xa by1pt
+ \edef\pgfplots@evaluate@tikz@coord@y{\pgf@sys@tonumber\pgf@xa}%
+ \fi
+ \fi
+ %
+ \ifx\pgfplots@evaluate@tikz@coord@z\pgfutil@empty
+ \pgfpointadd
+ {\pgfplotspointminminmin}%
+ {\pgfplotsqpointxy{\pgfplots@evaluate@tikz@coord@x}{\pgfplots@evaluate@tikz@coord@y}}%
+ \else
+ \ifpgfplots@allow@reversal@of@rel@axis@cs
+ \if\pgfkeysvalueof{/pgfplots/z dir/value}r%
+ \pgf@xa=-\pgfplots@evaluate@tikz@coord@z pt
+ \advance\pgf@xa by1pt
+ \edef\pgfplots@evaluate@tikz@coord@z{\pgf@sys@tonumber\pgf@xa}%
+ \fi
+ \fi
+ \pgfplotspointzaxis
+ \pgf@zx=\pgf@x
+ \pgf@zy=\pgf@y
+ \pgfpointadd
+ {\pgfplotspointminminmin}%
+ {\pgfplotsqpointxyz{\pgfplots@evaluate@tikz@coord@x}{\pgfplots@evaluate@tikz@coord@y}{\pgfplots@evaluate@tikz@coord@z}}%
+ \fi
+ \pgf@process{}%
+ \endgroup
+}
+
+\def\pgfplots@evalute@tikz@coord@system@interface@normalized{%
+ \begingroup
+ \let\pgfplots@evalute@tikz@coord@system@interface@for=\pgfplots@evalute@tikz@coord@system@interface@for@normalized
+ \pgfutil@ifnextchar[%
+ {\pgfplots@evalute@tikz@coord@system@interface@x}%
+ {\pgfplots@evalute@tikz@coord@system@interface@x[]}%
+}
+
+% In case of (semi-) logplots, this command will
+% - assign a filter which invokes \pgfmathlog@{} for each coordinate
+% - replace any user-specified coordinate by its log.
+%
+% All subsequent commands will then work with logarithmic coordinates.
+%
+% PRECONDITION:
+% - The user input options have been set correctly,
+% - the options have been set, but are not applied
+%
+% POSTCONDITION:
+% - 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{%
+ \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
+ % no high-level external coord trafos.
+ % Simply use identity:
+ \expandafter\def\csname pgfplots@prepare@#1coord\endcsname##1{%
+ \edef\pgfmathresult{##1}%
+ }%
+ \else
+ % Apply external coordinate trafo to all input values:
+ \expandafter\edef\csname pgfplots@prepare@#1coord\endcsname##1{%
+ % do not expand it here - might contain unexpandable
+ % material which is processed by the #1 coord trafo:
+ % FIXME : this might produce an endless loop if ##1 = \pgfmathresult!
+ \noexpand\def\noexpand\pgfmathresult{##1}%
+ % this becomes
+ \expandafter\noexpand\csname pgfplots@highlevel@trafo@#1\endcsname{##1}\noexpand\pgfeov
+ %
+ % ensure that it is expanded.
+ \noexpand\edef\noexpand\pgfmathresult{\noexpand\pgfmathresult}%
+ }%
+ %
+ % The transformation is now \pgfplots@loc@TMPc
+ %
+ % any user-specified axis limits:
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1min\endcsname
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPa}\pgfeov%
+ \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\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPa}\pgfeov%
+ \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
+ \fi
+ %
+ % any user-specified tick limits:
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmin\endcsname
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPa}\pgfeov%
+ \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\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPa}\pgfeov%
+ \expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult
+ \fi
+ %
+ % any user specified axis ticks:
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@#1tick\endcsname}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPb{data}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % #1tick=data is handled elsewhere...
+ \else
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname
+ \expandafter\pgfplots@filter@input@ticks@with@highleveltrafo\expandafter{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPc}%
+ \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@highleveltrafo\expandafter{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPc}%
+ \expandafter\edef\csname pgfplots@extra@#1tick\endcsname{\pgfmathresult}%
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\pgfplots@filter@input@ticks@with@highleveltrafo\expandafter{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPc}%
+ \pgfkeyslet{/pgfplots/minor #1tick}\pgfmathresult
+ \fi
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/#1filter}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\let\csname pgfplots@#1filter@backwcompat\endcsname=\pgfplots@loc@TMPa
+ \t@pgfplots@tokc={/pgfplots/#1filter is deprecated. Please use /pgfplots/#1 filter/.code={\def\pgfmathresult{\#1}}}%
+ \pgfplots@warning{\the\t@pgfplots@tokc}%
+ \pgfkeys{/pgfplots/#1 filter/.code={\csname pgfplots@#1filter@backwcompat\endcsname{##1}\to\pgfmathresult}}%
+ \fi
+ \csname ifpgfplots@#1islinear\endcsname
+ \pgfplotssetcoordmathfor{#1}{float}%
+ \csname pgfplots@apply@datatrafo@#1true\endcsname
+ \pgfplots@apply@datatrafotrue
+ \ifpgfplots@apply@datatrafo
+ % Check for any existing axis limits:
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1min\endcsname
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotscoordmath{#1}{parse}{\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
+ \pgfplotscoordmath{#1}{parse}{\pgfplots@loc@TMPa}%
+ \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
+ \fi
+ % Check for any existing tick limits:
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmin\endcsname
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotscoordmath{#1}{parse}{\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
+ \pgfplotscoordmath{#1}{parse}{\pgfplots@loc@TMPa}%
+ \expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult
+ \fi
+ \fi
+ \else
+ \pgfplotssetcoordmathfor{#1}{pgfbasic}%
+ %
+ % 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}%
+ \def\pgfplots@loc@TMPb{e}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % log basis x=e : same as empty value.
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \fi
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % log basis x={} (initial setting:)
+ \else
+ % use a different basis.
+ \pgfplotscoordmath{#1}{set log basis}{\pgfplots@loc@TMPa}%
+ %
+ % generate default ticks in the 'log basis', not base 10:
+ \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
+ \pgfkeyslet{/pgfplots/log basis #1/.@cmd}\pgfplots@cant@set@in@this@context
+ %%%
+ % 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
+ \pgfplotscoordmath{default}{parse}{\pgfplots@loc@TMPa}%
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{%
+ }{%
+ \pgfplotswarning{illegal user argument in log axis}{#1min}{\csname pgfplots@#1min\endcsname}\pgfeov%
+ }%
+ \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
+ \pgfplotscoordmath{default}{parse}{\pgfplots@loc@TMPa}%
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{%
+ }{%
+ \pgfplotswarning{illegal user argument in log axis}{#1max}{\csname pgfplots@#1max\endcsname}\pgfeov%
+ }%
+ \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
+ \fi
+ %
+ % any user-specified tick limits:
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmin\endcsname
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotscoordmath{#1}{log}{\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
+ \pgfplotscoordmath{#1}{log}{\pgfplots@loc@TMPa}%
+ \expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult
+ \fi
+ %
+ % any user specified axis ticks:
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@#1tick\endcsname}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPb{data}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % #1tick=data is handled elsewhere...
+ \else
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname
+ \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}{#1}%
+ \expandafter\edef\csname pgfplots@extra@#1tick\endcsname{\pgfmathresult}%
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\pgfplots@filter@input@ticks@with@log\expandafter{\pgfplots@loc@TMPa}{#1}%
+ \pgfkeyslet{/pgfplots/minor #1tick}\pgfmathresult
+ \fi
+ %
+ % append logarithm to prepare coord.
+ %
+ \t@pgfplots@toka={%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfplots@if{pgfplots@disablelogfilter@#1}{%
+ \pgfplotscoordmath{#1}{parsenumber}{\pgfmathresult}%
+ % FIXME : check for unbounded arguments!
+ }{%
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{}{%
+ \def\pgfplots@unbounded@dir{#1}%
+ }%
+ }%
+ \fi
+ }%
+ \pgfkeysgetvalue{/pgfplots/#1 coord trafo/.@cmd}\pgfplots@loc@TMPc
+ \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key
+ \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: APPEND
+ % the log stuff to the existing prepare method.
+ \t@pgfplots@tokb=\expandafter\expandafter\expandafter{%
+ \csname pgfplots@prepare@#1coord\endcsname{##1}%
+ }%
+ \expandafter\edef\csname pgfplots@prepare@#1coord\endcsname##1{%
+ \the\t@pgfplots@tokb
+ \the\t@pgfplots@toka
+ }%
+ \fi
+ }%
+ \fi
+}
+
+\def\pgfplots@create@axis@descriptions{%
+ \begingroup
+ %
+ \pgfplots@change@pgfpoints@to@descriptioncs
+ %
+ \pgfplots@create@axis@descriptions@
+ \endgroup
+}
+
+\def\pgfplots@create@axis@descriptions@{%
+ \begingroup
+ \ifpgfplots@hide@x
+ \else
+ \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
+ \ifpgfplots@hide@y
+ \else
+ \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
+ \ifpgfplots@threedim
+ \ifpgfplots@hide@z
+ \else
+ \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
+ \endgroup
+ %
+ \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%
+ %
+}
+
+% Invokes '#1' foreach key which should be saved by a color bar.
+%
+% The current key name is available as '##1', the macro under which
+% the key is / should be saved as '##2'.
+\def\pgfplots@colorbar@foreach@saved@key#1{%
+ \def\pgfplots@colorbar@foreach@saved@key@body##1##2{#1}%
+ \pgfplotsutilforeachcommasep{%
+ {/pgfplots/colorbar/draw/.@cmd}\pgfplots@savedstyle@colorbar@draw,%
+ {/pgfplots/every colorbar/.@cmd}\pgfplots@savedstyle@colorbar,%
+ {/pgfplots/colorbar shift/.@cmd}\pgfplots@savedstyle@colorbarshift,%
+ {/pgfplots/colorbar horizontal/lowlevel/.@cmd}\pgfplots@savedstyle@colorbar@horizontal,%
+ {/pgfplots/colorbar vertical/lowlevel/.@cmd}\pgfplots@savedstyle@colorbar@vertical,%
+ {/pgfplots/every tick/.@cmd}\pgfplots@savedstyle@tick,%
+ {/pgfplots/every minor tick/.@cmd}\pgfplots@savedstyle@minortick,%
+ {/pgfplots/every major tick/.@cmd}\pgfplots@savedstyle@majortick,%
+ {/pgfplots/every axis grid/.@cmd}\pgfplots@savedstyle@grid,%
+ {/pgfplots/every minor grid/.@cmd}\pgfplots@savedstyle@minorgrid,%
+ {/pgfplots/every major grid/.@cmd}\pgfplots@savedstyle@majorgrid,%
+ {/pgfplots/every tick label/.@cmd}\pgfplots@savedstyle@ticklabel,%
+ {/pgfplots/every tick label/.@cmd}\pgfplots@savedstyle@ticklabel%
+ }%
+ \as\pgfplots@colorbar@foreach@saved@key@@
+ {%
+ \expandafter\pgfplots@colorbar@foreach@saved@key@body\pgfplots@colorbar@foreach@saved@key@@
+ }%
+}%
+\def\pgfplots@colorbar@restore@saved@keys{%
+ \pgfplots@colorbar@foreach@saved@key{%
+ \pgfkeyslet{##1}##2%
+ }%
+}%
+
+% 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}%
+ %
+ \pgfkeysgetvalue{/pgfplots/colorbar to name}\pgfplots@colorbar@toname
+ %
+ \pgfnodealias{parent axis}{current axis}%
+ %
+ % FIXME :
+ % I would really prefer to find a different way to move these
+ % variables out of the current scope. But expansion leads to
+ % mistakes with '#' characters ... :-(
+ \pgfplots@colorbar@foreach@saved@key{%
+ \pgfkeysgetvalue{##1}\pgfplots@loc@TMPa
+ \global\let##2=\pgfplots@loc@TMPa
+ }%
+ %
+ \toks1={}%
+ \ifx\pgfplots@colorbar@toname\pgfutil@empty
+ \else
+ \toks1={%
+ \pgfplots@colorbar@get@rid@of@at@parent@axis
+ }%
+ \pgfplots@colorbar@foreach@saved@key{%
+ \pgfplots@command@with@args@to@string##2\pgfplots@loc@TMPa
+ \pgfplots@auxwrite{%
+ \noexpand\expandafter
+ \noexpand\long
+ \noexpand\expandafter
+ \noexpand\gdef
+ \noexpand\csname pgfplots@colorbar@\pgfplots@colorbar@toname @\noexpand\string\noexpand##2\noexpand\endcsname%
+ \pgfplots@loc@TMPa
+ }%
+ \edef\pgfplots@loc@TMPa{%
+ \the\toks1
+ \noexpand\expandafter
+ \noexpand\let
+ \noexpand\expandafter
+ \noexpand##2%
+ \noexpand\csname pgfplots@colorbar@\pgfplots@colorbar@toname @\noexpand\string\noexpand##2\noexpand\endcsname%
+ }%
+ \toks1=\expandafter{\pgfplots@loc@TMPa}%
+ }%
+ \fi
+ % %
+ % 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}%
+ %
+ \pgfkeysgetvalue{/pgfplots/colorbar addplot}\pgfplots@loc@TMPa
+ \toks2=\expandafter{\pgfplots@loc@TMPa}%
+ %
+ \ifx\pgfplots@colorbar@src@metamin\pgfutil@empty
+ \global\let\pgfplots@colorbar@src@metamin=\pgfplots@axiswide@metamin
+ \global\let\pgfplots@colorbar@src@metamax=\pgfplots@axiswide@metamax
+ \fi
+ %
+ \ifx\pgfplots@colorbar@src@metamax\pgfplots@invalidrange@metamax
+ \pgfplotswarning{colorbar uninitialised}\pgfeov
+ \pgfmathfloatparsenumber{0}%
+ \global\let\pgfplots@colorbar@src@metamin=\pgfmathresult
+ \pgfmathfloatparsenumber{1}%
+ \global\let\pgfplots@colorbar@src@metamax=\pgfmathresult
+ \fi
+ %
+ % normalize format:
+ \pgfplotscoordmath{meta}{tostring}{\pgfplots@colorbar@src@metamin}%
+ \global\let\pgfplots@colorbar@src@metamin=\pgfmathresult
+ \pgfplotscoordmath{meta}{tostring}{\pgfplots@colorbar@src@metamax}%
+ \global\let\pgfplots@colorbar@src@metamax=\pgfmathresult
+ %
+ \pgfplots@assemble@ref@picture
+ {\pgfplots@colorbar@draw}
+ {\tikz[/pgfplots/every colorbar to name picture/.try]{\pgfplots@colorbar@draw}}%
+ \toks3=\expandafter{\pgfplotsretval}%
+ %
+ \xdef#1{%
+ \noexpand\begingroup
+ \noexpand\def\noexpand\pgfplots@colorbar@draw{%
+ \the\toks0 % restore colormap definition
+ \noexpand\def\noexpand\pgfplots@colorbar@toname{\pgfplots@colorbar@toname}%
+ \the\toks1 % definitions for 'colorbar to name'
+ %
+ % restore relevant styles and variables:
+ \noexpand\pgfplots@colorbar@restore@saved@keys
+ \noexpand\pgfkeyssetvalue{/pgfplots/point meta min}{\pgfplots@colorbar@src@metamin}%
+ \noexpand\pgfkeyssetvalue{/pgfplots/point meta max}{\pgfplots@colorbar@src@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\pgfkeyssetvalue{/pgfplots/colorbar addplot}{\the\toks2 }%
+ \noexpand\def\noexpand\pgfplots@colormap@access{\pgfplots@colormap@access}%
+ \noexpand\pgfkeyssetvalue{/pgfplots/colorbar pos*}{\pgfkeysvalueof{/pgfplots/colorbar pos*}}%
+ % just to make sure that colorbar sampled respects it:
+ \noexpand\pgfkeyssetvalue{/pgfplots/mark list fill}{\pgfkeysvalueof{/pgfplots/mark list fill}}%
+ \noexpand\pgfplots@colorbar@define@hook%
+ \noexpand\pgfplots@colorbar@draw@
+ \ifx\pgfplots@colorbar@toname\pgfutil@empty
+ \noexpand\pgfnodealias{current colorbar axis}{current axis}%
+ \noexpand\pgfnodealias{current axis}{parent axis}%
+ \fi
+ }%
+ \the\toks3
+ \noexpand\endgroup
+ }%
+ \ifx\pgfplots@colorbar@toname\pgfutil@empty
+ \else
+ % finalize the 'colorbar to name' feature
+ \toks0=\expandafter{#1}%
+ \pgfplots@auxwrite{%
+ \noexpand\expandafter
+ \noexpand\gdef\noexpand\csname pgfplots@colorbar@to@name@\pgfplots@colorbar@toname\endcsname{\the\toks0}}%
+ \xdef#1{}% NOP.
+ %
+ % make sure \ref{<colorbarname>} works:
+ \pgfplots@label{\pgfplots@colorbar@toname}{pgfplots@colorbar@to@name@}%
+ \fi
+}%
+
+\newif\ifpgfplotscolorbarCMYKworkaround
+\pgfplotscolorbarCMYKworkaroundtrue
+
+\def\pgfplots@colorbar@draw@reconfigure@if@needed@legacy{%
+ \pgfkeysgetvalue{/pgfplots/colorbar/draw/.@cmd}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfplots@colorbar@draw@legacyimpl
+ \begingroup
+ \pgfkeysalso{/pgfplots/.search also=/tikz}%
+ % we need to activate this style because the decision
+ % below may depend on it (and will, for example for
+ % contour filled)
+ \pgfplotsset{every colorbar}%
+ \pgfplots@init@collect@firstplotastick%
+ %
+ % Ah-- the default colorbar implementation is active! We may need to substitute it by a better one.
+ % Check that:
+ \def\b@pgfplots@colorbar@fallback@to@sampled{0}%
+ %
+ \ifpgfplots@collect@firstplot@astick
+ % xtick={data} requires samples:
+ % see also call hierarchy of \pgfplots@colorbar@positions@to@samplesat
+ \def\b@pgfplots@colorbar@fallback@to@sampled{1}%
+ \fi
+ %
+ \ifpgfplotscolorbarCMYKworkaround
+ % the default implementation for colorbars is based on
+ % \pgfplotscolormaptoshadingspec.
+ % This, in turn, does NOT work for CMYK.
+ %
+ % This here detects that case and switches to the (visually)
+ % equivalent 'colorbar sampled={surf,shader=interp}' style.
+ \if1\pgfplotscolormaptoshadingspectorgb
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPb
+ \pgfplotscolormapgetcolorspace{\pgfplots@loc@TMPb}%
+ \def\pgfplots@loc@TMPa{cmyk}%
+ \ifx\pgfplots@loc@TMPa\pgfplotsretval
+ \pgfutil@ifundefined{pgfplots@colorbar@CMYK@\pgfplots@loc@TMPb}{%
+ \pgfplotswarning{colorbar CMYK unsupported}{\pgfplots@loc@TMPb}\pgfeov%
+ \expandafter\gdef\csname pgfplots@colorbar@CMYK@\pgfplots@loc@TMPb\endcsname{1}%
+ }{}%
+ \def\b@pgfplots@colorbar@fallback@to@sampled{1}%
+ \fi
+ \fi
+ \fi
+ %
+ \if c\pgfplots@colormap@access
+ % colormap access=piecewise constant
+ % In this case, we want a sampled colorbar.
+ \def\b@pgfplots@colorbar@fallback@to@sampled{1}%
+ %
+ \fi
+ \pgfmath@smuggleone\b@pgfplots@colorbar@fallback@to@sampled
+ \endgroup
+ %
+ \if 1\b@pgfplots@colorbar@fallback@to@sampled
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplotsset{%
+ colorbar sampled={%
+ surf,%
+ shader=interp,%
+ % 2x2 samples are enough since "shader=interp"
+ % automatically handles the correct interpolation scheme:
+ samples=2,%
+ }%
+ }%
+ }%
+ \pgfplots@loc@TMPa
+ \fi
+ \fi
+}%
+
+\def\pgfplots@colorbar@draw@reconfigure@if@needed{%
+ \pgfplots@colorbar@draw@reconfigure@if@needed@legacy
+ \pgfplotsset{%
+ /pgfplots/every axis plot post/.append code={%
+ \ifpgfplots@collect@firstplot@astick
+ % Oh! Someone wrote 'ytick=data. We want the precise positions.
+ %
+ % Note that this check needs to be done late: it must
+ % be after \begin{axis} -- and since many colorbar
+ % styles overwrite 'samples', we even have to run it
+ % after cycle list options!
+ %
+ % That's why it is in 'every axis plot post':
+ \pgfplots@colorbar@positions@to@samplesat
+ \fi
+ }%
+ }%
+}%
+
+% Defines and sets 'samples at' such that it resembles the colormap
+% positions.
+\def\pgfplots@colorbar@positions@to@samplesat{%
+ \pgfplots@colorbar@positions@to@samplesat@
+ \edef\pgfplots@loc@TMPa{samples at={\pgfplotsretval}}%
+ \expandafter\pgfplotsset\expandafter{\pgfplots@loc@TMPa}%
+}
+% Sets \pgfplotsretval such that it contains an argument for 'samples at'
+\def\pgfplots@colorbar@positions@to@samplesat@{%
+ \pgfkeysgetvalue{/pgfplots/point meta min}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfplots@error{Please define 'point meta min' and 'point meta max' before using 'samples at colormap pos'}%
+ \fi
+ \pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfplots@error{Please define 'point meta min' and 'point meta max' before using 'samples at colormap pos'}%
+ \fi
+ %
+ \edef\pgfplots@loc@TMPb{%
+ \noexpand\pgfplotscolormapgetpositions
+ [{\pgfkeysvalueof{/pgfplots/point meta min}}:{\pgfkeysvalueof{/pgfplots/point meta max}}]%
+ {\pgfkeysvalueof{/pgfplots/colormap name}}%
+ }%
+ \pgfplots@loc@TMPb
+}%
+
+% A utility method which draws a standalone colorbar for visualization
+% purposes.
+%
+% Example:
+% \pgfplotscolorbardrawstandalone[colorbar horizontal,colormap access=const]
+%
+% \pgfplotscolorbardrawstandalone[colorbar horizontal,point meta max=1000]
+%
+\def\pgfplotscolorbardrawstandalone{%
+ \pgfutil@ifnextchar[{\pgfplotscolorbardrawstandalone@opt}{\pgfplotscolorbardrawstandalone@opt[]}%
+}%
+\def\pgfplotscolorbardrawstandalone@opt[#1]{%
+ \pgfplots@ifintikzpicture{%
+ \pgfplotscolorbardrawstandalone@opt@[#1]%
+ }{%
+ \begin{tikzpicture}%
+ \pgfplotscolorbardrawstandalone@opt@[#1]%
+ \end{tikzpicture}%
+ }%
+}
+\def\pgfplotscolorbardrawstandalone@opt@[#1]{%
+ \coordinate (parent axis) at (0,0);
+ \pgfplotsset{%
+ point meta min=0,%
+ point meta max=1000,%
+ parent axis width/.initial=6cm,%
+ parent axis height/.initial=6cm,%
+ #1,%
+ colorbar/standalone draw,%
+ }%
+}%
+
+
+\def\pgfplots@colorbar@draw@{%
+ \pgfplots@colorbar@draw@reconfigure@if@needed
+ %
+ % FIXME : the semicolon after ';' has a fixed catcode, namely
+ % the one assigned while pgfplots.code.tex has been read.
+ %
+ % The \pgfplots@checkandpreparefor@active@semicolon gets
+ % confused if the catcodes change... this here is a
+ % work-around for babel support.
+ \let\pgfplots@checkandpreparefor@active@semicolon\relax
+ %
+ % make sure that 'every colorbar' is checked by the key-filtering
+ % stuff: we want to find 'ymode=log' inside of it.
+ % Note that we have to change it here because only the colorbar
+ % should expand 'every colorbar' that early in the processing:
+ \pgfkeys{/pgfplots/every colorbar/.belongs to family=/pgfplots/scale}%
+ %
+ \pgfkeysvalueof{/pgfplots/colorbar/draw/.@cmd}\pgfeov
+}
+
+\def\pgfplotsifnodeexists#1#2#3{%
+ \pgfutil@IfUndefined{pgf@sh@ns@#1}{#3}{#2}%
+}%
+
+\def\pgfplots@colorbar@get@rid@of@at@parent@axis{%
+ \pgfkeysgetvalue{/pgfplots/at/.@cmd}\pgfplots@at@orig
+ \pgfkeyslet{/pgfplots/at/orig/.@cmd}\pgfplots@at@orig
+ %
+ \pgfkeysgetvalue{/pgfplots/colorbar to name/at/.@cmd}\pgfplots@colorbar@toname@at
+ \pgfkeyslet{/pgfplots/at/.@cmd}\pgfplots@colorbar@toname@at
+ %
+ \let\pgfplots@colorbar@get@rid@of@at@parent@axis=\relax% already applied in this scope.
+}%
+\pgfkeysdef{/pgfplots/colorbar to name/at}{%
+ % automatically search-and-replace 'parent axis' which
+ % is not defined for a detached colorbar:
+ \pgfutil@in@{parent axis}{#1}%
+ \ifpgfutil@in@
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/at/orig/.@cmd}{(0pt,0pt)}%
+ \else
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/at/orig/.@cmd}{#1}%
+ \fi
+}%
+\let\pgfplots@colorbar@position@hook\relax
+\def\pgfplots@colorbar@define@hook{%
+ \ifx\pgfplots@colorbar@toname\pgfutil@empty
+ \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
+ }%
+ }%
+ \else
+ % nothing to do for colorbar to name:
+ \let\pgfplots@colorbar@position@hook=\relax
+ \fi
+}%
+
+% 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
+% further processing.
+%
+% Example:
+% \tikzstyle{every axis}=[xmin=0,xmax=1,line width=1pt
+% \pgfplots@set@keys@from@tikz@style\tmpmacro{every axis}{/pgfplots}
+%
+% - sets axis options 'xmin' and 'xmax'
+% - calls \tikzstyle{every axis}={line width=1pt}
+%
+% I assume that this method is called within local TeX groups so
+% nothing will be destroyed outside.
+%
+% #1: A style name.
+\def\pgfplots@set@keys@from@tikz@style#1{%
+ \let\pgfplots@rmopts=\pgfutil@empty
+ \pgfqkeysfiltered{/pgfplots}{/pgfplots/#1}%
+ \pgfplots@set@keymacro@to@style\pgfplots@rmopts{#1}%
+}
+
+% Invokes \pgfplots@set@keys@from@tikz@style and handles the "on
+% layer" key.
+%
+% More precisely, it stores any "on layer" value found in style "#1"
+% in
+% /pgfplots/layers for styles/#1.
+%
+% If there is no such value, it will store the empty string (main
+% layer)
+\def\pgfplots@set@keys@from@tikz@style@and@handle@layer#1{%
+ \pgfkeyslet{/pgfplots/on layer}\pgfutil@empty
+ \pgfplots@set@keys@from@tikz@style{#1}%
+ \pgfkeysgetvalue{/pgfplots/on layer}\pgfplots@loc@TMPa
+ \pgfkeyslet{/pgfplots/layers for styles/#1}\pgfplots@loc@TMPa
+}%
+
+% The same as \pgfplots@set@keys@from@tikz@style but this one appends
+% unmatched options to style #2.
+%
+% #1: A style name.
+% #2: A style name which will be filled with unprocessed options.
+\def\pgfplots@set@keys@from@tikz@style@append@to#1#2{%
+ \let\pgfplots@rmopts=\pgfutil@empty
+ \pgfqkeysfiltered{/pgfplots}{/pgfplots/#1}%
+ \pgfplots@append@keymacro@to@style\pgfplots@rmopts{#2}%
+}
+
+% #1: A sequence of options.
+% #2: A style name which will be filled with unprocessed options.
+\def\pgfplots@set@keys@and@append@remaining@to@style#1#2{%
+ \let\pgfplots@rmopts=\pgfutil@empty
+ \pgfqkeysfiltered{/pgfplots}{#1}%
+ \pgfplots@append@keymacro@to@style\pgfplots@rmopts{#2}%
+}%
+
+% #1: input macro
+\def\pgfplots@setkeys@from@macro#1{%
+ \let\pgfplots@rmopts=\pgfutil@empty
+ \def\pgfplots@loc@TMPa{\pgfqkeysfiltered{/pgfplots}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{#1}%
+}
+
+% #1: macro
+% #2: style name
+\long\def\pgfplots@append@keymacro@to@style#1#2{%
+ \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{%
+ \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@sanitizemode{%
+ \pgfkeyslet{/pgfplots/xmode/.@cmd}\pgfplots@cant@set@in@this@context@
+ \pgfkeyslet{/pgfplots/ymode/.@cmd}\pgfplots@cant@set@in@this@context@
+ \pgfkeyslet{/pgfplots/zmode/.@cmd}\pgfplots@cant@set@in@this@context@
+}
+\def\pgfplots@set@options@sanitize{%
+ \pgfkeyslet{/pgfplots/xmin/.@cmd}\pgfplots@cant@set@in@this@context
+ \pgfkeyslet{/pgfplots/ymin/.@cmd}\pgfplots@cant@set@in@this@context
+ \pgfkeyslet{/pgfplots/zmin/.@cmd}\pgfplots@cant@set@in@this@context
+ \pgfkeyslet{/pgfplots/xmax/.@cmd}\pgfplots@cant@set@in@this@context
+ \pgfkeyslet{/pgfplots/ymax/.@cmd}\pgfplots@cant@set@in@this@context
+ \pgfkeyslet{/pgfplots/zmax/.@cmd}\pgfplots@cant@set@in@this@context
+}%
+
+% This here is the main key filter for pgfplots.
+%
+% It sets keys if
+% ( they have an active key family)
+% OR
+% ( they have /pgfplots/ key prefix )
+% OR
+% ( they are a command key which contains \tikz@plot@handler ).
+%
+% In all other cases, the key filter will postpone the key.
+%
+% Note that \tikz@plot@handler should be defined before the survey
+% phase starts.
+\pgfkeysdef{/pgfplots/@@key filter}{%
+ \if\pgfkeyscasenumber0%
+ \pgfkeysfiltercontinuefalse
+ \else
+ \if\pgfkeyscasenumber3%
+ \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP
+ \else
+ \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP
+ \fi
+ \ifpgfkeyssuccess
+ % it has a family. Check it!
+ \pgfkeysisfamilyactive{\pgfkeyspred@TMP}%
+ \else% Ok, it does not belong to any family.
+ % Check if it has /pgfplots/ prefix:
+ \expandafter\pgfplots@key@filter@isdescendantof\pgfkeyscurrentkey/pgfplots/\pgf@@eov
+ \fi
+ \fi
+}
+\def\pgfplots@key@filter@isdescendantof#1/pgfplots/#2\pgf@@eov{%
+ \def\pgfkeyspred@TMP{#1}%
+ \ifx\pgfkeyspred@TMP\pgfkeys@empty
+ % Ah -- it *has* /pgfplots/ prefix. Use it!
+ \pgfkeysfiltercontinuetrue
+ \else
+ % Hm. Probably a /tikz/ key, but who knows.
+ \if1\pgfkeyscasenumber
+ % It is a command key.
+ % Check if the *body* of the command key contains
+ % \tikz@plot@handler.
+ \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}\pgfkeyspred@TMP%
+ \expandafter\pgfplots@key@filter@isplothandler\pgfkeyspred@TMP 123456789\pgfeov\tikz@plot@handler\pgfplots@EOI
+ \else
+ % Ok, it's no command key. Skip it directly.
+ \pgfkeysfiltercontinuefalse
+ \fi
+ \fi
+}%
+\def\pgfplots@key@filter@isplothandler#1\tikz@plot@handler#2\pgfplots@EOI{%
+ \def\pgfkeyspred@TMP{#2}%
+ \ifx\pgfkeyspred@TMP\pgfkeys@empty
+ % I didn't find '\tikz@plot@handler' in the key's body. Ok.
+ % key won't be processed.
+ \pgfkeysfiltercontinuefalse
+ \else
+ % Aaah -- it is something like /tikz/ybar! process it.
+ \pgfkeysfiltercontinuetrue
+ \fi
+}%
+
+\def\pgfplots@set@options#1{%
+ \pgfplots@check@global@colorspace@overrides
+ \pgfplots@bb@isactivetrue
+ \pgfplots@curplot@threedimfalse
+ \global\pgfplots@threedimfalse
+ \pgfutil@ifundefined{tikz@lastx}{%
+ % no warning. Its not that important anyway, I think.
+ \def\pgfplots@at{\pgfpointorigin}%
+ }{%
+ \edef\pgfplots@at{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
+ }%
+ %
+ % Temporarily assign families to 'name' and 'alias' options.
+ % This allows to get the names - they should not be appended to
+ % 'every axis'!
+ \pgfkeyssetfamily{/tikz/name}{/pgfplots/naming commands}%
+ \pgfkeyssetfamily{/tikz/alias}{/pgfplots/naming commands}%
+ \pgfkeyssetfamily{/tikz/overlay}{/pgfplots/shared with tikz}%
+ \pgfkeyssetfamily{/tikz/variable}{/pgfplots}%
+ %
+ \pgfkeysdef{/pgfplots/declare function}{\pgfkeysalso{/pgf/declare function={##1}}}%
+ \pgfkeyssetfamily{/pgf/declare function}{/pgfplots}%
+ %
+ % ... we need to set these options during the survey phase
+ % (because it might be interesting for enlarge limits to depend
+ % upon their value):
+ \pgfkeysdef{/pgfplots/bar width}{\pgfkeysalso{/pgf/bar width={##1}}}%
+ \pgfkeysdef{/pgfplots/bar shift}{\pgfkeysalso{/pgf/bar shift={##1}}}%
+ \pgfkeyssetfamily{/pgf/bar width}{/pgfplots}%
+ \pgfkeyssetfamily{/pgf/bar shift}{/pgfplots}%
+ %
+ \pgfkeyssetfamily{/pgf/trig format}{/pgfplots}%
+ \pgfkeyssetfamily{/pgf/trig format/deg}{/pgfplots}%
+ \pgfkeyssetfamily{/pgf/trig format/rad}{/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 and known}{}%
+ %
+ \pgfqkeysactivatesinglefamilyandfilteroptions{/pgfplots/scale}%
+ {/pgfplots}
+ {#1,/pgfplots/every axis post}%
+ \let\pgfplots@remaining@input=\pgfplots@rmopts
+ %
+ \pgfplotssetaxistype{\pgfkeysvalueof{/pgfplots/axis type}}%
+ %
+ % Step 2: parse any pgfplots options out of styles.
+ \pgfkeysactivatefamily{/pgfplots/style commands}%
+ %\pgfkeysinstallkeyfilter{/pgf/key filters/active families or descendants of}{/pgfplots}
+ \pgfkeysinstallkeyfilter{/pgfplots/@@key filter}{}%
+ %
+ \pgfkeysactivatefamilies
+ {/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}%
+ %
+ \pgfplots@set@keys@from@tikz@style@append@to{every \pgfkeysvalueof{/pgfplots/axis type} axis}{every axis}%
+ %
+ \ifpgfplots@xislinear
+ \ifpgfplots@yislinear
+ \pgfplots@set@keys@from@tikz@style@append@to{every linear axis}{every axis}%
+ \else
+ \pgfplots@set@keys@from@tikz@style@append@to{every semilogy axis}{every axis}%
+ \fi
+ \else
+ \ifpgfplots@yislinear
+ \pgfplots@set@keys@from@tikz@style@append@to{every semilogx axis}{every axis}%
+ \else
+ \pgfplots@set@keys@from@tikz@style@append@to{every loglog axis}{every axis}%
+ \fi
+ \fi
+ \pgfplots@deactivefamiliescmd
+ \pgfplots@set@options@sanitizemode
+ %
+ % Acquire style commands and nameing commands from direct input
+ % options '#1' BEFORE the 'every' styles are processed:
+ \pgfkeysactivatefamily{/pgfplots/naming commands}%
+ \pgfkeysactivatefamily{/pgfplots/shared with tikz}%
+ \pgfplots@setkeys@from@macro\pgfplots@remaining@input%
+ \let\pgfplots@remaining@input=\pgfplots@rmopts
+ \pgfkeysdeactivatefamily{/pgfplots/naming commands}%
+ \pgfkeysdeactivatefamily{/pgfplots/shared with tikz}%
+ %
+ \pgfplots@set@options@of@layered@graphics
+ %
+ % Now, any 'name' and 'alias' options have been processed.
+ %
+ % Remember their current meaning and reset the tikz options!
+ \let\pgfplots@fig@name=\tikz@fig@name
+ \let\pgfplots@fig@alias=\tikz@alias
+ \let\tikz@alias=\pgfutil@empty
+ \let\tikz@fig@name=\pgfutil@empty
+ %
+ % And protocol all named sub-nodes! Their positions need to be
+ % updated later.
+ \global\let\pgfplots@named@child@node@list=\pgfutil@empty
+ \pgfutil@ifundefined{pgfplots@old@name@impl}{%
+ \pgfkeysgetvalue{/tikz/name/.@cmd}\pgfplots@old@name@impl
+ \pgfkeysgetvalue{/tikz/alias/.@cmd}\pgfplots@old@alias@impl
+ }{}%
+ \pgfkeysdef{/tikz/name}{%
+ \pgfplots@add@named@child@node{##1}%
+ \pgfplots@old@name@impl##1\pgfeov
+ }%
+ \pgfkeysdef{/tikz/alias}{%
+ \pgfplots@add@named@child@node{##1}%
+ \pgfplots@old@alias@impl##1\pgfeov
+ }%
+ %
+ % Now, continue to process the 'every' styles. Please note that
+ % options like 'legend style={}' have already been processed;
+ % their values are already inside of the associated 'every'
+ % styles.
+ %
+ % What I am doing here is: set every pgfplots-option directly, and
+ % discard it from the every-style. Any non-pgfplots-option will
+ % be set in its context.
+ %
+ \pgfkeysactivatefamily{/pgfplots/legend}%
+ % this special treatmeant allows the (otherwise unsupported) construction
+ % 'legend style={legend pos=outer north east}':
+ \pgfkeysdef{/pgfplots/every axis legend/.append style}{\pgfkeysalso{##1}}%
+ %
+ \pgfplots@set@keys@from@tikz@style@and@handle@layer{every axis legend}%
+ %
+ % restore:
+ \pgfkeysdef{/pgfplots/every axis legend/.append style}{%
+ \pgfkeysalso{/pgfplots/every axis legend/.add code={}{\pgfkeysalso{##1}}}%
+ }%
+ \pgfkeysdeactivatefamily{/pgfplots/legend}%
+ %
+ % 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@and@handle@layer{every tick}%
+ \pgfplots@set@keys@from@tikz@style@and@handle@layer{every minor tick}%
+ \pgfplots@set@keys@from@tikz@style@and@handle@layer{every major tick}%
+ \pgfplots@set@keys@from@tikz@style@and@handle@layer{every axis grid}%
+ \pgfplots@set@keys@from@tikz@style@and@handle@layer{every minor grid}%
+ \pgfplots@set@keys@from@tikz@style@and@handle@layer{every major grid}%
+ \pgfkeysdeactivatefamily{/pgfplots/tick}%
+ %
+ %--------------------------------------------------
+ % \pgfkeysactivatefamily{/pgfplots}%
+ % \pgfplots@set@keys@from@tikz@style{every axis plot}%
+ % \pgfkeysdeactivatefamily{/pgfplots}%
+ %--------------------------------------------------
+ %
+ % 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@and@handle@layer{every x tick label}%
+ \pgfplots@set@keys@from@tikz@style@and@handle@layer{every y tick label}%
+ \pgfplots@set@keys@from@tikz@style@and@handle@layer{every tick label}%
+ \pgfkeysdeactivatefamily{/pgfplots/tick}%
+ %\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@deactivefamiliescmd}%
+ \expandafter
+ \pgfplots@set@keys@and@append@remaining@to@style
+ \expandafter
+ {\pgfplots@remaining@input}%
+ {every axis}%
+ \pgfplots@deactivefamiliescmd
+%\pgfkeysgetvalue{/pgfplots/every axis/.@cmd}\pgfplots@loc@TMPa
+%\message{every axis is now '\meaning\pgfplots@loc@TMPa'}%
+ %
+ \pgfkeysdeactivatefamily{/pgfplots/style commands}%
+ \global\pgfkeysgetvalue{/pgfplots/xmin}{\pgfplots@xmin}%
+ \global\pgfkeysgetvalue{/pgfplots/xmax}{\pgfplots@xmax}%
+ \global\pgfkeysgetvalue{/pgfplots/ymin}{\pgfplots@ymin}%
+ \global\pgfkeysgetvalue{/pgfplots/ymax}{\pgfplots@ymax}%
+ \global\pgfkeysgetvalue{/pgfplots/zmin}{\pgfplots@zmin}%
+ \global\pgfkeysgetvalue{/pgfplots/zmax}{\pgfplots@zmax}%
+ \pgfkeysgetvalue{/pgfplots/xtickmin}{\pgfplots@xtickmin}%
+ \pgfkeysgetvalue{/pgfplots/xtickmax}{\pgfplots@xtickmax}%
+ \pgfkeysgetvalue{/pgfplots/ytickmin}{\pgfplots@ytickmin}%
+ \pgfkeysgetvalue{/pgfplots/ytickmax}{\pgfplots@ytickmax}%
+ \pgfkeysgetvalue{/pgfplots/ztickmin}{\pgfplots@ztickmin}%
+ \pgfkeysgetvalue{/pgfplots/ztickmax}{\pgfplots@ztickmax}%
+ %
+ \pgfplots@init@collect@firstplotastick
+ \global\let\pgfplots@firstplot@coords@x=\pgfutil@empty
+ \global\let\pgfplots@firstplot@coords@y=\pgfutil@empty
+ \global\let\pgfplots@firstplot@coords@z=\pgfutil@empty
+ \pgfkeysalso{/pgfplots/.search also=/tikz}%
+ %
+ \pgfkeysifdefined{/tikz/on layer}{}{%
+ % make sure assignments 'on layer' in the /tikz/ prefix
+ % doesn't hurt.
+ % this may happen, for example with
+ % 'x grid style={on layer=...}'
+ % because 'x grid style' is not processed by the key filtering
+ % above (it is extracted later).
+ \pgfkeyslet{/tikz/on layer}\pgfutil@empty%
+ }%
+ %
+ \pgfplots@set@patched@options
+ %
+ \pgfplots@set@options@sanitize
+ \pgfplots@notify@options@are@set
+}
+
+\def\pgfplots@init@collect@firstplotastick{%
+ \def\pgfplots@loc@TMPa{data}%
+ \pgfplots@collect@firstplot@astickfalse
+ \ifx\pgfplots@xtick\pgfplots@loc@TMPa
+ \pgfplots@collect@firstplot@asticktrue
+ \fi
+ \ifx\pgfplots@ytick\pgfplots@loc@TMPa
+ \pgfplots@collect@firstplot@asticktrue
+ \fi
+ \ifx\pgfplots@ztick\pgfplots@loc@TMPa
+ \pgfplots@collect@firstplot@asticktrue
+ \fi
+ \pgfkeysgetvalue{/pgfplots/minor xtick}\pgfplots@loc@TMPb
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \pgfplots@collect@firstplot@asticktrue
+ \fi
+ \pgfkeysgetvalue{/pgfplots/minor ytick}\pgfplots@loc@TMPb
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \pgfplots@collect@firstplot@asticktrue
+ \fi
+ \pgfkeysgetvalue{/pgfplots/minor ztick}\pgfplots@loc@TMPb
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \pgfplots@collect@firstplot@asticktrue
+ \fi
+}%
+
+\def\pgfplots@set@options@of@layered@graphics{%
+ \ifpgfplots@axis@on@top
+ \ifpgfplots@layered@graphics
+ \pgfplots@log3{the combination of 'axis on top' and 'activate layers' implies 'set layers=axis on top'. Deactivate 'axis on top' if you want other layers.}%
+ \pgfplotsset{set layers=axis on top}%
+ \fi
+ \fi
+ % retrieve layer configurations (the one set with 'set layers*').
+ \pgfkeysgetvalue{/pgfplots/@set layers arg}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ % ah, yes: then set its style:
+ \pgfqkeys{/pgfplots/layers}{\pgfplots@loc@TMPa}% note that this here should not need key filtering; it adjusts only styles (hopefully ;) )
+ \fi
+}%
+
+\def\pgfplots@set@patched@options{%
+ \pgfkeysdef{/pgfplots/@@@tmp}{%
+ \let\tikz@intersect@def=\gdef
+ \pgfkeys{/tikz/name path={##1}}%
+ }%
+ \pgfkeysgetvalue{/pgfplots/@@@tmp/.@cmd}\pgfplots@name@path@global@cmd@pgf@two@ten
+ %
+ \pgfkeysifdefined{/tikz/name path/.@cmd}{%
+ % 'name path' does not work inside of a pgfplots axis because
+ % pgfplots unnecessarily introduces extra \scopes around each path :-/
+ % it needs to be 'name path global'.
+ % PATCH IT:
+ \pgfkeysgetvalue{/tikz/name path global/.@cmd}\pgfplots@loc@TMPa%
+ \ifx\pgfplots@loc@TMPa\pgfplots@name@path@global@cmd@pgf@two@ten
+ % ah - we operate against PGF 2.10 . In this case, we must
+ % not indirect from 'name path' to 'name path global' - would lead to
+ % an indefinite loop.
+ % Patch absolutely:
+ \pgfkeysgetvalue{/tikz/name path/.@cmd}\pgfplots@name@path@cmd@pgf@two@ten%
+ \pgfkeysdef{/tikz/name path}{%
+ % see the value of
+ % \pgfplots@name@path@global@cmd@pgf@two@ten to verify
+ % this patch:
+ \let\tikz@intersect@def=\gdef
+ \pgfplots@name@path@cmd@pgf@two@ten{##1}\pgfeov
+ }%
+ \else
+ \pgfkeysdef{/tikz/name path}{\pgfkeysalso{/tikz/name path global={##1}}}%
+ \fi
+ }{%
+ \pgfkeysdef{/tikz/name path}{\pgfplots@error{'name path' is undefined. Please load \string\usetikzlibrary{intersections} or \string\usepgfplotslibrary{fillbetween}}}%
+ }%
+}
+
+% EMPTY. This will be overridden by tex-engine specific code.
+% At the time of this writing, the latex driver will check for xcolor
+% configuration options and will override
+% mesh/colorspace explicit color output
+% and
+% colormap default colorspace
+% if needed.
+\def\pgfplots@check@global@colorspace@overrides{%
+}%
+
+\def\pgfplots@add@named@child@node#1{%
+ \xdef\pgfplots@named@child@node@list{\pgfplots@named@child@node@list,{#1}}%
+}%
+
+\def\pgfplots@notify@options@are@set{}%
+
+\def\pgfplots@install@abbrev@commands{
+ \let\pgfplots@orig@path=\path
+ \let\pgfplots@orig@plot=\plot
+ %
+ \let\axispath=\pgfplots@path
+ \let\pgfplotsinterruptdatabb=\pgfplots@interruptdatabb
+ \let\endpgfplotsinterruptdatabb=\endpgfplots@interruptdatabb
+ %
+ \let\addplot=\pgfplots@addplot
+ \let\plot=\addplot
+ %
+ %
+ \def\logten{2.3025851}%
+ \def\reciproclogten{0.434294}%
+ %
+ \def\logi##1{%
+ \ifcase##1
+ \or0
+ \or0.693147
+ \or1.098612
+ \or1.386294
+ \or1.60943791
+ \or1.7917594
+ \or1.94591014
+ \or2.07944154
+ \or2.197224
+ \fi
+ }%
+ \def\axisdefaultticklabel{\pgfplots@ticklabel@typeset@arg{\pgfmathprintnumber{\tick}}}%
+ \def\axisdefaultticklabellog{%
+ \pgfplots@ticklabel@typeset@arg{%
+ \pgfkeysgetvalue{/pgfplots/log number format code/.@cmd}\pgfplots@log@label@style
+ \expandafter\pgfplots@log@label@style\tick\pgfeov
+ }%
+ }%
+ %
+ \let\legend=\pgfplots@command@legend
+ \let\addlegendimage=\pgfplots@addlegendimage
+ \let\addlegendentry=\pgfplots@addlegendentry
+ \let\addlegendentryexpanded=\pgfplots@addlegendentryexpanded
+}
+
+\let\pgfplots@late@options=\pgfutil@empty
+\def\pgfplotssetlateoptions#1{%
+ \pgfplotsset{#1}%
+}%
+\def\pgfplotssetlateoptions@late#1{%
+ \t@pgfplots@toka=\expandafter{\pgfplots@late@options}%
+ \t@pgfplots@tokb={#1}%
+ \xdef\pgfplots@late@options{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}%
+}%
+
+\def\pgfplots@environment{%
+ \pgfutil@ifnextchar[{%
+ \pgfplots@environment@opt
+ }{%
+ \pgfplots@environment@opt[]%
+ }%
+}%
+
+% temporary (local) variables inside of axis
+\newif\ifpgfplots@autocompute@all@limits
+\newif\ifpgfplots@autocompute@xmin
+\newif\ifpgfplots@autocompute@xmax
+\newif\ifpgfplots@autocompute@ymin
+\newif\ifpgfplots@autocompute@ymax
+\newif\ifpgfplots@autocompute@zmin
+\newif\ifpgfplots@autocompute@zmax
+\newif\ifpgfplots@apply@datatrafo@x
+\newif\ifpgfplots@apply@datatrafo@y
+\newif\ifpgfplots@apply@datatrafo@z
+\newif\ifpgfplots@apply@datatrafo
+\newif\ifpgfplots@datascaletrafo@initialised
+
+% Extracts single components of an entry of
+% \pgfplots@stored@plotlist
+%
+% They are defined as
+% \pgfplots@stored@current@precmd
+% \pgfplots@stored@current@cmd
+% \pgfplots@stored@current@data
+% \pgfplots@stored@current@postcmd
+\long\def\pgfplots@stored@plotlist@EXTRACTENTRY#1#2#3#4{%
+ % the token register stuff allows '#' inside of arguments.
+ \t@pgfplots@tokc={#1}%
+ \edef\pgfplots@stored@current@precmd{\the\t@pgfplots@tokc}%
+ %
+ \t@pgfplots@tokc={#2}%
+ \edef\pgfplots@stored@current@cmd{\the\t@pgfplots@tokc}%
+ %
+ \def\pgfplots@stored@current@data{#3}%
+ %
+ \t@pgfplots@tokc={#4}%
+ \edef\pgfplots@stored@current@postcmd{\the\t@pgfplots@tokc}%
+ %
+}
+
+\def\pgfplots@init@cleared@structures{%
+ \global\pgfplotslistnewempty\pgfplots@plotspeclist
+ \global\pgfplotslistnewempty\pgfplots@legend
+ \global\pgfplotslistnewempty\pgfplots@stored@plotlist
+ \global\pgfplots@numplots=0
+ \let\pgfplots@already@computed@legend@node=\pgfutil@empty
+}
+
+% Takes a plot style and exports it to a self-contained drawing
+% command which can be used outside of the current context.
+%
+% This macro is used inside for \label{} / \ref{}; it tries to be
+% reasonable smart about restoring relevant flags stored in a pgfplots
+% axis. If it forgets something... well, it is not too smart.
+%
+% #1: the style to export.
+% #2: either empty or the fully qualified name of a code key. If #2 is not empty,
+% the current value of the code key is remembered. It will be restored
+% just before the exported \tikz statement is invoked, and \tikz[#2]
+% will be called. The code key should not rely on any arguments (it
+% won't be given any)
+%
+% The exported routine autodetects whether the result is used inside of
+% a picture. In that case, the '#2' style will be set inside of a
+% scope instead of \tikz[#2].
+%
+% Assembles a macro \pgfplotsretval which, upon execution, draws the
+% plot style.
+%
+% As a side effect, it returns the resulting plot style (nothing else) into
+% \pgfplotsretvalb
+\def\pgfplots@export@legend@image@to@macro#1#2{%
+ \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. How shall I do that?
+ % I can't handle every option separately... !?
+ \pgfkeysinstallkeyfilter
+ {/pgf/key filters/and}
+ {{/pgf/key filters/is descendant of=/pgfplots}%
+ {/pgf/key filters/defined}}%
+ \def\pgfplots@label@tikzopts{}%
+ \pgfkeysinstallkeyfilterhandler{/pgf/key filter handlers/append filtered to}{\pgfplots@label@tikzopts}%
+ % FIXME : this fails if 'error bars/.cd,/pgfplots/.cd' is used inside of #1 --
+ % the second /pgfplots/.cd will be applied, but the error bars
+ % command not
+ \pgfqkeysfiltered{/tikz}{#1}%
+ %
+ \pgfkeysgetvalue{/pgfplots/legend image code/.@cmd}{\pgfplots@curlegendcode}%
+ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
+ \toks0=\expandafter{\pgfplots@curlegendcode\pgfeov}%
+ \toks1=\expandafter{\pgfplots@label@tikzopts}%
+ \toks3=\expandafter{\pgfplots@basiclevel@plothandler}%
+ \def\pgfplots@stylekey{#2}%
+ \ifx\pgfplots@stylekey\pgfutil@empty
+ \else
+ \pgfkeysgetvalue{\pgfplots@stylekey/.@cmd}{\pgfplots@stylekey@}%
+ \toks4=\expandafter{\pgfplots@stylekey@\pgfeov}%
+ \fi
+ \edef\pgfplots@loc@TMPa{%
+ {%
+ \ifx\pgfplots@stylekey\pgfutil@empty
+ \else
+ \noexpand\scope[#2]%
+ \fi
+ %
+ \noexpand\pgfplots@draw@image
+ %
+ \ifx\pgfplots@stylekey\pgfutil@empty
+ \else
+ \noexpand\endscope%
+ \fi
+ }{%
+ \noexpand\tikz[#2]{%
+ \noexpand\pgfplots@draw@image
+ }%
+ }%
+ }%
+ \expandafter\pgfplots@assemble@ref@picture\pgfplots@loc@TMPa
+ \toks5=\expandafter{\pgfplotsretval}%
+ \pgfkeysgetvalue{/pgfplots/every legend image post/.@cmd}\pgfplots@legend@image@post
+ \toks6=\expandafter{\pgfplots@legend@image@post\pgfeov}%
+ %
+ \edef\pgfplotsretval{%
+ \noexpand\begingroup
+ \noexpand\def\noexpand\pgfplots@draw@image{%
+ \noexpand\def\noexpand\tikz@plot@handler{\the\toks3}%
+ \noexpand\pgfkeysdef{/pgfplots/legend image code}{\the\toks0}%
+ \noexpand\pgfkeysdef{/pgfplots/every legend image post}{\the\toks6 }%
+ \noexpand\pgfkeyssetvalue{/pgfplots/mark list fill}{\pgfkeysvalueof{/pgfplots/mark list fill}}%
+ \ifx\pgfplots@stylekey\pgfutil@empty
+ \else
+ \noexpand\pgfkeysdef{#2}{\the\toks4}%
+ \fi
+ \noexpand\pgfplots@show@small@legendplots{\the\toks1}{}%
+ }%
+ \the\toks5
+ \noexpand\endgroup%
+ }%
+ \xdef\pgfplots@glob@TMPa{\the\toks1}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ \let\pgfplotsretvalb=\pgfplots@glob@TMPa
+}%
+
+% 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{%
+ \pgfutil@ifnextchar<{%
+ \pgfplots@plot@label@beamer@mode
+ }{%
+ \pgfutil@ifnextchar[{\pgfplots@plot@label@{}}{\pgfplots@plot@label@{}[]}%
+ }%
+}%
+\def\pgfplots@plot@label@beamer@mode<#1>{
+ \pgfutil@ifnextchar[{\pgfplots@plot@label@{<#1>}}{\pgfplots@plot@label@{<#1>}[]}%
+}
+% #1: optional prefix options, used to support
+% \label<...>{<name>} of beamer package
+\def\pgfplots@plot@label@#1[#2]#3{%
+ \ifpgfplots@has@label@information
+ \begingroup
+ \expandafter\let\expandafter\pgfplots@loc@TMPb\csname pgfplots@last@plot@style@#2\endcsname
+ \expandafter\pgfplots@export@legend@image@to@macro\expandafter{\pgfplots@loc@TMPb}{/pgfplots/every crossref picture}%
+ %
+ \t@pgfplots@toka=\expandafter{\pgfplotsretval}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsretvalb}%
+ % 1. prepare /pgfplots/refstyle={#3}:
+ \pgfplots@auxwrite{%
+ \noexpand\expandafter\noexpand\gdef
+ \noexpand\csname pgfplots@labelstyle@#3\noexpand\endcsname{\the\t@pgfplots@tokb}%
+ }%
+ % 2. prepare \ref{#3} and \pageref{#3}:
+ %
+ % There are several nasty things to consider:
+ % a) macro expansion. Use \string to allow a safe \write
+ % operation.
+ %
+ % 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{#3}. Write it into
+ % the .aux file:
+ \pgfplots@auxwrite{%
+ \noexpand\expandafter\noexpand\gdef
+ \noexpand\csname pgfplots@show@ref@#3\noexpand\endcsname{%
+ \the\t@pgfplots@toka
+ }%
+ }%
+ % create the \label command:
+ \let\label=\pgfplots@original@LaTeX@label
+ \pgfplots@label[#1]{#3}{pgfplots@show@ref@}%
+ \endgroup
+ \else
+ \pgfplots@error{Can't create \string\label{#3}: it needs to be called after \string\addplot.}%
+ \fi
+}%
+
+
+\def\pgfplots@interruptdatabb{\pgfplots@bb@isactivefalse}
+\def\endpgfplots@interruptdatabb{\pgfplots@bb@isactivetrue}
+
+\def\pgfplots@search@also@tikz{%
+ % 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}%
+ }%
+}%
+
+% 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}{%
+ \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
+ %
+ \pgfkeysdef{/pgfplots/colorbar source}{}% make it NO-OP here. It has already been processed.
+ %
+ \pgfplots@install@local@bar@handlers% see its docs.
+ %
+ % set both, pgfplots and tikz keys:
+ % the draw is important since \addplot visualizes its stuff
+ % with \path coordinates ...
+ % -> we need to activate draw mode here.
+ \pgfplotsset{/tikz/draw,#1}%
+ \pgfplots@invoke@pgfkeyscode{/handler config/all/.@cmd}{}% unrestrict
+ %
+ % 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.
+ \pgfplots@every@addplot@path@prepare%
+ %
+ \pgfplots@markers@check@for@default@plot@mark%
+ %
+ %
+ % 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={%
+ % FIXME : is that portable!?
+ \pgfplots@every@addplot@path
+ \pgfplots@every@addplot@firstpath
+ \let\pgfplots@every@addplot@firstpath=\pgfutil@empty
+ }%
+ }%
+ }%
+}%
+
+\def\pgfplots@every@addplot@path{}
+\def\pgfplots@every@addplot@firstpath{}
+
+\def\pgfplots@every@addplot@path@prepare{%
+ \let\pgfplots@every@addplot@path=\pgfutil@empty
+ \let\pgfplots@every@addplot@firstpath=\pgfutil@empty
+ %
+ % remember these technical things: they will be
+ % reset in \path (see below!), so we will need to re-activate
+ % them.
+ % The re-activation is done in 'every path'.
+ \pgfplots@assert@tikzinternal@exists{tikz@options}%
+ \pgfplots@assert@tikzinternal@exists{tikz@mode}%
+ \let\pgfplots@drawoptions=\tikz@options
+ \let\pgfplots@drawmodes=\tikz@mode
+ \pgfplots@everypath@prepare@append{\pgfplots@every@addplot@path}{\pgfplots@restore@drawmodes}%
+ %
+ \iftikz@decoratepath
+ \pgfplots@everypath@prepare@append{\pgfplots@every@addplot@firstpath}{\tikz@decoratepathtrue}%
+ \fi
+ \pgfplots@everypath@prepare@append@macrorestore{\pgfplots@every@addplot@firstpath}\tikz@preactions
+ \pgfplots@everypath@prepare@append@macrorestore{\pgfplots@every@addplot@firstpath}\tikz@postactions
+}%
+\long\def\pgfplots@everypath@prepare@append#1#2{%
+ \t@pgfplots@toka=\expandafter{#1}%
+ \t@pgfplots@tokb={#2}%
+ \edef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+}%
+\long\def\pgfplots@everypath@prepare@append@macrorestore#1#2{%
+ \t@pgfplots@toka=\expandafter{#1}%
+ \t@pgfplots@tokb=\expandafter{#2}%
+ \edef#1{%
+ \the\t@pgfplots@toka
+ \noexpand\def\noexpand#2{\the\t@pgfplots@tokb}%
+ }%
+}%
+
+
+\newif\ifpgfplots@drawmodes@append
+
+\def\pgfplots@restore@drawmodes{%
+ \pgfutil@ifundefined{pgfplots@drawmodes}%
+ {\relax}%
+ {%
+ \ifpgfplots@drawmodes@append
+ \t@pgfplots@toka=\expandafter{\tikz@mode}%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@drawmodes}%
+ \edef\tikz@mode{\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
+ \else
+ \let\tikz@mode=\pgfplots@drawmodes
+ \fi
+% \let\tikz@options=\pgfplots@drawoptions
+ }%
+}%
+
+% Callback if the LUA backend does not support a sub-operation. The
+% reason will be logged.
+\def\pgfplots@LUA@backend@failed{%
+ \ifpgfplots@LUA@fail@on@TeX@fallback
+ \pgfplots@error{lua backend has been deactivated since some input option is unsupported and 'lua debug=compileerror' is active. Please see the most recent message in your .log file for details}%
+ \fi
+}%
+
+\def\pgfplots@LUA@visualizationlog@deactivation#1{%
+ \pgfplots@log{\pgfplots@LUA@loglevel@info}{Using 'lua backend=false' for axis: #1.}%
+ \pgfplots@LUA@backend@failed
+}%
+\def\pgfplots@prepare@LUA@api{%
+ \ifpgfplots@LUA@backend@supported
+ \ifpgfplots@LUA@supported
+ \else
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ %
+ \ifpgfplots@stackedmode
+ \pgfplots@LUA@visualizationlog@deactivation{stacked plots unsupported (yet)}%
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ %
+ \ifpgfplots@xislinear\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@visualizationlog@deactivation{xmode=log unsupported (yet)}\fi
+ \ifpgfplots@yislinear\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@visualizationlog@deactivation{ymode=log unsupported (yet)}\fi
+ \ifpgfplots@zislinear\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@visualizationlog@deactivation{zmode=log unsupported (yet)}\fi
+ %
+ \pgfkeysgetvalue{/pgfplots/x coord trafo/.@cmd}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@visualizationlog@deactivation{x coord trafo unsupported}\fi
+ \pgfkeysgetvalue{/pgfplots/y coord trafo/.@cmd}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@visualizationlog@deactivation{x coord trafo unsupported}\fi
+ \pgfkeysgetvalue{/pgfplots/z coord trafo/.@cmd}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@visualizationlog@deactivation{x coord trafo unsupported}\fi
+ %
+ % FIXME: collect all remaining items
+ %
+ \ifpgfplots@LUA@backend@supported
+ \pgfplots@log{\pgfplots@LUA@loglevel@debug}{lua backend=true: Activating LUA backend for axis.}%
+ \pgfplotsutil@directlua{%
+ pgfplots.gca = pgfplots.Axis.new();
+ pgfplots.gca.is3d = \pgfplots@boolval{pgfplots@threedim};
+ pgfplots.gca.clipLimits = {
+ \pgfplots@boolval{pgfplots@clip@limits@x},
+ \pgfplots@boolval{pgfplots@clip@limits@y},
+ \pgfplots@boolval{pgfplots@clip@limits@z} };
+ pgfplots.gca.autocomputeAllLimits = \pgfplots@boolval{pgfplots@autocompute@all@limits};
+ pgfplots.gca.autocomputeMin = {
+ \pgfplots@boolval{pgfplots@autocompute@xmin},
+ \pgfplots@boolval{pgfplots@autocompute@ymin},
+ \pgfplots@boolval{pgfplots@autocompute@zmin} };
+ pgfplots.gca.autocomputeMax = {
+ \pgfplots@boolval{pgfplots@autocompute@xmax},
+ \pgfplots@boolval{pgfplots@autocompute@ymax},
+ \pgfplots@boolval{pgfplots@autocompute@zmax} };
+ % attention: min/max is (also) handed over in \pgfplots@LUA@survey@start
+ }%
+ \fi
+ \fi
+}%
+
+\long\def\pgfplotsifissurveyphase#1#2{%
+ \if\pgfplots@phase@name s%
+ #1\relax
+ \else
+ #2\relax
+ \fi
+}%
+\long\def\pgfplotsifisvisualizationphase#1#2{\pgfplotsifissurveyphase{#2}{#1}}
+\def\pgfplots@phase@name{X}
+
+% Invokes #1 if the statement occurs within \begin{axis}...\end{axis}
+% and #2 if not.
+\long\def\pgfplotsifinaxis#1#2{%
+ \pgfutil@ifundefined{pgfplots@is@in@axis}{#2}{#1}%
+}%
+
+%
+% \begin{axis}[#1] :
+%
+% This command prepares the axis for collection. NOTHING will be drawn
+% until \end{axis}. During the collect phase, axis limits will be
+% computed.
+%
+% The following variables are accummulated between
+% \begin{axis}
+% and
+% \end{axis}:
+%
+% - \pgfplots@[xyz]min
+% \pgfplots@[xyz]max
+% - These denote the axis limits.
+% - They are always assigned globally.
+% - For linear axes, they will be computed in floating point.
+% - For log axes, they will be computed using pgf math engine.
+% - \pgfplots@[xyz]min@reg
+% - A register containing the value of macro \pgfplots@[xyz]min
+% in pt. It is only valid during \end{axis}.
+% - \pgfplots@[xyz]max@reg
+% - 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
+% \pgfplots@data@[xyz]max
+% - DATA limits. These limits are not affected by limit
+% restrictions
+% - They are used to initialise the data scaling trafo.
+% - They WON'T be assigned for log axes.
+% - Assigned globally.
+% - \pgfplots@[xyz]min@unscaled@as@float
+% - Assigned during \end{axis} (local variables).
+% - Contain the value of axis limits as floating point numbers
+% 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, 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@colorbar@src@metamin
+% - \pgfplots@colorbar@src@metamax
+% - these keys are usually empty, unless one provides the
+% 'colorbar source' key for an \addplot command. In that case,
+% they will be filled (globally) with the point meta min/max
+% ranges of that particular plot. The colorbar will use the
+% result for its ranges.
+% - \pgfplots@numplots
+% - A count register indexing the current plot counter. Assigned
+% globally.
+% - \ifpgfplots@apply@datatrafo
+% A boolean which indicates whether any scaling trafo is
+% active.
+% - \ifpgfplots@apply@datatrafo@[xyz]
+% Booleans indicating whether for which axes the scaling trafo
+% is active.
+% - \pgfplots@stored@plotlist
+% - An instance of pgfplotslist.
+% - It is assigned globally.
+% - Every \addplot or tikz path command is collected into this
+% structure.
+% - The element type is a compound object containing everything
+% needed to process the plot during \end{axis}.
+% - \pgfplots@plotspeclist
+% - instance of pgfplotslist
+% - collects every line specification for \addplot.
+% - Used to assemble legends.
+% - Assigned globally.
+% - \pgfplots@legend
+% - instance of pgfplotslist
+% - collects every legend entry.
+% - Used to assemble legends.
+% - Assigned globally.
+% - \pgfplots@data@scale@trafo@SHIFT@[xyz]
+% \pgfplots@data@scale@trafo@EXPONENT@[xyz]
+% - For any direction for which the scaling trafo is active,
+% these macros contain the two parameters for the affine scaling
+% trafo.
+% - \pgfplots@firstplot@coords@[xyz]
+% - A macro containing a comma separated list
+% - It is collected if and only if [xyz]tick = 'data'.
+% - Contains a list of coordinates in floating point
+% representation if the axis is linear.
+% - The coordinates are in pgf math notation for log axes.
+% - Assigned globally.
+% - \pgfplots@[xyz]@veclength
+% - A macro containing the vector length of the [xyz] unit
+% vector.
+% - Assigned in \end{axis}
+% - \pgfplots@[xyz]@inverseveclength
+% - A macro containing the INVERSE vector length of the [xyz]
+% unit vector.
+% - Assigned in \end{axis}
+% - \pgfplotspoint[xyz]axis
+% - A macro which sets 'pgf@x' and 'pgf@y' to the [xyz] axis.
+% - \pgfplotspoint[xyz]axislength
+% - A macro containing the vector length of the [xyz] axis
+% (including the 'pt' suffix).
+%
+% - \ifpgfplots@curplot@threedim
+% - valid during an '\addplot' preparation step.
+% - \ifpgfplots@threedim
+% - whether the axis shall be threedimensional.
+%
+% - \pgfplots@currentplot@firstcoord@[xyz]
+% - \pgfplots@currentplot@lastcoord@[xyz]
+% - contains the first/last coordinate of the current plot.
+% - assigned globally.
+% - \ifpgfplots@coord@stream@isfirst
+% - assigned globally during \addplot.
+% - \pgfplotssurveyphase@setactiveplothandlers
+% A macro which is used to implement '\numplotsofactualtype'
+% see \pgfplots@countplots@advance for details.
+%
+%
+%
+\def\pgfplots@environment@opt[#1]{%
+ \begingroup
+ \pgfplots@define@dummies@for@pseudoconstants
+ \pgfplotsifinaxis{%
+ \pgfplots@error{%
+ Sorry, nested axis environments are not supported.
+ Please move the inner axis environment below \string\end{axis} and
+ use alignment options (for example named nodes, see manual) to place it at the desired
+ position}%
+ }{}%
+ \def\pgfplots@is@in@axis{1}%
+ \pgfplots@environment@opt@@setup@pgfpoint@restores
+ %
+ \pgfplots@checkandpreparefor@active@semicolon
+ %
+ \pgfplots@install@abbrev@commands
+ \pgfplots@stacked@initialise
+ \pgfplotsplothandlers@init
+ %
+ %
+ % The explicit specification of 'x' and 'y' as 1pt is to avoid
+ % numeric overflow/underflow during scale computations:
+ %
+ % The scaling (i.e. proper values for 'x' and 'y') will be
+ % determined later-on, dependend on the axis limits. Since axis
+ % limits are implicitly in units of 1pt, it is reasonable to use
+ % '1pt' here as well.
+ \pgfsetxvec{\pgfqpoint{1pt}{0pt}}%
+ \pgfsetyvec{\pgfqpoint{0pt}{1pt}}%
+ \pgfsetzvec{\pgfqpoint{0pt}{0pt}}%
+ %
+ \pgfplots@set@options{#1}%
+ \global\let\pgfplots@late@options=\pgfutil@empty
+ \let\pgfplotssetlateoptions=\pgfplotssetlateoptions@late
+ %
+ %
+ %
+ % --------------------
+ % Allocations:
+ % --------------------
+ \pgfplots@init@cleared@structures
+ %
+ % --------------------
+ % Option preprocessing
+ % --------------------
+ \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
+ \pgfplots@datascaletrafo@initialisedtrue% there is no trafo.
+ \fi
+ %
+ \pgfplotsutilforeachcommasep{x,y,z}\as\pgfplots@loc@TMPa{%
+ \pgfplotscoordmath \pgfplots@loc@TMPa{min limit}%
+ \expandafter\let\csname pgfplots@invalidrange@\pgfplots@loc@TMPa max\endcsname=\pgfmathresult
+ \pgfplotscoordmath \pgfplots@loc@TMPa{max limit}%
+ \expandafter\let\csname pgfplots@invalidrange@\pgfplots@loc@TMPa min\endcsname=\pgfmathresult
+ }%
+ %
+ \pgfplotscoordmath{meta}{max limit}%
+ \let\pgfplots@invalidrange@metamin=\pgfmathresult
+ \pgfplotscoordmath{meta}{min limit}%
+ \let\pgfplots@invalidrange@metamax=\pgfmathresult
+ %
+ % These numbers will ONLY be filled for linear axis!
+ \global\let\pgfplots@data@xmin=\pgfplots@invalidrange@xmin
+ \global\let\pgfplots@data@xmax=\pgfplots@invalidrange@xmax
+ \global\let\pgfplots@data@ymin=\pgfplots@invalidrange@ymin
+ \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
+ \global\let\pgfplots@colorbar@src@metamin=\pgfutil@empty
+ \global\let\pgfplots@colorbar@src@metamax=\pgfutil@empty
+ %
+ \pgfplots@autocompute@all@limitstrue
+ \ifx\pgfplots@xmin\pgfutil@empty
+ \pgfplots@autocompute@xmintrue
+ \global\let\pgfplots@xmin=\pgfplots@invalidrange@xmin
+ \else
+ \pgfplots@autocompute@all@limitsfalse
+ \fi
+ \ifx\pgfplots@xmax\pgfutil@empty
+ \pgfplots@autocompute@xmaxtrue
+ \global\let\pgfplots@xmax=\pgfplots@invalidrange@xmax
+ \else
+ \pgfplots@autocompute@all@limitsfalse
+ \fi
+ \ifx\pgfplots@ymin\pgfutil@empty
+ \pgfplots@autocompute@ymintrue
+ \global\let\pgfplots@ymin=\pgfplots@invalidrange@ymin
+ \else
+ \pgfplots@autocompute@all@limitsfalse
+ \fi
+ \ifx\pgfplots@ymax\pgfutil@empty
+ \pgfplots@autocompute@ymaxtrue
+ \global\let\pgfplots@ymax=\pgfplots@invalidrange@ymax
+ \else
+ \pgfplots@autocompute@all@limitsfalse
+ \fi
+ \ifx\pgfplots@zmin\pgfutil@empty
+ \pgfplots@autocompute@zmintrue
+ \global\let\pgfplots@zmin=\pgfplots@invalidrange@zmin
+ \else
+ \global\pgfplots@threedimtrue
+ \pgfplots@autocompute@all@limitsfalse
+ \fi
+ \ifx\pgfplots@zmax\pgfutil@empty
+ \pgfplots@autocompute@zmaxtrue
+ \global\let\pgfplots@zmax=\pgfplots@invalidrange@zmax
+ \else
+ \global\pgfplots@threedimtrue
+ \pgfplots@autocompute@all@limitsfalse
+ \fi
+ %
+ \pgfutil@IfUndefined{pgfmathdeclarefunction}{%
+ % SKIP: \pgfmathdeclarefunction is unavailable in pgf 2.00 .
+ % UPGRADE TO PGF 2.10 to use these math functions.
+ }{%
+ \pgfplots@declare@mathfunctions
+ }%
+ %
+ % 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}%
+ \pgfplotscoordmath{meta}{parsenumber}{\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}%
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@loc@TMPa}%
+ \global\let\pgfplots@axiswide@metamax=\pgfmathresult
+ \fi
+ %
+ % --------------------
+ % Start axis:
+ % start survey phase!
+ % --------------------
+ %
+ \ifpgfplots@stackedmode
+ \else
+ % we have no stacked plots and thus no reversing.
+ \pgfplots@stacked@reversefalse
+ \fi
+ %
+ \pgfutil@IfUndefined{label}{\relax}{%
+ \let\pgfplots@original@LaTeX@label=\label
+ \let\label=\pgfplots@plot@label
+ }%
+ %
+ \global\pgfplots@has@label@informationfalse
+ %
+ \def\numplots{\the\pgfplots@numplots}%
+ \global\let\pgfplotssurveyphase@setactiveplothandlers=\pgfutil@empty
+ \let\numplotsofactualtype=\pgfplots@numplotsofactualtype
+ %
+ % any \path command is invalid inside of an axis.
+ % Use \axispath instead:
+ \let\path=\pgfplots@replacement@for@tikz@path
+ \let\closedcycle=\pgfplots@path@closed@cycle
+ %
+ % defines \pgfplotsaxisupdatelimitsforcoordinate etc.
+ \pgfplots@prepare@axis@API
+ \pgfplots@prepare@LUA@api
+ \pgfkeysvalueof{/pgfplots/execute at begin axis}%
+ \pgfkeysvalueof{/pgfplots/execute at begin axis@@}%
+ \def\pgfplots@phase@name{s}%
+ %
+ \pgfplots@replace@path@commands
+ %
+ % allow layer changes within the environment; reset:
+ \pgfkeyslet{/pgfplots/on layer}\pgfutil@empty
+}
+
+% #1 if and only if the limits are already ready (sanitized to bounded
+% values and transformed)
+\def\pgfplots@set@options@after@survey#1{%
+ \def\pgfplots@set@options@after@survey@@##1{%
+ \edef\pgfmathresult{\csname pgfplots@##1min\endcsname}%
+ \if1#1%
+ \pgfplotscoordmath{##1}{datascaletrafo inverse}{\pgfmathresult}%
+ \pgfplotscoordmath{##1}{tofixed}{\pgfmathresult}%
+ \else
+ % might be unbounded...
+ \pgfplotscoordmath{##1}{tostring}{\pgfmathresult}%
+ \fi
+ \pgfkeyslet{/pgfplots/##1min}\pgfmathresult
+ %
+ \edef\pgfmathresult{\csname pgfplots@##1max\endcsname}%
+ \if1#1%
+ \pgfplotscoordmath{##1}{datascaletrafo inverse}{\pgfmathresult}%
+ \pgfplotscoordmath{##1}{tofixed}{\pgfmathresult}%
+ \else
+ % might be unbounded...
+ \pgfplotscoordmath{##1}{tostring}{\pgfmathresult}%
+ \fi
+ \pgfkeyslet{/pgfplots/##1max}\pgfmathresult
+ }%
+ \pgfplots@set@options@after@survey@@ x%
+ \pgfplots@set@options@after@survey@@ y%
+ \ifpgfplots@threedim
+ \pgfplots@set@options@after@survey@@ z%
+ \fi
+ %
+ \pgfkeyslet{/pgfplots/point meta min}{\pgfplots@axiswide@metamin}%
+ \pgfkeyslet{/pgfplots/point meta max}{\pgfplots@axiswide@metamax}%
+}%
+
+% \end{axis} :
+%
+% This command actually takes all collected (global) variables,
+% creates an axis and performs all postponed drawing operations.
+\def\endpgfplots@environment@opt{%
+ \def\pgfplots@phase@name{v}%
+ \pgfutil@IfUndefined{label}{\relax}{%
+ % restore.
+ \let\label=\pgfplots@original@LaTeX@label
+ }%
+ \xdef\numplots{\the\pgfplots@numplots}%
+ \pgfkeysvalueof{/pgfplots/before end axis/.@cmd}\pgfeov%
+ \pgfkeysvalueof{/pgfplots/execute at end axis}%
+ \pgfkeysvalueof{/pgfplots/execute at end axis@@}%
+ %
+ \pgfplots@restore@path@commands
+ %
+ \pgfplotssurveyphase@setactiveplothandlers
+ %
+ \pgfplots@set@options@after@survey0%
+ \expandafter\pgfplotsset\expandafter{\pgfplots@late@options}%
+ %
+ \pgfplots@prepare@layered@graphics
+ %
+ \pgfplots@prepare@cell@picture
+ %
+ %\end{axis}:
+ %
+ % --------------------
+ % All plotting commands have been read.
+ % -> apply postponed drawing commands!
+ % --------------------
+ \pgfplots@determinedefaultvalues
+ \pgfplots@BEGIN@cell@picture[/pgfplots/every axis]%
+ \pgfplots@BEGIN@init@and@draw@axis
+ %
+ % replace some of tikz's paths (like ellipse and path): make them
+ % aware of any transformations:
+ \pgfplots@install@path@replacements
+ %
+ \pgfplots@stacked@initialise
+ \pgfplots@markers@visphase@after@axis@prepare
+ \ifpgfplots@stacked@reverse
+ % This here applies any scaling trafos and assembles a
+ % NEW \pgfplots@stored@plotlist!
+ \pgfplots@stacked@finalize@stored@plots
+ \fi
+ %
+ % ensure that (1,2) is automatically converted to (axis cs:1,2) :
+ \pgfplots@change@pgfpoints@to@axiscs
+ %
+ \ifpgfplots@LUA@backend@supported
+ \pgfplots@LUA@visualization@update@axis
+ \fi
+ %
+ % make it ungrouped: we must not destroy group nesting of tikz
+ % path instructions at this point.
+ \pgfplotslistforeachungrouped\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{%
+ \expandafter\pgfplots@stored@plotlist@EXTRACTENTRY\pgfplots@loc@TMPa
+%\message{^^JProcessing stored plot with precommand '\meaning\pgfplots@stored@current@precmd';^^J pgfplots@plotcmd '\meaning\pgfplots@stored@current@cmd'^^J postcommand '\meaning\pgfplots@stored@current@postcmd'^^J}%
+%\message{DATA: '\meaning\pgfplots@stored@current@data';^^J}%
+ % 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
+ % Ah: some \pgfplotsextra command like \draw,\path,
+ % \node or even \scope or \endscope.
+ %
+ % do NOT call \pgfplotsonlayer here! We MUST NOT
+ % destroy grouping levels here.
+ \pgfplots@stored@current@data%
+ \else
+ %
+ % this code here means we REALLY have a plotting
+ % command!
+ % This is the heart component of the visualization
+ % phase.
+ \pgfplots@stored@plotlist@visualize@selected@phases{\pgfplots@visphase@names}%
+ \fi
+ \pgfplots@stored@current@postcmd
+ }%
+ \pgfplots@restorepgfpoint
+ %
+ %
+ \pgfplots@END@init@and@draw@axis
+ %
+ \pgfplots@create@axis@descriptions
+ %
+ % this here does \endtikzpicture\endpgfinterruptpicture
+ % (and stores sizes):
+ \pgfplots@END@cell@picture
+ %
+ \let\tikz@fig@name=\pgfplots@fig@name
+ \tikz@fig@mustbenamed
+ %
+ \edef\pgfplots@shapename{pgfplots@low@level@shape\ifpgfplots@deprecated@anchors @deprecated\fi}%
+ \pgfutil@IfUndefined{pgf@anchor@\pgfplots@shapename @\pgfplots@anchorname}{%
+ % Oh. Well, suppose \pgfplots@anchorname is associated to an
+ % INNER node.
+ \def\pgfplots@loc@TMPa##1{%
+ \pgftransformshift{%
+ % So far, the inner node's position has not been
+ % corrected (that happens in
+ % \pgfplots@finally@correct@child@node@positions).
+ % Do that here with \pgfplots@saveddimen@picminx:
+ \pgfpointdiff
+ {\pgfplotspointorigininternal}
+ {##1}%
+ \global\pgf@x=-\pgf@x \global\pgf@y=-\pgf@y
+ }%
+ }%
+ \expandafter\tikz@scan@one@point\expandafter\pgfplots@loc@TMPa\expandafter(\pgfplots@anchorname)%
+ \def\pgfplots@anchorname{image}% that means: no shift!
+ }{}%
+ %
+ \begingroup
+ \pgfplots@beforenode
+ %
+ \ifpgfplots@has@cell@picture
+ \else
+ % the transformations have already been applied to the
+ % coordinates which are used to setup the node. Reset them:
+ \pgftransformresetnontranslations
+ \fi
+ %
+ \ifpgfplots@deprecated@anchors
+ \pgfplots@restore@deprecated@lowlevel@shape
+ \pgfmultipartnode{\pgfplots@shapename}{\pgfplots@anchorname}{\tikz@fig@name}{\pgfusepath{discard}}%
+ \else
+ \pgfmultipartnode{\pgfplots@shapename}{\pgfplots@anchorname}{\tikz@fig@name}{\pgfusepath{discard}}%
+ \fi
+ \endgroup
+ \pgfplots@fig@alias
+ \pgfnodealias{current axis}{\tikz@fig@name}%
+ %
+ \pgfplots@finally@correct@child@node@positions
+ \pgfplots@stacked@finalize
+ %
+ \pgfplots@LUA@cleanup
+ %
+ \ifpgfplots@colorbar
+ \pgfplots@colorbar@move@outside@scope@with@globalmacro{\pgfplots@glob@TMPa}%
+ \else
+ \global\let\pgfplots@glob@TMPa=\relax
+ \fi
+ %
+ % transport the current layer config - but only if nessary!
+ \def\pgfplots@loc@TMPa{0}%
+ \ifpgfplots@has@cell@picture
+ % layers are used for the cell picture only- no need to
+ % communicate them.
+ \else
+ \ifpgfplots@layered@graphics
+ \def\pgfplots@loc@TMPa{1}%
+ \else
+ % there are no layers.
+ \fi
+ \fi
+ \if1\pgfplots@loc@TMPa
+ % Ah - we need to transport the current layer config!
+ \pgf@remember@layerlist@globally
+ \aftergroup\pgf@restore@layerlist@from@global
+ \else
+ % Hm. No layers to transport. Make sure that the second
+ % \aftergroup does not hurt:
+ \aftergroup\pgf@remember@layerlist@globally
+ \fi
+ \endgroup
+ \pgfplots@glob@TMPa
+ %
+ % once more again - just to be sure that it works with LaTeX which
+ % introduces a further grouping level:
+ \aftergroup\pgf@restore@layerlist@from@global
+ %
+ \pgfplots@cell@picture@remembered
+ \aftergroup\pgfplots@cell@picture@remembered
+}
+
+\def\pgfplots@LUA@visualization@update@axis{%
+ \ifpgfplots@threedim
+ \pgfplotsmathvectortocomponents\pgfplots@view@dir@threedim{pgfplots@loc@}{default}%
+ \fi
+ %
+ \let\pgfplots@loc@TMPa\pgfutil@empty%
+ \pgfplotscoordmath{x}{datascaletrafo get params}%
+ \edef\pgfplots@loc@TMPa{%
+ \pgfplots@loc@TMPa
+ local datascaleTrafoX = pgfplots.DatascaleTrafo.new(\pgfplotsretval,\pgfplotsretvalb);^^J
+ }%
+ \pgfplotscoordmath{y}{datascaletrafo get params}%
+ \edef\pgfplots@loc@TMPa{%
+ \pgfplots@loc@TMPa
+ local datascaleTrafoY = pgfplots.DatascaleTrafo.new(\pgfplotsretval,\pgfplotsretvalb);^^J
+ }%
+ \pgfplotscoordmath{z}{datascaletrafo get params}%
+ \edef\pgfplots@loc@TMPa{%
+ \pgfplots@loc@TMPa
+ local datascaleTrafoZ = pgfplots.DatascaleTrafo.new(\pgfplotsretval,\pgfplotsretvalb);^^J
+ }%
+ %
+ \edef\pgfplots@loc@TMPa{%
+ \pgfplots@loc@TMPa
+ local axis = pgfplots.gca;^^J%
+ % FIXME : what about datamin/max?
+ axis.axiswidemetamin = pgfplots.pgftonumber("\pgfplots@axiswide@metamin"); ^^J%
+ axis.axiswidemetamax = pgfplots.pgftonumber("\pgfplots@axiswide@metamax"); ^^J%
+ axis.datascaleTrafo = { datascaleTrafoX, datascaleTrafoY, datascaleTrafoZ };^^J%
+ axis:setunitvectors({ %
+ { \pgf@sys@tonumber\pgf@xx, \pgf@sys@tonumber\pgf@xy },
+ { \pgf@sys@tonumber\pgf@yx, \pgf@sys@tonumber\pgf@yy },
+ { \pgf@sys@tonumber\pgf@zx, \pgf@sys@tonumber\pgf@zy } });^^J%
+ \ifpgfplots@threedim
+ axis.viewdir = {
+ pgfplots.pgftonumber("\pgfplots@loc@x"),
+ pgfplots.pgftonumber("\pgfplots@loc@y"),
+ pgfplots.pgftonumber("\pgfplots@loc@z") };^^J%
+ \fi
+ }%
+%\message{Executing \pgfplots@loc@TMPa}%
+ \pgfplotsutil@directlua{\pgfplots@loc@TMPa}
+}%
+
+\def\pgfplots@LUA@cleanup{%
+ \ifpgfplots@LUA@backend@supported
+ \pgfplotsutil@directlua{pgfplots.gca=nil}%
+ \fi
+}%
+
+%
+% This is part of \ifpgfplots@substitute@pgfpoint:
+\def\pgfplots@environment@opt@@setup@pgfpoint@restores{%
+ % There are places in pgfplots where the default coordinate system
+ % (i.e. the one used whenever one writes (1,2)) needs to be
+ % replaced:
+ % - during axis descriptions (see \pgfplots@change@pgfpoints@to@descriptioncs)
+ % - during the visualization phase (where it is substituted by
+ % (axis cs:1,2), compare XXXX)
+ %
+ % However, as soon as someone writes \pgfsetxvec (or its y/z
+ % variants), we want to *restore* the original PGF functionality.
+ %
+ % Prepare that here:
+ \let\pgfpointxy@orig=\pgfpointxy
+ \let\pgfqpointxy@orig=\pgfqpointxy
+ \let\pgfpointxyz@orig=\pgfpointxyz
+ \let\pgfqpointxyz@orig=\pgfqpointxyz
+ \let\pgfsetxvec@orig=\pgfsetxvec
+ \let\pgfsetyvec@orig=\pgfsetyvec
+ \let\pgfsetzvec@orig=\pgfsetzvec
+ \let\tikz@checkunit@orig=\tikz@checkunit
+ \let\pgfpatharcaxes@orig=\pgfpatharcaxes
+ \let\pgfpointpolarxy@orig=\pgfpointpolarxy
+ \let\tikz@do@arc@orig=\tikz@do@arc
+ %
+ \let\pgfsetxvec=\pgfplots@setxvec@restorepgfpoint
+ \let\pgfsetyvec=\pgfplots@setyvec@restorepgfpoint
+ \let\pgfsetzvec=\pgfplots@setzvec@restorepgfpoint
+}%
+
+\def\pgfplots@restorepgfpoint{%
+ \let\pgfpointxy=\pgfpointxy@orig
+ \let\pgfqpointxy=\pgfqpointxy@orig
+ \let\pgfpointxyz=\pgfpointxyz@orig
+ \let\pgfqpointxyz=\pgfqpointxyz@orig
+ \let\tikz@checkunit=\tikz@checkunit@orig
+ \let\pgfpointpolarxy=\pgfpointpolarxy@orig
+ \let\pgfpatharcaxes=\pgfpatharcaxes@orig
+ \let\tikz@do@arc=\tikz@do@arc@orig
+}%
+
+\def\pgfplots@setxvec@restorepgfpoint#1{%
+ \pgfsetxvec@orig{#1}%
+ \pgfplots@restorepgfpoint
+}%
+\def\pgfplots@setyvec@restorepgfpoint#1{%
+ \pgfsetyvec@orig{#1}%
+ \pgfplots@restorepgfpoint
+}%
+\def\pgfplots@setzvec@restorepgfpoint#1{%
+ \pgfsetzvec@orig{#1}%
+ \pgfplots@restorepgfpoint
+}%
+
+
+\def\pgfplots@replace@path@commands{%
+ \let\pgfplots@orig@scope=\scope
+ \let\pgfplots@orig@endscope=\endscope
+ \let\scope=\pgfplots@replacement@for@scope
+ \let\endscope=\pgfplots@replacement@for@endscope
+ %
+ \let\pgfplots@orig@pgfonlayer=\pgfonlayer
+ \let\pgfplots@orig@endpgfonlayer=\endpgfonlayer
+ \let\pgfonlayer=\pgfplots@replacement@for@onlayer
+ \let\endpgfonlayer=\pgfplots@replacement@for@endonlayer
+ %
+ \let\pgfplots@orig@pgfplotsonlayer=\pgfplotsonlayer
+ \let\pgfplots@orig@endpgfplotsonlayer=\endpgfplotsonlayer
+ \let\pgfplotsonlayer=\pgfplots@replacement@for@onlayer
+ \let\endpgfplotsonlayer=\pgfplots@replacement@for@endonlayer
+}%
+
+\def\pgfplots@restore@path@commands{%
+ % restore old \path command:
+ \let\path=\pgfplots@orig@path
+ \let\plot=\pgfplots@orig@plot
+ \let\scope=\pgfplots@orig@scope
+ \let\endscope=\pgfplots@orig@endscope
+ \let\pgfonlayer=\pgfplots@orig@pgfonlayer
+ \let\endpgfonlayer=\pgfplots@orig@endpgfonlayer
+ \let\pgfplotsonlayer=\pgfplots@orig@pgfplotsonlayer
+ \let\endpgfplotsonlayer=\pgfplots@orig@endpgfplotsonlayer
+}
+
+% visualizes selected phases.
+%
+% #1 a comma-separated list of selected phases. May be empty.
+% This is typically \pgfplots@visphase@names. The content will be
+% expanded, i.e. it can be a macro.
+\def\pgfplots@stored@plotlist@visualize@selected@phases#1{%
+ \begingroup
+ \def\pgfplotsaxisplotphase{V}%
+ \pgfplotsonlayer{\pgfkeysvalueof{/pgfplots/on layer}}{a plot or graphical element (or inherited from the axis)}%
+ \pgfkeysvalueof{/pgfplots/execute at begin plot visualization}%
+ \ifpgfplots@threedim
+ \else
+ % axis = 2d and plot=3d is forbidden here.
+ \pgfplots@curplot@threedimfalse
+ \fi
+ %
+ %
+ \pgfplots@LUA@visualization@init
+ % SIDE-effect: \ifpgfplots@LUA@backend@supported might have
+ % been switched to false here.
+ %
+ %
+ \pgfplots@execute@at@begin@plot@visualization@internal
+ %
+ \pgfplots@markers@prepare@layered@graphics@marks
+ %
+ \edef\pgfplots@current@phases{#1}%
+ %
+ % "boolean shouldExecuteClippedPart = \ifpgfplots@loc@tmp"
+ \pgfplots@loc@tmptrue
+ \ifx\pgfplots@current@phases\pgfutil@empty
+ \ifx\pgfplots@markers@visphase@name\pgfplots@markers@visphase@name@afterpath@clipped
+ % some special handling.... ok; start phase.
+ \else
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+ \ifpgfplots@loc@tmp
+ \expandafter\pgfplots@stored@plotlist@visualize@clippedpart\expandafter{\pgfplots@current@phases}%
+ \fi
+ %
+ \ifx\pgfplots@markers@visphase@name\pgfplots@markers@visphase@name@afterpath@unclipped
+ \scope[current plot style]%
+ \pgfplots@visphase@markers
+ \endscope
+ \fi
+ \pgfplots@execute@at@end@plot@visualization@internal
+ \pgfkeysvalueof{/pgfplots/execute at end plot visualization}%
+ \endpgfplotsonlayer
+ \endgroup
+}
+
+% #1: the list of phases to execute. This excludes marker phases.
+\def\pgfplots@stored@plotlist@visualize@clippedpart#1{%
+ \scope[current plot style] % this does set BOTH pgfplots and tikz options.
+ %
+ % do this here after options are set.
+ \pgfplots@initzerolevelhandler
+ %
+ % FIXME : what, precisely, was the motivation to use a
+ % scope here? It causes a lot of problems and
+ % work-arounds. Is it worth the effort!?
+ \ifpgfplots@clip
+ \if2\pgfplots@clipmode
+ % clip=true and 'clip mode=individual'
+ \pgfplots@clippath@install{\pgfusepath{clip}}%
+ \fi
+ \fi
+ %
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % skip. there is a case in which this can happen and makes
+ % sense: if
+ % \pgfplots@markers@visphase@name=\pgfplots@markers@visphase@name@afterpath@clipped
+ \else
+ % Standard visualization phases. See
+ % \pgfplotssurveyphase@set@visphase@names for a discussion about
+ % their intented use-case.
+ \pgfplotsutilforeachcommasep{#1}\as\pgfplots@visphase@name{%
+ \begingroup
+ \pgfutil@ifundefined{pgfplots@visphase@\pgfplots@visphase@name}{%
+ \pgfplots@error{Illegal state encountered: unknown visualization phase \pgfplots@visphase@name}%
+ }{%
+ \csname pgfplots@visphase@\pgfplots@visphase@name\endcsname
+ }%
+ \endgroup
+ }%
+ \fi
+ %
+ % marker visualization phase (one of the available ones):
+ \ifx\pgfplots@markers@visphase@name\pgfplots@markers@visphase@name@afterpath@clipped
+ \pgfplots@visphase@markers
+ \fi
+ %
+ \endscope
+}%
+
+\def\pgfplots@visphase@markers{%
+ \begingroup
+ \pgfplots@change@pgfpoints@to@axiscs
+ \pgfplots@markers@install@plotmark@handler
+ \let\pgfplots@visphase@name=\pgfplotsaxis@visphase@name@markers
+ \pgfplots@coord@stream@finalize@storedcoords@START
+ \endgroup
+}%
+
+% Inside of an axis, the default coordinate system for any draw
+% command should be (axis cs:1,2) instead of (1,2). Install that here:
+%
+% see \pgfplots@restorepgfpoint
+\def\pgfplots@change@pgfpoints@to@axiscs{%
+ %
+ \ifpgfplots@substitute@pgfpoint
+ \let\pgfpointxy=\pgfplotspointaxisxy
+ \let\pgfpointxyz=\pgfplotspointaxisxyz
+ \let\pgfqpointxy=\pgfplotsqpointaxisxy
+ \let\pgfqpointxyz=\pgfplotsqpointaxisxyz
+ \let\pgfpatharcaxes=\pgfplots@patharcaxes
+ \let\pgfpointpolarxy=\pgfplots@pointpolarxy
+ \let\tikz@do@arc=\pgfplots@tikz@do@arc
+ %
+ % tikz checks for units before it calls \pgfpointxy . This must
+ % not suffer from TeX's math restrictions, so we have to use the
+ % FPU for this task. Patch the command as well:
+ \let\tikz@checkunit=\pgfplots@checkunit@fpu
+ \fi
+}%
+
+\def\pgfplots@disable@directionmath{%
+ \def\pgfplotstransformdirectionx##1{\def\pgfmathresult{##1}}%
+ \let\pgfplotstransformdirectiony=\pgfplotstransformdirectionx
+ \let\pgfplotstransformdirectionz=\pgfplotstransformdirectionx
+}%
+
+% As of compat=1.11, pgfplots has to accept the following syntax elements:
+%
+% \draw[green,thick,->] (0,-1) arc[radius=1, start angle= -90, end angle=-180];
+% \draw[green,thick,->] (0,-1) arc[radius=1cm, start angle= -90, end angle=-180];
+% \draw[green,thick,->] (0,-1) arc[radius={transformdirectionx(1)}, start angle= -90, end angle=-180];
+%
+% all of them should work. The last one (transformdirectionx) is due
+% to legacy compatibility. Since the 1.11 code handles these syntaxes
+% automatically, 'transformdirectionx' will be ignored silently.
+\def\pgfplots@tikz@do@arc#1#2#3#4{%
+ \begingroup
+ % strip 'transformdirectionx' if it occurs in the angles:
+ \pgfplots@disable@directionmath
+ \pgfmathparse{#3}%
+ \t@pgfplots@toka={\tikz@do@arc@orig{#1}{#2}}%
+ \edef\pgfplots@arc@x{%
+ \pgfmathresult
+ \ifpgfmathunitsdeclared pt\fi
+ }%
+ \pgfmathparse{#4}%
+ \xdef\pgfplots@arc@y{%
+ \pgfmathresult
+ \ifpgfmathunitsdeclared pt\fi
+ }%
+ % ok, invoke the TikZ command with the expanded args:
+ \xdef\pgfplots@glob@TMPa{\the\t@pgfplots@toka{\pgfplots@arc@x}{\pgfplots@arc@y}}%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+\def\pgfplots@polarxy@#1and #2\@@{%
+ \edef\pgfplots@polarxy@X{#1}%
+ \edef\pgfplots@polarxy@Y{#2}%
+}
+\def\pgfplots@pointpolarxy#1#2{%
+ \pgfutil@in@{and }{#2}%
+ \ifpgfutil@in@%
+ \pgfplots@polarxy@#2\@@%
+ \else%
+ \pgfplots@polarxy@#2and #2\@@%
+ \fi%
+ \pgfmathparse{#1}%
+ \let\pgfpoint@angle=\pgfmathresult%
+ \pgfmathcos@{\pgfpoint@angle}%
+ \let\pgfpoint@cos=\pgfmathresult
+ \pgfmathsin@{\pgfpoint@angle}%
+ \let\pgfpoint@sin=\pgfmathresult
+ %
+ \begingroup
+ \pgfplots@plot@coords@mathparsertrue
+ \pgf@process{%
+ \pgfplotspointaxisxyz{\pgfplots@polarxy@X*\pgfpoint@cos}{\pgfplots@polarxy@Y*\pgfpoint@sin}{0}%
+ }%
+ \endgroup
+}%
+
+% #1 = angle of first point
+% #2 = angle of second point
+% #3 = first axis
+% #4 = second axis
+\def\pgfplots@patharcaxes#1#2#3#4{%
+ {%
+ % see docs of \pgfplots@tikz@do@arc for a motivation:
+ \pgfplots@disable@directionmath
+ %
+ % ok, now, evaluate the arcs. Since this implements
+ % 'substitute pgfpoint', we have to evaluate the angles via
+ % 'axis direction cs' ...
+ \let\pgfpointxy=\pgfplotspointaxisdirectionxy
+ \let\pgfpointxyz=\pgfplotspointaxisdirectionxyz
+ %
+ \pgftransformtriangle{\pgfpointorigin}{#3}{#4}%
+ %
+ % ... and the coordinates as such using 'axis cs':
+ \let\pgfpointxy=\pgfplotspointaxisxy
+ \let\pgfpointxyz=\pgfplotspointaxisxyz
+ %
+ \pgfpatharc{#1}{#2}{1pt}%
+ }%
+}%
+
+\def\pgfplots@checkunit@fpu#1{%
+ \ifpgfplots@usefpu
+ \begingroup
+ \pgfkeys{/pgf/fpu, /pgf/fpu/output format/float}%
+ \tikz@checkunit@orig{#1}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \xdef\pgfplots@glob@TMPd{%
+ \iftikz@isdimension
+ \noexpand\tikz@isdimensiontrue
+ \else
+ \noexpand\tikz@isdimensionfalse
+ \fi
+ \noexpand\def\noexpand\pgfmathresult{\pgfmathresult}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPd
+ \else
+ \tikz@checkunit@orig{#1}%
+ \fi
+}%
+
+\def\pgfplots@execute@at@end@plot@visualization@internal{%
+}%
+
+\def\pgfplots@beforenode{%
+ \pgfplots@sys@beforenode
+}%
+
+% Now, we need to process all named nodes inside of our
+% axis-image.
+%
+% The situation at this point is as follows:
+% 1. the complete axis image has been "typeset" into a box. That
+% means its coordinate system is LOST up to those variables
+% which have been saved explicitly.
+%
+% 2. the \pgfmultipartnode above knows about all axis anchors and
+% saved dimensions.
+%
+% 3. All sub-nodes don't know about their position any more. Any
+% saved anchors are wrong.
+%
+% The approach:
+% 1. we shift each named node's saved anchors such that it's
+% coordinate is valid inside of the TeX box.
+%
+% 2. we also shift each named node's saved anchors to reflect the
+% axis' anchor.
+%
+% Afterwards, everything should be fine.
+\def\pgfplots@finally@correct@child@node@positions{%
+ \ifx\pgfplots@named@child@node@list\pgfutil@empty%
+ \else%
+ \begingroup
+ \pgftransformreset% FIXME: what's that for!? Copied from matrix code...
+ %
+ % Use the 'image' anchor here - the internal anchor
+ % transformation matrix already has the shift for
+ % \pgfplots@anchorname.
+ \pgfpointanchor{\tikz@fig@name}{image}%
+ \pgf@xa=\pgf@x
+ \pgf@xb=\pgf@y
+ \pgf@process{\pgfplotspointorigininternal}%
+ \advance\pgf@xa by-\pgf@x
+ \advance\pgf@xb by-\pgf@y
+ \global\pgf@x=\pgf@xa
+ \global\pgf@y=\pgf@xb
+ \edef\pgfplots@offset{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfplots@finally@correct@remembered@picture@positions
+ %
+ \pgfutil@for\pgfplots@child@node@name:=\pgfplots@named@child@node@list\do{%
+ \ifx\pgfplots@child@node@name\pgfutil@empty
+ \else
+%\message{Attempting to correct '\pgfplots@child@node@name' position by \meaning\pgfplots@offset\space (the node is inside of an axis).}%
+ \expandafter\ifx\csname pgfplots@child@node@visited@\pgfplots@child@node@name\endcsname\relax%
+ \pgfutil@IfUndefined{pgf@sh@nt@\pgfplots@child@node@name}{%
+ \pgfplots@warning{could not adjust coordinates of named node '\pgfplots@child@node@name' for reasons I do not understand! After finishing the image, it did no longer exist!? Sorry.}%
+ }{%
+ \pgf@shift@node{\pgfplots@child@node@name}{\pgfplots@offset}%
+ \expandafter\let\csname pgfplots@child@node@visited@\pgfplots@child@node@name\endcsname=\pgfutil@empty%
+ }%
+ \fi
+ \fi
+ }%
+ \endgroup
+ \fi%
+}%
+
+% The feature 'remember picture' relies on the global position of
+% pgfpictures.
+%
+% If we have 'remember picture=true' and 'cell picture=true', that
+% global position has been shifted as well. We have to correct it.
+%
+% This, in turn, requires to patch the .aux file.
+%
+% PRECONDITION: takes the offset \pgf@x,\pgf@y.
+\def\pgfplots@finally@correct@remembered@picture@positions{%
+ % Note that the cell picture is already closed - but
+ % fortunately, we have saved its picture id.
+ \ifx\pgfplots@cell@pictureid\pgfutil@empty
+ % ah - no cell picture. OK; nothing to do.
+ \else
+ % ah - there WAS a cell picture ...
+ \pgfplots@cell@picture@remembered
+ \ifpgfrememberpicturepositiononpage
+ % ... AND it had its "remember picture" flag activated.
+ %
+ % It is task of
+ % \pgfplots@finally@correct@child@node@positions to
+ % express ALL node locations in terms of \pgfpictureid.
+ %
+ % So, we can simply replace the (already written) pdfmark
+ % of \pgfplots@cell@pictureid by that of \pgfpictureid
+ % (which, however, is NOT written because the picture is
+ % not finished).
+ %
+ % It will be written eventually because the outer picture
+ % will implicitly inherit
+ % \pgfrememberpicturepositiononpagetrue
+ % -> see all usages of \pgfplots@cell@picture@remembered
+ \begingroup
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\noexpand
+ \noexpand\pgfplotsreplacepdfmark
+ {\pgfplots@cell@pictureid}{\pgfpictureid}%
+ }%
+ \expandafter\write\expandafter\pgfutil@auxout\expandafter{\pgfplots@loc@TMPa}%
+ \endgroup
+ \fi
+ \fi
+}%
+
+% Replaces the pdfmark for #1 by that of #2.
+%
+% Note that when this macro is executed (it resides in the .aux file),
+% the pdfmark for #2 is typically UNDEFINED.
+%
+% #1: the pgfpictureid to modify
+% #2: the pgfpictureid which contains the correct values
+\def\pgfplotsreplacepdfmark#1#2{%
+ \pgfsys@getposition{#1}{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\relax
+ % hm. strange. Perhaps the driver does not support it?
+ \else
+ % Ok, make a "lazy replace":
+ \expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgf@sys@pdf@mark@pos@#1\endcsname
+ \expandafter\global\expandafter\let\csname pgf@sys@pdf@mark@pos@#1@old\endcsname=\pgfplots@loc@TMPa%
+ %
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{%
+ % this is the lazy replace, assuming knowledge about how
+ % pgf calls its internal structures :-/
+ %
+ % If pgf changes its name, this macro will never be
+ % called and we do not hurt someone.
+ \pgfsys@getposition{#2}{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\relax
+ % oh - the picture if for #2 has no remembered name!?
+ % Perhaps something failed?
+ % try a fall-back. This will most fail (most
+ % probably). Issue a warning?
+ \csname pgf@sys@pdf@mark@pos@#1@old\endcsname
+ \else
+ % use #2:
+ \pgfplots@loc@TMPa
+ \fi
+ }%
+ \fi
+}%
+
+\def\pgfplots@environment@axis{%
+ \pgfutil@ifnextchar[{\pgfplots@@environment@axis}{\pgfplots@@environment@axis[]}%
+}
+\def\endpgfplots@environment@axis{\endpgfplots@environment@opt}
+\def\pgfplots@@environment@axis[#1]{%
+ \pgfplots@environment@opt[/pgfplots/xmode=linear,/pgfplots/ymode=linear,#1]%
+}
+
+\def\pgfplots@environment@semilogxaxis{%
+ \pgfutil@ifnextchar[{\pgfplots@@environment@semilogxaxis}{\pgfplots@@environment@semilogxaxis[]}%
+}
+\def\endpgfplots@environment@semilogxaxis{\endpgfplots@environment@opt}
+\def\pgfplots@@environment@semilogxaxis[#1]{%
+ \pgfplots@environment@opt[/pgfplots/xmode=log,/pgfplots/ymode=linear,#1]%
+}
+
+\def\pgfplots@environment@semilogyaxis{%
+ \pgfutil@ifnextchar[{\pgfplots@@environment@semilogyaxis}{\pgfplots@@environment@semilogyaxis[]}%
+}
+\def\endpgfplots@environment@semilogyaxis{\endpgfplots@environment@opt}
+\def\pgfplots@@environment@semilogyaxis[#1]{%
+ \pgfplots@environment@opt[/pgfplots/xmode=linear,/pgfplots/ymode=log,#1]%
+}
+
+\def\pgfplots@environment@loglogaxis{%
+ \pgfutil@ifnextchar[{\pgfplots@@environment@loglogaxis}{\pgfplots@@environment@loglogaxis[]}%
+}
+\def\endpgfplots@environment@loglogaxis{\endpgfplots@environment@opt}
+\def\pgfplots@@environment@loglogaxis[#1]{%
+ \pgfplots@environment@opt[/pgfplots/xmode=log,/pgfplots/ymode=log,#1]%
+}
+
+
+\pgfutil@IfUndefined{tikzaddtikzonlycommandshortcutlet}{%
+ \def\tikzaddtikzonlycommandshortcutlet#1#2{%
+ \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands
+ \let#1=#2%
+ }%
+ }%
+}{}
+
+\tikzaddtikzonlycommandshortcutlet\axis\pgfplots@environment@axis
+\tikzaddtikzonlycommandshortcutlet\endaxis\endpgfplots@environment@axis
+
+\tikzaddtikzonlycommandshortcutlet\semilogxaxis\pgfplots@environment@semilogxaxis
+\tikzaddtikzonlycommandshortcutlet\endsemilogxaxis\endpgfplots@environment@semilogxaxis
+
+\tikzaddtikzonlycommandshortcutlet\semilogyaxis\pgfplots@environment@semilogyaxis
+\tikzaddtikzonlycommandshortcutlet\endsemilogyaxis\endpgfplots@environment@semilogyaxis
+
+\tikzaddtikzonlycommandshortcutlet\loglogaxis\pgfplots@environment@loglogaxis
+\tikzaddtikzonlycommandshortcutlet\endloglogaxis\endpgfplots@environment@loglogaxis
+
+%\input pgfplots.multiaxis.code.tex
+
+\pgfplotsdefineaxistype{rectangle}{%
+ % do nothing, this is the default anyway.
+}%
+
+\catcode`\;=\pgfplots@oldcatcodesemicolon
+\catcode`\"=\pgfplots@oldcatcodedoublequote
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.errorbars.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplots.errorbars.code.tex
new file mode 100644
index 0000000000..8e2a96a905
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.errorbars.code.tex
@@ -0,0 +1,608 @@
+%--------------------------------------------
+%
+% 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-2013 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 \addplot commands assign
+% \pgfplots@current@point@error@x@plus
+% \pgfplots@current@point@error@x@minus
+% \pgfplots@current@point@error@y@plus
+% \pgfplots@current@point@error@y@minus
+% \pgfplots@current@point@error@z@plus
+% \pgfplots@current@point@error@z@minus
+%
+% the error bar processing takes these values as input, adds them to
+% the current coordinates where applicable and according the the error
+% bar configuration and overwrites these macros.
+%
+% Then, these values are registered as "visualization depends on",
+% i.e. they will be available for every visualization phase.
+%
+% The visualization phase, in turn, expects these values. More
+% precisely, a separate visualization phase called
+% \pgfplotsaxis@visphase@name@errorbars is started. This installs the
+% plot handler \pgfplots@errorbars@plot@handler and does the same job
+% as it would for normal plot handlers.
+%
+\def\pgfplots@errorbars@survey@begin{%
+ %
+ \pgfplots@errorbars@prepare@value@serialization
+ %
+ % 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
+}
+
+\def\pgfplots@errorbars@survey@end{%
+ \pgfplots@streamerrorbarend
+}%
+
+\def\pgfplots@errorbars@survey@point{%
+ % This thing gets the 'current@point@...' context,
+ % that means
+ % \pgfplots@current@point@[xy]
+ % \pgfplots@current@point@[xy]@error
+ % \pgfplots@current@point@[xy]@unfiltered
+ \pgfplots@PREPARE@errorbar@process@x%
+ \pgfplots@PREPARE@errorbar@process@y%
+ \pgfplots@PREPARE@errorbar@process@z%
+}
+
+\def\pgfplots@errorbars@visphase@begin{%
+ \pgfplots@errorbars@prepare@value@serialization
+}
+
+\def\pgfplots@errorbars@visphase@end{%
+}%
+
+\def\pgfplots@errorbars@visphase@point{%
+}%
+
+\def\pgfplots@errorbars@prepare@value@serialization{%
+ \if0\pgfplots@errorbars@xdirection
+ \else
+ \pgfplotsset{%
+ visualization depends on=value \pgfplots@current@point@error@x@plus\as\pgfplots@current@point@error@x@plus,
+ visualization depends on=value \pgfplots@current@point@error@x@minus\as\pgfplots@current@point@error@x@minus,
+ }%
+ \fi
+ \if0\pgfplots@errorbars@ydirection
+ \else
+ \pgfplotsset{%
+ visualization depends on=value \pgfplots@current@point@error@y@plus\as\pgfplots@current@point@error@y@plus,
+ visualization depends on=value \pgfplots@current@point@error@y@minus\as\pgfplots@current@point@error@y@minus,
+ }%
+ \fi
+ \ifpgfplots@curplot@threedim
+ \if0\pgfplots@errorbars@zdirection
+ \else
+ \pgfplotsset{%
+ visualization depends on=value \pgfplots@current@point@error@z@plus\as\pgfplots@current@point@error@z@plus,
+ visualization depends on=value \pgfplots@current@point@error@z@minus\as\pgfplots@current@point@error@z@minus,
+ }%
+ \fi
+ \fi
+}%
+
+% 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{%
+ \pgfplots@PREPARE@errorbar@processing@in@dir@reset#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
+ %
+ % The routine which is invoked for every reported input
+ % coordinate is \pgfplots@process@errorbar@for.
+ %
+ % This here prepares its helper macros for direction '#1':
+ %
+ % More precisely, it prepared
+ %
+ % ##1 is either '+' or '-':
+ % \pgfplots@PREPARE@errorbar@process@x@##1
+ % \pgfplots@PREPARE@errorbar@process@y@##1
+ % \pgfplots@PREPARE@errorbar@process@z@##1
+ %
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \ifcase\csname pgfplots@errorbars@#1mode\endcsname\relax
+ % fixed absolute error.
+ \pgfplotscoordmath{#1}{parsenumber}{\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%
+ \def\pgfplots@loc@TMPb{add}%
+ \else
+ \def\pgfplots@loc@TMPb{subtract}%
+ \fi
+ \pgfplotscoordmath{#1}{op}{\pgfplots@loc@TMPb}{%
+ {\csname pgfplots@current@point@#1\endcsname}%
+ {\csname pgfplots@error@coord@#1\endcsname}%
+ }%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplots@PREPARE@errorbar@stream@it@#1##1%
+ }%
+ \or% fixed relative error:
+ \pgfplotscoordmath{#1}{parsenumber}{\csname pgfplots@errorbars@#1rel\endcsname}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ %
+ % +1:
+ \pgfplotscoordmath{#1}{parsenumber}{1}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ %
+ % Prepare '1 + err':
+ \pgfplotscoordmath{#1}{op}{add}{%
+ {\pgfplots@loc@TMPa}%
+ {\pgfplots@loc@TMPb}%
+ }%
+ \expandafter\let\csname pgfplots@error@coord@#1@+\endcsname=\pgfmathresult
+ %
+ % Prepare '1 - err':
+ \pgfplotscoordmath{#1}{op}{subtract}{%
+ {\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{%
+ \pgfplotscoordmath{#1}{op}{multiply}{%
+ {\csname pgfplots@current@point@#1\endcsname}
+ {\csname pgfplots@error@coord@#1@##1\endcsname}%
+ }%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplots@PREPARE@errorbar@stream@it@#1##1%
+ }%
+ \or% explicit absolute:
+ \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{%
+ \edef\pgfplots@error@coord{\csname pgfplots@current@point@error@#1@\pgfplots@errorbars@plusminus##1\endcsname}%
+ \ifx\pgfplots@error@coord\pgfutil@empty
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ \else
+ \pgfplotscoordmath{#1}{parsenumber}{\pgfplots@error@coord}%
+ \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{%
+ \let\pgfplots@error@coord=\pgfmathresult
+ % remember result here - will be used in case
+ % of '+' AND '-' error bars:
+ %\expandafter\let\csname pgfplots@current@point@error@#1@\pgfplots@errorbars@plusminus##1\endcsname=\pgfmathresult
+ \if +##1%
+ \def\pgfplots@loc@TMPb{add}%
+ \else
+ \def\pgfplots@loc@TMPb{subtract}%
+ \fi
+ \pgfplotscoordmath{#1}{op}{\pgfplots@loc@TMPb}{%
+ {\csname pgfplots@current@point@#1\endcsname}%
+ {\pgfplots@error@coord}%
+ }%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplots@PREPARE@errorbar@stream@it@#1##1%
+ }{%
+ % input is unbounded. Skip it.
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ }%
+ \fi
+ }%
+ \or% explicit relative:
+ \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{%
+ \edef\pgfplots@error@coord{\csname pgfplots@current@point@error@#1@\pgfplots@errorbars@plusminus##1\endcsname}%
+ \ifx\pgfplots@error@coord\pgfutil@empty
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ \else
+ \pgfplotscoordmath{#1}{parsenumber}{\pgfplots@error@coord}%
+ \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{%
+ \let\pgfplots@error@coord=\pgfmathresult
+ % compute ' 1 + value' or '1-value':
+ \pgfplotscoordmath{#1}{one}%
+ \if +##1%
+ \def\pgfplots@loc@TMPb{add}%
+ \else
+ \def\pgfplots@loc@TMPb{subtract}%
+ \fi
+ \pgfplotscoordmath{#1}{op}{\pgfplots@loc@TMPb}{%
+ {\pgfmathresult}%
+ {\pgfplots@error@coord}%
+ }%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplotscoordmath{#1}{op}{multiply}{%
+ {\csname pgfplots@current@point@#1\endcsname}
+ {\pgfplots@error@coord}%
+ }%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplots@PREPARE@errorbar@stream@it@#1##1%
+ }{%
+ % input is unbounded. Skip it.
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ }%
+ \fi
+ }%
+ \fi
+ }{%
+ % LOGARITHMIC scaling. All errors are interpreted as
+ % log(x +- e_x)
+ % or
+ % log( x*(1+-e_x) )
+ %
+ % 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 )
+ %
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@errorbars@#1fixed\endcsname}%
+ \expandafter\let\csname pgfplots@error@coord@#1\endcsname=\pgfmathresult
+ \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{%
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@current@point@#1@unfiltered\endcsname}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \if +##1%
+ \def\pgfplots@loc@op{add}%
+ \else
+ \def\pgfplots@loc@op{subtract}%
+ \fi
+ \pgfplotscoordmath{default}{op}{\pgfplots@loc@op}{%
+ {\pgfplots@loc@TMPa}%
+ {\csname pgfplots@error@coord@#1\endcsname}%
+ }%
+ \pgfplotscoordmath{default}{tostring}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplots@PREPARE@errorbar@stream@it@#1##1%
+ }%
+ \or% fixed relative, log( x ( 1+-e_x ) ) = log(x) + log(1+-e_x)
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@errorbars@#1rel\endcsname}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ %
+ % +1:
+ \pgfplotscoordmath{default}{one}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ %
+ % Prepare '1 + err':
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}}%
+ \pgfplotscoordmath{default}{tostring}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{%
+ }{%
+ % 1 + err <= 0 and log(1+err) is undefined:
+ \pgfplotscoordmath{default}{tostring}{\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
+ }%
+ \expandafter\let\csname pgfplots@error@coord@#1@+\endcsname=\pgfmathresult
+ %
+ % Prepare '1 - err':
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}}%
+ \pgfplotscoordmath{default}{tostring}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{%
+ }{%
+ % 1 - err <= 0 and log(1+err) is undefined:
+ \pgfplotscoordmath{default}{tostring}{\pgfplots@loc@TMPb}%
+ \pgfplots@error{Sorry, log(1 - \pgfmathresult) (\pgfplots@loc@TMPa - \pgfplots@loc@TMPb) is undefined. Please provide a different argument for '/pgfplots/error bar/#1 fixed relative'.}%
+ \let\pgfmathresult=\pgfutil@empty
+ }%
+ \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
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ \else
+ \pgfmath@basic@add@
+ {\csname pgfplots@current@point@#1\endcsname}
+ {\csname pgfplots@error@coord@#1@##1\endcsname}%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplots@PREPARE@errorbar@stream@it@#1##1%
+ \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@error@#1@\pgfplots@errorbars@plusminus##1\endcsname}%
+ \ifx\pgfplots@error@coord\pgfutil@empty
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ \else
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@error@coord}%
+ \pgfplotscoordmath{default}{if is bounded}{\pgfmathresult}{%
+ \let\pgfplots@error@coord=\pgfmathresult
+ % remember result here - will be used in case
+ % of '+' AND '-' error bars:
+ %\expandafter\let\csname pgfplots@current@point@error@#1@\pgfplots@errorbars@plusminus##1\endcsname=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@current@point@#1@unfiltered\endcsname}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \if +##1%
+ \def\pgfplots@loc@op{add}%
+ \else
+ \def\pgfplots@loc@op{subtract}%
+ \fi
+ \pgfplotscoordmath{default}{op}{\pgfplots@loc@op}{%
+ {\pgfplots@loc@TMPa}%
+ {\pgfplots@error@coord}%
+ }%
+ \pgfplotscoordmath{default}{tostring}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplots@PREPARE@errorbar@stream@it@#1##1%
+ }{%
+ % input is unbounded. Skip it.
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ }%
+ \fi
+ }%
+ %
+ \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@error@#1@\pgfplots@errorbars@plusminus##1\endcsname}%
+ \ifx\pgfplots@error@coord\pgfutil@empty
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ \else
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@error@coord}%
+ \pgfplotscoordmath{default}{if is bounded}{\pgfmathresult}{%
+ \let\pgfplots@error@coord=\pgfmathresult
+ % remember result here - will be used in case
+ % of '+' AND '-' error bars:
+ %\expandafter\let\csname pgfplots@current@point@error@#1@\pgfplots@errorbars@plusminus##1\endcsname=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{one}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \if +##1%
+ \def\pgfplots@loc@op{add}%
+ \else
+ \def\pgfplots@loc@op{subtract}%
+ \fi
+ \pgfplotscoordmath{default}{op}{\pgfplots@loc@op}{%
+ {\pgfplots@loc@TMPa}%
+ {\pgfplots@error@coord}%
+ }%
+ \pgfplotscoordmath{default}{tostring}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{%
+ \pgfplotscoordmath{#1}{op}{add}{%
+ {\csname pgfplots@current@point@#1\endcsname}
+ {\pgfplots@error@coord}%
+ }%
+ \let\pgfplots@error@coord=\pgfmathresult
+ \pgfplots@PREPARE@errorbar@stream@it@#1##1%
+ }{%
+ % -> log( <= 0 ) -> do nothing.
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ }%
+ }{%
+ % input is unbounded - do nothing.
+ \pgfplots@PREPARE@errorbar@stream@it@empty#1##1%
+ }%
+ \fi
+ }%
+ %
+ \fi
+ }%
+ \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
+}
+
+\def\pgfplots@PREPARE@errorbar@processing@in@dir@reset#1{%
+ \expandafter\let\csname pgfplots@current@point@error@#1@plus\endcsname=\pgfutil@empty
+ \expandafter\let\csname pgfplots@current@point@error@#1@minus\endcsname=\pgfutil@empty
+}%
+
+% #1: one of x,y, or z
+% #2: either '+' or '-', denotes the direction of the error
+% bar
+%
+% PRECONDITION: \pgfplots@error@coord contains the value which is to
+% be stored as \pgfplots@current@point@error@#1@plus or
+% \pgfplots@current@point@error@#1@minus
+%
+% POSTCONDITION: limits updated and
+% \pgfplots@current@point@error@#1@plus or
+% \pgfplots@current@point@error@#1@minus
+% is defined.
+\def\pgfplots@PREPARE@errorbar@stream@it@#1#2{%
+ \ifx\pgfplots@error@coord\pgfutil@empty
+ \else
+ \expandafter\let\expandafter\pgfplots@current@point@@old\csname pgfplots@current@point@#1\endcsname
+ \expandafter\let\csname pgfplots@current@point@#1\endcsname=\pgfplots@error@coord
+ \pgfplotsaxisupdatelimitsforcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z
+ \expandafter\let\csname pgfplots@current@point@#1\endcsname=\pgfplots@current@point@@old
+ \fi
+ %
+ % ... and remember what we need! This value will be stored as
+ % "visualization depends on"
+ \expandafter\let\csname pgfplots@current@point@error@#1@\pgfplots@errorbars@plusminus#2\endcsname=\pgfplots@error@coord
+}%
+
+\def\pgfplots@PREPARE@errorbar@stream@it@empty#1#2{%
+ % ... and remember what we need! This value will be stored as
+ % "visualization depends on"
+ \expandafter\let\csname pgfplots@current@point@error@#1@\pgfplots@errorbars@plusminus#2\endcsname=\pgfutil@empty
+}
+
+\def\pgfplots@errorbars@plusminus#1{%
+ \if#1+%
+ plus%
+ \else
+ minus%
+ \fi
+}%
+
+% A dummy plot handler which is used in a special visualization phase
+% for error bars.
+\def\pgfplots@errorbars@plot@handler{%
+ \gdef\pgf@plotstreamstart{%
+ \pgfplots@streamerrorbar@directdraw
+ \global\let\pgf@plotstreampoint=\pgfplots@errorbars@plot@handler@point
+ \global\let\pgf@plotstreamspecial=\relax
+ \global\let\pgf@plotstreamend=\pgfplots@streamerrorbarend
+ \pgfplots@streamerrorbarstart
+ }%
+}%
+
+\def\pgfplots@errorbars@plot@handler@point#1{%
+ \pgf@process{#1}%
+ \edef\pgfplots@errorbars@src{(\the\pgf@x,\the\pgf@y)}%
+ %
+ % we want to allow scatter plots to vary depending on 'point
+ % meta'. This here does not hurt:
+ \pgfplotsaxisvisphasetransformpointmetaifany
+ %
+ \pgfplots@errorbars@plot@handler@point@dir x%
+ \pgfplots@errorbars@plot@handler@point@dir y%
+ \ifpgfplots@curplot@threedim
+ \pgfplots@errorbars@plot@handler@point@dir z%
+ \fi
+}
+
+% #1: one of x,y, or z
+% #2: the error bar value in dir #1
+% output: \pgfplots@errorbars@trg in the form (<x>,<y>,<z>)
+\def\pgfplots@errorbars@to@pt#1#2{%
+ \begingroup
+ \expandafter\let\csname pgfplots@current@point@#1\endcsname=#2%
+ \ifpgfplots@curplot@threedim
+ \edef\pgfplotsretval{(\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)}%
+ \else
+ \edef\pgfplotsretval{(\pgfplots@current@point@x,\pgfplots@current@point@y)}%
+ \fi
+ \global\let\pgfplots@errorbars@trg=\pgfplotsretval
+ \endgroup
+}%
+
+% #1: a <\macro> containing the value
+% #2: either x,y, or z
+\def\pgfplots@errorbars@plot@handler@point@dir@@#1#2{%
+ \ifx#1\pgfutil@empty
+ \else
+ \pgfplotsaxisvisphasetransformcoordinateentry{#2}{#1}%
+ \pgfplots@errorbars@to@pt{#2}{\pgfmathresult}%
+ \pgfplots@streamerrorbarcoords{\pgfplots@errorbars@src}{\pgfplots@errorbars@trg}%
+ \fi
+}%
+
+\def\pgfplots@errorbars@plot@handler@point@dir#1{%
+ \ifcase\csname pgfplots@errorbars@#1direction\endcsname
+ % none
+ \or
+ % plus
+ \expandafter\pgfplots@errorbars@plot@handler@point@dir@@\csname pgfplots@current@point@error@#1@plus\endcsname#1%
+ \or
+ % minus
+ \expandafter\pgfplots@errorbars@plot@handler@point@dir@@\csname pgfplots@current@point@error@#1@minus\endcsname#1%
+ \or
+ % both
+ \expandafter\pgfplots@errorbars@plot@handler@point@dir@@\csname pgfplots@current@point@error@#1@plus\endcsname#1%
+ \expandafter\pgfplots@errorbars@plot@handler@point@dir@@\csname pgfplots@current@point@error@#1@minus\endcsname#1%
+ \fi
+}%
+
+\def\pgfplots@streamerrorbarstart{%
+}%
+\def\pgfplots@streamerrorbarend{%
+}%
+\def\pgfplots@streamerrorbarcoords#1#2{%
+}%
+
+\def\pgfplots@streamerrorbar@directdraw{%
+ \def\pgfplots@streamerrorbarstart{}%
+ \def\pgfplots@streamerrorbarend{}%
+ \def\pgfplots@streamerrorbarcoords##1##2{%
+ \pgfplots@errorbar@draw{##1}{##2}%
+ }%
+}
+
+\newif\ifpgfplots@error@bars@allow@name@path
+
+
+% This thing here shall draw all error bar commands listed in '#2'.
+%
+% It will be invoked when any plotting commands take effect (that
+% means all limits are computed; the axis has been drawn,
+% transformations are set up...)
+\def\pgfplots@errorbars@finishwithstyleoptions[#1]#2{%
+ \scope[/pgfplots/.cd,#1,/pgfplots/every error bar]% it uses the /pgfplots/.unknown handler
+ \ifpgfplots@error@bars@allow@name@path
+ \else
+ % 'name path=xxx' should NOT include errors bars! Only the
+ % main path.
+ \def\tikz@intersect@addto@path@names##1##2{}%
+ \fi
+ #2%
+ \endscope
+}
+
+\def\pgfplots@errorbar@draw#1#2{%
+ \begingroup
+ \pgfplots@restorepgfpoint
+ \pgfkeysvalueof{/pgfplots/error bars/draw error bar/.@cmd}{#1}{#2}\pgfeov%
+ \endgroup
+}%
+
+\def\pgfplotsaxis@visphase@name@errorbars{errorbars}
+
+\expandafter\def\csname pgfplots@visphase@\pgfplotsaxis@visphase@name@errorbars\endcsname{%
+ \pgfplots@errorbars@finishwithstyleoptions[]{%
+ \let\tikz@plot@handler=\pgfplots@errorbars@plot@handler
+ \pgfplots@coord@stream@finalize@storedcoords@START
+ }%
+}%
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.lua b/graphics/pgf/contrib/pgfplots/tex/pgfplots.lua
new file mode 100644
index 0000000000..23aeaab2a8
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.lua
@@ -0,0 +1,45 @@
+
+require("pgfplots.binary")
+
+-- all classes/globals will be added to this table:
+pgfplots = {}
+
+-- will be set by TeX:
+pgfplots.pgfplotsversion = nil
+
+if _VERSION == "Lua 5.1" or _VERSION == "Lua 5.0" then
+ texio.write("pgfplots: setting 'lua support=false': the lua version on this system is " .. _VERSION .. "; expected at least 'Lua 5.2'. Use a more recent TeX distribution to benefit from LUA in pgfplots.\n")
+
+ -- the entire lua backend will be switched off if this is false:
+ tex.sprint("\\pgfplotsset{lua support=false}")
+ return
+else
+ -- well, 5.2 is what this stuff has been written for.
+ -- Is there a good reason why it shouldn't work on 5.1 !? No, I guess not. Except that it took me a long time
+ -- to figure out that 5.2 broke compatibility in lots of ways - and it was difficult enough to get it up and running.
+ -- If someone wants (and needs) to run it in 5.1 - I would accept patches.
+end
+
+require("pgfplots.pgfplotsutil")
+
+-- see pgfrcs.code.tex -- all versions after 3.0.0 (excluding 3.0.0) will set this version:
+if not pgf or not pgf.pgfversion then
+ pgfplots.log("log", "pgfplots.lua: loading complementary lua code for your pgf version...\n")
+ pgfplots.pgfluamathfunctions = require("pgfplotsoldpgfsupp.luamath.functions")
+ pgfplots.pgfluamathparser = require("pgfplotsoldpgfsupp.luamath.parser")
+else
+ pgfplots.pgfluamathparser = require("pgf.luamath.parser")
+ pgfplots.pgfluamathfunctions = require("pgf.luamath.functions")
+end
+pgfplots.pgftonumber = pgfplots.pgfluamathfunctions.tonumber
+pgfplots.tostringfixed = pgfplots.pgfluamathfunctions.tostringfixed
+pgfplots.toTeXstring = pgfplots.pgfluamathfunctions.toTeXstring
+
+
+require("pgfplots.plothandler")
+require("pgfplots.meshplothandler")
+require("pgfplots.colormap")
+require("pgfplots.streamer")
+
+-- hm. perhaps this here should become a separate module:
+require("pgfplots.pgfplotstexio")
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.markers.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplots.markers.code.tex
new file mode 100644
index 0000000000..c836e1ea9e
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.markers.code.tex
@@ -0,0 +1,367 @@
+%--------------------------------------------
+%
+% 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-2013 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\pgfplots@markers@visphase@name@none{none}%
+\def\pgfplots@markers@visphase@name@afterpath@clipped{afterpath@clipped}%
+\def\pgfplots@markers@visphase@name@afterpath@unclipped{afterpath@unclipped}%
+\def\pgfplots@markers@visphase@name@endaxis@unclipped{endaxis@unclipped}%
+
+% defines \pgfplotsretval to contain the visualization phase used by
+% the current plot.
+\def\pgfplots@markers@survey@set@visphasename{%
+ \begingroup
+ %
+ % this validates+normalizes \tikz@plot@mark:
+ \pgfplots@markers@check@for@default@plot@mark
+ \ifx\tikz@plot@mark\pgfutil@empty
+ \ifpgfplots@scatterplotenabled
+ \def\b@pgfplots@has@plot@mark{1}%
+ \else
+ \def\b@pgfplots@has@plot@mark{0}%
+ \fi
+ \else
+ \def\b@pgfplots@has@plot@mark{1}%
+ \fi
+ %
+ % this sets \ifpgfplots@clip@marker@paths:
+ \pgfplots@markers@prepare@layered@graphics@marks
+ %
+ \if0\b@pgfplots@has@plot@mark
+ % no markers. Ok, we do not need a visualization phase for
+ % markers.
+ \let\pgfplotsretval=\pgfplots@markers@visphase@name@none
+ \else
+ \ifpgfplots@clip@marker@paths
+ \let\pgfplotsretval=\pgfplots@markers@visphase@name@afterpath@clipped
+ \else
+ \if2\pgfplots@clipmode
+ % clip mode=individual:
+ \let\pgfplotsretval=\pgfplots@markers@visphase@name@afterpath@unclipped
+ \else
+ % clip mode=global
+ \let\pgfplotsretval=\pgfplots@markers@visphase@name@endaxis@unclipped
+ \fi
+ \fi
+ \fi
+ %
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+\def\pgfplots@markers@visphase@after@axis@prepare{%
+ \global\pgfplotslistnewempty\pgfplots@stored@markerlist
+}
+
+% Draw any markers for which drawing has been postponed.
+%
+% The motivation here is that markers should be drawn on top of
+% their plots, and AFTER the clip path.
+%
+\def\pgfplots@markers@visphase@after@axis{%
+ \begingroup
+ \pgfplotslistforeach\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{%
+ \expandafter\pgfplots@stored@plotlist@EXTRACTENTRY\pgfplots@loc@TMPa
+%\message{^^JProcessing stored plot with precommand '\meaning\pgfplots@stored@current@precmd';^^J pgfplots@plotcmd '\meaning\pgfplots@stored@current@cmd'^^J postcommand '\meaning\pgfplots@stored@current@postcmd'^^J}%
+%\message{DATA: '\meaning\pgfplots@stored@current@data';^^J}%
+ % The precmd sets all required variables needed to
+ % finalize a plot.
+ % @see the stream preparation routines.
+ \pgfplots@stored@current@precmd
+ \ifx\pgfplots@markers@visphase@name\pgfplots@markers@visphase@name@endaxis@unclipped
+ \ifx\pgfplots@stored@current@cmd\pgfutil@empty
+ % Ah: some \pgfplotsextra command like \draw,\path,
+ % \node or even \scope or \endscope.
+ % Has been done earlier.
+ \else
+ \begingroup
+ % reconfigure...
+ \pgfkeyssetvalue{/pgfplots/on layer}{\pgfkeysvalueof{/pgfplots/mark layer}}%
+ %
+ % choose the one that is necessary for us here:
+ \let\pgfplots@markers@visphase@name=\pgfplots@markers@visphase@name@afterpath@unclipped
+ %
+ % provide an empty list of phase names here in order
+ % to turn off standard visualization phases: they
+ % have been applied already.
+ \pgfplots@stored@plotlist@visualize@selected@phases{}%
+ \endgroup
+ \fi
+ \pgfplots@stored@current@postcmd
+ \fi
+ }%
+ \endgroup
+}
+
+\def\pgfplots@execute@at@begin@plot@visualization@internal{%
+ \global\let\pgfplots@stored@markerlist@last=\relax
+}%
+
+\def\pgfplots@markers@install@plotmark@handler{%
+ % 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}{}%
+ %
+ %
+ % do not reset \tikz@options: draw color may be acquired
+ % from 'current plot style'
+ %\let\tikz@options=\pgfutil@empty%
+ \let\tikz@transform=\pgfutil@empty%
+ \tikzset{every plot/.try,every mark}%
+ %
+ % This sets colors:
+ \tikz@options
+ %
+ % This sets the \iftikz@mode@draw etc:
+ %\tikz@mode
+ % FIXME: using 'color=blue' will NOT activate filltrue!
+ % So: if 'tikz@mode' *contains* 'fillfalse', I know what to do...
+ % but all other cases are not clear
+ %--------------------------------------------------
+ % \iftikz@mode@draw
+ % \else
+ % % Override the marker codes: force 'draw=none'
+ % % even if the markers likes to be stroked:
+ % \let\pgfusepathqfillstroke=\pgfusepathqfill
+ % \fi
+ % \iftikz@mode@fill
+ % \else
+ % % Override the marker codes: force 'fill=none'
+ % % even if the markers likes to be filled:
+ % \let\pgfusepathqfillstroke=\pgfusepathqstroke
+ % \fi
+ %--------------------------------------------------
+ %
+ % this here is the MAIN marker code.
+ % It may be modified if scatter plot is enabled, see below.
+ \def\pgfplots@loc@TMPa{%
+ % the transformation has been reset before processing plot
+ % marks.
+ % Consequently, it applies only transformation options in "every mark".
+ \tikz@transform
+ \pgfuseplotmark{\tikz@plot@mark}%
+ }%
+ \ifpgfplots@scatterplotenabled
+ % Scatter plots work like this:
+ %
+ % <compute per-point meta info>
+ % /pgfplots/scatter/@pre marker code
+ % <marker code, lowlevel>
+ % /pgfplots/scatter/@post marker code
+ %
+ % -> that's all. The Rest is configurable with style which
+ % (re)define '@pre marker code' and '@post marker code' (see
+ % the docs for details).
+ %
+ % Prepare arguments for '@pre/@post' macros:
+ \t@pgfplots@toka={%
+ \begingroup
+ % prepare programmatic access to '/data point/x' etc:
+ \pgfplotspointgetcoordinates
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfkeysvalueof{/pgfplots/scatter/@pre marker code/.@cmd}\pgfeov
+ }%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}%
+ \t@pgfplots@tokc={%
+ \pgfkeysvalueof{/pgfplots/scatter/@post marker code/.@cmd}\pgfeov
+ \endgroup
+ }%
+ \edef\pgfplots@loc@TMPa{%
+ \the\t@pgfplots@toka
+ \the\t@pgfplots@tokb
+ \the\t@pgfplots@tokc
+ }%
+ \if r\pgfplots@scatter@position
+ % scatter/position=relative
+ %
+ % tikz transforms the coordinate system such that "(0,0)"
+ % is the point where the mark should be placed.
+ \else
+ % scatter/position=absolute
+ %
+ % ah - we do not want tikz's transformation.
+ %
+ % Disable it by means of \aftergroup hackery:
+ \t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}%
+ \xdef\pgfplots@scatter@plot@mark{%
+ \noexpand\begingroup
+ \the\t@pgfplots@tokc
+ \noexpand\endgroup
+ }%
+ \def\pgfplots@loc@TMPa{\aftergroup\pgfplots@scatter@plot@mark}%
+ \fi
+ \fi
+ \def\pgfplots@loc@TMPb##1{%
+ \ifx\tikz@mark@list\pgfutil@empty%
+ \pgfplothandlermark{##1}%
+ \else
+ \pgfplothandlermarklisted{##1}{\tikz@mark@list}%
+ \fi
+ }%
+ \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}}%
+ \edef\pgfplots@basiclevel@plothandler{\the\t@pgfplots@tokc}%
+ \expandafter\def\expandafter\pgfplots@basiclevel@plothandler\expandafter{%
+ \pgfplots@basiclevel@plothandler
+ \global\let\pgfplots@markers@plotstreamstart=\pgf@plotstreamstart
+ \def\pgf@plotstreamstart{%
+ \pgfplots@markers@plotstreamstart
+ \global\let\pgfplots@markers@mark@handler@@=\pgf@plotstreampoint
+ \global\let\pgf@plotstreampoint=\pgfplots@markers@mark@handler
+ }%
+ }%
+ \let\tikz@plot@handler=\pgfplots@basiclevel@plothandler
+ %
+ \pgfplots@basiclevel@plothandler
+ %
+}%
+
+\def\pgfplots@markers@mark@handler#1{%
+ \ifpgfplots@clip
+ % check for clip marker paths:
+ \pgfplotsaxisifcontainspoint{\pgfplots@markers@mark@handler@@{#1}}{}%
+ \else
+ \pgfplots@markers@mark@handler@@{#1}%
+ \fi
+}%
+
+\def\pgfplots@if@has@plot@marks#1#2{%
+ % make sure there is a mark set!
+ \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}%
+ \def\pgfplots@loc@TMPa{none}%
+ \ifx\tikz@plot@mark\pgfplots@loc@TMPa
+ % this here happens only in older versions of pgf.
+ \let\tikz@plot@mark\pgfutil@empty
+ \fi
+ \ifx\tikz@plot@mark\pgfutil@empty
+ #2\relax
+ \else
+ #1\relax
+ \fi
+}%
+
+\def\pgfplots@markers@check@for@default@plot@mark{%
+ \pgfplots@if@has@plot@marks{}{%
+ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
+ \ifx\pgfplots@basiclevel@plothandler\pgfplothandlerdiscard
+ % oh, the "only marks" plot handler-- and no plot mark!?
+ % what's that!?
+ \ifpgfplots@scatterplotenabled
+ % scatter handles this in /pgfplots/scatter/true
+ % automatically.
+ \else
+ % that appears to be nonsense...
+ \def\tikz@plot@mark{*}%
+ \fi
+ \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:
+ \pgfplotscoordmath{meta}{tofixed}{\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}{%
+ \pgfplotswarning{scatter classes no such class}\pgfplotspointmeta\pgfeov%
+ \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]%
+}%
+
+% validates 'mark layer' such that it can be queried afterwards.
+\def\pgfplots@markers@prepare@layered@graphics@marks{%
+ \ifpgfplots@layered@graphics
+ \pgfkeysgetvalue{/pgfplots/mark layer}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \def\pgfplots@loc@TMPa{auto}%
+ \fi
+ \def\pgfplots@loc@TMPb{auto}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % COMBINATION: 'activate layers,mark layer=auto' --> keep
+ % backwards compatibility with 'clip marker paths'
+ % -> nothing to do.
+ \pgfkeyslet{/pgfplots/mark layer}\pgfutil@empty%
+ \else
+ % mark layer=like plot
+ \def\pgfplots@loc@TMPb{like plot}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % draw markers together with their plot (no matter
+ % on which layer):
+ \pgfplots@clip@marker@pathstrue
+ \pgfkeyslet{/pgfplots/mark layer}\pgfutil@empty%
+ \else
+ \edef\pgfplots@loc@TMPb{\pgfkeysvalueof{/pgfplots/on layer}}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % nothing to do; they are on the same layer
+ % anyway: (this is the same as 'like plot'
+ \pgfplots@clip@marker@pathstrue
+ \pgfkeyslet{/pgfplots/mark layer}\pgfutil@empty%
+ \else
+ % OK, marks will be plotted on their own layer.
+ \fi
+ \fi
+ \fi
+ \else
+ % reset its value:
+ \pgfkeyslet{/pgfplots/mark layer}\pgfutil@empty%
+ \fi
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.paths.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplots.paths.code.tex
new file mode 100644
index 0000000000..077a3a2b95
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.paths.code.tex
@@ -0,0 +1,71 @@
+%--------------------------------------------
+%
+% 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-2012 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/>.
+%
+%--------------------------------------------
+%
+
+\newif\ifpgfplots@path@replace@ellipse
+
+\def\pgfplots@install@path@replacements{%
+ \ifpgfplots@path@replace@ellipse
+ \let\tikz@do@circle=\pgfplots@path@@tikz@do@circle
+ \expandafter\def\expandafter\pgfinterruptpicture\expandafter{\pgfinterruptpicture
+ \let\tikz@do@circle=\pgfplots@path@@tikz@do@circle@orig
+ }%
+ \fi
+}%
+
+\let\pgfplots@path@@tikz@do@circle@orig=\tikz@do@circle
+
+% This is a replacement for \tikz@do@circle which replaces the "xy"
+% coordinate system by one which is compatible with pgfplots.
+\def\pgfplots@path@@tikz@do@circle#1#2{%
+ \begingroup
+ \ifpgfplots@usefpu
+ \pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
+ \fi
+ \pgfmathparse{#1}%
+ \let\tikz@ellipse@x=\pgfmathresult%
+ \ifpgfmathunitsdeclared%
+ \pgfmathparse{#2}%
+ \let\tikz@ellipse@y=\pgfmathresult%
+ \ifpgfmathunitsdeclared%
+ \pgfpathellipse{\pgfpointorigin}{%
+ \pgfqpoint{\tikz@ellipse@x pt}{0pt}}{\pgfpoint{0pt}{\tikz@ellipse@y pt}}%
+ \else%
+ \PackageError{tikz}{You cannot mix dimensions and dimensionless values in an ellipse}{}%
+ \fi%
+ \else%
+ \pgfmathparse{#2}%
+ \let\tikz@ellipse@y=\pgfmathresult%
+ \ifpgfmathunitsdeclared%
+ \PackageError{tikz}{You cannot mix dimensions and dimensionless values in an ellipse}{}%
+ \else%
+ \pgfpathellipse{\pgfpointorigin}
+ {\pgfplotspointaxisdirectionxy{\tikz@ellipse@x}{0}}
+ {\pgfplotspointaxisdirectionxy{0}{\tikz@ellipse@y}}%
+ \fi%
+ \fi%
+ \endgroup
+}
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.revision.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplots.revision.tex
new file mode 100644
index 0000000000..6dbe7ab108
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.revision.tex
@@ -0,0 +1,15 @@
+\begingroup
+\catcode`\-=12
+\catcode`\/=12
+\catcode`\.=12
+\catcode`\:=12
+\catcode`\+=12
+\catcode`\-=12
+\gdef\pgfplotsrevision{1.16}
+\gdef\pgfplotsversion{1.16}
+\gdef\pgfplotsversiondatetime{2018-03-28 20:42:04 +0200}
+\gdef\pgfplotsrevisiondatetime{2018-03-28 20:42:04 +0200}
+\gdef\pgfplots@glob@TMPa#1-#2-#3 #4\relax{#1/#2/#3}
+\xdef\pgfplotsversiondate{\expandafter\pgfplots@glob@TMPa\pgfplotsversiondatetime\relax}
+\xdef\pgfplotsrevisiondate{\expandafter\pgfplots@glob@TMPa\pgfplotsrevisiondatetime\relax}
+\endgroup
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.scaling.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplots.scaling.code.tex
new file mode 100644
index 0000000000..d5d045ddfb
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.scaling.code.tex
@@ -0,0 +1,3399 @@
+%--------------------------------------------
+%
+% 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-2012 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/>.
+%
+%--------------------------------------------
+
+% PRECONDITION:
+% - final axis limits are given in transformed range
+% - \pgfplots@set@default@size@options has been invoked before
+% POSTCONDITION:
+% - 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.
+ %
+ %
+ \pgfplots@xmin@reg=\pgfplots@xmin pt %
+ \pgfplots@xmax@reg=\pgfplots@xmax pt %
+ \pgfplots@ymin@reg=\pgfplots@ymin pt %
+ \pgfplots@ymax@reg=\pgfplots@ymax pt %
+ \ifpgfplots@threedim
+ \pgfplots@zmin@reg=\pgfplots@zmin pt %
+ \pgfplots@zmax@reg=\pgfplots@zmax pt %
+ \fi
+ %
+ %-----------------------------------------
+ % PROCESS THE 'width' and 'height' options
+ %-----------------------------------------
+ %
+ %
+ \pgfkeysgetvalue{/pgfplots/view/az}{\pgfplots@view@az}%
+ \pgfkeysgetvalue{/pgfplots/view/el}{\pgfplots@view@el}%
+ \ifpgfplots@threedim
+ \else
+ \let\pgfplots@view@el=\pgfutil@empty
+ \let\pgfplots@view@az=\pgfutil@empty
+ \fi
+ \ifx\pgfplots@view@az\pgfutil@empty
+ % Note that in presence of "x,y,z" options, the
+ % \pgfplots@set@default@size@options RESETS /pgfplots/view/az.
+ %
+ %\let\pgfplots@rectangle@width=\pgfutil@empty
+ %\let\pgfplots@rectangle@height=\pgfutil@empty
+ \pgfplotsmathvectorfromstring{0,0,1}{default}%
+ \let\pgfplots@view@dir@threedim=\pgfplotsretval
+ %
+ \ifx\pgfplots@x\pgfutil@empty
+ \ifx\pgfplots@width\pgfutil@empty
+ \pgfplots@error{INTERNAL LOGIC ERROR! WIDTH NOT SET}%
+ \fi
+ \fi
+ %
+ \ifx\pgfplots@y\pgfutil@empty
+ \ifx\pgfplots@height\pgfutil@empty
+ \pgfplots@error{INTERNAL LOGIC ERROR! HEIGHT NOT SET}%
+ \fi
+ \fi
+ \ifpgfplots@threedim
+ \def\pgfplots@tmp@Zscale{1}%
+ \else
+ \def\pgfplots@tmp@Zscale{0}%
+ \fi
+ %
+ \pgfplots@initsizes@setunitvector{x}{0}{1}{\pgfplots@tmp@xisaxisparallel}%
+ \pgfplots@initsizes@setunitvector{y}{1}{1}{\pgfplots@tmp@yisaxisparallel}%
+ \pgfplots@initsizes@setunitvector{z}{2}{\pgfplots@tmp@Zscale}{\pgfplots@loc@TMPc}%
+ %
+ \pgfplots@scaling@changewidthheight@for@enlargelimits@by@dimension%
+ %
+ \pgfplots@scale@plotbox@to@widthheight
+ \else
+ % 3D case by `view':
+ \let\pgfplots@x=\pgfutil@empty
+ \let\pgfplots@y=\pgfutil@empty
+ \let\pgfplots@z=\pgfutil@empty
+ \pgfplotssetaxesfromazel{\pgfplots@view@az}{\pgfplots@view@el}{\pgfplots@tmp@xisaxisparallel}%
+ %
+ \pgfplots@scaling@changewidthheight@for@enlargelimits@by@dimension%
+ %
+ \pgfplots@scale@plotbox@to@widthheight
+ \if1\pgfplots@tmp@xisaxisparallel%
+ \def\pgfplots@tmp@yisaxisparallel{1}%
+ \fi
+ \fi
+ \pgfplots@computeunitvectorlengths
+ %
+ \pgfplots@scaling@apply@enlargelimits@by@dimension{x}%
+ \pgfplots@scaling@apply@enlargelimits@by@dimension{y}%
+ \ifpgfplots@threedim
+ \pgfplots@scaling@apply@enlargelimits@by@dimension{z}%
+ \fi
+ %
+ \ifpgfplots@threedim
+ \pgfplotsgetnormalforcurrentview
+ \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), n = (\pgfplots@view@dir@threedim). Limits are x=\pgfplots@xmin:\pgfplots@xmax, y=\pgfplots@ymin:\pgfplots@ymax^^J }%
+ %
+ \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%
+ % Optimize for axis-parallel case!
+ % puh. Did not make any measureable difference!? Ok...
+ \let\pgfplotsqpointxy=\pgfplotsqpointxy@orthogonal
+ \fi
+ \fi
+ \fi
+}
+
+% 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 cannot be implemented 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
+}%
+
+% #1: axis
+\def\pgfplots@axis@apply@post@scale#1{%
+ %
+ \pgfkeysgetvalue{/pgfplots/#1 post scale}\pgfplots@loc@TMPd
+ \ifx\pgfplots@loc@TMPd\pgfutil@empty
+ \else
+ \pgfmathparse{\csname pgfplots@target@unit@scale@#1x\endcsname*\pgfplots@loc@TMPd}%
+ \expandafter\let\csname pgfplots@target@unit@scale@#1x\endcsname=\pgfmathresult
+ %
+ \pgfmathparse{\csname pgfplots@target@unit@scale@#1y\endcsname*\pgfplots@loc@TMPd}%
+ \expandafter\let\csname pgfplots@target@unit@scale@#1y\endcsname=\pgfmathresult
+ \fi
+}
+
+% 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'.
+%
+% '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(azimuth) -sin(azimuth) 0; ...
+% sin(azimuth) cos(azimuth) 0; ...
+% 0 0 1 ];
+%
+%
+% Ax = [ 1 0 0; ...
+% 0 cos(elevation) -sin(elevation) ;...
+% 0 sin(elevation) cos(elevation) ];
+%
+% v= Ax * Az;
+% = [ ...
+% cosaz -sinaz cosel sinaz sinel; ...
+% sinaz cosaz cosel -sinel cosaz; ...
+% 0 sinel cosel ];
+%
+% 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 '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] )
+% = [ 0, cosel]'
+%
+% 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 : 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. azimuth=0, elevation=90).
+% - [xyz] vectors,
+% \pgfplots@view@dir@threedim will contain the three components
+% of 'n' (without the suffix 'pt', but in units of 'pt') (see
+% \pgfplotsmathvectorfromstring).
+\def\pgfplotssetaxesfromazel#1#2#3{%
+ \begingroup
+ \pgfmathparse{#1}%
+ \let\pgfplots@az=\pgfmathresult
+ \pgfmathparse{#2}%
+ \edef\pgfplots@el{-\pgfmathresult}%
+ \pgfmathsin@{\pgfplots@az}%
+ \let\sinaz=\pgfmathresult
+ \pgfmathcos@{\pgfplots@az}%
+ \let\cosaz=\pgfmathresult
+ \pgfmathsin@{\pgfplots@el}%
+ \let\sinel=\pgfmathresult
+ \pgfmathcos@{\pgfplots@el}%
+ \let\cosel=\pgfmathresult
+ % x:
+ \pgfmathmultiply@{\sinaz}{\sinel}%
+ \xdef\pgfplots@glob@TMPa{\noexpand\pgfqpoint{\cosaz pt}{\pgfmathresult pt}}%
+ % y:
+ \pgfmathmultiply@{-\sinel}{\cosaz}%
+ \xdef\pgfplots@glob@TMPb{\noexpand\pgfqpoint{\sinaz pt}{\pgfmathresult pt}}%
+ % z:
+ \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
+ %
+ % Process 'plot box ratio':
+ \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
+ }%
+ \def\pgfplots@extract@plot@box@ratio@spaces##1 ##2 ##3 ##4\pgfplots@EOI{%
+ \pgfplots@extract@plot@box@ratio{##1}{##2}{##3}{##4}\pgfplots@EOI
+ }%
+ \pgfkeysgetvalue{/pgfplots/plot box ratio}\pgfplots@loc@TMPa
+ % Auto-determine input format which is either '{x}{y}{z}' or 'x y z'
+ \def\pgfplots@loc@TMPb{%
+ \pgfutil@ifnextchar\bgroup{%
+ \pgfplots@loc@tmptrue
+ \pgfplots@gobble@until@EOI
+ }{%
+ \pgfplots@loc@tmpfalse
+ \pgfplots@gobble@until@EOI
+ }%
+ }%
+ \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI
+ \ifpgfplots@loc@tmp
+ % Ah- braces format.
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa{1}{1}{1}}%
+ \expandafter\pgfplots@extract@plot@box@ratio\pgfplots@loc@TMPa\pgfplots@EOI
+ \else
+ % Ah- space-separated
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa\space 1 1 1}%
+ \expandafter\pgfplots@extract@plot@box@ratio@spaces\pgfplots@loc@TMPa\pgfplots@EOI
+ \fi
+ %
+ % process it:
+ \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^^J x = \meaning\pgfplots@glob@TMPa,^^J y = \meaning\pgfplots@glob@TMPb,^^J z = \meaning\pgfplots@glob@TMPc,^^J n = \pgfplots@glob@TMPd.^^J}%
+ \pgfsetxvec{\pgfplots@glob@TMPa}%
+ \pgfsetyvec{\pgfplots@glob@TMPb}%
+ \pgfsetzvec{\pgfplots@glob@TMPc}%
+ \def\pgfplots@loc@TMPa##1##2##3{%
+ \pgfplotsmathvectorfromstring{##1,##2,##3}{default}%
+ \let\pgfplots@view@dir@threedim=\pgfplotsretval
+ }%
+ \expandafter\pgfplots@loc@TMPa\pgfplots@glob@TMPd\relax
+ \def#3{0}%
+}%
+
+% Takes the current plot box, defined by the actual PGF x,y and z unit
+% vectors, and re-scales it such that it fits into the
+% width and height of the axis (as they have been provided by the
+% user).
+%
+% @see \pgfplots@scale@axisbox@to@widthheight
+% @see\pgfplots@scaleaxes@to@BB
+\def\pgfplots@scale@plotbox@to@widthheight{%
+ \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
+}
+
+
+% 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 relative length of the input vectors is important for the 3D case: it
+% will be scaled as-is.
+%
+% PRECONDITION
+% - the x, y and z unit vectors have been set to the proper
+% DIRECTIONS. Their relative vector lengths are set-up properly
+% (i.e. y is twice as large as x and half as large as z or so).
+% - the \ifpgfplots@threedim boolean is set.
+% - the data limits have been initialised and transformed according
+% to the data transformation.
+% - the data transformation has ONLY been applied to the axis limits
+% (not other axis inputs). It may be changed by this method.
+%
+% POSTCONDITION
+% - the unit vectors have been re-scaled such that the final plot
+% has the desired dimensions.
+% - the @veclength and @inverseveclength have been initialized
+\def\pgfplots@scaleaxes@to@BB#1#2{%
+ \if0\pgfplots@scale@mode@choice
+ % scale mode=auto
+ \def\pgfplots@scale@mode@choice{2}% stretch to fill
+ \fi
+ \pgfplots@scaleaxes@to@BB@{#1}{#2}%
+ % NOTE: we have not yet computed the lengths of unit vectors. In
+ % addition, we have not yet updated the normal vector.
+}%
+
+% DEPRECATED:
+\def\pgfplots@rescale@view@dir{%
+ \expandafter\ifx\csname pgfplots@view@dir@threedim\endcsname\relax
+ \else
+ % At this point, we ALREADY HAVE a normal vector. However, it
+ % might be skewed due to the scaling.
+ %
+ % -> recompute normal vector. In earlier versions, I tried to
+ % rescale it - but that was too complicated (for me). This
+ % here produces correct results, and it is a correct approach
+ % anyway.
+ \pgfplotsgetnormalforcurrentview
+ \fi
+}%
+
+% \pgfplots@BB@for@plotbox@get@unit@scales@for@limits{#1}{#2}{#3}:
+% a helper tool which computes individual unit vector scales in order
+% to respect the limits.
+%
+% This method ignores width/height; its purpose is only to make sure
+% that [xmin,xmax] fits into the CURRENT plot box.
+%
+% In this context, each unit vector is supposed to be scaled such that
+% width/height fit if xmin=0 and xmax=1.
+%
+% #1 [output] a macro name which will contain the INVERSE scale for x
+% #2 [output] a macro name which will contain the INVERSE scale for y
+% #3 [output] a macro name which will contain the INVERSE scale for z
+%
+\def\pgfplots@BB@for@plotbox@get@unit@scales@for@limits#1#2#3{%
+ \if1\b@pgfplots@plotbox@xisunit
+ % Consequently, we have to multiply with 1/(max-min):
+ % compute 1/(xmax - xmin) in float for more recent versions (see /pgfplots/compat/scaling).
+ % I observed that it is much more accurate
+ \pgfmathsubtract@{\pgfplots@xmax}{\pgfplots@xmin}%
+ \else
+ \def\pgfmathresult{1}%
+ \fi
+ \let#1=\pgfmathresult
+ %
+ \if1\b@pgfplots@plotbox@yisunit
+ \pgfmathsubtract@{\pgfplots@ymax}{\pgfplots@ymin}%
+ \else
+ \def\pgfmathresult{1}%
+ \fi
+ \let#2=\pgfmathresult
+ %
+ \ifpgfplots@threedim
+ \if1\b@pgfplots@plotbox@zisunit
+ \pgfmathsubtract@{\pgfplots@zmax}{\pgfplots@zmin}%
+ \else
+ \def\pgfmathresult{1}%
+ \fi
+ \else
+ \def\pgfmathresult{1}%
+ \fi
+ \let#3=\pgfmathresult
+}%
+\def\pgfplots@BB@for@plotbox{%
+ \ifpgfplots@threedim
+ \pgfpathmoveto{\pgfqpointxyz\pgfplots@plotbox@xmin\pgfplots@plotbox@ymin\pgfplots@plotbox@zmin}%
+ \pgfpathmoveto{\pgfqpointxyz\pgfplots@plotbox@xmin\pgfplots@plotbox@ymin\pgfplots@plotbox@zmax}%
+ \pgfpathmoveto{\pgfqpointxyz\pgfplots@plotbox@xmin\pgfplots@plotbox@ymax\pgfplots@plotbox@zmin}%
+ \pgfpathmoveto{\pgfqpointxyz\pgfplots@plotbox@xmin\pgfplots@plotbox@ymax\pgfplots@plotbox@zmax}%
+ \pgfpathmoveto{\pgfqpointxyz\pgfplots@plotbox@xmax\pgfplots@plotbox@ymin\pgfplots@plotbox@zmin}%
+ \pgfpathmoveto{\pgfqpointxyz\pgfplots@plotbox@xmax\pgfplots@plotbox@ymin\pgfplots@plotbox@zmax}%
+ \pgfpathmoveto{\pgfqpointxyz\pgfplots@plotbox@xmax\pgfplots@plotbox@ymax\pgfplots@plotbox@zmin}%
+ \pgfpathmoveto{\pgfqpointxyz\pgfplots@plotbox@xmax\pgfplots@plotbox@ymax\pgfplots@plotbox@zmax}%
+ \else
+ \pgfpathmoveto{\pgfqpointxy\pgfplots@plotbox@xmin\pgfplots@plotbox@ymin}%
+ \pgfpathmoveto{\pgfqpointxy\pgfplots@plotbox@xmin\pgfplots@plotbox@ymax}%
+ \pgfpathmoveto{\pgfqpointxy\pgfplots@plotbox@xmax\pgfplots@plotbox@ymin}%
+ \pgfpathmoveto{\pgfqpointxy\pgfplots@plotbox@xmax\pgfplots@plotbox@ymax}%
+ \fi
+}%
+
+
+
+% Returns width and height of the current plot box
+% (the path produced by \pgfplots@BB@for@plotbox).
+%
+% PRECONDITION: \pgfplots@BB@for@plotbox is defined to produce a path
+% for the plot box
+%
+% POSTCONDITION: \pgfplotsretval contains the with and
+% \pgfplotsretvalb contains the height
+\def\pgfplots@get@dimension@of@BB{%
+ \begingroup
+ \pgfinterruptboundingbox
+ %
+ % the result of this call will be used to scale to target
+ % dimensions. If we omit \pgftransformreset here, we might
+ % accidentally UNDO the PGF transformation matrix (compare by
+ % writing \tikzpicture[scale=0.5] before the axis).
+ \pgftransformreset
+ %
+ % STEP 1: compute the bounding box for the plot box.
+ \pgfplots@BB@for@plotbox
+ %
+ % TMPa = width
+ \pgf@xa=\pgf@pathmaxx
+ \advance\pgf@xa by-\pgf@pathminx
+ % TMPb = height
+ \pgf@xb=\pgf@pathmaxy
+ \advance\pgf@xb by-\pgf@pathminy
+ \xdef\pgfplots@glob@TMPa{%
+ \def\noexpand\pgfplotsretval{\the\pgf@xa}%
+ \def\noexpand\pgfplotsretvalb{\the\pgf@xb}%
+ }%
+ \pgfusepath{discard}%
+ \endpgfinterruptboundingbox
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+\def\pgfplots@scaleaxes@to@BB@prepare@plotbox@limits{%
+ \def\b@pgfplots@rescale@x{1}%
+ \def\b@pgfplots@rescale@y{1}%
+ \def\b@pgfplots@rescale@z{1}%
+ %
+ \pgfplots@scaleaxes@to@BB@prepare@plotbox@limits@ x%
+ \pgfplots@scaleaxes@to@BB@prepare@plotbox@limits@ y%
+ \pgfplots@scaleaxes@to@BB@prepare@plotbox@limits@ z%
+}%
+
+\def\pgfplots@scaleaxes@to@BB@prepare@plotbox@limits@#1{%
+ \expandafter\ifx\csname pgfplots@#1\endcsname\pgfutil@empty
+ % Ah - we have no unit vector in this direction.
+ \expandafter\def\csname pgfplots@plotbox@#1min\endcsname{0}%
+ \expandafter\def\csname pgfplots@plotbox@#1max\endcsname{1}%
+ \expandafter\def\csname b@pgfplots@plotbox@#1isunit\endcsname{1}%
+ \else
+ % we have a unit vector... prepare for limits. Note that the
+ % unit vector has been prepared for data scaling already.
+ \pgfutil@namelet{pgfplots@plotbox@#1min}{pgfplots@#1min}%
+ \pgfutil@namelet{pgfplots@plotbox@#1max}{pgfplots@#1max}%
+ \expandafter\def\csname b@pgfplots@plotbox@#1isunit\endcsname{0}%
+ \if2\pgfplots@scale@mode@choice
+ % scale mode=stretch to fill
+ % do NOT rescale unit vectors for stretch to fill :
+ \expandafter\def\csname b@pgfplots@rescale@#1\endcsname{0}%
+ \fi
+ \fi
+ \expandafter\def\csname b@pgfplots@unitvec@is@zero@#1\endcsname{0}%
+ \ifdim\csname pgf@#1x\endcsname=0pt %
+ \ifdim\csname pgf@#1y\endcsname=0pt %
+ \expandafter\def\csname b@pgfplots@unitvec@is@zero@#1\endcsname{1}%
+ \fi
+ \fi
+}
+
+
+\def\pgfplots@scaleaxes@to@BB@#1#2{%
+ \begingroup
+%\message{SCALING: scale mode choice = \pgfplots@scale@mode@choice^^J}%
+ %
+ \pgfplots@scaleaxes@to@BB@prepare@plotbox@limits
+ \def\pgfplots@target@limitrescale@x{1}%
+ \def\pgfplots@target@limitrescale@y{1}%
+ \def\pgfplots@target@limitrescale@z{1}%
+ \if1\pgfplots@scale@mode@choice
+ % scale mode=none
+ \def\xscale{1}%
+ \def\yscale{1}%
+ \def\pgfplots@target@unit@scale@inv@x{1}%
+ \def\pgfplots@target@unit@scale@inv@y{1}%
+ \def\pgfplots@target@unit@scale@inv@z{1}%
+ \else
+ %
+ % This here CAN cause anisotropic (different) scaling factors.
+ \pgfplots@BB@for@plotbox@get@unit@scales@for@limits
+ {\pgfplots@target@unit@scale@inv@x}
+ {\pgfplots@target@unit@scale@inv@y}
+ {\pgfplots@target@unit@scale@inv@z}%
+ %
+%\message{got scales to fit limits into BB: x=1/\pgfplots@target@unit@scale@inv@x, y=1/\pgfplots@target@unit@scale@inv@y, z=1/\pgfplots@target@unit@scale@inv@z^^J}%
+ %
+ \if3\pgfplots@scale@mode@choice
+ % scale mode=scale uniformly
+ %
+ % We need to recompensate in case the previous method chose
+ % different unit scaling scalings:
+ \pgfplots@BB@for@plotbox@get@unit@scales@compensated@axis@limits
+ {\pgfplots@target@unit@scale@inv@x}
+ {\pgfplots@target@unit@scale@inv@y}
+ {\pgfplots@target@unit@scale@inv@z}
+ {\pgfplots@target@limitrescale@x}{\pgfplots@target@limitrescale@y}{\pgfplots@target@limitrescale@z}%
+ %
+ %\pgfplots@BB@update@cumulative@limit@compensations
+ \fi
+%\message{adjusted scales for 'scale mode': x=1/\pgfplots@target@unit@scale@inv@x, y=1/\pgfplots@target@unit@scale@inv@y, z=1/\pgfplots@target@unit@scale@inv@z; ^^J axis limit componsation scales x=\pgfplots@target@limitrescale@x, y=\pgfplots@target@limitrescale@y, z=\pgfplots@target@limitrescale@z^^J}%
+ %
+ % ATTENTION: this MODIFIES \pgfplots@target@limitrescale@x and its
+ % variants directly - and it needs the input values.
+ \pgfplots@get@scale@horiz@and@vert
+ {#1}%
+ {#2}%
+ {\xscale}%
+ {\yscale}% yscale
+ {\pgfplots@target@limitrescale@x}%
+ {\pgfplots@target@limitrescale@y}%
+ {\pgfplots@target@limitrescale@z}%
+%\message{Got W/H scale for all x components: \xscale; for all y components: \xscale; ^^J axis limit componsation scales x=1/\pgfplots@target@limitrescale@x, y=1/\pgfplots@target@limitrescale@y, z=1/\pgfplots@target@limitrescale@z^^J}%
+ % Ok, we know the W,H scalings now.
+ %
+ %
+ %
+ \pgfplots@apply@unit@ratio
+ {\pgfplots@target@unit@scale@inv@x}
+ {\pgfplots@target@unit@scale@inv@y}
+ {\pgfplots@target@unit@scale@inv@z}
+ {\pgfplots@target@limitrescale@x@}{\pgfplots@target@limitrescale@y@}{\pgfplots@target@limitrescale@z@}%
+ \pgfplots@BB@update@cumulative@limit@compensations
+ %
+%\message{adjusted scales for 'unit vector ratio': x=1/\pgfplots@target@unit@scale@inv@x, y=1/\pgfplots@target@unit@scale@inv@y, z=1/\pgfplots@target@unit@scale@inv@z; ^^J axis limit componsation scales x=\pgfplots@target@limitrescale@x, y=\pgfplots@target@limitrescale@y, z=\pgfplots@target@limitrescale@z^^J}%
+ \fi
+ %
+ %
+ \pgfplots@scaling@minimize@limitrescale%
+ %
+ %
+ \pgfplots@scaling@adjust@datascaling%
+%\message{adjusted scales for data scale trafo: x=1/\pgfplots@target@unit@scale@inv@x, y=1/\pgfplots@target@unit@scale@inv@y, z=1/\pgfplots@target@unit@scale@inv@z; ^^J axis limit componsation scales x=\pgfplots@target@limitrescale@x, y=\pgfplots@target@limitrescale@y, z=\pgfplots@target@limitrescale@z;^^J data scale trafo exponents x=\pgfplots@target@datascaletrafo@x@exponent@old -> \pgfplots@target@datascaletrafo@x@exponent, y=\pgfplots@target@datascaletrafo@y@exponent@old -> \pgfplots@target@datascaletrafo@y@exponent, z=\pgfplots@target@datascaletrafo@z@exponent@old -> \pgfplots@target@datascaletrafo@z@exponent^^J}%
+ %
+ \pgfplots@scaling@compute@final@scales%
+ {\xscale}{\yscale}%
+ {\pgfplots@target@unit@scale@inv@x}%
+ {\pgfplots@target@unit@scale@inv@y}%
+ {\pgfplots@target@unit@scale@inv@z}%
+ %
+ \pgfplots@axis@apply@post@scale{x}%
+ \pgfplots@axis@apply@post@scale{y}%
+ \ifpgfplots@threedim
+ \pgfplots@axis@apply@post@scale{z}%
+ \fi
+ %
+ % and finally, resize limits appropriately and add all cumulative limit compensations:
+ \xdef\pgfplots@glob@TMPa{%
+ %
+ \pgf@xx=\pgfplots@target@unit@scale@xx\pgf@xx
+ \pgf@xy=\pgfplots@target@unit@scale@xy\pgf@xy
+ %
+ \pgf@yx=\pgfplots@target@unit@scale@yx\pgf@yx
+ \pgf@yy=\pgfplots@target@unit@scale@yy\pgf@yy
+ %
+ \ifpgfplots@threedim
+ \pgf@zx=\pgfplots@target@unit@scale@zx\pgf@zx
+ \pgf@zy=\pgfplots@target@unit@scale@zy\pgf@zy
+ \fi
+ %
+ \noexpand\pgfplots@apply@datascaletrafo@change@{x}{\pgfplots@target@datascaletrafo@x@exponent}%
+ \noexpand\pgfplots@apply@datascaletrafo@change@{y}{\pgfplots@target@datascaletrafo@y@exponent}%
+ \noexpand\pgfplots@apply@datascaletrafo@change@{z}{\pgfplots@target@datascaletrafo@z@exponent}%
+ %
+ \noexpand\pgfplots@apply@unit@vector@rescale@keep@size{x}{\pgfplots@target@limitrescale@x}%
+ \noexpand\pgfplots@apply@unit@vector@rescale@keep@size{y}{\pgfplots@target@limitrescale@y}%
+ \noexpand\pgfplots@apply@unit@vector@rescale@keep@size{z}{\pgfplots@target@limitrescale@z}%
+ %
+ \noexpand\pgfplots@notify@final@scalings{%
+ x unit scale=\pgfplots@target@unit@scale@x,%
+ y unit scale=\pgfplots@target@unit@scale@y,%
+ z unit scale=\pgfplots@target@unit@scale@z,%
+ x datatrafo exponent=\pgfplots@target@datascaletrafo@x@exponent,%
+ y datatrafo exponent=\pgfplots@target@datascaletrafo@y@exponent,%
+ z datatrafo exponent=\pgfplots@target@datascaletrafo@z@exponent,%
+ x limit rescale=\pgfplots@target@limitrescale@x,%
+ y limit rescale=\pgfplots@target@limitrescale@y,%
+ z limit rescale=\pgfplots@target@limitrescale@z,%
+ }%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+% Checks for the case the ALL (visible) limit compensation scales are
+% bigger than one (for example x = 1.22, y = 2). In such a case, we
+% want to MINIMIZE the rescaling. This can happen if unit vector ratio
+% is active.
+%
+% In our example, we want to use limit rescaling factors x = 1, y = 2/1.22
+% and, consequently, unit rescaling factors x *= 1.22, y *= 1.22 .
+%
+% This method checks for the case and applies the rescaling if
+% necessary.
+%
+\def\pgfplots@scaling@minimize@limitrescale{%
+ % boolean allLimitScalesAreBiggerThanOne;
+ \pgfplots@loc@tmptrue
+ \if0\b@pgfplots@unitvec@is@zero@x
+ \ifdim\pgfplots@target@limitrescale@x pt<1.002pt %
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+ \if0\b@pgfplots@unitvec@is@zero@y
+ \ifdim\pgfplots@target@limitrescale@y pt<1.002pt %
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+ \if0\b@pgfplots@unitvec@is@zero@z
+ \ifdim\pgfplots@target@limitrescale@z pt<1.002pt %
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+ %
+ \ifpgfplots@loc@tmp
+ \begingroup
+ % Ah -- all non-vanishing limit rescaling factors are BIGGER
+ % THAN ONE.
+ % In this case, we can save some rescalings!
+ %
+ % Search for the smallest rescaling factor.
+ \let\pgfplots@smallest=\pgf@x
+ \pgfplots@smallest=16000pt %
+ \def\pgfplots@smallest@arg{}%
+ \if0\b@pgfplots@unitvec@is@zero@x
+ \pgf@xa=\pgfplots@target@limitrescale@x pt %
+ \ifdim\pgf@xa<\pgfplots@smallest%
+ \pgfplots@smallest=\pgf@xa
+ \def\pgfplots@smallest@arg{x}%
+ \fi
+ \fi
+ \if0\b@pgfplots@unitvec@is@zero@y
+ \pgf@xa=\pgfplots@target@limitrescale@y pt %
+ \ifdim\pgf@xa<\pgfplots@smallest%
+ \pgfplots@smallest=\pgf@xa
+ \def\pgfplots@smallest@arg{y}%
+ \fi
+ \fi
+ \if0\b@pgfplots@unitvec@is@zero@z
+ \pgf@xa=\pgfplots@target@limitrescale@z pt %
+ \ifdim\pgf@xa<\pgfplots@smallest%
+ \pgfplots@smallest=\pgf@xa
+ \def\pgfplots@smallest@arg{z}%
+ \fi
+ \fi
+ %
+ % OK. We have the smallest scaling factor. It is > 1.
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@target@limitrescale@x}%
+ \let\pgfplots@target@limitrescale@x=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@target@limitrescale@y}%
+ \let\pgfplots@target@limitrescale@y=\pgfmathresult
+ %
+ %
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@target@unit@scale@inv@x}%
+ \let\pgfplots@target@unit@scale@inv@x=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@target@unit@scale@inv@y}%
+ \let\pgfplots@target@unit@scale@inv@y=\pgfmathresult
+ %
+ \if0\b@pgfplots@unitvec@is@zero@z
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@target@limitrescale@z}%
+ \let\pgfplots@target@limitrescale@z=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@target@unit@scale@inv@z}%
+ \let\pgfplots@target@unit@scale@inv@z=\pgfmathresult
+ \fi
+ %
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\csname pgfplots@target@limitrescale@\pgfplots@smallest@arg\endcsname}}%
+ \let\scale=\pgfmathresult
+ %
+ \pgfplotsforeachentryinCSV\value{%
+ \pgfplots@target@unit@scale@inv@x,%
+ \pgfplots@target@unit@scale@inv@y,%
+ \pgfplots@target@limitrescale@x,%
+ \pgfplots@target@limitrescale@y%
+ }{%
+ \pgfplotscoordmath{default}{op}{multiply}{{\scale}{\value}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \expandafter\let\value=\pgfmathresult
+ }%
+ \if0\b@pgfplots@unitvec@is@zero@z
+ \pgfplotsforeachentryinCSV\value{%
+ \pgfplots@target@unit@scale@inv@z,%
+ \pgfplots@target@limitrescale@z%
+ }{%
+ \pgfplotscoordmath{default}{op}{multiply}{{\scale}{\value}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \expandafter\let\value=\pgfmathresult
+ }%
+ \fi
+ %
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand\pgfplots@target@unit@scale@inv@x{\pgfplots@target@unit@scale@inv@x}%
+ \noexpand\def\noexpand\pgfplots@target@unit@scale@inv@y{\pgfplots@target@unit@scale@inv@y}%
+ \noexpand\def\noexpand\pgfplots@target@unit@scale@inv@z{\pgfplots@target@unit@scale@inv@z}%
+ \noexpand\def\noexpand\pgfplots@target@limitrescale@x{\pgfplots@target@limitrescale@x}%
+ \noexpand\def\noexpand\pgfplots@target@limitrescale@y{\pgfplots@target@limitrescale@y}%
+ \noexpand\def\noexpand\pgfplots@target@limitrescale@z{\pgfplots@target@limitrescale@z}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+%
+%\message{adjusted scales by minimizing common scaling factors: x=1/\pgfplots@target@unit@scale@inv@x, y=1/\pgfplots@target@unit@scale@inv@y, z=1/\pgfplots@target@unit@scale@inv@z; ^^J axis limit componsation scales x=\pgfplots@target@limitrescale@x, y=\pgfplots@target@limitrescale@y, z=\pgfplots@target@limitrescale@z;^^J}%
+ \fi
+}%
+
+% Defines
+% \pgfplots@target@unit@scale@xx
+% \pgfplots@target@unit@scale@xy
+% \pgfplots@target@unit@scale@yx
+% \pgfplots@target@unit@scale@yy
+% \pgfplots@target@unit@scale@zx
+% \pgfplots@target@unit@scale@zy
+% %
+% \pgfplots@target@unit@scale@x
+% \pgfplots@target@unit@scale@y
+% \pgfplots@target@unit@scale@z
+% by combining the input args.
+%
+% #1: the scale to be applied to ALL x components
+% #2: the scale to be applied to ALL y components
+% #3: the scale to be applied to x unit
+% #4: the scale to be applied to y unit
+% #5: the scale to be applied to z unit
+\def\pgfplots@scaling@compute@final@scales#1#2#3#4#5{%
+ % ##1: the axis (x,y,or z)
+ % ##2: the horizontal scale
+ % ##3: the vertical scale
+ % ##4: the inverse unit scale for this axis
+ \def\pgfplots@loc@TMPa##1##2##3##4{%
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{##2}%
+ \let\xscale@@=\pgfmathresult
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{##3}%
+ \let\yscale@@=\pgfmathresult
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{##4}%
+ \let\unitscale@inv@@=\pgfmathresult
+ %
+ % NOTE : it *would* be more efficient to use
+ % 1/\unitscale@inv@@ in the routines above. BUT THAT IS NOT BACKWARDS COMPATIBLE.
+ % Leave it this way!
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{op}{reciprocal}{{\unitscale@inv@@}}%
+ \let\unitscale@@=\pgfmathresult
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{tofixed}{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@target@unit@scale@##1\endcsname=\pgfmathresult
+ %
+ %
+ \ifx\pgfplots@compat@scaling@coordmath@final\pgfplots@compat@scaling@coordmath
+ \else
+ % backwards compatibility is such a burden.... :-(
+ %
+ % earlier versions relied on TeX's dimen arithmetics to
+ % multiply the final scales. Make sure we do the same -
+ % rounding errors on unit vectors are instable, i.e. the
+ % errors add up considerably.
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{parsenumber}{\xscale@@}%
+ \let\xscale@@=\pgfmathresult
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{parsenumber}{\yscale@@}%
+ \let\yscale@@=\pgfmathresult
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{parsenumber}{\unitscale@@}%
+ \let\unitscale@@=\pgfmathresult
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{parsenumber}{\unitscale@inv@@}%
+ \let\unitscale@inv@@=\pgfmathresult
+ \fi
+ %
+ \ifpgfplots@threedim
+ % backw. compatibility: this is how it used to be in 3d
+ % axes:
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{op}{multiply}{{\xscale@@}{\unitscale@@}}%
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{tofixed}{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@target@unit@scale@##1x\endcsname=\pgfmathresult
+ %
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{op}{multiply}{{\yscale@@}{\unitscale@@}}%
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{tofixed}{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@target@unit@scale@##1y\endcsname=\pgfmathresult
+ \else
+ % backw. compatibility: 2d axes used divide in earlier
+ % versions, not reciprocal. Believe it or not; for
+ % \pgfplots@compat@scaling@coordmath=pgfbasic, it makes a
+ % visible difference of about 2-3pt in the complete figure
+ % size.
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{op}{divide}{{\xscale@@}{\unitscale@inv@@}}%
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{tofixed}{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@target@unit@scale@##1x\endcsname=\pgfmathresult
+ %
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{op}{divide}{{\yscale@@}{\unitscale@inv@@}}%
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath@final}{tofixed}{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@target@unit@scale@##1y\endcsname=\pgfmathresult
+ \fi
+ %
+ }%
+ \if1\b@pgfplots@rescale@x
+ \pgfplots@loc@TMPa{x}{\xscale}{\yscale}{#3}%
+ \else
+ \pgfplots@loc@TMPa{x}{1}{1}{#3}%
+ \fi
+ %
+ \if1\b@pgfplots@rescale@y
+ \pgfplots@loc@TMPa{y}{\xscale}{\yscale}{#4}%
+ \else
+ \pgfplots@loc@TMPa{y}{1}{1}{#4}%
+ \fi
+ %
+ \ifpgfplots@threedim
+ \if1\b@pgfplots@rescale@z
+ \pgfplots@loc@TMPa{z}{\xscale}{\yscale}{#5}%
+ \else
+ \pgfplots@loc@TMPa{z}{1}{1}{#5}%
+ \fi
+ \else
+ \def\pgfplots@target@unit@scale@z{0}%
+ \def\pgfplots@target@unit@scale@zx{0}%
+ \def\pgfplots@target@unit@scale@zy{0}%
+ \def\pgfplots@target@unit@scale@inv@z{inf}%
+ \fi
+ %
+}%
+
+\def\pgfplots@notify@final@scalings#1{%
+ \pgfkeys{/pgfplots/scaling/.cd,
+ .unknown/.code={%
+%\message{setting key '\pgfkeyscurrentkey' to {##1}^^J}
+ \pgfkeyssetvalue{\pgfkeyscurrentkey}{##1}%
+ },
+ #1%
+ }%
+}%
+
+% #1: either x,y, or z
+% #2: the new exponent
+\def\pgfplots@apply@datascaletrafo@change@#1#2{%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplotscoordmath{#1}{datascaletrafo get params}%
+ \edef\pgfplots@loc@TMPa{\expandafter\pgfutil@firstoftwo\pgfmathresult}%
+ \edef\pgfplots@loc@TMPb{#2}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % ok; the data scale trafo did not change at all - we
+ % still have the same exponent.
+ \else
+ % Ah - we have a new data scale trafo!
+ \pgfplotscoordmath{#1}{datascaletrafo inverse}{\csname pgfplots@#1min\endcsname}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{#1}{datascaletrafo inverse}{\csname pgfplots@#1max\endcsname}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ %
+ % first: determine the optimal shift (which is the
+ % transformed lower limit):
+ \pgfplotscoordmath{#1}{datascaletrafo set params}{#2}{0}%
+ \pgfplotscoordmath{#1}{datascaletrafo}{\pgfplots@loc@TMPa}%
+ %
+ % ok, finalize the data trafo:
+ \pgfplotscoordmath{#1}{datascaletrafo set params}{#2}{\pgfmathresult}%
+ %
+ % ... and recompute axis limits:
+ \pgfplotscoordmath{#1}{datascaletrafo}{\pgfplots@loc@TMPa}%
+ \expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
+ \pgfplotscoordmath{#1}{datascaletrafo}{\pgfplots@loc@TMPb}%
+ \expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
+ \fi
+ }{}%
+}%
+
+% Inspects the limit enlargement factors and reinitializes the data
+% scale transformations.
+%
+% The purpose of this method is to avoid "dimension too large" if the
+% factors exceed certain limits.
+%
+% INPUT:
+% \pgfplots@target@limitrescale@x and its variants for y and z
+% \pgfplots@target@unit@scale@inv@x and its variants for y and z
+%
+% OUTPUT:
+% \pgfplots@target@datascaletrafo@x@exponent and its variants for y and z
+% -> contains NEW datascaletrafo exponents
+% \pgfplots@target@datascaletrafo@x@exponent@old and its variants for y and z
+% -> contains OLD datascaletrafo exponents
+% \pgfplots@target@unit@scale@inv@x and its variants for y and z
+% -> contains (modified) unit vector scales
+\def\pgfplots@scaling@adjust@datascaling{%
+ \pgfplots@scaling@adjust@datascaling@for x%
+ \pgfplots@scaling@adjust@datascaling@for y%
+ \pgfplots@scaling@adjust@datascaling@for z%
+}
+\def\pgfplots@scaling@adjust@datascaling@for#1{%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplotscoordmath{#1}{datascaletrafo get params}%
+ \def\pgfplots@loc@TMPa##1##2{%
+ \expandafter\def\csname pgfplots@target@datascaletrafo@#1@exponent\endcsname{##1}%
+ \expandafter\def\csname pgfplots@target@datascaletrafo@#1@exponent@old\endcsname{##1}%
+ }%
+ \expandafter\pgfplots@loc@TMPa\pgfmathresult
+ \pgf@xa=\csname pgfplots@target@limitrescale@#1\endcsname pt
+ \ifdim\pgf@xa>5pt %
+ % We want to enlarge axis limits considerably!
+ %
+ \pgfplots@scaling@adjust@datascaling@for@get@compensation{\pgf@xa}%
+ %
+ % Ok, make sure that we do not get "dimension too large"
+ % by adjusting the data scale trafo.
+ %
+ % Note that the data scale trafo has (only) been applied
+ % to axis limits, so we have to reapply it before these
+ % changes can take effect:
+ \pgf@xa=\csname pgfplots@target@unit@scale@inv@#1\endcsname pt
+ \divide\pgf@xa by\pgfplotsretval\relax %
+ \expandafter\edef\csname pgfplots@target@unit@scale@inv@#1\endcsname{\pgf@sys@tonumber\pgf@xa}%
+ %
+ \c@pgf@countd=\csname pgfplots@target@datascaletrafo@#1@exponent\endcsname\relax
+ \advance\c@pgf@countd by-\pgfplotsretvalb\relax %
+ \expandafter\edef\csname pgfplots@target@datascaletrafo@#1@exponent\endcsname{\the\c@pgf@countd}%
+ \fi
+ }{%
+ \expandafter\def\csname pgfplots@target@datascaletrafo@#1@exponent\endcsname{0}%
+ \expandafter\def\csname pgfplots@target@datascaletrafo@#1@exponent@old\endcsname{0}%
+ }%
+}
+
+% Returns
+% \pgfplotsretval -> the absolute scaling
+% \pgfplotsretvalb -> the log10 of the scaling
+\def\pgfplots@scaling@adjust@datascaling@for@get@compensation#1{
+ \ifdim#1<100pt %
+ \def\pgfplotsretval{10}%
+ \def\pgfplotsretvalb{1}%
+ \else
+ \ifdim#1<1000pt %
+ \def\pgfplotsretval{100}%
+ \def\pgfplotsretvalb{2}%
+ \else
+ \ifdim#1<10000pt %
+ \def\pgfplotsretval{1000}%
+ \def\pgfplotsretvalb{3}%
+ \else
+ % too much for this approach anyway... and probably no
+ % use-case at all.
+ \def\pgfplotsretval{1000}%
+ \def\pgfplotsretvalb{3}%
+ \fi
+ \fi
+ \fi
+}%
+
+% Computes the initial scale from a plot box of unit size to the
+% desired with and height.
+%
+% #1 the desired width
+% #2 the desired height
+% #3 [output] a macro which will contain the horizontal (x) scale
+% #4 [output] a macro which will contain the vertical (y) scale
+% #5 [input/output] a macro which, on input, contains the x axis limit compensation scale
+% which is required to select a single unit vector scale without
+% reducing the plots dimension (without actually respecting the
+% final dimension). On output, the input has been multiplied by
+% some additional x limit componensation scale (selected by scale
+% uniformly strategy).
+% #6 [input/output] a macro which will contain a y axis limit
+% compensation scale; it works in the same way as #5
+% #7 [input/output] a macro which will contain a z axis limit
+% compensation scale; it works in the same way as #5
+\def\pgfplots@get@scale@horiz@and@vert#1#2#3#4#5#6#7{%
+ \begingroup
+ \edef\pgfplots@target@limitrescale@x{#5}%
+ \edef\pgfplots@target@limitrescale@y{#6}%
+ \edef\pgfplots@target@limitrescale@z{#7}%
+ \pgfplots@get@dimension@of@BB
+ \pgf@xa=\pgfplotsretval\relax
+ \pgf@xb=\pgfplotsretvalb\relax
+ \pgf@ya=#1\relax
+ \pgf@yb=#2\relax
+ \edef\w{\pgf@sys@tonumber\pgf@xa}%
+ \edef\h{\pgf@sys@tonumber\pgf@xb}%
+ \edef\W{\pgf@sys@tonumber\pgf@ya}%
+ \edef\H{\pgf@sys@tonumber\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)...^^J}%
+ \ifcase\pgfplots@scale@mode@choice
+ % scale mode=auto does not happen here
+ \or
+ % scale mode=none does not happen here
+ \or
+ % scale mode=stretch to fill
+ %
+ % This is very simple:
+ %
+ % Compute individual scaling factors for X and Y
+ % such that the UNIT-BB will have size #1,#2. Keep limits.
+ \pgfmathdivide@{\W}{\w}%
+ \let\scalex=\pgfmathresult
+ %
+ \pgfmathdivide@{\H}{\h}%
+ \let\scaley=\pgfmathresult
+ %
+ % no changes to the axis limits - we only rescale units.
+ \def\pgfplots@target@limitrescale@x@{1}%
+ \def\pgfplots@target@limitrescale@y@{1}%
+ \def\pgfplots@target@limitrescale@z@{1}%
+ \pgfplots@BB@update@cumulative@limit@compensations
+ \or
+ % scale mode=scale uniformly
+ % compute ONE common scale for both, X and Y - and satisfy
+ % width/height constraints by adjusting the axis limits.
+ %
+ % The idea is as follows:
+ % we WANT to have width W and height H.
+ % The constraint is that each unit vector must get the same
+ % scale -- but the axis limits can receive individual
+ % compensation scales. But it should "look reasonable well".
+ %
+ % currently, we have
+ % w = r_x e_xx + r_y e_yx + rz e_zx (with e_zx = 0 typically)
+ % h = r_x e_xy + r_y e_yy + rz e_zy
+ %
+ % where r_x, r_y, r_z are the maximal range of the data in
+ % x,y,z respectively. Depending on the context of this method,
+ % they are either 1 (relative coords) or
+ % (xmax-xmin) (absolute coords).
+ %
+ % Now, search for a set of real numbers
+ % Rx, Ry, Rz, s
+ % such that
+ % W = (Rx r_x) (s e_xx) + (Ry r_y) (s e_yx) + (Rz r_z) (s e_zx)
+ % H = (Rx r_x) (s e_xy) + (Ry r_y) (s e_yy) + (Rz r_z) (s e_zy)
+ %
+ % clearly, the solution is not unique.
+ % ONE choice is to employ the fact that e_zx = 0 (or, for 2d
+ % plots, e_zx=0, e_zy=0 and e_yx=0):
+ %
+ % in that case, we can compute s such that the equation for W
+ % is satisfied and compensate only the limit r_z, i.e. to
+ % choose
+ % s := W / w, (scale to satisfy width constraint)
+ % Rx := Ry := 1 (keep limits in X and Y)
+ % Rz = ( H - s (w - r_z e_zy) ) / (s r_z e_zy) (adjust z limit to satisfy height constraint)
+ %
+ % This approach works well if W < H . If W > H, it will look
+ % bad: Rz will be less than 1, causing the limit to become
+ % smaller. This, in turn, will clip away parts of the image.
+ %
+ %
+ %
+ % Another solution is to make it the other way: to keep the
+ % limit r_z, but to reduce the size and enlarge the other
+ % limits to satisfy the size constraints. This solution is
+ % considerably more involved; it requires to solve a nonlinear
+ % set of equations.
+ %
+ % Formally, this second solution uses
+ % Rz := 1 (no limit componensation scale for z -- keep z limit)
+ % R:= Rx := Ry (same limit componensation scale for both X and Y)
+ % R and s still need to be determined from the two equations for W
+ % and H.
+ %
+ % Substituting the given choices into the equations for W and H, we find
+ %
+ % R = W / (s w)
+ %
+ % s = H * (R * (h-r_z e_zy) + r_z e_zy)^-1
+ %
+ % Here, we employed the definition of 'h', see above. The
+ % equations are non-linear.
+ %
+ % ATTENTION: we assume that the datascaletrafo set params
+ % method has been called with THE SAME SCALE IN EACH
+ % DIRECTION.
+ \if0\pgfplots@scaleuniformly@choice
+ % scale uniformly strategy=auto
+ \pgfplots@get@scale@horiz@and@vert@scaleuniformly@of@optimal@strategy
+ \else
+ \pgfplots@get@scale@horiz@and@vert@scaleuniformly
+ \pgfplots@BB@update@cumulative@limit@compensations
+ \fi
+ \fi
+ %
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand#3{\scalex}%
+ \noexpand\def\noexpand#4{\scaley}%
+ \noexpand\def\noexpand#5{\pgfplots@target@limitrescale@x}%
+ \noexpand\def\noexpand#6{\pgfplots@target@limitrescale@y}%
+ \noexpand\def\noexpand#7{\pgfplots@target@limitrescale@z}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+% This is the implementation for 'scale uniformly strategy=auto'.
+%
+% It works by finding the strategy which involves the minimal scaling
+% overhead.
+%
+% To this end, it computes the result for each 'scale uniformly
+% strategy', and computes a cost function. The one with optimal cost
+% function wins, and its results are returned.
+%
+% The cost function is the overal scaling which is applied to AXIS
+% LIMITS. It works as follows:
+% 1. if a choice requires to REDUCE the axis limits in order to
+% fulfill all constraints, it is neglected (using maximal cost 16000).
+% Reducing axis limits may clip away information.
+%
+% 2. if a choice requires to ENLARGE some axis limits, its cost is the
+% sum of the individual scaling factors (even if they are are one -
+% who cares).
+%
+% Note that this method *is* relevant and the optimization appears to
+% be necessary.
+% Examples are
+% unittest_scalemode_2d_standard_1.tex
+% and perhaps
+% unittest_scalemode_2d_standard_0.tex
+% and more involved 3d examples are also available.
+%
+% My first guess was that it is sufficient to decide the optimal
+% strategy in advance by comparing the target width and the target
+% height - but that proved to be insufficient: it leads to correct
+% results, but wastes too much space (i.e. enlarges limits too much).
+%
+% ATTENTION: the cost function INCLUDES RESULTS OF
+% \pgfplots@BB@for@plotbox@get@unit@scales@for@limits and its
+% corrector
+% \pgfplots@BB@for@plotbox@get@unit@scales@compensated@axis@limits.
+%
+% More precisely, it relies on already computes limit compensation
+% factors which do not depend on the target width/target height: both
+% \pgfplots@BB@for@plotbox@get@unit@scales@compensated@axis@limits and
+% this implementation of 'scale uniformly strategy' can be used to compute
+% the cost of a strategy.
+%
+\def\pgfplots@get@scale@horiz@and@vert@scaleuniformly@of@optimal@strategy{%
+ \begingroup
+ \def\mathclass{default}%
+ \pgfplotscoordmath{\mathclass}{max limit}%
+ \let\pgfplots@cost@for@choice@superhigh=\pgfmathresult%
+ %
+ % private helpers to compute the cost.
+ \def\pgfplots@scalestrategy@compute@cost{%
+ \begingroup
+ % ATTENTION: this call changes
+ % '\pgfplots@target@limitrescale@x' and its variants.
+ % Restore its value after the iteration:
+ \pgfplots@BB@update@cumulative@limit@compensations
+ \pgfplotscoordmath{\mathclass}{one}%
+ \let\ONE=\pgfmathresult
+ \pgfplotscoordmath{\mathclass}{parsenumber}{\pgfplots@target@limitrescale@x}%
+ \let\X=\pgfmathresult
+ \pgfplotscoordmath{\mathclass}{parsenumber}{\pgfplots@target@limitrescale@y}%
+ \let\Y=\pgfmathresult
+ \ifpgfplots@threedim
+ \pgfplotscoordmath{\mathclass}{parsenumber}{\pgfplots@target@limitrescale@z}%
+ \let\Z=\pgfmathresult
+ \else
+ \let\Z=\pgfplots@target@limitrescale@z
+ \fi
+ %
+ % If one of the resulting limit compensation scales is
+ % less than 1, we can immediately skip it - we do not want
+ % to risk to clip away image content.
+ \pgfplotscoordmath{\mathclass}{if less than}{\X}{\ONE}{%
+ \let\pgfplots@cost@for@choice=\pgfplots@cost@for@choice@superhigh
+ }{%
+ \pgfplotscoordmath{\mathclass}{if less than}{\Y}{\ONE}{%
+ \let\pgfplots@cost@for@choice=\pgfplots@cost@for@choice@superhigh
+ }{%
+ \ifpgfplots@threedim
+ \pgfplotscoordmath{\mathclass}{if less than}{\Z}{\ONE}{%
+ \let\pgfplots@cost@for@choice=\pgfplots@cost@for@choice@superhigh
+ }{%
+ % ah - 3 limit scales >= 1. Good, assign cost:
+ \pgfplots@scalestrategy@compute@cost@
+ }%
+ \else
+ % ah - all limit scales >=1. Good, assign cost:
+ \pgfplots@scalestrategy@compute@cost@
+ \fi
+ }%
+ }%
+%\message{scale uniformly strategy=auto: '\pgfplots@tostring@scaleuniformlystrategy{\pgfplots@scaleuniformly@choice}' has cost \pgfplots@cost@for@choice\space(limit rescaling factors x=\X, y=\Y, z=\Z)^^J}%
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand\pgfplots@scaleuniformly@choice{\pgfplots@scaleuniformly@choice}%
+ \noexpand\def\noexpand\scalex{\scalex}%
+ \noexpand\def\noexpand\scaley{\scaley}%
+ \noexpand\def\noexpand\pgfplots@target@limitrescale@x{\pgfplots@target@limitrescale@x}%
+ \noexpand\def\noexpand\pgfplots@target@limitrescale@y{\pgfplots@target@limitrescale@y}%
+ \noexpand\def\noexpand\pgfplots@target@limitrescale@z{\pgfplots@target@limitrescale@z}%
+ }%
+ \pgfmath@smuggleone\pgfplots@cost@for@choice
+ % keep in mind that this scope IS NECESSARY: we have
+ % changed the target quantities
+ % \pgfplots@target@limitrescale@x and its variants!
+ \endgroup
+ \let\pgfplots@scalestrategy@values=\pgfplots@glob@TMPa
+ }%
+ \def\pgfplots@scalestrategy@compute@cost@{%
+ \pgfplotscoordmath{\mathclass}{op}{add}{{\X}{\Y}}%
+ \ifpgfplots@threedim
+ \pgfplotscoordmath{\mathclass}{op}{add}{{\pgfmathresult}{\Z}}%
+ \fi
+ \let\pgfplots@cost@for@choice=\pgfmathresult
+ }%
+ %
+ % compute initial cost:
+ \def\pgfplots@scaleuniformly@choice{3}% change horizontal limits
+ \pgfplots@get@scale@horiz@and@vert@scaleuniformly
+ \pgfplots@scalestrategy@compute@cost
+ %
+ % init minimum:
+ \let\pgfplots@cost@for@choice@arg=\pgfplots@scalestrategy@values
+ \let\pgfplots@cost@for@choice@sofar=\pgfplots@cost@for@choice%
+ %
+ % compute cost of next strategy:
+ \def\pgfplots@scaleuniformly@choice{2}% change vertical limits
+ \pgfplots@get@scale@horiz@and@vert@scaleuniformly
+ \pgfplots@scalestrategy@compute@cost
+ %
+ % update minimum:
+ \pgfplotscoordmath{\mathclass}{if less than}{\pgfplots@cost@for@choice}{\pgfplots@cost@for@choice@sofar}{%
+ \let\pgfplots@cost@for@choice@arg=\pgfplots@scalestrategy@values
+ \let\pgfplots@cost@for@choice@sofar=\pgfplots@cost@for@choice%
+ }{%
+ }%
+ %
+ \ifx\pgfplots@cost@for@choice@sofar\pgfplots@cost@for@choice@superhigh
+ % the algorithm discarded every available strategy.
+ \def\pgfplots@scaleuniformly@choice{1}% fall back to 'units only'
+ \pgfplots@get@scale@horiz@and@vert@scaleuniformly
+ \pgfplots@scalestrategy@compute@cost
+ \let\pgfplots@cost@for@choice@arg=\pgfplots@scalestrategy@values
+ \let\pgfplots@cost@for@choice@sofar=\pgfplots@cost@for@choice%
+ \fi
+ %
+ %
+ \global\let\pgfplots@glob@TMPa=\pgfplots@cost@for@choice@arg
+ \endgroup
+ \pgfplots@glob@TMPa
+%\message{scale uniformly strategy=auto: choosing '\pgfplots@tostring@scaleuniformlystrategy{\pgfplots@scaleuniformly@choice}'^^J}%
+}
+
+\def\pgfplots@tostring@scaleuniformlystrategy#1{%
+ % scale uniformly strategy:
+ \ifcase#1\relax
+ auto
+ \or
+ units only
+ \or
+ change vertical limits
+ \or
+ change horizontal limits
+ \fi
+}
+% Does the work for 'scale mode=scale uniformly' inside of
+% \pgfplots@get@scale@horiz@and@vert.
+%
+% It returns its result into \pgfplots@target@limitrescale@x@ (i.e.
+% with an extra '@')
+\def\pgfplots@get@scale@horiz@and@vert@scaleuniformly{%
+ \ifcase\pgfplots@scaleuniformly@choice\relax
+ % scale uniformly strategy=auto does not happen here.
+ \or
+ % scale uniformly strategy=units only
+ \pgfplots@scaleuniformly@onlyunits
+ \or
+ % scale uniformly strategy=change vertical limits
+ %
+ % first, scale to the width ...
+ \pgfplots@scaleuniformly@onlyunits@{\w}{\W}%
+ % ... and change (only) vertical limits to get the "correct"
+ % height:
+ \ifdim\pgf@zy=0pt
+ \ifdim\pgf@yx=0pt
+ \pgfplots@prepare@vertical@rescaling@for@scale@uniformly@in@dir{y}\returninto\pgfplots@target@limitrescale@y@
+ \else
+ \pgfplots@scale@uniformly@fallback
+ \fi
+ \else
+ \ifdim\pgf@zx=0pt
+ \pgfplots@prepare@vertical@rescaling@for@scale@uniformly@in@dir{z}\returninto\pgfplots@target@limitrescale@z@
+ \else
+ \pgfplots@scale@uniformly@fallback
+ \fi
+ \fi
+ \or
+ % scale uniformly strategy=change horizontal limits
+ \ifdim\pgf@zy=0pt
+ \ifdim\pgf@yx=0pt
+ \ifdim\pgf@xy=0pt
+ % special 2d routine with explicit solution
+ \pgfplots@scaleuniformly@change@horizontal@limits@twodim
+ {\scalex}
+ {\pgfplots@target@limitrescale@x@}
+ {\pgfplots@target@limitrescale@y@}
+ {\pgfplots@target@limitrescale@z@}%
+ \else
+ \pgfplots@scale@uniformly@fallback
+ \fi
+ \else
+ \pgfplots@scale@uniformly@fallback
+ \fi
+ \else
+ \ifdim\pgf@zx=0pt
+ \pgfplots@scaleuniformly@change@horizontal@limits
+ {\scalex}
+ {\pgfplots@target@limitrescale@x@}
+ {\pgfplots@target@limitrescale@y@}
+ {\pgfplots@target@limitrescale@z@}%
+ \else
+ \pgfplots@scale@uniformly@fallback
+ \fi
+ \fi
+ \let\scaley=\scalex
+ \fi
+}
+
+\def\pgfplots@scaleuniformly@onlyunits{%
+ % scale to the smaller target dimension:
+ \ifdim\W pt<\H pt %
+ \pgfplots@scaleuniformly@onlyunits@{\w}{\W}%
+ \else
+ \pgfplots@scaleuniformly@onlyunits@{\h}{\H}%
+ \fi
+}%
+
+% #1 : the actual dimension
+% #2 : the target dimension
+\def\pgfplots@scaleuniformly@onlyunits@#1#2{%
+ \def\pgfplots@target@limitrescale@x@{1}%
+ \def\pgfplots@target@limitrescale@y@{1}%
+ \def\pgfplots@target@limitrescale@z@{1}%
+ \pgfmathdivide@{#2}{#1}%
+ \let\scalex=\pgfmathresult
+ \let\scaley=\scalex % we *need* the same unit scale.
+}%
+
+% Computes 'scale uniformly strategy=change horizontal limits'.
+% This is a complicated solution, see the documentation in the
+% implementation for
+% 'scale mode=scale uniformly'
+%
+% #1 [output] a macro which will contain the (uniform) scale for the
+% unit vectors
+% #2 [output] a macro which will contain a x axis limit compensation scale
+% #3 [output] a macro which will contain a x axis limit compensation scale
+% #4 [output] a macro which will contain a x axis limit compensation scale
+\def\pgfplots@scaleuniformly@change@horizontal@limits#1#2#3#4{%
+ \begingroup
+ %
+ \pgfplots@BB@for@plotbox@getunitheight{\pgf@xc}{z}%
+ %
+ % compute the rest in floating point - intermediate results may
+ % become too huge for TeX.
+ \pgfplotscoordmath{default}{parsenumber}{\expandafter\pgf@sys@tonumber\csname pgf@xc\endcsname}%
+ \let\M=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{parsenumber}{\w}%
+ \let\w=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\W}%
+ \let\W=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\h}%
+ \let\h=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\H}%
+ \let\H=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{divide}{{\W}{\w}}%
+ \let\Wwinv=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{subtract}{{\h}{\M}}%
+ \let\hminusM=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{one}%
+ \let\S=\pgfmathresult%
+ \let\R=\pgfmathresult%
+ \let\Rx=\pgfmathresult
+ \def\Rz{1}%
+ %
+ \def\pgfplots@hold@S@get@R{%
+ \pgfplotscoordmath{default}{op}{divide}{{\Wwinv}{\S}}%
+ \let\R=\pgfmathresult
+%\message{updated R = \R\space ( S = \S ) ^^J}%
+ }%
+ \def\pgfplots@hold@R@get@S{%
+ \pgfplotscoordmath{default}{op}{multiply}{{\R}{\hminusM}}%
+ \pgfplotscoordmath{default}{op}{add}{{\pgfmathresult}{\M}}%
+ \pgfplotscoordmath{default}{op}{divide}{{\H}{\pgfmathresult}}%
+ \let\S=\pgfmathresult
+%\message{updated S = \S\space ( R = \R ) ^^J}%
+ }%
+ %
+ % This is the (most stupid) nonlinear method which is at hand:
+ % fix point iteration.
+ % choose R arbitrarily (R=1 seems adequate), solve for s.
+ % Then, fix s and solve for R. Then, fix R and
+ % solve for s until convergence.
+ \c@pgf@countc=0
+ \pgfplotsloop{%
+ \ifnum\c@pgf@countc<\pgfkeysvalueof{/pgfplots/scale uniformly strategy iter} %
+ \pgfplotsloopcontinuetrue
+ \else
+ \pgfplotsloopcontinuefalse
+ \fi
+ }{%
+ \pgfplots@hold@R@get@S \pgfplots@hold@S@get@R
+ \advance\c@pgf@countc by1 %
+ }%
+ %
+ \pgfplotscoordmath{default}{tofixed}{\R}\let\R=\pgfmathresult
+ \pgfplotscoordmath{default}{tofixed}{\S}\let\S=\pgfmathresult
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand#1{\S}%
+ \noexpand\def\noexpand#2{\R}%
+ \noexpand\def\noexpand#3{\R}%
+ \noexpand\def\noexpand#4{\Rz}%
+ }%
+ \endgroup
+ %
+ \pgfplots@glob@TMPa
+}%
+
+% Computes 'scale uniformly strategy=change horizontal limits'.
+%
+% This is a simplified closed solution assuming that e_xy=0 and e_yx = 0
+%
+% #1 [output] a macro which will contain the (uniform) scale for the
+% unit vectors
+% #2 [output] a macro which will contain a x axis limit compensation scale
+% #3 [output] a macro which will contain a x axis limit compensation scale
+% #4 [output] a macro which will contain a x axis limit compensation scale
+\def\pgfplots@scaleuniformly@change@horizontal@limits@twodim#1#2#3#4{%
+ \begingroup
+ % Assuming that we have a standard 2d axis, i.e.
+ % e_zx = e_zy = 0, e_xy = 0, and e_yx =0,
+ % we can immediately compute a solution.
+ %
+ % In this case, we have the actual width
+ % w = r_x e_xx + r_y e_yx + rz e_zx
+ % = r_x e_xx
+ % and actual height
+ % h = r_x e_xy + r_y e_yy + rz e_zy
+ % = r_y e_yy
+ % and, consequently, desired width
+ % W = (Rx r_x) (s e_xx) + (Ry r_y) (s e_yx) + (Rz r_z) (s e_zx)
+ % = (Rx r_x) (s e_xx)
+ % and desired height
+ % H = (Rx r_x) (s e_xy) + (Ry r_y) (s e_yy) + (Rz r_z) (s e_zy)
+ % = (Ry r_y) (s e_yy).
+ % since this strategy changes horizontal limits (only), we have
+ % Ry := 1.
+ % We find
+ % s : = H/h
+ % and
+ % Rx : = W/w /s .
+ %
+ \pgfplotscoordmath{default}{parsenumber}{\w}%
+ \let\w=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\W}%
+ \let\W=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\h}%
+ \let\h=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\H}%
+ \let\H=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{divide}{{\H}{\h}}%
+ \let\S=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{divide}{{\W}{\w}}%
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfmathresult}{\S}}%
+ \let\Rx=\pgfmathresult
+ \def\Ry{1}%
+ \def\Rz{1}%
+ %
+ \pgfplotscoordmath{default}{tofixed}{\Rx}\let\Rx=\pgfmathresult
+ \pgfplotscoordmath{default}{tofixed}{\S}\let\S=\pgfmathresult
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand#1{\S}%
+ \noexpand\def\noexpand#2{\Rx}%
+ \noexpand\def\noexpand#3{\Ry}%
+ \noexpand\def\noexpand#4{\Rz}%
+ }%
+ \endgroup
+ %
+ \pgfplots@glob@TMPa
+}%
+
+\def\pgfplots@BB@update@cumulative@limit@compensations{%
+%\message{ -> additional limit componensation scales x=\pgfplots@target@limitrescale@x@, y=\pgfplots@target@limitrescale@y@, z=\pgfplots@target@limitrescale@z@^^J}%
+ % add limit compensation to what we have from earlier
+ % operations:
+ \pgfplotscoordmath{pgfbasic}{op}{multiply}{{\pgfplots@target@limitrescale@x@}{\pgfplots@target@limitrescale@x}}%
+ \let\pgfplots@target@limitrescale@x=\pgfmathresult
+ \pgfplotscoordmath{pgfbasic}{op}{multiply}{{\pgfplots@target@limitrescale@y@}{\pgfplots@target@limitrescale@y}}%
+ \let\pgfplots@target@limitrescale@y=\pgfmathresult
+ \pgfplotscoordmath{pgfbasic}{op}{multiply}{{\pgfplots@target@limitrescale@z@}{\pgfplots@target@limitrescale@z}}%
+ \let\pgfplots@target@limitrescale@z=\pgfmathresult
+}%
+
+\def\pgfplots@scale@uniformly@fallback{%
+ \ifpgfplots@scaleuniformly@warning
+ \pgfplotswarning{scale uniformly unsupported}\pgfeov%
+ \fi
+ \pgfplots@scaleuniformly@onlyunits
+}%
+
+% This is part of the implementation of 'scale mode=scale uniformly'.
+%
+% Its purpose it to set up the initial scaling such that
+% 1. each unit vector gets the same scale
+% 2. the axis limits are resized (enlarged) to keep the plot box ratio
+% (as far as possible)
+%
+% It repairs the outcome of
+% \pgfplots@BB@for@plotbox@get@unit@scales@for@limits .
+%
+% The assumption is that on input #1, #2, and #3 are the factors which
+% would be used by stretch-to-fill in order to squeze the axis limits
+% into the plot box defined by e_x, e_y, and e_z (the unit vectors).
+%
+% On output, #1, #2, and #3 will be modified such that *each has the
+% same value*. The value will be chosen with care. More precisely, it
+% is the *minimum* of {#1,#2,#3}.
+%
+% Clearly, 'scale mode=scale uniformly' has less freedom than
+% strech-to-fill. In order to keep the plot box ratio intact (as far
+% as possible), the axis limits will be rescaled to componsate for the
+% ignored scaling factors. More precisely, if direction i is not the
+% extremal value (as discussed in the last paragraph), the axis limits
+% will be rescaled by #i/extremum .
+%
+%
+%
+% #1: on input, it contains the x unit scale which would be taken without the
+% compensation. On output, it contains the x unit scale which *will* be
+% used.
+% #2: same as #1, but for y
+% #3: same as #1, but for z
+% #4: [output] a scale for use as argument of \pgfplots@apply@unit@vector@rescale@keep@size{x}{<arg>}
+% #5: [output] a scale for use as argument of \pgfplots@apply@unit@vector@rescale@keep@size{y}{<arg>}
+% #6: [output] a scale for use as argument of \pgfplots@apply@unit@vector@rescale@keep@size{z}{<arg>}
+%
+% The output arguments need to be applied before they take effect.
+\def\pgfplots@BB@for@plotbox@get@unit@scales@compensated@axis@limits#1#2#3#4#5#6{%
+ \begingroup
+ % ATTENTION : this code ASSUMES that the datascaling trafo is
+ % initialized with THE SAME SCALE IN EACH DIRECTION.
+ % The data scaling also leads to (potentially non-uniform) scaling per component.
+ %
+ % Note that we could handle the datascaling here -- but we would
+ % leave the supported number range easily. That's why that part of
+ % the 'scale mode=scale uniformly' implementation has been moved
+ % to \pgfplots@set@optimal@datatrafos@allaxes
+ %
+ % This here handles the limits only.
+ \edef\pgfplots@scale@unitx{#1}%
+ \edef\pgfplots@scale@unity{#2}%
+ \edef\pgfplots@scale@unitz{#3}%
+ %
+ % compute extreme + arg extreme of these scales:
+ \def\pgfplots@extreme@scale{-16300}%
+ \def\pgfplots@extreme@scale@arg{NONE}%
+ %
+ \if0\b@pgfplots@unitvec@is@zero@x
+ \ifdim\pgfplots@extreme@scale pt<\pgfplots@scale@unitx pt
+ \let\pgfplots@extreme@scale=\pgfplots@scale@unitx
+ \def\pgfplots@extreme@scale@arg{x}%
+ \fi
+ \fi
+ \if0\b@pgfplots@unitvec@is@zero@y
+ \ifdim\pgfplots@extreme@scale pt<\pgfplots@scale@unity pt
+ \let\pgfplots@extreme@scale=\pgfplots@scale@unity
+ \def\pgfplots@extreme@scale@arg{y}%
+ \fi
+ \fi
+ \if0\b@pgfplots@unitvec@is@zero@z
+ \ifdim\pgfplots@extreme@scale pt<\pgfplots@scale@unitz pt
+ \let\pgfplots@extreme@scale=\pgfplots@scale@unitz
+ \def\pgfplots@extreme@scale@arg{z}%
+ \fi
+ \fi
+ %
+ % Now, adjust axis limits to compensate for the effect: we still
+ % want to have a plot box which is as close as possible to the
+ % target plot box.
+ \def\pgfplots@loc@TMPa##1##2{%
+ \if0\csname b@pgfplots@unitvec@is@zero@##1\endcsname
+ \if1\pgfplots@scaleuniformly@choice % FIXME : this appears to be too much. Disable this!?
+ % ok, nothing to do for this direction.
+ \pgfplotscoordmath{pgfbasic}{one}%
+ \let##2=\pgfmathresult
+ \else
+ \if\pgfplots@extreme@scale@arg ##1%
+ % ok, nothing to do for this direction.
+ \pgfplotscoordmath{pgfbasic}{one}%
+ \let##2=\pgfmathresult
+ \else
+ \pgfplotscoordmath{pgfbasic}{op}{divide}{{\pgfplots@extreme@scale}{\csname pgfplots@scale@unit##1\endcsname}}%
+ % do not call apply@unit@rescale immediately because the
+ % unit vectors may not be in their final state. Postpone until
+ % they are final.
+ \edef##2{\pgfmathresult}%
+ \fi
+ \fi
+ \else
+ \def##2{1}%
+ \fi
+ }%
+ \pgfplots@loc@TMPa{x}{#4}%
+ \pgfplots@loc@TMPa{y}{#5}%
+ \pgfplots@loc@TMPa{z}{#6}%
+ %
+ \toks0=\expandafter{#4}%
+ \toks1=\expandafter{#5}%
+ \toks2=\expandafter{#6}%
+ \xdef\pgfplots@glob@TMPa{%
+ % same scale in each dir:
+ \def\noexpand#1{\pgfplots@extreme@scale}%
+ \def\noexpand#2{\pgfplots@extreme@scale}%
+ \def\noexpand#3{\pgfplots@extreme@scale}%
+ \def\noexpand#4{\the\toks0}%
+ \def\noexpand#5{\the\toks1}%
+ \def\noexpand#6{\the\toks2}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+}
+
+% #1 : a dimen register
+% #2 : x, y, or z
+\def\pgfplots@BB@for@plotbox@getunitheight#1#2{%
+ #1=\csname pgfplots@plotbox@#2max\endcsname\csname pgf@#2y\endcsname
+ \advance#1 by -\csname pgfplots@plotbox@#2min\endcsname\csname pgf@#2y\endcsname
+ \ifdim#1<0pt %
+ % we want to return a height. It is also bigger than 0.
+ % the difference above may be negative if the unit points
+ % downward (special combinations of view/h and view/v)
+ #1=-#1\relax
+ \fi
+}%
+
+
+% Modifies the AXIS LIMITS to ensure that a suitable width/height is
+% achieved.
+%
+% This does NOT introduce a further scale to the unit vectors.
+%
+% #1: a direction (x,y, or z)
+% #2: a macro name. It will be assigned globally. It will contain
+% EXECUTABLE instructions which will modify the axis limits to fit the
+% scaling.
+%
+% PRECONDITION:
+% - \pgfplots@glob@TMPa contains the already computed
+% scaling factor for 'scale uniformly'
+% - \pgf@xb is the actual height and \pgf@yb is the desired height
+% (set as in the scaling routine)
+%
+% POSTCONDITION:
+% #2 will contain the argument <arg> for \pgfplots@apply@unit@vector@rescale@keep@size{#1}{<arg>}
+\def\pgfplots@prepare@vertical@rescaling@for@scale@uniformly@in@dir#1\returninto#2{%
+ % The strategy is as follows:
+ % 1. I want to fit the axis into width #1 (\pgf@ya) and
+ % height #1 (\pgf@yb).
+ % 2. I want to MAINTAIN the unit vector ratio.
+ % 3. I want to MAINTAIN the unit vector directions.
+ %
+ % I already know the scaling factor to fit the width (it
+ % is stored in \scalex = \scaley).
+ % Let's call it "s".
+ %
+ % Consequently, a uniform scaling by "s" leads to the image
+ % height
+ % h = s* (r_x * e_xy + r_y * e_yy + r_z * e_zy)
+ % where r_i = (imax - imin). This here is essentially the
+ % same as the bounding box computation above (at least for
+ % standart orthographic 3D axes).
+ %
+ % What I want now is to enlarge the limits such that I
+ % have BOTH, width #1 AND height #2, without obscuring the
+ % unit vector ratio. Recall that width #1 is already
+ % given.
+ %
+ % This strategy achieves this goal by
+ % modifying axis limits for an axis whose unit vector is
+ % parallel to the canvas y axis, i.e. e_i = (0,*).
+ %
+ % That means I have to introduce a SECOND scale s_z which
+ % applies only to the Z unit vector (since e_z = (0,*) ).
+ % If H = #2 is the desired height, I find the target
+ % equation for s_z,
+ %
+ % H = s* r_x e_xy + s * r_y e_yy + s_z * s * r_z * e_zy
+ % =>
+ % s_z = ( H- s*r_x e_xy - s*r_y e_yy) / ( s * r_z * e_zy).
+ %
+ % Remember that
+ % s = \scalex
+ % H = \H
+ % h = r_x * e_xy + r_y * e_yy + r_z * e_zy = \h
+ % =>
+ % s_z = ( H- s*( h - r_z * e_zy) ) / ( s * r_z * e_zy).
+ %
+ \begingroup
+ \pgfplots@BB@for@plotbox@getunitheight{\pgf@xc}{#1}%
+ %
+ % compute the rest in floating point - intermediate results may
+ % become too huge for TeX.
+ \pgfplotscoordmath{default}{parsenumber}{\expandafter\pgf@sys@tonumber\csname pgf@xc\endcsname}%
+ \let\pgfplots@diff=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{parsenumber}{\scalex}%
+ \let\pgfplots@s=\pgfmathresult
+ %
+ % this is a precondition of this method:
+ \pgfplotscoordmath{default}{parsenumber}{\h}%
+ \let\h=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\H}%
+ \let\H=\pgfmathresult
+ %
+ % compute counter := H - s * (h - (max-min))
+ \pgfplotscoordmath{default}{op}{subtract}{{\h}{\pgfplots@diff}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@s}{\pgfmathresult}}%
+ \pgfplotscoordmath{default}{op}{subtract}{{\H}{\pgfmathresult}}%
+ \let\pgfplots@counter=\pgfmathresult
+ %
+ % computer denom := s * (max-min)
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@s}{\pgfplots@diff}}%
+ \let\pgfplots@denom=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfplots@counter}{\pgfplots@denom}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ %
+ % Now, s_z = \pgfmathresult .
+ %
+ % Now, adjust the z limits.
+ % Note that \pgfplots@apply@unit@vector@rescale@keep@size
+ % has a slightly different context; it assumes that the
+ % unit vector has been rescaled, not the axis limits.
+ % Consequently, the inverse of the scaling factor enters.
+ % Since \pgfplots@apply@unit@vector@rescale@keep@size
+ % expects the inverse of the scale, we can provide
+ % \pgfmathresult:
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \let#2=\pgfmathresult
+}
+
+\def\pgfplots@computeunitvectorlengths{%
+ \pgfplotsutil@edef@invoke\pgfmathveclen@{%
+ {\pgf@sys@tonumber\pgf@xx}%
+ {\pgf@sys@tonumber\pgf@xy}%
+ }%
+ \let\pgfplots@x@veclength=\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@{%
+ {\pgf@sys@tonumber\pgf@yx}%
+ {\pgf@sys@tonumber\pgf@yy}%
+ }%
+ \let\pgfplots@y@veclength=\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
+ \pgfplotsutil@edef@invoke\pgfmathveclen@{%
+ {\pgf@sys@tonumber\pgf@zx}%
+ {\pgf@sys@tonumber\pgf@zy}%
+ }%
+ \let\pgfplots@z@veclength=\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
+ \else
+ \def\pgfplots@z@veclength{0}%
+ \def\pgfplots@z@inverseveclength{infty}%
+ \fi
+}%
+
+% Defines \pgfplots@view@dir@threedim according to the actual
+% configuration of x,y,z (2d) unit vectors, assuming the associated
+% unit vectors form a right-handed-system.
+%
+% The algorithm works for standard three dimensional axes. It works as
+% follows:
+%
+% First, observe that we have a normal direction N if all its
+% multiples are mapped onto the same point in 2D canvas
+% coordinates. In other words: all 3D coordinates which are mapped
+% onto an arbitrary point in 2D canvas coordinates (take, for example,
+% the origin (0,0) ) are on a line in direction of N.
+%
+% We use this observation to compute the normal axis, i.e. we search
+% for all points which are mapped onto the 2D canvas coordinate (0,0):
+% N_x e_xx + N_y e_yx + N_z e_zx = 0
+% N_x e_xy + N_y e_yy + N_z e_zy = 0.
+% All solutions make up a linear space of dimension 1 (up to special
+% cases). In the general case, we can chose an arbitrary N_z != 0
+% and reduce the linear system to
+% N_x e_xx + N_y e_yx = - N_z e_zx
+% N_x e_xy + N_y e_yy = - N_z e_zy.
+% Choosing *any* N_z != 0, say, N_z=-1 (which corresponds to view
+% from above) will lead to a vector parallel to the normal direction.
+% But it might have the wrong sign.
+%
+% FIXME : this fails if one of e_x or e_y is zero.
+%
+% To find the correct sign for N, I have made several case
+% distinctions to identify the cases when we have to multiply with -1.
+% The key idea is to assume a right-handed-system of unit vectors;
+% this is the condition which allows to determine the sign.
+%
+% Furthermore, I assume that e_z points to the top, i.e. that e_zy >0.
+% Then, there are (mainly) four conditions on the signs of e_x and e_y
+% which indicate that we are viewing from below and should switch the
+% sign of N (keep in mind that our initial choice was N_z =-1, see above).
+%
+% The conditions can be identified by drawing a 3D box and
+% identifying the corner which represents the lower left 3D limits.
+%
+% You can visualize these cases using
+%--------------------------------------------------
+% \pgfplotsset{
+% separate axis lines,
+% every outer x axis line/.append style= {-stealth},
+% every outer y axis line/.append style= {-stealth},
+% every outer z axis line/.append style= {-stealth},
+% samples=2,shader=interp,title={view=\h,\v},
+% domain=0:1,
+% enlargelimits=false,
+% view=\h\v,xlabel=x,ylabel=y,
+% extra description/.code={%
+% \node[draw,fill=white] at (axis cs:0,0,0) {};
+% },
+% }
+%
+% \def\v{30}
+% \foreach \h in {30,120,210,300} {
+% \message{VIEW={\h}{\v}^^J}
+% \begin{tikzpicture}
+% \begin{axis}
+% \addplot3[surf] {x};
+% \end{axis}
+% \end{tikzpicture}
+%
+% }
+%
+% \def\v{-30}
+% \foreach \h in {30,120,210,300} {
+% \message{VIEW={\h}{\v}^^J}
+% \begin{tikzpicture}
+% \begin{axis}
+% \addplot3[surf] {x};
+% \end{axis}
+% \end{tikzpicture}
+%
+% }
+%--------------------------------------------------
+% The precise formulas can be found below in the source code.
+%
+% You can override this function by the /pgfplots/view dir key.
+\def\pgfplotsgetnormalforcurrentview{%
+ \pgfkeysgetvalue{/pgfplots/view dir}\pgfplots@loc@TMPc
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ \begingroup
+ % temporarily undo the effects of reversed axes -- we *really*
+ % need a right-handed-coordinate system here:
+ \if r\pgfkeysvalueof{/pgfplots/x dir/value}%
+ \pgf@xx=-\pgf@xx
+ \pgf@xy=-\pgf@xy
+ \fi
+ \if r\pgfkeysvalueof{/pgfplots/y dir/value}%
+ \pgf@yx=-\pgf@yx
+ \pgf@yy=-\pgf@yy
+ \fi
+ \if r\pgfkeysvalueof{/pgfplots/z dir/value}%
+ \pgf@zx=-\pgf@zx
+ \pgf@zy=-\pgf@zy
+ \fi
+ % FIRST: check for special cases.
+ \let\pgfplots@view@dir@threedim=\pgfutil@empty%
+ % Special case:
+ % e_xx = e_xy = 0
+ %
+ % i.e.:
+ %
+ % ^
+ % | |---|
+ % z | |
+ % |---|
+ % y->
+ %
+ % In this case, N must be the x axis.
+ \ifdim\pgf@xx=0pt %
+ \ifdim\pgf@xy=0pt %
+ \def\pgfplots@view@dir@threedim{-1,0,0}%
+ \fi
+ \fi
+ % Special case:
+ % e_yx = e_yy = 0
+ %
+ % i.e.:
+ %
+ % ^
+ % | |---|
+ % z | |
+ % |---|
+ % x->
+ %
+ % In this case, N must be the y axis.
+ \ifdim\pgf@yx=0pt %
+ \ifdim\pgf@yy=0pt %
+ \def\pgfplots@view@dir@threedim{0,1,0}%
+ \fi
+ \fi
+ % Special case:
+ % e_xy = e_yy = 0 (i.e. one row)
+ %
+ % that is hard to draw, use view={30}{0} to see it.
+ %
+ % In this case, N_z must be 0 and we have a different system.
+ \ifdim\pgf@xy=0pt %
+ \ifdim\pgf@yy=0pt %
+ \ifx\pgfplots@view@dir@threedim\pgfutil@empty
+ % we have N_x e_xx + N_y e_yx = 0
+ % Note that e_xx != 0 and e_yx != 0 (otherwise one
+ % of our other special cases above would have
+ % caught the case)
+ % -> we have N_x = -N_y e_yx / e_xx and N_y
+ % arbitrary. only the sign needs to be fixed.
+ \def\pgfplots@view@dir@threedim@z{0}%
+ \def\pgfplots@view@dir@threedim@y{1}% fix it somehow. We correct the sign later.
+ \edef\pgfplots@loc@TMPa{-(\pgfplots@view@dir@threedim@y) * \pgf@sys@tonumber\pgf@yx / (\pgf@sys@tonumber\pgf@xx)}%
+ \pgfmathparse{\pgfplots@loc@TMPa}%
+ \let\pgfplots@view@dir@threedim@x=\pgfmathresult
+ %
+ \def\pgfplots@scale{1}%
+ % I identified these cases by comparing the
+ % results with \pgfplots@scale{1} with those of
+ % the view dir generated by
+ % \pgfplotssetaxesfromazel (which has the correct quality of solution)
+ \ifdim\pgf@zy>0pt %
+ \ifdim\pgf@xx<0pt %
+ \def\pgfplots@scale{-1}%
+ \fi
+ \else
+ \ifdim\pgf@xx>0pt %
+ \def\pgfplots@scale{-1}%
+ \fi
+ \fi
+ \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@x}%
+ \let\pgfplots@view@dir@threedim@x\pgfmathresult
+ \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@y}%
+ \let\pgfplots@view@dir@threedim@y\pgfmathresult
+ \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@z}%
+ \let\pgfplots@view@dir@threedim@z\pgfmathresult
+ %
+ \edef\pgfplots@view@dir@threedim{\pgfplots@view@dir@threedim@x,\pgfplots@view@dir@threedim@y,\pgfplots@view@dir@threedim@z}%
+ \else
+ % Ah - we already caught that special case above.
+ \fi
+ \fi
+ \fi
+ %
+ % NOTE : the case e_xx = e_yx = 0 IS NO USE-CASE (would
+ % require a rotated z axis which is forbidden currently)
+ %
+ \ifx\pgfplots@view@dir@threedim\pgfutil@empty
+ \def\pgfplots@view@dir@threedim@z{-1}% hold it at some arbitrary value
+ \pgf@xa=-\pgfplots@view@dir@threedim@z\pgf@zx
+ \pgf@ya=-\pgfplots@view@dir@threedim@z\pgf@zy
+ \edef\pgfplots@loc@TMPa{%
+ {%
+ {\pgf@sys@tonumber\pgf@xx}{\pgf@sys@tonumber\pgf@yx}%
+ {\pgf@sys@tonumber\pgf@xy}{\pgf@sys@tonumber\pgf@yy}%
+ }%
+ {%
+ {\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@ya}%
+ }%
+ }%
+ \expandafter\pgfutilsolvetwotwoleq\pgfplots@loc@TMPa
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfplots@error{Singular matrix encountered during view computation. Please choose different input values.}%
+ \def\pgfmathresult{{0}{0}}%
+ \fi
+ \def\pgfplots@loc@TMPb##1##2{%
+ \def\pgfplots@view@dir@threedim@x{##1}%
+ \def\pgfplots@view@dir@threedim@y{##2}%
+ }%
+ \expandafter\pgfplots@loc@TMPb\pgfmathresult
+ %
+ % Identify if we need to switch the sign.
+ % To verify that these cases are useful, I suggest visualizing
+ % that stuff using the TeX code from above...
+ %
+ % I guess it is correct up to collapsing views (as you see, I
+ % did not properly identify the cases with "=0" )
+ \def\pgfplots@scale{1}%
+ \ifdim\pgf@xx>0pt
+ \ifdim\pgf@yx<0pt
+ \else
+ %
+ \ifdim\pgf@xy<0pt
+ \else
+ \ifdim\pgf@yy<0pt
+ \def\pgfplots@scale{-1}%
+ \fi
+ \fi
+ %
+ \fi
+ \else
+ \ifdim\pgf@xx<0pt
+ \ifdim\pgf@yx>0pt
+ \else
+ %
+ \ifdim\pgf@xy>0pt
+ \else
+ \ifdim\pgf@yy>0pt
+ \def\pgfplots@scale{-1}%
+ \fi
+ \fi
+ %
+ \fi
+ \fi
+ \fi
+ \ifdim\pgf@xy>0pt
+ \ifdim\pgf@yy<0pt
+ \else
+ %
+ \ifdim\pgf@xx>0pt
+ \else
+ \ifdim\pgf@yx>0pt
+ \def\pgfplots@scale{-1}%
+ \fi
+ \fi
+ %
+ \fi
+ \else
+ \ifdim\pgf@xy<0pt
+ \ifdim\pgf@yy>0pt
+ \else
+ %
+ \ifdim\pgf@xx<0pt
+ \else
+ \ifdim\pgf@yx<0pt
+ \def\pgfplots@scale{-1}%
+ \fi
+ \fi
+ %
+ \fi
+ \fi
+ \fi
+ \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@x}%
+ \let\pgfplots@view@dir@threedim@x\pgfmathresult
+ \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@y}%
+ \let\pgfplots@view@dir@threedim@y\pgfmathresult
+ \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@z}%
+ \let\pgfplots@view@dir@threedim@z\pgfmathresult
+ %
+ \pgfplotsmathvectorfromstring{\pgfplots@view@dir@threedim@x,\pgfplots@view@dir@threedim@y,\pgfplots@view@dir@threedim@z}{default}%
+ \let\pgfplots@view@dir@threedim=\pgfplotsretval
+ % normalize. This is not absolutely required -- but it is used
+ % to accumulate point depth (for the mesh handler) in pgfmath
+ % arithmetics. At least \pgfplotsmathviewdepthxyz should use
+ % a properly scaled view dir.
+ \pgfplotsmathvectorlength{\pgfplotsretval}{default}%
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplotsretval}}%
+ \pgfplotsmathvectorscale{\pgfplots@view@dir@threedim}{\pgfmathresult}{default}%
+ \else
+ \pgfplotsmathvectorfromstring{\pgfplots@view@dir@threedim}{default}%
+ \fi
+ %
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ \let\pgfplots@view@dir@threedim=\pgfplotsretval
+ \else
+ \def\pgfplots@loc@TMPb##1##2##3{%
+ \pgfplotsmathvectorfromstring{##1,##2,##3}{default}%
+ \let\pgfplots@view@dir@threedim=\pgfplotsretval
+ }%
+ \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPc
+ \fi
+}%
+
+% PRECONDITION:
+% none
+% POSTCONDITION:
+% \pgfplots@default@aspect@ratio is set.
+\def\pgfplots@compute@default@aspect@ratio{%
+ \expandafter\pgfmath@x\axisdefaultwidth
+ \expandafter\pgfmath@y\axisdefaultheight
+ \pgfmathlog@invoke@expanded\pgfmathdivide@{%
+ {\pgf@sys@tonumber{\pgfmath@x}}%
+ {\pgf@sys@tonumber{\pgfmath@y}}%
+ }%
+ \let\pgfplots@default@aspect@ratio=\pgfmathresult
+}
+
+\def\pgfplots@ifneeds@one@uniform@datascale#1#2{%
+ \if3\pgfplots@scale@mode@choice
+ % scale mode=scale uniformly
+ \def\pgfplots@loc@TMPa{1}%
+ %
+ % if we have at least one unit vector given explicitly, the
+ % meaning changes: in that case, we can (and probably should)
+ % use different data scale factors in each direction.
+ \ifx\pgfplots@x\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \ifx\pgfplots@y\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \ifx\pgfplots@z\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \else
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \if1\pgfplots@loc@TMPa
+ #1%
+ \else
+ #2%
+ \fi
+}%
+
+\def\pgfplots@set@default@size@options{%
+ % The axes 'x' and 'y' vectors will be scaled such that the total
+ % size is (\axisdefaultwidth, \axisdefaultheight).
+ %
+ % If the user specifies ONE of width OR height,
+ % the plot will be resized; keeping the aspect ratio.
+ %
+ \let\pgfplots@default@aspect@ratio=\pgfutil@empty
+ \pgfkeysgetvalue{/pgfplots/x}{\pgfplots@x}%
+ \pgfkeysgetvalue{/pgfplots/y}{\pgfplots@y}%
+ \pgfkeysgetvalue{/pgfplots/z}{\pgfplots@z}%
+ %\pgfkeysgetvalue{/pgfplots/viewdir}{\pgfplots@viewdir}%
+ \pgfkeysgetvalue{/pgfplots/width}{\pgfplots@width}%
+ \pgfkeysgetvalue{/pgfplots/height}{\pgfplots@height}%
+ \ifx\pgfplots@width\pgfutil@empty
+ \def\pgfplots@user@provided@width{0}%
+ \else
+ \def\pgfplots@user@provided@width{1}%
+ \pgfmathparse{\pgfplots@width}%
+ \edef\pgfplots@width{\pgfmathresult pt}%
+ \fi
+ \ifx\pgfplots@height\pgfutil@empty
+ \def\pgfplots@user@provided@height{0}%
+ \else
+ \def\pgfplots@user@provided@height{1}%
+ \pgfmathparse{\pgfplots@height}%
+ \edef\pgfplots@height{\pgfmathresult pt}%
+ \fi
+ %
+ % CASES:
+ % W := 'width' option non-empty
+ % H := 'height' option non-empty
+ %
+ % W H
+ % 0 0 -> \axisdefaultwidth
+ % 0 1 -> determine width out of H and the default aspect ratio
+ % 1 X -> ok, use the user parameter.
+ % -> KEEP ASPECT RATIO if just one W, or H is given!
+ \ifx\pgfplots@width\pgfutil@empty
+ \ifx\pgfplots@height\pgfutil@empty
+ % The case W=0 H=0:
+ \let\pgfplots@width=\axisdefaultwidth
+ \let\pgfplots@height=\axisdefaultheight
+ \else
+ % The case W=0 H=1:
+ \pgfplots@compute@default@aspect@ratio
+ \expandafter\pgfmath@y\pgfplots@height
+ \pgfmathlog@invoke@expanded\pgfmathmultiply@{%
+ {\pgf@sys@tonumber{\pgfmath@y}}%
+ {\pgfplots@default@aspect@ratio}%
+ }%
+ \edef\pgfplots@width{\pgfmathresult pt}%
+ \fi
+ \else
+ \ifx\pgfplots@height\pgfutil@empty
+ % The case W=1 H=0:
+ \pgfplots@compute@default@aspect@ratio
+ \expandafter\pgfmath@x\pgfplots@width
+ \pgfmathlog@invoke@expanded\pgfmathdivide@{%
+ {\pgf@sys@tonumber{\pgfmath@x}}%
+ {\pgfplots@default@aspect@ratio}%
+ }%
+ \edef\pgfplots@height{\pgfmathresult pt}%
+ \else
+ % The case W=1 H=1:
+ \fi
+ \fi
+ \pgfkeyslet{/pgfplots/width}{\pgfplots@width}%
+ \pgfkeyslet{/pgfplots/height}{\pgfplots@height}%
+ %
+ \ifpgfplots@threedim
+ \pgfplots@set@default@size@options@threedim
+ \fi
+ %
+ \pgfplots@set@scale@mode
+}
+
+% This method must be called BEFORE THE DATASCALING is initialized.
+\def\pgfplots@set@scale@mode{%
+ \pgfkeysgetvalue{/pgfplots/unit vector ratio}\pgfplots@loc@TMPb
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \else
+ \ifcase\pgfplots@scale@mode@choice
+ % 'scale mode'=auto
+ \def\pgfplots@scale@mode@choice{3}% set to 'scale uniformly'
+ %
+ \if1\pgfplots@compat@scale@mode@compatible@mode
+ % backwards compatibility mode...
+ \ifpgfplots@threedim
+ % ... for 3d: there is no backwards compatibility
+ % mode here; it was plain wrong for 3d axes:
+ % neither lengths nor angles have been correct.
+ \pgfplots@compat@scale@mode@compatible@mode@warning
+ \fi
+ \fi
+ \or
+ % scale mode=none: keep it this way.
+ \immediate\write-1{PGFPlots: scale mode=none and unit vector ratio is incompatible. Ignoring unit vector ratio.^^J}%
+ \or
+ % scale mode=stretch to fill
+ \immediate\write-1{PGFPlots: scale mode=stretch to fill and unit vector ratio might produce unexpected results. Consider using scale mode=auto^^J}%
+ \fi
+ \fi
+ %
+}
+
+\def\pgfplots@compat@scale@mode@compatible@mode@warning{%
+ \pgfplotswarning{axis equal incompatible change}\pgfeov%
+}%
+
+\def\pgfplots@set@default@size@options@threedim{%
+ \pgfplots@loc@tmpfalse
+ \ifx\pgfplots@x\pgfutil@empty
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifx\pgfplots@y\pgfutil@empty
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifx\pgfplots@z\pgfutil@empty
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifpgfplots@loc@tmp
+ % oh - we have at least one of the [xyz] unit vectors!
+ % make sure all of them are there
+ \ifx\pgfplots@x\pgfutil@empty
+ \pgfplots@set@default@size@options@threedim@{x}{(1pt,0pt)}%
+ \fi
+ \ifx\pgfplots@y\pgfutil@empty
+ \pgfplots@set@default@size@options@threedim@{y}{(0pt,1pt)}%
+ \fi
+ \ifx\pgfplots@z\pgfutil@empty
+ \pgfplots@set@default@size@options@threedim@{z}{(0pt,1pt)}%
+ \fi
+ \pgfkeyslet{/pgfplots/view/az}\pgfutil@empty
+ \pgfkeyslet{/pgfplots/view/el}\pgfutil@empty
+ \fi
+}
+\def\pgfplots@set@default@size@options@threedim@#1#2{%
+ \pgfplots@error{Sorry, a 3D axis needs either NONE or ALL of "x,y,z". I found partial information, but (at least) '#1' is lacking... please add '#1'}%
+ \expandafter\def\csname pgfplots@#1\endcsname{#2}%
+}
+
+% A helper method for \pgfplots@initsizes which
+% - applies the data scaling trafo to user arguments
+% - sets calls pgfset#1vec
+%
+% #1: the vector to set (either 'x' or 'y')
+% #2: the index of the vector to set (either 0 or 1)
+% #3: the already precomputed temporary scale (see pgfplots@initsizes)
+% #4: an output argument. It is a macro name which will be defined to
+% '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
+ \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
+ \ifcase#2\relax
+ \pgfsetxvec{\pgfqpoint{\pgfplots@loc@TMPa pt}{0pt}}%
+ \or
+ \pgfsetyvec{\pgfqpoint{0pt}{\pgfplots@loc@TMPa pt}}%
+ \or
+ \pgfsetzvec{\pgfqpoint{\pgfplots@loc@TMPa pt}{\pgfplots@loc@TMPa pt}}%
+ \fi
+ \else
+ % Ok, we have a user-defined unit vector.
+ %
+ % That means we also need to apply the scaling trafo!
+ %
+ % 1. Check whether we have a complete vector of type (x,y):
+ \expandafter\pgfutil@in@\expandafter(\expandafter{\pgfplots@loc@TMPb}%
+ \ifpgfutil@in@
+ % YES: we have (x,y):
+ %
+ \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 ...}%
+ \def\pgfplots@loc@TMPa(##1,##2){%
+ \pgfplotscoordmath{default}{parse}{##1}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscoordmath{default}{parse}{##2}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult
+ %
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplotscoordmath{#1}{datascaletrafo noshift inverse to fixed}{\pgfplots@loc@TMPb}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscoordmath{#1}{datascaletrafo noshift inverse to fixed}{\pgfplots@loc@TMPc}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult
+ }{}%
+ \csname pgfset#1vec\endcsname{%
+ \pgfqpoint
+ {\if r\pgfplots@loc@dirvalue -\fi\pgfplots@loc@TMPb pt}
+ {\if r\pgfplots@loc@dirvalue -\fi\pgfplots@loc@TMPc pt}}%
+ }%
+ \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb%
+ %
+ \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}...}%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplotscoordmath{default}{parse}{\csname pgfplots@#1\endcsname}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \pgfplotscoordmath{#1}{datascaletrafo noshift inverse to fixed}{\pgfmathresult}%
+ \edef\pgfplots@loc@TMPb{\pgfmathresult pt}%
+ }{\relax}%
+ \edef\pgfplots@loc@TMPb{\if r\pgfplots@loc@dirvalue -\fi\pgfplots@loc@TMPb}%
+ \begingroup
+ \pgf@xa=\pgfplots@loc@TMPb\relax
+ \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}%
+ \endgroup
+ \ifcase#2\relax
+ \pgfsetxvec{\pgfqpoint{\pgfplots@loc@TMPb}{0pt}}%
+ \or
+ \pgfsetyvec{\pgfqpoint{0pt}{\pgfplots@loc@TMPb}}%
+ \or
+ \pgfsetzvec{\pgfqpoint{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPb}}%
+ \fi
+ \fi
+ \fi
+%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).^^J}%
+}%
+
+% Applies the 'axis equal' feature.
+%
+% PRECONDITION:
+% - #1, #2, #3 contains the current scaling
+% factors in x,y, z, resp. which are to be applied to unit vectors
+% - neither unit vectors nor limits are in their final shape
+% - \pgfplots@set@default@size@options has been invoked before
+%
+% POSTCONDITION:
+% - #1, #2, #3 have been changed to accomodate unit vector ratio
+% - #4, #5, #6 [output] contain axis limit compensation scales
+%
+% There is just one algorithmic difficulty: the data scaling
+% transformation. All unit vector length above are only meaningful in
+% the UNTRANSFORMED range, so we have to mingle with the scaling
+% transformation.
+\def\pgfplots@apply@unit@ratio#1#2#3#4#5#6{%
+ \begingroup
+ \edef\pgfplots@target@unit@scale@inv@x{#1}%
+ \edef\pgfplots@target@unit@scale@inv@y{#2}%
+ \edef\pgfplots@target@unit@scale@inv@z{#3}%
+ \def\pgfplots@target@limitrescale@x@{1}%
+ \def\pgfplots@target@limitrescale@y@{1}%
+ \def\pgfplots@target@limitrescale@z@{1}%
+ %
+ \pgfkeysgetvalue{/pgfplots/unit vector ratio}\pgfplots@unit@vector@ratio
+ \ifx\pgfplots@unit@vector@ratio\pgfutil@empty
+ \else
+ \edef\pgfplots@unit@vector@ratio{\pgfplots@unit@vector@ratio\space1 1 }%
+ %
+ \expandafter\pgfplots@unit@vector@ratio@check@nop\pgfplots@unit@vector@ratio\pgfplots@EOI
+ \ifpgfplots@loc@tmp
+ %
+ % Step 1: compute the unit vector which STAYS CONSTANT.
+ %
+ \pgfkeysgetvalue{/pgfplots/unit vector ratio axis}\pgfplots@apply@unit@ratio@reference
+ \ifx\pgfplots@apply@unit@ratio@reference\pgfutil@empty
+ \pgfplots@apply@unit@ratio@find@reference%
+ \fi
+ %
+ % FIXME : I could spent some attention here to save work:
+ % both, unit ratios and the resulting scales are computed at
+ % least twice (once in \pgfplots@apply@unit@ratio@find@reference and once in the
+ % following).
+ \expandafter\pgfplots@apply@unit@ratio@prepareratios\pgfplots@unit@vector@ratio\pgfplots@EOI
+ %
+%\message{USING REFERENCE UNIT VECTOR FROM \pgfplots@apply@unit@ratio@reference; ratio \pgfplots@unit@ratio@x\space \pgfplots@unit@ratio@y\space \pgfplots@unit@ratio@z.^^J}%
+ %
+ % Step 2: apply the scaling:
+ \pgfplots@rescale@unit@vector@reltoreference{x}{\pgfplots@unit@ratio@x}%
+ \pgfplots@rescale@unit@vector@reltoreference{y}{\pgfplots@unit@ratio@y}%
+ \ifpgfplots@threedim
+ \pgfplots@rescale@unit@vector@reltoreference{z}{\pgfplots@unit@ratio@z}%
+ \fi
+ %
+ \else
+%\message{Skipped application of 'unit vector ratio=\pgfkeysvalueof{/pgfplots/unit vector ratio}': it is already done by 'scale uniformly'.^^J}%
+ \fi
+ \fi
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand#1{\pgfplots@target@unit@scale@inv@x}%
+ \noexpand\def\noexpand#2{\pgfplots@target@unit@scale@inv@y}%
+ \noexpand\def\noexpand#3{\pgfplots@target@unit@scale@inv@z}%
+ \noexpand\def\noexpand#4{\pgfplots@target@limitrescale@x@}%
+ \noexpand\def\noexpand#5{\pgfplots@target@limitrescale@y@}%
+ \noexpand\def\noexpand#6{\pgfplots@target@limitrescale@z@}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+\def\pgfplots@appy@unit@ratio@reciprocal#1{%
+ \pgfplotscoordmath{default}{parsenumber}{#1}%
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+}%
+
+% Defines \ifpgfplots@loc@tmp := need to modify scaling factors
+\def\pgfplots@unit@vector@ratio@check@nop#1 #2 #3 #4\pgfplots@EOI{%
+ \pgfplots@loc@tmptrue
+ \if3\pgfplots@scale@mode@choice
+ % scale mode=scale uniformly
+ \ifpgfplots@threedim
+ \ifdim#1pt=#2pt
+ \ifdim#1pt=#3pt
+ % 'axis equal' is implicitly done by 'scale mode=scale
+ % uniformly' anyway
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+ \else
+ \ifdim#1pt=#2pt
+ % 'axis equal' is implicitly done by 'scale mode=scale
+ % uniformly' anyway
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+ \fi
+ % activate the following line to deactivate optimization: [FIXME]
+ %\pgfplots@loc@tmpfalse
+}%
+
+% This macro determines the reference axis for unit vector rescaling.
+% The reference axis remains unscaled (it gets scaling factor 1 if you
+% want it this way).
+%
+% The other axes are scaled such that the desired unit vector ratios
+% are fulfilled.
+%
+% The idea to select a reference axis is as follows:
+% 1. Every unit vector scaling factor s should fulfill s <= 1.
+% 2. Choose the reference axis such that the minimal amount of scaling
+% is performed.
+%
+% The motivation for (1) is: if all involved scaling factors are at
+% most 1, the resulting picture will only become *smaller*.
+% Consequently, we can simply enlarge axis limits to restore the
+% original width/height!
+%
+% The motivation for (2) is: a huge amount of scaling might reduce the
+% size of the image too much. Of course, the figure will be enlarged
+% to fit the original width/height, but most of it will be empty. So,
+% use the smallest scaling.
+%
+% @POSTCONDITION The reference axis is stored in
+% \pgfplots@apply@unit@ratio@reference .
+%
+% @see the key 'unit vector ratio axis=y' which allows to manually
+% select the reference axis. This will illustrate what happens here.
+\def\pgfplots@apply@unit@ratio@find@reference{%
+ %
+ \begingroup
+ \let\pgfplots@ONE=\pgf@x
+ \global\pgfplots@ONE=1.002pt
+ %
+ \def\pgfplots@optimum@sofar@axis{}%
+ \let\pgfplots@optimum@sofar@value=\pgf@y
+ \global\pgfplots@optimum@sofar@value=16000pt
+ %
+ %\pgfplots@apply@unit@ratio@find@reference@checkexplicitlimits
+ %
+ \ifx\pgfplots@optimum@sofar@axis\pgfutil@empty
+ % set \pgfplots@loc@TMPa := 1 if and only if the axis is 3d
+ \def\pgfplots@loc@TMPa{0}%
+ \if0\b@pgfplots@unitvec@is@zero@z
+ % ah, it IS 3d!
+ \def\pgfplots@loc@TMPa{1}%
+ \else
+ % ok, 2d mode (includes view={0}{90})
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \if1\pgfplots@loc@TMPa
+ % 3D is more complicated than 2D:
+ % for every fixed reference axis, we have to check *two*
+ % scaling factors.
+ %
+ % Furthermore, the optimality condition (2) needs to be
+ % performed on the maximum max{1-s_a, 1-s_b} provided both of
+ % these numbers are positive.
+ %
+ \def\pgfplots@check@##1##2{%
+ % PRECONDITION: \pgfplots@apply@unit@ratio@reference is defined.
+ %
+ % renormalize \pgfplots@unit@[xyz] :
+ \expandafter\pgfplots@apply@unit@ratio@prepareratios\pgfplots@unit@vector@ratio\pgfplots@EOI
+ %
+ % compute s_a :
+ \pgfplots@getscale@unit@vector@reltoreference ##1{\csname pgfplots@unit@ratio@##1\endcsname}%
+ \let\pgfplots@scale@a=\pgfmathresult
+ %
+ % compute s_b :
+ \pgfplots@getscale@unit@vector@reltoreference ##2{\csname pgfplots@unit@ratio@##2\endcsname}%
+ \let\pgfplots@scale@b=\pgfmathresult
+ %
+ % check if the actual choice of
+ % \pgfplots@apply@unit@ratio@reference is FEASIBLE.
+ % That is the case if s_a <= 1 && s_b <= 1.
+ % We check
+ % (1 - s_a >= 0 ) && ( 1 - s_b >= 0 )
+ % instead, since I need the value
+ % max( 1-s_a, 1-s_b )
+ % anyway.
+ \def\pgfplots@ref@is@feasible{1}%
+ \pgf@xa=\pgfplots@ONE \advance\pgf@xa by-\pgfplots@scale@a pt
+ \ifdim\pgf@xa<0sp
+ \def\pgfplots@ref@is@feasible{0}%
+ \else
+ \pgf@xb=\pgfplots@ONE \advance\pgf@xb by-\pgfplots@scale@b pt
+ \ifdim\pgf@xb<0sp
+ \def\pgfplots@ref@is@feasible{0}%
+ \fi
+ \fi
+ % compute max(1-s_a,1-s_b) into \pgf@xa:
+ % pgf@xa= max(pgf@xa,pgf@xb):
+ \ifdim\pgf@xb>\pgf@xa \pgf@xa=\pgf@xb \fi
+ \if1\pgfplots@ref@is@feasible
+ \ifdim\pgf@xa<\pgfplots@optimum@sofar@value
+ % Ah, ok. The actual choice is BETTER as it
+ % involves less scaling.
+ %
+ % Remember it!
+ \let\pgfplots@optimum@sofar@axis=\pgfplots@apply@unit@ratio@reference
+ \global\pgfplots@optimum@sofar@value=\pgf@xa
+ \fi
+ \fi
+%\message{^^Junit vector ratio 3D searching reference: checking \pgfplots@apply@unit@ratio@reference. feasable=\pgfplots@ref@is@feasible. \if1\pgfplots@ref@is@feasible max=\the\pgf@xa. \fi Optimum so far: value =\the\pgfplots@optimum@sofar@value\space for axis \pgfplots@optimum@sofar@axis.^^J}%
+ }%
+ %
+ % Check 'x' as reference :
+ \def\pgfplots@apply@unit@ratio@reference{x}%
+ \pgfplots@check@ yz%
+ %
+ % Check 'y' as reference :
+ \def\pgfplots@apply@unit@ratio@reference{y}%
+ \pgfplots@check@ xz%
+ %
+ % Check 'z' as reference :
+ \def\pgfplots@apply@unit@ratio@reference{z}%
+ \pgfplots@check@ xy%
+ %
+ \else
+ % 2D is much simpler: find the scale s which fulfills s <= 1.
+ % One of them MUST fulfill it.
+ %
+ % try 'x' axis as reference:
+ \def\pgfplots@apply@unit@ratio@reference{x}%
+ %
+ % renormalize:
+ \expandafter\pgfplots@apply@unit@ratio@prepareratios\pgfplots@unit@vector@ratio\pgfplots@EOI
+ %
+ % compute scaling factor:
+ \pgfplots@getscale@unit@vector@reltoreference y\pgfplots@unit@ratio@y%
+ %
+%\message{^^Junit vector ratio 2D searching reference: checking \pgfplots@apply@unit@ratio@reference. feasable=\pgfmathresult < 1: \ifdim\pgfmathresult pt <\pgfplots@ONE YES-> use x\else NO->use y\fi^^J}%
+ % and check (1). The condition (2) is irrelevant; it is met
+ % anyway.
+ \ifdim\pgfmathresult pt<\pgfplots@ONE
+ \def\pgfplots@optimum@sofar@axis{x}%
+ \else
+ \def\pgfplots@optimum@sofar@axis{y}%
+ \fi
+ \fi
+ \else
+%\message{^^Junit vector ratio chose \pgfplots@optimum@sofar@axis\space to fulfill explicitly provided limits (at least partially).^^J}%
+ \fi
+ %
+ \ifx\pgfplots@optimum@sofar@axis\pgfutil@empty
+ \if1\b@pgfplots@unitvec@is@zero@z
+ \def\pgfplots@optimum@sofar@axis{y}%
+ \else
+ \def\pgfplots@optimum@sofar@axis{z}%
+ \fi
+ \pgfplotswarning{unit vector ratio axis undetermined}{\pgfplots@optimum@sofar@axis}\pgfeov%
+ \fi
+ \let\pgfplots@apply@unit@ratio@reference=\pgfplots@optimum@sofar@axis
+ \pgfmath@smuggleone\pgfplots@apply@unit@ratio@reference
+ \endgroup
+}%
+\def\pgfplots@apply@unit@ratio@find@reference@checkexplicitlimits{%
+ \ifpgfplots@autocompute@ymax \else \def\pgfplots@optimum@sofar@axis{y}\fi
+ \ifpgfplots@autocompute@ymin \else \def\pgfplots@optimum@sofar@axis{y}\fi
+ \ifpgfplots@autocompute@xmax \else \def\pgfplots@optimum@sofar@axis{x}\fi
+ \ifpgfplots@autocompute@xmin \else \def\pgfplots@optimum@sofar@axis{x}\fi
+ \ifpgfplots@threedim
+ \ifpgfplots@autocompute@zmax \else \def\pgfplots@optimum@sofar@axis{z}\fi
+ \ifpgfplots@autocompute@zmin \else \def\pgfplots@optimum@sofar@axis{z}\fi
+ \fi
+}%
+
+% This is ONLY applied to the value of 'unit vector ratio'. It does
+% not touch the current axis scaling factors.
+\def\pgfplots@apply@unit@ratio@prepareratios#1 #2 #3 #4\pgfplots@EOI{%
+ \def\pgfplots@unit@ratio@x{#1}%
+ \def\pgfplots@unit@ratio@y{#2}%
+ \def\pgfplots@unit@ratio@z{#3}%
+ %
+ % 'unit vector ratio' is measured relative to the y axis for 2d
+ % and relative to the z axis for 3d plots.
+ % renormalize such that it is relative to
+ % \pgfplots@apply@unit@ratio@reference.
+ %
+ % Furthermore, renormalize such that
+ % unit@ratio@\pgfplots@apply@unit@ratio@reference is 1.
+ \pgfmathreciprocal@{\csname pgfplots@unit@ratio@\pgfplots@apply@unit@ratio@reference\endcsname}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \ifpgfplots@threedim
+ \if z\pgfplots@apply@unit@ratio@reference
+ \else
+ \pgfmathmultiply@{\pgfplots@loc@TMPa}{\pgfplots@unit@ratio@z}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \fi
+ %
+ \pgfmathmultiply@{\pgfplots@loc@TMPa}{\pgfplots@unit@ratio@x}%
+ \let\pgfplots@unit@ratio@x=\pgfmathresult
+ %
+ \pgfmathmultiply@{\pgfplots@loc@TMPa}{\pgfplots@unit@ratio@y}%
+ \let\pgfplots@unit@ratio@y=\pgfmathresult
+ %
+ \pgfmathmultiply@{\pgfplots@loc@TMPa}{\pgfplots@unit@ratio@z}%
+ \let\pgfplots@unit@ratio@z=\pgfmathresult
+ \else
+ \if y\pgfplots@apply@unit@ratio@reference
+ \else
+ \pgfmathmultiply@{\pgfplots@loc@TMPa}{\pgfplots@unit@ratio@y}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \fi
+ %
+ \pgfmathmultiply@{\pgfplots@loc@TMPa}{\pgfplots@unit@ratio@x}%
+ \let\pgfplots@unit@ratio@x=\pgfmathresult
+ %
+ \pgfmathmultiply@{\pgfplots@loc@TMPa}{\pgfplots@unit@ratio@y}%
+ \let\pgfplots@unit@ratio@y=\pgfmathresult
+ %
+ \def\pgfplots@unit@ratio@z{<unused>}%
+ \fi
+ %
+}%
+
+
+% Computes a new unit vector E_#1 for direction #1 such that
+% ||E_#1|| = #2 * ||e_reference||.
+% Here, #2 is a scaling factor and e_reference is a reference axis.
+% The reference axis is stored in
+% \pgfplots@apply@unit@ratio@reference, the macro contains one of
+% {x,y,z}.
+%
+% The data limits for '#1' will be enlarged as well (for 'unit rescale
+% keep size').
+%
+% #1 is the axis which should be scaled (i.e. #1 in {x,y,z}).
+% It is allowed if #1 = \pgfplots@apply@unit@ratio@reference. In this
+% case, you can provide a scale '#2' to rescale the axis.
+%
+% #2 is a desired scale, relative to
+% \pgfplots@apply@unit@ratio@reference. #2 should be a number without
+% unit.
+%
+% The parameter \pgfplots@apply@unit@ratio@reference is also one of
+% {x,y,z}.
+%
+\def\pgfplots@rescale@unit@vector@reltoreference#1#2{%
+ \def\pgfplots@loc@TMPa{0}%
+ \if#1\pgfplots@apply@unit@ratio@reference
+ \pgfplotsmath@ifapproxequal@dim{#2pt}{1pt}{0.0002pt}{%
+ }{%
+ \def\pgfplots@loc@TMPa{1}%
+ }%
+ \else
+ \def\pgfplots@loc@TMPa{1}%
+ \fi
+ \if1\csname b@pgfplots@unitvec@is@zero@#1\endcsname
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \if1\pgfplots@loc@TMPa
+ %
+ \pgfplots@getscale@unit@vector@reltoreference{#1}{#2}%
+ \global\let\pgfplots@glob@TMPa=\pgfmathresult
+ %
+%\message{Rescaling '#1' by \pgfplots@glob@TMPa.^^J}%
+ %
+ \pgfmathdivide@{\csname pgfplots@target@unit@scale@inv@#1\endcsname}{\pgfplots@glob@TMPa}%
+ \expandafter\let\csname pgfplots@target@unit@scale@inv@#1\endcsname=\pgfmathresult
+ %
+ \pgfmathreciprocal@\pgfplots@glob@TMPa
+ \expandafter\let\csname pgfplots@target@limitrescale@#1@\endcsname=\pgfmathresult
+ %
+ \fi
+}
+
+% Updates the #1 axis limits such that the axis' dimensions
+% stay the same after scaling the #1 unit vector by a scale 's'.
+%
+% PRECONDITION:
+% - the #1 unit vector has been rescaled by a factor s.
+% For example, e_xnew := e_x * 0.5 .
+%
+% POSTCONDITION:
+% - the axis limits are enlarged by a factor 1/s such that
+% 1/s (#1max - #1min) * e_xnew = (#1max- #1min) * e_x.
+%
+% In other words, the unit vector rescale is componensated by
+% modifying the axis limits: we want to add an absolute component 'd'
+% to the range:
+% 1/s (xmax - xmin ) = xmax - xmin +d
+% =>
+% d = (1/s - 1) * (xmax - xmin)
+%
+% The only remaining thing to do is to distribute 'd' to 'xmax' and
+% 'xmin'. Typically, 50% to each will be fine, I guess...
+%
+% #1: either x, y or z. It denotes the direction which has been
+% modified.
+% #2: the INVERSE of the scaling factor, #2 = 1/s .
+%
+\def\pgfplots@apply@unit@vector@rescale@keep@size#1#2{%
+ \ifdim#2pt=1pt
+ \else
+ \if0\pgfplots@unit@vector@rescale@keep@size
+ % unit rescale keep size=false : do nothing. Ignore the
+ % scaling request.
+ \else
+ % unit rescale keep size=true|unless limits declared
+ %
+%\message{'unit rescale keep size': Resizing data range for #1 by #2: from \csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname\ to}%
+ \pgfmathsubtract@{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#1min\endcsname}%
+ \begingroup
+ \pgf@xa=\pgfmathresult pt
+ \pgfmathsubtract@{#2}{1.0}%
+ \pgf@xa=\pgfmathresult \pgf@xa% this is 'd'
+ %
+ % \pgfplots@glob@TMPb : will be subtracted from #1min
+ % \pgfplots@glob@TMPc : will be added to #1max
+ \pgfplots@if{pgfplots@autocompute@#1min}{%
+ \pgfplots@if{pgfplots@autocompute@#1max}{%
+ \pgf@xa=0.5 \pgf@xa
+ \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}%
+ \xdef\pgfplots@glob@TMPc{\pgfplots@glob@TMPb}%
+ }{%
+ \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}%
+ \xdef\pgfplots@glob@TMPc{0.0}%
+ }%
+ }{%
+ \pgfplots@if{pgfplots@autocompute@#1max}{%
+ \xdef\pgfplots@glob@TMPb{0.0}%
+ \xdef\pgfplots@glob@TMPc{\pgf@sys@tonumber{\pgf@xa}}%
+ }{%
+ \if1\pgfplots@unit@vector@rescale@keep@size
+ % unit rescale keep size=true : FORCE
+ % enlargement!
+ \pgf@xa=0.5 \pgf@xa
+ \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}%
+ \xdef\pgfplots@glob@TMPc{\pgfplots@glob@TMPb}%
+ \else
+ % unit rescale keep size=unless limits declared:
+ % do not scale - all limits are declared
+ % explicitly
+ \xdef\pgfplots@glob@TMPb{0.0}%
+ \xdef\pgfplots@glob@TMPc{0.0}%
+ \fi
+ }%
+ }%
+ \endgroup
+ \pgfmathsubtract@{\csname pgfplots@#1min\endcsname}{\pgfplots@glob@TMPb}%
+ \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
+ \pgfmathadd@{\csname pgfplots@#1max\endcsname}{\pgfplots@glob@TMPc}%
+ \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
+%\message{\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname. [- \pgfplots@glob@TMPb; + \pgfplots@glob@TMPc]^^J}%
+ %
+ % Update auxiliary data members:
+ \pgfplots@visphase@notify@changeofcanvaslimits{#1}%
+ \fi
+ \fi
+}%
+
+% #1: an axis which should be scaled
+% #2: the desired final ratio ||e_#1||/||e_ref||
+\def\pgfplots@getscale@unit@vector@reltoreference#1#2{%
+ %
+ % If the datascaling transformation is active (which is almost
+ % everytime the case here), we have a transformation
+ % T^{-1}(x)= 10^scale * x
+ % with different scales for every axis.
+ %
+ % If the datascaling transformation is NOT active, scale is 0
+ % and T^{-1} = Identity.
+ %
+ % Note that the datascaling transformation also has
+ % translations (shifts). These are not important here.
+ %
+ % Goal:
+ % compute E_#1 such that
+ % #2* || T^{-1} e_ref || = || T^{-1} E_#1 ||
+ % where T^{-1} is the data scaling transformation and e_ref the
+ % reference unit vector. Keep in mind that there are
+ % *different* data scaling transformations for each axis.
+ %
+ % We are given e_ref and e_#1 and the desired aspect ratio
+ % between e_ref and E_#1, which is available as #2.
+ %
+ % So: T^{-1} E_#1 := s* T^{-1} e_#1 where
+ % s = #2 * ||T^{-1} e_ref|| / || T^{-1} e_#1 ||
+ % = |10^{scale_ref}| / |10^{scale_#1}| * #2 * || e_ref|| / ||e_#1||.
+ %
+ % Then, E_#1 = T ( T^{-1} E_#1 ) = s * e_#1.
+ %
+ % -> compute 's'!
+ %
+ % Part 1: compute
+ % #2 * ||e_ref|| / ||e_#1||.
+ %
+ \def\pgfplots@loc@TMPa{1}%
+ \if1\csname b@pgfplots@unitvec@is@zero@#1\endcsname
+ \def\pgfplots@loc@TMPa{0}%
+ \else
+ \if1\csname b@pgfplots@unitvec@is@zero@\pgfplots@apply@unit@ratio@reference\endcsname
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \fi
+ \if0\pgfplots@loc@TMPa
+ \def\pgfmathresult{16001}%
+ \else
+ % note that x^{-1} / y^{-1} == ( x/y )^{-1} == y/x .
+ % consequently, we can use our @inv@[xyz] values here:
+ \pgfmathdivide@
+ {\csname pgfplots@target@unit@scale@inv@#1\endcsname}%
+ {\csname pgfplots@target@unit@scale@inv@\pgfplots@apply@unit@ratio@reference\endcsname}
+ \pgfmathmultiply@
+ {\pgfmathresult}%
+ {#2}%
+ \global\let\pgfplots@glob@TMPa=\pgfmathresult
+ %
+ % also compute 1/s, required as temporary value:
+ %\pgfmathmultiply@
+ % {\csname pgfplots@\pgfplots@apply@unit@ratio@reference @inverseveclength\endcsname}
+ % {\csname pgfplots@target@unit@scale@#1\endcsname}%
+ %\ifdim#2pt=1pt
+ %\else
+ % \pgfmathdivide@{\pgfmathresult}{#2}%
+ %\fi
+ %\global\let\pgfplots@glob@TMPb=\pgfmathresult
+ %
+ % Part 2: handle data scaling trafo scales:
+ \begingroup
+ \def\pgfplots@tmp@exponentref{0}%
+ \def\pgfplots@tmp@exponentK{0}%
+ \pgfplots@if{pgfplots@apply@datatrafo@\pgfplots@apply@unit@ratio@reference }{%
+ \pgfplots@letcsname{pgfplots@tmp@exponentref}={pgfplots@data@scale@trafo@EXPONENT@\pgfplots@apply@unit@ratio@reference }%
+ }{}%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplots@letcsname{pgfplots@tmp@exponentK}={pgfplots@data@scale@trafo@EXPONENT@#1}%
+ }{}%
+ \c@pgf@counta=\pgfplots@tmp@exponentref\relax
+ \advance\c@pgf@counta by-\pgfplots@tmp@exponentK\relax
+ \ifnum\c@pgf@counta=0
+ \else
+ \pgfplotsmathmultiplypowten@{\pgfplots@glob@TMPa}{\c@pgf@counta}%
+ \global\let\pgfplots@glob@TMPa=\pgfmathresult
+ % \pgfplotsmathmultiplypowten@{\pgfplots@glob@TMPb}{-\c@pgf@counta}%
+ % \global\let\pgfplots@glob@TMPb=\pgfmathresult
+ \fi
+ \xdef\pgfplots@glob@TMPc{\the\c@pgf@counta}%
+ \endgroup
+ \let\pgfmathresult=\pgfplots@glob@TMPa
+ \fi
+%\message{\string\pgfplots@getscale@unit@vector@reltoreference{#1}{#2} (reference \pgfplots@apply@unit@ratio@reference) = \pgfmathresult.^^J}%
+}
+
+% helper for \pgfplots@check@and@apply@datatrafo@for.
+\def\pgfplots@compute@number@order@for@trafo@isdimen#1\tocount#2{%
+ \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber{#1}}%
+ \pgfmathfloatparsenumber{\pgfplots@loc@TMPa}%
+ \expandafter\pgfmathfloat@decompose@E\pgfmathresult\relax#2
+ \advance#2 by1\relax
+}
+
+% helper for \pgfplots@check@and@apply@datatrafo@for.
+%
+\def\pgfplots@compute@number@order@for@trafo@isfloat#1\tocount#2{%
+ \pgfmathfloatparsenumber{#1}%
+ \expandafter\pgfmathfloat@decompose@E\pgfmathresult\relax#2\relax
+ \advance#2 by1
+}
+
+\def\pgfplots@if@is@float@zero#1#2#3{%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloatgetflags{\pgfmathresult}{\c@pgf@countd}%
+ \ifnum\c@pgf@countd=0 %
+ % ah - it *is* 0.0:
+ #2%
+ \else
+ #3%
+ \fi
+}
+
+% Initialises the data scale transformation such that it is optimal
+% for direction #1 (using its axis limits and the target scaling size).
+%
+% Note that it will not be applied in any way; and it may still be
+% modified.
+%
+% PRECONDITION:
+% - all axis limits are available in float representation
+% - \pgfplots@set@default@size@options has been called before
+% POSTCONDITION:
+% - the scaling transformation is set up,
+\def\pgfplots@set@optimal@datatrafo@for@#1{%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ % initialise data scale transformation
+ % T(x) = 10^{q-m} * x
+ %
+ \ifpgfplots@disabledatascaling
+ % this here is a waste of time, because the NO-OP trafo
+ % will be applied to all coordinates. One could really
+ % safe a lot of CPU time when disabledatascaling is enabled...
+ % but it requires so much extra cases; I really don't want
+ % that!
+ \gdef\pgfplots@glob@TMPa{0}%
+ \gdef\pgfplots@glob@TMPb{0}%
+ \else
+ \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
+ \ifpgfplots@autocompute@all@limits
+ \else
+ \pgfplotscoordmath{#1}{max}{\pgfplots@display@max@float}{\pgfplots@data@max@float}%
+ \let\pgfplots@data@max@float=\pgfmathresult
+ \pgfplotscoordmath{#1}{min}{\pgfplots@display@min@float}{\pgfplots@data@min@float}%
+ \let\pgfplots@data@min@float=\pgfmathresult
+ \fi
+ %
+%\message{minmax = [\pgfplots@data@min@float,\pgfplots@data@max@float]^^J}%
+ % Step 1: compute 'm', the data order
+ \pgfplots@if@is@float@zero{\pgfplots@data@min@float}{%
+ \pgfplots@if@is@float@zero{\pgfplots@data@max@float}{%
+ \data@max@order=1 % both are zero. ok.
+ % Note that this is '1' due to backwards
+ % compatibility.
+ }{%
+ % one of them is zero. Take the other one!
+ \pgfplots@compute@number@order@for@trafo@isfloat
+ \pgfplots@data@max@float
+ \tocount\data@cur@order
+ \data@max@order=\data@cur@order
+ }%
+ }{%
+ \pgfplots@if@is@float@zero{\pgfplots@data@max@float}{%
+ % one of them is zero. Take the other one!
+ \pgfplots@compute@number@order@for@trafo@isfloat
+ \pgfplots@data@min@float
+ \tocount\data@cur@order
+ \data@max@order=\data@cur@order
+ }{%
+ % none of them is zero. Compute MAX:
+ \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
+ \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' (I always have them).
+ %
+ % 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
+ \if1\pgfplots@compat@scaling@zunitfix@enable
+ \data@dimen=\pgfplots@height\relax
+ \else
+ % this code here belongs to versions up to
+ % 1.3.1.
+ % It is now deprecated and produces small
+ % pixel differences.
+ \def\pgfplots@loc@TMPb{y}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \data@dimen=\pgfplots@height\relax
+ \else
+ \data@dimen=42pt % this is actually different from 1.3.1: there, it was UNDEFINED.
+ \fi
+ \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
+ %
+%\message{Direction #1: data max order=\the\data@max@order; data dimen order=\the\data@dimen@order. ^^J}%
+ \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).
+ %
+ \def\pgfplotscoordmathnotifydatascalesetfor##1{}% disable temporarily. We are just testing it.
+ \pgfplots@loop@CONTINUEtrue
+ \pgfutil@loop
+ \pgfplotscoordmath{#1}{datascaletrafo set params}{\the\data@EXPONENT}{0}%
+ \pgfplotscoordmath{#1}{datascaletrafo}{\pgfplots@data@min@float}%
+ \let\pgfplots@min@fixed=\pgfmathresult
+ \ifpgfplots@loop@CONTINUE
+ \pgfplotscoordmath{#1}{datascaletrafo}{\pgfplots@data@max@float}%
+ \let\pgfplots@max@fixed=\pgfmathresult
+ \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...^^J}%
+ \ifdim\data@tmp<0pt
+ % I need absolute values here:
+ \multiply\data@tmp by-1\relax
+ \fi
+ \pgfmathsubtract@{\pgfplots@max@fixed}{\pgfplots@min@fixed}%
+ \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
+ %--------------------------------------------------
+ % \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{\the\data@EXPONENT}%
+ \xdef\pgfplots@glob@TMPb{\pgfplots@min@fixed}%
+ \endgroup
+ \fi
+ % COMPLETE INITIALISATION:
+%\message{Initialising the data scale transformation in direction #1 to 10^\pgfplots@glob@TMPa*#1 - \pgfplots@glob@TMPb...^^J}%
+ \pgfplotscoordmath{#1}{datascaletrafo set params}{\pgfplots@glob@TMPa}{\pgfplots@glob@TMPb}%
+ }{%
+ % case apply trafo == false:
+ \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}%
+ }%
+}
+
+
+\def\pgfplots@set@optimal@datatrafos@allaxes{%
+ \pgfplots@letcsname pgfplots@xmin@unscaled@as@float={pgfplots@xmin}%
+ \pgfplots@letcsname pgfplots@xmax@unscaled@as@float={pgfplots@xmax}%
+ %
+ \pgfplots@letcsname pgfplots@ymin@unscaled@as@float={pgfplots@ymin}%
+ \pgfplots@letcsname pgfplots@ymax@unscaled@as@float={pgfplots@ymax}%
+ %
+ \pgfplots@letcsname pgfplots@zmin@unscaled@as@float={pgfplots@zmin}%
+ \pgfplots@letcsname pgfplots@zmax@unscaled@as@float={pgfplots@zmax}%
+ %
+ \pgfplots@ifneeds@one@uniform@datascale{%
+ % Ah - we have to ensure that there is ONE common scale for
+ % each unit (x, y, and z have the same).
+ %
+ % In this case, we need to choose one of the transformations
+ % and apply it to all axes -- such that each axis gets the
+ % same scale.
+ %
+ % this mode is used for axis equal and its variants.
+ %
+ % The strategy to fix the transformation is as follows:
+ % 1. we assume that axis limits will be enlarged in order to
+ % satisfy 'scale uniformly'.
+ % 2. we assume that the LARGEST axis limit dominates the
+ % others.
+ % 3. if one of the axes does not have datascaling (i.e. is
+ % log scale), we disable all other datascalings.
+ %
+ % Consequently, we search for the axis with the largest limit
+ % - and copy its data scaling to all other axes. If one of the
+ % axes is log, that one overrules it and all data scaling
+ % effects are disabled..
+ \ifpgfplots@disabledatascaling
+ \def\pgfplots@loc@TMPd##1{%
+ \pgfplotscoordmath{##1}{datascaletrafo set params}{0}{0}%
+ }%
+ \else
+ \begingroup
+ \let\pgfplots@data@scale@trafo@EXPONENT@common=\pgfutil@empty
+ \ifpgfplots@disabledatascaling
+ \def\pgfplots@data@scale@trafo@EXPONENT@common{{0}{0}}% disable scaling!
+ \fi
+ \def\pgfplots@data@scale@trafo@EXPONENT@common@arg{-}% this should not match anything in this context.
+ \pgfplots@if{pgfplots@apply@datatrafo@x}{%
+ }{%
+ \def\pgfplots@data@scale@trafo@EXPONENT@common{{0}{0}}% disable scaling!
+ }%
+ \pgfplots@if{pgfplots@apply@datatrafo@y}{%
+ }{%
+ \def\pgfplots@data@scale@trafo@EXPONENT@common{{0}{0}}% disable scaling!
+ }%
+ \ifpgfplots@threedim
+ \pgfplots@if{pgfplots@apply@datatrafo@z}{%
+ }{%
+ \def\pgfplots@data@scale@trafo@EXPONENT@common{{0}{0}}% disable scaling!
+ }%
+ \fi
+ \ifx\pgfplots@data@scale@trafo@EXPONENT@common\pgfutil@empty
+ % ah - we still need to compute one. ok, search for the
+ % largest limit.
+ %
+ \pgfplots@get@axis@with@largest@limits
+ \let\pgfplots@data@scale@trafo@EXPONENT@common@arg=\pgfplotsretval
+ %
+ % ok, compute data scaling transformation for the target axis:
+ \expandafter\pgfplots@set@optimal@datatrafo@for@\pgfplots@data@scale@trafo@EXPONENT@common@arg%
+ %
+ \pgfplotscoordmath{\pgfplots@data@scale@trafo@EXPONENT@common@arg}{datascaletrafo get params}%
+ \let\pgfplots@data@scale@trafo@EXPONENT@common=\pgfmathresult%
+ \else
+ % hm. early-out - we already have the scaling trafo.
+ % return it.
+ \fi
+ \global\let\pgfplots@glob@TMPa=\pgfplots@data@scale@trafo@EXPONENT@common
+ \global\let\pgfplots@glob@TMPb=\pgfplots@data@scale@trafo@EXPONENT@common@arg
+ \endgroup
+ %
+ \xdef\pgfplots@glob@TMPc{\expandafter\pgfutil@firstoftwo\pgfplots@glob@TMPa}%
+ %
+ \def\pgfplots@loc@TMPd##1{%
+ \if ##1\pgfplots@glob@TMPb
+ % we need to set the scaling trafo for the target direction
+ % (was lost after \endgroup)
+ \def\pgfplots@loc@TMPa{\pgfplotscoordmath{##1}{datascaletrafo set params}}%
+ \expandafter\pgfplots@loc@TMPa\pgfplots@glob@TMPa%
+ \else
+ \pgfplotscoordmath{##1}{datascaletrafo set params}{\pgfplots@glob@TMPc}{0}%
+ \pgfplotscoordmath{##1}{datascaletrafo}{\csname pgfplots@##1min\endcsname}%
+ \pgfplotscoordmath{##1}{datascaletrafo set params}{\pgfplots@glob@TMPc}{\pgfmathresult}%
+ \fi
+ }%
+ \fi
+ \pgfplots@loc@TMPd x%
+ \pgfplots@loc@TMPd y%
+ \ifpgfplots@threedim
+ \pgfplots@loc@TMPd z%
+ \fi
+ }{%
+ % optimize individually:
+ \pgfplots@set@optimal@datatrafo@for@ x%
+ \pgfplots@set@optimal@datatrafo@for@ y%
+ \ifpgfplots@threedim
+ \pgfplots@set@optimal@datatrafo@for@ z%
+ \fi
+ }%
+ %
+}%
+
+% Defines \pgfplotsretval to be one of x, y, or z, such that the
+% return value indicates the axis with largest untransformed axis
+% limits.
+\def\pgfplots@get@axis@with@largest@limits{%
+ \begingroup
+ \let\pgfplotsretval@extreme=\pgfutil@empty
+ \let\pgfplotsretval@extreme@arg=\pgfutil@empty
+ \def\pgfplots@@##1{%
+ % compute axis range for axis ##1 ...
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@##1min\endcsname}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@##1max\endcsname}%
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfmathresult}{\pgfplots@loc@TMPa}}%
+ % ... ok, it is in \pgfmathresult.
+ \let\candidate=\pgfmathresult
+ \ifx\pgfplotsretval@extreme@arg\pgfutil@empty
+ % ah: no extreme value so far. use ours.
+ \def\pgfplotsretval@extreme@arg{##1}%
+ \let\pgfplotsretval@extreme=\candidate
+ \else
+ \pgfplotscoordmath{default}{if less than}{\pgfplotsretval@extreme}{\candidate}{%
+ % update extreme value:
+ \def\pgfplotsretval@extreme@arg{##1}%
+ \let\pgfplotsretval@extreme=\candidate
+ }{%
+ }%
+ \fi
+ }%
+ \pgfplots@@ x%
+ \pgfplots@@ y%
+ \ifpgfplots@threedim
+ \pgfplots@@ z%
+ \fi
+ \let\pgfplotsretval=\pgfplotsretval@extreme@arg
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% Initialises the data scale transformation and applies it to any
+% user specified options.
+%
+% PRECONDITION:
+% - all axis limits are available in float representation
+% - \pgfplots@set@default@size@options has been called before
+% - the scaling transformation for direction x is set up
+% (\pgfplots@set@optimal@datatrafo@for@),
+% POSTCONDITION:
+% - all axis limits are transformed, but no other axis inputs.
+%
+% Unit vectors and other axis input parameters will be scaled later.
+%
+% @see \pgfplots@check@and@apply@datatrafo@for
+\def\pgfplots@apply@datatrafo@to@axis@limits#1{%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ % Transform axis limits:
+%\message{#1- display limits BEFORE data transformation: [\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname]^^J}%
+ \pgfplotscoordmath{#1}{datascaletrafo}{\csname pgfplots@#1min\endcsname}%
+ \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
+ %
+ \pgfplotscoordmath{#1}{datascaletrafo}{\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]^^J}%
+ }{%
+ % case apply trafo == false:
+ \expandafter\let\csname pgfplots@#1min@unscaled@as@float\endcsname=\pgfutil@empty
+ \expandafter\let\csname pgfplots@#1max@unscaled@as@float\endcsname=\pgfutil@empty
+ }%
+}
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.sty b/graphics/pgf/contrib/pgfplots/tex/pgfplots.sty
new file mode 100644
index 0000000000..ffcbc45cf1
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.sty
@@ -0,0 +1,155 @@
+%--------------------------------------------
+%
+% Package pgfplots.sty
+%
+% 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-2013 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/>.
+%
+%--------------------------------------------
+\IfFileExists{pgfplots.revision.tex}{\input pgfplots.revision.tex } {%
+ \def\pgfplotsrevision{0}%
+ \def\pgfplotsversion{0.0}%
+ \def\pgfplotsversiondatetime{2014-07-01 00:00:00 +100}%
+ \def\pgfplotsrevisiondatetime{2014-07-01 00:00:00 +100}%
+ \def\pgfplotsversiondate{2014/07/01}%
+ \def\pgfplotsrevisiondate{2014/07/01}%
+}
+\ProvidesPackage{pgfplots}[\pgfplotsversiondate\space v\pgfplotsversion\space Data Visualization (\pgfplotsrevision)]
+
+\RequirePackage{graphicx}
+
+% ATTENTION:
+% you MAY need one of
+% \def\pgfsysdriver{pgfsys-dvipdfm.def}
+% \def\pgfsysdriver{pgfsys-pdftex.def}
+% \def\pgfsysdriver{pgfsys-dvips.def}
+%
+% BEFORE the first \usepackage{pgf}, \usepackage{tikz} or
+% \usepackage{pgfplots}.
+% Default is
+% 'dvips' for 'latex'
+% 'pdftex' for 'pdflatex'
+% -> dvipdfm needs special attention.
+
+\IfFileExists{pgfsys-luatex.def}{%
+ % OK, proceed as usual
+}{%
+ % hm. check if we need it:
+ \def\pgfplots@glob@TMPa{luatex.def}%
+ \edef\pgfplots@glob@TMPb{\Gin@driver}%
+ \ifx\pgfplots@glob@TMPb\pgfplots@glob@TMPa
+ % hm. probably
+ \@ifundefined{pgfsysdriver}{%
+ % use a patch shipped with pgfplots:
+ \def\pgfsysdriver{pgfsys-luatexpatch.def}%
+ \immediate\write16{Package pgfplots external lib: activating patch for pgfsys-luatex.def driver (PGF is too old)}
+ }{%
+ \def\pgfplots@glob@TMPa{pgfsys-luatex.def}%
+ \ifx\pgfsysdriver\pgfplots@glob@TMPa
+ % use a patch shipped with pgfplots:
+ \def\pgfsysdriver{pgfsys-luatexpatch.def}%
+ \immediate\write16{Package pgfplots external lib: activating patch for pgfsys-luatex.def driver (PGF is too old)}
+ \fi
+ }%
+ \fi
+}
+
+\RequirePackage{tikz}
+
+% This is *identical* to \pgfutil@IfUndefined . I copied it here
+% because pgf up to and including version 2.10 does not contain it.
+\def\pgfplotsutil@IfUndefined#1{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname#1\endcsname\relax
+ \expandafter\pgfutil@firstoftwo
+ \else
+ \expandafter\pgfutil@secondoftwo
+ \fi
+}
+
+\gdef\pgfplots@glob@TMPa{}%
+\pgfplotsutil@IfUndefined{directlua}{}{%
+ \pgfplotsutil@IfUndefined{newcatcodetable}{%
+ % I need \newcatcodetable
+ \gdef\pgfplots@glob@TMPa{\RequirePackage{luatexbase}}%
+ }
+}%
+
+\ifx\pgfplots@glob@TMPa\pgfutil@empty
+\else
+ \expandafter\pgfplots@glob@TMPa
+\fi
+
+\def\pgfplots@texdist@protect{\protect}%
+
+\input pgfplots.code.tex
+
+
+% checks for xcolor configuration options and will override
+% mesh/colorspace explicit color output
+% and
+% colormap default colorspace
+% if needed.
+\def\pgfplots@check@global@colorspace@overrides{%
+ % "bOverridesColorspace"
+ \pgfplots@loc@tmpfalse
+ \ifconvertcolorsD
+ % xcolor converts at *definition* time:
+ \pgfplots@loc@tmptrue
+ \else
+ \ifconvertcolorsU
+ % xcolor converts at *usage* time:
+ \pgfplots@loc@tmptrue
+ \fi
+ \fi
+ %
+ \ifpgfplots@loc@tmp
+ \let\pgfplots@loc@TMPb=\pgfutil@empty%
+ \ifx\XC@tgt@mod\pgfplots@XC@tgt@mod@rgb \def\pgfplots@loc@TMPb{rgb}\fi
+ \ifx\XC@tgt@mod\pgfplots@XC@tgt@mod@RGB \def\pgfplots@loc@TMPb{rgb}\fi
+ \ifx\XC@tgt@mod\pgfplots@XC@tgt@mod@cmyk\def\pgfplots@loc@TMPb{cmyk}\fi
+ \ifx\XC@tgt@mod\pgfplots@XC@tgt@mod@cmy \def\pgfplots@loc@TMPb{cmyk}\fi
+ \ifx\XC@tgt@mod\pgfplots@XC@tgt@mod@gray \def\pgfplots@loc@TMPb{gray}\fi
+ \ifx\XC@tgt@mod\pgfplots@XC@tgt@mod@Gray \def\pgfplots@loc@TMPb{gray}\fi
+ %
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \else
+ \edef\pgfplots@loc@TMPa{%
+ mesh/colorspace explicit color output=\pgfplots@loc@TMPb,%
+ colormap default colorspace=\pgfplots@loc@TMPb,%
+ }%
+ \pgfplots@log3{Overriding colorspace to \pgfplots@loc@TMPb\space due to xcolor configuration.}%
+ \expandafter\pgfplotsset\expandafter{\pgfplots@loc@TMPa}%
+ \fi
+ \fi
+}%
+
+\def\pgfplots@XC@tgt@mod@rgb#1{rgb}
+\def\pgfplots@XC@tgt@mod@RGB#1{rgb}
+\def\pgfplots@XC@tgt@mod@cmyk#1{cmyk}
+\def\pgfplots@XC@tgt@mod@cmy#1{cmy}
+\def\pgfplots@XC@tgt@mod@gray#1{gray}
+\def\pgfplots@XC@tgt@mod@Gray#1{gray}
+
+\usetikzlibrary{plotmarks}
+
+
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplots.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplots.tex
new file mode 100644
index 0000000000..c4711be164
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplots.tex
@@ -0,0 +1,50 @@
+%--------------------------------------------
+%
+% 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/>.
+%
+%--------------------------------------------
+% ATTENTION:
+% you MAY need one of
+% \def\pgfsysdriver{pgfsys-dvipdfm.def}
+% \def\pgfsysdriver{pgfsys-pdftex.def}
+% \def\pgfsysdriver{pgfsys-dvips.def}
+%
+% BEFORE the first \input pgf.tex, \input tikz.tex or
+% \input pgfplots.tex
+% Default is
+% 'dvips' for 'tex'
+% 'pdftex' for 'pdftex'
+% -> dvipdfm needs special attention.
+%
+\input tikz.tex%
+%
+\edef\pgfplotscatcode{\the\catcode`\@}%
+\catcode`\@=11
+%
+\input pgfplots.revision.tex
+\input pgfplots.code.tex%
+\usetikzlibrary{plotmarks}%
+%
+\catcode`\@=\pgfplotscatcode
+%
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsarray.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsarray.code.tex
new file mode 100644
index 0000000000..3bf006f31f
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsarray.code.tex
@@ -0,0 +1,733 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% This is a helper package with an elementary array datastructure,
+% featuring O(1) index access and O(N) creation, deletion, copy.
+%
+% The following macros are supplied:
+%
+% \pgfplotsarraynewempty
+% \pgfplotsarraynew
+% \pgfplotsarrayresize
+% \pgfplotsarraycopy
+% \pgfplotsarraypushback
+% \pgfplotsarraysize
+% \pgfplotsarrayselect
+% \pgfplotsarrayset
+% \pgfplotsarrayletentry
+% \pgfplotsarraycheckempty
+% \pgfplotsarrayforeach
+% \pgfplotsarraysort
+% \pgfplotsarraybinarysearch
+%
+% and a subset also for global arrays:
+% \pgfplotsarraynewemptyglobal
+% \pgfplotsarrayresizeglobal
+% \pgfplotsarraysetglobal
+% \pgfplotsarrayletentryglobal
+%
+% 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/>.
+%
+%
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newcount\c@pgfplotsarray@tmp
+\newif\ifpgfplotsarrayempty
+
+% Creates a new, empty array.
+\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{%
+ \c@pgfplotsarray@tmp=#2
+ \pgfplotsarray@@edef{#1@size}{\the\c@pgfplotsarray@tmp}%
+}
+\def\pgfplotsarrayresizeglobal#1#2{%
+ \c@pgfplotsarray@tmp=#2
+ \expandafter\xdef\csname\string#1@size\endcsname{\the\c@pgfplotsarray@tmp}%
+}
+
+% Invokes code '#2' if the array named '#1' exists and '#3' if it does
+% not exist.
+\def\pgfplotsarrayifdefined#1#2#3{%
+ \pgfutil@ifundefined{#1@size}{#3}{#2}%
+}%
+
+% Creates a new array with an abirtrary number of elements.
+% Arguments:
+% #1: the array's name (a macro name)
+% #2: the elements in one of the following forms
+% a) a '\\' terminated list:
+% first\\second\\third\\ ...\\
+% 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}
+%
+%
+\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
+}
+
+% #1 the array's name (a macro name
+% #2 a list created by \pgfplotslistnew
+\def\pgfplotsarrayfrompgfplotslist#1#2{%
+ \pgfplotsarraynewempty#1%
+ \pgfplotslistforeachungrouped#2\as\pgfplotsarray@TMPa{%
+ \expandafter\pgfplotsarraypushback\expandafter{\pgfplotsarray@TMPa}\to#1%
+ }%
+}%
+
+\def\pgfplotsarraynew@backslash#1#2{%
+ \pgfplotsarraynewempty{#1}%
+ \long\def\pgfplotsarraynew@impl@rest{#2}%
+ \pgfutil@loop
+ \ifx\pgfplotsarraynew@impl@rest\pgfutil@empty
+ \pgfplots@loop@CONTINUEfalse
+ \else
+ \pgfplots@loop@CONTINUEtrue
+ \fi
+ \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%
+ \def\pgfplotsarraynew@impl@rest{#2}%
+}
+
+
+\def\pgfplotsarray@@let#1=#2{%
+ \def\pgfplotsarray@TMP@@{\expandafter\let\csname\string#1\endcsname}%
+ \expandafter\pgfplotsarray@TMP@@\csname\string#2\endcsname
+}%
+
+\def\pgfplotsarray@@#1#2{%
+ \expandafter#1\csname\string#2\endcsname
+}%
+\def\pgfplotsarray@@def#1{%
+ \expandafter\def\csname\string#1\endcsname
+}%
+\def\pgfplotsarray@@edef#1{%
+ \expandafter\edef\csname\string#1\endcsname
+}%
+
+\def\pgfplotsarray@@getsizeto#1#2{%
+ \pgfplotsarraysize{#1}\to\c@pgfplotsarray@tmp
+ \edef#2{\the\c@pgfplotsarray@tmp}%
+}%
+
+% Copies array #1 to array #2.
+\def\pgfplotsarraycopy#1\to#2{%
+ \pgfplotsarray@@let{#2@size}={#1@size}%
+ \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}%
+ \c@pgfplotsarray@tmp=0
+ \pgfutil@loop
+ \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP
+ \pgfplotsarray@@let{#2@\the\c@pgfplotsarray@tmp}={#1@\the\c@pgfplotsarray@tmp}%
+ \advance\c@pgfplotsarray@tmp by1
+ \pgfutil@repeat
+}
+
+
+
+% #1: the item to append
+% #2: the array as macro name
+% Example:
+% \pgfplotsarraypushback Next last element\to\fooarray
+\long\def\pgfplotsarraypushback#1\to#2{%
+ \pgfplotsarraysize{#2}\to\c@pgfplotsarray@tmp
+ \pgfplotsarray@@def{#2@\the\c@pgfplotsarray@tmp}{#1}%
+ \advance\c@pgfplotsarray@tmp by1
+ \pgfplotsarray@@edef{#2@size}{\the\c@pgfplotsarray@tmp}%
+}
+\long\def\pgfplotsarraypushbackglobal#1\to#2{%
+ \pgfplotsarraysize{#2}\to\c@pgfplotsarray@tmp
+ \pgfplotsarray@@\gdef{#2@\the\c@pgfplotsarray@tmp}{#1}%
+ \advance\c@pgfplotsarray@tmp by1
+ \pgfplotsarray@@\xdef{#2@size}{\the\c@pgfplotsarray@tmp}%
+}
+
+\long\def\pgfplotsarraypushbackglobal#1\to#2{%
+ \pgfplotsarraysize{#2}\to\c@pgfplotsarray@tmp
+ \pgfplotsarray@@\gdef{#2@\the\c@pgfplotsarray@tmp}{#1}%
+ \advance\c@pgfplotsarray@tmp by1
+ \pgfplotsarray@@\xdef{#2@size}{\the\c@pgfplotsarray@tmp}%
+}
+
+% Counts the number of elements in array #1, storing it into the count
+% register #2.
+% Example:
+% \pgfplotsarraysize\foo\to{\count0}%
+% \the\count0
+\long\def\pgfplotsarraysize#1\to#2{%
+ #2=\csname\string#1@size\endcsname\relax
+}
+\long\def\pgfplotsarraysizetomacro#1\to#2{%
+ \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:
+% #1: a count 0,...,N-1 where N is the array size.
+% You may specify a number of a count.
+% #2: a array
+% #3: a macro name
+% Example:
+% Element 0:
+% \pgfplotsarrayselect0\of\foo\to\elem
+% \elem
+% Element \count1:
+% \pgfplotsarrayselect\count1\of\foo\to\elem
+\def\pgfplotsarrayselect#1\of#2\to#3{%
+ \c@pgfplotsarray@tmp=#1\relax
+ \expandafter\let\expandafter#3\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname%
+ \ifx#3\relax
+ \pgfplotsthrow{no such element}{#1}{No such element: \string\pgfplotsarrayselect\the\c@pgfplotsarray@tmp\string\of{\string#2}}\pgfeov%
+ \fi
+}
+
+% 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
+}
+
+% Defines \pgfplotsretval to be a text-representation of the array.
+% It will contain \t to separate cells.
+%
+\def\pgfplotsarraytotext#1{%
+ \begingroup
+ \pgfplotsapplistXnewempty\pgfplotsretval@
+ \pgfplotsarrayforeachungrouped#1\as\entry{%
+ \pgfmathfloatparsenumber\entry
+ \pgfmathfloattosci\pgfmathresult
+ \edef\entry{\pgfmathresult\noexpand\t}%
+ \expandafter\pgfplotsapplistXpushback\entry\to\pgfplotsretval@
+ }%
+ \pgfplotsapplistXlet\pgfplotsretval=\pgfplotsretval@
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}
+
+% Sets the boolean \ifpgfplotsarrayempty depending on whether array #1 is empty
+% or not.
+% Example:
+%
+% \pgfplotsarraycheckempty\fooarray
+% \ifpgfplotsarrayempty
+% List fooarray is empty!
+% \else
+% List is not empty.
+% \fi
+\def\pgfplotsarraycheckempty#1{%
+ \ifnum\csname\string#1@size\endcsname=0
+ \pgfplotsarrayemptytrue
+ \else
+ \pgfplotsarrayemptyfalse
+ \fi
+}
+
+
+% Iterates through each array element, names it #2 and calls code #3.
+% Example:
+% \pgfplotsarraynew\fooarray{Eins\\Zwei\\Drei\\}%
+% \pgfplotsarrayforeach\fooarray\as\foo{Element \foo\par}%
+% results in
+% Element Eins
+% 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{%
+ % FIXME : add support for \breakforeach
+ \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%
+ \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}%
+ \pgfutil@loop
+ \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP\relax
+ \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname%
+ \begingroup
+ \toks0={#3}%
+ \xdef\pgfplotsarray@glob@TMP{%
+ \the\toks0 %
+ % restore loop state:
+ \c@pgfplotsarray@tmp=\the\c@pgfplotsarray@tmp\space
+ \noexpand\def\noexpand\pgfplotsarray@TMP{\pgfplotsarray@TMP}%
+ }%
+ \endgroup
+ \pgfplotsarray@glob@TMP
+ \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%
+}
+
+\pgfkeys{%
+ /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/iflessthan/.code args={#1#2#3#4}, see docs in
+% pgfplotsutil.code.tex.
+%
+% 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}]
+%
+%--------------------------------------------------
+%
+% @see \pgfplotsutilsortthree
+% @see \pgfplotsutilsortfour
+\def\pgfplotsarraysort{%
+ \pgfutil@ifnextchar[{\pgfplotsarraysort@opt}{\pgfplotsarraysort@opt[]}%
+}%
+\def\pgfplotsarraysort@opt[#1]#2{%
+ % 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 (that means: it is slow).
+ \begingroup
+ \pgfqkeys{/pgfplots/array}{#1}%
+ \pgfkeysifdefined{/pgfplots/array/iflessthan/.@cmd}{%
+ \pgfplots@warning{Warning: /pgfplots/array/iflessthan/.@cmd is deprecated. Please use /pgfplots/iflessthan/.@cmd instead.}%
+ \pgfkeysgetvalue{/pgfplots/array/iflessthan/.@cmd}\pgfplotsarraysort@iflt
+ }{%
+ \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotsarraysort@iflt
+ }%
+ \pgfplotsarraysize{#2}\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{#2}}%
+ \def\pgfplotsarray@mergesort@recurse@{\pgfplotsarray@mergesort@recurse{#2}}%
+ \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}#2\pgfeov
+ \endgroup
+ \pgfkeysvalueof{/pgfplots/array/unscope post/.@cmd}#2\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
+ \begingroup
+ \pgfplotsarraysort@iflt
+ {\pgfplotsarray@x@mpl}%
+ {\pgfplotsarray@x@k}%
+ {% x[m+l] < x[k]
+ \aftergroup\pgfplots@loc@tmptrue
+ }%
+ {% x[k] <= x[m+l]
+ \aftergroup\pgfplots@loc@tmpfalse
+ }%
+ \pgfeov
+ \endgroup
+ \ifpgfplots@loc@tmp
+ \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@mpl
+ \advance\c@pgfplotsarraysort@i by1
+ \advance\c@pgfplotsarraysort@l by1
+ \else
+ \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@k
+ \advance\c@pgfplotsarraysort@i by1
+ \advance\c@pgfplotsarraysort@k by1
+ \fi
+ \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}%
+}
+
+
+% A simple, ungrouped insert sort algorithm for small arrays.
+%
+% for i := 1; i < N; ++i do
+% begin
+% value := A[i];
+% j := i - 1;
+% done := false;
+% repeat
+% if A[j] > value then
+% begin
+% A[j + 1] := A[j];
+% j := j - 1;
+% if j < 0 then
+% done := true;
+% end
+% else
+% done := true;
+% until done;
+% A[j + 1] := value;
+% end;
+\def\pgfplotsarrayinsertionsort#1{%
+ \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotsarraysort@iflt
+ \pgfplotsarraysizetomacro#1\to\pgfplotsarrayinsertionsort@N
+ \c@pgf@countd=1
+ \pgfplotsarrayinsertionsort@{#1}%
+}%
+\def\pgfplotsarrayinsertionsort@#1{%
+ \ifnum\c@pgf@countd<\pgfplotsarrayinsertionsort@N\relax
+ \pgfplotsarrayselect\c@pgf@countd\of#1\to\pgfplotsarrayinsertionsort@v
+ %
+ \c@pgf@countb=\c@pgf@countd
+ \advance\c@pgf@countb by-1
+ %
+ \pgfplotsarrayinsertionsort@@{#1}%
+ \advance\c@pgf@countb by1
+ \pgfplotsarrayletentry\c@pgf@countb\of#1=\pgfplotsarrayinsertionsort@v
+ %
+ \advance\c@pgf@countd by1
+ \expandafter\pgfplotsarrayinsertionsort@\expandafter#1%
+ \fi
+}
+\def\pgfplotsarrayinsertionsort@@#1{%
+ \pgfplotsarrayselect\c@pgf@countb\of#1\to\pgfplotsarrayinsertionsort@j
+ \pgfplotsarraysort@iflt{\pgfplotsarrayinsertionsort@v}{\pgfplotsarrayinsertionsort@j}
+ {%
+ \advance\c@pgf@countb by1
+ \pgfplotsarrayletentry\c@pgf@countb\of#1=\pgfplotsarrayinsertionsort@j
+ \advance\c@pgf@countb by-2
+ \ifnum\c@pgf@countb<0
+ \let\pgfplotsarrayinsertionsort@@next\relax%
+ \else
+ \def\pgfplotsarrayinsertionsort@@next{\pgfplotsarrayinsertionsort@@#1}%
+ \fi
+ }{%
+ \let\pgfplotsarrayinsertionsort@@next\relax%
+ }\pgfeov%
+ \pgfplotsarrayinsertionsort@@next
+}%
+
+% applies a binary seach for value '#2' on array '#1', starting with
+% index '#3' (inclusive) and ending in index '#4' (exclusive).
+%
+% Returns: \pgfplotsretval, the index of the search key, if it is
+% contained in the array; otherwise, (-(insertion point) - 1). The
+% insertion point is defined as the point at which the key would be
+% inserted into the array: the index of the first element greater than
+% the key, or a.length if all elements in the array are less than the
+% specified key. Note that this guarantees that the return value will
+% be >= 0 if and only if the key is found.
+%
+\def\pgfplotsarraybinarysearch#1#2#3#4{%
+ \begingroup
+ \edef\targetvalue{#2}%
+ \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotsarray@iflt
+ \let\mid=\c@pgf@counta
+ \let\left=\c@pgf@countb
+ \let\right=\c@pgf@countc
+ \left=#3\relax
+ \right=#4\relax
+ \advance\right by-1 % make it inclusive
+ \let\pgfplotsretval\pgfutil@empty
+ %
+ \pgfutil@loop
+ \ifnum\left>\right
+ \pgfplots@loop@CONTINUEfalse
+ \else
+ \pgfplots@loop@CONTINUEtrue
+ \fi
+ \ifpgfplots@loop@CONTINUE
+ \mid=\right
+ \advance\mid by -\left
+ \divide\mid by2 %
+ \advance\mid by\left
+ %
+ \pgfplotsarrayselect\mid\of#1\to\midvalue
+ \pgfplotsarray@iflt{\targetvalue}{\midvalue}{%
+ \right=\mid
+ \advance\right by-1 %
+ }{%
+ \pgfplotsarray@iflt{\midvalue}{\targetvalue}{%
+ \left=\mid
+ \advance\left by1 %
+ }{%
+ % found it! abort loop!
+ \left=\right
+ \advance\left by1 %
+ \edef\pgfplotsretval{\the\mid}%
+ }%
+ \pgfeov%
+ }%
+ \pgfeov%
+ \pgfutil@repeat
+ %
+ \ifx\pgfplotsretval\pgfutil@empty
+ \advance\left by1 %
+ \left=-\left
+ \edef\pgfplotsretval{\the\left}%
+ \fi
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsbinary.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsbinary.code.tex
new file mode 100644
index 0000000000..42c4cb1aae
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsbinary.code.tex
@@ -0,0 +1,603 @@
+%--------------------------------------------
+% $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
+
+
+% Returns a single character, which has the
+% binary ASCII code '#1', with catcode 11.
+%
+% #1 (expands to) a number between 0 and 255 (inclusive).
+%
+% @see \pgfplotsgetchar Note that \pgfplotsgetchar is more powerful,
+% but can't be used inside of \edef (it is not expandable) whereas
+% \pgfplotscharno is.
+\def\pgfplotscharno#1{\csname pgfp@bin@#1\endcsname}%
+\let\pgfplotscharno@bincatcode=\pgfplotscharno
+
+\def\pgfplotscharno@lualatex#1{#1,}
+
+\input pgfplotsbinary.data.code.tex
+
+% Defines the LUA (!) value pgfplotsretval to be a binary string
+% containing the pgfplots binary value #1.
+%
+% #1 a pgfplots binary value collected with \pgfplotscharno.
+% More precisely, it should be a comma-separated sequence of numbers
+% of the form '0,255,2,128,' (can be terminated by comma). It will be
+% converted to the respective binary numbers 0x0, 0xff, 0x02,..
+%
+% example:
+% \pgfplotsbinarytoluabinary{0, 255,2,128}
+% \directlua{
+% pdf.immediateobj{"stream", pgfplotsretval,"/DataWithBinaryStream"}
+% }
+\def\pgfplotsbinarytoluabinary#1{%
+ % lualatex does not support binary chars as pdftex does - so we have to resort to LUA
+ % methods. The idea is to use
+ % string.char(1,2,3) which results in a binary string with chars 0x01, 0x02, 0x03 etc.
+ % I only need to get the integer numbers. To this end, I patch \pgfplotscharno
+ % and create the binary string here:
+ \pgfplotsutil@directlua{%
+ pgfplotsretval = pgfplotsGetLuaBinaryStringFromCharIndices({#1});
+ }%
+}%
+
+% Defines \pgfplotsretval to be the ASCII character for #1, with
+% catcode 11.
+%
+% #1: either a number between 0 and 255 (inclusive) or a description
+% of the character.
+%
+% Examples:
+% \pgfplotsgetchar{35}
+% \pgfplotsgetchar{`\#} % code for '#'
+% \pgfplotsgetchar{`\^^M} % Newline
+% \pgfplotsgetchar{`\^^ff}% 255
+%
+% @see \pgfplotscharno
+\def\pgfplotsgetchar#1{%
+ \begingroup
+ \count0=#1\relax
+ \edef\pgfplotsretval{\pgfplotscharno{\the\count0 }}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+\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={%
+ \pgfutil@IfUndefined{directlua}{%
+ \let\pgfplotscharno=\pgfplotscharno@bincatcode
+ }{%
+ % Ah - we use LuaTeX!
+ % At the time of this writing, LUA does not allow binary output which has been
+ % created by means of catcode modifications & TeX string concatenation.
+ % binary output in LUA needs to be (re)implemented in LUA (see inline code
+ % comments below).
+ %
+ % There are two possible work-arounds:
+ % (a) Base64 encoding
+ % (b) binary encoding using special LUA handling.
+ % This is what I do. Set the 'encode filter' such that it reinitializes the encoder:
+ % we patch \pgfplotscharno with a special routine which collects
+ % only the integer indices:
+ \let\pgfplotscharno=\pgfplotscharno@lualatex
+ % later, the user has to convert this list into a binary lua
+ % string before he can use it. See \pgfplotsbinarytoluabinary
+ }%
+ \edef\pgfplotsbinary@ZERO{\pgfplotscharno0}%
+ \edef\pgfplotsbinary@ZERO@LINEARMAP{\pgfplotscharno{128}}%
+ \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
+ \pgfplotsbinary@hook@signed@linearmap@error
+ \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={%
+ \let\pgfplotscharno=\pgfplotscharno@bincatcode
+ \edef\pgfplotsbinary@ZERO{\pgfplotscharno{48}}%
+ \edef\pgfplotsbinary@ZERO@LINEARMAP{\pgfplotscharno{56}}%
+ \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
+ \pgfplotsbinary@hook@signed@linearmap@error
+ \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={%
+ \let\pgfplotscharno=\pgfplotscharno@bincatcode
+ \edef\pgfplotsbinary@ZERO{\pgfplotscharno{33}}%
+ \edef\pgfplotsbinary@ZERO@LINEARMAP{\pgfplotscharno{42}}%
+ \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
+ \pgfplotsbinary@hook@signed@linearmap@error
+ \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\pgfplotscharno{%
+ \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@hook@signed@linearmap@error{%
+ \pgfplots@error{Sorry, there are not enough bytes to store the current number. I tried to write \the\c@pgfplotsbin@input...}%
+}%
+
+\def\pgfplotsbinary@apphighorderbytes@DEBUG@csname\pgfplotscharno#1\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{\pgfplotscharno{\the\c@pgfplotsbin@input}}%
+ \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\relax%
+ \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/graphics/pgf/contrib/pgfplots/tex/pgfplotsbinary.data.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsbinary.data.code.tex
new file mode 100644
index 0000000000..6483daf68f
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsbinary.data.code.tex
@@ -0,0 +1,291 @@
+\begingroup
+% prepare ONE-BYTE conversion [0-255] -> binary character:
+\count0=0
+\countdef\counter=0
+\catcode`\^^00=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^00}\advance\counter by1
+\catcode`\^^01=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^01}\advance\counter by1
+\catcode`\^^02=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^02}\advance\counter by1
+\catcode`\^^03=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^03}\advance\counter by1
+\catcode`\^^04=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^04}\advance\counter by1
+\catcode`\^^05=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^05}\advance\counter by1
+\catcode`\^^06=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^06}\advance\counter by1
+\catcode`\^^07=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^07}\advance\counter by1
+\catcode`\^^08=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^08}\advance\counter by1
+\begingroup
+\catcode`\^^09=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^09}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^0a=11\expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^0a}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^0b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^0b}\endgroup\advance\counter by1
+\catcode`\^^0c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^0c}\advance\counter by1
+\begingroup
+\catcode`\^^0d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^0d}\endgroup\advance\counter by1
+\catcode`\^^0e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^0e}\advance\counter by1
+\catcode`\^^0f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^0f}\advance\counter by1
+\catcode`\^^10=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^10}\advance\counter by1
+\catcode`\^^11=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^11}\advance\counter by1
+\catcode`\^^12=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^12}\advance\counter by1
+\catcode`\^^13=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^13}\advance\counter by1
+\catcode`\^^14=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^14}\advance\counter by1
+\catcode`\^^15=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^15}\advance\counter by1
+\catcode`\^^16=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^16}\advance\counter by1
+\catcode`\^^17=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^17}\advance\counter by1
+\catcode`\^^18=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^18}\advance\counter by1
+\catcode`\^^19=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^19}\advance\counter by1
+\catcode`\^^1a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^1a}\advance\counter by1
+\catcode`\^^1b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^1b}\advance\counter by1
+\catcode`\^^1c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^1c}\advance\counter by1
+\catcode`\^^1d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^1d}\advance\counter by1
+\catcode`\^^1e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^1e}\advance\counter by1
+\catcode`\^^1f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^1f}\advance\counter by1
+\begingroup
+\catcode`\^^20=11^^I\expandafter\xdef\csname^^Ipgfp@bin@\the\counter^^I\endcsname{^^20}\endgroup\advance\counter by1
+\catcode`\^^21=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^21}\advance\counter by1
+\catcode`\^^22=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^22}\advance\counter by1
+\catcode`\^^23=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^23}\advance\counter by1
+\catcode`\^^24=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^24}\advance\counter by1
+\catcode`\^^25=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^25}\advance\counter by1
+\catcode`\^^26=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^26}\advance\counter by1
+\catcode`\^^27=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^27}\advance\counter by1
+\catcode`\^^28=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^28}\advance\counter by1
+\catcode`\^^29=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^29}\advance\counter by1
+\catcode`\^^2a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^2a}\advance\counter by1
+\catcode`\^^2b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^2b}\advance\counter by1
+\catcode`\^^2c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^2c}\advance\counter by1
+\catcode`\^^2d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^2d}\advance\counter by1
+\catcode`\^^2e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^2e}\advance\counter by1
+\catcode`\^^2f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^2f}\advance\counter by1
+\begingroup
+\catcode`\^^30=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^30}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^31=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^31}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^32=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^32}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^33=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^33}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^34=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^34}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^35=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^35}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^36=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^36}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^37=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^37}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^38=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^38}\endgroup\advance\counter by1
+\begingroup
+\catcode`\^^39=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^39}\endgroup\advance\counter by1
+\catcode`\^^3a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^3a}\advance\counter by1
+\catcode`\^^3b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^3b}\advance\counter by1
+\catcode`\^^3c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^3c}\advance\counter by1
+\begingroup
+\catcode`\^^3d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^3d}\endgroup\advance\counter by1
+\catcode`\^^3e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^3e}\advance\counter by1
+\catcode`\^^3f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^3f}\advance\counter by1
+\catcode`\^^40=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^40}\advance\counter by1
+\catcode`\^^41=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^41}\advance\counter by1
+\catcode`\^^42=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^42}\advance\counter by1
+\catcode`\^^43=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^43}\advance\counter by1
+\catcode`\^^44=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^44}\advance\counter by1
+\catcode`\^^45=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^45}\advance\counter by1
+\catcode`\^^46=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^46}\advance\counter by1
+\catcode`\^^47=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^47}\advance\counter by1
+\catcode`\^^48=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^48}\advance\counter by1
+\catcode`\^^49=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^49}\advance\counter by1
+\catcode`\^^4a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^4a}\advance\counter by1
+\catcode`\^^4b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^4b}\advance\counter by1
+\catcode`\^^4c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^4c}\advance\counter by1
+\catcode`\^^4d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^4d}\advance\counter by1
+\catcode`\^^4e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^4e}\advance\counter by1
+\catcode`\^^4f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^4f}\advance\counter by1
+\catcode`\^^50=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^50}\advance\counter by1
+\catcode`\^^51=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^51}\advance\counter by1
+\catcode`\^^52=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^52}\advance\counter by1
+\catcode`\^^53=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^53}\advance\counter by1
+\catcode`\^^54=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^54}\advance\counter by1
+\catcode`\^^55=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^55}\advance\counter by1
+\catcode`\^^56=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^56}\advance\counter by1
+\catcode`\^^57=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^57}\advance\counter by1
+\catcode`\^^58=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^58}\advance\counter by1
+\catcode`\^^59=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^59}\advance\counter by1
+\catcode`\^^5a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^5a}\advance\counter by1
+\catcode`\^^5b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^5b}\advance\counter by1
+\begingroup
+\catcode`\|=0
+\catcode`\\=11 |expandafter|xdef|csname pgfp@bin@|the|counter|endcsname{^^5c}|endgroup \advance\counter by1
+\catcode`\^^5d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^5d}\advance\counter by1
+\begingroup
+\catcode`\^^5e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^}\endgroup\advance\counter by1
+\catcode`\^^5f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^5f}\advance\counter by1
+\begingroup
+\catcode`\^^60=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^60}\endgroup\advance\counter by1
+\catcode`\^^61=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^61}\advance\counter by1
+\catcode`\^^62=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^62}\advance\counter by1
+\catcode`\^^63=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^63}\advance\counter by1
+\catcode`\^^64=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^64}\advance\counter by1
+\catcode`\^^65=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^65}\advance\counter by1
+\catcode`\^^66=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^66}\advance\counter by1
+\catcode`\^^67=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^67}\advance\counter by1
+\catcode`\^^68=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^68}\advance\counter by1
+\catcode`\^^69=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^69}\advance\counter by1
+\catcode`\^^6a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^6a}\advance\counter by1
+\catcode`\^^6b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^6b}\advance\counter by1
+\catcode`\^^6c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^6c}\advance\counter by1
+\catcode`\^^6d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^6d}\advance\counter by1
+\catcode`\^^6e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^6e}\advance\counter by1
+\catcode`\^^6f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^6f}\advance\counter by1
+\catcode`\^^70=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^70}\advance\counter by1
+\catcode`\^^71=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^71}\advance\counter by1
+\catcode`\^^72=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^72}\advance\counter by1
+\catcode`\^^73=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^73}\advance\counter by1
+\catcode`\^^74=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^74}\advance\counter by1
+\catcode`\^^75=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^75}\advance\counter by1
+\catcode`\^^76=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^76}\advance\counter by1
+\catcode`\^^77=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^77}\advance\counter by1
+\catcode`\^^78=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^78}\advance\counter by1
+\catcode`\^^79=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^79}\advance\counter by1
+\catcode`\^^7a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^7a}\advance\counter by1
+\begingroup
+\catcode`\q=1
+\catcode`\^^7b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname q^^7b}\endgroup\advance\counter by1
+\catcode`\^^7c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^7c}\advance\counter by1
+\begingroup
+\catcode`\q=2
+\catcode`\^^7d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^7dq\endgroup\advance\counter by1
+\catcode`\^^7e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^7e}\advance\counter by1
+\catcode`\^^7f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^7f}\advance\counter by1
+\catcode`\^^80=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^80}\advance\counter by1
+\catcode`\^^81=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^81}\advance\counter by1
+\catcode`\^^82=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^82}\advance\counter by1
+\catcode`\^^83=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^83}\advance\counter by1
+\catcode`\^^84=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^84}\advance\counter by1
+\catcode`\^^85=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^85}\advance\counter by1
+\catcode`\^^86=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^86}\advance\counter by1
+\catcode`\^^87=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^87}\advance\counter by1
+\catcode`\^^88=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^88}\advance\counter by1
+\catcode`\^^89=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^89}\advance\counter by1
+\catcode`\^^8a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^8a}\advance\counter by1
+\catcode`\^^8b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^8b}\advance\counter by1
+\catcode`\^^8c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^8c}\advance\counter by1
+\catcode`\^^8d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^8d}\advance\counter by1
+\catcode`\^^8e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^8e}\advance\counter by1
+\catcode`\^^8f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^8f}\advance\counter by1
+\catcode`\^^90=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^90}\advance\counter by1
+\catcode`\^^91=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^91}\advance\counter by1
+\catcode`\^^92=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^92}\advance\counter by1
+\catcode`\^^93=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^93}\advance\counter by1
+\catcode`\^^94=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^94}\advance\counter by1
+\catcode`\^^95=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^95}\advance\counter by1
+\catcode`\^^96=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^96}\advance\counter by1
+\catcode`\^^97=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^97}\advance\counter by1
+\catcode`\^^98=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^98}\advance\counter by1
+\catcode`\^^99=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^99}\advance\counter by1
+\catcode`\^^9a=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^9a}\advance\counter by1
+\catcode`\^^9b=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^9b}\advance\counter by1
+\catcode`\^^9c=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^9c}\advance\counter by1
+\catcode`\^^9d=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^9d}\advance\counter by1
+\catcode`\^^9e=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^9e}\advance\counter by1
+\catcode`\^^9f=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^9f}\advance\counter by1
+\catcode`\^^a0=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a0}\advance\counter by1
+\catcode`\^^a1=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a1}\advance\counter by1
+\catcode`\^^a2=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a2}\advance\counter by1
+\catcode`\^^a3=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a3}\advance\counter by1
+\catcode`\^^a4=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a4}\advance\counter by1
+\catcode`\^^a5=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a5}\advance\counter by1
+\catcode`\^^a6=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a6}\advance\counter by1
+\catcode`\^^a7=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a7}\advance\counter by1
+\catcode`\^^a8=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a8}\advance\counter by1
+\catcode`\^^a9=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^a9}\advance\counter by1
+\catcode`\^^aa=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^aa}\advance\counter by1
+\catcode`\^^ab=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ab}\advance\counter by1
+\catcode`\^^ac=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ac}\advance\counter by1
+\catcode`\^^ad=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ad}\advance\counter by1
+\catcode`\^^ae=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ae}\advance\counter by1
+\catcode`\^^af=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^af}\advance\counter by1
+\catcode`\^^b0=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b0}\advance\counter by1
+\catcode`\^^b1=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b1}\advance\counter by1
+\catcode`\^^b2=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b2}\advance\counter by1
+\catcode`\^^b3=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b3}\advance\counter by1
+\catcode`\^^b4=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b4}\advance\counter by1
+\catcode`\^^b5=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b5}\advance\counter by1
+\catcode`\^^b6=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b6}\advance\counter by1
+\catcode`\^^b7=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b7}\advance\counter by1
+\catcode`\^^b8=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b8}\advance\counter by1
+\catcode`\^^b9=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^b9}\advance\counter by1
+\catcode`\^^ba=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ba}\advance\counter by1
+\catcode`\^^bb=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^bb}\advance\counter by1
+\catcode`\^^bc=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^bc}\advance\counter by1
+\catcode`\^^bd=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^bd}\advance\counter by1
+\catcode`\^^be=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^be}\advance\counter by1
+\catcode`\^^bf=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^bf}\advance\counter by1
+\catcode`\^^c0=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c0}\advance\counter by1
+\catcode`\^^c1=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c1}\advance\counter by1
+\catcode`\^^c2=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c2}\advance\counter by1
+\catcode`\^^c3=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c3}\advance\counter by1
+\catcode`\^^c4=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c4}\advance\counter by1
+\catcode`\^^c5=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c5}\advance\counter by1
+\catcode`\^^c6=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c6}\advance\counter by1
+\catcode`\^^c7=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c7}\advance\counter by1
+\catcode`\^^c8=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c8}\advance\counter by1
+\catcode`\^^c9=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^c9}\advance\counter by1
+\catcode`\^^ca=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ca}\advance\counter by1
+\catcode`\^^cb=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^cb}\advance\counter by1
+\catcode`\^^cc=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^cc}\advance\counter by1
+\catcode`\^^cd=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^cd}\advance\counter by1
+\catcode`\^^ce=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ce}\advance\counter by1
+\catcode`\^^cf=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^cf}\advance\counter by1
+\catcode`\^^d0=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d0}\advance\counter by1
+\catcode`\^^d1=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d1}\advance\counter by1
+\catcode`\^^d2=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d2}\advance\counter by1
+\catcode`\^^d3=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d3}\advance\counter by1
+\catcode`\^^d4=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d4}\advance\counter by1
+\catcode`\^^d5=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d5}\advance\counter by1
+\catcode`\^^d6=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d6}\advance\counter by1
+\catcode`\^^d7=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d7}\advance\counter by1
+\catcode`\^^d8=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d8}\advance\counter by1
+\catcode`\^^d9=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^d9}\advance\counter by1
+\catcode`\^^da=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^da}\advance\counter by1
+\catcode`\^^db=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^db}\advance\counter by1
+\catcode`\^^dc=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^dc}\advance\counter by1
+\catcode`\^^dd=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^dd}\advance\counter by1
+\catcode`\^^de=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^de}\advance\counter by1
+\catcode`\^^df=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^df}\advance\counter by1
+\catcode`\^^e0=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e0}\advance\counter by1
+\catcode`\^^e1=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e1}\advance\counter by1
+\catcode`\^^e2=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e2}\advance\counter by1
+\catcode`\^^e3=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e3}\advance\counter by1
+\catcode`\^^e4=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e4}\advance\counter by1
+\catcode`\^^e5=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e5}\advance\counter by1
+\catcode`\^^e6=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e6}\advance\counter by1
+\catcode`\^^e7=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e7}\advance\counter by1
+\catcode`\^^e8=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e8}\advance\counter by1
+\catcode`\^^e9=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^e9}\advance\counter by1
+\catcode`\^^ea=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ea}\advance\counter by1
+\catcode`\^^eb=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^eb}\advance\counter by1
+\catcode`\^^ec=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ec}\advance\counter by1
+\catcode`\^^ed=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ed}\advance\counter by1
+\catcode`\^^ee=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ee}\advance\counter by1
+\catcode`\^^ef=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ef}\advance\counter by1
+\catcode`\^^f0=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f0}\advance\counter by1
+\catcode`\^^f1=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f1}\advance\counter by1
+\catcode`\^^f2=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f2}\advance\counter by1
+\catcode`\^^f3=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f3}\advance\counter by1
+\catcode`\^^f4=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f4}\advance\counter by1
+\catcode`\^^f5=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f5}\advance\counter by1
+\catcode`\^^f6=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f6}\advance\counter by1
+\catcode`\^^f7=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f7}\advance\counter by1
+\catcode`\^^f8=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f8}\advance\counter by1
+\catcode`\^^f9=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^f9}\advance\counter by1
+\catcode`\^^fa=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^fa}\advance\counter by1
+\catcode`\^^fb=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^fb}\advance\counter by1
+\catcode`\^^fc=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^fc}\advance\counter by1
+\catcode`\^^fd=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^fd}\advance\counter by1
+\catcode`\^^fe=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^fe}\advance\counter by1
+\catcode`\^^ff=11 \expandafter\xdef\csname pgfp@bin@\the\counter \endcsname{^^ff}\advance\counter by1
+\ifnum\counter=256
+\else
+ \pgfplots@error{Internal logic Error: initialisation failed. I have only \the\counter\space bytes initialised.}
+\fi
+\endgroup
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotscolor.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotscolor.code.tex
new file mode 100644
index 0000000000..f0145d7f78
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotscolor.code.tex
@@ -0,0 +1,630 @@
+%--------------------------------------------
+%
+% 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-2013 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/>.
+%
+%--------------------------------------------
+
+\pgfkeys{
+ /pgfplots/color sequence/reset/.style={
+ /pgfplots/color sequence/colorspace,
+ /pgfplots/color sequence/default input colorspace,
+ /pgfplots/color sequence/every input component/.code=,
+ /pgfplots/color sequence/context message,
+ },
+ /pgfplots/color sequence/colorspace/.initial=auto,
+ /pgfplots/color sequence/colorspace/.default=auto,
+ /pgfplots/color sequence/default input colorspace/.initial=,
+ /pgfplots/color sequence/default input colorspace/.default=\pgfkeysvalueof{/pgfplots/color sequence/colorspace},
+ % applied to every INPUT component, i.e. before transforming it to some target color space.
+ /pgfplots/color sequence/every input component/.code=,
+ /pgfplots/color sequence/context message/.code={\def\pgfplotscolornormalizesequence@context@message{#1}},
+ /pgfplots/color sequence/context message/.default=\pgfplotscolornormalizesequence@context@message@default,
+ /pgfplots/color sequence/reset,
+}
+
+\newif\ifpgfplotscolor@colorspaceknown
+
+% the beginning of a normalized color sequence.
+%
+% It is to be used like
+% \pgfplotscolornormalizesequence[colorspace=rgb]
+%
+% \pgfplotscolornormalizesequencenext{1,1,1}
+% -> \pgfplotsretval = {1,1,1} % uses default colorspace
+% \pgfplotscolornormalizesequencenext{color=red}
+% -> \pgfplotsretval = {1,0,0}
+% \pgfplotscolornormalizesequencenext{color=blue}
+% -> \pgfplotsretval = {0,0,1}
+% \pgfplotscolornormalizesequencenext{rgb=1,0,0}
+% -> \pgfplotsretval = {1,0,0}
+% \pgfplotscolornormalizesequencenext{cmyk=1,0,0,1}
+% -> \pgfplotsretval = {<converted value>}
+%
+% \endpgfplotscolornormalizesequence
+%
+% Every color provided in the sequence will be normalized by
+% transforming it to the common color space and by computing the
+% separate components representing the color in that space.
+%
+% These components are available for use in interpolation routines.
+%
+% #1 : keys in the /pgfplots/color sequence path
+\def\pgfplotscolornormalizesequence[#1]{%
+ \pgfqkeys{/pgfplots/color sequence}{%
+ #1,%
+ }%
+ \pgfkeysgetvalue{/pgfplots/color sequence/colorspace}\pgfplots@loc@TMPa
+ \pgfkeysgetvalue{/pgfplots/color sequence/default input colorspace}\pgfplotscolornormalizesequence@colspace@input
+ \edef\pgfplotscolornormalizesequence@colspace@input{\pgfplotscolornormalizesequence@colspace@input}%
+ \pgfkeysgetvalue{/pgfplots/color sequence/every input component/.@cmd}\pgfplotscolornormalizesequencenext@every@component
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \def\pgfplots@loc@TMPb{auto}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % colorspace=auto: same as empty.
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \fi
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % colorspace=auto:
+ \def\pgfplotscolornormalizesequence@colspace{}%
+ \else
+ \def\pgfplots@loc@TMPb{rgb}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % colorspace=rgb:
+ \def\pgfplotscolornormalizesequence@colspace{rgb}%
+ \else
+ \def\pgfplots@loc@TMPb{cmyk}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % colorspace=cmyk:
+ \def\pgfplotscolornormalizesequence@colspace{cmyk}%
+ \else
+ \def\pgfplots@loc@TMPb{gray}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % colorspace=gray:
+ \def\pgfplotscolornormalizesequence@colspace{gray}%
+ \else
+ \pgfplots@error{Sorry, the choice colorspace=\pgfplots@loc@TMPa\space is unsupported as interpolation colorspace in pgfplots, please use one of 'auto,rgb,cmyk,gray'}%
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+
+% ends a normalized color sequence and returns the final colorspace
+% and its number of components into \pgfplotsretval and
+% \pgfplotsretvalb, respectively
+\def\endpgfplotscolornormalizesequence{%
+ \let\pgfplotsretval=\pgfplotscolornormalizesequence@colspace
+ \pgfplotscolor@get@num@components{\pgfplotsretval}{\pgfplotsretvalb}%
+ \pgfqkeys{/pgfplots/color sequence}{reset}%
+}%
+
+% accepts the next color in a sequence of colors. The color will be
+% normalized and the normalized result written to \pgfplotsretval.
+%
+% SEE \pgfplotscolornormalizesequencenext -- it is MUCH more powerful!
+%
+% #1 the color space of the color.
+% #2 the components of the color, separated by comma.
+%
+% POSTCONDITION:
+% \pgfplotsretval contains '{<color space>}{<comma-separated-components>}'
+% -> including the curly braces.
+%
+% \pgfplotsretvalb contains the number of input components in
+% \pgfplotsretval
+\def\pgfplotscolornormalizesequencenextbycomponents#1#2{%
+ \edef\pgfplotscolornormalizesequence@cur@colspace{#1}%
+ \pgfplotscolornormalizesequencenextbycomponents@normalize@components{#2}%
+ %
+ \ifx\pgfplotscolornormalizesequence@cur@colspace\pgfplotscolornormalizesequence@colspace
+ \else
+ \ifx\pgfplotscolornormalizesequence@colspace\pgfutil@empty
+ \pgfplotscolornormalizesequencenextbycomponents@assign@auto@colspace
+ \fi
+ %
+ \ifx\pgfplotscolornormalizesequence@colspace\pgfplotscolornormalizesequence@cur@colspace
+ % Ah, ok - the colorspace is NOW the correct one (because
+ % we chose it as the colorspace for this complete color
+ % sequence.
+ \else
+ % Oh. We need to convert the color space!
+ \edef\pgfplots@loc@TMPa{{\pgfplotscolornormalizesequence@cur@colspace}{\pgfplotsretval}}%
+ \expandafter\pgfutil@convertcolorspec\pgfplots@loc@TMPa
+ {\pgfplotscolornormalizesequence@colspace}% target color spaces
+ {\pgfplotsretval}% target macro
+ \fi
+ \fi
+ \edef\pgfplotsretval{\pgfplotsretval}%
+ \pgfplotscolor@get@num@components{\pgfplotscolornormalizesequence@colspace}{\pgfplotsretvalb}%
+}
+
+\def\pgfplotscolornormalizesequencenextbycomponents@assign@auto@colspace{%
+ % Ah; we have '/pgfplots/color sequence/colorspace=auto'.
+ % Well, check if the current colorspace (stored in
+ % \pgfplotscolornormalizesequence@cur@colspace) is suitable.
+ %
+ % It is suitable if it is rgb or cmyk. In all other cases,
+ % we choose either rgb or cmyk. More precisely. 'cmy' is
+ % mapped to cmyk. All other cases are treated as rgb.
+ %
+ \def\pgfplots@loc@TMPa{cmyk}%
+ \ifx\pgfplotscolornormalizesequence@cur@colspace\pgfplots@loc@TMPa
+ \let\pgfplotscolornormalizesequence@colspace=\pgfplotscolornormalizesequence@cur@colspace
+ \else
+ \def\pgfplots@loc@TMPa{cmy}%
+ \ifx\pgfplotscolornormalizesequence@cur@colspace\pgfplots@loc@TMPa
+ \def\pgfplotscolornormalizesequence@colspace{cmyk}%
+ \else
+ % rgb appears to be the best choice: (1) it is backwards
+ % compatible and (2) gray or something like that might fit
+ % badly to any other colors in the sequence.
+ \def\pgfplotscolornormalizesequence@colspace{rgb}%
+ \fi
+ \fi
+}
+
+% #1: color components
+%
+% PRECONDITION: \pgfplotscolornormalizesequence@cur@colspace is the
+% current color space
+%
+% POSTCONDITION: \pgfplotsretval contains the normalized color
+% components
+\def\pgfplotscolornormalizesequencenextbycomponents@normalize@components#1{%
+ \pgfutil@ifundefined{pgfplots@colspace@name@\pgfplotscolornormalizesequence@cur@colspace}{%
+ \pgfplotscolor@colorspaceknownfalse
+ }{%
+ \pgfplotscolor@colorspaceknowntrue
+ }%
+ \edef\pgfplots@loc@TMPb{#1}%
+ \def\pgfplotsretval{}%
+ \c@pgf@counta=0 %
+ \expandafter\pgfplotscolornormalizesequencenext@prepare@loop\pgfplots@loc@TMPb,\pgfplots@EOI,%
+}%
+
+% assigns the number of color components for the given colorspace to
+% \pgfplotsretval
+\def\pgfplotscolorspacegetcomponents#1{%
+ \pgfplotscolor@get@num@components{#1}{\pgfplotsretval}%
+}%
+
+% Defines \pgfplotsretval to contain the number of components in the
+% color space.
+\def\pgfplotscolornormalizesequencegetnumcomponents{%
+ \ifx\pgfplotscolornormalizesequence@colspace\pgfutil@empty
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Cannot create color with zero components: no colorspace set for the normalized color sequence.}\pgfeov%
+ \fi
+ \pgfplotscolorspacegetcomponents{\pgfplotscolornormalizesequence@colspace}%
+}%
+
+\def\pgfplotscolor@get@num@components#1#2{%
+ \pgfutil@ifundefined{pgfplots@colspace@numcomp@#1}{%
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{The input color has an unsupported color space '#1'}\pgfeov%
+ }{%
+ \edef#2{\csname pgfplots@colspace@numcomp@#1\endcsname}%
+ }%
+}%
+
+
+\def\pgfplots@colspace@numcomp@gray{1}%
+\def\pgfplots@colspace@name@gray{gray}%
+
+\def\pgfplots@colspace@numcomp@rgb{3}%
+\def\pgfplots@colspace@name@rgb{rgb}%
+
+\def\pgfplots@colspace@numcomp@cmyk{4}%
+\def\pgfplots@colspace@name@cmyk{cmyk}%
+
+\def\pgfplots@colspace@numcomp@cmy{3}%
+\def\pgfplots@colspace@name@cmy{cmy}%
+
+\def\pgfplots@colspace@numcomp@wave{1}%
+\def\pgfplots@colspace@name@wave{wave}%
+\pgfutil@namedef{pgfplots@colspace@minaccept@wave@0}{362.998}%
+\pgfutil@namedef{pgfplots@colspace@min@wave@0}{363}%
+\pgfutil@namedef{pgfplots@colspace@maxaccept@wave@0}{814.001}%
+\pgfutil@namedef{pgfplots@colspace@max@wave@0}{814}%
+
+\def\pgfplots@colspace@numcomp@Hsb{3}%
+\def\pgfplots@colspace@name@Hsb{Hsb}%
+\pgfutil@namedef{pgfplots@colspace@minaccept@Hsb@0}{-0.001}%
+\pgfutil@namedef{pgfplots@colspace@min@Hsb@0}{0}%
+\pgfutil@namedef{pgfplots@colspace@maxaccept@Hsb@0}{\rangeHsb}%
+\pgfutil@namedef{pgfplots@colspace@max@Hsb@0}{\rangeHsb}%
+
+\def\pgfplotscolornormalizesequencenext@prepare@loop#1,{%
+ \def\pgfmathresult{#1}%
+ \ifx\pgfmathresult\pgfplots@EOI
+ \else
+ \begingroup
+ \pgfkeyslet{/pgf/fpu/handlers/invalid number/.@cmd}\pgfplotscolornormalizesequencenextbycomponents@parsenumber@error
+ \expandafter\pgfplotscolornormalizesequencenext@every@component\expandafter{\pgfmathresult}\pgfeov%
+ \ifpgfplotscolor@colorspaceknown
+ \expandafter\pgfplotscolornormalizesequencenextbycomponents@parsenumber\expandafter{\pgfmathresult}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \ifpgfplotscolor@colorspaceknown
+ \expandafter\pgfplotscolornormalizesequencenextbycomponents@sanitize\expandafter{\pgfmathresult}%
+ \fi
+ \ifx\pgfplotsretval\pgfutil@empty
+ \edef\pgfplotsretval{\pgfmathresult}%
+ \else
+ \edef\pgfplotsretval{\pgfplotsretval,\pgfmathresult}%
+ \fi
+ \advance\c@pgf@counta by1 %
+ \expandafter\pgfplotscolornormalizesequencenext@prepare@loop
+ \fi
+}
+
+\def\pgfplotscolornormalizesequencenextbycomponents@parsenumber#1{%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloattofixed\pgfmathresult
+}
+
+\def\pgfplotscolornormalizesequencenextbycomponents@parsenumber@error#1#2\pgfeov{%
+ \pgfplotsthrow{invalid color component}{\pgfmathresult}{Sorry, the color component value '#1' is no number. Did you mean 'color=#1'? The error occured near `\pgfplotscolornormalizesequence@context@message'}\pgfeov%
+ \pgfmathfloatcreate{0}{0.0}{0}%
+}%
+
+% #1 the color component value
+\def\pgfplotscolornormalizesequencenextbycomponents@sanitize#1{%
+ \pgf@xa=#1pt %
+ %
+ % check if we have something like
+ % \csname pgfplots@colspace@minaccept@<colorspace name>@2\endcsname where 2 is component index:
+ \edef\pgfplots@loc@TMPc{@\pgfplotscolornormalizesequence@cur@colspace @\the\c@pgf@counta}%
+ \pgfutil@ifundefined{pgfplots@colspace@minaccept\pgfplots@loc@TMPc}{%
+ % NO - implicitly defined to [0,1]
+ \def\pgfplots@colspace@minaccept@@{-0.001}%
+ \def\pgfplots@colspace@min@@{-0.001}%
+ \def\pgfplots@colspace@maxaccept@@{1.001}%
+ \def\pgfplots@colspace@max@@{1}%
+ }{%
+ % YES - expect all four values:
+ \edef\pgfplots@colspace@minaccept@@{\csname pgfplots@colspace@minaccept\pgfplots@loc@TMPc\endcsname}%
+ \edef\pgfplots@colspace@min@@{\csname pgfplots@colspace@min\pgfplots@loc@TMPc\endcsname}%
+ \edef\pgfplots@colspace@maxaccept@@{\csname pgfplots@colspace@maxaccept\pgfplots@loc@TMPc\endcsname}%
+ \edef\pgfplots@colspace@max@@{\csname pgfplots@colspace@max\pgfplots@loc@TMPc\endcsname}%
+ }%
+ \ifdim\pgf@xa<\pgfplots@colspace@minaccept@@ pt %
+ \edef\pgfmathresult{\pgfplots@colspace@min@@}%
+ \pgfplotscolor@rangeexception{#1}%
+ \else
+ \ifdim\pgf@xa>\pgfplots@colspace@maxaccept@@ pt %
+ \edef\pgfmathresult{\pgfplots@colspace@max@@}%
+ \pgfplotscolor@rangeexception{#1}%
+ \else
+ % Ah - the common case!
+ \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}% normalize number (strip trailing zeros etc).
+ \fi
+ \fi
+}
+
+\def\pgfplotscolor@rangeexception#1{%
+ \pgfplotsthrow{invalid color component}{\pgfmathresult}{Sorry, the color component value #1 (no. \the\c@pgf@counta) is out of range. The allowed range is 0 <= value <= 1. The error occured near `\pgfplotscolornormalizesequence@context@message'}\pgfeov%
+}
+
+
+% Same as \pgfplotscolornormalizesequencenextbycomponents but with
+% more freedom in the input.
+%
+% #1 some color.
+% Accepted formats:
+% 'color=<xcolor value>'
+% <xcolor value> is any valid expression of the xcolor package.
+%
+% 'rgb=R,G,B'
+% R,G,B are numbers in [0,1]
+%
+% 'rgb255=R,G,B'
+% R,G,B are numbers in [0,255]
+%
+% 'cmyk=C,M,Y,K'
+% C, M, Y, and K are numbers in [0,1]
+%
+% 'cmyk255=C,M,Y,K'
+% C, M, Y, and K are numbers in [0,255]
+%
+% 'gray=G'
+% G is a gray scale number in [0,1]
+%
+% 'C1,C2,C3'
+% any number of Ci can folow, each is interpreted in the default
+% colorspace (i.e. the one set before at the beginning of the
+% sequence)
+%
+%
+% Example:
+% \pgfplotscolornormalizesequencenext{color=blue}
+% \pgfplotscolornormalizesequencenext{rgb=1,0,0}
+% \pgfplotscolornormalizesequencenext{cmyk=1,0,0,1}
+% \pgfplotscolornormalizesequencenext{1,0,0} (interpreted in the
+% colorspace set at \pgfplotscolornormalizesequence)
+%
+% POSTCONDITION: see \pgfplotscolornormalizesequencenextbycomponents
+\def\pgfplotscolornormalizesequencenext#1{%
+ \edef\pgfplotscolornormalizesequence@context@message@default{#1}%
+ \expandafter\pgfplotscolornormalizesequencenext@\pgfplotscolornormalizesequence@context@message@default\pgfplots@EOI
+}
+\def\pgfplotscolornormalizesequencenext@{%
+ \pgfutil@ifnextchar c{%
+ \pgfplotscolornormalizesequencenext@c
+ }{%
+ \pgfutil@ifnextchar r{%
+ \pgfplotscolornormalizesequencenext@rgb
+ }{%
+ \pgfutil@ifnextchar g{%
+ \pgfplotscolornormalizesequencenext@gray
+ }{%
+ \pgfplotscolornormalizesequencenext@defaultcolspace
+ }%
+ }%
+ }%
+}
+
+\def\pgfplotscolornormalizesequencenext@gray gray=#1\pgfplots@EOI{%
+ % FIXME : we might be better off with real support for a gray
+ % colorspace!
+ \pgfplotscolornormalizesequencenextbycomponents{rgb}{#1,#1,#1}%
+}
+
+\def\pgfplotscolornormalizesequencenext@defaultcolspace#1\pgfplots@EOI{%
+ \edef\pgfplotsretval{#1}%
+ \ifx\pgfplotsretval\pgfutil@empty
+ % hm. Ok, simply return the empty input.
+ %
+ % ... and the number of components.
+ \pgfplotscolor@get@num@components{\pgfplotscolornormalizesequence@colspace}{\pgfplotsretvalb}%
+ %
+ \else
+ \expandafter\pgfutil@in@\expandafter=\expandafter{\pgfplotsretval}%
+ \ifpgfutil@in@
+ \expandafter\pgfplotscolornormalizesequencenext@unknown@colspace\pgfplotsretval\pgfplots@EOI
+ \else
+ \ifx\pgfplotscolornormalizesequence@colspace@input\pgfutil@empty
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{The input color #1 cannot be interpreted; please assign a default color space first}\pgfeov%
+ \fi
+ \pgfplotscolornormalizesequencenextbycomponents{\pgfplotscolornormalizesequence@colspace@input}{#1}%
+ \fi
+ \fi
+}
+
+\def\pgfplotscolornormalizesequencenext@unknown@colspace#1=#2\pgfplots@EOI{%
+ \pgfplotscolornormalizesequencenextbycomponents{#1}{#2}%
+}
+
+\def\pgfplotscolornormalizesequencenext@rgb rgb{%
+ \pgfutil@ifnextchar2{%
+ \pgfplotscolornormalizesequencenext@rgb@two@five@five
+ }{%
+ \pgfplotscolornormalizesequencenext@rgb@plain
+ }%
+}
+\def\pgfplotscolornormalizesequencenext@rgb@plain=#1\pgfplots@EOI{%
+ \pgfplotscolornormalizesequencenextbycomponents{rgb}{#1}%
+}
+
+\def\pgfplotscolorsequence@two@five@five@rescale#1{%
+ \pgfmath@basic@multiply@{0.003921568}{#1}%
+}%
+\def\pgfplotscolornormalizesequencenext@rgb@two@five@five255=#1,#2,#3\pgfplots@EOI{%
+ \pgfplotscolorsequence@two@five@five@rescale{#1}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscolorsequence@two@five@five@rescale{#2}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscolorsequence@two@five@five@rescale{#3}%
+ \edef\pgfplots@loc@TMPc{{rgb}{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfmathresult}}%
+ \expandafter\pgfplotscolornormalizesequencenextbycomponents\pgfplots@loc@TMPc%
+}
+
+\def\pgfplotscolornormalizesequencenext@c c{%
+ \pgfutil@ifnextchar m{%
+ \pgfplotscolornormalizesequencenext@cmyk
+ }{%
+ \pgfplotscolornormalizesequencenext@color
+ }%
+}%
+
+\def\pgfplotscolornormalizesequencenext@cmyk myk{%
+ \pgfutil@ifnextchar2{%
+ \pgfplotscolornormalizesequencenext@cmyk@two@five@five
+ }{%
+ \pgfplotscolornormalizesequencenext@cmyk@plain
+ }%
+}%
+
+\def\pgfplotscolornormalizesequencenext@cmyk@plain=#1\pgfplots@EOI{%
+ \pgfplotscolornormalizesequencenextbycomponents{cmyk}{#1}%
+}%
+\def\pgfplotscolornormalizesequencenext@cmyk@two@five@five255=#1,#2,#3,#4\pgfplots@EOI{%
+ \pgfplotscolorsequence@two@five@five@rescale{#1}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscolorsequence@two@five@five@rescale{#2}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscolorsequence@two@five@five@rescale{#3}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult
+ \pgfplotscolorsequence@two@five@five@rescale{#4}%
+ \edef\pgfplots@loc@TMPc{{cmyk}{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc,\pgfmathresult}}%
+ \expandafter\pgfplotscolornormalizesequencenextbycomponents\pgfplots@loc@TMPc%
+}
+
+% The implementation of \pgfutil@extractcolorspec for plain tex and
+% context is ... strange. I prefer one which does the same as the
+% xcolor version (which is also what pgf does for latex):
+\def\pgfplotsutil@extractcolorspec@xcolor@substitute#1#2{%
+ \begingroup
+ % this here relies on PGF's emulation of color in plain tex and
+ % context. Let's hope it works in the future...
+ \def\xcolor@##1##2##3##4{%
+ \edef#2{{##3}{##4}}%
+ }%
+ \csname\string\color@#1\endcsname
+ \global\let\pgfutil@extractcolorspec@@temp=#2%
+ \endgroup
+ \let#2=\pgfutil@extractcolorspec@@temp
+}%
+
+\def\pgfplots@glob@TMPa#1#2{%
+ \def#2{{#1}}%
+}%
+
+\pgfutil@IfUndefined{extractcolorspec}{%
+ % Ah. We do not have a suitable implementation of
+ % \extractcolorspec -- \pgfutil@extractcolorspec does not yield
+ % the colorspec on context and plain tex.
+ \def\pgfplotsutil@extractcolorspec{\pgfplotsutil@extractcolorspec@xcolor@substitute}%
+}{%
+ \ifx\extractcolorspec\pgfplots@glob@TMPa
+ % Same problem as above: pgfutil-plain.def says
+ % \let\extractcolorspec=\pgfutil@extractcolorspec and that one
+ % is broken.
+ % Use my substitute:
+ \def\pgfplotsutil@extractcolorspec{\pgfplotsutil@extractcolorspec@xcolor@substitute}%
+ \else
+ \def\pgfplotsutil@extractcolorspec{\extractcolorspec}%
+ \fi
+}%
+
+\def\pgfplotscolornormalizesequencenext@color olor=#1\pgfplots@EOI{%
+ \pgfutil@colorlet{pgf@tempcol}{#1}%
+ \pgfplotsutil@extractcolorspec{pgf@tempcol}{\pgf@tempcolor}%
+ \edef\pgfplots@loc@TMPa{\expandafter\pgfutil@firstoftwo\pgf@tempcolor}%
+ \edef\pgfplots@loc@TMPb{\expandafter\pgfutil@secondoftwo\pgf@tempcolor}%
+ %
+ % I expect that \pgf@tempcolor is of the form
+ % {<colorspace>}{<comma-separated components>}
+ %
+ % unfortunately, the <colorspace> has strange catcodes such that
+ % we cannot easily compare it by means of \ifx. I normalize it
+ % here:
+ \pgfutil@ifundefined{pgfplots@colspace@name@\pgfplots@loc@TMPa}{%
+ % ohoh. we cannot normalize the name. Let's hope that works out.
+ % note that we cannot throw an exception here as we might very well be able
+ % to convert the color to some suitable color space!
+ }{%
+ \edef\pgfplots@loc@TMPa{%
+ \csname pgfplots@colspace@name@\pgfplots@loc@TMPa\endcsname%
+ }%
+ }%
+ \edef\pgf@tempcolor{%
+ {\pgfplots@loc@TMPa}%
+ {\pgfplots@loc@TMPb}%
+ }%
+ \expandafter\pgfplotscolornormalizesequencenextbycomponents\pgf@tempcolor%
+ %
+}%
+
+% Defines \pgfplotsretval to be a "neutral" color, i.e. one in which
+% all components are zero.
+% @see \pgfplotscolorzero
+% @see \pgfplotscoloraddweighted
+\def\pgfplotscolornormalizesequencezero{%
+ \pgfplotscolornormalizesequencegetnumcomponents
+ \pgfplotscolorzero{\pgfplotsretval}%
+}
+
+% Defines \pgfplotsretval to be a "neutral" color, i.e. one in which
+% all components are zero.
+%
+% #1: the number of color components to be used (like 3 for rgb)
+% @see \pgfplotscoloraddweighted
+\def\pgfplotscolorzero#1{%
+ \csname pgfplotscolorzero@num@#1\endcsname
+}%
+
+\expandafter\def\csname pgfplotscolorzero@num@1\endcsname{\def\pgfplotsretval{0}}
+\expandafter\def\csname pgfplotscolorzero@num@2\endcsname{\def\pgfplotsretval{0,0}}
+\expandafter\def\csname pgfplotscolorzero@num@3\endcsname{\def\pgfplotsretval{0,0,0}}
+\expandafter\def\csname pgfplotscolorzero@num@4\endcsname{\def\pgfplotsretval{0,0,0,0}}
+
+% Defines \pgfplotsretval to be the interpolated color #1 + #2*#3.
+% #1 the first color (like 0,0,0)
+% #2 a scaling factor (like 4)
+% #3 the second color (like 1,0,0.5)
+%
+% POSTCONDITION: \pgfplotsretval contains the result
+%
+% @see \pgfplotscolorzero
+% @see \pgfplotscoloraddweighted
+\def\pgfplotscolornormalizesequenceaddweighted#1#2#3{%
+ \begingroup
+ \pgfplotscolornormalizesequencegetnumcomponents
+ \global\let\pgfplots@glob@TMPd\pgfplotsretval
+ \endgroup
+ \pgfplotscoloraddweighted{\pgfplots@glob@TMPd}{#1}{#2}{#3}%
+}
+
+% Defines \pgfplotsretval to be the interpolated color #2 + #3*#4.
+% #1 the number of color components to be used (3 for rgb)
+% #2 the first color (like 0,0,0)
+% #3 a scaling factor (like 4)
+% #4 the second color (like 1,0,0.5)
+%
+% POSTCONDITION: \pgfplotsretval contains the result
+%
+% @see \pgfplotscolorzero
+\def\pgfplotscoloraddweighted#1#2#3#4{%
+ \pgfplots@ifempty{#4}{%
+ \pgfplots@error{Illegal input argument encountered while computing colors:
+ one color argument is missing (was empty). Please ensure that you have explicit color values in your input}%
+ }{%
+ \expandafter\let
+ \expandafter\pgfplots@loc@TMPb\csname pgfplotscolornormalizesequencegetnumcomponents@#1\endcsname
+ \edef\pgfplots@loc@TMPa{#2:#4\noexpand\relax{#3}}%
+ \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa%
+ }%
+}%
+
+\def\pgfplotscolornormalizesequenceaddweighted@single#1#2#3{%
+ \pgf@xa=#1pt %
+ \pgf@xb=#3pt %
+ \advance\pgf@xa by#2\pgf@xb
+ \edef\pgfplotsretval{\pgf@sys@tonumber\pgf@xa}%
+}%
+
+\expandafter\def\csname pgfplotscolornormalizesequencegetnumcomponents@1\endcsname#1:#2\relax#3{%
+ \pgfplotscolornormalizesequenceaddweighted@single{#1}{#3}{#2}%
+}%
+\expandafter\def\csname pgfplotscolornormalizesequencegetnumcomponents@3\endcsname#1,#2,#3:#4,#5,#6\relax#7{%
+ \pgfplotscolornormalizesequenceaddweighted@single{#1}{#7}{#4}%
+ \let\pgfplots@loc@TMPa=\pgfplotsretval
+ \pgfplotscolornormalizesequenceaddweighted@single{#2}{#7}{#5}%
+ \let\pgfplots@loc@TMPb=\pgfplotsretval
+ \pgfplotscolornormalizesequenceaddweighted@single{#3}{#7}{#6}%
+ \let\pgfplots@loc@TMPc=\pgfplotsretval
+ \edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc}%
+}%
+\expandafter\def\csname pgfplotscolornormalizesequencegetnumcomponents@4\endcsname#1,#2,#3,#4:#5,#6,#7,#8\relax#9{%
+ \pgfplotscolornormalizesequenceaddweighted@single{#1}{#9}{#5}%
+ \let\pgfplots@loc@TMPa=\pgfplotsretval
+ \pgfplotscolornormalizesequenceaddweighted@single{#2}{#9}{#6}%
+ \let\pgfplots@loc@TMPb=\pgfplotsretval
+ \pgfplotscolornormalizesequenceaddweighted@single{#3}{#9}{#7}%
+ \let\pgfplots@loc@TMPc=\pgfplotsretval
+ \pgfplotscolornormalizesequenceaddweighted@single{#4}{#9}{#8}%
+ \let\pgfplots@loc@TMPd=\pgfplotsretval
+ \edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc,\pgfplots@loc@TMPd}%
+}%
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotscolormap.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotscolormap.code.tex
new file mode 100644
index 0000000000..464f05359f
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotscolormap.code.tex
@@ -0,0 +1,2500 @@
+%--------------------------------------------
+% $Header: /cvsroot/pgfplots/pgfplots/generic/pgfplots/util/pgfplotscolormap.code.tex,v 1.15 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-2013 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/>.
+%
+%--------------------------------------------
+
+\input pgfplotscolor.code.tex
+
+\pgfkeyssetvalue{/pgfplots/colormap default colorspace}{auto}
+
+% preset for '/pgfplots/colormap uniform=always
+% This is only used for the colormap predefined in this very file.
+\def\pgfplots@colormap@uniform@choice{0}%
+
+% 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 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:
+% \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{%
+ \pgfkeysinterruptkeyfilter
+ \edef\pgfplots@createcolormap@name{pgfpl@cm@#1}%
+ \expandafter\pgfplotsarraynewempty\expandafter{\pgfplots@createcolormap@name}%
+ \pgfplotsapplistXnewempty\pgfplots@createcolormap@X
+ %
+ % '0' = is not uniform
+ % '1' = is uniform
+ % '2' = is FORCED to be uniform, i.e. will be reinterpolated
+ \ifcase\pgfplots@colormap@uniform@choice\relax
+ % colormap uniform=always (due to compatibility requirements)
+ \def\b@pgfplotscreatecolormap@isuniform{2}%
+ \or
+ % colormap uniform=if requested
+ \def\b@pgfplotscreatecolormap@isuniform{1}%
+ \fi
+ \def\pgfplots@createcolormap@MIN{}% To be computed.
+ \def\pgfplots@createcolormap@MAX{}% To be computed.
+ \def\b@pgfplots@createcolormap@pos@mode{a}% [a]uto or [m]anual
+ \pgfplots@createcolormap@initcolorspace
+ \let\pgfplots@createcolormap@LAST=\pgfplots@createcolormap@MIN
+ % PARSE IT:
+ \let\pgfplots@createcolormap@context=\pgfutil@empty
+ %%%%%%%%%%%%%%%%%%
+ % this does also init @H:
+ \pgflibraryfpuifactive{%
+ \def\pgfplots@createcolormap@restore@fpu{}%
+ }{%
+ \def\pgfplots@createcolormap@restore@fpu{\pgfkeys{/pgf/fpu=false}}%
+ \pgfkeys{/pgf/fpu=true}%
+ }%
+ %\edef\pgfplots@loc@TMPa{#2}% XXX this fails for active chars and
+ %if key/value options are too special
+ \def\pgfplots@loc@TMPa{#2}%
+ \expandafter\pgfplots@createcolormap@startloop\pgfplots@loc@TMPa\pgfplots@EOI
+ %
+ \pgfplots@createcolormap@restore@fpu
+ %
+ %%%%%%%%%%%%%%%%%%
+ %
+ \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 two points of a colormap.}%
+ \or
+ \pgfplots@error{Sorry, you need to provide at least two points of a colormap.}%
+ \fi
+ % Map the input range [MIN,MAX] linearly to [0,1000]
+ \pgfmathfloatsubtract@{\pgfplots@createcolormap@MAX}{\pgfplots@createcolormap@MIN}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfmathfloatdivide@{\pgfplotscolormaprange@float}{\pgfplots@loc@TMPb}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfplots@loc@TMPb}{\pgfplots@createcolormap@H}%
+ \let\pgfplots@loc@TMPd=\pgfmathresult
+ \pgfplots@createcolormap@normalize{\pgfmathresult}%
+ \expandafter\let\csname\pgfplots@createcolormap@name @h\endcsname=\pgfmathresult
+ %
+ \pgfmathfloatreciprocal@{\pgfplots@loc@TMPd}%
+ \pgfplots@createcolormap@normalize{\pgfmathresult}%
+ \expandafter\let\csname\pgfplots@createcolormap@name @invh\endcsname=\pgfmathresult
+ %
+ % ... and set up the X coordinates if the grid is not uniform:
+ \expandafter\pgfplotsarraynewempty\expandafter{\pgfplots@createcolormap@name @X}%
+ \if0\b@pgfplotscreatecolormap@isuniform
+ % Uncomment the '\iftrue' for testing purposes (to see if a uniform map changes if
+ % processed as non-uniform):
+% \iftrue
+ \pgfplotsapplistXlet\pgfplots@loc@TMPc=\pgfplots@createcolormap@X
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots@loc@TMPc}\as\pgfplots@loc@TMPc{%
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ \else
+ % apply the trafo [MIN,MAX] -> [0,1000] here as well:
+ \pgfmathfloatsubtract@{\pgfplots@loc@TMPc}{\pgfplots@createcolormap@MIN}%
+ \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPb}%
+ \pgfplots@createcolormap@normalize{\pgfmathresult}%
+ \expandafter\pgfplotsarraypushback\expandafter{\pgfmathresult}\to{pgfpl@cm@#1@X}%
+ \fi
+ }%
+ %
+ \pgfplotscolormapsetadditionalintervalwidth@{#1}%
+ \else
+ \expandafter\let\csname\pgfplots@createcolormap@name @X@scale@order@z\endcsname=\pgfutil@empty
+ \fi
+ % clear temporary list:
+ \pgfplotsapplistXnewempty\pgfplots@createcolormap@X
+ %
+ \if m\b@pgfplots@createcolormap@pos@mode
+ % Ah - we have manually provided positions!
+ % DISABLE the extra interval. You have to enable it explicitly
+ % by means of 'colormap access/extra interval width=0.1'
+ \expandafter\def\csname\pgfplots@createcolormap@name @X@scale@order@z\endcsname{0}%
+ \fi
+ %
+ \endpgfplotscolornormalizesequence%
+ \expandafter\let\csname\pgfplots@createcolormap@name @colspace\endcsname=\pgfplotsretval
+ \expandafter\let\csname\pgfplots@createcolormap@name @col@comps\endcsname=\pgfplotsretvalb
+ \c@pgf@counta=\expandafter\pgfplotsarraysizeof\expandafter{\pgfplots@createcolormap@name}\relax
+ \advance\c@pgf@counta by-1 %
+ \expandafter\edef\csname\pgfplots@createcolormap@name @lastindex\endcsname{\the\c@pgf@counta}%
+%\pgfplots@colormap@showdebuginfofor{#1}%
+ \pgfplots@colormap@LUA@new{#1}%
+ \endpgfkeysinterruptkeyfilter
+}
+
+\def\pgfplots@createcolormap@normalize#1{%
+ \pgfmathfloattofixed{#1}%
+ \pgf@xa=\pgfmathresult pt %
+ \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}% normalize number.
+}%
+
+% Allows to customize the width of the additional interval used for
+% 'colormap access=piecewise constant'.
+%
+% #1 colormap name
+% #2 the additional interval width for this colormap. Use '0' to disable the additional
+% interval. The value is relative to the total width and must be in
+% the range 0<=#2<=0.9
+\def\pgfplotscolormapsetadditionalintervalwidth#1#2{%
+ \edef\pgfplots@loc@TMPd{#2}%
+ \def\pgfplots@loc@TMPc{h}%
+ \ifx\pgfplots@loc@TMPd\pgfplots@loc@TMPc
+ % 'h' means: mesh width:
+ \pgfplotscolormapifisuniform{#1}{%
+ \expandafter\let\csname pgfpl@cm@#1@X@scale@order@z\endcsname\pgfutil@empty%
+ }{%
+ \pgfplotscolormapsetadditionalintervalwidth@{#1}%
+ }%
+ \else
+ \pgfmathparse{#2}%
+ \pgfplotscolormapifisuniform{#1}{%
+ \ifdim\pgfmathresult pt>0pt
+ \pgfplots@error{Uniform colormaps support no configuration of the additional interval width for a colormap (although you can use 0 to turn it off). Please use a non-uniform colormap.}%
+ \else
+ % DISABLE the extra interval!
+ \expandafter\def\csname pgfpl@cm@#1@X@scale@order@z\endcsname{0}%
+ \fi
+ }{%
+ \ifdim\pgfmathresult pt>0pt
+ \ifdim\pgfmathresult pt>0.9pt
+ \pgfplots@error{Expected a number 0< X <= 0.9, not \pgfmathresult}%
+ \else
+ % compute the 'h'.
+ %
+ % Note that 's:=#2' is a fraction 0<x<1 of the RESULTING
+ % range, i.e. s * 1000 = H where 0<=H<=1000.
+ % but H = 1000/(1000+h) * 1000, and we need the 'h'.
+ %
+ % -> h = 1000/s - 1000.
+ % regarding the '1-#2': I did some mistake in my
+ % computation and that fixed it :-/
+ \pgfmathparse{1000/(1-#2)-1000}%
+ \expandafter\let\csname pgfpl@cm@#1@h\endcsname=\pgfmathresult
+ \expandafter\let\csname pgfpl@cm@#1@invh\endcsname=\pgfutil@empty% unused!
+ \pgfplotscolormapsetadditionalintervalwidth@{#1}%
+ \fi
+ \else
+ % DISABLE the extra interval!
+ \expandafter\def\csname pgfpl@cm@#1@X@scale@order@z\endcsname{0}%
+ \fi
+ }%
+ \fi
+ %
+ \ifpgfplots@LUA@supported
+ \pgfplotsutil@directlua{%
+ pgfplots.texColorMapSetScaleOrderZ("#1", "\csname pgfpl@cm@#1@X@scale@order@z\endcsname")
+ }%
+ \fi
+}%
+
+% see \pgfplotscolormapsetadditionalintervalwidth
+\def\pgfplotscolormapsetadditionalintervalwidth@#1{%
+ % 'colormap access=piecewise constant' (order 0) requires a
+ % special scaling factor. See its consumers for details +
+ % documentation
+ \pgfmathparse{1000/(1000+\csname pgfpl@cm@#1@h\endcsname)}%
+ \expandafter\let\csname pgfpl@cm@#1@X@scale@order@z\endcsname=\pgfmathresult
+}%
+
+\def\pgfplots@createcolormap@initcolorspace{%
+ \pgfplotscolornormalizesequence[
+ colorspace=\pgfkeysvalueof{/pgfplots/colormap default colorspace},
+ context message=\pgfplots@createcolormap@context\pgfplots@createcolormap@trace,
+ ]%
+}%
+\def\pgfplots@createcolormap@seth[#1]{%
+ \def\pgfplots@createcolormap@context{[#1]}%
+ \pgfmathparse{#1}%
+ \let\pgfplots@createcolormap@H=\pgfmathresult
+ % request for a uniform colormap:
+ \def\b@pgfplotscreatecolormap@isuniform{3}%
+ \pgfplots@createcolormap@
+}%
+
+\def\pgfplots@createcolormap@startloop{%
+ \pgfutil@ifnextchar[%
+ {\pgfplots@createcolormap@seth}%
+ {%
+ \let\pgfplots@createcolormap@H=\pgfutil@empty
+ \pgfplots@createcolormap@
+ }%
+}%
+\def\pgfplots@createcolormap@{%
+ \pgfutil@ifnextchar\pgfplots@EOI{\pgfutil@gobble}%done!
+ {%
+ \pgfutil@ifnextchar;{\pgfplots@createcolormap@grabsemicolon}%
+ {%
+ \pgfutil@ifnextchar,{\pgfplots@createcolormap@grabcomma}%
+ {%
+ \expandafter\pgfutil@ifnextchar\pgfplots@activesemicolon{\pgfplots@createcolormap@grabsemicolon@active}%
+ {%
+ \pgfplots@createcolormap@grabnext
+ }%
+ }%
+ }%
+ }%
+}
+
+% Executes '#1' if there are more tokens and '#2' if not.
+\def\pgfplots@createcolormap@ifhasmorecolors#1#2{%
+ \pgfutil@ifnextchar\pgfplots@EOI{%
+ #2% no more tokens.
+ }{%
+ \pgfutil@ifnextchar;{\pgfplots@createcolormap@grabsemicolon@hasnext{#1}{#2}}%
+ {%
+ \pgfutil@ifnextchar,{\pgfplots@createcolormap@grabcomma@hasnext{#1}{#2}}%
+ {%
+ \expandafter\pgfutil@ifnextchar\pgfplots@activesemicolon{\pgfplots@createcolormap@grabsemicolon@active@hasnext{#1}{#2}}%
+ {%
+ #1% has more.
+ }%
+ }%
+ }%
+ }%
+}%
+
+\def\pgfplots@createcolormap@error#1#2\pgfplots@EOI{%
+ {%
+ \t@pgfplots@toka={#1#2}%
+ \t@pgfplots@tokb={#1}%
+ \pgfplots@error{Illformed colormap specification: I could not read the substring `\the\t@pgfplots@toka' starting at `\the\t@pgfplots@tokb'\pgfplots@createcolormap@trace}%
+ }%
+}%
+
+\def\pgfplots@createcolormap@trace{%
+ \space(color no \expandafter\pgfplotsarraysizeof\expandafter{\pgfplots@createcolormap@name})
+}
+
+\def\pgfplots@createcolormap@grabnext#1={%
+ \pgfutil@ifnextchar({\pgfplots@createcolormap@grabnext@round{#1}=}{%
+ \pgfutil@ifnextchar\bgroup{\pgfplots@createcolormap@grabnext@curly{#1}=}{%
+ \pgfplots@createcolormap@error#1=%
+ }%
+ }%
+}
+\def\pgfplots@createcolormap@grabnext@round#1=(#2){%
+ \pgfplots@createcolormap@grabnext@@{#1}={#2}%
+}%
+\def\pgfplots@createcolormap@grabnext@curly#1=#2{%
+ \pgfplots@createcolormap@grabnext@@{#1}={#2}%
+}%
+\def\pgfplots@createcolormap@grabnext@@#1=#2{%
+ \pgfutil@in@({#1}%
+ \ifpgfutil@in@
+ % Ah. We have something like 'color(1cm)' before the equal sign.
+ \pgfplots@createcolormap@grabnext@read@pos#1\pgfplots@EOI%
+ % now:
+ %\pgfplots@loc@TMPa = colorspace
+ %\pgfplots@loc@TMPb = position
+ %
+ \else
+ % Ah. we do not have a position, i.e. we have
+ % color=(green)
+ % or something like this.
+ %
+ % this here defines \pgfplots@loc@TMPa to contain the
+ % colorspace:
+ \pgfkeys@spdef\pgfplots@loc@TMPa{#1}%
+ %
+ \pgfplots@createcolormap@grabnext@computenextposition
+ \let\pgfplots@loc@TMPb=\pgfmathresult% position
+ \fi
+ \def\pgfplots@loc@TMPc{#2}%
+ \pgfplots@createcolormap@grabnext@complete
+}%
+
+\def\pgfplots@createcolormap@grabnext@read@pos#1({%
+ \pgfkeys@spdef\pgfplots@loc@TMPa{#1}% colorspace
+ \pgfplots@createcolormap@grabnext@read@pos@
+}%
+\def\pgfplots@createcolormap@grabnext@read@pos@#1){%
+ \def\pgfplots@loc@TMPb{#1}% position
+ \def\b@pgfplots@createcolormap@pos@mode{m}% [m]anual
+ \pgfutil@ifnextchar\pgfplots@EOI{%
+ % OK
+ \pgfplots@gobble@until@EOI
+ }{%
+ \pgfplots@createcolormap@error#1)%
+ }%
+}%
+
+%%%%%%%%%%
+
+% Splits '<argument> of <source name>*' into (\pgfplotsretval,
+% \pgfplotsretvalb).
+%
+% The 'of' part is optional. If it is missing, '\pgfplotsretval'
+% contains the entire argument and '\pgfplotsretvalb' is the current
+% colormap.
+%
+% Note that '<source name>*' is typically just a colormap name (i.e. without
+% '*'), but it _may_ contain key-value lists! They will be returned as-is.
+% #1: the string to split
+% #2: '1' if '#1' may contain ',' and '0' otherwise
+\def\pgfplots@createcolormap@special@split#1#2{%
+ \pgfutil@in@{of }{#1}%
+ \ifpgfutil@in@
+ \pgfplots@createcolormap@special@split@#1\pgfplots@EOI
+ \else
+ \if1#2\relax
+ % do not check it -- commas are allowed here!
+ \pgfutil@in@false
+ \else
+ \pgfutil@in@{,}{#1}%
+ \fi
+ \ifpgfutil@in@
+ % ah - might be something like '5, target pos={1,2,3}'.
+ % -> define \pgfplotsretval='5' and
+ % \pgfplotsretvalb='<colormap name>, target pos={1,2,3}':
+ %
+ \pgfplots@createcolormap@special@split@command#1\pgfplots@EOI
+ \t@pgfplots@tokb=\expandafter{\pgfplotsretvalb}%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretvalb
+ \edef\pgfplotsretvalb{\pgfplotsretvalb,\the\t@pgfplots@tokb}%
+ \else
+ \pgfkeys@spdef\pgfplotsretval{#1}%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretvalb
+ \fi
+ \fi
+%\message{Split (#1) --> '\pgfplotsretval', '\pgfplotsretvalb'^^J}%
+}%
+\def\pgfplots@createcolormap@special@split@#1of #2\pgfplots@EOI{%
+ \pgfkeys@spdef\pgfplotsretval{#1}%
+ \pgfkeys@spdef\pgfplotsretvalb{#2}%
+}
+\def\pgfplots@createcolormap@special@split@command#1,#2\pgfplots@EOI{%
+ \pgfkeys@spdef\pgfplotsretval{#1}%
+ \pgfkeys@spdef\pgfplotsretvalb{#2}%
+}
+
+% Output: \pgfplotsretval will be populated with the resulting
+% colormap name.
+\def\pgfplots@createcolormap@special@ensure@source@cm#1{%
+ \edef\pgfplotsretval{#1}%
+ \pgfplotscolormapifdefined{#1}{}{%
+ % hm... the colormap does not exist? Perhaps someone used
+ % style 'colormap/cool'. Try to define it!
+ \pgfkeysifdefined{/pgfplots/#1/.@cmd}{%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@color@of@colormap@name@old
+ \pgfplotsset{#1}%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretval
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplots@color@of@colormap@name@old
+ }{%
+ \pgfplots@error{The argument '#1' is no valid colormap.}%
+ }%
+ }%
+}%
+
+\newif\ifpgfplots@createcolormap@target@pos@includes@limits@min
+\newif\ifpgfplots@createcolormap@target@pos@includes@limits@max
+
+% these keys are only evaluated inside of
+% \pgfplots@of@colormap@getresult :
+\pgfqkeys{/pgfplots/of colormap}{%
+ source name/.initial=,
+ target pos/.initial=,
+ target pos min/.initial=,
+ target pos min/insert/.is if=pgfplots@createcolormap@target@pos@includes@limits@min,
+ target pos min*/.style={%
+ /pgfplots/of colormap/target pos min={#1},
+ /pgfplots/of colormap/target pos min/insert=true,
+ },%
+ target pos max/.initial=,
+ target pos max*/.style={%
+ /pgfplots/of colormap/target pos max={#1},
+ /pgfplots/of colormap/target pos max/insert=true,
+ },%
+ target pos max/insert/.is if=pgfplots@createcolormap@target@pos@includes@limits@max,
+ source pos/.initial=,
+ source pos/.set if not empty/.code={%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfkeyslet{/pgfplots/of colormap/source pos}\pgfplots@loc@TMPa
+ \fi
+ },
+ %
+ @define/.code={%
+ \pgfplots@error{Please write 'single color' or 'color list' such that pgfplots knows how to interprete values}%
+ \let\pgfplotsretval=\pgfutil@empty
+ },
+ single color/.style={%
+ /pgfplots/of colormap/@define/.code={%
+ \pgfplots@createcolormap@special@process@single
+ },
+ },
+ color list/.style={%
+ /pgfplots/of colormap/@define/.code={%
+ \pgfplots@createcolormap@special@process@list%
+ },
+ },
+ color list,
+ %
+ of colormap/.style={#1},
+ %
+ % 'color of colormap={#1}' is a style which boils down to
+ % '@delegate to@ of colormap={color}{#1}'.
+ % The same is true for
+ % colors of colormap
+ % index of colormap
+ % indices of colormap
+ % samples of colormap
+ %
+ % All use this implementation:
+ % #1: how to interprete results. /pgfplots/of colormap/#1 must be
+ % a valid key (like 'color').
+ % #2: the argument which can be '<source pos> of <source name>' or '<source pos>'.
+ % #3: '1' if the source pos may contain ',' and '0' otherwise
+ @delegate to@ of colormap/.code args={#1#2#3}{%
+ % Convert 'color of colormap={...}' and its variants into
+ % 'of colormap={<list of keys>}':
+ \pgfplots@createcolormap@special@split{#2}{#3}%
+ \edef\pgfplots@loc@TMPa{%
+ #1,%
+ source pos={\pgfplotsretval},%
+ % \pgfplotsretvalb will contain the colormap name
+ % --- but it _can_ also contain further key-value pairs!
+ % Do not add braces here such that further key-value pairs
+ % can be found:
+ source name=\pgfplotsretvalb,%
+ }%
+ \expandafter\pgfkeysalso\expandafter{\pgfplots@loc@TMPa}%
+ },
+ %
+ color/.style={%
+ /pgfplots/of colormap/colormap access=map,
+ /pgfplots/of colormap/single color,
+ /pgfplots/of colormap/source pos/.set if not empty={#1},
+ },
+ const color/.style={%
+ /pgfplots/of colormap/colormap access=piecewise constant,
+ /pgfplots/of colormap/single color,
+ /pgfplots/of colormap/source pos/.set if not empty={#1},
+ },
+ index/.style={%
+ /pgfplots/of colormap/colormap access=direct,
+ /pgfplots/of colormap/single color,
+ /pgfplots/of colormap/source pos/.set if not empty={#1},
+ },
+ colors/.style={%
+ /pgfplots/of colormap/colormap access=map,
+ /pgfplots/of colormap/color list,
+ /pgfplots/of colormap/source pos/.set if not empty={#1},
+ },
+ samples/.style={%
+ /pgfplots/of colormap/colormap access=map,% can be overridden if needed.
+ /pgfplots/of colormap/@define/.code={%
+ \pgfplots@createcolormap@special@process@list@sampled%
+ },
+ /pgfplots/of colormap/source pos/.set if not empty={#1},
+ },%
+ %
+ const colors/.style={%
+ /pgfplots/of colormap/colormap access=piecewise constant,
+ /pgfplots/of colormap/color list,
+ /pgfplots/of colormap/source pos/.set if not empty={#1},
+ },
+ indices/.style={%
+ /pgfplots/of colormap/colormap access=direct,
+ /pgfplots/of colormap/color list,
+ /pgfplots/of colormap/source pos/.set if not empty={#1},
+ },
+ colormap access/.style={/pgfplots/colormap access={#1}},
+ source range/.initial=0:1000,
+ %
+ sample for/.is choice,
+ sample for/default/.code={\def\pgfplots@ofcolorbar@sample@for@choice{m}},
+ sample for/const/.code={\def\pgfplots@ofcolorbar@sample@for@choice{c}},
+ sample for=default,
+ %
+ /pgfplots/of colormap/.unknown/.code={%
+ \pgfplotsutilifstringequal{#1}{\pgfkeysnovalue}{%
+ % This here allows to write 'of colormap={initial}'
+ \pgfplotscolormapifdefined{\pgfkeyscurrentname}{%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfkeysalso{%
+ /pgfplots/of colormap/source name={\pgfkeyscurrentname},
+ }%
+ }%
+ \pgfplots@loc@TMPa
+ }{%
+ \pgfplots@error{Unknown key '\pgfkeyscurrentname'. Is this a colormap name? Maybe you need to write \string\pgfplotsset{\pgfkeyscurrentname} first?}%
+ }%
+ }{%
+ \pgfkeysgetvalue{/handlers/.unknown/.@cmd}{\pgfkeys@code}%
+ \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov%
+ }%
+ },
+ %
+ % allow something like 'of colormap={colormap/PuBuGn}':
+ /pgfplots/of colormap/colormap/.unknown/.code={%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsset{colormap/\pgfkeyscurrentname}}%
+ \pgfplots@loc@TMPa
+ },%
+}
+\pgfplotsinvokeforeach{%
+ color,% defines 'color of colormap'
+ index,% defines 'index of colormap'
+ const color,% defines 'const color of colormap'
+ samples,% defines 'samples of colormap'
+}{%
+ \def\pgfplots@glob@TMPa{#1}%
+ \ifx\pgfplots@glob@TMPa\pgfutil@empty
+ \else
+ \pgfkeysdef{/pgfplots/of colormap/#1 of colormap}{%
+ \pgfkeysalso{/pgfplots/of colormap/@delegate to@ of colormap={#1}{##1}{0}}%
+ }%
+ \fi
+}%
+\pgfplotsinvokeforeach{%
+ indices,% defines 'indices of colormap'
+ colors,% defines 'colors of colormap'
+ const colors,% defines 'const colors of colormap'
+}{%
+ \def\pgfplots@glob@TMPa{#1}%
+ \ifx\pgfplots@glob@TMPa\pgfutil@empty
+ \else
+ \pgfkeysdef{/pgfplots/of colormap/#1 of colormap}{%
+ \pgfkeysalso{/pgfplots/of colormap/@delegate to@ of colormap={#1}{##1}{1}}%
+ }%
+ \fi
+}%
+
+% This is the main implementation of 'of colormap'. It is shared by
+% both cycle lists and colormaps.
+%
+\def\pgfplots@of@colormap@getresult#1{%
+ \pgfkeysinterruptkeyfilter
+ \pgfqkeys{/pgfplots/of colormap}{%
+ % ensure that this here is not inherited from the axis'
+ % configuration -- reset it:
+ colormap access=map,%
+ #1}%
+ \pgfkeysgetvalue{/pgfplots/of colormap/source name}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplots@loc@TMPa
+ \fi
+ \pgfplots@createcolormap@special@ensure@source@cm{\pgfkeysvalueof{/pgfplots/colormap name}}%
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplotsretval
+ %
+ \pgfqkeys{/pgfplots/of colormap}{@define}%
+ \endpgfkeysinterruptkeyfilter
+}%
+
+
+\def\pgfplots@createcolormap@special@process@single@error{%
+ \pgfplots@error{Did not find a suitable input source pos in a 'of colormap' specification. Did you forget the 'source pos'? It can be given as 'colors of colormap=(source pos of name)' or 'of colormap=(source pos=...,..)'}%
+ \pgfkeyssetvalue{/pgfplots/of colormap/source pos}{0}%
+}%
+\def\pgfplots@createcolormap@special@process@single@error@comma{%
+ \pgfplots@error{Found an unexpected comma in 'source pos=\pgfkeysvalueof{/pgfplots/of colormap/source pos}'. Please use one of the styles 'colors', 'indices', or 'const colors' in order to process more than one position}%
+ \pgfkeyssetvalue{/pgfplots/of colormap/source pos}{0}%
+}%
+\def\pgfplots@createcolormap@special@process@single{%
+ \begingroup
+ \let\pgfplots@color@of@colormap@access=\pgfplots@colormap@access
+ \pgfkeysgetvalue{/pgfplots/of colormap/source range}\pgfplotspointmetatransformedrange
+ \ifx\pgfplotspointmetatransformedrange\pgfutil@empty
+ % evaluated by \pgfplots@color@of@colormap@define...
+ \let\pgfplotspointmetatransformedrange=\pgfplotscolormaprange
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfplots@createcolormap@special@process@single@error
+ \else
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfutil@in@{,}{\pgfplots@loc@TMPa}%
+ }%
+ \pgfplots@loc@TMPa
+ \ifpgfutil@in@
+ \pgfplots@createcolormap@special@process@single@error@comma
+ \else
+ \pgfmathparse{\pgfkeysvalueof{/pgfplots/of colormap/source pos}}%
+ \pgfkeyslet{/pgfplots/of colormap/source pos}\pgfmathresult
+ \fi
+ \fi
+ %
+ \pgflibraryfpuifactive{\pgfkeys{/pgf/fpu=false}}{}%
+ %
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplots@color@of@colormap@define{\pgfkeysvalueof{/pgfplots/of colormap/source pos}}%
+ }%
+ \pgfplots@loc@TMPa
+ %
+ \pgfplots@createcolormap@special@process@single@define
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+\def\pgfplots@createcolormap@special@process@single@define{%
+ \pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots@temp@pos
+ \ifx\pgfplots@temp@pos\pgfutil@empty
+ \else
+ \edef\pgfplots@temp@pos{(\pgfplots@temp@pos)}%
+ \fi
+ %
+ \edef\pgfplotsretval{%
+ \csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname\pgfplots@temp@pos=(\pgfmathresult)%
+ }%
+}%
+\let\pgfplots@createcolormap@special@process@single@define@CM=\pgfplots@createcolormap@special@process@single@define%
+
+\def\pgfplots@createcolormap@special@process@list@sanitize@selection{%
+ \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % default to a suitable source pos.
+ \ifnum\pgfplots@pos@size<2
+ % We have either 0 positions or 1 position.
+ % This is clearly insufficient and we assume that this
+ % position argument merely gives the start point for the
+ % list.
+ %
+ % Select all of the input colormap:
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfkeysalso{%
+ /pgfplots/of colormap/source pos={0,...,\pgfplotscolormaplastindexof{\pgfkeysvalueof{/pgfplots/colormap name}}},%
+ /pgfplots/of colormap/indices,
+ }%
+ }%
+ \pgfplots@loc@TMPa
+ \else
+ % hm... we have no source pos, but we have positions! In
+ % this case, we _sample_ source pos uniformly with one
+ % sample for each position!
+ \pgfkeyslet{/pgfplots/of colormap/source pos}\pgfplots@pos@size
+ \pgfplots@createcolormap@special@process@list@sampled@define{P}%
+ \fi
+ \fi
+}
+\def\pgfplots@createcolormap@special@process@list@limits{%
+ \begingroup
+ %
+ \pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots@target
+ \ifx\pgfplots@target\pgfutil@empty
+ \else
+ \pgfkeys{/pgf/fpu=true}%
+ \pgfkeysgetvalue{/pgfplots/of colormap/target pos min}\pgfplots@target@min
+ \pgfkeysgetvalue{/pgfplots/of colormap/target pos max}\pgfplots@target@max
+ \pgfplots@loc@tmpfalse
+ \ifx\pgfplots@target@min\pgfutil@empty
+ \else
+ \pgfmathparse\pgfplots@target@min
+ \let\pgfplots@target@min=\pgfmathresult
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifx\pgfplots@target@max\pgfutil@empty
+ \else
+ \pgfmathparse\pgfplots@target@max
+ \let\pgfplots@target@max=\pgfmathresult
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifpgfplots@loc@tmp
+ % Ah - we _have_ limit constraints! Enforce them:
+ \def\b@pgfplots@isfirst{1}%
+ \pgfmathfloatcreate{1}{1.0}{324}%
+ \let\pgfplots@firstpos\pgfmathresult%
+ \let\pgfplots@lastpos\pgfmathresult%
+ \pgfplotsapplistXnewempty\pgfplots@createcolormap@trg@accum
+ \def\pgfplots@loc@TMPa{\pgfplotsforeachungrouped \x in}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@target}{%
+ \ifx\x\pgfutil@empty
+ \else
+ \pgfmathparse{\x}%
+ \let\x=\pgfmathresult
+ \ifx\pgfplots@target@min\pgfutil@empty
+ \else
+ \pgfmathfloatlessthan{\x}{\pgfplots@target@min}%
+ \ifpgfmathfloatcomparison
+ \let\x=\pgfutil@empty
+ \fi
+ \fi
+ \ifx\pgfplots@target@max\pgfutil@empty
+ \else
+ \ifx\x\pgfutil@empty
+ \else
+ \pgfmathfloatlessthan{\pgfplots@target@max}{\x}%
+ \ifpgfmathfloatcomparison
+ \let\x=\pgfutil@empty
+ \fi
+ \fi
+ \fi
+ %
+ \ifx\x\pgfutil@empty
+ \else
+ \let\pgfplots@lastpos=\x
+ \if1\b@pgfplots@isfirst
+ \let\pgfplots@firstpos=\x
+ \def\b@pgfplots@isfirst{0}%
+ \else
+ \edef\x{,\x}%
+ \fi
+ \expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots@createcolormap@trg@accum
+ \fi
+ \fi
+ }%
+ %
+ \ifpgfplots@createcolormap@target@pos@includes@limits@max
+ \ifx\pgfplots@target@max\pgfutil@empty
+ \else
+ \pgfmathfloatifapproxequalrel{\pgfplots@lastpos}{\pgfplots@target@max}{%
+ }{%
+ \let\x=\pgfplots@target@max
+ \if1\b@pgfplots@isfirst
+ \def\b@pgfplots@isfirst{0}%
+ \else
+ \edef\x{,\x}%
+ \fi
+ \expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots@createcolormap@trg@accum
+ }%
+ \fi
+ \fi
+ %
+ \pgfplotsapplistXlet\pgfplots@target=\pgfplots@createcolormap@trg@accum
+ %
+ \ifpgfplots@createcolormap@target@pos@includes@limits@min
+ \ifx\pgfplots@target@min\pgfutil@empty
+ \else
+ \pgfmathfloatifapproxequalrel{\pgfplots@firstpos}{\pgfplots@target@min}{%
+ }{%
+ \let\x=\pgfplots@target@min
+ \if1\b@pgfplots@isfirst
+ \let\pgfplots@target=\x
+ \else
+ \edef\pgfplots@target{\x,\pgfplots@target}%
+ \fi
+ }%
+ \fi
+ \fi
+ \fi
+ \fi
+ %
+ \global\let\pgfplots@glob@TMPb=\pgfplots@target
+ \endgroup
+%\message{limit application: \pgfkeysvalueof{/pgfplots/of colormap/target pos} ^^J -->\pgfplots@glob@TMPb^^J}%
+ \pgfkeyslet{/pgfplots/of colormap/target pos}\pgfplots@glob@TMPb
+}%
+
+\def\pgfplots@createcolormap@special@process@list@define@target@array{%
+ \pgfplots@createcolormap@special@process@list@limits%
+ %
+ \pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots@loc@TMP
+ \expandafter\pgfplotsarraynew\expandafter\pgfplots@pos@array\expandafter{\pgfplots@loc@TMP}%
+ %
+ \pgfplotsarraysizetomacro\pgfplots@pos@array\to\pgfplots@pos@size
+}%
+
+% PRECONDITION: Must be invoked within \pgfplots@of@colormap@getresult
+\def\pgfplots@createcolormap@special@process@list{%
+ \begingroup
+ \pgfkeys{/pgf/fpu=true}%
+ \pgfplots@createcolormap@special@process@list@define@target@array
+ %
+ \pgfplotsapplistXnewempty\pgfplots@createcolormap@special@process@result
+ %
+ \gdef\c@pgfplots@elem{0}%
+ %
+ \def\pgfplots@createcolormap@special@process@list@append{%
+ \pgfplots@createcolormap@special@process@single
+ %
+ % append separator
+ \t@pgfplots@toka=\expandafter{\pgfplotsretval}%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@createcolormap@special@process@list@separator}%
+ \edef\pgfplotsretval{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ %
+ \expandafter\pgfplotsapplistXpushback\pgfplotsretval\to\pgfplots@createcolormap@special@process@result
+ }%
+ %
+ \pgfplots@createcolormap@special@process@list@sanitize@selection
+ %
+ \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots@source
+ %
+ \def\pgfplots@loc@TMPa{\pgfplotsforeachungrouped \x in }%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@source}{%
+ %
+ \pgfkeyslet{/pgfplots/of colormap/source pos}\x
+ %
+ \ifnum\c@pgfplots@elem<\pgfplots@pos@size\relax
+ \pgfplotsarrayselect\c@pgfplots@elem\of\pgfplots@pos@array\to\pgfplots@loc@TMPa
+ \pgfkeyslet{/pgfplots/of colormap/target pos}\pgfplots@loc@TMPa
+ \else
+ % auto-position:
+ \pgfkeyslet{/pgfplots/of colormap/target pos}\pgfutil@empty
+ \fi
+ %
+ \pgfplots@createcolormap@special@process@list@append
+ %
+ \pgfplotsutil@advancestringcounter@global\c@pgfplots@elem
+ }%
+ %
+ \pgfutil@loop
+ \ifnum\c@pgfplots@elem<\pgfplots@pos@size\relax
+ \pgfplotsarrayselect\c@pgfplots@elem\of\pgfplots@pos@array\to\pgfplots@loc@TMPa
+ \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\x
+ \pgfplotswarning{too many colormap positions}{index \c@pgfplots@elem\space (value \pgfplots@loc@TMPa)}\pgfeov%
+ \pgfplotsutil@advancestringcounter@global\c@pgfplots@elem
+ %
+ \pgfutil@repeat
+ %
+ \pgfplotsapplistXlet\pgfplotsretval=\pgfplots@createcolormap@special@process@result
+ \global\let\pgfplots@glob@TMPa=\pgfplotsretval
+ \endgroup
+ \let\pgfplotsretval=\pgfplots@glob@TMPa
+%\message{of colormap with list functionality results in \meaning\pgfplotsretval^^J}%
+}%
+\def\pgfplots@createcolormap@special@process@list@sampled{%
+ \begingroup
+ \pgfkeys{/pgf/fpu=true}%
+ \pgfplots@createcolormap@special@process@list@define@target@array
+ %
+ % no need to reapply it in \pgfplots@createcolormap@special@process@list:
+ \let\pgfplots@createcolormap@special@process@list@define@target@array=\relax
+ %
+ \pgfplots@createcolormap@special@process@list@sampled@define{S}%
+ \pgfplots@createcolormap@special@process@list
+ \global\let\pgfplots@glob@TMPa=\pgfplotsretval
+ \endgroup
+ \let\pgfplotsretval=\pgfplots@glob@TMPa
+}
+
+% Defines
+% * 'source range',
+% * 'source pos',
+% in a way such that it implements 'samples of colormap'
+% #1: 'S' if it _must_ satisfy the number of samples and 'P' if it
+% _must_ satisfy the positions
+\def\pgfplots@createcolormap@special@process@list@sampled@define#1{%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots@source
+ %
+ \def\b@pgfplots@special@interval{0}%
+ \def\b@pgfplots@special@interval@additional{0}%
+ \if c\pgfplots@ofcolorbar@sample@for@choice%
+ % or colormap/sample for=const:
+ % sample one less and replicate the last color. This
+ % is to compensate for 'colormap access/extra interval width=0'
+ % (which is the default for colormaps with positions)
+ \ifnum\pgfplots@pos@size>1
+ % ah - we have at least 2 positions and 'extra interval width=0' applies!
+ \if S#1%
+ \c@pgf@counta=\pgfplots@source\relax
+ \advance\c@pgf@counta by1 %
+ \ifnum\pgfplots@pos@size=\c@pgf@counta
+ \else
+ \pgfplotsthrow{too few colormap positions}{\pgfplots@pos@size}{There is an unexpected number of arguments to 'target pos' for 'samples of colormap=(\pgfplots@source)'. Please provide \the\c@pgf@counta\space positions, not \pgfplots@pos@size}\pgfeov%
+ \fi
+ \fi
+ \if S#1%
+ % this is the case
+ % samples of colormap={5, target pos={<6 positions>}}
+ % -> we need to replicate the last color such that we see the rightmost color of the input map
+ \def\b@pgfplots@special@interval{1}%
+ % -> we also need one more sample point (one for each position):
+ \def\b@pgfplots@special@interval@additional{1}%
+ \else
+ % we have pgfplots@pos@size=pgfplots@source.
+ \if1\b@pgfplots@createcolormap@found@more@colors
+ % there are more positions/colors!? Ok, no need to
+ % apply it here:
+ \def\b@pgfplots@special@interval{0}%
+ \else
+ \def\b@pgfplots@special@interval{1}%
+ \fi
+ \fi
+ \else
+ \def\b@pgfplots@special@interval{0}%
+ \fi
+ \else
+ \def\b@pgfplots@special@interval{0}%
+ \ifnum\pgfplots@pos@size>1
+ % ah - we have at least 2 positions
+ \if S#1%
+ \ifnum\pgfplots@pos@size=\pgfplots@source
+ \else
+ \pgfplotsthrow{too few colormap positions}{\pgfplots@pos@size}{There is an unexpected number of arguments to 'target pos' for 'samples of colormap=(\pgfplots@source)'. Please provide \pgfplots@source\space positions, not \pgfplots@pos@size}\pgfeov%
+ \fi
+ \fi
+ \fi
+ \fi
+ %
+ \if1\b@pgfplots@special@interval@additional
+ \c@pgf@counta=\pgfplots@source\relax
+ \advance\c@pgf@counta by+1
+ \edef\pgfplots@source{\the\c@pgf@counta}%
+ \fi
+ \if1\b@pgfplots@special@interval
+ \begingroup
+ \c@pgf@counta=\pgfplots@source\relax
+ \advance\c@pgf@counta by-1
+ %
+ \pgfplotsapplistXnewempty\pgfplots@createcolormap@trg@accum
+ \ifnum\c@pgf@counta<2
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult,}\to\pgfplots@createcolormap@trg@accum
+ \else
+ \edef\pgfplots@source{\the\c@pgf@counta}%
+ \pgfplots@domain@to@foreach 0:1000\relax{\pgfplots@source}%
+ %
+ \def\pgfplots@loc@TMPa{\pgfplotsforeachungrouped \x in}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotsretval}{%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\x,}\to\pgfplots@createcolormap@trg@accum
+ }%
+ \fi
+ %
+ \pgfmathfloatcreate{1}{1.0}{3}%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots@createcolormap@trg@accum
+ %
+ \pgfplotsapplistXlet\pgfplots@target=\pgfplots@createcolormap@trg@accum
+ \global\let\pgfplots@glob@TMPa=\pgfplots@target
+ \endgroup
+ %
+ \let\pgfplotsretval=\pgfplots@glob@TMPa
+ \else
+ \pgfplots@domain@to@foreach 0:1000\relax{\pgfplots@source}%
+ \fi
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ \pgfkeyslet{/pgfplots/of colormap/source pos}\pgfplotsretval
+ \pgfqkeys{/pgfplots/of colormap}{%
+ source range=0:1000,%
+ }%
+%\message{define sample positions(#1) = \pgfplotsretval^^J}%
+}%
+
+
+\def\pgfplots@createcolormap@special@process@list@separator@CM{ }%
+\let\pgfplots@createcolormap@special@process@list@separator=\pgfplots@createcolormap@special@process@list@separator@CM
+%%%%%%%%%%
+
+\def\b@pgfplots@createcolormap@found@more@colors{0}%
+
+\def\pgfplots@createcolormap@grabnext@complete{%
+ \edef\pgfplots@loc@TMPd{%
+ \noexpand\pgfutil@in@{of color}{\pgfplots@loc@TMPa}%
+ }%
+ \pgfplots@loc@TMPd
+ \ifpgfutil@in@
+ \def\pgfplots@loc@TMPd{%
+ \pgfplots@createcolormap@ifhasmorecolors{%
+ \def\b@pgfplots@createcolormap@found@more@colors{1}%
+ \pgfplots@createcolormap@grabnext@complete@of@colormap
+ }{%
+ \def\b@pgfplots@createcolormap@found@more@colors{0}%
+ \pgfplots@createcolormap@grabnext@complete@of@colormap
+ }%
+ }%
+ \else
+ % ok, this is a 'normal' color specification with position,
+ % colorspace, and color data.
+ %
+ \edef\pgfplots@loc@TMPa{%
+ {\pgfplots@loc@TMPb}% position
+ {%
+ \pgfplots@loc@TMPa% colorspace
+ =\pgfplots@loc@TMPc% color data
+ }%
+ }%
+ \expandafter\pgfplots@createcolormap@nextcolor\pgfplots@loc@TMPa
+ %
+ % continue loop:
+ \def\pgfplots@loc@TMPd{\pgfplots@createcolormap@}%
+ \fi
+ %
+ %
+ % continue loop:
+ \pgfplots@loc@TMPd
+}%
+
+\def\pgfplots@createcolormap@grabnext@complete@of@colormap{%
+ % ah - a special one based on another colormap!
+ % convert it into the standard format:
+ \begingroup
+ \let\pgfplotscolormap@at=\pgfplots@loc@TMPb
+ \let\pgfplotscolormap@argument=\pgfplots@loc@TMPc
+ \let\pgfplotscolormap@key=\pgfplots@loc@TMPa
+ %
+ \pgfplots@createcolormap@grabnext@complete@ofcolormap
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ %
+ \expandafter\pgfplots@createcolormap@\pgfplotsretval
+}%
+
+% INPUT:
+% \pgfplotscolormap@at
+% \pgfplotscolormap@argument
+% \pgfplotscolormap@key
+% OUTPUT:
+% The result of /pgfplots/of colormap/@define.
+% For the normal colormap definition, it populates
+% \pgfplotsretval with the color specifications as they should
+% be processed by the colormap definition code.
+\def\pgfplots@createcolormap@grabnext@complete@ofcolormap{%
+ \t@pgfplots@tokb=\expandafter{\pgfplotscolormap@argument}%
+ \edef\pgfplotscolormap@keyvalue{%
+ \if m\b@pgfplots@createcolormap@pos@mode
+ % ah - we have had manually provided positions before.
+ % Well, keep them. Otherwise, we will stay at the default
+ % placement.
+ target pos={\pgfplotscolormap@at},%
+ \fi
+ % ... but can be overriden here:
+ \pgfplotscolormap@key={\the\t@pgfplots@tokb},%
+ }%
+ %
+ \let\pgfplots@createcolormap@special@process@single@define=\pgfplots@createcolormap@special@process@single@define@CM
+ \let\pgfplots@createcolormap@special@process@list@separator=\pgfplots@createcolormap@special@process@list@separator@CM
+ %
+ % finally, process the keys:
+ \expandafter\pgfplots@of@colormap@getresult\expandafter{%
+ \pgfplotscolormap@keyvalue,
+ }%
+%\message{\pgfplotscolormap@key={\pgfplotscolormap@argument} -> '\pgfplotscolormap@keyvalue' -> \pgfplotsretval^^J}%
+}%
+
+\def\pgfplots@createcolormap@grabnext@computenextposition{%
+ % determine next step size automatically:
+ \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}%
+ \ifpgfplotsarrayempty
+ % first: just use 0.
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \else
+ % not first:
+ \ifx\pgfplots@createcolormap@H\pgfutil@empty
+ % ah; we really have to deduce something. We are at the
+ % second node:
+ %\def\pgfmathresult{1cm}%
+ \pgfmathfloatcreate{1}{2.845274}{1}% 1cm=28.45274pt . Backw compat
+ \else
+ \pgfmathfloatadd@\pgfplots@createcolormap@LAST\pgfplots@createcolormap@H
+ \fi
+ \fi
+}%
+
+\def\pgfplots@createcolormap@grabsemicolon;{\pgfplots@createcolormap@}%
+\def\pgfplots@createcolormap@grabcomma,{\pgfplots@createcolormap@}%
+
+\def\pgfplots@createcolormap@grabsemicolon@hasnext#1#2;{\pgfplots@createcolormap@ifhasmorecolors{#1}{#2}}%
+\def\pgfplots@createcolormap@grabcomma@hasnext#1#2,{\pgfplots@createcolormap@ifhasmorecolors{#1}{#2}}%
+
+{
+ \catcode`\;=13
+ \gdef\pgfplots@createcolormap@grabsemicolon@active;{\pgfplots@createcolormap@}%
+ \gdef\pgfplots@createcolormap@grabsemicolon@active@hasnext#1#2;{\pgfplots@createcolormap@ifhasmorecolors{#1}{#2}}%
+}
+
+\def\pgfplots@createcolormap@nextcolor@tostring#1=#2\pgfplots@EOI#3{%
+ #1(#3)=(#2)%
+}%
+
+% #1: h
+% #2: a compound element of the form
+% '<colorspace>=<comma-separated-color-components>'
+% The format is chosen such that it can be forwarded directly to
+% \pgfplotscolornormalizesequencenext
+%
+% see \pgfplotscolornormalizesequencenext for details
+\def\pgfplots@createcolormap@nextcolor#1#2{%
+ \def\pgfplots@createcolormap@context{\pgfplots@createcolormap@nextcolor@tostring#2\pgfplots@EOI{#1}\pgfplots@createcolormap@trace}%
+ %
+ \pgfplotscolornormalizesequencenext{#2}%
+ \let\pgfplots@createcolormap@col@comps=\pgfplotsretvalb
+ %
+ \edef\pgfplots@loc@TMPa{{#1}{\pgfplotsretval}}%
+ \expandafter\pgfplots@createcolormap@nextcolor@\pgfplots@loc@TMPa%
+}%
+\def\pgfplots@createcolormap@nextcolor@#1#2{%
+%\message{processing color #1=(#2)^^J}%
+ % compute 'h':
+ \pgfmathparse{#1}%
+ \let\pgfplots@createcolormap@MAX=\pgfmathresult
+ %
+ \ifx\pgfplots@createcolormap@MIN\pgfutil@empty
+ % it is the first.
+ \let\pgfplots@createcolormap@MIN=\pgfmathresult
+ \let\pgfplots@createcolormap@LAST=\pgfmathresult
+ \fi
+ %
+ \expandafter\pgfmathfloatsubtract@\expandafter{\pgfmathresult}{\pgfplots@createcolormap@LAST}%
+ \let\pgfplots@createcolormap@H@cur=\pgfmathresult
+ \pgfplots@createcolormap@check@increasing@mesh@width
+ \let\pgfplots@createcolormap@LAST=\pgfplots@createcolormap@MAX
+ \ifx\pgfplots@createcolormap@H\pgfutil@empty
+ \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}%
+ \ifpgfplotsarrayempty
+ \else
+ \let\pgfplots@createcolormap@H=\pgfplots@createcolormap@H@cur
+ \fi
+ \else
+ \pgfplots@createcolormap@compute@equalto{\pgfplots@createcolormap@H}{\pgfplots@createcolormap@H@cur}%
+ \ifpgfmathfloatcomparison
+ \else
+ \ifnum\b@pgfplotscreatecolormap@isuniform>1
+ % force reinterpolation:
+ \pgfplotscreatecolormap@reinterpolate{#2}%
+ \else
+ % it is NOT uniform!
+ \def\b@pgfplotscreatecolormap@isuniform{0}%
+ %
+ \pgfmathfloatmintwo{\pgfplots@createcolormap@H@cur}{\pgfplots@createcolormap@H}%
+ \let\pgfplots@createcolormap@H=\pgfmathresult
+ \fi
+ \fi
+ \fi
+ %\message{found current H@cur = \pgfplots@createcolormap@H@cur\space (\pgfplots@createcolormap@LAST) -> H=\pgfplots@createcolormap@H^^J}%
+ %
+ % remember positions:
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@createcolormap@MAX,}\to\pgfplots@createcolormap@X
+ %
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsarraypushback{#2}\noexpand\to}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}%
+ \edef\pgfplots@createcolormap@last{#2}%
+}%
+
+\def\pgfplots@createcolormap@check@increasing@mesh@width{%
+ \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}%
+ \ifpgfplotsarrayempty
+ \else
+ \pgfmathfloatifflags{\pgfplots@createcolormap@H@cur}{1}{%
+ % ok, H>0
+ }{%
+ \pgfmathfloattofixed{\pgfplots@createcolormap@H@cur}%
+ \pgfplots@error{Colormaps must have increasing positions. The provided colormap has mesh width '\pgfmathresult' at \pgfplots@createcolormap@context. Please assign increasing positions}%
+ }%
+ \fi
+}%
+\def\pgfplots@createcolormap@compute@equalto#1#2{%
+ %\begingroup
+ %\pgfmathfloatcreate{1}{1.0}{-4}%
+ %\let\pgfmathfloat@relthresh=\pgfmathresult
+ \pgfmathfloatequalto@{#1}{#2}%
+ %\xdef\pgfplots@glob@TMPa{%
+ % \noexpand\def\noexpand\pgfmathresult{\pgfmathresult}%
+ % \ifpgfmathfloatcomparison
+ % \noexpand\pgfmathfloatcomparisontrue
+ % \else
+ % \noexpand\pgfmathfloatcomparisonfalse
+ % \fi
+ %}%
+ %\endgroup
+ %\pgfplots@glob@TMPa
+ %\message{equalto (#1,#2) = \pgfmathresult^^J}%
+}%
+\def\pgfplotscreatecolormap@reinterpolate#1{%
+ \pgfmathfloatdivide@{\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
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \afterassignment\pgfplots@createcolormap@nextRGB@consider@reinterpolation
+ \c@pgf@counta=\pgfmathresult\relax
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \ifx\pgfmathresult\pgfutil@empty
+ % I can't do that yet.
+ \else
+ \let\pgfplots@createcolormap@loop@end=\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{}{[1pt]}
+ \pgfplotsforeachungrouped \c@pgfplots@createcolormap in {1,2,...,\pgfplots@createcolormap@loop@end} {%
+ \pgfmathfloatequalto@{\c@pgfplots@createcolormap}{\pgfplots@createcolormap@loop@end}%
+ \ifpgfmathfloatcomparison
+ % omit the last.
+ \else
+ \pgfmathparse{\c@pgfplots@createcolormap/\pgfplots@createcolormap@loop@end}%
+ \let\pgfplots@createcolormap@scale@current=\pgfmathresult
+ \pgfmathparse{1-\pgfplots@createcolormap@scale@current}%
+ \let\pgfplots@createcolormap@scale@last=\pgfmathresult
+ %
+ \pgfmathfloattofixed\pgfplots@createcolormap@scale@current
+ \let\pgfplots@createcolormap@scale@current=\pgfmathresult
+ \pgfmathfloattofixed\pgfplots@createcolormap@scale@last
+ \let\pgfplots@createcolormap@scale@last=\pgfmathresult
+ %
+ \pgfplotscolornormalizesequencezero
+ \pgfplotscolornormalizesequenceaddweighted
+ {\pgfplotsretval}%
+ {\pgfplots@createcolormap@scale@current}%
+ {#1}%
+ \pgfplotscolornormalizesequenceaddweighted
+ {\pgfplotsretval}%
+ {\pgfplots@createcolormap@scale@last}%
+ {\pgfplots@createcolormap@last}%
+ %
+%\message{interpolation step \c@pgfplots@createcolormap = \pgfplotsretval^^J}%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplotsarraypushback{\pgfplotsretval}%
+ \noexpand\to}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}%
+ \fi
+ }%
+ \fi
+}%
+\def\pgfplots@createcolormap@nextRGB@consider@reinterpolation#1\relax{%
+ \pgf@xa=#1pt
+ \ifdim\pgf@xa>0.5pt % we have something like 99.995 or so.
+ % round up and compute 1 - #1:
+ \advance\c@pgf@counta by1
+ \pgf@xa=1pt \advance\pgf@xa by-#1pt
+ \fi
+ %
+ % compute relative error:
+ \pgf@xb=\the\c@pgf@counta pt
+ \divide\pgf@xb by10000
+%\message{Checking H/h = \pgfplots@createcolormap@H@cur pt/\pgfplots@createcolormap@H pt = \the\c@pgf@counta+-\pgf@sys@tonumber\pgf@xa\space: \the\pgf@xa > \the\pgf@xb\space (relative to \the\c@pgf@counta)?}%
+ %
+ \ifdim\pgf@xa>\pgf@xb
+ \begingroup
+ \if2\b@pgfplotscreatecolormap@isuniform
+ \pgfplots@error{Non-uniform colormaps are only supported if you write 'compat=1.14' (or higher). Please adopt the compatibility level and retry. The error occured near '\pgfplots@createcolormap@context'}%
+ \else
+ \pgfmathfloattofixed{\pgfplots@createcolormap@H}%
+ \let\pgfplots@createcolormap@H=\pgfmathresult
+ \pgfmathfloattofixed{\pgfplots@createcolormap@H@cur}%
+ \let\pgfplots@createcolormap@H@cur=\pgfmathresult
+ \pgfplots@error{The provided colormap positions are not multiples of the prescribed mesh width h=\pgfplots@createcolormap@H\space (found one with H/h = \pgfplots@createcolormap@H@cur/\pgfplots@createcolormap@H = \the\c@pgf@counta+-\pgf@sys@tonumber\pgf@xa\space which is no integer). The error occured near `\pgfplots@createcolormap@context'}%
+ \fi
+ \endgroup
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ \ifnum\c@pgf@counta=0
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ \edef\pgfmathresult{\the\c@pgf@counta}%
+ \fi
+ \fi
+}%
+
+\def\pgfplots@colormap@LUA@new#1{%
+ \ifpgfplots@LUA@supported
+ \begingroup
+ \pgfplotscolormapserializecomponentstomacro{#1}\pgfplots@values
+ \pgfplotscolormapserializeXtomacro{#1}\pgfplots@pos
+ \pgfplotsutil@directlua{%
+ local colorspace =^^J%
+ pgfplots.\csname pgfpl@cm@#1@colspace\endcsname;^^J%
+ if colorspace then^^J%
+ pgfplots.ColorMaps["#1"] = pgfplots.ColorMap.new(^^J%
+ \csname pgfpl@cm@#1@h\endcsname,^^J%
+ colorspace,^^J%
+ { \pgfplots@values },^^J
+ { \pgfplots@pos },^^J
+ "\csname pgfpl@cm@#1@X@scale@order@z\endcsname"^^J
+ );^^J%
+ else^^J%
+ io.write("There is no LUA colorspace for '\csname pgfpl@cm@#1@colspace\endcsname' - skipping LUA color map definition of #1\string\n");^^J%
+ end^^J%
+ }%
+ \endgroup
+ \fi
+}%
+
+% Executes '#2' if the colormap named '#1' has a uniform grid and '#3'
+% if not.
+\def\pgfplotscolormapifisuniform#1#2#3{%
+ \ifnum0=\pgfplotsarraysizeof{pgfpl@cm@#1@X}\relax
+ #2\relax
+ \else
+ #3\relax
+ \fi
+}%
+
+% Shows debug info about colormap #1 into the console.
+\def\pgfplots@colormap@showdebuginfofor#1{%
+ \message{Debug info for color map '#1':^^J}%
+ \message{(Transformed) Range: [0:\pgfplotscolormaprange]; ^^J}%
+ \message{H: \csname pgfpl@cm@#1@h\endcsname; ^^J}%
+ \message{H:^{-1}: \csname pgfpl@cm@#1@invh\endcsname; ^^J}%
+ \pgfplotsarraysizetomacro{pgfpl@cm@#1}\to\pgfplots@loc@TMPa
+ \message{Size: \pgfplots@loc@TMPa; ^^J}%
+ \message{Colorspace: \csname pgfpl@cm@#1@colspace\endcsname^^JValues (\csname pgfpl@cm@#1@col@comps\endcsname\space components each): ^^J}%
+ \begingroup
+ \c@pgf@counta=0
+ \pgfplotscolormapifisuniform{#1}{%
+ \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\elem{%
+ \pgfmath@basic@multiply@{\the\c@pgf@counta}{\csname pgfpl@cm@#1@h\endcsname}%
+ \message{\#\the\c@pgf@counta=(\pgfmathresult)=(\elem);^^J}%
+ \advance\c@pgf@counta by1 %
+ }%
+ }{%
+ \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\elem{%
+ \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#1@X}\to\pgfmathresult
+ \message{\#\the\c@pgf@counta=(\pgfmathresult)=(\elem);^^J}%
+ \advance\c@pgf@counta by1 %
+ }%
+ }%
+ \message{^^J}%
+ \endgroup
+}
+
+% #1: comma-separated list of values for the current entry
+% #2: color map name
+% #3: the current index into the colormap
+% #4: the "x coordinate", i.e. the offset within the colormap
+%
+% Defines \pgfplotsretval
+%
+% Example:
+% \pgfplotscolormaptodatafile[
+% output each nth=1,
+% output format=csv,
+% ]{viridis}
+% {viridis.dat}
+\def\pgfplotscolormaptodatafile@elem#1#2#3#4{%
+ \let\pgfplotsretval=\pgfutil@empty
+}%
+
+\begingroup
+\catcode`\[=1
+\catcode`\]=2
+\catcode`\{=12
+\catcode`\}=12
+\xdef\pgfplots@lbrace[{]%
+\xdef\pgfplots@rbrace[}]%
+\endgroup
+
+
+\pgfkeys{
+ /pgfplots/colormap/output each nth/.initial=1,
+ /pgfplots/colormap/output format/.is choice,
+ /pgfplots/colormap/output format/csv/.code={%
+ \def\pgfplotscolormaptodatafile@head##1{%
+ \let\pgfplotsretval=\pgfutil@empty
+ }%
+ \def\pgfplotscolormaptodatafile@elem##1##2##3##4{%
+ \edef\pgfplotsretval{##4,##1}%
+ }%
+ \def\pgfplotscolormaptodatafile@foot##1{%
+ \let\pgfplotsretval=\pgfutil@empty
+ }%
+ },
+ /pgfplots/colormap/output format/native/.code={%
+ \def\pgfplotscolormaptodatafile@head##1{%
+ \edef\pgfplotsretval{\string\pgfplotsset\pgfplots@lbrace colormap={##1}\pgfplots@lbrace}%
+ }%
+ \def\pgfplotscolormaptodatafile@elem##1##2##3##4{%
+ \edef\pgfplotsretval{\csname pgfpl@cm@##2@colspace\endcsname=(##1)}%
+ }%
+ \def\pgfplotscolormaptodatafile@foot##1{%
+ \edef\pgfplotsretval{\pgfplots@rbrace\pgfplots@rbrace}%
+ }%
+ },
+ /pgfplots/colormap/output format=csv,
+}
+
+
+% An export of a color map.
+% #1: options. Can use 'output each nth=2' and 'output format=csv|native'
+% #2: a color map
+% #3: a data file
+\def\pgfplotscolormaptodatafile{\pgfutil@ifnextchar[{\pgfplotscolormaptodatafile@}{\pgfplotscolormaptodatafile@[]}}%
+\def\pgfplotscolormaptodatafile@[#1]#2#3{%
+ \begingroup
+ \pgfqkeys{/pgfplots/colormap}{#1}%
+ \pgfkeysgetvalue{/pgfplots/colormap/output each nth}{\pgfplots@eachnth}%
+ \immediate\openout\w@pgf@writea=#3\relax
+ \pgfplotscolormaptodatafile@head{#2}%
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \immediate\write\w@pgf@writea{%
+ \pgfplotsretval
+ }%
+ \fi
+ \gdef\pgfplots@eachnth@cur{0}%
+ \pgfplotsarrayforeach{pgfpl@cm@#2}\as\elem{%
+ \ifnum\pgfplots@eachnth@cur=0\relax
+ \gdef\pgfplots@eachnth@cur{0}%
+ \pgfplotscolormapifisuniform{#2}{%
+ \pgfmath@basic@multiply@{\pgfplotsarrayforeachindex}{\csname pgfpl@cm@#2@h\endcsname}%
+ }{%
+ \pgfplotsarrayselect\pgfplotsarrayforeachindex\of{pgfpl@cm@#1@X}\to\pgfmathresult
+ }%
+ \edef\pgfplots@loc@TMPa{{\elem}{#2}{\pgfplotsarrayforeachindex}{\pgfmathresult}}%
+ \expandafter\pgfplotscolormaptodatafile@elem\pgfplots@loc@TMPa
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \immediate\write\w@pgf@writea{%
+ \pgfplotsretval
+ }%
+ \fi
+ \fi
+ \pgfplotsutil@advancestringcounter@global\pgfplots@eachnth@cur%
+ \ifnum\pgfplots@eachnth@cur=\pgfplots@eachnth\relax
+ \gdef\pgfplots@eachnth@cur{0}%
+ \fi
+ }%
+ \pgfplotscolormaptodatafile@foot{#2}%
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \immediate\write\w@pgf@writea{%
+ \pgfplotsretval
+ }%
+ \fi
+ \immediate\closeout\w@pgf@writea
+ \endgroup
+}
+
+% Defines \pgfplotsretval to contain the mesh width of colormap #1.
+% If the color map has a non-uniform grid, it returns the SMALLEST
+% encountered mesh width.
+\def\pgfplotscolormapgetmeshwidth#1{%
+ \expandafter\let\expandafter\pgfplotsretval\csname pgfpl@cm@#1@h\endcsname%
+}%
+
+% defines macro #2 to contain a serialized variant of the color
+% components (only the color components!)
+\def\pgfplotscolormapserializecomponentstomacro#1#2{%
+ \pgfplotscolormapserialize@to@macro{pgfpl@cm@#1}{#2}%
+}
+\def\pgfplotscolormapserialize@to@macro#1#2{%
+ \pgfplotsapplistXnewempty\pgfplots@serialize@list@
+ \pgfplots@loc@tmptrue
+ \expandafter\pgfplotsarrayforeachungrouped\expandafter{#1}\as\elem{%
+ \ifpgfplots@loc@tmp
+ \expandafter\pgfplotsapplistXpushback\expandafter{\expandafter{\elem}}\to\pgfplots@serialize@list@
+ \pgfplots@loc@tmpfalse
+ \else
+ \expandafter\pgfplotsapplistXpushback\expandafter,\expandafter{\elem}\to\pgfplots@serialize@list@
+ \fi
+ }%
+ \pgfplotsapplistXlet#2=\pgfplots@serialize@list@
+}%
+
+\def\pgfplotscolormapserialize@to@macro@nobraces#1#2{%
+ \pgfplotsapplistXnewempty\pgfplots@serialize@list@
+ \pgfplots@loc@tmptrue
+ \expandafter\pgfplotsarrayforeachungrouped\expandafter{#1}\as\elem{%
+ \ifpgfplots@loc@tmp
+ \expandafter\pgfplotsapplistXpushback\elem\to\pgfplots@serialize@list@
+ \pgfplots@loc@tmpfalse
+ \else
+ \expandafter\pgfplotsapplistXpushback\expandafter,\elem\to\pgfplots@serialize@list@
+ \fi
+ }%
+ \pgfplotsapplistXlet#2=\pgfplots@serialize@list@
+}%
+\def\pgfplotscolormapserializeXtomacro#1#2{%
+ \pgfplotscolormapserialize@to@macro@nobraces{pgfpl@cm@#1@X}{#2}%
+}%
+
+% 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
+ \pgfplotscolormapserializecomponentstomacro{#1}\pgfplots@serialize@list
+ \pgfplotscolormapserializeXtomacro{#1}\pgfplots@serialize@list@X
+ \toks0={\expandafter\def\csname pgfpl@cm@#1@h\endcsname}%
+ \toks1={\expandafter\def\csname pgfpl@cm@#1@invh\endcsname}%
+ \toks2={%
+ \pgfplotsarraynewempty{pgfpl@cm@#1}%
+ \expandafter\pgfplotsutilforeachcommasep\pgfplots@loc@TMPa\as\pgfplots@loc@TMPb{%
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \else
+ \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPb\to{pgfpl@cm@#1}%
+ \fi
+ }%
+ }%
+ \toks3=\expandafter{\pgfplots@serialize@list}%
+ \toks4=\expandafter{\expandafter\def\csname pgfpl@cm@#1@colspace\endcsname}%
+ \toks5=\expandafter{\expandafter\def\csname pgfpl@cm@#1@col@comps\endcsname}%
+ \toks6=\expandafter{\expandafter\def\csname pgfpl@cm@#1@lastindex\endcsname}%
+ \toks7={%
+ \pgfplotsarraynewempty{pgfpl@cm@#1@X}%
+ \expandafter\pgfplotsutilforeachcommasep\pgfplots@loc@TMPa\as\pgfplots@loc@TMPb{%
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \else
+ \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPb\to{pgfpl@cm@#1@X}%
+ \fi
+ }%
+ }%
+ \toks8=\expandafter{\pgfplots@serialize@list@X}%
+ \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
+ \the\toks4 {\csname pgfpl@cm@#1@colspace\endcsname}%
+ \the\toks5 {\csname pgfpl@cm@#1@col@comps\endcsname}%
+ \the\toks6 {\csname pgfpl@cm@#1@lastindex\endcsname}%
+ \noexpand\def\noexpand\pgfplots@loc@TMPa{\the\toks8 }%
+ \the\toks7
+ \def\expandafter\noexpand\csname pgfpl@cm@#1@X@scale@order@z\endcsname{\csname pgfpl@cm@#1@X@scale@order@z\endcsname}%
+ }%
+ \endgroup
+ \let#2=\pgfplots@glob@TMPa
+}%
+
+% Defines \pgfplotsretval to contain an argument for use in \foreachlist
+% which results in all the positions.
+%
+% [#1:#2] : the desired output domain. The smallest position will be
+% mapped to #1, the largest to #2, and all in-between will be mapped
+% accordingly.
+% #3: the colormap name.
+%
+% Note that this switch depends on the current value of 'colormap
+% access': piecewise constant may use different positions.
+%
+% On output, \pgfplotsretval will contain the result.
+\def\pgfplotscolormapgetpositions[#1:#2]#3{%
+ \begingroup
+ \if d\pgfplots@colormap@access
+ \edef\pgfplotsretval{0,1,...,\pgfplotscolormaplastindexof{#3}}%
+ \else
+ \if m\pgfplots@colormap@access
+ \def\b@pgfplots@extra@interval{0}%
+ \edef\pgfplots@H{\csname pgfpl@cm@#3@h\endcsname}%
+ \else
+ \if c\pgfplots@colormap@access
+ \pgfplotscolormap@piecewiseconst@prepare@scale{#3}%
+ \edef\pgfplots@H{\pgf@sys@tonumber\pgf@x}%
+ \fi
+ \fi
+ %
+ \pgfkeys{/pgf/fpu}%
+ \pgfplotsapplistXnewempty\pgfplots@resultaccum
+ \pgfplotscolormapifisuniform{#3}{%
+ \pgfmathparse{#1 + (#2-#1) * \pgfplots@H/1000}%
+ \let\next=\pgfmathresult
+ \pgfmathparse{#2}% + (#2-#1)/1000}%
+ %
+ \def\b@pgfplots@isfirst{1}%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungrouped\noexpand \x in {#1,\next,...,\pgfmathresult}}%
+ \pgfplots@loc@TMPa{%
+ \if0\b@pgfplots@isfirst
+ \pgfplotsapplistXpushback,\to\pgfplots@resultaccum
+ \fi
+ \expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots@resultaccum
+ \def\b@pgfplots@isfirst{0}%
+ }%
+ }{%
+ \pgfmathparse{(#2-#1)/1000}%
+ \let\pgfplots@scale=\pgfmathresult
+ \pgfplotsarrayforeachungrouped{pgfpl@cm@#3@X}\as\pgfplots@loc@TMPc{%
+ \if m\pgfplots@colormap@access
+ % colormap access=map
+ \pgfmathparse{#1 + \pgfplots@loc@TMPc * \pgfplots@scale}%
+ \else
+ \if1\b@pgfplots@extra@interval
+ \pgfmathparse{#1 + \pgfplots@loc@TMPc * \pgfplots@H* \pgfplots@scale}%
+ \else
+ % DISABLE additional interval!
+ % Means: use the input position as usual:
+ \pgfmathparse{#1 + \pgfplots@loc@TMPc * \pgfplots@scale}%
+ \fi
+ \fi
+ \ifnum\pgfplotsarrayforeachindex>0
+ \pgfplotsapplistXpushback,\to\pgfplots@resultaccum
+ \fi
+ \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots@resultaccum
+ }%
+ \if1\b@pgfplots@extra@interval
+ \pgfmathparse{#2}%
+ \pgfplotsapplistXpushback,\to\pgfplots@resultaccum
+ \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots@resultaccum
+ \fi
+ }%
+ \pgfplotsapplistXlet\pgfplotsretval=\pgfplots@resultaccum
+ \fi
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% 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{1000}%
+\def\pgfplotscolormappdfmax@inv{1}%
+
+% Expands to the size of colormap #1 .
+\def\pgfplotscolormapsizeof#1{%
+ \pgfplotscolormapifdefined{#1}{%
+ \pgfplotsarraysizeof{pgfpl@cm@#1}%
+ }{%
+ 0%
+ }%
+}%
+
+% Defines \pgfplotsretval to contain the color of color map '#1' at
+% index '#2'
+\def\pgfplotscolormapgetcolor#1#2{%
+ \pgfplotsarrayselect{#2}\of{pgfpl@cm@#1}\to\pgfplotsretval
+}%
+
+% Expands to the last index of colormap #1 (or -1)
+\def\pgfplotscolormaplastindexof#1{%
+ \pgfplotscolormapifdefined{#1}{%
+ \csname pgfpl@cm@#1@lastindex\endcsname%
+ }{%
+ -1%
+ }%
+}%
+
+% POSTCONDITION:
+% 1. for uniform #1:
+% \pgf@x contains the MODIFIED mesh width
+% \b@pgfplots@extra@interval is 1 if and only if an extra interval
+% should be added
+% 2. for non-uniform #1:
+% \pgf@x is a scaling factor to map input positions to MODIFIED
+% positions
+% \b@pgfplots@extra@interval is 1 if and only if an extra interval
+\def\pgfplotscolormap@piecewiseconst@prepare@scale#1{%
+ % advance the number of intervals by 1.
+ \pgfplotscolormapifisuniform{#1}{%
+ % To this end, we have to compute
+ % N = n+1
+ % and
+ % H = 1000 / (N-1) = 1000/n.
+ % Store H in \pgf@x:
+ \expandafter\ifx\csname pgfpl@cm@#1@X@scale@order@z\endcsname\pgfutil@empty%
+ \c@pgf@countd=\pgfplotscolormapsizeof{#1}\relax
+ %
+ \global\pgf@x=1000pt %
+ \global\divide\pgf@x by\c@pgf@countd
+ \def\b@pgfplots@extra@interval{1}%
+ \else
+ % DISABLE the extra interval!
+ \global\pgf@x=\csname pgfpl@cm@#1@h\endcsname pt %
+ \def\b@pgfplots@extra@interval{0}%
+ \fi
+ }{%
+ % the very same idea as for uniform colormaps applies
+ % for non-uniform maps as well: we create an
+ % artificial interval at the rightmost end.
+ % The idea is to think of a temporary map in the range
+ % [0,1000+ h] where h is the current colormap's
+ % mesh width.
+ % Since the domain is [0,1000], we map [0,1000+h]
+ % linearly into [0,1000].
+ %
+ % This here is the scaling factor:
+ \global\pgf@x=\csname pgfpl@cm@#1@X@scale@order@z\endcsname pt %
+ % see also
+ % \pgfplotscolormapfindpiecewiseconst@precomputed for
+ % comments
+ \ifdim\pgf@x>0sp %
+ \def\b@pgfplots@extra@interval{1}%
+ \else
+ % disable it
+ \def\b@pgfplots@extra@interval{0}%
+ \fi
+ }%
+}%
+
+% #1: colormap name
+% #2: yes code
+% #3: no code
+\def\pgfplotscolormapifrequiresextrainterval#1#2#3{%
+ \if c\pgfplots@colormap@access
+ \pgfplotscolormapifisuniform{#1}{%
+ \expandafter\ifx\csname pgfpl@cm@#1@X@scale@order@z\endcsname\pgfutil@empty%
+ % no...
+ #3\relax%
+ \else
+ % yes:
+ #2\relax%
+ \fi
+ }{%
+ \ifdim\csname pgfpl@cm@#1@X@scale@order@z\endcsname pt>0pt
+ % yes:
+ #2\relax%
+ \else
+ % no:
+ #3\relax%
+ \fi
+ }%
+ \else
+ % no:
+ #3\relax%
+ \fi
+}%
+% #1: colormap name
+% #2: yes code
+% #3: no code
+\def\pgfplotscolormapifdrawslastcolor#1#2#3{%
+ \pgfplotscolormapifrequiresextrainterval{#1}{%
+ #2\relax%
+ }{%
+ \if c\pgfplots@colormap@access
+ #3\relax%
+ \else
+ #2\relax%
+ \fi
+ }%
+}%
+
+% Writes a PDF function of /FunctionType 3 to \pgfplotsretval
+%
+% The /Domain argument will be set to [ 0 \pgfplotscolormappdfmax ] and bounds will be
+% computed accordingly.
+%
+% Note that the value depends on 'colormap access'
+%
+% #1: the colormap
+\def\pgfplotscolormaptopdffunction#1{%
+ \begingroup
+ \pgfplotscolormapassertexists{#1}%
+ \pgfplotsapplistXnewempty\pgfplots@resultaccum
+ \pgfplotsapplistXpushback{
+ <<
+ /FunctionType 3
+ /Domain [0 \pgfplotscolormappdfmax]
+ /Functions [
+ }\to\pgfplots@resultaccum%
+ \c@pgf@counta=0
+ \c@pgf@countb=\pgfplotsarraysizeof{pgfpl@cm@#1} %
+ \advance\c@pgf@countb by-1
+ \def\pgfplots@loc@TMPa{}%
+ \pgfplotsapplistXnewempty\pgfplots@bounds@accum%
+ \pgfplotsapplistXnewempty\pgfplots@encode@accum
+ \ifnum\csname pgfpl@cm@#1@col@comps\endcsname>4
+ \pgfplots@error{Sorry, processing more than 4 color components (as required for color map #1) is unsupported in this context}%
+ \fi
+ %
+ \def\b@pgfplots@extra@interval{0}%
+ \if m\pgfplots@colormap@access
+ % colormap access=map
+ \def\pgfplots@order{1}%
+ \global\pgf@x=\csname pgfpl@cm@#1@h\endcsname pt %
+ \def\pgfplots@C@left{C0}%
+ \def\pgfplots@C@right{C1}%
+ \else
+ \if c\pgfplots@colormap@access
+ % colormap access=piecewise constant
+ % This has a dedicated special interval at the rightmost
+ % end.
+ % See comments in pgfplotscolormapfindpiecewiseconst@precomputed@
+ \def\pgfplots@order{0}%
+ %
+ \pgfplotscolormap@piecewiseconst@prepare@scale{#1}%
+ %
+ % interchange the sequence in the PDF function as it is
+ % defined as
+ % y = C0 + x^0 * (C1 - C0) = C1
+ % -> we want the left interval boundary.
+ \def\pgfplots@C@left{C1}%
+ \def\pgfplots@C@right{C0}%
+ \else
+ % colormap access=direct
+ \pgfplots@error{This should never happen}%
+ % ?
+ \def\pgfplots@order{0}%
+ \global\pgf@x=\csname pgfpl@cm@#1@h\endcsname pt %
+ \def\pgfplots@C@left{C0}%
+ \def\pgfplots@C@right{C1}%
+ \fi
+ \fi
+ %
+ \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\cdata{%
+ \edef\cdata{%
+ \expandafter
+ \expandafter
+ \csname pgfplotscolormaptopdffunction@convertcdata@\csname pgfpl@cm@#1@col@comps\endcsname\endcsname
+ \cdata\relax
+ }%
+ \ifnum\c@pgf@counta>0
+ \edef\pgfplots@loc@TMPd{%
+ <<
+ /FunctionType 2
+ /Domain [0 \pgfplotscolormappdfmax]
+ /\pgfplots@C@left\space [\pgfplots@loc@TMPa] /\pgfplots@C@right\space [\cdata]
+ /N \pgfplots@order
+ >>
+ }%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPd}\to\pgfplots@resultaccum
+ \ifnum\c@pgf@counta<\c@pgf@countb\relax
+ \pgfplotscolormapifisuniform{#1}{%
+ \pgf@xa=\pgf@x
+ \multiply\pgf@xa by\c@pgf@counta\relax
+ }{%
+ \pgfplotsarrayselect{\c@pgf@counta}\of{pgfpl@cm@#1@X}\to\pgfplots@loc@TMPc
+ \if m\pgfplots@colormap@access
+ % colormap access=map
+ \pgf@xa=\pgfplots@loc@TMPc pt %
+ \else
+ \if1\b@pgfplots@extra@interval
+ \pgf@xa=\pgfplots@loc@TMPc\pgf@x%
+ \else
+ % DISABLE additional interval!
+ % Means: use the input position as usual:
+ \pgf@xa=\pgfplots@loc@TMPc pt %
+ \fi
+ \fi
+ }%
+ \divide\pgf@xa by\pgfplotscolormappdfmax@inv\relax% we want [ 0 1 ] not [0 1000] as domain XXX : why!?
+ \edef\pgfplots@loc@TMPc{ \pgf@sys@tonumber\pgf@xa}%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPc}\to\pgfplots@bounds@accum%
+ \fi
+ \pgfplotsapplistXpushback{ 0 1}\to\pgfplots@encode@accum%
+ \fi
+ \let\pgfplots@loc@TMPa=\cdata
+ \advance\c@pgf@counta by1
+ }%
+ \if1\b@pgfplots@extra@interval
+ % add an artificial interval.
+ \edef\pgfplots@loc@TMPd{%
+ <<
+ /FunctionType 2
+ /Domain [0 \pgfplotscolormappdfmax]
+ /\pgfplots@C@left\space [\cdata] /\pgfplots@C@right\space [\cdata]
+ /N \pgfplots@order
+ >>
+ }%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPd}\to\pgfplots@resultaccum
+ \advance\c@pgf@counta by-1 %
+ \pgfplotscolormapifisuniform{#1}{%
+ \pgf@xa=\pgf@x
+ \multiply\pgf@xa by\c@pgf@counta\relax
+ }{%
+ \pgfplotsarrayselect{\c@pgf@counta}\of{pgfpl@cm@#1@X}\to\pgfplots@loc@TMPc
+ \pgf@xa=\pgfplots@loc@TMPc\pgf@x%
+ }%
+ \divide\pgf@xa by\pgfplotscolormappdfmax@inv\relax% we want [ 0 1 ] not [0 1000] as domain XXX : why!?
+ \edef\pgfplots@loc@TMPc{ \pgf@sys@tonumber\pgf@xa}%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPc}\to\pgfplots@bounds@accum%
+ \pgfplotsapplistXpushback{ 0 1}\to\pgfplots@encode@accum%
+ \fi
+ \pgfplotsapplistXlet\pgfplotsretval=\pgfplots@resultaccum
+ \pgfplotsapplistXlet\pgfplotsbounds=\pgfplots@bounds@accum
+ \pgfplotsapplistXlet\pgfplotsencode=\pgfplots@encode@accum
+ \t@pgfplots@toka=\expandafter{\pgfplotsretval}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsbounds}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotsencode}%
+ \xdef\pgfplots@glob@TMPa{%
+ \the\t@pgfplots@toka
+ ]
+ /Bounds [\the\t@pgfplots@tokb]
+ /Encode [\the\t@pgfplots@tokc]
+ >>
+ }%
+ \endgroup
+ \let\pgfplotsretval=\pgfplots@glob@TMPa
+}%
+\expandafter\def\csname pgfplotscolormaptopdffunction@convertcdata@1\endcsname#1\relax{#1}%
+\expandafter\def\csname pgfplotscolormaptopdffunction@convertcdata@2\endcsname#1,#2\relax{#1 #2}%
+\expandafter\def\csname pgfplotscolormaptopdffunction@convertcdata@3\endcsname#1,#2,#3\relax{#1 #2 #3}%
+\expandafter\def\csname pgfplotscolormaptopdffunction@convertcdata@4\endcsname#1,#2,#3,#4\relax{#1 #2 #3 #4}%
+
+% 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.
+%
+% #1: the colormap's name.
+% #2: the PGF "size" of the shading. It is used to set the right end
+% of the color specification.
+% #3: a macro which will be filled with the result.
+%
+% Example:
+% \pgfplotscolormaptoshadingspec{my colormap}{4cm}{\output}
+% \def\tempb{\pgfdeclarehorizontalshading{myshadingA}{1cm}}
+% \expandafter\tempb\expandafter{\temp}
+%
+% \pgfuseshading{myshadingA}
+\def\pgfplotscolormaptoshadingspec#1#2#3{%
+ \pgfplotscolormapassertexists{#1}%
+ \begingroup
+ \def\pgfplots@rgb{rgb}%
+ \pgfmathparse{#2}%
+ \expandafter\pgfmathdivide@\expandafter{\pgfmathresult}{\pgfplotscolormaprange}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfmathmultiply@{\csname pgfpl@cm@#1@h\endcsname}{\pgfplots@loc@TMPb}%
+ \pgf@ya=\pgfmathresult pt
+ \c@pgf@counta=0
+ \let#3=\pgfutil@empty
+ \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\pgfplotscolormaptoshadingspec@TMP{%
+ \pgfplotscolormapifisuniform{#1}{%
+ \pgf@yb=\c@pgf@counta\pgf@ya
+ }{%
+ \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#1@X}\to\pgfplots@loc@TMPd
+ \pgfmathmultiply@{\pgfplots@loc@TMPd}{\pgfplots@loc@TMPb}%
+ \pgf@yb=\pgfmathresult pt %
+ }%
+ \edef\pgfplots@colspace{\csname pgfpl@cm@#1@colspace\endcsname}%
+ % FIXME : PGF shadings accept only RGB!
+ \if1\pgfplotscolormaptoshadingspectorgb
+ \ifx\pgfplots@colspace\pgfplots@rgb
+ \else
+ \pgfutil@ifundefined{pgfpl@cm@#1@warned}{%
+ \expandafter\gdef\csname pgfpl@cm@#1@warned\endcsname{1}%
+ \pgfplotswarning{lossy colormap rgb conversion}{#1}{\pgfplots@colspace}\pgfeov%
+ }{%
+ }%
+ \edef\pgf@tempcolor{{\pgfplots@colspace}{\pgfplotscolormaptoshadingspec@TMP}}%
+ \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgfplotscolormaptoshadingspec@TMP}%
+ \def\pgfplots@colspace{rgb}%
+ \fi
+ \fi
+ \edef\pgfplots@loc@TMPc{\pgfplots@colspace(\the\pgf@yb)=(\pgfplotscolormaptoshadingspec@TMP)}%
+ \ifx#3\pgfutil@empty
+ \t@pgfplots@toka={}%
+ \else
+ \t@pgfplots@toka=\expandafter{#3; }%
+ \fi
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPc}%
+ \edef#3{\the\t@pgfplots@toka \the\t@pgfplots@tokb }%
+ \advance\c@pgf@counta by1
+ }%
+ \pgfmath@smuggleone#3%
+ \endgroup
+}%
+\def\pgfplotscolormaptoshadingspectorgb{1}%
+
+% 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'.
+\def\pgfplotscolormaprange{1000}
+\pgfmathfloatcreate{1}{1.0}{3}%
+\let\pgfplotscolormaprange@float=\pgfmathresult
+
+\def\pgfplotscolormapgetcolorspace#1{%
+ \edef\pgfplotsretval{\csname pgfpl@cm@#1@colspace\endcsname}%
+}%
+\def\pgfplotscolormapgetcolorcomps#1{%
+ \edef\pgfplotsretval{\csname pgfpl@cm@#1@col@comps\endcsname}%
+}%
+\def\pgfplotscolormapcolorspaceof#1{%
+ \csname pgfpl@cm@#1@colspace\endcsname%
+}%
+\def\pgfplotscolormapcolorcompsof#1{%
+ \csname pgfpl@cm@#1@col@comps\endcsname%
+}%
+
+
+% Linearly maps the number #4 into the colormap #5 and returns the
+% interpolated colors into \pgfmathresult. The result will be a triple
+% for an RGB colormap and it will contain four numbers for CMYK. The
+% components of the result will be in the range [0:1].
+%
+% [#1:#2] the number range of the data source (i.e. of #4). This is required to
+% map into the colormap.
+% [#3] (optional) the quantity
+% s := \pgfplotscolormaprange / (#2-#1).
+% Precomputing this quantity may save a lot of time because
+% divisions are expensive in TeX. You can omit [#3] or
+% provide an empty string here.
+% #4 the number to map.
+% #5 the colormap's name. Must be defined with
+% \pgfplotscreatecolormap before.
+%
+% Example:
+% \pgfplotscolormapfind[-1:1]{0.2}{my colormap}
+\def\pgfplotscolormapfind[#1:#2]{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotscolormapfind@precomputed[#1:#2]%
+ }{%
+ \pgfplotscolormapfind@precomputed[#1:#2][]%
+ }%
+}%
+\def\pgfplotscolormapfind@precomputed[#1:#2][#3]#4#5{%
+ \ifpgfplots@LUA@supported
+ \pgfplotscolormapifisuniform{#5}{%
+ \edef\pgfmathresult{%
+ \pgfplotsutil@directlua{%
+ pgfplots.texColorMapPrecomputed("#5", "#1","#2","#4")
+ }%
+ }%
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfplotscolormapfind@precomputed@warn@LUA{#5}%
+ \pgfplotscolormapfind@precomputed@[#1:#2][#3]{#4}{#5}%
+ \else
+ %\message{LUA colormapfind[#1:#2](#4)(#5) = \pgfmathresult^^J}%
+ \fi
+ }{%
+ % FIXME : implement LUA for non-uniform colormaps
+ \pgfplotscolormapfind@precomputed@[#1:#2][#3]{#4}{#5}%
+ }%
+ \else
+ \pgfplotscolormapfind@precomputed@[#1:#2][#3]{#4}{#5}%
+ \fi
+}
+
+\def\pgfplotscolormapfind@precomputed@warn@LUA#1{%
+ \expandafter\ifx\csname pgfplotscolormapfind@precomputed@warn@LUA@#1\endcsname\relax
+ \pgfplotswarning{lua colormap unavailable}{#1}\pgfeov%
+ \expandafter\gdef\csname pgfplotscolormapfind@precomputed@warn@LUA@#1\endcsname{1}%
+ \fi
+}%
+\def\pgfplotscolormapfind@transform[#1:#2][#3]#4#5{%
+ \edef\pgfplots@loc@TMPa{#1:#2}%
+ \edef\pgfplots@loc@samerange{0:\pgfplotscolormaprange}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@samerange
+ % we have phi(#4) = #4 because #4 in [0:1000].
+ \pgfmathfloatparsenumber{#4}%
+ \pgfmathfloattofixed\pgfmathresult
+ \else
+ % Step 0: compute #3 if it is missing and write it into \pgfplots@loc@TMPa.
+%\message{mapping '#4' into colormap '#5' with range [#1:#2] ... ^^J}%
+ \pgfmathfloatparsenumber{#1}%
+ \let\pgfplots@L=\pgfmathresult
+ %
+ \def\pgfplots@loc@TMPa{#3}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfmathfloatparsenumber{#2}%
+ \let\pgfplots@R=\pgfmathresult
+ \pgfmathfloatsubtract@{\pgfplots@R}{\pgfplots@L}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfmathfloatdivide@{\pgfplotscolormaprange@float}{\pgfplots@loc@TMPb}%
+ \else
+ \pgfmathfloatparsenumber{#3}%
+ \fi
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ %
+ % 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.
+ \pgfmathfloatparsenumber{#4}%
+ \let\pgfplots@V=\pgfmathresult
+ \pgfmathfloatsubtract@{\pgfplots@V}{\pgfplots@L}%
+ \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPa}%
+ \pgfmathfloattofixed\pgfmathresult
+ \fi
+ \ifdim\pgfmathresult pt<0pt %
+ \def\pgfmathresult{0}%
+ \else
+ \ifdim\pgfmathresult pt>1000pt %
+ \def\pgfmathresult{1000}%
+ \fi
+ \fi
+}%
+\def\pgfplotscolormapfind@precomputed@[#1:#2][#3]#4#5{%
+ \pgfplotscolormapassertexists{#5}%
+ \begingroup
+ \pgfplotscolormapfind@transform[#1:#2][#3]{#4}{#5}%
+ \let\pgfplotscolormapfind@transformedx=\pgfmathresult
+ %
+ % Now, we have it in [0,1000]. Find the correct interval:
+ \pgfplotscolormapifisuniform{#5}{%
+ \pgfmathmultiply@{\pgfplotscolormapfind@transformedx}{\csname pgfpl@cm@#5@invh\endcsname}%
+ \let\pgfplotscolormapfind@transformedx@divh=\pgfmathresult
+ % assign \pgfplotscolormapfind@intervalno := \pgfmathresult
+ % without '.0' suffix:
+ \expandafter\pgfplotscolormap@floor@unforgiving\pgfmathresult\relax
+ % Step 2: interpolate the desired RGB value using vector valued
+ % interpolation on the identified interval.
+ \c@pgf@counta=\pgfplotscolormapfind@intervalno\relax
+ % color^m(x) = ( (x-x_i)/(x_{i+1} - x_i) ) * (c_{i+1}^m - c_i^m ) + c_i^m
+ % = ( x/h - i ) * ( c_{i+1}^m - c_{i}^m ) + c_i^m
+ % = s * c_{i+1}^m + S * c_i^m
+ %
+ % s= x_h / h -i
+ \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}%
+ \let\pgfplots@loc@factor=\pgfmathresult
+ }{%
+ \pgfplotsarraybinarysearch{pgfpl@cm@#5@X}{\pgfplotscolormapfind@transformedx}{0}{\pgfplotscolormapsizeof{#5}}%
+ \c@pgf@counta=\pgfplotsretval\relax
+ \ifnum\c@pgf@counta<0
+ % as per definition of \pgfplotsarraybinarysearch, a
+ % negative result indicates the "insertion point" ...
+ \c@pgf@counta=-\c@pgf@counta
+ % ... plus one.
+ \advance\c@pgf@counta by-1
+ %
+ % But we do not WANT the insertion point! We want the LEFT
+ % interval boundary!
+ \advance\c@pgf@counta by-1
+ \fi
+ %
+ % color^m(x) = ( (x-x_i)/(x_{i+1} - x_i) ) * (c_{i+1}^m - c_i^m ) + c_i^m
+ % = s * c_{i+1}^m + S * c_i^m
+ %
+ % s = (x - x_i) / (x_{i+1} - x_i)
+ \begingroup
+ \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5@X}\to\pgfplotscolormapfind@rgb@X@left
+ \advance\c@pgf@counta by1
+ \ifnum\c@pgf@counta<\pgfplotsarraysizeof{pgfpl@cm@#5} %
+ % ok, we really have an interval
+ \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5@X}\to\pgfplotscolormapfind@rgb@X@right
+ %
+ \pgfmathsubtract@{\pgfplotscolormapfind@rgb@X@right}{\pgfplotscolormapfind@rgb@X@left}%
+ \let\pgfplotscolormapfind@h=\pgfmathresult
+ \pgfmathsubtract@{\pgfplotscolormapfind@transformedx}{\pgfplotscolormapfind@rgb@X@left}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfmathdivide@{\pgfplots@loc@TMPa}{\pgfplotscolormapfind@h}%
+ \let\pgfplots@loc@factor=\pgfmathresult
+ \else
+ % irrelevant (not used)
+ \def\pgfplots@loc@factor{1}%
+ \fi
+ \pgfmath@smuggleone\pgfplots@loc@factor
+ \endgroup
+ }%
+ % POSTCONDITION: \c@pgf@counta is the index of the LEFT interval
+ % and \pgfplots@loc@factor is the factor for the linear interpolation.
+ %
+%\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange] yielded phi(#4) = \pgfplotscolormapfind@transformedx, situated in interval no \the\c@pgf@counta.^^J}%
+ \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5}\to\pgfplotscolormapfind@rgb@LEFT
+ %
+ % do the stuff which is specific to linear interpolation:
+ %
+ % S = 1 - s
+ \pgfmathsubtract@{1}{\pgfplots@loc@factor}%
+ \let\pgfplots@loc@factor@two=\pgfmathresult
+ %
+ \advance\c@pgf@counta by1 %
+ \ifnum\c@pgf@counta<\pgfplotsarraysizeof{pgfpl@cm@#5} %
+ % Ah: (selected index < length) . That means: we have an interval.
+ \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5}\to\pgfplotscolormapfind@rgb@RIGHT
+%\message{After lookup: the corresponding RGB interval boundaries are [\pgfplotscolormapfind@rgb@LEFT: \pgfplotscolormapfind@rgb@RIGHT].^^J}%
+ %
+ %
+ \pgfplotscolorzero{\csname pgfpl@cm@#5@col@comps\endcsname}%
+ \pgfplotscoloraddweighted
+ {\csname pgfpl@cm@#5@col@comps\endcsname}%
+ {\pgfplotsretval}%
+ {\pgfplots@loc@factor@two}%
+ {\pgfplotscolormapfind@rgb@LEFT}%
+ \pgfplotscoloraddweighted
+ {\csname pgfpl@cm@#5@col@comps\endcsname}%
+ {\pgfplotsretval}%
+ {\pgfplots@loc@factor}%
+ {\pgfplotscolormapfind@rgb@RIGHT}%
+ \let\pgfmathresult=\pgfplotsretval
+ \else
+ % Ah: selected index = last index. Use the rightmost color!
+ \let\pgfmathresult=\pgfplotscolormapfind@rgb@LEFT
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+%\message{-> got finally mapping(#4, #5) = RGB'\pgfmathresult'.}%
+}%
+
+
+% Maps the number #4 into the colormap #5 using piecewise constant
+% interpolation. It returns the interpolated colors into \pgfmathresult. The result will be a triple
+% for an RGB colormap and it will contain four numbers for CMYK. The
+% components of the result will be in the range [0:1].
+%
+% [#1:#2] the number range of the data source (i.e. of #4). This is required to
+% map into the colormap.
+% [#3] (optional) the quantity
+% s := \pgfplotscolormaprange / (#2-#1).
+% Precomputing this quantity may save a lot of time because
+% divisions are expensive in TeX. You can omit [#3] or
+% provide an empty string here.
+% #4 the number to map.
+% #5 the colormap's name. Must be defined with
+% \pgfplotscreatecolormap before.
+%
+% Example:
+% \pgfplotscolormapfindpiecewiseconst[-1:1]{0.2}{my colormap}
+\def\pgfplotscolormapfindpiecewiseconst[#1:#2]{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotscolormapfindpiecewiseconst@precomputed[#1:#2]%
+ }{%
+ \pgfplotscolormapfindpiecewiseconst@precomputed[#1:#2][]%
+ }%
+}%
+\def\pgfplotscolormapfindpiecewiseconst@precomputed[#1:#2][#3]#4#5{%
+ \ifpgfplots@LUA@supported
+ \pgfplotscolormapifisuniform{#5}{%
+ \edef\pgfmathresult{%
+ \pgfplotsutil@directlua{%
+ pgfplots.texColorMapFindPiecewiseConst("#5", #1,#2,#4)
+ }%
+ }%
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfplotscolormapfindpiecewiseconst@precomputed@warn@LUA{#5}%
+ \pgfplotscolormapfindpiecewiseconst@precomputed@[#1:#2][#3]{#4}{#5}%
+ \else
+ %\message{LUA colormapfindpiecewiseconst[#1:#2](#4)(#5) = \pgfmathresult^^J}%
+ \fi
+ }{%
+ % FIXME : implement LUA for non-uniform colormaps
+ \pgfplotscolormapfindpiecewiseconst@precomputed@[#1:#2][#3]{#4}{#5}%
+ }%
+ \else
+ \pgfplotscolormapfindpiecewiseconst@precomputed@[#1:#2][#3]{#4}{#5}%
+ \fi
+}
+
+\def\pgfplotscolormapfindpiecewiseconst@precomputed@warn@LUA#1{%
+ \expandafter\ifx\csname pgfplotscolormapfindpiecewiseconst@precomputed@warn@LUA@#1\endcsname\relax
+ \pgfplotswarning{lua colormap unavailable}{#1}\pgfeov%
+ \expandafter\gdef\csname pgfplotscolormapfindpiecewiseconst@precomputed@warn@LUA@#1\endcsname{1}%
+ \fi
+}%
+
+\def\pgfplotscolormapfindpiecewiseconst@precomputed@[#1:#2][#3]#4#5{%
+ \pgfplotscolormapassertexists{#5}%
+ \begingroup
+ \pgfplotscolormapfind@transform[#1:#2][#3]{#4}{#5}%
+ \let\pgfplotscolormapfind@transformedx=\pgfmathresult
+ %
+ % Now, we have it in [0,1000]. Find the correct interval:
+ % In principle, we could easily find the correct interval. But the
+ % native approach has one distinct disadvantage: we will never
+ % assign the rightmost color unless #4=1000! That means that our
+ % colormap is not used entirely.
+ %
+ % I decided to enlarge the colormap artificially such that the
+ % rightmost color receives its own interval.
+ %
+ % To this end, I recompute the coordinates at which colors "live".
+ % The operations sounds more involved than it is: I simply need a NEW mesh width locally
+ % inside of this function. The new mesh width H can be computed as
+ % follows, assuming that the OLD colormap has mesh width h.
+ %
+ % H := 1000/ (N-1)
+ %
+ % N := n+1
+ % n := 1000/h + 1 = \pgfplotscolormapsizeof{#5}
+ %
+ % what I really need is:
+ % 1/H = N/1000 = (1000 h^{-1} +1)/ 1000 = h^{-1} + 1/1000
+ %
+ \pgfplotscolormapifisuniform{#5}{%
+ %
+ \expandafter\ifx\csname pgfpl@cm@#5@X@scale@order@z\endcsname\pgfutil@empty%
+ % compute 1/H here:
+ \pgfmathadd@{\csname pgfpl@cm@#5@invh\endcsname}{0.001}%
+ \let\pgfplots@piecewiseconst@invh=\pgfmathresult%
+ \else
+ % disable the extra interval
+ \expandafter\let\expandafter\pgfplots@piecewiseconst@invh\csname pgfpl@cm@#5@invh\endcsname
+ \fi
+ \pgfmathmultiply@{\pgfplotscolormapfind@transformedx}{\pgfplots@piecewiseconst@invh}%
+ \let\pgfplotscolormapfind@transformedx@divh=\pgfmathresult
+ % assign \pgfplotscolormapfind@intervalno := \pgfmathresult
+ % without '.0' suffix:
+ \expandafter\pgfplotscolormap@floor\pgfmathresult\relax
+ % Step 2: interpolate the desired RGB value using vector valued
+ % interpolation on the identified interval.
+ \c@pgf@counta=\pgfplotscolormapfind@intervalno\relax
+ }{%
+ % the same idea can also be applied to non-uniform grids.
+ % However, it is more involved here.
+ %
+ % My idea is that I add an extra interval of length 'h' at the right end of
+ % the domain, i.e. I enlarge the domain to [0,1000+h].
+ %
+ % To this end, I map the input number linearly from
+ % [0,1000] -> [0,1000+h]
+ % using k(t) = (1000+h)/1000 * t
+ %
+ % Note that k(t) = 1/ pgfpl@cm@#5@X@scale@order@z
+ %
+ % and search in the existing X coordinates of the colormap.
+ % Note that these X coordinates actually do not contain the
+ % artifical rightmost boundary point at 1000+h. But that is
+ % ok, we plan to assign COLOR(1000+h) := COLOR(1000) anyway.
+ %
+ % Naturally, some values 'k(t)' will be BEYOND '1000'. In this
+ % case, we simply use the rightmost interval and are done with
+ % it.
+ %
+ % compute k(t):
+ \ifdim\csname pgfpl@cm@#5@X@scale@order@z\endcsname pt>0pt
+ \pgfmathadd@{1000}{\csname pgfpl@cm@#5@h\endcsname}%
+ \pgf@xa=\pgfmathresult pt %
+ \divide\pgf@xa by1000 %
+ \edef\pgfplotscolormapfind@map@to@extra@interval{\pgf@sys@tonumber\pgf@xa}%
+ %
+ \pgfmathmultiply@{\pgfplotscolormapfind@transformedx}{\pgfplotscolormapfind@map@to@extra@interval}%
+ \let\pgfplotscolormapfind@transformedx@=\pgfmathresult
+ \else
+ % disable the extra interval
+ \let\pgfplotscolormapfind@transformedx@=\pgfplotscolormapfind@transformedx
+ \fi
+ %
+ % search k(t) in the original X values.
+ \pgfplotsarraybinarysearch{pgfpl@cm@#5@X}{\pgfplotscolormapfind@transformedx@}{0}{\pgfplotscolormapsizeof{#5}}%
+ \c@pgf@counta=\pgfplotsretval\relax
+ \ifnum\c@pgf@counta<0
+ % as per definition of \pgfplotsarraybinarysearch, a
+ % negative result indicates the "insertion point" ...
+ \c@pgf@counta=-\c@pgf@counta
+ % ... plus one.
+ \advance\c@pgf@counta by-1
+ %
+ % But we do not WANT the insertion point! We want the LEFT
+ % interval boundary!
+ \advance\c@pgf@counta by-1
+ \fi
+%\pgfplotscolormapserializeXtomacro{#5}\XXX
+%\message{k(\pgfplotscolormapfind@transformedx) = \pgfplotscolormapfind@transformedx@. Searching for value in X=(\XXX) resulted in \pgfplotsretval, and the index to use is \the\c@pgf@counta.^^J}%
+ }%
+ %
+ \ifnum\c@pgf@counta=\pgfplotscolormapsizeof{#5}\relax
+ % we have artificially increased the "h" (see the comments
+ % above) -- meaning that this 'if' can happen.
+ % ->Map the rightmost point to the rightmost interval:
+ \advance\c@pgf@counta by-1
+ \fi
+ %
+%\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange] yielded phi = \pgfplotscolormapfind@transformedx, situated in interval no \the\c@pgf@counta/\pgfplotsarraysizeof{pgfpl@cm@#5}.^^J}%
+ \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5}\to\pgfplotscolormapfind@rgb@LEFT
+ \let\pgfmathresult=\pgfplotscolormapfind@rgb@LEFT
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+\def\pgfplotscolormap@floor#1.#2\relax{%
+ \ifdim0.#2pt>0.999pt
+ % ok, it is ALMOST one more! Take this as rounding inaccuracy
+ \c@pgf@counta=#1\relax
+ \advance\c@pgf@counta by1
+ \edef\pgfplotscolormapfind@intervalno{\the\c@pgf@counta}%
+ \else
+ \def\pgfplotscolormapfind@intervalno{#1}%
+ \fi
+}%
+
+\def\pgfplotscolormap@floor@unforgiving#1.#2\relax{%
+ \def\pgfplotscolormapfind@intervalno{#1}%
+}%
+
+% 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
+ \pgfmathfloatparsenumber{#1}%
+ \expandafter\pgfmathfloattoint\expandafter{\pgfmathresult}%
+ %\afterassignment\pgfplots@gobble@until@relax
+ \c@pgf@counta=\pgfmathresult\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 one of \pgfplotscolormapfind,
+% \pgfplotscolormapfindpiecewiseconst, 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
+ % colormap access=map
+ \pgfplotscolormapfind@precomputed[#1:#2][#3]{#4}{#5}%
+ \else
+ \if c\pgfplots@colormap@access
+ % colormap access=piecewise constant
+ \pgfplotscolormapfindpiecewiseconst@precomputed[#1:#2][#3]{#4}{#5}%
+ \else
+ % colormap access=direct
+ \pgfplotscolormapgetindex{#4}{#5}%
+ \fi
+ \fi
+}%
+
+\pgfutil@definecolor{mapped color}{rgb}{0,0,0}% make sure this color exists. It will be overwritten if needed.
+% ATTENTION: replicated in pgfplots.code.tex :
+\pgfplotscreatecolormap{hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)}
+
+
+\def\pgfplotspointmetatransformedrange{0:1000}
+
+% 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')^^J}%
+ \def\pgfplots@loc@TMPb{\pgfutil@definecolor{mapped color}{\csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}}%
+ \expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}%
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotscoordprocessing.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotscoordprocessing.code.tex
new file mode 100644
index 0000000000..92cb99709c
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotscoordprocessing.code.tex
@@ -0,0 +1,9721 @@
+%--------------------------------------------
+%
+% 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-2010 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 contains the code to process coordinates
+% - coordinate input: \addplot and its variants,
+% - coordinate loops,
+% - single coordinate processing
+%
+% -> see \pgfplots@addplot
+
+
+% 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@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ % do not use \pgfqpoint here - it may have been replaced
+ % (compare \pgfplots@change@pgfpoints@to@descriptioncs)
+ \pgfsetxvec{\global\pgf@x=\pgf@xa \global\pgf@y=0pt }%
+ \pgfsetyvec{\global\pgf@x=0pt \global\pgf@y=\pgf@ya}%
+ \pgfsetzvec{\global\pgf@x=0pt \global\pgf@y=0pt }%
+ }%
+ %
+ % The \pgfplotsqpointxyz method (or its 2d counterpart) are THE
+ % point method. If you override them, all other coordinate systems
+ % should inherit the changes as well.
+ \edef\pgfplotsplothandlerpointxyz##1##2##3{%
+ \ifpgfplots@curplot@threedim
+ \noexpand\pgfplotsqpointxyz{##1}{##2}{##3}%
+ \else
+ \noexpand\pgfplotsqpointxy{##1}{##2}%
+ \fi
+ }%
+ %
+ % 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}}%
+ }%
+ }%
+ \pgfplotspoint@initialisation@axes
+ \pgfplotspoint@initialisation@units
+ \pgfplotspoint@initialisation@center
+ %
+ % declare the '[xyz]ticklabel cs'
+ \tikzdeclarecoordinatesystem{xticklabel}{\pgfplotspointticklabelcs{x}{##1}}%
+ \tikzdeclarecoordinatesystem{yticklabel}{\pgfplotspointticklabelcs{y}{##1}}%
+ \tikzdeclarecoordinatesystem{zticklabel}{\pgfplotspointticklabelcs{z}{##1}}%
+ \tikzdeclarecoordinatesystem{xticklabel*}{\pgfplotspointticklabelnoshiftcs{x}{##1}}%
+ \tikzdeclarecoordinatesystem{yticklabel*}{\pgfplotspointticklabelnoshiftcs{y}{##1}}%
+ \tikzdeclarecoordinatesystem{zticklabel*}{\pgfplotspointticklabelnoshiftcs{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[##1]{x}}}%
+ \pgfkeysdef{/tikz/sloped like y axis}{\tikz@addtransform{\pgfplotstransformtoaxisdirection[##1]{y}}}%
+ \pgfkeysdef{/tikz/sloped like z axis}{\tikz@addtransform{\pgfplotstransformtoaxisdirection[##1]{z}}}%
+ %
+}%
+
+% Determine final axes this does also fix the axis' dimension.
+% There are the following cases:
+% 1. the user really wants a fixed dimension,
+% i.e. he used 'scale only axis'.
+% Then, we have to work to get the correct dimension!
+%
+% Up to now, the scaling mechanism looses to many significant
+% digits such that the final width/height differs by 1-2 pt.
+%
+% If I am not mistaken, this does ONLY affect the final size,
+% not the relative plot precision.
+%
+% FIXME : really compute the plot precision!
+%
+% 2. The use specified width and/or height, but not 'scale only
+% axis'. Accept inaccurate final widths/heights (see above).
+%
+% 3. The user supplied 'x' and or 'y'. Simply use them, its
+% accurate.
+% POSTCONDITION: the macros
+% \pgfplotspointminminmin
+% \pgfplotspoint[xyz]axis
+% \pgfplotspoint[xyz]axislength
+% are defined (globally).
+%
+\def\pgfplotspoint@initialisation@axes{%
+ \begingroup
+ \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
+ \let\pgfplots@ycoordminTEX=\pgf@yb
+ \pgfplots@xcoordminTEX=\pgf@x
+ \pgfplots@ycoordminTEX=\pgf@y
+ %
+ %--------------------------------------------------
+ % 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}}
+ {\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}}
+ {\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}}
+ {\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}%
+ \else
+ \global\let\pgfplotspointzaxis=\pgfpointorigin
+ \gdef\pgfplotspointzaxislength{0pt}%
+ \fi
+ \endgroup
+ %
+}
+
+% PRECONDITION: called after \pgfplotspoint@initialisation@axes
+% POSTCONDITION:
+% \pgfplotspointcenter is defined.
+\def\pgfplotspoint@initialisation@center{%
+ \begingroup
+ %
+ %
+ \ifpgfplots@threedim
+ %
+ \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
+ \pgfpointscale
+ {0.5}%
+ {\pgfpointadd
+ \pgfplotspointxaxis%
+ \pgfplotspointyaxis%
+ }%
+ \xdef\pgfplotspointcenter{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
+ \fi
+ \endgroup
+}
+
+% PRECONDITION:
+% the unit vectors are set up
+%
+% POSTCONDITION:
+% \pgfplotspointunit[xyz]
+% \pgfplotspointunit[xyz]length
+% \pgfplotspointunit[xyz]invlength
+% are all set up.
+\def\pgfplotspoint@initialisation@units{%
+ \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
+}%
+
+% 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
+}%
+
+\def\pgfplotspointticklabelnoshiftcs#1#2{%
+ \pgfutil@in@{,}{#2}%
+ \ifpgfutil@in@
+ \edef\pgfplots@loc@TMPa{#2}%
+ \else
+ \edef\pgfplots@loc@TMPa{#2,0}%
+ \fi
+ \def\pgfplots@loc@TMPb##1,##2\relax{%
+ % invoke
+ % \pgfplotsqpointoutsideofticklabelaxisrel{#2}{##1}{##2}:
+ \pgfmathparse{##2}%
+ \def\pgfplots@loc@TMPa{\pgfplotsqpointoutsideofticklabelaxisrel{#1}{##1}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
+ }%
+ \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.
+%
+% The meaning of coordinates #1 and #2 will be redefined depending on
+% which surface we are currently processing. You can get the axis
+% names for '#1' (a) and '#2' (b) using the macros
+% \pgfplotspointonorientedsurfaceA (one of the characters x,y or z)
+% and
+% \pgfplotspointonorientedsurfaceB.
+% The surface normal direction is
+% \pgfplotspointonorientedsurfaceN.
+%
+% Example:
+% \pgfplotspointonorientedsurfaceabsetupfor xyz
+% \pgfplotspointonorientedsurfaceabsetupforsetz{<lower z limit>}{0}
+%
+% ->
+% \pgfplotspointonorientedsurfaceA = x
+% \pgfplotspointonorientedsurfaceB = y
+% \pgfplotspointonorientedsurfaceN = z
+% \pgfplotspointonorientedsurfacespec = {ab0}
+% \pgfplotspointonorientedsurfacespecunordered = {vv0}
+% \pgfplotspointonorientedsurfaceab{3}{4} =\pgfqpointxyz{3}{4}{<lower z limit>}
+%
+% \pgfplotspointonorientedsurfaceabsetupfor yxz
+% \pgfplotspointonorientedsurfaceabsetupforsetz{<lower z limit>}{0}
+% ->
+% \pgfplotspointonorientedsurfaceA = y
+% \pgfplotspointonorientedsurfaceB = x
+% \pgfplotspointonorientedsurfaceN = z
+% \pgfplotspointonorientedsurfacespec = {ba0}
+% \pgfplotspointonorientedsurfacespecunordered = {vv0}
+% \pgfplotspointonorientedsurfaceab{3}{4} =\pgfqpointxyz{4}{3}{<lower z limit>}
+%
+% @see \pgfplotspointonorientedsurfaceabsetupfor xyz
+\def\pgfplotspointonorientedsurfaceab#1#2{%
+ \pgfplots@error{Internal logic error: \string\pgfplotspointonorientedsurfaceab\ used although surface has not been declared! You need to call \string\pgfplotspointonorientedsurfaceabsetupfor xyz\ or its friends to do so.}%
+}%
+
+% This is a shortcut for
+% \pgfpointadd
+% {\pgfplotspointonorientedsurfaceab{#1}{#2}}
+% {<shift in B direction of #3>}
+%
+% where #3 is a dimension (a number with unit).
+\def\pgfplotspointonorientedsurfaceabwithbshift#1#2#3{%
+ \begingroup
+ \pgf@xa=#3\relax
+ \ifdim\pgf@xa=0pt
+ \else
+ \pgf@xa=\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname\pgf@xa
+ \fi
+ \advance\pgf@xa by#2pt
+ \edef\pgfplots@loc@b{\pgf@sys@tonumber\pgf@xa}%
+ \pgf@process{\pgfplotspointonorientedsurfaceab{#1}{\pgfplots@loc@b}}%
+ \endgroup
+}
+
+\pgfkeyssetvalue{/pgfplots/oriented surf installed}{}
+
+% This macro will be defined after
+% \pgfplotspointonorientedsurfaceabsetupfor...
+% routines. It expands to a three-character string
+% where the first character contains information about the x axis,
+% the second about the y axis and the third about the z axis.
+%
+% The single characters can be one of
+% - 'a' - the corresponding axis is the PRIMARY direction of the
+% oriented surface.
+% - 'b' - the corresponding axis is the SECONDARY direction of the
+% oriented surface.
+% - anything else - the characters provides as second argument for
+% \pgfplotspointonorientedsurfaceabsetupforsetz{}{}, for example.
+% Common choices are '0' for lower limit, '1' for upper limit and
+% '2' for other.
+\def\pgfplotspointonorientedsurfacespec{}%
+
+% Similar to \pgfplotspointonorientedsurfacespec, this macro encodes
+% the currently active oriented surface.
+% However, it only contains the characters 'v', '0' and '1' and '2'.
+% 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}
+
+\def\pgfplotspointonorientedsurfaceabsetupfor#1#2#3{%
+ \pgfutil@ifundefined{pgfplotspointonorientedsurfaceabsetupfor@@#1#2#3}{%
+ \pgfplots@error{Sorry, \string\pgfplotspointonorientedsurfaceabsetupfor\space#1#2#3 is not yet implemented.}%
+ }{
+ \csname pgfplotspointonorientedsurfaceabsetupfor@@#1#2#3\endcsname
+ }%
+}%
+%
+% Initialises \pgfplotspointonorientedsurfaceab such that 'a' is the x
+% axis and 'b' is the y axis and the z coordinate has been fixed with
+% \pgfplotspointonorientedsurfaceabsetupforsetz{}.
+%
+% The Z value needs to be fixed with
+% \pgfplotspointonorientedsurfaceabsetupforsetz .
+\def\pgfplotspointonorientedsurfaceabsetupfor@@xyz{%
+ \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{##1}{##2}{\pgfplotspointonorientedsurfaceabsetupfor@fixedz}}%
+ \def\pgfplotspointonorientedsurfaceA{x}%
+ \def\pgfplotspointonorientedsurfaceB{y}%
+ \def\pgfplotspointonorientedsurfaceN{z}%
+ \edef\pgfplotspointonorientedsurfacespec{ab\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}%
+ \edef\pgfplotspointonorientedsurfacespecunordered{vv\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}%
+ \pgfkeysvalueof{/pgfplots/oriented surf installed}%
+}%
+\def\pgfplotspointonorientedsurfaceabsetupfor@@yxz{%
+ \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{##2}{##1}{\pgfplotspointonorientedsurfaceabsetupfor@fixedz}}%
+ \def\pgfplotspointonorientedsurfaceA{y}%
+ \def\pgfplotspointonorientedsurfaceB{x}%
+ \def\pgfplotspointonorientedsurfaceN{z}%
+ \edef\pgfplotspointonorientedsurfacespec{ba\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}%
+ \edef\pgfplotspointonorientedsurfacespecunordered{vv\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}%
+ \pgfkeysvalueof{/pgfplots/oriented surf installed}%
+}%
+\def\pgfplotspointonorientedsurfaceabsetupfor@@xzy{%
+ \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{##1}{\pgfplotspointonorientedsurfaceabsetupfor@fixedy}{##2}}%
+ \def\pgfplotspointonorientedsurfaceA{x}%
+ \def\pgfplotspointonorientedsurfaceB{z}%
+ \def\pgfplotspointonorientedsurfaceN{y}%
+ \edef\pgfplotspointonorientedsurfacespec{a\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol b}%
+ \edef\pgfplotspointonorientedsurfacespecunordered{v\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol v}%
+ \pgfkeysvalueof{/pgfplots/oriented surf installed}%
+}%
+\def\pgfplotspointonorientedsurfaceabsetupfor@@zxy{%
+ \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{##2}{\pgfplotspointonorientedsurfaceabsetupfor@fixedy}{##1}}%
+ \def\pgfplotspointonorientedsurfaceA{z}%
+ \def\pgfplotspointonorientedsurfaceB{x}%
+ \def\pgfplotspointonorientedsurfaceN{y}%
+ \edef\pgfplotspointonorientedsurfacespec{b\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol a}%
+ \edef\pgfplotspointonorientedsurfacespecunordered{v\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol v}%
+ \pgfkeysvalueof{/pgfplots/oriented surf installed}%
+}%
+\def\pgfplotspointonorientedsurfaceabsetupfor@@yzx{%
+ \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{\pgfplotspointonorientedsurfaceabsetupfor@fixedx}{##1}{##2}}%
+ \def\pgfplotspointonorientedsurfaceA{y}%
+ \def\pgfplotspointonorientedsurfaceB{z}%
+ \def\pgfplotspointonorientedsurfaceN{x}%
+ \edef\pgfplotspointonorientedsurfacespec{\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol ab}%
+ \edef\pgfplotspointonorientedsurfacespecunordered{\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol vv}%
+ \pgfkeysvalueof{/pgfplots/oriented surf installed}%
+}%
+\def\pgfplotspointonorientedsurfaceabsetupfor@@zyx{%
+ \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{\pgfplotspointonorientedsurfaceabsetupfor@fixedx}{##2}{##1}}%
+ \def\pgfplotspointonorientedsurfaceA{z}%
+ \def\pgfplotspointonorientedsurfaceB{y}%
+ \def\pgfplotspointonorientedsurfaceN{x}%
+ \edef\pgfplotspointonorientedsurfacespec{\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol ba}%
+ \edef\pgfplotspointonorientedsurfacespecunordered{\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol vv}%
+ \pgfkeysvalueof{/pgfplots/oriented surf installed}%
+}%
+
+% Fixes 'x' to #1 for use in
+% \pgfplotspointonorientedsurfaceabsetupfor zyx and
+% \pgfplotspointonorientedsurfaceabsetupfor yzx.
+%
+% #1: The fixed value for 'x' (a coordinate in transformed range).
+% #2: a one-character symbol describing 'x'.
+% Command characters are
+% 0 : x is the lower x-axis range.
+% 1 : x is the upper x-axis range.
+% 2 : other.
+\def\pgfplotspointonorientedsurfaceabsetupforsetx#1#2{%
+ \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedx{#1}%
+ \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{#2}%
+}%
+\def\pgfplotspointonorientedsurfaceabsetupforsety#1#2{%
+ \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedy{#1}%
+ \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{#2}%
+}%
+\def\pgfplotspointonorientedsurfaceabsetupforsetz#1#2{%
+ \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedz{#1}%
+ \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{#2}%
+}%
+
+% Helper methods which should be used if no Z component exists (pure
+% 2d plots).
+\def\pgfplotspointonorientedsurfaceabsetupfor@@xy{%
+ \def\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{0}%
+ \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxy{##1}{##2}}%
+ \def\pgfplotspointonorientedsurfaceA{x}%
+ \def\pgfplotspointonorientedsurfaceB{y}%
+ \def\pgfplotspointonorientedsurfaceN{z}%
+ \edef\pgfplotspointonorientedsurfacespec{ab\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}%
+ \edef\pgfplotspointonorientedsurfacespecunordered{vv\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}%
+ \pgfkeysvalueof{/pgfplots/oriented surf installed}%
+}%
+\def\pgfplotspointonorientedsurfaceabsetupfor@@yx{%
+ \def\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{0}%
+ \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxy{##2}{##1}}%
+ \def\pgfplotspointonorientedsurfaceA{y}%
+ \def\pgfplotspointonorientedsurfaceB{x}%
+ \def\pgfplotspointonorientedsurfaceN{z}%
+ \edef\pgfplotspointonorientedsurfacespec{ba\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}%
+ \edef\pgfplotspointonorientedsurfacespecunordered{vv\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}%
+ \pgfkeysvalueof{/pgfplots/oriented surf installed}%
+}%
+
+
+% 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'
+% - b=1: 'v01'
+% - b=2: 'v02'
+%
+% To check which of them should be drawn, this macro here converts 'a'
+% 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:
+% \pgfplotspointonorientedsurfaceabsetupfor xyz
+% \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
+}%
+% writes into \pgfplots@loc@TMPa:
+\def\pgfplotspointonorientedsurfaceabgetcontainedaxisline@#1#2#3\relax#4{%
+ \pgfplotspointonorientedsurfaceabgetcontainedaxisline@single{#1}{#4}\to\pgfplots@loc@TMPa
+ \pgfplotspointonorientedsurfaceabgetcontainedaxisline@single{#2}{#4}\to\pgfplots@loc@TMPb
+ \pgfplotspointonorientedsurfaceabgetcontainedaxisline@single{#3}{#4}\to\pgfplots@loc@TMPc
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa\pgfplots@loc@TMPb\pgfplots@loc@TMPc}%
+}%
+\def\pgfplotspointonorientedsurfaceabgetcontainedaxisline@single#1#2\to#3{%
+ \if#1a%
+ \def#3{v}%
+ \else
+ \if#1b%
+ \def#3{#2}%
+ \else
+ \def#3{#1}%
+ \fi
+ \fi
+}%
+
+
+% Finds the two surfaces which are adjacent to an axis line encoded as
+% three-character-string.
+%
+% There are the following possibilities:
+% #1 = 'v**' where '*' is not 'v'.
+% -> #2 = 'vv*' and #3 = 'v*v'
+%
+% #1 = '*v*'
+% -> #2 = 'vv*' and #3 = '*vv'
+%
+% #1 = '**v'
+% -> #2 = 'v*v' and #3 = '*vv'
+\def\pgfplotsgetadjacentsurfsforaxisline#1\to#2#3{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotsgetadjacentsurfsforaxisline@\pgfplots@loc@TMPa\relax{#2}{#3}%
+}%
+\def\pgfplotsgetadjacentsurfsforaxisline@#1#2#3\relax#4#5{%
+ \if#1v%
+ \def#4{vv#3}%
+ \def#5{v#2v}%
+ \else
+ \if#2v%
+ \def#4{vv#3}%
+ \def#5{#1vv}%
+ \else
+ \def#4{v#2v}%
+ \def#5{#1vv}%
+ \fi
+ \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
+}%
+
+% 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.
+%
+% Example:
+% Let's assume the current oriented surface is 'b0a'.
+% Then,
+% \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{draw it!}{\relax}
+% will check whether the line '00v' shall be drawn while
+% \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%
+ }%
+}%
+\def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@allaxislinevariations#1#2#3{%
+ \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@{#1}{%
+ #2%
+ }{%
+ #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{%
+ \pgfplotspointonorientedsurfaceabgetcontainedaxisline#1\pgfplots@loc@TMPc
+ \pgfplotsgetadjacentsurfsforaxisline\pgfplots@loc@TMPc\to\pgfplots@loc@TMPb\pgfplots@loc@TMPc
+ \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPb}{%
+ \pgfplotsifaxissurfaceisforeground{\pgfplots@loc@TMPc}{%
+ #3%
+ }{%
+ #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@allaxislinevariations{0}{%
+ % remark: this is ALWAYS true for 2D plots.
+ \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@allaxislinevariations{1}{%
+ #1%
+ }{%
+ #2%
+ }%
+ }{%
+ #2%
+ }%
+}%
+
+% Checks whether the line specified by a three-character-string '#1'
+% is inside of the currently set-up oriented surface.
+%
+% The return value is encoded as integer into the macro #2 as
+% described below.
+%
+% #1 : a three-character string uniquely identifing an axis line.
+% Each of the three characters can be 'v', '0' or '1'.
+% The value '0' denotes the lower axis range while '1' denotes
+% the upper axis range. The character 'v' stands for 'varying'
+% and indicates the direction in which the line varies. The first
+% character contains the values for the 'x' axis, the second
+% character for the 'y' axis and the third character for the 'z'
+% axis.
+% Example:
+% 'v01' is the axis line with 'y=lower y limit' and 'z=upper z limit'
+% '10v' is the axis line with 'x=upper x limit' and 'y=lower y limit'
+% The 'v' character indicates the varying component. There may be
+% only one 'v'.
+% #2 : a macro name. It will be empty if the line is NOT on the
+% current surface. If will be non-empty if it IS on the current
+% surface.
+% To be more precise, If the line IS on the current surface, '#2' will be set to
+% the character in '#1' which belongs to the second oriented
+% surface axis (which is called the 'b' axis).
+% Thus, the following values for '#2' can be expected:
+% - '' (empty) if the line is not on the surface,
+% - 'v' if the line IS on the surface, and '#1' contains a 'v'
+% in direction of the surface's 'b' axis.
+% - '0' if the line IS on the surface and '#1' contains a '0' in
+% direction of the surface's 'b' axis,
+% - '1' if the line IS on the surface and '#1' contains a '1' in
+% direction of the surface's 'b' axis.
+% No other values are possible.
+%
+% Example:
+% \pgfplotspointonorientedsurfaceabsetupforsetz{\zmax}{1}
+% \pgfplotspointonorientedsurfaceabsetupfor yxz
+% \pgfplotspointonorientedsurfaceabmatchaxisline{v01}{\result}
+% -> \result will be 'v' because 'x=v' in '{v01}
+%
+% \pgfplotspointonorientedsurfaceabsetupforsety{\ymin}{0}
+% \pgfplotspointonorientedsurfaceabsetupfor xzy
+% \pgfplotspointonorientedsurfaceabmatchaxisline{v01}{\result}
+% -> \result will be '1' because 'z=1' in '{v01}
+%
+% \pgfplotspointonorientedsurfaceabsetupforsety{\ymax}{1}
+% \pgfplotspointonorientedsurfaceabsetupfor xzy
+% \pgfplotspointonorientedsurfaceabmatchaxisline{v01}{\result}
+% -> \result will be empty because 'y=0' in '{v01}
+%
+% \pgfplotspointonorientedsurfaceabsetupforsetx{\xmax}{1}
+% \pgfplotspointonorientedsurfaceabsetupfor yzx
+% \pgfplotspointonorientedsurfaceabmatchaxisline{10v}{\result}
+% -> \result will be 'v' because 'z=v' in '{10v}
+\def\pgfplotspointonorientedsurfaceabmatchaxisline#1#2{%
+ \pgfplotsmatchcubeparts{#1}{\pgfplotspointonorientedsurfacespec}{#2}%
+}%
+
+% Checks whether the line or surface specified by a three-character-string '#1'
+% is inside of the surface designated by the three-character-string '#2'.
+%
+%
+% Arguments:
+% #1 a cube-part (axis line or surface) encoded as three character
+% 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 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'.
+\def\pgfplotsmatchcubeparts#1#2#3{%
+ \edef\pgfplots@loc@TMPa{#1:#2}%
+ \expandafter\pgfplotspointonorientedsurfaceabmatchaxisline@\pgfplots@loc@TMPa\pgfplots@EOI
+ \let#3=\pgfplots@loc@TMPa
+}%
+
+% IMPLEMENTATION:
+% The return value is 'yes, #1#2#3 is on the oriented surface #4#5#6'
+% if and only if for all three character pairs, the following single
+% relations hold.
+% Input char oriented surface char
+% 'v' : is either a or b or v
+% '0' : is either 0, a, b, v or 2 (i.e. NOT 1) FIXME : is the '2' correct here!?
+% '1' : is either 1, a, b, v or 2 (i.e. NOT 0)
+% '2' : is either 2, a, b, v (i.e. NOT 0 or 1)
+% That's all.
+%
+% If the 'oriented surface char' is 'v', then we actually don't have
+% an oriented surface but just a surface.
+% So, 'a0b' is the same surface as 'v0v', but the first choice has
+% designated orientations.
+%
+% @POST \pgfplots@loc@TMPa contains the return value macro.
+% More precisely, \pgfplots@loc@TMPa will be EMPTY is #1#2#3 is NOT
+% on #4#5#6 . It will contain the value on the surface if it IS on
+% the surface
+\def\pgfplotspointonorientedsurfaceabmatchaxisline@#1#2#3:#4#5#6\pgfplots@EOI{%
+ % Search for the 'b' character:
+ \if#4b%
+ \def\pgfplots@loc@TMPa{#1}%
+ \else
+ \if#5b%
+ \def\pgfplots@loc@TMPa{#2}%
+ \else
+ \if#6b%
+ \def\pgfplots@loc@TMPa{#3}%
+ \else
+ \def\pgfplots@loc@TMPa{v}% FALLBACK solution.
+ \fi
+ \fi
+ \fi
+ % Now, check whether we need to clear the return value (i.e.
+ % return false)
+ \pgfplotspointonorientedsurfaceabmatchaxisline@single{#1}{#4}%
+ \pgfplotspointonorientedsurfaceabmatchaxisline@single{#2}{#5}%
+ \pgfplotspointonorientedsurfaceabmatchaxisline@single{#3}{#6}%
+%\message{\string\pgfplotspointonorientedsurfaceabmatchaxisline@#1#2#3:#4#5#6 = '\pgfplots@loc@TMPa'.^^J}%
+}
+\def\pgfplotspointonorientedsurfaceabmatchaxisline@single#1#2{%
+ \if#1v%
+ \if#2a%
+ \else
+ \if#2b%
+ \else
+ \if#2v%
+ \else
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \fi
+ \fi
+ \fi
+ \else
+ \if0#1%
+ \if1#2%
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \fi
+ \else
+ \if1#1%
+ \if0#2%
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \fi
+ \else
+ \if2#1%
+ \if0#2%
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \fi
+ \if1#2%
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \fi
+ \else
+ % return TRUE.
+ % I admit I am not sure at all if this works in all
+ % cases
+ \pgfplotspointonorientedsurfaceabmatchaxisline@warn{#1}%
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+\def\pgfplotspointonorientedsurfaceabmatchaxisline@warn#1{%
+ \pgfplots@warning{The internal implementation is suspicious that something is wrong: \string\pgfplotspointonorientedsurfaceabmatchaxisline@warn: the character '#1' in a three-character axis line or surface description might not be fully supported...}%
+}%
+
+% 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).
+%
+% NOTE: some specialized axis types support non-linear axes (for
+% example, polar axes). In that case, the outer normal vector *varies*
+% along the `v' direction (of the three-character-string `#1').
+% The value of `v' can be set using
+% \pgfplotspointouternormalvectorofaxissetv{<axis three char string>}{<transformed coordinate>}
+\def\pgfplotspointouternormalvectorofaxis#1{%
+ \pgfplotspointouternormalvectorofaxis@ifdependson@v{#1}{%
+ \expandafter\global\expandafter\let\csname pgfplotspointouternormalvectorofaxis@cache@#1\endcsname\relax
+ }{%
+ }%
+ \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{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ \else
+ \csname pgfplotspointouternormalvectorofaxis@cache@#1\endcsname
+ \fi
+}%
+
+% Fixes the "v" value for successive calls to
+% \pgfplotspointouternormalvectorofaxis{#1}.
+%
+% #1 the three-character-string of an axis or the empty string.
+% If #1 is empty, the actual configuration of oriented surfaces may be
+% used to check which normal vector is intented.
+%
+% #2 the "v" value to store. It should be a transformed coordinate.
+\def\pgfplotspointouternormalvectorofaxissetv#1#2{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \expandafter\edef\csname pgfplotspointouternormalvectorofaxis@v@\pgfplotspointonorientedsurfaceA\endcsname{#2}%
+ \else
+ \expandafter\edef\csname pgfplotspointouternormalvectorofaxis@v@#1\endcsname{#2}%
+ \fi
+}%
+
+% Defines \pgfplotsretval to contain the 'v' value for an outer normal
+% vector (if there is one known). If there is no such value,
+% \pgfplotsretval will be empty.
+% #1 a three-character-string
+%
+% see \pgfplotspointouternormalvectorofaxissetv
+\def\pgfplotspointouternormalvectorofaxisgetv#1{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotspointouternormalvectorofaxisgetv@\pgfplots@loc@TMPa\relax\relax\relax\relax
+}
+\def\pgfplotspointouternormalvectorofaxisgetv@#1#2#3\relax{%
+ \pgfutil@ifundefined{pgfplotspointouternormalvectorofaxis@v@#1#2#3}{%
+ % no value found so far.
+ \if#1v%
+ \def\pgfplotsretval{x}%
+ \else
+ \if#2v%
+ \def\pgfplotsretval{y}%
+ \else
+ \def\pgfplotsretval{z}%
+ \fi
+ \fi
+ \pgfutil@ifundefined{pgfplotspointouternormalvectorofaxis@v@\pgfplotsretval}{%
+ \let\pgfplotsretval\pgfutil@empty
+ }{%
+ \edef\pgfplotsretval{\csname pgfplotspointouternormalvectorofaxis@v@\pgfplotsretval\endcsname}%
+ }%
+ }{%
+ \edef\pgfplotsretval{\csname pgfplotspointouternormalvectorofaxis@v@#1#2#3\endcsname}%
+ }%
+}%
+
+% invokes #2 if the outer normal for the axis #1 (identified by a
+% three-character-string) depends on a coordinate on that axis and #3
+% otherwise.
+%
+% Overwrite in subclasses if necessary.
+\def\pgfplotspointouternormalvectorofaxis@ifdependson@v#1#2#3{#3}
+
+\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@vaxis{x}%
+ \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@vaxis{y}%
+ \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@vaxis{z}%
+ \def\pgfplots@loc@baxis{x}%
+ \def\pgfplots@loc@naxis{y}%
+ \fi
+ \fi
+ %
+ \pgfplotspointouternormalvectorofaxis@get@otheraxis@sign{\pgfplots@loc@vaxis}{\pgfplots@loc@baxis}{\pgfplots@loc@char@for@baxis}%
+ \let\pgfplots@loc@baxissign=\pgfplotsretval
+ %
+ \pgfplotspointouternormalvectorofaxis@get@otheraxis@sign{\pgfplots@loc@vaxis}{\pgfplots@loc@naxis}{\pgfplots@loc@char@for@naxis}%
+ \let\pgfplots@loc@naxissign=\pgfplotsretval
+ %
+ %
+ % ok, compute vector scales:
+ \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}%
+ }%
+ \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
+}%
+
+% #1: the axis for which we want the "outer normal".
+% #2: the "other axis" for which we seek the sign.
+% #3: the entry in the three-char-identifier which corresponds to
+% "other axis".
+\def\pgfplotspointouternormalvectorofaxis@get@otheraxis@sign#1#2#3{%
+ \ifcase#3\relax%
+ % case 0:
+ % 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\pgfplotsretval{-}%
+ \or
+ % case 1:
+ % in this case, the OUTSIDE area requires a plus sign - the b
+ % axis already points to the inside.
+ \def\pgfplotsretval{+}%
+ \or
+ % case 2: we have the 'axis lines=centered' case.
+ %
+ % This case is complicated. The problem is that we do not know
+ % if we are at the top or bottom limit.
+ %
+ % BUT: we know what we would have done if this would be a
+ % normal boxed axis!
+ %
+ % The idea is to return the same normal vector as if this would be a boxed axis.
+ % To this end, we have to access the "ticklabel axis spec"
+ % which would have been used in this case.
+ %
+ % We computed it at startup. Might be a hack ... :-(
+ \edef\pgfplots@loc@TMPb{\csname pgfplots@#1ticklabelaxisspec@box\endcsname}%
+ %
+ % decode it: we have to replace '#3' by the value that it has
+ % in that boxed ticklabel axis spec!
+ \def\pgfplots@loc@TMPa##1##2##3{%
+ % search for the correct entry.
+ \if x#2\def\pgfplotsretval{##1}\fi
+ \if y#2\def\pgfplotsretval{##2}\fi
+ \if z#2\def\pgfplotsretval{##3}\fi
+ }%
+ \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ %
+ \if 2\pgfplotsretval
+ \pgfplots@error{internal assertion failed.}%
+ \fi
+ %
+ % invoke it again!
+ \pgfplotspointouternormalvectorofaxis@get@otheraxis@sign{#1}{#2}{\pgfplotsretval}%
+ \fi
+}
+
+% 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{%
+ %
+ \def\pgfplotspointoutsideofaxis@lineshift{}%
+ %
+ \if v#1%
+ \pgfplotspointoutsideofaxis@plug@getlimit{y}{#2}\let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@loc@TMPa}{#2}%
+ \def\pgfplotspointoutsideofaxis@lineshift{x}%
+ %
+ \pgfplotspointonorientedsurfaceabsetupfor xzy%
+ \pgfplotspointoutsideofaxis@plug@trafo{x}{#4}\let\pgfplots@loc@A=\pgfmathresult
+ \ifpgfplots@threedim
+ \pgfplotspointoutsideofaxis@plug@getlimit{z}{#3}\let\pgfplots@loc@B=\pgfmathresult
+ \else
+ \def\pgfplots@loc@B{0}%
+ \fi
+ \else
+ \if v#2%
+ \ifpgfplots@threedim
+ \pgfplotspointoutsideofaxis@plug@getlimit{z}{#3}\let\pgfplots@loc@TMPa=\pgfmathresult
+ \else
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@loc@TMPa}{#3}%
+ %
+ \pgfplotspointonorientedsurfaceabsetupfor yxz%
+ \pgfplotspointoutsideofaxis@plug@trafo{y}{#4}\let\pgfplots@loc@A=\pgfmathresult
+ \pgfplotspointoutsideofaxis@plug@getlimit{x}{#1}\let\pgfplots@loc@B=\pgfmathresult
+ \def\pgfplotspointoutsideofaxis@lineshift{y}%
+ \else
+ \pgfplotspointoutsideofaxis@plug@getlimit{x}{#1}\let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@loc@TMPa}{#1}%
+ %
+ \pgfplotspointonorientedsurfaceabsetupfor zyx%
+ \ifpgfplots@threedim
+ \pgfplotspointoutsideofaxis@plug@trafo{z}{#4}\let\pgfplots@loc@A=\pgfmathresult
+ \else
+ \def\pgfplots@loc@A{0}%
+ \fi
+ \pgfplotspointoutsideofaxis@plug@getlimit{y}{#2}\let\pgfplots@loc@B=\pgfmathresult
+ \def\pgfplotspointoutsideofaxis@lineshift{z}%
+ \fi
+ \fi
+ %
+ % read dimen argument #5:
+ \afterassignment\pgfplots@gobble@until@relax
+ \pgf@xa=#5pt\relax
+ %
+ \pgfkeysgetvalue{/pgfplots/axis \pgfplotspointoutsideofaxis@lineshift\space line shift}\pgfmathresult
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \advance\pgf@xa by \pgfmathresult pt %
+ \fi
+ %
+ \edef\pgfplots@loc@distalong@normal{\pgf@sys@tonumber\pgf@xa}%
+ %
+%\message{pgfplotspointoutsideofaxis{#1#2#3}{#4}{#5}: A = \pgfplots@loc@A, B = \pgfplots@loc@B.^^J}%
+ %
+ \pgf@process{%
+ \pgfpointadd
+ {\pgfplotspointonorientedsurfaceab{\pgfplots@loc@A}{\pgfplots@loc@B}}
+ {%
+ \pgfplotspointouternormalvectorofaxissetv{#1#2#3}{\pgfplots@loc@A}%
+ \pgfqpointscale
+ {\pgfplots@loc@distalong@normal}%
+ {\pgfplotspointouternormalvectorofaxis{#1#2#3}}%
+ }%
+ }%
+ \endgroup
+}%
+%--------------------------------------------------
+% \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: o(\pgfplots@loc@TMPa - \pgfplots@loc@TMPb) ne 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
+ \else
+ \expandafter\let\expandafter\pgfmathresult\csname pgfplots@logical@ZERO@#1\endcsname
+ \fi
+ \fi
+}%
+
+\newif\ifpgfplots@sloped
+\pgfplots@slopedtrue % its only purpose is to *DEACTIVATE* the sloped transformation after it has been activated.
+\newif\ifpgfplots@sloped@resets@nontranslations
+\newif\ifpgfplots@sloped@allowupsidedown
+\pgfkeys{
+ /pgfplots/sloped/true/.code={\pgfplots@slopedtrue},
+ /pgfplots/sloped/false/.code={\pgfplots@slopedfalse},
+ /pgfplots/sloped/allow upside down/.is if=pgfplots@sloped@allowupsidedown,
+ /pgfplots/sloped/allow upside down/.default=true,
+ /pgfplots/sloped/execute for upside down/.initial=,
+ /pgfplots/sloped/reset nontranslations/.is if=pgfplots@sloped@resets@nontranslations,
+ /pgfplots/sloped/reset nontranslations/.default=true,
+ %
+ % only used by polar axes at the time of this writing:
+ /pgfplots/sloped/at position/.initial=,
+}
+% Installs a rotation transformation matrix such that labels or
+% whatever are aligned precisely in direction of one of the two/three
+% coordinate directions.
+%
+% \pgfplotstransformtoaxisdirection[<options>]{<axis char>}
+%
+% <axis char>: 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 uses \ifpgfplots@sloped@allowupsidedown (=false) and
+% \ifpgfplots@sloped@resets@nontranslations (= true). The default
+% setting is reinitialised before options are processed
+\def\pgfplotstransformtoaxisdirection{%
+ \pgfutil@ifnextchar[{\pgfplotstransformtoaxisdirection@}{\pgfplotstransformtoaxisdirection@[]}%
+}%
+\def\pgfplotstransformtoaxisdirection@[#1]#2{%
+ \pgfplots@sloped@allowupsidedownfalse
+ \pgfplots@sloped@resets@nontranslationstrue
+ %
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfqkeys{/pgfplots/sloped}{#1}%
+ \fi
+ \ifpgfplots@sloped
+ %
+ \ifpgfplots@sloped@resets@nontranslations
+ \pgftransformresetnontranslations
+ \fi
+ %
+ % compute unit length vector pointing into the direction of
+ % '#1#2#3':
+ \pgfqpointscale{\csname pgfplotsunit#2invlength\endcsname}{\csname pgfplotspointunit#2\endcsname}%
+ %
+ \ifdim\pgf@x<0pt%
+ % oh. upside down.
+ \pgfkeysvalueof{/pgfplots/sloped/execute for upside down}%
+ \ifpgfplots@sloped@allowupsidedown
+ \else
+ % do not allow upside down labels:
+ \global\pgf@x=-\pgf@x%
+ \global\pgf@y=-\pgf@y%
+ \fi
+ \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}%
+ \fi
+}
+
+
+% 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}{\pgfplots@borderanchor@for@axis{#1}{#2}{##1}}%
+ \pgfdeclaregenericanchor{#3 opposite}{\pgfplots@borderanchor@for@axis@{#1}{#2}{##1}{+1}}%
+ %
+ % 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
+ }%
+ }%
+ }%
+}%
+
+% this does the work for \pgfplotsdeclareborderanchorforaxis.
+%
+% It depends on \pgfplotspointunit[xyz] and
+% \pgfplotspointouternormalvectorofaxis
+%
+% #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 shape, provided as argument by the pgf routine invoking the
+% anchor.
+\def\pgfplots@borderanchor@for@axis#1#2#3{%
+ \pgfplots@borderanchor@for@axis@{#1}{#2}{#3}{-1}%
+}
+% same as \pgfplots@borderanchor@for@axis{#1}{#2}{3} except that #4 is
+% the SIGN for the outer normal.
+%
+% #4: the sign for the outer normal. #4=-1 means "use inner normal"
+% and +1 means "use outer normal"
+\def\pgfplots@borderanchor@for@axis@#1#2#3#4{%
+ \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
+ %
+ \pgfplotspointouternormalvectorofaxisgetv{#2}%
+ \ifx\pgfplotsretval\pgfutil@empty
+ \pgfkeysgetvalue{/pgfplots/near ticklabel at}\pgfplotsretval
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ % ah - we have one!
+ \csname pgfplotstransformcoordinate#1\endcsname{\pgfplotsretval}%
+ \pgfplotspointouternormalvectorofaxissetv{#2}{\pgfmathresult}%
+ \fi
+ \fi
+ %
+ % This here is the normal direction (points to the axis)
+ \pgfqpointscale{#4}{\pgfplotspointouternormalvectorofaxis{#2}}%
+ %
+ % we apply the inverse CM onto it here:
+ \pgf@pos@transform\pgf@x\pgf@y
+ \edef\pgfplots@tmp@normaldir{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfplots@borderanchor@snap@to@nearest@anchor{}% takes \pgf@x and \pgf@y
+ \let\pgfplots@anchor=\pgfplotsretval
+ %
+ % 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:
+ %
+ % 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 :-(
+ %
+ % UPDATE: I realized that using the 'center' anchor might be too
+ % restrictive. See the 'near ticklabel align' key.
+ %
+ % Note that this is actually too much work for the 2d case - I
+ % guess it would be more efficient without it. But for 3d, it
+ % really rocks.
+ %
+ % 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 for the intersection of two lines).
+ % Scale unit vector to length 1 to improve conditioning:
+ \pgfqpointscale
+ {\csname pgfplotsunit#1invlength\endcsname}
+ {\csname pgfplotspointunit#1\endcsname}%
+ % FIXME : shouldn't the values be copied AFTER the CM!?
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgf@pos@transform\pgf@xa\pgf@ya
+ %
+ \ifcase\pgfplots@borderanchor@align\relax
+ % near ticklabel align=inside:
+ % make sure that we are close to the beginning of the axis
+ % direction vector.
+ \pgfplots@borderanchor@snap@to@nearest@anchor{%
+ \if\pgfkeysvalueof{/pgfplots/#1 dir/value}n%
+ % simply take \pgf@x and \pgf@y as-is.
+ \else
+ \global\pgf@x=-\pgf@x
+ \global\pgf@y=-\pgf@y
+ \fi
+ }%
+ \or
+ % near ticklabel align=center:
+ \def\pgfplotsretval{center}% Ah. simple.
+ \or
+ % near ticklabel align=outside:
+ % make sure that we are far away from the beginning of the
+ % axis direction vector.
+ \pgfplots@borderanchor@snap@to@nearest@anchor{%
+ \if\pgfkeysvalueof{/pgfplots/#1 dir/value}n%
+ \global\pgf@x=-\pgf@x
+ \global\pgf@y=-\pgf@y
+ \else
+ % simply take \pgf@x and \pgf@y as-is.
+ \fi
+ }%
+ \fi
+ \let\pgfplots@anchor@inner=\pgfplotsretval
+ %
+ %
+ % verify that |n^T d |
+ \pgf@xc=\pgf@sys@tonumber\pgf@xa\pgf@xb
+ \advance\pgf@xc by\pgf@sys@tonumber\pgf@ya\pgf@yb
+ \ifdim\pgf@xc<0pt \pgf@xc=-\pgf@xc \fi
+ \ifdim\pgf@xc<0.8pt
+ % ok. 'n' and 'd' are not parallel.
+ %
+ \edef\pgfplots@LEQ{%
+ % solve linear system
+ % a11 a12
+ % a21 a22
+ {\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@xa}%
+ {\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@ya}%
+ }%
+ %
+ % This here controls the anchor! Changing it might be more
+ % useful than I thought in the first place...
+ \pgf@sh@reanchor{#3}{\pgfplots@anchor@inner}%
+ \edef\pgfplots@loc@center{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ %
+ % apply inverse matrix to right-hand-side (and compute RHS):
+ \pgfpointdiff% {<start>}{<end>} -> computes <end> - <start>
+ {\pgfplots@loc@center}%
+ {\pgf@sh@reanchor{#3}{\pgfplots@anchor}}%
+ \edef\pgfplots@RHS{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}%
+ %
+ \pgfutilsolvetwotwoleq{\pgfplots@LEQ}{\pgfplots@RHS}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfplots@error{Singular matrix encountered while computing boundary anchor. Please choose different values.}%
+ \def\pgfmathresult{0}{0}%
+ \fi
+ \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}}%
+ \else
+ \pgfplotswarning{ticklabel anchor undetermined}{#1}{\the\pgf@xb,\the\pgf@yb}{\the\pgf@xa,\the\pgf@ya}{\the\pgf@xc}\pgfeov
+ % Something went awry: normal and unit#1 are almost parallel!?
+ % just use the determined anchor.
+ \def\pgfplots@r{0}%
+ \pgf@sh@reanchor{#3}{\pgfplots@anchor}%
+ \fi
+%\message{==========>>>>>>>>>> I got finally (\the\pgf@x,\the\pgf@y). <<<<<<<<<===================}%
+ \pgf@process{}% <- transport outside of group
+ \endgroup
+}%
+
+% #1: a direction vector.
+%
+% assigns the resulting anchor to \pgfplotsretval
+\def\pgfplots@borderanchor@snap@to@nearest@anchor#1{%
+ \begingroup
+ #1%
+ % 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).
+ %
+ % This is kind of a snap-to-nearest-existing-anchor feature. But
+ % it tends to move the node too far away. It is used as starting
+ % point; we will refine it in the next step.
+ %
+ % This is a heuristicial procedure.
+ %
+ % Note that it does not hurt if there are "multiple best matches"
+ % (for example because they lie on the same line).
+ % The code below will move the final anchor point.
+ %
+ \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\pgfplotsretval{%
+ \pgfplots@ycomp
+ \ifx\pgfplots@ycomp\pgfutil@empty
+ \else
+ \ifx\pgfplots@xcomp\pgfutil@empty
+ \else
+ \space
+ \fi
+ \fi
+ \pgfplots@xcomp
+ }%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}
+
+\def\pgfplotspointviewdir{%
+ %\pgfplotsmathvectordatascaletrafoinverse{\pgfplots@view@dir@threedim}{default}%
+ \let\pgfplotsretval=\pgfplots@view@dir@threedim
+ \pgfplotspointfromcsvvector{\pgfplotsretval}{default}%
+}%
+
+\def\message@pgfplots@units{%
+ \begingroup
+ \pgfmathparse{veclen(\pgf@zx,\pgf@zy)}\let\Z=\pgfmathresult
+ \ifdim\Z pt=0pt
+ \def\Z{1}%
+ \fi
+ \pgfmathparse{veclen(\pgf@xx,\pgf@xy)/\Z}\let\X=\pgfmathresult
+ \pgfmathparse{veclen(\pgf@yx,\pgf@yy)/\Z}\let\Y=\pgfmathresult
+ \expandafter\ifx\csname pgfplots@view@dir@threedim\endcsname\relax
+ \def\normal{view = (---),^^J}%
+ \else
+ \pgfplotsmathvectortostring{\pgfplots@view@dir@threedim}{default}%
+ \edef\normal{view = (\pgfplotsretval),^^J}%
+ \fi
+ \message{^^J
+ x = (\the\pgf@xx,\the\pgf@xy),^^J
+ y =(\the\pgf@yx,\the\pgf@yy),^^J
+ z = (\the\pgf@zx,\the\pgf@zy),^^J
+ \normal
+ unit vector ratio=[\X\space\Y\space 1],^^J}%
+ \endgroup
+}%
+
+
+% ==================================================================================
+%
+% COORDINATE MATH.
+%
+% ==================================================================================
+
+% Declares a new "subclass" to perform coordinate math.
+%
+% Coordinate math usually needs a more powerful number format than the pgf
+% basic layer, or at least a powerful mapping into the pgf basic
+% layer. Both cases are realized by the coordinate math class.
+%
+% Different coordinates can use different instances, and it is also
+% possible to use yet a further instance for point meta (or whatever).
+%
+% Coordinate math is used to compute axis limits and to map the range
+% into the pgf number format.
+%
+% It is *not* necessarily used for \pgfmathparse, since switching
+% the number format of \pgfmathparse is quite involved (at the time of
+% this writing). Instead, it is used for *single* operations (like
+% max, min, multiply, add).
+%
+% #1: the name of the coord math class
+% #2: methods to override the default.
+%
+% The available methods are documented and shown below in the
+% \pgfqkeys listing.
+%
+% @see the predefined examples, also shown below.
+\def\pgfplotsdeclarecoordmath#1#2{%
+ \edef\pgfplotsdeclarecoordmath@{@#1@}%
+ \pgfqkeys{/pgfplots/@declare coord math}{%
+ initialise=,
+ parse=\edef\pgfmathresult{##1}\expandafter\pgfmathparse\expandafter{\pgfmathresult},
+ parse int={%
+ \begingroup
+ \pgfplotscoordmath{\pgfplotscoordmathid}{parse}{##1}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{tofixed}{\pgfmathresult}%
+ \afterassignment\pgfplots@gobble@until@relax
+ \c@pgf@countd=\pgfmathresult\relax
+ \edef\pgfmathresult{\the\c@pgf@countd}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ },
+ parsenumber=\pgfmathfloatparsenumber{##1}\pgfmathfloattofixed{##1},%
+ zero= \pgfplotscoordmath{\pgfplotscoordmathid}{parsenumber}{0},
+ one= \pgfplotscoordmath{\pgfplotscoordmathid}{parsenumber}{1},
+ -one= \pgfplotscoordmath{\pgfplotscoordmathid}{parsenumber}{-1},
+ log e= \pgfmathlog@{##1},%
+ log to display log=\pgfmath@basic@multiply@{##1}{2.3025851},% * log(10)
+ log from display log=\pgfmath@basic@multiply@{##1}{0.434294},% / log(10)
+ log unsigned int={%
+ \edef\pgfmathresult{%
+ \ifcase##1
+ \or0
+ \or0.693147
+ \or1.098612
+ \or1.386294
+ \or1.60943791
+ \or1.7917594
+ \or1.94591014
+ \or2.07944154
+ \or2.197224
+ \fi
+ }%
+ },
+ set log basis=\edef\pgfmathresult{{#1}{##1}}\expandafter\pgfplotscoordmath@log@set@basis\pgfmathresult,
+ exp e={%
+ % make sure the exponential can be represented, i.e. use
+ % 'float' in the default repr:
+ \pgfmathfloatparsenumber{##1}%
+ \pgfmathfloatexp@\pgfmathresult%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{parsenumber}{\pgfmathresult}%
+ },
+ tofixed= \edef\pgfmathresult{##1},%
+ tostring= \edef\pgfmathresult{##1},%
+ max= \pgfplotsmathmax{##1}{##2},%
+ min= \pgfplotsmathmin{##1}{##2},%
+ min limit= \def\pgfmathresult{-16300},%
+ max limit= \def\pgfmathresult{16300},%
+ if less than= {\pgfplotsmathlessthan{##1}{##2}\ifpgfmathfloatcomparison ##3\else ##4\fi},
+ if is= {%
+ \if##20%
+ \ifdim##1pt=0pt ##3\else ##4\fi
+ \else
+ \if##2+\ifdim##1pt>0pt ##3\else ##4\fi
+ \else
+ \if##2-\ifdim##1pt<0pt ##3\else ##4\fi
+ \else
+ \def\pgfplots@loc@TMPd{##1}\ifx\pgfplots@loc@TMPd\pgfutil@empty ##3\else ##4\fi
+ \fi
+ \fi
+ \fi
+ },%
+ if is bounded=\edef\pgfplotsretval{##1}\ifx\pgfplotsretval\pgfutil@empty ##3\else ##2\fi,
+ suffix= #1,%
+ datascaletrafo set params=,
+ datascaletrafo get params= \def\pgfmathresult{{0}{0}}\def\pgfplotsretval{0}\def\pgfplotsretvalb{0},
+ datascaletrafo= \edef\pgfmathresult{##1},
+ datascaletrafo inverse= \edef\pgfmathresult{##1},
+ datascaletrafo noshift inverse= \edef\pgfmathresult{##1},
+ datascaletrafo inverse to fixed= \edef\pgfmathresult{##1},
+ datascaletrafo noshift inverse to fixed= \edef\pgfmathresult{##1},
+ datascaletrafo noshift= \edef\pgfmathresult{##1},
+ datascaletrafo undo shift= \edef\pgfmathresult{##1},
+ datascaletrafo redo shift= \edef\pgfmathresult{##1},
+ #2%
+ }%
+ \expandafter\edef\csname pgfpmth\pgfplotsdeclarecoordmath@ op\endcsname##1##2{%
+ \noexpand\edef\noexpand\pgfplotscoordmath@{##2}%
+ \noexpand\expandafter\noexpand\expandafter\noexpand\csname pgfmath\csname pgfpmth@#1@suffix\endcsname ##1@\noexpand\endcsname\noexpand\pgfplotscoordmath@
+ }%
+ %
+ %
+ % these log function depend on the first argument of
+ % \pgfplotscoordmath{}, which is available as
+ % \pgfplotscoordmathid.
+ \pgfplotsutilforeachcommasep{%
+ exp,%
+ log,%
+ log to display log,%
+ log from display log,%
+ log to log 10,%
+ log unsigned int}\as\pgfplots@loc@TMPa
+ {%
+ \expandafter\edef\csname pgfpmth\pgfplotsdeclarecoordmath@\pgfplots@loc@TMPa\endcsname{%
+ % invoke \pgfpmth@#1@@<name>@<function>
+ % for example
+ % \pgfpmth@pgfbasic@@y@log
+ \noexpand\csname pgfpmth\pgfplotsdeclarecoordmath@ @\noexpand\pgfplotscoordmathid @\pgfplots@loc@TMPa\noexpand\endcsname
+ }%
+ }%
+ %
+ \pgfutil@ifundefined{pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log}{%
+ \pgfutil@namelet
+ {pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log}
+ {pgfpmth\pgfplotsdeclarecoordmath@ log e}%
+ }{}%
+ \pgfutil@ifundefined{pgfpmth\pgfplotsdeclarecoordmath@ tmpl@exp}{%
+ \pgfutil@namelet
+ {pgfpmth\pgfplotsdeclarecoordmath@ tmpl@exp}
+ {pgfpmth\pgfplotsdeclarecoordmath@ exp e}%
+ }{}%
+ \pgfplotscoordmath@def@log@to@log@ten{#1}{}{tmpl}% empty arg
+ %
+}%
+\pgfqkeys{/pgfplots/@declare coord math}{%
+ initialise/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ initialise\endcsname{#1%
+ \pgfplotscoordmath@initialise@logs
+ }},%
+ % takes a number literal as input and defines \pgfmathresult to be
+ % the parsed result.
+ parsenumber/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ parsenumber\endcsname##1{#1}},%
+ %
+ zero/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ zero\endcsname{#1}},%
+ one/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ one\endcsname{#1}},%
+ -one/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ -one\endcsname{#1}},%
+ %
+ % Calls pgfmathparse. Note that this might need to switch to the
+ % required math library (which is not necessarily cheap)
+ parse/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ parse\endcsname##1{#1}},%
+ parse int/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ parse int\endcsname##1{#1}},%
+ %
+ % takes a parsed number and returns a fixed point number:
+ tofixed/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ tofixed\endcsname##1{#1}},%
+ %
+ % chooses a human readable string (which can be processed by parsenumber):
+ tostring/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ tostring\endcsname##1{#1}},%
+ %
+ % defines a max routine which returns the max of *exactly* two numbers:
+ max/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ max\endcsname##1##2{#1}},%
+ %
+ % counterpart for max:
+ min/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ min\endcsname##1##2{#1}},%
+ %
+ % defines \pgfmathresult to be the largest supported number.
+ max limit/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ max limit\endcsname{#1}},%
+ %
+ % defines \pgfmathresult to be the smallest supported number.
+ min limit/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ min limit\endcsname{#1}},%
+ %
+ % computes ##1 < ##2 and invokes ##3 in the true case and ##4 in
+ % the false case.
+ if less than/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ if less than\endcsname##1##2##3##4{#1}},%
+ % checks if ##1 is 0, positive, negative or unbounded
+ % ##1: the number to check
+ % ##2: either 0 or + or - or u (u = unbounded)
+ % ##3: true code
+ % ##4: false code
+ if is/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ if is\endcsname##1##2##3##4{#1}},%
+ %
+ % Checks if the argument ##1 is bounded and invokes ##2 in that
+ % case. IF the argument is unbounded, it invokes #3.
+ if is bounded/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ if is bounded\endcsname##1##2##3{#1}},%
+ %
+ % applies the natural logarithm. If the log is not defined, the
+ % argument is "unbounded", see 'if is bounded'
+ %
+ % 'log' is special in that it accepts a number literal which may
+ % be OUTSIDE of the accepted number format. The result, however, is
+ % then in the accepted number format.
+ log e/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ log e\endcsname##1{#1}},%
+ %
+ % Similar, but the log basis can be set with 'set log basis'.
+ % This allows \pgfplotscoordmath{x}{log}{} to use a different log
+ % basis thatn \pgfplotscoordmath{y}{log}{} (with special handling)
+ log/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log\endcsname##1{#1}},%
+ % applies a *scale* from the actual log basis to the actual
+ % *display* log basis. The display log basis is usually 10, unless
+ % the log basis has been changed.
+ log to display log/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log to display log\endcsname##1{#1}},%
+ % applies a *scale* from the displau log basis to the actual
+ % log basis (the inverse of `log to display log').
+ log from display log/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log from display log\endcsname##1{#1}},%
+ log to log 10/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log to log 10\endcsname##1{#1}},%
+ % returns log(i) where i \in {1,2,3,...,basis-1}
+ % currently, it is only invoked for log basis 10
+ log unsigned int/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log unsigned int\endcsname##1{#1}},%
+ % sets (changes) the actual log basis.
+ set log basis/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ set log basis\endcsname##1{#1}},%
+ %
+ % The inverse to 'log e '.
+ exp e/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ exp e\endcsname##1{#1}},%
+ %
+ % The inverse to 'log'. It also uses the correct log basis.
+ exp/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ tmpl@exp\endcsname##1{#1}},%
+ %
+ % A macro taking two parameters:
+ % #1: the EXPONENT (as integer)
+ % #2: the SHIFT (as fixed point number)
+ %
+ % After any change, \pgfplotscoordmathnotifydatascalesetfor{<id>} will be
+ % invoked where <id> is the argument to
+ % \pgfplotscoordmath{<id>}...
+ datascaletrafo set params/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo set params\endcsname##1##2{%
+ #1\relax\pgfplotscoordmathnotifydatascalesetfor{\pgfplotscoordmathid}%
+ }},%
+ datascaletrafo set shift/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo set shift\endcsname##1{%
+ #1\relax\pgfplotscoordmathnotifydatascalesetfor{\pgfplotscoordmathid}%
+ }},%
+ %
+ % Defines \pgfmathresult to contain the two parameters in the form
+ % {#1}{#2} required for 'datascaletrafo set params':
+ % #1: the EXPONENT (as integer)
+ % #2: the SHIFT (as fixed point number)
+ % AND \pgfplotsretval as the EXPONENT and \pgfplotsretvalb as the SHIFT
+ datascaletrafo get params/.code={%
+ \expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo get params\endcsname{#1}%
+ },%
+ datascaletrafo/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo\endcsname##1{#1}},%
+ datascaletrafo inverse/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo inverse\endcsname##1{#1}},%
+ datascaletrafo noshift inverse/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo noshift inverse\endcsname##1{#1}},%
+ datascaletrafo inverse to fixed/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo inverse to fixed\endcsname##1{#1}},%
+ datascaletrafo noshift inverse to fixed/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo noshift inverse to fixed\endcsname##1{#1}},%
+ datascaletrafo noshift/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo noshift\endcsname##1{#1}},%
+ datascaletrafo noshift/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo noshift\endcsname##1{#1}},%
+ datascaletrafo undo shift/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo undo shift\endcsname##1{#1}},%
+ datascaletrafo redo shift/.code=
+ {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo redo shift\endcsname##1{#1}},%
+ %
+ % defines a suffix such that
+ % \csname pgfmath<suffix><op>@\endcsname
+ % exists. Example: <suffix>=float --> \pgfmathfloatmultiply@ for <op>=multiply
+ suffix/.code=
+ {\expandafter\edef\csname pgfpmth\pgfplotsdeclarecoordmath@ suffix\endcsname{#1}},%
+}%
+
+\def\pgfplotscoordmath@initialise@logs{%
+ \edef\pgfplotsdeclarecoordmath@{@\pgfplotscoordmathclassfor{\pgfplotscoordmathid}@}%
+ \pgfutil@ifundefined{pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @log}{%
+ \pgfplotsutilforeachcommasep{%
+ exp,%
+ log,%
+ log to display log,%
+ log from display log,%
+ log to log 10,%
+ log unsigned int}\as\pgfplots@loc@TMPa
+ {%
+ \pgfutil@namelet
+ {pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @\pgfplots@loc@TMPa}
+ {pgfpmth\pgfplotsdeclarecoordmath@ tmpl@\pgfplots@loc@TMPa}%
+ }%
+ }{}%
+}%
+
+% shared implementation for 'set log basis' It works for every
+% subclass.
+\def\pgfplotscoordmath@log@set@basis#1#2{%
+ \edef\pgfplotsdeclarecoordmath@{@#1@}%
+ %
+ \pgfplotscoordmath{\pgfplotscoordmathid}{log e}{#2}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult% TMPa = log_e(#2)
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{reciprocal}{{\pgfmathresult}}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult% TMPb = 1/log_e(#2)
+ %
+ % log_a(x) = log_e(x) / log_e(a)
+ \expandafter\edef\csname pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @log\endcsname##1{%
+ \noexpand\pgfplotscoordmath{\pgfplotscoordmathid}{log e}{##1}%
+ \noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty
+ \noexpand\else
+ \noexpand\pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{%
+ {\noexpand\pgfmathresult}%
+ {\pgfplots@loc@TMPb}%
+ }%
+ \noexpand\fi
+ }%
+ %
+ % a^x = exp(log_e(a^x)) = exp(x*log_e(a))
+ \expandafter\edef\csname pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @exp\endcsname##1{%
+ \noexpand\edef\noexpand\pgfmathresult{##1}%
+ \noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty
+ \noexpand\else
+ \noexpand\pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{%
+ {\noexpand\pgfmathresult}%
+ {\pgfplots@loc@TMPa}%
+ }%
+ \noexpand\pgfplotscoordmath{\pgfplotscoordmathid}{exp e}{\noexpand\pgfmathresult}%
+ \noexpand\fi
+ }%
+ \expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @log to display log\endcsname##1{\edef\pgfmathresult{##1}}%
+ \expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @log from display log\endcsname##1{\edef\pgfmathresult{##1}}%
+ %
+ % compute 'log unsigned int' for the new basis.
+ %
+ % Idea: re-scale the old implementation (of basis e for i = 1,...,9)
+ % and re-compute i>=10 :
+ \begingroup
+ \expandafter\let\expandafter\logi\csname pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log unsigned int\endcsname
+ \let\logscale=\pgfplots@loc@TMPb
+ %
+ \logi{1}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@1\endcsname=\pgfmathresult
+ %
+ \logi{2}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@2\endcsname=\pgfmathresult
+ %
+ \logi{3}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@3\endcsname=\pgfmathresult
+ %
+ \logi{4}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@4\endcsname=\pgfmathresult
+ %
+ \logi{5}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@5\endcsname=\pgfmathresult
+ %
+ \logi{6}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@6\endcsname=\pgfmathresult
+ %
+ \logi{7}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@7\endcsname=\pgfmathresult
+ %
+ \logi{8}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@8\endcsname=\pgfmathresult
+ %
+ \logi{9}%
+ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{multiply}{{\pgfmathresult}{\logscale}}%
+ \expandafter\let\csname logi@@9\endcsname=\pgfmathresult
+ %
+ \xdef\pgfplots@glob@TMPa##1{%
+ \noexpand\ifcase##1
+ \noexpand\def\noexpand\pgfmathresult{}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@1\endcsname}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@2\endcsname}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@3\endcsname}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@4\endcsname}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@5\endcsname}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@6\endcsname}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@7\endcsname}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@8\endcsname}%
+ \noexpand\or\noexpand\def\noexpand\pgfmathresult{\csname logi@@9\endcsname}%
+ \noexpand\else
+ \noexpand\pgfplotscoordmath{\pgfplotscoordmathid}{log}{##1}%
+ \noexpand\fi
+ }%
+ \endgroup
+ \expandafter\let\csname pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @log unsigned int\endcsname=\pgfplots@glob@TMPa
+ \pgfplotscoordmath@def@log@to@log@ten{#1}\pgfplots@loc@TMPa{\pgfplotscoordmathid}%
+ %
+ \pgfutil@namelet
+ {pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @log to log 10}
+ {pgfpmth\pgfplotsdeclarecoordmath@ tmpl@log to log 10}%
+}%
+% #1: the coord math class
+% #2: either empty (basis e) or 1/ln(basis)
+% #3: either 'tmpl' or '\pgfplotscoordmathid. It defines the target
+% macro name (see the source code)
+\def\pgfplotscoordmath@def@log@to@log@ten#1#2#3{%
+ \csname pgfpmth@#1@parsenumber\endcsname{0.434294}%
+ \edef\pgfplots@loc@TMPa{#2}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % log basis e ---> log basis 10
+ % log_10 x = log x / log(10)
+ \else
+ % log basis a ---> log basis 10
+ %
+ % log_a x = log x / log a
+ % log_10 x = log_a x * log a / log(10) = log x / log(10) [OK]
+ \csname pgfpmth@#1@op\endcsname{multiply}{{#2}{\pgfmathresult}}%
+ \fi
+ \expandafter\edef\csname pgfpmth@#1@#3@log to log 10\endcsname##1{%
+ \noexpand\pgfplotscoordmath{\noexpand\pgfplotscoordmathid}{op}{multiply}{{##1}{\pgfmathresult}}%
+ }%
+}%
+
+% Assumes that #2 is a macro, parses it as number with "coord math choice" #1, and overwrites it with the result.
+\def\pgfplotscoordmathparsemacro#1#2{%
+ \pgfplotscoordmath{#1}{parsenumber}{#2}\let#2=\pgfmathresult
+}%
+
+
+\pgfplotsdeclarecoordmath{pgfbasic}{%
+ parsenumber={%
+ \pgfmathfloatparsenumber{#1}%
+ \expandafter\pgfmathfloatgetflagstomacro\expandafter{\pgfmathresult}\pgfplotsretval
+ \ifnum\pgfplotsretval>2
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ \pgfmathfloattofixed\pgfmathresult
+ \fi
+ },
+ suffix=@basic@,
+ zero=\def\pgfmathresult{0},
+ one=\def\pgfmathresult{1},
+ -one=\def\pgfmathresult{-1},
+}
+\pgfplotsdeclarecoordmath{float}{%
+ initialise=
+ \pgfutil@ifundefined{pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid}{%
+ \expandafter\edef\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname{0}%
+ \expandafter\edef\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname{0}%
+ }{},
+ parsenumber=\pgfmathfloatparsenumber{#1},
+ parse={%
+ \begingroup
+ \pgfkeys{/pgf/fpu,%
+ /pgf/fpu/output format=float,%
+ }%
+ \edef\pgfmathresult{#1}%
+ \expandafter\pgfmathparse\expandafter{\pgfmathresult}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ },
+ zero=\pgfmathfloatcreate{0}{0.0}{0},%
+ one=\pgfmathfloatcreate{1}{1.0}{0},%
+ -one=\pgfmathfloatcreate{2}{1.0}{0},%
+ tofixed=\pgfmathfloattofixed{#1},
+ tostring=\pgfmathfloattosci{#1},
+ max=\pgfplotsmathfloatmax{#1}{#2},%
+ min=\pgfplotsmathfloatmin{#1}{#2},%
+ max limit=\pgfmathfloatcreate{1}{1.0}{2147483645},%
+ min limit=\pgfmathfloatcreate{2}{1.0}{2147483645},%
+ log e=\pgfmathfloatparsenumber{#1}\pgfmathfloatln@{\pgfmathresult},%
+ if less than=\pgfmathfloatlessthan@{#1}{#2}\ifpgfmathfloatcomparison #3\else #4\fi,
+ if is bounded=%
+ \expandafter\pgfmathfloatgetflagstomacro\expandafter{#1}\pgfplotsretval
+ \ifnum\pgfplotsretval>2 #3\else #2\fi,
+ if is=%
+ \pgfmathfloatifflags{#1}{#2}{#3}{#4},
+ log=\pgfmathlog@float{#1},%
+ datascaletrafo set params={%
+ \expandafter\edef\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname{#1}%
+ \expandafter\edef\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname{#2}%
+ },%
+ datascaletrafo set shift={%
+ \expandafter\edef\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname{#1}%
+ },%
+ datascaletrafo get params={%
+ \edef\pgfplotsretval{\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname}%
+ \edef\pgfplotsretvalb{\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname}%
+ \edef\pgfmathresult{%
+ {\pgfplotsretval}%
+ {\pgfplotsretvalb}%
+ }%
+ },%
+ datascaletrafo={%
+ \edef\pgfmathresult{#1}%
+ \pgfmathfloatshift@\pgfmathresult{\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname}%
+ \pgfmathfloattofixed\pgfmathresult
+ \expandafter\pgfmath@basic@subtract@\expandafter{\pgfmathresult}{\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname}%
+ },%
+ datascaletrafo noshift={%
+ \edef\pgfmathresult{#1}%
+ \pgfmathfloatshift@\pgfmathresult{\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ },%
+ datascaletrafo undo shift=
+ \pgfmath@basic@subtract@{#1}{\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname},%
+ datascaletrafo redo shift=\pgfmath@basic@add@{#1}{\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname},%
+ datascaletrafo inverse={%
+ \pgfplotscoordmath@float@datascaletrafo@inverse{#1}%
+ },%
+ datascaletrafo inverse to fixed={%
+ \pgfplotscoordmath@float@datascaletrafo@inverse{#1}%
+ \pgfmathfloattofixed\pgfmathresult
+ },%
+ datascaletrafo noshift inverse={%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloatshift@{\pgfmathresult}{-\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname}%
+ },%
+ datascaletrafo noshift inverse to fixed={%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloatshift@{\pgfmathresult}{-\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname}%
+ \pgfmathfloattofixed\pgfmathresult
+ },%
+}
+
+\def\pgfplotscoordmath@float@datascaletrafo@inverse#1{%
+ \pgfmath@basic@add@{#1}{\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname}%
+ \let\pgfplots@inverse@datascaletrafo@@shifted=\pgfmathresult
+ \pgfmathapproxequalto@{\pgfplots@inverse@datascaletrafo@@shifted}{0.0}%
+ \ifpgfmathcomparison
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \else
+ \pgfmathfloatparsenumber{\pgfplots@inverse@datascaletrafo@@shifted}%
+ \pgfmathfloatshift@{\pgfmathresult}{-\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname}%
+ \fi
+}%
+
+% Invokes a coordinate math routine.
+%
+% #1: the axis (x,y or z)
+% #2: a method name declared by \pgfplotsdeclarecoordmath (one of
+% 'op', 'parsenumber', 'tofixed' etc)
+% #3-#9: any further arguments required to perform the call to '#2'.
+%
+% \pgfplotscoordmath {x}{op}{multiply}{{<a>}{<b>}}
+% \pgfplotscoordmath {x}{parsenumber}{<a>}
+\def\pgfplotscoordmath#1#2{%
+ \edef\pgfplotscoordmathid{#1}%
+ \csname pgfpmth@\csname pgfcrdmth@#1\endcsname @#2\endcsname}%
+
+\def\pgfplotscoordmathclassfor#1{\csname pgfcrdmth@#1\endcsname}%
+
+\def\pgfplotscoordmathnotifydatascalesetfor#1{}%
+
+% Enables a particular coordinate math class for the label `#1'.
+%
+% #1 a label (usually x,y or z)
+% #2 the coordinate math class (one prepare by
+% \pgfplotsdeclarecoordmath)
+%
+% From this point on, any call to \pgfplotscoordmath{#1}{...}
+% will use the selected math class.
+\def\pgfplotssetcoordmathfor#1#2{%
+ \pgfutil@ifundefined{pgfpmth@#2@initialise}{%
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, \string\pgfplotssetcoordmathfor{#1}{#2} failed since `#2' is unknown. Maybe you misspelled it?}\pgfeov%
+ }{%
+ \expandafter\edef\csname pgfcrdmth@#1\endcsname{#2}%
+ \pgfplotscoordmath{#1}{initialise}%
+ }%
+}%
+
+% Defines \pgfplotsretval to be the coordmath id for #1
+\def\pgfplotsgetcoordmathfor#1{%
+ \pgfutil@ifundefined{pgfcrdmth@#1}{%
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, \string\pgfplotsgetcoordmathfor{#1} failed since `#1' is unknown. Maybe you misspelled it?}\pgfeov%
+ }{%
+ \pgfutil@namelet{pgfplotsretval}{pgfcrdmth@#1}%
+ }%
+}%
+\pgfplotssetcoordmathfor{pgfbasic}{pgfbasic}%
+\pgfplotssetcoordmathfor{float}{float}%
+\pgfplotssetcoordmathfor{meta}{float}%
+\pgfplotssetcoordmathfor{default}{float}%
+
+
+
+% ==================================================================================
+
+
+
+% #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{}
+
+\def\pgfplotsaxisifhaspointmeta#1#2{%
+ \ifx\pgfplotspointmetainputhandler\pgfutil@empty #2\else #1\fi
+}%
+
+\newif\ifpgfplots@perpointmeta@expand
+
+% Executes code '#2' if the point meta data #1 is bounded
+% and '#3' otherwise
+%
+% If the point meta is symbolic, it will always return true if and
+% only if the input is non-empty.
+\def\pgfplotsifpointmetaisbounded#1#2#3{%
+ \ifpgfplots@perpointmeta@expand
+ \edef\pgfplots@loc@TMPc{#1}%
+ \else
+ % symbolic point meta may have expansion issues -- but support one
+ % level as we usually invoke it with a macro name:
+ \expandafter\def\expandafter\pgfplots@loc@TMPc\expandafter{#1}%
+ \fi
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ % an empty meta data is _never_ bounded.
+ #3\relax
+ \else
+ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname
+ % a (non-empty, see above) symbolic meta data is "bounded"
+ #2\relax
+ \else
+ % check the number:
+ \pgfplotscoordmath{meta}{if is bounded}{\pgfplots@loc@TMPc}{#2}{#3}%
+ \fi
+ \fi
+}%
+
+% Invokes '#1' if the axis contains the coordinate designated by
+% \pgfplots@current@point@[xyz] and '#2' if not.
+\def\pgfplotsaxisifcontainspoint#1#2{%
+ \pgf@xa=\pgfplots@current@point@x pt % FIXME : SCOPE REGISTERS!?
+ \pgf@ya=\pgfplots@current@point@y pt %
+ \ifpgfplots@curplot@threedim
+ \pgf@yb=\pgfplots@current@point@z pt %
+ \fi
+ \def\pgfplots@loc@TMPa{#2}%
+ %
+ % I assume that \pgfplots@[xyz]min@reg and min@reg are registers
+ % containing the limits.
+ \ifdim\pgf@xa<\pgfplots@xmin@reg
+ \else
+ \ifdim\pgf@xa>\pgfplots@xmax@reg
+ \else
+ \ifdim\pgf@ya<\pgfplots@ymin@reg
+ \else
+ \ifdim\pgf@ya>\pgfplots@ymax@reg
+ \else
+ \ifpgfplots@curplot@threedim
+ \ifdim\pgf@yb<\pgfplots@zmin@reg
+ \else
+ \ifdim\pgf@yb>\pgfplots@zmax@reg
+ \else
+ \def\pgfplots@loc@TMPa{#1}%
+ \fi
+ \fi
+ \else
+ \def\pgfplots@loc@TMPa{#1}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \pgfplots@loc@TMPa%
+}
+
+% 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, which
+% are described below, in the key definitions.
+%
+% #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{%
+ \pgfplots@pointmeta@set@expand{#1}%
+ }%
+ \expandafter\def\csname pgfpmeta@#1@issymbolic\endcsname{0}%
+ \expandafter\def\csname pgfpmeta@#1@explicitinput\endcsname{0}%
+ \expandafter\def\csname pgfpmeta@#1@activate\endcsname{}%
+ \expandafter\def\csname pgfpmeta@#1@LUA class\endcsname{}%
+ \expandafter\def\csname pgfpmeta@#1@tostring\endcsname{#1}%
+ \edef\pgfplotsdeclarepointmetasource@{#1}%
+ \pgfqkeys{/pgfplots/@declare point meta src}{#2}%
+}%
+
+\def\pgfplots@pointmeta@set@expand#1{%
+ \if1\csname pgfpmeta@#1@explicitinput\endcsname
+ \pgfplots@perpointmeta@expandfalse
+ \else
+ \pgfplots@perpointmeta@expandtrue
+ \fi
+}%
+
+\pgfqkeys{/pgfplots/@declare point meta src}{%
+ %
+ % 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.
+ initfor/.code=
+ {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @initfor\endcsname##1{#1}},%
+ %
+ % Called during the survey phase before the first 'assign' call.
+ % It is usually empty.
+ activate/.code=
+ {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @activate\endcsname{#1}},%
+ %
+ % During the survey phase, this macro is expected to assign
+ % \pgfplots@current@point@meta
+ % 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 the issymbolic boolean is true)
+ % The default implementation is
+ % \let\pgfplots@current@point@meta=\pgfutil@empty
+ %
+ assign/.code=
+ {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @assign\endcsname{#1}},%
+ %
+ % expands to either '1' or '0'
+ % A numeric source will be processed numerically in float
+ % arithmetics. Thus, the output of the @assign routine should be
+ % a macro \pgfplots@current@point@meta in float format.
+ %
+ % The output of a numeric point meta source will result in meta
+ % limit updates and the final map to [0,1000] will be
+ % initialised automatically.
+ %
+ % A symbolic input routine won't be processed.
+ % Default is '0'
+ %
+ issymbolic/.code=
+ {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @issymbolic\endcsname{#1}},%
+ %
+ % 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'
+ %
+ explicitinput/.code=
+ {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @explicitinput\endcsname{#1}},%
+ %
+ % the associated LUA class name (if any). Use an empty string if
+ % there is none.
+ LUA class/.code=
+ {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @LUA class\endcsname{#1}},%
+ %
+ tostring/.code=
+ {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @tostring\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
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}%
+ \let\pgfplots@current@point@meta=\pgfmathresult
+ },
+ LUA class=pgfplots.XcoordAssignmentPointMetaHandler}
+\pgfplotsdeclarepointmetasource{y}{assign={%
+ \let\pgfplots@current@point@meta=\pgfplots@current@point@y
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}%
+ \let\pgfplots@current@point@meta=\pgfmathresult
+ },
+ LUA class=pgfplots.YcoordAssignmentPointMetaHandler}
+\pgfplotsdeclarepointmetasource{z}{assign={%
+ \let\pgfplots@current@point@meta=\pgfplots@current@point@z
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}%
+ \let\pgfplots@current@point@meta=\pgfmathresult
+ },
+ LUA class=pgfplots.ZcoordAssignmentPointMetaHandler}
+
+\pgfplotsdeclarepointmetasource{explicit}{%
+ assign={%
+ \ifx\pgfplots@current@point@meta\pgfutil@empty
+ \else
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}%
+ \let\pgfplots@current@point@meta=\pgfmathresult
+ \fi
+ },
+ explicitinput=1,%
+ LUA class=pgfplots.ExplicitPointMetaHandler.new(),
+}%
+\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}%
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfmathresult}%
+ \let\pgfplots@current@point@meta=\pgfmathresult
+ \fi
+ },%
+ initfor={%
+ \pgfkeyssetvalue{/pgfplots/point meta/expr}{#1}%
+ \def\pgfplots@loc@TMPa{expr}%
+ \ifx\pgfplots@loc@TMPa\pgfplotspointmetainputhandler
+ \else
+ \let\pgfpmeta@expr@origchoice\pgfplotspointmetainputhandler
+ \fi
+ \ifx\pgfpmeta@expr@origchoice\pgfplots@loc@TMPa
+ \let\pgfpmeta@expr@origchoice\pgfutil@empty
+ \fi
+ %
+ \pgfplotsutilifcontainsmacro{#1}{%
+ % oh. The point meta expression contains a backslash - it
+ % depends on a macro. This means: it depends on \thisrow
+ % or similar TeX stuff - which must be evaluated by TeX.
+ %
+ % LUA cannot be used for this point meta handler.
+ \let\pgfpmeta@expr@LUA@class\pgfutil@empty
+ }{%
+ \def\pgfpmeta@expr@LUA@class{pgfplots.ExpressionPointMetaHandler.new("#1")}%
+ }%
+ \pgfplots@perpointmeta@expandtrue
+ },
+ LUA class=\pgfpmeta@expr@LUA@class,
+}%
+\pgfkeyssetvalue{/pgfplots/point meta/expr}{}%
+
+\pgfplotsdeclarepointmetasource{f(x)}{%
+ activate={%
+ \ifpgfplots@curplot@threedim
+ \def\pgfplotspointmetainputhandler{z}%
+ \else
+ \def\pgfplotspointmetainputhandler{y}%
+ \fi
+ \csname pgfpmeta@\pgfplotspointmetainputhandler @activate\endcsname
+ },
+}%
+
+\pgfplotsdeclarepointmetasource{TeX code}{%
+ assign={%
+ \begingroup
+ \let\pgfplotspointmeta=\pgfutil@empty
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/code/.@cmd}{}%
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfplotspointmeta}%
+ \let\pgfplots@current@point@meta=\pgfmathresult
+ \pgfmath@smuggleone\pgfplots@current@point@meta
+ \endgroup
+ },%
+ initfor={%
+ \pgfkeysdef{/pgfplots/point meta/code}{#1}%
+ \pgfplots@perpointmeta@expandtrue
+ },
+}%
+\pgfplotsdeclarepointmetasource{TeX code symbolic}{%
+ assign={%
+ \begingroup
+ \let\pgfplotspointmeta=\pgfutil@empty
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/code/.@cmd}{}%
+ \let\pgfplots@current@point@meta=\pgfplotspointmeta
+ \pgfmath@smuggleone\pgfplots@current@point@meta
+ \endgroup
+ },%
+ initfor={%
+ \pgfkeysdef{/pgfplots/point meta/code}{#1}%
+ \pgfplots@perpointmeta@expandfalse
+ },
+ issymbolic=1%
+}%
+\pgfkeysdef{/pgfplots/point meta/code}{}%
+
+% Internal stream methods.
+%
+% Please overwrite
+% - \pgfplots@coord@stream@start@,
+% - \pgfplots@coord@stream@end@ and
+% - \pgfplots@coord@stream@coord@
+% if you implement streams.
+%
+% REMARK:
+% - the stream methods automatically collect first and last
+% coordinates.
+% - I have experimented with global \addplot accumulation to reduce
+% copy operations. That experiment was not successfull (it was not
+% faster :-( ). However, the streaming methods still assign their
+% things globally...
+\def\pgfplots@coord@stream@start{%
+ \let\pgfplots@current@point@x=\pgfutil@empty
+ \let\pgfplots@current@point@y=\pgfutil@empty
+ \let\pgfplots@current@point@z=\pgfutil@empty
+ \let\pgfplots@current@point@meta=\pgfutil@empty
+ \let\pgfplots@current@point@error@x@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@x@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@z@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@z@minus=\pgfutil@empty
+ \pgfplots@coord@stream@start@}%
+\def\pgfplots@coord@stream@end{\pgfplots@coord@stream@end@}
+
+% Will be invoked for every point coordinate.
+%
+% It invokes \pgfplots@coord@stream@coord@.
+%
+% Arguments:
+% \pgfplots@current@point@[xyz]
+% \pgfplots@current@point@[xyz]@error (if in argument list)
+% \pgfplots@current@point@meta
+\def\pgfplots@coord@stream@coord{%
+ \pgfplots@coord@stream@coord@%
+}%
+\def\pgfplotscoordstream@firstlast@init{%
+ \global\let\pgfplots@currentplot@firstcoord@x=\pgfutil@empty
+ \global\let\pgfplots@currentplot@firstcoord@y=\pgfutil@empty
+ \global\let\pgfplots@currentplot@firstcoord@z=\pgfutil@empty
+ \global\let\pgfplots@currentplot@lastcoord@x=\pgfutil@empty
+ \global\let\pgfplots@currentplot@lastcoord@y=\pgfutil@empty
+ \global\let\pgfplots@currentplot@lastcoord@z=\pgfutil@empty
+}%
+\def\pgfplotscoordstream@firstlast@update{%
+ \ifx\pgfplots@current@point@x\pgfutil@empty
+ % only one \if is enough as ONE empty coordinate causes all
+ % others to be reset as well.
+ \else
+ \ifx\pgfplots@currentplot@firstcoord@x\pgfutil@empty
+ \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
+ \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 handle complete sequences of
+% input coordinates, which are usually separated by a blank line.
+%
+% This allows a simple syntax to provide matrix input - by means of scanlines.
+% Furthermore, 2d plots can use it to interrupt the display.
+%
+% 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 steps taken whenever a scan line is complete depend on the
+% configuration of the /pgfplots/empty line choice key (queried in
+% \pgfplotsscanlinelengthinitzero).
+%
+%
+% The following methods constitute the scanline interface.
+%
+% Usage:
+%
+% \pgfplotsscanlinelengthinitzero
+%
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinecomplete
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinecomplete
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinelengthincrease
+% <process point>
+% \pgfplotsscanlinecomplete
+%
+% \pgfplotsscanlinelengthcleanup
+%
+% In other words, the \pgfplotsscanlinelengthincrease routine is
+% invoked *before* the point is processed. That's important.
+%
+% 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{%
+ \def\pgfplotsscanlinelength{-1}%
+ \pgfkeysgetvalue{/pgfplots/empty line}\pgfplots@loc@TMPa%
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \def\pgfplots@loc@TMPb{auto}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \pgfplotsdetermineemptylinehandler
+ \pgfkeysgetvalue{/pgfplots/empty line}\pgfplots@loc@TMPa%
+ \fi
+ \def\pgfplots@loc@TMPb{jump}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \def\pgfplots@loc@TMPa{nan}% alias for jump
+ \fi
+ \def\pgfplots@loc@TMPb{no op}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \def\pgfplots@loc@TMPa{none}% alias for no op
+ \fi
+ \pgfutil@ifundefined{pgfplotsscanlinelength@\pgfplots@loc@TMPa @initzero}{%
+ \pgfplots@error{Sorry, the choice `empty line=\pgfkeysvalueof{/pgfplots/empty line}' is unknown. Maybe you misspelled it}%
+ }{}%
+ \expandafter\let\expandafter\pgfplotsscanlinelength@initzero \csname pgfplotsscanlinelength@\pgfplots@loc@TMPa @initzero\endcsname
+ \expandafter\let\expandafter\pgfplotsscanlinelengthincrease \csname pgfplotsscanlinelength@\pgfplots@loc@TMPa @increase\endcsname
+ \edef\pgfplotsscanlinecomplete{%
+ \expandafter\noexpand\csname pgfplotsscanlinelength@\pgfplots@loc@TMPa @complete\endcsname
+ }%
+ \expandafter\let\expandafter\pgfplotsscanlinelengthcleanup \csname pgfplotsscanlinelength@\pgfplots@loc@TMPa @cleanup\endcsname
+ \pgfplotsscanlinelength@initzero
+}%
+
+\newif\ifpgfplots@emptyline@compat
+
+% Invoked for 'empty line=auto'.
+%
+% @POSTCONDITION: '/pgfplots/empty line' is set to something useful
+% (not auto)
+\def\pgfplotsdetermineemptylinehandler{%
+ \if n\pgfplots@meshmode
+ % no mesh/surf plot:
+ \pgfkeyssetvalue{/pgfplots/empty line}{jump}%
+ \ifpgfplots@emptyline@compat
+ \pgfkeyssetvalue{/pgfplots/empty line}{none}% do nothing for backwards compatibility with 2D processing.
+ \fi
+ \else
+ % it is a mesh or surf plot; use scanline:
+ \pgfkeyssetvalue{/pgfplots/empty line}{scanline}%
+ \fi
+}%
+\def\pgfplotsscanlinedisablechanges{%
+ \let\pgfplotsscanlinecomplete=\relax
+ \let\pgfplotsscanlinelengthincrease=\relax
+ \let\pgfplotsscanlinelengthcleanup=\relax
+ \let\pgfplotsscanlinelengthinitzero=\relax
+ \let\pgfplotsscanlineendofinput=\relax
+}%
+
+% -------------------------------------------------------------------------------
+% empty line=scanline
+% class:
+\def\pgfplotsscanlinelength@scanline@initzero{%
+ \c@pgfplots@scanlineindex=0 % the index _inside_ of the current scanline
+ \def\pgfplotsscanlinecurrentlength{\the\c@pgfplots@scanlineindex}%
+ \def\pgfplotsscanlineindex{0}% 0 is the first scanline, 1 the second, and so on
+ \def\pgfplots@scanlinelength{-1}%
+}
+\def\pgfplotsscanlinelength@scanline@increase{%
+ \advance\c@pgfplots@scanlineindex by1
+}
+\def\pgfplotsscanlinelength@scanline@complete{%
+ \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
+ \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
+ \pgfplotsplothandlernotifyscanlinecomplete
+ \fi
+ \else
+ \ifnum\pgfplots@scanlinelength=-2
+ \else
+ \edef\pgfplots@scanlinelength{\the\c@pgfplots@scanlineindex}%
+ \fi
+ %
+ \ifnum\c@pgfplots@scanlineindex>0
+ \pgfplotsplothandlernotifyscanlinecomplete
+ \fi
+ \fi
+ \c@pgfplots@scanlineindex=0
+ \pgfplotsutil@advancestringcounter\pgfplotsscanlineindex%
+}
+\def\pgfplotsscanlinelength@scanline@cleanup{%
+ \ifnum\c@pgfplots@scanlineindex=0
+ % I assume the last scan line is already complete.
+ \else
+ \pgfplotsscanlinecomplete
+ \fi
+ \let\pgfplotsscanlinelength=\pgfplots@scanlinelength
+}
+% -------------------------------------------------------------------------------
+%
+% empty line=none class:
+%
+\let\pgfplotsscanlinelength@none@initzero=\pgfutil@empty
+\let\pgfplotsscanlinelength@none@increase=\relax
+\let\pgfplotsscanlinelength@none@complete=\relax
+\let\pgfplotsscanlinelength@none@cleanup=\relax
+% -------------------------------------------------------------------------------
+%
+% empty line=nan class:
+\def\pgfplotsscanlinelength@nan@initzero{%
+ \def\pgfplotsscanlinelength@nan@isfirst{1}%
+ \let\pgfplotsscanlinelength@nan@pendingwork=\relax
+ \pgfplotsifinplot{}{%
+ \let\pgfplotsaxisserializedatapoint=\relax
+ }%
+}%
+\def\pgfplotsscanlinelength@nan@increase{%
+ \def\pgfplotsscanlinelength@nan@isfirst{0}%
+ \pgfplotsscanlinelength@nan@pendingwork
+}%
+\def\pgfplotsscanlinelength@nan@complete{%
+ \if1\pgfplotsscanlinelength@nan@isfirst
+ \else
+ \pgfplotsifinplot{%
+ \let\pgfplotsscanlinelength@nan@pendingwork=\pgfplotsscanlinelength@nan@pendingwork@PREPARED
+ }{%
+ \let\pgfplotsscanlinelength@nan@pendingwork=\relax
+ }%
+ \fi
+ \def\pgfplotsscanlinelength@nan@isfirst{1}%
+}%
+\let\pgfplotsscanlinelength@nan@cleanup=\relax
+\def\pgfplotsscanlinelength@nan@pendingwork@PREPARED{%
+ \pgfplotsplothandlerappendjumpmarker`
+ %
+ \let\pgfplotsscanlinelength@nan@pendingwork=\relax
+}%
+
+\def\pgfplotsplothandlerappendjumpmarker{%
+ \ifpgfplots@LUA@backend@supported
+ \pgfplotsutil@directlua{pgfplots.texSurveyAddJump()}%
+ \else
+ % this will be executed when the next point has been
+ % found.
+ \def\pgfplots@current@point@x{}%
+ \def\pgfplots@current@point@y{}%
+ \def\pgfplots@current@point@z{}%
+ % simply serialize an empty point. That works -- the
+ % visualization phase checks if the coordinates are empty and
+ % visualizes them as "jump"
+ %
+ % Note that \pgfplotsplothandlersurveypoint is not a good
+ % choice here unless one employs its 'unbounded coords=jump'
+ % feature
+ \def\pgfplotsaxisplothasjumps{1}%
+ \pgfplotsaxisserializedatapoint
+ \fi
+}%
+%
+% -------------------------------------------------------------------------------
+
+
+\def\pgfplotsaxisfilteredcoordsaway{0}%
+\def\pgfplotsaxisplothasjumps{0}%
+\def\pgfplotsaxisplothasunboundedpointmeta{0}%
+\newif\ifpgfplotsaxisparsecoordinateok
+
+% Possibly values:
+% N = none, is not in \addplot
+% S = survey
+% V = visualization
+\def\pgfplotsaxisplotphase{N}
+
+\def\pgfplotsifinplot#1#2{%
+ \if\pgfplotsaxisplotphase N%
+ #2%
+ \else
+ #1%
+ \fi
+}%
+
+% Initialises
+% \pgfplots@coord@stream@start
+% \pgfplots@coord@stream@coord
+% \pgfplots@coord@stream@end
+% 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: any trailing path commands after the 'plot' command as such,
+% for example \addplot plot coordinates {...} -- (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@coord@stream@start
+% ...
+% \pgfplots@coord@stream@coord
+% ..
+% \pgfplots@coord@stream@coord
+% ..
+% \pgfplots@coord@stream@end
+% -> All need to be the SAME LEVEL OF SCOPING! The '@coord' commands
+% may not be scoped deeper than 'begin' and 'end'!
+% - I had a version which allowed that. it was actually slower!
+% - For now, the following things are global / local:
+% - point coordinate list: local
+% - meta data limits: global,
+% - 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.
+%
+% @see the detailed documentation in pgfplotsplothandlers.code.tex
+\long\def\pgfplots@PREPARE@COORD@STREAM#1{%
+ \ifpgfplots@curplot@threedim
+ \global\pgfplots@threedimtrue
+ \fi
+ \def\pgfplotsaxisfilteredcoordsaway{0}%
+ \def\pgfplotsaxisplothasjumps{0}%
+ \def\pgfplotsaxisplothasunboundedpointmeta{0}%
+ %
+ % FIXME : these macros should not be redefined! They are defined
+ % in \pgfplots@prepare@axis@API right during \begin{axis}... they
+ % probably shouldn't be changed.
+ \ifpgfplots@curplot@threedim
+ \let\pgfplotsaxisupdatelimitsforcoordinate=\pgfplotsaxisupdatelimitsforcoordinatethreedim
+ \let\pgfplotsaxisparsecoordinate=\pgfplotsaxisparsecoordinatethreedim
+ \else
+ \let\pgfplotsaxisupdatelimitsforcoordinate=\pgfplotsaxisupdatelimitsforcoordinatetwodim
+ \let\pgfplotsaxisparsecoordinate=\pgfplotsaxisparsecoordinatetwodim
+ \fi
+ \begingroup
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \let\E=\noexpand
+ %
+%\message{Assembled update-limits \ifpgfplots@curplot@threedim 3D\else 2D\fi macro to {\meaning\pgfplotsaxisupdatelimitsforcoordinate}}%
+ \ifpgfplots@bb@isactive
+ \else
+ % we are inside of
+ % \pgfplotsinterruptdatabb
+ % ..
+ % \endpgfinterruptboundingbox
+ % -> don't change data limits!
+ \gdef\pgfplotsaxisupdatelimitsforcoordinate##1##2##3{}%
+ \fi
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ %
+ % Takes a coordinate which is already parsed and applies steps
+ % such that it becomes its final values.
+ %
+ % This implements the stacked plot feature currently.
+ %
+ % PRECONDITION:
+ % \pgfplotsaxisparsecoordinate has already been called.
+ %
+ % POSTCONDITION:
+ % the point has its final coordinates; the axis won't change it
+ % anymore.
+ \xdef\pgfplotsaxispreparecoordinate{%
+ \E\ifpgfplotsaxisparsecoordinateok
+ % All following routines (limit updating/stacking/error
+ % bars) will use float numerics if necessary (controlled
+ % by ifs).
+ \E\pgfplotsaxistransformfromdatacs
+ \ifpgfplots@stackedmode
+ \E\pgfplots@stacked@preparepoint@inmacro%
+ \fi
+ \E\fi
+ }%
+ %
+ % A macro which should be called once for every data point during the
+ % survey phase.
+ %
+ % The caller is the plot handler's point survey routine.
+ %
+ % A data point might be a complicated thing which contains
+ % multiple coordinates. You need to invoke
+ % \pgfplotsaxisparsecoordinate and
+ % \pgfplotsaxispreparecoordinate for each of them. But
+ % \pgfplotsaxisdatapointsurveyed is invoked once for the complete
+ % set.
+ %
+ % @PRECONDITION
+ % - \pgfplots@current@point@[xyz] contain final coordinates
+ % (i.e. output of \pgfplotsaxispreparecoordinate)
+ %
+ % @POSTCONDITION
+ % - stacked plot things,
+ % - error bars,
+ % - xtick=data
+ % are all processed.
+ %
+ \xdef\pgfplotsaxisdatapointsurveyed{%
+ \E\ifpgfplotsaxisparsecoordinateok
+ % All following routines (limit updating/stacking/error
+ % bars) will use float numerics if necessary (controlled
+ % by ifs).
+ %
+ % Prepare \pgfplots@current@point@meta (see the preparation
+ % routine above):
+ \E\pgfplotsaxissurveysetpointmeta
+ %
+ \ifpgfplots@errorbars@enabled
+ \E\pgfplots@errorbars@survey@point
+ \fi
+ %
+ \ifpgfplots@collect@firstplot@astick
+ \ifnum\pgfplots@numplots=0
+ \E\ifx\E\pgfplots@firstplot@coords@x\E\pgfutil@empty
+ \E\t@pgfplots@tokc={}%
+ \E\else
+ \E\t@pgfplots@tokc=\E\expandafter{\E\pgfplots@firstplot@coords@x,}%
+ \E\fi
+ \E\xdef\E\pgfplots@firstplot@coords@x{\E\the\E\t@pgfplots@tokc\E\pgfplots@current@point@x}%
+ \E\ifx\E\pgfplots@firstplot@coords@y\E\pgfutil@empty
+ \E\t@pgfplots@tokc={}%
+ \E\else
+ \E\t@pgfplots@tokc=\E\expandafter{\E\pgfplots@firstplot@coords@y,}%
+ \E\fi
+ \E\xdef\E\pgfplots@firstplot@coords@y{\E\the\E\t@pgfplots@tokc\E\pgfplots@current@point@y}%
+ %
+ \ifpgfplots@curplot@threedim
+ \E\ifx\E\pgfplots@firstplot@coords@z\E\pgfutil@empty
+ \E\t@pgfplots@tokc={}%
+ \E\else
+ \E\t@pgfplots@tokc=\E\expandafter{\E\pgfplots@firstplot@coords@z,}%
+ \E\fi
+ \E\xdef\E\pgfplots@firstplot@coords@z{\E\the\E\t@pgfplots@tokc\E\pgfplots@current@point@z}%
+ \fi
+ \fi
+ \fi
+ \E\pgfplotscoordstream@firstlast@update
+ \E\pgfplotsaxisserializedatapoint
+ \E\else
+ % COORDINATE HAS BEEN FILTERED AWAY:
+ %
+ % 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
+ \E\def\E\pgfplotsaxisfilteredcoordsaway{1}%
+ \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
+ (see also unbounded coords=jump).
+ }%
+ \fi
+ \else
+ % unbounded coords=jump
+ \E\ifx\E\pgfplots@unbounded@dir\E\pgfutil@empty
+ \E\def\E\pgfplotsaxisfilteredcoordsaway{1}%
+ \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
+ \E\def\E\pgfplotsaxisplothasjumps{1}%
+ \E\pgfplotsaxisserializedatapoint
+ \E\fi
+ \fi
+ \E\fi
+ %
+ % increase \pgfplots@current@point@coordindex:
+ \E\advance\E\c@pgfplots@coordindex by1
+ }%
+ %
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \endgroup
+ %
+ \def\pgfplotsaxissurveysetpointmeta{%
+ \pgfplotsplothandlersurveybeforesetpointmeta
+ \pgfplots@set@perpointmeta
+ \pgfplotsplothandlersurveyaftersetpointmeta
+ }%
+ %
+%\message{Prepared macro \string\pgfplots@update@limits@for@one@point: {\meaning\pgfplotsaxisupdatelimitsforcoordinate}}%
+%\message{Prepared macro \string\pgfplots@process@one@point: {\meaning\pgfplots@process@one@point}}%
+ %
+ \let\pgfplots@coord@stream@start@=\pgfplots@PREPARE@COORD@STREAM@start@
+ \def\pgfplots@coord@stream@coord@{%
+ \def\pgfplots@set@perpointmeta@done{0}%
+ % NOTE: this might call LUA (if supported):
+ \pgfplotsplothandlersurveypoint
+ }%
+ \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
+ %
+ \edef\plotnumofactualtype{\numplotsofactualtype}%
+ \csname pgfpmeta@\pgfplotspointmetainputhandler @activate\endcsname
+ \pgfplots@LUA@survey@start
+ \pgfplotsplothandlersurveystart
+ \pgfplotscoordstream@firstlast@init
+ %
+ \pgfkeyssetvalue{/data point/x}{\pgfplots@current@point@x}%
+ \pgfkeyssetvalue{/data point/y}{\pgfplots@current@point@y}%
+ \pgfkeyssetvalue{/data point/z}{\pgfplots@current@point@z}%
+ \pgfkeyssetvalue{/data point/meta}{\pgfplots@current@point@meta}%
+ %
+ \ifpgfplots@stackedmode
+ \pgfplots@stacked@beginplot
+ \fi
+ \ifpgfplots@errorbars@enabled
+ % prepare error bar processing.
+ \pgfplots@errorbars@survey@begin
+ \fi
+ %
+ %
+ \pgfplots@prepare@visualization@dependencies
+ %
+ % Inside of math expressions, 'x', 'y' and 'z' expand to the
+ % current x,y and z coords respectively. Introduce these (and some
+ % more) shortcuts:
+ % FIXME : defining the resulting x/y coordinates as 'x' and 'y' constants was a really really bad idea in the first place :-(
+ \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
+ \pgfplotscoordmath{meta}{parsenumber}{0}%
+ \fi
+ }%
+ \pgfmathredeclarefunction{thisrow}{%
+ \getthisrow{##1}\pgfmathresult
+ % XXX : this does NOT allow to return string values,
+ % unfortunately! the fpu makes garbage out of it.
+ % I already tried to parse it here and return special string
+ % markers, but that approach requires much more effort...
+ }%
+ \pgfmathredeclarefunction{thisrowno}{%
+ \getthisrowno{##1}\pgfmathresult
+ }%
+ %
+ % %%%%%%%%%%%%%%
+ %
+ % Define \pgfplots@set@perpointmeta properly:
+ \def\pgfplots@set@perpointmeta{%
+ \if0\pgfplots@set@perpointmeta@done
+ \csname pgfpmeta@\pgfplotspointmetainputhandler @assign\endcsname
+ \def\pgfplots@set@perpointmeta@done{1}%
+ \pgfplots@set@perpointmeta@limits
+ \fi
+ }%
+ % append limit updating to \pgfplots@set@perpointmeta :
+ \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
+ \pgfplotscoordmath{meta}{min}{\pgfplots@metamin}{\pgfplots@current@point@meta}%
+ \global\let\pgfplots@metamin=\pgfmathresult
+ }%
+ \else
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@metamin}%
+ \global\let\pgfplots@metamin=\pgfmathresult
+ \fi
+ \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
+ \pgfplotscoordmath{meta}{max}{\pgfplots@metamax}{\pgfplots@current@point@meta}%
+ \global\let\pgfplots@metamax=\pgfmathresult
+ }%
+ \else
+ \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@metamax}%
+ \global\let\pgfplots@metamax=\pgfmathresult
+ \fi
+ %
+ \edef\pgfplots@set@perpointmeta@limits{%
+ \noexpand\pgfplotsifpointmetaisbounded{\noexpand\pgfplots@current@point@meta}{%
+ \the\t@pgfplots@tokb
+ }{%
+ \noexpand\def\noexpand\pgfplotsaxisplothasunboundedpointmeta{1}%
+ }%
+ }%
+ \else
+ % there is no point meta:
+ \global\let\pgfplots@metamin=\pgfutil@empty
+ \global\let\pgfplots@metamax=\pgfutil@empty
+ \def\pgfplots@set@perpointmeta@limits{%
+ \pgfplotsifpointmetaisbounded{\pgfplots@current@point@meta}{%
+ }{%
+ \def\pgfplotsaxisplothasunboundedpointmeta{1}%
+ }%
+ }%
+ \fi
+}%
+
+\def\pgfplots@define@dummies@for@pseudoconstants{%
+ \pgfmathdeclarefunction{thisrow}{1}{%
+ \pgfplots@error{You cannot use 'thisrow' in the current context.}%
+ }%
+ \pgfmathdeclarefunction{thisrowno}{1}{%
+ \pgfplots@error{You cannot use 'thisrowno' in the current context.}%
+ }%
+}%
+\def\pgfplotsaxisupdatelimitsforpointmeta#1{%
+ \begingroup
+ \def\pgfplots@current@point@meta{#1}%
+ \pgfplots@set@perpointmeta@limits
+ \endgroup
+}%
+% 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{%
+ \pgfkeysvalueof{/pgfplots/execute at end survey}%
+ \ifpgfplots@LUA@backend@supported
+ \pgfplots@LUA@survey@end
+ \fi
+ % FIXME : move this the \pgfplotsplothandlersurveyend of mesh plot
+ % handler:
+ \pgfkeyssetvalue{/pgfplots/mesh/num points}{\pgfplots@current@point@coordindex}%
+ %
+ \pgfplotsplothandlersurveyend
+ \ifx\pgfplots@metamin\pgfutil@empty
+ \else
+ \if\pgfplots@axiswide@metamin@autocompute1%
+ \pgfplotscoordmath{meta}{min}{\pgfplots@axiswide@metamin}{\pgfplots@metamin}%
+ \global\let\pgfplots@axiswide@metamin=\pgfmathresult
+ \fi
+ \if\pgfplots@axiswide@metamax@autocompute1%
+ \pgfplotscoordmath{meta}{max}{\pgfplots@axiswide@metamax}{\pgfplots@metamax}%
+ \global\let\pgfplots@axiswide@metamax=\pgfmathresult
+ \fi
+ \fi
+ \if1\pgfplots@colorbar@set@src% this 0|1 switch is set in \pgfplots@start@plot@with@behavioroptions
+ \ifx\pgfplots@metamin\pgfutil@empty
+ \pgfplotsthrow{no such element}{\pgfplots@loc@TMPa}{Sorry, `colorbar source' can't be processed: the current \string\addplot\space command doesn't have point meta. Ignoring it.}\pgfeov%
+ \else
+ \global\let\pgfplots@colorbar@src@metamin=\pgfplots@metamin
+ \global\let\pgfplots@colorbar@src@metamax=\pgfplots@metamax
+ \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@errorbars@survey@end
+ \fi
+ \ifpgfplots@stackedmode
+ \pgfplots@stacked@survey@endplot
+ \fi
+ \ifx\pgfplots@currentplot@firstcoord@x\pgfutil@empty
+ \pgfplotswarning{plot without coordinates}\pgfeov%
+ \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
+ %
+ %% FIXME : why is this here and not in the mesh plot handler!?
+ \pgfplotspreparemeshkeydefaults%
+ \pgfplots@PREPARE@COORD@STREAM@end@determinecoordsorting x%
+ \pgfplots@PREPARE@COORD@STREAM@end@determinecoordsorting y%
+ %
+ \pgfplots@remember@survey@option@list
+ %
+ % 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!
+ %
+ \pgfplotsplothandlerserializestateto\pgfplots@loc@TMPa
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}%
+ %
+ \pgfplots@markers@survey@set@visphasename
+ \let\pgfplots@markers@visphase@name=\pgfplotsretval
+ %
+ \pgfplotssurveyphase@set@visphase@names{#1}%
+ \let\pgfplots@visphase@names=\pgfplotsretval
+ %
+ \t@pgfplots@tokc={#1}%
+ %
+ % 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
+ %
+ % Did we prepare the data within LUA? remember that!
+ \ifpgfplots@LUA@backend@supported
+ \noexpand\pgfplots@LUA@backend@supportedtrue
+ \pgfplots@LUA@backend@serialized@commands
+ \else
+ \noexpand\pgfplots@LUA@backend@supportedfalse
+ \fi
+ \noexpand\def\noexpand\plotnum{\plotnum}%
+ %
+ % store \plotnumofactualtype
+ \noexpand\def\noexpand\plotnumofactualtype{\plotnumofactualtype}%
+ % ... and make sure that it
+ % remains the same type even if some plot handler uses
+ % other plot handlers internally:
+ \noexpand\def\noexpand\pgfplotsplothandlername@actual{\pgfplotsplothandlername@actual}%
+ \noexpand\let\noexpand\numplotsofactualtype\noexpand\pgfplots@numplotsofactualtype@duringplot
+ %
+ \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
+ %
+ \ifpgfplots@stackedmode
+ \pgfplots@stacked@serialized@commands
+ \fi
+ %
+ % 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}}%
+ \noexpand\pgfkeyssetvalue{/pgfplots/mesh/num points}{\pgfkeysvalueof{/pgfplots/mesh/num points}}%
+ % either '+' or '-' :
+ \noexpand\pgfkeyssetvalue{/pgfplots/x coord sorting}{\pgfkeysvalueof{/pgfplots/x coord sorting}}%
+ \noexpand\pgfkeyssetvalue{/pgfplots/y coord sorting}{\pgfkeysvalueof{/pgfplots/y coord sorting}}%
+ %
+ % remember 'current plot style':
+ \noexpand\pgfplots@define@currentplotstyle@as{%
+ \the\t@pgfplots@toka
+ }%
+ % 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}%
+ \noexpand\def\noexpand\pgfplots@serialized@state@plothandler{\the\t@pgfplots@tokb}%
+ \noexpand\def\noexpand\pgfplots@markers@visphase@name{\pgfplots@markers@visphase@name}%
+ \noexpand\def\noexpand\pgfplots@visphase@names{\pgfplots@visphase@names}%
+ \noexpand\def\noexpand\pgfplotsaxisfilteredcoordsaway{\pgfplotsaxisfilteredcoordsaway}%
+ \noexpand\def\noexpand\pgfplotsaxisplothasjumps{\pgfplotsaxisplothasjumps}%
+ \noexpand\def\noexpand\pgfplotsaxisplothasunboundedpointmeta{\pgfplotsaxisplothasunboundedpointmeta}%
+ \noexpand\pgfkeyssetvalue{/pgfplots/on layer}{\pgfkeysvalueof{/pgfplots/on layer}}%
+ \noexpand\def\noexpand\pgfplots@serialized@afterpath{\the\t@pgfplots@tokc}%
+ \noexpand\def\noexpand\pgfplots@addplot@point@meta@description@of@explicit@value{\pgfplots@addplot@point@meta@description@of@explicit@value}%
+ }%
+ {% draw command:
+ \noexpand\path%
+ }%
+ }%
+ \pgfplotsapplistXXlet\pgfplots@coord@stream@recorded
+ \pgfplotsapplistXXclear
+ \t@pgfplots@tokc=\expandafter{\pgfplots@coord@stream@recorded}%
+ \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
+ % (will become available as \pgfplots@stored@current@data)
+ \the\t@pgfplots@tokc
+ }%
+ }%
+ %
+ \pgfplots@glob@TMPa
+ {%
+ % Post commands are empty here.
+ }%
+ %^^^^^^^^^^^^ ... END of \pgfplots@addplot@enqueue@coords HERE
+ \fi
+ \pgfplots@end@plot
+}%
+
+\def\pgfplots@remember@survey@option@list{%
+ \t@pgfplots@tokc=\expandafter{\pgfplots@addplot@survey@@optionlist,%
+ /pgfplots/.cd,/pgfplots/every axis plot post}%
+ \edef\pgfplots@addplot@survey@@optionlist{\the\t@pgfplots@tokc}%
+ \edef\pgfplots@loc@TMPa{/pgfplots/every axis plot except legend/.code=,\the\t@pgfplots@tokc}%
+ \ifpgfplots@curplot@isirrelevant
+ % for \label commands:
+ \expandafter\pgfplots@rememberplotspec@for@label\expandafter{\pgfplots@addplot@survey@@optionlist}%
+ \else
+ \expandafter\pgfplots@rememberplotspec\expandafter{\pgfplots@loc@TMPa}%
+ \fi
+}%
+
+\def\pgfplots@LUA@survey@log@deactivation#1{%
+ \pgfplots@log{\pgfplots@LUA@loglevel@info}{Using 'lua backend=false' for plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername'): #1.}%
+ \pgfplots@LUA@backend@failed
+}%
+
+\def\pgfplots@LUA@survey@get@filter#1{%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/#1 filter/.@cmd}\pgfplots@loc@TMPc
+ \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key
+ \let\pgfplotsretval=\pgfutil@empty
+ \else
+ \pgfplots@ifisfilterexpression{#1 filter}{%
+ \pgfkeysgetvalue{/pgfplots/#1 filter/@expressionvalue}\pgfplotsretval
+ \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplotsretval}{%
+ \aftergroup\pgfplots@LUA@backend@supportedfalse
+ \pgfplots@command@to@string\pgfplotsretval\pgfplots@loc@TMPa
+ \pgfplots@LUA@survey@log@deactivation{#1 filter/.expression='\pgfplots@loc@TMPa' contains a TeX macro}%
+ \let\pgfplotsretval=\pgfutil@empty
+ }{%
+ }%
+ }{%
+ \aftergroup\pgfplots@LUA@backend@supportedfalse
+ \pgfplots@LUA@survey@log@deactivation{LUA does not support #1 filter (yet)}%
+ \let\pgfplotsretval=\pgfutil@empty
+ }%
+ \fi
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+\def\pgfplots@LUA@survey@start{%
+ \ifpgfplots@LUA@backend@supported
+ \ifx\pgfplotsplothandlerLUAfactory\pgfutil@empty
+ \pgfplots@LUA@survey@log@deactivation{plot handler does not support LUA}%
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ %
+ \ifx\pgfplotspointmetainputhandler\pgfutil@empty
+ \def\pgfplots@loc@TMPa{nil}%
+ \else
+ \edef\pgfplots@loc@TMPa{%
+ \csname pgfpmeta@\pgfplotspointmetainputhandler @LUA class\endcsname}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfplots@LUA@survey@log@deactivation{point meta choice does not support LUA}%
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ \fi
+ \ifpgfplots@stackedmode
+ \pgfplots@LUA@survey@log@deactivation{LUA does not support stacked plots (yet)}%
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ \ifpgfplots@errorbars@enabled
+ \pgfplots@LUA@survey@log@deactivation{LUA does not support error bars (yet)}%
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ \ifpgfplots@collect@firstplot@astick
+ \pgfplots@LUA@survey@log@deactivation{LUA does not support xtick=data (yet)}%
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ \pgfkeysgetvalue{/pgfplots/pre filter/.@cmd}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@survey@log@deactivation{LUA does not support filter (yet)}\fi
+ \pgfplots@LUA@survey@get@filter x%
+ \let\pgfplots@loc@filter@x=\pgfplotsretval
+ \pgfplots@LUA@survey@get@filter y%
+ \let\pgfplots@loc@filter@y=\pgfplotsretval
+ \pgfplots@LUA@survey@get@filter z%
+ \let\pgfplots@loc@filter@z=\pgfplotsretval
+ \pgfkeysgetvalue{/pgfplots/filter point/.@cmd}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@survey@log@deactivation{LUA does not support filter (yet)}\fi
+ %
+ \pgfkeysgetvalue{/pgfplots/execute for finished point}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfutil@empty\else \pgfplots@LUA@backend@supportedfalse\fi
+ %
+ \pgfkeysgetvalue{/pgfplots/visualization depends on/list}\pgfplots@loc@TMPc \ifx\pgfplots@loc@TMPc\pgfutil@empty\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@survey@log@deactivation{LUA does not support 'visualization depends on' (yet)} \fi
+ %
+ %
+ \edef\pgfplots@loc@TMPc{\pgfkeysvalueof{/pgfplots/data cs}}%
+ \edef\pgfplots@loc@TMPd{\pgfkeysvalueof{/pgfplots/@expected axis cs}}%
+ \ifx\pgfplots@loc@TMPc\pgfplots@loc@TMPd\else\pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@survey@log@deactivation{LUA does not support 'data cs' (yet)}\fi
+ %
+ % hm. There are various cases which are supported during a
+ % SURVEY -- but not during a visualization. Check that here:
+ \if m\pgfplots@colormap@access
+ \else
+ \if c\pgfplots@colormap@access
+ \else
+ \pgfplots@LUA@survey@log@deactivation{color map access=direct not supported (yet)}%
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ \fi
+ \pgfplotscolormapifisuniform{\pgfkeysvalueof{/pgfplots/colormap name}}{%
+ }{%
+ % FIXME : implement LUA for non-uniform colormaps
+ \pgfplots@LUA@survey@log@deactivation{non-uniform color maps unsupported currently}%
+ \pgfplots@LUA@backend@supportedfalse
+ }%
+ %
+ \ifpgfplots@curplot@threedim
+ \else
+ \ifpgfplots@threedim
+ \pgfplots@LUA@survey@log@deactivation{2d plots in 3d axis currently unsupported}%
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ \fi
+ %
+ \ifpgfplots@LUA@backend@supported
+ \edef\pgfplots@LUA@backend@plotnum{\pgfutil@directlua{tex.sprint(\pgfplotsHASH pgfplots.gca.plothandlers)}}%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/point meta min}\pgfplots@loc@metamin
+ \pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots@loc@metamax
+ \pgfplots@log{\pgfplots@LUA@loglevel@debug}{lua backend=true: Activating LUA backend for plot \the\pgfplots@numplots\space (lua \pgfplots@LUA@backend@plotnum, type '\pgfplotsplothandlername').}%
+ \edef\pgfplots@loc@TMPa{%
+ local gca = pgfplots.gca;^^J%
+ gca.min = {^^J%
+ pgfplots.pgftonumber("\pgfplots@xmin"), ^^J%
+ pgfplots.pgftonumber("\pgfplots@ymin"), ^^J%
+ pgfplots.pgftonumber("\pgfplots@zmin")}; ^^J%
+ gca.max = {^^J%
+ pgfplots.pgftonumber("\pgfplots@xmax"), ^^J%
+ pgfplots.pgftonumber("\pgfplots@ymax"), ^^J%
+ pgfplots.pgftonumber("\pgfplots@zmax")}; ^^J%
+ % FIXME : what about datamin/datamax!?
+ local plothandlerFactory = \pgfplotsplothandlerLUAfactory; ^^J%
+ local plothandler = plothandlerFactory(gca, \pgfplots@loc@TMPa);^^J% second arg: point meta handler
+ \ifx\pgfplots@loc@metamin\pgfutil@empty
+ \else
+ plothandler.autocomputeMetaMin = false;^^J%
+ plothandler.metamin = pgfplots.pgftonumber("\pgfplots@loc@metamin");^^J%
+ \fi
+ \ifx\pgfplots@loc@metamax\pgfutil@empty
+ \else
+ plothandler.autocomputeMetaMax = false;^^J%
+ plothandler.metamax = pgfplots.pgftonumber("\pgfplots@loc@metamax");^^J%
+ \fi
+ local config = plothandler.config;^^J%
+ config.unboundedCoords = "\pgfplots@unbounded@handler";^^J%
+ config.warnForfilterDiscards = \pgfplots@boolval{pgfplots@warn@for@filter@discards};^^J%
+ config.pointmetarel = \pgfplots@perpointmeta@rel@choice;^^J%
+ config.updateLimits = \ifpgfplots@bb@isactive true\else false\fi;^^J%
+ config.filterExpressionByDir = {^^J%
+ "\pgfplots@loc@filter@x",^^J%
+ "\pgfplots@loc@filter@y",^^J%
+ "\pgfplots@loc@filter@z"};^^J%
+ gca.plothandlers[\pgfplots@LUA@backend@plotnum+1]= plothandler;^^J%
+ gca.currentPlotHandler = plothandler;^^J%
+ plothandler:surveystart();^^J%
+ }%
+%\message{Executing ^^J\pgfplots@loc@TMPa^^J^^J}%
+ \pgfplotsutil@directlua{\pgfplots@loc@TMPa}%
+ \endgroup
+ \def\pgfplots@LUA@backend@serialized@commands{%
+ \noexpand\def\noexpand\pgfplots@LUA@backend@plotnum{\pgfplots@LUA@backend@plotnum}%
+ }%
+ \def\pgfplotsapplistXXpushback##1{%
+ \pgfplots@error{Illegal internal state encountered: lua backend should have been invoked at this point}%
+ }%
+ \fi
+ \fi
+}%
+
+\let\pgfplotsapplistXXpushback@orig=\pgfplotsapplistXXpushback
+
+\def\pgfplots@LUA@survey@point{%
+ \edef\pgfplots@loc@TMPa{pgfplots.texSurveyPoint("\pgfplots@current@point@x","\pgfplots@current@point@y","\pgfplots@current@point@z","\pgfplots@current@point@meta")}%
+ \pgfplotsutil@directlua{\pgfplots@loc@TMPa}%
+ % increase \pgfplots@current@point@coordindex:
+ \advance\c@pgfplots@coordindex by1
+}%
+
+\def\pgfplots@LUA@survey@end{%
+ % LUA defines a couple of TeX macros here...
+ \pgfplotsutil@directlua{pgfplots.texSurveyEnd()}%
+ %
+ \let\pgfplotsapplistXXpushback=\pgfplotsapplistXXpushback@orig
+ \pgfplotsapplistXXpushback{--- acquire from LUA! --}%
+}%
+
+% this appears to be necessary for the mesh legend...
+\def\b@pgfplots@LUA@visualization@enabled{0}%
+
+% PRECONDITION : \pgfplots@LUA@visualization@init has already been
+% executed.
+\def\pgfplots@LUA@visualization@of@current@plot{%
+ \def\b@pgfplots@LUA@visualization@enabled{0}%
+ \ifpgfplots@LUA@backend@supported
+ \pgfkeysgetvalue{/pgfplots/axis type}\pgfplots@loc@TMPa
+ \def\pgfplots@loc@TMPb{rectangle}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \else
+ % disable visualizer - we cannot do this right now.
+ \pgfplots@LUA@backend@failed
+ \let\pgfplotsplothandlerLUAvisualizerfactory=\pgfutil@empty
+ \fi
+ %
+ \ifx\pgfplotsplothandlerLUAvisualizerfactory\pgfutil@empty
+ % hm. This plot cannot be visualized in LUA - BUT it has a
+ % LUA survey! Ok, then: acquire the survey results.
+ % Otherwise we would have nothing here.
+ % FIXME : what about \pgfplots@LUA@backend@failed in this context!?
+ \pgfplots@log{\pgfplots@LUA@loglevel@info}{Using 'lua backend=false' for visualization of plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername'): it has no LUA visualizer.}%
+ % NOTE:
+ % I use two levels of \expandafter here because 'lua debug =trace'
+ % introduces another level of expansion. And I do not
+ % want to use \edef... silly, perhaps..?
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\pgfplots@stored@current@data
+ \expandafter\expandafter\expandafter{%
+ \pgfplotsutil@directlua{pgfplots.texGetSurveyedCoordsToPgfplots()}%
+ }%
+ \else
+ % visualize using LUA! ... and acquire the coordinates.
+ % NOTE:
+ % I use two levels of \expandafter here because 'lua debug =trace'
+ % introduces another level of expansion. And I do not
+ % want to use \edef... silly, perhaps..?
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\pgfplots@stored@current@data
+ \expandafter\expandafter\expandafter{%
+ \pgfplotsutil@directlua{pgfplots.texVisualizePlot(\pgfplotsplothandlerLUAvisualizerfactory)}%
+ }%
+%\message{plot \plotnum: LUA backend returned \meaning\pgfplots@stored@current@data^^J}%
+ %
+ % ... and ensure that the resulting
+ % \pgfplots@stored@current@data can be deserialized. It
+ % contains the fully mapped X/Y coordinates as first item.
+ \let\pgfplotsaxisdeserializedatapointfrom@private@nonLUA=\pgfplotsaxisdeserializedatapointfrom@private
+ \def\pgfplotsaxisdeserializedatapointfrom@private##1{%
+ \pgfplotsaxisdeserializedatapointfrom@private@LUA##1%
+ }%
+ \def\pgfplotsaxisdeserializedatapointfrom@private@LUA##1##2##3{%
+ \global\pgf@x=##1pt %
+ \global\pgf@y=##2pt %
+ \pgfplotsaxisdeserializedatapointfrom@private@nonLUA{##3}%
+ }%
+ % FIXME : do I need to adopt the serializer as well!?
+ %
+ \def\b@pgfplots@LUA@visualization@enabled{1}%
+ \fi
+ \fi
+}%
+
+% Defines \pgfplotsretval to contain a comma-separated-list of
+% visualization phase names. May be empty.
+%
+% These names will be stored as \pgfplots@visphase@names during the
+% visualization phase.
+%
+% The role of "visualization phases" is to call the plot
+% handler, and perhaps further visualization phases.
+%
+% This is entirely *independent* of plot marks which have their own,
+% very special visualization phase.
+%
+% It is allowed if a plot has an empty list of visualization phases
+% (common for 'only marks').
+%
+% #1: any tikz path instructions after the \addplot command but before
+% the semicolon.
+\def\pgfplotssurveyphase@set@visphase@names#1{%
+ % 1. check if we need the 'default' visualization phase:
+ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
+ \ifx\pgfplots@basiclevel@plothandler\pgfplothandlerdiscard
+ % Ah - "only marks". In this case, we rely on the (special)
+ % marker visualization phase - there is no need for a further
+ % phase.
+ \pgfplotsutil@trim{#1}%
+ \ifx\pgfplotsretval\pgfutil@empty
+ % OK, we do not have after-path instructions.
+ % No need for this phase.
+ \let\pgfplotsretval=\pgfutil@empty
+ \else
+ % Hm. We found after-path instructions! These *need* to be
+ % done during the standard visualization phase. Ok, then
+ % do it, even if it has no uses otherwise!
+ \let\pgfplotsretval=\pgfplotsaxis@visphase@name@default
+ \fi
+ \else
+ \let\pgfplotsretval=\pgfplotsaxis@visphase@name@default
+ \fi
+ %
+ % 2. error bar phase:
+ \ifpgfplots@errorbars@enabled
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \edef\pgfplotsretval{\pgfplotsretval,}%
+ \fi
+ %
+ \edef\pgfplotsretval{\pgfplotsretval \pgfplotsaxis@visphase@name@errorbars}%
+ \fi
+ %
+ % markers have the special phase \pgfplots@markers@visphase@name .
+}%
+
+\def\pgfplotsaxis@visphase@name@default{default}
+\def\pgfplotsaxis@visphase@name@markers{markers}
+
+% This defines \pgfplots@visphase@default:
+\expandafter\def\csname pgfplots@visphase@\pgfplotsaxis@visphase@name@default\endcsname{%
+ \pgfplots@coord@stream@finalize@storedcoords@START
+}%
+
+% A routine which transforms the current set of
+% \pgfplots@current@point@[xyz] values to the coordinate system
+% accepted by the actual axis.
+\def\pgfplotsaxistransformfromdatacs{%
+ \pgfkeyslet{/data point/x}\pgfplots@current@point@x
+ \pgfkeyslet{/data point/y}\pgfplots@current@point@y
+ \pgfkeyslet{/data point/z}\pgfplots@current@point@z
+ \pgfplotsaxistransformcs
+ {\pgfkeysvalueof{/pgfplots/data cs}}
+ {\pgfkeysvalueof{/pgfplots/@expected axis cs}}%
+ \pgfkeysgetvalue{/data point/x}\pgfplots@current@point@x
+ \pgfkeysgetvalue{/data point/y}\pgfplots@current@point@y
+ \pgfkeysgetvalue{/data point/z}\pgfplots@current@point@z
+}%
+
+% Changes '/data point/[xyz]' to the new coordinate system
+% (cs) designated by '#2'.
+%
+% #1: the actual coordinate system's name
+% #2: the desired coordinate system's name
+%
+% PRECONDITION: '/data point/[xyz]' contain the current
+% point's coordinates in the '#1' system. The z coordinate is ignored for 2d plots (or
+% for coordinate systems which are inherently two-dimensional).
+%
+% POSTCONDITION: 'data point/[xyz]' contain same point as
+% before, but represented in the '#2' system.
+%
+% The coordinate system transformations must be defined,
+% see \pgfplotsdefinecstransform.
+%
+% Example:
+% \pgfkeyssetvalue{/data point/x}{90}
+% \pgfkeyssetvalue{/data point/y}{1}
+% \pgfplotsaxistransformcs{polar}{cart}
+% -->
+% \pgfkeysvalueof{/data point/x}= 0
+% \pgfkeysvalueof{/data point/y}= 1
+\def\pgfplotsaxistransformcs#1#2{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \edef\pgfplots@loc@TMPb{#2}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % nothing to do
+ \else
+ \pgfutil@ifundefined{pgfp@transform@\pgfplots@loc@TMPa @to@\pgfplots@loc@TMPb}{%
+ \pgfutil@ifundefined{pgfp@transform@\pgfplots@loc@TMPa @to@cart}{%
+ \pgfplotsaxistransformcs@error
+ }{%
+ \pgfplotsaxistransformcs{#1}{cart}%
+ \pgfplotsaxistransformcs{cart}{#2}%
+ }%
+ }{%
+ \csname pgfp@transform@\pgfplots@loc@TMPa @to@\pgfplots@loc@TMPb\endcsname
+ }%
+ \fi
+}%
+
+% Defines a new coordinate transformation for use in
+% \pgfplotsaxistransformcs.
+% #1: the source coordinate system
+% #2: the target coordinate system
+% #3: the transformation code.
+%
+% @see \pgfplotsaxistransformcs for what #3 should do.
+%
+% This does also declare a coordinate system for use in 'data cs'.
+% The minimal requirements are to define the transformations from and
+% to "cart" (cartesian coordinates).
+%
+\def\pgfplotsdefinecstransform#1#2#3{%
+ \expandafter\def\csname pgfp@transform@#1@to@#2\endcsname{#3}%
+}%
+
+\pgfplotsdefinecstransform{polar}{cart}{%
+ \pgfplotscoordmath{default}{parsenumber}{\pgfkeysvalueof{/data point/x}}%
+ \let\pgfplots@current@point@x=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\pgfkeysvalueof{/data point/y}}%
+ \let\pgfplots@current@point@y=\pgfmathresult
+ \pgfplotsmathpoltocart\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@x@\pgfplots@current@point@y@
+ \pgfplotscoordmath{x}{parsenumber}{\pgfplots@current@point@x@}%
+ \pgfkeyslet{/data point/x}\pgfmathresult
+ \pgfplotscoordmath{y}{parsenumber}{\pgfplots@current@point@y@}%
+ \pgfkeyslet{/data point/y}\pgfmathresult
+}%
+\pgfplotsdefinecstransform{cart}{polar}{%
+ \pgfplotscoordmath{default}{parsenumber}{\pgfkeysvalueof{/data point/x}}%
+ \let\pgfplots@current@point@x=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\pgfkeysvalueof{/data point/y}}%
+ \let\pgfplots@current@point@y=\pgfmathresult
+ \pgfplotsmathcarttopol\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@x@\pgfplots@current@point@y@
+ \pgfplotscoordmath{x}{parsenumber}{\pgfplots@current@point@x@}%
+ \pgfkeyslet{/data point/x}\pgfmathresult
+ \pgfplotscoordmath{y}{parsenumber}{\pgfplots@current@point@y@}%
+ \pgfkeyslet{/data point/y}\pgfmathresult
+}%
+
+\pgfplotsdefinecstransform{polarrad}{polar}{%
+ \pgfplotsgetcoordmathfor{default}\let\pgfplots@coordmath@id=\pgfplotsretval
+ \pgfutil@ifundefined{pgfp@polarradscale@\pgfplots@coordmath@id}{%
+ \pgfplotscoordmath{default}{parsenumber}{57.2957795130823}%
+ \expandafter\global\expandafter\let\csname pgfp@polarradscale@\pgfplots@coordmath@id\endcsname=\pgfmathresult
+ }{}%
+ %
+ \pgfplotscoordmath{default}{parsenumber}{\pgfkeysvalueof{/data point/x}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\csname pgfp@polarradscale@\pgfplots@coordmath@id\endcsname}}%
+ \pgfkeyslet{/data point/x}\pgfmathresult
+}%
+\pgfplotsdefinecstransform{polar}{polarrad}{%
+ \pgfplotsgetcoordmathfor{default}\let\pgfplots@coordmath@id=\pgfplotsretval
+ \pgfutil@ifundefined{pgfp@polarradiscale@\pgfplots@coordmath@id}{%
+ \pgfplotscoordmath{default}{parsenumber}{0.0174532925199433}%
+ \expandafter\global\expandafter\let\csname pgfp@polarradiscale@\pgfplots@coordmath@id\endcsname=\pgfmathresult
+ }{}%
+ %
+ \pgfplotscoordmath{default}{parsenumber}{\pgfkeysvalueof{/data point/x}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\csname pgfp@polarradiscale@\pgfplots@coordmath@id\endcsname}}%
+}%
+\pgfplotsdefinecstransform{polarrad}{cart}{%
+ \pgfplotsaxistransformcs{polarrad}{polar}%
+ \pgfplotsaxistransformcs{polar}{cart}%
+}%
+\pgfplotsdefinecstransform{cart}{polarrad}{%
+ \pgfplotsaxistransformcs{cart}{polar}%
+ \pgfplotsaxistransformcs{polar}{polarrad}%
+}%
+
+\def\pgfplotsaxistransformcs@error{%
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, I do not know how to transform the coordinate system '\pgfplots@loc@TMPa' to '\pgfplots@loc@TMPb'. Maybe you misspelled the 'data cs'? Or perhaps the feature is not yet implemented?}\pgfeov%
+}%
+
+% Takes the current point and serializes it into \pgfplotsretval.
+%
+% The serialization includes the coordinates (as returned by the
+% current plot handler), the point meta, and any "visualization
+% depends on" keys.
+%
+% See \pgfplotsaxisdeserializedatapointfrom
+%
+% POSTCONDITION:
+% \pgfplotsretval contains everything that is needed to restore the
+% current coordinate. This includes
+% - the coordinate values for x,y, and z
+% - any special coordinate values reported by the plot handler
+% (like u,v,w for quiver plots)
+% - the point meta
+% - any 'visualization depends on' value
+% - anything which is needed for other purposes (stacked plots have
+% a plugin).
+%
+% The result has an EXTRA SET OF BRACES which needs to be dealt with.
+%
+% Example:
+% \pgfplotsaxisserializedatapointtostring
+%
+% \expandafter\pgfplotsaxisdeserializedatapointfrom\pgfplotsretval
+%
+% -> note the absence of extra braces for the deserialization!
+\def\pgfplotsaxisserializedatapointtostring{%
+ \pgfplotsplothandlerserializepointto\pgfplotsaxisserializedatapoint@val
+ \let\pgfplots@oldprotect=\protect
+ \let\protect=\noexpand
+ \pgfplotsaxisserializedatapoint@private
+ \let\protect=\pgfplots@oldprotect
+ \t@pgfplots@toka=\expandafter{\pgfplotsaxisserializedatapoint@val}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsretval}%
+ \edef\pgfplotsretval{{\the\t@pgfplots@tokb;\the\t@pgfplots@toka}}%
+}%
+
+\def\pgfplotsaxisserializedatapoint{%
+ \pgfplotsaxisserializedatapointtostring
+ \expandafter\pgfplotsapplistXXpushback\expandafter{\pgfplotsretval}%
+}%
+\def\pgfplotsaxisserializedatapoint@private{%
+ \let\pgfplotsretval=\pgfplots@current@point@meta
+}%
+\def\pgfplotsaxisdeserializedatapointfrom@private#1{%
+ \def\pgfplots@current@point@meta{#1}%
+}%
+% Restores the variables serialized in '#1'.
+%
+% As a side--effect, the macro
+% \pgfplotsaxisdeserializedatapointfrom@private@lastvalue will contain
+% the serialized part which is specific to pgfplots (i.e. the private
+% parts which can be read with
+% \pgfplotsaxisdeserializedatapointfrom@private)
+\def\pgfplotsaxisdeserializedatapointfrom#1{%
+ \expandafter\pgfplotsaxisdeserializedatapointfrom@#1\pgfplots@EOI
+}%
+\def\pgfplotsaxisdeserializedatapointfrom@#1;#2\pgfplots@EOI{%
+ \def\pgfplotsaxisdeserializedatapointfrom@private@lastvalue{#1}%
+ \pgfplotsaxisdeserializedatapointfrom@private{#1}%
+ \pgfplotsplothandlerdeserializepointfrom{#2}%
+}%
+
+% Handle User-defined parts which should be serialized as well.
+% This preparation tool should be called at the start of both, survey
+% and visualization phase.
+%
+% @PRECONDITION
+% - the macros
+% \pgfplotsaxisserializedatapoint@private
+% \pgfplotsaxisdeserializedatapointfrom@private
+% are known and valid.
+% - '/pgfplots/visualization depends on' contains its correct value.
+%
+% @POSTCONDITION
+% Both,
+% \pgfplotsaxisserializedatapoint@private
+% and
+% \pgfplotsaxisdeserializedatapointfrom@private
+% have been patched to incorporate the '/pgfplots/visualization
+% depends on' feature.
+%
+\def\pgfplots@prepare@visualization@dependencies{%
+ \pgfkeysgetvalue{/pgfplots/visualization depends on/list}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ % SERIALIZATION format:
+ % visualization depends on={{value1}\as \macro1, {<value2>}\as \macro2,...}
+ % ->
+ % {<original private data>}<\macro1>{<value1>}<\macro2>{<value2>}...<\macroN>{<valueN>}
+ %
+ % prepare
+ % \t@pgfplots@tokb={<\macro1>{<value1>}<\macro2>{<value2>}...<\macroN>{<valueN>}}
+ \t@pgfplots@tokb={}%
+ %
+ % prepare
+ % \t@pgfplots@tokc={<\macro1><\macro2><\macro3>...}
+ \t@pgfplots@tokc={}%
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots@loc@TMPa}\as\pgfplots@loc@TMPa{%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\pgfplots@prepare@visualization@depends@on\pgfplots@loc@TMPa\pgfplots@EOI%
+ \fi
+ }%
+ % Step 1: modify the SERIALIZATION method:
+ \t@pgfplots@toka=\expandafter{\pgfplotsaxisserializedatapoint@private}%
+ \edef\pgfplotsaxisserializedatapoint@private{%
+ \the\t@pgfplots@tokc
+ \the\t@pgfplots@toka
+ % nothing is expanded here, only \t@pgfplots@tokb
+ \noexpand\t@pgfplots@toka=\noexpand\expandafter{\noexpand\pgfplotsretval}%
+ \noexpand\edef\noexpand\pgfplotsretval{{\noexpand\the\t@pgfplots@toka},\the\t@pgfplots@tokb}%
+ }%
+ % Step 2: modify the DESERIALIZATION method:
+ \let\pgfplotsaxisdeserializedatapointfrom@private@orig=\pgfplotsaxisdeserializedatapointfrom@private
+ \let\pgfplotsaxisdeserializedatapointfrom@private=\pgfplotsaxisdeserializedatapointfrom@private@withdeplist
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/execute for finished point}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\def\expandafter\pgfplotsaxisserializedatapoint@private\expandafter{%
+ \pgfplotsaxisserializedatapoint@private
+ \pgfkeysvalueof{/pgfplots/execute for finished point}%
+ }%
+ \fi
+}%
+\def\pgfplots@prepare@visualization@depends@on#1\pgfplots@EOI{%
+ \pgfutil@in@\as{#1}%
+ \ifpgfutil@in@
+ % ok, we have the '<content>\as<\macro>' syntax:
+ \pgfplots@prepare@visualization@depends@on@#1\pgfplots@EOI
+ \else
+ \pgfplots@prepare@visualization@depends@on@preparetype@checkvalue#1value\pgfplots@EOI
+ \ifpgfutil@in@
+ % ok, then it should be 'value <\macro>'.
+ % extract the <\macro>:
+ \def\pgfplots@loc@TMPa value{\pgfplots@loc@TMPb}%
+ \def\pgfplots@loc@TMPb##1{\pgfplots@loc@TMPc ##1}% this step should remove leading white spaces
+ \def\pgfplots@loc@TMPc##1\pgfplots@EOI{%
+ % sanitize: check if ##1 is a defined macro:
+ \begingroup
+ \escapechar=-1
+ \xdef\pgfplots@glob@TMPa{\string##1}%
+ \endgroup
+ \pgfutil@ifundefined{\pgfplots@glob@TMPa}{%
+ \begingroup
+ \t@pgfplots@toka={##1}%
+ \pgfplotsthrow{invalid argument}
+ {\pgfplots@loc@TMPa}%
+ {Sorry, `visualization depends on=value <\string\macro>' expected a defined control sequence name instead of `\the\t@pgfplots@toka'. Please make sure `\the\t@pgfplots@toka' is a properly defined macro or use the `visualization depends on=value <content> \string\as <\string\macro>' syntax instead}%
+ \pgfeov
+ \endgroup
+ }{%
+ \def\pgfplots@loc@TMPa{%
+ \pgfplots@prepare@visualization@depends@on@ value}%
+ \expandafter\pgfplots@loc@TMPa##1\as##1\pgfplots@EOI
+ }%
+ }%
+ \pgfplots@loc@TMPa#1\pgfplots@EOI
+ \else
+ % then, I expect '<\macro>'.
+ % sanitize: check if #1 is a defined macro:
+ \begingroup
+ \escapechar=-1
+ \xdef\pgfplots@glob@TMPa{\string#1}%
+ \endgroup
+ \pgfutil@ifundefined{\pgfplots@glob@TMPa}{%
+ \begingroup
+ \t@pgfplots@toka={#1}%
+ \pgfplotsthrow{invalid argument}
+ {\pgfplots@loc@TMPa}%
+ {Sorry, `visualization depends on' expected a defined control sequence name instead of `\the\t@pgfplots@toka'. Please make sure `\the\t@pgfplots@toka' is a properly defined macro or use the `visualization depends on=<expression> \string\as <\string\macro>' syntax instead}%
+ \pgfeov
+ \endgroup
+ }{%
+ \expandafter\pgfplots@prepare@visualization@depends@on@#1\as#1\pgfplots@EOI
+ }%
+ \fi
+ \fi
+}%
+\def\pgfplots@prepare@visualization@depends@on@#1\as#2\pgfplots@EOI{%
+ \pgfplots@prepare@visualization@depends@on@preparetype{#1}\as{#2}%
+ % prepare the serialization:
+ \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\noexpand#2{\csname\string#2@value\endcsname}}%
+ \t@pgfplots@tokc=\expandafter{\the\t@pgfplots@tokc\csname assign@\string#2\endcsname}%
+}%
+
+% task: define a macro '\csname assign@\string#2\endcsname' which, when executed,
+% defines \csname\string#2@value\endcsname such that it expands
+% to a the correct value.
+\def\pgfplots@prepare@visualization@depends@on@preparetype#1\as#2{%
+ \pgfplots@prepare@visualization@depends@on@preparetype@checkvalue#1value\pgfplots@EOI
+ \ifpgfutil@in@
+ \pgfplots@prepare@visualization@depends@on@preparetype@value#1\as{#2}% no braces here.
+ \else
+ \pgfplots@prepare@visualization@depends@on@preparetype@expr{#1}\as{#2}%
+ \fi
+}%
+\def\pgfplots@prepare@visualization@depends@on@preparetype@expr#1\as#2{%
+ \pgflibraryfpuifactive{%
+ \expandafter\def\csname assign@\string#2\endcsname{%
+ \pgfmathparse{#1}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \expandafter\let\csname \string#2@value\endcsname=\pgfmathresult
+ }%
+ }{%
+ \expandafter\def\csname assign@\string#2\endcsname{%
+ \pgfmathparse{#1}%
+ \expandafter\let\csname \string#2@value\endcsname=\pgfmathresult
+ }%
+ }%
+}
+\def\pgfplots@prepare@visualization@depends@on@preparetype@checkvalue#1value#2\pgfplots@EOI{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfutil@in@true
+ \else
+ \pgfutil@in@false
+ \fi
+}%
+\def\pgfplots@prepare@visualization@depends@on@preparetype@value value#1\as#2{%
+ % remove spaces from #1:
+ \pgfkeys@spdef\pgfplots@loc@TMPa{#1}%
+ %
+ % ok, prepare the value.
+ \def\pgfplots@loc@TMPb{#2}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ % oh - a special case! We have value\macro\as\macro.
+ \expandafter\def\csname\string#2@value\endcsname{#2}%
+ %
+ % this is special; we do not need to EXECUTE assign@\string#2 to arrive at its value.
+ % But we need to define #2@value as that will be stored.
+ \expandafter\let\csname assign@\string#2\endcsname=\relax
+ \else
+ \begingroup
+ \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}%
+ \t@pgfplots@tokb=\expandafter{\csname\string#2@value\endcsname}%
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\the\t@pgfplots@tokb{\the\t@pgfplots@toka}%
+ }%
+ \endgroup
+ \expandafter\let\csname assign@\string#2\endcsname=\pgfplots@glob@TMPa
+ \fi
+}
+
+\def\pgfplotsaxisdeserializedatapointfrom@private@withdeplist#1{%
+ \pgfplotsaxisdeserializedatapointfrom@private@withdeplist@#1\pgfplots@EOI
+}%
+\def\pgfplotsaxisdeserializedatapointfrom@private@withdeplist@#1,{%
+ \pgfplotsaxisdeserializedatapointfrom@private@orig{#1}%
+ \pgfplotsaxisdeserializedatapointfrom@private@withdeplist@@
+}%
+\def\pgfplotsaxisdeserializedatapointfrom@private@withdeplist@@#1{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@EOI
+ \else
+ \afterassignment\pgfplotsaxisdeserializedatapointfrom@private@withdeplist@@
+ \expandafter\def\expandafter#1%
+ \fi
+}%
+
+% 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{%
+ \pgfplotscoordmath{#1}{if less than}
+ {\csname pgfplots@currentplot@firstcoord@#1\endcsname}%
+ {\csname pgfplots@currentplot@lastcoord@#1\endcsname}%
+ {\pgfkeyssetvalue{/pgfplots/#1 coord sorting}{+}}%
+ {\pgfkeyssetvalue{/pgfplots/#1 coord sorting}{-}}%
+}%
+
+% Defines the linear transformation macro \pgfplots@perpointmeta@trafo,
+%
+% phi : [meta_min,meta,max] -> [0,10^k]
+%
+% which operates on the per-point meta data (if any).
+% 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 \pgfplotscolormapaccess (or
+% \pgfplotscolormapdefinemappedcolor). Thus, the 10^k is chosen to be
+% the same as \pgfplotscolormaprange (which is 1000 per default).
+%
+% 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.
+%
+% Note: it does not hurt to call it multiple times. It checks automatically whether it already is up-to-date.
+\def\pgfplots@perpointmeta@preparetrafo{%
+ \def\pgfplotspointmetarangeexponent{1}% pre-fill
+ \pgfutil@ifundefined{pgfplots@perpointmeta@trafo}{%
+ \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
+ %
+ \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
+ \pgfplotscoordmath{meta}{tostring}{##1}%
+ \pgfplotswarning{point meta unbounded}{\pgfmathresult}{##1}\pgfeov
+ \endgroup
+ \gdef\pgfplots@perpointmeta@unboundedwarning@stop{1}%
+ \fi
+ }%
+ \else
+ \def\pgfplots@perpointmeta@unboundedwarning##1{}%
+ \fi
+ \if d\pgfplots@colormap@access
+ % colormap access=direct
+ \def\pgfplots@perpointmeta@trafo##1{%
+ \pgfplotscoordmath{meta}{if is}{##1}{u}{%
+ \pgfplotscolorzero{\pgfplotscolormapcolorcompsof{\pgfkeysvalueof{/pgfplots/colormap name}}}%
+ \pgfplots@perpointmeta@unboundedwarning{##1}%
+ }{%
+ \pgfplotscoordmath{meta}{tofixed}{##1}%
+ \pgfplotscolormapgetindex{\pgfmathresult}{\pgfkeysvalueof{/pgfplots/colormap name}}%
+ }%
+ }%
+ \def\pgfplots@perpointmeta@traforange{0:0}%
+ \edef\pgfplotspointmetarange{\pgfplots@metamin:\pgfplots@metamax}%
+ \else
+ % colormap access=map|piecewise constant
+ \ifx\pgfplots@metamax\pgfutil@empty
+ \def\pgfplots@perpointmeta@trafo##1{%
+ \pgfplotscoordmath{meta}{if is}{##1}{u}
+ {%
+ \def\pgfmathresult{0}%
+ \pgfplots@perpointmeta@unboundedwarning{##1}%
+ }{%
+ \pgfplotscoordmath{meta}{tofixed}{##1}%
+ }%
+ }%
+ \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!
+ \if\pgfplots@perpointmeta@rel@choice0%
+ % point meta rel=axis wide:
+ \pgfplots@perpointmeta@preparetrafo@initfrom{pgfplots@axiswide@}%
+ \else
+ \pgfplots@perpointmeta@preparetrafo@initfrom{pgfplots@}%
+ \fi
+ \fi
+ \fi
+ \edef\pgfplotspointmetatransformedrange{\pgfplots@perpointmeta@traforange}%
+ }{}%
+}%
+
+% Employs \csname #1metamin\endcsname and its metamax counterpart to
+% initialize the trafo.
+%
+% This unifies the approaches for \pgfplots@axiswide@metamax and
+% \pgfplots@metamax.
+\def\pgfplots@perpointmeta@preparetrafo@initfrom#1{%
+ \edef\pgfplotspointmetarange{\csname #1metamin\endcsname:\csname #1metamax\endcsname}%
+ % Now, prepare the trafo as such.
+ % It assigns \pgfmathresult (in fixed point).
+ \ifpgfplots@LUA@backend@supported
+ \def\pgfplots@perpointmeta@trafo##1{%
+ \edef\pgfmathresult{%
+ \pgfplotsutil@directlua{%
+ pgfplots.texPerpointMetaTrafo("\pgfplots@current@point@meta")
+ }%
+ }%
+ }%
+ \else
+ \def\pgfplots@perpointmeta@trafo##1{%
+ \pgfplotscoordmath{meta}{if is}{##1}{u}{%
+ \def\pgfmathresult{0}%
+ \pgfplots@perpointmeta@unboundedwarning{##1}%
+ }{%
+ \pgfplotscoordmath{meta}{op}{subtract}{{##1}{\csname #1metamin\endcsname}}%
+ \pgfplotscoordmath{meta}{op}{multiply}{{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}}%
+ \pgfplots@perpointmeta@trafo@clipresult
+ \pgfplotscoordmath{meta}{tofixed}{\pgfmathresult}%
+ }%
+ }%
+ \pgfplotscoordmath{meta}{op}{subtract}{{\csname #1metamax\endcsname}{\csname #1metamin\endcsname}}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{meta}{zero}%
+ \let\pgfplots@perpointmeta@lowerrange=\pgfmathresult
+ \pgfplotscoordmath{meta}{parsenumber}{1000}%
+ \let\pgfplots@perpointmeta@upperrange=\pgfmathresult
+ \pgfplotscoordmath{meta}{op}{divide}{{\pgfmathresult}{\pgfplots@loc@TMPa}}%
+ \let\pgfplots@perpointmeta@trafo@factor=\pgfmathresult
+ \fi
+ %
+ % Expands to the transformation range as 'a:b':
+ \def\pgfplots@perpointmeta@traforange{0:1000}%
+ %
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname #1metamax\endcsname
+ \pgfplotscoordmath{meta}{tostring}{\pgfplots@loc@TMPa}%
+ \pgfmathfloatparsenumber\pgfmathresult
+ \pgfmathfloatgetexponent\pgfmathresult\c@pgf@countd
+ \edef\pgfplotspointmetarangeexponent{\the\c@pgf@countd}%
+}
+
+\def\pgfplots@perpointmeta@trafo@clipresult{%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{meta}{if less than}{\pgfplots@loc@TMPa}{\pgfplots@perpointmeta@upperrange}{%
+ \pgfplotscoordmath{meta}{if less than}{\pgfplots@loc@TMPa}{\pgfplots@perpointmeta@lowerrange}{%
+ \let\pgfmathresult=\pgfplots@perpointmeta@lowerrange
+ }{%
+ \let\pgfmathresult=\pgfplots@loc@TMPa
+ }%
+ }{%
+ \let\pgfmathresult=\pgfplots@perpointmeta@upperrange
+ }%
+}%
+
+% define it globally - this simplifies some mesh plots.
+\pgfplotscoordmath{meta}{one}%
+\let\pgfplotspointmeta=\pgfmathresult
+\def\pgfplotspointmetatransformed{1000}% use the maximum because it is usually divided by 1000
+
+% A command which is readily available during the visualization phase of each plot.
+%
+% It takes existing point meta data and transforms it, i.e. it defines
+% \pgfplotspointmetatransformed.
+%
+% The command won't be invoked automatically, it is task of a plot
+% handler to decide if it is needed. It's application is relatively
+% fast, however.
+%
+% PRECONDITION:
+% - point meta has been set up during the survey phase (i.e. the
+% /pgfplots/point meta!=none),
+% - there *is* point meta data for the current data point.
+%
+% POSTCONDITION:
+% - the macros \pgfplotspointmeta and \pgfplotspointmetatransformed
+% are defined.
+%
+% @see also \pgfplotsaxisifhaspointmeta
+\def\pgfplotsaxisvisphasetransformpointmeta{%
+ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname
+ % symbolic point meta may be empty.
+ \let\pgfplotspointmeta=\pgfplots@current@point@meta
+ \let\pgfplotspointmetatransformed=\pgfplotspointmeta
+ \else
+ % numeric point meta may NOT be empty.
+ \ifx\pgfplots@current@point@meta\pgfutil@empty%
+ \pgfplots@error{%
+ could not access the 'point meta=\csname pgfpmeta@\pgfplotspointmetainputhandler @tostring\endcsname' for coordinate \the\c@pgfplots@coordindex: %
+ its value is empty. %
+ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @explicitinput\endcsname%
+ \pgfplots@addplot@point@meta@description@of@explicit@value
+ \else
+ Please ensure that the value exists and is not empty
+ \fi
+ }%
+ \pgfplotscoordmath{meta}{one}%
+ \let\pgfplotspointmeta=\pgfmathresult
+ \def\pgfplotspointmetatransformed{1.0}%
+ \else
+ % prepare arguments:
+ \let\pgfplotspointmeta=\pgfplots@current@point@meta
+ \pgfplots@perpointmeta@trafo{\pgfplotspointmeta}%
+ \let\pgfplotspointmetatransformed=\pgfmathresult
+ \fi
+ \fi
+}%
+\def\pgfplots@addplot@point@meta@description@of@explicit@value{%
+ Please use an input stream which provides 'explicit point meta' like \string\addplot\space table or \string\addplot\space coordinates
+}
+
+\def\pgfplotsaxisvisphasetransformpointmetaifany{%
+ \pgfplotsaxisifhaspointmeta{\pgfplotsaxisvisphasetransformpointmeta}{}%
+}
+
+% A looping method which applies
+% \pgfplots@coord@stream@start
+% for each coordinate '(x,y)' or '(x,y) +- (ex,ey)',
+% assign \pgfplots@current@point@[xyz]
+% assign \pgfplots@current@point@[xyz]@error (if in argument list)
+% assign \pgfplots@current@point@meta
+% call \pgfplots@coord@stream@coord
+% \pgfplots@coord@stream@end
+%
+% #1 a sequence of coordinates of the form
+% '(x,y)' or '(x,y,z)'
+% or
+% '(x,y[,z]) +- (ex,ey)'
+% or
+% '(x,y[,z]) += (ex+,ey+) -= (ex-,ey-)'
+% or
+% '(x,y) [meta]'
+% or
+% '(x,y) +- (ex,ey) [meta]'
+% separated by white-space.
+%
+\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
+}%
+
+\begingroup
+\def\\{\global\let\pgfplots@let@space@token= } \\ % now, \pgfplots@let@space@token is a space token
+\endgroup
+
+
+% A looping command to loop through plot coordinates.
+% For every point, \pgfplots@coord@stream@coord will be invoked.
+%
+% No scoping is used during this operation, so you can access outer
+% variables.
+\def\pgfplots@foreach@plot@coord@ITERATE{%
+ \futurelet\pgfplots@foreach@plot@coord@ITERATE@tok\pgfplots@foreach@plot@coord@ITERATE@
+}%
+\long\def\pgfplots@foreach@plot@coord@ITERATE@#1{%
+ \ifx\pgfplots@foreach@plot@coord@ITERATE@tok(%
+ \pgfplotsscanlinelengthincrease
+ \let\pgfplots@loop@next=\pgfplots@foreach@plot@coord@NEXT%
+ \else
+ \ifx\pgfplots@foreach@plot@coord@ITERATE@tok\pgfplots@let@space@token
+ \def\pgfplots@loop@next{\pgfplots@foreach@plot@coord@ITERATE#1}%
+ \else
+ \ifx\pgfplots@foreach@plot@coord@ITERATE@tok\pgfplots@EOI
+ % ok, do nothing more
+ \let\pgfplots@loop@next=\relax
+ \else
+ \ifx\pgfplots@foreach@plot@coord@ITERATE@tok\par
+ \pgfplotsscanlinecomplete
+ \let\pgfplots@loop@next=\pgfplots@foreach@plot@coord@ITERATE
+ \else
+ \if\noexpand\pgfplots@foreach@plot@coord@ITERATE@tok\noexpand\anymacro
+ % Ah. #1 has the same character (!) code as \anymacro,
+ % that means it is a macro! Expand it:
+ \def\pgfplots@loop@next{\expandafter\pgfplots@foreach@plot@coord@ITERATE#1}%
+ \else
+ \def\pgfplots@loop@next{\pgfplots@foreach@plot@coord@error#1}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \pgfplots@loop@next
+}
+
+\long\def\pgfplots@foreach@plot@coord@error#1\pgfplots@EOI{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPa
+ \pgfplots@error{Sorry, I could not read the plot coordinates near '\pgfplots@loc@TMPa'. Please check for format mistakes}%
+}%
+\def\pgfplots@foreach@plot@coord@NEXT#1,#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
+ \let\pgfplots@current@point@error@x@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@x@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@minus=\pgfutil@empty
+ \let\pgfplots@current@point@meta=\pgfutil@empty
+ \pgfplots@foreach@plot@coord@NEXT@cont
+}
+\def\pgfplots@foreach@plot@coord@NEXT@cont{%
+ \pgfutil@ifnextchar+{%
+ \pgfplots@foreach@plot@coord@NEXT@plus%
+ }{%
+ \pgfutil@ifnextchar-{%
+ \pgfplots@foreach@plot@coord@NEXT@minus%
+ }{%
+ \pgfutil@ifnextchar[{%
+ \pgfplots@foreach@plot@coord@NEXT@meta
+ }{%
+ \pgfplots@coord@stream@coord
+ \pgfplots@foreach@plot@coord@ITERATE
+ }%
+ }%
+ }%
+}
+\def\pgfplots@foreach@plot@coord@NEXT@meta[#1]{%
+ \def\pgfplots@current@point@meta{#1}%
+ \pgfplots@coord@stream@coord
+ \pgfplots@foreach@plot@coord@ITERATE
+}%
+\def\pgfplots@foreach@plot@coord@NEXT@plus+{%
+ \pgfutil@ifnextchar={%
+ \pgfplots@foreach@plot@coord@NEXT@pluseq%
+ }{%
+ \pgfplots@foreach@plot@coord@NEXT@plusminus%
+ }%
+}
+\def\pgfplots@foreach@plot@coord@NEXT@minus-=#1({%
+ \def\pgfplots@foreach@plot@coord@state{-}%
+ \pgfplots@foreach@plot@coord@NEXT@WITH@ERRORRANGE@
+}
+\def\pgfplots@foreach@plot@coord@NEXT@pluseq=#1({%
+ \def\pgfplots@foreach@plot@coord@state{+}%
+ \pgfplots@foreach@plot@coord@NEXT@WITH@ERRORRANGE@
+}
+\def\pgfplots@foreach@plot@coord@NEXT@plusminus-#1({%
+ \def\pgfplots@foreach@plot@coord@state{B}%
+ \pgfplots@foreach@plot@coord@NEXT@WITH@ERRORRANGE@
+}
+
+% processing something like '(x,y) +- (error_x,error_y)'
+\def\pgfplots@foreach@plot@coord@NEXT@WITH@ERRORRANGE@#1,#2){%
+ \ifpgfplots@plot@coords@mathparser
+ \pgfmathparse{#1}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfmathparse{#2}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult
+ \else
+ \def\pgfplots@loc@TMPb{#1}%
+ \def\pgfplots@loc@TMPc{#2}%
+ \fi
+ %
+ \if +\pgfplots@foreach@plot@coord@state
+ % ah, it was a "+=" item:
+ \let\pgfplots@current@point@error@x@plus=\pgfplots@loc@TMPb
+ \let\pgfplots@current@point@error@y@plus=\pgfplots@loc@TMPc
+ \else
+ \if -\pgfplots@foreach@plot@coord@state
+ % ah, it was a "-=" item:
+ \let\pgfplots@current@point@error@x@minus=\pgfplots@loc@TMPb
+ \let\pgfplots@current@point@error@y@minus=\pgfplots@loc@TMPc
+ \else
+ % ah, it was a "+-" item:
+ \let\pgfplots@current@point@error@x@plus=\pgfplots@loc@TMPb
+ \let\pgfplots@current@point@error@x@minus=\pgfplots@loc@TMPb
+ \let\pgfplots@current@point@error@y@plus=\pgfplots@loc@TMPc
+ \let\pgfplots@current@point@error@y@minus=\pgfplots@loc@TMPc
+ \fi
+ \fi
+ %
+ \pgfplots@foreach@plot@coord@NEXT@cont
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+% 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{%
+ \futurelet\pgfplots@foreach@plot@coord@threedim@ITERATE@tok\pgfplots@foreach@plot@coord@threedim@ITERATE@
+}%
+\long\def\pgfplots@foreach@plot@coord@threedim@ITERATE@#1{%
+ \ifx\pgfplots@foreach@plot@coord@threedim@ITERATE@tok(%
+ \pgfplotsscanlinelengthincrease
+ \let\pgfplots@loop@next=\pgfplots@foreach@plot@coord@threedim@NEXT%
+ \else
+ \ifx\pgfplots@foreach@plot@coord@threedim@ITERATE@tok\pgfplots@let@space@token
+ \def\pgfplots@loop@next{\pgfplots@foreach@plot@coord@threedim@ITERATE#1}%
+ \else
+ \ifx\pgfplots@foreach@plot@coord@threedim@ITERATE@tok\pgfplots@EOI
+ % ok, do nothing more
+ \let\pgfplots@loop@next=\relax
+ \else
+ \ifx\pgfplots@foreach@plot@coord@threedim@ITERATE@tok\par
+ \pgfplotsscanlinecomplete
+ \let\pgfplots@loop@next=\pgfplots@foreach@plot@coord@threedim@ITERATE
+ \else
+ \if\noexpand\pgfplots@foreach@plot@coord@threedim@ITERATE@tok\noexpand\anymacro
+ % Ah. #1 has the same character (!) code as \anymacro,
+ % that means it is a macro! Expand it:
+ \def\pgfplots@loop@next{\expandafter\pgfplots@foreach@plot@coord@threedim@ITERATE#1}%
+ \else
+ \def\pgfplots@loop@next{\pgfplots@foreach@plot@coord@error#1}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \pgfplots@loop@next
+}
+\def\pgfplots@foreach@plot@coord@threedim@NEXT#1,#2,#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
+ \let\pgfplots@current@point@error@x@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@x@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@z@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@z@minus=\pgfutil@empty
+ %
+ \let\pgfplots@current@point@meta=\pgfutil@empty
+ %
+ \pgfplots@foreach@plot@coord@threedim@NEXT@cont
+}
+\def\pgfplots@foreach@plot@coord@threedim@NEXT@cont{%
+ \pgfutil@ifnextchar+{%
+ \pgfplots@foreach@plot@coord@threedim@NEXT@plus%
+ }{%
+ \pgfutil@ifnextchar-{%
+ \pgfplots@foreach@plot@coord@threedim@NEXT@minus%
+ }{%
+ \pgfutil@ifnextchar[{%
+ \pgfplots@foreach@plot@coord@threedim@NEXT@meta
+ }{%
+ \pgfplots@coord@stream@coord
+ \pgfplots@foreach@plot@coord@threedim@ITERATE
+ }%
+ }%
+ }%
+}
+\def\pgfplots@foreach@plot@coord@threedim@NEXT@meta[#1]{%
+ \def\pgfplots@current@point@meta{#1}%
+ \pgfplots@coord@stream@coord
+ \pgfplots@foreach@plot@coord@threedim@ITERATE
+}%
+
+\def\pgfplots@foreach@plot@coord@threedim@NEXT@plus+{%
+ \pgfutil@ifnextchar={%
+ \pgfplots@foreach@plot@coord@threedim@NEXT@pluseq%
+ }{%
+ \pgfplots@foreach@plot@coord@threedim@NEXT@plusminus%
+ }%
+}
+\def\pgfplots@foreach@plot@coord@threedim@NEXT@minus-=#1({%
+ \def\pgfplots@foreach@plot@coord@state{-}%
+ \pgfplots@foreach@plot@coord@threedim@NEXT@WITH@ERRORRANGE@
+}
+\def\pgfplots@foreach@plot@coord@threedim@NEXT@pluseq=#1({%
+ \def\pgfplots@foreach@plot@coord@state{+}%
+ \pgfplots@foreach@plot@coord@threedim@NEXT@WITH@ERRORRANGE@
+}
+\def\pgfplots@foreach@plot@coord@threedim@NEXT@plusminus-#1({%
+ \def\pgfplots@foreach@plot@coord@state{B}%
+ \pgfplots@foreach@plot@coord@threedim@NEXT@WITH@ERRORRANGE@
+}
+% processing something like '(x,y) +- (error_x,error_y)'
+\def\pgfplots@foreach@plot@coord@threedim@NEXT@WITH@ERRORRANGE@#1,#2,#3){%
+ \ifpgfplots@plot@coords@mathparser
+ \pgfmathparse{#1}\let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfmathparse{#2}\let\pgfplots@loc@TMPc=\pgfmathresult
+ \pgfmathparse{#3}\let\pgfplots@loc@TMPd=\pgfmathresult
+ \else
+ \def\pgfplots@loc@TMPb{#1}%
+ \def\pgfplots@loc@TMPc{#2}%
+ \def\pgfplots@loc@TMPd{#3}%
+ \fi
+ %
+ \if +\pgfplots@foreach@plot@coord@state
+ % ah, it was a "+=" item:
+ \let\pgfplots@current@point@error@x@plus=\pgfplots@loc@TMPb
+ \let\pgfplots@current@point@error@y@plus=\pgfplots@loc@TMPc
+ \let\pgfplots@current@point@error@z@plus=\pgfplots@loc@TMPd
+ \else
+ \if -\pgfplots@foreach@plot@coord@state
+ % ah, it was a "-=" item:
+ \let\pgfplots@current@point@error@x@minus=\pgfplots@loc@TMPb
+ \let\pgfplots@current@point@error@y@minus=\pgfplots@loc@TMPc
+ \let\pgfplots@current@point@error@z@minus=\pgfplots@loc@TMPd
+ \else
+ % ah, it was a "+-" item:
+ \let\pgfplots@current@point@error@x@plus=\pgfplots@loc@TMPb
+ \let\pgfplots@current@point@error@x@minus=\pgfplots@loc@TMPb
+ \let\pgfplots@current@point@error@y@plus=\pgfplots@loc@TMPc
+ \let\pgfplots@current@point@error@y@minus=\pgfplots@loc@TMPc
+ \let\pgfplots@current@point@error@z@plus=\pgfplots@loc@TMPd
+ \let\pgfplots@current@point@error@z@minus=\pgfplots@loc@TMPd
+ \fi
+ \fi
+ %
+ \pgfplots@foreach@plot@coord@threedim@NEXT@cont
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+%
+% A coordinate stream which works like this:
+%
+% -------------
+% \pgfplots@coord@stream@start
+%
+% foreach encoded coordinate:
+% \def\pgfplots@coord@stream@foreach@NORMALIZED@curencoded{<encoded data>}%
+% \def\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced{{<encoded data>}}% note the extra braces.
+% \pgfplotsaxisdeserializedatapointfrom{<encoded data>}
+% \pgfplots@coord@stream@coord
+%
+% \pgfplots@coord@stream@end
+% -------------
+%
+% The format of #1 is
+% {<datapoint>}{<datapoint>}...{<datapoint>}
+% Each data point is decoded with
+% \pgfplotsaxisserializedatapoint
+% and then, \pgfplots@coord@stream@coord will be called.
+\long\def\pgfplots@coord@stream@foreach@NORMALIZED#1{%
+ \pgfplots@coord@stream@start
+ \pgfplotscoordstream@firstlast@init
+ \pgfplots@foreach@plot@coord@NORMALIZED@ITERATE#1\pgfplots@EOI%
+ \pgfplots@coord@stream@end
+}%
+% No scoping is used during this operation, so you can access outer
+% variables.
+\def\pgfplots@foreach@plot@coord@NORMALIZED@ITERATE#1{%
+ \def\pgfplots@coord@stream@foreach@NORMALIZED@curencoded{#1}%
+ \ifx\pgfplots@coord@stream@foreach@NORMALIZED@curencoded\pgfplots@EOI
+ \else
+ \def\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced{{#1}}%
+ \pgfplotsaxisdeserializedatapointfrom{#1}%
+ \pgfplots@coord@stream@coord
+ \pgfplotsplothandlerifcurrentpointcanbefirstlast{%
+ \pgfplotscoordstream@firstlast@update
+ }{}%
+ \expandafter\pgfplots@foreach@plot@coord@NORMALIZED@ITERATE
+ \fi
+}
+
+% 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\pgfplotsaxisplotphase{S}% "in survey"
+ \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
+ \def\pgfplots@addplot@running{1}%
+ %
+ \def\pgfplots@colorbar@set@src{0}%
+ \pgfkeysdef{/pgfplots/colorbar source}{%
+ \pgfplotsutilifstringequal{##1}{true}{%
+ \def\pgfplots@colorbar@set@src{1}%
+ }{%
+ \pgfplotsutilifstringequal{##1}{false}{%
+ \def\pgfplots@colorbar@set@src{0}%
+ }{%
+ \pgfplots@error{Sorry, I don't know the value `colorbar source={##1}' and I am going to ignore it. Maybe you misspelled it?}%
+ }%
+ }%
+ }%
+ %
+ \pgfplots@start@plot@with@behavioroptions@setkeys{#1}%
+ %
+ % enable FPU after any \pgfplotsset operations. Otherwise things like
+ % linewidth=... which use the math parser might fail.
+ \ifpgfplots@usefpu
+ \pgfkeys{/pgf/fpu=true,%
+ /pgf/fpu/output format=float,%
+ }%
+ \fi
+ %
+ % make sure it is reset, just in case it is not supported by the
+ % input method.
+ \pgfplotsscanlinelengthinitzero
+ %
+ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
+ \pgfplotsresetplothandler
+ \pgfplots@basiclevel@plothandler
+ %
+ \pgfplots@countplots@init
+ %
+ % hooks:
+ \pgfkeysvalueof{/pgfplots/execute at begin plot@@}%
+ \pgfkeysvalueof{/pgfplots/execute at begin plot}%
+ %
+ \if1\pgfplots@colorbar@set@src
+ \t@pgfplots@tokc={/pgfplots/point meta rel=per plot}%
+ \t@pgfplots@toka=\expandafter{\pgfplots@addplot@survey@@optionlist}%
+ \edef\pgfplots@addplot@survey@@optionlist{\the\t@pgfplots@tokc,\the\t@pgfplots@toka}%
+ \fi
+ %
+ %
+ \pgfplots@validate@plot@domain@arguments
+}
+
+\def\pgfplots@disable@non@survey@keys{%
+ %
+ % this here would try to compute something. DON'T DO THIS DURING
+ % SURVEY!
+ \pgfkeysdef{/tikz/name intersections}{}%
+ \pgfkeysdef{/tikz/intersection segments}{}%
+ %
+}%
+
+\def\pgfplots@start@plot@with@behavioroptions@setkeys#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.}%
+% }%
+ % ATTENTION:
+ % as of january 30, 2010, I will set /tikz keys as well. This won't hurt
+ % too much, I hope... there are no graphics operations anyway. But it *is*
+ % necessary since I *need* the plot handler for the new version. And the plot
+ % handler is, most likely, a /tikz key.
+ %
+ % it is possible that '#1' contains 'forget plot'. So, we need to
+ % set the options before checking \ifpgfplots@curplot@isirrelevant:
+ \pgfplots@disable@non@survey@keys
+ \pgfplotsset{/pgfplots/every axis plot,#1}%
+ %
+ \ifpgfplots@curplot@isirrelevant
+ \def\pgfplots@addplot@survey@@optionlist{/pgfplots/every axis plot,/pgfplots/every forget plot}%
+ \pgfplotsset{/pgfplots/every forget plot,/pgfplots/every axis plot post}%
+ \else
+ \edef\pgfplots@addplot@survey@@optionlist{%
+ /pgfplots/every axis plot,%
+ /pgfplots/every axis plot except legend,%
+ /pgfplots/every axis plot no \the\pgfplots@numplots/.try}%
+ \pgfplotsset{%
+ /pgfplots/every axis plot except legend,
+ /pgfplots/every axis plot no \the\pgfplots@numplots/.try,%
+ /pgfplots/every axis plot post}%
+ \fi
+ %
+ \t@pgfplots@tokc=\expandafter{\pgfplots@addplot@survey@@optionlist,#1}% this allows '#' inside of '#1'
+ \edef\pgfplots@addplot@survey@@optionlist{\the\t@pgfplots@tokc}%
+ %
+ \pgfplots@set@trig@format@plots
+}
+
+\long\def\pgfplotssurveyphaseaddoptionsbeforesurveybegins#1{%
+ \pgfplotsset{%
+ /pgfplots/execute at end survey/.add={}{%
+ \t@pgfplots@tokc=\expandafter{\pgfplots@addplot@survey@@optionlist,#1}% this allows '#' inside of '#1'
+ \edef\pgfplots@addplot@survey@@optionlist{\the\t@pgfplots@tokc}%
+ },%
+ #1%
+ }%
+}%
+\long\def\pgfplotsplothandlersurveyaddoptions#1{%
+ \t@pgfplots@tokc=\expandafter{\pgfplots@addplot@survey@@optionlist,#1}% this allows '#' inside of '#1'
+ \edef\pgfplots@addplot@survey@@optionlist{\the\t@pgfplots@tokc}%
+ \pgfplotsset{#1}%
+}%
+
+
+% The main interface to draw a plot into an axis.
+%
+% Usage:
+% \addplot
+% plot coordinates {
+% (0,0)
+% (1,1)
+% };
+%
+% or
+%
+% \addplot[color=blue,mark=*]
+% plot coordinates {
+% (0,0)
+% (1,1)
+% };
+%
+% or one of the other input types.
+%
+% The first syntax will use the next plot specification in the list
+% \autoplotspeclist
+% and the first will use blue color and * markers.
+%
+% \addplot [<style options>] plot[<behavior options>] <input type and args> <post plot path> ;
+% \addplot3[<style options>] plot[<behavior options>] <input type and args> <post plot path> ;
+%
+% The complete accumulation is done GLOBALLY. It should be safe to put
+% '\addplot' into local groups.
+%
+%
+% The linespec. will be used in the legend.
+%
+% Low-level implementation:
+%
+% \pgfplots@addplot
+% \pgfplots@addplotimpl
+% \pgfplots@start@plot@with@behavioroptions <--- \begingroup
+% ...
+% ... remember options GLOBALLY
+% ... update limits GLOBALLY
+% ... \pgfplots@addplot@enqueue@coords GLOBALLY
+% ...
+% \pgfplots@end@plot <--- \endgroup
+\def\pgfplots@addplot{%
+ \pgfutil@ifnextchar3{%
+ \pgfplots@curplot@threedimtrue
+ \pgfplots@addplot@three
+ }{%
+ \pgfplots@curplot@threedimfalse
+ \pgfplots@addplot@
+ }%
+}
+\def\pgfplots@addplot@three3{\pgfplots@addplot@}%
+\def\pgfplots@addplot@{%
+ \pgfutil@ifnextchar+{%
+ \pgfplots@getautoplotspec into\nextplotspec
+ \pgfplots@addplotimplAPPEND
+ }{%
+ \pgfutil@ifnextchar[{%
+ \pgfplots@addplotimpl%
+ }{%
+ \pgfplots@getautoplotspec into\nextplotspec
+ % the space after ']' is required here:
+ % FIXME:
+ % - \addplot[]plot coordinates is NOT allowed!?
+ \expandafter\pgfplots@addplotimpl\expandafter[\nextplotspec]%
+ }%
+ }%
+}
+
+\def\pgfplots@addplotimplAPPEND+{\pgfutil@ifnextchar[{\pgfplots@addplotimplAPPEND@}{\pgfplots@addplotimplAPPEND@[]}}% this allows to gobble spaces and to skip the '[]'
+\def\pgfplots@addplotimplAPPEND@[{%
+ \expandafter\pgfplots@addplotimpl\expandafter[\nextplotspec,%
+}
+
+\long\def\pgfplots@addplotimpl[#1]{%
+ \pgfplotsutil@ifnextchar p{%
+ \pgfplots@addplotimpl@plot{#1}%
+ }{%
+ \pgfplots@addplotimpl@plot{#1}plot
+ }%
+}
+
+\long\def\pgfplots@addplotimpl@plot#1plot{%
+ \pgfplotsutil@ifnextchar[{%
+ \pgfplots@addplotimpl@plot@withoptions{#1}%
+ }{%
+ \pgfplots@addplotimpl@plot@withoptions{#1}[]%
+ }%
+}
+
+\long\def\pgfplots@addplotimpl@plot@withoptions#1[#2]{
+ \begingroup% <-- This groups ends in \pgfplots@end@plot
+ %
+ \pgfplotsutil@ifnextchar c{%
+ \pgfplots@addplotimpl@coordinates{#1}{#2}plot
+ }{%
+ \pgfplotsutil@ifnextchar f{%
+ \pgfplots@addplotimpl@f{#1}{#2}%
+ }{%
+ \pgfplotsutil@ifnextchar t{%
+ \def\pgfplotssurveyphaseinputclass{table}%
+ \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2}%
+ \pgfplots@addplotimpl@table{#1,#2}%
+ }{%
+ \pgfplotsutil@ifnextchar ({%
+ \pgfplots@addplotimpl@expression{#1}{#2}%
+ }{%
+ \pgfplotsutil@ifnextchar\bgroup{%
+ \pgfplots@addplotimpl@expression@curly{#1}{#2}%
+ }{%
+ \pgfplotsutil@ifnextchar e{%
+ \pgfplots@addplotimpl@expression@e{#1}{#2}%
+ }{%
+ \pgfplotsutil@ifnextchar g{%
+ \pgfplots@addplotimpl@g{#1}{#2}%
+ }{%
+ \pgfplotsutil@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
+ }%
+ }%
+ }%
+ }%
+ }%
+ }%
+ }%
+ }%
+}
+\long\def\pgfplots@addplotimpl@f#1#2f{%
+ \pgfplotsutil@ifnextchar i{%
+ \pgfplots@addplotimpl@fil{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@function{#1}{#2}%
+ }%
+}%
+
+\long\def\pgfplots@addplotimpl@fil#1#2il{%
+ \pgfplotsutil@ifnextchar e{%
+ \pgfplots@addplotimpl@file{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@fillbetween{#1}{#2}%
+ }%
+}%
+
+\def\pgfplots@addplotimpl@fillbetween#1#2l between{%
+ \pgfplotsutil@ifnextchar[{%
+ \pgfplots@addplotimpl@fillbetween@opt{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@fillbetween@opt{#1}{#2}[]%
+ }%
+}
+% \addplot[#1] [#2] fill between[#3] #4;
+\long\def\pgfplots@addplotimpl@fillbetween@opt#1#2[#3]#4;{\pgfplots@addplotimpl@fillbetween@opt@{#1}{#2}{#3}{#4}}%
+
+\long\def\pgfplots@addplotimpl@fillbetween@opt@#1#2#3#4{%
+ \pgfkeysifdefined{/tikz/fill between/of/.@cmd}{%
+ \pgfplotslibraryfillbetween@addplot{#1,#2}{#3}{#4}%
+ }{%
+ \pgfplotsthrow{invalid argument}
+ {\pgfplots@loc@TMPa}%
+ {Please load \string\usepgfplotslibrary{fillbetween} in order to use `\string\addplot\space fill between'.}%
+ \pgfeov
+ }%
+ %
+ \pgfplots@end@plot%
+}%
+
+\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 (will become a macro like '\x')
+% \pgfplots@plot@var@nonmacro (the same as \tikz@plot@var, but without backslash)
+% \pgfplots@plot@var@y (like \tikz@plot@var, but for y)
+% \pgfplots@plot@var@y@nonmacro (like \pgfplots@plot@var@nonmacro, but for y)
+% 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 sample 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
+ %
+ \ifx\pgfplots@plot@samples@y\pgfutil@empty
+ \else
+ \pgfplotscoordmath{default}{parse int}{\pgfplots@plot@samples@y}%
+ \let\pgfplots@plot@samples@y=\pgfmathresult
+ \pgfkeyslet{/pgfplots/samples y}{\pgfplots@plot@samples@y}%
+ \fi
+ %
+ % \tikz@plot@var is '\x' be default:
+ \pgfplots@gettikzinternal@keyval{variable}{tikz@plot@var}{\x}%
+ %
+ \begingroup
+ \escapechar=-1
+ \xdef\pgfplots@glob@TMPa{\expandafter\string\tikz@plot@var}%
+ \xdef\pgfplots@glob@TMPb{\expandafter\string\pgfplots@plot@var@y}%
+ \endgroup
+ % \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
+ %
+ % make sure the 'plot vars' have a backslash (as it was in tikz
+ % plot expression):
+ \edef\pgfplots@loc@TMPa{\expandafter\string\tikz@plot@var}%
+ \ifx\pgfplots@plot@var@nonmacro\pgfplots@loc@TMPa
+ \edef\tikz@plot@var{\expandafter\noexpand\csname \tikz@plot@var\endcsname}%
+ \fi
+ %
+ \edef\pgfplots@loc@TMPa{\expandafter\string\pgfplots@plot@var@y}%
+ \ifx\pgfplots@plot@var@y@nonmacro\pgfplots@loc@TMPa
+ \edef\pgfplots@plot@var@y{\expandafter\noexpand\csname \pgfplots@plot@var@y\endcsname}%
+ \fi
+ %
+ % Check if we have to sample a line or a matrix.
+ %
+ \pgfkeysgetvalue{/pgfplots/sample dim}\pgfplots@loc@TMPa
+ \def\pgfplots@loc@TMPb{auto}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \ifpgfplots@curplot@threedim
+ \def\b@pgfplots@should@sample@LINE{0}%
+ \else
+ \def\b@pgfplots@should@sample@LINE{1}%
+ \fi
+ \else
+ \ifcase\pgfplots@loc@TMPa\relax
+ % sample dim=0 not useful!?
+ \def\b@pgfplots@should@sample@LINE{1}%
+ \or
+ \def\b@pgfplots@should@sample@LINE{1}%
+ \or
+ \def\b@pgfplots@should@sample@LINE{0}%
+ \else
+ \pgfplots@error{Sorry, sample dim=\pgfplots@loc@TMPa\space is unsupported (use either 1 or 2)}%
+ \fi
+ \fi
+ %
+ \if0\b@pgfplots@should@sample@LINE
+ % sample a matrix. Check the keys; if they are one
+ % dimensional, switch back to line sampling:
+ \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
+ %
+ \iftikz@plot@raw@gnuplot
+ % FIXME : verify this case
+ \else
+ \pgfkeyssetvalue{/pgfplots/mesh/rows}{\pgfkeysvalueof{/pgfplots/samples y}}%
+ \ifx\pgfplots@plot@samples@at\pgfutil@empty
+ \pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/samples}}%
+ \else
+ % FIXME : count number of samples in 'samples at'!
+ \fi
+ \fi
+ \if1\b@pgfplots@should@sample@LINE
+ \pgfkeyssetvalue{/pgfplots/sample dim}{1}%
+ \pgfkeyslet{/pgfplots/mesh/rows}\pgfplots@plot@samples
+ \pgfkeyssetvalue{/pgfplots/mesh/cols}{1}%
+ \else
+ \pgfkeyssetvalue{/pgfplots/sample dim}{2}%
+ \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.
+%
+%
+\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{%
+ \pgfplots@addplotimpl@expression@set@options{#1}{#2}%
+ \pgfplots@addplotimpl@expression@@{#3}{#4}{#5}%
+}
+
+\long\def\pgfplots@addplotimpl@expression@set@options#1#2{%
+ \def\pgfplotssurveyphaseinputclass{expression}%
+ \pgfplots@start@plot@with@behavioroptions{%
+ #1,%
+ /pgfplots/.cd,%
+ #2,%
+ /utils/exec={%
+ \if0\pgfplotsplothandlermesh@matrixinput
+ % mesh input=patches unsupported in this context.
+ \pgfkeysalso{/pgfplots/mesh input=lattice}%
+ \fi
+ },%
+ /pgfplots/mesh/ordering/x varies%
+ }%
+ \pgfplots@plot@expression@preparekeys
+}%
+
+% \addplot (#1,#2) #3;
+\long\def\pgfplots@addplotimpl@expression@@#1#2#3{%
+ %
+ \pgfplots@PREPARE@COORD@STREAM{#3}%
+ %
+ \def\pgfplots@addplotimpl@expression@xEXPR{#1}%
+ %
+ % Determine whether the x range is parameterized or uniform and
+ % prepare a macro which assigns \pgfplots@current@point@x:
+ \def\pgfplots@addplotimpl@expression@prepare@x{%
+ \pgfmathparse{#1}%
+ \let\pgfplots@current@point@x=\pgfmathresult
+ }%
+ \def\pgfplots@addplotimpl@expression@prepare@y{%
+ \pgfmathparse{\pgfplots@addplotimpl@expression@yEXPR}%
+ \let\pgfplots@current@point@y=\pgfmathresult
+ }%
+ \def\pgfplots@addplotimpl@expression@hasuniform@x{0}%
+ % do we have '\x' as x coordinate?
+ \expandafter\def\expandafter\pgfplots@loc@TMPb\expandafter{\tikz@plot@var}%
+ \ifx\pgfplots@addplotimpl@expression@xEXPR\pgfplots@loc@TMPb
+ \def\pgfplots@addplotimpl@expression@hasuniform@x{1}%
+ \else
+ \edef\pgfplots@loc@TMPb{\pgfplots@plot@var@nonmacro}%
+ % do we have 'x' as x coordinate?
+ \ifx\pgfplots@addplotimpl@expression@xEXPR\pgfplots@loc@TMPb
+ \def\pgfplots@addplotimpl@expression@hasuniform@x{1}%
+ \fi
+ \fi
+ \if\pgfplots@addplotimpl@expression@hasuniform@x1%
+ % if '#1' is '\x' or 'x', we don't need the math parser -
+ % we can simply take \tikz@plot@var.
+ \def\pgfplots@addplotimpl@expression@prepare@x{%
+ \edef\pgfplots@current@point@x{\tikz@plot@var}%
+ }%
+ \fi
+ %
+ \def\pgfplots@addplotimpl@expression@hasuniform@y{0}%
+ %
+ %
+ %
+ % if(
+ % x is logarithmic &&
+ % #1 == '\x' &&
+ % the 'samples at' key has not been used )
+ % -> sample logarithmically!
+ \def\pgfplots@samples@logarithmically@x{0}%
+ \ifpgfplots@xislinear
+ \else
+ \if\pgfplots@addplotimpl@expression@hasuniform@x1%
+ \ifx\pgfplots@plot@samples@at\pgfutil@empty
+ % we don't have 'samples at' -> use domain!
+ \def\pgfplots@samples@logarithmically@x{1}%
+ \fi
+ \fi
+ \fi
+ %
+ \def\pgfplots@samples@logarithmically@y{0}%
+ %
+ % Now, prepare the loops.
+ %
+ % I am using \pgfplotsforeachungrouped in favor of
+ % \foreach because \foreach does NOT allow extended
+ % precision. Besides, \pgfplotsforeachungrouped avoids
+ % scoping problems.
+ \let\pgfplots@plot@data@notify@next@x=\relax
+ \let\pgfplots@plot@data@notify@next@y=\relax
+ %
+ \ifpgfplots@curplot@threedim
+ \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#2\pgfplots@EOI%
+ %
+ % do we have '\y' as y coordinate?
+ \expandafter\def\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@plot@var@y}%
+ \ifx\pgfplots@addplotimpl@expression@yEXPR\pgfplots@loc@TMPb
+ \def\pgfplots@addplotimpl@expression@hasuniform@y{1}%
+ \def\pgfplots@addplotimpl@expression@prepare@y{%
+ \edef\pgfplots@current@point@y{\pgfplots@plot@var@y}%
+ }%
+ \else
+ \edef\pgfplots@loc@TMPb{\pgfplots@plot@var@y@nonmacro}%
+ % do we have 'y' as y coordinate?
+ \ifx\addplotimpl@expression@yEXPR\pgfplots@loc@TMPb
+ \def\pgfplots@addplotimpl@expression@hasuniform@y{1}%
+ \def\pgfplots@addplotimpl@expression@prepare@y{%
+ \edef\pgfplots@current@point@y{\pgfplots@plot@var@y}%
+ }%
+ \fi
+ \fi
+ %
+ \ifpgfplots@yislinear
+ \else
+ \if\pgfplots@addplotimpl@expression@hasuniform@y1%
+ \def\pgfplots@samples@logarithmically@y{1}%
+ \fi
+ \fi
+ %
+ \ifpgfplots@threedim@log@sampling
+ \else
+ \def\pgfplots@samples@logarithmically@x{0}%
+ \def\pgfplots@samples@logarithmically@y{0}%
+ \fi
+ %
+ \if\pgfplots@samples@logarithmically@x1%
+ \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{\pgfplots@plot@samples}%
+ \let\pgfplots@expression@xdomain=\pgfplotsretval
+ \else
+ % use 'samples at':
+ \let\pgfplots@expression@xdomain=\pgfplots@plot@samples@at
+ \fi
+ \fi
+ %
+ \if\pgfplots@samples@logarithmically@x1%
+ \if\pgfplots@samples@logarithmically@y1%
+ \pgfplots@warning{Sorry, 3d log sampling in BOTH x and y is not implemented yet}%
+ \def\pgfplots@samples@logarithmically@y{0}%
+ \fi
+ \fi
+ %
+ \if0\b@pgfplots@should@sample@LINE
+ % Samples twodimensionally (a lattice):
+ \if\pgfplots@samples@logarithmically@y0%
+ \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@ydomain\relax{\pgfplots@plot@samples@y}%
+ \let\pgfplots@expression@ydomain=\pgfplotsretval
+ \fi
+ %
+ % Assemble a
+ % \pgfplots@plot@data##1 ->
+ % \foreach \y in {-5,-4.6,...,5} {##1};
+ % \foreach \x in {-5,-4.6,...,5}
+ % macro:
+ \if\pgfplots@samples@logarithmically@x0%
+ \if\pgfplots@samples@logarithmically@y0%
+ % standard case: no log sampling.
+ \edef\pgfplots@plot@data##1{%
+ \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\pgfplots@plot@var@y in {\pgfplots@expression@ydomain}
+ {%
+ \pgfplots@plot@data@notify@next@y
+ \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@expression@xdomain} {%
+ \pgfplots@plot@data@notify@next@x
+ ##1%
+ }%
+ \noexpand\pgfplotsplothandlernotifyscanlinecomplete
+ }%
+ }%
+ \fi
+ \fi
+ \if\pgfplots@samples@logarithmically@x1%
+ \if\pgfplots@samples@logarithmically@y0%
+ % sample logarithmically in X:
+ \edef\pgfplots@plot@data##1{%
+ \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\pgfplots@plot@var@y in {\pgfplots@expression@ydomain}
+ {%
+ \pgfplots@plot@data@notify@next@y
+ %
+ \noexpand\pgfplotsforeachlogarithmicungrouped[\pgfplots@plot@samples][x]
+ \expandafter\noexpand\tikz@plot@var/\noexpand\pgfplots@current@point@x@log
+ in {\pgfplots@plot@domain}%
+ {%
+ \pgfplots@plot@data@notify@next@x
+ ##1%
+ }%
+ \noexpand\pgfplotsplothandlernotifyscanlinecomplete
+ }%
+ }%
+ \fi
+ \fi
+ \if\pgfplots@samples@logarithmically@x0%
+ \if\pgfplots@samples@logarithmically@y1%
+ % sample logarithmically in Y:
+ \edef\pgfplots@plot@data##1{%
+ \noexpand\pgfplotsforeachlogarithmicungrouped[\pgfplots@plot@samples@y][y]
+ \expandafter\noexpand\pgfplots@plot@var@y/\noexpand\pgfplots@current@point@y@log
+ in {\pgfplots@plot@ydomain}%
+ {%
+ \pgfplots@plot@data@notify@next@y
+ \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@expression@xdomain} {%
+ \pgfplots@plot@data@notify@next@x
+ ##1%
+ }%
+ \noexpand\pgfplotsplothandlernotifyscanlinecomplete
+ }%
+ }%
+ \fi
+ \fi
+ \if\pgfplots@samples@logarithmically@x1%
+ \if\pgfplots@samples@logarithmically@y1%
+ % sample logarithmically in X and Y:
+ % FIXME : IMPLEMENT!
+ % FIXME : implementation UNFINISHED: also support log
+ % sampling in BOTH 'x' 'y'!
+ % requires to solve FIXME in \pgfplotsforeachlogarithmicungrouped)
+ % -> also adopt unittest_log_sampling_3d.tex
+ %
+ \fi
+ \fi
+ \else
+ % sample a line:
+ \def\pgfplots@plot@ydomain{0:0}%
+ \if\pgfplots@samples@logarithmically@x1%
+ % sample logarithmically:
+ \edef\pgfplots@plot@data##1{%
+ \noexpand\pgfplotsforeachlogarithmicungrouped[\pgfplots@plot@samples][x]
+ \expandafter\noexpand\tikz@plot@var/\noexpand\pgfplots@current@point@x@log
+ in {\pgfplots@plot@domain}%
+ {%
+ \pgfplots@plot@data@notify@next@x
+ ##1%
+ }%
+ }%
+ \else
+ \edef\pgfplots@plot@data##1{%
+ \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@expression@xdomain} {%
+ \pgfplots@plot@data@notify@next@x
+ ##1%
+ }%
+ }%
+ \fi
+ %
+ % If we have (\x,\y,f(x)), use (\x,0,f(x)) instead and
+ % suppress the error message which would occur for \y.
+ \if1\pgfplots@addplotimpl@expression@hasuniform@y
+ \def\pgfplots@addplotimpl@expression@yEXPR{0}%
+ \def\pgfplots@plot@var@y{0}%
+ \else
+ \expandafter\edef\pgfplots@plot@var@y{\pgfplots@plot@var@y@nonmacro}% this provides an error message, see above.
+ \fi
+ \fi
+ \else
+ % Assemble a
+ % \pgfplots@plot@data##1 -> \foreach \x in {-5,-4.6,...,5} {##1} macro:
+ \if\pgfplots@samples@logarithmically@x1%
+ % sample logarithmically:
+ \edef\pgfplots@plot@data##1{%
+ \noexpand\pgfplotsforeachlogarithmicungrouped[\pgfplots@plot@samples][x]
+ \expandafter\noexpand\tikz@plot@var/\noexpand\pgfplots@current@point@x@log
+ in {\pgfplots@plot@domain}%
+ {%
+ \pgfplots@plot@data@notify@next@x
+ ##1%
+ }%
+ }%
+ \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{\pgfplots@plot@samples}%
+ \let\pgfplots@loc@TMPa=\pgfplotsretval
+ \else
+ % use 'samples at':
+ \let\pgfplots@loc@TMPa=\pgfplots@plot@samples@at
+ \fi
+ \edef\pgfplots@plot@data##1{%
+ \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@loc@TMPa}%
+ {%
+ \pgfplots@plot@data@notify@next@x
+ ##1%
+ }%
+ }%
+ \fi
+ \expandafter\def\pgfplots@plot@var@y{0}%
+ \def\pgfplots@addplotimpl@expression@yEXPR{#2}%
+ \def\pgfplots@addplotimpl@expression@zEXPR{}%
+ \def\pgfplots@current@point@z{}%
+ \fi
+ %
+ %
+ \if\pgfplots@samples@logarithmically@x1%
+ % we have a logarithmic sampling sequence,
+ % \pgfplots@current@point@x@log is already available
+ % logarithmic! We can safe time and accuracy for the x
+ % coordinate by using that one instead of computing
+ % log(exp(\x)) numerically:
+ \pgfplots@disablelogfilter@xtrue
+ \def\pgfplots@addplotimpl@expression@prepare@x{%
+ \let\pgfplots@current@point@x=\pgfplots@current@point@x@log
+ }%
+ \pgflibraryfpuifactive
+ {\relax}
+ {%
+ % ok, if the FPU is NOT active, we should return
+ % results as fixed points.
+ % We need to configure that for
+ % \pgfplotsforeachlogarithmicungrouped manually:
+ \pgfplotsforeachlogarithmicformatresultwith{%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ }%
+ }%
+ \fi
+ \if\pgfplots@samples@logarithmically@y1%
+ % we have a logarithmic sampling sequence,
+ % \pgfplots@current@point@y@log is already available
+ % logarithmic! We can safe time and accuracy for the y
+ % coordinate by using that one instead of computing
+ % log(exp(\y)) numerically:
+ \pgfplots@disablelogfilter@ytrue
+ \def\pgfplots@addplotimpl@expression@prepare@y{%
+ \let\pgfplots@current@point@y=\pgfplots@current@point@y@log
+ }%
+ \pgflibraryfpuifactive
+ {\relax}
+ {%
+ % ok, if the FPU is NOT active, we should return
+ % results as fixed points.
+ % We need to configure that for
+ % \pgfplotsforeachlogarithmicungrouped manually:
+ \pgfplotsforeachlogarithmicformatresultwith{%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ }%
+ }%
+ \fi
+ % START:
+ % (NOTE: this does also define 'x', 'y', and 'z' math
+ % expressions!)
+ \pgfplots@coord@stream@start
+ %
+ \pgfplots@addplotimpl@expression@check@LUA
+ \if1\pgfplotsretval
+ \pgfplots@log{\pgfplots@LUA@loglevel@debug}{lua backend=true: Activating LUA version of plot expression for plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername').}%
+ \begingroup
+ \expandafter\def\tikz@plot@var{\pgfplots@plot@var@nonmacro}%
+ \expandafter\def\pgfplots@plot@var@y{\pgfplots@plot@var@y@nonmacro}%
+ \expandafter\pgfplots@parse@domain\pgfplots@plot@domain\relax{pgfplots@plot@domain}%
+ %
+ \if0\b@pgfplots@should@sample@LINE
+ \expandafter\pgfplots@parse@domain\pgfplots@plot@ydomain\relax{pgfplots@plot@ydomain}%
+ \else
+ \def\pgfplots@plot@ydomain@min{0}%
+ \def\pgfplots@plot@ydomain@max{0}%
+ \def\pgfplots@plot@samples@y{1}%
+ \fi
+ %
+ % FIXME : there are some cases in which this here might be a
+ % bad idea:
+ % - if someone has redefined math functions on TeX
+ % - if someone has defined his own math functions (only in
+ % TeX)
+ % - if a plot expression contains directlua -- the expansion will play
+ % funny tricks in this case
+ \xdef\pgfplotsglobalretval{%
+ \pgfplotsutil@directlua{%
+ pgfplots.texAddplotExpressionCoordinateGenerator(^^J%
+ \ifpgfplots@curplot@threedim true \else false\fi,^^J%
+ "#1", ^^J%
+ "\pgfplots@addplotimpl@expression@yEXPR",^^J%
+ "\pgfplots@addplotimpl@expression@zEXPR",^^J%
+ \b@pgfplots@should@sample@LINE,^^J%
+ "\pgfplots@plot@domain@min", "\pgfplots@plot@domain@max",^^J%
+ "\pgfplots@plot@ydomain@min", "\pgfplots@plot@ydomain@max",^^J%
+ "\pgfplots@plot@samples",^^J%
+ "\pgfplots@plot@samples@y",^^J%
+ "\pgfplots@plot@var@nonmacro",^^J%
+ "\pgfplots@plot@var@y@nonmacro",
+ "\pgfplots@plot@samples@at",
+ "\pgfplots@LUA@backend@debugmode")^^J%
+ }%
+ }%
+ \endgroup
+ \if0\pgfplotsglobalretval
+ \pgfplots@log{\pgfplots@LUA@loglevel@info}{lua backend=true: LUA version of plot expression failed. Using TeX version. (plot \the\pgfplots@numplots).}%
+ \pgfplots@LUA@backend@failed
+ \pgfplots@addplotimpl@expression@streamall
+ \else
+ \fi
+ \else
+ \pgfplots@addplotimpl@expression@streamall
+ \fi
+ %
+ \pgfplots@coord@stream@end
+}%
+
+% Defines \pgfplotsretval to be '1' if the pure LUA version of
+% \addplot expression is enabled. It defines \pgfplotsretval to be 0
+% if not.
+\def\pgfplots@addplotimpl@expression@check@LUA{%
+ \def\pgfplotsretval{0}%
+ \ifpgfplots@LUA@backend@supported
+ \def\pgfplotsretval{1}%
+ \ifpgfplotsplothandlermesh@patch@type@sampling
+ \def\pgfplotsretval{0}%
+ \pgfplots@LUA@plotexpression@log@deactivation{patch type sampling unsupported (yet)}%
+ \fi
+ %
+ \if1\pgfplots@addplotimpl@expression@hasuniform@x
+ \else
+ \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplots@addplotimpl@expression@xEXPR}{%
+ \def\pgfplotsretval{0}%
+ \pgfplots@command@to@string\pgfplots@addplotimpl@expression@xEXPR\pgfplots@loc@TMPa
+ \pgfplots@LUA@plotexpression@log@deactivation{x expression '\pgfplots@loc@TMPa' contains a TeX macro}%
+ }{%
+ }%
+ \fi
+ %
+ \ifx\pgfplots@plot@samples@at\pgfutil@empty
+ \else
+ \def\pgfplotsretval{0}%
+ \pgfplots@LUA@plotexpression@log@deactivation{samples at unsupported (yet)}%
+ \fi
+ %
+ \if1\pgfplots@addplotimpl@expression@hasuniform@y
+ \else
+ \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplots@addplotimpl@expression@yEXPR}{%
+ \def\pgfplotsretval{0}%
+ \pgfplots@command@to@string\pgfplots@addplotimpl@expression@yEXPR\pgfplots@loc@TMPa
+ \pgfplots@LUA@plotexpression@log@deactivation{y expression '\pgfplots@loc@TMPa' contains a TeX macro}%
+ }{%
+ }%
+ \fi
+ %
+ \ifpgfplots@curplot@threedim
+ \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplots@addplotimpl@expression@zEXPR}{%
+ \def\pgfplotsretval{0}%
+ \pgfplots@command@to@string\pgfplots@addplotimpl@expression@zEXPR\pgfplots@loc@TMPa
+ \pgfplots@LUA@plotexpression@log@deactivation{z expression '\pgfplots@loc@TMPa' contains a TeX macro}%
+ }{%
+ }%
+ \fi
+ \fi
+}%
+
+\def\pgfplots@LUA@plotexpression@log@deactivation#1{%
+ \pgfplots@log{\pgfplots@LUA@loglevel@info}{Deactivating LUA version of plot expression for plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername'): #1.}%
+ \pgfplots@LUA@backend@failed
+}
+\def\pgfplots@parse@domain#1:#2\relax#3{%
+ \pgfmathparse{#1}%
+ \expandafter\let\csname #3@min\endcsname=\pgfmathresult%
+ \pgfmathparse{#2}%
+ \expandafter\let\csname #3@max\endcsname=\pgfmathresult%
+}%
+\def\pgfplots@addplotimpl@expression@streamall{%
+ % 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@
+ %
+% \if n\pgfplots@meshmode
+ % mesh=false : ignore patch type sampling.
+% \else
+ \ifpgfplotsplothandlermesh@patch@type@sampling
+ \pgfplots@plot@expression@prepare@patch@type@sampling
+ \fi
+% \fi
+ %
+ % Warning for use fpu=false: evaluation '\x^3' might be different from 'x^3' for
+ % negative arguments:
+ % \x^3 ---> -0.2^3 but x^3 = (-0.2)^3 .
+ % This does not happen for use fpu=true.
+ %
+ \pgfplots@plot@data{%
+ \let\pgfmathx@=\pgfplots@addplotimpl@expression@pseudoconst@x
+ \let\pgfmathy@=\pgfplots@addplotimpl@expression@pseudoconst@y
+ % eval expressions:
+ \pgfplots@addplotimpl@expression@prepare@x%
+ \pgfplots@addplotimpl@expression@prepare@y%
+ \ifpgfplots@curplot@threedim
+ \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
+ %
+ %\pgfplots@expression@normalize@floats
+ %
+ % process coords as usual:
+ \pgfplots@coord@stream@coord
+ }%
+}
+
+% Typically, the FPU will generate stuff like '1Y1.0e5'. Since such
+% internal representations will be available to API users (especially
+% 'x filter' and its variants, we want to simplify its output - by
+% normalizing it.
+%
+% This routine will convert any floats to scientific format, i.e.
+% 1.0e5 instead of 1Y1.0e5 (1Y means 'positive float', compare
+% pgfmathfloat.code.tex).
+\def\pgfplots@expression@normalize@floats{%
+ \pgflibraryfpuifactive{%
+ \ifx\pgfplots@current@point@x\pgfutil@empty\else
+ \pgfmathfloattosci{\pgfplots@current@point@x}\let\pgfplots@current@point@x=\pgfmathresult
+ \fi%
+ \ifx\pgfplots@current@point@y\pgfutil@empty\else
+ \pgfmathfloattosci{\pgfplots@current@point@y}\let\pgfplots@current@point@y=\pgfmathresult
+ \fi%
+ \ifx\pgfplots@current@point@z\pgfutil@empty\else
+ \pgfmathfloattosci{\pgfplots@current@point@z}\let\pgfplots@current@point@z=\pgfmathresult
+ \fi%
+ }{%
+ }%
+}%
+
+% \addplot[#1] [#2] {#3} #4;
+\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@addplotimpl@expression@set@options{#1}{#2}%
+ \ifpgfplots@curplot@threedim
+ \t@pgfplots@toka={,#3}%
+ % 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}%
+ {\expandafter\noexpand\pgfplots@plot@var@y\the\t@pgfplots@toka}%
+ }%
+ \expandafter\pgfplots@addplotimpl@expression@@\pgfplots@loc@TMPb{#4}%
+ \else
+ \expandafter\pgfplots@addplotimpl@expression@@\expandafter{\tikz@plot@var}{#3}{#4}%
+ \fi
+}%
+% \addplot[#1] [#2] expression[#3] {#4} #5;
+\def\pgfplots@addplotimpl@expression@e#1#2expression{%
+ \pgfplotsutil@ifnextchar[{%
+ \pgfplots@addplotimpl@expression@e@{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@expression@e@{#1}{#2}[]%
+ }%
+}%
+\def\pgfplots@addplotimpl@expression@e@#1#2[#3]{%
+ \pgfplots@addplotimpl@expression@curly{#1}{#2,#3}%
+}%
+
+
+% This prepares the implementation for 'patch type sampling':
+\def\pgfplots@plot@expression@prepare@patch@type@sampling{%
+ \pgfplotssurveyphaseaddoptionsbeforesurveybegins{
+ mesh input=patches,%
+ }%
+ %
+ \pgfkeysgetvalue{/pgfplots/patch type}\pgfplotsplothandlermesh@patchclass
+ %
+ \let\pgfplots@plot@data@@=\pgfplots@plot@data
+ \let\pgfplots@plot@data@curx=\pgfutil@empty
+ \let\pgfplots@plot@data@cury=\pgfutil@empty
+ \let\pgfplots@plot@data@lastx=\pgfutil@empty
+ \let\pgfplots@plot@data@lasty=\pgfutil@empty
+ \let\pgfplots@plot@data@first@x=\pgfutil@empty
+ \let\pgfplots@plot@data@first@y=\pgfutil@empty
+ %
+ \def\pgfplots@plot@data@notify@next@x{%
+ \ifx\pgfplots@plot@data@first@x\pgfutil@empty
+ \edef\pgfplots@plot@data@first@x{\tikz@plot@var}%
+ \fi
+ \let\pgfplots@plot@data@lastx=\pgfplots@plot@data@curx
+ \edef\pgfplots@plot@data@curx{\tikz@plot@var}%
+ }%
+ \def\pgfplots@plot@data@notify@next@y{%
+ \ifx\pgfplots@plot@data@first@y\pgfutil@empty
+ \edef\pgfplots@plot@data@first@y{\pgfplots@plot@var@y}%
+ \fi
+ \let\pgfplots@plot@data@lasty=\pgfplots@plot@data@cury
+ \edef\pgfplots@plot@data@cury{\pgfplots@plot@var@y}%
+ }%
+ \def\pgfplots@plot@data##1{%
+ %
+ \pgfplots@plot@data@@{%
+ \let\tikz@plot@var@old=\tikz@plot@var
+ \let\pgfplots@plot@var@y@old=\pgfplots@plot@var@y
+ %
+ %
+ %
+ % boolean 'if is first row || is first cell':
+ \pgfplots@loc@tmpfalse
+ \ifx\pgfplots@plot@data@curx\pgfplots@plot@data@first@x
+ % ah - we have the first row.
+ \pgfplots@loc@tmptrue
+ \fi
+ \if0\b@pgfplots@should@sample@LINE
+ \ifx\pgfplots@plot@data@cury\pgfplots@plot@data@first@y
+ % ah - we have the first cell.
+ \pgfplots@loc@tmptrue
+ \fi
+ \fi
+ %
+ \ifpgfplots@loc@tmp
+ \else
+ \pgfmathparse{\pgfplots@plot@data@curx-\pgfplots@plot@data@lastx}%
+ \let\pgfplots@plot@data@hx=\pgfmathresult
+ %
+ \if0\b@pgfplots@should@sample@LINE
+ \pgfmathparse{\pgfplots@plot@data@cury-\pgfplots@plot@data@lasty}%
+ \let\pgfplots@plot@data@hy=\pgfmathresult
+ \fi
+ %
+ \def\pgfplotspatchready{\pgfplotsscanlinecomplete}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{sample in unit cube}{%
+ \pgfmathparse{\pgfplots@plot@data@lastx + \pgfplotspatchclassx*\pgfplots@plot@data@hx}%
+ \let\tikz@plot@var=\pgfmathresult
+ %
+ \if0\b@pgfplots@should@sample@LINE
+ \pgfmathparse{\pgfplots@plot@data@lasty + \pgfplotspatchclassy*\pgfplots@plot@data@hy}%
+ \let\pgfplots@plot@var@y=\pgfmathresult
+ \fi
+ %
+ ##1%
+ %
+ \let\tikz@plot@var=\tikz@plot@var@old
+ \let\pgfplots@plot@var@y=\pgfplots@plot@var@y@old
+ }%
+ \fi
+ }%
+ }%
+}%
+
+\let\pgfplots@backupof@pgfplotxyfile=\pgfplotxyfile
+
+% the following code
+% results finally in
+%
+% set format "%.7e";; set samples <...>; plot ...
+%
+% The windows port of gnuplot doesn't run without the second semicolon
+% - for whatever reason.
+{
+ \catcode`\%=12
+ \catcode`\"=12
+ \catcode`\;=12
+ \xdef\pgfplots@gnuplot@format{set format "%.7e";}
+}
+\def\pgfplots@addplotimpl@g#1#2g{%
+ \pgfplotsutil@ifnextchar r{%
+ \pgfplots@addplotimpl@graphics{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@gnuplot{#1}{#2}%
+ }%
+}%
+
+% |\addplot gnuplot| is an alias to |\addplot function|
+\def\pgfplots@addplotimpl@gnuplot#1#2nuplot{\pgfplots@addplotimpl@function{#1}{#2}unction}%
+
+% \addplot[#1] plot[#2] function[#3] {#4} #5;
+\def\pgfplots@addplotimpl@function#1#2unction{%
+ \pgfplotsutil@ifnextchar[{%
+ \pgfplots@addplotimpl@function@opt{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@function@opt{#1}{#2}[]%
+ }%
+}%
+\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{%
+ % FIXME : what about the key search paths if the user changes
+ % them!?
+ \def\pgfplotssurveyphaseinputclass{gnuplot}%
+ \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}%
+ %
+ % determine dummy variables:
+ \iftikz@plot@parametric
+ \ifpgfplots@curplot@threedim
+ \pgfkeysgetvalue{/pgfplots/parametric/var 2d}\pgfplots@gnuplot@dummy%
+ \else
+ \pgfkeysgetvalue{/pgfplots/parametric/var 1d}\pgfplots@gnuplot@dummy%
+ \fi
+ \ifx\pgfplots@gnuplot@dummy\pgfutil@empty
+ \else
+ \expandafter\pgfutil@in@\expandafter,\expandafter{\pgfplots@gnuplot@dummy}%
+ \ifpgfutil@in@
+ \def\pgfplots@loc@TMPa##1,##2\pgfeov{\pgfplotsset{variable={##1},variable y={##2}}}%
+ \else
+ \def\pgfplots@loc@TMPa##1\pgfeov{\pgfplotsset{variable={##1}}}%
+ \fi
+ \expandafter\pgfplots@loc@TMPa\pgfplots@gnuplot@dummy\pgfeov
+ \fi
+ \fi
+ %
+ % prepare domain and samples, normalize dummy variables:
+ \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]{\pgfplots@gnuplot@format;\pgfplots@gnuplotcode}}%
+ \else%
+ % collect logs:
+ \def\pgfplots@gnuplot@logdirs{}%
+ \ifpgfplots@xislinear
+ \else
+ \pgfplots@identify@gnuplot@logbehavior x%
+ \expandafter\def\expandafter\pgfplots@gnuplot@logdirs\expandafter{\pgfplots@gnuplot@logdirs x}%
+ \fi
+ \ifpgfplots@yislinear
+ \else
+ \pgfplots@identify@gnuplot@logbehavior y%
+ \expandafter\def\expandafter\pgfplots@gnuplot@logdirs\expandafter{\pgfplots@gnuplot@logdirs y}%
+ \fi
+ \ifpgfplots@curplot@threedim
+ \ifpgfplots@zislinear
+ \else
+ \pgfplots@identify@gnuplot@logbehavior z%
+ \expandafter\def\expandafter\pgfplots@gnuplot@logdirs\expandafter{\pgfplots@gnuplot@logdirs z}%
+ \fi
+ \fi
+ %
+ \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@gnuplot@x{\pgfplots@plot@var@nonmacro}%
+ \def\pgfplots@gnuplot@y{\pgfplots@plot@var@y@nonmacro}%
+ \def\pgfplots@plot@data{\pgfplotgnuplot[\pgfplots@plot@filename]{%
+ \pgfplots@gnuplot@format;
+ set samples \pgfkeysvalueof{/pgfplots/samples}\if0\b@pgfplots@should@sample@LINE, \pgfkeysvalueof{/pgfplots/samples y}\fi;
+ set dummy \pgfplots@gnuplot@x\if0\b@pgfplots@should@sample@LINE,\pgfplots@gnuplot@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
+ \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 [\pgfplots@gnuplot@x=\pgfplots@plot@domain] [\pgfplots@gnuplot@y=\pgfplots@plot@ydomain] \pgfplots@gnuplotcode;%
+ \else
+ % *should* sample a line, but I don't know how.
+ splot [\pgfplots@gnuplot@x=\pgfplots@plot@domain] \pgfplots@gnuplotcode;%
+ \fi
+ \else
+ plot [\pgfplots@gnuplot@x=\pgfplots@plot@domain] \pgfplots@gnuplotcode;%
+ \fi
+ }}%
+ \fi%
+ \def\pgfplotxyfile{\pgfplots@addplotimpl@gnuplotresult{#5}}%
+ \pgfplots@plot@data
+ \let\pgfplotxyfile=\pgfplots@backupof@pgfplotxyfile
+}%
+
+\def\pgfplots@identify@gnuplot@logbehavior#1{%
+ \pgfutil@ifundefined{pgfplots@gnuplot@logscale@writes@log}{%
+ \pgfplots@identify@gnuplot@logbehavior@checkversion%
+ }{}%
+ \if1\pgfplots@gnuplot@logscale@writes@log
+ \csname pgfplots@disablelogfilter@#1true\endcsname
+ \fi
+}%
+\def\pgfplots@identify@gnuplot@logbehavior@checkversion{%
+ \begingroup
+ \pgfplots@shellescape{gnuplot -V >\pgfplots@plot@filename.vrs}%
+ \openin\r@pgfplots@reada=\pgfplots@plot@filename.vrs\relax
+ \ifeof\r@pgfplots@reada
+ \pgfplotswarning{gnuplot -V impossible}\pgfeov
+ \gdef\pgfplots@gnuplot@logscale@writes@log{1}% something doesn't work. set it somehow.
+ \else
+ \read\r@pgfplots@reada to\pgfplots@loc@TMPa
+ \gdef\pgfplots@gnuplot@logscale@writes@log{1}%
+ \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}%
+ \immediate\write-1{Package pgfplots: checking gnuplot -V : `\the\t@pgfplots@toka' (if this fails, set `/pgfplots/gnuplot writes logscale=true|false')}%
+ \expandafter\pgfplots@identify@gnuplot@logbehavior@checkversion@\pgfplots@loc@TMPa 0 0.0 0\relax
+ \if0\pgfplots@gnuplot@logscale@writes@log
+ \immediate\write-1{Package pgfplots: I found gnuplot version >= 4.4. This one doesn't write log() coordinates. I will apply log() manually.}%
+ \else
+ \immediate\write-1{Package pgfplots: I found gnuplot version < 4.4. This one writes log() coordinates. I'll handle it accordingly.}%
+ \fi
+ \closein\r@pgfplots@reada
+ \fi
+ \endgroup
+}%
+\long\def\pgfplots@identify@gnuplot@logbehavior@checkversion@{%
+ \pgfutil@ifnextchar\par{%
+ \pgfplotswarning{gnuplot -V format unknown}\pgfeov%
+ \gdef\pgfplots@gnuplot@logscale@writes@log{1}%
+ \pgfplots@identify@gnuplot@logbehavior@checkversion@@@
+ }{%
+ \pgfplots@identify@gnuplot@logbehavior@checkversion@@
+ }%
+}%
+\long\def\pgfplots@identify@gnuplot@logbehavior@checkversion@@@#1\relax{%
+}%
+\long\def\pgfplots@identify@gnuplot@logbehavior@checkversion@@#1 #2.#3 #4\relax{%
+ % starting with gnuplot 4.4, output files are no longer in
+ % logarithmic scale for log plots.
+ \ifnum#2<4
+ % version 3.X
+ \gdef\pgfplots@gnuplot@logscale@writes@log{1}%
+ \else
+ \ifnum#2>4
+ % version 5.X
+ \gdef\pgfplots@gnuplot@logscale@writes@log{0}%
+ \else
+ \ifnum#3<4
+ % version 4.2 :
+ \gdef\pgfplots@gnuplot@logscale@writes@log{1}%
+ \else
+ % version 4.4 or later :
+ \gdef\pgfplots@gnuplot@logscale@writes@log{0}%
+ \fi
+ \fi
+ \fi
+}%
+
+\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*.
+ \let\pgfplots@addplotimpl@file@parsesingle@twodim=\pgfplots@addplotimpl@file@parsesingle@twodim@gnuplotformat
+ \let\pgfplots@addplotimpl@file@parsesingle@threedim=\pgfplots@addplotimpl@file@parsesingle@threedim@gnuplotformat
+ \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{%
+ \pgfplotsutil@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{%
+ \def\pgfplotssurveyphaseinputclass{shell}%
+ \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@shellresult#1#2{%
+ \begingroup
+ \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
+ \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}%
+ \else
+ \expandafter\pgfplots@end@plot
+ \fi
+}
+
+% \addplot[#1] [#2] file{#3} #4;
+\def\pgfplots@addplotimpl@file#1#2e{%
+ \pgfplotsutil@ifnextchar[{%
+ \pgfplots@addplotimpl@file@opt{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@file@opt{#1}{#2}[]%
+ }%
+}
+
+% \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{%
+ % invoke this here - allows to share the 'plot file' impl with
+ % 'plot gnuplot'.
+ \def\pgfplotssurveyphaseinputclass{file}%
+ \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
+ \def\pgfplots@loc@TMPa{#2}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfqkeys{/pgfplots/plot file}{#2}%
+ \fi
+ \pgfplots@PREPARE@COORD@STREAM{#4}%
+ \pgfplots@addplotimpl@file@streamit{#3}%
+ \endgroup
+}%
+% #1: the file name
+\def\pgfplots@addplotimpl@file@streamit#1{%
+ \pgfplots@coord@stream@start
+ \pgfplotsscanlinelengthinitzero
+ \openin\r@pgfplots@reada=#1
+ \ifeof\r@pgfplots@reada
+ \pgfplots@error{sorry, plot file{#1} could not be opened}%
+ \else
+ \pgfplots@logfileopen{#1}%
+ \let\pgfplots@current@point@error@x@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@x@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@z@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@z@minus=\pgfutil@empty
+ \let\pgfplots@current@point@meta=\pgfutil@empty
+ \ifpgfplots@curplot@threedim
+ \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@threedim
+ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @explicitinput\endcsname
+ \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@threedim@andmeta
+ \fi
+ \else
+ \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@twodim
+ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @explicitinput\endcsname
+ \let\pgfplots@addplotimpl@file@parsesingle=\pgfplots@addplotimpl@file@parsesingle@twodim@andmeta
+ \fi
+ \fi
+ \pgfplotstableinstallignorechars%
+ \pgfplots@addplotimpl@file@readall
+ \fi
+ \pgfplotsscanlinelengthcleanup
+ \pgfplots@coord@stream@end
+}%
+\def\pgfplots@addplotimpl@file@readall{%
+ \read\r@pgfplots@reada to\pgfplots@file@LINE
+ \expandafter\pgfplotstableread@checkspecial@line\pgfplots@file@LINE\pgfplotstable@EOI
+ \ifpgfplotstableread@skipline
+ \else
+ \ifpgfplots@plot@file@skipfirst
+ % Silently skip first data row, assuming it is a header.
+ \pgfplots@plot@file@skipfirstfalse
+ \else
+ \pgfplotsscanlinelengthincrease
+ \expandafter\pgfplots@addplotimpl@file@parsesingle\pgfplots@file@LINE 0 0 0 0 0\pgfplots@EOI
+ \fi
+ \fi
+ \ifeof\r@pgfplots@reada
+ \else
+ \expandafter
+ \pgfplots@addplotimpl@file@readall
+ \fi
+}%
+
+\def\pgfplots@gnuplot@unbounded{u}%
+\def\pgfplots@gnuplot@unbounded@handler@jump{jump}%
+\def\pgfplots@gnuplot@handle@unbounded{%
+ \pgfkeysgetvalue{/pgfplots/empty line}\pgfplots@loc@TMPa%
+ \ifx\pgfplots@loc@TMPa\pgfplots@gnuplot@unbounded@handler@jump
+ \pgfplotsplothandlerappendjumpmarker
+ \else
+ \ifpgfplots@curplot@threedim
+ \def\pgfplots@current@point@z{nan}%
+ \else
+ \def\pgfplots@current@point@y{nan}%
+ \fi
+ \pgfplots@coord@stream@coord%
+ \fi
+}
+\def\pgfplots@addplotimpl@file@parsesingle@threedim@gnuplotformat#1 #2 #3 #4 #5\pgfplots@EOI{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+ \def\pgfplots@loc@TMPa{#4}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@gnuplot@unbounded%
+ % a special gnuplot "unbounded" marker
+ \pgfplots@gnuplot@handle@unbounded
+ \else
+ \pgfplots@coord@stream@coord%
+ \fi
+}%
+\def\pgfplots@addplotimpl@file@parsesingle@twodim@gnuplotformat#1 #2 #3 #4\pgfplots@EOI{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@loc@TMPa{#3}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@gnuplot@unbounded
+ % a special gnuplot "unbounded" marker
+ \pgfplots@gnuplot@handle@unbounded
+ \else
+ \pgfplots@coord@stream@coord%
+ \fi
+}%
+\def\pgfplots@addplotimpl@file@parsesingle@threedim#1 #2 #3 #4\pgfplots@EOI{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+ \pgfplots@coord@stream@coord%
+}%
+\def\pgfplots@addplotimpl@file@parsesingle@twodim#1 #2 #3\pgfplots@EOI{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \pgfplots@coord@stream@coord%
+}%
+\def\pgfplots@addplotimpl@file@parsesingle@threedim@andmeta#1 #2 #3 #4 #5\pgfplots@EOI{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+ \def\pgfplots@current@point@meta{#4}%
+ \pgfplots@coord@stream@coord%
+}%
+\def\pgfplots@addplotimpl@file@parsesingle@twodim@andmeta#1 #2 #3 #4\pgfplots@EOI{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@meta{#3}%
+ \pgfplots@coord@stream@coord%
+}%
+
+
+\def\pgfplots@addplotimpl@graphics#1#2raphics{%
+ \pgfplotsutil@ifnextchar[{%
+ \pgfplots@addplotimpl@graphics@{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@graphics@{#1}{#2}[]%
+ }%
+}%
+% \addplot[#1] plot[#2] graphics[#3] {#4} #5;
+\long\def\pgfplots@addplotimpl@graphics@#1#2[#3]#4#5;{\pgfplots@addplotimpl@graphics@@{#1}{#2}{#3}{#4}{#5}}%
+\long\def\pgfplots@addplotimpl@graphics@@#1#2#3#4#5{%
+ \def\pgfplotssurveyphaseinputclass{graphics}%
+ \pgfplots@start@plot@with@behavioroptions{%
+ /pgfplots/filter discard warning=false,
+ /pgfplots/mesh/rows=2,% allow \addplot[surf] graphics ... --> yields a good legend.
+ /pgfplots/mesh/cols=2,
+ /pgfplots/mesh/check=false,%
+ #1,/pgfplots/.cd,#2,%
+ /pgfplots/plot graphics/@prepare legend,
+ /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/points}{\pgfplots@current@point@points}%
+ \ifx\pgfplots@current@point@points\pgfutil@empty
+ \else
+ \let\pgfplotsplothandlergraphicspointmappoint=\pgfplotsplothandlergraphics@survey@pointmappoint
+ \expandafter\pgfplots@plot@handler@graphics@parsepointmap\expandafter{\pgfplots@current@point@points}%
+ \ifpgfplots@plot@graphics@autoadjustaxis
+ \pgfplotsplothandlergraphicspointmapcomputerequiredview
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \expandafter\pgfplotssetlateoptions\expandafter{\pgfplotsretval}%
+ \fi
+ \fi
+ %
+ \def\pgfplots@addplotimpl@graphics@@error##1{}%
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/plot graphics/xmin}{\pgfplots@current@point@x}%
+ \pgfkeysgetvalue{/pgfplots/plot graphics/ymin}{\pgfplots@current@point@y}%
+ %
+ % these sanity checks do nothing of the 'plot graphics/points' feature has been used:
+ \ifx\pgfplots@current@point@x\pgfutil@empty\pgfplots@addplotimpl@graphics@@error{xmin}\fi
+ \ifx\pgfplots@current@point@y\pgfutil@empty\pgfplots@addplotimpl@graphics@@error{ymin}\fi
+ \ifpgfplots@curplot@threedim
+ \pgfkeysgetvalue{/pgfplots/plot graphics/zmin}{\pgfplots@current@point@z}%
+ \ifx\pgfplots@current@point@z\pgfutil@empty\pgfplots@addplotimpl@graphics@@error{zmin}\fi
+ \fi
+ \pgfplots@coord@stream@coord
+ %
+ \pgfkeysgetvalue{/pgfplots/plot graphics/xmax}{\pgfplots@current@point@x}%
+ \pgfkeysgetvalue{/pgfplots/plot graphics/ymax}{\pgfplots@current@point@y}%
+ \ifx\pgfplots@current@point@x\pgfutil@empty\pgfplots@addplotimpl@graphics@@error{xmax}\fi
+ \ifx\pgfplots@current@point@y\pgfutil@empty\pgfplots@addplotimpl@graphics@@error{ymax}\fi
+ \ifpgfplots@curplot@threedim
+ \pgfkeysgetvalue{/pgfplots/plot graphics/zmax}{\pgfplots@current@point@z}%
+ \ifx\pgfplots@current@point@z\pgfutil@empty\pgfplots@addplotimpl@graphics@@error{zmax}\fi
+ \fi
+ \pgfplots@coord@stream@coord
+ %
+ \pgfplots@coord@stream@end
+}%
+\def\pgfplots@addplotimpl@graphics@@error#1{%
+ \begingroup
+ \pgfplots@error{Sorry, but 'plot graphics' can't determine where to place the graphics file - (at least) the key '#1' is missing. Please verify that you provided all required limits, for example 'plot graphics[xmin=0,xmax=1,ymin=0,ymax=1] {<graphics>}'.}%
+ \endgroup
+}%
+
+
+
+
+% \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{%
+ \pgfplotsutil@ifnextchar[{%
+ \pgfplots@addplotimpl@table@getopts{#1}%
+ }{%
+ \pgfplots@addplotimpl@table@getopts{#1}[]%
+ }%
+}%
+
+\def\pgfplots@addplotimpl@table@getopts#1[#2]{%
+ % set options outside of the following group.
+ % They may contain behavior options.
+ \pgfplots@addplotimpl@table@installkeypath
+ \pgfplotstableset{#2}%
+ %
+ \pgfplotsutil@ifnextchar s{%
+ \pgfplots@addplotimpl@table@fromshell{#1}{#2}%
+ }{%
+ \pgfplotsutil@ifnextchar f{%
+ \pgfplots@addplotimpl@table@fromstructure@gobble@space{#1}{#2}%
+ }{%
+ \pgfplots@addplotimpl@table@fromfile@gobble@space{#1}{#2}%
+ }%
+ }%
+}
+
+% this macro simply invokes the "correct" table processing routine.
+% The distinction between 'table from {<\macro>}' and 'table
+% {<filename>}' is deprecated; it is done automatically now.
+%
+% \addplot[#1] table[#2] [from] {#3} #4;
+\def\pgfplots@addplotimpl@table@startprocessing#1#2#3#4{%
+ \pgfplotstable@isloadedtable{#3}{%
+ \pgfplots@addplotimpl@table@fromstructure@{#1}{#2}{#3}{#4}%
+ }{%
+ \pgfplots@addplotimpl@table@fromfile@{#1}{#2}{#3}{#4}%
+ }%
+}%
+
+% \addplot[#1] table[#2] from {#3} #4;
+%
+% #1: arguments to \addplot[...]
+% #2: arguments to table[...] (already processed!)
+% #3: the argument of plot table{...}
+% #4: trailing path arguments after plot table{...}#4;
+\long\def\pgfplots@addplotimpl@table@fromstructure@gobble@space#1#2from{%
+ \pgfplotstablecollectoneargwithpreparecatcodes{%
+ \pgfplots@addplotimpl@table@fromstructure{#1}{#2}from%
+ }%
+}%
+
+\def\pgfplots@addplot@table@fromstructure@preparecolname#1#2#3#4{%
+ \pgfkeysgetvalue{/pgfplots/table/#1}{\pgfplots@loc@TMPa}%
+ %
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfkeysgetvalue{/pgfplots/table/#1 index}{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotstablegetcolumnnamebyindex\pgfplots@loc@TMPa\of#2\to\pgfplots@loc@TMPa
+ \fi
+ \fi
+ \let#3=\pgfplots@loc@TMPa
+ %
+ % modify \pgfplots@plot@tbl@{x,y,z,meta} if there are
+ % corresponding '#1 expr' statements:
+ \pgfplots@addplotimpl@table@fromstructure@prepareexpr@for{#1}{#3}{#4}%
+}
+
+% Invokes `#1' if the command is invoked within
+% \addplot table {<\macro>};
+% and `#2' if not.
+\def\pgfplotsifinaddplottablestruct#1#2{%
+ \pgfutil@ifundefined{pgfplots@plot@tbl@meta}{#2}{#1}%
+}%
+
+\long\def\pgfplots@addplotimpl@table@fromstructure#1#2from#3#4;{\pgfplots@addplotimpl@table@startprocessing{#1}{#2}{#3}{#4}}%
+% \addplot[#1] table[#2] from {#3} #4 ;
+\long\def\pgfplots@addplotimpl@table@fromstructure@#1#2#3#4{%
+ \begingroup
+ \def\pgfplotstablename{#3}% store the name of the currently processed table.
+ \pgfplotstablegetscanlinelength{#3}{\pgfplotsscanlinelength}%
+ % FIXME : this thing here has runtime O(N^2) !
+ % I fear it is faster to simply reload the data .... !?
+ %
+ % well, for a lot of columns which are used in different contexts
+ % and few rows, this here IS more efficient.
+ %
+ \pgfplots@addplot@table@fromstructure@preparecolname{x}{#3}\pgfplots@plot@tbl@x\columnx
+ \pgfplots@addplot@table@fromstructure@preparecolname{y}{#3}\pgfplots@plot@tbl@y\columny
+ \ifpgfplots@curplot@threedim
+ \pgfplots@addplot@table@fromstructure@preparecolname{z}{#3}\pgfplots@plot@tbl@z\columnz
+ \fi
+ \pgfplots@addplot@table@fromstructure@preparecolname{meta}{#3}\pgfplots@plot@tbl@meta\columnmeta
+ %
+ %
+ % high level user interface functions:
+ \let\pgfplotstable@coordindex@old=\coordindex
+ \def\coordindex{\pgfplotstablerow}%
+ \def\lineno{\coordindex}% is the same here
+ % The normal implementation of \thisrow is not accessable here. And the
+ % worst is: error messages are impossible either because they are
+ % not executed... we resort to the associated math functions:
+ \def\thisrow##1{thisrow("##1")}% let us hope that math parsing is active!
+ \def\thisrowno##1{thisrowno(##1)}%
+ % this should work.
+ \def\getthisrow##1##2{\pgfplotstablegetelem{\coordindex}{##1}\of{#3}\let##2=\pgfplotsretval}%
+ \def\getthisrowno##1##2{\pgfplotstablegetelem{\coordindex}{[index]##1}\of{#3}\let##2=\pgfplotsretval}%
+ %
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@plot@tbl@x}\of#3\to\addplot@tbl@x
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@plot@tbl@y}\of#3\to\addplot@tbl@y
+ \ifpgfplots@curplot@threedim
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@plot@tbl@z}\of#3\to\addplot@tbl@z
+ \fi
+ %
+ \let\addplot@tbl@meta=\pgfutil@empty
+ \ifx\pgfplots@plot@tbl@meta\pgfutil@empty
+ \else
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@plot@tbl@meta}\of#3\to\addplot@tbl@meta
+ \fi
+ %
+ %
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@init x{#3}{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@init x{#3}{minus}%
+ %
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@init y{#3}{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@init y{#3}{minus}%
+ %
+ \ifpgfplots@curplot@threedim
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@init z{#3}{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@init z{#3}{minus}%
+ \fi
+ %
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@load x{#3}{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@load x{#3}{minus}%
+ %
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@load y{#3}{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@load y{#3}{minus}%
+ \ifpgfplots@curplot@threedim
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@load z{#3}{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@load z{#3}{minus}%
+ \fi
+ %
+ \let\coordindex=\pgfplotstable@coordindex@old
+ %
+ \pgfplots@PREPARE@COORD@STREAM{#4}%
+ \pgfplots@coord@stream@start
+ \pgfutil@loop
+ \pgfplotslistcheckempty\addplot@tbl@x
+ \ifpgfplotslistempty
+ \pgfplots@loop@CONTINUEfalse
+ \else
+ % This here is just for sanity checking: if the 'y' column is
+ % - for whatever reasons - invalid; provide good error
+ % recovery.
+ \pgfplotslistcheckempty\addplot@tbl@y
+ \ifpgfplotslistempty
+ \pgfplots@loop@CONTINUEfalse
+ \else
+ \pgfplots@loop@CONTINUEtrue
+ \fi
+ \fi
+ \ifpgfplots@loop@CONTINUE
+ \pgfplotslistpopfront\addplot@tbl@x\to\pgfplots@current@point@x
+ \pgfplotslistpopfront\addplot@tbl@y\to\pgfplots@current@point@y
+ \ifpgfplots@curplot@threedim
+ \pgfplotslistpopfront\addplot@tbl@z\to\pgfplots@current@point@z
+ \fi
+ \ifx\addplot@tbl@meta\pgfutil@empty
+ \else
+ \pgfplotslistpopfront\addplot@tbl@meta\to\pgfplots@current@point@meta
+ \fi
+ \ifpgfplots@errorbars@enabled
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@getnext x{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@getnext x{minus}%
+ %
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@getnext y{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@getnext y{minus}%
+ %
+ \ifpgfplots@curplot@threedim
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@getnext z{plus}%
+ \pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@getnext z{minus}%
+ \fi
+ \fi
+ \pgfplots@coord@stream@coord
+ \pgfutil@repeat
+ \pgfplots@coord@stream@end
+ \pgfmath@smuggleone\pgfplotsscanlinelength
+ \endgroup
+}
+
+% #1: x, y, or z
+% #2: the table name
+% #3: either "plus" or "minus"
+\def\pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@init#1#2#3{%
+ \expandafter\let\csname addplot@tbl@error@#1@#3\endcsname=\pgfutil@empty
+ \expandafter\let\csname pgfplots@current@point@error@#1@#3\endcsname=\pgfutil@empty
+ \ifpgfplots@errorbars@enabled
+ % prepare with suitable expansion:
+ \def\pgfplots@loc@TMPa{%
+ \pgfplots@addplot@table@fromstructure@preparecolname{#1 error #3}{#2}}%
+ \edef\pgfplots@loc@TMPb{%
+ \expandafter\noexpand\csname pgfplots@plot@tbl@error@#1@#3\endcsname
+ % FIXME : these macros are UNDOCUMENTED! I suppose they are dead code...
+ \expandafter\noexpand\csname columnerror#1\endcsname
+ }%
+ % execute prepared statement:
+ % = \pgfplots@addplot@table@fromstructure@preparecolname
+ % {x error plus}{#2}{\pgfplots@plot@tbl@error@x@plus}{\columnerrorx}
+ \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ %
+ \fi
+}%
+
+% #1: x, y, or z
+% #2: the table name
+% #3: either "plus" or "minus"
+\def\pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@load#1#2#3{%
+ \ifpgfplots@errorbars@enabled
+ \expandafter\ifx\csname pgfplots@plot@tbl@error@#1@#3\endcsname\pgfutil@empty
+ % ok, we do not have this error kind.
+ \else
+ % assemble the statement
+ % \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@plot@tbl@error@x@plus}\of#2\to\addplot@tbl@error@x@plus
+ % -> but with suitable expansion restrictions.
+ \edef\pgfplots@loc@TMPa{\expandafter\noexpand\csname pgfplots@plot@tbl@error@#1@#3\endcsname}%
+ %
+ \def\pgfplots@loc@TMPb{%
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@loc@TMPa}\of#2\to
+ }%
+ \expandafter\pgfplots@loc@TMPb\csname addplot@tbl@error@#1@#3\endcsname
+ \fi
+ \fi
+}%
+
+% #1: x, y, or z
+% #2: either "plus" or "minus"
+\def\pgfplots@addplotimpl@table@fromstructure@prepare@errorbar@getnext#1#2{%
+ \expandafter\ifx\csname addplot@tbl@error@#1@#2\endcsname\pgfutil@empty
+ \expandafter\let\csname pgfplots@current@point@error@#1@#2\endcsname=\pgfutil@empty
+ \else
+ \expandafter\pgfplotslistpopfront\csname addplot@tbl@error@#1@#2\endcsname\to\pgfplots@loc@TMPa
+ \expandafter\let\csname pgfplots@current@point@error@#1@#2\endcsname=\pgfplots@loc@TMPa
+ \fi
+}%
+
+% 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 '#3' will be set correctly.
+%
+% #1: the key name of the current entity, for example 'x' for
+% '/pgfplots/table/x'
+% #2: the low level column name representing the data which is already
+% defined somehow
+% #3: a high level user interface command
+\def\pgfplots@addplotimpl@table@fromstructure@prepareexpr@for#1#2#3{%
+ % get old column name into a register:
+ \t@pgfplots@tokb=\expandafter{#2}%
+ %
+ % high level user interface command:
+ \edef#3{\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.
+ \def#2{#1expr@tempcol}%
+ \fi
+}%
+
+
+% \addplot[#1] table[#2] {#3} #4;
+%
+% This here is the (probably) faster input method from tables.
+%
+% It has linear complexity in the number of rows (as long as the
+% number of rows is less than about 110000).
+%
+% #1: arguments to \addplot[...]
+% #2: arguments to table[...] (already processed!)
+% #3: the argument of plot table{...}
+% #4: trailing path arguments after plot table{...}#4;
+%
+\long\def\pgfplots@addplotimpl@table@fromfile@gobble@space#1#2{%
+ \pgfplotstablecollectoneargwithpreparecatcodes{%
+ \pgfplots@addplotimpl@table@fromfile{#1}{#2}%
+ }%
+}%
+\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{%
+ \if1\pgfplots@addplotimpl@readcompletely@auto
+ \pgfplots@addplotimpl@table@check@createonuse@for{x}%
+ \pgfplots@addplotimpl@table@check@createonuse@for{y}%
+ \ifpgfplots@curplot@threedim
+ \pgfplots@addplotimpl@table@check@createonuse@for{z}%
+ \fi
+ \pgfplots@addplotimpl@table@check@createonuse@for{x error plus}%
+ \pgfplots@addplotimpl@table@check@createonuse@for{x error minus}%
+ \pgfplots@addplotimpl@table@check@createonuse@for{y error plus}%
+ \pgfplots@addplotimpl@table@check@createonuse@for{y error minus}%
+ \ifpgfplots@curplot@threedim
+ \pgfplots@addplotimpl@table@check@createonuse@for{z error plus}%
+ \pgfplots@addplotimpl@table@check@createonuse@for{z error minus}%
+ \fi
+ \pgfplots@addplotimpl@table@check@createonuse@for{meta}%
+ \fi
+ %
+ \let\pgfplots@addplot@point@meta@description@of@explicit@value=\pgfplots@addplot@point@meta@description@of@explicit@value@table%
+ %
+ \ifpgfplots@addplotimpl@readcompletely
+ \pgfplotstableread{#3}\pgfplots@table
+ \pgfplots@addplotimpl@table@fromstructure@{#1}{}{\pgfplots@table}{#4}%
+ \else
+ \pgfplotsapplistXXglobalnewempty
+ %
+ % 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
+ %
+ % prepare:
+ \let\pgfplots@current@point@error@x@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@x@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@y@minus=\pgfutil@empty
+ \let\pgfplots@current@point@error@z@plus=\pgfutil@empty
+ \let\pgfplots@current@point@error@z@minus=\pgfutil@empty
+ %
+ % high level user interface functions:
+ % FIXME : these macros are UNDOCUMENTED! I suppose they are dead code...
+ \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
+ \fi
+ \pgfplots@coord@stream@end
+ \fi
+}
+\def\pgfplots@addplot@point@meta@description@of@explicit@value@table{%
+ Please add a non-empty value for \string\addplot\space table[meta=...]
+}%
+\def\pgfplots@addplotimpl@table@check@createonuse@for#1{%
+ \pgfkeysgetvalue{/pgfplots/table/#1}\pgfplots@addplotimpl@table@check@createonuse@for@
+ \expandafter\pgfplotstableifiscreateonuse\expandafter{\pgfplots@addplotimpl@table@check@createonuse@for@}{%
+ \pgfplots@addplotimpl@readcompletelytrue
+ }{%
+ }%
+}%
+\def\pgfplots@addplotimpl@table@fromfile@listener@COLLECTNORMALIZED{%
+ \pgfplots@addplotimpl@table@fromfile@listener@
+ \pgfplots@coord@stream@coord
+}
+\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
+ \def\pgfplots@dereferencepointer@and@ASSIGN@z{%
+ \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/z expr}}%
+ \let\pgfplots@current@point@z=\pgfmathresult
+ }%
+ \fi
+ \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
+ \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
+ \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@metaindex}{\pgfplots@table@PTR@meta}%
+ \fi
+ \else
+ \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@meta}{\pgfplots@table@PTR@meta}%
+ \fi
+ \pgfkeysgetvalue{/pgfplots/table/meta expr}{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \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@{%
+ \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
+}%
+
+% #1: x, y, or z
+% #2: either "plus" or "minus"
+\def\pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare@#1#2{%
+ \pgfkeysgetvalue{/pgfplots/table/#1 error #2 index}\pgfplots@plot@tbl@error@index
+ \pgfkeysgetvalue{/pgfplots/table/#1 error #2}\pgfplots@plot@tbl@error
+ %
+ \expandafter\def\csname pgfplots@table@ERRPTR@#1@#2\endcsname{#1 error #2}%
+ %
+ \expandafter\def\csname pgfplots@dereferencepointer@and@ASSIGN@error@#1@#2\endcsname{%
+ \expandafter\pgfplotstablereadevalptr\csname pgfplots@table@ERRPTR@#1@#2\endcsname\pgfmathresult
+ \expandafter\let\csname pgfplots@current@point@error@#1@#2\endcsname=\pgfmathresult
+ }%
+ %
+ \ifx\pgfplots@plot@tbl@error\pgfutil@empty
+ \ifx\pgfplots@plot@tbl@error@index\pgfutil@empty
+ \let\pgfplotsretval=\relax
+ \expandafter\let\csname pgfplots@dereferencepointer@and@ASSIGN@error@#1@#2\endcsname=\relax
+ \else
+ \pgfplotstablereadgetptrtocolindex{\pgfplots@plot@tbl@error@index}{\pgfplotsretval}%
+ \fi
+ \else
+ \pgfplotstablereadgetptrtocolname{\pgfplots@plot@tbl@error}{\pgfplotsretval}%
+ \fi
+ \expandafter\let\csname pgfplots@table@ERRPTR@#1@#2\endcsname=\pgfplotsretval
+ %
+ \pgfkeysgetvalue{/pgfplots/table/#1 error #2 expr}{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\def\csname pgfplots@dereferencepointer@and@ASSIGN@error@#1@#2\endcsname{%
+ \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/#1 error #2 expr}}%
+ \expandafter\let\csname pgfplots@current@point@error@#1@#2\endcsname=\pgfmathresult
+ }%
+ \fi
+}%
+
+\def\pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare{%
+ % this here is only evaluated ONCE.
+ \pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare@ x{plus}%
+ \pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare@ x{minus}%
+ \pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare@ y{plus}%
+ \pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare@ y{minus}%
+ %
+ \ifpgfplots@curplot@threedim
+ \pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare@ z{plus}%
+ \pgfplots@addplotimpl@table@fromfile@listener@witherrors@COLLECTHIGHLEVEL@prepare@ z{minus}%
+ \else
+ \let\pgfplots@dereferencepointer@and@ASSIGN@error@z@plus=\relax
+ \let\pgfplots@dereferencepointer@and@ASSIGN@error@z@minus=\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@plus
+ \pgfplots@dereferencepointer@and@ASSIGN@error@x@minus
+ %
+ \pgfplots@dereferencepointer@and@ASSIGN@error@y@plus
+ \pgfplots@dereferencepointer@and@ASSIGN@error@y@minus
+ %
+ \ifpgfplots@curplot@threedim
+ \pgfplots@dereferencepointer@and@ASSIGN@error@z@plus
+ \pgfplots@dereferencepointer@and@ASSIGN@error@z@minus
+ \fi
+ \pgfplots@coord@stream@coord
+}%
+\def\pgfplots@addplotimpl@table@installkeypath{%
+ \pgfkeysdef{/pgfplots/table/.unknown}{%
+ \let\pgfplots@table@curkeyname=\pgfkeyscurrentname
+ \pgfqkeys{/pgfplots}{\pgfplots@table@curkeyname=##1}%
+ }%
+}%
+
+% \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;%
+}%
+
+% 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@ybar
+ \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{%
+ \ifpgfplots@curplot@isirrelevant
+ \else
+ \pgfplots@countplots@advance
+ \fi
+ \pgfkeysvalueof{/pgfplots/execute at end plot@@}%
+ \pgfkeysvalueof{/pgfplots/execute at end plot}%
+ \endgroup%<-- close the \begingroup of \pgfplots@addplotimpl@plot@withoptions
+}
+
+% \numplotsofactualtype
+% Expands to the number of plots which have been seen in the current
+% axis and which have the same type as the actual plot handler.
+%
+% See also \plotnumofactualtype
+\def\pgfplots@numplotsofactualtype{%
+ \pgfutil@ifundefined{pgfplotssurveyphase@setactiveplothandlers@\pgfplotsplothandlername}{%
+ 0%
+ }{%
+ \csname c@pgfplots@numplotsofactualtype@\pgfplotsplothandlername\endcsname
+ }%
+}%
+% use this only inside of \addplot or during the visualization phase
+% of a plot.
+\def\pgfplots@numplotsofactualtype@duringplot{%
+ \pgfutil@ifundefined{pgfplotssurveyphase@setactiveplothandlers@\pgfplotsplothandlername@actual}{%
+ 0%
+ }{%
+ \csname c@pgfplots@numplotsofactualtype@\pgfplotsplothandlername@actual\endcsname
+ }%
+}%
+%
+%
+\def\pgfplots@countplots@init{%
+%
+ %
+ \pgfplotssurveyphase@setactiveplothandlers
+ %
+ \def\plotnum{\the\pgfplots@numplots}%
+ \let\numplotsofactualtype=\pgfplots@numplotsofactualtype@duringplot
+ %
+ % Store this name during the \addplot command. Thus, even if the
+ % plot handler changes, we will keep this one.
+ \edef\pgfplotsplothandlername@actual{\pgfplotsplothandlername}%
+ %
+ \pgfutil@ifundefined{pgfplotssurveyphase@setactiveplothandlers@\pgfplotsplothandlername@actual}{%
+ % oh. This is the first time \pgfplotsplothandlername was used
+ % in this axis. Set its counter to 0 and remember that it has
+ % been initialised.
+ \expandafter\xdef\csname c@pgfplots@numplotsofactualtype@\pgfplotsplothandlername@actual\endcsname{0}%
+ \t@pgfplots@toka=\expandafter{\pgfplotssurveyphase@setactiveplothandlers}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsplothandlername@actual}%
+ \xdef\pgfplotssurveyphase@setactiveplothandlers{%
+ \the\t@pgfplots@toka
+ \noexpand\expandafter\noexpand\def\noexpand\csname pgfplotssurveyphase@setactiveplothandlers@\the\t@pgfplots@tokb\noexpand\endcsname{1}%
+ }%
+ \expandafter\def\csname pgfplotssurveyphase@setactiveplothandlers@\the\t@pgfplots@tokb\endcsname{1}%
+ }{%
+ % ok. do nothing.
+ }%
+ %
+}%
+\def\pgfplots@countplots@advance{%
+ \global\advance\pgfplots@numplots by1\relax%
+ %
+ \expandafter\pgfplotsutil@advancestringcounter@global\csname c@pgfplots@numplotsofactualtype@\pgfplotsplothandlername@actual\endcsname
+}%
+
+% \addplot[#1] [#2] {#3} #4;
+\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{%
+ \def\pgfplotssurveyphaseinputclass{coordinates}%
+ \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2}%
+ \pgfplots@PREPARE@COORD@STREAM{#4}%
+ \ifpgfplots@curplot@threedim
+ \let\pgfplots@addplot@point@meta@description@of@explicit@value=\pgfplots@addplot@point@meta@description@of@explicit@value@coordinates@threedim
+ \pgfplots@coord@stream@foreach@threedim{#3}%
+ \else
+ \let\pgfplots@addplot@point@meta@description@of@explicit@value=\pgfplots@addplot@point@meta@description@of@explicit@value@coordinates@twodim
+ \pgfplots@coord@stream@foreach{#3}%
+ \fi
+}%
+
+\def\pgfplots@addplot@point@meta@description@of@explicit@value@coordinates@twodim{%
+ Please add suffixes for every coordinate in order to specify explicit point meta. The suffixes must have the form '(x,y) [meta]'
+}%
+\def\pgfplots@addplot@point@meta@description@of@explicit@value@coordinates@threedim{%
+ Please add suffixes for every coordinate in order to specify explicit point meta. The suffixes must have the form '(x,y,z) [meta]'
+}%
+
+{
+ % A block which handles active semicolons.
+ %
+ % ATTENTION: this block does only work if
+ % \pgfplots@addplotimpl.... changes are reflected here!
+ %
+ \catcode`\;=\active
+ \globaldefs=1
+ % 'AS' == 'active semicolon'
+ % 'IS' == 'inactive semicolon'
+ \let\pgfplots@gobble@until@semicolon@IS=\pgfplots@gobble@until@semicolon
+ \let\pgfplots@addplotimpl@expression@IS=\pgfplots@addplotimpl@expression
+ \let\pgfplots@addplotimpl@expression@curly@IS=\pgfplots@addplotimpl@expression@curly
+ \let\pgfplots@addplotimpl@function@opt@IS=\pgfplots@addplotimpl@function@opt
+ \let\pgfplots@addplotimpl@file@opt@IS=\pgfplots@addplotimpl@file@opt
+ \let\pgfplots@addplotimpl@fillbetween@opt@IS=\pgfplots@addplotimpl@fillbetween@opt
+ \let\pgfplots@addplotimpl@table@fromstructure@IS=\pgfplots@addplotimpl@table@fromstructure
+ \let\pgfplots@addplotimpl@table@fromfile@IS=\pgfplots@addplotimpl@table@fromfile
+ \let\pgfplots@addplotimpl@graphics@IS=\pgfplots@addplotimpl@graphics@
+ \let\pgfplots@addplotimpl@coordinates@IS=\pgfplots@addplotimpl@coordinates
+ %
+ \def\pgfplots@gobble@until@semicolon@AS#1;{}
+ \long\def\pgfplots@addplotimpl@expression@AS#1#2(#3,#4)#5;{\pgfplots@addplotimpl@expression@{#1}{#2}{#3}{#4}{#5}}%
+ \long\def\pgfplots@addplotimpl@expression@curly@AS#1#2#3#4;{\pgfplots@addplotimpl@expression@curly@{#1}{#2}{#3}{#4}}%
+ \def\pgfplots@addplotimpl@function@opt@AS#1#2[#3]#4#5;{\pgfplots@addplotimpl@function@opt@{#1}{#2}{#3}{#4}{#5}}%
+ \def\pgfplots@addplotimpl@file@opt@AS#1#2[#3]#4#5;{\pgfplots@addplotimpl@file@opt@{#1}{#2}{#3}{#4}{#5}}%
+ \long\def\pgfplots@addplotimpl@fillbetween@opt@AS#1#2[#3]#4;{\pgfplots@addplotimpl@fillbetween@opt@{#1}{#2}{#3}{#4}}%
+ \long\def\pgfplots@addplotimpl@table@fromstructure@AS#1#2from#3#4;{\pgfplots@addplotimpl@table@startprocessing{#1}{#2}{#3}{#4}}%
+ \long\def\pgfplots@addplotimpl@table@fromfile@AS#1#2#3#4;{\pgfplots@addplotimpl@table@startprocessing{#1}{#2}{#3}{#4}}%
+ \long\def\pgfplots@addplotimpl@coordinates@AS#1#2plot coordinates#3#4;{\pgfplots@addplotimpl@coordinates@{#1}{#2}{#3}{#4}}%
+ \long\def\pgfplots@addplotimpl@graphics@AS#1#2[#3]#4#5;{\pgfplots@addplotimpl@graphics@@{#1}{#2}{#3}{#4}{#5}}%
+ %
+ % Checks whether ';' is an active character and, if that is the
+ % case, modifies all public macros for it.
+ \pgfplots@appendto@activesemicolon@switcher{%
+ \let\pgfplots@gobble@until@semicolon=\pgfplots@gobble@until@semicolon@AS
+ \let\pgfplots@addplotimpl@expression=\pgfplots@addplotimpl@expression@AS
+ \let\pgfplots@addplotimpl@expression@curly=\pgfplots@addplotimpl@expression@curly@AS
+ \let\pgfplots@addplotimpl@function@opt=\pgfplots@addplotimpl@function@opt@AS
+ \let\pgfplots@addplotimpl@file@opt=\pgfplots@addplotimpl@file@opt@AS
+ \let\pgfplots@addplotimpl@fillbetween@opt=\pgfplots@addplotimpl@fillbetween@opt@AS
+ \let\pgfplots@addplotimpl@table@fromstructure=\pgfplots@addplotimpl@table@fromstructure@AS
+ \let\pgfplots@addplotimpl@table@fromfile=\pgfplots@addplotimpl@table@fromfile@AS
+ \let\pgfplots@addplotimpl@coordinates=\pgfplots@addplotimpl@coordinates@AS
+ \let\pgfplots@addplotimpl@graphics@=\pgfplots@addplotimpl@graphics@AS
+ }%
+}
+
+\newif\ifpgfplots@update@limits@for@one@point@ISCLIPPED
+\def\pgfplots@math@ONE{1.0}%
+
+\def\pgfplots@invoke@prefilter{%
+ \pgfkeysvalueof{/pgfplots/pre filter/.@cmd}\pgfeov%
+}%
+\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%
+}%
+
+% #1 the target which will contain the filter
+% #2 a math expression.
+\def\pgfplots@install@filter@expression#1#2{%
+ \pgfkeysdef{/pgfplots/#1}{%
+ % DO NOT MODIFY THIS VALUE without also modifying
+ % \pgfplots@ifisfilterexpression!
+ \pgfplots@filter@expression{#1}%
+ }%
+ %
+ % remember for lua backend:
+ \pgfkeyssetvalue{/pgfplots/#1/@expressionvalue}{#2}%
+}%
+% #1 the target which will contain the filter
+% #2 a math expression.
+\def\pgfplots@install@filter@expression@append#1#2{%
+ \pgfkeysgetvalue{/pgfplots/#1/.@cmd}\pgfplots@loc@TMPc
+ \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key
+ % ok, this is the first filter. Make sure it can also be
+ % processed by the lua backend
+ \pgfplots@install@filter@expression{#1}{#2}%
+ \else
+ % there is a subtle difference to /.expression: this here CANNOT
+ % be processed by the lua backend!
+ \pgfkeysalso{/pgfplots/#1/.append code={\pgfplots@filter@expression@{#1}{#2}}}%
+ \fi
+}%
+
+% Executes #2 if the filter key was defined by
+% \pgfplots@install@filter@expression.
+%
+% #1 the target which will contain the filter (like 'x filter')
+% #2: true code
+% #3: false code
+\def\pgfplots@ifisfilterexpression#1#2#3{%
+ \pgfkeysgetvalue{/pgfplots/#1/.@cmd}\pgfplots@loc@TMPc
+ \long\def\pgfplots@loc@TMPd##1\pgfeov{\pgfplots@filter@expression{#1}}%
+ \ifx\pgfplots@loc@TMPc\pgfplots@loc@TMPd
+ #2\relax
+ \else
+ #3\relax
+ \fi
+}%
+
+% #1 the key name (example: 'x filter')
+\def\pgfplots@filter@expression#1{%
+ \pgfplots@filter@expression@{#1}{\pgfkeysvalueof{/pgfplots/#1/@expressionvalue}}%
+}%
+% #1 the key name (example: 'x filter')
+% #2 the expression
+\def\pgfplots@filter@expression@#1#2{%
+ \begingroup
+ \pgfkeys{/pgf/fpu=true,%
+ /pgf/fpu/output format=float,%
+ }%
+ \pgfmathparse{#2}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% 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}}
+
+\def\pgfplots@stream@decode@and@apply#1#2#3#4{%
+ \def\pgfplots@current@point@coordindex{#1}%
+ \pgfplotsaxisdeserializedatapointfrom@private{#2}%
+ \pgfplotstreampoint{\pgfqpoint{#3}{#4}}%
+}
+
+% Takes a sequence of PREPARED coordinates which are given in floating
+% point representation and applies the data scaling trafo (if
+% necessary).
+%
+% Any coordinate will be plotted with the selected PGF plot handler.
+%
+% This stream is designed to be done at the end of an axis.
+% See \pgfplots@coord@stream@finalize@storedcoords@START
+%
+\def\pgfplots@coord@stream@INIT@finalize@storedcoords{%
+ %
+ % Init the plot handlers:
+ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
+ \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}%
+ %
+ \ifpgfplots@threedim
+ \pgfplots@apply@zbuffer
+ \fi
+ %
+ \pgfplots@perpointmeta@preparetrafo
+ %
+ \ifpgfplots@stackedmode
+ \pgfplots@stacked@visphase@beginplot
+ \fi
+ \ifpgfplots@errorbars@enabled
+ \pgfplots@errorbars@visphase@begin
+ \fi
+ \pgfplots@prepare@visualization@dependencies
+ %
+ \def\pgfplots@loc@TMPa{0}% <-- if (collectmark positions)
+ \ifpgfplots@scatterplotenabled
+ \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
+ %
+ % OK, initialize the plot handler.
+ \pgfplotsresetplothandler
+ \pgfplots@basiclevel@plothandler
+ \expandafter\pgfplotsplothandlerdeserializestatefrom\expandafter{\pgfplots@serialized@state@plothandler}%
+ %
+ \pgfplots@LUA@visualization@of@current@plot
+ %
+ \pgfplotstreamstart
+ %
+ % Now, set up coordinate streams.
+ \def\pgfplots@coord@stream@start@{%
+ \let\pgfplots@data@scaletrafo@result=\pgfutil@empty
+ \c@pgfplots@coordindex=0
+ }%
+ \def\pgfplots@coord@stream@end@{%
+ \ifpgfplots@stackedmode
+ \pgfplots@stacked@visphase@endplot
+ \fi
+ \ifpgfplots@errorbars@enabled
+ \pgfplots@errorbars@visphase@end
+ \fi
+ \pgfplots@addplot@get@named@startendpoints@command\pgfplots@loc@TMPa
+ \pgfplots@loc@TMPa
+ \pgfplotstreamend
+ }%
+ \begingroup
+ \let\E=\noexpand
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \pgfplots@coord@stream@INIT@finalize@storedcoords@prepare@scaletrafomacro
+ %
+ % Will be inserted in one of two possible places below (to collect
+ % marker positions)
+ % This finalize command maps the logical coordinate into PGF's
+ % point space. Furthermore, it collects marker coordinates
+ % (properly clipped by position) if markers are required (see
+ % above).
+ %
+ % It is prepared here to eliminate if's.
+ \gdef\pgfplots@coord@stream@finalize@currentpt{%
+ %
+ % NOTE: this here INVALIDATES \pgfplotlastpoint. However, we assign a correct value
+ % for that macro after all coordinates have been assigned - and we do it in a way
+ % which respects the special coordinates of 'patch plots'.
+ %
+ \pgfplotstreampoint{}% it will simply take \pgf@x and \pgf@y!
+ %
+ \advance\c@pgfplots@coordindex by1
+ }%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \endgroup
+%
+%\message{Prepared macro \string \pgfplotsaxisvisphasetransformcoordinate {\meaning\pgfplotsaxisvisphasetransformcoordinate}}%
+%\message{Prepared macro \string \pgfplots@coord@stream@finalize@currentpt {\meaning\pgfplots@coord@stream@finalize@currentpt}}%
+ \if1\b@pgfplots@LUA@visualization@enabled
+ \def\pgfplots@coord@stream@coord@{%
+ \ifx\pgfplots@current@point@x\pgfutil@empty% this implements `unbounded coords=jump', for example
+ \pgfplotsplothandlervisualizejump
+ \else
+ \pgfplotscoordmath{x}{tofixed}{\pgfplots@current@point@x}\let\pgfplots@current@point@x=\pgfmathresult
+ \pgfplotscoordmath{y}{tofixed}{\pgfplots@current@point@y}\let\pgfplots@current@point@y=\pgfmathresult
+ \ifpgfplots@curplot@threedim
+ \pgfplotscoordmath{z}{tofixed}{\pgfplots@current@point@z}\let\pgfplots@current@point@z=\pgfmathresult
+ \fi
+ % no need to call this here -- we got them from LUA:
+ % \pgfplotsaxis@toPGF@coords
+ \pgfplots@coord@stream@finalize@currentpt
+ \fi
+ }%
+ \else
+ \def\pgfplots@coord@stream@coord@{%
+ \ifpgfplots@stackedmode
+ \pgfplots@stacked@visphase@stream@coord@
+ \fi
+ \ifx\pgfplots@current@point@x\pgfutil@empty% this implements `unbounded coords=jump', for example
+ \pgfplotsplothandlervisualizejump
+ \else
+ \pgfplotsaxisvisphasegetpoint
+ \pgfplots@coord@stream@finalize@currentpt
+ \fi
+ }%
+ \fi
+}
+
+\def\pgfplots@LUA@visualization@init{%
+ \ifpgfplots@LUA@backend@supported
+ \edef\pgfplots@loc@TMPa{%
+ \pgfplotsutil@directlua{pgfplots.texVisualizationInit(\pgfplots@LUA@backend@plotnum, \ifpgfplots@curplot@threedim true\else false\fi)}%
+ }%
+ \if1\pgfplots@loc@TMPa
+ \pgfplots@log{\pgfplots@LUA@loglevel@debug}{lua backend=true: Activating partial LUA backend for visualization of plot \plotnum\space (lua: \pgfplots@LUA@backend@plotnum).}%
+ \else
+ \pgfplots@LUA@backend@supportedfalse
+ \fi
+ \fi
+}%
+
+% Takes the current point (defined by a set of macros) as input and defines \pgf@x and \pgf@y
+% as the output point. It also defines
+% \pgfplots@current@point@x and its variants to contain the
+% transformed canvas coords (those which can be given to
+% \pgfplotsqpointxyz).
+%
+\def\pgfplotsaxisvisphasegetpoint{%
+ \pgfplotsaxisvisphasetransformcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z%
+ \pgfplotsaxisvisphasepreparedatapoint
+ \pgfplotsaxis@toPGF@coords
+}%
+
+\def\pgfplotsaxis@toPGF@coords{%
+ \ifpgfplots@curplot@threedim
+ \pgfplotsqpointxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}%
+ \else
+ \pgfplotsqpointxy{\pgfplots@current@point@x}{\pgfplots@current@point@y}%
+ \fi
+}%
+
+% A command which returns high-level (logical) coordinates into the keys
+% /data point/x
+% /data point/y
+% /data point/z
+% /data point/meta
+% /data point/index
+%
+% The command has two modes:
+%
+% 1. without arguments. In this case, it reads the "current" point
+% from the plot handler.
+%
+% 2. with an argument in curly braces. In this case, it expects one of
+% the following:
+% a) a \pgfpoint instruction (i.e. some code which assigns \pgf@x and
+% \pgf@y) and returns the associated logical (high-level) coordinates.
+% b) a TikZ point starting with '('.
+%
+% Examples:
+% * \pgfplotspointgetcoordinates
+% -> useful for nodes near coords
+% * \pgfplotspointgetcoordinates{\pgfpoint{200pt}{100pt}}
+% * \pgfplotspointgetcoordinates{(5,3)}
+%
+%
+% This works for 2D axes only.
+%
+\def\pgfplotspointgetcoordinates{%
+ \pgfutil@ifnextchar\bgroup{%
+ \pgfplotspointgetcoordinates@frompgfpoint
+ }{%
+ \pgfplotspointgetcoordinates@currentpoint
+ }%
+}%
+\def\pgfplotspointgetcoordinates@frompgfpoint#1{%
+ \pgfplotspointgetnormalizedcoordinates{#1}%
+ \pgfplotspointgetcoordinatesfromnormalized
+}%
+\def\pgfplotspointgetcoordinates@currentpoint{%
+ \pgfplotspointgetnormalizedcoordinates
+ \pgfplotspointgetcoordinatesfromnormalized
+}%
+
+\def\pgfplotspointgetnormalizedcoordinates@@@x{undefined}
+\def\pgfplotspointgetnormalizedcoordinates@@@y{undefined}
+\def\pgfplotspointgetnormalizedcoordinates@@@z{undefined}
+\let\pgfplotspointgetnormalizedcoordinates@@@index=\pgfutil@empty
+\let\pgfplotspointgetnormalizedcoordinates@@@meta=\pgfutil@empty
+
+% PRECONDITION: \pgfplots@current@point@x and its variants is given in
+% TRANSFORMED format, i.e. we assume that we are in the visualization
+% phase after the coordinates have been prepared.
+% POSTCONDITION: the untransformed #1 coordinate is assigned to
+% \pgfplotsretval
+\def\pgfplotspointgetnormalizedcoordinates@#1{%
+ % XXX : this is slower than it used to be - in 1.11, I simply
+ % remembered 'x untransformed'! I switched it to this lazy
+ % computation due to the LUA backend in which case remembering it
+ % leads to extensive (=expensive?) communication between lua and
+ % TeX. Does it hurt here? Scatter plots compute this stuff...
+ \expandafter\let\expandafter\pgfplotsretval\csname pgfplotspointgetnormalizedcoordinates@@@#1\endcsname
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplotscoordmath{#1}{datascaletrafo inverse}{\pgfplotsretval}%
+ \let\pgfplotsretval=\pgfmathresult
+ }{}%
+ \fi
+}%
+
+% Same as \pgfplotspointgetcoordinates, but the resulting values are
+% for use in 'normalized axis cs'.
+\def\pgfplotspointgetnormalizedcoordinates{%
+ \pgfutil@ifnextchar\bgroup{%
+ \pgfplotspointgetnormalizedcoordinates@frompgfpoint
+ }{%
+ \pgfplotspointgetnormalizedcoordinates@currentpoint
+ }%
+}
+\def\pgfplotspointgetnormalizedcoordinates@frompgfpoint#1{%
+ \pgfplotspointgetnormalizedcoordinates@frompgfpoint@#1\pgfplots@EOI
+}
+\def\pgfplotspointgetnormalizedcoordinates@frompgfpoint@{%
+ \pgfutil@ifnextchar({\pgfplotspointgetnormalizedcoordinates@frompgfpoint@tikz}{\pgfplotspointgetnormalizedcoordinates@frompgfpoint@@}%
+}%
+\def\pgfplotspointgetnormalizedcoordinates@frompgfpoint@tikz#1\pgfplots@EOI{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \def\pgfplots@loc@TMPb{(.)}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \pgfplotspointgetnormalizedcoordinates@frompgfpoint@@\tikz@last@position\pgfplots@EOI
+ \else
+ \tikz@scan@one@point\pgfplotspointgetnormalizedcoordinates@frompgfpoint@@@#1\relax
+ \fi
+}%
+\def\pgfplotspointgetnormalizedcoordinates@frompgfpoint@@@#1{%
+ \pgfplotspointgetnormalizedcoordinates@frompgfpoint@@#1\pgfplots@EOI
+}
+\def\pgfplotspointgetnormalizedcoordinates@frompgfpoint@@#1\pgfplots@EOI{%
+ \pgf@process{#1}%
+ \pgfplotsconvertunittocoordinate{x}{\pgf@x}%
+ \let\pgfplotspointgetnormalizedcoordinates@@@x=\pgfmathresult
+ \pgfplotsconvertunittocoordinate{y}{\pgf@y}%
+ \let\pgfplotspointgetnormalizedcoordinates@@@y=\pgfmathresult
+ \let\pgfplotspointgetnormalizedcoordinates@@@z=\pgfutil@empty
+ \let\pgfplotspointgetnormalizedcoordinates@@@index=\pgfutil@empty
+ \let\pgfplotspointgetnormalizedcoordinates@@@meta=\pgfutil@empty
+ %
+ \pgfplotspointgetnormalizedcoordinates@internal%
+}%
+
+\def\pgfplotspointgetnormalizedcoordinates@currentpoint{%
+ \let\pgfplotspointgetnormalizedcoordinates@@@x=\pgfplots@current@point@x
+ \let\pgfplotspointgetnormalizedcoordinates@@@y=\pgfplots@current@point@y
+ \let\pgfplotspointgetnormalizedcoordinates@@@z=\pgfplots@current@point@z
+ \let\pgfplotspointgetnormalizedcoordinates@@@meta=\pgfplots@current@point@meta
+ \let\pgfplotspointgetnormalizedcoordinates@@@index=\pgfplots@current@point@coordindex
+ \pgfplotspointgetnormalizedcoordinates@internal
+}
+\def\pgfplotspointgetnormalizedcoordinates@internal{%
+ \pgfplotspointgetnormalizedcoordinates@ x%
+ \pgfkeyslet{/data point/x}\pgfplotsretval
+ %
+ \pgfplotspointgetnormalizedcoordinates@ y%
+ \pgfkeyslet{/data point/y}\pgfplotsretval
+ %
+ \ifpgfplots@curplot@threedim
+ \pgfplotspointgetnormalizedcoordinates@ z%
+ \pgfkeyslet{/data point/z}\pgfplotsretval
+ \else
+ \pgfkeyslet{/data point/z}\pgfutil@empty
+ \fi
+ %
+ \pgfkeyslet{/data point/meta}\pgfplotspointgetnormalizedcoordinates@@@meta
+ \edef\pgfplots@loc@TMPa{\pgfplotspointgetnormalizedcoordinates@@@index}%
+ \pgfkeyslet{/data point/index}\pgfplots@loc@TMPa
+}%
+
+% Assumes that we are given normalized coordinates (i.e. those for use
+% in 'normalized axis cs') and transforms them into those which are
+% for use in 'axis cs'.
+%
+% Accepts an optional argument in square brackets, namely one or more
+% options in the /pgfplots/coords key path (see below).
+\def\pgfplotspointgetcoordinatesfromnormalized{%
+ \pgfutil@ifnextchar[{\pgfplotspointgetcoordinatesfromnormalized@opt}{\pgfplotspointgetcoordinatesfromnormalized@opt[]}%
+}%
+
+% Defines where to expect INPUT coordinates
+% \pgfplotspointgetcoordinatesfromnormalized[path=/data point/
+% would expect input coordinates
+% /data point/x
+% /data point/y
+% /data point/z
+\pgfkeyssetvalue{/pgfplots/coords/path}{/data point}
+
+% \pgfplotspointgetcoordinatesfromnormalized[target path=/data point/zero/
+% would write output coordinates
+% /data point/zero/x
+% /data point/zero/y
+% /data point/zero/z
+\pgfkeyssetvalue{/pgfplots/coords/target path}{\pgfkeysvalueof{/pgfplots/coords/path}}
+
+\def\pgfplotspointgetcoordinatesfromnormalized@opt[#1]{%
+ \begingroup
+ \pgfqkeys{/pgfplots/coords}{#1}%
+ \pgfkeysgetvalue{/pgfplots/coords/path}\pgfplots@path
+ \pgfkeysgetvalue{/pgfplots/coords/target path}\pgfplots@path@trg
+ \pgfkeysifdefined{\pgfplots@path/x}{}{%
+ \pgfplots@error{Illegal argument: '\pgfplots@path' is no valid data point path (\pgfplots@path/x does not exist)}%
+ }%
+ \pgfkeysgetvalue{\pgfplots@path/x}\pgfplots@loc@x
+ \pgfkeysgetvalue{\pgfplots@path/y}\pgfplots@loc@y
+ \pgfkeysgetvalue{\pgfplots@path/z}\pgfplots@loc@z
+ %
+ \pgfplotspointgetcoordinatesfromnormalized@transform x\pgfplots@loc@x%
+ \pgfplotspointgetcoordinatesfromnormalized@transform y\pgfplots@loc@y%
+ \ifpgfplots@threedim
+ \pgfplotspointgetcoordinatesfromnormalized@transform z\pgfplots@loc@z%
+ \fi
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\pgfkeyssetvalue{\pgfplots@path@trg/x}{\pgfplots@loc@x}%
+ \noexpand\pgfkeyssetvalue{\pgfplots@path@trg/y}{\pgfplots@loc@y}%
+ \noexpand\pgfkeyssetvalue{\pgfplots@path@trg/z}{\pgfplots@loc@z}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+\def\pgfplotspointgetcoordinatesfromnormalized@transform#1#2{%
+ \edef\pgfplots@loc@TMPa{#2}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \pgfplotscoordmath{#1}{tofixed}{#2}%
+ }{%
+ \pgfplotscoordmath{#1}{exp}{#2}%
+ }%
+ \let#2=\pgfmathresult
+ \pgfplots@coord@inv@trafo@apply{#1}{#2}%
+ \let#2=\pgfmathresult
+ \fi
+}%
+
+% Defines an optimized and matching \pgfplotsaxisvisphasetransformcoordinate
+% during the coordinate finalization step in \end{axis}.
+\def\pgfplots@coord@stream@INIT@finalize@storedcoords@prepare@scaletrafomacro{%
+ \begingroup
+ \let\E=\noexpand
+ %
+ % \pgfplotsaxisvisphasetransformcoordinate
+ % Maps a point to the low level xyz coordinate system by applying
+ % data scaling transformations.
+ %
+ % This method should be invoked for every coordinate before it can
+ % be drawn.
+ %
+ % It is prepared here to eliminate if's.
+ %
+ % Arguments:
+ % #1 : a MACRO containing the x value
+ % #2 : a MACRO containing the y value
+ % #3 : a MACRO containing the z value
+ %
+ % PRECONDITION:
+ % - the visualization phase is running.
+ % - #1,#2,#3 are defined and contain
+ % values resulting from the survey phase.
+ %
+ % POSTCONDITION
+ % - #1,#2,#3 will be redefined to contain data which is
+ % readily usable by low level pgf plot handlers for
+ % visualization.
+ %
+ % @see \pgfplotsaxisvisphasepreparedatapoint
+ \xdef\pgfplotsaxisvisphasetransformcoordinate##1##2##3{%
+ \ifpgfplots@apply@datatrafo@x
+ \E\pgfplotscoordmath{x}{datascaletrafo}{##1}%
+ \E\let##1=\E\pgfmathresult
+ \fi
+ \ifpgfplots@apply@datatrafo@y
+ \E\pgfplotscoordmath{y}{datascaletrafo}{##2}%
+ \E\let##2=\E\pgfmathresult
+ \fi
+ \ifpgfplots@curplot@threedim
+ \ifpgfplots@apply@datatrafo@z
+ \E\pgfplotscoordmath{z}{datascaletrafo}{##3}%
+ \E\let##3=\E\pgfmathresult
+ \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)}%
+ }%
+ %
+ % Just before the visualization phase can call the low level
+ % interface, this method is called to handle final changes.
+ % It is currently only used by the stacked plot interface.
+ \xdef\pgfplotsaxisvisphasepreparedatapoint{%
+ \ifpgfplots@stackedmode
+ % all these calls work with pgfmath; no more floating point
+ % arithmetics are applied.
+ \E\pgfplots@stacked@visphasepreparedatapoint%
+ \fi
+ }%
+ %
+ \endgroup
+}
+
+% Defines \pgfmathresult to contain the transformed coordinate entry
+% #1: one of x,y ,or z
+% #2: the input value
+\def\pgfplotsaxisvisphasetransformcoordinateentry#1#2{%
+ \pgfplots@if{pgfplots@apply@datatrafo@#1}{%
+ \pgfplotscoordmath{#1}{datascaletrafo}{#2}%
+ }{%
+ \edef\pgfmathresult{#2}%
+ }%
+}%
+
+\def\pgfplots@addplot@define@plot@cycle@threedim{%
+ \def\pgfplots@path@closed@cycle@std{%
+ \pgfextra{%
+ \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@currentplot@lastcoord@x}{\pgfplots@currentplot@lastcoord@y}{\pgfplots@logical@ZERO@z}}%
+ \pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@currentplot@firstcoord@x}{\pgfplots@currentplot@firstcoord@y}{\pgfplots@logical@ZERO@z}}%
+ }%
+ -- cycle
+ }%
+}%
+\def\pgfplots@addplot@get@named@startendpoints@command#1{%
+ \ifx\pgfplots@currentplot@firstcoord@x\pgfutil@empty
+ % empty plot.
+ \def#1{%
+ \pgfcoordinate{current plot begin}{\pgfplotspointaxisorigin}%
+ \pgfcoordinate{current plot end}{\pgfplotspointaxisorigin}%
+ }%
+ \else
+ \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}}%
+ }%
+ % FIXME : wouldn't this be a good idea for 2d axes as
+ % well!?
+ \pgfplots@addplot@define@plot@cycle@threedim
+ \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
+}%
+
+% This is the pgfplots implementation for 'node[pos=<fraction>]'.
+% Besides modifications of the transformation matrix, it also defines the COORDINATES of the point to
+% /data point/x
+% /data point/y
+% /data point/z
+% (or more keys which depend on the plot handler).
+\def\pgfplots@plot@timer{%
+ \pgfplotstransformplotattime{\tikz@time}%
+}
+
+% Installs a transformation matrix such that (0,0) is the point of the
+% current plot with fraction #1.
+%
+% This does actually nothing more than using
+% \pgfplotspointplotattime{#1} as shift and using the slope of the
+% curve at that point to set up the 'sloped' rotation (if enabled).
+\def\pgfplotstransformplotattime#1{%
+ \pgftransformshift{\pgfplotspointplotattime{#1}}%
+ \ifpgfresetnontranslationattime%
+ \pgftransformresetnontranslations%
+ \fi%
+ \ifpgfslopedattime%
+ \pgfplotsplothandlertransformslopedattime{#1}{\pgfplotspointplotattimefirst}{\pgfplotspointplotattimesecond}%
+ \fi%
+}
+
+\def\pgfplotspointplotattimeclearcache{%
+ \global\let\pgfplotspointplotattime@cache=\pgfutil@empty
+ \gdef\pgfplotspointplotattime@cachesize{0}%
+}%
+\pgfplotspointplotattimeclearcache
+\def\pgfplotspointplotattime@cachesize@max{20}
+
+% Checks if the cache for \pgfplotspointplotattime has a cached entry for '#1'.
+% POSTCONDITION:
+% if \ifpgfplots@loc@tmp is true, the value(s) from the cache have been retrieved successfully.
+% if \ifpgfplots@loc@tmp is false, there is not hit.
+\def\pgfplotspointplotattimegetfromcache#1{%
+ \pgf@xa=#1pt %
+ \pgfplotspointplotattime@cache
+ \pgfkeysifdefined{/data point/@pos \the\pgf@xa/segment \pgfkeysvalueof{/tikz/pos segment}}{%
+ \pgfkeysvalueof{/data point/@pos \the\pgf@xa/segment \pgfkeysvalueof{/tikz/pos segment}}%
+ \pgfplots@loc@tmptrue
+ }{%
+ \pgfplots@loc@tmpfalse
+ }%
+}%
+\def\pgfplotspointplotattimeaddtocache#1{%
+ \pgfplotsutil@advancestringcounter@global\pgfplotspointplotattime@cachesize
+ \ifnum\pgfplotspointplotattime@cachesize=\pgfplotspointplotattime@cachesize@max
+ \pgfplotspointplotattimeclearcache
+ \fi
+ \pgf@xa=#1pt %
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\gdef\noexpand\pgfplotspointplotattimefirst{\pgfplotspointplotattimefirst}%
+ \noexpand\gdef\noexpand\pgfplotspointplotattimesecond{\pgfplotspointplotattimesecond}%
+ \noexpand\gdef\noexpand\pgfplotspointplotattimecoords{\pgfplotspointplotattimecoords}%
+ \noexpand\pgf@x=\the\pgf@x\space% attempt to fix bugs/94/ aka q/271792/.
+ \noexpand\pgf@y=\the\pgf@y\space% sometimes there are \noexpand sometimes there are not.
+ }%
+ \t@pgfplots@toka=\expandafter{\pgfplotspointplotattime@cache}%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}%
+ \xdef\pgfplotspointplotattime@cache{%
+ \the\t@pgfplots@toka
+ \noexpand\pgfkeyssetvalue{/data point/@pos \the\pgf@xa/segment \pgfkeysvalueof{/tikz/pos segment}}{\the\t@pgfplots@tokb}%
+ }%
+}
+
+% Sets (\pgf@x,\pgf@y) to the point of the current plot with fraction #1.
+% For #1 = 0, this is the first point.
+% For #1 = 1, this is the last point.
+% For #1 = 0.5, it is the middle of the plot.
+% The argument '#1' is optional: if you leave it away, the current value of the 'pos' key will be used.
+% This method will work for most plot handlers, although some of them might be unsupported.
+%
+% As a side-effect, it defines the (global) macros
+% - \pgfplotspointplotattimefirst the start coordinate of the line segment containing #1
+% - \pgfplotspointplotattimesecond the end coordinate of the line segment containing #1
+% - \pgfplotspointplotattimecoords the coordinates of #1
+% The first two are interesting in order to allow the computation of gradients.
+% \pgfplotsplothandlerpointtokeys{/data point}%
+% for the \pgfplotspointplotattimecoords point
+%
+% Any of these macros can be decoded using
+% \pgfplotsplothandlerdeserializepointfrom\pgfplotspointplotattimesecond
+% \pgfplotsaxisvisphasegetpoint
+%
+% @see \pgfplotsplothandlerpointtokeys
+\def\pgfplotspointplotattime{%
+ \pgfutil@ifnextchar\bgroup{\pgfplotspointplotattime@}{\pgfplotspointplotattime@{\tikz@time}}%
+}
+\def\pgfplotspointplotattime@#1{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfplots@error{Sorry, the provided fraction of the plot is empty (maybe the argument of 'pos' has been cleared by the tikz node processing). Please provide a valid 'pos' argument}%
+ \else
+ \pgfplotspointplotattimegetfromcache{#1}%
+ \ifpgfplots@loc@tmp
+ % CACHE HIT!
+%\message{CACHE HIT for \string\pgfplotspointplotattime{#1}^^J}%
+ \else
+%\message{NO cache hit for \string\pgfplotspointplotattime{#1}^^J}%
+ \begingroup
+ %
+ \if1\b@pgfplots@LUA@visualization@enabled
+ \ifx\pgfplots@plot@timer@args\relax
+ \expandafter\gdef\expandafter\pgfplots@plot@timer@args\expandafter{%
+ \pgfplotsutil@directlua{pgfplots.texGetSurveyedCoordsToPgfplots()}%
+ }%
+ \fi
+ \let\pgfplotsaxisdeserializedatapointfrom@private=\pgfplotsaxisdeserializedatapointfrom@private@nonLUA
+ \else
+ \global\let\pgfplots@plot@timer@args=\pgfplots@stored@current@data
+ \fi
+ %
+ %
+ \edef\pgfplots@time{#1}%
+ \pgfplotscoordmathparsemacro{default}{\pgfplots@time}%
+ \pgfkeysgetvalue{/tikz/pos segment}\pgfplots@pos@segment
+ %
+\iffalse
+ % this here is a simple experiment which finds x or y
+ % values. IMPLEMENT IT!
+ \def\pgfplotspointattime@do@set@current@value{%
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@current@point@y}%
+ \let\pgfplotspointattime@value@current=\pgfmathresult
+ }%
+ \def\pgfplotspointattime@do@set@target@value{%
+ \let\pgfplotspointattime@value@target=\pgfplots@time
+ }%
+ \def\pgfplots@ifpointattime@do@set@current@value@accumulates##1##2{##2}%
+\fi
+ %
+ \let\pgfplotspointattime@do=\relax
+ \let\pgfplots@coord@stream@start@=\pgfplots@coord@stream@start@plot@at@time
+ \let\pgfplots@coord@stream@coord@=\pgfplots@coord@stream@coord@plot@at@time
+ \def\pgfplots@coord@stream@end@{}%
+ \pgfplots@ifpointattime@do@set@current@value@accumulates{%
+ % 1. compute the total length of the plot (by integrating along a linear spline)
+ %
+ % we need to compute the TOTAL length in order to set the
+ % target values.
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@plot@timer@args}%
+ }{}%
+ %
+ \pgfplotspointattime@do@set@target@value
+ %
+ \pgfplotscoordmath{default}{zero}%
+ \let\pgfplots@len@last=\pgfmathresult
+ \let\pgfplots@len@last@last=\pgfplots@len@last
+%\message{plot at time (#1, segment \pgfplots@pos@segment): total length=\pgfplotspointattime@value@current; target len \pgfplotspointattime@value@target\space (#1)^^J}%
+ %
+ \def\pgfplots@HIT{0}%
+ \let\pgfplots@last@last=\pgfutil@empty
+ \let\pgfplots@coord@stream@coord@=\pgfplots@coord@stream@coord@plot@at@time
+ \let\pgfplotspointattime@do=\pgfplotspointattime@do@find@target@value
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@plot@timer@args}%
+ \if\pgfplots@HIT0%
+ \let\pgfplots@last@processed=\pgfplots@last@last
+ \let\pgfplots@len@last=\pgfplots@len@last@last
+ \pgfplotspointattime@pointbetween@two
+ \fi
+ \endgroup
+ \pgfplotspointplotattimeaddtocache{#1}%
+ \fi
+ \pgfplotsplothandlerdeserializepointfrom\pgfplotspointplotattimecoords
+ \pgfplotscoordmath{x}{tofixed}{\pgfplots@current@point@x}%
+ \pgfplots@coord@inv@trafo@apply{x}{\pgfmathresult}%
+ \let\pgfplots@current@point@x=\pgfmathresult
+ \pgfplotscoordmath{y}{tofixed}{\pgfplots@current@point@y}%
+ \pgfplots@coord@inv@trafo@apply{y}{\pgfmathresult}%
+ \let\pgfplots@current@point@y=\pgfmathresult
+ \ifpgfplots@curplot@threedim
+ \pgfplotscoordmath{z}{tofixed}{\pgfplots@current@point@z}%
+ \pgfplots@coord@inv@trafo@apply{z}{\pgfmathresult}%
+ \let\pgfplots@current@point@z=\pgfmathresult
+ \fi
+ \pgfplotsplothandlerpointtokeys{/data point}%
+ \fi
+}
+
+% coordinate streaming method for use in
+% \pgfplotspointplotattime
+\def\pgfplots@coord@stream@start@plot@at@time{%
+ \ifx\pgfplots@pos@segment\pgfutil@empty
+ \let\c@pgfplots@segments=\pgfutil@empty
+ \else
+ \def\c@pgfplots@segments{0}%
+ \c@pgf@countd=\pgfplots@pos@segment\relax
+ \edef\pgfplots@pos@segment{\the\c@pgf@countd}%
+ \fi
+ \pgfplotscoordmath{default}{zero}%
+ \let\pgfplotspointattime@value@current=\pgfmathresult
+ \let\pgfplots@last@processed=\pgfutil@empty
+ \def\pgfplots@last@was@empty{1}%
+}%
+
+
+% coordinate streaming method for use in
+% \pgfplotspointplotattime
+%
+% It invokes \pgfplotspointattime@do{} whenever is has found a line
+% segment.
+\def\pgfplots@coord@stream@coord@plot@at@time{%
+%\message{plot at time (#1, segment \pgfplots@pos@segment): processing (\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)^^J}%
+ \ifx\pgfplots@current@point@x\pgfutil@empty
+ \if1\pgfplots@last@was@empty
+ \else
+ % oh. a jump... start new length segment
+ \ifx\c@pgfplots@segments\pgfutil@empty
+ \else
+ \ifx\pgfplots@pos@segment\c@pgfplots@segments
+ \let\pgfplots@coord@stream@coord@=\relax
+ \fi
+ \pgfplotsutil@advancestringcounter\c@pgfplots@segments
+ \fi
+ \fi
+ \let\pgfplots@last@processed=\pgfutil@empty
+ \def\pgfplots@last@was@empty{1}%
+ \else
+ \ifx\pgfplots@pos@segment\c@pgfplots@segments
+ \pgfplotsplothandlerserializepointto{\pgfplots@cur}%
+ \pgfplotspointattime@do@set@current@value
+ %
+ \ifx\pgfplots@last@processed\pgfutil@empty
+ \else
+ \pgfplotspointattime@do
+ \fi
+ %
+ \let\pgfplots@len@last@last=\pgfplots@len@last
+ \let\pgfplots@len@last=\pgfplotspointattime@value@current
+ \let\pgfplots@last@last=\pgfplots@last@processed
+ \let\pgfplots@last@processed=\pgfplots@cur
+ \fi
+ \def\pgfplots@last@was@empty{0}%
+ \fi
+}%
+
+% A macro which is invoked whenever \pgfplotspointplotattime found a
+% line segment.
+%
+% INPUT:
+% - \pgfplots@cur : serialized current point. This current point's
+% properties are available in the macros
+% \pgfplots@current@point@[xyz] etc.
+% - \pgfplots@last@processed : serialized last point
+% - \pgfplotspointattime@value@current : the accumulated length so far
+%
+\def\pgfplotspointattime@do{}
+
+% \pgfplots@ifpointattime@do@set@current@value@accumulates{<true code>}{<false code>}
+%
+% is invokes to test if \pgfplotspointattime@do@set@current@value
+% accumulates stuff. If so, it will invoke <true code>. If it does NOT
+% accumulate stuff, it will invoke <false code>
+\def\pgfplots@ifpointattime@do@set@current@value@accumulates#1#2{%
+ % the default "time fraction" implementation accumulates:
+ #1\relax
+}
+
+\def\pgfplotspointattime@do@set@current@value{%
+ \ifx\pgfplots@last@processed\pgfutil@empty
+ \else
+ \pgfplotsplothandlersurveydifflen{\pgfplots@last@processed}{\pgfplots@cur}%
+ \pgfplotscoordmath{default}{op}{add}{{\pgfmathresult}{\pgfplotspointattime@value@current}}%
+ \let\pgfplotspointattime@value@current=\pgfmathresult
+ \fi
+%\message{plot at time (#1, segment \pgfplots@pos@segment): length \pgfplotspointattime@value@current^^J}%
+}%
+
+% Needs to define \pgfplotspointattime@value@target .
+%
+% This value is the search target: once the loop realizes that it
+% passed \pgfplotspointattime@value@target, it will report a hit in the current
+% interval.
+\def\pgfplotspointattime@do@set@target@value{%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@time}{\pgfplotspointattime@value@current}}%
+ \let\pgfplotspointattime@value@target=\pgfmathresult
+}%
+
+\def\pgfplotspointattime@do@find@target@value{%
+ % compare \pgfplotspointattime@value@target and \pgfplotspointattime@value@current to see if
+ % we passed the target interval:
+ \pgfplotscoordmath{default}{if less than}
+ {\pgfplotspointattime@value@target}
+ {\pgfplotspointattime@value@current}
+ {% HIT!
+ \def\pgfplots@HIT{1}%
+ \pgfplotspointattime@pointbetween@two
+ %
+ % we cannot stop the loop; what we can turn it into no-op:
+ \let\pgfplots@coord@stream@coord@=\relax
+ }{%
+ }%
+}%
+
+\def\pgfplotspointattime@pointbetween@two{%
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotspointattime@value@target}{\pgfplots@len@last}}%
+ \let\pgfplots@tmp=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotspointattime@value@current}{\pgfplots@len@last}}%
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfplots@tmp}{\pgfmathresult}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@time@between@two=\pgfmathresult
+%\message{HIT of \pgfplotspointattime@value@target\space between \pgfplots@len@last\space and \pgfplotspointattime@value@current\space (\pgfplots@time@between@two)^^J}%
+ \ifx\pgfplots@last@processed\pgfutil@empty
+ \pgfplotsplothandlerserializepointto{\pgfplots@cur}%
+ \else
+ \pgfplotsplothandlersurveypointattime{\pgfplots@time@between@two}{\pgfplots@last@processed}{\pgfplots@cur}%
+ \fi
+ \pgfplotsplothandlerserializepointto\pgfplots@loc@TMPa
+ \global\let\pgfplotspointplotattimecoords=\pgfplots@loc@TMPa
+ \pgfplotsaxisvisphasegetpoint
+ \global\let\pgfplotspointplotattimefirst=\pgfplots@last@processed
+ \global\let\pgfplotspointplotattimesecond=\pgfplots@cur
+}%
+
+
+% #1 : either x,y, or z
+% #2 : the argument on which the inv trafo shall be applied. It has to
+% be a fixed point number.
+\def\pgfplots@coord@inv@trafo@apply#1#2{%
+ \edef\pgfmathresult{#2}%
+ \pgfkeysgetvalue{/pgfplots/#1 coord inv trafo/.@cmd}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key
+ \else
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov
+ \fi
+}%
+
+% INPUT:
+% either floating point or fixed point coordinates (depending on the
+% state of the \ifpgfplots@apply@datatrafo boolean)
+%
+\long\def\pgfplots@coord@stream@finalize@storedcoords@START{%
+ % de-activate the FPU here! I fear its number
+ % format may cause errors when used in low-level
+ % routines.
+ \pgfkeys{/pgf/fpu=false}%
+ %
+ \pgfplots@assert@tikzinternal@exists{tikz@make@last@position}%
+ %
+ \ifpgfplots@clip
+ \else
+ % "clip marker paths=true" actually doesn't checks anything --
+ % it leaves the checks to the clip path. But since there is no
+ % clip path, it is adequate to use it here:
+ \pgfplots@clip@marker@pathstrue
+ \fi
+ %
+ \pgfplots@stored@current@cmd%[current plot style] <--- options are already set
+ \pgfextra
+ %
+ \tikzset{every plot/.try}%
+ \pgfplots@coord@stream@INIT@finalize@storedcoords%
+ %
+ \iffalse
+ %\ifx\pgfplots@basiclevel@plothandler\pgfplothandlerdiscard
+ % discard!? Well, no need to loop through the elements.
+ % But there may be a good reason that we entered the phase!
+ % keep it.
+ % FIXME : this does not work, although it might be desirable.
+ % It fails because we need the named start/end points.
+ \pgfplots@coord@stream@start
+ \pgfplots@coord@stream@end
+ \else
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}%
+ \fi
+ %
+ % This here ensures that the LAST position of the path is the last plotted point.
+ % However, the "last plotted point" is not necessarily the LAST in the sequence.
+ % This here is the last plotted point:
+ \xdef\pgfplotlastpoint{\noexpand\pgfpointanchor{current plot end}{center}}%
+ \tikz@make@last@position{\pgfplotlastpoint}%
+ %
+ % the coordinate stream will be assigned as soon as it is needed:
+ \global\let\pgfplots@plot@timer@args=\relax
+ \pgfplotspointplotattimeclearcache
+ \let\tikz@timer=\pgfplots@plot@timer%
+ \pgfplotsaxisvisphase@get@afterpath%
+ \expandafter
+ \endpgfextra
+ \pgfplotsretval
+ ;%
+ %
+ \pgfplotspointplotattimeclearcache
+ \global\let\pgfplots@plot@timer@args=\relax
+ %
+}%
+
+% Defines \pgfplotsretval to contain the "after path", i.e. the
+% standard tikz instructions which are to be carried out after the
+% plot path. This depends on the current visualization phase and the
+% available visualization phases.
+\def\pgfplotsaxisvisphase@get@afterpath{%
+ \ifx\pgfplots@visphase@name\pgfplotsaxis@visphase@name@default
+ % ah - we have the standard visualization phase. Draw them
+ % here.
+ %
+ % Note that the existance of (nontrivial) after path
+ % instructions ALWAYS implies the existance of a standard
+ % visualization phase (compare \pgfplotssurveyphase@set@visphase@names)
+ \let\pgfplotsretval=\pgfplots@serialized@afterpath%
+ \else
+ \let\pgfplotsretval=\pgfutil@empty
+ \fi
+}%
+
+
+% This routine is called at the begin of every plot.
+% It initialises a zero level stream.
+%
+% The default is to use '0' as zero level streams.
+%
+% This method is called as "precommand"; before any Tikz drawing
+% commands have been started.
+\def\pgfplots@initzerolevelhandler{%
+ \ifpgfplots@stackedmode
+ % ATTENTION: this thing here says:
+ % "draw zero level coordinates from list XYZ."
+ % But at the time of this initialisation, the list will be EMPTY!
+ %
+ % It will be filled later. That's ok, because
+ % \pgfplots@initzerolevelhandler will be
+ % used as 'precommand', that means before Tikz sees any
+ % coordinates.
+ \pgfplots@stacked@initzerolevelhandler
+ \else
+ \ifpgfplots@threedim
+ \def\pgfplotxzerolevelstreamstart{}%
+ \def\pgfplotxzerolevelstreamend{}%
+ \def\pgfplotxzerolevelstreamnext{%
+ \begingroup
+ \pgf@xa=\pgf@y
+ \pgfplotsqpointxyz{\pgfplots@logical@ZERO@x}{\pgfplots@current@point@y}{\ifpgfplots@curplot@threedim\pgfplots@current@point@z\else\pgfplots@logical@ZERO@z\fi}%
+ \global\pgf@x=\pgf@x
+ \global\pgf@y=\pgf@xa
+ \endgroup
+ }%
+ %
+ \def\pgfplotyzerolevelstreamstart{}%
+ \def\pgfplotyzerolevelstreamend{}%
+ \def\pgfplotyzerolevelstreamnext{%
+ \begingroup
+ \pgf@xa=\pgf@y
+ \pgfplotsqpointxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@logical@ZERO@z}%
+ \global\pgf@x=\pgf@y
+ \global\pgf@y=\pgf@xa
+ \endgroup
+ }%
+ \else
+ \pgfplotspointaxisorigin
+ \expandafter\pgfplotxzerolevelstreamconstant\expandafter{\the\pgf@x}%
+ \expandafter\pgfplotyzerolevelstreamconstant\expandafter{\the\pgf@y}%
+ \fi
+ \fi
+}
+
+% This code is mainly interesting for bar plots.
+%
+% It precomputes x = 0 and y = 0 - which is not necessarily
+% trivial in case of data scaling. Furthermore, it applies
+% coordinate clipping to the resulting values and multiplies them
+% with x- and y scale vectors.
+\def\pgfplots@prepare@ZERO@coordinates{%
+ \ifpgfplots@xislinear
+ \ifpgfplots@apply@datatrafo@x
+ \pgfplotscoordmath{x}{parsenumber}{0}%
+ \pgfplotscoordmath{x}{datascaletrafo}{\pgfmathresult}%
+ \global\let\pgfplots@logical@ZERO@x=\pgfmathresult
+ \else
+ \gdef\pgfplots@logical@ZERO@x{0}%
+ \fi
+ % this works in standard fixed pt math:
+ \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
+ \if\pgfplots@log@origin@choice@x0%
+ \global\let\pgfplots@logical@ZERO@x=\pgfplots@xmin%
+ \else
+ \gdef\pgfplots@logical@ZERO@x{0}%
+ \fi
+ \fi
+ %
+ \ifpgfplots@yislinear
+ \ifpgfplots@apply@datatrafo@y
+ \pgfplotscoordmath{y}{parsenumber}{0}%
+ \pgfplotscoordmath{y}{datascaletrafo}{\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
+ \if\pgfplots@log@origin@choice@y0%
+ \global\let\pgfplots@logical@ZERO@y=\pgfplots@ymin%
+ \else
+ \gdef\pgfplots@logical@ZERO@y{0}%
+ \fi
+ \fi
+ %
+ \ifpgfplots@threedim
+ \ifpgfplots@zislinear
+ \ifpgfplots@apply@datatrafo@z
+ \pgfplotscoordmath{z}{parsenumber}{0}%
+ \pgfplotscoordmath{z}{datascaletrafo}{\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
+ \if\pgfplots@log@origin@choice@z0%
+ \global\let\pgfplots@logical@ZERO@z=\pgfplots@zmin%
+ \else
+ \gdef\pgfplots@logical@ZERO@z{0}%
+ \fi
+ \fi
+ \fi
+ %
+ %
+ \ifpgfplots@threedim
+ \pgfplotsqpointxyz{\pgfplots@logical@ZERO@x}{\pgfplots@logical@ZERO@y}{\pgfplots@logical@ZERO@z}%
+ \else
+ \pgfplotsqpointxy{\pgfplots@logical@ZERO@x}{\pgfplots@logical@ZERO@y}%
+ \fi
+ \xdef\pgfplots@ZERO@x{\the\pgf@x}%
+ \xdef\pgfplots@ZERO@y{\the\pgf@y}%
+ \xdef\pgfplotspointaxisorigin{\noexpand\global\pgf@x=\pgfplots@ZERO@x\space\noexpand\global\pgf@y=\pgfplots@ZERO@y\space}%
+ %
+ %
+ %--------------------------------------------------
+ % \pgfkeyslet{/pgfplots/axis/zero/x}\pgfplots@logical@ZERO@x
+ % \pgfkeyslet{/pgfplots/axis/zero/y}\pgfplots@logical@ZERO@y
+ % \ifpgfplots@threedim
+ % \pgfkeyslet{/pgfplots/axis/zero/z}\pgfplots@logical@ZERO@z
+ % \fi
+ %--------------------------------------------------
+}%
+
+
+
+% the low-level Tikz command which implements 'plot graphics'.
+%
+% It's current state is described by some pgfkeys options and two
+% coordinates.
+\def\pgfplotsplothandlergraphics{%
+ \def\pgf@plotstreamstart{%
+ \gdef\pgfplots@plot@handler@graphics@bb@first{\pgf@x=16000pt \pgf@y=16000pt }%
+ \gdef\pgfplots@plot@handler@graphics@bb@second{\pgf@x=-16000pt \pgf@y=-16000pt }%
+ \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\pgfplotsplothandlervisualizejump{%
+ \pgfplots@error{Sorry, plot graphics does not support 'unbounded coords=jump'.}%
+ }%
+ }%
+ \def\pgfplotsplothandlername{graphics}%
+}%
+\def\pgfplots@plot@handler@graphics@collectbb#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgfplots@plot@handler@graphics@bb@first
+ \ifdim\pgf@xa<\pgf@x \pgf@x=\pgf@xa\fi
+ \ifdim\pgf@ya<\pgf@y \pgf@y=\pgf@ya\fi
+ \xdef\pgfplots@plot@handler@graphics@bb@first{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfplots@plot@handler@graphics@bb@second
+ \ifdim\pgf@xa>\pgf@x \pgf@x=\pgf@xa\fi
+ \ifdim\pgf@ya>\pgf@y \pgf@y=\pgf@ya\fi
+ \xdef\pgfplots@plot@handler@graphics@bb@second{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ %
+}%
+\def\pgfplots@plot@handler@graphics@finish{%
+ \let\pgfplots@plot@handler@graphics@pointmap@B@canvas\pgfutil@empty
+ %
+ % check if we have a pointmap. If so, the pointmap should be used
+ % to place the graphics.
+ \pgfkeysgetvalue{/pgfplots/plot graphics/points}\pgfplots@plot@handler@graphics@pointmap
+ \ifx\pgfplots@plot@handler@graphics@pointmap\pgfutil@empty
+ \else
+ \let\pgfplots@plot@handler@graphics@parsepointmap@error=\relax
+ \expandafter\pgfplots@plot@handler@graphics@parsepointmap\expandafter{\pgfplots@plot@handler@graphics@pointmap}%
+ \fi
+ %
+ %
+ \ifx\pgfplots@plot@handler@graphics@pointmap@B@canvas\pgfutil@empty
+ % no pointmap. Good; then squeze graphics into the bounding
+ % box:
+ \pgfplots@plot@handler@graphics@usebb
+ \else
+ % oh, a pointmap! Process it.
+ \pgfplots@plot@handler@graphics@process@pointmap
+ \fi
+}%
+
+% Parses the argument of '/pgfplots/plot graphics/points'.
+%
+% #1: the argument of the key above.
+\def\pgfplots@plot@handler@graphics@parsepointmap#1{%
+ \let\pgfplots@plot@handler@graphics@pointmap@A@canvas\pgfutil@empty
+ \let\pgfplots@plot@handler@graphics@pointmap@A@img\pgfutil@empty
+ \let\pgfplots@plot@handler@graphics@pointmap@B@canvas\pgfutil@empty
+ \let\pgfplots@plot@handler@graphics@pointmap@B@img\pgfutil@empty
+ \let\pgfplots@plot@handler@graphics@pointmap@C@canvas\pgfutil@empty
+ \let\pgfplots@plot@handler@graphics@pointmap@C@img\pgfutil@empty
+ \let\pgfplots@plot@handler@graphics@pointmap@D@canvas\pgfutil@empty
+ \let\pgfplots@plot@handler@graphics@pointmap@D@img\pgfutil@empty
+ \pgfplots@plot@handler@graphics@parsepointmap@loop#1\pgfplots@EOI
+ \ifpgfplots@plot@graphics@autoadjustaxis
+ \ifx\pgfplots@plot@handler@graphics@pointmap@A@img\pgfutil@empty
+ \else
+ \ifx\pgfplots@plot@handler@graphics@pointmap@D@img\pgfutil@empty
+ \def\pgfplots@loc@TMPa{#1}%
+ \pgfplots@plot@handler@graphics@parsepointmap@error
+ \fi
+ \fi
+ \fi
+}%
+\def\pgfplots@plot@handler@graphics@parsepointmap@error{%
+ \pgfplots@error{plot graphics/points={\pgfplots@loc@TMPa} cannot be processed: I need at least *four* inner anchor points to automatically adjust the axis, i.e. 4 points of the form (x,y,z) => (imgx,imgy). Use 'plot graphics/auto adjust axis=false' to disable this feature}%
+}%
+\def\pgfplots@plot@handler@graphics@parsepointmap@loop{%
+ \pgfutil@ifnextchar\pgfplots@EOI{%
+ \pgfplots@gobble@until@EOI
+ }{%
+ \pgfplots@plot@handler@graphics@parsepointmap@loop@
+ }%
+}%
+\def\pgfplots@plot@handler@graphics@parsepointmap@loop@(#1,#2){%
+ \pgfutil@ifnextchar={%
+ \pgfplots@plot@handler@graphics@parsepointmap@loop@@(#1,#2)%
+ }{%
+ \pgfplots@plot@handler@graphics@parsepointmap@loop@@(#1,#2)=>(,)%
+ }%
+}%
+\def\pgfplots@plot@handler@graphics@parsepointmap@loop@@(#1,#2)=>{%
+ \pgfutil@ifnextchar({%
+ \pgfplots@plot@handler@graphics@parsepointmap@loop@@@(#1,#2)%
+ }{%
+ \pgfplots@error{Syntax error for plot graphics/pointmap: expected '(#1,#2) => (...,...)'}%
+ \pgfplots@gobble@until@EOI
+ }%
+}
+\def\pgfplots@plot@handler@graphics@parsepointmap@loop@@@(#1,#2)(#3,#4){%
+ \def\pgfplotsplothandlergraphicspointmappointindex{}%
+ \def\pgfplots@loc@TMPc{#4}%
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ \else
+ \ifx\pgfplots@plot@handler@graphics@pointmap@A@img\pgfutil@empty
+ \def\pgfplotsplothandlergraphicspointmappointindex{A}%
+ \else
+ \ifx\pgfplots@plot@handler@graphics@pointmap@B@img\pgfutil@empty
+ \def\pgfplotsplothandlergraphicspointmappointindex{B}%
+ \else
+ \ifx\pgfplots@plot@handler@graphics@pointmap@C@img\pgfutil@empty
+ \def\pgfplotsplothandlergraphicspointmappointindex{C}%
+ \else
+ \ifx\pgfplots@plot@handler@graphics@pointmap@D@img\pgfutil@empty
+ \def\pgfplotsplothandlergraphicspointmappointindex{D}%
+ \else
+ \def\pgfplotsplothandlergraphicspointmappointindex{*}%
+ %\pgfplots@error{Sorry, the argument '(#1,#2) => (#3,#4)' of plot graphics/pointmap is superfluos; ignoring it.}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \pgfmathparse{#3}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ %
+ \pgfmathparse{#4}%
+ \expandafter\edef\csname pgfplots@plot@handler@graphics@pointmap@\pgfplotsplothandlergraphicspointmappointindex @img\endcsname{{\pgfplots@loc@TMPb}{\pgfmathresult}}%
+ \fi
+ %
+ %
+ \pgfutil@in@,{#2}%
+ \ifpgfutil@in@
+ \def\pgfplots@loc@TMPa##1,##2\relax{%
+ \expandafter\edef\csname pgfplots@plot@handler@graphics@pointmap@\pgfplotsplothandlergraphicspointmappointindex @logical\endcsname{{#1}{##1}{##2}}%
+ %
+ \pgfplotsplothandlergraphicspointmappoint(#1,##1,##2)(#3,#4)
+ }%
+ \pgfplots@loc@TMPa#2\relax
+ \else
+ \expandafter\edef\csname pgfplots@plot@handler@graphics@pointmap@\pgfplotsplothandlergraphicspointmappointindex @logical\endcsname{{#1}{#2}{}}%
+ \pgfplotsplothandlergraphicspointmappoint(#1,#2,)(#3,#4)
+ \fi
+ \pgfplots@plot@handler@graphics@parsepointmap@loop
+}
+
+\def\pgfplotsplothandlergraphics@survey@pointmappoint(#1,#2,#3)(#4,#5){%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+ \pgfplots@coord@stream@coord
+}%
+
+% PRECONDITION:
+% \pgfplotsplothandlergraphicspointmappointindex is
+% empty if and only if (#4,#5) is empty
+% or it is an index among all points with non--empty (#4,#5) image
+% coordinates.
+\def\pgfplotsplothandlergraphicspointmappoint(#1,#2,#3)(#4,#5){%
+ \ifx\pgfplotsplothandlergraphicspointmappointindex\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPc{#3}%
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ \pgfplotspointaxisxy{#1}{#2}%
+ \else
+ \pgfplotspointaxisxyz{#1}{#2}{#3}%
+ \fi
+ \expandafter\edef\csname pgfplots@plot@handler@graphics@pointmap@\pgfplotsplothandlergraphicspointmappointindex @canvas\endcsname{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ \fi
+}%
+
+% Computes view-related keys which should be communicated to the axis
+% in order to render the plot graphics correctly.
+%
+% @POSTCONDITION: \pgfplotsretval contains any required keys.
+\def\pgfplotsplothandlergraphicspointmapcomputerequiredview{%
+ \begingroup
+ \let\pgfplotsretval=\pgfutil@empty
+ \ifx\pgfplots@plot@handler@graphics@pointmap@D@img\pgfutil@empty
+ \else
+ \pgfkeysgetvalue{/pgfplots/plot graphics/debug}\pgfplots@loc@TMPa
+ \def\pgfplots@loc@TMPb{false}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \let\pgfplots@loc@TMPa=\pgfplots@loc@TMPb
+ \fi
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \def\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug{0}%
+ \else
+ \def\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug{1}%
+ \fi
+ % The following implementation computes the 'unit vector
+ % ratio' of the IMAGE.
+ %
+ % It then tells PGFPlots to use the very same unit vector
+ % ratio for its axis.
+ %
+ %
+ % The actual implementation is dumb; it requires 4 (!) points for
+ % which BOTH, the 3D coordinates and the projected 2D
+ % coordinates relative to the image's lower left corner are
+ % available.
+ %
+ % Since the 2D projected coordinates are generated by the map
+ %
+ % T(x,y,z) = o + x e_x + y e_y + z e_z in R^2
+ % with o,e_x,e_y,e_z in R^2,
+ %
+ % I have 8 degrees of freedom (two for each of the four
+ % involved vectors). Thus, a simple approach is to provide 4
+ % linearly independend points to get 8 equations.
+ %
+ % Then, I solve for o,e_x,e_y,e_z
+ %
+ \pgfplotsmatrixnewempty\pgfplotsmatrix
+ \pgfplotsmatrixresize\pgfplotsmatrix88%
+ %
+ \pgfplotsarraynewempty\pgfplotsE
+ \pgfplotsarrayresize\pgfplotsE8%
+ %
+ \def\pgfplots@extractimg##1##2{%
+ \def\pgfplots@img@x{##1}%
+ \def\pgfplots@img@y{##2}%
+ }%
+ \def\pgfplots@extractlogical##1##2##3{%
+ \def\pgfplots@logical@x{##1}%
+ \def\pgfplots@logical@y{##2}%
+ \def\pgfplots@logical@z{##3}%
+ }%
+ % Assemble the linear system such that
+ % x = [
+ % exx
+ % exy
+ % eyx
+ % eyy
+ % ezx
+ % ezy
+ % ox
+ % oy]
+ % are the degrees of freedom.
+ \c@pgfplots@coordindex=0
+ \pgfplotsutilforeachcommasep{A,B,C,D}\as\pgfplots@loc@TMPa{%
+ \expandafter\expandafter\expandafter\pgfplots@extractimg\csname pgfplots@plot@handler@graphics@pointmap@\pgfplots@loc@TMPa @img\endcsname
+ \expandafter\expandafter\expandafter\pgfplots@extractlogical\csname pgfplots@plot@handler@graphics@pointmap@\pgfplots@loc@TMPa @logical\endcsname
+ \ifx\pgfplots@logical@z\pgfutil@empty
+ \else
+ %
+ \pgfplotsmatrixletentry \the\c@pgfplots@coordindex,0\of\pgfplotsmatrix=\pgfplots@logical@x%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,1\of\pgfplotsmatrix\to{0}%
+ \pgfplotsmatrixletentry \the\c@pgfplots@coordindex,2\of\pgfplotsmatrix=\pgfplots@logical@y%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,3\of\pgfplotsmatrix\to{0}%
+ \pgfplotsmatrixletentry \the\c@pgfplots@coordindex,4\of\pgfplotsmatrix=\pgfplots@logical@z%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,5\of\pgfplotsmatrix\to{0}%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,6\of\pgfplotsmatrix\to{1}%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,7\of\pgfplotsmatrix\to{0}%
+ %
+ \pgfplotsarrayletentry\c@pgfplots@coordindex\of\pgfplotsE=\pgfplots@img@x
+ %
+ \advance\c@pgfplots@coordindex by1
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,0\of\pgfplotsmatrix\to{0}%
+ \pgfplotsmatrixletentry \the\c@pgfplots@coordindex,1\of\pgfplotsmatrix=\pgfplots@logical@x%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,2\of\pgfplotsmatrix\to{0}%
+ \pgfplotsmatrixletentry \the\c@pgfplots@coordindex,3\of\pgfplotsmatrix=\pgfplots@logical@y%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,4\of\pgfplotsmatrix\to{0}%
+ \pgfplotsmatrixletentry \the\c@pgfplots@coordindex,5\of\pgfplotsmatrix=\pgfplots@logical@z%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,6\of\pgfplotsmatrix\to{0}%
+ \pgfplotsmatrixset \the\c@pgfplots@coordindex,7\of\pgfplotsmatrix\to{1}%
+ %
+ \pgfplotsarrayletentry\c@pgfplots@coordindex\of\pgfplotsE=\pgfplots@img@y
+ %
+ \advance\c@pgfplots@coordindex by1
+ \fi
+ }%
+ \ifx\pgfplots@logical@z\pgfutil@empty
+ \else
+ \if1\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug
+ \pgfplotsplothandlergraphics@debug@matrix@to@string
+ \fi
+ %
+ %
+ \pgfplotsmatrixsolveLEQS\pgfplotsmatrix=\pgfplotsE
+ %
+ \edef\pgfmathresult{\pgfplotsarrayvalueofelem0\of\pgfplotsE}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@xx=\pgfmathresult
+ \edef\pgfmathresult{\pgfplotsarrayvalueofelem1\of\pgfplotsE}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@xy=\pgfmathresult
+ \if r\pgfkeysvalueof{/pgfplots/x dir/value}%
+ % they will be reversed again during the final
+ % processing:
+ \edef\pgfplots@xx{-\pgfplots@xx}%
+ \edef\pgfplots@xy{-\pgfplots@xy}%
+ \fi
+ %
+ \edef\pgfmathresult{\pgfplotsarrayvalueofelem2\of\pgfplotsE}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@yx=\pgfmathresult
+ \edef\pgfmathresult{\pgfplotsarrayvalueofelem3\of\pgfplotsE}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@yy=\pgfmathresult
+ \if r\pgfkeysvalueof{/pgfplots/y dir/value}%
+ % they will be reversed again during the final
+ % processing:
+ \edef\pgfplots@yx{-\pgfplots@yx}%
+ \edef\pgfplots@yy{-\pgfplots@yy}%
+ \fi
+ %
+ \edef\pgfmathresult{\pgfplotsarrayvalueofelem4\of\pgfplotsE}%
+ \pgfkeysgetvalue{/pgfplots/plot graphics/snap z}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \let\pgfplots@zx=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{veclen}{%
+ {\pgfplotsarrayvalueofelem4\of\pgfplotsE}%
+ {\pgfplotsarrayvalueofelem5\of\pgfplotsE}%
+ }%
+ \let\pgfplotszlen=\pgfmathresult
+ %
+ % compute 'snap z' relative to
+ % '\pgfplotszlen'
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@loc@TMPa}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplotszlen}}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{op}{abs}{{\pgfplots@zx}}%
+ \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@loc@TMPa}{%
+ \pgfplotscoordmath{default}{zero}%
+ }{%
+ \let\pgfmathresult=\pgfplots@zx
+ }%
+ \fi
+ \pgfplotscoordmath{default}{tofixed}\pgfmathresult%
+ \let\pgfplots@zx=\pgfmathresult
+ %
+ \edef\pgfmathresult{\pgfplotsarrayvalueofelem5\of\pgfplotsE}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@zy=\pgfmathresult
+ \if r\pgfkeysvalueof{/pgfplots/z dir/value}%
+ % they will be reversed again during the final
+ % processing:
+ \edef\pgfplots@zx{-\pgfplots@zx}%
+ \edef\pgfplots@zy{-\pgfplots@zy}%
+ \fi
+ %
+ %
+ \if1\b@pgfplots@compat@plot@graphics@threedim
+ \pgfplotswarning{plot3 graphics compatibility mode}\pgfeov%
+ \else
+ \fi
+ %
+ \edef\pgfplotsretval{%
+ x={(\pgfplots@xx,\pgfplots@xy)},%
+ y={(\pgfplots@yx,\pgfplots@yy)},%
+ z={(\pgfplots@zx,\pgfplots@zy)},%
+ scale mode=scale uniformly,%
+ \if1\b@pgfplots@compat@plot@graphics@threedim
+ % this is the only strategy pre 1.6
+ scale uniformly strategy=change vertical limits,%
+ \fi
+ }%
+ %
+ \if1\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug
+ \pgfplotsplothandlergraphicspointmapcomputerequiredview@debug@output
+ \fi
+ %
+ \ifx\pgfplotsretval\pgfutil@empty
+ \pgfplots@error{plot graphics failed to perform the 'auto adjust axis' feature \csname on@line\endcsname\space\space (compare 'plot graphics[debug]). The graphics might be scaled incorrectly. Perhaps the provided 'points' are not linearly independent?}%
+ \else
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/plot graphics/src}\pgfplots@loc@TMPa
+ \t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}%
+ \immediate\write
+ \if1\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug 16\else -1\fi
+ {PGFPlots plot graphics[auto adjust axis=true] {\the\t@pgfplots@tokc} \csname on@line\endcsname: determined options '\pgfplotsretval'.
+ \if1\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug
+ See \the\t@pgfplots@tokc.dat for debug output.
+ \else
+ Use 'plot graphics[debug]' or 'plot graphics[debug=visual]' to generate debug output files.
+ \fi
+ ^^J}%
+ \endgroup
+ \fi
+ %
+ \fi
+ \fi
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsplothandlergraphics@debug@matrix@to@string{%
+ \pgfplotsmatrixtotext\pgfplotsmatrix
+ \let\pgfplotsmatrix@text=\pgfplotsretval
+ \pgfplotsarraytotext\pgfplotsE
+ \let\pgfplotsrhs@text=\pgfplotsretval
+}%
+\def\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug@output{%
+ \begingroup
+ \immediate\openout\w@pgf@writea=\pgfkeysvalueof{/pgfplots/plot graphics/src}.dat
+ \pgfplotsarrayselect0\of\pgfplotsE\to\pgfmathresult \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}\let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotsarrayselect1\of\pgfplotsE\to\pgfmathresult \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}\let\pgfplots@loc@TMPb=\pgfmathresult
+ \immediate\write\w@pgf@writea{img x unit=\pgfplots@loc@TMPa\space\pgfplots@loc@TMPb\if r\pgfkeysvalueof{/pgfplots/x dir/value}(reversed due to x dir=reverse)\fi,}%
+ \pgfplotsarrayselect2\of\pgfplotsE\to\pgfmathresult \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}\let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotsarrayselect3\of\pgfplotsE\to\pgfmathresult \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}\let\pgfplots@loc@TMPb=\pgfmathresult
+ \immediate\write\w@pgf@writea{img y unit=\pgfplots@loc@TMPa\space\pgfplots@loc@TMPb\if r\pgfkeysvalueof{/pgfplots/y dir/value}(reversed due to y dir=reverse)\fi,}%
+ \pgfplotsarrayselect4\of\pgfplotsE\to\pgfmathresult \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}\let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotsarrayselect5\of\pgfplotsE\to\pgfmathresult \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}\let\pgfplots@loc@TMPb=\pgfmathresult
+ \immediate\write\w@pgf@writea{img z unit=\pgfplots@loc@TMPa\space\pgfplots@loc@TMPb,}%
+ \pgfplotsarrayselect6\of\pgfplotsE\to\pgfmathresult \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}\let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotsarrayselect7\of\pgfplotsE\to\pgfmathresult \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}\let\pgfplots@loc@TMPb=\pgfmathresult
+ \immediate\write\w@pgf@writea{img origin=\pgfplots@loc@TMPa\space\pgfplots@loc@TMPb\if r\pgfkeysvalueof{/pgfplots/z dir/value}(reversed due to z dir=reverse)\fi,}%
+ \def\n{^^J}%
+ \def\t{^^I}%
+ \immediate\write\w@pgf@writea{canvasmapmatrix=[\pgfplotsmatrix@text];^^Jcanvasmaprhs = [\pgfplotsrhs@text];^^J}%
+ %
+ \immediate\write\w@pgf@writea{key configuration = \pgfplotsretval;^^J}%
+ \immediate\write\w@pgf@writea{use debug=visual to see the mapped keys.^^J}%
+ \immediate\closeout\w@pgf@writea
+ \endgroup
+}%
+
+\def\pgfplots@plot@handler@graphics@process@pointmap{%
+ \begingroup
+ % determine natural size:
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/plot graphics/lowlevel get natural size/.@cmd}{}%
+ \def\pgfplots@loc@TMPa##1##2{%
+ \global\pgf@x=##1
+ \global\pgf@y=##2
+ }%
+ \expandafter\pgfplots@loc@TMPa\pgfmathresult
+ \edef\pgfplots@W{\pgf@sys@tonumber\pgf@x}% natural WIDTH
+ \edef\pgfplots@H{\pgf@sys@tonumber\pgf@y}% natural HEIGHT
+ %
+ \def\pgfplots@extractimg##1##2{%
+ \def\pgfplots@img@x{##1}%
+ \def\pgfplots@img@y{##2}%
+ }%
+ \def\pgfplots@extractimgaspoint##1##2{%
+ \pgfqpoint{##1pt}{##2pt}%
+ }%
+ \expandafter\pgfplots@extractimg\pgfplots@plot@handler@graphics@pointmap@A@img% anchor 1 in image
+ \let\pgfplots@Ax=\pgfplots@img@x
+ \let\pgfplots@Ay=\pgfplots@img@y
+ %
+ \pgfplots@plot@handler@graphics@pointmap@A@canvas% the canvas coordinate corresponding to 'A'
+ \edef\pgfplots@ax{\pgf@sys@tonumber\pgf@x}% call it 'a'
+ \edef\pgfplots@ay{\pgf@sys@tonumber\pgf@y}%
+ %
+ % compute the CANVAS diagonal between the two anchors points a,b,
+ % dd := b-a
+ \pgfpointdiff
+ \pgfplots@plot@handler@graphics@pointmap@A@canvas
+ \pgfplots@plot@handler@graphics@pointmap@B@canvas
+ \edef\pgfplots@ddx{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfplots@ddy{\pgf@sys@tonumber\pgf@y}%
+ %
+ % compute the IMAGE diagonal between the two image anchor points A,B,
+ % DD := B - A
+ \pgfpointdiff
+ {\expandafter\pgfplots@extractimgaspoint\pgfplots@plot@handler@graphics@pointmap@A@img}
+ {\expandafter\pgfplots@extractimgaspoint\pgfplots@plot@handler@graphics@pointmap@B@img}%
+ \pgfplots@loop@CONTINUEtrue
+ \ifdim\pgf@x=0pt \pgfplots@loop@CONTINUEfalse \fi
+ \ifdim\pgf@y=0pt \pgfplots@loop@CONTINUEfalse \fi
+ \ifpgfplots@loop@CONTINUE
+ \else
+ \pgfplots@error{Sorry, the first two points with '=>' in plot graphics[points={}] are expected to have different image Y coordinates. Please reorder the sequence.}%
+ \fi
+ \edef\pgfplots@DDx{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfplots@DDy{\pgf@sys@tonumber\pgf@y}%
+ %
+ % What I need now is a shift and the CANVAS dimensions of the
+ % image. Both can be computed using the relative sizes dd/DD.
+ %
+ % The shift is needed to compute the lower left corner of the
+ % CANVAS image. thus, the lower left CANVAS image corresponds to
+ % the (0,0) coordinate in the IMAGE.
+ %
+ % Remember that 'A' is the anchor 1 in IMAGE coordinates. It is a
+ % vector from (0,0) --> (A_x,A_y) in IMAGE coordinates.
+ %
+ % Now, I want a vector (v_x,v_y) such that q + v = a in CANVAS
+ % coordinates. Here, 'q' is the lower left corner; it corresponds
+ % to the (0,0) in IMAGE coordinates. Thus, we have
+ % v = (a-q). Taking the relative sizes of dd and DD, we find
+ %
+ % DD_x / A_x = dd_x / v_x
+ % DD_y / A_y = dd_y / v_y
+ %
+ % and finally q = a-v is the lower left CANVAS coordinate.
+ \pgfmath@basic@divide@{\pgfplots@ddx}{\pgfplots@DDx}%
+ \let\pgfplots@x@rel=\pgfmathresult
+ %
+ \pgfmath@basic@divide@{\pgfplots@ddy}{\pgfplots@DDy}%
+ \let\pgfplots@y@rel=\pgfmathresult
+ %
+ \pgfmath@basic@multiply@{\pgfplots@Ax}{\pgfplots@x@rel}%
+ \let\pgfplots@vx=\pgfmathresult
+ %
+ \pgfmath@basic@multiply@{\pgfplots@Ay}{\pgfplots@y@rel}%
+ \let\pgfplots@vy=\pgfmathresult
+ %
+ %
+ %
+ %
+ % now, the canvas width. It is even simpler because it holds
+ %
+ % DD_x / dd_x = W / w
+ % DD_y / dd_y = H / h
+ %
+ % where (W,H) is the natural size (i.e. in IMAGE coordinates) of the picture and
+ % (w,h) is the size the picture will occupy in CANVAS coordinates.
+ %
+ \pgfmath@basic@multiply@{\pgfplots@x@rel}{\pgfplots@W}%
+ \let\pgfplots@w=\pgfmathresult
+ %
+ \pgfmath@basic@multiply@{\pgfplots@y@rel}{\pgfplots@H}%
+ \let\pgfplots@h=\pgfmathresult
+ %
+ \edef\pgfplots@plot@handler@graphics@DRAW@{%
+ \noexpand\pgfplots@invoke@pgfkeyscode{/pgfplots/plot graphics/lowlevel draw/.@cmd}{%
+ {\pgfplots@w pt}% width
+ {\pgfplots@h pt}% height
+ }%
+ }%
+ \pgfpointadd
+ {\pgfplots@plot@handler@graphics@pointmap@A@canvas}% the canvas coordinate corresponding to 'A'
+ {\pgfqpointscale{-1}
+ {\pgfqpoint{\pgfplots@vx pt}{\pgfplots@vy pt}}%
+ }%
+ \edef\pgfplots@plot@handler@graphics@pointmap@lowerleft@canvas{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+%
+ %
+ %
+ \begingroup
+ \pgftransformshift{}% simply take \pgf@x and \pgf@y
+ %
+ \node[/pgfplots/plot graphics/node] {%
+ \pgfplots@plot@handler@graphics@DRAW@
+ };%
+ \endgroup
+ %
+ %
+ \pgfkeysgetvalue{/pgfplots/plot graphics/debug}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPb{visual}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % debug = visual: "sanitize" also triggers the visualization.
+ \pgfplots@plot@handler@graphics@pointmap@sanitize@scaling{A}%
+ \pgfplots@plot@handler@graphics@pointmap@sanitize@scaling{B}%
+ \fi
+ %
+ %
+ \ifx\pgfplots@plot@handler@graphics@pointmap@C@canvas\pgfutil@empty
+ \ifpgfplots@threedim
+ \pgfplotswarning{plot3 graphics too few inner anchors}\pgfeov%
+ \fi
+ \else
+ \pgfplots@plot@handler@graphics@pointmap@sanitize@scaling{C}%
+ \ifx\pgfplots@plot@handler@graphics@pointmap@D@canvas\pgfutil@empty
+ \else
+ \pgfplots@plot@handler@graphics@pointmap@sanitize@scaling{D}%
+ \fi
+ \fi
+ \endgroup
+}%
+
+% Checks if the logical and canvas coordinates of the point identified
+% by #1 are correct.
+%
+% #1: a character in {A,B,C...}.
+%
+\def\pgfplots@plot@handler@graphics@pointmap@sanitize@scaling#1{%
+ \begingroup
+ \expandafter\let\expandafter\pgfplots@point@img\csname pgfplots@plot@handler@graphics@pointmap@#1@img\endcsname
+ \expandafter\let\expandafter\pgfplots@point@canvas\csname pgfplots@plot@handler@graphics@pointmap@#1@canvas\endcsname
+ \expandafter\let\expandafter\pgfplots@point@logical\csname pgfplots@plot@handler@graphics@pointmap@#1@logical\endcsname
+ \expandafter\pgfplots@extractimgaspoint\pgfplots@point@img% anchor 3 in image
+ \edef\pgfplots@Cx{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfplots@Cy{\pgf@sys@tonumber\pgf@y}%
+ %
+ \pgfmath@basic@multiply@{\pgfplots@Cx}{\pgfplots@x@rel}%
+ \let\pgfplots@Cx=\pgfmathresult
+ %
+ \pgfmath@basic@multiply@{\pgfplots@Cy}{\pgfplots@y@rel}%
+ \let\pgfplots@Cy=\pgfmathresult
+ \pgfpointadd
+ {\pgfplots@plot@handler@graphics@pointmap@lowerleft@canvas}%
+ {\pgfpoint\pgfplots@Cx\pgfplots@Cy}%
+ \edef\pgfplots@point@canvas@check{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ \pgfpointdiff
+ {\pgfplots@point@canvas@check}%
+ {\pgfplots@point@canvas}%
+ \ifdim\pgf@x<0pt \pgf@x=-\pgf@x\fi
+ \ifdim\pgf@y<0pt \pgf@y=-\pgf@y\fi
+ \def\pgfplots@is@the@same@point{1}%
+ \ifdim\pgf@x>\pgfkeysvalueof{/pgfplots/plot graphics/squeeze tol}
+ \def\pgfplots@is@the@same@point{0}%
+ \else
+ \ifdim\pgf@y>\pgfkeysvalueof{/pgfplots/plot graphics/squeeze tol}
+ \def\pgfplots@is@the@same@point{0}%
+ \fi
+ \fi
+ \if0\pgfplots@is@the@same@point
+ %
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/plot graphics/src}\pgfplots@loc@TMPa
+ \t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}%
+ \def\pgfplots@extractcoord##1##2##3{##1,##2,##3}%
+ \pgfplots@error{sorry, I can't fix the scaling of 'plot graphics {\the\t@pgfplots@tokc}'.
+ The points (\expandafter\pgfplots@extractcoord\pgfplots@plot@handler@graphics@pointmap@A@logical) and (\expandafter\pgfplots@extractcoord\pgfplots@plot@handler@graphics@pointmap@B@logical) are correct, but the point (\expandafter\pgfplots@extractcoord\pgfplots@point@logical) is wrong (its position vector has an error of (\the\pgf@x,\the\pgf@y) which is larger than 'squeeze tol=\pgfkeysvalueof{/pgfplots/plot graphics/squeeze tol}'). This is probably caused by improper relations between the axis' unit vectors because the view is incorrect.^^J
+ - Is the 'view' argument correct (matlab: [h,v] = view)? ^^J
+ - Does your image have a non-trivial 'plot box ratio' (matlab: ratio = pbaspect)?^^J
+ Please refer to the pgfplots manual for details. If you continue now, I'll show the points in the image}%
+ \endgroup
+ %
+ \pgfplots@plot@handler@graphics@pointmap@sanitize@scaling@draw
+ %
+ \fi
+ \pgfkeysgetvalue{/pgfplots/plot graphics/debug}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPb{visual}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \pgfplots@plot@handler@graphics@pointmap@sanitize@scaling@draw
+ \fi
+ \endgroup
+}
+
+\def\pgfplots@plot@handler@graphics@pointmap@sanitize@scaling@draw{%
+ \scope
+ \pgfsetstrokecolor{black}%
+ \pgfsetfillcolor{red}%
+ \pgfpathcircle{\pgfplots@point@canvas@check}{2pt}%
+ \pgfusepath{stroke,fill}%
+ \pgfsetfillcolor{green}%
+ \pgfpathcircle{\pgfplots@point@canvas}{2pt}%
+ \pgfusepath{stroke,fill}%
+ \draw[->,red]
+ \pgfextra{
+ \pgfpathmoveto{\pgfplots@point@canvas@check}%
+ \pgfpathlineto{\pgfplots@point@canvas}};
+ \endscope
+}%
+
+\def\pgfplots@plot@handler@graphics@usebb{%
+ \pgfpointdiff{\pgfplots@plot@handler@graphics@bb@first}{\pgfplots@plot@handler@graphics@bb@second}%
+ \def\pgfplots@plot@handler@graphics@finish@ok{1}%
+ \ifdim\pgf@x=0pt
+ \def\pgfplots@plot@handler@graphics@finish@ok{0}%
+ \else
+ \ifdim\pgf@y=0pt
+ \def\pgfplots@plot@handler@graphics@finish@ok{0}%
+ \fi
+ \fi
+ \if0\pgfplots@plot@handler@graphics@finish@ok
+ \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@first{\noexpand\pgfqpoint{0pt}{0pt}}%
+ \xdef\pgfplots@plot@handler@graphics@bb@first{\noexpand\pgfqpoint{0pt}{0pt}}%
+
+ \fi
+ \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
+ \begingroup
+ \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPc}%
+ %
+ \def\pgfplots@loc@TMPa{#1}%
+ \def\pgfplots@loc@TMPb{#2}%
+ %
+ \edef\pgfplots@loc@TMPc{%
+ \the\t@pgfplots@toka,%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty\else width=#1,\fi
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty\else height=#2,\fi
+ }%
+ \pgfmath@smuggleone\pgfplots@loc@TMPc
+ \endgroup
+ %
+ \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPc}%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPd}%
+ \edef\pgfplots@loc@TMPc{%
+ \noexpand\pgfkeysvalueof{/pgfplots/plot graphics/includegraphics cmd}%
+ [\the\t@pgfplots@toka]
+ {\the\t@pgfplots@tokb}}%
+ \pgfplots@loc@TMPc
+ \fi
+}%
+
+\def\pgfplots@plot@handler@graphics@getnaturalsize{%
+ \begingroup
+ \setbox0=\hbox{%
+ \pgfplots@invoke@pgfkeyscode{/pgfplots/plot graphics/lowlevel draw/.@cmd}{{}{}}%
+ }%
+ \pgf@x=\wd0
+ \pgf@y=\ht0
+ \ifdim\dp0>0pt
+ \advance\pgf@y by\dp0
+ \else
+ \ifdim\dp0<0pt
+ \advance\pgf@y by-\dp0
+ \fi
+ \fi
+ \xdef\pgfplots@glob@TMPb{{\the\pgf@x}{\the\pgf@y}}%
+ \endgroup
+ \let\pgfmathresult=\pgfplots@glob@TMPb
+}%
+
+% legends for plot graphics should not use 'plot graphics' themselfes
+% (for obvious reasons).
+% This key handles that. Furthermore, it remembers the plot mark for
+% the legend -- although no plot mark is allowed for plot graphics as
+% such.
+\pgfkeysdef{/pgfplots/plot graphics/@prepare legend}{%
+ \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}%
+ %
+ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
+ \t@pgfplots@tokc=\expandafter{\pgfplots@basiclevel@plothandler}%
+ %
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfkeys{/pgfplots/every legend image post/.append code={%
+ \noexpand\def\noexpand\tikz@plot@handler{\the\t@pgfplots@tokc}%
+ \ifx\tikz@plot@mark\pgfutil@empty
+ \else
+ \noexpand\pgfkeysalso{/tikz/mark=\tikz@plot@mark}%
+ \fi
+ }%
+ }%
+ }%
+ \pgfplots@loc@TMPa
+}
+
+
+
+% Input : \pgfplots@stored@current@data contains the coordinate stream
+% Output: \pgfplots@stored@current@data contains the (modified)
+% coordinate stream
+\def\pgfplots@apply@zbuffer{%
+ \ifcase\pgfplotsplothandlermesh@zbuffer@choice\relax
+ % none.
+ \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.}%
+ \else
+ \pgfplotsautocompletemeshkeys
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = rowwise -> scanline is cols!
+ \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsscanlinelength
+ \pgfplots@apply@zbuffer@reversescanline%
+ \else
+ % ordering = colwise: scanline is rows!
+ \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsscanlinelength
+ \pgfplots@apply@zbuffer@reversetransposed%
+ \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.}%
+ \else
+ \pgfplotsautocompletemeshkeys
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = rowwise -> scanline is cols!
+ \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsscanlinelength
+ \pgfplots@apply@zbuffer@reversetransposed%
+ \else
+ % ordering = colwise: scanline is rows!
+ \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsscanlinelength
+ \pgfplots@apply@zbuffer@reversescanline%
+ \fi
+ \fi
+ \or
+ % reverse xy seq:
+ \ifpgfplots@LUA@backend@supported
+ \pgfplotsutil@directlua{pgfplots.texApplyZBufferReverseStream()}%
+ \else
+ \begingroup
+ \def\pgfplots@coord@stream@start{%
+ \pgfplotsprependlistXnewempty{reversed}%
+ }%
+ \def\pgfplots@coord@stream@coord{%
+ \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\to{reversed}%
+ }%
+ \def\pgfplots@coord@stream@end{%
+ \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversed}%
+ \pgfplotsprependlistXnewempty{reversed}% clear it
+ \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa
+ }%
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}%
+ \endgroup
+ \let\pgfplots@stored@current@data=\pgfplotsglobalretval
+ \global\let\pgfplotsglobalretval=\pgfutil@empty
+ \fi
+ \or
+ % sort.
+ \if\pgfplots@meshmode n%
+ \ifpgfplots@LUA@backend@supported
+ \pgfplotsutil@directlua{pgfplots.texApplyZBufferSort()}%
+ \else
+ \pgfplots@apply@zbuffer@sort@coordinates
+ \fi
+ \else
+ % meshmode handles sort separately!
+ \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.
+ %
+ \ifcase\pgfplotsplothandlermesh@matrixinput
+ % mesh input=patches
+ \ifpgfplots@threedim
+ \if\pgfplots@meshmode n%
+ \else
+ \pgfkeys{/pgfplots/z buffer=sort}%
+ \fi
+ \else
+ \pgfkeys{/pgfplots/z buffer=none}%
+ \fi
+ \else
+ % mesh input=lattice|image
+ \begingroup
+ \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}%
+ \pgfmath@smuggleone\pgfplotsplothandlermesh@zbuffer@choice
+ \endgroup
+ % 'z buffer' is no longer 'auto' now:
+ \pgfplots@apply@zbuffer
+ \fi
+ \or
+ % z buffer=default.
+ \if\pgfplots@meshmode n%
+ % mesh mode deactivated!
+ \else
+ % mesh=true
+ \if2\pgfplotsplothandlermesh@matrixinput
+ % mesh input=image
+ % we do not want z buffering by default because it
+ % leads to undefined color associations.
+ % Use 'z buffer=auto' to re-enable it
+ \pgfkeys{/pgfplots/z buffer=none}%
+ \else
+ \pgfkeysalso{/pgfplots/z buffer=auto}%
+ \fi
+ \pgfplots@apply@zbuffer%
+ \fi
+ \fi
+}%
+
+\def\pgfplots@apply@zbuffer@sort@coordinates{%
+ \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{%
+ \expandafter\pgfplots@zbuffer@local@SETCUR\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded}%
+ \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/iflessthan/.@cmd}\pgfplots@apply@zbuffer@SORT@iflessthan
+ \pgfkeysdef{/pgfplots/array/unscope pre}{%
+ \pgfplotsapplistXnewempty{\pgfp@sortedlist}%
+ \pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\expandafter{\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
+ }%
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}%
+ \endgroup
+ \let\pgfplots@stored@current@data=\pgfplotsglobalretval
+ \global\let\pgfplotsglobalretval=\pgfutil@empty
+}%
+% 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{%
+ \ifpgfplots@LUA@backend@supported
+ \pgfplotsutil@directlua{pgfplots.texApplyZBufferReverseScanline(\pgfplotsscanlinelength)}%
+ \else
+ \begingroup
+ \def\pgfplots@coord@stream@start{%
+ \pgfplotsprependlistXnewempty{reversedscanline}%
+ \c@pgfplots@scanlineindex=0
+ \pgfplotsapplistXnewempty{\resultlist}%
+ }%
+ \def\pgfplots@coord@stream@coord{%
+ \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\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
+ }%
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}%
+ \endgroup
+ \let\pgfplots@stored@current@data=\pgfplotsglobalretval
+ \global\let\pgfplotsglobalretval=\pgfutil@empty
+ \fi
+%\message{I have performed partial reversion of '#1' and got '\pgfplotsglobalretval'!}%
+}%
+
+% 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{%
+ \ifpgfplots@LUA@backend@supported
+ \pgfplotsutil@directlua{pgfplots.texApplyZBufferReverseTransposed(\pgfplotsscanlinelength)}%
+ \else
+ \begingroup
+ \def\pgfplots@coord@stream@start{%
+ \pgfplotsapplistXnewempty{\scanline}%
+ \c@pgfplots@scanlineindex=0
+ \pgfplotsprependlistXnewempty{resultlist}%
+ }%
+ \def\pgfplots@coord@stream@coord{%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\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
+ }%
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}%
+ \endgroup
+ \let\pgfplots@stored@current@data=\pgfplotsglobalretval
+ \global\let\pgfplotsglobalretval=\pgfutil@empty
+ \fi
+%\message{I have performed partial reversion (reverse transposed) of '#1' and got '\pgfplotsglobalretval'!}%
+}%
+\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{%
+ \pgfplotsaxisdeserializedatapointfrom{#1}%
+ \pgfplotsmathvectorfromstring{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}{default}%
+ \pgfplotsmathvectorscalarproduct{\pgfplots@view@dir@threedim}{\pgfplotsretval}{default}%
+ \let\pgfplots@apply@zbuffer@SORT@iflessthan@a=\pgfplotsretval
+ %
+ \pgfplotsaxisdeserializedatapointfrom{#2}%
+ \pgfplotsmathvectorfromstring{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}{default}%
+ \pgfplotsmathvectorscalarproduct{\pgfplots@view@dir@threedim}{\pgfplotsretval}{default}%
+ \let\pgfplots@apply@zbuffer@SORT@iflessthan@b=\pgfplotsretval
+ %
+ \pgfplotscoordmath{default}{if less than}{\pgfplots@apply@zbuffer@SORT@iflessthan@b}{\pgfplots@apply@zbuffer@SORT@iflessthan@a}{%
+ #3\relax
+ }{%
+ #4\relax
+ }%
+}%
+
+
+% 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
+% DEPRECATED use \pgfplotsmathvectorviewdepth instead!
+\def\pgfplotsmathfloatviewdepthxyz#1#2#3{%
+ \begingroup
+ \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
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% #1: a 3d vector of the form x,y,z in 'default' coordmath format
+% defines \pgfplotsretval to the view depth
+% of the point
+%
+% Use \pgfplotsmathvectorfromstring{x,y,z}{default} to transform a
+% vector into the requested format.
+%
+% Use \pgfplotscoordmath{default}{tofixed}{\pgfplotsretval} to
+% transform the result into fixed point representation.
+\def\pgfplotsmathvectorviewdepth#1{%
+ \pgfplotsmathvectorscalarproduct{#1}{\pgfplots@view@dir@threedim}{default}%
+}%
+
+\def\pgfplotsmathfloatviewdepthxyz@#1#2#3{%
+ \pgfplots@error{Sorry, you can't use \string\pgfplotsmathfloatviewdepthxyz\space in this context.}%
+}%
+\def\pgfplotsmathfloatviewdepthxyz@infigure#1#2#3{%
+ \pgfplotsmathvectorfromstring{\pgfplots@view@dir@threedim}{float}%
+ \pgfplotsmathvectorscalarproduct{#1,#2,#3}{\pgfplotsretval}{float}% FIXME : \pgfplots@view@dir@threedim might have a different math format!
+ \let\pgfmathresult=\pgfplotsretval
+}%
+
+% Similar to \pgfplotsmathfloatviewdepthxyz, but this always relies on
+% fixed point arithmetics.
+% DEPRECATED use \pgfplotsmathvectorviewdepth instead
+\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{%
+ \pgfplotsmathvectorfromstring{\pgfplots@view@dir@threedim@unitlength}{pgfbasic}%
+ \pgfplotsmathvectorscalarproduct{#1,#2,#3}{\pgfplotsretval}{pgfbasic}% FIXME : \pgfplots@view@dir@threedim might have a different math format!
+ \let\pgfmathresult=\pgfplotsretval
+}%
+
+
+% 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%
+ \pgfplots@shellescape{sh #1.sh > #1.out}
+ \fi%
+}
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotscore.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotscore.code.tex
new file mode 100644
index 0000000000..bc37418c68
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotscore.code.tex
@@ -0,0 +1,465 @@
+%--------------------------------------------
+%
+% 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-2014 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\pgfplotsset#{\pgfqkeys{/pgfplots}}
+
+% This is *identical* to \pgfutil@IfUndefined . I copied it here
+% because pgf up to and including version 2.10 does not contain it.
+\def\pgfplotsutil@IfUndefined#1{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname#1\endcsname\relax
+ \expandafter\pgfutil@firstoftwo
+ \else
+ \expandafter\pgfutil@secondoftwo
+ \fi
+}
+\pgfplotsutil@IfUndefined{pgfutil@IfUndefined}{\let\pgfutil@IfUndefined=\pgfplotsutil@IfUndefined}{}
+
+\def\pgfplotsloglevel{4}%
+
+\def\pgfplots@log#1#2{%
+ \ifnum#1>\pgfplotsloglevel\relax
+ \else
+ \ifnum\inputlineno=1
+ \pgfutil@IfUndefined{@currenvline}{%
+ \def\pgfplots@log@tmp{}%
+ }{%
+ \let\pgfplots@log@tmp=\@currenvline
+ }%
+ \else
+ \def\pgfplots@log@tmp{ on input line \the\inputlineno}%
+ \fi
+ \immediate\write-1{Package pgfplots info\pgfplots@log@tmp: #2}%
+ \fi
+}%
+
+\newif\ifpgfplots@LUA@supported
+\pgfkeys{
+ /pgfplots/lua support/.is choice,
+ /pgfplots/lua support/true/.code={\pgfplots@LUA@supportedtrue},%
+ /pgfplots/lua support/false/.code={\pgfplots@LUA@supportedfalse},%
+ /pgfplots/lua support/auto/.code={%
+ \pgfutil@IfUndefined{directlua}{%
+ \pgfplots@LUA@supportedfalse
+ }{%
+ \pgfplots@LUA@supportedtrue
+ }%
+ },%
+ /pgfplots/lua support/auto,% this is the default anyway
+}
+
+% this is an emergency key which allows to switch off LUA support in
+% pgfplots early at boot time.
+%
+% use \def\pgfplotsenablelua{0} to switch it off. '1' switches it on
+% (or uncommenting the line).
+\pgfutil@IfUndefined{pgfplotsenablelua}{}{%
+ \ifpgfplots@LUA@supported
+ \def\pgfplots@glob@TMPc{1}%
+ \ifx\pgfplots@glob@TMPc\pgfplotsenablelua
+ \message{Pgfplots: found emergency control flag \string\pgfplotsenablelua=1. Keeping LUA active.^^J}%
+ \else
+ \message{Pgfplots: found emergency control flag \string\pgfplotsenablelua!=1. Disabling LUA support.^^J}%
+ \pgfplots@LUA@supportedfalse
+ \fi
+ \fi
+}%
+
+\def\pgfplots@alloc@catcodetable{%
+ % it is task of the TeX format to load this.
+ % context comes with it out-of-the box, and pgfplots.sty loads luatexbase.sty
+ \pgfutil@IfUndefined{newcatcodetable}{%
+ % Oh. The TeX format does not have support for
+ % \newcatcodetable and the associated pgfplots module did not
+ % load an addon-package!?
+ %
+ % We _need_ the catcodes which are active when pgfplots starts.
+ % And there is no central mechanism to allocate catcodes. I will
+ % take one for me now and hope that it will not be used (soon).
+ \def\pgfplotsglobalretval{41}%
+ }{%
+ % the macro \pgfplots@luabackend@table is never used by TeX
+ % code.
+ % I only need the value inside of the .lua files: whenever
+ % they print something, they need to use it.
+ \newcatcodetable\pgfplots@luabackend@table
+ \let\pgfplotsglobalretval=\pgfplots@luabackend@table
+ }%
+}%
+
+\ifpgfplots@LUA@supported
+ \let\pgfplotsutil@directlua=\directlua
+ \let\pgfplotsutil@directlua@std=\pgfplotsutil@directlua
+ \pgfplotsutil@directlua{
+ tex.enableprimitives("pgfplotsutil@",{ "savecatcodetable", "luaescapestring"})}%
+ \def\pgfplotsutil@directlua@trace#1{%
+ \directlua{%
+ texio.write_nl("CALLING\string\n\pgfplotsutil@luaescapestring{#1}");
+ #1%
+ }%
+ }%
+ \pgfplots@log3{Initializing with LUA version \pgfplotsutil@directlua{tex.print(_VERSION)}}%
+ % attention: this can set 'lua support=false' as a side-effect:
+ \pgfplotsutil@directlua{require("pgfplots"); pgfplots.pgfplotsversion = "\pgfplotsversion";}%
+ %
+ \pgfplots@alloc@catcodetable
+ \c@pgf@counta=\pgfplotsglobalretval
+ \pgfplotsutil@savecatcodetable\c@pgf@counta
+ \pgfplotsutil@directlua{pgfplots.LOAD_TIME_CATCODETABLE = \the\c@pgf@counta}%
+\fi
+
+
+\def\pgfplots@error#1{\PackageError{pgfplots}{#1}{}}%
+\def\pgfplotstable@error@pkg#1{\PackageError{pgfplotstable}{#1}{}}%
+% DO NOT USE THIS METHOD DIRECTLY: use \pgfplotswarning{<warning name>}<args>\pgfeov
+\pgfplotsutil@IfUndefined{PackageWarning}{%
+ \def\pgfplots@warning#1{\pgfplots@message{! Package pgfplots Warning:
+#1}}%
+}{%
+ \def\pgfplots@warning#1{\PackageWarning{pgfplots}{#1}{}}%
+}%
+
+\def\pgfplots@message#1{%
+ \immediate\write16{#1}%
+}%
+
+\pgfutil@IfUndefined{pgfkeys}{%
+ \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{%
+ \def\pgfkeyscurrentkey{/pgfplots/exception/#1}%
+ \pgfkeysvalueof{/pgfplots/exception/#1/.@cmd}#2\pgfeov
+}%
+\let\pgfplotsthrow@orig=\pgfplotsthrow
+
+% Generates warning `#1' with argument(s) `#2'.
+%
+% It works in exactly the same way as \pgfplotsthrow.
+\def\pgfplotswarning#1#2\pgfeov{%
+ \def\pgfkeyscurrentkey{/pgfplots/warning/#1}%
+ \pgfkeysvalueof{/pgfplots/warning/#1/.@cmd}#2\pgfeov
+}%
+
+\def\pgfplotsthrow@warning#1{%
+ \pgfplots@warning{#1}%
+ \immediate\write-1{ [warning \pgfkeyscurrentkey]}%
+}%
+
+\def\pgfplots@assert@not@zero#1#2{%
+ \ifdim#1=0sp %
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{#2}\pgfeov
+ \fi
+}%
+
+% A primitive try #1 catch #2 end block.
+%
+% It tries code #1. If any exception occurs within, it suppresses the
+% exception and tries to continue. It then invokes #2 as soon as it
+% can.
+%
+% You can use \pgfplotsrethrow in #2.
+%
+% ATTENTION: this is a simple attempt to simulate error control. Don't
+% rely on it too heavily! In the moment, I am not even sure if it can
+% be nested (perhaps you need to introduce extra scopes since
+% \pgfplotstry doesn't).
+\long\def\pgfplotstry#1\catch#2\endpgfplotstry{%
+ \global\let\pgfplotstry@exception\pgfutil@empty
+ \def\pgfplotsthrow##1##2\pgfeov{\gdef\pgfplotstry@exception{{##1}{##2}}}%
+ #1\relax%
+ \let\pgfplotsthrow=\pgfplotsthrow@orig
+ \ifx\pgfplotstry@exception\pgfutil@empty
+ \else
+ #2%
+ \fi
+ \global\let\pgfplotstry@exception\pgfutil@empty
+}%
+\def\pgfplotsrethrow{\expandafter\pgfplotsthrow\pgfplotstry@exception\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 layer name
+ % #2 : additional context information (message)
+ /pgfplots/exception/inactive layer/.code 2 args={%
+ \ifx\pgfplotsexceptionmsg\relax
+ \pgfplots@error{Sorry, the layer '#1' has not been activated but it is referenced in #2. Perhaps you misspelled it? Each referenced layer must be activated (expect for layer 'discard').}%
+ \else
+ \pgfplots@error{\pgfplotsexceptionmsg}%
+ \fi
+ },%
+ % #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
+ },%
+ /pgfplots/exception/invalid color component/.code 2 args={%
+ \ifx\pgfplotsexceptionmsg\relax
+ \pgfplots@error{#2}%
+ \else
+ \pgfplots@error{\pgfplotsexceptionmsg}%
+ \fi
+ \let#1=\pgfutil@empty
+ },%
+ /pgfplots/exception/cycle list instantiation needed/.code={%
+ \ifx\pgfplotsexceptionmsg\relax
+ \pgfplots@error{Please invoke \string\pgfplotsset{cycle list/#1} before using cycle list '#1'}%
+ \else
+ \pgfplots@error{\pgfplotsexceptionmsg}%
+ \fi
+ },%
+ % #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
+ },
+ /pgfplots/exception/too few colormap positions/.code args={#1#2}{%
+ \ifx\pgfplotsexceptionmsg\relax
+ \pgfplots@error{#2}%
+ \else
+ \pgfplots@error{\pgfplotsexceptionmsg}%
+ \fi
+ \let#1=\relax
+ },
+ /pgfplots/exception/dimension too small in ticks/.code args={#1}{%
+ \ifx\pgfplotsexceptionmsg\relax
+ \pgfplots@error{The argument(s) for #1tick resulted in a tick distance which is too small. Please reconfigure the xtick argument(s)}%
+ \else
+ \pgfplots@error{\pgfplotsexceptionmsg}%
+ \fi
+ },
+ %
+ %
+ %
+ %
+ % Generated if you say 'ymin=0' in a log axis.
+ % #1: the user argument ('ymin')
+ % #2: the offending value.
+ /pgfplots/warning/illegal user argument in log axis/.code args={#1#2}{%
+ \pgfplotsthrow@warning{Ignoring illegal input argument #1=#2: cannot apply log.}%
+ },
+ /pgfplots/warning/too many colormap positions/.code={%
+ \pgfplotsthrow@warning{the colormap has too many positions; ignoring position #1}%
+ },
+ /pgfplots/warning/plot without coordinates/.code={%
+ \pgfplotsthrow@warning{the current plot has no coordinates (or all have been filtered away)}%
+ },
+ /pgfplots/warning/log basis required/.code 2 args={%
+ \pgfplotsthrow@warning{Some input argument (#2) explicitly relies on the log basis of #1 (which is e). Please verify that this is intended and set 'log basis #1=10' otherwise. This warning will be shown only once per document.}%
+ },
+ /pgfplots/warning/no such legend to name/.code={%
+ \pgfplotsthrow@warning{There is no `legend to name=#1', sorry. I am skipping it}%
+ },
+ /pgfplots/warning/no such colorbar to name/.code={%
+ \pgfplotsthrow@warning{There is no `colorbar to name=#1', sorry. I am skipping it}%
+ },
+ /pgfplots/warning/no such addplot label/.code={%
+ \pgfplotsthrow@warning{There is no \string\addplot\space label `#1', sorry. I am skipping it}%
+ },
+ /pgfplots/warning/missing near ticklabel at/.code={%
+ \pgfplotsthrow@warning{The anchor 'near ticklabel' cannot be computed correctly because the position is missing. Please add 'near ticklabel at=coordinate' with a suitable coordinate}%
+ },
+ /pgfplots/warning/enlargelimits respects figure size failed/.code={%
+ \pgfplotsthrow@warning{enlargelimits respects figure size=true: could not respect the prescribed width/height (\pgfplotsretval). The size and/or aspect ratio of your image will be different than expected. You can try to modify BOTH width and height.}%
+ },
+ % #1: the axis
+ /pgfplots/warning/empty range cleared axis/.code={%
+ \pgfplotsthrow@warning{You have an axis with empty range (in direction #1). Replacing it with a default range and clearing all plots.}%
+ },
+ /pgfplots/warning/approx empty range enlarged/.code args={#1#2#3}{%
+ \pgfplotsthrow@warning{Axis range for axis #1 is approximately empty; enlarging it (it is [#2:#3])}%
+ },
+ /pgfplots/warning/dimension too large in ticks/.code args={#1#2#3}{%
+ \pgfplotsthrow@warning{The argument for #1tick distance=#2 was capped to #3 in order to avoid 'dimension too large'}%
+ },
+ /pgfplots/warning/lossy colormap rgb conversion/.code 2 args={%
+ \pgfplotsthrow@warning{I am about to convert colormap '#1' from #2\space to rgb (which might be lossy). Perhaps the choice 'colorbar sampled={surf,shader=interp}' yields better results since it supports #2.}%
+ },
+ /pgfplots/warning/cycle list size limit reached/.code={%
+ \pgfplotsthrow@warning{Reached /pgfplots/@cycle/max size=\pgfkeysvalueof{/pgfplots/@cycle/max size}. Omitting all following entries.}%
+ },
+ /pgfplots/warning/colorbar uninitialised/.code={%
+ \pgfplotsthrow@warning{Sorry, the colorbar is uninitialised - your axis has no color data. Consider using 'point meta=f(x)' or something like that. I am using a color range of [0,1] for the colorbar.}%
+ },
+ /pgfplots/warning/colorbar CMYK unsupported/.code={%
+ \pgfplotsthrow@warning{colorbar remark: The colormap '#1' has a CMYK colorspace which is not (yet) supported by PGF. I switched colorbar styles automatically to the visually equivalent 'colorbar sampled={surf,shader=interp}' to generate a proper CMYK colorbar. This has less support in some previewers. Use \string\pgfplotscolorbarCMYKworkaroundfalse\space to disable this improvement. [This message won't be replicated for '#1']}%
+ },
+ /pgfplots/warning/ticklabel anchor undetermined/.code args={#1#2#3#4}{%
+ \pgfplotsthrow@warning{the ticklabel anchor cannot be determined, the normal vector -(#2) and the unit #1 vector (#3) are almost parallel (abs(cos(angle)) = #4)!}%
+ },
+ /pgfplots/warning/point meta unbounded/.code 2 args={%
+ \pgfplotsthrow@warning{The per point meta data `#1' (#2) (and probably others as well) is unbounded - using the minimum value instead.}%
+ },
+ /pgfplots/warning/gnuplot -V impossible/.code={%
+ \pgfplotsthrow@warning{Sorry, I could not determine 'gnuplot -V' to check whether gnuplot and logscale writes results in log() or not. Please set `/pgfplots/gnuplot writes logscale=true|false' manually.}%
+ },
+ /pgfplots/warning/gnuplot -V format unknown/.code={%
+ \pgfplotsthrow@warning{Sorry, I can't reliably check which version of gnuplot is available. I guess it is gnuplot < 4.4. Please set `/pgfplots/gnuplot writes logscale=true|false' manually if anything fails.}%
+ },
+ /pgfplots/warning/plot3 graphics compatibility mode/.code={%
+ \pgfplotsthrow@warning{plot3 graphics is running in backwards compatibility mode. %
+ Use \string\pgfplotsset{compat=1.6} or higher to benefit from upgraded scaling capabilites.}%
+ },
+ /pgfplots/warning/plot3 graphics too few inner anchors/.code={%
+ \pgfplotsthrow@warning{plot graphics in 3D axis has just two inner anchors (those with '(x,y,z)=>(imgx,imgy)'). You should provide a third one such that I can check for correct scaling.}%
+ },
+ /pgfplots/warning/scatter classes no such class/.code={%
+ \pgfplotsthrow@warning{scatter/classes: can't find class for '#1'!? Please make sure you have specified 'scatter src=explicit symbolic'. Ignoring class '#1' (this message will not come again).}%
+ },
+ /pgfplots/warning/lua colormap unavailable/.code={%
+ \pgfplotsthrow@warning{there is no LUA colormap representation for #1. Using TeX arithmetics.}%
+ },
+ /pgfplots/warning/interior colormap inefficient/.code={%
+ \pgfplotsthrow@warning{the combination 'shader=interp,interior colormap name' is inefficient (it uses 'shader=faceted interp,faceted color=none') and may slow down the *display* of your document}%
+ },
+ /pgfplots/warning/matrix delinearize uses sqrt/.code args={#1#2#3#4}{%
+ \pgfplotsthrow@warning{%
+ mesh processing did not find '[mesh/rows=<N>]' or '[mesh/cols=<N>]'.
+ Assuming [mesh/rows=#1,mesh/cols=#2]
+ as sqrt(num points) = sqrt(#3) [ = #4].}%
+ },
+ /pgfplots/warning/matrix check/.code args={#1#2#3#4#5}{%
+ #1{the arguments of [mesh/rows=#2,mesh/cols=#3] assume #5\space points, but I actually got N = #4\space points! The data matrix appears to be incomplete or overcomplete!? [Use mesh/check=false to disable this message]}%
+ },
+ /pgfplots/warning/imagesc limits incomplete/.code args={#1}{%
+ \pgfkeysgetvalue{/pgfplots/empty line}\pgfplots@loc@TMPa%
+ \def\pgfplots@loc@TMPb{scanline}
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \pgfplotsthrow@warning{Automatic computation of axis limits for 'matrix plot' is INACCURATE. Please add the key '#1'. You can also ignore this warning and deal with axis limits manually}%
+ \else
+ \pgfplotsthrow@warning{Automatic computation of axis limits for 'matrix plot' is INACCURATE. Please add the keys '#1,empty line=scanline' (current value is empty line=\pgfplots@loc@TMPa). You can also ignore this warning and deal with axis limits manually}%
+ \fi
+ },
+ /pgfplots/warning/tick computation failed/.code 2 args={%
+ \pgfplotsthrow@warning{Tick computation for direction #1 failed; there are always too few tick labels (try min ticks has already been advanced to #2)}%
+ },
+ /pgfplots/warning/scale uniformly unsupported/.code={%
+ \pgfplotsthrow@warning{Sorry, 'scale uniformly' failed because its actual implementation works only if y_x = 0 and x_y = 0 (for 2d axes) or if z_x = 0 (for 3d axes). The result will not fill the prescribed dimensions. Falling back to 'scale uniformly strategy=units only. (use scale uniformly warning=false to disable this warning)}%
+ },
+ /pgfplots/warning/axis equal incompatible change/.code={%
+ \pgfplotsthrow@warning{the content of your 3d axis has changed compared to previous versions of pgfplots. please review it. ^^J %
+ [continued] explanation: you have a 3d axis with 'axis equal' and/or 'unit vector ratio' which has (probably) been optimized for an older version of pgfplots. any version older than 1.6 produced wrong output.^^J %
+ [continued] to remove this warning, write \string\pgfplotsset{compat=1.6} (or newer) in your preamble (may change all figures in your document) or by adding that to the affected axis.}%
+ },
+ /pgfplots/warning/unit vector ratio axis undetermined/.code={%
+ \pgfplotsthrow@warning{The algorithm to implement 'unit vector ratio' failed! It could not determine the axis which shall be scaled and decided to use 'unit vector ratio axis=#1'.}%
+ },
+ /pgfplots/warning/linear system singular/.code={%
+ \pgfplotsthrow@warning{Linear system is singular up to machine precision! Continuing with small threshold.}%
+ },
+ /pgfplots/warning/center lines upgrade required/.code={%
+ \pgfplotsthrow@warning{Please use '\string\pgfplotsset{compat=1.8}' to enable correct label placement for 3d axes (at least compat/labels=1.8).}%
+ },
+ /pgfplots/warning/empty column name/.code 2 args={%
+ \pgfplotsthrow@warning{Table '#1' has an empty column name; replacing it by '#2'}%
+ },
+}
+\let\pgfplotsexceptionmsg=\relax
+
+\def\pgfplots@EOI{\pgfplots@EOI}%
+
+\newif\ifpgfplots@loc@tmp
+\newtoks\t@pgfplots@toka
+\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.
+\gdef\pgfplots@glob@TMPa{}%
+\gdef\pgfplots@glob@TMPb{}%
+\gdef\pgfplots@glob@TMPc{}%
+
+% use these macros for LOCAL temporary assigments.
+% you can NEVER rely on their values unless you know exactly what you are doing.
+\def\pgfplots@loc@TMPa{}%
+\def\pgfplots@loc@TMPb{}%
+\def\pgfplots@loc@TMPc{}%
+
+
+% Invokes code #2 if file '#1' exists and #3 if not.
+\long\def\pgfplots@iffileexists#1#2#3{%
+ \openin\r@pgfplots@reada=#1
+ \ifeof\r@pgfplots@reada
+ #3\relax
+ \else
+ \closein\r@pgfplots@reada
+ #2\relax
+ \fi
+}
+\let\pgfplotsiffileexists=\pgfplots@iffileexists
+
+\pgfutil@ifundefined{pgfplots@texdist@protect}{%
+ \def\pgfplots@texdist@protect{}%
+}{}
+
+\input pgfplotssysgeneric.code.tex
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsdeque.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsdeque.code.tex
new file mode 100644
index 0000000000..7a524f1ee6
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/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/graphics/pgf/contrib/pgfplots/tex/pgfplotslibrary.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotslibrary.code.tex
new file mode 100644
index 0000000000..7ab01a3b03
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotslibrary.code.tex
@@ -0,0 +1,94 @@
+% 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\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}%
+ \ifx\pgf@temp\pgfutil@empty
+ \else
+ \pgfplotsiflibraryloaded{\pgf@temp}{}{%
+ \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
+ \expandafter\ifx\csname pgfp@library@#1@loadoptions\endcsname\relax
+ \else
+ \expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfp@library@\pgf@temp @loadoptions\endcsname
+ \expandafter\pgfplotsset\expandafter{\pgfplots@glob@TMPa}%
+ \fi
+ }%
+ \fi
+ }%
+}
+
+\pgfkeys{
+ % #1: library name
+ % #2: compatiblity presets which are controlled by the
+ % compatibility system but which belong to the library.
+ %
+ % FIXME : now as I wrote it, it might have been better to reverse
+ % the dependency... !?
+ /pgfplots/compat/library hook/.code 2 args={%
+ \pgfplotsiflibraryloaded{#1}{%
+ \pgfkeysalso{#2}%
+ }{%
+ \expandafter\ifx\csname pgfp@library@#1@loadoptions\endcsname\relax
+ \expandafter\def\csname pgfp@library@#1@loadoptions\endcsname{#2}%
+ \else
+ \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfp@library@#1@loadoptions\endcsname}%
+ \t@pgfplots@tokb={#2}%
+ \expandafter\edef\csname pgfp@library@#1@loadoptions\endcsname{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}%
+ \fi
+ }%
+ },
+}
+
+\def\pgfplotsiflibraryloaded#1#2#3{%
+ \expandafter\ifx\csname pgfp@library@#1@loaded\endcsname\relax%
+ #3\relax
+ \else
+ #2\relax
+ \fi%
+}%
+
+% Default loaded libraries:
+% Currently none
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsliststructure.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsliststructure.code.tex
new file mode 100644
index 0000000000..a30a28e48a
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsliststructure.code.tex
@@ -0,0 +1,440 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% This is a helper package with an elementary list datastructure.
+%
+% Its implementation is based on Knuth's list macros in "The TeXbook".
+%
+% It features a convenient set of list macros, but it is not fast.
+% In fact, every elementary operation requires time O(N), so working
+% with this list easily leads to O(N^2) runtime.
+%
+% The following macros are supplied:
+%
+% \pgfplotslistnewempty
+% \pgfplotslistnew
+% \pgfplotslistcopy
+% \pgfplotslistpopfront
+% \pgfplotslistfront
+% \pgfplotslistpushback
+% \pgfplotslistpushfront
+% \pgfplotslistsize
+% \pgfplotslistselect
+% \pgfplotslistset
+% \pgfplotslistcheckempty
+% \pgfplotslistforeach
+%
+% @see \pgfplotsapplist a "real" list with O(1) pushback, but limited application.
+% @see \pgfplotsapplistX a preasymptotical fast list to accumulate elements.
+% @see \pgfplotsapplistXX an optimized version of \pgfplotsapplistX.
+%
+% Copyright 2007/2008 by Christian Feuersänger.
+%
+% This program is free software: you can redistribute it and/or modify
+% 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\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
+
+% Creates a new, empty list.
+\long\def\pgfplotslistnewempty#1{\let#1=\pgfutil@empty}
+
+% Creates a new list with an abirtrary number of elements.
+% Arguments:
+% #1: the list's name (a macro name)
+% #2: the elements in the form
+% first\\second\\third\\ ...\\
+% like in tabular with one column.
+% You can also use comma-separated lists
+% first,second,third
+%
+% Example:
+% 1.
+% \pgfplotslistnew\foolist{First Element\\Second Element\\Third Element\\}
+% WARNING: do NOT forget the final '\\'!
+%
+% 2.
+% \pgfplotslistnew\foolist{First Element,Second Element,Third Element}
+%
+% Use braces '{}' to use '\\' or ',' as arguments.
+%
+\long\def\pgfplotslistnew#1#2{%
+ \pgfkeys@spdef\pgfplotslist@loc@TMPa{#2}%
+ \def\pgfplotslist@loc@TMPb{\pgfplotslistnew@{#1}}%
+ \expandafter\pgfplotslist@loc@TMPb\expandafter{\pgfplotslist@loc@TMPa}%
+}
+\long\def\pgfplotslistnew@#1#2{%
+ \pgfplotslist@check@backslash@list #2\\\pgfplotslist@EOI
+ \ifpgfplotslist@is@backslash@terminated
+ \pgfplotslistnew@backslash@{#1}{#2}%
+ \else
+ \pgfplots@foreach@to@list{#2}\to#1%
+ \fi
+}
+% Is this here *ever* used!? I guess not.
+\long\def\pgfplotslistnew@backslash#1#2{%
+ \pgfplotslistnewempty{#1}%
+ \pgfplotslist@check@backslash@list #2\\\pgfplotslist@EOI
+ \ifpgfplotslist@is@backslash@terminated
+ \long\def\pgfplotslistnew@impl@rest{#2\pgfplotslist@EOI\\}%
+ \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl{#1}}%
+ \else
+ \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl@comma{#1}}%
+ \long\def\pgfplotslistnew@impl@rest{#2\pgfplotslist@EOI,}%
+ \fi
+ \expandafter\pgfplotslistnew@backslash@loop\pgfplotslistnew@impl@rest
+}%
+\long\def\pgfplotslistnew@backslash@#1#2{%
+ \pgfplotslistnewempty{#1}%
+ \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl{#1}}%
+ \pgfplotslistnew@backslash@loop#2\pgfplotslist@EOI\\%
+}%
+
+% helper macro for \pgfplotslistnew
+\long\def\pgfplotslistnew@impl#1#2\\{%
+ \def\pgfplotslist@loc@TMPa{#2}%
+ \ifx\pgfplotslist@loc@TMPa\pgfplotslist@EOI
+ \else
+ \pgfplotslistpushback{#2}\to#1\relax%
+ \expandafter\pgfplotslistnew@backslash@loop
+ \fi
+}
+\long\def\pgfplotslistnew@impl@comma#1#2,{%
+ \def\pgfplotslist@loc@TMPa{#2}%
+ \ifx\pgfplotslist@loc@TMPa\pgfplotslist@EOI
+ \else
+ \pgfplotslistpushback{#2}\to#1\relax%
+ \expandafter\pgfplotslistnew@backslash@loop
+ \fi
+}
+\def\pgfplotslist@EOI{\pgfplotslist@EOI}
+\def\pgfplotslist@backslashsep{\\}
+
+\long\def\pgfplotslist@check@backslash@list#1\\#2\pgfplotslist@EOI{%
+ \def\pgfplotslist@loc@TMPx{#2}%
+ \ifx\pgfplotslist@loc@TMPx\pgfutil@empty
+ \pgfplotslist@is@backslash@terminatedfalse
+ \let\pgfplotslist@check@backslash@list@next=\relax
+ \else
+ \def\pgfplotslist@loc@TMPy{ }%
+ \ifx\pgfplotslist@loc@TMPx\pgfplotslist@loc@TMPy
+ \pgfplotslist@is@backslash@terminatedfalse
+ \let\pgfplotslist@check@backslash@list@next=\relax
+ \else
+ \ifx\pgfplotslist@loc@TMPx\pgfplotslist@backslashsep
+ % ok. The list is something like 'a\\b\\' so the
+ % complete input is
+ % 'a\\b\\ \\ \EOI'
+ % we have iterated long enough to find only the '\\'
+ % right before the \EOI. It is thus backslash
+ % terminated.
+ \pgfplotslist@is@backslash@terminatedtrue
+ \let\pgfplotslist@check@backslash@list@next=\relax
+ \else
+ % Iterate. We want to check the last list element.
+ \long\def\pgfplotslist@check@backslash@list@next{\pgfplotslist@check@backslash@list#2\pgfplotslist@EOI}%
+ \fi
+ \fi
+ \fi
+ \pgfplotslist@check@backslash@list@next
+}%
+
+% Copies list #1 to list #2.
+\def\pgfplotslistcopy#1\to#2{\let#2=#1}
+
+
+
+
+% #1: the item to prepend
+% #2: the list as macro name
+% Example:
+% \pgfplotslistpushfront Next first Element\to\foolist
+\long\def\pgfplotslistpushfront#1\to#2{%
+ \t@pgfplots@toka={\pgfpl@@{#1}}%
+ \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.
+\long\def\pgfplotslist@assembleentry#1\into#2{%
+ #2={\pgfpl@@{#1}}%
+}
+
+% #1: the item to append
+% #2: the list as macro name
+% Example:
+% \pgfplotslistpushback Next last element\to\foolist
+\long\def\pgfplotslistpushback#1\to#2{%
+ \t@pgfplots@toka={\pgfpl@@{#1}}%
+ \ifx#2\pgfutil@empty
+ \t@pgfplots@tokb={}%
+ \else
+ \t@pgfplots@tokb=\expandafter{#2}%
+ \fi
+ \edef#2{\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
+}
+% Adds '#1' to the GLOBAL list '#2'.
+\long\def\pgfplotslistpushbackglobal#1\to#2{%
+ \t@pgfplots@toka={\pgfpl@@{#1}}%
+ \ifx#2\pgfutil@empty
+ \t@pgfplots@tokb={}%
+ \else
+ \t@pgfplots@tokb=\expandafter{#2}%
+ \fi
+ \xdef#2{\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
+}
+
+% Concatenates two lists #2 and #3 into #1
+% Example:
+% \pgfplotslistconcat\result=\foolist&\bar
+\long\def\pgfplotslistconcat#1=#2&#3{%
+ \t@pgfplots@toka=\expandafter{#2}%
+ \t@pgfplots@tokb=\expandafter{#3}%
+ \edef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+}
+
+% implements #2 := pop_front(#1)
+% Example:
+% \pgfplotslistpopfront\foolist\to\poppedfirstelem
+\long\def\pgfplotslistpopfront#1\to#2{%
+ \pgfplotslistcheckempty#1\relax
+ \ifpgfplotslistempty
+ \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
+}
+\long\def\pgfplotslistfront#1\to#2{%
+ \pgfplotslistcheckempty#1\relax
+ \ifpgfplotslistempty
+ \pgfplotsthrow{no such element}{#2}{\string\pgfplotslistfront\ from \string#1\ although list is EMPTY}\pgfeov%
+ \else
+ \expandafter\pgfplotslistfront@impl#1\pgfplotslistpopfront@macronames#2%
+ \fi
+}
+
+% implementation helper for listpopfront
+\long\def\pgfplotslistpopfront@impl\pgfpl@@#1#2\pgfplotslistpopfront@macronames#3#4{%
+ \def#4{#1}%
+ \def#3{#2}%
+}
+\long\def\pgfplotslistfront@impl\pgfpl@@#1#2\pgfplotslistpopfront@macronames#3{%
+ \def#3{#1}%
+}
+
+% Counts the number of elements in list #1, storing it into the count
+% register #2.
+% Example:
+% \pgfplotslistsize\foo\to{\count0}%
+% \the\count0
+\long\def\pgfplotslistsize#1\to#2{%
+ #2=0%
+ \long\def\pgfpl@@##1{\advance#2 by 1 }%
+ #1%
+}
+
+% Returns the #1th element of list #2 into macro #3
+% Arguments:
+% #1: a count 0,...,N-1 where N is the list size.
+% You may specify a number of a count.
+% #2: a list
+% #3: a macro name
+% Example:
+% Element 0:
+% \pgfplotslistselect0\of\foo\to\elem
+% \elem
+% Element \count1:
+% \pgfplotslistselect\count1\of\foo\to\elem
+\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}%
+}
+\long\def\pgfplotslistselect@#1\of#2\to#3{%
+ \begingroup
+ \count0=#1\relax
+ \long\def\pgfpl@@##1{%
+ \advance\count0 by-1\relax
+ \ifnum\count0=-1\relax
+ \global\def\pgfplotslistselect@tmp{\def#3{##1}}%
+ \fi%
+ }%
+ #2%
+ \endgroup
+ \pgfplotslistselect@tmp
+}
+
+% 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:
+%
+% \pgfplotslistcheckempty\foolist
+% \ifpgfplotslistempty
+% List foolist is empty!
+% \else
+% List is not empty.
+% \fi
+\def\pgfplotslistcheckempty#1{%
+ \ifx#1\pgfutil@empty
+ \pgfplotslistemptytrue
+ \else
+ \ifx#1\relax
+ \pgfplots@warning{WARNING: possible logic error in script code: the command \string\pgfplotslistcheckempty{\string#1} encountered an undefined argument.}%
+ \pgfplotslistemptytrue
+ \else
+ \pgfplotslistemptyfalse
+ \fi
+ \fi
+}
+
+
+% Iterates through each list element, names it #2 and calls code #3.
+% Example:
+% \pgfplotslistnew\foolist{Eins\\Zwei\\Drei\\}%
+% \pgfplotslistforeach\foolist\as\foo{Element \foo\par}%
+% results in
+% Element Eins
+% Element Zwei
+% Element Drei
+% Each single element will be grouped with TeX groups.
+\long\def\pgfplotslistforeach#1\as#2#3{%
+ \begingroup
+ \long\def\pgfpl@@##1{%
+ \t@pgfplots@tokc={##1}% this allows '#' inside of '##1'
+ \edef#2{\the\t@pgfplots@tokc}%
+ \begingroup #3\endgroup}%
+ #1\relax
+ \endgroup
+}
+
+% The same but without groups around #3.
+%
+% The list can be nested.
+\long\def\pgfplotslistforeachungrouped#1\as#2#3{%
+ \t@pgfplots@tokb={{#2}{#3}}%
+ \t@pgfplots@tokc=\expandafter{#1}%
+ \edef\pgfplotslist@loc@TMPa{%
+ \noexpand\pgfplotslistforeachungrouped@
+ \the\t@pgfplots@tokb%
+ \the\t@pgfplots@tokc
+ \noexpand\pgfpl@@\noexpand\pgfplotslistforeachungrouped@EOI
+ }%
+ \pgfplotslist@loc@TMPa
+}%
+
+% Technical helper method which performs the loop.
+% ASSUMPTION:
+% \pgfplotslistforeachungrouped@
+% {<macro name>}
+% {<code to execute>}
+% \pgfpl@@{<list elem>}\pgfpl@@{<list elem>}\pgfpl@@{<list elem>}\pgfpl@@\pgfplotslistforeachungrouped@EOI
+%
+% -> iterate through argument until \pgfplotslistforeachungrouped@EOI
+% comes.
+\long\def\pgfplotslistforeachungrouped@#1#2\pgfpl@@#3{%
+ \t@pgfplots@tokc={#3}% this allows '#' inside of '#3'
+ \edef\pgfplotslist@loc@TMPa{\the\t@pgfplots@tokc}%
+ \ifx\pgfplotslist@loc@TMPa\pgfplotslistforeachungrouped@EOI
+ % ok, terminate loop.
+ \let\pgfplotslistforeachungrouped@next=\relax
+ \else
+ % perform loop iteration ...
+ \let#1=\pgfplotslist@loc@TMPa
+ #2\relax
+ % and continue iterating.
+ \def\pgfplotslistforeachungrouped@next{\pgfplotslistforeachungrouped@{#1}{#2}}%
+ \fi
+ \pgfplotslistforeachungrouped@next
+}%
+\def\pgfplotslistforeachungrouped@EOI{\pgfplotslistforeachungrouped@EOI}% equals only itself in \ifx
+
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsliststructureext.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsliststructureext.code.tex
new file mode 100644
index 0000000000..990b796ce5
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsliststructureext.code.tex
@@ -0,0 +1,615 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% This is a helper package with an elementary list datastructure.
+% In contrast to \pgfplotslist, this one features fast append and fast
+% copy-to-macro.
+%
+% The 'pgfplotsapplist' is a list which has ONLY the features
+%
+% \pgfplotsapplistnewempty
+% \pgfplotsapplistpushback O(1)
+% \pgfplotsapplistedefcontenttomacro (N)
+% \pgfplotsapplistxdefcontenttomacro (N)
+%
+% It has been designed to accumulate macro content in O(N) (in
+% contrast to TeX's macro append routines which lead to O(N^2)
+% runtime).
+%
+% Furthermore, there is the
+%
+% \pgfplotsapplistXnewempty
+% \pgfplotsapplistXpushback
+% \pgfplotsapplistXedefcontenttomacro (N)
+% \pgfplotsapplistXxdefcontenttomacro (N)
+% \pgfplotsapplistXlet (N)
+%
+% structure which features **preasymptotical** constant runtime for
+% pushback. That means, as long as N < 80000, the runtime is linear.
+% It is only slightly slower than \pgfplotsapplist, and that only due
+% to its generality. It could easily be adopted to be FASTER than
+% \pgfplotsapplist.
+%
+% Credits for \pgfplotsapplist go to Till Tantau: he developped it for
+% the PGF kernel.
+%
+%
+% Copyright 2007/2008 by Christian Feuersänger.
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see <http://www.gnu.org/licenses/>.
+%
+%
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% the applist defines one macro for each element, like
+%
+% \def\element<i>{<content>\element<i+1>}
+% \def\element<i+1>{<content>\element<i+2>}
+% \def\element<i+2>{}
+%
+% The '<i>' value belongs to the private interface and is part of the
+% macro name.
+%
+% It features:
+% - real O(1) pushback
+% - O(N) edef to macro
+% - O(N) execute
+% - it requires O(N) different macros.
+% - it ***can't*** be copied outside of the current TeX group!
+%
+% I have never used it (besides early tests)
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% Time: O(1), number of macros: 3
+\def\pgfplotsapplistnewempty#1{%
+ \expandafter\def\csname\string#1@endno\endcsname{0}%
+ \edef#1{\expandafter\noexpand\csname\string#1@0\endcsname}%
+ \expandafter\def\csname\string#1@0\endcsname{}%
+}%
+
+% Time: O(1), number of macros per list: about N
+% #1: the item to append
+% #2: the list as macro name
+\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
+ \advance\c@pgf@counta by1
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \expandafter\let\csname\string#2@endno\endcsname=\pgfplots@glob@TMPa%
+ \t@pgfplots@toka={#1}%
+ \t@pgfplots@tokb=\expandafter{\csname\string#2@\pgfplots@glob@TMPa\endcsname}%
+ \expandafter\edef\csname\string#2@\pgfplots@loc@TMPa\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \expandafter\let\the\t@pgfplots@tokb=\pgfutil@empty
+}%
+
+% time O(N)
+% Expands the complete content of list #1 as-is into the macro #2.
+\def\pgfplotsapplistedefcontenttomacro#1\to#2{\edef#2{#1}}
+\def\pgfplotsapplistxdefcontenttomacro#1\to#2{\xdef#2{#1}}
+
+% Foreach list element, the stored value will simply be processed by
+% TeX. Characters will be printed and commands will be executed.
+% time O(N)
+\def\pgfplotsapplistexecute#1{#1}%
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+%
+% This list here is a general re-implementation of the list used in
+% the PGF system layer.
+% It employs two collect-buffers to reduce the runtime.
+%
+% - It has preasymptotical runtime O(N), but is O(N^2) asymptotically.
+% - It requires only 5 macros per list.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Usage:
+% \pgfplotsapplistXnewempty\macro
+% \pgfplotsapplistXnewempty[to global]\macro
+%
+% The 'to global' flag will configure the list such that all
+% assignments to \macro are global. The list accumulation is
+% LOCAL, however: 'to global' is to be used inside of a local
+% group such that the final result, when all buffers are flushed,
+% is assigned globally.
+%
+% ATTENTION: maybe that [to global] thing is useless.
+% Consider using the \pgfplotsapplistXglobal list (see below)
+\def\pgfplotsapplistXnewempty{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotsapplistXnewempty@opt
+ }{%
+ \pgfplotsapplistXnewempty@opt[]%
+ }%
+}
+
+\def\pgfplotsapplistXnewempty@opt@TOGLOBAL{to global}
+
+\def\pgfplotsapplistXnewempty@opt[#1]#2{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \expandafter\let\csname\string#2@let\endcsname=\let%
+ \expandafter\let\csname\string#2@edef\endcsname=\edef
+ \else
+ \ifx\pgfplots@loc@TMPa\pgfplotsapplistXnewempty@opt@TOGLOBAL
+ \expandafter\def\csname\string#2@let\endcsname{\global\let}%
+ \expandafter\let\csname\string#2@edef\endcsname=\xdef
+ \else
+ \pgfplots@error{Sorry, the argument '#1' to \string\pgfplotsapplistXnewempty\ is unknown. Accepted is 'to global' or empty.}%
+ \fi
+ \fi
+ \pgfplotsapplistXnewempty@{#2}%
+}%
+
+\def\pgfplotsapplistXnewempty@#1{%
+ \csname\string#1@let\endcsname#1=\pgfutil@empty
+ \expandafter\let\csname\string#1@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\let\csname\string#1@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname\string#1@smallbuf@c\endcsname{0}%
+ \expandafter\def\csname\string#1@bigbuf@c\endcsname{0}%
+}%
+
+% #1: the item to append
+% #2: the list as macro name
+\long\def\pgfplotsapplistXpushback#1\to#2{%
+ \begingroup
+ \c@pgf@counta=\csname\string#2@smallbuf@c\endcsname\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \expandafter\let\csname\string#2@smallbuf@c\endcsname=\pgfplots@glob@TMPa
+ \ifnum\csname\string#2@smallbuf@c\endcsname<40
+ \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
+ \expandafter\edef\csname\string#2@smallbuf\endcsname{\the\t@pgfplots@toka}%
+ \else
+ \pgfplotsapplistXpushback@smallbufoverfl{#1}{#2}%
+ \fi
+}%
+\long\def\pgfplotsapplistXpushback@smallbufoverfl#1#2{%
+ \begingroup
+ \c@pgf@counta=\csname\string#2@bigbuf@c\endcsname\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \expandafter\let\csname\string#2@bigbuf@c\endcsname=\pgfplots@glob@TMPa
+ %
+ \ifnum\csname\string#2@bigbuf@c\endcsname<30
+ \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}%
+ \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
+ \expandafter\edef\csname\string#2@bigbuf\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \expandafter\let\csname\string#2@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname\string#2@smallbuf@c\endcsname{0}%
+ \else%
+ \t@pgfplots@toka=\expandafter{#2}%
+ \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}%
+ \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
+ \csname\string#2@edef\endcsname#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \expandafter\let\csname\string#2@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname\string#2@smallbuf@c\endcsname{0}%
+ \expandafter\let\csname\string#2@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname\string#2@bigbuf@c\endcsname{0}%
+ \fi%
+}%
+\def\pgfplotsapplistXflushbuffers#1{%
+ \t@pgfplots@toka=\expandafter{#1}%
+ \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#1@bigbuf\endcsname}%
+ \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#1@smallbuf\endcsname}%
+ \csname\string#1@edef\endcsname#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \expandafter\let\csname\string#1@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname\string#1@smallbuf@c\endcsname{0}%
+ \expandafter\let\csname\string#1@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname\string#1@bigbuf@c\endcsname{0}%
+}%
+
+
+% Expands the complete content of list #1 as-is into the macro #2.
+\def\pgfplotsapplistXedefcontenttomacro#1\to#2{%
+ \pgfplotsapplistXflushbuffers#1%
+ \edef#2{#1}}
+\def\pgfplotsapplistXxdefcontenttomacro#1\to#2{%
+ \pgfplotsapplistXflushbuffers#1%
+ \xdef#2{#1}}
+\def\pgfplotsapplistXlet#1=#2{%
+ \pgfplotsapplistXflushbuffers#2%
+ \let#1=#2}
+
+% Foreach list element, the stored value will simply be processed by
+% TeX. Characters will be printed and commands will be executed.
+\def\pgfplotsapplistXexecute#1{%
+ \pgfplotsapplistXflushbuffers#1%
+ #1}%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% 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
+%
+% This list \pgfplotsapplistXX here is essentially the SAME as \pgfplotslistX.
+%
+% But there can only be one such list at a time, so it is faster than
+% \pgfplotslistX.
+%
+% This here is probably the fastest list.
+%
+% It is nothing else but a copy of Till Tantau's pgf kernel list.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+
+
+
+% WARNING: call \pgfplotsapplistclear if there is another list active.
+\def\pgfplotsapplistXXnewempty{%
+ \pgfutil@ifundefined{pgfplotsapplistXX}{}{%
+ \ifx\pgfplotsapplistXX\pgfutil@empty
+ \else
+ \pgfplots@error{\string\pgfplotsapplistXXnewempty: there is already another list which is *not* empty. It currently contains '\meaning\pgfplotsapplistXX'. Please call '\string\pgfplotsapplistXXclear' before using a new list to ensure clean separations.}%
+ \fi
+ }%
+ \let\pgfplotsapplistXX=\pgfutil@empty
+ \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
+ \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty
+ \def\pgfplotsapplistXX@smallbuf@c{0}%
+ \def\pgfplotsapplistXX@bigbuf@c{0}%
+}%
+
+
+\def\pgfplotsapplistXXclear{%
+ \pgfutil@ifundefined{pgfplotsapplistXX}{}{%
+ \let\pgfplotsapplistXX=\pgfutil@empty
+ \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
+ \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty
+ \def\pgfplotsapplistXX@smallbuf@c{0}%
+ \def\pgfplotsapplistXX@bigbuf@c{0}%
+ }%
+}%
+
+% #1: the item to append
+% #2: the list as macro name
+\long\def\pgfplotsapplistXXpushback#1{%
+ \begingroup
+ \c@pgf@counta=\pgfplotsapplistXX@smallbuf@c\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \let\pgfplotsapplistXX@smallbuf@c=\pgfplots@glob@TMPa
+ \ifnum\pgfplotsapplistXX@smallbuf@c<40
+ \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX@smallbuf#1}%
+ \edef\pgfplotsapplistXX@smallbuf{\the\t@pgfplots@toka}%
+ \else
+ \pgfplotsapplistXXpushback@smallbufoverfl{#1}%
+ \fi
+}%
+\long\def\pgfplotsapplistXXpushback@smallbufoverfl#1{%
+ \begingroup
+ \c@pgf@counta=\pgfplotsapplistXX@bigbuf@c\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \let\pgfplotsapplistXX@bigbuf@c=\pgfplots@glob@TMPa
+ %
+ \ifnum\pgfplotsapplistXX@bigbuf@c<30
+ \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX@bigbuf}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@smallbuf#1}%
+ \edef\pgfplotsapplistXX@bigbuf{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
+ \def\pgfplotsapplistXX@smallbuf@c{0}%
+ \else%
+ \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@bigbuf}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXX@smallbuf#1}%
+ \edef\pgfplotsapplistXX{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
+ \def\pgfplotsapplistXX@smallbuf@c{0}%
+ \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty
+ \def\pgfplotsapplistXX@bigbuf@c{0}%
+ \fi%
+}%
+\def\pgfplotsapplistXXflushbuffers{%
+ \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@bigbuf}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXX@smallbuf}%
+ \edef\pgfplotsapplistXX{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
+ \def\pgfplotsapplistXX@smallbuf@c{0}%
+ \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty
+ \def\pgfplotsapplistXX@bigbuf@c{0}%
+}%
+
+
+% Expands the complete content of list #1 as-is into the macro #2.
+\def\pgfplotsapplistXXedefcontenttomacro#1{%
+ \pgfplotsapplistXXflushbuffers
+ \edef#1{\pgfplotsapplistXX}}
+\def\pgfplotsapplistXXxdefcontenttomacro#1{%
+ \pgfplotsapplistXXflushbuffers%
+ \xdef#1{\pgfplotsapplistXX}}
+\def\pgfplotsapplistXXlet#1{%
+ \pgfplotsapplistXXflushbuffers%
+ \let#1=\pgfplotsapplistXX}
+
+% Foreach list element, the stored value will simply be processed by
+% TeX. Characters will be printed and commands will be executed.
+\def\pgfplotsapplistXXexecute#1{%
+ \pgfplotsapplistXXflushbuffers
+ #1}%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+%
+% \pgfplotslistXXglobal assigns to a global list.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+\def\pgfplotsapplistXXglobalnewempty{%
+ \pgfutil@ifundefined{pgfplotsapplistXXglobal}{}{%
+ \ifx\pgfplotsapplistXXglobal\pgfutil@empty
+ \else
+ \pgfplots@error{\string\pgfplotsapplistXXglobalnewempty: there is already another list which is *not* empty. It currently contains '\meaning\pgfplotsapplistXXglobal'. Please call '\string\pgfplotsapplistXXglobalclear' before using a new list to ensure clean separations.}%
+ \fi
+ }%
+ \global\let\pgfplotsapplistXXglobal=\pgfutil@empty
+ \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
+ \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty
+ \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
+ \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}%
+}%
+
+
+\def\pgfplotsapplistXXglobalclear{%
+ \pgfutil@ifundefined{pgfplotsapplistXXglobal}{}{%
+ \global\let\pgfplotsapplistXXglobal=\pgfutil@empty
+ \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
+ \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty
+ \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
+ \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}%
+ }%
+}%
+
+% #1: the item to append
+% #2: the list as macro name
+\long\def\pgfplotsapplistXXglobalpushback#1{%
+ \begingroup
+ \c@pgf@counta=\pgfplotsapplistXXglobal@smallbuf@c\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \global\let\pgfplotsapplistXXglobal@smallbuf@c=\pgfplots@glob@TMPa
+ \ifnum\pgfplotsapplistXXglobal@smallbuf@c<40
+ \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}%
+ \xdef\pgfplotsapplistXXglobal@smallbuf{\the\t@pgfplots@toka}%
+ \else
+ \pgfplotsapplistXXglobalpushback@smallbufoverfl{#1}%
+ \fi
+}%
+\long\def\pgfplotsapplistXXglobalpushback@smallbufoverfl#1{%
+ \begingroup
+ \c@pgf@counta=\pgfplotsapplistXXglobal@bigbuf@c\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \global\let\pgfplotsapplistXXglobal@bigbuf@c=\pgfplots@glob@TMPa
+ %
+ \ifnum\pgfplotsapplistXXglobal@bigbuf@c<30
+ \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal@bigbuf}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}%
+ \xdef\pgfplotsapplistXXglobal@bigbuf{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
+ \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
+ \else%
+ \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@bigbuf}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}%
+ \xdef\pgfplotsapplistXXglobal{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
+ \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
+ \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty
+ \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}%
+ \fi%
+}%
+\def\pgfplotsapplistXXglobalflushbuffers{%
+ \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@bigbuf}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXXglobal@smallbuf}%
+ \xdef\pgfplotsapplistXXglobal{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
+ \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
+ \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty
+ \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}%
+}%
+
+
+% Expands the complete content of list #1 as-is into the macro #2.
+%
+% this assigns locally into #1.
+\def\pgfplotsapplistXXglobaledefcontenttomacro#1{%
+ \pgfplotsapplistXXglobalflushbuffers
+ \edef#1{\pgfplotsapplistXXglobal}}
+% this assigns locally into #1.
+\def\pgfplotsapplistXXglobalxdefcontenttomacro#1{%
+ \pgfplotsapplistXXglobalflushbuffers%
+ \xdef#1{\pgfplotsapplistXXglobal}}
+% this assigns locally into #1.
+\def\pgfplotsapplistXXgloballet#1{%
+ \pgfplotsapplistXXglobalflushbuffers%
+ \let#1=\pgfplotsapplistXXglobal}
+
+% Foreach list element, the stored value will simply be processed by
+% TeX. Characters will be printed and commands will be executed.
+% this assigns locally into #1.
+\def\pgfplotsapplistXXglobalexecute#1{%
+ \pgfplotsapplistXXglobalflushbuffers
+ #1}%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% \pgfplotsapplistXglobalnewempty --> same as \pgfplotsapplistX, but
+% it always assigns everything *globally*.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\pgfplotsgloballet{\global\let}%
+
+% Usage:
+% \pgfplotsapplistXglobalnewempty\macro
+% \pgfplotsapplistXglobalnewempty[to global]\macro
+%
+% The 'to global' flag will configure the list such that all
+% assignments to \macro are global. The list accumulation is
+% LOCAL, however: 'to global' is to be used inside of a local
+% group such that the final result, when all buffers are flushed,
+% is assigned globally.
+\def\pgfplotsapplistXglobalnewempty#1{%
+ \pgfplotsgloballet#1=\pgfutil@empty
+ \expandafter\pgfplotsgloballet\csname\string#1@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\pgfplotsgloballet\csname\string#1@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\gdef\csname\string#1@smallbuf@c\endcsname{0}%
+ \expandafter\gdef\csname\string#1@bigbuf@c\endcsname{0}%
+}%
+
+% #1: the item to append
+% #2: the list as macro name
+\long\def\pgfplotsapplistXglobalpushback#1\to#2{%
+ \begingroup
+ \c@pgf@counta=\csname\string#2@smallbuf@c\endcsname\relax
+ \advance\c@pgf@counta by1
+ \expandafter\xdef\csname\string#2@smallbuf@c\endcsname{\the\c@pgf@counta}%
+ \endgroup
+ \ifnum\csname\string#2@smallbuf@c\endcsname<40
+ \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
+ \expandafter\xdef\csname\string#2@smallbuf\endcsname{\the\t@pgfplots@toka}%
+ \else
+ \pgfplotsapplistXglobalpushback@smallbufoverfl{#1}{#2}%
+ \fi
+}%
+\long\def\pgfplotsapplistXglobalpushback@smallbufoverfl#1#2{%
+ \begingroup
+ \c@pgf@counta=\csname\string#2@bigbuf@c\endcsname\relax
+ \advance\c@pgf@counta by1
+ \expandafter\xdef\csname\string#2@bigbuf@c\endcsname{\the\c@pgf@counta}%
+ \endgroup
+ %
+ \ifnum\csname\string#2@bigbuf@c\endcsname<30
+ \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}%
+ \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
+ \expandafter\xdef\csname\string#2@bigbuf\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \expandafter\pgfplotsgloballet\csname\string#2@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\gdef\csname\string#2@smallbuf@c\endcsname{0}%
+ \else%
+ \t@pgfplots@toka=\expandafter{#2}%
+ \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}%
+ \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
+ \xdef#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \expandafter\pgfplotsgloballet\csname\string#2@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\gdef\csname\string#2@smallbuf@c\endcsname{0}%
+ \expandafter\pgfplotsgloballet\csname\string#2@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\gdef\csname\string#2@bigbuf@c\endcsname{0}%
+ \fi%
+}%
+\def\pgfplotsapplistXglobalflushbuffers#1{%
+ \t@pgfplots@toka=\expandafter{#1}%
+ \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#1@bigbuf\endcsname}%
+ \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#1@smallbuf\endcsname}%
+ \xdef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
+ \expandafter\pgfplotsgloballet\csname\string#1@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\gdef\csname\string#1@smallbuf@c\endcsname{0}%
+ \expandafter\pgfplotsgloballet\csname\string#1@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\gdef\csname\string#1@bigbuf@c\endcsname{0}%
+}%
+
+
+\def\pgfplotsapplistXgloballet#1=#2{%
+ \pgfplotsapplistXglobalflushbuffers#2%
+ \let#1=#2}
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsmatrix.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsmatrix.code.tex
new file mode 100644
index 0000000000..ddaf323e7d
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsmatrix.code.tex
@@ -0,0 +1,544 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% This is a helper package with an elementary (full) matrix datastructure,
+% featuring O(1) index access and O(N) creation, deletion, copy.
+%
+% The following macros are supplied:
+%
+% \pgfplotsmatrixnewempty
+% \pgfplotsmatrixresize
+% \pgfplotsmatrixsize
+% \pgfplotsmatrixselect
+% \pgfplotsmatrixset
+% \pgfplotsmatrixletentry
+% \pgfplotsmatrixforeach
+% \pgfplotsmatrixLUdecomp
+% \pgfplotsmatrixLUsolve
+%
+%
+% 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/>.
+%
+%
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Creates a new, empty matrix.
+\def\pgfplotsmatrixnewempty#1{%
+ \pgfplotsarray@@def{#1@rows}{0}%
+ \pgfplotsarray@@def{#1@cols}{1}%
+}
+
+% resizes (truncates) matrix #1 to #2 rows and #3 cols.
+%
+% the elements won't be initialised. Use 'set' for each element.
+\def\pgfplotsmatrixresize#1#2#3{%
+ \pgfplotsarray@@edef{#1@rows}{#2}%
+ \pgfplotsarray@@edef{#1@cols}{#3}%
+}
+
+% Invokes code '#2' if the matrix named '#1' exists and '#3' if it does
+% not exist.
+\def\pgfplotsmatrixifdefined#1#2#3{%
+ \pgfutil@ifundefined{#1@rows}{#3}{#2}%
+}%
+
+
+
+% Counts the number of rows/cols in matrix #1, storing it into the count
+% registers #2, #3.
+% Example:
+% \pgfplotsmatrixsize\foo\to{\count0}{\count1}%
+% \the\count0, \the\count1
+\long\def\pgfplotsmatrixsize#1\to#2#3{%
+ #2=\csname\string#1@rows\endcsname\relax
+ #3=\csname\string#1@cols\endcsname\relax
+}
+
+\long\def\pgfplotsmatrixsizetomacro#1\to#2#3{%
+ \expandafter\let\expandafter#2\csname\string#1@rows\endcsname
+ \expandafter\let\expandafter#3\csname\string#1@cols\endcsname
+}
+
+
+% Returns the (#1,#2) element of matrix #3 into macro #4
+% Arguments:
+% #1: a row index 0,...,N-1 where N is rowcount.
+% #1 must expand to an integer.
+% #2: a col index 0,...,N-1 where N is colcount.
+% #2 must expand to an integer.
+% #3: a matrix
+% #4: a macro name
+% Example:
+% Element 0:
+% \pgfplotsmatrixselect0,1\of\foo\to\elem
+% \elem
+% Element \count1:
+% \pgfplotsmatrixselect\count1,2\of\foo\to\elem
+\def\pgfplotsmatrixselect#1,#2\of#3\to#4{%
+ \expandafter\let\expandafter#4\csname\string#3@#1,#2\endcsname%
+ \ifx#4\relax
+ \pgfplotsthrow{no such element}{#1,#2}{No such element: \string\pgfplotsmatrixselect#1,#2\string\of{\string#3}}\pgfeov%
+ \fi
+}
+
+% Expands to the value (#1,#2) of matrix #3.
+% #1: a row index (not a register)
+% #2: a col index
+% #3: a matrix
+\def\pgfplotsmatrixvalueofelem#1,#2\of#3{\csname\string#3@#1,#2\endcsname}%
+
+% Sets element '#1,#2' of matrix '#3' to '#4'.
+\def\pgfplotsmatrixset#1,#2\of#3\to#4{%
+ \pgfutil@namedef{\string#3@#1,#2}{#4}%
+}
+\long\def\pgfplotsmatrixletentry#1,#2\of#3=#4{%
+ \expandafter\let\csname\string#3@#1,#2\endcsname=#4\relax
+}
+
+% During the loop, \pgfplotsmatrixforeachrowindex expands to the
+% current row index and \pgfplotsmatrixforeachcolindex to the actual
+% col index. It invokes \pgfplotsmatrixforeachrowend after each
+% complete row.
+%
+% This macro uses
+% \c@pgf@counta,\c@pgf@countb,\c@pgf@countc,\c@pgf@countd
+\long\def\pgfplotsmatrixforeach#1\as#2#3{%
+ \pgfplotsmatrixsize#1\to\c@pgf@countc\c@pgf@countd
+ \long\def\pgfplotsmatrixforeach@{#3}%
+ \def\pgfplotsmatrixforeach@assign##1{\def#2{##1}}%
+ \def\pgfplotsmat@select##1,##2\to{\pgfplotsmatrixselect##1,##2\of#1\to}%
+ \def\pgfplotsmatrixforeachrowindex{\the\c@pgf@counta}%
+ \def\pgfplotsmatrixforeachcolindex{\the\c@pgf@countb}%
+ \c@pgf@counta=0
+ \pgfplotsmatrixforeach@loop
+ \let\pgfplotsmatrixforeachcolindex\relax
+ \let\pgfplotsmatrixforeachrowindex\relax%
+}%
+\let\pgfplotsmatrixforeachrowend=\relax
+\def\pgfplotsmatrixforeach@loop{%
+ \ifnum\c@pgf@counta<\c@pgf@countc
+ \c@pgf@countb=0
+ \pgfplotsmatrixforeach@loop@
+ %
+ \pgfplotsmatrixforeachrowend
+ %
+ \advance\c@pgf@counta by1
+ \expandafter\pgfplotsmatrixforeach@loop
+ \fi
+}%
+\def\pgfplotsmatrixforeach@loop@{%
+ \ifnum\c@pgf@countb<\c@pgf@countd
+ \pgfplotsmat@select\the\c@pgf@counta,\the\c@pgf@countb\to\pgfplotsmat@Aij
+ \expandafter\pgfplotsmatrixforeach@assign\expandafter{\pgfplotsmat@Aij}%
+ \pgfplotsmatrixforeach@
+ %
+ \advance\c@pgf@countb by1
+ \expandafter\pgfplotsmatrixforeach@loop@
+ \fi
+}%
+
+% Defines \pgfplotsretval to be a text-representation of the matrix.
+% It will contain '\n' as newline macro and \t to separate cells.
+%
+\def\pgfplotsmatrixtotext#1{%
+ \begingroup
+ \pgfplotsapplistXnewempty\pgfplotsretval@
+ \def\pgfplotsmatrixforeachrowend{%
+ \pgfplotsapplistXpushback\n\to\pgfplotsretval@
+ }%
+ \pgfplotsmatrixforeach#1\as\entry{%
+ \pgfmathfloatparsenumber\entry
+ \pgfmathfloattosci\pgfmathresult
+ \edef\entry{\pgfmathresult\noexpand\t}%
+ \expandafter\pgfplotsapplistXpushback\entry\to\pgfplotsretval@
+ }%
+ \pgfplotsapplistXlet\pgfplotsretval=\pgfplotsretval@
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}
+
+% Takes a matrix #1 and replaces it by its LU decomposition.
+% The LU decomposition uses implicit pivoting; the pivoting
+% information is stored in a permutation array #2 and a sign macro #3.
+%
+% It is to be used together with \pgfplotsmatrixsolveLEQS.
+%
+% #1: the input matrix (square size)
+% #2: a macro name; will be used to store the permutation array for
+% the pivoting.
+% #3: a macro name, will contain the sign of the permutation (either
+% +1 or -1).
+%
+% The algorithm has been converted from Numerical Recipes in C (I did
+% not copy the comments, though). You find the complete reference in
+% Chapter 2 of Numerical Recipes.
+%
+% If the matrix is singular, an exception will be raised.
+% If the matrix is singular up to working precision,
+% \pgfplotsmatrixLUdecompwarnsingular will be invoked and the
+% algorithm continues with a small threshold.
+%
+% All arithmetics is computed with \pgfplotscoordmath{default} (which
+% is float in the initial configuration). Use
+% \pgfplotssetcoordmathfor{default}{pgfbasic} to switch it to standard
+% pgf arithmetics.
+%
+% ATTENTION. This routine re-uses the four counters
+% \c@pgf@counta,...\c@pgf@countd.
+% Furthermore, it does not free any memory.
+% Make sure you use it inside of local scopes.
+\def\pgfplotsmatrixLUdecomp#1\perm#2\sign#3{%
+ \let\pgfplotsmat@i=\c@pgf@counta
+ \let\pgfplotsmat@imax=\c@pgf@countb
+ \let\pgfplotsmat@j=\c@pgf@countc
+ \let\pgfplotsmat@k=\c@pgf@countd
+ \countdef\pgfplotsmat@n=0
+ \let\pgfplotsmat@big=\pgfutil@empty
+ \let\pgfplotsmat@dum=\pgfutil@empty
+ \let\pgfplotsmat@sum=\pgfutil@empty
+ \let\pgfplotsmat@temp=\pgfutil@empty
+ \pgfplotsmatrixsize#1\to\pgfplotsmat@n\c@pgf@countd
+ \ifnum\c@pgf@countd=\pgfplotsmat@n
+ \else
+ \pgfplots@error{Sorry, \string\pgfplotsmatrixLUdecomp\space expected an n x n matrix, but got \the\pgfplotsmat@n\space x \the\c@pgf@countd.}%
+ \fi
+ \pgfplotsarraynewempty\pgfplotsmat@vv
+ \pgfplotsarrayresize\pgfplotsmat@vv\pgfplotsmat@n
+ \pgfplotsarrayresize#2\pgfplotsmat@n
+ \def\pgfplotsmat@parity{1}%
+ \def\pgfplotsmat@select##1,##2\to{\pgfplotsmatrixselect##1,##2\of#1\to}%
+ \def\pgfplotsmat@letentry##1,##2={\pgfplotsmatrixletentry##1,##2\of#1=}%
+ \def\pgfplotsmat@letpermentry##1={\pgfplotsarrayletentry##1\of#2=}%
+ %
+ \pgfplotsmat@i=0
+ \pgfplotsmatrixLUdecomp@scalingloop
+ %
+ \ifnum\pgfplotsmat@n>0 % this is used for error recovery.
+ %
+ \pgfplotsmat@j=0
+ \pgfplotsmatrixLUdecomp@mainloop@j
+ %
+ \let#3=\pgfplotsmat@parity
+ \fi
+}%
+\def\pgfplotsmatrixLUdecomp@scalingloop{%
+ \ifnum\pgfplotsmat@i<\pgfplotsmat@n
+ \pgfplotscoordmath{default}{zero}%
+ \let\pgfplotsmat@big=\pgfmathresult
+ %
+ \pgfplotsmat@j=0
+ \pgfplotsmatrixLUdecomp@scalingloop@
+ %
+ \pgfplotscoordmath{default}{if is}{\pgfplotsmat@big}{0}{%
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Singular matrix in \string\pgfplotsmatrixLUdecomp}\pgfeov%
+ \pgfplotsmat@n=-1
+ }{%
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplotsmat@big}}%
+ \pgfplotsarrayletentry\pgfplotsmat@i\of\pgfplotsmat@vv=\pgfmathresult
+ }%
+ %
+ \advance\pgfplotsmat@i by1
+ \expandafter\pgfplotsmatrixLUdecomp@scalingloop
+ \fi
+}%
+\def\pgfplotsmatrixLUdecomp@scalingloop@{%
+ \ifnum\pgfplotsmat@j<\pgfplotsmat@n
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@Aij
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplotsmat@Aij}%
+ \let\pgfplotsmat@Aij=\pgfmathresult
+ \pgfplotsmat@letentry\the\pgfplotsmat@i,\the\pgfplotsmat@j=\pgfplotsmat@Aij
+ %
+ \pgfplotscoordmath{default}{op}{abs}{{\pgfplotsmat@Aij}}%
+ \let\pgfplotsmat@temp=\pgfmathresult
+ \pgfplotscoordmath{default}{max}{\pgfplotsmat@temp}{\pgfplotsmat@big}%
+ \let\pgfplotsmat@big=\pgfmathresult
+ %
+ \advance\pgfplotsmat@j by1
+ \expandafter\pgfplotsmatrixLUdecomp@scalingloop@
+ \fi
+}%
+
+\def\pgfplotsmatrixLUdecomp@mainloop@j{%
+ \ifnum\pgfplotsmat@j<\pgfplotsmat@n
+ %
+ \pgfplotsmat@i=0
+ \pgfplotsmatrixLUdecomp@mainloop@j@i
+ %
+ \pgfplotscoordmath{default}{zero}%
+ \let\pgfplotsmat@big=\pgfmathresult
+ %
+ \pgfplotsmat@i=\pgfplotsmat@j
+ \pgfplotsmatrixLUdecomp@mainloop@j@i@second
+ %
+ \ifnum\pgfplotsmat@j=\pgfplotsmat@imax
+ \else
+ % interchange rows...
+ \pgfplotsmat@k=0
+ \pgfplotsmatrixLUdecomp@mainloop@j@k
+ %
+ \c@pgfplotsarray@tmp=-\pgfplotsmat@parity\relax%
+ \edef\pgfplotsmat@parity{\the\c@pgfplotsarray@tmp}%
+ %
+ % FIXME : this here is DIFFERENT. Seems there is something
+ % missing in Numerical Recipes book
+ \pgfplotsarrayselect\pgfplotsmat@j\of\pgfplotsmat@vv\to\pgfplotsmat@dum
+ %\pgfplotsarrayselect\pgfplotsmat@imax\of\pgfplotsmat@vv\to\pgfplotsmat@temp
+ %\pgfplotsarrayletentry\pgfplotsmat@j\of\pgfplotsmat@vv=\pgfplotsmat@temp
+ \pgfplotsarrayletentry\pgfplotsmat@imax\of\pgfplotsmat@vv=\pgfplotsmat@dum
+ \fi
+ %
+ \edef\pgfplotsmat@dum{\the\pgfplotsmat@imax}%
+ \pgfplotsmat@letpermentry\pgfplotsmat@j=\pgfplotsmat@dum
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@j,\the\pgfplotsmat@j\to\pgfplotsmat@Ajj
+ \pgfplotscoordmath{default}{if is}{\pgfplotsmat@Ajj}{0}{%
+ \pgfplotscoordmath{default}{parsenumber}{1e-15}%
+ \pgfplotsmatrixLUdecompwarnsingular
+ \pgfplotsmat@letentry\the\pgfplotsmat@j,\the\pgfplotsmat@j=\pgfmathresult
+ }{%
+ }%
+ %
+ %
+ \advance\pgfplotsmat@j by1
+ \ifnum\pgfplotsmat@j=\pgfplotsmat@n
+ \advance\pgfplotsmat@j by-1
+ \else
+ \advance\pgfplotsmat@j by-1
+ \pgfplotsmat@select\the\pgfplotsmat@j,\the\pgfplotsmat@j\to\pgfplotsmat@Ajj
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplotsmat@Ajj}}%
+ \let\pgfplotsmat@dum=\pgfmathresult
+ \pgfplotsmat@i=\pgfplotsmat@j
+ \advance\pgfplotsmat@i by1
+ \pgfplotsmatrixLUdecomp@mainloop@j@i@final
+ \fi
+ \advance\pgfplotsmat@j by1
+ \expandafter\pgfplotsmatrixLUdecomp@mainloop@j
+ \fi
+}%
+\def\pgfplotsmatrixLUdecompwarnsingular{%
+ \pgfplotswarning{linear system singular}\pgfeov%
+}%
+\def\pgfplotsmatrixLUdecomp@mainloop@j@i{%
+ \ifnum\pgfplotsmat@i<\pgfplotsmat@j
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@sum
+ \pgfplotsmat@k=0
+ \pgfplotsmatrixLUdecomp@mainloop@j@i@k
+ \pgfplotsmat@letentry\the\pgfplotsmat@i,\the\pgfplotsmat@j=\pgfplotsmat@sum
+ %
+ \advance\pgfplotsmat@i by1
+ \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i
+ \fi
+}%
+\def\pgfplotsmatrixLUdecomp@mainloop@j@i@k{%
+ \ifnum\pgfplotsmat@k<\pgfplotsmat@i
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@k\to\pgfplotsmat@Aik
+ \pgfplotsmat@select\the\pgfplotsmat@k,\the\pgfplotsmat@j\to\pgfplotsmat@Akj
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@Aik}{\pgfplotsmat@Akj}}%
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotsmat@sum}{\pgfmathresult}}%
+ \let\pgfplotsmat@sum=\pgfmathresult
+ %
+ \advance\pgfplotsmat@k by1
+ \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i@k
+ \fi
+}
+\def\pgfplotsmatrixLUdecomp@mainloop@j@i@second{%
+ \ifnum\pgfplotsmat@i<\pgfplotsmat@n
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@sum
+ %
+ \pgfplotsmat@k=0
+ \pgfplotsmatrixLUdecomp@mainloop@j@i@second@k
+ \pgfplotsmat@letentry\the\pgfplotsmat@i,\the\pgfplotsmat@j=\pgfplotsmat@sum
+ %
+ \pgfplotscoordmath{default}{op}{abs}{{\pgfplotsmat@sum}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplotsarrayvalueofelem\the\pgfplotsmat@i\of\pgfplotsmat@vv}}%
+ \let\pgfplotsmat@dum=\pgfmathresult
+ \pgfplotscoordmath{default}{if less than}{\pgfplotsmat@dum}{\pgfplotsmat@big}{%
+ }{%
+ \let\pgfplotsmat@big=\pgfplotsmat@dum
+ \pgfplotsmat@imax=\pgfplotsmat@i
+ }%
+ %
+ \advance\pgfplotsmat@i by1
+ \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i@second
+ \fi
+}%
+\def\pgfplotsmatrixLUdecomp@mainloop@j@i@second@k{%
+ \ifnum\pgfplotsmat@k<\pgfplotsmat@j
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@k\to\pgfplotsmat@Aik
+ \pgfplotsmat@select\the\pgfplotsmat@k,\the\pgfplotsmat@j\to\pgfplotsmat@Akj
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@Aik}{\pgfplotsmat@Akj}}%
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotsmat@sum}{\pgfmathresult}}%
+ \let\pgfplotsmat@sum=\pgfmathresult
+ %
+ \advance\pgfplotsmat@k by1
+ \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i@second@k
+ \fi
+}%
+
+\def\pgfplotsmatrixLUdecomp@mainloop@j@k{%
+ \ifnum\pgfplotsmat@k<\pgfplotsmat@n
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@imax,\the\pgfplotsmat@k\to\pgfplotsmat@dum
+ \pgfplotsmat@select\the\pgfplotsmat@j,\the\pgfplotsmat@k\to\pgfplotsmat@Ajk
+ \pgfplotsmat@letentry\the\pgfplotsmat@imax,\the\pgfplotsmat@k=\pgfplotsmat@Ajk
+ \pgfplotsmat@letentry\the\pgfplotsmat@j,\the\pgfplotsmat@k=\pgfplotsmat@dum
+ %
+ \advance\pgfplotsmat@k by1
+ \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@k
+ \fi
+}
+\def\pgfplotsmatrixLUdecomp@mainloop@j@i@final{%
+ \ifnum\pgfplotsmat@i<\pgfplotsmat@n
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@Aij
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@Aij}{\pgfplotsmat@dum}}%
+ \pgfplotsmat@letentry\the\pgfplotsmat@i,\the\pgfplotsmat@j=\pgfmathresult
+ %
+ \advance\pgfplotsmat@i by1
+ \expandafter\pgfplotsmatrixLUdecomp@mainloop@j@i@final
+ \fi
+}
+
+
+
+% Solves the set of n linear equations Ax = b where A = LU is given in
+% (#1,#2) and b = #3.
+%
+% #1: is a result of \pgfplotsmatrixLUdecomp
+% #2: is the permutation vector returned by \pgfplotsmatrixLUdecomp
+% #3: the right hand side. On output, it will be *overwritten* with
+% the solution.
+%
+% The algorithm has been converted from Numerical Recipes in C (I did
+% not copy the comments, though). You find the complete reference in
+% Chapter 2 of Numerical Recipes.
+\def\pgfplotsmatrixLUbacksubst#1\perm#2\inout#3{%
+ \let\pgfplotsmat@i=\c@pgf@counta
+ \let\pgfplotsmat@ii=\c@pgf@countb
+ \let\pgfplotsmat@j=\c@pgf@countc
+ \let\pgfplotsmat@n=\c@pgf@countd
+ \let\pgfplotsmat@sum=\pgfutil@empty
+ \pgfplotsmatrixsize#1\to\pgfplotsmat@n\c@pgf@counta
+ \pgfplotsarraysize#3\to\c@pgf@counta
+ \ifnum\c@pgf@counta=\pgfplotsmat@n
+ \def\pgfplotsmat@select##1,##2\to{\pgfplotsmatrixselect##1,##2\of#1\to}%
+ \def\pgfplotsmat@selectperm##1\to{\pgfplotsarrayselect##1\of#2\to}%
+ \def\pgfplotsmat@selectb##1\to{\pgfplotsarrayselect##1\of#3\to}%
+ \def\pgfplotsmat@letresult##1={\pgfplotsarrayletentry##1\of#3=}%
+ %
+ \pgfplotsmat@ii=-1
+ \pgfplotsmat@i=0
+ \pgfplotsmatrixLUbacksubst@loop@i
+ %
+ \pgfplotsmat@i=\pgfplotsmat@n
+ \advance\pgfplotsmat@i by-1
+ \pgfplotsmatrixLUbacksubst@loop@i@backw
+ \else
+ \pgfplots@error{Sorry, \string\pgfplotsmatrixLUbacksubst\space expected a vector of length \the\pgfplotsmat@n\space, not \the\c@pgf@counta}%
+ \fi
+}%
+\def\pgfplotsmatrixLUbacksubst@loop@i{%
+ \ifnum\pgfplotsmat@i<\pgfplotsmat@n
+ %
+ \pgfplotsmat@selectperm\pgfplotsmat@i\to\pgfplotsmat@ip
+ \pgfplotsmat@selectb\pgfplotsmat@ip\to\pgfplotsmat@sum
+ \pgfplotsmat@selectb\pgfplotsmat@i\to\pgfplotsmat@temp
+ %
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplotsmat@sum}%
+ \let\pgfplotsmat@sum=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplotsmat@temp}%
+ \let\pgfplotsmat@temp=\pgfmathresult
+ %
+ \pgfplotsmat@letresult\pgfplotsmat@ip=\pgfplotsmat@temp
+ %
+ \ifnum\pgfplotsmat@ii<0
+ \pgfplotscoordmath{default}{if is}{\pgfplotsmat@sum}{0}{%
+ }{%
+ \pgfplotsmat@ii=\pgfplotsmat@i
+ }%
+ \else
+ \pgfplotsmat@j=\pgfplotsmat@ii
+ \pgfplotsmatrixLUbacksubst@loop@i@j
+ \fi
+ \pgfplotsmat@letresult\pgfplotsmat@i=\pgfplotsmat@sum
+ %
+ \advance\pgfplotsmat@i by1
+ \expandafter\pgfplotsmatrixLUbacksubst@loop@i
+ \fi
+}%
+\def\pgfplotsmatrixLUbacksubst@loop@i@j{%
+ \ifnum\pgfplotsmat@j<\pgfplotsmat@i
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@Aij
+ \pgfplotsmat@selectb\pgfplotsmat@j\to\pgfplotsmat@temp
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@temp}{\pgfplotsmat@Aij}}%
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotsmat@sum}{\pgfmathresult}}%
+ \let\pgfplotsmat@sum=\pgfmathresult
+ %
+ \advance\pgfplotsmat@j by1
+ \expandafter\pgfplotsmatrixLUbacksubst@loop@i@j
+ \fi
+}%
+
+\def\pgfplotsmatrixLUbacksubst@loop@i@backw{%
+ \ifnum\pgfplotsmat@i<0
+ \else
+ %
+ \pgfplotsmat@selectb\pgfplotsmat@i\to\pgfplotsmat@sum
+ \pgfplotsmat@j=\pgfplotsmat@i
+ \advance\pgfplotsmat@j by1
+ \pgfplotsmatrixLUbacksubst@loop@i@backw@j
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@i\to\pgfplotsmat@Aii
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfplotsmat@sum}{\pgfplotsmat@Aii}}%
+ \pgfplotsmat@letresult\pgfplotsmat@i=\pgfmathresult
+ %
+ \advance\pgfplotsmat@i by-1
+ \expandafter\pgfplotsmatrixLUbacksubst@loop@i@backw
+ \fi
+}%
+\def\pgfplotsmatrixLUbacksubst@loop@i@backw@j{%
+ \ifnum\pgfplotsmat@j<\pgfplotsmat@n
+ %
+ \pgfplotsmat@select\the\pgfplotsmat@i,\the\pgfplotsmat@j\to\pgfplotsmat@Aij
+ \pgfplotsmat@selectb\pgfplotsmat@j\to\pgfplotsmat@temp
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplotsmat@temp}{\pgfplotsmat@Aij}}%
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplotsmat@sum}{\pgfmathresult}}%
+ \let\pgfplotsmat@sum=\pgfmathresult
+ %
+ \advance\pgfplotsmat@j by1
+ \expandafter\pgfplotsmatrixLUbacksubst@loop@i@backw@j
+ \fi
+}%
+
+% Solves the linear equation system Ax = b.
+% #1: the matrix A
+% #2: the right-hand-side b. On output, #2 will contain the solution
+% and A will be overwritten.
+%
+% ATTENTION. This routine re-uses the four counters
+% \c@pgf@counta,...\c@pgf@countd.
+% Furthermore, it does not free any memory.
+% Make sure you use it inside of local scopes.
+\def\pgfplotsmatrixsolveLEQS#1=#2{%
+ \pgfplotsmatrixLUdecomp#1\perm\pgfplotsmatrix@perm\sign\pgfplotsmatrix@sign
+ \pgfplotsmatrixLUbacksubst#1\perm\pgfplotsmatrix@perm\inout#2%
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsmeshplothandler.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsmeshplothandler.code.tex
new file mode 100644
index 0000000000..60d6274eb5
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsmeshplothandler.code.tex
@@ -0,0 +1,3528 @@
+%--------------------------------------------
+%
+% 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-2015 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 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.
+%
+
+\input pgfplotsmeshplotimage.code.tex
+
+\def\pgfplotsplothandlermesh{%
+ \def\pgfplotsplothandlername{mesh}%
+ %
+ % acquire values as they are known right now. Note that these values may change during the survey phase, so they will be updated later.
+ \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}%
+ %
+ \pgfkeysgetvalue{/pgfplots/patch type}\pgfplotsplothandlermesh@patchclass
+ \ifx\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@defaulttext
+ \let\pgfplotsplothandlermesh@patchclass=\pgfutil@empty
+ \fi
+ \ifx\pgfplotsplothandlermesh@patchclass\pgfutil@empty
+ % assign default patch class.
+ \if0\pgfplotsplothandlermesh@matrixinput
+ \def\pgfplotsplothandlermesh@patchclass{triangle}%
+ \else
+ \def\pgfplotsplothandlermesh@patchclass{rectangle}%
+ \fi
+ \pgfkeyslet{/pgfplots/patch type}\pgfplotsplothandlermesh@patchclass
+ \fi
+ %
+ \if0\pgfplotsplothandlermesh@matrixinput
+ % mesh input=patches: simply skip empty input lines:
+ \pgfkeyssetvalue{/pgfplots/empty line}{none}%
+ \fi
+ %
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@mesh
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@mesh
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@mesh
+ \let\pgfplotsplothandlersurveyaftersetpointmeta=\pgfplotsplothandlersurveyaftersetpointmeta@mesh@cdatanormalize
+ \let\pgfplotsplothandlernotifyscanlinecomplete=\pgfplotsplothandlersurvey@mesh@scanlinecomplete
+ %
+ \def\pgfplotsplothandlerLUAfactory{pgfplots.MeshPlothandler.new}%
+ \if2\pgfplotsplothandlermesh@matrixinput
+ % mesh input=image
+ % this is currently unsupported in LUA:
+ \let\pgfplotsplothandlerLUAfactory=\pgfutil@empty
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/patch table/value}\pgfplotsplothandlermesh@patchtable
+ \ifx\pgfplotsplothandlermesh@patchtable\pgfutil@empty
+ \else
+ \def\pgfplotsplothandlermesh@matrixinput{0}% implies 'patch input=patches'
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@mesh@patchtable
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@mesh@patchtable
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@mesh@patchtable
+ %
+ % this is currently unsupported in LUA:
+ \let\pgfplotsplothandlerLUAfactory=\pgfutil@empty
+ \fi
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \else
+ % mesh/color input=explicit
+ \if0\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, color input!=colormap requires 'point meta=symbolic' or 'explicit symbolic'. Please adjust the format of your input point meta data}\pgfeov%
+ \fi
+ \fi
+ %
+ %
+ \pgfplotsifisvisualizationphase{%
+ \pgfplotsplothandlermesh@init@variables
+ }{}%
+ %
+ %
+ \def\pgf@plotstreamstart{%
+% \scope
+ %
+ % this shouldn't be necessary, but it doesn't hurt either.
+ \pgfplots@perpointmeta@preparetrafo
+ %
+ %
+ \pgfplotsplothandlermesh@init@DECODE
+ \pgfplotsplothandlermesh@init@REFINE
+ %
+ \pgfutil@IfUndefined{pgfplots@drawmodes}{%
+ \let\pgfplots@drawmodes=\tikz@mode
+ \let\pgfplots@drawoptions=\tikz@options
+ }{}%
+ %
+ %
+ % Prepare color data source:
+ \ifx\pgfplotspointmetainputhandler\pgfutil@empty%
+ % oh. There is no color data!?
+ \pgfplotsplothandlermesh@init@path@without@point@meta
+ %
+ \else
+ \pgfplotsplothandlermesh@init@cdata
+ \pgfplotsplothandlermesh@init@shader
+ \pgfplotsplothandlermesh@init@flat@color
+ \fi
+ % PREPARE THE STREAM PROCESSING:
+ % handling of jumps.
+ \pgfplotsplothandlermesh@init@jumphandling
+ %
+ \ifpgfplotsplothandlermesh@shownormals
+ \let\pgfplotsplothandlermesh@show@normals@if@configured=\pgfplotsplothandlermesh@show@normals
+ % actually store 3d coordinates:
+ \let\pgfplotsplothandlermesh@serialize@logical@coords=\pgfplotsplothandlermesh@serialize@logical@coords@doit
+ \fi
+ %
+ % z buffering:
+ \pgfplotsplothandlermesh@init@zbuffer
+ %
+ \pgfplotsplothandlermesh@init@mesh@stream
+ %
+ \c@pgfplots@scanlineindex=0
+ }%
+ %
+ \let\pgfplotsplothandlerifcurrentpointcanbefirstlast=\pgfplotsplothandlerifcurrentpointcanbefirstlast@mesh
+}%
+
+\def\pgfplotsplothandlermesh@init@variables{%
+ % Check if the current shader needs to be reset.
+ % Do this early as some processing steps depend on it:
+ \if\pgfplots@meshmode m% mesh
+ % this is processed by the 'shader=flat' code below.
+ \def\pgfplotsplothandlermesh@shader{0}% 'flat'
+ \fi
+ \ifnum\pgfplotsplothandlermesh@shader>1% 'shader=interp' and 'shader=faceted 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
+ %
+ \def\pgfplotsplothandlermesh@ONEDIMMODE{0}%
+ \pgfplotsplothandlermesh@init@meshkeys
+ %
+ %
+ \let\pgfplotsplothandlermesh@patchclass@input=\pgfplotsplothandlermesh@patchclass
+ \let\pgfplotsplothandlermesh@patchclass@output=\pgfplotsplothandlermesh@patchclass@input
+ \if0\pgfplotsplothandlermesh@triangulate
+ \else
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@input}{triangulate class}%
+ \let\pgfplotsplothandlermesh@patchclass@output=\pgfplotsretval
+ \fi
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@input}{init}%
+ \ifx\pgfplotsplothandlermesh@patchclass@input\pgfplotsplothandlermesh@patchclass@output
+ \else
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{init}%
+ \fi
+ %
+ % assign boolean:
+ \ifcase\pgfplotsplothandlermesh@matrixinput
+ % mesh input=patches
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \or
+ % mesh input=lattice
+ \def\b@pgfplotsplothandlermesh@matrixoutput{1}%
+ \or
+ % mesh input=image
+ % while it _could_ potentially provide matrix output, the
+ % implementation is quite involved. We don't have it.
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{allow matrix}%
+ \if0\pgfplotsretval
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ \ifnum\pgfkeysvalueof{/pgfplots/patch refines}>0
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ \if1\pgfplotsaxisplothasjumps
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ \if1\pgfplotsaxisplothasunboundedpointmeta
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ \if\pgfplotsplothandlermesh@zbuffer@choice4% 'z buffer=sort':
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ %
+ \if2\pgfplotsplothandlermesh@shader
+ % shader=interp
+ %
+ \pgfkeysgetvalue{/pgfplots/mesh/interior colormap name}\pgfplots@loc@TMPc
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ \else
+ \pgfplotswarning{interior colormap inefficient}\pgfeov%
+ \pgfplotsset{shader=faceted interp,faceted color=none}%
+ \fi
+ \fi
+ \if2\pgfplotsplothandlermesh@shader
+ % shader=interp
+ \if0\pgfplotsplothandlermesh@triangulate
+ % patch to triangles=false
+ \else
+ % no matrix output possible:
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ \else
+ % 'shader!=interp'
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{get pdf shading type}%
+ \if5\pgfplotsretval
+ \else
+ \def\b@pgfplotsplothandlermesh@matrixoutput{0}%
+ \fi
+ %
+ % special handling: check if Type=5 shadings need to be
+ % converted to Type=4
+ \if0\b@pgfplotsplothandlermesh@matrixoutput
+ % no matrix output possible
+ \if5\pgfplotsretval
+ % pdf shading type=5 (matrix output)
+ \if2\pgfplotsplothandlermesh@shader
+ % shader=interp
+ %
+ % FIXME : I am unsure if this here is still
+ % necessary as of 3fc734d7ac3020600c06258b1bc80b22da53edf3
+ % -> perhaps the check can be skipped entirely.
+ %
+ % oh. shading type=5 is *essentially* the same as
+ % matrix output, but matrix output is forbidden.
+ % In that case, triangulate the matrix and shade the
+ % triangles:
+ \def\pgfplotsplothandlermesh@triangulate{1}%
+ \def\pgfplotsplothandlermesh@patchclass@output{triangle}%
+ % Note shader=faceted interp can be written as
+ % matrix -- it shades individual elements anyway;
+ % and one single patch can be written as matrix.
+ \fi
+ \fi
+ \fi
+ %
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{LUA class}%
+ \ifx\pgfplotsretval\pgfutil@empty
+ \let\pgfplotsplothandlerLUAvisualizerfactory=\pgfutil@empty
+ \else
+ \edef\pgfplotsplothandlerLUAvisualizerfactory{
+ function(plothandler) return pgfplots.MeshVisualizer.new(
+ plothandler,
+ \pgfplotsretval(),
+ pgfplots.pgftonumber("\pgfkeysvalueof{/pgfplots/mesh/rows}"),
+ pgfplots.pgftonumber("\pgfkeysvalueof{/pgfplots/mesh/cols}"),
+ \if0\pgfplots@plot@mesh@ordering true\else false\fi,
+ \if1\pgfplotsplothandlermesh@matrixinput true\else false\fi,
+ \if1\b@pgfplotsplothandlermesh@matrixoutput true\else false\fi,
+ \if4\pgfplotsplothandlermesh@zbuffer@choice true\else false\fi)% 'z buffer=sort'
+ end
+ }%
+ \fi
+}%
+
+\def\pgfplotsplothandlerifcurrentpointcanbefirstlast@mesh#1#2{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{if current point can be first last}{#1}{#2}%
+}%
+
+% 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{%
+ % For #1 = 0, the values are only partially completed (which is
+ % also compatible with patch plots)
+ %
+ % get (potentially) updated values:
+ \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}%
+ %
+ \def\pgfplots@loc@TMPa{0}%
+ \ifpgfplots@curplot@threedim
+ \def\pgfplots@loc@TMPa{1}%
+ \else
+ \if s\pgfplots@meshmode
+ % we have a 'surf' plot. That doesn't make sense unless
+ % one has a matrix, even for a two--dimensional plot. Try it.
+ \def\pgfplots@loc@TMPa{1}%
+ \fi
+ \fi
+ \if1\pgfplots@loc@TMPa
+ \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 since 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, a 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.
+ \edef\pgfplotsplothandlermesh@rows{\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.
+ \edef\pgfplotsplothandlermesh@rows{\the\c@pgf@countb}%
+ \else
+ % no... did not work. num points doesn't
+ % appear to be a squared number.
+ \def\pgfplotsretval{0}%
+ \edef\pgfplotsplothandlermesh@rows{5}%
+ \fi
+ \fi
+ \if\pgfplotsretval1
+ \pgfplotswarning{matrix delinearize uses sqrt}{\pgfplotsplothandlermesh@rows}{\pgfplotsplothandlermesh@cols}{\pgfplotsplothandlermesh@numpoints}{\pgfmathresult}\pgfeov%
+ \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
+ \pgfmath@smuggleone\pgfplotsplothandlermesh@rows
+ \endgroup
+ \let\pgfplotsplothandlermesh@cols=\pgfplotsplothandlermesh@rows
+ \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
+ \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
+ %
+ \c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@rows\relax
+ \multiply\c@pgfplots@scanlineindex by\pgfplotsplothandlermesh@cols\relax
+ \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@numpoints\relax
+ \else
+ \ifcase\pgfplots@mesh@checkmode\relax
+ % mesh/check=false
+ \def\pgfplots@loc@TMPa##1{}%
+ \or
+ % mesh/check=warning
+ \def\pgfplots@loc@TMPa##1{\pgfplotsthrow@warning{##1}}%
+ \or
+ % mesh/check=error
+ \def\pgfplots@loc@TMPa##1{\pgfplots@error{##1}}%
+ \fi
+ \pgfplotswarning{matrix check}{\pgfplots@loc@TMPa}{\pgfplotsplothandlermesh@rows}{\pgfplotsplothandlermesh@cols}{\pgfplotsplothandlermesh@numpoints}{\the\c@pgfplots@scanlineindex}\pgfeov%
+ \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}%
+}%
+
+%%
+%% Helper structs for patch plots (surfaces)
+
+% #1: the canvas x coordinate
+% #2: the canvas y coordinate
+% #3: the point meta data (cdata)
+% #4: the vertex'es depth (if required)
+% #5: the 3d coordinates of the vertex (will only be stored if it is deemed necessary)
+\def\pgfplotspatchvertex#1#2#3#4:#5\endvertex{%
+ \def\pgfplotspatchvertexstruct{{#1}{#2}{#3}#4:#5}%
+ \def\pgfplotspatchvertexx{#1}%
+ \def\pgfplotspatchvertexy{#2}%
+ \def\pgfplotspatchvertexmeta{#3}%
+ \def\pgfplotspatchvertexdepth{#4}%
+ \def\pgfplotspatchvertexcoords{#5}%
+}%
+
+% Assumes that #1 expands to an argument of \pgfplotspatchvertex and
+% that #2 is a macro containing another patch vertex.
+%
+% It then replaces #2 by a new vector which is equal to #2 except for
+% the point meta which is taken from #1.
+\def\pgfplotspatchvertexcopymeta#1\to#2{%
+ \begingroup
+ \expandafter\pgfplotspatchvertex#1\endvertex
+ \let\pgfplots@loc@TMPa=\pgfplotspatchvertexmeta
+ \expandafter\pgfplotspatchvertex#2\endvertex
+ \xdef\pgfplots@glob@TMPc{%
+ {\pgfplotspatchvertexx}%
+ {\pgfplotspatchvertexy}%
+ {\pgfplots@loc@TMPa}%
+ \pgfplotspatchvertexdepth:\pgfplotspatchvertexcoords
+ }%
+ \endgroup
+ \let#2=\pgfplots@glob@TMPc
+}%
+
+% Same as \pgfplotspatchvertexcopymeta but it becomes a no-op if the
+% point meta in #1 is bounded (according to
+% \pgfplotsifpointmetaisbounded)
+\def\pgfplotspatchvertexcopymetaifbounded#1\to#2{%
+ \begingroup
+ \expandafter\pgfplotspatchvertex#1\endvertex
+ \let\pgfplots@loc@TMPa=\pgfplotspatchvertexmeta
+ \pgfplotsifpointmetaisbounded{\pgfplots@loc@TMPa}{%
+ \expandafter\pgfplotspatchvertex#2\endvertex
+ \xdef\pgfplots@glob@TMPc{%
+ {\pgfplotspatchvertexx}%
+ {\pgfplotspatchvertexy}%
+ {\pgfplots@loc@TMPa}%
+ \pgfplotspatchvertexdepth:\pgfplotspatchvertexcoords
+ }%
+ }{%
+ \global\let\pgfplots@glob@TMPc=#2%
+ }%
+ \endgroup
+ \let#2=\pgfplots@glob@TMPc
+}%
+
+\def\pgfplotspointpatchvertex#1#2#3#4:#5\endvertex{%
+ \global\pgf@x=#1
+ \global\pgf@y=#2
+}%
+
+% Allows to combined different vertices in the form
+% \pgfplotspatchvertexaccumstart
+% \expandafter\pgfplotspatchvertexadd\vertexA\times{0.25}%
+% \expandafter\pgfplotspatchvertexadd\vertexB\times{0.5}%
+% \expandafter\pgfplotspatchvertexadd\vertexC\times{0.75}%
+% \pgfplotspatchvertexfinish\finalvertex
+% --> now, \finalvertex contains the result vertex, 0.25*A + 0.5*B + 0.75*C .
+%
+% THERE MUST NOT BE MATH INBETWEEN.
+% More precisely, this overwrites the macros
+% \pgf@x,\pgf@y, \pgf@xa,\pgf@ya, \pgf@yb, \pgfmathresult and \pgfplotspatchvertexdepth
+\def\pgfplotspatchvertexaccumstart{%
+ \pgf@xa=0pt
+ \pgf@ya=0pt
+ \pgf@yb=0pt
+ \def\b@pgfplotspatchvertexaccum@ignore@unbounded@metadata{0}%
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ %\if m\pgfplots@colormap@access
+ \iftrue
+ % colormap access=map
+ \pgfplotscoordmath{meta}{zero}%
+ \else
+ % colormap access=direct
+ % FIXME : this causes lots of problems because the result is
+ % of an unexpected format at consumer side:
+ \begingroup
+ \pgfplotscolorzero{\pgfplotsplothandlermesh@explicit@color@num@comps}%
+ \let\pgfmathresult=\pgfplotsretval
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \fi
+ \else
+ % mesh/color input=explicit
+ \begingroup
+ \pgfplotscolorzero{\pgfplotsplothandlermesh@explicit@color@num@comps}%
+ \let\pgfmathresult=\pgfplotsretval
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \fi
+}%
+
+% if this is called, all following accumulation commands will replace unbounded point meta by the fixed zero value.
+\def\pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata{%
+ \def\b@pgfplotspatchvertexaccum@ignore@unbounded@metadata{1}%
+}%
+
+% #1 scale
+% #2 meta
+\def\pgfplotspatchvertexaddscaledmeta@if@applicable@colormap#1#2{%
+ \let\pgfmathresult@=\pgfmathresult
+ \if1\b@pgfplotspatchvertexaccum@ignore@unbounded@metadata
+ \pgfplotsifpointmetaisbounded{#2}{\pgfplots@loc@tmptrue}{\pgfplots@loc@tmpfalse}%
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifpgfplots@loc@tmp
+ %\if m\pgfplots@colormap@access
+ \iftrue
+ % colormap access=map
+ \pgfplotscoordmath{meta}{parsenumber}{#1}%
+ \pgfplotscoordmath{meta}{op}{multiply}{{#2}{\pgfmathresult}}%
+ \pgfplotscoordmath{meta}{op}{add}{{\pgfmathresult@}{\pgfmathresult}}%
+ \else
+ % colormap access=direct
+ % FIXME : this causes lots of problems because the result is
+ % of an unexpected format at consumer side:
+ % colormap access=direct
+ % interpolate colors, not their indices:
+ \begingroup
+ \pgfplotscoordmath{meta}{parsenumber}{#1}%
+ \pgfplotscoordmath{meta}{tofixed}{\pgfmathresult}%
+ \pgfplotscolormapgetindex{\pgfmathresult}{\pgfplotsplothandlermesh@colormapname}%
+ \global\let\pgfplots@glob@TMPc=\pgfmathresult
+ \endgroup
+ \pgfplotspatchvertexaddscaledmeta@if@applicable@explicit{#1}{\pgfplots@glob@TMPc}%
+ \fi
+ \else
+ \pgfplotscoordmath{meta}{op}{multiply}{{\pgfplots@metamin}{\pgfmathresult}}%
+ \pgfplotscoordmath{meta}{op}{add}{{\pgfmathresult@}{\pgfmathresult}}%
+ \fi
+}%
+
+% #1 scale
+% #2 meta
+\def\pgfplotspatchvertexaddscaledmeta@if@applicable@explicit#1#2{%
+ \if1\b@pgfplotspatchvertexaccum@ignore@unbounded@metadata
+ \edef\pgfmathresult@{#2}%
+ \ifx\pgfmathresult@\pgfutil@empty
+ \pgfplots@loc@tmpfalse
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \else
+ \pgfplots@loc@tmptrue
+ \fi
+ \let\pgfmathresult@=\pgfmathresult
+ \ifpgfplots@loc@tmp
+ \begingroup
+ \pgfplotscoloraddweighted{\pgfplotsplothandlermesh@explicit@color@num@comps}
+ {\pgfmathresult@}{#1}{#2}%
+ \let\pgfmathresult=\pgfplotsretval
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \fi
+}
+
+% #1: the patch's x coordinate
+% #2: the patch's y coordinate
+% #3: the patch's point meta value
+% #4: depth (if required)
+% #5: 3d coordinate of the vertex
+\def\pgfplotspatchvertexadd#1#2#3#4:#5\times#6{%
+ \global\pgf@x=#1 %
+ \global\pgf@y=#2 %
+ \advance\pgf@xa by#6\pgf@x
+ \advance\pgf@ya by#6\pgf@y
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \pgfplotspatchvertexaddscaledmeta@if@applicable@colormap{#6}{#3}%
+ \else
+ % mesh/color input=explicit
+ \pgfplotspatchvertexaddscaledmeta@if@applicable@explicit{#6}{#3}%
+ \fi
+ \def\pgfplotspatchvertexdepth{#4}%
+ \ifx\pgfplotspatchvertexdepth\pgfutil@empty
+ \else
+ \global\pgf@y=#4pt %
+ \advance\pgf@yb by#6\pgf@y
+ \fi
+}%
+\def\pgfplotspatchvertexfinish#1{%
+ \edef#1{%
+ {\the\pgf@xa}%
+ {\the\pgf@ya}%
+ {\pgfmathresult}%
+ \ifx\pgfplotspatchvertexdepth\pgfutil@empty\else\pgf@sys@tonumber\pgf@yb\fi%
+ :%
+ }%
+}
+% Same as \pgfplotspatchvertexadd, but it only adds the X and Y
+% coordinates (ignoring the rest).
+\def\pgfplotspatchvertexaddXY#1#2#3#4:#5\times#6{%
+ \global\pgf@x=#1
+ \global\pgf@y=#2
+ \advance\pgf@xa by#6\pgf@x
+ \advance\pgf@ya by#6\pgf@y
+}%
+% Same as \pgfplotspatchvertexfinish, but it only saves X and Y.
+\def\pgfplotspatchvertexfinishXY#1{%
+ \edef#1{{\the\pgf@xa}{\the\pgf@ya}{}:}%
+}
+
+% #1 class name
+% #2 method
+% <any method arguments follow>
+\def\pgfplotspatchclass#1#2{%
+ \pgfutil@ifundefined{pgfpptch@#1@#2}{%
+ \pgfplotspatchclasserror{#1}{#2}%
+ }{%
+ \edef\pgfplotspatchclassname{#1}%
+ \csname pgfpptch@#1@#2\endcsname
+ }%
+}%
+\def\pgfplotspatchclasserror#1#2{%
+ \pgfutil@ifundefined{pgfpptch@#1@}{%
+ \pgfplots@error{Sorry, the 'patch type=#1' is not defined. Maybe you misspelled it? Or perhaps you need to load \string\usepgfplotslibrary{patchplots}?}%
+ }{%
+ \pgfplots@error{Sorry, the patch class '#1' has no method '#2' (or it is not yet implemented)}%
+ }%
+}%
+
+% #1: will be expanded with \edef
+\def\pgfplotsplothandlermesh@setnextvertex#1{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set next vertex}{#1}%
+}%
+
+% Declares a new patch class named #1.
+%
+% #1: a string name.
+% #2: methods defining the class, provided as key values. See the
+% predefined classes to adjust your own ones. Documentation about the
+% available methods and their arguments can be found below in this
+% file.
+%
+% @see \usepgfplotslibrary{patchplots}
+\def\pgfplotsdeclarepatchclass#1#2{%
+ \edef\pgfplotsdeclarepatchclass@{@#1@}%
+ \pgfutil@ifundefined{pgfpptch@#1@}{%
+ % Ok. This is the FIRST declaration of this patch class.
+ % Define some default algorithms.
+ %
+ \expandafter\def\csname pgfpptch@#1@\endcsname{#1}%
+ \pgfqkeys{/pgfplots/@declare patch}{%
+ init=,
+ allow matrix=\def\pgfplotsretval{0},
+ init pdf shading=,
+ stream to shader={%
+%\message{\pgfplotspatchclassname: stream to shader: Starting ^^J}%
+ \pgfplotspatchclass{\pgfplotspatchclassname}{foreach vertex}{%
+%\message{vertex (\pgfplotspatchvertexx,\pgfplotspatchvertexy[\pgfplotspatchvertexmeta]. ^^J}%
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{%
+ \global\pgf@x=\pgfplotspatchvertexx\space
+ \global\pgf@y=\pgfplotspatchvertexy\space
+ }{\pgfplotspointmetatransformed}%
+ }%
+ },%
+ fill path={%
+ \def\b@pgfplotsmeshplothandler@fillpath@default@isfirst{1}%
+ \pgfplotspatchclass{\pgfplotspatchclassname}{foreach vertex}{%
+%\message{vertex (\pgfplotspatchvertexx,\pgfplotspatchvertexy[\pgfplotspatchvertexmeta]. ^^J}%
+ \if1\b@pgfplotsmeshplothandler@fillpath@default@isfirst
+ \expandafter\pgfpathmoveto
+ \else
+ \expandafter\pgfpathlineto
+ \fi
+ {\global\pgf@x=\pgfplotspatchvertexx\space\global\pgf@y=\pgfplotspatchvertexy\space}%
+ \def\b@pgfplotsmeshplothandler@fillpath@default@isfirst{0}%
+ }%
+ \pgfpathclose
+ },
+ get num cdata vertices=\pgfplotspatchclass{\pgfplotspatchclassname}{get num vertices},
+ get dimension=\def\pgfplotsretval{2},
+ supports global path=\def\pgfplotsretval{0},
+ set edge visible=\expandafter\edef\csname pgfppatchedge@##1\endcsname{##2},
+ uses view depth=\def\pgfplotsretval{0},
+ if current point can be first last=##1,
+ serialize except vertices=\let\pgfplotsretval\pgfutil@empty,
+ deserialize except vertices=##1,
+ serialize={%
+ % the default serialization is not necessarily the fastest
+ % possible. But it should work.
+ \pgfplotspatchclass{\pgfplotspatchclassname}{serialize except vertices}%
+ \t@pgfplots@toka=\expandafter{\pgfplotsretval
+ \let\pgfplotspatchready@defaultserialize=\pgfplotspatchready
+ \let\pgfplotspatchready=\relax
+ }%
+ \edef\pgfplotsretval{%
+ \noexpand\pgfplotspatchclass{\pgfplotspatchclassname}{new}%
+ \the\t@pgfplots@toka
+ }%
+ \pgfplotspatchclass{\pgfplotspatchclassname}{foreach vertex}{%
+ \t@pgfplots@toka=\expandafter{\pgfplotsretval}%
+ \edef\pgfplotsretval{\the\t@pgfplots@toka
+ \noexpand\pgfplotspatchclass{\pgfplotspatchclassname}{set next vertex}{\pgfplotspatchvertexstruct}%
+ }%
+ }%
+ \expandafter\def\expandafter\pgfplotsretval\expandafter{\pgfplotsretval
+ \let\pgfplotspatchready=\pgfplotspatchready@defaultserialize
+ }%
+ },
+ deserialize=##1,
+ triangulate class=\def\pgfplotsretval{triangle},
+ triangulate={%
+ \pgfplots@error{triangulate: not yet implemented for \pgfplotspatchclassname}%
+ },%
+ refine={%
+ \let\pgfplotsrefinedpatchready=\pgfplotspatchready
+ \pgfplotspatchclass@recursiverefine{##1}%
+ },%
+ recursive refine@={%
+ \pgfplots@error{refine: not yet implemented for \pgfplotspatchclassname}%
+ },%
+ compute normal={%
+ \pgfplotsplothandlermesh@compute@normal@default
+ },%
+ sample in unit cube={%
+ \pgfplots@error{sample in unit cube: not implemented for \pgfplotspatchclassname}%
+ },
+ LUA class=,
+ }%
+ }{}%
+ %
+ %
+ \pgfqkeys{/pgfplots/@declare patch}{#2}%
+ %
+ %
+ \pgfutil@ifundefined{pgfpptch\pgfplotsdeclarepatchclass@ foreach cdata vertex}{%
+ \pgfutil@namelet
+ {pgfpptch\pgfplotsdeclarepatchclass@ foreach cdata vertex}
+ {pgfpptch\pgfplotsdeclarepatchclass@ foreach vertex}%
+ }{%
+ }%
+ \pgfutil@ifundefined{pgfpptch\pgfplotsdeclarepatchclass@ stroke path}{%
+ \pgfutil@namelet
+ {pgfpptch\pgfplotsdeclarepatchclass@ stroke path}
+ {pgfpptch\pgfplotsdeclarepatchclass@ fill path}%
+ }{%
+ }%
+}%
+\pgfqkeys{/pgfplots/@declare patch}{%
+ % may do any more or less global preparations. It is some sort (!)
+ % of constructor.
+ init/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ init\endcsname{#1}},%
+ allow matrix/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ allow matrix\endcsname{#1}},%
+ %
+ % FIXME : this is NOT properly used in higher order patches!?
+ % Uses view depth defines \pgfplotsretval to '1' if and only if it
+ % does ALWAYS needs the view depth. Note that 'z buffer=sort' will
+ % automatically provide the view depth. Use this key if view depth
+ % is necessary even for 'z buffer!=sort'.
+ uses view depth/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ uses view depth\endcsname{#1}},%
+ %
+ % creates a new patch. The vertices need to be added by 'set next
+ % vertex'
+ new/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ new\endcsname{#1}},%
+ %
+ % sets the next vertex value of the patch.
+ %
+ % if the patch has all expected vertices, \pgfplotspatchready is
+ % invoked and the next call to 'set next vertex' will start a new
+ % patch.
+ %
+ % #1: encodes the current vertex such that
+ % \pgfplotspatchvertex#1\endvertex
+ % is accepted.
+ set next vertex/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ set next vertex\endcsname##1{#1}},%
+ %
+ %
+ % Creates a new patch by means of sampling. The sampling is
+ % applied in the unit cube [0,1]x[0,1] (unit interval if this is an 1d patch
+ % type).
+ %
+ % 'sample in unit cube={<code to invoke for each sampled point>}'
+ %
+ % It will invoke <code to invoke for each sampled point> once for
+ % every sampled vertex. The complete unit cube will be covered.
+ % Depending on the patch type, either one or more patches are
+ % required to fill the unit cube. As soon as one patch is ready,
+ % \pgfplotspatchready will be invoked.
+ %
+ %
+ % PRECONDITION:
+ % -\pgfplotspatchready is defined.
+ %
+ % Arguments:
+ % #1: code which will be invoked whenever a new coordinate is
+ % ready. Inside of #1, the macros \pgfplotspatchclassx and
+ % \pgfplotspatchclassy result in the x and y coordinate (inside
+ % of the unit cube), in fixed point representation.
+ %
+ % Example:
+ % \def\pgfplotspatchready{}
+ % \pgfplotspatchclass{biquadratic}{sample in unit cube}{%
+ % point ready at (\pgfplotspatchclassx, \pgfplotspatchclassy)
+ % }
+ sample in unit cube/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ sample in unit cube\endcsname##1{#1}},%
+ %
+ % declares whether a single edge is visible or not.
+ % #1: an integer denoting the edge, either 0,1,2,...,N-1 where N = num verts
+ % #2: 0 if the edge is not to be stroked and 1 if it is stroked.
+ %
+ % This command doesn't need to be called; but if it is, it needs
+ % to be called for every edge.
+ %
+ % ATTENTION: this is *only* used by 'stroke path'. You will never
+ % need 'stroke path' unless some edges are invisible. If all edges
+ % are visible, 'stroke path' and 'fill path' are the same.
+ %
+ % This is currently *only* used for triangle triangulations!
+ set edge visible/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ set edge visible\endcsname##1##2{#1}},%
+ %
+ % Defines \pgfplotsretval to be a serialized representation of
+ % this patch.
+ serialize/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ serialize\endcsname{#1}},%
+ % Defines \pgfplotsretval to be a serialized representation of
+ % this patches extra data fields, excluding vertices.
+ % This is often a NO-OP (unless 'set edge visible' has been used)
+ serialize except vertices/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ serialize except vertices\endcsname{#1}},%
+ %
+ % Restores a serialized representation from #1.
+ deserialize/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ deserialize\endcsname##1{#1}},%
+ % Restores a serialized representation from #1. Only vertices are
+ % not stored here.
+ deserialize except vertices/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ deserialize except vertices\endcsname##1{#1}},%
+ %
+ % issues \pgfplotspatchvertex{...}\endvertex for the first vertex.
+ first vertex/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ first vertex\endcsname{#1}},%
+ % issues \pgfplotspatchvertex{...}\endvertex for the vertex which
+ % was the first BEFORE any z buffer reorderings changed the
+ % sequence (i.e. it undoes the effect of z buffer for the patch).
+ first vertex before z buffer/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ first vertex before z buffer\endcsname{#1}},%
+ %
+ % invokes
+ % \pgfplotspatchvertex...\endvertex
+ % #1
+ % for the every vertex.
+ foreach vertex/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ foreach vertex\endcsname##1{#1}},%
+ %
+ % invokes
+ % \pgfplotspatchvertex...\endvertex
+ % #1
+ % for every colored vertex.
+ % See 'get num cdata vertices'
+ foreach cdata vertex/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ foreach cdata vertex\endcsname##1{#1}},%
+ %
+ % generates a pgf path which is readily usable for filling.
+ fill path/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ fill path\endcsname{#1}},%
+ %
+ % Similar to 'fill path', this here paints the edges. It is only
+ % useful if 'set edge visible' is in use. In all other cases, it
+ % is the same as 'fill path'
+ %
+ % This is currently *only* used for triangle triangulations!
+ stroke path/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ stroke path\endcsname{#1}},%
+ %
+ init pdf shading/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ init pdf shading\endcsname{#1}},%
+ stream to shader/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ stream to shader\endcsname{#1}},%
+ %
+ % defines \pgfplotsretval to contain the number of vertices.
+ get num vertices/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ get num vertices\endcsname{#1}},%
+ %
+ % defines \pgfplotsretval to contain the number of vertices which have color data
+ % attached. This is usually the same as 'get num vertices' (but
+ % see coons patches).
+ get num cdata vertices/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ get num cdata vertices\endcsname{#1}},%
+ %
+ % defines \pgfplotsretval to contain the dimension of this patch
+ % (either 1 for lines or 2 for patches).
+ get dimension/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ get dimension\endcsname{#1}},%
+ %
+ % defines \pgfplotsretval to be 1 if and only if the patch class
+ % supports global paths.
+ % A global path is one which is drawn as one huge, uninterrupted
+ % PGF path (except for jumps perhaps). Its area can be filled,
+ % i.e. it behaves exactly like the 'sharp' plot handler. This is
+ % used implicitly if 'point meta=none' (if there is point meta
+ % data, we always want individual path segments and \pgfusepath
+ % them after each segment).
+ supports global path/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ supports global path\endcsname{#1}},%
+ %
+ % Approximates the given patch by at least one triangle.
+ % For every finished triangle, \pgfplotspatchready will be invoked
+ % and \pgfplotsplothandlermesh@patchclass will be set to triangle.
+ % More precisely, it is expected to be set to the return value of
+ % 'triangulate class'.
+ triangulate/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ triangulate\endcsname{#1}},%
+ % Defines \pgfplotsretval to be the classname returned by
+ % 'triangulate'. This is usually 'triangle'
+ triangulate class/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ triangulate class\endcsname{#1}},%
+ %
+ % Refines the given patch #1 times.
+ % For every finished patch, \pgfplotspatchready will be invoked.
+ refine/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ refine\endcsname##1{#1}},%
+ %
+ % shared helper method which can be invoked recursively by refine.
+ % the default implementation of 'refine' will invoke this one.
+ %
+ % #1: a serialized representation of the given patch. Use it to
+ % restore the current patch in intermediate steps. Note that you
+ % may not use \begingroup/\endgroup in this method; otherwise the
+ % 'z buffer' algorithm will need to be done with \global (and I
+ % don't want that. You probably neither).
+ %
+ % The refinement loop as such will be controlled by the default
+ % implementation of 'refine'. This macro is ONLY to be called by the
+ % default implementation of 'refine'! Overwriting it should
+ % automatically yield refinement facilities.
+ %
+ % the macro \pgfplotspatchready should be called for each refined
+ % element (happens automatically if you use 'set next vertex').
+ %
+ % POSTCONDITION:
+ % the element has been refined once.
+ recursive refine@/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ recursive refine@\endcsname##1{#1}},%
+ %
+ get pdf shading type/.style={get pdf shading type*={\def\pgfplotsretval{#1}}},
+ get pdf shading type*/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ get pdf shading type\endcsname{#1}},%
+ %
+ % A method which defines \pgfplotsretval to be the normal of the current segment.
+ % The values will be given in a format understood by
+ % \pgfplotsmathvectortostring{\pgfplotsretval}{default}
+ %
+ % This method REQUIRES that 3d coordinates are stored (see \pgfplotsplothandlermesh@serialize@logical@coords).
+ compute normal/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ compute normal\endcsname{#1}},%
+ %
+ % executes '##1' if the current point can be the first or last
+ % point of the patch. Executes ##2 if that is not the case.
+ if current point can be first last/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ if current point can be first last\endcsname##1##2{#1}},%
+ %
+ % Defines \pgfplotsretval to contain LUA code which returns a
+ % factory method (with no arguments) which returns an instance of the
+ % associated LUA pgfplots.PatchType
+ %
+ % If the returned \pgfplotsretval is empty: there is no LUA implementation.
+ LUA class/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ LUA class\endcsname{\def\pgfplotsretval{#1}}},%
+}
+
+% This implements 'compute normal' :
+\def\pgfplotsplothandlermesh@compute@normal@default{%
+ \begingroup
+ \c@pgf@countd=0
+ \pgfplotspatchclass{\pgfplotspatchclassname}{foreach vertex}{%
+ \ifx\pgfplotspatchvertexcoords\pgfutil@empty
+ \pgfplotsplothandlermesh@compute@normal@error
+ \fi
+ \pgfplotsmathvectorfromstring{\pgfplotspatchvertexcoords}{default}%
+ \expandafter\let\csname point\the\c@pgf@countd\endcsname=\pgfplotsretval
+ \let\pointlast=\pgfplotsretval
+ \advance\c@pgf@countd by1 %
+ }%
+ \pgfplotsmathvectorsubtract{\csname point1\endcsname}{\csname point0\endcsname}{default}%
+ \let\diffA=\pgfplotsretval
+ % Hm. usually, I would use \point2 here... but it turned out that
+ % the result looks ugly for rectangular patches -- so I used the
+ % last point instead (which is, at least, consistent with the
+ % patch boundaries)
+ \pgfplotsmathvectorsubtract{\csname pointlast\endcsname}{\csname point0\endcsname}{default}%
+ \let\diffB=\pgfplotsretval
+ \pgfplotsmathvectorcrossprod{\diffA}{\diffB}{default}%
+ \let\crossAB=\pgfplotsretval
+ % this here is an experiment to use the MEAN of two normal
+ % vectors for rectangular patches... but it did not work as good
+ % as expected:
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{get num vertices}%
+ % \ifnum\pgfplotsretval=4
+ % \pgfplotsmathvectorsubtract{\csname point3\endcsname}{\csname point0\endcsname}{default}%
+ % \let\diffC=\pgfplotsretval
+ % \pgfplotsmathvectorcrossprod{\diffB}{\diffC}{default}%
+ % \let\crossBC=\pgfplotsretval
+ % \pgfplotsmathvectoradd{\crossAB}{\crossBC}{default}%
+ % \pgfplotscoordmath{default}{parsenumber}{0.5}%
+ % \pgfplotsmathvectorscale{\pgfplotsretval}{\pgfmathresult}{default}%
+ % \let\normal=\pgfplotsretval
+ % \else
+ \let\normal=\crossAB
+ %\fi
+ %
+ % specific choices of z buffering change the sequence of points.
+ % If the number of reversals is off, we need to switch the
+ % normal's sign:
+ \def\pgfplots@switch@normal@dir{0}%
+ \if1\pgfplotsplothandlermesh@zbuffer@choice
+ % z buffer=reverse x seq
+ \def\pgfplots@switch@normal@dir{1}%
+ \else
+ \if2\pgfplotsplothandlermesh@zbuffer@choice
+ % z buffer=reverse y seq
+ \def\pgfplots@switch@normal@dir{1}%
+ \fi
+ \fi
+ \if1\pgfplots@switch@normal@dir
+ \pgfplotscoordmath{default}{parsenumber}{-1}%
+ \pgfplotsmathvectorscale{\normal}{\pgfmathresult}{default}%
+ \fi
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsplothandlermesh@compute@normal@error{%
+ \pgfplots@error{Cannot compute normal vectors: due to some reason, only canvas coordinates of the involved patch are available in this context, but the original input coordinates are required. This indicates an incompatible combination of variables (sorry). Please report this as a bug}%
+}%
+
+\def\pgfplotspatchclass@recursiverefine#1{%
+ \c@pgf@counta=#1
+ \ifnum\c@pgf@counta=1
+ \let\pgfplotspatchready=\pgfplotsrefinedpatchready
+ \else
+ \advance\c@pgf@counta by-1
+ \edef\pgfplotspatchready{\noexpand\pgfplotspatchclass@recursiverefine{\the\c@pgf@counta}}%
+ \fi
+ %
+ \pgfplotspatchclass{\pgfplotspatchclassname}{serialize}%
+ \t@pgfplots@toka=\expandafter{\pgfplotsretval}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotspatchready}%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplotspatchclass{\pgfplotspatchclassname}{deserialize}{\the\t@pgfplots@toka}%
+ \noexpand\def\noexpand\pgfplotspatchready{\the\t@pgfplots@tokc}%
+ \noexpand\def\noexpand\pgfplotspatchclassname{\pgfplotspatchclassname}% % FIXME: is that correct?
+ }%
+ \expandafter\pgfplotspatchclass@recursiverefine@\expandafter{\pgfplots@loc@TMPa}%
+}%
+\def\pgfplotspatchclass@recursiverefine@{%
+ \pgfplotspatchclass{\pgfplotspatchclassname}{recursive refine@}%
+}%
+
+
+% sequence macros preferred over integer indices.
+% using characters avoids the extensive use of \csname ...\endcsname
+% and \expandafter which would be necessary for integer indices.
+\def\pgfpptchindexnext@A{B}% 0->1
+\def\pgfpptchindexnext@B{C}% 1->2
+\def\pgfpptchindexnext@C{D}% 2->3
+\def\pgfpptchindexnext@D{E}% 3->4
+\def\pgfpptchindexnext@E{F}% 4->5
+\def\pgfpptchindexnext@F{G}% 5->6
+\def\pgfpptchindexnext@G{H}% 6->7
+\def\pgfpptchindexnext@H{I}% 7->8
+\def\pgfpptchindexnext@I{J}% 8->9
+\def\pgfpptchindexnext@J{K}% 9->10
+\def\pgfpptchindexnext@K{L}% 10->11
+\def\pgfpptchindexnext@L{M}% 11->12
+\def\pgfpptchindexnext@M{N}% 12->13
+\def\pgfpptchindexnext@N{O}% 13->14
+\def\pgfpptchindexnext@O{P}% 14->15
+\def\pgfpptchindexnext@P{Q}% 15->16
+\def\pgfpptchindexnext@Q{R}% 16->17
+
+\pgfplotsdeclarepatchclass{line}{%
+ allow matrix=\def\pgfplotsretval{0},
+ new=\def\pgfplotspatchclass@line@no{0},
+ set next vertex={%
+ \if0\pgfplotspatchclass@line@no\relax
+ \edef\pgfplotspatchclass@line@A{#1}%
+ \def\pgfplotspatchclass@line@no{1}%
+ \else
+ \edef\pgfplotspatchclass@line@B{#1}%
+ \def\pgfplotspatchclass@line@no{0}%
+ \pgfplotspatchready%
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \pgfplotspatchready
+ },%
+ get dimension=\def\pgfplotsretval{1},
+ supports global path=\def\pgfplotsretval{1},
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@line@A\endvertex,
+ first vertex before z buffer=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@line@A\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@line@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@line@B\endvertex #1%
+ },
+ fill path={%
+ \pgfplotsplothandlermesh@pathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@line@A\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@line@B\endvertex}%
+ \pgfplotsplothandlermesh@setlastpoint{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@line@B\endvertex}%
+ },
+ serialize except vertices=\let\pgfplotsretval\pgfutil@empty,%
+ deserialize except vertices=,
+ get num vertices=\def\pgfplotsretval{2},
+ get pdf shading type=0,
+}%
+
+\def\pgfplotsplothandlermesh@last@x{-16000pt}
+\def\pgfplotsplothandlermesh@last@y{-16000pt}
+
+\def\pgfplotsplothandlermesh@pathmoveto#1{%
+ \pgf@process{#1}%
+ \pgfpathmoveto{}%
+}
+\def\pgfplotsplothandlermesh@setlastpoint#1{%
+}
+
+% Applies a moveto to #1 - but only if #1 is NOT the last used path
+% segment.
+\def\pgfplotsplothandlermesh@pathmoveto@globalpath#1{%
+ \pgf@process{#1}%
+ \pgfplots@loc@tmptrue
+ \ifdim\pgf@x=\pgfplotsplothandlermesh@last@x\relax
+ \ifdim\pgf@y=\pgfplotsplothandlermesh@last@y\relax
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+ \ifpgfplots@loc@tmp
+ \pgfpathmoveto{}%
+ \fi
+}%
+
+\def\pgfplotsplothandlermesh@setlastpoint@globalpath#1{%
+ \pgf@process{#1}%
+ \xdef\pgfplotsplothandlermesh@last@x{\the\pgf@x}%
+ \xdef\pgfplotsplothandlermesh@last@y{\the\pgf@y}%
+}%
+
+\pgfplotsdeclarepatchclass{triangle}{%
+ allow matrix=\def\pgfplotsretval{0},
+ new=\def\pgfplotspatchclass@tri@no{0}\let\pgfplotspatchclass@trie@AB\relax,
+ set next vertex={%
+ \ifcase\pgfplotspatchclass@tri@no\relax
+ \edef\pgfplotspatchclass@tri@A{#1}%
+ \def\pgfplotspatchclass@tri@no{1}%
+ \or
+ \edef\pgfplotspatchclass@tri@B{#1}%
+ \def\pgfplotspatchclass@tri@no{2}%
+ \or
+ \edef\pgfplotspatchclass@tri@C{#1}%
+ \def\pgfplotspatchclass@tri@no{0}%
+ \pgfplotspatchready%
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \pgfplotspatchready
+ %
+ %
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \pgfplotspatchready
+ },%
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@tri@A\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tri@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tri@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tri@C\endvertex #1%
+ },
+ fill path={%
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@A\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@B\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@C\endvertex}%
+ \pgfpathclose
+ },
+ stroke path={%
+ \ifx\pgfplotspatchclass@trie@AB\relax
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@A\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@B\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@C\endvertex}%
+ \pgfpathclose
+ \else
+ \if1\pgfplotspatchclass@trie@AB
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@A\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@B\endvertex}%
+ \fi
+ \if1\pgfplotspatchclass@trie@BC
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@B\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@C\endvertex}%
+ \fi
+ \if1\pgfplotspatchclass@trie@CA
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@C\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@A\endvertex}%
+ \fi
+ \fi
+ },
+ triangulate=\pgfplotspatchready,
+ set edge visible={%
+ \ifcase#1
+ \edef\pgfplotspatchclass@trie@AB{#2}%
+ \or
+ \edef\pgfplotspatchclass@trie@BC{#2}%
+ \or
+ \edef\pgfplotspatchclass@trie@CA{#2}%
+ \fi
+ },
+ serialize except vertices={%
+ \ifx\pgfplotspatchclass@trie@AB\relax
+ \let\pgfplotsretval\pgfutil@empty%
+ \else
+ \edef\pgfplotsretval{%
+ \noexpand\def\noexpand\pgfplotspatchclass@trie@AB{\pgfplotspatchclass@trie@AB}%
+ \noexpand\def\noexpand\pgfplotspatchclass@trie@BC{\pgfplotspatchclass@trie@BC}%
+ \noexpand\def\noexpand\pgfplotspatchclass@trie@CA{\pgfplotspatchclass@trie@CA}%
+ }%
+ \fi
+ },%
+ recursive refine@={%
+ %
+ \pgfplotspatchclass{\pgfplotspatchclassname}{new}%
+ %
+ % Perform longest edge bisection.
+ \pgfpointdiff
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@A\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@B\endvertex}%
+ \edef\pgfplots@loc@TMPa{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}%
+ \expandafter\pgfmath@basic@veclen@\pgfplots@loc@TMPa
+ \pgf@xa=\pgfmathresult pt
+ \pgf@yc=\pgf@xa % "max so far"
+ \def\pgfplotspatch@tri@longestedgestart{A}%
+ %
+ \pgfpointdiff
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@B\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@C\endvertex}%
+ \edef\pgfplots@loc@TMPa{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}%
+ \expandafter\pgfmath@basic@veclen@\pgfplots@loc@TMPa
+ \pgf@xa=\pgfmathresult pt
+ \ifdim\pgf@xa>\pgf@yc
+ \pgf@yc=\pgf@xa
+ \def\pgfplotspatch@tri@longestedgestart{B}%
+ \fi
+ %
+ \pgfpointdiff
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@C\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tri@A\endvertex}%
+ \edef\pgfplots@loc@TMPa{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}%
+ \expandafter\pgfmath@basic@veclen@\pgfplots@loc@TMPa
+ \pgf@xa=\pgfmathresult pt
+ \ifdim\pgf@xa>\pgf@yc
+ \def\pgfplotspatch@tri@longestedgestart{C}%
+ \fi
+ % The ordering is not arbitrary
+ % (unless z buffer=sort is in effect). Let's assume that the
+ % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then
+ % this sequence here should have approximately the same depth
+ % ordering:
+ %
+ \pgfplotspatchvertexaccumstart
+ \if A\pgfplotspatch@tri@longestedgestart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@tri@A\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@tri@B\times{0.5}%
+ \def\pgfplots@loc@TMPa{ACM,BCM}%
+ \else
+ \if B\pgfplotspatch@tri@longestedgestart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@tri@B\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@tri@C\times{0.5}%
+ \def\pgfplots@loc@TMPa{ABM,ACM}%
+ \else
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@tri@C\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@tri@A\times{0.5}%
+ \def\pgfplots@loc@TMPa{ABM,BCM}%
+ \fi
+ \fi
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@tri@M
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa;\pgfplotspatchclass@tri@M}%
+ %
+ % invoke helper method such that I don't need to restore or
+ % recompute \pgfplotspatchclass@tri@M during recursion.
+ \expandafter\pgfplotspatchclass@tri@recursiverefine@@\pgfplots@loc@TMPa\relax{#1}%
+ },
+ deserialize except vertices=%
+ \let\pgfplotspatchclass@trie@AB\relax
+ #1,
+ get pdf shading type=4,
+ get num vertices=\def\pgfplotsretval{3},
+ LUA class=pgfplots.TrianglePatchType.new,
+}%
+\def\pgfplotspatchclass@tri@recursiverefine@@#1#2M,#3#4M;#5\relax#6{%
+ \expandafter\let\expandafter\pgfplotspatchclass@tri@A@\csname pgfplotspatchclass@tri@#1\endcsname
+ \expandafter\let\expandafter\pgfplotspatchclass@tri@B@\csname pgfplotspatchclass@tri@#2\endcsname
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@tri@A@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@tri@B@}%
+ \pgfplotsplothandlermesh@setnextvertex{#5}%
+ #6%
+ %
+ \expandafter\let\expandafter\pgfplotspatchclass@tri@A@\csname pgfplotspatchclass@tri@#3\endcsname
+ \expandafter\let\expandafter\pgfplotspatchclass@tri@B@\csname pgfplotspatchclass@tri@#4\endcsname
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@tri@A@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@tri@B@}%
+ \pgfplotsplothandlermesh@setnextvertex{#5}%
+ #6%
+}%
+
+% implements 'first vertex before z buffer' for rectangle
+% Note that 'mesh input=lattice' generates the rectangle patch as
+% follows: if the input matrix has the form
+%
+% (i-1,j-1) (i,j-1)
+%
+% (i-1,j) (i,j)
+%
+% it generates the rectangle
+%
+% A B
+%
+% D C
+%
+% (if you try to map this to a plot, ensure that you have 'y dir=reverse')
+\def\pgfplotspatchclass@rect@first@before@z@buffer{%
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = rowwise -> scanline is cols!
+ \ifcase\pgfplotsplothandlermesh@zbuffer@choice\relax
+ % none
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@A
+ \or
+ % reverse x seq
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@B
+ \or
+ % reverse y seq
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@D
+ \or
+ % reverse xy seq
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@C
+ \or
+ % sort
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@A
+ \else
+ % the choices 'default' or 'auto' should have been expanded already. Nothing to do here:
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@A
+ \fi
+ \else
+ % ordering = colwise: scanline is rows!
+ \ifcase\pgfplotsplothandlermesh@zbuffer@choice\relax
+ % none
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@A
+ \or
+ % reverse x seq
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@D
+ \or
+ % reverse y seq
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@B
+ \or
+ % reverse xy seq
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@C
+ \or
+ % sort
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@A
+ \else
+ % the choices 'default' or 'auto' should have been expanded already. Nothing to do here:
+ \let\pgfplots@loc@TMPa\pgfplotspatchclass@rect@A
+ \fi
+ \fi
+ \expandafter\pgfplotspatchvertex\pgfplots@loc@TMPa\endvertex
+}%
+
+% A rectangle specified in the sequence
+% D <-- C
+% | ^
+% v |
+% A --> B
+%
+\pgfplotsdeclarepatchclass{rectangle}{%
+ allow matrix=\def\pgfplotsretval{1},
+ new=\def\pgfplotspatchclass@rect@no{0},
+ set next vertex={%
+ \ifcase\pgfplotspatchclass@rect@no\relax
+ \edef\pgfplotspatchclass@rect@A{#1}%
+ \def\pgfplotspatchclass@rect@no{1}%
+ \or
+ \edef\pgfplotspatchclass@rect@B{#1}%
+ \def\pgfplotspatchclass@rect@no{2}%
+ \or
+ \edef\pgfplotspatchclass@rect@C{#1}%
+ \def\pgfplotspatchclass@rect@no{3}%
+ \or
+ \edef\pgfplotspatchclass@rect@D{#1}%
+ \def\pgfplotspatchclass@rect@no{0}%
+ \pgfplotspatchready%
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \pgfplotspatchready
+ },%
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex,
+ first vertex before z buffer=\pgfplotspatchclass@rect@first@before@z@buffer,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@C\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex #1%
+ },
+ stream to shader={%
+ % a 'foreach vertex' with slightly different sequence:
+ \def\pgfplots@foreachvertex@@{%
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{%
+ \global\pgf@x=\pgfplotspatchvertexx\space
+ \global\pgf@y=\pgfplotspatchvertexy\space
+ }{\pgfplotspointmetatransformed}%
+ }%
+ \if1\b@pgfplotsplothandlermesh@matrixoutput
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex\pgfplots@foreachvertex@@%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex\pgfplots@foreachvertex@@%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex\pgfplots@foreachvertex@@% EXCHANGED SEQUENCE
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@C\endvertex\pgfplots@foreachvertex@@%
+ \else
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex\pgfplots@foreachvertex@@%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex\pgfplots@foreachvertex@@%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex\pgfplots@foreachvertex@@%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex\pgfplots@foreachvertex@@%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@C\endvertex\pgfplots@foreachvertex@@%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex\pgfplots@foreachvertex@@%
+ \fi
+ },%
+ fill path={%
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@A\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@B\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@C\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@D\endvertex}%
+ \pgfpathclose
+ },
+ init pdf shading={%
+ \if0\b@pgfplotsplothandlermesh@matrixoutput
+ \ifnum\pgfkeysvalueof{/pgfplots/surf shading/cols}=2
+ \else
+ \pgfplots@error{Sorry, (patch type=rectangle) and (rectangular patch shadings with more than one rectangle) is not supported (got \pgfkeysvalueof{/pgfplots/surf shading/cols} x * input points).
+ It is supported if z buffer!=sort. Consider using 'patch to triangles=true' to combine it with z buffer=sort}%
+ \fi
+ \fi
+ },
+ recursive refine@={%
+ \pgfplots@error{Please use \string\usepgfplotslibrary{patchplots} in order to use 'refine,patch type=\pgfplotspatchclassname'}%
+ },
+ triangulate={%
+ \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass
+ \def\pgfplotsplothandlermesh@patchclass{triangle}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}21%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}%
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}11%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}%
+ \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@
+ },%
+ serialize except vertices=\let\pgfplotsretval\pgfutil@empty,%
+ deserialize except vertices=,
+ get pdf shading type=5,
+ get num vertices=\def\pgfplotsretval{4},
+ LUA class=pgfplots.RectanglePatchType.new,
+}%
+
+\def\pgfplots@rect@next@A{B}
+\def\pgfplots@rect@next@B{C}
+\def\pgfplots@rect@next@C{D}
+\def\pgfplots@rect@next@D{A}
+
+\def\pgfplots@rect@rnext@A{D}
+\def\pgfplots@rect@rnext@B{A}
+\def\pgfplots@rect@rnext@C{B}
+\def\pgfplots@rect@rnext@D{C}
+
+% Ideas: make sure that the foreground edge is the 'v=1'
+% edge of the coons patch, i.e. that it is drawn on top of
+% the rest.
+%
+% Furthermore, for fixed v, the 'u=1' point should belong
+% to the foreground (as it is drawn on top of u=0).
+%
+% In other words, if the coons patch looks like
+%
+% BB-------CC <--v=1
+% | |
+% | |
+% | |
+% AA-------DD <--v=0
+% | |
+% u=0 u=1
+%
+% where the AA,BB,CC,DD are the corners of the coons
+% patch, The FOREGROUND POINT of our visualization here should be CC,
+% the second most foreground point BB (assuming that
+% foreground point and second most foreground point are
+% adjacent).
+%
+% Thus, if 'CC' is behind of 'BB' in the A,B,C,D ordering:
+% start the coons patch with AA := BB-1 in forward
+% direction.
+% else
+% start the coons patch with AA := BB+1 in reverse
+% direction.
+%
+% #1: the vertex prefix for the rectangular shape.
+% Thus, \csname #1A\endcsname is the first vertex, \csname #1B\endcsname the second
+% and #1C, #1D the third and fourth.
+%
+% [output] #2: A macro name which will be filled with the FIRST point
+% to stream to the shader. It will be defined to be either A,B,C or D.
+% [output] #3: A macro name which indicates whether the stream shall
+% be forward or backward. It will be defined to be either empty or 'r'. If
+% it is empty, the coons patch shall be in the sequence
+% #2,next(#2),next(next(#2),....
+% If it is 'r', the coons patch shall be in the sequence
+% #2,prev(#2),prev(prev(#2),...
+%
+% Note that this method works also for biquadratic patches since these
+% patches also have #1A, #1B, #1C and #1D as their corners.
+%
+\def\pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth#1#2#3{%
+ \def#2{A}%
+ \def#3{}%
+ %
+ \expandafter\expandafter\expandafter\pgfplotspatchvertex\csname #1A\endcsname\endvertex
+ \ifx\pgfplotspatchvertexdepth\pgfutil@empty
+ \else
+ % aaah -- we have z buffer information. Then we will use it!
+ \edef\PA{\pgfplotspatchvertexdepth pt A}%
+ \expandafter\expandafter\expandafter\pgfplotspatchvertex\csname #1B\endcsname\endvertex
+ \edef\PB{\pgfplotspatchvertexdepth pt B}%
+ \expandafter\expandafter\expandafter\pgfplotspatchvertex\csname #1C\endcsname\endvertex
+ \edef\PC{\pgfplotspatchvertexdepth pt C}%
+ \expandafter\expandafter\expandafter\pgfplotspatchvertex\csname #1D\endcsname\endvertex
+ \edef\PD{\pgfplotspatchvertexdepth pt D}%
+ \pgfplotsutilsortfour\PA\PB\PC\PD
+ \def\toCHAR##1pt ##2{##2}% get original index
+ %
+ %
+ \edef\PA{\expandafter\toCHAR\PA}%%
+ \edef#2{\expandafter\toCHAR\PB}%%
+ \edef\Pnext{\csname pgfplots@rect@next@#2\endcsname}% this here uses only A,B,C and D (also for biquadratic patches!)
+ \if\Pnext\PA
+ % ok, next(BB) = CC.
+ % that means we have to advance forward.
+ \def#3{}%
+ \edef#2{\csname pgfplots@rect@rnext@#2\endcsname}%
+ \else
+ \edef#2{\csname pgfplots@rect@next@#2\endcsname}%
+ \def#3{r}%
+ \fi
+%\message{^^JDEPTH SEQUENCE for rectangle: \PA, \PB, \PC, \PD^^J}%
+%\message{COONS PATH ORDERING: starts with #2, direction: \ifx#3\pgfutil@empty forward\else backward\fi^^J}%
+ \fi
+}%
+
+\def\pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth@no@op#1#2#3{%
+ \def#2{A}%
+ \def#3{}%
+}
+
+\def\pgfplotsplothandlermesh@patchclass@defaulttext{default}%
+
+% This is a VERY special case. The idea is to switch to
+% "normal" path mode:
+% \pgfpathmoveto \pgfpathlineto \pgfpathlineto
+% \pgfpathlineto \pgfusepath.
+%
+% Note that the mesh handler's default is to issue
+% \pgfusepath after *each* elementary patch.
+%
+% This special use-case might not cover all aspects of the
+% mesh/surf/patch plot handler.
+\def\pgfplotsplothandlermesh@init@path@without@point@meta{%
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{supports global path}%
+ \ifnum\pgfplotsretval=1 %
+ \def\pgfplotsplothandlermesh@definecolor{%
+ % no-op
+ }%
+ % FIXME : this does not handle separate edges, i.e.
+ % \pgfplotsplothandlermesh@VISUALIZE@std@separate@fillstroke
+ \def\pgfplotsplothandlermesh@VISUALIZE{\pgfplotsplothandlermesh@VISUALIZE@globalpath@fill@andor@stroke}%
+ \let\pgfplotsplothandlermesh@pathmoveto=\pgfplotsplothandlermesh@pathmoveto@globalpath
+ \let\pgfplotsplothandlermesh@setlastpoint=\pgfplotsplothandlermesh@setlastpoint@globalpath
+ %
+ % This activates tikz colors:
+ %\tikz@options
+ \pgfplots@drawoptions
+ % Acquire the values for \tikz@mode@* [used for faceted]
+ \pgfplots@drawmodes
+ \else
+ \pgfplots@error{Please provide 'point meta' for your plot. Omitting point meta is only supported for 1d patch types.}%
+ \fi
+}
+
+% implements 'show normals'. Keep in mind that this is more-or-less a
+% debugging helper, not productive code.
+\def\pgfplotsplothandlermesh@show@normals{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{compute normal}%
+ \let\pgfplots@normal@vector=\pgfplotsretval
+%\pgfplotsmathvectortostring\pgfplots@normal@vector{default}%
+%\message{got normal \pgfplotsretval^^J}%
+ \pgfplotsmathvectorlength{\pgfplots@normal@vector}{default}%
+ \pgfplotscoordmath{default}{parsenumber}{\pgfkeysvalueof{/pgfplots/mesh/show normals length factor}}% FIXME
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfmathresult}{\pgfplotsretval}}%
+ \pgfplotsmathvectorscale{\pgfplots@normal@vector}{\pgfmathresult}{default}%
+ %\pgfplotsmathvectoradd{\pgfplotspatchvertexcoords}{\pgfplotsretval}{default}%
+ \let\pgfplots@normal@vector=\pgfplotsretval
+ %
+ \draw[/pgfplots/every patch normal]
+ \pgfextra{%
+ \pgfpathmoveto
+ {%
+ \pgf@process{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{get num vertices}%
+ \pgfmath@basic@reciprocal@{\pgfplotsretval}%
+ \let\scale=\pgfmathresult
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchclass{\pgfplotspatchclassname}{foreach vertex}{%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchvertexstruct\times{\scale}%
+ }%
+ \pgfplotspatchvertexfinishXY{\pgfplots@loc@TMPa}%
+ \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex%
+ }%
+ }%
+ \edef\pgfplots@loc@TMPa{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfpathlineto{%
+ \pgfpointadd
+ {\pgfplots@loc@TMPa}
+ {\pgfplotspointfromcsvvector\pgfplots@normal@vector{default}}%
+ }%
+ }%
+ ;
+}%
+
+% Defines \pgfplotsretval to be either empty or the current point's
+% depth according to z buffer information.
+\def\pgfplotsplothandlermesh@compute@vertex@depth{\let\pgfplotsretval\pgfutil@empty}%
+
+% If \pgfplotsplothandlermesh@compute@vertex@depth is set to this
+% particular implementation, the \pgfplotspatchvertexdepth macro will
+% contain the view depth.
+%
+\def\pgfplotsplothandlermesh@compute@vertex@depth@doit{%
+ \ifx\pgfplots@current@point@x\pgfutil@empty
+ \let\pgfplotsretval\pgfutil@empty
+ \else
+ \pgfplotsmathvectorfromstring{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}{default}%
+ \pgfplotsmathvectorviewdepth{\pgfplotsretval}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfplotsretval}%
+ \edef\pgfplotsretval{\pgfmathresult}%
+ \fi
+}%
+
+% A command which defines \pgfplotsretval to be either empty or to
+% the (x,y,z) 3d coordinates of the data point. Usually, the data
+% scaling transformation will already be applied to these points.
+%
+% Note that this is unnecessary for most applications of mesh plots.
+%
+% The resulting value will be available as \pgfplotspatchvertexcoords
+\def\pgfplotsplothandlermesh@serialize@logical@coords{%
+ % empty by default
+ \let\pgfplotsretval=\pgfutil@empty
+}%
+\def\pgfplotsplothandlermesh@serialize@logical@coords@doit{%
+ \ifx\pgfplots@current@point@x\pgfutil@empty
+ \let\pgfplotsretval=\pgfutil@empty
+ \else
+ % note that these points are the result of the data scaling
+ % trafo. That is OK because the view normal is also in the
+ % same coordinate space.
+ \pgfplotsmathvectorfromstring{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}{default}%
+ \fi
+}
+
+% the inverse for \pgfplotsplothandlermesh@serialize@logical@coords: it defines \pgfplots@current@point@[xyz].
+% You should only call it if you know that there IS something to deserialize.
+\def\pgfplotsplothandlermesh@deserialize@logical@coords#1{%
+ \expandafter\pgfplotsplothandlermesh@deserialize@logical@coords@#1\relax
+}%
+\def\pgfplotsplothandlermesh@deserialize@logical@coords@#1,#2,#3\relax{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+}%
+
+% The patch visualization works like a PIPELINE:
+%
+% DECODE -> CHECK JUMP -> REFINE -> FINISH
+%
+% where FINISH is usually nothing but VISUALIZE; but it can also mean
+% to collect patches, sort them according to view depth and visualize
+% the result.
+%
+% Each single PIPE element can be exchanged by a separate "subclass".
+% For example, DECODE can either DECODE from a matrix (a lattice) or a
+% sequence of patch coords.
+%
+\def\pgfplotsplothandlermesh@stream#1{%
+ \pgfplotsplothandlermesh@PIPE@DECODE{#1}%
+}%
+
+% accumulates a patch vertex-by-vertex.
+% #1 the next vertex of a patch (#1 defines canvas coordinates \pgf@x
+% and \pgf@y).
+%
+% @PRECONDITION \pgfplots@current@point@[xyz] and \pgfplots@current@point@meta
+% need to be defined.
+\def\pgfplotsplothandlermesh@PIPE@DECODE#1{%
+ \let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
+ \pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval
+ \let\pgfplots@view@depth=\pgfplotsretval
+ \pgf@process{#1}%
+ % calls \pgfplotspatchready when ready
+ \pgfplotsplothandlermesh@serialize@logical@coords
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set next vertex}{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplots@view@depth:\pgfplotsretval}%%
+}%
+\def\pgfplotspatchready{%
+ \pgfplotsplothandlermesh@PIPE@CHECKJUMP
+}%
+\let\pgfplotspatchready@orig=\pgfplotspatchready
+\def\pgfplotsplothandlermesh@PIPE@CHECKJUMP{%
+ \pgfplots@loc@tmptrue
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{foreach vertex}{%
+ \pgfplotsplothandlermesh@check@unbounded%
+ }%
+ %
+ \ifpgfplots@loc@tmp
+ \pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta
+ \fi
+ %
+ \ifpgfplots@loc@tmp
+ \expandafter\pgfplotsplothandlermesh@PIPE@REFINE
+ \fi
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@noop{%
+}
+
+\let\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta=\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@noop
+
+\def\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@everyvertex{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{foreach cdata vertex}{%
+ \pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@check
+ }%
+}%
+\def\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@firstvertex{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{first vertex before z buffer}%
+ \pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@check
+}%
+\def\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@firstvertex@legacy{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{first vertex}%
+ \pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@check
+}%
+\def\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@check{%
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \pgfplotsifpointmetaisbounded{\pgfplotspatchvertexmeta}{}{%
+ \pgfplots@loc@tmpfalse
+ }%
+ \else
+ % mesh/color input=explicit
+ \ifx\pgfplotspatchvertexmeta\pgfutil@empty
+ \pgfplots@loc@tmpfalse
+ \fi
+ \fi
+}
+
+\def\pgfplotsplothandlermesh@PIPE@REFINE@no@op{%
+ \pgfplotsplothandlermesh@PIPE@FINISH
+}%
+\let\pgfplotsplothandlermesh@PIPE@REFINE=\pgfplotsplothandlermesh@PIPE@REFINE@no@op
+
+% invoked when a patch is completely processed.
+% This might be replaced by the z buffering algorithm
+\def\pgfplotsplothandlermesh@PIPE@FINISH{%
+ \pgfplotsplothandlermesh@PIPE@interior@exterior@styles
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@interior@exterior@styles{%
+ \pgfplotsplothandlermesh@interior@exterior@hook
+ \pgfplotsplothandlermesh@VISUALIZE
+}%
+
+% Standard implementation for VISUALIZE
+\def\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{fill path}%
+ \pgfplotsplothandlermesh@definecolor
+ \pgfplotsplothandlermesh@usepath
+ \pgfplotsplothandlermesh@show@normals@if@configured
+}%
+
+% a special VISUALIZE implementation which allows to draw a CONTINUOS
+% global path, i.e. one which is not "\pgfusepath"ed after each patch
+% segment. This is only used if 'point meta=none'
+\def\pgfplotsplothandlermesh@VISUALIZE@globalpath@fill@andor@stroke{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{fill path}%
+}%
+
+\def\pgfplotsplothandlermesh@VISUALIZE@std{\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke}
+
+\def\pgfplotsplothandlermesh@VISUALIZE{\pgfplotsplothandlermesh@VISUALIZE@std}
+
+\let\pgfplotsplothandlermesh@show@normals@if@configured\relax
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\pgfplotsplothandlermesh@init@DECODE{%
+ \if0\pgfplotsplothandlermesh@matrixinput
+%\message{initialised DECODE for patch output (from patch).^^J}%
+ \else
+ % mesh input=lattice|image
+ % Init memory:
+ %
+ % 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
+ \let\pgfplotsplothandlermesh@numscanlines=\pgfplotsplothandlermesh@rows
+ \else
+ % y varies (=colwise):
+ \let\pgfplotsplothandlermesh@scanlinelength=\pgfplotsplothandlermesh@rows
+ \let\pgfplotsplothandlermesh@numscanlines=\pgfplotsplothandlermesh@cols
+ \fi
+ %
+ \if1\pgfplotsplothandlermesh@ONEDIMMODE
+%\message{initialised DECODE for 1d mode.^^J}%
+ % FIXME : needs LUA support...
+ \if2\pgfplotsplothandlermesh@matrixinput
+ % mesh input=image
+ \pgfplots@error{'matrix input=image' is unsupported for line plots (or matrix plots with just 1 row or 1 column). Please provide at least 2 rows and 2 cols for 'matrix input=image'}%
+ \fi
+ \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@matrix@ONEDIMMODE
+ \else
+ \if0\b@pgfplotsplothandlermesh@matrixoutput
+ \if1\b@pgfplots@LUA@visualization@enabled
+%\message{initialised DECODE for patch output (from matrix which has already been decoded in LUA).^^J}%
+ \else
+ % in fact, this does only remember the maximum capacity;
+ % it doesn't fill the memory.
+ \c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
+ \advance\c@pgfplots@scanlineindex by1
+ \pgfplotsdequenewempty{lastscanline}\capacity{\the\c@pgfplots@scanlineindex}%
+ \if1\pgfplotsplothandlermesh@matrixinput
+ % mesh input=lattice
+ \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline
+%\message{initialised DECODE for patch output (from matrix).^^J}%
+ \else
+ % mesh input=image
+ % lastinterpscanline contains a line of
+ % interpolated points, and there is one more than points. Preallocate it:
+ \advance\c@pgfplots@scanlineindex by1
+ \pgfplotsdequenewempty{lastinterpscanline}\capacity{\the\c@pgfplots@scanlineindex}%
+ % NOTE: implementation is in a separate file.
+ \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@image@fillscanline
+%\message{initialised DECODE for IMAGE output (from matrix).^^J}%
+ \fi
+ \fi
+ \else
+ % SPECIAL HANDLING!
+ \if1\pgfplotsplothandlermesh@matrixinput
+ % mesh input=lattice
+ \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@to@shader
+ \else
+ % mesh input=image
+ % this should never happen because matrix output
+ % is off for mesh input=image
+ \pgfplots@error{Illegal internal state encountered}%
+ \fi
+%\message{initialised DECODE for direct matrix output (from matrix).^^J}%
+ \fi
+ \fi
+ \fi
+}%
+
+
+\def\pgfplotsplothandlermesh@PIPE@REFINE@triangulate{%
+ \let\pgfplotspatchready\pgfplotsplothandlermesh@PIPE@FINISH
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{triangulate}%
+ \let\pgfplotspatchready\pgfplotspatchready@orig
+}%
+\def\pgfplotsplothandlermesh@PIPE@REFINE@recursively{%
+ \let\pgfplotspatchready\pgfplotsplothandlermesh@PIPE@FINISH
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{refine}{\pgfplotsplothandlermesh@refinecount}%
+ \let\pgfplotspatchready\pgfplotspatchready@orig
+}%
+\def\pgfplotsplothandlermesh@PIPE@REFINE@triangulate@recursively{%
+ \let\pgfplotspatchready=\pgfplotsplothandlermesh@PIPE@REFINE@triangulate@recursively@patchready
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{refine}{\pgfplotsplothandlermesh@refinecount}%
+ \let\pgfplotspatchready\pgfplotspatchready@orig
+}%
+\def\pgfplotsplothandlermesh@PIPE@REFINE@triangulate@recursively@patchready{%
+ \let\pgfplotspatchready\pgfplotsplothandlermesh@PIPE@FINISH
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{triangulate}%
+ \let\pgfplotspatchready\pgfplotsplothandlermesh@PIPE@REFINE@triangulate@recursively@patchready
+}%
+\def\pgfplotsplothandlermesh@init@REFINE{%
+ \pgfkeysgetvalue{/pgfplots/patch refines}\pgfplotsplothandlermesh@refinecount
+ \if0\pgfplotsplothandlermesh@triangulate
+ \ifnum\pgfplotsplothandlermesh@refinecount>0
+%\message{initiased REFINE to REFINE.}%
+ \let\pgfplotsplothandlermesh@PIPE@REFINE=\pgfplotsplothandlermesh@PIPE@REFINE@recursively
+ \else
+%\message{initiased REFINE to NOP.}%
+ \let\pgfplotsplothandlermesh@PIPE@REFINE=\pgfplotsplothandlermesh@PIPE@REFINE@no@op
+ \fi
+ \else
+%\message{initiased REFINE to triangulate.}%
+ \ifnum\pgfplotsplothandlermesh@refinecount>0
+ \let\pgfplotsplothandlermesh@PIPE@REFINE=\pgfplotsplothandlermesh@PIPE@REFINE@triangulate@recursively
+ \else
+ \let\pgfplotsplothandlermesh@PIPE@REFINE=\pgfplotsplothandlermesh@PIPE@REFINE@triangulate
+ \fi
+ \fi
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% MESH SURVEY
+\def\pgfplotsplothandlersurveystart@mesh{%
+ \pgfplotsplothandlersurveystart@default
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \else
+ % mesh/color input=explicit
+ \if1\pgfplotsplothandlermesh@colorinput@mathparse
+ \pgfkeysdef{/pgfplots/color sequence/every input component}{%
+ \expandafter\pgfmathparse\expandafter{\pgfmathresult}%
+ \ifpgfplots@usefpu
+ \pgfmathfloattofixed\pgfmathresult
+ \fi
+ }%
+ \else
+ \pgfkeysdef{/pgfplots/color sequence/every input component}{}%
+ \fi
+ \pgfplotscolornormalizesequence[
+ colorspace=\pgfkeysvalueof{/pgfplots/mesh/colorspace explicit color output},
+ default input colorspace=\pgfkeysvalueof{/pgfplots/mesh/colorspace explicit color input},
+ context message={point meta '\pgfplots@current@point@meta' of coord no \the\c@pgfplots@coordindex\space (\pgfplots@current@point@x,\pgfplots@current@point@y\ifpgfplots@curplot@threedim,\pgfplots@current@point@z\fi)},
+ ]%
+ \fi
+ %
+ \if2\pgfplotsplothandlermesh@matrixinput
+ % mesh input=image
+ \pgfplotsplothandlersurveystart@mesh@image
+ \pgfplotsplothandlermesh@needs@scanlinecomplete@notificationstrue
+ \fi
+ %
+ \pgfplotsplothandlersurveypoint@mesh@check@scanline@length@init
+}%
+
+\def\pgfplotsplothandlersurveypoint@mesh{%
+ \pgfplotsplothandlersurveypoint@default
+ %
+ \pgfplotsplothandlersurveypoint@mesh@common
+}
+
+\def\pgfplotsplothandlersurveypoint@mesh@common{%
+ \if2\pgfplotsplothandlermesh@matrixinput
+ \pgfplotsplothandlersurveypoint@mesh@image
+ \fi
+ %
+ \ifcase\pgfplotsplothandlermesh@matrixinput
+ \else
+ % mesh input=lattice|image
+ \pgfplotsplothandlersurveypoint@mesh@check@scanline@length
+ \fi
+}%
+
+\def\pgfplotsplothandlersurveypoint@pseudoconstant@row@index{%
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = x varies= rowwise -> scanline is cols!
+ \else
+ % ordering = y varies = colwise: scanline is rows!
+ \ifx\pgfplotsplothandlermesh@rows\pgfutil@empty
+ \fi
+}%
+
+% initializes \pgfplotsplothandlersurveypoint@mesh@check@scanline@length, see its comments.
+\def\pgfplotsplothandlersurveypoint@mesh@check@scanline@length@init{%
+ \pgfkeysgetvalue{/pgfplots/empty line}\pgfplots@loc@TMPa%
+ \def\pgfplots@loc@TMPb{scanline}
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \else
+ % without end-of-scanline markers, the notification
+ % \pgfplotsscanlinecomplete does not make sense anyway in this
+ % context. Disable it:
+ \let\pgfplotsplothandlersurveypoint@mesh@check@scanline@length=\relax
+ \fi
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = x varies= rowwise -> scanline is cols!
+ \ifx\pgfplotsplothandlermesh@cols\pgfutil@empty
+ % ... and without columns, we cannot generate the notification.
+ \let\pgfplotsplothandlersurveypoint@mesh@check@scanline@length=\relax
+ \fi
+ \else
+ % ordering = y varies = colwise: scanline is rows!
+ \ifx\pgfplotsplothandlermesh@rows\pgfutil@empty
+ % ... and without rows, we cannot generate the notification.
+ \let\pgfplotsplothandlersurveypoint@mesh@check@scanline@length=\relax
+ \fi
+ \fi
+}
+
+% Invokes \pgfplotsscanlinecomplete if the scanline is complete according to the keys 'mesh/rows' and/or 'mesh/cols'
+%
+% This routine improves the precision of the scanline computation, but not much.
+% At the time of this writing, its only purpose is to help 'matrix input=image'
+% as that requires information about the current scanline in order to update its
+% axis limits.
+%
+% Note that this macro is unnecessary in many cases: if the user input _contains_ end-of-scanline markers, it is redundant.
+%
+% Limitations of this routine:
+% 1. it requires 'empty line=scanline'.
+% 2. if mesh/ordering=x varies, it requires that mesh/cols is set.
+% if mesh/ordering=y varies, it requires that mesh/rows is set.
+%
+% In all other cases, it simply becomes a no-op without further notice (i.e. it will be \let to \relax)
+\def\pgfplotsplothandlersurveypoint@mesh@check@scanline@length{%
+%\message{checking scanline length for \the\c@pgfplots@scanlineindex. cols=\pgfplotsplothandlermesh@cols, rows=\pgfplotsplothandlermesh@rows. ordering = \pgfplots@plot@mesh@ordering^^J}%
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = x varies= rowwise -> scanline is cols!
+ \ifnum\pgfplotsplothandlermesh@cols=\c@pgfplots@scanlineindex\relax
+ % it does not hurt to invoke this here multiple times -- it has to handle that case anyway:
+ \pgfplotsscanlinecomplete
+ \fi
+ \else
+ % ordering = y varies = colwise: scanline is rows!
+ \ifnum\pgfplotsplothandlermesh@rows=\c@pgfplots@scanlineindex\relax
+ % it does not hurt to invoke this here multiple times -- it has to handle that case anyway:
+ \pgfplotsscanlinecomplete
+ \fi
+ \fi
+}%
+
+\def\pgfplotsplothandlersurveypoint@mesh@noreset@of@pointmeta{%
+ \pgfplotsplothandlersurveypoint@default@noreset@of@pointmeta
+ \pgfplotsplothandlersurveypoint@mesh@common
+}%
+
+\newif\ifpgfplotsplothandlermesh@needs@scanlinecomplete@notifications
+
+\def\pgfplotsplothandlersurveyend@mesh{%
+ \pgfplotsplothandlersurveyend@default
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \else
+ % mesh/color input=explicit
+ \endpgfplotscolornormalizesequence
+ \fi
+ %
+ \if2\pgfplotsplothandlermesh@matrixinput
+ % mesh input=image
+ \pgfplotsplothandlersurveyend@mesh@image
+ \fi
+ %
+ \ifpgfplotsplothandlermesh@needs@scanlinecomplete@notifications
+ %
+ % OK, we EXPECT that the code generated
+ % notifications of sorts \pgfplotsscanlinecomplete.
+ %
+ % If this turns out to be NOT the case, we generate a
+ % warning/error.
+ %
+ % This, in turn, is restricted to the following cases:
+ % 1. there have been end-of-scanline markers in the input
+ % stream (that's why we can only decide it here, after the
+ % input has been surveyed)
+ % 2. OR \pgfplotsscanlinecomplete has been called due to scan
+ % line length comparison with mesh/cols or mesh/rows. In this
+ % case, the required argument must have been set, see
+ % \pgfplotsplothandlersurveypoint@mesh@check@scanline@length@init
+ %
+ \ifnum\c@pgfplotsplothandlermesh@image@numscanlines<2
+ \pgfplotsautocompletemeshkeys%
+ \ifx\pgfplotsplothandlersurveypoint@mesh@check@scanline@length\relax
+ % ah -- this routine has been cleared because the keys are
+ % missing.
+ %
+ % Please see the comments on
+ % \pgfplotsplothandlersurveypoint@mesh@check@scanline@length
+ % for details.
+ %
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = x varies= rowwise -> scanline is cols!
+ \pgfplotswarning{imagesc limits incomplete}{mesh/cols=\pgfplotsplothandlermesh@cols}\pgfeov%
+ \else
+ % ordering = y varies = colwise: scanline is rows!
+ \pgfplotswarning{imagesc limits incomplete}{mesh/rows=\pgfplotsplothandlermesh@rows}\pgfeov%
+ \fi
+ \fi
+ \fi
+ \fi
+ %
+}
+
+\def\pgfplotsplothandlersurvey@mesh@scanlinecomplete{%
+ %
+ %
+ \if2\pgfplotsplothandlermesh@matrixinput
+ % mesh input=image
+ \pgfplotsplothandlersurveyend@mesh@image@scanlinecomplete
+ \fi
+}%
+
+\def\pgfplotsplothandlersurveyaftersetpointmeta@mesh@cdatanormalize{%
+ \pgfplotsplothandlersurveyaftersetpointmeta@default
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \else
+ % mesh/color input=explicit
+ \pgfplotscolornormalizesequencenext{\pgfplots@current@point@meta}%
+ \let\pgfplots@current@point@meta=\pgfplotsretval
+ \fi
+}%
+
+\newif\ifpgfplotsplothandlermesh@patchtable@hascdata
+\newif\ifpgfplotsplothandlermesh@patchtable@cdata@individual
+\def\pgfplotsplothandlersurveystart@mesh@patchtable{%
+ \pgfplotsplothandlersurveystart@mesh
+ \pgfplotsarraynewempty\pgfplots@verts
+}%
+\def\pgfplotsplothandlersurveypoint@mesh@patchtable{%
+ \pgfplotscoordmath{x}{parsenumber}{\pgfplots@current@point@x}%
+ \let\pgfplots@current@point@x=\pgfmathresult
+ %
+ \pgfplotscoordmath{y}{parsenumber}{\pgfplots@current@point@y}%
+ \let\pgfplots@current@point@y=\pgfmathresult
+ %
+ \ifpgfplots@curplot@threedim
+ \pgfplotscoordmath{z}{parsenumber}{\pgfplots@current@point@z}%
+ \let\pgfplots@current@point@z=\pgfmathresult
+ \fi
+ %
+ \ifpgfplotsplothandlermesh@patchtable@hascdata
+ % will be handled later, using data from within 'patch table':
+ \let\pgfplots@current@point@meta=\pgfutil@empty
+ \else
+ \pgfplotsaxissurveysetpointmeta
+ \fi
+ %
+ \def\pgfplots@loc@TMPa{1}%
+ \ifx\pgfplots@current@point@x\pgfutil@empty
+ \def\pgfplots@loc@TMPa{0}%
+ \else
+ \ifx\pgfplots@current@point@y\pgfutil@empty
+ \def\pgfplots@loc@TMPa{0}%
+ \else
+ \ifx\pgfplots@current@point@z\pgfutil@empty
+ \ifpgfplots@curplot@threedim
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \if1\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z;\pgfplots@current@point@meta;}%
+ \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPa\to\pgfplots@verts
+ \fi
+}%
+\def\pgfplotsplothandlersurveyend@mesh@patchtable{%
+ \pgfplotsplothandlersurveyend@mesh
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@default
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@default
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@mesh@noreset@of@pointmeta
+ \pgfplotsplothandlersurveystart
+ \expandafter\pgfplotstable@isloadedtable\expandafter{\pgfplotsplothandlermesh@patchtable}{%
+ \pgfplots@error{Sorry, 'patch table={<loaded table>}' has not been implemented; it would probably be too slow :-(. Please provide a file name or inline table data}%
+ }{%
+ \expandafter\pgfplotstableread\expandafter*\expandafter{\pgfplotsplothandlermesh@patchtable} to listener\pgfplotsplothandlermesh@patchtable@rowlistener
+ }%
+ \pgfplotsplothandlersurveyend
+}%
+
+\def\pgfplotsplothandlermesh@patchtable@init{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{get num vertices}%
+ \let\pgfplotsplothandlermesh@patchtable@numverts=\pgfplotsretval
+ %
+ \ifpgfplotsplothandlermesh@patchtable@hascdata
+ \ifpgfplotsplothandlermesh@patchtable@cdata@individual
+ \else
+ \ifnum\pgfplotsplothandlermesh@patchtable@numverts<\pgfplotstablecols\relax
+ % prepare a pointer to data column: use the column
+ % after the last vertex index.
+ % this thing constitutes the "default" cdata source for
+ % 'point meta=explicit'.
+ \pgfplotstablereadgetptrtocolindex
+ {\pgfplotsplothandlermesh@patchtable@numverts}
+ {\pgfplots@table@PTR@CDATA}%
+ \else
+ \let\pgfplots@table@PTR@CDATA=\relax
+ \fi
+ \fi
+ \else
+ \pgfplotsplothandlermesh@patchtable@cdata@individualfalse
+ \fi
+ %
+ \c@pgf@countb=0
+ \pgfutil@loop
+ \ifnum\c@pgf@countb<\pgfplotsplothandlermesh@patchtable@numverts\relax
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplotstablereadgetptrtocolindex{\the\c@pgf@countb}{\expandafter\noexpand\csname pgfplots@table@PTR@\the\c@pgf@countb\endcsname}%
+ }%
+ \pgfplots@loc@TMPa
+ \advance\c@pgf@countb by1
+ \pgfutil@repeat
+ \let\pgfplotsplothandlermesh@patchtable@init=\relax
+}%
+\def\pgfplotsplothandlermesh@patchtable@rowlistener@exceptionmsg{%
+ patch table \pgfplotsplothandlermesh@patchtable\space line \pgfplotstablelineno: could not read column no \the\c@pgf@countb: expected '\pgfplots@current@vertexindex' to be a valid index into the vertex arrays (the \pgfplotsarraysizeof\pgfplots@verts\space input coordinates)%
+}%
+\def\pgfplotsplothandlermesh@patchtable@rowlistener{%
+ \pgfplotsplothandlermesh@patchtable@init%
+ %
+ \ifpgfplotsplothandlermesh@patchtable@hascdata
+ \ifpgfplotsplothandlermesh@patchtable@cdata@individual
+ \else
+ \ifx\pgfplots@table@PTR@CDATA\relax
+ \let\pgfplots@current@point@meta=\pgfutil@empty
+ \else
+ \pgfplotstablereadevalptr\pgfplots@table@PTR@CDATA\pgfplots@current@point@meta
+ \fi
+ \fi
+ \fi
+ %
+ \c@pgf@countb=0
+ \pgfutil@loop
+ \ifnum\c@pgf@countb<\pgfplotsplothandlermesh@patchtable@numverts\relax
+ \expandafter\pgfplotstablereadevalptr\csname pgfplots@table@PTR@\the\c@pgf@countb\endcsname\pgfplots@current@vertexindex%
+ %
+ \ifx\pgfplots@current@vertexindex\pgfutil@empty
+ \else
+ \pgfmathfloatparsenumber{\pgfplots@current@vertexindex}%
+ \pgfmathfloattoint\pgfmathresult
+ \let\pgfplots@current@vertexindex=\pgfmathresult
+ %
+ \let\pgfplotsexceptionmsg=\pgfplotsplothandlermesh@patchtable@rowlistener@exceptionmsg
+ \pgfplotsarrayselect\pgfplots@current@vertexindex\of\pgfplots@verts\to\pgfplots@stored@pt
+ \let\pgfplotsexceptionmsg=\relax
+ %
+ \ifpgfplotsplothandlermesh@patchtable@cdata@individual
+ \c@pgf@countc=\c@pgf@countb\relax
+ \advance\c@pgf@countc by\pgfplotsplothandlermesh@patchtable@numverts\relax
+ \expandafter\getthisrowno\expandafter{\the\c@pgf@countc}\pgfplots@current@point@meta
+ \fi
+ %
+ \expandafter\pgfplotsplothandlermesh@patchtable@stream\pgfplots@stored@pt
+ \fi
+ \advance\c@pgf@countb by1
+ \pgfutil@repeat
+}
+\def\pgfplotsplothandlermesh@patchtable@stream#1,#2,#3;#4;{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+ \ifpgfplotsplothandlermesh@patchtable@hascdata
+ \def\pgfplots@set@perpointmeta@done{0}%
+ \pgfplotsaxissurveysetpointmeta
+ \else
+ \def\pgfplots@current@point@meta{#4}%
+ \fi
+ \pgfplotsplothandlersurveypoint
+}%
+% MESH SURVEY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\pgfplotsplothandlermesh@init@meshkeys{%
+ \ifcase\pgfplotsplothandlermesh@matrixinput\relax
+ % mesh input=patches
+ \pgfkeys{/pgfplots/mesh/ordering/x varies}% disable any special handling.
+ \else
+ % mesh input=lattice|image
+ \pgfplotsautocompletemeshkeys%
+ \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsplothandlermesh@rows
+ \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsplothandlermesh@cols
+ \pgfkeysgetvalue{/pgfplots/mesh/num points}\pgfplotsplothandlermesh@numpoints
+ %
+ % the \pgfplotsplothandlermesh@ONEDIMMODE macro is ONLY
+ % interesting for matrix input.
+ \ifnum\pgfplotsplothandlermesh@cols>1
+ \else
+ \def\pgfplotsplothandlermesh@ONEDIMMODE{1}%
+ \fi
+ \ifnum\pgfplotsplothandlermesh@rows>1
+ \else
+ \def\pgfplotsplothandlermesh@ONEDIMMODE{1}%
+ \fi
+ \if1\pgfplotsplothandlermesh@ONEDIMMODE
+ \def\pgfplotsplothandlermesh@patchclass{line}%
+ \pgfkeyslet{/pgfplots/patch type}\pgfplotsplothandlermesh@patchclass
+ \fi
+ \fi
+ %
+ \pgfplotspatchclass{\pgfkeysvalueof{/pgfplots/patch type}}{get dimension}%
+ \ifnum\pgfplotsretval=1 %
+ \def\pgfplots@meshmode{m}% mesh.
+ \fi
+ %
+}%
+
+\let\pgfplotsplothandlermesh@interior@exterior@hook=\relax
+\def\pgfplotsplothandlermesh@interior@exterior@hook@active@zerothresh{%
+ \begingroup
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{compute normal}%
+% \let\pgfplots@normal=\pgfplotsretval
+% \pgfplotsmathvectorlength{\pgfplotsretval}{default}%
+% \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplotsretval}}%
+% \pgfplotsmathvectorscale{\pgfplots@normal}{\pgfmathresult}{default}%
+ %
+ \pgfplotsmathvectorscalarproduct{\pgfplots@view@dir@threedim}{\pgfplotsretval}{default}%
+ \pgfplotscoordmath{default}{if is}{\pgfplotsretval}{-}{%
+ % <0:
+ \global\let\pgfplots@glob@TMPc\pgfplotsplothandlermesh@is@interior
+ }{%
+ % >=0:
+ \global\let\pgfplots@glob@TMPc\pgfplotsplothandlermesh@is@exterior
+ }%
+ \endgroup
+ \pgfplots@glob@TMPc
+}%
+
+\def\pgfplotsplothandlermesh@interior@exterior@hook@active{%
+ \begingroup
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{compute normal}%
+ \let\pgfplots@normal=\pgfplotsretval
+ \pgfplotsmathvectorlength{\pgfplotsretval}{default}%
+ \let\pgfplots@normal@len=\pgfplotsretval
+ %
+ \pgfplotsmathvectorscalarproduct{\pgfplots@view@dir@threedim}{\pgfplots@normal}{default}%
+ \let\pgfplots@dot=\pgfplotsretval
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@view@dir@threedim@len}{\pgfplots@normal@len}}%
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfplots@dot}{\pgfmathresult}}%
+
+ \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplotsplothandlermesh@interior@thresh}{%
+ % <0:
+ \global\let\pgfplots@glob@TMPc\pgfplotsplothandlermesh@is@interior
+ }{%
+ % >=0:
+ \global\let\pgfplots@glob@TMPc\pgfplotsplothandlermesh@is@exterior
+ }%
+ \endgroup
+ \pgfplots@glob@TMPc
+}%
+
+
+% only used if
+% \pgfplotsplothandlermesh@interior@exterior@hook@active is
+% active
+\def\pgfplotsplothandlermesh@is@interior{%
+%\def\pgfplotsplothandlermesh@usepath{\pgfusepath{discard}}%
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplotsplothandlermesh@colormapname@interior
+ \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsplothandlermesh@shader@colormap@interior
+}%
+\def\pgfplotsplothandlermesh@is@exterior{%
+%\let\pgfplotsplothandlermesh@usepath=\pgfplotsplothandlermeshusepathfillstroke
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplotsplothandlermesh@colormapname
+ \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsplothandlermesh@shader@colormap
+}%
+
+\def\pgfplotsplothandlermesh@init@cdata{%
+ % Ok, we have color data.
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsplothandlermesh@colormapname
+ %
+ %
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \pgfplotscolormapgetcolorcomps{\pgfplotsplothandlermesh@colormapname}%
+ \let\pgfplotsplothandlermesh@explicit@color@num@comps=\pgfplotsretval
+ \else
+ % mesh/color input=explicit
+ \pgfkeysgetvalue{/pgfplots/mesh/colorspace explicit color output}\pgfplots@loc@TMPa
+ \pgfplotscolorspacegetcomponents{\pgfplots@loc@TMPa}%
+ \let\pgfplotsplothandlermesh@explicit@color@num@comps=\pgfplotsretval
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/mesh/interior colormap name}\pgfplotsplothandlermesh@colormapname@interior
+ \ifx\pgfplotsplothandlermesh@colormapname@interior\pgfutil@empty
+ \else
+ \pgfkeysgetvalue{/pgfplots/mesh/interior colormap thresh}\pgfplotsplothandlermesh@interior@thresh
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplotsplothandlermesh@interior@thresh}%
+ \let\pgfplotsplothandlermesh@interior@thresh=\pgfmathresult
+ \pgfplotscoordmath{default}{if is}{\pgfplotsplothandlermesh@interior@thresh}{0}{%
+ \let\pgfplotsplothandlermesh@interior@exterior@hook=\pgfplotsplothandlermesh@interior@exterior@hook@active@zerothresh
+ }{%
+ \pgfplotsmathvectorlength{\pgfplots@view@dir@threedim}{default}% should be 1, but never mind
+ \let\pgfplots@view@dir@threedim@len=\pgfplotsretval
+ \let\pgfplotsplothandlermesh@interior@exterior@hook=\pgfplotsplothandlermesh@interior@exterior@hook@active
+ }%
+ % actually store 3d coordinates:
+ \let\pgfplotsplothandlermesh@serialize@logical@coords=\pgfplotsplothandlermesh@serialize@logical@coords@doit
+ \fi
+ %
+ % Prepare:
+ \def\pgfplotsplothandlermesh@definecolor{%
+ % FIXME : use lua backend to improve this here! it is
+ % _extremely_ slow!
+ \pgfplotsplothandlermesh@get@flat@color
+ \pgfplotsplothandlermesh@definemappedcolor{\pgfplotsretval}%
+ \pgfplots@drawoptions
+ }%
+ %
+ % Acquire the values for \tikz@mode@* [used for faceted]
+ \pgfplots@drawmodes
+}
+
+\def\pgfplotsplothandlermesh@definemappedcolor#1{%
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \if d\pgfplots@colormap@access
+ % colormap access=direct
+ % we assume that the color *is* already normalized,
+ % i.e. it is {<comma-separate-components>} and to be
+ % interpreted in the correct color space.
+ \edef\pgfplots@loc@TMPb{%
+ \noexpand\pgfutil@definecolor{mapped color}
+ {\pgfplotscolormapcolorspaceof{\pgfplotsplothandlermesh@colormapname}}%
+ {#1}%
+ }%
+ \pgfplots@loc@TMPb
+ \else
+ % colormap access=map|piecewise constant
+ \pgfplotscolormapdefinemappedcolor{#1}%
+ \fi
+ \else
+ % mesh/color input=explicit
+ %
+ % we assume that the color *is* already normalized,
+ % i.e. it is {<comma-separate-components>} and to be
+ % interpreted in the correct color space.
+ \edef\pgfplots@loc@TMPb{%
+ \noexpand\pgfutil@definecolor{mapped color}
+ {\pgfkeysvalueof{/pgfplots/mesh/colorspace explicit color output}}
+ {#1}%
+ }%
+ \pgfplots@loc@TMPb
+ \fi
+}%
+
+\let\pgfsetstrokecolor@orig=\pgfsetstrokecolor
+\def\pgfplotsplothandlermesh@VISUALIZE@std@separate@fillstroke@setstrokecolor#1{%
+ \pgfsetstrokecolor@orig{.}%
+}%
+\def\pgfplotsplothandlermesh@VISUALIZE@std@separate@fillstroke{%
+ \pgfplotsplothandlermesh@get@flat@color
+ \pgfplotsplothandlermesh@definemappedcolor{\pgfplotsretval}%
+ %
+ \ifx\pgfplotsplothandlermesh@usepathfill\relax
+ \else
+ \let\pgfsetstrokecolor=\pgfplotsplothandlermesh@VISUALIZE@std@separate@fillstroke@setstrokecolor
+ \pgfplots@drawoptions
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{fill path}%
+ \pgfplotsplothandlermesh@usepathfill
+ \fi
+ \ifx\pgfplotsplothandlermesh@usepathstroke\relax
+ \else
+ \let\pgfsetstrokecolor=\pgfsetstrokecolor@orig
+ \pgfplots@drawoptions
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{stroke path}%
+ \pgfplotsplothandlermesh@usepathstroke
+ \fi
+}%
+
+% This is one of two places where shadings are served with
+% coordinates; the other one uses matrix output (which does not work
+% with 'stream to shader')
+\def\pgfplotsplothandlermesh@VISUALIZE@interp{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{stream to shader}%
+ \ifpgf@relevantforpicturesize
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{foreach vertex}{%
+ \global\pgf@x=\pgfplotspatchvertexx\space
+ \global\pgf@y=\pgfplotspatchvertexy\space
+ % compute the bounding box using the vertices:
+ \pgfpointtransformed{}%
+ \pgf@protocolsizes{\pgf@x}{\pgf@y}%
+ }%
+ \fi
+}%
+
+\def\pgfplotsplothandlermesh@VISUALIZE@faceted@interp{%
+ \pgfplotslibrarysurfstreamstart
+ \pgfplotsplothandlermesh@VISUALIZE@interp
+ \pgfplotslibrarysurfstreamend
+ \pgfplotslibrarysurfdrawinpicture
+ %
+ \pgfplotsplothandlermesh@VISUALIZE@std
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@CHECKJUMP@disable{%
+ \def\pgfplotsplothandlermesh@PIPE@CHECKJUMP{\pgfplotsplothandlermesh@PIPE@REFINE}%
+}%
+
+\def\pgfplotsplothandlermesh@init@shader{%
+ %
+ \ifnum\pgfplotsplothandlermesh@shader>1
+ % 'shader=2': 'interp':
+ % very simple: defer work to surf library. Only
+ % provide the mapped colordata.
+ %
+ % 'shader=3': 'faceted interp':
+ % a mix of 'faceted' and 'interp'. (might be inefficient in
+ % terms of pdf memory and rendering times)
+ %
+ % This won't be used for mesh plots, neither in one
+ % nor in two dimensions.
+ \pgfkeyssetvalue{/pgfplots/surf shading/anchor}{\pgfpointorigin}%
+ %
+ % do NOT update the picture's BB using the streamed low-level coordinates
+ % (which are bezier control points in most cases).
+ % We do that on our own using the input vertices.
+ \pgfkeys{/pgfplots/surf shading/update BB=false}%
+ \if1\b@pgfplotsplothandlermesh@matrixoutput
+ % this *implies* a compatible patch class, see the
+ % definition of \b@pgfplotsplothandlermesh@matrixoutput
+ \def\pgfplotsretval{5}%
+ \else
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{get pdf shading type}%
+ \if5\pgfplotsretval
+ % we have no matrix output->
+ % downgrade lattice triangular grid to individual
+ % triangles:
+ \def\pgfplotsretval{4}%
+ \fi
+ \fi
+ \pgfkeyslet{/pgfplots/surf shading/shading type}\pgfplotsretval%
+ %
+ \pgfplotsplothandlermesh@set@shader@colormap
+ \pgfkeysgetvalue{/pgfplots/mesh/interior colormap name}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \let\pgfplotsplothandlermesh@shader@colormap=\pgfplotsretval
+ \begingroup
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplots@loc@TMPa
+ \pgfplotsplothandlermesh@set@shader@colormap
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ \let\pgfplotsplothandlermesh@shader@colormap@interior=\pgfplotsretval
+ \fi
+ %
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa
+ \pgfplotscolormapgetcolorspace\pgfplots@loc@TMPa
+ \pgfkeyslet{/pgfplots/surf shading/colorspace}\pgfplotsretval
+ \else
+ % mesh/color input=explicit
+ \pgfkeysgetvalue{/pgfplots/mesh/colorspace explicit color output}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \pgfkeyslet{/pgfplots/surf shading/colorspace}\pgfplots@loc@TMPa
+ \fi
+ \if2\pgfplotsplothandlermesh@shader
+ % shader=interp
+ \let\pgfplotsplothandlermesh@definecolor=\relax
+ \let\pgfplotsplothandlermesh@VISUALIZE=\pgfplotsplothandlermesh@VISUALIZE@interp%
+ \pgfkeyslet{/pgfplots/surf shading/cols}\pgfplotsplothandlermesh@scanlinelength
+ %\if1\b@pgfplotsplothandlermesh@matrixoutput
+ \iffalse% FIXME : is this special handling necessary!?
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering=x varies:
+ % nothing special to do
+ \else
+ % FIXME
+ % [this happens only for mesh input=lattice]
+ % 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.
+ \let\pgfplotsplothandlermesh@shader@interp=\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
+ \fi
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{init pdf shading}%
+ \pgfplotslibrarysurfstreamstart
+ \else
+ % shader='faceted interp'
+ \def\pgfplotsplothandlermesh@VISUALIZE{\pgfplotsplothandlermesh@VISUALIZE@faceted@interp}%
+ \pgfkeyssetvalue{/pgfplots/surf shading/cols}{2}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{init pdf shading}%
+ \fi
+ \else
+ \def\pgfplotsplothandlermesh@VISUALIZE{\pgfplotsplothandlermesh@VISUALIZE@std}%
+ \fi
+ %
+ %%
+ \ifpgfplotsplothandlermesh@internaldepth
+ \else
+ % disable internal sorting.
+ \let\pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth=\pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth@no@op%
+ \let\pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth=\pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth@no@op
+ \fi
+}%
+
+\def\pgfplotsplothandlermesh@init@flat@color{%
+ \ifcase\pgfplotsplothandlermesh@shader
+ % 0 == 'flat'
+ \def\pgfplotsplothandlermesh@needs@flat@color{1}%
+ \or
+ % 1 == 'faceted'
+ \def\pgfplotsplothandlermesh@needs@flat@color{1}%
+ \or
+ % 2 == 'interp'
+ \def\pgfplotsplothandlermesh@needs@flat@color{0}%
+ \or
+ % 3 == 'faceted interp'
+ \def\pgfplotsplothandlermesh@needs@flat@color{1}%
+ \fi
+ \if1\pgfplotsplothandlermesh@needs@flat@color
+ \pgfplotsplothandlermesh@init@flat@color@getter
+ %
+ \pgfplotsplothandlermesh@init@flat@color@usepath
+ %
+ %
+ \pgfplotsplothandlermesh@init@flat@color@visualize@pipe@step
+ \fi
+}%
+
+\def\pgfplotsplothandlermeshusepathstroke{\pgfusepathqstroke}%
+\def\pgfplotsplothandlermeshusepathfill{\pgfusepathqfill}%
+\def\pgfplotsplothandlermeshusepathfillstroke{\pgfusepathqfillstroke}%
+
+\def\pgfplotsplothandlermesh@init@flat@color@visualize@pipe@step{%
+ \ifx\pgfplotsplothandlermesh@PIPE@REFINE\pgfplotsplothandlermesh@PIPE@REFINE@no@op
+ \let\pgfplotsplothandlermesh@VISUALIZE@std=\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke
+ \else
+ \ifpgfplotsplothandlermesh@hide@refined@edges
+ % this is (at most) partially implemented.
+ \let\pgfplotsplothandlermesh@VISUALIZE@std=\pgfplotsplothandlermesh@VISUALIZE@std@separate@fillstroke
+ \else
+ \let\pgfplotsplothandlermesh@VISUALIZE@std=\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke
+ \fi
+ %
+ % FIXME : that doesn't work.
+ % filling *always* seems to need a stroke operation,
+ % otherwise there will be translucent edges.
+ % I need to adjust the stroke color :-(
+ %
+ % FIXME : even that doesn't work correctly. The problem
+ % is: drawing adjacent patches on top of each other
+ % OVERDRAWS edges: once with the correct stroke color;
+ % once with the fill color.
+ %
+ \ifx\pgfplotsplothandlermesh@usepath\pgfplotsplothandlermeshusepathstroke
+ \let\pgfplotsplothandlermesh@usepathfill=\relax
+ \let\pgfplotsplothandlermesh@usepathstroke=\plotsplothandlermeshusepathstroke
+ \else
+ \ifx\pgfplotsplothandlermesh@usepath\pgfplotsplothandlermeshusepathfillstroke
+ \let\pgfplotsplothandlermesh@usepathfill=\pgfplotsplothandlermeshusepathfillstroke
+ \let\pgfplotsplothandlermesh@usepathstroke=\pgfplotsplothandlermeshusepathstroke
+ \else
+ \let\pgfplotsplothandlermesh@usepathfill=\relax
+ \let\pgfplotsplothandlermesh@usepathstroke=\relax
+ \fi
+ \fi
+ \fi
+}%
+
+\def\pgfplotsplothandlermesh@init@flat@color@usepath{%
+ \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=\pgfplotsplothandlermeshusepathstroke
+ \else
+ % 'surf' plot:
+ \let\pgfplotsplothandlermesh@usepath=\pgfplotsplothandlermeshusepathfillstroke
+ \if\pgfplotsplothandlermesh@shader3% faceted interp
+ % it has an extra fill command (shading)
+ \let\pgfplotsplothandlermesh@usepath=\pgfplotsplothandlermeshusepathstroke
+ \fi
+ %
+ % the distinction between 'faceted' and 'flat' is
+ % technical: it is just the default draw color.
+ %
+ % 'flat,draw=black' is the same as 'faceted'.
+ \pgfkeysgetvalue{/pgfplots/faceted color}\pgfplots@loc@TMPb
+ \def\pgfplots@loc@TMPc{none}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPc
+ \pgfkeyslet{/pgfplots/faceted color}\pgfutil@empty
+ \def\pgfplots@loc@TMPb{}%
+ \fi
+ %
+ \def\pgfplots@loc@TMPa{0}%
+ \if\pgfplotsplothandlermesh@shader1% faceted
+ \def\pgfplots@loc@TMPa{1}%
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ % oh. no faceted color. Then: fill only, use
+ % whatever color is available.
+ \def\pgfplots@loc@TMPa{0}%
+ %\let\pgfplotsplothandlermesh@usepath=\pgfplotsplothandlermeshusepathfill
+ \fi
+ \fi
+ \if\pgfplotsplothandlermesh@shader3% faceted interp
+ \def\pgfplots@loc@TMPa{1}%
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ % oh. no faceted color. Then: no-op!
+ % This is the same as interp with more overhead
+ % (but allows z buffering).
+ \def\pgfplots@loc@TMPa{0}%
+ \def\pgfplotsplothandlermesh@usepath{\pgfusepath{discard}}%
+ \fi
+ \fi
+ \if1\pgfplots@loc@TMPa
+ % make sure there is a the correct color.
+ \expandafter\def\expandafter\pgfplots@drawoptions\expandafter{%
+ \pgfplots@drawoptions
+ \pgfsetstrokecolor{\pgfkeysvalueof{/pgfplots/faceted color}}%
+ }%
+ \fi
+ %
+ \fi
+}
+
+\def\pgfplotsplothandlermesh@init@flat@color@getter{%
+ \if\pgfplotsplothandlermesh@flatmode c% 'flat corner':
+ %
+ % use colordata of ONE corner point. That's easy, not
+ % much to do.
+ \if1\b@pgfplots@correct@shader@flat
+ \def\pgfplotsplothandlermesh@get@flat@color{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{first vertex before z buffer}%
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \let\pgfplotsretval=\pgfplotspointmetatransformed%
+ }%
+ \else
+ \def\pgfplotsplothandlermesh@get@flat@color{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{first vertex}%
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \let\pgfplotsretval=\pgfplotspointmetatransformed%
+ }%
+ \fi
+ \else
+ % 'flat mean':
+ %
+ % use colordata as mean of all corners for shading.
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \if d\pgfplots@colormap@access
+ % colormap access=direct
+ % interpolate adjacent colors, not their indices:
+ \pgfplotsplothandlermesh@get@flat@color@explicit@prepare
+ \def\pgfplotsplothandlermesh@get@flat@color{%
+ \pgfplotsplothandlermesh@get@flat@color@explicit@accum{%
+ \begingroup
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \let\pgfplotspatchvertexmeta=\pgfplotspointmetatransformed
+ \pgfmath@smuggleone\pgfplotspatchvertexmeta
+ \endgroup
+ }%
+ }%
+ \else
+ % colormap access=map|piecewise constant
+ \def\pgfplotsplothandlermesh@get@flat@color{%
+ \global\pgfplots@tmpa=0pt
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{foreach cdata vertex}{%
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \global\advance\pgfplots@tmpa by\pgfplotspointmetatransformed pt
+ }%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{get num cdata vertices}%
+ \global\divide\pgfplots@tmpa by\pgfplotsretval\relax
+ \edef\pgfplotsretval{\pgf@sys@tonumber\pgfplots@tmpa}%
+ \global\pgfplots@tmpa=0pt
+ }%
+ \fi
+ \else
+ % mesh/color input=explicit
+ \pgfplotsplothandlermesh@get@flat@color@explicit@prepare
+ %
+ \def\pgfplotsplothandlermesh@get@flat@color{%
+ \pgfplotsplothandlermesh@get@flat@color@explicit@accum{}%
+ \pgfplotsaxisvisphasetransformpointmeta
+ }%
+ \fi
+ \fi
+}%
+
+\def\pgfplotsplothandlermesh@get@flat@color@explicit@prepare{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{get num cdata vertices}%
+ \pgf@xa=1pt %
+ \divide\pgf@xa by\pgfplotsretval\relax
+ \edef\pgfplotsplothandlermesh@get@flat@color@@{\pgf@sys@tonumber\pgf@xa}%
+}%
+\def\pgfplotsplothandlermesh@get@flat@color@explicit@accum#1{%
+ \pgfplotscolorzero{\pgfplotsplothandlermesh@explicit@color@num@comps}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{foreach cdata vertex}{%
+ #1%
+ \pgfplotscoloraddweighted
+ {\pgfplotsplothandlermesh@explicit@color@num@comps}%
+ {\pgfplotsretval}
+ {\pgfplotsplothandlermesh@get@flat@color@@}%
+ {\pgfplotspatchvertexmeta}%
+ }%
+ % FIXME : this here sounds wrong: !? what is this good for:
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+}%
+
+\def\pgfplotsplothandlermesh@init@jumphandling{%
+ % For matrix input, a "jump" should result in something
+ % visible although it must not destroy the matrix structure.
+ %
+ % try this here:
+ \def\pgfplotsplothandlervisualizejump{%
+ \pgfplotstreampoint{\global\pgf@x=-16000.0pt \global\pgf@y=-16000.0pt }%
+ }%
+ %
+ % Prepare jumps according to point meta:
+ \ifx\pgfplotspointmetainputhandler\pgfutil@empty%
+ % oh. No point meta!?
+ \let\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta=\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@noop
+ \else
+ % we have point meta. This is the standard case.
+ %
+ % prepare the routine for "jump on unbounded point meta":
+ \ifcase\pgfplotsplothandlermesh@shader
+ % 0 == 'flat'
+ \def\pgfplots@loc@TMPa{1}%
+ \or
+ % 1 == 'faceted'
+ \def\pgfplots@loc@TMPa{1}%
+ \else
+ \def\pgfplots@loc@TMPa{0}%
+ \fi
+ %
+ \if 1\pgfplots@loc@TMPa
+ % ok, this uses (only) 'shader=flat'
+ \if c\pgfplotsplothandlermesh@flatmode
+ % 'flat corner':
+ \if1\b@pgfplots@correct@shader@flat
+ \let\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta=\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@firstvertex
+ \else
+ \let\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta=\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@firstvertex@legacy
+ \fi
+ \else
+ % 'flat mean':
+ \let\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta=\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@everyvertex
+ \fi
+ \else
+ \let\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta=\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@everyvertex
+ \fi
+ \fi
+ %
+ \if0\pgfplotsaxisplothasunboundedpointmeta
+ \let\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta=\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@noop
+ \fi
+ \if0\pgfplotsaxisplothasjumps
+ \ifx\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta\pgfplotsplothandlermesh@PIPE@CHECKJUMP@meta@noop
+ \pgfplotsplothandlermesh@PIPE@CHECKJUMP@disable
+ \fi
+ \fi
+}%
+
+
+\def\pgfplotsplothandlermesh@init@zbuffer{%
+ \ifpgfplots@curplot@threedim
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{uses view depth}%
+ \if1\pgfplotsretval
+ \let\pgfplotsplothandlermesh@compute@vertex@depth=\pgfplotsplothandlermesh@compute@vertex@depth@doit%
+ \fi
+ %
+ \if\pgfplotsplothandlermesh@zbuffer@choice4%
+ \def\pgfplotsplothandlermesh@zbuffer@sort@in@TeX{1}%
+ \else
+ \def\pgfplotsplothandlermesh@zbuffer@sort@in@TeX{0}%
+ \fi
+ \if1\b@pgfplots@LUA@visualization@enabled
+ % set it to 'z buffer=none' -- LUA did the job already.
+ \def\pgfplotsplothandlermesh@zbuffer@sort@in@TeX{0}%
+ \fi
+ %
+ \if\pgfplotsplothandlermesh@zbuffer@sort@in@TeX1%
+ % z buffer=sort:
+ % create a z buffer:
+ % the z buffer contains elements {<view depth>}{{<pt1>}{<pt2>}{<pt3>}{<pt4>}}
+ \pgfplotsarraynewempty\pgfplots@zbuffer@local
+ %
+ \let\pgfplotsplothandlermesh@compute@vertex@depth=\pgfplotsplothandlermesh@compute@vertex@depth@doit%
+ %
+ % the "element depth" is defined to be the MEAN of all
+ % vertex depths.
+ % And since the mean is 1/n * sum_{i=1}^n V_i, we can
+ % directly omit the 1/n --- it is the same for every
+ % vertex anyway, and we only want to compare the depth
+ % values.
+ \let\pgfplotsplothandlermesh@accum@element@depth=\pgfmath@basic@add@
+ %
+ % and collect each point into the z buffer
+ % (instead of drawing it):
+ \def\pgfplotsplothandlermesh@PIPE@FINISH{%
+ %
+ % compute DEPTH(lattice element):= min{DEPTH(A),DEPTH(B),DEPTH(C),DEPTH(D)}
+ \def\pgfmathresult{0}%
+ \def\pgfplotsplothandlermesh@zbuffer@tmp{}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{foreach vertex}{%
+ \pgfplotsplothandlermesh@accum@element@depth\pgfplotspatchvertexdepth\pgfmathresult
+ \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@zbuffer@tmp}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotspatchvertexstruct}%
+ \edef\pgfplotsplothandlermesh@zbuffer@tmp{%
+ \the\t@pgfplots@toka
+ {\the\t@pgfplots@tokb}%
+ }%
+ }%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{serialize except vertices}%
+ \t@pgfplots@toka=\expandafter{\pgfplotsretval}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsplothandlermesh@zbuffer@tmp}%
+ \edef\pgfplotsplothandlermesh@zbuffer@tmp{%
+ {\the\t@pgfplots@toka}% first argument is meta data, then follow the vertices
+ \the\t@pgfplots@tokb%
+ }%
+ %
+ % assemble array element:
+ \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@zbuffer@tmp}%
+ \edef\pgfplots@loc@TMPa{%
+ {\pgfmathresult}%
+ {%
+ \the\t@pgfplots@toka
+ }%
+ }%
+ \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPa\to\pgfplots@zbuffer@local
+ }%
+ \fi
+ \else
+ \def\pgfplotsplothandlermesh@zbuffer@sort@in@TeX{0}%
+ \fi
+}%
+\def\pgfplotsplothandlermesh@init@mesh@stream{%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgfplotsplothandlermesh@finish%
+ \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@stream
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
+}
+
+\def\pgfplotsplothandlermesh@set@shader@colormap{%
+ \if0\pgfplotsplothandlermesh@colorinput
+ % mesh/color input=colormap
+ \if d\pgfplots@colormap@access
+ % colormap access=direct
+ % tell it to expect explicit colors:
+ \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfutil@empty
+ \else
+ % colormap access=map|piecewise constant
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa
+ \expandafter\pgfplotscolormaptopdffunction\expandafter{\pgfplots@loc@TMPa}%
+ \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsretval
+ \fi
+ \else
+ % mesh/color input=explicit
+ %
+ % tell it to expect explicit colors:
+ \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfutil@empty
+ \fi
+}%
+
+\def\pgfplotsplothandlermesh@check@unbounded@value{-16000.0pt}%
+{
+\dimen0=\pgfplotsplothandlermesh@check@unbounded@value
+\xdef\pgfplotsplothandlermesh@check@unbounded@text{\the\dimen0}%
+}
+
+\def\pgfplotsplothandlermesh@check@unbounded{%
+ \ifx\pgfplotspatchvertexx\pgfplotsplothandlermesh@check@unbounded@text
+ \pgfplots@loc@tmpfalse
+ \fi
+}%
+
+\long\def\pgfplotsplothandlermesh@defaultlegend@img#1{%
+ \scope[%
+ #1,
+ /pgfplots/mesh/rows=3,
+ /pgfplots/mesh/cols=3,
+ /pgfplots/mesh/num points=,
+ /pgfplots/mesh input=lattice,
+ /pgfplots/patch type=rectangle,
+ /pgfplots/z buffer=default,
+ /tikz/x={(0.44237cm,-0.07439cm)},
+ /tikz/y={(0.30942cm,0.23932cm)},
+ /tikz/z={(0.0cm,1.5cm)},
+ scale=0.4,
+ yshift=-0.7cm,
+ /pgfplots/point meta=explicit,
+ /pgfplots/mesh/color input=colormap,
+ ]
+ \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
+
+ \def\simplecoordinate(##1,##2,##3){%
+ \pgfmathparse{\factor*(##3 - \rangea)}%
+ \pgfmathfloatparsenumber\pgfmathresult
+ \let\pgfplots@current@point@meta=\pgfmathresult
+ \pgfplotstreampoint{\pgfqpointxyz{##1}{##2}{##3}}%
+ }%
+ % for the case 'shader=interp':
+ %\def\pgfplotspointbbupperright{\pgfqpointxyz{2}{2}{0.9}}
+ %\def\pgfplotspointbblowerleft {\pgfqpointxyz{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{%
+ \if\pgfplotsplothandlermesh@zbuffer@sort@in@TeX1%
+ % z buffer=sort:
+ % process the z buffer:
+ \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplotsplothandlermesh@zbuffer@sort@iflessthen
+ \pgfkeysdef{/pgfplots/array/unscope pre}{%
+ \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@output
+ \def\pgfplotspatchready{\pgfplotsplothandlermesh@PIPE@interior@exterior@styles}%
+ \pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{%
+ \expandafter\pgfplotsplothandlermesh@draw@zbufferelement\curelem%
+ }%
+ }%
+ \pgfkeysdef{/pgfplots/array/unscope post}{}%
+ \pgfplotsarraysort\pgfplots@zbuffer@local
+ \fi
+ %
+ \if2\pgfplotsplothandlermesh@shader
+ % shader=interp:
+ % FIXME : broken!
+ %\ifx\pgfplotsplothandlermesh@shader@interp\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
+ \fi
+}%
+
+
+% This is one of two places where the shader is served with
+% coordinates: it handles the special matrix-form shading which is
+% incompatible with the patch-wise sequence of coordinates
+\def\pgfplotsplothandlermesh@PIPE@DECODE@to@shader#1{%
+ \pgfplotsaxisvisphasetransformpointmeta
+ \ifpgf@relevantforpicturesize
+ \pgfpointtransformed{#1}%
+ \pgf@protocolsizes{\pgf@x}{\pgf@y}%
+ \fi
+ \pgfplotslibrarysurfstreamcoord
+ {#1}%
+ {\pgfplotspointmetatransformed}%
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix@ONEDIMMODE#1{%
+ \let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
+ \pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval
+ \let\pgfplots@view@depth=\pgfplotsretval
+ \pgf@process{#1}%
+ \pgfplotsplothandlermesh@serialize@logical@coords
+ \edef\pgfplotsplothandlermesh@i{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplots@view@depth:\pgfplotsretval}%
+ \ifnum\c@pgfplots@scanlineindex>0
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@im}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@i}%
+ \else
+ \advance\c@pgfplots@scanlineindex by1
+ \fi
+ \let\pgfplotsplothandlermesh@im=\pgfplotsplothandlermesh@i
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline@common#1{%
+ \pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval
+ \let\pgfplots@view@depth=\pgfplotsretval
+ \pgf@process{#1}%
+ \pgfplotsplothandlermesh@serialize@logical@coords
+ \edef\pgfplots@loc@TMPa{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplots@view@depth:\pgfplotsretval}%
+ \expandafter\pgfplotsdequepushback\pgfplots@loc@TMPa\to{lastscanline}%
+ \advance\c@pgfplots@scanlineindex by1
+}%
+
+% the pgf@plotstreampoint routine for the first scan line:
+\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline#1{%
+ \pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline@common{#1}%
+ \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
+ % second line!
+ \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@matrix%%
+ \c@pgfplots@scanlineindex=0
+ \fi
+}%
+
+% This is the pgf@plotstreampoint for all scan lines starting with the
+% second.
+%
+% We perform
+% // i == y
+% // j == x
+% 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 ) [from last iteration] -- (i ,j-1) [from #1]
+% -- cycle
+% 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.
+% #1: the current point of the linearized data matrix
+% #2: a callback (TeX code) which will be executed for each point with j>0
+% #3: a callback (TeX code) which will be executed if the scanline is completed, i.e. j=cols
+\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix@collect@and@callback#1#2#3{%
+ % NOTATION:
+ % 'im == (i-1)'
+ % 'jm == (j-1)'
+ \pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval
+ \let\pgfplots@view@depth=\pgfplotsretval
+ \pgf@process{#1}%
+ \pgfplotsplothandlermesh@serialize@logical@coords
+ \edef\pgfplotsplothandlermesh@i@j{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplots@view@depth:\pgfplotsretval}% 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
+ #2%
+ \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
+ #3%
+ \fi
+}%
+\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix#1{%
+ \pgfplotsplothandlermesh@PIPE@DECODE@matrix@collect@and@callback{#1}{%
+ \let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@im@jm}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@im@j}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@i@j}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@i@jm}%
+ }{%
+ % if scan line is completed, start the next one:
+ \c@pgfplots@scanlineindex=0
+ }%
+}%
+
+
+\def\pgfplotsplothandlermesh@shader@interp@incremental@transpose#1{%
+ \pgfplotsaxisvisphasetransformpointmeta
+ \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{\global\pgf@x=##1 \global\pgf@y=##2 }{##3}%
+ }%
+ \c@pgfplots@scanlineindex=0
+ \pgfutil@loop
+ \ifnum\c@pgfplots@scanlineindex<\pgfplotsplothandlermesh@rows\relax
+ \expandafter\pgfplotsapplistXlet\expandafter\pgfplots@loc@TMPd\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@TMPd
+ \advance\c@pgfplots@scanlineindex by1
+ \pgfutil@repeat
+ \let\pgfplots@loc@TMPd=\relax
+}%
+
+\def\pgfplotsplothandlermesh@draw@zbufferelement#1#2{%
+ \pgfplotsplothandlermesh@draw@zbufferelement@#2\pgfplots@EOI
+}
+\def\pgfplotsplothandlermesh@draw@zbufferelement@#1{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{deserialize except vertices}{#1}%
+ \pgfplotsplothandlermesh@draw@zbufferelement@@
+}
+\def\pgfplotsplothandlermesh@draw@zbufferelement@@#1{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@EOI
+ \else
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{set next vertex}{#1}%
+ \expandafter\pgfplotsplothandlermesh@draw@zbufferelement@@
+ \fi
+}%
+
+
+\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}%
+}%
+\def\pgfplotsplothandlermesh@unpack@zbuffer@pointdepth#1{%
+ \expandafter\pgfplotsplothandlermesh@unpack@zbuffer@pointdepth@#1%
+}%
+\def\pgfplotsplothandlermesh@unpack@zbuffer@pointdepth@#1#2#3#4{%
+ \def\pgfplotsretval{#4}%
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsmeshplotimage.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsmeshplotimage.code.tex
new file mode 100644
index 0000000000..b5a51cd3b2
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsmeshplotimage.code.tex
@@ -0,0 +1,545 @@
+%--------------------------------------------
+%
+% 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-2015 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 essentially belongs to the 'mesh' plot handler.
+% It implements the (rather involved) feature 'mesh input=image'.
+%
+% 'mesh input=image' is implemented during the visualization phase
+% and, partially, during the survey phase. The survey phase merely
+% updates the data limits. The visualization phase has the complete
+% knowledge about the input matrix size and can compute the cells.
+
+\def\pgfplotsplothandlersurveystart@mesh@image{%
+ \let\pgfplotsplothandlermesh@image@lastA=\pgfutil@empty
+ \let\pgfplotsplothandlermesh@image@lastlastA=\pgfutil@empty
+ \let\pgfplotsplothandlermesh@image@lastB=\pgfutil@empty
+ \def\b@pgfplotsplothandlermesh@image@updatedlimits@A@next{1}%
+ \def\b@pgfplotsplothandlermesh@image@updatedlimits@B@next{0}%
+ \def\c@pgfplotsplothandlermesh@image@numscanlines{0}%
+ %
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = x varies= rowwise -> scanline is cols!
+ \def\pgfplotsplothandlermesh@image@A@dir{x}%
+ \def\pgfplotsplothandlermesh@image@B@dir{y}%
+ \def\pgfplotsplothandlermesh@image@updatelimits@AB##1##2##3{%
+ \pgfplotsaxisupdatelimitsforcoordinate{##1}{##2}{##3}%
+ }%
+ \else
+ % ordering = y varies = colwise: scanline is rows!
+ \def\pgfplotsplothandlermesh@image@A@dir{y}%
+ \def\pgfplotsplothandlermesh@image@B@dir{x}%
+ \def\pgfplotsplothandlermesh@image@updatelimits@AB##1##2##3{%
+ \pgfplotsaxisupdatelimitsforcoordinate{##2}{##1}{##3}%
+ }%
+ \fi
+}%
+\def\pgfplotsplothandlersurveyend@mesh@image{%
+ \if1\pgfplotsaxisplothasjumps
+ % the approach to interpolate cell corners using the adjacent cell midpoints becomes extremely complicated once
+ % we allow all kinds of holes in the input matrix.
+ % If you want to make invisible cells, you can add "nan" as color data
+ \pgfplots@error{Sorry, 'matrix plot' supports no holes (jumps) in the input data. Please implement jumps using an unbounded point meta value (i.e. inf or nan)}%
+ \fi
+ %
+}%
+\def\pgfplotsplothandlersurveypoint@mesh@image{%
+ % already called:
+ %\pgfplotsplothandlersurveypoint@default
+ %
+ % The 'update limits' routine for 'mesh input=image' is a
+ % HEURISTICS.
+ %
+ % It works well for "real" image plots, i.e. for those which are
+ % not skewed or changed parametrically.
+ %
+ % The main challenge is that we have to update the matrix limits
+ % while we pass through the scanlines.
+ %
+ % The idea is:
+ % - update cell midpoint limits using the standard PGFPlots
+ % methods. We would like to have the cell limits instead,
+ % though... to this end:
+ % - update the lower x cell limit for the first encountered X in every
+ % scanline
+ % - update the upper x cell limit for the last encountered X in every
+ % scanline
+ % - update the lower AND upper y cell limit for the first encountered Y
+ % in every scanline.
+ %
+ % That means:
+ % - we do NOT update X limits for mid points
+ % - we do NOT update Y limits for the second, third, ..., nth
+ % point on scanlines. Only for the first.
+ %
+ % For parametric image plots, these limits will be inaccurate. I
+ % suppose these are rather exotic anyway, so I accept that to
+ % simplify the implementation.
+ %
+ \expandafter\let\expandafter\pgfplotsplothandlermesh@cur\csname pgfplots@current@point@\pgfplotsplothandlermesh@image@A@dir\endcsname
+ \expandafter\let\expandafter\pgfplotsplothandlermesh@cur@B\csname pgfplots@current@point@\pgfplotsplothandlermesh@image@B@dir\endcsname
+ %
+ \if1\b@pgfplotsplothandlermesh@image@updatedlimits@A@next
+ \ifx\pgfplotsplothandlermesh@cur\pgfutil@empty
+ \else
+ \ifx\pgfplotsplothandlermesh@image@lastA\pgfutil@empty
+ \else
+ \pgfplotscoordmath{x}{parse}{\pgfplotsplothandlermesh@image@lastA - 0.5*(\pgfplotsplothandlermesh@cur - \pgfplotsplothandlermesh@image@lastA)}%
+ \let\pgfplots@current@point@xh=\pgfmathresult
+ \pgfplotsplothandlermesh@image@updatelimits@AB\pgfplots@current@point@xh\pgfplotsplothandlermesh@cur@B\pgfplots@current@point@z
+ %
+ \def\b@pgfplotsplothandlermesh@image@updatedlimits@A@next{0}%
+ \fi
+ \fi
+ \fi
+ %
+ \if1\b@pgfplotsplothandlermesh@image@updatedlimits@B@next
+ \ifx\pgfplotsplothandlermesh@cur@B\pgfutil@empty
+ \else
+ \ifx\pgfplotsplothandlermesh@image@lastB\pgfutil@empty
+ \else
+ \pgfplotscoordmath{y}{parse}{\pgfplotsplothandlermesh@image@lastB - 0.5*(\pgfplotsplothandlermesh@cur@B - \pgfplotsplothandlermesh@image@lastB)}%
+ \let\pgfplots@current@point@yh=\pgfmathresult
+ \pgfplotsplothandlermesh@image@updatelimits@AB\pgfplotsplothandlermesh@cur\pgfplots@current@point@yh\pgfplots@current@point@z
+ %
+ %
+ \pgfplotscoordmath{y}{parse}{\pgfplotsplothandlermesh@cur@B + 0.5*(\pgfplotsplothandlermesh@cur@B - \pgfplotsplothandlermesh@image@lastB)}%
+ \let\pgfplots@current@point@yh=\pgfmathresult
+ \pgfplotsplothandlermesh@image@updatelimits@AB\pgfplotsplothandlermesh@cur\pgfplots@current@point@yh\pgfplots@current@point@z
+ %
+ \def\b@pgfplotsplothandlermesh@image@updatedlimits@B@next{0}%
+ \fi
+ \fi
+ \fi
+ \let\pgfplotsplothandlermesh@image@lastlastA=\pgfplotsplothandlermesh@image@lastA
+ \let\pgfplotsplothandlermesh@image@lastA=\pgfplotsplothandlermesh@cur
+ %
+ \let\pgfplotsplothandlermesh@image@lastB=\pgfplotsplothandlermesh@cur@B
+}%
+
+\def\pgfplotsplothandlersurveyend@mesh@image@scanlinecomplete{%
+ \ifx\pgfplotsplothandlermesh@image@lastlastA\pgfutil@empty
+ \else
+ \ifx\pgfplotsplothandlermesh@image@lastA\pgfutil@empty
+ \else
+ \expandafter\let\expandafter\pgfplotsplothandlermesh@cur@B\csname pgfplots@current@point@\pgfplotsplothandlermesh@image@B@dir\endcsname
+ \pgfplotscoordmath{x}{parse}{\pgfplotsplothandlermesh@image@lastA + 0.5*(\pgfplotsplothandlermesh@image@lastA - \pgfplotsplothandlermesh@image@lastlastA)}%
+ \let\pgfplots@current@point@xh=\pgfmathresult
+ \pgfplotsplothandlermesh@image@updatelimits@AB\pgfplots@current@point@xh\pgfplotsplothandlermesh@cur@B\pgfplots@current@point@z
+ \fi
+ \fi
+ %
+ \def\b@pgfplotsplothandlermesh@image@updatedlimits@B@next{1}%
+ %
+ \let\pgfplotsplothandlermesh@image@lastlastA=\pgfutil@empty
+ \let\pgfplotsplothandlermesh@image@lastA=\pgfutil@empty
+ \def\b@pgfplotsplothandlermesh@image@updatedlimits@A@next{1}%
+ %
+ \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlermesh@image@numscanlines
+}%
+
+%
+% The 'mesh' plot handler has a "visualization pipeline" as part of
+% its visualization:
+%
+% if it is active, the coordinate stream used for the visualization
+% (\pgfplotsplothandlermesh@stream) invokes
+% \pgfplotsplothandlermesh@PIPE@DECODE as first item. This, in turn,
+% fires other elements of the mesh plot pipeline, but its most
+% important task is to assemble patches while it goes.
+%
+% That's where 'mesh input=image' hooks in: it simply generates special patches.
+
+% this is part of the implementation of mesh input=image
+% the pgf@plotstreampoint routine for the first scan line:
+\def\pgfplotsplothandlermesh@PIPE@DECODE@image@fillscanline#1{%
+ \pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline@common{#1}%
+ \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
+ % second line!
+ \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@image@secondscanline%%
+ \c@pgfplots@scanlineindex=0
+ \def\c@pgfplotsplothandlermesh@image@nextrownum{2}%
+ \fi
+}%
+
+% IDEA:
+%
+% 1. The first scanline is merely buffered and collected into the deque 'lastscanline' (just as any mesh plot).
+% 2. The second scanline
+% - generates cells for the first scanline _and_
+% - appends the computed intermediate vertices to the deque 'lastinterpscanline'.
+% - during the sweep, a single cell of the first scanline is
+% generated
+% - only the _last_ element of the scanline generates two cells
+% 3. All scanlines after the second
+% - pop the intermediate vertices from the deque
+% - use them to construct cells for the previous scanline
+% - append their computed intermediate vertices to the deque 'lastinterpscanline'.
+% - during the sweep, a single cell of the first scanline is
+% generated
+% - only the _last_ element of the scanline generates two cells (just as in step 2)
+% 4. the last scanline is special in that it generates cells for the
+% previous scanline _and_ the last scanline.
+%
+% The "computed intermediate vertices" are mean values and
+% extrapolation points. My idea is to make this special cell-based
+% mesh more flexible than a simple imagesc, hoping that this pays off.
+\def\pgfplotsplothandlermesh@PIPE@DECODE@image@secondscanline#1{%
+ \pgfplotsplothandlermesh@PIPE@DECODE@matrix@collect@and@callback{#1}{%
+ %
+ % create cell:
+ \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell{1}%
+ %
+ \advance\c@pgfplots@scanlineindex by1
+ \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
+ % ok, we have to extrapolate the last column.
+ \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastcolumn{1}%
+ \fi
+ \advance\c@pgfplots@scanlineindex by-1
+ }{%
+ % if scanline is completed, switch states:
+ \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@image@after@second%%
+ \c@pgfplots@scanlineindex=0
+ \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlermesh@image@nextrownum
+ }%
+}%
+\def\pgfplotsplothandlermesh@PIPE@DECODE@image@after@second#1{%
+ \pgfplotsplothandlermesh@PIPE@DECODE@matrix@collect@and@callback{#1}{%
+ \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell{0}%
+ %
+ \advance\c@pgfplots@scanlineindex by1
+ \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
+ % ok, we have to extrapolate the last column.
+ \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastcolumn{0}%
+ \fi
+ \advance\c@pgfplots@scanlineindex by-1
+ }{%
+ % if scanline is completed: advance to next
+ \c@pgfplots@scanlineindex=0
+ \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlermesh@image@nextrownum
+ }%
+}%
+
+% To be used within the DECODE "loop" only! It assembles temporary
+% variables for the next iteration (and consumes it).
+%
+% #1: '1' if topmost row is to be extrapolated, '0' if it should be
+% acquired from the datastructure 'lastinterpscanline'
+\def\pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell#1{%
+ \let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
+ %
+ % we have to compute the four corners by means of
+ % averaging/extrapolation.
+ %
+ % We place the rectangle around (i-1,j-1), i.e. imjm
+ % Notation: the four corners are aa, ab, ba, and bb.
+ % aa ----- ab
+ % | |
+ % | |
+ % | imjm |
+ % | |
+ % | |
+ % ba ------ bb
+ %
+ % bb is the average of the four cell mid points of our
+ % scanline, the others are acquired from previous iterations
+ % or from extrapolation schemes.
+ %
+ % compute bb:
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@jm\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@j\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@j\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@jm\times{0.25}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@bb
+ \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@j\to\pgfplotsplothandlermesh@bb
+ %
+ %
+ \if1#1%
+ % Ah -- this here is the very first row! That means we
+ % have to extrapolate the topmost coordinates.
+ %
+ % Apply extrapolation for ab:
+ %
+ % compute ab = bb + 2* ( 1/2 (imj + imjm) - bb)
+ % which resolves to the following:
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{-1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@j\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@jm\times{1.0}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@ab
+ \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@im@j\to\pgfplotsplothandlermesh@ab
+ \else
+ \ifnum\c@pgfplots@scanlineindex=1
+ \pgfplotsdequepopfront{lastinterpscanline}\to\pgfplotsplothandlermesh@aa
+ \fi
+ \pgfplotsdequepopfront{lastinterpscanline}\to\pgfplotsplothandlermesh@ab
+ \fi
+ %
+ \ifnum\c@pgfplots@scanlineindex=1
+ % ah, we have to apply special treatment for the leftmost
+ % cell.
+ %
+ %
+ % compute ba = bb + 2* ( 1/2 (imjm + ijm) - bb)
+ % which resolves to the following:
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{-1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@jm\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@jm\times{1.0}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@ba
+ \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@jm\to\pgfplotsplothandlermesh@ba
+ %
+ \if1#1%
+ % ok, extrapolate 'aa' as well:
+ %
+ % compute aa = ba + (ab - bb)
+ % which resolves to the following:
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{-1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@ba\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@ab\times{1.0}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@aa
+ \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@im@jm\to\pgfplotsplothandlermesh@aa
+ \else
+ % in this case, 'aa' has been fetched from the deque
+ % (from the previous scanline)
+ \fi
+ %
+ % as soon as we process the next scanline, we need to know the
+ % interpolated values -- they will become the top row of the
+ % next scanline's cells.
+ \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@ba\to{lastinterpscanline}%
+ \else
+ % ok, we take the left edge (ba and aa) from the previous
+ % iteration (see the end of this code where the previous
+ % loop iteration prepared them).
+ \fi
+ %
+ \pgfplotsplothandlermesh@image@set@first@color@to\pgfplotsplothandlermesh@im@jm\to\pgfplotsplothandlermesh@aa
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsretval}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@ab}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@bb}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@ba}%
+ %
+ % ... and communicate this as well to the next scanline (see
+ % \pgfplotsplothandlermesh@PIPE@DECODE@image@after@second)
+ \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@bb\to{lastinterpscanline}%
+ %
+ \ifnum\c@pgfplotsplothandlermesh@image@nextrownum=\pgfplotsplothandlermesh@numscanlines\relax
+ \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastrow
+ \fi
+ %
+ % merely shift the current points such that the next loop
+ % iteration can use them without modifications:
+ \let\pgfplotsplothandlermesh@ba=\pgfplotsplothandlermesh@bb
+ \let\pgfplotsplothandlermesh@aa=\pgfplotsplothandlermesh@ab
+ %
+}%
+
+% The color handling of 'matrix input=image' is quite involved.
+% There are the following requirements:
+% 1. the point meta of the cell's first vertex _must_ be equal to the point meta of the cell mid point, i.e. equal to the user input.
+% 2. All other vertices should be interpolated "as smart as possible". This interpolation scheme should work even if adjacent cell midpoints have _no_ bounded meta data!
+% 3. The routines which glue adjacent cells together have to ensure that they do not accidentally intermix (1) and (2). This is complicated since the sweep loop intermingles both responsibilities (sigh).
+%
+% This helper function ensures (1): it copies the point meta of the \pgfplotspatchvertex #1 to the values of of #2 and assigns the result to \pgfplotsretval.
+% #1 a valid \pgfplotspatchvertex
+% #2 a valid \pgfplotspatchvertex
+%
+% POSTCONDITION: \pgfplotsretval contains the result, i.e. a copy of '#2' which contains the point meta of '#1'.
+\def\pgfplotsplothandlermesh@image@set@first@color@to#1\to#2{%
+ \let\pgfplotsretval=#2%
+ \pgfplotspatchvertexcopymeta#1\to\pgfplotsretval
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastrow{%
+ %
+ \let\pgfplotsplothandlermesh@last@aa=\pgfplotsplothandlermesh@ba
+ \let\pgfplotsplothandlermesh@last@ab=\pgfplotsplothandlermesh@bb
+ %
+ % ASSUMPTION: we want to compute Laa, Lab, Lba and Lbb in the following setup:
+ %
+ % aa ----- ab
+ % | |
+ % | |
+ % | imjm |
+ % | |
+ % | |
+ % ba ------ bb
+ % =Laa =Lab
+ % | |
+ % | |
+ % | ijm |
+ % | |
+ % | |
+ % Lba------ Lbb
+ %
+ % compute Lbb = bb + 2 * (1/2 ( ijm + ij) - bb ). We assume that
+ % we can still access 'bb', the coordinate of the current point.
+ % This resolves to the following:
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{-1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@jm\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@j\times{1.0}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@last@bb
+ % FIXME : which is the correctly extrapolated cdata!?
+ %\pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@j\to\pgfplotsplothandlermesh@last@bb
+ %
+ \ifnum\c@pgfplots@scanlineindex=1
+ % compute Lba = Lbb + Laa - Lab
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@bb\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@aa\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@ab\times{-1.0}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@last@ba
+ % FIXME : which is the correctly extrapolated cdata!?
+ %\pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@jm\to\pgfplotsplothandlermesh@last@ba
+ \else
+ % transported from previous iteration.
+ \fi
+ %
+ \pgfplotsplothandlermesh@image@set@first@color@to\pgfplotsplothandlermesh@i@jm\to\pgfplotsplothandlermesh@last@aa
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsretval}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@ab}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@bb}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@ba}%
+ %
+ \let\pgfplotsplothandlermesh@last@ba=\pgfplotsplothandlermesh@last@bb
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastrow@lastcol{%
+ %
+ % ASSUMPTION: we want to compute Laa, Lab, Lba and Lbb in the following setup:
+ %
+ % aa ----- ab
+ % | |
+ % | |
+ % | imj |
+ % | |
+ % | |
+ % ba ------ bb
+ % =Laa =Lab
+ % | |
+ % | |
+ % | ij |
+ % | |
+ % | |
+ % Lba------ Lbb
+ \let\pgfplotsplothandlermesh@last@aa=\pgfplotsplothandlermesh@ba
+ \let\pgfplotsplothandlermesh@last@ab=\pgfplotsplothandlermesh@bb
+ %
+ % I mirrored the formula for lastrow.
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@bb\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@aa\times{-1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@ab\times{1.0}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@last@bb
+ \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@j\to\pgfplotsplothandlermesh@last@bb
+ %
+ \pgfplotsplothandlermesh@image@set@first@color@to\pgfplotsplothandlermesh@i@j\to\pgfplotsplothandlermesh@last@aa
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsretval}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@ab}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@bb}%
+ % this value is transported from previous iteration:
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@ba}%
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastcolumn#1{%
+ \let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
+ %
+ % we have to compute the four corners by means of
+ % averaging/extrapolation.
+ %
+ % We place the rectangle around (i-1,j), i.e. imj.
+ % This is in contrast to
+ % \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell
+ % where we placed the rectange around (i-1,j-1).
+ %
+ % Notation: the four corners are aa, ab, ba, and bb.
+ % aa ----- ab
+ % | |
+ % | |
+ % | imj |
+ % | |
+ % | |
+ % ba ------ bb
+ %
+ % We can simply copy aa and ba from the previous cell (as in
+ % the standard case). Note that this has already been prepared
+ % for us, i.e. the variables have already been set by the
+ % previous iteration.
+ %
+ % compute ab and bb by means of extrapolation:
+ %
+ % compute bb:
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@ba\times{-1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@j\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@j\times{1.0}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@bb
+ % FIXME : which is the correctly extrapolated cdata!?
+ %
+ %
+ \if1#1%
+ % Ah -- this here is the very first row! That means we
+ % have to extrapolate the topmost coordinates.
+ %
+ % Apply extrapolation for ab:
+ %
+ % compute ab = bb + (aa - ba)
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@aa\times{1.0}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@ba\times{-1.0}%
+ \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@ab
+ % FIXME : which is the correctly extrapolated cdata!?
+ \else
+ \pgfplotsdequepopfront{lastinterpscanline}\to\pgfplotsplothandlermesh@ab
+ \fi
+ %
+ \pgfplotsplothandlermesh@image@set@first@color@to\pgfplotsplothandlermesh@im@j\to\pgfplotsplothandlermesh@aa
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsretval}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@ab}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@bb}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@ba}%
+ %
+ % ... and communicate this as well to the next scanline (see
+ % \pgfplotsplothandlermesh@PIPE@DECODE@image@after@second)
+ \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@bb\to{lastinterpscanline}%
+ %
+ \ifnum\c@pgfplotsplothandlermesh@image@nextrownum=\pgfplotsplothandlermesh@numscanlines\relax
+ \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastrow@lastcol
+ \fi
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_leq.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_leq.code.tex
new file mode 100644
index 0000000000..8be16c806a
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_leq.code.tex
@@ -0,0 +1,279 @@
+% ======================================================
+% compatibility with PGF 3.0.1a
+% ======================================================
+%
+%%% 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.
+%%%
+%%% It contains a couple of patches such that selected changes which
+%%% are also part of PGF/TikZ (and can be found in the development
+%%% version of PGF/TikZ) are available within pgfplots.
+%%%
+%%% this file contains solvers which have been written by Christian Feuersaenger (primarily, but not only, for pgfplots)
+
+% 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.
+% It is acceptable if '#1' is a macro which expands to the expected
+% format.
+% #2: should contain 2 sets of braces with the right-hand-side,
+% {<r1>}{<r2>}
+% where each entry should be a number without unit.
+% It is acceptable if '#2' is a macro which expands to the expected
+% format.
+%
+% 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.
+%
+% If the matrix is singular, the routine will return {}.
+\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
+ \tmpa=\csname m\Pa a\endcsname pt %
+ \ifdim\tmpa<0pt \tmpa=-\tmpa\fi
+ \ifdim\tmpa<0.0001pt
+ % singular matrix!
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ \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
+ %
+ \tmpa=\csname \Pb b\endcsname%
+ \ifdim\tmpa<0pt \tmpa=-\tmpa\fi
+ \ifdim\tmpa<0.0001pt
+ % singular matrix!
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ % 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 := 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}%
+ }%
+ \fi
+ \fi
+ \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\pgfutilsolvetwotwoleqfloat@ifislarger#1#2#3#4{%
+ \pgfmathfloatabs@{#1}\let\tmpa=\pgfmathresult
+ \pgfmathfloatabs@{#2}\let\tmpb=\pgfmathresult
+ \pgfmathfloatlessthan@{\tmpb}{\tmpa}%
+ \ifpgfmathfloatcomparison
+ #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\pgfutilsolvetwotwoleqfloat@A#1#2#3#4{%
+ \pgfmathfloatparsenumber{#1}\let\maa=\pgfmathresult
+ \pgfmathfloatparsenumber{#2}\let\mab=\pgfmathresult
+ \pgfmathfloatparsenumber{#3}\let\mba=\pgfmathresult
+ \pgfmathfloatparsenumber{#4}\let\mbb=\pgfmathresult
+}
+\def\pgfutilsolvetwotwoleqfloat@r#1#2{%
+ \pgfmathfloatparsenumber{#1}\let\ra=\pgfmathresult
+ \pgfmathfloatparsenumber{#2}\let\rb=\pgfmathresult
+}%
+
+% Same as \pgfutilsolvetwotwoleq, but using floating point
+% arithmetics. The return value is still in fixed point.
+\def\pgfutilsolvetwotwoleqfloat#1#2{%
+ \begingroup
+ \pgfmathfloatcreate{1}{1.0}{-4}% FIXME : use a smaller threshold for FPU?
+ \let\thresh=\pgfmathresult
+ %
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutilsolvetwotwoleqfloat@A\pgf@temp
+ \edef\pgf@temp{#2}%
+ \expandafter\pgfutilsolvetwotwoleqfloat@r\pgf@temp
+ %
+ \pgfutilsolvetwotwoleqfloat@ifislarger\maa\mba{%
+ % identity "permutation":
+ \def\Pa{a}%
+ \def\Pb{b}%
+ }{%
+ % permutation matrix: switch rows!
+ \def\Pa{b}%
+ \def\Pb{a}%
+ }%
+ % \pivot := 1/aa
+ \expandafter\pgfmathfloatabs@\expandafter{\csname m\Pa a\endcsname}%
+ \let\tmpa=\pgfmathresult
+ \pgfmathfloatlessthan@{\tmpa}{\thresh}%
+ \ifpgfmathfloatcomparison
+ % singular matrix!
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ \expandafter\pgfmathfloatreciprocal@\expandafter{\csname m\Pa a\endcsname}%
+ \let\pivot=\pgfmathresult
+ %
+ % \factor := 1/aa * ba
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pb a\endcsname}{\pivot}%
+ \let\factor=\pgfmathresult
+ \expandafter\let\csname m\Pb a\endcsname=\factor
+ %
+ % bb -= ba/aa * ab
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pa b\endcsname}{\factor}%
+ \let\tmpa=\pgfmathresult
+ \expandafter\pgfmathfloatsubtract@\expandafter{\csname m\Pb b\endcsname}{\tmpa}%
+ \expandafter\let\csname m\Pb b\endcsname=\pgfmathresult
+ %
+ % rb -= ba/aa * ra
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname r\Pa\endcsname}{\factor}%
+ \let\tmpa=\pgfmathresult
+ \expandafter\pgfmathfloatsubtract@\expandafter{\csname r\Pb\endcsname}{\tmpa}%
+ \expandafter\let\csname r\Pb\endcsname=\pgfmathresult
+ %
+ \expandafter\pgfmathfloatabs@\expandafter{\csname m\Pb b\endcsname}%
+ \let\tmpa=\pgfmathresult
+ \pgfmathfloatlessthan@{\tmpa}{\thresh}%
+ \ifpgfmathfloatcomparison
+ % singular matrix!
+ \let\pgfmathresult=\pgfutil@empty
+ \else
+ % xb := rb / bb (the modified rb and modified bb!)
+ \edef\pgf@marshal{
+ \noexpand\pgfmathfloatdivide@
+ {\csname r\Pb\endcsname}
+ {\csname m\Pb b\endcsname}%
+ }%
+ \pgf@marshal
+ \expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult
+ \let\tmpa=\pgfmathresult
+ %
+ % ra := ra - xb * ab
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname m\Pa b\endcsname}{\tmpa}%
+ \let\tmpa=\pgfmathresult
+ \expandafter\pgfmathfloatsubtract@\expandafter{\csname r\Pa\endcsname}{\tmpa}%
+ \expandafter\let\csname r\Pa\endcsname=\pgfmathresult
+ %
+ % xa := 1/aa * ra (the modified ra!)
+ \expandafter\pgfmathfloatmultiply@\expandafter{\csname r\Pa\endcsname}{\pivot}%
+ \expandafter\let\csname pgfmathresult\Pa\endcsname=\pgfmathresult
+ %
+ \edef\pgfmathresult{%
+ {\csname pgfmathresult\Pa\endcsname}%
+ {\csname pgfmathresult\Pb\endcsname}%
+ }%
+ \expandafter\pgfutilsolvetwotwoleqfloat@to@pgf@range\pgfmathresult
+ \fi
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+
+\def\pgfutilsolvetwotwoleqfloat@to@pgf@range#1#2{%
+ \pgfmathfloatcreate{1}{1.6}{4}\let\pgfutilsolvetwotwoleqfloat@to@pgf@range@max=\pgfmathresult
+ \pgfmathfloatabs@{#1}%
+ \expandafter\pgfmathfloatlessthan@\expandafter{\pgfmathresult}{\pgfutilsolvetwotwoleqfloat@to@pgf@range@max}%
+ \ifpgfmathfloatcomparison
+ \pgfmathfloatabs@{#2}%
+ \expandafter\pgfmathfloatlessthan@\expandafter{\pgfmathresult}{\pgfutilsolvetwotwoleqfloat@to@pgf@range@max}%
+ \ifpgfmathfloatcomparison
+ % ok.
+ \pgfmathfloattofixed{#1}\let\tmpa=\pgfmathresult
+ \pgfmathfloattofixed{#2}%
+ \edef\pgfmathresult{{\tmpa}{\pgfmathresult}}%
+ \else
+ % singular (because PGF cannot represent its result
+ \let\pgfmathresult=\pgfutil@empty
+ \fi
+ \else
+ % singular (because PGF cannot represent its result
+ \let\pgfmathresult=\pgfutil@empty
+ \fi
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_loader.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_loader.code.tex
new file mode 100644
index 0000000000..b68c50eac2
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_loader.code.tex
@@ -0,0 +1,361 @@
+
+%\input pgfplotsoldpgfsupp_pgfmathparse.opt.code.tex
+%\beginpgfmathparsecheckfornumber
+
+\pgfutil@ifundefined{pgfmathlessthan@}{%
+ \let\pgfmathlessthan@=\pgfmathless@
+ \let\pgfmathgreaterthan@=\pgfmathgreater@
+}{}%
+
+
+\def\pgfplotsusecompatibilityfile#1{%
+ \pgfutil@IfUndefined{pgfplotsusecompatibilityfile@loaded@#1}{%
+ \expandafter\gdef\csname pgfplotsusecompatibilityfile@loaded@#1\endcsname{1}%
+ \input pgfplotsoldpgfsupp_#1
+ }{%
+ % already loaded.
+ }%
+}%
+
+
+\def\pgfmathfloatrounddisplaystyle@shared@impl@WRONG#1#2{%
+ {\toks0={#1}%
+ \toks1=\expandafter{\pgfmathfloatrounddisplaystyle@e@mark #2}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }%
+ }%
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+}%
+
+% check whether we need to load supplementary code.
+% The development of pgfplots and pgf is intermingled, so pgfplots
+% always uses up-to-date pgf CVS versions - the relevant complements between
+% PGF 2.10 and PGF CVS are loaded here:
+%
+% #1: for backwards compatibility
+% #2: for normal processing.
+\def\pgfplots@ifneedspgfcompabitibilitycode@has@pgf@one@zero@zero#1#2{%
+ %\pgfkeysifdefined{/pgf/number format/sci precision/.@cmd}{#2}{#1}%
+ \pgfutil@ifundefined{pgfmathprintnumber@RELATIVE@choice@roundtofixed}{#1}{#2}%
+}%
+
+\let\pgfplots@ifneedspgfcompabitibilitycode=\pgfplots@ifneedspgfcompabitibilitycode@has@pgf@one@zero@zero
+
+\pgfplots@ifneedspgfcompabitibilitycode
+ {%
+ \immediate\write16{Package pgfplots: loading complementary code for your PGF version...}
+ \input pgfplotsoldpgfsupp_misc.code.tex
+ \let\pgfkeysloaded=\undefined
+ \input pgfplotsoldpgfsupp_pgfkeys.code.tex
+ \input pgfplotsoldpgfsupp_pgfmathfloat.code.tex
+ \input pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex
+ \input pgfplotsoldpgfsupp_pgflibraryfpu.code.tex
+ \input pgfplotsoldpgfsupp_pgfcorescopes.code.tex
+ \input pgfplotsoldpgfsupp_pgfcorelayers.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
+ }%
+ }%
+
+\gdef\pgfplots@glob@TMPa{0}%
+
+\def\pgfmathfloatfloor@broken#1{%
+ \edef\pgfmathfloat@loc@TMPa{#1}%
+ \pgfmathfloatcreate{2}{5.0}{-1}% -0.5
+ \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ \pgfmathfloatadd@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPb}%
+ \expandafter\pgfmathfloatround@\expandafter{\pgfmathresult}%
+}
+\ifx\pgfmathfloatfloor\pgfmathfloatfloor@broken
+ \gdef\pgfplots@glob@TMPa{1}%
+\fi
+
+\def\pgfmathfloor@broken#1{%
+ \begingroup%
+ \expandafter\pgfmath@x#1pt\relax%
+ \afterassignment\pgfmath@gobbletilpgfmath@%
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@%
+ \expandafter\pgfmath@x#1pt\relax%
+ \ifdim\pgfmath@x<0pt\relax%
+ \advance\c@pgfmath@counta by -1\relax%
+ \fi%
+ \pgfmath@x\c@pgfmath@counta pt\relax%
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}%
+\ifx\pgfmathfloor@\pgfmathfloor@broken
+ \def\pgfmathfloor@#1{%
+ \begingroup%
+ \expandafter\pgfmath@x#1pt\relax%
+ \afterassignment\pgfmathfloor@collect@remainder%
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\pgfmath@%
+ \expandafter\pgfmath@x#1pt\relax%
+ \ifdim\pgfmath@x<0pt\relax%
+ \ifdim\pgfmathfloor@remainder>0pt
+ \advance\c@pgfmath@counta by -1\relax%
+ \else
+ % ok, we stripped only '0'.
+ \fi
+ \fi%
+ \pgfmath@x\c@pgfmath@counta pt\relax%
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+ }%
+ \def\pgfmathfloor@collect@remainder#1\pgfmath@{%
+ \def\pgfmathfloor@remainder{#1}%
+ \ifx\pgfmathfloor@remainder\pgfutil@empty
+ \def\pgfmathfloor@remainder{0}%
+ \fi
+ }%
+\fi
+
+
+\pgfutil@ifundefined{pgfmathfloat@stack@push@operand@single@str}{
+ \gdef\pgfplots@glob@TMPa{1}%
+}
+{}%
+
+\if1\pgfplots@glob@TMPa
+ \immediate\write16{Package pgfplots: loading complementary arithmetics for your pgf version...}
+ \input pgfplotsoldpgfsupp_pgflibraryfpu.code.tex
+ \input pgfplotsoldpgfsupp_pgfmathfloat.code.tex
+\fi
+
+\pgfutil@IfUndefined{pgfmathdeclarefunction}{
+ \pgfplots@warning{Parts of pgfplots require PGF 2.10; you have PGF 2.00 . Consider upgrading if you experience problems.}%
+}{%
+}%
+
+\pgfutil@IfUndefined{pgfutilifcontainsmacro}{%
+ \gdef\pgfplots@glob@TMPa{1}%
+}{%
+ \gdef\pgfplots@glob@TMPa{0}%
+}%
+\if1\pgfplots@glob@TMPa
+ \begingroup
+ \catcode`\|=0
+ \catcode`\\=12
+ |gdef|pgfutil@backslash@as@other{\}%
+ |endgroup
+ \def\pgfutil@command@to@string#1#2{%
+ \expandafter\pgfutil@command@to@string@@\meaning#1\pgfutil@EOI{#2}%
+ }%
+ \xdef\pgfutil@glob@TMPa{\meaning\pgfutil@empty}%
+ \expandafter\def\expandafter\pgfutil@command@to@string@@\pgfutil@glob@TMPa#1\pgfutil@EOI#2{%
+ \def#2{#1}%
+ }%
+ \def\pgfutilifcontainsmacro#1#2#3{%
+ \def\pgf@marshal{#1}%
+ \pgfutil@command@to@string\pgf@marshal\pgf@marshal
+ \edef\pgf@marshal{\noexpand\pgfutil@in@{\pgfutil@backslash@as@other}{\pgf@marshal}}%
+ \pgf@marshal
+ \ifpgfutil@in@
+ \def\pgf@marshal{#2}%
+ \else
+ \def\pgf@marshal{#3}%
+ \fi
+ \pgf@marshal
+ }%
+\fi
+
+\pgfutil@IfUndefined{pgfapplistnewempty}{%
+ \immediate\write16{Package pgfplots: loading complementary utilities for your pgf version...}
+ \csname newtoks\endcsname\t@pgf@toka
+ \csname newtoks\endcsname\t@pgf@tokb
+ \csname newtoks\endcsname\t@pgf@tokc
+ \gdef\pgfutil@advancestringcounter{\pgfplotsutil@advancestringcounter}%
+ \input pgfplotsoldpgfsupp_pgfutil-common-lists.tex
+}{}%
+
+\pgfutil@IfUndefined{pgfmathiftrigonometricusesdeg}{%
+ \pgfutil@ifundefined{pgfmathdeclarefunction}{%
+ % PGF 2.00 !? Well, trig format won't work here.
+ }{%
+ \input pgfplotsoldpgfsupp_trig_format.code.tex
+ }%
+}{}%
+
+\def\pgfmathfloat@install@unimplemented@broken#1{%
+ \expandafter\pgfmathfloat@prepareuninstallcmd\csname pgfmath@#1@\endcsname%
+ \expandafter\def\csname pgfmath#1@\endcsname##1{\pgfmathfloat@notimplemented{#1}}%
+}
+
+\ifx\pgfmathfloat@install@unimplemented\pgfmathfloat@install@unimplemented@broken
+ \def\pgfmathfloat@install@unimplemented#1{%
+ \expandafter\pgfmathfloat@prepareuninstallcmd\csname pgfmath#1@\endcsname%
+ \expandafter\def\csname pgfmath#1@\endcsname##1{\pgfmathfloat@notimplemented{#1}}%
+ }%
+\fi
+
+
+\ifpgfplots@LUA@supported
+ \def\PATCH@pgfmath@local@function@body#1;{%
+ \def\pgfmath@local@body{#1}%
+ \begingroup%
+ \c@pgf@counta=0\relax%
+ \ifx\pgfmath@local@args\pgfmath@empty%
+ \expandafter\pgfmath@toks\expandafter=\expandafter{\pgfmath@local@body}%
+ \else%
+ \pgfmath@toks={}%
+ \expandafter\pgfmath@local@function@@body\pgfmath@local@args,,%
+ \fi%
+ \xdef\pgfmath@local@temp{%
+ \noexpand\pgfmathnotifynewdeclarefunction{\pgfmath@local@name}{\the\c@pgf@counta}%
+ {\the\pgfmath@toks}%
+ }%
+ \endgroup%
+ \pgfmath@local@temp%
+ }
+ % #1: the name
+ % #2: the number of arguments <n>
+ % #3: a math expression containing '#1', '#2', ... ,'#'<n>
+ % This callback is overwritten by pgflibraryluamath.
+ \def\PATCH@pgfmathnotifynewdeclarefunction#1#2#3{%
+ \pgfmathdeclarefunction{#1}{#2}{\pgfmathparse{#3}}%
+ }%
+ %
+ % currently, pgfplots does NOT call directly call any TeX macros
+ % from this library - but it relies on the fact that "trig
+ % format", \pgfmathsetseed and other configuration macros also
+ % mirror their values in LUA.
+ % And this mirroring is done in library luamath:
+ \def\pgfplots@glob@TMPa{3.0.0}%
+ \ifx\pgfversion\pgfplots@glob@TMPa
+ % 3.0.0 does not have the (correct) luamath library.
+ \let\pgfmathnotifynewdeclarefunction=\PATCH@pgfmathnotifynewdeclarefunction
+ \let\pgfmath@local@function@body=\PATCH@pgfmath@local@function@body
+ \pgfplotsusecompatibilityfile{pgflibraryluamath.code.tex}
+ \else
+ \let\PATCH@pgfmathnotifynewdeclarefunction@orig=\pgfmathnotifynewdeclarefunction
+ \let\PATCH@pgfmathsetseed@pgfbasic = \pgfmathsetseed
+ \pgfutil@IfFileExists{pgflibraryluamath.code.tex}{%
+ % ah - we have a very recent version of PGF.
+ % Well, it will hopefully come with a suitable version of the
+ % luamath library! Use it.
+ \usepgflibrary{luamath}%
+ }{%
+ % hm. PGF 2.10 ?
+ %
+ % FIXME
+ %\pgfplots@LUA@supportedfalse
+ }%
+ %
+ \gdef\pgfplots@glob@TMPa{1}% "is up to date = 1"
+ \def\pgfplots@glob@TMPa{3.0.1}%
+ \ifx\pgfversion\pgfplots@glob@TMPa
+ \gdef\pgfplots@glob@TMPa{0}% "is up to date = 0"
+ \else
+ \def\pgfplots@glob@TMPa{3.0.1a}%
+ \ifx\pgfversion\pgfplots@glob@TMPa
+ \gdef\pgfplots@glob@TMPa{0}% "is up to date = 0"
+ \fi
+ \fi
+ \if0\pgfplots@glob@TMPa
+ % 3.0.1 does not have the (correct) luamath library.
+ \pgfutil@directlua{%
+ package.loaded["pgf.luamath.functions"]=nil;
+ package.loaded["pgf.luamath.parser"]=nil;
+ pgfluamathfunctions = nil;
+ pgfluamathparser = nil}
+ \pgfplotsusecompatibilityfile{pgflibraryluamath.code.tex}
+ % ATTENTION: see 'pgfplots.lua' which ALSO loads these items
+ % FIXME : some .lua files reference outdated
+ % tonumber/tostring functions!
+ \pgfutil@directlua{%
+ pgfplots.pgfluamathfunctions = pgfluamathfunctions;
+ pgfplots.pgfluamathparser = pgfluamathparser}%
+ \let\pgfmathnotifynewdeclarefunction@orig=\PATCH@pgfmathnotifynewdeclarefunction@orig
+ \let\pgfmathsetseed@pgfbasic=\PATCH@pgfmathsetseed@pgfbasic
+ \pgfplots@log4{luamath library shipped with pgf \pgfversion\space is outdated; using a substitute shipped with pgfplots}%
+ \else
+ \pgfplots@log4{luamath library shipped with pgf \pgfversion\space is up-to-date}%
+ \fi
+ \fi
+\fi
+
+\def\pgf@plotgnuplot@luatex@eight@seven[#1]#2{%
+ \pgf@resample@plottrue%
+ \pgfutilpreparefilename{#1.gnuplot}%
+ \let\pgf@plotgnuplotfile=\pgfretval
+ \pgfutilpreparefilename{#1.table}%
+ \let\pgf@plottablefile=\pgfretval
+ \let\pgf@plottablefile@quoted=\pgfretvalquoted
+ % Check, whether it is up-to-date
+ \openin\pgfutil@inputcheck=\pgf@plotgnuplotfile\relax
+ \ifeof\pgfutil@inputcheck%
+ \else%
+ \pgfutil@read\pgfutil@inputcheck to\pgf@temp% ignored
+ \pgfutil@read\pgfutil@inputcheck to\pgf@plot@line%
+ \closein\pgfutil@inputcheck
+ \edef\pgf@plot@code{#2\space}%
+ \ifx\pgf@plot@code\pgf@plot@line%
+ \openin\pgfutil@inputcheck=\pgfretval\relax
+ \ifeof\pgfutil@inputcheck%
+ \else%
+ \closein\pgfutil@inputcheck
+ \pgf@resample@plotfalse%
+ \fi%
+ \fi%
+ \fi
+ \ifpgf@resample@plot%
+ \immediate\openout\pgf@plotwrite=\pgf@plotgnuplotfile\relax
+ \immediate\pgfutil@write\pgf@plotwrite{\pgf@gnuplot@head}%
+ \immediate\pgfutil@write\pgf@plotwrite{#2}%
+ \immediate\closeout\pgf@plotwrite%
+ \pgfutil@shellescape{%
+ \pgfkeysvalueof{/pgf/plot/gnuplot call} \pgf@plotgnuplotfile}%
+ \fi%
+% \let\pgf@savedparsexyline=\pgf@parsexyline%
+% \let\pgf@parsexyline=\pgf@parsegnuplotxyline%
+ \pgfplotxyfile{\pgf@plottablefile}%
+% \let\pgf@parsexyline=\pgf@savedparsexyline%
+}
+
+\pgfutil@IfUndefined{pgfutil@shellescape}{%
+ \def\pgfutil@shellescape{\pgfplots@shellescape}%
+ \let\pgf@plotgnuplot=\pgf@plotgnuplot@luatex@eight@seven
+}{%
+ % ok, plot function is up-to-date
+}%
+
+\def\pgfmathfloatmod@broken#1#2{%
+ \begingroup
+ \pgfmathfloatdivide@{#1}{#2}%
+ \pgfmathfloatint@{\pgfmathresult}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}%
+ \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+\ifx\pgfmathfloatmod@\pgfmathfloatmod@broken
+ \def\pgfmathfloatmod@#1#2{%
+ \begingroup
+ \pgfmathfloattoint{#1}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloattoint{#2}%
+ \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ \c@pgfmath@counta=\pgfmathfloat@loc@TMPa\relax
+ \divide\c@pgfmath@counta by\pgfmathfloat@loc@TMPb\relax
+ \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}%
+ %
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}%
+ \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ }
+\fi
+
+\pgfutil@IfUndefined{pgfutilsolvetwotwoleqfloat}{%
+ \input pgfplotsoldpgfsupp_leq.code.tex
+}{}%
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_misc.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_misc.code.tex
new file mode 100644
index 0000000000..5d1188e856
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_misc.code.tex
@@ -0,0 +1,885 @@
+% ======================================================
+% compatibility with PGF 2.10
+% ======================================================
+%
+%%% 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.
+%%%
+%%% It contains a couple of patches such that selected changes which
+%%% are also part of PGF/TikZ (and can be found in the development
+%%% version of PGF/TikZ) are available within pgfplots.
+%%%
+%%% Typically, these modifications have been done by the pgfplots team
+%%% as contribution to PGf/TIKZ
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+\def\pgfdeclarelayer#1{%
+ \pgfutil@ifundefined{pgf@layerbox@#1}{%
+ \expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerbox@#1\endcsname%
+ \expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerboxsaved@#1\endcsname%
+ }{}%
+}
+
+\def\tikz@key@name@path@wrong#1#2{%
+ \tikz@addmode{%
+ \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round%
+ \pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath%
+ \ifx\tikz@intersect@namedpaths\pgfutil@empty%
+ \else%
+ \tikz@intersect@namedpaths%
+ \pgfutil@ifundefined{tikz@intersect@path@name@#1}{}%
+ {%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@intersect@@temppath%
+ \expandafter\expandafter\expandafter{\csname tikz@intersect@path@name@#1\endcsname}%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@intersect@temppath%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@intersect@temppath\tikz@intersect@temppath}%
+ }%
+ \fi%
+ \tikz@intersect@addto@path@names{#1}{#2}%
+ }%
+}%
+
+\def\tikz@key@name@path@new#1#2{%
+ \tikz@addmode{%
+ \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round%
+ \pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath%
+ \ifx\tikz@intersect@namedpaths\pgfutil@empty%
+ \else%
+ \tikz@intersect@namedpaths%
+ \fi%
+ \tikz@intersect@addto@path@names{#1}{#2}%
+ }%
+}%
+
+\ifx\tikz@key@name@path@wrong\tikz@key@name@path
+ \let\tikz@key@name@path=\tikz@key@name@path@new
+\fi
+
+\def\pgfutil@insertatbegincurrentpagefrombox@WRONG#1{%
+ \global\setbox\pgfutil@abb\hbox{\unhbox\pgfutil@abb#1}%
+}
+
+% needed for dvipdfmx and shader=interp
+\def\pgfutil@insertatbegincurrentpagefrombox@FIXED#1{%
+ \edef\pgf@temp{\the\wd\pgfutil@abb}%
+ \global\setbox\pgfutil@abb\hbox{%
+ \unhbox\pgfutil@abb
+ %
+ % the order in which \pgfutil@insertatbegincurrentpagefrombox
+ % matters unless we make the following -shift!
+ % To see this, consider writing two such statements. The second
+ % one will (naturally) be placed more to the right, although there
+ % is no apparent reason why it should.
+ %
+ % CF observed problems when placing patterns in XObjects without
+ % this skip (dvipdfmx driver for pgfplots shader=interp)
+ \hskip-\pgf@temp\relax
+ #1%
+ }%
+}
+\expandafter\ifx\csname pgfutil@insertatbegincurrentpagefrombox\endcsname\pgfutil@insertatbegincurrentpagefrombox@WRONG
+ \let\pgfutil@insertatbegincurrentpagefrombox=\pgfutil@insertatbegincurrentpagefrombox@FIXED
+\fi
+
+% check if \endtikzpicture deals with layerlist:
+\expandafter\pgfutil@in@\expandafter\pgf@remember@layerlist@globally\expandafter{\endtikzpicture}%
+\ifpgfutil@in@
+\else
+ \def\endtikzpicture{%
+ \tikz@atend@picture%
+ \global\let\pgf@shift@baseline@smuggle=\pgf@baseline%
+ \global\let\pgf@trimleft@final@smuggle=\pgf@trimleft%
+ \global\let\pgf@trimright@final@smuggle=\pgf@trimright%
+ \global\let\pgf@remember@smuggle=\ifpgfrememberpicturepositiononpage%
+ \pgf@remember@layerlist@globally
+ \endscope%
+ \let\pgf@baseline=\pgf@shift@baseline@smuggle%
+ \let\pgf@trimleft=\pgf@trimleft@final@smuggle%
+ \let\pgf@trimright=\pgf@trimright@final@smuggle%
+ \let\ifpgfrememberpicturepositiononpage=\pgf@remember@smuggle%
+ \pgf@restore@layerlist@from@global
+ \endpgfpicture}
+\fi
+
+% ======================================================
+% compatibility with PGF 2.0
+% ======================================================
+\def\pgfutil@gobble@until@relax#1\relax{}
+
+\expandafter\ifx\csname w@pgf@writea\endcsname\relax
+\csname newwrite\endcsname\w@pgf@writea
+\fi
+
+\expandafter\ifx\csname r@pgf@reada\endcsname\relax
+\csname newread\endcsname\r@pgf@reada
+\fi
+\let\pgfutil@inputcheck=\r@pgf@reada
+
+\pgfutil@ifundefined{pgf@texdist@protect}{%
+ \def\pgf@texdist@protect{}%
+}{}
+
+% 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
+}%
+
+
+%%%%%%%
+%%%%%%%
+
+% from pgfmoduleshapes.code.tex:
+% Invoke an anchor
+\def\pgf@sh@reanchor#1#2{%
+ \pgfutil@ifundefined{pgf@anchor@#1@#2}%
+ {%
+ \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}%
+ }%
+ }%
+ {\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)
+
+\def\pgfutil@loop#1\pgfutil@repeat{\def\pgfutil@body{#1}\pgfutil@iterate}
+\def\pgfutil@iterate{\pgfutil@body \let\pgfutil@next\pgfutil@iterate \else\let\pgfutil@next\relax\fi \pgfutil@next}
+\let\pgfutil@repeat=\fi % this makes \loop...\if...\repeat skippable
+
+\def\pgfqpointxy#1#2{%
+ \pgf@x=#1\pgf@xx%
+ \advance\pgf@x by #2\pgf@yx%
+ \pgf@y=#1\pgf@xy%
+ \advance\pgf@y by #2\pgf@yy}
+\def\pgfqpointxyz#1#2#3{%
+ \pgf@x=#1\pgf@xx%
+ \advance\pgf@x by #2\pgf@yx%
+ \advance\pgf@x by #3\pgf@zx%
+ \pgf@y=#1\pgf@xy%
+ \advance\pgf@y by #2\pgf@yy%
+ \advance\pgf@y by #3\pgf@zy}
+\def\pgfcoordinate#1#2{%
+ \edef\pgf@temp{#1}%
+ \ifx\pgf@temp\pgfutil@empty% do nothing
+ \else%
+ \pgf@process{\pgfpointtransformed{#2}}%
+ \expandafter\gdef\csname pgf@sh@ns@#1\endcsname{coordinate}%
+ \expandafter\xdef\csname pgf@sh@np@#1\endcsname{%
+ \noexpand\def\noexpand\centerpoint{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ }
+ \expandafter\gdef\csname pgf@sh@nt@#1\endcsname{{1}{0}{0}{1}{0pt}{0pt}}%
+ \expandafter\global\expandafter\let\csname pgf@sh@ma@#1\endcsname\pgfutil@empty%
+ \expandafter\gdef\csname pgf@sh@pi@#1\endcsname{\pgfpictureid}%
+ \fi%
+}
+% 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{%
+ \ifmmode#1\else$#1$\fi
+}
+\def\tikzifinpicture#1#2{%
+ \pgfutil@ifundefined{filldraw}{#2}{#1}%
+}%
+
+\def\tikz@fig@scan@name(#1){%
+ \pgfkeysvalueof{/tikz/name/.@cmd}#1\pgfeov% CF : this is now ALWAYS consistent with 'name=' option; allows overrides.
+ \tikz@@scan@fig}%
+
+\tikzoption{ybar}[]{\let\tikz@plot@handler=\pgfplothandlerybar}
+\tikzoption{xbar}[]{\let\tikz@plot@handler=\pgfplothandlerxbar}
+\tikzoption{ybar interval}[]{\let\tikz@plot@handler=\pgfplothandlerybarinterval}
+\tikzoption{xbar interval}[]{\let\tikz@plot@handler=\pgfplothandlerxbarinterval}
+\tikzoption{const plot}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto}
+\tikzoption{const plot mark left}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto}
+\tikzoption{const plot mark right}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkright}
+\tikzoption{const plot mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkmid}
+\tikzoption{jump mark right}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkright}
+\tikzoption{jump mark left}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkleft}
+\tikzoption{jump mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkmid}
+
+\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
+ \ifx\tikz@temp\tikz@plot@mark
+ \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}%
+ }}
+\def\tikz@@@plot{%
+ \def\pgfplotlastpoint{\pgfpointorigin}%
+ \tikz@plot@handler%
+ \tikz@plot@data%
+ \global\let\tikz@@@temp=\pgfplotlastpoint%
+ \ifx\tikz@plot@mark\pgfutil@empty%
+ \else%
+ % Marks are drawn after the path.
+ \setbox\tikz@figbox=\hbox{%
+ \unhbox\tikz@figbox%
+ \hbox{{%
+ \pgfinterruptpath%
+ \pgfscope%
+ \let\tikz@options=\pgfutil@empty%
+ \let\tikz@transform=\pgfutil@empty%
+ \tikzset{every mark}%
+ \tikz@options%
+ \ifx\tikz@mark@list\pgfutil@empty%
+ \pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}%
+ \else
+ \pgfplothandlermarklisted{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}{\tikz@mark@list}%
+ \fi
+ \tikz@plot@data%
+ \endpgfscope
+ \endpgfinterruptpath%
+ }}%
+ }%
+ \fi%
+ \global\setbox\tikz@tempbox=\copy\tikz@figbox%
+ %\global\let\tikz@after@path@smuggle=\tikz@after@path
+ \endgroup%
+ \setbox\tikz@figbox=\box\tikz@tempbox%
+ \tikz@make@last@position{\tikz@@@temp}%
+ %\expandafter\tikz@scan@next@command\tikz@after@path@smuggle%
+ \tikz@scan@next@command%
+}
+
+
+
+
+% ======================================================
+
+
+\newif\ifpgfmathcomparison
+
+% Assigns \pgfmathresult to 1.0 if #1 ~= #1.
+%
+% It will also set the boolean \ifpgfmathcomparison accordingly
+% (globally).
+\def\pgfmathapproxequalto#1#2{%
+ \edef\pgfmath@marshal{%
+ \noexpand\pgfmathparse{#2}
+ \noexpand\let\noexpand\pgfmath@arg\noexpand\pgfmathresult%
+ \noexpand\pgfmathparse{#1}%
+ }%
+ \pgfmath@marshal%
+ \pgfmathapproxequalto@{\pgfmathresult}{\pgfmath@arg}}
+\def\pgfmathapproxequalto@#1#2{%
+ \begingroup%
+ \pgfmath@x#1pt%
+ \pgfmath@y#2pt%
+ \advance\pgfmath@x-\pgfmath@y%
+ \ifdim\pgfmath@x<0pt
+ \multiply\pgfmath@x by-1
+ \fi
+ \ifdim\pgfmath@x<0.0001pt\relax%
+ \def\pgfmathresult{1.0}%
+ \global\pgfmathcomparisontrue
+ \else%
+ \def\pgfmathresult{0.0}%
+ \global\pgfmathcomparisonfalse
+ \fi%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup%
+}
+
+\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 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}\pgfmarktext@
+ \ifpgfmarktext@usetikznode
+ \expandafter\node\expandafter[\pgfmarktext@style]{\pgfmarktext@};
+ \else
+ \expandafter\pgftext\expandafter[\pgfmarktext@style]{\pgfmarktext@}%
+ \fi
+}
+
+% A fix for the overlay option and matrices:
+\def\pgf@matrix@startcell{%
+ %
+ % Step 1: Init the list of nodes for this cell
+ %
+ \let\pgf@nodecallback=\pgf@matrix@nodecallback%
+ %
+ % Step 2: Setup the bounding box
+ %
+ \pgfinterruptboundingbox%
+ %
+ % Step 3: Reset the transformation matrix
+ %
+ \pgftransformreset%
+ %
+ % Step 4: Collect everything in a cell box
+ %
+ \setbox\pgf@matrix@cell=\hbox\bgroup\bgroup%
+ % make sure that cell pictures are not affected if matrizes have
+ % 'overlay' option on:
+ \pgf@relevantforpicturesizetrue
+ \pgfsys@beginpicture%
+ \normalbaselines%
+ % Find out whether the cell is empty:
+ \pgfutil@ifnextchar\let%
+ {% ok, candidate, check following symbol
+ \afterassignment\pgf@matrix@empty@check\let\pgf@matrix@temp=% get rid of \let
+ }%
+ {% no, not empty
+ \pgf@matrix@empty@cell@false%
+ \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
+}
+
+% From pgfcorescopes.code.tex:
+\def\pgfresetboundingbox{%
+ \global\pgf@picmaxx=-16000pt\relax%
+ \global\pgf@picminx=16000pt\relax%
+ \global\pgf@picmaxy=-16000pt\relax%
+ \global\pgf@picminy=16000pt\relax%
+}%
+
+% from pgfcorepathconstruct.code.tex:
+
+
+\def\pgfpatharctomaxstepsize{45}
+
+% A specialized arc operation for an arc on an (axis--parallel) ellipse.
+%
+% In contrast to \pgfpatharc, it explicitly interpolates start- and end points.
+%
+% In contrast to \pgfpatharcto, this routine is numerically stable and
+% quite fast since it relies on a lot of precomputed information.
+%
+% #1 center of ellipse
+% #2 angle of last path position inside of the ellipse
+% #3 end angle
+% #4 end point (a \pgfpoint)
+% #5 xradius
+% #6 yradius
+% #7 the ratio xradius/yradius of the ellipse
+% #8 the ratio yradius/xradius of the ellipse
+% Example:
+% \def\cx{1cm}% center x
+% \def\cy{1cm}% center y
+% \def\startangle{0}%
+% \def\endangle{45}%
+% \def\a{5cm}% xradius
+% \def\b{10cm}% yradius
+% \pgfmathparse{\a/\b}\let\abratio=\pgfmathresult
+% \pgfmathparse{\b/\a}\let\baratio=\pgfmathresult
+%
+% \pgfpathmoveto{\pgfpoint{\cx+\a*cos(\startangle)}{\cy+\b*sin(\startangle)}}%
+% \pgfpatharctoprecomputed
+% {\pgfpoint{\cx}{\cy}}
+% {\startangle}
+% {\endangle}
+% {\pgfpoint{\cx+\a*cos(\endangle)}{\cy+\b*sin(\endangle)}}%
+% {\a}
+% {\b}
+% {\abratio}
+% {\baratio}
+%
+\def\pgfpatharctoprecomputed#1#2#3#4#5#6#7#8{%
+ \begingroup
+ % Implementation idea:
+ %
+ % let
+ % m = center (#1)
+ % \gamma_0 = start angle
+ % \gamma_1 = end angle
+ % a = x radius
+ % b = y radius
+ %
+ % an axis parallel ellipse is parameterized by
+ % C(\gamma) = m + ( a cos(\gamma), b sin(\gamma) ), \gamma in [0,360].
+ %
+ % Now, consider the segment \gamma(t),
+ % \gamma:[0,1] -> [\gamma_0,\gamma_1],
+ % t -> \gamma_0 + t(\gamma_1 - \gamma_0)
+ % and
+ % C(\gamma(t)) which is defined on [0,1].
+ %
+ % I'd like to approximate the arc by one or more cubic bezier
+ % splines which interpolate through the last and first provided
+ % points.
+ %
+ % In general, a Bezier spline C:[0,1] -> \R of order n fulfills
+ % C'(0) = n ( P_1 - P_0 ),
+ % C'(1) = n ( P_n - P_{n-1} ).
+ % For n=3 and given P_0 and P_3, I can directly compute P_1 and P_2 once I know
+ % the derivatives at t=0 and t=1.
+ %
+ % The derivatives in our case are
+ % ( C \circ \gamma )'(t) = C'[\gamma(t)] * \gamma'(t)
+ % = ( -a pi/180 sin(\gamma(t)), b pi/180 cos(\gamma(t)) ) * (\gamma_1 - \gamma_0).
+ % The pi/180 comes into play since we are working with degrees.
+ %
+ % Expression (C\circ\gamma)'(0) using P_0 and (C \circ \gamma)'(1)
+ % using P_3 yields the expressions
+ % (C \circ \gamma)'(0) =
+ % pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_0^y - my), b/a (P_0^x - mx) ]
+ % (C \circ \gamma)'(1) =
+ % pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_3^y - my), b/a (P_3^x - mx) ]
+ %
+ % defining
+ % scaleA = a/b * pi / (3*180) * (\gamma_1 - \gamma_0)
+ % and
+ % scaleB = b/a * pi / (3*180) * (\gamma_1 - \gamma_0)
+ % yields the direct expressions for the intermediate bezier
+ % control points
+ %
+ % P_1 = [
+ % P_0^x - scaleA* ( P_0^y -my),
+ % P_0^y + scaleB* ( P_0^x -mx) ]
+ % and
+ % P_2 = [
+ % P_3^x + scaleA* ( P_3^y -my),
+ % P_3^y - scaleB* ( P_3^x -mx) ].
+ %
+ % This works fast, with few operations, if
+ % - a/b and b/a are known in advance
+ % - P_0 and P_3 are known in advance
+ % - \gamma_0 and \gamma_1 are known.
+ %
+ % It is also reliable if (\gamma_1 - \gamma_0) is small
+ %
+ \pgf@process{#1}%
+ \edef\pgfpath@center@x{\the\pgf@x}%
+ \edef\pgfpath@center@y{\the\pgf@y}%
+ \def\pgfpath@completearcend{#4}%
+ % compute scale (#3-#2) * pi/(3*180) = (#3 - #2) * pi/27 * 1/20
+ % splitting pi/(3*180) into two scales has higher TeX accuracy
+ \pgf@xa=#2pt
+ \pgf@xb=#3pt
+ \edef\pgfpath@startangle{#2pt}%
+ \edef\pgfpath@endangle{\pgf@sys@tonumber\pgf@xb}%
+ %
+ \pgf@ya=\pgf@xb
+ \advance\pgf@ya by-\pgf@xa
+ %
+ \ifx\pgfpatharctomaxstepsize\pgfutil@empty
+ \def\pgfpath@N{1}%
+ \pgf@xc=\pgf@ya
+ \else
+ \pgf@xc=\pgf@ya% compute N = floor((gamma_1 - gamma_0) / max) +1
+ \ifdim\pgf@xc<0pt
+ \multiply\pgf@xc by-1
+ \fi
+ \divide\pgf@xc by\pgfpatharctomaxstepsize\relax
+ \afterassignment\pgfutil@gobble@until@relax
+ \c@pgf@counta=\the\pgf@xc\relax
+ \advance\c@pgf@counta by1
+ \edef\pgfpath@N{\the\c@pgf@counta}%
+ %
+ \pgf@xc=\pgf@ya
+ \divide\pgf@xc by\c@pgf@counta
+ \fi
+ %
+ \edef\pgfpath@h{\pgf@sys@tonumber\pgf@xc}%
+ %
+%\message{pgfpathellipse: using N =\pgfpath@N\space spline points y0 = \pgfpath@startangle, y0+i*h, yN=\pgfpath@endangle, i=1,...,(\pgfpath@N-1), with h=\pgfpath@h\space mesh width (total arc angle \pgf@sys@tonumber\pgf@ya).}%
+ %
+ %
+ \pgf@xc=0.116355283466289\pgf@xc % pi/27
+ \divide\pgf@xc by20
+ \pgf@xa=#7\pgf@xc
+ \edef\pgfpath@scale@A{\pgf@sys@tonumber\pgf@xa}%
+ \pgf@xa=#8\pgf@xc
+ \edef\pgfpath@scale@B{\pgf@sys@tonumber\pgf@xa}%
+ %
+ % compute intermediate spline segments for
+ % i = 1,...,N-1
+ % this is a no-op for N=1.
+ \c@pgf@countd=1
+ \pgfutil@loop
+ \ifnum\c@pgf@countd<\pgfpath@N\relax
+ %
+ \pgf@xa=\pgfpath@startangle % compute \pgf@xa = y_0 + i*h
+ \pgf@xb=\pgfpath@h pt
+ \multiply\pgf@xb by\c@pgf@countd
+ \advance\pgf@xa by\pgf@xb
+ \edef\pgfpath@angle@i{\pgf@sys@tonumber\pgf@xa}%
+%\message{angle \the\c@pgf@countd: \pgfpath@angle@i...}%
+ %
+ \pgfpatharcofellipse@{%
+ \pgfpoint
+ {\pgfpath@center@x + #5*cos(\pgfpath@angle@i)}
+ {\pgfpath@center@y + #6*sin(\pgfpath@angle@i)}
+ }%
+ %
+ \advance\c@pgf@countd by1
+ \pgfutil@repeat
+ %
+ % compute final spline segment. It only differs insofar as the
+ % final point is already known explicitly and should be
+ % interpolated without additional math error.
+%\message{angle \pgfpath@N: \pgfpath@endangle...}%
+ \pgfpatharcofellipse@{\pgfpath@completearcend}%
+ \endgroup
+}%
+\def\pgfpatharcofellipse@#1{%
+ \begingroup
+ \pgf@process{#1}%
+ \edef\pgfpath@endpt{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfpathcurveto{
+ \begingroup
+ \global\pgf@x=\pgf@path@lastx
+ \global\pgf@y=\pgf@path@lasty
+ \pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x
+ \pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y
+ \global\advance\pgf@x by-\pgfpath@scale@A\pgf@ya
+ \global\advance\pgf@y by \pgfpath@scale@B\pgf@xa
+ \endgroup
+ }{%
+ \begingroup
+ \pgfpath@endpt
+ \pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x
+ \pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y
+ \global\advance\pgf@x by \pgfpath@scale@A\pgf@ya
+ \global\advance\pgf@y by-\pgfpath@scale@B\pgf@xa
+ \endgroup
+ }{%
+ \pgfpath@endpt
+ }%
+ \endgroup
+}
+
+% bugfix for pgf 2.10, pgfmathfunctions.basic.code.tex :
+%
+\newif\ifpgfmath@divide@period
+\def\pgfmathdivide@#1#2{%
+ \begingroup%
+ \pgfmath@x=#1pt\relax%
+ \pgfmath@y=#2pt\relax%
+ \let\pgfmath@sign=\pgfmath@empty%
+ \ifdim0pt=\pgfmath@y%
+ \pgfmath@error{You've asked me to divide `#1' by `#2', %
+ but I cannot divide any number by `#2'}%
+ \fi%
+ \afterassignment\pgfmath@xa%
+ \c@pgfmath@counta\the\pgfmath@y\relax%
+ \ifdim0pt=\pgfmath@xa%
+ \divide\pgfmath@x by\c@pgfmath@counta%
+ \else%
+ \ifdim0pt>\pgfmath@x%
+ \def\pgfmath@sign{-}%
+ \pgfmath@x=-\pgfmath@x%
+ \fi%
+ \ifdim0pt>\pgfmath@y%
+ \expandafter\def\expandafter\pgfmath@sign\expandafter{\pgfmath@sign-}%
+ \pgfmath@y=-\pgfmath@y%
+ \fi%
+ \ifdim1pt>\pgfmath@y%
+ \pgfmathreciprocal@{\pgfmath@tonumber{\pgfmath@y}}%
+ \pgfmath@x=\pgfmath@sign\pgfmathresult\pgfmath@x%
+ \else%
+ \def\pgfmathresult{0}%
+ \pgfmath@divide@periodtrue%
+ \c@pgfmath@counta=0\relax%
+ \pgfmathdivide@@%
+ \pgfmath@x=\pgfmath@sign\pgfmathresult pt\relax%
+ \fi%
+ \fi%
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}
+\def\pgfmath@small@number{0.00002}
+\def\pgfmathdivide@@{%
+ \let\pgfmath@next=\relax%
+ \ifdim\pgfmath@small@number pt<\pgfmath@x%
+ \ifdim\pgfmath@small@number pt<\pgfmath@y%
+ \ifdim\pgfmath@y>\pgfmath@x%
+ \ifpgfmath@divide@period%
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult.}%
+ \pgfmath@divide@periodfalse%
+ \fi%
+ \pgfmathdivide@dimenbyten\pgfmath@y%
+ \ifdim\pgfmath@y>\pgfmath@x%
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult0}%
+ \fi%
+ \else%
+ \c@pgfmath@counta=\pgfmath@x%
+ \c@pgfmath@countb=\pgfmath@y%
+ \divide\c@pgfmath@counta by\c@pgfmath@countb%
+ \pgfmath@ya=\c@pgfmath@counta\pgfmath@y%
+ \advance\pgfmath@x by-\pgfmath@ya%
+ \def\pgfmath@next{%
+ \toks0=\expandafter{\pgfmathresult}%
+ \edef\pgfmathresult{\the\toks0 \the\c@pgfmath@counta}%
+ }%
+ \ifpgfmath@divide@period
+ \else
+ % we are behind the period. It may happen that the
+ % result is more than one digit - in that case,
+ % introduce special handling:
+ \ifnum\c@pgfmath@counta>9 %
+ \expandafter\pgfmathdivide@advance@last@digit\pgfmathresult CCCCC\@@
+ \advance\c@pgfmath@counta by-10 %
+ \ifnum\c@pgfmath@counta=0
+ \let\pgfmath@next=\relax
+ \fi
+ \fi
+ \fi
+ \pgfmath@next
+ \fi%
+ \let\pgfmath@next=\pgfmathdivide@@%
+ \fi%
+ \fi%
+ \pgfmath@next%
+}
+
+% advances the last digit found in the number. Any missing digits are
+% supposed to be filled with 'C'.
+\def\pgfmathdivide@advance@last@digit#1.#2#3#4#5#6#7\@@{%
+ \pgfmath@ya=\pgfmathresult pt %
+ \if#2C%
+ \pgfmath@xa=1pt %
+ \else
+ \if#3C%
+ \pgfmath@xa=0.1pt %
+ \else
+ \if#4C%
+ \pgfmath@xa=0.01pt %
+ \else
+ \if#5C%
+ \pgfmath@xa=0.001pt %
+ \else
+ \if#6C%
+ \pgfmath@xa=0.0001pt %
+ \else
+ \pgfmath@xa=0.00001pt %
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \advance\pgfmath@ya by\pgfmath@xa
+ \edef\pgfmathresult{\pgfmath@tonumber@notrailingzero\pgfmath@ya}%
+}%
+
+{
+\catcode`\p=12
+\catcode`\t=12
+\gdef\Pgf@geT@NO@TRAILING@ZERO#1.#2pt{%
+ #1.%
+ \ifnum#2=0 \else #2\fi
+}
+}
+\def\pgfmath@tonumber@notrailingzero#1{\expandafter\Pgf@geT@NO@TRAILING@ZERO\the#1}
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex
new file mode 100644
index 0000000000..dc36ce9277
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex
@@ -0,0 +1,567 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Do 31. Dez 19:01:21 CET 2015 %%%
+
+
+
+% Copyright 2006 by Till Tantau
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreexternal.code.tex,v 1.22 2015/08/29 10:15:21 cfeuersaenger Exp $
+
+
+
+\newif\ifpgfexternal@aux@in@dpth
+\newif\ifpgfexternal@info
+
+\pgfkeys{
+ /pgf/images/include external/.code={\pgfimage{#1}},
+ /pgf/images/aux in dpth/.is if=pgfexternal@aux@in@dpth,
+ /pgf/images/aux in dpth/.default=true,
+ /pgf/images/trim external/.code n args={4}{%
+ \def\pgf@external@kern@left{#1}%
+ \def\pgf@external@kern@bottom{#2}%
+ \def\pgf@external@kern@right{#3}%
+ \def\pgf@external@kern@top{#4}%
+ \ifx\pgf@external@kern@left\pgfutil@empty\def\pgf@external@kern@left{0sp}\fi%
+ \ifx\pgf@external@kern@bottom\pgfutil@empty\def\pgf@external@kern@bottom{0sp}\fi%
+ \ifx\pgf@external@kern@right\pgfutil@empty\def\pgf@external@kern@right{0sp}\fi%
+ \ifx\pgf@external@kern@top\pgfutil@empty\def\pgf@external@kern@top{0sp}\fi%
+ },
+ /pgf/images/trim external={1truein}{1truein}{1truein}{1truein},
+ /pgf/images/external info/.is if=pgfexternal@info,
+ /pgf/images/external info/.default=true,
+}
+
+% The external read/write mechanism is used as follows:
+%
+% In your document, you put a number or all of your pgfpicture (or
+% tikzpicture) environments inside a pair of \beginpgfexternal and
+% \endpgfexternal. The \beginpgfexternal gets one parameter called the
+% graphics name.
+%
+% Once this is done, the next step is to declare the names of your
+% graphics in the document at the beginning using the
+% \pgfdeclaregraphicname command.
+%
+% Now, when you typeset your document, each time a \beginpgfexternal
+% command is encountered, it will be checked whether the corresponding
+% graphics file exists. If this is the case, it will be included and
+% the code between \beginpgfexternal and \endpgfexternal is
+% ignored. Otherwise, the code is executed normally.
+%
+% Things change when you run tex on your file with the \jobname set to
+% the name of a decalred graphics name. In this case, only your
+% graphic will be typeset, the rest of the document will be "thrown away".
+% To be more precise, everything is gobbled up to the beginning
+% of the first \beginpgfexternal with the given graphics name. Then,
+% the content of the "environment" is put in a box (this "environment"
+% need not contain a graphics, it may contain anything that can be put
+% in a box). Then a single page is output whose size is exactly the
+% size of the picture.
+%
+% So, once you have run tex repeatedly, each time with the jobname set
+% to each of the graphics, you can then run tex on the whole document
+% and this will cause all graphics to be included rather than begin
+% typeset.
+%
+% Finally, once all the graphics have been created, you can also say
+% \input pgfexternal.tex instead of including pgf/TikZ.
+
+
+\newif\ifpgfexternalreadmainaux
+\pgfexternalreadmainauxtrue
+
+% Tells pgf which jobname is the name of the real file
+%
+% #1 = name
+%
+% Description:
+%
+% This command is used to tell pgf that the file named #1 should be
+% typeset normally. If \jobname is not equal to #1, only
+% the graphic called \jobname will be typeset.
+%
+% Example:
+%
+% \pgfrealjobname{survey}
+%
+% Note that afterwards, \jobname will be set to the argument. In our
+% example, \jobname will be 'survey'. This is to accomplish
+% compatibility with aux-file generation.
+
+\def\pgfrealjobname#1{%
+ \global\let\pgfactualjobname=\jobname
+ \edef\pgf@tempa{\expandafter\string\csname #1\endcsname}%
+ \edef\pgf@tempb{\expandafter\string\csname\jobname\endcsname}%
+ \ifx\pgf@tempa\pgf@tempb%
+ \else%
+ \pgf@external@grabshipouttrue%
+ \pgfexternal@nofiles% see also \pgf@external@init@aux@in@dpth
+ \ifpgfexternalreadmainaux
+ % and reset the jobname. This should allow to handle any
+ % \label/\ref constructions which are stored in \jobname.aux (and
+ % which won't be found otherwise)
+ \gdef\jobname{#1}%
+ \fi
+ \ifpgfexternal@aux@in@dpth
+ \csname newwrite\endcsname\w@pgfexternal@auxout
+ \fi
+ \pgfexternal@geometry@compatibility
+ \fi%
+ \gdef\pgfrealjobname##1{}% avoid multiple calls.
+}
+
+\def\pgfexternal@geometry@compatibility{%
+ % check if \usepackage{geometry} is loaded:
+ \pgfutil@ifundefined{geometry}{%
+ }{%
+ % The geometry package hooks into \begin{document}, evaluates
+ % its driver -- and generates \special instructions to set the
+ % paper size.
+ %
+ % Unfortunately, this confuses dvips utterly - and perhaps
+ % other drivers as well.
+ %
+ % Thus, if we currently about to generate some external
+ % graphics, we WANT to disable geometry (it has no purpose in
+ % this context anyway).
+ %
+ % This here works well:
+ \immediate\write16{Package TikZ externalization: calling \string\geometry{driver=none} during externalization.^^J}%
+ \geometry{driver=none}%
+ }%
+}%
+
+\def\pgfexternal@nofiles{%
+ % replace \relax. The \nofiles macros does
+ % \let\makeglossary=\relax
+ % but the glossary.sty calls \renewcommand\makeglossary (which
+ % will fail if \makeglossary=\relax). Stupid, but it works.
+ \let\pgfexternal@nofiles@=\relax
+ \def\relax{\relax}%
+ %
+ % suppress generation of LaTeX .aux, .toc etc files.
+ % generation of these files is not thread-safe.
+ % the \csname \endcsname yields \relax if \nofiles doesn't exist.
+ \csname nofiles\endcsname
+ %
+ \let\relax=\pgfexternal@nofiles@
+}%
+
+\newif\ifpgf@external@grabshipout
+\newbox\pgfexternal@startupbox
+
+\pgfutil@ifundefined{AtBeginDocument}{}{%
+ \AtBeginDocument{%
+ \ifpgf@external@grabshipout%
+ \global\let\pgfexternal@originalshipout=\shipout%
+ \global\def\shipout{\setbox\pgfpic=}%
+ \maxdeadcycles=10000%
+ % Ok, gather everything we have seen up to now in a box. This box
+ % will contain any specials that have been used.
+ {%
+ \output{\global\setbox\pgfexternal@startupbox=\vbox{\csname @begindvi\endcsname\unvbox255}}%
+ \hbox{}\eject%
+ }%
+ \fi%
+ }
+}%
+
+\pgfutil@ifundefined{AtEndDocument}{}{%
+ \AtEndDocument{%
+ \ifpgf@external@grabshipout
+ \pgfutil@ifundefined{pgfexternal@did@a@shipout}{%
+ \pgfexternal@error@no@shipout
+ }{}%
+ \fi
+ }%
+}
+
+% This will be overwritten by the tikz external lib if it is loaded.
+\def\pgfexternal@error@no@shipout{%
+ \pgferror{Sorry, image externalization failed: the resulting image was EMPTY. I tried to externalize '\pgfactualjobname'. Perhaps there was a typo somewhere? Please check that your document contains '\string\beginpgfgraphicnamed{\pgfactualjobname} ... \string\endpgfgraphicnamed'}%
+}%
+
+
+% "Environment" for an external graphic.
+%
+% #1 = graphic name
+%
+% Example:
+%
+% \beginpgfgraphicnamed{main-graphic2}
+% \begin{tikzpicture}
+% ...
+% \end{tikzpicture}
+% \endpgfgraphicnamed
+
+\def\pgf@externalbegin#1{%
+ % First, check whether we wish to grab this graphic:
+ \let\pgf@next=\pgf@external@normal%
+ \ifpgf@external@grabshipout%
+ \edef\pgf@tempa{\expandafter\string\csname #1\endcsname}%
+ \edef\pgf@tempb{\expandafter\string\csname\pgfactualjobname\endcsname}%
+ \ifx\pgf@tempa\pgf@tempb%
+ \let\pgf@next=\pgf@external@grab%
+ \fi%
+ \fi%
+ \pgf@next{#1}%
+}
+
+
+\AtBeginDocument{
+ \let\beginpgfgraphicnamed=\pgf@externalbegin% overwrite definition of pgfexternal.tex if necessary
+ \let\endpgfgraphicnamed=\unskip
+}
+
+
+% Normal operation: Include an external graphic instead of the
+% picture, if such an external picture exists.
+\def\pgf@external@normal#1{%
+ \let\pgf@filename=\pgfutil@empty%
+ \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#1}%
+ \ifx\pgf@filename\pgfutil@empty%
+ % Ok, no such image... Just typeset the picture normally.
+ \let\pgf@next=\relax%
+ \else%
+ \let\pgf@next=\pgf@replacepicturebygraphic%
+ \fi%
+ \pgf@next%
+}
+
+\long\def\pgf@replacepicturebygraphic#1\endpgfgraphicnamed{%
+ \expandafter\pgfincludeexternalgraphics\expandafter{\pgf@filename}\unskip
+}
+
+% This is almost the same as \includegraphics{#1}, but it checks
+% whether '#1.dpth' exists. In such case, it restores the boxes depth
+% stored in #1.dpth.
+%
+% Furthermore, the .dpth file may contain .aux related information
+% collected for the external graphics (references). They start after
+% the first line (if any).
+\def\pgfincludeexternalgraphics#1{%
+ \begingroup
+ \pgfexternalreaddpth{#1}%
+ \pgfkeysifdefined{/pgf/images/include external/#1/.@cmd}{%
+ \pgfkeysgetvalue{/pgf/images/include external/#1/.@cmd}\pgf@tempa
+ \pgfkeyslet{/pgf/images/include external/.@cmd}\pgf@tempa
+ }{}%
+ \setbox1=\hbox{\pgfkeysvalueof{/pgf/images/include external/.@cmd}{#1}\pgfeov}%
+ \ifdim\pgfexternaltrimleft=0sp \else \kern\pgfexternaltrimleft\relax \fi
+ \ifdim\pgfexternaldepth=0pt
+ \box1
+ \else
+ \dimen0=\pgfexternaldepth\relax
+ \hbox{\lower\dimen0 \box1 }%
+ \fi
+ \ifdim\pgfexternaltrimright=0sp \else \kern\pgfexternaltrimright\relax \fi
+ \endgroup
+}
+
+% Reads the .dpth file which contains meta data of the external
+% picture.
+%
+% This command handles the following stuff:
+% - it defines \pgfexternaldepth . The macro contains the contents of
+% a line which does not start with a control sequence (for example a
+% line containing '50pt')
+% - it defines \pgfexternaltrimleft and \pgfexternaltrimright
+% - it checks if the .dpth file contains content stored by means of
+% \pgfexternalstorecommand. If so, the argument of
+% \pgfexternalstorecommand will be restored.
+% - anything else will be appended to the main .aux file, assuming that
+% it contains \label or \ref information (only if the LaTeX switch
+% \if@filesw is \iftrue).
+%
+%
+% #1: the image file name (such that #1.dpth exists)
+\def\pgfexternalreaddpth#1{%
+ % no \begingroup. Handle that manually:
+ \edef\pgfexternalreaddpth@restore{%
+ \noexpand\endlinechar=\the\endlinechar\space
+ \noexpand\catcode`\noexpand\@=\the\catcode`\@\space
+ }%
+ %
+ \def\pgfexternaldepth{0sp}%
+ \def\pgfexternaltrimleft{0sp}%
+ \def\pgfexternaltrimright{0sp}%
+ \endlinechar=-1 % suppress white space at end
+ \catcode`\@=11
+ \openin\r@pgf@reada=#1.dpth
+ \pgfincludeexternalgraphics@read@dpth
+ %
+ \pgfexternalreaddpth@restore
+}%
+%
+% The .dpth consists of 0-N lines, where each is either a single
+% dimension (the box' depth) or something which belongs to the .aux
+% file (such lines will always start with a macro).
+\def\pgfincludeexternalgraphics@read@dpth{%
+ \ifeof\r@pgf@reada
+ \closein\r@pgf@reada
+ \else
+ \read\r@pgf@reada to\pgfincludeexternalgraphics@auxline
+ \ifx\pgfincludeexternalgraphics@auxline\pgfutil@empty
+ \else
+ \expandafter\pgfincludeexternalgraphics@read@dpth@line\pgfincludeexternalgraphics@auxline\pgfincludeexternalgraphics@read@dpth@line@EOI
+ \fi
+ \expandafter\pgfincludeexternalgraphics@read@dpth
+ \fi
+}%
+
+\def\pgfexternal@restore#1{#1}%
+
+\long\def\pgfincludeexternalgraphics@read@dpth@line@getfirst#1#2\pgfincludeexternalgraphics@read@dpth@line@EOI{%
+ \def\pgf@first{#1}%
+}%
+\long\def\pgfincludeexternalgraphics@read@dpth@line#1\pgfincludeexternalgraphics@read@dpth@line@EOI{%
+ \pgfincludeexternalgraphics@read@dpth@line@getfirst#1\pgfincludeexternalgraphics@read@dpth@line@EOI
+ \expandafter\ifcat\expandafter\noexpand\pgf@first\relax
+ % Ah -- the first token is a control sequence. It belongs to
+ % the .aux file.
+ %
+ \expandafter\ifx\pgf@first\pgfexternal@restore
+ % if the first line in the .dpth file starts with the
+ % magic string \pgfexternal@restore, the complete line
+ % will be executed as-is. Example:
+ % \pgfexternal@restore{\def\somevalue{1}}
+ #1%
+ \else
+ % do NOT execute #1! many LaTeX commands don't support it (\label for example)
+ \pgfutil@ifundefined{if@filesw}{%
+ % sorry, .aux file support only for latex
+ }{%
+ % append to main .aux file (for forward references)
+ \if@filesw
+ {%
+ \toks0={#1}%
+ % believe it or not, but the
+ % \def\dpthimport{...}\dpthimport *makes* a
+ % difference! In ensures any occuring `##' characters are properly expanded to `#'.
+ \immediate\write\@auxout{%
+ \noexpand\def\noexpand\dpthimport{\the\toks0}\noexpand\dpthimport}%
+ }%
+ \fi
+ }%
+ \fi
+ \else% it is the depth (which is simply a number for backwards compatibility)
+ \def\pgfexternaldepth{#1}%
+ \fi
+}%
+
+% Stores '#1' (expanded!) into the .dpth file of the currently
+% exported image.
+%
+% This command has only an effect if an image is being exported.
+%
+% The stored contents will be read in the context where
+% /pgf/images/include external is active (i.e. by
+% \pgfexternalreaddpth).
+%
+\def\pgfexternalstorecommand#1{%
+}%
+\def\pgfexternalstorecommand@isexporting#1{%
+ \immediate\write\w@pgfexternal@auxout{\noexpand\pgfexternal@restore{#1}}%
+}%
+
+
+
+% Grab operation: If jobname matches the graphic name, typeset this
+% picture normall.
+% REMARK:
+% this method is also invoked from within the tikz external library.
+\def\pgf@external@grab#1{%
+ \def\pgf@filename{#1}%
+ \ifpgfexternal@aux@in@dpth
+ \begingroup
+ \pgf@external@init@aux@in@dpth
+ \let\G@refundefinedtrue=\pgf@external@grab@refundefinedtrue
+ \fi
+ \gdef\pgf@trimleft@final{0sp}%
+ \gdef\pgf@trimright@final{0sp}%
+ \setbox\pgfpic=\hbox\bgroup\bgroup%
+ \let\endpgfgraphicnamed=\pgf@externalend%
+}
+
+{\catcode`\^=12 \gdef\pgfexternal@hat{^}}
+
+\expandafter\let\expandafter\pgf@external@grab@refundefinedtrue@orig\csname G@refundefinedtrue\endcsname
+
+\def\pgf@external@grab@refundefinedtrue{%
+ \pgf@external@grab@refundefinedtrue@orig
+ \begingroup
+ \def\n{\pgfexternal@hat\pgfexternal@hat J}%
+ \pgfexternalstorecommand{%
+ \pgf@external@grab@refundefinedtrue@code
+ \noexpand\immediate\noexpand\write16{\pgf@external@grab@refundefinedtrue@warning}%
+ \noexpand\G@refundefinedtrue
+ }%
+ \endgroup
+}%
+
+% A hook. will be overwritten by \usetikzlibrary{external}
+\def\pgf@external@grab@refundefinedtrue@code{}
+
+\def\pgf@external@grab@refundefinedtrue@warning{%
+ LaTeX Warning: External picture `\pgfactualjobname' contains undefined references\noexpand\on@line.\n
+}%
+
+\let\pgf@external@@protected@write@orig=\protected@write
+\long\def\pgf@external@@protected@write@immediate#1#2#3{%
+ \begingroup
+ \let\pgf@write@=\write
+ \def\write{\noexpand\immediate\pgf@write@}%
+ \pgf@external@@protected@write@orig{#1}{#2}{#3}%
+ \endgroup
+}%
+
+\def\pgf@external@init@aux@in@dpth{%
+ \let\pgfexternalstorecommand=\pgfexternalstorecommand@isexporting
+ %
+ % tell LaTeX to write aux files...
+ \csname @fileswtrue\endcsname
+ % ... but redirect output to the .dpth file!
+ \immediate\openout\w@pgfexternal@auxout=\pgf@filename.dpth
+ \let\@auxout=\w@pgfexternal@auxout
+ % ... and disable the correct page numbers. I can't get that
+ % (because the correct page number is only available in the
+ % shipout routine). Use immediate output:
+ \let\protected@write=\pgf@external@@protected@write@immediate
+}%
+
+\def\pgf@externalend@storeshifts#1{%
+ \immediate\write#1{\the\dp\pgfpic}% store the depth simply as number for backw. compat.
+ \ifx\pgf@trimleft@final\pgfutil@empty\else
+ \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimleft{\pgf@trimleft@final}}}%
+ \fi
+ \ifx\pgf@trimright@final\pgfutil@empty\else
+ \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternaltrimright{\pgf@trimright@final}}}%
+ \fi
+ \ifpgfexternal@info
+ \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalwidth{\the\wd\pgfpic}}}%
+ \immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\pgfexternalheight{\the\dimen0}}}%
+ \fi
+}
+% REMARK:
+% this method is also invoked from within the tikz external library.
+\def\pgf@externalend{%
+ \unskip\egroup\egroup%
+ {%
+ \def\pgf@external@trim{0}%
+ \def\pgf@external@store@dpth{0}%
+ %
+ \ifpgf@trim@lowlevel
+ \gdef\pgf@trimleft@final{}%
+ \gdef\pgf@trimright@final{}%
+ \else
+ \ifdim\pgf@trimleft@final=0sp \gdef\pgf@trimleft@final{} \else\def\pgf@external@trim{1}\fi
+ \ifdim\pgf@trimright@final=0sp \gdef\pgf@trimright@final{} \else\def\pgf@external@trim{1}\fi
+ \if1\pgf@external@trim
+ % UNDO the trimming! export to pdf doesn't supported trimmed
+ % bounding boxes (has to do with the mediabox/trimbox etc).
+ % I'll keep the bounding box intact and store the trim information
+ % into the .dpth file.
+ \setbox\pgfpic=\hbox{%
+ \ifx\pgf@trimleft@final\pgfutil@empty\else\kern-\pgf@trimleft@final\fi
+ \box\pgfpic
+ \ifx\pgf@trimright@final\pgfutil@empty\else\kern-\pgf@trimright@final\fi
+ }%
+ \def\pgf@external@store@dpth{1}%
+ \fi
+ \fi
+ %
+ \parindent0pt % leave the space
+% \leftmargin0pt%
+% \rightmargin0pt%
+ \hoffset=0pt % reset to default
+ \voffset=0pt
+ \dimen0\ht\pgfpic%
+ \advance\dimen0\dp\pgfpic%
+ \ifdim\dp\pgfpic=0pt\relax
+ \else% store the picture's depth. Otherwise, it would be lost.
+ \def\pgf@external@store@dpth{1}%
+ \fi
+ \ifpgfexternal@info
+ \def\pgf@external@store@dpth{1}%
+ \fi
+ %
+ \if1\pgf@external@store@dpth
+ \ifpgfexternal@aux@in@dpth
+ \pgf@externalend@storeshifts\@auxout
+ \immediate\closeout\@auxout
+ \else
+ \immediate\openout\pgf@plotwrite=\pgf@filename.dpth
+ \pgf@externalend@storeshifts\pgf@plotwrite
+ \immediate\closeout\pgf@plotwrite
+ \fi
+ \fi
+ \pgfsys@prepare@papersize{\the\wd\pgfpic}{\the\dimen0}%
+ %
+ \setbox0=\vbox{%
+ % I admit that I don't know why there is this kerning:
+ \kern -\pgf@external@kern@top\relax%
+ \hbox{%
+ \kern -\pgf@external@kern@left\relax%
+ \hbox to0pt{%
+ \wd\pgfexternal@startupbox=0pt %
+ \ht\pgfexternal@startupbox=0pt %
+ \dp\pgfexternal@startupbox=0pt %
+ \box\pgfexternal@startupbox%
+ \pgfsys@atbegindocument\hss}%
+ \box\pgfpic%
+ \kern\pgf@external@kern@right\relax%
+ }%
+ \kern\pgf@external@kern@bottom\relax%
+ }%
+ %
+ % compatibility with eso-pic package: \nointerlineskip is not
+ % allowed here, but the eso-pic package uses \nointerlineskip in
+ % its shipout routine.
+ \let\pgfexternal@nointerlineskip@orig=\nointerlineskip
+ \let\nointerlineskip=\pgfexternal@nointerlineskip
+ %
+ \pgfexternal@originalshipout\box0 %
+ \gdef\pgfexternal@did@a@shipout{1}%
+ }%
+ \ifpgfexternal@aux@in@dpth
+ \endgroup
+ \fi
+}
+
+\def\pgfexternal@nointerlineskip{%
+ \ifvmode
+ \pgfexternal@nointerlineskip@orig
+ \else
+ \relax% \nointerlineskip in horizontal mode not allowed. Silently ignore the error message.
+ \fi
+}%
+
+\endinput
+% vi: tabstop=4 shiftwidth=2 expandtab
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcoreimage.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcoreimage.code.tex
new file mode 100644
index 0000000000..1079776c07
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcoreimage.code.tex
@@ -0,0 +1,584 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Mon Mar 22 16:42:03 CET 2010 %%%
+
+
+
+% Copyright 2006 by Till Tantau
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreimage.code.tex,v 1.14 2010/03/19 09:50:32 ludewich Exp $
+
+
+
+% Declare an image
+%
+% #1 = optional argument: width, height, page specification
+% #2 = name of the image for later use
+% #4 = filename without extension, automatic extensions are .pdf,
+% .jpg, and .png for PDF and .ps, .eps, .epsi for postscript.
+%
+% Description:
+%
+% This command declares an image file for later use. Even if the image
+% is used several times in the document, in PDF it will only be stored
+% once.
+%
+% Example:
+%
+% \pgfdeclareimage[width=2cm,page=2]{myimage}{imagefilename}
+
+\def\pgfdeclareimage{\pgfutil@ifnextchar[{\pgf@declareimage}{\pgf@declareimage[]}}
+\def\pgf@declareimage[#1]#2#3{%
+ \pgfqkeys{/pgf/images}{height=,width=,page=,interpolate=false,mask=,#1}%
+ % Try to find the file
+ \gdef\pgf@filename{}%
+ % If page= parameter is not empty, try that file first:
+ \ifx\pgf@imagepage\pgfutil@empty%
+ \else%
+ \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3.page\pgf@imagepage}%
+ \fi%
+ \ifx\pgf@filename\pgfutil@empty%
+ \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3}%
+ \else%
+ \pgfkeys{/pgf/images/page=}% make page empty
+ \fi%
+ \ifx\pgf@filename\pgfutil@empty%
+ \PackageWarning{pgf}%
+ {File "#3" not found when defining image "#2".\MessageBreak
+ Tried all extensions in "\pgfsys@imagesuffixlist"}%
+ \pgf@declaredraftimage{#2}{#3}%
+ \else%
+ \ifpgf@draftmode%
+ \pgf@declaredraftimage{#2}{#3}%
+ \else%
+ \pgfsys@defineimage%
+ \fi%
+ \fi%
+ \expandafter\global\expandafter\let\csname pgf@image@#2!\endcsname=\pgf@image%
+}
+
+\newif\ifpgfexternal@allow@aux
+
+\pgfkeys{
+ /pgf/images/include external/.code={\pgfimage{#1}},
+ /pgf/images/aux in dpth/.is if=pgfexternal@allow@aux,
+ /pgf/images/aux in dpth/.default=true,
+ /pgf/images/draft/.is if=pgf@draftmode,
+ /pgf/images/draft/.default=true}
+\pgfkeys{/pgf/images/width/.estore in=\pgf@imagewidth}
+\pgfkeys{/pgf/images/height/.estore in=\pgf@imageheight}
+\pgfkeys{/pgf/images/page/.estore in=\pgf@imagepage}
+\pgfkeys{/pgf/images/interpolate/.cd,.code=\edef\pgf@imageinterpolate{#1},.default=true}
+\pgfkeys{/pgf/images/mask/.code=%
+ {%
+ \edef\pgf@imagemask{#1}%
+ \ifx\pgf@imagemask\pgfutil@empty%
+ \else%
+ \pgfutil@ifundefined{pgf@mask@#1}%
+ {\PackageError{pgf}{Undefined mask "#1".}{}%
+ \edef\pgf@imagemask{}}%
+ {\edef\pgf@imagemask{\csname pgf@mask@#1\endcsname}%
+ }%
+ \fi%
+ }}
+
+
+\def\pgf@findfile#1:#2+#3{%
+ \pgfutil@IfFileExists{#3#1}%
+ {\xdef\pgf@filename{#3#1}}%
+ {\def\pgf@mightbeempty{#2}%
+ \ifx\pgf@mightbeempty\pgfutil@empty\else%
+ \pgf@findfile#2+{#3}%
+ \fi}}
+
+% #1: image name
+% #2: file name
+\def\pgf@declaredraftimage#1#2{%
+ \ifx\pgf@imagewidth\pgfutil@empty%
+ \PackageWarning{pgf}{Missing width for image "#1" ("#2") in draft mode.\MessageBreak Using 1cm instead}%
+ \edef\pgf@imagewidth{1cm}%
+ \fi%
+ \ifx\pgf@imageheight\pgfutil@empty%
+ \PackageWarning{pgf}{Missing height for image "#1" ("#2") in draft mode.\MessageBreak Using 1cm instead}%
+ \edef\pgf@imageheight{1cm}%
+ \fi%
+ \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepagetext{ page \pgf@imagepage}\fi%
+ \edef\pgf@image{%
+ \hbox to \pgf@imagewidth{%
+ \vrule\kern-0.4pt%
+ \vbox to \pgf@imageheight{%
+ \hrule\vfil%
+ \hbox to \pgf@imagewidth{\hskip-10cm\hfil\noexpand\tiny#2\pgf@imagepage\hfil\hskip-10cm}%
+ \vfil\hrule}%
+ \kern-0.4pt\vrule}%
+ }%
+}
+
+
+
+% Declare a soft mask
+%
+% #1 = optional argument: matte specification. default matte is
+% white.
+% #2 = name of the mask for later use
+% #3 = filename without extension, automatic extensions are .pdf,
+% .jpg, and .png for PDF. Postscript is not supported.
+%
+% Description:
+%
+% This command declares a soft mask for later masking an image. The
+% declared mask should be used together with an image of exactly the
+% same height/width if matte is defined. Matte should be the
+% preblended background color (see pdf spec for details).
+%
+% Example:
+%
+% \pgfdeclaremask[matte=white]{maskname}{maskfilename}
+% \pgfdeclareimage[mask=maskname]{image}{imagefilename}
+
+\def\pgfdeclaremask{\pgfutil@ifnextchar[\pgf@declaremask{\pgf@declaremask[]}}
+\def\pgf@declaremask[#1]#2#3{%
+ \pgfqkeys{/pgf/images/mask}{matte={1 1 1},#1}% defaults
+ \def\pgf@mask{}%
+ % Try to find the file
+ \gdef\pgf@filename{}%
+ \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#3}%
+ \ifx\pgf@filename\pgfutil@empty%
+ \PackageWarning{pgf}%
+ {File "#3" not found when defining mask "#2".\MessageBreak
+ Tried all extensions in "\pgfsys@imagesuffixlist"}%
+ \else%
+ \pgfsys@definemask{#2}%
+ \fi%
+ \expandafter\global\expandafter\let\csname pgf@mask@#2\endcsname=\pgf@mask%
+}
+
+\pgfkeys{/pgf/images/mask/matte/.cd,.estore in=\pgf@maskmatte,.value required}
+
+
+
+% Create an alias name for an image
+%
+% #1 = name of the alias
+% #2 = name of the original
+%
+% Example:
+%
+% \pgfdeclareimage{image}{1cm}{1cm}{filename
+% \pgfaliasimage{alias}{image}
+% \pgfuseimage{alias}
+
+\def\pgfaliasimage#1#2{%
+ \expandafter\global\expandafter\let\expandafter\pgf@temp\expandafter=\csname pgf@image@#2!\endcsname%
+ \expandafter\global\expandafter\let\csname pgf@image@#1!\endcsname=\pgf@temp%
+ }
+
+
+% Use an image
+%
+% #1 = name of a previously declared image
+%
+% Example:
+%
+% \pgfputat{\pgforigin}{\pgfbox[left,base]{\pgfuseimage{myimage}}}
+
+\def\pgfuseimage#1{%
+ \def\pgf@imagename{pgf@image@#1}%
+ \pgf@tryextensions{\pgf@imagename}{\pgfalternateextension}%
+ \expandafter\pgfutil@ifundefined\expandafter{\pgf@imagename}%
+ {\PackageError{pgf}{Undefined image "#1"}{}}%
+ {{\leavevmode\csname\pgf@imagename\endcsname}}}
+
+\def\pgf@tryextensions#1#2{%
+ \edef\pgf@args{[#2!]}\expandafter\pgf@@tryextensions\pgf@args{#1}}
+\def\pgf@@tryextensions[#1!#2]#3{%
+ \expandafter\pgfutil@ifundefined\expandafter{#3#1!#2}%
+ {\def\pgf@temp{#2}%
+ \ifx\pgf@temp\pgfutil@empty%
+ \edef#3{#3!}%
+ \else%
+ \pgf@@tryextensions[#2]{#3}%
+ \fi}%
+ {\edef#3{#3#1!#2}}}
+
+
+% Alternate image
+%
+% Description:
+%
+% When an image is used, pgf first attempts to use the image with the
+% alternate extension added. If this fails, the original image is
+% used. If the alternate extension contains ``!'', then the text up to
+% the ! is successively removed and the remainder is tried as an
+% alternate extension.
+%
+% Example:
+%
+% \def\pgfalternateextension{20!white}
+
+\def\pgfalternateextension{}
+
+
+
+% Directly insert an image
+%
+% #1 = optional argument: width, height, page specification
+% #2 = file name
+%
+% Description:
+%
+% Directly inserts an image without declaration. You can, however,
+% still access this image using the name pgflastimage. By using
+% pgfaliasimage, you can also save this image for later.
+%
+% Example:
+%
+% \pgfimage[height=2cm]{filename}
+
+\def\pgfimage{\pgfutil@ifnextchar[\pgf@imagecom{\pgf@imagecom[]}}
+\def\pgf@imagecom[#1]#2{%
+ \pgfdeclareimage[#1]{pgflastimage}{#2}%
+ \pgfuseimage{pgflastimage}}
+
+
+
+
+
+
+
+
+% The external read/write mechanism is used as follows:
+%
+% In your document, you put a number or all of your pgfpicture (or
+% tikzpicture) environments inside a pair of \beginpgfexternal and
+% \endpgfexternal. The \beginpgfexternal gets one parameter called the
+% graphics name.
+%
+% Once this is done, the next step is to declare the names of your
+% graphics in the document at the beginning using the
+% \pgfdeclaregraphicname command.
+%
+% Now, when you typeset your document, each time a \beginpgfexternal
+% command is encountered, it will be checked whether the corresponding
+% graphics file exists. If this is the case, it will be included and
+% the code between \beginpgfexternal and \endpgfexternal is
+% ignored. Otherwise, the code is executed normally.
+%
+% Things change when you run tex on your file with the \jobname set to
+% the name of a decalred graphics name. In this case, only your
+% graphic will be typeset, the rest of the document will be "thrown away".
+% To be more precise, everything is gobbled up to the beginning
+% of the first \beginpgfexternal with the given graphics name. Then,
+% the content of the "environment" is put in a box (this "environment"
+% need not contain a graphics, it may contain anything that can be put
+% in a box). Then a single page is output whose size is exactly the
+% size of the picture.
+%
+% So, once you have run tex repeatedly, each time with the jobname set
+% to each of the graphics, you can then run tex on the whole document
+% and this will cause all graphics to be included rather than begin
+% typeset.
+%
+% Finally, once all the graphics have been created, you can also say
+% \input pgfexternal.tex instead of including pgf/TikZ.
+
+
+\newif\ifpgfexternalreadmainaux
+\pgfexternalreadmainauxtrue
+
+% Tells pgf which jobname is the name of the real file
+%
+% #1 = name
+%
+% Description:
+%
+% This command is used to tell pgf that the file named #1 should be
+% typeset normally. If \jobname is not equal to #1, only
+% the graphic called \jobname will be typeset.
+%
+% Example:
+%
+% \pgfrealjobname{survey}
+%
+% Note that afterwards, \jobname will be set to the argument. In our
+% example, \jobname will be 'survey'. This is to accomplish
+% compatibility with aux-file generation.
+
+\def\pgfrealjobname#1{%
+ \global\let\pgfactualjobname=\jobname
+ \edef\pgf@tempa{\expandafter\string\csname #1\endcsname}%
+ \edef\pgf@tempb{\expandafter\string\csname\jobname\endcsname}%
+ \ifx\pgf@tempa\pgf@tempb%
+ \else%
+ \pgf@external@grabshipouttrue%
+ \pgfexternal@nofiles
+ \ifpgfexternalreadmainaux
+ % and reset the jobname. This should allow to handle any
+ % \label/\ref constructions which are stored in \jobname.aux (and
+ % which won't be found otherwise)
+ \gdef\jobname{#1}%
+ \fi
+ \ifpgfexternal@allow@aux
+ \csname newwrite\endcsname\w@pgfexternal@auxout
+ \fi
+ \fi%
+ \gdef\pgfrealjobname##1{}% avoid multiple calls.
+}
+
+\def\pgfexternal@nofiles{%
+ % replace \relax. The \nofiles macros does
+ % \let\makeglossary=\relax
+ % but the glossary.sty calls \renewcommand\makeglossary (which
+ % will fail if \makeglossary=\relax). Stupid, but it works.
+ \let\pgfexternal@nofiles@=\relax
+ \def\relax{\relax}%
+ %
+ % suppress generation of LaTeX .aux, .toc etc files.
+ % generation of these files is not thread-safe.
+ % the \csname \endcsname yields \relax if \nofiles doesn't exist.
+ \csname nofiles\endcsname
+ %
+ \let\relax=\pgfexternal@nofiles@
+}%
+
+\newif\ifpgf@external@grabshipout
+\newbox\pgfexternal@startupbox
+
+\AtBeginDocument{%
+ \ifpgf@external@grabshipout%
+ \global\let\pgfexternal@originalshipout=\shipout%
+ \global\def\shipout{\setbox\pgfpic=}%
+ \maxdeadcycles=10000%
+ % Ok, gather everything we have seen up to now in a box. This box
+ % will contain any specials that have been used.
+ {%
+ \output{\global\setbox\pgfexternal@startupbox=\vbox{\csname @begindvi\endcsname\unvbox255}}%
+ \hbox{}\eject%
+ }%
+ \fi%
+}
+
+
+% "Environment" for an external graphic.
+%
+% #1 = graphic name
+%
+% Example:
+%
+% \beginpgfgraphicnamed{main-graphic2}
+% \begin{tikzpicture}
+% ...
+% \end{tikzpicture}
+% \endpgfgraphicnamed
+
+\def\pgf@externalbegin#1{%
+ % First, check whether we wish to grab this graphic:
+ \let\pgf@next=\pgf@external@normal%
+ \ifpgf@external@grabshipout%
+ \edef\pgf@tempa{\expandafter\string\csname #1\endcsname}%
+ \edef\pgf@tempb{\expandafter\string\csname\pgfactualjobname\endcsname}%
+ \ifx\pgf@tempa\pgf@tempb%
+ \let\pgf@next=\pgf@external@grab%
+ \fi%
+ \fi%
+ \pgf@next{#1}%
+}
+
+
+\AtBeginDocument{
+ \let\beginpgfgraphicnamed=\pgf@externalbegin% overwrite definition of pgfexternal.tex if necessary
+ \let\endpgfgraphicnamed=\unskip
+}
+
+
+% Normal operation: Include an external graphic instead of the
+% picture, if such an external picture exists.
+\def\pgf@external@normal#1{%
+ \let\pgf@filename=\pgfutil@empty%
+ \expandafter\pgf@findfile\pgfsys@imagesuffixlist:+{#1}%
+ \ifx\pgf@filename\pgfutil@empty%
+ % Ok, no such image... Just typeset the picture normally.
+ \let\pgf@next=\relax%
+ \else%
+ \let\pgf@next=\pgf@replacepicturebygraphic%
+ \fi%
+ \pgf@next%
+}
+
+\long\def\pgf@replacepicturebygraphic#1\endpgfgraphicnamed{%
+ \expandafter\pgfincludeexternalgraphics\expandafter{\pgf@filename}\unskip
+}
+
+% This is almost the same as \includegraphics{#1}, but it checks
+% whether '#1.dpth' exists. In such case, it restores the boxes depth
+% stored in #1.dpth.
+%
+% Furthermore, the .dpth file may contain .aux related information
+% collected for the external graphics (references). They start after
+% the first line (if any).
+\def\pgfincludeexternalgraphics#1{%
+ \begingroup
+ \setbox1=\hbox{\pgfkeysvalueof{/pgf/images/include external/.@cmd}{#1}\pgfeov}%
+ %
+ \let\pgfincludeexternalgraphics@dp=\pgfutil@empty
+ \endlinechar=-1 % suppress white space at end
+ \catcode`\@=11
+ \openin\r@pgf@reada=#1.dpth
+ \pgfincludeexternalgraphics@read@dpth
+ \ifx\pgfincludeexternalgraphics@dp\pgfutil@empty
+ \box1
+ \else
+ \dimen0=\pgfincludeexternalgraphics@dp\relax
+ \hbox{\lower\dimen0 \box1 }%
+ \fi
+ \endgroup
+}
+%
+% The .dpth consists of 0-N lines, where each is either a single
+% dimension (the box' depth) or something which belongs to the .aux
+% file (such lines will always start with a macro).
+\def\pgfincludeexternalgraphics@read@dpth{%
+ \ifeof\r@pgf@reada
+ \closein\r@pgf@reada
+ \else
+ \read\r@pgf@reada to\pgfincludeexternalgraphics@auxline
+ \ifx\pgfincludeexternalgraphics@auxline\pgfutil@empty
+ \else
+ \expandafter\pgfincludeexternalgraphics@read@dpth@line\pgfincludeexternalgraphics@auxline\pgfincludeexternalgraphics@read@dpth@line@EOI
+ \fi
+ \expandafter\pgfincludeexternalgraphics@read@dpth
+ \fi
+}%
+\long\def\pgfincludeexternalgraphics@read@dpth@line#1#2\pgfincludeexternalgraphics@read@dpth@line@EOI{%
+ \ifcat\noexpand#1\relax
+ % Ah -- the first token is a control sequence. It belongs to
+ % the .aux file.
+ %
+ % #1#2\relax% do NOT set the information! many LaTeX commands don't support it (\label for example)
+ \pgfutil@ifundefined{if@filesw}{%
+ % sorry, .aux file support only for latex
+ }{%
+ % append to main .aux file (for forward references)
+ \if@filesw
+ {%
+ \toks0={#1#2}%
+ % believe it or not, but the
+ % \def\dpthimport{...}\dpthimport *makes* a
+ % difference! In ensures any occuring `##' characters
+ % are properly expanded to `#'.
+ \immediate\write\@auxout{\noexpand\def\noexpand\dpthimport{\the\toks0 }\noexpand\dpthimport }%
+ }%
+ \fi
+ }%
+ \else
+ \def\pgfincludeexternalgraphics@dp{#1#2}%
+ \fi
+}%
+
+
+
+% Grab operation: If jobname matches the graphic name, typeset this
+% picture normall.
+% REMARK:
+% this method is also invoked from within the tikz external library.
+\def\pgf@external@grab#1{%
+ \def\pgf@filename{#1}%
+ \ifpgfexternal@allow@aux
+ \begingroup
+ \pgf@external@init@aux@in@dpth
+ \fi
+ \setbox\pgfpic=\hbox\bgroup\bgroup%
+ \let\endpgfgraphicnamed=\pgf@externalend%
+}
+
+\let\pgf@external@@protected@write@orig=\protected@write
+\long\def\pgf@external@@protected@write@immediate#1#2#3{%
+ \begingroup
+ \let\pgf@write@=\write
+ \def\write{\noexpand\immediate\pgf@write@}%
+ \pgf@external@@protected@write@orig{#1}{#2}{#3}%
+ \endgroup
+}%
+
+\def\pgf@external@init@aux@in@dpth{%
+ % tell LaTeX to write aux files...
+ \csname @fileswtrue\endcsname
+ % ... but redirect output to the .dpth file!
+ \immediate\openout\w@pgfexternal@auxout=\pgf@filename.dpth
+ \let\@auxout=\w@pgfexternal@auxout
+ % ... and disable the correct page numbers. I can't get that
+ % (because the correct page number is only available in the
+ % shipout routine). Use immediate output:
+ \let\protected@write=\pgf@external@@protected@write@immediate
+}%
+
+% REMARK:
+% this method is also invoked from within the tikz external library.
+\def\pgf@externalend{%
+ \unskip\egroup\egroup%
+ {%
+ \parindent0pt % leave the space
+% \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.
+ \ifpgfexternal@allow@aux
+ \immediate\write\@auxout{\the\dp\pgfpic}%
+ \immediate\closeout\@auxout
+ \else
+ \immediate\openout\pgf@plotwrite=\pgf@filename.dpth
+ \immediate\write\pgf@plotwrite{\the\dp\pgfpic}%
+ \immediate\closeout\pgf@plotwrite
+ \fi
+ \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 %
+ }%
+ \ifpgfexternal@allow@aux
+ \endgroup
+ \fi
+}
+
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcorelayers.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcorelayers.code.tex
new file mode 100644
index 0000000000..7665a76afb
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcorelayers.code.tex
@@ -0,0 +1,217 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%%
+
+
+
+% Copyright 2006 by Till Tantau
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorelayers.code.tex,v 1.5 2012/11/07 19:23:16 ludewich Exp $
+
+
+% Creates a new pgf layer
+%
+% #1 = layer name
+%
+% Declares a new layer for pgf.
+%
+% Example:
+%
+% \pgfdeclarelayer{background}
+
+\def\pgfdeclarelayer#1{%
+ \pgfutil@ifundefined{pgf@layerbox@#1}{%
+ \expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerbox@#1\endcsname%
+ \expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerboxsaved@#1\endcsname%
+ }{}%
+}
+\let\pgf@newbox=\newbox % avoid plain TeX outer problem
+
+% Sets the layers that compose the picture
+%
+% #1 = List of layers
+%
+% Description:
+%
+% Sets the list of layers that make up the picture. The layers will be
+% put on top of each other in the order given.
+%
+% This command can also be given inside of a picture in which case it
+% applies only to that very picture.
+%
+% Example:
+%
+% \pgfsetlayers{background,main}
+
+\def\pgfsetlayers#1{\edef\pgf@layerlist{#1}}
+\pgfsetlayers{main}
+
+% Adds code to a layer
+%
+% #1 = layer name
+%
+% Note:
+%
+% You cannot add anything to the ``main'' layer using this command.
+%
+% Example:
+%
+% \begin{pgfonlayer}{background}
+% \fill[red] (0,0) -- (1,1);
+% \end{pgfonlayer}
+
+\def\pgfonlayer@name{main}
+
+\def\pgfonlayer#1{%
+ \pgfutil@ifundefined{pgf@layerbox@#1}{%
+ \PackageError{pgf}{Sorry, the requested layer '#1' could not be found. Maybe you misspelled it?}{}%
+ \bgroup
+ \begingroup
+ }{%
+ \begingroup
+ \edef\pgf@temp{#1}%
+ \ifx\pgf@temp\pgfonlayer@name
+ % we are already on this layer.
+ \def\pgf@temp{%
+ \bgroup
+ \begingroup
+ }%
+ \else
+ \let\pgfonlayer@name=\pgf@temp
+ \pgfonlayer@assert@is@active
+ \def\pgf@temp{%
+ \expandafter\global\expandafter%
+ \setbox\csname pgf@layerbox@#1\endcsname=\hbox to 0pt%
+ \bgroup%
+ \expandafter\box\csname pgf@layerbox@#1\endcsname%
+ \begingroup%
+ }%
+ \fi
+ \pgf@temp
+ }%
+}
+\def\endpgfonlayer{%
+ \endgroup%
+ \hss
+ \egroup%
+ \endgroup
+}
+
+\let\startpgfonlayer=\pgfonlayer
+\let\stoppgfonlayer=\endpgfonlayer
+
+\def\pgfdiscardlayername{discard}
+
+\def\pgfonlayer@assert@is@active{%
+ \ifx\pgfonlayer@name\pgfdiscardlayername
+ % this special layer name can be used as /dev/null without
+ % warning.
+ \else
+ \begingroup
+ \def\pgfonlayer@isactive{0}%
+ \expandafter\pgf@assert@layer@is@active@loop\pgf@layerlist,,\relax%
+ \if0\pgfonlayer@isactive
+ \pgfonlayer@assert@fail
+ \fi
+ \endgroup
+ \fi
+}%
+\def\pgfonlayer@assert@fail{%
+ \PackageError{pgf}{Sorry, the requested layer '\pgfonlayer@name' is not
+ part of the layer list. Please verify that you provided
+ \string\pgfsetlayers\space and that '\pgfonlayer@name' is part of this list}{}%
+}%
+\def\pgf@assert@layer@is@active@loop#1,#2,\relax{%
+ \edef\pgf@test{#1}%
+ \ifx\pgf@test\pgfonlayer@name
+ \def\pgfonlayer@isactive{1}%
+ \else
+ \def\pgf@test{#2}%
+ \ifx\pgf@test\pgfutil@empty%
+ \else%
+ \pgf@assert@layer@is@active@loop#2,\relax%
+ \fi%
+ \fi
+}
+
+% Hooks into the scoping:
+
+\def\pgf@insertlayers{%
+ \expandafter\pgf@dolayer\pgf@layerlist,,\relax%
+}
+\def\pgf@maintext{main}%
+\def\pgf@dolayer#1,#2,\relax{%
+ \def\pgf@test{#1}%
+ \ifx\pgf@test\pgf@maintext%
+ \box\pgf@layerbox@main%
+ \else%
+ \pgfsys@beginscope%
+ \expandafter\box\csname pgf@layerbox@#1\endcsname%
+ \pgfsys@endscope%
+ \fi%
+ \def\pgf@test{#2}%
+ \ifx\pgf@test\pgfutil@empty%
+ \else%
+ \pgf@dolayer#2,\relax%
+ \fi%
+}
+
+\def\pgf@savelayers{%
+ \expandafter\pgf@dosavelayer\pgf@layerlist,,\relax%
+}
+\def\pgf@dosavelayer#1,#2,\relax{%
+ \def\pgf@test{#1}%
+ \ifx\pgf@test\pgf@maintext%
+ \else%
+ \setbox\csname pgf@layerboxsaved@#1\endcsname=\box\csname pgf@layerbox@#1\endcsname%
+ \fi%
+ \def\pgf@test{#2}%
+ \ifx\pgf@test\pgfutil@empty%
+ \else%
+ \pgf@dosavelayer#2,\relax%
+ \fi%
+}
+
+\def\pgf@restorelayers{%
+ \expandafter\pgf@dorestorelayer\pgf@layerlist,,\relax%
+}
+\def\pgf@dorestorelayer#1,#2,\relax{%
+ \def\pgf@test{#1}%
+ \ifx\pgf@test\pgf@maintext%
+ \else%
+ \global\setbox\csname pgf@layerbox@#1\endcsname=\box\csname pgf@layerboxsaved@#1\endcsname%
+ \fi%
+ \def\pgf@test{#2}%
+ \ifx\pgf@test\pgfutil@empty%
+ \else%
+ \pgf@dorestorelayer#2,\relax%
+ \fi%
+}
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcorescopes.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcorescopes.code.tex
new file mode 100644
index 0000000000..69ef0d9318
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfcorescopes.code.tex
@@ -0,0 +1,607 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%%
+
+
+
+% Copyright 2006 by Till Tantau
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcorescopes.code.tex,v 1.38 2012/11/30 12:00:51 tantau Exp $
+
+% Globals
+
+\newbox\pgfpic
+\newbox\pgf@hbox
+
+\newbox\pgf@layerbox@main
+
+\newcount\pgf@picture@serial@count
+
+
+
+% This if decides whether the position of pictures on the page is
+% protocolled or not. Normally,
+% this is switched off as it works only with certain drivers and it
+% causes external files to be written. When switched on, the position
+% of pgfpictures are protocolled and can be referenced using
+% \pgfsys@getposition{XXX} where XXX is the value of \pgfpictureid
+% inside the picture.
+\newif\ifpgfrememberpicturepositiononpage
+
+
+
+
+% Scopes
+
+
+% Pgf scope environment. All changes of the graphic state are local to
+% the scope.
+%
+% Example:
+%
+% \begin{pgfscope}
+% \pgfsetlinewidth{3pt}
+% \pgfline{\pgfxy(0,0)}{\pgfxy(3,3)}
+% \end{pgfscope}
+
+\def\pgfscope{%
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+ \pgfsys@beginscope%
+ \pgf@resetpathsizes%
+ \edef\pgfscope@linewidth{\the\pgflinewidth}%
+ \begingroup}
+\def\endpgfscope{%
+ \endgroup%
+ \global\pgflinewidth=\pgfscope@linewidth%
+ \pgfsys@endscope}
+
+
+
+
+% Quickly insert a box can contain normal TeX text at the origin.
+%
+% #1 = box of width/height and depth 0pt
+%
+% Example:
+%
+% \pgfqbox{\mybox}
+
+\def\pgfqbox#1{%
+ \pgfsys@hbox#1%
+}
+
+
+% Insert a box that can contain normal TeX text at the origin, but
+% with the current coordinate transformation matrix synced with the
+% low-level transformation matrix.
+%
+% #1 = box of width/height and depth 0pt
+%
+% In essence, this command does the same as if you first said
+% \pgflowlevelsynccm and then \pgfqbox. However, pgf will use a
+% ``TeX-translation'' for the translation part of the transformation
+% cm. This will ensure that hyperlinks ``survive'' at least
+% translations.
+%
+% Example:
+%
+% \pgfqboxsynced{\mybox}
+
+\def\pgfqboxsynced#1{%
+ \pgfsys@hboxsynced#1%
+}
+
+
+% Puts some text in a box and inserts it with the current
+% transformations applied.
+%
+% #1 = List of optional positioning. Possible values are ``left'', ``right'',
+% ``top'', ``bottom'' and ``base''.
+% #2 = TeX text. May contain verbatims.
+%
+% Example:
+%
+% \pgftransformshift{\pgfpoint{1cm}{0cm}}
+% \pgftext{Hello World!}
+
+\def\pgftext{\pgfutil@ifnextchar[\pgf@text{\pgf@text[]}}%
+\def\pgf@text[#1]{%
+ \def\pgf@text@options{#1}%
+ \pgf@maketext\pgf@after@text}
+\def\pgf@after@text{%
+ {%
+ \def\pgf@text@hshift{center}%
+ \def\pgf@text@vshift{center}%
+ \expandafter\pgf@text@setkeys\expandafter{\pgf@text@options}%
+ \csname pgf@halign\pgf@text@hshift\endcsname%
+ \csname pgf@valign\pgf@text@vshift\endcsname%
+ % Protocol sizes:
+ \pgf@process{\pgfpointtransformed{\pgfqpoint{0pt}{\dp\pgf@hbox}}}%
+ \pgf@protocolsizes{\pgf@x}{\pgf@y}%
+ \pgf@process{\pgfpointtransformed{\pgfqpoint{\wd\pgf@hbox}{\dp\pgf@hbox}}}%
+ \pgf@protocolsizes{\pgf@x}{\pgf@y}%
+ \pgf@process{\pgfpointtransformed{\pgfqpoint{0pt}{\ht\pgf@hbox}}}%
+ \pgf@protocolsizes{\pgf@x}{\pgf@y}%
+ \pgf@process{\pgfpointtransformed{\pgfqpoint{\wd\pgf@hbox}{\ht\pgf@hbox}}}%
+ \pgf@protocolsizes{\pgf@x}{\pgf@y}%
+ \pgfqboxsynced{\pgf@hbox}%
+ }%
+}
+\def\pgf@text@setkeys{\pgfqkeys{/pgf/text}}%
+
+\pgfkeys{/pgf/text/left/.code=\def\pgf@text@hshift{left}}
+\pgfkeys{/pgf/text/center/.code=}
+\pgfkeys{/pgf/text/right/.code=\def\pgf@text@hshift{right}}
+\pgfkeys{/pgf/text/top/.code=\def\pgf@text@vshift{top}}
+\pgfkeys{/pgf/text/bottom/.code=\def\pgf@text@vshift{bottom}}
+\pgfkeys{/pgf/text/base/.code=\def\pgf@text@vshift{base}}
+\pgfkeys{/pgf/text/at/.cd,.code=\pgftransformshift{#1},.value required}
+\pgfkeys{/pgf/text/x/.cd,.code=\pgftransformxshift{#1},.value required}
+\pgfkeys{/pgf/text/y/.cd,.code=\pgftransformyshift{#1},.value required}
+\pgfkeys{/pgf/text/rotate/.cd,.code=\pgftransformrotate{#1},.value required}
+
+\def\pgf@halignleft{}% do nothing
+\def\pgf@haligncenter{\pgftransformxshift{+-.5\wd\pgf@hbox}}
+\def\pgf@halignright{\pgftransformxshift{+-\wd\pgf@hbox}}%
+\def\pgf@valignbase{}% do nothing
+\def\pgf@valignbottom{\pgftransformyshift{+\dp\pgf@hbox}}%
+\def\pgf@valigncenter{\pgftransformyshift{+.5\dp\pgf@hbox}\pgftransformyshift{+-.5\ht\pgf@hbox}}%
+\def\pgf@valigntop{\pgftransformyshift{+-\ht\pgf@hbox}}%
+
+
+% Internal function for creating a hbox.
+\def\pgf@maketext#1{%
+ \def\pgf@@maketextafter{#1}%
+ \setbox\pgf@hbox=\hbox\bgroup%
+ \pgfinterruptpicture%
+ \bgroup%
+ \aftergroup\pgf@collectresetcolor%
+ \let\next=%
+}
+\def\pgf@collectresetcolor{%
+ \pgfutil@ifnextchar\reset@color%
+ {\reset@color\afterassignment\pgf@collectresetcolor\let\pgf@temp=}%
+ {\pgf@textdone}%
+}
+\def\pgf@textdone{%
+ \endpgfinterruptpicture%
+ \egroup%
+ \pgf@@maketextafter%
+}
+
+\long\def\pgf@makehbox#1{%
+ \setbox\pgf@hbox=\hbox{{%
+ \pgfinterruptpicture%
+ #1%
+ \endpgfinterruptpicture%
+ }}}
+
+
+
+% Picture environment
+%
+% Example:
+%
+% \begin{pgfpicture}
+% \pgfsetendarrow{\pgfarrowto}
+% \pgfpathmoveto{\pgfpointxy{-0.9}{0.2}}
+% \pgfpathlineto{\pgfpointxy{0.9}{0.4}}
+% \pgfusepath{stroke}
+% \end{pgfpicture}
+
+\newif\ifpgfpicture
+
+\def\pgfresetboundingbox{%
+ \global\pgf@picmaxx=-16000pt\relax%
+ \global\pgf@picminx=16000pt\relax%
+ \global\pgf@picmaxy=-16000pt\relax%
+ \global\pgf@picminy=16000pt\relax%
+}%
+
+\def\pgfpicture{%
+ \begingroup%
+ \pgfpicturetrue%
+ \global\advance\pgf@picture@serial@count by1\relax%
+ \edef\pgfpictureid{pgfid\the\pgf@picture@serial@count}%
+ \let\pgf@nodecallback=\pgfutil@gobble%
+ \pgf@picmaxx=-16000pt\relax%
+ \pgf@picminx=16000pt\relax%
+ \pgf@picmaxy=-16000pt\relax%
+ \pgf@picminy=16000pt\relax%
+ \pgf@relevantforpicturesizetrue%
+ \pgf@resetpathsizes%
+ \pgfutil@ifnextchar\bgroup\pgf@oldpicture\pgf@picture}
+\def\pgf@oldpicture#1#2#3#4{%
+ \pgfmathsetlength\pgf@picminx{#1}%
+ \pgfmathsetlength\pgf@picminy{#2}%
+ \pgfmathsetlength\pgf@picmaxx{#3}%
+ \pgfmathsetlength\pgf@picmaxy{#4}%
+ \pgf@relevantforpicturesizefalse%
+ \pgf@picture}
+
+\def\pgf@picture{%
+ \setbox\pgfpic\hbox to0pt\bgroup%
+ \begingroup%
+ \pgfsys@beginpicture%
+ \pgfsys@beginscope%
+ \begingroup%
+ \pgfsetcolor{.}%
+ \pgfsetlinewidth{0.4pt}%
+ \pgftransformreset%
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+ \begingroup%
+ \let\pgf@setlengthorig=\setlength%
+ \let\pgf@addtolengthorig=\addtolength%
+ \let\pgf@selectfontorig=\selectfont%
+ \let\setlength=\pgf@setlength%
+ \let\addtolength=\pgf@addtolength%
+ \let\selectfont=\pgf@selectfont%
+ \nullfont\spaceskip0pt\xspaceskip0pt%
+ \setbox\pgf@layerbox@main\hbox to0pt\bgroup%
+ \begingroup%
+ }
+\def\endpgfpicture{%
+ \ifpgfrememberpicturepositiononpage%
+ \hbox to0pt{\pgfsys@markposition{\pgfpictureid}}%
+ \fi%
+ % ok, now let's position the box
+ \ifdim\pgf@picmaxx=-16000pt\relax%
+ % empty picture. make size 0.
+ \global\pgf@picmaxx=0pt\relax%
+ \global\pgf@picminx=0pt\relax%
+ \global\pgf@picmaxy=0pt\relax%
+ \global\pgf@picminy=0pt\relax%
+ \fi%
+ % Shift baseline outside:
+ \pgf@relevantforpicturesizefalse%
+ \pgf@process{\pgf@baseline}%
+ \xdef\pgf@shift@baseline{\the\pgf@y}%
+ %
+ \pgf@process{\pgf@trimleft}%
+ \global\advance\pgf@x by-\pgf@picminx
+ % prepare \hskip\pgf@trimleft@final.
+ % note that \pgf@trimleft@final is also queried
+ % by the pgf image externalization.
+ \xdef\pgf@trimleft@final{-\the\pgf@x}%
+ %
+ \pgf@process{\pgf@trimright}%
+ \global\advance\pgf@x by-\pgf@picmaxx
+ % prepare \hskip\pgf@trimright@final.
+ % note that \pgf@trimright@final is also queried
+ % by the pgf image externalization.
+ \xdef\pgf@trimright@final{\the\pgf@x}%
+ %
+ \pgf@remember@layerlist@globally
+ \endgroup%
+ \hss%
+ \egroup%
+ \pgf@restore@layerlist@from@global
+ \pgf@insertlayers%
+ \endgroup%
+ \pgfsys@discardpath%
+ \endgroup%
+ \pgfsys@endscope%
+ \pgfsys@endpicture%
+ \endgroup%
+ \hss
+ \egroup%
+ \pgfsys@typesetpicturebox\pgfpic%
+ \endgroup%
+}
+
+\def\pgf@remember@layerlist@globally{%
+ \global\let\pgf@layerlist@=\pgf@layerlist
+}%
+\def\pgf@restore@layerlist@from@global{%
+ \let\pgf@layerlist=\pgf@layerlist@
+}%
+\def\pgf@insertlayers{%
+ \box\pgf@layerbox@main%
+}
+
+\def\pgf@selectfont{\pgf@selectfontorig\nullfont}
+
+\def\pgf@setlength#1#2{% these will be used only when \nullfont is active
+ \begingroup% keep font setting local
+ \pgfutil@selectfont% restore font
+ \pgf@setlengthorig#1{#2}% calculate dimension (possibly using calc)
+ \expandafter%
+ \endgroup%
+ \expandafter#1\expandafter=\the#1\relax}
+\def\pgf@addtolength#1#2{%
+ \begingroup% keep font setting local
+ \pgfutil@selectfont% restore font
+ \pgf@addtolengthorig#1{#2}% calculate dimension (possibly using calc)
+ \expandafter%
+ \endgroup%
+ \expandafter#1\expandafter=\the#1\relax}
+
+
+% Sets the baseline at the y-coordinate of a given point
+%
+% #1 = point
+%
+% Sets the baseline of the picture to the y-coordinate of a given
+% point. However, the point will be evaluated *at the end of the
+% picture*.
+%
+% Example:
+%
+% \pgfsetbaselinepointlater{\pgfpointanchor{mynode}{base}}
+
+\def\pgfsetbaselinepointlater#1{\def\pgf@baseline{#1}}
+
+
+% Sets the baseline at the y-coordinate of a given point, now
+%
+% #1 = point
+%
+% Sets the baseline of the picture to the y-coordinate of a given
+% point.
+%
+% Example:
+%
+% \pgfsetbaselinepointnow{\pgfpoint{1cm}{2pt}}
+
+\def\pgfsetbaselinepointnow#1{%
+ \pgf@process{#1}%
+ \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfsetbaselinepointlater{\pgf@setter@baseline}%
+}
+
+\def\pgf@default@text{default}%
+
+% Sets the baseline
+%
+% #1 = baseline
+%
+% Sets the baseline of the picture. Default is the lower border, which
+% is the same as \pgf@picminy
+%
+% Example:
+%
+% \pgfsetbaseline{1cm+2pt}
+% \pgfsetbaseline{default}% resets to default value
+
+\def\pgfsetbaseline#1{%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\pgf@default@text
+ \pgfsetbaseline{\pgf@picminy}%
+ \else
+ \pgfsetbaselinepointlater{\pgfpoint{0pt}{#1}}%
+ \fi
+}
+\pgfsetbaseline{\pgf@picminy}
+
+% controls how the image externalization implements trim:
+\newif\ifpgf@trim@lowlevel
+\pgfkeys{
+ /pgf/trim lowlevel/.is if=pgf@trim@lowlevel,
+ /pgf/trim lowlevel/.default=true,
+}
+
+% Same as the y-baseline for horizontal alignment.
+% The effect is different, though: it is some kind of trimming which
+% leaves the bounding box intact.
+\def\pgfsettrimleftpointlater#1{\def\pgf@trimleft{#1}}
+\def\pgfsettrimleftpointnow#1{%
+ \pgf@process{#1}%
+ \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfsettrimleftpointlater{\pgf@setter@baseline}%
+}
+% \pgfsettrimleft{<x coord>}
+% or
+% \pgfsettrimleft{default}
+\def\pgfsettrimleft#1{%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\pgf@default@text
+ \pgfsettrimleft{\pgf@picminx}
+ \else
+ \pgfsettrimleftpointlater{\pgfpoint{#1}{0pt}}%
+ \fi
+}
+\pgfsettrimleft{\pgf@picminx}
+
+\def\pgfsettrimrightpointlater#1{\def\pgf@trimright{#1}}
+\def\pgfsettrimrightpointnow#1{%
+ \pgf@process{#1}%
+ \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfsettrimrightpointlater{\pgf@setter@baseline}%
+}
+% \pgfsettrimright{<x coord>}
+% or
+% \pgfsettrimright{default}
+\def\pgfsettrimright#1{%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\pgf@default@text
+ \pgfsettrimright{\pgf@picmaxx}%
+ \else
+ \pgfsettrimrightpointlater{\pgfpoint{#1}{0pt}}%
+ \fi
+}
+\pgfsettrimright{\pgf@picmaxx}
+
+
+% Interrupt path
+%
+% Description:
+%
+% The environment can be used to insert some drawing commands while
+% constructing a path. The drawing commands inside the environment
+% will not interfere with the path being constructed ``outside.''
+% However, you must ward against graphic state changes using a scope.
+%
+% Example: Draw two parallel lines
+%
+% \pgfmoveto{\pgfpoint{0cm}{0cm}}
+% \begin{pgfinterruptpath}
+% \pgfmoveto{\pgfpoint{1cm}{0cm}}
+% \pgfmoveto{\pgfpoint{1cm}{1cm}}
+% \pgfusepath{stroke}
+% \end{pgfinterruptpath}
+% \pgflineto{\pgfpoint{0cm}{1cm}}
+% \pgfusepath{stroke}
+
+\def\pgfinterruptpath
+{%
+ \begingroup%
+ % save all sorts of things...
+ \edef\pgf@interrupt@savex{\the\pgf@path@lastx}%
+ \edef\pgf@interrupt@savey{\the\pgf@path@lasty}%
+ \pgf@getpathsizes\pgf@interrupt@pathsizes%
+ \pgfsyssoftpath@getcurrentpath\pgf@interrupt@path%
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+ \edef\pgfscope@linewidth{\the\pgflinewidth}%
+ \let\pgf@interrupt@lastmoveto=\pgfsyssoftpath@lastmoveto%
+ \begingroup%
+}
+\def\endpgfinterruptpath
+{%
+ \endgroup%
+ \global\pgflinewidth=\pgfscope@linewidth%
+ \pgfsyssoftpath@setcurrentpath\pgf@interrupt@path%
+ \pgf@setpathsizes\pgf@interrupt@pathsizes%
+ \global\pgf@path@lastx=\pgf@interrupt@savex%
+ \global\pgf@path@lasty=\pgf@interrupt@savey%
+ \global\let\pgfsyssoftpath@lastmoveto=\pgf@interrupt@lastmoveto%
+ \endgroup%
+}
+
+
+
+% Interrupt bounding box
+%
+% Description:
+%
+% The environment can be used to temporarily setup a new bounding box
+% computation. The bounding box will be made empty at the beginning of
+% the environment and will be reset to its old value after the
+% environment.
+%
+% Example:
+%
+% \begin{pgfinterruptboundinbox}
+% \pgfmoveto{\pgfpoint{1cm}{0cm}}
+% \pgfmoveto{\pgfpoint{1cm}{1cm}}
+% \pgfusepath{stroke}
+% \end{pgfinterruptboundinbox}
+
+\def\pgfinterruptboundingbox
+{%
+ \begingroup%
+ \edef\pgf@interrupt@savemaxx{\the\pgf@picmaxx}%
+ \edef\pgf@interrupt@saveminx{\the\pgf@picminx}%
+ \edef\pgf@interrupt@savemaxy{\the\pgf@picmaxy}%
+ \edef\pgf@interrupt@saveminy{\the\pgf@picminy}%
+ \pgf@picmaxx=-16000pt\relax%
+ \pgf@picminx=16000pt\relax%
+ \pgf@picmaxy=-16000pt\relax%
+ \pgf@picminy=16000pt\relax%
+ \pgf@size@hookedfalse%
+ \let\pgf@path@size@hook=\pgfutil@empty%
+}
+\def\endpgfinterruptboundingbox
+{%
+ \global\pgf@picmaxx=\pgf@interrupt@savemaxx%
+ \global\pgf@picmaxy=\pgf@interrupt@savemaxy%
+ \global\pgf@picminx=\pgf@interrupt@saveminx%
+ \global\pgf@picminy=\pgf@interrupt@saveminy%
+ \endgroup%
+}
+
+
+
+
+
+% Interrupts a picture
+%
+% Description:
+%
+% This environment interrupts a picture and temporarily returns to
+% normal TeX mode. All sorts of things are saved and restored by this
+% environment.
+%
+% WARNING: Using this environment in conjuction with low level
+% transformations can *strongly* upset the typesetting. Typically, the
+% contents of this environment should have size/height/depth 0pt in
+% the end.
+%
+% WARNING: This environment should only be used inside typesetting a
+% box and this box must in turn be inserted using \pgfqbox.
+%
+% Example: Draw two parallel lines
+%
+% \pgfmoveto{\pgfpoint{0cm}{0cm}}
+% \setbox\mybox=\hbox{
+% \begin{pgfinterruptpicture}
+% This is normal text.
+% \begin{pgfpicture} % a subpicture
+% \pgfmoveto{\pgfpoint{1cm}{0cm}}
+% \pgfmoveto{\pgfpoint{1cm}{1cm}}
+% \pgfusepath{stroke}
+% \end{pgfpicture}
+% More text.
+% \end{pgfinterruptpicture}
+% }
+% \ht\mybox=0pt
+% \wd\mybox=0pt
+% \dp\mybox=0pt
+% \pgfqbox{\mybox}%
+% \pgfpathlineto{\pgfpoint{0cm}{1cm}}
+% \pgfusepath{stroke}
+
+\def\pgfinterruptpicture
+{%
+ \begingroup%
+ \pgfinterruptboundingbox%
+ \pgftransformreset%
+ \pgfinterruptpath%
+ \ifx\pgf@selectfontorig\@undefined%
+ \else%
+ \let\setlength\pgf@setlengthorig%
+ \let\addtolength\pgf@addtolengthorig%
+ \let\selectfont\pgf@selectfontorig%
+ \fi%
+ \pgfutil@selectfont%
+ \pgfpicturefalse%
+ \let\pgf@positionnodelater@macro\relax%
+ \pgf@savelayers%
+}
+\def\endpgfinterruptpicture
+{%
+ \pgf@restorelayers%
+ \endpgfinterruptpath%
+ \endpgfinterruptboundingbox%
+ \endgroup%
+}
+
+\let\pgf@savelayers=\relax
+\let\pgf@restorelayers=\relax
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfkeys.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfkeys.code.tex
new file mode 100644
index 0000000000..c2edfccaea
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfkeys.code.tex
@@ -0,0 +1,1067 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%%
+
+
+
+% 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%
+}
+\newif\ifpgfkeys@syntax@handlers
+\def\pgfkeys@normal{%
+ \ifpgfkeys@syntax@handlers%
+ \expandafter\pgfkeys@syntax@handlers%
+ \else%
+ \expandafter\pgfkeys@@normal%
+ \fi%
+}
+\def\pgfkeys@syntax@handlers{\pgfutil@ifnextchar\relax\pgfkeys@syntax@@handlers\pgfkeys@syntax@@handlers}%get rid of spaces
+\def\pgfkeys@syntax@@handlers{\futurelet\pgfkeys@first@char\pgfkeys@syntax@handlers@test}
+\def\pgfkeys@syntax@handlers@test{%
+ \pgfkeysgetvalue{/handlers/first char syntax/\meaning\pgfkeys@first@char}\pgfkeys@the@handler%
+ \ifx\pgfkeys@the@handler\relax%
+ \expandafter\pgfkeys@@normal%
+ \else%
+ \expandafter\pgfkeys@use@handler%
+ \fi%
+}
+\long\def\pgfkeys@use@handler#1,{%
+ \pgfkeys@the@handler{#1}%
+ \pgfkeys@parse%
+}
+
+\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\pgfkeysaddhandleonlyexistingexception#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{%
+ \long\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{%
+ \long\edef\pgfkeys@temp#2\pgfeov{#3}%
+ \pgfkeyslet{#1/.@cmd}{\pgfkeys@temp}%
+ \pgfkeyssetvalue{#1/.@args}{#2\pgfeov}%
+ \pgfkeyssetvalue{#1/.@body}{#3}%
+}
+
+% Like \pgfkeysdefargs, but `#2' is an integer denoting the expected
+% *number* of arguments.
+%
+% There is a subtle difference between the 'args' command, when it
+% comes to spaces:
+% a key defined with defargs{#1#2} must not have spaces between the
+% arguments when it is used.
+%
+% See this:
+%
+%--------------------------------------------------
+% % defnargs:
+% \pgfkeysdefnargs{/a}{2}{1=`#1', 2=`#2'}
+% \pgfkeys{
+% /a=
+% {1}
+% {2}
+% }
+% ->defnargs: 1=`1', 2=`2'
+%
+% defargs:
+% \pgfkeysdefargs{/b}{#1#2}{1=`#1', 2=`#2'}
+% \pgfkeys{
+% /b=
+% {1}
+% {2}
+% }
+% ->defargs: 1=`1', 2=` 2' (note the space!)
+%
+% defargs:
+% \pgfkeysdefargs{/b}{#1#2}{1=`#1', 2=`#2'}
+% \pgfkeys{
+% /b=
+% {1}%
+% {2}
+% }
+% ->defargs: 1=`1', 2=`2'
+%--------------------------------------------------
+\long\def\pgfkeysdefnargs#1#2#3{\pgfkeysdefnargs@{#1}{#2}{#3}{\def}}%
+\long\def\pgfkeysedefnargs#1#2#3{\pgfkeysdefnargs@{#1}{#2}{#3}{\edef}}%
+\long\def\pgfkeysdefnargs@#1#2#3#4{%
+ \ifcase#2\relax
+ \pgfkeyssetvalue{#1/.@args}{}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1##2}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1##2##3}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1##2##3##4}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8}%
+ \or
+ \pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8##9}%
+ \else
+ \pgfkeys@error{\string\pgfkeysdefnargs: expected <= 9 arguments, got #2}%
+ \fi
+ \pgfkeysgetvalue{#1/.@args}\pgfkeys@tempargs
+ \def\pgfkeys@temp{\expandafter#4\csname pgfk@#1/.@@body\endcsname}%
+ \expandafter\pgfkeys@temp\pgfkeys@tempargs{#3}%
+ % eliminate the \pgfeov at the end such that TeX gobbles spaces
+ % by using
+ % \pgfkeysdef{#1}{\pgfkeysvalueof{#1/.@@body}##1}
+ % (with expansion of '#1'):
+ \edef\pgfkeys@tempargs{\noexpand\pgfkeysvalueof{#1/.@@body}}%
+ \def\pgfkeys@temp{\pgfkeysdef{#1}}%
+ \expandafter\pgfkeys@temp\expandafter{\pgfkeys@tempargs##1}%
+ \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}}
+\pgfkeysdefnargs{/handlers/.code args}{2}{\pgfkeysdefargs{\pgfkeyscurrentpath}{#1}{#2}}
+\pgfkeysdefnargs{/handlers/.ecode args}{2}{\pgfkeysedefargs{\pgfkeyscurrentpath}{#1}{#2}}
+\pgfkeysdefnargs{/handlers/.code n args}{2}{\pgfkeysdefnargs{\pgfkeyscurrentpath}{#1}{#2}}
+\pgfkeysdefnargs{/handlers/.ecode n args}{2}{\pgfkeysedefnargs{\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}%
+ \def\pgfkeys@marshal{\expandafter\gdef\expandafter\pgfkeys@global@temp\pgfkeys@tempargs}%
+ \expandafter\pgfkeys@marshal\expandafter{\pgfkeys@tempbody}%
+ }%
+ \pgfkeysifdefined{\pgfkeyscurrentpath/.@@body}{%
+ % support for \pgfkeysndefargs:
+ \pgfkeyslet{\pgfkeyscurrentpath/.@@body}{\pgfkeys@global@temp}%
+ }{%
+ % support for \pgfkeysdefargs:
+ \pgfkeyslet{\pgfkeyscurrentpath/.@cmd}{\pgfkeys@global@temp}%
+ }%
+ }%
+ {%
+ % No, so single argument (simple \pgfkeysdef). 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}}}
+\pgfkeys{/handlers/.style n args/.code 2 args=\pgfkeys{\pgfkeyscurrentpath/.code n args={#1}{\pgfkeysalso{#2}}}}
+
+% 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}}}
+
+
+% Repeatedly setting a key
+
+\pgfkeys{/handlers/.list/.code=%
+ {%
+ % Use foreach to unfold the list
+ \let\pgf@keys@temp=\pgfutil@empty%
+ \foreach \pgf@keys@key in{#1}%
+ {\expandafter\expandafter\expandafter\gdef%
+ \expandafter\expandafter\expandafter\pgf@keys@temp%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@keys@temp\expandafter{\pgf@keys@key}}}%
+ \edef\pgf@keys@list@path{\pgfkeyscurrentpath}%
+ \expandafter\expandafter\expandafter\pgf@keys@do@list%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@keys@list@path\expandafter}\pgf@keys@temp\pgf@stop%
+ }%
+}
+\def\pgf@keys@do@list#1{\pgfutil@ifnextchar\bgroup{\pgf@keys@do@list@item{#1}}\pgfutil@gobble}
+\def\pgf@keys@do@list@item#1#2{\pgfkeysalso{#1={#2}}\pgf@keys@do@list{#1}}
+
+
+% Forwarding
+
+\pgfkeys{/handlers/.forward to/.code=%
+ \pgfkeysifdefined{\pgfkeyscurrentpath/.@cmd}{}{\pgfkeysdef{\pgfkeyscurrentpath}{}}
+ \pgfkeys{\pgfkeyscurrentpath/.add code={}{\pgfkeys{#1={##1}}}}
+}
+
+
+% 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
+
+
+% First char syntax handlers
+\pgfkeys{/handlers/first char syntax/.is if=pgfkeys@syntax@handlers}
+
+% 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}}
+
+\long\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={\pgfkeysaddhandleonlyexistingexception{#1}},
+}%
+\pgfkeysaddhandleonlyexistingexception{.cd}%
+\pgfkeysaddhandleonlyexistingexception{.try}%
+\pgfkeysaddhandleonlyexistingexception{.retry}%
+\pgfkeysaddhandleonlyexistingexception{.lastretry}%
+\pgfkeysaddhandleonlyexistingexception{.unknown}%
+
+
+\input pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex
new file mode 100644
index 0000000000..b40528c43a
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex
@@ -0,0 +1,1041 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%%
+
+
+
+% Copyright 2008 by Christian Feuersaenger
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+%
+% This file contains additions to pgfkeys.code.tex (loaded
+% automatically at the end of pgfkeys.code.tex)
+%
+% Improvements:
+%
+% - option filtering
+% you provide
+% - a boolean predicate
+% - a "filter handler" which will be invoked for non-matching options,
+% - a key=value list as usual.
+% The filter sets only matching options and invokes the handler for
+% unmatching ones.
+%
+% - Fast family support as in xkeyval.
+% - A key like /my tree/my option can be associated with /my family
+% - You can efficiently set keys which belong to a set of "active"
+% families.
+% Remaining options can be collected into a macro.
+
+% WARNING:
+% this file overwrites
+% \pgfkeys@addpath
+% \pgfkeys@nevermind
+%
+% all other features are 'additive'
+
+
+% these implementations will be switched dynamically with their
+% filtered versions (in \pgfkeys@install@filter@and@invoke)
+\let\pgfkeys@orig@case@one=\pgfkeys@case@one
+\let\pgfkeys@orig@@set=\pgfkeys@@set
+\let\pgfkeys@orig@@qset=\pgfkeys@@qset
+\let\pgfkeys@orig@try=\pgfkeys@try
+\let\pgfkeys@orig@unknown=\pgfkeys@unknown
+
+\newif\ifpgfkeysfilteringisactive
+\newif\ifpgfkeysfiltercontinue
+\let\pgfkeys@key@predicate=\pgfkeys@empty
+\let\pgfkeys@filtered@handler=\pgfkeys@empty
+\newtoks\pgfkeys@tmptoks
+
+% Performs 'filtered' key settings.
+%
+% For every option for which the path prefixing has already been done,
+% the current key filter predicate will be invoked. If the predicate
+% returns true, pgfkeys will process this key in the normal manner.
+% If not, a key filter handler will be invoked.
+%
+% The *predicate* and *handler* semantics are as follows:
+% PRECONDITION:
+% 1. The variables
+% \pgfkeyscurrentkey (full path including name)
+% \pgfkeyscurrentkeyRAW (the current key as it has been
+% found in the key=value list
+% without path modification)
+% \pgfkeyscurrentvalue
+% are all set. If the current key is a handler variable,
+% \pgfkeyscurrentname
+% and
+% \pgfkeyscurrentpath
+% are also set.
+% 2. The type of option has already been checked, that means
+% case (1) whether '.@cmd' exists
+% case (2) whether the key as such has its value
+% case (3) it is a handler like '.code', '.cd' or whatever.
+% case (0) it is unknown.
+% The actual case number (0-3) will be provided as contents
+% of the macro
+% \pgfkeyscasenumber.
+% 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.
+%
+% POSTCONDITION:
+% the predicate sets
+% \pgfkeysfiltercontinuetrue
+% or
+% \pgfkeysfiltercontinuefalse
+% (the boolean \ifpgfkeysfiltercontinue).
+% Depending on this 'if', option processing will be continued or
+% skipped.
+%
+% The handler can do anything with the option, for example collect
+% unmatched ones.
+%
+% ATTENTION: \pgfkeysfiltered can't be nested (yet). Use the
+% \pgfkeyspredicateAND if you need multiple predicates at once.
+% Nesting would produce unexpected results because the current filter
+% state can't be stored/restored without TeX-groups, therefor it is
+% disabled.
+%
+% ATTENTION: you can't filter error messages.
+%
+% REMARK: In case (3), the macros \pgfkeyscurrentpath and
+% \pgfkeyscurrentname have already been computed, you do not need to
+% invoke \pgfkeyssplitpath. In any other case, neither path nor name
+% are required for the options processing - if you need them for
+% predicates/handlers, you need to compute them by hand.
+%
+%
+% Example:
+% \def\unmatched{}
+% \pgfkeys{/pgf/key filters/is descendant of/.install key filter=/my group}
+% \pgfkeys{/pgf/key filter handlers/append filtered to/.install key filter handler=\unmatched}
+% \pgfkeysfiltered%
+% {/my group/option 1=value 1,/tikz/option 2=value 2}
+% ->
+% will set '/my group/option 1' as usual, but '/tikz/option 2' will not
+% be set. Instead, it will be appended to '\unmatched' such that
+% \unmatched = {/tikz/option 2=value2}
+% after the operation.
+%
+% Arguments:
+% #1: key-value list.
+\def\pgfkeysfiltered{%
+ % produce
+ % '{<default path>}'
+ % each expanded exactly one time into the register:
+ \expandafter\pgfkeysfiltered@@install\expandafter{\pgfkeysdefaultpath}%
+}
+
+% #1: old value of default path.
+% #2: key-value-list.
+\def\pgfkeysfiltered@@install#1#2{%
+ \pgfkeys@install@filter@and@invoke{%
+ \let\pgfkeysdefaultpath\pgfkeys@root%
+ \pgfkeys@parse#2,\pgfkeys@mainstop%
+ \def\pgfkeysdefaultpath{#1}%
+ }%
+}
+
+% Assuming that macro #1 contains a key=value list, this command
+% performs an \pgfkeysalso command for the content of macro #1.
+%
+% It can be used in conjunction with
+% - \pgfkeysfiltered and
+% - \pgfkeysappendfilterednamestomacro:
+% the first pass fill only process options matching the filter, then,
+% a \pgfkeysalsofrom can be used at a later time to set the remaining
+% options.
+%
+% Example:
+% \pgfkeys{/my group/.cd,/utils/exec=\pgfkeysalsofrom\filtered}
+\long\def\pgfkeysalsofrom#1{%
+ \expandafter\pgfkeysalso\expandafter{#1}%
+}
+
+% The same as \pgfkeysalsofrom, but it invokes \pgfkeysalsofiltered.
+\long\def\pgfkeysalsofilteredfrom#1{%
+ \expandafter\pgfkeysalsofiltered\expandafter{#1}%
+}
+
+% #1 = options
+\long\long\def\pgfkeysalsofiltered#1{%
+ \pgfkeys@install@filter@and@invoke{\pgfkeysalso{#1}}%
+}%
+
+% The same like \pgfkeysfiltered, but with quick search path setting.
+%
+% #1: default path
+% #2: key-value-pairs
+\long\def\pgfqkeysfiltered#1{%
+ \expandafter\pgfqkeysfiltered@@install\expandafter{\pgfkeysdefaultpath}{#1}%
+}
+
+% #1: old value of default path.
+% #2: default path
+% #3: key-value-list.
+\long\def\pgfqkeysfiltered@@install#1#2#3{%
+ \pgfkeys@install@filter@and@invoke{%
+ \def\pgfkeysdefaultpath{#2/}\pgfkeys@parse#3,\pgfkeys@mainstop\def\pgfkeysdefaultpath{#1}%
+ }%
+}
+
+% Family management
+%
+% The family code provides the following features:
+% 1. every key can be associated with 0 or 1 'family'.
+% 2. Families are a loose association which are independend of the key
+% hierarchy.
+% For example, /my tree/key1 can belong to family /tikz.
+%
+% 3. It is possible to "activate" or "deactivate" single families.
+% Furthermore, it is possible to set only keys which belong to
+% active families (using \pgfkeysfiltered).
+% 4. Runtime complexities:
+% If you have N options and you only want to process K active
+% families, the runtime is O( N + K ):
+% - activate every family O(K)
+% - use \pgfkeyshasactivefamily as filter predicate O(N)
+% - deactivate every family O(K)
+
+
+% Activates family #1.
+%
+% #1 maybe a macro.
+\def\pgfkeysactivatefamily#1{%
+ \pgfkeysiffamilydefined
+ {#1}%
+ {\csname pgfk@#1/familyactivetrue\endcsname}%
+ {\pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov}%
+%\message{[ACTIVATING FAMILY #1]}%
+}
+
+% Deactivates family #1.
+%
+% #1 maybe a macro.
+\def\pgfkeysdeactivatefamily#1{%
+ \pgfkeysiffamilydefined
+ {#1}%
+ {\csname pgfk@#1/familyactivefalse\endcsname}%
+ {\pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov}%
+%\message{[DEACTIVATING FAMILY #1]}%
+}
+
+% Activates all families in the comma separated list #1.
+%
+% It will also generate code for deactivation of all those families
+% into the command #2.
+%
+% #1: a comma-separated list of fully qualified family names.
+% #2: a command which will be filled with a deactivate-all command.
+\def\pgfkeysactivatefamilies#1#2{%
+ \pgfkeyssavekeyfilterstateto\pgfkeys@cur@state
+ \expandafter\pgfkeysactivatefamilies@impl\expandafter{\pgfkeys@cur@state}{#1}{#2}%
+}
+% #1: commands needed to restore the old filtering state
+% #2: family name list
+% #3: macro name for de-activate command
+\def\pgfkeysactivatefamilies@impl#1#2#3{%
+ \pgfkeysinstallkeyfilter{/pgf/key filters/false}{}%
+ \let#3=\pgfkeys@empty%
+ \def\pgfkeys@filtered@handler{\pgfkeys@family@activate@handler{#3}}%
+ \pgfkeysalsofiltered{#2}%
+ #1%
+}
+
+\def\pgfkeys@family@activate@handler#1{%
+ \pgfkeysactivatefamily{\pgfkeyscurrentkey}%
+ % produce
+ % <old list> '\pgfkeysdeactivatefamily{' <current key> '}'
+ \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter#1\expandafter\pgfkeysdeactivatefamily\expandafter{\pgfkeyscurrentkey}}%
+ \edef#1{\the\pgfkeys@tmptoks}%
+}
+
+% If for testing whether a family exists.
+%
+% #1 = fully qualified family name
+% #2 = if-case
+% #3 = else-case
+%
+% Description:
+%
+% If the family exists, #2 will be executed. Otherwise, #3 will be
+% called.
+\long\def\pgfkeysiffamilydefined#1#2#3{\pgfkeys@ifcsname ifpgfk@#1/familyactive\endcsname#2\else#3\fi}
+
+% Sets the TeX boolean
+% \ifpgfkeysfiltercontinue := ( family #1 is active )
+%
+% Argument:
+% #1 the family name. Maybe a macro.
+\def\pgfkeysisfamilyactive#1{%
+ \pgfkeysiffamilydefined{#1}{%
+ \expandafter\let\expandafter\ifpgfkeysfiltercontinue\csname ifpgfk@#1/familyactive\endcsname
+ }{%
+ \pgfkeysvalueof{/errors/family unknown/.@cmd}{#1}\pgfeov%
+ \expandafter\expandafter\expandafter\let\csname ifpgfkeysfiltercontinue\endcsname\csname iffalse\endcsname
+ }%
+}%
+
+% Retrieve the family of full key #1 into macro #2.
+%
+% Will set the TeX boolean \ifpgfkeyssuccess to whether the full key
+% really has a family.
+%
+% The family for any key is stored in the sub-key #1/family.
+%
+% Parameters:
+% #1: the full key name for which the family is requested. Maybe a
+% macro.
+% #2: a macro name which will be filled with the result.
+\def\pgfkeysgetfamily#1#2{%
+ \pgfkeysifdefined{#1/family}{\pgfkeysgetvalue{#1/family}{#2}\pgfkeyssuccesstrue}{\pgfkeyssuccessfalse}%
+}
+
+% 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
+% the /errors tree.
+\long\def\pgfkeys@cur@is@descendant@of@errors{%
+ \expandafter\pgfkeys@cur@is@descendant@of@errors@impl\pgfkeyscurrentkey/errors\pgf@@eov
+}%
+\long\def\pgfkeys@cur@is@descendant@of@errors@impl#1/errors#2\pgf@@eov{%
+ \def\pgfkeyspred@TMP{#1}%
+ \ifx\pgfkeyspred@TMP\pgfkeys@empty
+%\message{[SPECIAL CHECK] '\pgfkeyscurrentkey' is descendant of '/errors': TRUE.}%
+ \pgfkeysfiltercontinuetrue
+ \else
+%\message{[SPECIAL CHECK] '\pgfkeyscurrentkey' is descendant of '/errors': FALSE.}%
+ \pgfkeysfiltercontinuefalse
+ \fi
+}%
+
+% \pgfkeysinterruptkeyfilter
+% ...
+% \endpgfkeysinterruptkeyfilter
+% temporarily interrupts key filtering and enables it in
+% \endpgfkeysinterruptkeyfilter.
+%
+% If key filtering it not active, this has no effect at all.
+%
+% REMARK:
+% \pgfkeysinterruptkeyfilter...\endpgfkeysinterruptkeyfilter does NOT
+% introduce a \TeX-group.
+\def\pgfkeysinterruptkeyfilter{%
+ \ifpgfkeysfilteringisactive
+ \let\pgfkeys@case@one=\pgfkeys@orig@case@one
+ \let\pgfkeys@try=\pgfkeys@orig@try
+ \let\pgfkeys@unknown=\pgfkeys@orig@unknown
+ \fi
+}
+
+\def\endpgfkeysinterruptkeyfilter{%
+ \ifpgfkeysfilteringisactive
+ \let\pgfkeys@case@one=\pgfkeys@case@one@filtered
+ \let\pgfkeys@try=\pgfkeys@try@filtered
+ \let\pgfkeys@unknown=\pgfkeys@unknown@filtered
+ \fi
+}
+
+% Activates families #1, calls \pgfkeysfiltered and deactivates the
+% families afterwards.
+%
+% REMARK: you need to install a family-based key filter predicate
+% manually to benefit from the activated families!
+%
+% #1: comma separated family list
+% #2: key-value pairs
+%
+% @see \pgfkeysactivatefamiliesandfilteroptions
+\def\pgfkeysactivatefamiliesandfilteroptions#1#2{%
+ \pgfkeysactivatefamilies{#1}{\pgfkeys@family@deactivation}%
+ \pgfkeysfiltered{#2}%
+ \pgfkeys@family@deactivation
+}
+
+% The "quick" variant of \pgfkeysactivatefamiliesandfilteroptions: it
+% also assigns a default path.
+%
+% #1: comma separated family list
+% #2: default path
+% #3: key-value pairs
+\def\pgfqkeysactivatefamiliesandfilteroptions#1#2#3{%
+ \pgfkeysactivatefamilies{#1}{\pgfkeys@family@deactivation}%
+ \pgfqkeysfiltered{#2}{#3}%
+ \pgfkeys@family@deactivation
+}
+
+% Public version of split path:
+\def\pgfkeyssplitpath{\pgfkeys@split@path}%
+
+
+% The same as \pgfkeysactivatefamiliesandfilteroptions but just for
+% ONE family.
+%
+% #1: family (maybe a macro)
+% #2: key-value pairs
+\def\pgfkeysactivatesinglefamilyandfilteroptions#1#2{%
+ \pgfkeysactivatefamily{#1}%
+ \pgfkeysfiltered{#2}%
+ \pgfkeysdeactivatefamily{#1}%
+}
+
+% The "quick" variant of \pgfkeysactivatesinglefamilyandfilteroptions
+%
+% #1: family (maybe a macro)
+% #2: default path
+% #3: key-value pairs
+\def\pgfqkeysactivatesinglefamilyandfilteroptions#1#2#3{%
+ \pgfkeysactivatefamily{#1}%
+ \pgfqkeysfiltered{#2}{#3}%
+ \pgfkeysdeactivatefamily{#1}%
+}
+
+% Installs the key filter '#1' with argument '#2'.
+% This is equivalent to
+% \pgfkeys{#1/.install key filter=#2}
+%
+% The current values of the key filter handler is stored into the public
+% macros
+% \pgfkeyscurrentkeyfilter
+% and
+% \pgfkeyscurrentkeyfilterargs
+%
+% #1: a full key name; may be a macro
+% #2: optional arguments for the key. If the key expects more than one
+% argument, supply '{{first}{second}}'
+\def\pgfkeysinstallkeyfilter#1#2{%
+ \pgfkeysifdefined{#1/.@cmd}{%
+ \edef\pgfkeyscurrentkeyfilter{#1}%
+ \def\pgfkeyscurrentkeyfilterargs{#2}%
+ \pgfkeysgetvalue{#1/.@cmd}{\pgfkeys@key@predicate@}%
+ \def\pgfkeys@key@predicate{\pgfkeys@key@predicate@#2\pgfeov}%
+ }{%
+ \pgfkeysvalueof{/errors/no such key filter/.@cmd}{#1}{#2}\pgfeov%
+ }%
+}
+
+% Installs the key filter handler '#1' with argument '#2'.
+% This is equivalent to
+% \pgfkeys{#1/.install key filter handler=#2}
+%
+% The current values of the key filter handler is stored into the public
+% macros
+% \pgfkeyscurrentkeyfilterhandler
+% and
+% \pgfkeyscurrentkeyfilterhandlerargs
+%
+% #1: a full key name; may be a macro
+% #2: optional arguments for the handler. If the handler expects more than one
+% argument, supply '{{first}{second}}'
+\def\pgfkeysinstallkeyfilterhandler#1#2{%
+ \pgfkeysifdefined{#1/.@cmd}{%
+ \edef\pgfkeyscurrentkeyfilterhandler{#1}%
+ \def\pgfkeyscurrentkeyfilterhandlerargs{#2}%
+ \pgfkeysgetvalue{#1/.@cmd}{\pgfkeys@filtered@handler@}%
+ \def\pgfkeys@filtered@handler{\pgfkeys@filtered@handler@#2\pgfeov}%
+ }{%
+ \pgfkeysvalueof{/errors/no such key filter handler/.@cmd}{#1}{#2}\pgfeov%
+ }%
+}
+
+% Creates a macro which contains commands to re-activate the current
+% key filter and key filter handler. It can be used to temporarily
+% switch the key filter.
+\def\pgfkeyssavekeyfilterstateto#1{%
+ % produce the string
+ % \pgfkeysinstallkeyfilter{...}{...}
+ % \pgfkeysinstallkeyfilterhandler{...}{...}
+ % where each argument is expanded once
+ % FIXME: Do the same with less overhead!
+ \pgfkeys@tmptoks={\pgfkeysinstallkeyfilter}%
+ \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilter}}%
+ \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterargs}\pgfkeysinstallkeyfilterhandler}%
+ \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterhandler}}%
+ \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfkeys@tmptoks\expandafter{\pgfkeyscurrentkeyfilterhandlerargs}}%
+ \edef#1{%
+ \the\pgfkeys@tmptoks
+ }%
+}
+
+
+\pgfkeys{%
+ /errors/family unknown/.code=\pgfkeys@error{%
+ Sorry, I do not know family '#1' and can't work with any assoicated family handling. Perhaps you misspelled it?},
+ /errors/no such key filter/.code 2 args=\pgfkeys@error{Sorry, there is no such key filter '#1'.},
+ /errors/no such key filter handler/.code 2 args=\pgfkeys@error{Sorry, there is no such key filter handler '#1'.},
+ % HANDLERS:
+ %
+ % .is family should
+ % 1. '.cd' into the families' path,
+ % 2. define booleans to activate/deactive the family
+ % (see \pgfkeysisfamilyactive)
+ % 3. make sure that \pgfkeyshasactivefamily returns true for
+ % the family itsself.
+ /handlers/.is family/.append code={%
+ %\newif is an \outer macro in plain tex, so this here is not portable:
+ %\expandafter\newif\csname if\pgfkeyscurrentpath/familyactive\endcsname
+ \edef\pgfkeyspred@TMP{pgfk@\pgfkeyscurrentpath/familyactive}%
+ \expandafter\pgfkeys@non@outer@newif\expandafter{\pgfkeyspred@TMP}%
+ \edef\pgfkeyspred@TMP{\pgfkeyscurrentpath/.belongs to family=\pgfkeyscurrentpath}%
+ \expandafter\pgfkeysalso\expandafter{\pgfkeyspred@TMP}%
+ },%
+ /handlers/.activate family/.code=\pgfkeysactivatefamily{\pgfkeyscurrentpath},
+ /handlers/.deactivate family/.code=\pgfkeysdeactivatefamily{\pgfkeyscurrentpath},
+ /handlers/.belongs to family/.code={\pgfkeyssetfamily{\pgfkeyscurrentpath}{#1}},%
+ %
+ %
+ % An addition to the '.try' and '.retry' handlers:
+ %
+ % It is the same as '.retry', but if the option is still unknown, the
+ % usual handlers for unknown keys will be invoked.
+ /handlers/.lastretry/.code={%
+ \ifpgfkeyssuccess\else
+ \pgfkeys@try
+ \ifpgfkeyssuccess\else
+ % discard the '.lastretry' suffix:
+ \edef\pgfkeyscurrentkey{\pgfkeyscurrentpath}%
+ \pgfkeys@split@path%
+ \pgfkeys@unknown
+ \fi
+ \fi
+ },
+ %
+ %
+ /handlers/.install key filter/.code={%
+ \pgfkeysinstallkeyfilter{\pgfkeyscurrentpath}{#1}%
+ },%
+ /handlers/.install key filter handler/.code={%
+ \pgfkeysinstallkeyfilterhandler{\pgfkeyscurrentpath}{#1}%
+ },%
+ %
+ %
+ % KEY FILTER HANDLERS:
+ %
+ /pgf/key filter handlers/append filtered to/.code={%
+ % Produce
+ % <orig key> '={' <value> '}'
+ % where both, the key and the value are expanded just ONCE:
+ \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter\pgfkeyscurrentkeyRAW\expandafter=\expandafter{\pgfkeyscurrentvalue}}%
+ \ifx#1\pgfkeys@empty
+ \else
+ % Produce <old list> ',' <orig key> '={' <value> '}'
+ \pgfkeys@tmptoks=\expandafter\expandafter\expandafter{\expandafter#1\expandafter,\the\pgfkeys@tmptoks}%
+ \fi
+ \edef#1{\the\pgfkeys@tmptoks}%
+ },%
+ /pgf/key filter handlers/ignore/.code={},
+ /pgf/key filter handlers/ignore/.install key filter handler,
+ /pgf/key filter handlers/log/.code={%
+ \immediate\write16{LOG: the option '\pgfkeyscurrentkey' (was originally '\pgfkeyscurrentkeyRAW') (case \pgfkeyscasenumber) has not been processed due to pgfkeysfiltered.}%
+ },
+ %
+ %
+ % KEY FILTER PREDICATES:
+ %
+ % Returns true iff the currently processed key belongs to an active family.
+ % A family is active if it has been activated before.
+ /pgf/key filters/active families/.code={%
+ \if\pgfkeyscasenumber0%
+ % unknown options shall be processed with the
+ % unknown-handlers.
+ \pgfkeysfiltercontinuetrue
+ \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
+ },%
+ %
+ %
+ %
+ % This filter works as follows:
+ % 1. if the current key belongs to a family:
+ % return whether its family is active,
+ % 2. if the current key does NOT belong to a family:
+ % return the result of criterion '#1',
+ % 3. the current key is unknown:
+ % return the result of criterion '#2'.
+ %
+ % Arguments:
+ % #1: the predicate which will be invoked in case 2.
+ % It will be invoked with the current case number as argument.
+ % #2: the predicate which will be invoked in case 3 with
+ % the current case number as argument.
+ /pgf/key filters/active families or no family/.code 2 args={%
+ \if\pgfkeyscasenumber0%
+ \pgfkeysevalkeyfilterwith{#2}%
+ \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.
+ \pgfkeysevalkeyfilterwith{#1}%
+ \fi
+ \fi
+ },
+ /pgf/key filters/active families or no family DEBUG/.code 2 args={%
+ \if\pgfkeyscasenumber0%
+ \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) invoking unknown handler '#2']}%
+ \pgfkeysevalkeyfilterwith{#2}%
+ \else
+ \if\pgfkeyscasenumber3%
+ \pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP
+ \else
+ \pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP
+ \fi
+ \ifpgfkeyssuccess
+ \pgfkeysisfamilyactive{\pgfkeyspred@TMP}%
+ \ifpgfkeysfiltercontinue
+ \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) family is ACTIVE]}%
+ \else
+ \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) family is NOT active.]}%
+ \fi
+ \else% Ok, it does not belong to any family.
+ \immediate\write16{[pgfkeyshasactivefamilyornofamily(\pgfkeyscurrentkey, \pgfkeyscasenumber) invoking has-no-family-handler '#1']}%
+ \pgfkeysevalkeyfilterwith{#1}%
+ \fi
+ \fi
+ },
+ %
+ % 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
+ % will be true for
+ % /foo/bar/x=y
+ % /foo/.cd
+ % /foo/bar/.style=...
+ % but not for
+ % /bar/foo/...
+ /pgf/key filters/is descendant of/.code={%
+ \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:
+ % [ 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.}%
+ \pgfkeysfiltercontinuetrue
+ \else
+%\message{'\pgfkeyscurrentkey' (case \pgfkeyscasenumber) is descendant of '#1': FALSE.}%
+ \pgfkeysfiltercontinuefalse
+ \fi
+ }%
+ \expandafter\pgfkeysisdescendantof@impl\pgfkeyscurrentkey#1\pgf@@eov
+ \fi
+ },%
+ %
+ %
+ %
+ % Returns true if the currently processed full key equals #2.
+ /pgf/key filters/equals/.code={%
+ \if\pgfkeyscasenumber0%
+ % Unknown option:
+ \pgfkeysfiltercontinuetrue
+ \else
+ \def\pgfkeyspred@TMP{#1}%
+ \ifx\pgfkeyscurrentkey\pgfkeyspred@TMP
+ \pgfkeysfiltercontinuetrue
+ \else
+ \pgfkeysfiltercontinuefalse
+ \fi
+ \fi
+ },%
+ %
+ %
+ % Argument #1 can be any other (evaluated) filter predicate, its logical return
+ % value will be inverted.
+ % Example:
+ % not/.install key filter={is descendend of=/tikz}
+ % will install a key filter which evaluates 'is descendant of' with argument '/tikz' and returns the logical negation of the result.
+ %
+ /pgf/key filters/not/.code={%
+ \pgfkeysevalkeyfilterwith{#1}%
+ \ifpgfkeysfiltercontinue
+ \pgfkeysfiltercontinuefalse
+ \else
+ \pgfkeysfiltercontinuetrue
+ \fi
+ },%
+ /pgf/key filters/and/.code 2 args={%
+ \pgfkeysevalkeyfilterwith{#1}%
+ \ifpgfkeysfiltercontinue
+ \pgfkeysevalkeyfilterwith{#2}%
+ \fi
+ },%
+ /pgf/key filters/or/.code 2 args={%
+ \pgfkeysevalkeyfilterwith{#1}%
+ \ifpgfkeysfiltercontinue
+ \else
+ \pgfkeysevalkeyfilterwith{#2}%
+ \fi
+ },%
+ /pgf/key filters/true/.code={\pgfkeysfiltercontinuetrue},%
+ /pgf/key filters/true/.install key filter,
+ /pgf/key filters/false/.code={%
+ \pgfkeysfiltercontinuefalse
+ },%
+ %
+ % Returns false if the current key is unknown, which avoids calling
+ % the unknown handlers.
+ /pgf/key filters/defined/.code={%
+ \if\pgfkeyscasenumber0%
+ \pgfkeysfiltercontinuefalse
+ \else
+ \pgfkeysfiltercontinuetrue
+ \fi
+ },
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Private IMPLEMENTATION
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% This command does THE SAME work as \pgfkeys@case@one,
+% but it applies filtering whenever it identified the type of an
+% option.
+\def\pgfkeys@case@one@filtered{%
+ \pgfkeys@cur@is@descendant@of@errors
+ \ifpgfkeysfiltercontinue
+ \pgfkeys@orig@case@one
+ \else
+ \pgfkeysfiltercontinuetrue
+ \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}{%
+ % CASE ONE: a command option
+ \def\pgfkeyscasenumber{1}%
+ \pgfkeys@key@predicate%
+ \ifpgfkeysfiltercontinue
+%\message{PROCESSING KEY \pgfkeyscurrentkey!}%
+ \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}%
+ \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov
+ \else
+%\message{FILTERED OUT KEY \pgfkeyscurrentkey!}%
+ \pgfkeys@filtered@handler%
+ \fi
+ }{%
+ % CASE TWO: a normal value option
+ \pgfkeysifdefined{\pgfkeyscurrentkey}{%
+ \def\pgfkeyscasenumber{2}%
+ \pgfkeys@key@predicate%
+ \ifpgfkeysfiltercontinue
+%\message{PROCESSING KEY \pgfkeyscurrentkey!}%
+ \pgfkeys@case@two@extern
+ \else
+%\message{FILTEReD OUT KEY \pgfkeyscurrentkey!}%
+ \pgfkeys@filtered@handler%
+ \fi
+ }{%
+ \pgfkeys@split@path
+ % CASE THREE: a handler
+ \pgfkeysifdefined{/handlers/\pgfkeyscurrentname/.@cmd}{%
+ \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
+ }{%
+ \pgfkeys@unknown
+ }%
+ }{%
+ \pgfkeys@unknown
+ }%
+ }%
+ }%
+ \fi
+}%
+
+\def\pgfkeys@unknown@filtered{%
+ % CASE ZERO: an unknown option.
+ \def\pgfkeyscasenumber{0}%
+ \pgfkeys@key@predicate%
+ \ifpgfkeysfiltercontinue
+%\message{PROCESSING KEY \pgfkeyscurrentkey!}%
+ % start normal 'unknown' handlers:
+ \pgfkeys@orig@unknown
+ \else
+%\message{FILTEReD OUT KEY \pgfkeyscurrentkey!}%
+ \pgfkeys@filtered@handler%
+ \fi
+}
+
+% Does the same as \pgfkeys@try, but it also invokes the key filters.
+\def\pgfkeys@try@filtered{%
+ \ifpgfkeysfiltercontinue
+ \pgfkeys@orig@try
+ \else
+ \pgfkeysfiltercontinuetrue
+ \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
+ \def\pgfkeyscasenumber{1}%
+ \pgfkeys@key@predicate%
+ \ifpgfkeysfiltercontinue
+ \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}%
+ \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov%
+ \else
+ \pgfkeys@filtered@handler%
+ \fi
+ \pgfkeyssuccesstrue%
+ }%
+ {%
+ \pgfkeysifdefined{\pgfkeyscurrentpath}%
+ {% CASE TWO: a normal value option
+ \def\pgfkeyscasenumber{2}%
+ \pgfkeys@key@predicate%
+ \ifpgfkeysfiltercontinue
+ \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text%
+ \pgfkeysvalueof{\pgfkeyscurrentpath}%
+ \else%
+ \pgfkeyslet{\pgfkeyscurrentpath}\pgfkeyscurrentvalue%
+ \fi%
+ \else
+ \pgfkeys@filtered@handler%
+ \fi
+ \pgfkeyssuccesstrue%
+ }%
+ {%
+ \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
+}
+
+
+% #1 the code to invoke after init and before cleanup
+\def\pgfkeys@install@filter@and@invoke#1{%
+ \ifpgfkeysfilteringisactive
+ \pgfkeys@error{Sorry, nested calls to key filtering routines are not allowed. (reason: It is not possible to properly restore the previous filtering state after returning from the nested call)}%
+ \fi
+ \pgfkeysfilteringisactivetrue
+ \let\pgfkeys@case@one=\pgfkeys@case@one@filtered
+ \let\pgfkeys@try=\pgfkeys@try@filtered
+ \let\pgfkeys@unknown=\pgfkeys@unknown@filtered
+ #1%
+ \let\pgfkeys@case@one=\pgfkeys@orig@case@one
+ \let\pgfkeys@try=\pgfkeys@orig@try
+ \let\pgfkeys@unknown=\pgfkeys@orig@unknown
+ \pgfkeysfilteringisactivefalse
+}
+
+
+%--------------------------------------------------
+% \def\pgfkeys@eval@key@filter@subroutine@case@one{%
+% \pgfkeysifdefined{\pgfkeyscurrentkey/.@cmd}{%
+% \pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}{\pgfkeys@code}%
+% \let\pgfkeyspred@TMP=\pgfkeyscurrentvalue
+% \pgfkeys@eval@key@filter@subroutine@restorestate
+% \expandafter\pgfkeys@code\pgfkeyspred@TMP\pgfeov
+% }{%
+% \pgfkeysvalueof{/errors/no such key filter/.@cmd}\pgfkeyscurrentkey\pgfkeyscurrentvalue\pgfeov%
+% }%
+% }
+% % THIS VERSION IS TOO SLOW. See below.
+% \def\pgfkeysevalkeyfilterwith#1{%
+% \edef\pgfkeys@eval@key@filter@subroutine@restorestate{%
+% \noexpand\def\noexpand\pgfkeyscurrentkey{\pgfkeyscurrentkey}%
+% \noexpand\def\noexpand\pgfkeyscurrentkeyRAW{\pgfkeyscurrentkeyRAW}%
+% \noexpand\def\noexpand\pgfkeyscurrentname{\pgfkeyscurrentname}%
+% \noexpand\def\noexpand\pgfkeyscurrentvalue{\pgfkeyscurrentvalue}%
+% \noexpand\pgfkeys@pathtoks={\pgfkeyscurrentpath}%
+% }%
+% \pgfkeysinterruptkeyfilter
+% \let\pgfkeys@case@one=\pgfkeys@eval@key@filter@subroutine@case@one
+% \pgfkeysalso{#1}%
+% \endpgfkeysinterruptkeyfilter% this here also restored \pgfkeys@case@one.
+% \pgfkeys@eval@key@filter@subroutine@restorestate
+% }%
+%--------------------------------------------------
+
+
+% Evaluates a key filter '#1'. Example:
+% \pgfkeysevalkeyfilterwith{/pgf/key filters/equals=/tikz}
+%
+% \pgfkeysevalkeyfilterwith works only if key filtering is
+% active.
+%
+% The argument '#1' MUST be a FULL KEY.
+%
+% The implementation employs a subset of the \pgfkeysalso code.
+\long\def\pgfkeysevalkeyfilterwith#1{%
+ \pgfkeys@eval@key@filter@subroutine@unpack#1=\pgfkeysnovalue=\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
+ \ifx\pgfkeyspred@TMPB\pgfkeysnovalue@text% Hmm... no value
+ \pgfkeysifdefined{\pgfkeyspred@TMP/.@def}%
+ {\pgfkeysgetvalue{\pgfkeyspred@TMP/.@def}{\pgfkeyspred@TMPB}}
+ {}% no default, so leave it
+ \fi%
+ \ifx\pgfkeyspred@TMPB\pgfkeysvaluerequired%
+ \pgfkeysvalueof{/errors/value required/.@cmd}\pgfkeyspred@TMP\pgfkeyspred@TMPB\pgfeov%
+ \else%
+ \pgfkeysifdefined{\pgfkeyspred@TMP/.@cmd}{%
+ \pgfkeysgetvalue{\pgfkeyspred@TMP/.@cmd}{\pgfkeys@code}%
+ \expandafter\pgfkeys@code\pgfkeyspred@TMPB\pgfeov
+ }{%
+ \pgfkeysvalueof{/errors/no such key filter/.@cmd}\pgfkeyspred@TMP\pgfkeyspred@TMPB\pgfeov%
+ }%
+ \fi%
+}
+
+
+\def\pgfkeys@non@outer@newif@#1#2{%
+ \expandafter\edef\csname #2true\endcsname{\noexpand\let\noexpand#1=\noexpand\iftrue}%
+ \expandafter\edef\csname #2false\endcsname{\noexpand\let\noexpand#1=\noexpand\iffalse}%
+ \csname #2false\endcsname
+}%
+
+% For latex and context, this here has the same effect as a \newif
+% applied to 'if#1'. For plain tex, it has also the same effect, but
+% it is not an \outer macro as the plain-tex \newif.
+\def\pgfkeys@non@outer@newif#1{%
+ \expandafter\pgfkeys@non@outer@newif@\csname if#1\endcsname{#1}%
+}
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex
new file mode 100644
index 0000000000..1c9cfe742d
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex
@@ -0,0 +1,2326 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Fr 10. Nov 17:18:26 CET 2017 %%%
+
+
+
+% Copyright 2008/2009 by Christian Feuersaenger
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU General Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+\newif\ifpgfmathfloatparseactive
+\newif\ifpgfmathfloat@scaleactive
+
+% public macro which invokes '#1' if the fpu is installed and ready and '#2'
+% otherwise.
+\def\pgflibraryfpuifactive#1#2{%
+ \ifpgfmathfloatparseactive
+ #1%
+ \else
+ #2%
+ \fi
+}%
+
+\pgfqkeys{/pgf}{
+ % enable the FPU parser if it is not yet active
+ %
+ % It will be deactivated after the current TeX group
+ fpu/.is choice,
+ fpu/true/.code={%
+ \ifpgfmathfloatparseactive
+ \else
+ \pgfutil@ifundefined{pgfmathdeclarefunction}{%
+ % Ohoh - we are running on a TeX distribution with
+ % PGF 2.00 which doesn't have the new math engine.
+ % I can provide special treatment here, provided that
+ % all float commands are still able to run (that means
+ % more information needs to be copied from the pgf cvs
+ % to pgf 2.00 - for example pgfmathfloat.code.tex).
+ %
+ % I employ this to work with pgfplots and pgf 2.00
+ % using all new features.
+ \pgfmathfloat@parser@install@pgf@two@null@null%
+ }{%
+ \pgfmathfloat@parser@install%
+ }%
+ \pgfmathfloatparseactivetrue
+ % improve compatibility with Marks FP library:
+ \pgfkeysalso{/pgf/fixed point arithmetic/.prefix style={/pgf/fpu=false}}%
+ \fi
+ },%
+ fpu/false/.code={%
+ \ifpgfmathfloatparseactive
+ \pgfmathfloat@uninstall%
+ \pgfmathfloatparseactivefalse
+ \fi
+ },%
+ fpu/.default=true,
+ % Use this to introduce a result scaling.
+ % Every expression in which the prefix '*' occurs
+ % will be multiplied with the result and converted to fixed point
+ % representation.
+ fpu/scale results/.code={%
+ \ifpgfmathfloatparseactive
+ \pgfmathparse{#1}%
+ \else
+ \pgfmathfloatparsenumber{#1}%
+ \fi
+ \let\pgfmathfloatscale=\pgfmathresult%
+ },%
+ % determines the output format of each complete expression parsing
+ % process. If 'scale results' is active, 'fixed' is assumed
+ % automatically.
+ fpu/output format/.is choice,
+ fpu/output format/float/.code= {\let\pgfmathfloatparse@output=\relax},
+ fpu/output format/sci/.code= {\def\pgfmathfloatparse@output{\pgfmathfloattosci@{\pgfmathresult}}},
+ fpu/output format/fixed/.code= {\def\pgfmathfloatparse@output{\pgfmathfloattofixed@{\pgfmathresult}}},
+ fpu/output format/float,
+ fpu/rel thresh/.code={%
+ \pgfmathfloatparsenumber{#1}%
+ \let\pgfmathfloat@relthresh=\pgfmathresult
+ },
+ fpu/rel thresh=1e-4,
+}
+
+\pgfmathfloatcreate{1}{1.0}{0}\let\pgfmathfloatscale=\pgfmathresult
+
+% This is the replacement parser invocation.
+% It does two things which are different to \pgfmathparse:
+% 1. it disables any dimension dependand scalings,
+% 2. it implements the 'scale results' feature.
+\def\pgfmathfloatparse{%
+ \begingroup%
+ % disable any dimension-dependant scalings:
+ \let\pgfmathpostparse=\relax%
+ \pgfmath@catcodes%
+ \pgfmath@quickparsefalse%
+ \pgfmathfloatparse@}
+
+% for pgf 2.00 :
+\def\pgfmathfloatparse@pgf@two@null@null{%
+ \pgfmath@quickparsefalse%
+ \pgfmathfloatparse@}
+
+\def\pgfmathfloatparse@#1{%
+ \edef\pgfmathfloat@expression{#1}%
+ \expandafter\pgfmathfloatparse@@\pgfmathfloat@expression\pgfmathfloat@
+ \ifpgfmathfloat@scaleactive
+ \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfmathfloatscale}
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \else
+ \pgfmathfloatparse@output
+ \fi
+}
+
+\def\pgfmathfloat@char@asterisk{*}
+\def\pgfmathfloatparse@@#1#2\pgfmathfloat@{%
+ \def\pgfmathfloat@test{#1}%
+ \ifx\pgfmathfloat@test\pgfmathfloat@char@asterisk%
+ \def\pgfmathfloat@expression{#2}%
+ \pgfmathfloat@scaleactivetrue
+ \fi%
+ \expandafter\pgfmathparse@\expandafter{\pgfmathfloat@expression}%
+ % \endgroup provided by \pgfpathmarse@end
+}
+
+% Crude handling of file plots
+%
+\pgfkeys{/pgf/fpu/.cd,
+ scale file plot x/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscalex{\pgfmathresult*},
+ scale file plot y/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscaley{\pgfmathresult*},
+ scale file plot z/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscalez{\pgfmathresult*}
+}
+
+\def\pgfmathfloat@uninstall@appendcmd#1{%
+ \expandafter\gdef\expandafter\pgfmathfloat@uninstall\expandafter{\pgfmathfloat@uninstall #1}%
+}%
+
+% If the uninstall command is already assembled, it will skip the
+% uninstall assemblation.
+\def\pgfmathfloat@plots@checkuninstallcmd{%
+ \pgfutil@ifundefined{pgfmathfloat@uninstall}{%
+ \global\let\pgfmathfloat@uninstall=\pgfutil@empty
+ }{%
+ % We already HAVE an uninstall command (prepared globally).
+ % So: don't waste time assembling one!
+ \def\pgfmathfloat@uninstall@appendcmd##1{}%
+ \def\pgfmathfloat@prepareuninstallcmd##1{}%
+ }%
+}%
+
+% This assembles an uninstall command globally ON FIRST USAGE.
+% See \pgfmathfloat@plots@checkuninstallcmd
+\def\pgfmathfloat@prepareuninstallcmd#1{%
+ % and store backup information (globally - I don't want to do that
+ % all the time when the FPU is used!):
+ \expandafter\global\expandafter\let\csname pgfmathfloat@backup@\string#1\endcsname=#1%
+ \expandafter\gdef\expandafter\pgfmathfloat@uninstall\expandafter{\pgfmathfloat@uninstall
+ \expandafter\let\expandafter#1\csname pgfmathfloat@backup@\string#1\endcsname%
+ }%
+}
+
+\def\pgfmathfloat@install#1=#2{%
+ \pgfmathfloat@prepareuninstallcmd{#1}%
+ \let#1=#2%
+}
+\def\pgfmathfloat@install@csname#1#2{%
+ \expandafter\pgfmathfloat@prepareuninstallcmd\csname #1\endcsname%
+ \pgfutil@namelet{#1}{#2}%
+}
+\def\pgfmathfloat@install@unimplemented#1{%
+ \expandafter\pgfmathfloat@prepareuninstallcmd\csname pgfmath#1@\endcsname%
+ \expandafter\def\csname pgfmath#1@\endcsname##1{\pgfmathfloat@notimplemented{#1}}%
+}
+\def\pgfmathfloat@plots@install{%
+ \let\pgfmathfloatplotscalex=\pgfutil@empty
+ \let\pgfmathfloatplotscaley=\pgfutil@empty
+ \let\pgfmathfloatplotscalez=\pgfutil@empty
+ \pgfmathfloat@install\pgf@parsexyline=\pgfmathfloat@parsexyline%
+ \pgfmathfloat@install\pgf@parsexyzline=\pgfmathfloat@parsexyzline%
+}
+\def\pgfmathfloat@parsexyline#1 #2 #3\pgf@stop{%
+ \edef\pgfmathfloat@marshal{%
+ \noexpand\pgfplotstreampoint{\noexpand\pgfpointxy{\pgfmathfloatplotscalex#1}{\pgfmathfloatplotscaley#2}}%
+ }%
+ \pgfmathfloat@marshal%
+}
+\def\pgfmathfloat@parsexyzline#1 #2 #3 #4\pgf@stop{%
+ \edef\pgfmathfloat@marshal{%
+ \noexpand\pgfplotstreampoint{%
+ \noexpand\pgfpointxyz{\pgfmathfloatplotscalex#1}{\pgfmathfloatplotscaley#2}{\pgfmathfloatplotscalez#3}%
+ }%
+ }%
+ \pgfmathfloat@marshal%
+}
+
+%
+\def\pgfmathfloat@parser@install@functions{%
+ % Install float commands...
+ %
+ \pgfmathfloat@install\pgfmathadd@=\pgfmathfloatadd@%
+ \pgfmathfloat@install\pgfmathsubtract@=\pgfmathfloatsubtract@%
+ \pgfmathfloat@install\pgfmathneg@=\pgfmathfloatneg@%
+ \pgfmathfloat@install\pgfmathmultiply@=\pgfmathfloatmultiply@%
+ \pgfmathfloat@install\pgfmathdivide@=\pgfmathfloatdivide@%
+ \pgfmathfloat@install\pgfmathabs@=\pgfmathfloatabs@%
+ \pgfmathfloat@install\pgfmathsign@=\pgfmathfloatsign@%
+ \pgfmathfloat@install\pgfmathround@=\pgfmathfloatround@%
+ \pgfmathfloat@install\pgfmathfloor@=\pgfmathfloatfloor@%
+ \pgfmathfloat@install\pgfmathceil@=\pgfmathfloatceil@
+ \pgfmathfloat@install\pgfmathint@=\pgfmathfloatint@
+ \pgfmathfloat@install\pgfmathmod@=\pgfmathfloatmod@%
+ \pgfmathfloat@install\pgfmathmax@=\pgfmathfloatmax@%
+ \pgfmathfloat@install\pgfmathmin@=\pgfmathfloatmin@%
+ \pgfmathfloat@install\pgfmathsin@=\pgfmathfloatsin@%
+ \pgfmathfloat@install\pgfmathcos@=\pgfmathfloatcos@%
+ \pgfmathfloat@install\pgfmathtan@=\pgfmathfloattan@%
+ \pgfmathfloat@install\pgfmathdeg@=\pgfmathfloatdeg@%
+ \pgfmathfloat@install\pgfmathrad@=\pgfmathfloatrad@%
+ \pgfmathfloat@install\pgfmathatan@=\pgfmathfloatatan@%
+ \pgfmathfloat@install\pgfmathasin@=\pgfmathfloatasin@%
+ \pgfmathfloat@install\pgfmathacos@=\pgfmathfloatacos@%
+ \pgfmathfloat@install\pgfmathcot@=\pgfmathfloatcot@%
+ \pgfmathfloat@install\pgfmathsec@=\pgfmathfloatsec@%
+ \pgfmathfloat@install\pgfmathcosec@=\pgfmathfloatcosec@%
+ \pgfmathfloat@install\pgfmathexp@=\pgfmathfloatexp@%
+ \pgfmathfloat@install\pgfmathln@=\pgfmathfloatln@%
+ \pgfmathfloat@install@csname{pgfmathlog10@}{pgfmathfloatlog10@}%
+ \pgfmathfloat@install@csname{pgfmathlog2@}{pgfmathfloatlog2@}%
+ \pgfmathfloat@install\pgfmathsqrt@=\pgfmathfloatsqrt@%
+ \pgfmathfloat@install\pgfmath@pi=\pgfmathfloatpi@%
+ \pgfmathfloat@install\pgfmathpi=\pgfmathfloatpi@%
+ \pgfmathfloat@install\pgfmathe@=\pgfmathfloate@%
+ \pgfmathfloat@install\pgfmathe=\pgfmathfloate@%
+ \pgfmathfloat@install\pgfmathlessthan@=\pgfmathfloatlessthan@%
+ \pgfmathfloat@install\pgfmathnotless@=\pgfmathfloatnotless@%
+ \pgfmathfloat@install\pgfmathnotgreater@=\pgfmathfloatnotgreater@%
+ \pgfmathfloat@install\pgfmathless@=\pgfmathfloatlessthan@%
+ \pgfmathfloat@install\pgfmathgreaterthan@=\pgfmathfloatgreaterthan@%
+ \pgfmathfloat@install\pgfmathgreater@=\pgfmathfloatgreaterthan@%
+ \pgfmathfloat@install\pgfmathifthenelse@=\pgfmathfloatifthenelse@%
+ \pgfmathfloat@install\pgfmathequal@=\pgfmathfloatequal@%
+ \pgfmathfloat@install\pgfmathequalto@=\pgfmathfloatequal@%
+ \pgfmathfloat@install\pgfmathnotequal@=\pgfmathfloatnotequal@%
+ \pgfmathfloat@install\pgfmathnotequalto@=\pgfmathfloatnotequal@%
+ \pgfmathfloat@install\pgfmathpow@=\pgfmathfloatpow@
+ \pgfmathfloat@install\pgfmathrand@=\pgfmathfloatrand@
+ \pgfmathfloat@install\pgfmathrand=\pgfmathfloatrand@
+ \pgfmathfloat@install\pgfmathrnd@=\pgfmathfloatrnd@
+ \pgfmathfloat@install\pgfmathrnd=\pgfmathfloatrnd@
+ \pgfmathfloat@install\pgfmathtrue@=\pgfmathfloattrue@
+ \pgfmathfloat@install\pgfmathfalse@=\pgfmathfloatfalse@
+ \pgfmathfloat@install\pgfmathnot@=\pgfmathfloatnot@
+ \pgfmathfloat@install\pgfmathhex@=\pgfmathfloathex@
+ \pgfmathfloat@install\pgfmathHex@=\pgfmathfloatHex@
+ \pgfmathfloat@install\pgfmathoct@=\pgfmathfloatoct@
+ \pgfmathfloat@install\pgfmathbin@=\pgfmathfloatbin@
+ \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@
+ \expandafter\pgfmathfloat@install\csname pgfmathatan2@\endcsname=\pgfmathfloatatantwo@
+ \pgfmathfloat@install@unimplemented{isprime}%
+ \pgfmathfloat@install@unimplemented{iseven}%
+ \pgfmathfloat@install@unimplemented{isodd}%
+ \pgfmathfloat@install@unimplemented{gcd}%
+ \pgfmathfloat@install@unimplemented{frac}%
+ \pgfmathfloat@install@unimplemented{random}%
+ \pgfmathfloat@install@unimplemented{setseed}%
+ \pgfmathfloat@install@unimplemented{Mod}%
+ \pgfmathfloat@install@unimplemented{div}%
+ \pgfmathfloat@install@unimplemented{real}%
+% \pgfmathfloat@install@unimplemented{height}%
+ %
+ %
+ \pgfmathfloat@install\pgfmathscientific=\pgfmathfloatscientific%
+}
+
+\def\pgfmathfloat@parser@install{%
+ \pgfmathfloat@plots@checkuninstallcmd
+ \pgfmathfloat@plots@install%
+ \pgfmathfloat@parser@install@functions
+ %
+ %
+ %
+ % The following methods actually enable the parser to work with
+ % the internal floating point number representation.
+ %
+ % The idea is as follows:
+ % 1. Every operand must be given in internal float representation.
+ % 2. The internal float repr can be distinguished by a normal
+ % number. This is accomplished by introducing a new "exponent"
+ % token.
+ % 3. The stack-push-operation checks whether the argument is a
+ % float. If not, it is parsed properly before pushing it.
+ \pgfmath@tokens@make{exponent}{\pgfmathfloat@POSTFLAGSCHAR}%
+ \pgfmathfloat@uninstall@appendcmd{%
+ \expandafter\let\csname pgfmath@token@exponent@\pgfmathfloat@POSTFLAGSCHAR\endcsname=\relax
+ }%
+ \let\pgfmath@basic@parse@exponent=\pgfmath@parse@exponent%
+ \let\pgfmath@basic@stack@push@operand=\pgfmath@stack@push@operand
+ \pgfmathfloat@install\pgfmath@stack@push@operand=\pgfmathfloat@stack@push@operand
+ \pgfmathfloat@install\pgfmath@parse@operand@quote=\pgfmathfloat@parse@operand@quote
+ \pgfmathfloat@install\pgfmath@parse@exponent=\pgfmathfloat@parse@float@or@exponent
+ %
+ \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse%
+ %\pgfmathfloat@install\pgfmathparse@trynumber@token=\pgfmathfloat@parse@trynumber@token
+ \pgfmathfloat@install\pgfmathparse@expression@is@number=\pgfmathfloat@parse@expression@is@number
+}%
+
+% This here might bring speed improvements... if implemented
+% correctly.
+% However, this heuristics might fail in cases like "1+1" vs "1e+1" ...
+%\def\pgfmathfloat@parse@trynumber@token{numericfpu}
+%\pgfmath@tokens@make{numericfpu}{eE+-Y.0123456789}
+
+\def\pgfmathfloat@parse@expression@is@number{%
+ \pgfmathfloatparsenumber{\pgfmath@expression}%
+ \pgfmath@smuggleone\pgfmathresult%
+ \endgroup
+ \ignorespaces
+}%
+
+\def\pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG#1{%
+ \edef\pgfmathfloat@loc@TMPa{%
+ \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1\endcsname{%
+ \noexpand\let\noexpand\pgfmath@parsepostgroup\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname%
+ \noexpand\expandafter\noexpand\pgfmath@parse@}%
+ \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname{%
+ \noexpand\expandafter\expandafter\noexpand\csname pgfmath#1@\endcsname\noexpand\expandafter{\noexpand\pgfmathresult}%
+ \noexpand\pgfmath@postfunction%
+ }%
+ }%
+ \pgfmathfloat@loc@TMPa
+}%
+\def\pgfmathfloat@parser@install@pgf@two@null@null{%
+ \pgfmathfloat@plots@checkuninstallcmd
+ \pgfmathfloat@plots@install%
+ \pgfmathfloat@parser@install@functions
+ \let\pgfmathrand@=\pgfmath@basic@rand@
+ \let\pgfmathrnd@=\pgfmath@basic@rnd@
+ \pgfmathfloat@install\pgfmathmax@=\pgfmathfloatmaxtwo%
+ \pgfmathfloat@install\pgfmathmin@=\pgfmathfloatmintwo%
+ \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{factorial}%
+ \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.
+ %
+ % The idea is as follows:
+ % 1. Every operand must be given in internal float representation.
+ % 2. The internal float repr can be distinguished by a normal
+ % number. This is accomplished by introducing a new "exponent"
+ % token.
+ % 3. The stack-push-operation checks whether the argument is a
+ % float. If not, it is parsed properly before pushing it.
+ \let\pgfmath@basic@parsedecimalpoint=\pgfmath@parsedecimalpoint%
+ \let\pgfmath@basic@stack@push@operand=\pgfmath@stackpushoperand
+ \pgfmathfloat@install\pgfmath@stackpushoperand=\pgfmathfloat@stack@push@operand
+ \pgfmathfloat@install\pgfmath@parsedecimalpoint=\pgfmathfloat@parsedecimalpoint@pgf@two@null@null
+ \pgfmathfloat@install\pgfmath@endparse=\pgfmathfloat@endparse@pgf@two@null@null
+ \pgfmathfloat@install\pgfmath@endparsegroup=\pgfmathfloat@endparsegroup@pgf@two@null@null
+ \pgfmathfloat@install\pgfmath@postfunction=\pgfmathfloat@postfunction@pgf@two@null@null
+ \pgfmathfloat@install\pgfmath@@parseoperandgroup=\pgfmathfloat@@parseoperandgroup
+ %
+ \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{INF}{\def\pgfmathresult{inf}}
+\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:
+%
+% WARNING: These methods rely heavily on the internal float representation!
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% for pgf2.00 :
+\def\pgfmathfloat@parsedecimalpoint@pgf@two@null@null#1{%
+ \expandafter\ifx\pgfmathfloat@POSTFLAGSCHAR#1% check whether it is a float
+ \let\pgfmath@next=\pgfmathfloat@return@float@pgf@two@null@null%
+ \else
+ \def\pgfmath@next{\pgfmath@basic@parsedecimalpoint#1}%
+ \fi
+ \pgfmath@next
+}
+% for pgf2.00:
+\def\pgfmathfloat@return@float@pgf@two@null@null#1]{%
+ \edef\pgfmathresult{\the\c@pgfmath@parsecounta\pgfmathfloat@POSTFLAGSCHAR#1]}%
+ \let\pgfmath@resulttemp=\pgfmathresult
+ \pgfmath@parseoperator%
+}%
+% for pgf2.00:
+\def\pgfmathfloat@endparse@pgf@two@null@null#1\pgfmath@empty{%
+ \pgfmath@processalloperations%
+ \pgfmath@stackpop{\pgfmathresult}%
+ % delete the final unit scalings
+ \pgfmath@smuggleone{\pgfmathresult}%
+ \endgroup%
+ \ignorespaces%
+}
+% for pgf2.00:
+\def\pgfmathfloat@endparsegroup@pgf@two@null@null{%
+ \pgfmath@processalloperations%
+ \pgfmath@stackpop{\pgfmathresult}%
+ % eliminated register usage here...
+ \pgfmath@smuggleone{\pgfmathresult}%
+ \endgroup%
+ \pgfmath@parsepostgroup%
+}
+% for pgf2.00:
+\def\pgfmathfloat@postfunction@pgf@two@null@null{%
+ \let\pgfmath@parsepostgroup\pgfmath@parseoperator%
+ \ifnum\pgfmath@sign1<0
+ \pgfmathfloatneg@{\pgfmathresult}%
+ \let\pgfmath@sign\pgfutil@empty
+ \fi
+ \pgfmath@parseoperator}
+% for pgf2.00:
+\def\pgfmathfloat@@parseoperandgroup{%
+ \let\pgfmath@postparsegroup\pgfmath@parseoperator%
+ \ifnum\pgfmath@sign1<0
+ \pgfmathfloatneg@{\pgfmathresult}%
+ \let\pgfmath@sign\pgfutil@empty
+ \fi
+ \pgfmath@parseoperator%
+}
+
+
+
+
+
+
+% PRECONDITION:
+% either
+% <number>e
+% ^
+% -> read the exponent.
+% or
+% <sign>\pgfmathfloat@POSTFLAGSCHAR
+% ^
+% -> we have a parsed floating point number -> read it.
+\def\pgfmathfloat@parse@float@or@exponent{%
+ \if\pgfmath@token \pgfmathfloat@POSTFLAGSCHAR%
+ % Ok, we actually HAVE a pre-parsed floating point number!
+ % Return it.
+ \expandafter\pgfmathfloat@return@float\expandafter\pgfmath@token@next
+ \else
+ % We have a standard number in scientific format. Parse it.
+ \expandafter\pgfmath@basic@parse@exponent
+ \fi
+}%
+\def\pgfmathfloat@return@float#1]{%
+ \edef\pgfmathresult{\pgfmath@number \pgfmathfloat@POSTFLAGSCHAR#1]}%
+ \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}%
+ \pgfmath@parse@@operator%
+}%
+
+\def\pgfmathfloat@parse@operand@quote#1"{%
+ \edef\pgfmathresult{\pgfmath@fpu@stringmarker #1}%
+ \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}%
+ \pgfmath@parse@@operator%
+}
+
+\def\pgfmath@fpu@stringmarker{@@str@@:}%
+
+% This extends the functionality of the basic level operand stack: it
+% assures every element on the stack is a float.
+\def\pgfmathfloat@stack@push@operand#1{%
+ \pgfutil@ifnextchar\bgroup{%
+ \let\pgfmathfloat@stack@push@operand@list@=\pgfutil@empty
+ \pgfmathfloat@stack@push@operand@list
+ }{%
+ \pgfmathfloat@stack@push@operand@single
+ }%
+ #1\relax
+}%
+\def\pgfmathfloat@stack@push@operand@single#1\relax{%
+ \expandafter\pgfutil@in@\pgfmathfloat@POSTFLAGSCHAR{#1}%
+ \ifpgfutil@in@
+ \pgfmath@basic@stack@push@operand{#1}%
+ \else
+ \expandafter\pgfutil@in@\expandafter{\pgfmath@fpu@stringmarker}{#1}%
+ \ifpgfutil@in@
+ \pgfmathfloat@stack@push@operand@single@str#1\relax
+ \else
+ \pgfmathfloatparsenumber{#1}%
+ \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}%
+ \fi
+ \fi
+}%
+
+\expandafter\def\expandafter\pgfmathfloat@stack@push@operand@single@str\pgfmath@fpu@stringmarker #1\relax{%
+ \pgfmath@basic@stack@push@operand{#1}%
+}%
+\def\pgfmathfloat@stack@push@operand@GOBBLE#1\relax{}%
+\def\pgfmathfloat@stack@push@operand@list#1{%
+ \expandafter\pgfutil@in@ \pgfmathfloat@POSTFLAGSCHAR{#1}%
+ \ifpgfutil@in@
+ \expandafter\def\expandafter\pgfmathfloat@stack@push@operand@list@\expandafter{%
+ \pgfmathfloat@stack@push@operand@list@{#1}%
+ }%
+ \else
+ \pgfmathfloatparsenumber{#1}%
+ \begingroup
+ \toks0=\expandafter{\pgfmathfloat@stack@push@operand@list@}%
+ \toks1=\expandafter{\pgfmathresult}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 {\the\toks1}}%
+ \endgroup
+ \let\pgfmathfloat@stack@push@operand@list@=\pgfmathfloat@glob@TMP
+ \fi
+ \pgfutil@ifnextchar\relax{%
+ \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathfloat@stack@push@operand@list@}%
+ \pgfmathfloat@stack@push@operand@GOBBLE
+ }{%
+ \pgfmathfloat@stack@push@operand@list
+ }%
+}%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% --- END --- Hacks to the basic level pgf math engine
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Here starts the implementation of the floating point
+% routines.
+%
+% They can be used even if the FPU parser is not active.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Remember the basic math commands. They will be invoked as subroutines in floating point routines.
+\let\pgfmath@basic@add@=\pgfmathadd@
+\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@
+\let\pgfmath@basic@rnd@=\pgfmathrnd@
+\let\pgfmath@basic@setseed@=\pgfmathsetseed@
+\let\pgfmath@basic@random@=\pgfmathrandom@
+\let\pgfmath@basic@floor@=\pgfmathfloor@
+\let\pgfmath@basic@ceil@=\pgfmathceil@
+\let\pgfmath@basic@mod@=\pgfmathmod@
+\let\pgfmath@basic@max@=\pgfmathmax@
+\let\pgfmath@basic@min@=\pgfmathmin@
+\let\pgfmath@basic@sin@=\pgfmathsin@
+\let\pgfmath@basic@cos@=\pgfmathcos@
+\let\pgfmath@basic@tan@=\pgfmathtan@
+\let\pgfmath@basic@deg@=\pgfmathdeg@
+\let\pgfmath@basic@rad@=\pgfmathrad@
+\let\pgfmath@basic@atan@=\pgfmathatan@
+\let\pgfmath@basic@asin@=\pgfmathasin@
+\let\pgfmath@basic@acos@=\pgfmathacos@
+\let\pgfmath@basic@cot@=\pgfmathcot@
+\let\pgfmath@basic@sec@=\pgfmathsec@
+\let\pgfmath@basic@cosec@=\pgfmathcosec@
+\let\pgfmath@basic@pow@=\pgfmathpow@
+\let\pgfmath@basic@exp@=\pgfmathexp@
+\let\pgfmath@basic@ln@=\pgfmathln@
+\let\pgfmath@basic@sqrt@=\pgfmathsqrt@
+\let\pgfmath@basic@@pi=\pgfmath@pi
+\let\pgfmath@basic@veclen@=\pgfmathveclen@
+\let\pgfmath@basic@e@=\pgfmathe@
+\let\pgfmath@basic@lessthan@=\pgfmathlessthan@
+\let\pgfmath@basic@greaterthan@=\pgfmathgreaterthan@
+\let\pgfmath@basic@equalto@=\pgfmathequalto@
+\let\pgfmath@basic@equal@=\pgfmathequal@
+\let\pgfmath@basic@true@=\pgfmathtrue@
+\let\pgfmath@basic@false@=\pgfmathfalse@
+
+\def\pgfmathfloatscientific#1#2{%
+ \edef\pgfmathresult{#1e#2}%
+ \expandafter\pgfmathfloatparsenumber\expandafter{\pgfmathresult}%
+}
+% Compares #1 with #2 and sets \pgfmathresult either to 1.0 or 0.0.
+%
+% It also sets the boolean \ifpgfmathfloatcomparison (globally).
+\def\pgfmathfloatlessthan@#1#2{%
+%\def\pgfmathfloatlessthan#1#2#3\and#4#5#6{%
+ \global\pgfmathfloatcomparisonfalse
+ \begingroup
+ \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)
+ \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|) )
+ \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|) )
+ \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
+ \fi
+ \endgroup
+ \ifpgfmathfloatcomparison
+ \def\pgfmathresult{1.0}%
+ \else
+ \def\pgfmathresult{0.0}%
+ \fi
+}
+\let\pgfmathfloatlessthan=\pgfmathfloatlessthan@
+\let\pgfmathfloatless@=\pgfmathfloatlessthan@
+
+% ! (#1 < #2) <=> (#1 >= #2)
+\def\pgfmathfloatnotless@#1#2{%
+ \pgfmathfloatless@{#1}{#2}%
+ \ifpgfmathfloatcomparison
+ \def\pgfmathresult{0.0}%
+ \else
+ \def\pgfmathresult{1.0}%
+ \fi
+}%
+% ! (#1 > #2) <=> (#1 <= #2)
+\def\pgfmathfloatnotgreater@#1#2{%
+ \pgfmathfloatless@{#2}{#1}%
+ \ifpgfmathfloatcomparison
+ \def\pgfmathresult{0.0}%
+ \else
+ \def\pgfmathresult{1.0}%
+ \fi
+}%
+
+% compares \pgfmathfloat@a@[SME] < \pgfmathfloat@b@[SME]
+\def\pgfmathfloatlessthan@positive{%
+ \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E
+ \global\pgfmathfloatcomparisontrue
+ \else
+ \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E
+ \ifdim\pgfmathfloat@a@M<\pgfmathfloat@b@M
+ \global\pgfmathfloatcomparisontrue
+ \fi
+ \fi
+ \fi
+}
+
+% compares \pgfmathfloat@a@[SME] > \pgfmathfloat@b@[SME]
+\def\pgfmathfloatgreaterthan@positive{%
+ \ifnum\pgfmathfloat@a@E>\pgfmathfloat@b@E
+ \global\pgfmathfloatcomparisontrue
+ \else
+ \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E
+ \ifdim\pgfmathfloat@a@M>\pgfmathfloat@b@M
+ \global\pgfmathfloatcomparisontrue
+ \fi
+ \fi
+ \fi
+}
+
+
+\def\pgfmathfloatgreaterthan@#1#2{\pgfmathfloatlessthan@{#2}{#1}}
+\let\pgfmathfloatgreaterthan=\pgfmathfloatgreaterthan@
+\let\pgfmathfloatgreater@=\pgfmathfloatgreaterthan@
+
+\def\pgfmathfloatmax@#1{%
+ \begingroup
+ \pgfmathfloatcreate{2}{1.0}{2147483644}%
+ \let\pgfmathmaxsofar=\pgfmathresult
+ \pgfmathfloatmax@@#1{}%
+}%
+\def\pgfmathfloatmax@@#1{%
+ \def\pgfmath@temp{#1}%
+ \ifx\pgfmath@temp\pgfmath@empty%
+ \expandafter\pgfmathfloatmax@@@%
+ \else%
+ \pgfmathfloatlessthan{\pgfmathmaxsofar}{#1}%
+ \ifpgfmathfloatcomparison
+ \edef\pgfmathmaxsofar{#1}%
+ \fi
+ \expandafter\pgfmathfloatmax@@%
+ \fi%
+}%
+\def\pgfmathfloatmax@@@{%
+ \let\pgfmathresult=\pgfmathmaxsofar
+ \pgfmath@smuggleone{\pgfmathresult}%
+ \endgroup
+}%
+\def\pgfmathfloatmin@#1{%
+ \begingroup
+ \pgfmathfloatcreate{1}{1.0}{2147483644}%
+ \let\pgfmathminsofar=\pgfmathresult
+ \pgfmathfloatmin@@#1{}%
+}%
+\def\pgfmathfloatmin@@#1{%
+ \def\pgfmath@temp{#1}%
+ \ifx\pgfmath@temp\pgfmath@empty%
+ \expandafter\pgfmathfloatmin@@@%
+ \else%
+ \pgfmathfloatlessthan{#1}{\pgfmathminsofar}%
+ \ifpgfmathfloatcomparison
+ \edef\pgfmathminsofar{#1}%
+ \fi
+ \expandafter\pgfmathfloatmin@@%
+ \fi%
+}%
+\def\pgfmathfloatmin@@@{%
+ \let\pgfmathresult=\pgfmathminsofar
+ \pgfmath@smuggleone{\pgfmathresult}%
+ \endgroup
+}%
+
+\def\pgfmathfloatmaxtwo#1#2{%
+ \pgfmathfloatlessthan{#1}{#2}%
+ \ifpgfmathfloatcomparison
+ \edef\pgfmathresult{#2}%
+ \else
+ \edef\pgfmathresult{#1}%
+ \fi
+}
+\let\pgfmathfloatmax=\pgfmathfloatmaxtwo
+
+\def\pgfmathfloatmintwo#1#2{%
+ \pgfmathfloatlessthan{#1}{#2}%
+ \ifpgfmathfloatcomparison
+ \edef\pgfmathresult{#1}%
+ \else
+ \edef\pgfmathresult{#2}%
+ \fi
+}
+\let\pgfmathfloatmin=\pgfmathfloatmintwo
+
+% Renormalizes #1 to extended precision mantisse, meaning
+% 100 <= m < 1000
+% instead of 1 <= m < 10.
+%
+% The 'extended precision' means we have higher accuracy when we apply pgfmath operations to mantissas.
+%
+% The input argument is expected to be a normalized floating point number; the output argument is a non-normalized floating point number (well, normalized to extended precision).
+%
+% The operation is supposed to be very fast.
+%
+% @see \pgfmathfloatsetextprecision
+%
+% There is a routine for internal usage,
+% \pgfmathfloattoextentedprecision@a. It also provides exponent and
+% sign of #1 in output arguments and may be used to increase speed.
+\def\pgfmathfloattoextentedprecision#1{%
+ \begingroup
+ \pgfmathfloattoextentedprecision@a{#1}%
+ \pgfmathfloatcreate{\pgfmathfloat@a@S}{\pgfmathresult}{\pgfmathfloat@a@E}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+\def\pgfmathfloattoextentedprecision@@zero#1\pgfmathfloat@EOI{%
+ \edef\pgfmathresult{#1}%
+}%
+\def\pgfmathfloattoextentedprecision@@one#1.#2#3\pgfmathfloat@EOI{%
+ \edef\pgfmathresult{#1#2.#3}%
+}%
+\def\pgfmathfloattoextentedprecision@@two#1.#2#3#4\pgfmathfloat@EOI{%
+ \edef\pgfmathresult{#1#2#3.#4}%
+}%
+\def\pgfmathfloattoextentedprecision@@three#1.#2#3#4#5\pgfmathfloat@EOI{%
+ \edef\pgfmathresult{#1#2#3#4.#5}%
+}%
+
+% Sets extended precision to 10^#1.
+%
+% The different choices are
+%
+% - 0: normalization 0 <= m < 1 (disable extended precision)
+% - 1: normalization 10 <= m < 100
+% - 2: normalization 100 <= m < 1000 (default)
+% - 3: normalization 1000 <= m < 10000
+%
+% #1 is the exponent, #1 = 0,1,2 or 3.
+%
+% This setting applies to \pgfmathfloattoextentedprecision and friends.
+\def\pgfmathfloatsetextprecision#1{%
+ \ifcase#1\relax
+ \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@zero
+ \def\pgfmathfloatextprec@shift{0}%
+ \or
+ \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@one
+ \def\pgfmathfloatextprec@shift{1}%
+ \or
+ \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@two
+ \def\pgfmathfloatextprec@shift{2}%
+ \else
+ \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@three
+ \def\pgfmathfloatextprec@shift{3}%
+ \fi
+}%
+\pgfmathfloatsetextprecision{2}%
+
+% Does the "hard" work for \pgfmathfloattoextentedprecision. It
+% provides additional outputs.
+%
+% INPUT:
+% #1 normalized floating point number. Maybe a macro (it will be expanded ONCE)
+%
+% OUTPUT:
+% - \pgfmathresult : the mantisse in extended precision
+% - \pgfmathfloat@a@S : the sign of #1
+% - \pgfmathfloat@a@E : the exponent of #1, adjusted for extended precision
+% - \pgfmathfloat@a@Mtok : undefined (its contents will be destroyed.
+%
+\def\pgfmathfloattoextentedprecision@a#1{%
+ \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
+ \fi
+}%
+
+
+% Similar to \pgfmathfloattoextentedprecision@a, this one here fills the '@b' registers.
+\def\pgfmathfloattoextentedprecision@b#1{%
+ \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
+ \fi
+}%
+
+% Addition of two floating point numbers using 8 significant digits.
+\def\pgfmathfloatadd@#1#2{%
+ \begingroup
+ %
+ % renormalize argument to 100 <= m < 1000 for extended accuracy:
+ \pgfmathfloattoextentedprecision@a{#1}%
+ \let\pgfmathfloat@arga=\pgfmathresult
+ %
+ \pgfmathfloattoextentedprecision@b{#2}%
+ \let\pgfmathfloat@argb=\pgfmathresult
+ %
+ \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases.
+ \ifcase\pgfmathfloat@a@S
+ \edef\pgfmathresult{#2}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \or
+ \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}%
+ \else
+ \pgfmathfloatcomparisonfalse
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}%
+ \fi
+ \ifcase\pgfmathfloat@b@S
+ \edef\pgfmathresult{#1}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \or
+ \edef\pgfmathfloat@argb{-\pgfmathfloat@argb}%
+ \else
+ \pgfmathfloatcomparisonfalse
+ \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}%
+ \fi
+ \ifpgfmathfloatcomparison
+ % Shift lesser mantisse to fit the larger one:
+ \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E
+ \pgfmathfloatadd@shift{\pgfmathfloat@arga}{\pgfmathfloat@a@E}{\pgfmathfloat@b@E}%
+ \else
+ \pgfmathfloatadd@shift{\pgfmathfloat@argb}{\pgfmathfloat@b@E}{\pgfmathfloat@a@E}%
+ \fi
+ % add them!
+ \pgfmath@basic@add@{\pgfmathfloat@arga}{\pgfmathfloat@argb}%
+ % renormalize sum. This is the only part were an expensive routine comes into play:
+ \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}%
+ \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% #1= floating point number
+% #2= TeX code to execute if #1 == 0
+% #3= TeX code to execute if #1 != 0
+\def\pgfmathfloatifzero#1#2#3{%
+ \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
+}%
+
+\def\pgfmathfloatifthenelse@#1#2#3{%
+ \pgfmathfloatifflags{#1}{0}{%
+ \edef\pgfmathresult{#3}%%
+ }{%
+ \edef\pgfmathresult{#2}%
+ }%
+}
+\def\pgfmathfloatequal@#1#2{%
+ \pgfmathfloatifapproxequalrel{#1}{#2}{%
+ \def\pgfmathresult{1}%
+ \pgfmathfloatcomparisontrue
+ }{%
+ \def\pgfmathresult{0}%
+ \pgfmathfloatcomparisonfalse
+ }%
+}
+\let\pgfmathfloatequalto@=\pgfmathfloatequal@
+
+\def\pgfmathfloatnotequal@#1#2{%
+ \pgfmathfloatifapproxequalrel{#1}{#2}{%
+ \def\pgfmathresult{0}%
+ \pgfmathfloatcomparisonfalse
+ }{%
+ \def\pgfmathresult{1}%
+ \pgfmathfloatcomparisontrue
+ }%
+}
+\let\pgfmathfloatnotequalto@=\pgfmathfloatnotequal@
+
+% Computes the relative error between #1 and #2 (assuming #2 != 0) and
+% invokes #3 if the relative error is below `/pgf/fpu/rel thresh' and
+% #4 if that is not the case.
+\long\def\pgfmathfloatifapproxequalrel#1#2#3#4{%
+ \begingroup
+ \pgfmathfloatparsenumber{#1}%
+ \let\pgfmathfloatarga=\pgfmathresult
+ \pgfmathfloatparsenumber{#2}%
+ \let\pgfmathfloatargb=\pgfmathresult
+ \pgfmathfloatrelerror@\pgfmathfloatarga\pgfmathfloatargb
+ \let\pgfmathfloatarga=\pgfmathresult
+ \pgfmathfloatlessthan@\pgfmathfloatarga\pgfmathfloat@relthresh
+ \ifpgfmathfloatcomparison
+ \def\pgfmathfloat@loc@TMPa{#3}%
+ \else
+ \def\pgfmathfloat@loc@TMPa{#4}%
+ \fi
+ \expandafter\endgroup
+ \pgfmathfloat@loc@TMPa
+}%
+
+% 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!}%
+% it also supports #2=u which means 'unbounded'
+\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#2u%
+ \ifnum\pgfmathfloat@loc@TMPa>2
+ #3\relax
+ \else
+ #4\relax
+ \fi
+ \else
+ \if\pgfmathfloat@loc@TMPa#2%
+ #3\relax
+ \else
+ #4\relax
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+
+% #1=mantisse which needs to be shifted (with smaller exponent)
+% #2=smaller exponent
+% #3=larger exponent
+%
+% ATTENTION: this helper method DESTROYS contents of \pgfmathfloat@a@S.
+\def\pgfmathfloatadd@shift#1#2#3{%
+ \pgf@xa=#1 pt%
+ \pgfmathfloat@a@S=#3\relax
+ \advance\pgfmathfloat@a@S by-#2\relax
+ \ifcase\pgfmathfloat@a@S
+ \or
+ \divide\pgf@xa by10\relax
+ \or
+ \divide\pgf@xa by100\relax
+ \or
+ \divide\pgf@xa by1000\relax
+ \or
+ \divide\pgf@xa by10000\relax
+ \or
+ \divide\pgf@xa by10000\relax
+ \divide\pgf@xa by10\relax
+ \or
+ \divide\pgf@xa by10000\relax
+ \divide\pgf@xa by100\relax
+ \or
+ \divide\pgf@xa by10000\relax
+ \divide\pgf@xa by1000\relax
+ \or
+ \divide\pgf@xa by10000\relax
+ \divide\pgf@xa by10000\relax
+ \else
+ \pgf@xa=0pt%
+ \fi
+ #2=#3\relax
+ \edef#1{\pgf@sys@tonumber\pgf@xa}%
+}
+
+\let\pgfmathfloatadd=\pgfmathfloatadd@
+
+
+% Subtracts two floating point numbers.
+\def\pgfmathfloatsubtract@#1#2{%
+ \begingroup
+ \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
+ \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}%
+ \let\pgfmathfloatsub@arg=\pgfmathresult
+ \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}%
+ \or
+ \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}%
+ \let\pgfmathfloatsub@arg=\pgfmathresult
+ \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}%
+ \else
+ \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+\let\pgfmathfloatsubtract=\pgfmathfloatsubtract@
+
+% Scales a floating point number #1 with a fixed point number #2 using pgfmathmultiply.
+%
+% Use this method if #2 is small number.
+\def\pgfmathfloatmultiplyfixed@#1#2{%
+ \begingroup
+ %
+ % renormalize argument to 100 <= m < 1000 for extended accuracy:
+ \pgfmathfloattoextentedprecision@a{#1}%
+ \let\pgfmathfloat@arga=\pgfmathresult
+ %
+ \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases.
+ \ifcase\pgfmathfloat@a@S
+ \edef\pgfmathresult{#1}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \or
+ \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}%
+ \else
+ \pgfmathfloatcomparisonfalse
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}%
+ \fi
+ \ifpgfmathfloatcomparison
+ \pgfmath@basic@multiply@{\pgfmathfloat@arga}{#2}%
+ % renormalize product. This is the only part were an expensive routine comes into play:
+ \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}%
+ \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+\let\pgfmathfloatmultiplyfixed=\pgfmathfloatmultiplyfixed@
+
+
+\def\pgfmathfloatmultiply@#1#2{%
+ \begingroup
+ \pgfmathfloatsetextprecision{1}%
+ \pgfmathfloattoextentedprecision@a{#1}%
+ \let\pgfmathfloat@arga=\pgfmathresult
+ %
+ \pgfmathfloattoextentedprecision@b{#2}%
+ \let\pgfmathfloat@argb=\pgfmathresult
+ %
+ \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases.
+ \ifcase\pgfmathfloat@a@S
+ % 0
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or% +
+ \ifcase\pgfmathfloat@b@S
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \def\pgfmathresult@S{1}%
+ \or
+ \def\pgfmathresult@S{2}%
+ \else
+ \expandafter\pgfmathfloatcreate\the\pgfmathfloat@b@S{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \fi
+ \or% -
+ \ifcase\pgfmathfloat@b@S
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \def\pgfmathresult@S{2}%
+ \or
+ \def\pgfmathresult@S{1}%
+ \or
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \fi
+ \or% nan
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or% +infty
+ \ifcase\pgfmathfloat@b@S
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \fi
+ \or% -infty
+ \ifcase\pgfmathfloat@b@S
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \fi
+ \fi
+ \ifpgfmathfloatcomparison
+ \pgfmath@basic@multiply@{\pgfmathfloat@arga}{\pgfmathfloat@argb}%
+ \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E
+ % renormalize sum. This is the only part were an expensive routine comes into play:
+ \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}%
+ \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}%
+ \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\let\pgfmathfloatmultiply=\pgfmathfloatmultiply@
+
+% Defines \pgfmathresult to be #1 / #2 for two floating point numbers.
+%
+% It employs the basic math engine internally to divide mantissas.
+\def\pgfmathfloatdivide@#1#2{%
+ \begingroup
+ \pgfmathfloatsetextprecision{1}% is not too important, I think. After all, 0.1 <= #1/#2 < 10 or so due to normalization (no matter, which)
+ \edef\pgfmathfloat@arga{#1}%
+ \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}%
+ \let\pgfmathfloat@arga=\pgfmathresult
+ %
+ \edef\pgfmathfloat@argb{#2}%
+ \pgfmathfloattoextentedprecision@b{\pgfmathfloat@argb}%
+ \let\pgfmathfloat@argb=\pgfmathresult
+ %
+ \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases.
+ \ifcase\pgfmathfloat@a@S
+ % 0
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or% +
+ \ifcase\pgfmathfloat@b@S
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \def\pgfmathresult@S{1}%
+ \or
+ \def\pgfmathresult@S{2}%
+ \or
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \else
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \fi
+ \or% -
+ \ifcase\pgfmathfloat@b@S
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \def\pgfmathresult@S{2}%
+ \or
+ \def\pgfmathresult@S{1}%
+ \or
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \else
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \fi
+ \or% nan
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or% +infty
+ \ifcase\pgfmathfloat@b@S
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}% what is inf/inf ?
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}% or inf/-inf ?
+ \pgfmathfloatcomparisonfalse
+ \fi
+ \or% -infty
+ \ifcase\pgfmathfloat@b@S
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{5}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \or
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \pgfmathfloatcomparisonfalse
+ \fi
+ \fi
+ \ifpgfmathfloatcomparison
+ \pgfmath@basic@divide@{\pgfmathfloat@arga}{\pgfmathfloat@argb}%
+ \advance\pgfmathfloat@a@E by-\pgfmathfloat@b@E
+ % renormalize. This is the only part were an expensive float routine comes into play:
+ \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}%
+ \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}%
+ % And re-insert the proper sign:
+ \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\let\pgfmathfloatdivide=\pgfmathfloatdivide@
+
+\def\pgfmathfloatreciprocal@#1{%
+ \begingroup
+ % FIXME optimize
+ \edef\pgfmathfloat@loc@TMPa{#1}%
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \pgfmathfloatdivide@{\pgfmathresult}{\pgfmathfloat@loc@TMPa}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% Computes sqrt(#1) in floating point arithmetics.
+%
+% It employs sqrt( m * 10^e ) = sqrt(m) * sqrt(10^e).
+\def\pgfmathfloatsqrt@#1{%
+ \begingroup
+ \pgfmathfloatsetextprecision{3}%
+ \edef\pgfmathfloat@arga{#1}%
+ \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}%
+ \let\pgfmathfloat@arga=\pgfmathresult
+ %
+ \ifcase\pgfmathfloat@a@S
+ % 0
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \or% +
+ \pgfmath@basic@sqrt@{\pgfmathfloat@arga}%
+ \ifodd\pgfmathfloat@a@E
+ \ifnum\pgfmathfloat@a@E>0
+ \expandafter\pgfmath@basic@multiply@\expandafter{\pgfmathresult}{3.16227766}% * sqrt(10)
+ \else
+ \expandafter\pgfmath@basic@multiply@\expandafter{\pgfmathresult}{0.316227766}% * sqrt(0.1)
+ \fi
+ \fi
+ \divide\pgfmathfloat@a@E by2 % sqrt(10^e) = 10^{e/2} (see above for odd e)
+ % renormalize sum. This is the only part were an expensive routine comes into play:
+ \edef\pgfmathfloat@arga{\pgfmathresult e\the\pgfmathfloat@a@E}%
+ \pgfmathfloatqparsenumber{\pgfmathfloat@arga}%
+ \or% -
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \or% nan
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \or% +infty
+ \pgfmathfloatcreate{4}{0.0}{0}%
+ \or% -infty
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\let\pgfmathfloatsqrt=\pgfmathfloatsqrt@
+
+% Returns the integer part of the floating point number #1.
+%
+% The result is returned as floating point as well.
+%
+% This operation is not limited to TeX's range of count registers (it
+% works symbolly)
+%
+% @see \pgfmathfloattoint
+% POSTCONDITION: \pgfmathresult contains the result and
+% \pgfmathfloatintwasnoop=1 if there was nothing to do
+% \pgfmathfloatintwasnoop=0 if there where non-zero digits after the period
+% \pgfmathfloatintwasnoop=2 if there where digits after the period. The digits will be stored in \pgfmathfloatintremainder in this case.
+\def\pgfmathfloatint@#1{%
+ \begingroup
+ \edef\pgfmathfloatint@input{#1}%
+ \expandafter\pgfmathfloat@decompose@tok\pgfmathfloatint@input\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \gdef\pgfmathfloatintwasnoop{1}%
+ \gdef\pgfmathfloatintremainder{}%
+ \ifcase\pgfmathfloat@a@S
+ % 0: nothing to do.
+ \or% +
+ \expandafter\pgfmathfloatint@@\the\pgfmathfloat@a@Mtok\pgfmathfloat@EOI
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \or% -
+ \expandafter\pgfmathfloatint@@\the\pgfmathfloat@a@Mtok\pgfmathfloat@EOI
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \else
+ % nothing to do
+ \fi
+ %\message{ XXXXX int(\pgfmathfloatint@input) = \pgfmathresult -> was no op = \pgfmathfloatintwasnoop\space (remainder \pgfmathfloatintremainder)^^J}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\def\pgfmathfloatint@@#1.{%
+ \ifnum\pgfmathfloat@a@E<0
+ \pgfmathfloat@a@S=0
+ \pgfmathfloat@a@Mtok={0.0}%
+ \pgfmathfloat@a@E=0
+ \gdef\pgfmathfloatintwasnoop{0}%
+ \expandafter\pgfmathfloatint@@loop@gobble
+ \else
+ \pgfmathfloat@a@Mtok={#1.}%
+ \pgfmathfloat@b@E=\pgfmathfloat@a@E
+ \expandafter\pgfmathfloatint@@loop
+ \fi
+}%
+\def\pgfmathfloatint@@loop#1{%
+ \def\pgfmathfloatint@@loop@{#1}%
+ \ifx\pgfmathfloatint@@loop@\pgfmathfloat@EOI
+ \gdef\pgfmathfloatintwasnoop{1}%
+ \let\pgfmathfloatint@@loop@next=\relax
+ \else
+ \ifnum\pgfmathfloat@b@E=0
+ \def\pgfmathfloatint@@loop@next{\pgfmathfloatint@@loop@gobble#1}%
+ \else
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}%
+ \advance\pgfmathfloat@b@E by-1
+ \let\pgfmathfloatint@@loop@next=\pgfmathfloatint@@loop
+ \fi
+ \fi
+ \pgfmathfloatint@@loop@next
+}%
+\def\pgfmathfloatint@@loop@gobble#1\pgfmathfloat@EOI{%
+ \if0\pgfmathfloatintwasnoop
+ \else
+ \gdef\pgfmathfloatintwasnoop{2}%
+ \gdef\pgfmathfloatintremainder{#1}%
+ \fi
+}%
+\let\pgfmathfloatint=\pgfmathfloatint@
+
+\def\pgfmathfloatfloor#1{%
+ \edef\pgfmath@orig{#1}%
+ \pgfmathfloatint@{#1}%
+ \pgfmathfloatifflags{\pgfmath@orig}{2}{%
+ \let\pgfmath@trunc=\pgfmathresult
+ \ifcase\pgfmathfloatintwasnoop\relax
+ % ah - we stripped something! Round DOWN
+ \pgfmathfloatcreate{2}{1.0}{0}% -1
+ \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfmath@trunc}%
+ \or
+ % was no-op
+ \let\pgfmathresult=\pgfmath@trunc
+ \else
+ % ok, we have to inspect the remainder:
+ \pgfmathfloatparsenumber{0.\pgfmathfloatintremainder}%
+ \pgfmathfloatifflags{\pgfmathresult}{1}{%
+ % ah - we stripped a non-zero remainder! Round DOWN
+ \pgfmathfloatcreate{2}{1.0}{0}% -1
+ \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfmath@trunc}%
+ }{%
+ % was no-op
+ \let\pgfmathresult=\pgfmath@trunc
+ }%
+ \fi
+ }{}%
+}
+\let\pgfmathfloatfloor@=\pgfmathfloatfloor
+
+\def\pgfmathfloatceil#1{%
+ \edef\pgfmath@orig{#1}%
+ \pgfmathfloatint@{#1}%
+ \pgfmathfloatifflags{\pgfmath@orig}{1}{%
+ \let\pgfmath@trunc=\pgfmathresult
+ \ifcase\pgfmathfloatintwasnoop\relax
+ % ah - we stripped something! Round UP
+ \pgfmathfloatcreate{1}{1.0}{0}% +1
+ \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfmath@trunc}%
+ \or
+ % was no-op
+ \let\pgfmathresult=\pgfmath@trunc
+ \else
+ % ok, we have to inspect the remainder:
+ \pgfmathfloatparsenumber{0.\pgfmathfloatintremainder}%
+ \pgfmathfloatifflags{\pgfmathresult}{1}{%
+ % ah - we stripped a non-zero remainder! Round UP
+ \pgfmathfloatcreate{1}{1.0}{0}% +1
+ \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfmath@trunc}%
+ }{%
+ % was no-op
+ \let\pgfmathresult=\pgfmath@trunc
+ }%
+ \fi
+ }{}%
+}
+\let\pgfmathfloatceil@=\pgfmathfloatceil
+
+\def\pgfmathfloat@notimplemented#1{%
+ \pgfmath@error{Sorry, the operation '#1' has not yet been implemented in the floating point unit}{}%
+ \pgfmathfloatcreate{0}{0.0}{0}%
+}%
+
+% Divides or multiplies the input number by 10^#4 using an arithmetic
+% left/right shift.
+%
+% Input:
+% #1 a normalised floating point number.
+% #2 a positive or negative integer number denoting the shift.
+%
+% Example:
+% \pgfmathfloatshift{11e3}{4}%
+% -> pgfmathresult = 11e7
+\def\pgfmathfloatshift@#1#2{%
+ \begingroup
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \advance\pgfmathfloat@a@E by#2\relax
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+\let\pgfmathfloatshift=\pgfmathfloatshift@
+
+% Defines \pgfmathresult to be |#1|, the absolute value of the
+% normalized floating point number #1.
+\def\pgfmathfloatabs@#1{%
+ \begingroup
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifcase\pgfmathfloat@a@S
+ % 0: do nothing.
+ \or
+ % +: ok, is positive.
+ \or
+ % -: multiply with -1:
+ \pgfmathfloat@a@S=1
+ \or
+ % nan: do nothing.
+ \or
+ % +infty: ok.
+ \or
+ % -infty: multiply with -1:
+ \pgfmathfloat@a@S=4
+ \fi
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+%
+% Defines \pgfmathresult to be sign(#1)
+\def\pgfmathfloatsign@#1{%
+ \begingroup
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifcase\pgfmathfloat@a@S
+ % 0:
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \or
+ % +: ok, is positive.
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \or
+ % -:
+ \pgfmathfloatcreate{2}{1.0}{0}%
+ \or
+ % nan: do nothing.
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \or
+ % +infty:.
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \or
+ % -infty:
+ \pgfmathfloatcreate{2}{1.0}{0}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\let\pgfmathfloatsign=\pgfmathfloatsign@
+
+% Computes the absolute error |#1 - #2| into \pgfmathresult.
+\def\pgfmathfloatabserror@#1#2{%
+ \pgfmathfloatsubtract@{#1}{#2}%
+ \pgfmathfloatabs@{\pgfmathresult}%
+}%
+\let\pgfmathfloatabserror=\pgfmathfloatabserror@
+
+% Computes the relative error |#1 - #2|/|#2| into \pgfmathresult,
+% assuming #2 != 0.
+\def\pgfmathfloatrelerror@#1#2{%
+ \pgfmathfloatsubtract@{#1}{#2}%
+ \let\pgfmathfloat@subtract=\pgfmathresult
+ \pgfmathfloatifflags{#2}{0}{%
+ \let\pgfmathresult=\pgfmathfloat@subtract
+ }{%
+ \pgfmathfloatdivide@{\pgfmathfloat@subtract}{#2}%
+ }%
+ \pgfmathfloatabs@{\pgfmathresult}%
+}%
+\let\pgfmathfloatrelerror=\pgfmathfloatrelerror@
+
+% Computes \pgfmathresult = #1 mod #2 using truncated division.
+%
+\def\pgfmathfloatmod@#1#2{%
+ \begingroup
+ \pgfmathfloattoint{#1}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloattoint{#2}%
+ \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ \c@pgfmath@counta=\pgfmathfloat@loc@TMPa\relax
+ \divide\c@pgfmath@counta by\pgfmathfloat@loc@TMPb\relax
+ \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}%
+ %
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}%
+ \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+\let\pgfmathfloatmod=\pgfmathfloatmod@
+
+
+% A modification of \pgfmathfloatmod@ where #3 = 1/#2 is already
+% known. This may be faster.
+\def\pgfmathfloatmodknowsinverse@#1#2#3{%
+ \pgfmathfloatmod@{#1}{#2}%
+ %--------------------------------------------------
+ % \begingroup
+ % % FIXME : is this function correct? \pgfmathfloatmod had a
+ % % rounding flaw...
+ % \pgfmathfloatmultiply@{#1}{#3}%
+ % \pgfmathfloatint@{\pgfmathresult}%
+ % \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ % \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}%
+ % \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ % \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}%
+ % \pgfmath@smuggleone\pgfmathresult
+ % \endgroup
+ %--------------------------------------------------
+}
+\let\pgfmathfloatmodknowsinverse=\pgfmathfloatmodknowsinverse@
+
+\def\pgfmathfloatpi@{%
+ \pgfmathfloatcreate{1}{3.14159265358979}{0}%
+}%
+\let\pgfmathfloatpi=\pgfmathfloatpi@
+
+\def\pgfmathfloate@{%
+ \pgfmathfloatcreate{1}{2.71828182845905}{0}%
+}
+\let\pgfmathfloate=\pgfmathfloate@
+
+% Converts #1 from radians to degrees.
+\def\pgfmathfloatdeg@#1{%
+ \expandafter\ifx\csname pgfmfltdeg@factor\endcsname\relax
+ % Lazy evaluation:
+ \pgfmathfloatcreate{1}{5.72957795130823}{1}%
+ \global\let\pgfmfltdeg@factor=\pgfmathresult
+ \fi
+ \pgfmathfloatmultiply@{#1}\pgfmfltdeg@factor%
+}
+\let\pgfmathfloatdeg=\pgfmathfloatdeg@
+
+% Converts #1 from degree to radians.
+\def\pgfmathfloatrad@#1{%
+ \expandafter\ifx\csname pgfmfltrad@factor\endcsname\relax
+ % Lazy evaluation:
+ \pgfmathfloatcreate{1}{1.74532925199433}{-2}%
+ \global\let\pgfmfltrad@factor=\pgfmathresult
+ \fi
+ \pgfmathfloatmultiply@{#1}\pgfmfltrad@factor%
+}
+\let\pgfmathfloatrad=\pgfmathfloatrad@
+
+% Computes #1(#2) where #1 is a trigonometric function, i.e.
+% #1(#2) = #1( #2 + r*360 )
+%
+% #1 is a one-argument macro which assigns \pgfmathresult.
+\def\pgfmathfloatTRIG@#1#2{%
+ \if0\pgfmath@trig@format@choice
+ % trig format=deg
+ \expandafter\ifx\csname pgfmathfloatTRIG@NUM\endcsname\relax%
+ % Lazy evaluation:
+ \pgfmathfloatcreate{1}{3.6}{2}%
+ \global\let\pgfmathfloatTRIG@NUM=\pgfmathresult
+ \pgfmathfloatcreate{1}{2.77777777777778}{-3}%
+ \global\let\pgfmathfloatTRIG@NUM@INV=\pgfmathresult
+ \fi
+ \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@NUM}{\pgfmathfloatTRIG@NUM@INV}%
+ \else
+ % trig format=rad
+ \expandafter\ifx\csname pgfmathfloatTRIG@rad@NUM\endcsname\relax%
+ % Lazy evaluation:
+ \pgfmathfloatcreate{1}{6.28318530717959}{0}%
+ \global\let\pgfmathfloatTRIG@rad@NUM=\pgfmathresult
+ \pgfmathfloatcreate{1}{1.59154943091895}{-1}%
+ \global\let\pgfmathfloatTRIG@rad@NUM@INV=\pgfmathresult
+ \fi
+ \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@rad@NUM}{\pgfmathfloatTRIG@rad@NUM@INV}%
+ \fi
+ \pgfmathfloattofixed@{\pgfmathresult}%
+ \expandafter#1\expandafter{\pgfmathresult}%
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+}%
+
+\def\pgfmathfloatsin@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}}
+\let\pgfmathfloatsin=\pgfmathfloatsin@
+\def\pgfmathfloatcos@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}}
+\let\pgfmathfloatcos=\pgfmathfloatcos@
+\def\pgfmathfloattan@#1{%
+ % compute sin(#1) / cos(#1)
+ \begingroup
+ \pgfmathfloatcos@{#1}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloatsin@{#1}%
+ \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+\let\pgfmathfloattan=\pgfmathfloattan@
+
+\def\pgfmathfloatcot@#1{%
+ % compute cos(#1) / sin(#1)
+ \begingroup
+ \pgfmathfloatsin@{#1}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloatcos@{#1}%
+ \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\let\pgfmathfloatcot=\pgfmathfloatcot@
+
+\def\pgfmathfloatatan@#1{%
+ \begingroup
+ \expandafter\ifx\csname pgfmathfloatatan@TMP\endcsname\relax%
+ \pgfmathfloatcreate{1}{1.6}{4}%
+ \global\let\pgfmathfloatatan@TMP=\pgfmathresult
+ \pgfmathfloatcreate{2}{1.6}{4}%
+ \global\let\pgfmathfloatatan@TMPB=\pgfmathresult
+ \fi
+ \pgfmathfloatgreaterthan@{#1}{\pgfmathfloatatan@TMP}%
+ \ifpgfmathfloatcomparison
+ \pgfmathiftrigonometricusesdeg{%
+ \pgfmathfloatcreate{1}{9.0}{1}%
+ }{%
+ \pgfmathfloatcreate{1}{1.570796326794}{0}%
+ }%
+ \else
+ \pgfmathfloatlessthan{#1}{\pgfmathfloatatan@TMPB}%
+ \ifpgfmathfloatcomparison
+ \pgfmathiftrigonometricusesdeg{%
+ \pgfmathfloatcreate{2}{9.0}{1}%
+ }{%
+ \pgfmathfloatcreate{2}{1.570796326794}{0}%
+ }%
+ \else
+ \pgfmathfloattofixed@{#1}%
+ \expandafter\pgfmath@basic@atan@\expandafter{\pgfmathresult}%
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \fi
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\let\pgfmathfloatatan=\pgfmathfloatatan@
+
+\def\pgfmathfloatatantwo#1#2{%
+ % Note: first parameter is y (!), second is x (!)
+ \begingroup%
+ \let\pgfmath@trig@format@choice@@=\pgfmath@trig@format@choice
+ \def\pgfmath@trig@format@choice{0}%
+ %
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \expandafter\pgfmathfloat@decompose#2\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E
+ \ifnum\pgfmathfloat@a@S=0
+ % ok, #1 = 0. Substitute by 1e-16 such that the next \ifnum catches it:
+ \pgfmathfloat@a@E=-16 %
+ \fi
+ %
+ \ifnum\pgfmathfloat@a@E<-3 %
+ \ifnum\pgfmathfloat@b@S=2 %
+ % #2 < 0
+ \pgfmathfloatcreate{1}{1.8}{2}% +180
+ \else
+ \ifnum\pgfmathfloat@b@S=1 %
+ % #2 >0
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \else
+ % + or - 90, just use the sign of #1:
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{9.0}{1}%
+ \fi
+ \fi
+ \else%
+ \pgfmathfloatabs@{#1}\let\pgfmath@tempa\pgfmathresult%
+ \pgfmathfloatabs@{#2}\let\pgfmath@tempb\pgfmathresult%
+ \pgfmathfloatgreaterthan@{\pgfmath@tempa}{\pgfmath@tempb}%
+ \ifpgfmathfloatcomparison
+ \pgfmathfloatdivide@{#2}{\pgfmath@tempa}%
+ \expandafter\pgfmathfloatatan@\expandafter{\pgfmathresult}%
+ \let\pgfmath@tempa=\pgfmathresult
+ \pgfmathfloatcreate{1}{9.0}{1}%
+ \let\pgfmath@tempb=\pgfmathresult
+ \pgfmathfloatsubtract@{\pgfmath@tempb}{\pgfmath@tempa}%
+ \else%
+ \pgfmathfloatdivide@{\pgfmath@tempa}{#2}%
+ \expandafter\pgfmathfloatatan@\expandafter{\pgfmathresult}%
+ \expandafter\pgfmathfloatifflags\expandafter{\pgfmathresult}{2}{%
+ \let\pgfmath@tempa=\pgfmathresult
+ \pgfmathfloatcreate{1}{1.8}{2}%
+ \let\pgfmath@tempb=\pgfmathresult
+ \pgfmathfloatadd@{\pgfmath@tempa}{\pgfmath@tempb}%
+ }{}%
+ \fi%
+ %
+ \pgfmathfloatifflags{#1}{-}{%
+ % #1 < 0:
+ \pgfmathfloatmultiplyfixed@{\pgfmathresult}{-1}%
+ }{}%
+ \fi%
+ \if1\pgfmath@trig@format@choice@@
+ % trig format=rad
+ \pgfmathfloat@scale@deg@to@rad\pgfmathresult
+ \fi
+ \pgfmath@smuggleone\pgfmathresult%
+ \endgroup%
+}%
+\let\pgfmathfloatatantwo@=\pgfmathfloatatantwo
+\expandafter\let\csname pgfmathfloatatan2\endcsname=\pgfmathfloatatantwo
+\expandafter\let\csname pgfmathfloatatan2@\endcsname=\pgfmathfloatatantwo@
+
+\def\pgfmathfloat@scale@deg@to@rad#1{%
+ \edef\pgfmathfloat@loc@TMPb{#1}%
+ \pgfmathfloatcreate{1}{1.74532925199433}{-2}% = pi / 180
+ \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@loc@TMPb}%
+}%
+
+\def\pgfmathfloatsec@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}}
+\let\pgfmathfloatsec=\pgfmathfloatsec@
+\def\pgfmathfloatcosec@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}}
+\let\pgfmathfloatcosec=\pgfmathfloatcosec@
+
+% Expands #2 using \edef and invokes #1 with the resulting string.
+%
+% DEPRECATED
+% Example:
+% \pgfmath@y=7.9pt
+% \pgfmathlog@invoke@expanded\pgfmathexp@{{\pgf@sys@tonumber{\pgfmath@y}}}%
+% will invoke
+% \pgfmathexp@{7.9}
+\def\pgfmathlog@invoke@expanded#1#2{%
+ \edef\pgfmath@resulttemp{#2}%
+ \expandafter#1\pgfmath@resulttemp
+}
+
+\def\pgfmathfloatln@#1{%
+ \pgfmathlog@float{#1}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \fi
+}
+\let\pgfmathfloatln=\pgfmathfloatln@
+
+\expandafter\def\csname pgfmathfloatlog10@\endcsname#1{%
+ \pgfmathfloatln@{#1}%
+ \let\pgfmathfloat@log@e=\pgfmathresult
+ \pgfmathfloatcreate{1}{4.34294481903252}{-1}% 1/ln(10)
+ \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@log@e}%
+}%
+\pgfutil@namelet{pgfmathfloatlog10}{pgfmathfloatlog10@}%
+
+\expandafter\def\csname pgfmathfloatlog2@\endcsname#1{%
+ \pgfmathfloatln@{#1}%
+ \let\pgfmathfloat@log@e=\pgfmathresult
+ \pgfmathfloatcreate{1}{1.44269504088896}{0}% 1/ln(2)
+ \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@log@e}%
+}%
+\pgfutil@namelet{pgfmathfloatlog2}{pgfmathfloatlog2@}%
+
+\expandafter\let\expandafter\pgfmathfloatlogtwo\csname pgfmathfloatlog2\endcsname
+\expandafter\let\expandafter\pgfmathfloatlogtwo@\csname pgfmathfloatlog2@\endcsname
+\expandafter\let\expandafter\pgfmathfloatlogten\csname pgfmathfloatlog10\endcsname
+\expandafter\let\expandafter\pgfmathfloatlogten@\csname pgfmathfloatlog10@\endcsname
+
+% Computes log(x) into \pgfmathresult.
+%
+% This allows numbers such at 10000000 or 5.23e-10 to be represented
+% properly, although TeX-registers would produce overflow/underflow
+% errors in these cases.
+%
+% The natural logarithm is computed using log(X*10^Y) = log(X) + log(10)*Y
+%
+% FIXME This routine is only kept for backwards compatibility!
+% It does not work as expected because
+% 1. it calls \pgfmathfloatparsenumber
+% 2. it returns the result as fixed point number
+% Use \pgfmathln@ instead!
+\def\pgfmathlog@#1{%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathlog@float{\pgfmathresult}%
+}
+\let\pgfmathlog=\pgfmathlog@
+\def\pgfmathlog@float#1{%
+ \begingroup%
+ % compute #1 = M*10^E with normalised mantisse M = [+-]*[1-9].XXXXX
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifnum\pgfmathfloat@a@S=1
+ % Now, compute log(#1) = log(M) + E*log(10)
+ \expandafter\pgfmath@basic@ln@\expandafter{\the\pgfmathfloat@a@Mtok}%
+ \pgfmathfloat@b@M=\pgfmathresult pt%
+ \pgfmathfloat@a@M=2.302585pt% = log(10)
+ \multiply\pgfmathfloat@a@M by\pgfmathfloat@a@E\relax
+ \advance\pgfmathfloat@b@M by\pgfmathfloat@a@M
+ \edef\pgfmathresult{\pgf@sys@tonumber{\pgfmathfloat@b@M}}%
+ \else
+ \let\pgfmathresult=\pgfutil@empty%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup%
+}
+
+
+% Computes exp(#1) in floating point.
+%
+% The algorithm employs the identity
+% exp(x) = exp(x - log(10^k) + log(10^k)
+% = 10^k exp( x - k*log 10 )
+% with k choosen such that exp( x - k*log10) can be computed with the
+% basic level math engine.
+%
+% The precision (relative error) is between 10^{-4} and 10^{-6}. For
+% #1 = 700, it is even 10^{-3}. I will need to improve that someday.
+\def\pgfmathfloatexp@#1{%
+ \begingroup
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifcase\pgfmathfloat@a@S
+ % #1 = 0:
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \or% #1 > 0
+ \pgfmathfloatexp@@{#1}%
+ \or% #1 < 0
+ \pgfmathfloatexp@@{#1}%
+ \else
+ \edef\pgfmathresult{#1}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\def\pgfmathfloatexp@@#1{%
+ % Employ the identity
+ % exp(x) = exp(x - log(10^k) + log(10^k)) = 10^k exp( x - k *log(10))
+ %
+ % I'd like to have x - k*log(10) <= 1
+ % => compute k := int( (x - 1) * 1/log(10) )
+ % that should suffice since \pgfmathexp@ should be
+ % accurate enough for those numbers.
+ %
+ % please note that we can do all this in TeX registers.
+ % exp(700) is almost the maximum of double precision
+ % anyway, and exp(16000) is certainly the largest we will
+ % ever need.
+ \pgfmathfloattofixed@{#1}%
+ \pgf@xa=\pgfmathresult pt
+ \pgf@xa=0.434294481\pgf@xa\relax
+ \edef\pgfmathfloat@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}%
+ \expandafter\pgfmathfloatexp@@toint\pgfmathfloat@loc@TMPa\relax
+ \pgf@xa=2.302585092pt
+ \multiply\pgf@xa by-\pgfmathfloat@k\relax
+ \advance\pgf@xa by\pgfmathresult pt
+ \edef\pgfmathfloat@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}%
+%\message{computing exp(\pgfmathresult) = 10^\pgfmathfloat@k * exp(\pgfmathfloat@loc@TMPa)...}%
+ \pgfmath@basic@exp@{\pgfmathfloat@loc@TMPa}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloatparsenumber{\pgfmathfloat@loc@TMPa}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloatshift@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@k}%
+}
+% determine 'k'. This is a heuristics. The exponential series
+% converges best for |x| <= 1. However, the fixed point arithmetics
+% for tex results in best results for large |x|. Well, I'll need to
+% tune this here.
+\def\pgfmathfloatexp@@toint#1.#2\relax{%
+ \c@pgf@counta=#1\relax
+ \ifnum\c@pgf@counta<0
+\advance\c@pgf@counta by-1 % FIXME . this is a test for optimizations.
+ \c@pgf@countb=#2\relax
+ \ifnum\c@pgf@countb>0
+ \advance\c@pgf@counta by-1
+ \fi
+ \fi
+ \edef\pgfmathfloat@k{\the\c@pgf@counta}%
+}%
+\let\pgfmathfloatexp=\pgfmathfloatexp@
+
+\def\pgfmathfloatround@#1{%
+ \begingroup
+ \pgfkeysvalueof{/pgf/number format/precision/.@cmd}0\pgfeov
+ \pgfmathfloattofixed{#1}%
+ \pgfmathroundto{\pgfmathresult}%
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+
+\def\pgfmathfloatneg@#1{%
+ \begingroup
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifcase\pgfmathfloat@a@S\relax
+ % 0:
+ \edef\pgfmathresult{#1}%
+ \or
+ % +:
+ \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \or
+ % -:
+ \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \or
+ % nan:
+ \edef\pgfmathresult{#1}%
+ \or
+ % +infty:
+ \pgfmathfloatcreate{5}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \or
+ % -infty:
+ \pgfmathfloatcreate{4}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+
+\def\pgfmathfloatpow@#1#2{%
+ \begingroup%
+ \expandafter\pgfmathfloat@decompose@tok#2\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifcase\pgfmathfloat@a@S\relax
+ % #1 ^ 0 = 1
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \or
+ % #2 > 0
+ \pgfmathfloatpow@@{#1}{#2}%
+ \or
+ % #2 < 0
+ \pgfmathfloatpow@@{#1}{#2}%
+ \or
+ % #2 = nan
+ \edef\pgfmathresult{#2}%
+ \or
+ % #2 = inf
+ \edef\pgfmathresult{#2}%
+ \or
+ % #2 = -inf
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% computes #1^#2
+% PRECONDITIONS
+% - #2 is positive.
+\def\pgfmathfloatpow@@#1#2{%
+ \pgfmathfloattofixed@{#2}%
+ \afterassignment\pgfmath@x%
+ \expandafter\c@pgfmath@counta\pgfmathresult pt\relax%
+ \ifdim\pgfmath@x=0pt %
+ % loop "manually"; we have an integer exponent!
+ \ifnum\c@pgfmath@counta<0
+ \pgfmathfloatreciprocal@{#1}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \c@pgfmath@counta=-\c@pgfmath@counta
+ \else
+ \edef\pgfmathfloat@loc@TMPa{#1}%
+ \fi
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ \pgfmathloop
+ \ifnum\c@pgfmath@counta>0\relax%
+ \ifodd\c@pgfmath@counta%
+ \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPb}{\pgfmathfloat@loc@TMPa}%
+ \let\pgfmathfloat@loc@TMPb=\pgfmathresult
+ \fi
+ \ifnum\c@pgfmath@counta>1\relax%
+ \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPa}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \fi%
+ \divide\c@pgfmath@counta by2\relax%
+ \repeatpgfmathloop%
+ \else
+ \pgfmathfloatgetflags{#1}\c@pgfmath@counta
+ \ifnum0=\c@pgfmath@counta
+ % ah: 0^x
+ \pgfmathfloatgetflags{#2}\c@pgfmath@counta
+ \ifnum0=\c@pgfmath@counta
+ % ah: 0^0
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \else
+ % ah: 0^x with x!=0:
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \fi
+ \else
+ % employ #1^#2 = exp( #2 * ln(#1) )
+ \pgfmathfloatln@{#1}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \edef\pgfmathfloat@loc@TMPb{#2}%
+ \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPb}%
+ \pgfmathfloatexp@{\pgfmathresult}%
+ \fi
+ \fi
+}
+
+\def\pgfmathfloat@definemethodfrombasic@NOARG#1{%
+ \pgfutil@ifundefined{pgfmath@basic@#1@}{%
+ \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}%
+ }{}%
+ \edef\pgfmathfloat@glob@TMP{%
+ \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname
+ \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}%
+ }%
+ \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP%
+ \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP%
+}%
+\def\pgfmathfloat@definemethodfrombasic@ONEARG#1{%
+ \pgfutil@ifundefined{pgfmath@basic@#1@}{%
+ \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}%
+ }{}%
+ \edef\pgfmathfloat@glob@TMP##1{%
+ \noexpand\pgfmathfloattofixed{##1}%
+ \noexpand\expandafter
+ \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname\noexpand\expandafter%
+ {\noexpand\pgfmathresult}%
+ \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}%
+ }%
+ \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP%
+ \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP%
+}%
+\def\pgfmathfloat@definemethodfrombasic@TWOARGS#1{%
+ \pgfutil@ifundefined{pgfmath@basic@#1@}{%
+ \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}%
+ }{}%
+ \edef\pgfmathfloat@glob@TMP##1##2{%
+ \noexpand\pgfmathfloattofixed{##2}%
+ \noexpand\let\noexpand\pgfmathfloat@loc@TMPa=\noexpand\pgfmathresult
+ \noexpand\pgfmathfloattofixed{##1}%
+ \noexpand\expandafter
+ \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname\noexpand\expandafter%
+ {\noexpand\pgfmathresult}{\noexpand\pgfmathfloat@loc@TMPa}%
+ \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}%
+ }%
+ \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP%
+ \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP%
+}%
+\pgfmathfloat@definemethodfrombasic@NOARG{rand}
+\pgfmathfloat@definemethodfrombasic@NOARG{rnd}
+\pgfmathfloat@definemethodfrombasic@NOARG{false}
+\pgfmathfloat@definemethodfrombasic@NOARG{true}
+% arcsin, arccos
+\pgfmathfloat@definemethodfrombasic@ONEARG{asin}
+\pgfmathfloat@definemethodfrombasic@ONEARG{acos}
+\pgfmathfloat@definemethodfrombasic@ONEARG{not}
+\pgfmathfloat@definemethodfrombasic@ONEARG{hex}
+\pgfmathfloat@definemethodfrombasic@ONEARG{Hex}
+\pgfmathfloat@definemethodfrombasic@ONEARG{oct}
+\pgfmathfloat@definemethodfrombasic@ONEARG{bin}
+\pgfmathfloat@definemethodfrombasic@TWOARGS{and}
+\pgfmathfloat@definemethodfrombasic@TWOARGS{or}
+
+\pgfutil@ifundefined{pgfmathdeclarefunction}{%
+ % special treatment: \pgfmathrand@ was not properly defined for pgf 2.00:
+ \let\pgfmath@basic@rand=\pgfmathrand
+ \let\pgfmath@basic@rand@=\pgfmathrand@
+ \def\pgfmathfloatrand@{%
+ \pgfmath@basic@rand
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ }%
+ \let\pgfmathfloatrand=\pgfmathfloatrand@%
+ %
+ % special treatment: \pgfmathrnd@ was not properly defined for pgf 2.00:
+ \let\pgfmath@basic@rnd=\pgfmathrnd
+ \let\pgfmath@basic@rnd@=\pgfmathrnd@
+ \def\pgfmathfloatrnd@{%
+ \pgfmath@basic@rnd
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ }%
+ \let\pgfmathfloatrnd=\pgfmathfloatrnd@%
+}{}
+
+% Implements the factorial of '#1'.
+% This does only work if '#1 < 2^32'.
+\def\pgfmathfloatfactorial@#1{%
+ \begingroup
+ \pgfmathfloattofixed{#1}%
+ % collect integer part into a 32 bit register:
+ \afterassignment\pgfmath@gobbletilpgfmath@%
+ \expandafter\c@pgfmath@counta\pgfmathresult\relax\pgfmath@%
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathloop
+ \ifnum\c@pgfmath@counta<2 %
+ \else
+ \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}%
+ \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \advance\c@pgfmath@counta by-1\relax%
+ \repeatpgfmathloop
+ \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/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex
new file mode 100644
index 0000000000..e6cb9e3bca
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryintersections.code.tex
@@ -0,0 +1,1190 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Di 14. Nov 22:41:45 CET 2017 %%%
+
+
+
+% Copyright 2008 by Mark Wibrow
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Free Documentation License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+% Note: at the time of this writing, the library has quadratic runtime.
+% Experimentally, it performed well while computing ~12 intersections of two
+% plots, each with 600 samples. It failed when the number of samples exceeded 700.
+
+\usepgflibrary{fpu}
+
+\newcount\pgf@intersect@solutions
+
+\newif\ifpgf@intersect@sort
+\newif\ifpgf@intersect@sort@by@second@path
+
+\def\pgfintersectionsortbyfirstpath{%
+ \pgf@intersect@sorttrue%
+ \pgf@intersect@sort@by@second@pathfalse%
+}
+
+\def\pgfintersectionsortbysecondpath{%
+ \pgf@intersect@sorttrue%
+ \pgf@intersect@sort@by@second@pathtrue%
+}
+
+% #1: the index. It starts at 1 and ends with \pgfintersectionsolutions (inclusive).
+% Invalid values will implicitly result in the origin.
+\def\pgfpointintersectionsolution#1{%
+ \ifnum#1<1\relax%
+ \pgfpoint@intersect@solution@orgin%
+ \else%
+ \ifnum#1>\pgfintersectionsolutions\relax%
+ \pgfpoint@intersect@solution@orgin%
+ \else%
+ \csname pgfpoint@intersect@solution@#1\endcsname%
+ \fi%
+ \fi%
+}
+
+% Gets the segment indices of solution #1.
+%
+% #1: the solution index (i.e. the same argument as in \pgfpointintersectionsolution)
+% #2: [output] a macro name which will contain the segment index of the first path which contains the solution
+% #3: [output] a macro name which will contain the segment index of the second path which contains the solution
+%
+% Example: \pgfintersectiongetsolutionsegmentindices{0}{\first}{\second}
+%
+% -> \first may be 0 if point #0 is in the 0'th segment
+% -> \second may be 42 if point #0 is in the 42'th segment
+%
+% The "segment index" is actually close to the "time" of the solution.
+% If a solution is at "time" 42.2, it will have segment index 42.
+\def\pgfintersectiongetsolutionsegmentindices#1#2#3{%
+ \ifnum#1<1\relax%
+ \let#2=\pgfutil@empty
+ \let#3=\pgfutil@empty
+ \else%
+ \ifnum#1>\pgfintersectionsolutions\relax%
+ \let#2=\pgfutil@empty
+ \let#3=\pgfutil@empty
+ \else%
+ \def\pgf@temp##1##2##3##4{%
+ \edef#2{##1}%
+ \edef#3{##2}%
+ }%
+ \expandafter\let\expandafter\pgf@tempb\csname pgf@intersect@solution@props@#1\endcsname
+ \expandafter\pgf@temp\pgf@tempb
+ \fi%
+ \fi%
+}%
+
+% Gets the time indices of solution #1.
+%
+% #1: the solution index (i.e. the same argument as in \pgfpointintersectionsolution)
+% #2: [output] a macro name which will contain the time of the first path which contains the solution
+% It will never be empty.
+% #3: [output] a macro name which will contain the time of the second path which contains the solution
+% It will never be empty.
+%
+% Example: \pgfintersectiongetsolutiontimes{0}{\first}{\second}
+%
+% -> \first may be 0.5 if point #0 is in just in the middle of the path
+% -> \second may be 42.8 if point #0 is in the 42'th segment (compare
+% \pgfintersectiongetsolutionsegmentindices) and is at 80% of the
+% 42'th segment
+%
+% Note that the precise time inside of a segment may be unavailable
+% (currently, it is only computed for curveto paths and not
+% necessarily for lineto). If the precise time is unavailable, this
+% call will return the value of
+% \pgfintersectiongetsolutionsegmentindices (which is a
+% "coarse-grained" time).
+\def\pgfintersectiongetsolutiontimes#1#2#3{%
+ \ifnum#1<1\relax%
+ \let#2=\pgfutil@empty
+ \let#3=\pgfutil@empty
+ \else%
+ \ifnum#1>\pgfintersectionsolutions\relax%
+ \let#2=\pgfutil@empty
+ \let#3=\pgfutil@empty
+ \else%
+ \def\pgf@temp##1##2##3##4{%
+ \edef#2{##3}%
+ \edef#3{##4}%
+ %
+ % check for fallback to segment indices:
+ \ifx#2\pgfutil@empty \edef#2{##1}\fi
+ \ifx#3\pgfutil@empty \edef#3{##2}\fi
+ }%
+ \expandafter\let\expandafter\pgf@tempb\csname pgf@intersect@solution@props@#1\endcsname
+ \expandafter\pgf@temp\pgf@tempb
+ \fi%
+ \fi%
+}%
+
+\def\pgfpoint@intersect@solution@orgin{%
+ \begingroup%
+ \pgftransforminvert%
+ \pgfpointorigin%
+ \pgf@pos@transform@glob
+ \global\pgf@x=\pgf@x%
+ \global\pgf@y=\pgf@y%
+ \endgroup%
+}
+
+% #1 code which assigns the first path using \pgfsetpath.
+% #2 code which assigns the second path using \pgfsetpath.
+%
+% On output, the points, their properties, and the number of points are set.
+% Use \pgfintersectionsolutions which expands to the number of intersections
+\long\def\pgfintersectionofpaths#1#2{%
+ \begingroup%
+ \pgfinterruptpath%
+ #1%
+ \pgfgetpath\pgf@intersect@path@a%
+ \global\let\pgf@intersect@path@temp=\pgf@intersect@path@a%
+ \endpgfinterruptpath%
+ \endgroup%
+ \let\pgf@intersect@path@a=\pgf@intersect@path@temp%
+ %
+ \begingroup%
+ \pgfinterruptpath%
+ #2%
+ \pgfgetpath\pgf@intersect@path@b%
+ \global\let\pgf@intersect@path@temp=\pgf@intersect@path@b%
+ \endpgfinterruptpath%
+ \endgroup%
+ \let\pgf@intersect@path@b=\pgf@intersect@path@temp%
+ %
+ \pgf@intersect@solutions=0\relax%
+ \pgf@intersect@path@reset@a
+ %
+ \ifpgf@intersect@sort@by@second@path%
+ \let\pgf@intersect@temp=\pgf@intersect@path@a%
+ \let\pgf@intersect@path@a=\pgf@intersect@path@b%
+ \let\pgf@intersect@path@b=\pgf@intersect@temp%
+ \fi%
+ %
+ \pgfprocessround\pgf@intersect@path@a\pgf@intersect@path@a%
+ \pgfprocessround\pgf@intersect@path@b\pgf@intersect@path@b%
+ %
+ \let\pgf@intersect@token@after=\pgf@intersect@path@process@a%
+ \expandafter\pgf@intersectionofpaths\pgf@intersect@path@a\pgf@stop%
+ \edef\pgfintersectionsolutions{\the\pgf@intersect@solutions}%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter>\pgfintersectionsolutions\relax%
+ \else%
+ \pgfutil@namelet{pgfpoint@intersect@solution@\pgfmathcounter}%
+ {pgfpoint@g@intersect@solution@\pgfmathcounter}%
+ \edef\pgf@marshal{\noexpand\pgf@intersection@set@properties{\csname pgfpoint@g@intersect@solution@\pgfmathcounter @props\endcsname}}%
+ \pgf@marshal
+ \ifpgf@intersect@sort%
+ \pgfutil@namelet{pgf@intersect@solution@\pgfmathcounter @time@a}%
+ {pgf@g@intersect@solution@\pgfmathcounter @time@a}%
+ \fi%
+ \repeatpgfmathloop%
+ \ifpgf@intersect@sort%
+ \pgfintersectionsolutionsortbytime%
+ \fi%
+}
+
+\def\pgf@intersection@set@properties#1{%
+ \pgfutil@namedef{pgf@intersect@solution@props@\pgfmathcounter}{#1}%
+}%
+
+% #1 a global name prefix to store properties.
+\def\pgf@intersection@store@properties#1{%
+ % we store the time offsets as well and make them available programmatically:
+ % note that \pgf@intersect@time@a and \pgf@intersect@time@b may be empty.
+ %
+ % However, \pgf@intersect@time@offset and
+ % \pgf@intersect@time@offset@b are *always* valid. In fact,they
+ % resemble a part of the time: it holds
+ % 0 <= \pgf@intersect@time@a < 1
+ % and \pgf@intersect@time@offset > 0.
+ %
+ % If we have an intersection in segment 42 of path A,
+ % \pgf@intersect@time@offset will be 42. The time inside of that
+ % segment is given as number in the interval [0,1]. If it is 0.3,
+ % the total time will be 42.3 and that number will be stored as
+ % \pgf@intersect@time@a.
+ %
+ \expandafter\xdef\csname #1@props\endcsname{{\pgf@intersect@time@offset}{\pgf@intersect@time@offset@b}{\pgf@intersect@time@a}{\pgf@intersect@time@b}}%
+}
+
+\def\pgf@intersectionofpaths#1{%
+ \ifx#1\pgf@stop%
+ \let\pgf@intersect@next=\relax%
+ \else%
+ \ifx#1\pgfsyssoftpath@movetotoken%
+ \let\pgf@intersect@next=\pgf@intersect@token@moveto%
+ \else%
+ \ifx#1\pgfsyssoftpath@linetotoken%
+ \let\pgf@intersect@next=\pgf@intersect@token@lineto%
+ \else%
+ \ifx#1\pgfsyssoftpath@closepathtoken%
+ \let\pgf@intersect@next=\pgf@intersect@token@lineto%
+ \else%
+ \ifx#1\pgfsyssoftpath@curvetosupportatoken%
+ \let\pgf@intersect@next=\pgf@intersect@token@curveto%
+ \else%
+ \ifx#1\pgfsyssoftpath@rectcornertoken%
+ \let\pgf@intersect@next=\pgf@intersect@token@rect%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \pgf@intersect@next}
+
+\def\pgf@intersect@token@moveto#1#2{%
+ \def\pgfpoint@intersect@start{\pgfqpoint{#1}{#2}}%
+ \pgf@intersectionofpaths%
+}
+
+\def\pgf@intersect@token@lineto#1#2{%
+ \def\pgfpoint@intersect@end{\pgfqpoint{#1}{#2}}%
+ \def\pgf@intersect@type{line}%
+ \pgf@intersect@token@after%
+}
+\def\pgf@intersect@token@curveto#1#2\pgfsyssoftpath@curvetosupportbtoken#3#4\pgfsyssoftpath@curvetotoken#5#6{%
+ \def\pgfpoint@intersect@firstsupport{\pgfqpoint{#1}{#2}}%
+ \def\pgfpoint@intersect@secondsupport{\pgfqpoint{#3}{#4}}%
+ \def\pgfpoint@intersect@end{\pgfqpoint{#5}{#6}}%
+ \def\pgf@intersect@type{curve}%
+ \pgf@intersect@token@after%
+}
+
+\def\pgf@intersect@token@rect#1#2\pgfsyssoftpath@rectsizetoken#3#4{%
+ \pgf@xa=#1\relax%
+ \advance\pgf@xa by#3\relax%
+ \pgf@ya=#2\relax%
+ \advance\pgf@ya by#4\relax%
+ \edef\pgf@marshal{%
+ \noexpand\pgfsyssoftpath@movetotoken{#1}{#2}%
+ \noexpand\pgfsyssoftpath@linetotoken{#1}{\the\pgf@ya}%
+ \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{\the\pgf@ya}%
+ \noexpand\pgfsyssoftpath@linetotoken{\the\pgf@xa}{#2}%
+ \noexpand\pgfsyssoftpath@closepathtoken{#1}{#2}%
+ }%
+ \expandafter\pgf@intersectionofpaths\pgf@marshal%
+}
+
+\def\pgf@intersect@path@process@a{%
+ \pgf@intersect@path@getpoints@a%
+ \let\pgf@intersect@token@after=\pgf@intersect@path@process@b%
+ \pgf@intersect@path@reset@b
+ \expandafter\pgf@intersectionofpaths\pgf@intersect@path@b\pgf@stop%
+ \let\pgfpoint@intersect@start=\pgfpoint@intersect@end@a%
+ \let\pgf@intersect@token@after=\pgf@intersect@path@process@a%
+ \c@pgf@counta=\pgf@intersect@time@offset\relax%
+ \advance\c@pgf@counta by1\relax%
+ \edef\pgf@intersect@time@offset{\the\c@pgf@counta}%
+ \pgf@intersectionofpaths%
+}
+
+\def\pgf@intersect@path@reset@a{%
+ \def\pgf@intersect@time@offset{0}%
+ \def\pgf@intersect@time@a{}%
+}%
+
+\def\pgf@intersect@path@reset@b{%
+ \def\pgf@intersect@time@offset@b{0}%
+ \def\pgf@intersect@time@b{}%
+}%
+
+\def\pgf@intersect@path@getpoints@a{%
+ \let\pgfpoint@intersect@start@a=\pgfpoint@intersect@start%
+ \let\pgfpoint@intersect@end@a=\pgfpoint@intersect@end%
+ \let\pgfpoint@intersect@firstsupport@a=\pgfpoint@intersect@firstsupport%
+ \let\pgfpoint@intersect@secondsupport@a=\pgfpoint@intersect@secondsupport%
+ \let\pgf@intersect@type@a=\pgf@intersect@type%
+}
+
+\def\pgf@intersect@path@process@b{%
+ \pgf@intersect@path@getpoints@b%
+ \csname pgf@intersect@\pgf@intersect@type@a @and@\pgf@intersect@type@b\endcsname%
+ \let\pgfpoint@intersect@start=\pgfpoint@intersect@end@b%
+ \c@pgf@counta=\pgf@intersect@time@offset@b\relax%
+ \advance\c@pgf@counta by1\relax%
+ \edef\pgf@intersect@time@offset@b{\the\c@pgf@counta}%
+ \pgf@intersectionofpaths}
+
+\def\pgf@intersect@path@getpoints@b{%
+ \let\pgfpoint@intersect@start@b=\pgfpoint@intersect@start%
+ \let\pgfpoint@intersect@end@b=\pgfpoint@intersect@end%
+ \let\pgfpoint@intersect@firstsupport@b=\pgfpoint@intersect@firstsupport%
+ \let\pgfpoint@intersect@secondsupport@b=\pgfpoint@intersect@secondsupport%
+ \let\pgf@intersect@type@b=\pgf@intersect@type%
+}
+
+\def\pgf@intersect@line@and@line{%
+ \pgf@intersectionoflines{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}%
+ {\pgfpoint@intersect@start@b}{\pgfpoint@intersect@end@b}%
+}%
+
+\def\pgf@intersect@line@and@curve{%
+ \pgf@intersectionoflineandcurve%
+ {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@end@a}}%
+ {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@firstsupport@b}}%
+ {\pgf@process{\pgfpoint@intersect@secondsupport@b}}{\pgf@process{\pgfpoint@intersect@end@b}}%
+}
+
+\def\pgf@intersect@curve@and@line{%
+ \pgf@intersectionofcurveandline%
+ {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@firstsupport@a}}%
+ {\pgf@process{\pgfpoint@intersect@secondsupport@a}}{\pgf@process{\pgfpoint@intersect@end@a}}%
+ {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@end@b}}%
+}
+
+\def\pgf@intersect@curve@and@curve{%
+ \pgf@intersectionofcurves%
+ {\pgf@process{\pgfpoint@intersect@start@a}}{\pgf@process{\pgfpoint@intersect@firstsupport@a}}%
+ {\pgf@process{\pgfpoint@intersect@secondsupport@a}}{\pgf@process{\pgfpoint@intersect@end@a}}%
+ {\pgf@process{\pgfpoint@intersect@start@b}}{\pgf@process{\pgfpoint@intersect@firstsupport@b}}%
+ {\pgf@process{\pgfpoint@intersect@secondsupport@b}}{\pgf@process{\pgfpoint@intersect@end@b}}%
+}
+
+
+\def\pgfintersectionoflines#1#2#3#4{%
+ \pgf@intersect@solutions=0\relax%
+ \pgf@intersectionoflines{#1}{#2}{#3}{#4}%
+}
+
+\def\pgf@intersectionoflines#1#2#3#4{%
+ \pgf@iflinesintersect{#1}{#2}{#3}{#4}%
+ {%
+ \pgfextract@process\pgf@intersect@solution@candidate{%
+ % pgf@x and pgf@y are already assigned by \pgf@iflinesintersect
+ }%
+ \pgf@ifsolution@duplicate{\pgf@intersect@solution@candidate}{%
+ % ah - we a duplicate. Apparently, we have a hit on an
+ % endpoint.
+ }{%
+ \global\advance\pgf@intersect@solutions by1\relax%
+ \expandafter\global\expandafter\let\csname pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions\endcsname=\pgf@intersect@solution@candidate
+ \ifpgf@intersect@sort%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgf@process{\pgfpointdiff{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}}%
+ \edef\pgf@marshal{%
+ \noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@ya}}%
+ }%
+ \pgf@marshal%
+ \let\pgf@intersect@length@a=\pgfmathresult%
+ \pgf@process{\pgfpointdiff{\pgfpoint@intersect@start@a}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}%
+ \edef\pgf@marshal{%
+ \noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
+ }%
+ \pgf@marshal%
+ \pgfmathdivide@{\pgfmathresult}{\pgf@intersect@length@a}%
+ \pgf@x=\pgfmathresult pt\relax%
+ \advance\pgf@x by\pgf@intersect@time@offset pt\relax%
+ \edef\pgf@intersect@time@a{\pgfmath@tonumber{\pgf@x}}%
+ \expandafter\global\expandafter\let\csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname=
+ \pgf@intersect@time@a
+ \else
+ \let\pgf@intersect@time@a=\pgfutil@empty
+ \fi%
+ \let\pgf@intersect@time@b=\pgfutil@empty
+ \pgf@intersection@store@properties{pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions}%
+ }%
+ %
+ }{%
+ }%
+}
+
+% Test if two lines L1 and L2 intersect.
+%
+% #1 - first point P1 on L1.
+% #2 - second point P2 on L1.
+% #3 - first point P3 on L2.
+% #2 - second point P4 on L2.
+% #5 - code executed if intersection occurs.
+% #6 - code executed if intersection does no occur.
+%
+% Let L1 be represented by P1+(P2-P1)s where 0<=s<=1
+% Let L2 be represented by P3+(P4-P3)t where 0<=t<=1
+%
+% Then L1 and L2 intersect at
+%
+% s = |x2-x1 x3-x1| / |x4-x3 x2-x1|
+% |y2-y1 y3-y1| |y4-y3 y2-y1|
+%
+% t = |x4-x3 x3-x1| / |x4-x3 x2-x1|
+% |y4-y3 y3-y1| |y4-y3 y2-y1|
+%
+% with 0<=s,t<=1
+%
+% s and t do not need to be calculated:
+%
+% Let s = A / C and t = B / C
+%
+% Then 0<=s<=1 if !(C=0) && ((A=0) || ((A>0) && !(C<A)) || ((A<0) && !(C>A)))
+% 0<=t<=1 if !(C=0) && ((B=0) || ((B>0) && !(C<B)) || ((B<0) && !(C>B)))
+%
+\newif\ifpgf@s
+\newif\ifpgf@t
+\def\pgfiflinesintersect#1#2#3#4{%
+ \begingroup%
+ \pgf@iflinesintersect{\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}%
+ {\aftergroup\pgfutil@firstoftwo}{\aftergroup\pgfutil@secondoftwo}%
+ \endgroup%
+}
+
+% queried by pgfplots. Do not delete, only increase.
+\def\pgf@intersections@version{2}%
+
+% #1,#2: line 1
+% #3,#4: line 2
+\def\pgf@iflinesintersect#1#2#3#4{%
+ % first: check bounding boxes -- but somewhat increased such that we do not
+ % exclude "visible" hits due to rounding issues (i.e. use an upper bound):
+ \pgf@intersect@boundingbox@reset%
+ \pgf@intersect@boundingbox@update{#1}%
+ \pgf@intersect@boundingbox@update{#2}%
+ \pgf@intersect@boundingbox@assign@b%
+ %
+ \pgf@intersect@boundingbox@reset%
+ \pgf@intersect@boundingbox@update{#3}%
+ \pgf@intersect@boundingbox@update{#4}%
+ \pgf@intersect@boundingbox@assign@a%
+ %
+ \pgf@intersect@boundingbox@a%
+ \pgf@intersect@boundingbox@b%
+ %
+ \pgf@intersect@boundingbox@ifoverlap@upperbound{%
+ \pgf@iflinesintersect@{#1}{#2}{#3}{#4}%
+ }{%
+ \let\pgf@intersect@next=\pgfutil@secondoftwo%
+ }%
+ \pgf@intersect@next%
+}%
+
+% a helper routine which simply defines \pgf@intersect@next.
+%
+% In principle, this routine is capable of computing the entire intersection... but we only invoke it after checking for bounding box overlaps. This has two reasons:
+% 1. robustness. almost-parallel lines could cause "dimension too large" when solving the linear equation system
+% XXX : I still needed to replace the linear solver by one using the FPU. Perhaps I do not need the BB check anymore?
+% 2. performance. I hope it is faster to first check for BB (but this is not sure in TeX)
+%
+% #1,#2: line 1
+% #3,#4: line 2
+\def\pgf@iflinesintersect@#1#2#3#4{%
+ % we have two lines of sorts
+ % l_1(s) := #1 + s * (#2 - #1), 0<= s <= 1
+ % and
+ % l_2(t) := #3 + t * (#4 - #3), 0<= t <= 1
+ % ->
+ % set up LGS
+ % ( #2 - #1 ) *s + (#3-#4) * t = #3-#1
+ % we have a hit if 0<= s,t <= 1 .
+ #1\relax%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ #2\relax%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ #3\relax%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ #4\relax%
+ %
+ % will be overwritten, remember it:
+ \edef\pgf@intersect@A{%
+ \pgf@xa=\the\pgf@xa\space
+ \pgf@ya=\the\pgf@ya\space
+ }%
+ %
+ % B := (2-1)
+ \advance\pgf@xb by-\pgf@xa
+ \advance\pgf@yb by-\pgf@ya
+ %
+ % A := (3-1)
+ \advance\pgf@xa by-\pgf@xc
+ \advance\pgf@ya by-\pgf@yc
+ \pgf@xa=-\pgf@xa
+ \pgf@ya=-\pgf@ya
+ %
+ % C := (3-4)
+ \advance\pgf@xc by-\pgf@x
+ \advance\pgf@yc by-\pgf@y
+ %
+ \begingroup
+ % compute the |.|_1 norm of each of lines. We need to compute
+ % tolerance factors in order to decide if we have an intersection.
+ % line 1: compute |#2 - #1|_1 :
+ \ifdim\pgf@xb<0sp \pgf@xb=-\pgf@xb\fi
+ \ifdim\pgf@yb<0sp \pgf@yb=-\pgf@yb\fi
+ \advance\pgf@xb by\pgf@yb
+ \xdef\pgf@intersect@len@a{\pgf@sys@tonumber\pgf@xb}%
+ %
+ % line 2: compute |#3 - #4|_1 :
+ \ifdim\pgf@xc<0sp \pgf@xc=-\pgf@xc\fi
+ \ifdim\pgf@yc<0sp \pgf@yc=-\pgf@yc\fi
+ \advance\pgf@xc by\pgf@yc
+ \xdef\pgf@intersect@len@b{\pgf@sys@tonumber\pgf@xc}%
+ \endgroup
+ %
+ \edef\pgf@marshal{%
+ \noexpand\pgfutilsolvetwotwoleqfloat{%
+ {\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@xc}%
+ {\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@yc}%
+ }{%
+ {\pgf@sys@tonumber\pgf@xa}%
+ {\pgf@sys@tonumber\pgf@ya}%
+ }%
+ }%
+ \pgf@marshal
+ %
+ \let\pgf@intersect@next=\pgfutil@secondoftwo%
+ \ifx\pgfmathresult\pgfutil@empty
+ % matrix was singular.
+ \else
+ \def\pgf@marshal##1##2{%
+ \global\pgf@x=##1pt %
+ \global\pgf@y=##2pt %
+ }%
+ \expandafter\pgf@marshal\pgfmathresult
+ %
+ \def\pgf@marshal{XXXX}% this should never be read
+ % FIRST: check line 1:
+ \ifdim\pgf@x<0sp
+ % let it count as hit if
+ % || l_1(s) - l_1(0) || < eps
+ % <=> |s| * ||#2 - #1|| < eps
+ % and, since s< 0 here:
+ % <=> -s * ||#2 - #1|| < eps
+ \pgf@xa=-\pgf@intersect@len@a\pgf@x
+ \ifdim\pgf@xa<\pgfintersectiontolerance\relax
+ % close enough to first endpoint of line 1:
+ \def\pgf@marshal{1}%
+ \else
+ \def\pgf@marshal{0}%
+ \fi
+ \else
+ \ifdim\pgf@x>1pt
+ % let it count as hit if
+ % || l_1(s) - l_1(1) || < eps
+ % <=> |s-1| * ||#2 - #1|| < eps
+ % and, since s > 1 here:
+ % <=> s * ||#2 - #1|| - ||#2 - #1|| < eps
+ \pgf@xa=\pgf@intersect@len@a\pgf@x
+ \advance\pgf@xa by-\pgf@intersect@len@a pt %
+ \ifdim\pgf@xa<\pgfintersectiontolerance\relax
+ % close enough to second endpoint of line 1:
+ \def\pgf@marshal{1}%
+ \else
+ \def\pgf@marshal{0}%
+ \fi
+ \else
+ % 0<= s <= 1: we have an intersection within line 1.
+ \def\pgf@marshal{1}%
+ \fi
+ \fi
+ %
+ % SECOND: check line 2:
+ \if1\pgf@marshal
+ \ifdim\pgf@y<0sp
+ % see remarks for line 1. same applies here.
+ \pgf@xa=-\pgf@intersect@len@b\pgf@y
+ \ifdim\pgf@xa<\pgfintersectiontolerance\relax
+ % close enough to first endpoint of line 2:
+ \def\pgf@marshal{1}%
+ \else
+ \def\pgf@marshal{0}%
+ \fi
+ \else
+ \ifdim\pgf@y>1pt
+ % see remarks for line 1. same applies here.
+ \pgf@xa=\pgf@intersect@len@b\pgf@y
+ \advance\pgf@xa by-\pgf@intersect@len@b pt %
+ \ifdim\pgf@xa<\pgfintersectiontolerance\relax
+ % close enough to second endpoint of line 2:
+ \def\pgf@marshal{1}%
+ \else
+ \def\pgf@marshal{0}%
+ \fi
+ \else
+ % 0<= t <= 1: we have an intersection within line 2.
+ \def\pgf@marshal{1}%
+ \fi
+ \fi
+ \fi
+ %
+ \if1\pgf@marshal
+ % Ok, compute the intersection point and return it:
+ % we use (x,y) = A + s * (B-A)
+ % keep in mind that (s,t) == (\pgf@x,\pgf@y)
+ \pgf@intersect@A
+ \pgf@yc=\pgf@x
+ \global\pgf@x=\pgf@sys@tonumber\pgf@xb\pgf@yc
+ \global\pgf@y=\pgf@sys@tonumber\pgf@yb\pgf@yc
+ \global\advance\pgf@x by \pgf@xa
+ \global\advance\pgf@y by \pgf@ya
+ \let\pgf@intersect@next=\pgfutil@firstoftwo%
+ \fi
+ \fi
+}
+
+
+
+
+\def\pgfintersectionoflineandcurve#1#2#3#4#5#6{%
+ \pgf@intersect@solutions=0\relax%
+ \pgf@intersectionoflineandcurve{#1}{#2}{#3}{#4}{#5}{#6}%
+}
+
+\def\pgf@intersectionoflineandcurve#1#2#3#4#5#6{%
+ \pgf@intersectionofcurves%
+ {\pgf@process{#1}}%
+ {%
+ \pgf@process{%
+ \pgfpointadd{#1\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}%
+ {#2\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}%
+ }%
+ }%
+ {%
+ \pgf@process{%
+ \pgfpointadd{#1\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}%
+ {#2\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}%
+ }%
+ }%
+ {\pgf@process{#2}}%
+ {\pgf@process{#3}}%
+ {\pgf@process{#4}}%
+ {\pgf@process{#5}}%
+ {\pgf@process{#6}}%
+}%
+
+\def\pgf@intersectionofcurveandline#1#2#3#4#5#6{%
+ \pgf@intersectionofcurves%
+ {\pgf@process{#1}}%
+ {\pgf@process{#2}}%
+ {\pgf@process{#3}}%
+ {\pgf@process{#4}}%
+ {\pgf@process{#5}}%
+ {%
+ \pgf@process{%
+ \pgfpointadd{#5\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}%
+ {#6\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}%
+ }%
+ }%
+ {%
+ \pgf@process{%
+ \pgfpointadd{#5\relax\pgf@x=0.333333\pgf@x\pgf@y=0.333333\pgf@y}%
+ {#6\relax\pgf@x=0.666666\pgf@x\pgf@y=0.666666\pgf@y}%
+ }%
+ }%
+ {\pgf@process{#6}}%
+}%
+
+
+
+
+\def\pgfintersectiontolerance{0.1pt}
+\def\pgfintersectiontoleranceupperbound{1pt}
+\def\pgfintersectiontolerancefactor{0.1}
+
+
+
+% Find the intersections of two bezier curves.
+%
+% #1 - #4 = curve 1.
+% #5 - #8 = curve 2.
+% #9 = the solution number.
+%
+% There is no guarantee of ordering of solutions. If there are
+% no solutions, the origin is returned.
+%
+\def\pgfpointintersectionofcurves#1#2#3#4#5#6#7#8#9{%
+ \pgf@intersect@solutions=0\relax%
+ \pgf@intersectionofcurves%
+ {\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}%
+ {\pgf@process{#5}}{\pgf@process{#6}}{\pgf@process{#7}}{\pgf@process{#8}}%
+ \pgfpointintersectionsolution{#9}%
+}
+
+% Return any intersection points of two curves C1 and C2.
+% No order can be guaranteed for the solutions.
+%
+% #1, #2, #3, #4 - the points on C1
+% #5, #6, #7, #8 - the points on C2
+%
+% Returns:
+%
+% \pgf@intersect@solutions - the number of solutions.
+% \pgfpointintersectionsolution{<S>} - the point for soultion S.
+%
+% (Sort of) use:
+%
+% intersection(C1,C2)
+% S = {};
+% intersection'(C1,C2);
+% return S;
+%
+% intersection'(C1,C2)
+% B1 = boundingbox(C1);
+% B2 = boundingbox(C2);
+% if intersect(B1,B2)
+% if (B1.width < q) and (B1.height < q) and
+% (B2.width < q) and (B2.height < q)
+% S = S + {average_of_all_points(B1,B2)}; \\ is there a better choice?
+% else
+% Q = subdivideLeft(C1);
+% R = subdivideRight(C1);
+% intersection'(C2,Q);
+% intersection'(C2,R);
+%
+% where q is a small value (tolerance).
+%
+\def\pgfintersectionofcurves#1#2#3#4#5#6#7#8{%
+ \pgf@intersect@solutions=0\relax%
+ \pgf@intersectionofcurves%
+ {\pgf@process{#1}}{\pgf@process{#2}}{\pgf@process{#3}}{\pgf@process{#4}}%
+ {\pgf@process{#5}}{\pgf@process{#6}}{\pgf@process{#7}}{\pgf@process{#8}}%
+}%
+\def\pgf@intersectionofcurves#1#2#3#4#5#6#7#8{%
+ \begingroup%
+ \dimendef\pgf@time@a=2\relax%
+ \dimendef\pgf@time@aa=4\relax%
+ \dimendef\pgf@time@b=6\relax%
+ \dimendef\pgf@time@bb=8\relax%
+ \pgf@time@a=0pt\relax%
+ \pgf@time@aa=1pt\relax%
+ \pgf@time@b=0pt\relax%
+ \pgf@time@bb=1pt\relax%
+ \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b%
+ \let\pgf@curve@subdivde@after=\pgf@@intersectionofcurves%
+ \pgf@@intersectionofcurves{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
+ \endgroup%
+}
+
+\def\pgf@intersect@boundingbox@assign@a{%
+ \edef\pgf@intersect@boundingbox@a{%
+ % lower left:
+ \noexpand\pgf@xb=\the\pgf@xa\space%
+ \noexpand\pgf@yb=\the\pgf@ya\space%
+ % upper right:
+ \noexpand\pgf@xc=\the\pgf@xb\space%
+ \noexpand\pgf@yc=\the\pgf@yb\space%
+ }%
+}
+\def\pgf@intersect@boundingbox@assign@b{%
+ \edef\pgf@intersect@boundingbox@b{%
+ % lower left:
+ \noexpand\global\noexpand\pgf@x=\the\pgf@xa\space%
+ \noexpand\global\noexpand\pgf@y=\the\pgf@ya\space%
+ % upper right:
+ \noexpand\pgf@xa=\the\pgf@xb\space%
+ \noexpand\pgf@ya=\the\pgf@yb\space%
+ }%
+}
+
+% see \pgf@intersect@boundingbox@assign@a and \pgf@intersect@boundingbox@assign@b for the naming conventions
+\def\pgf@intersect@boundingbox@ifoverlap{%
+ \def\pgf@intersect@next{\pgfutil@secondoftwo}%
+ %
+ \ifdim\pgf@xa<\pgf@xb%
+ \else%
+ \ifdim\pgf@x>\pgf@xc%
+ \else%
+ \ifdim\pgf@ya<\pgf@yb%
+ \else%
+ \ifdim\pgf@y>\pgf@yc%
+ \else%
+ \def\pgf@intersect@next{\pgfutil@firstoftwo}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \pgf@intersect@next
+}%
+\def\pgf@intersect@boundingbox@ifoverlap@upperbound{%
+ \begingroup
+ \def\pgf@intersect@next{\pgfutil@secondoftwo}%
+ %
+ \advance\pgf@xa by+\pgfintersectiontolerance\relax
+ \ifdim\pgf@xa<\pgf@xb%
+ \else%
+ \global\advance\pgf@x by-\pgfintersectiontolerance\relax
+ \ifdim\pgf@x>\pgf@xc%
+ \else%
+ \advance\pgf@ya by\pgfintersectiontolerance\relax
+ \ifdim\pgf@ya<\pgf@yb%
+ \else%
+ \global\advance\pgf@y by-\pgfintersectiontolerance\relax
+ \ifdim\pgf@y>\pgf@yc%
+ \else%
+ \def\pgf@intersect@next{\pgfutil@firstoftwo}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \expandafter
+ \endgroup
+ \pgf@intersect@next
+}%
+\def\pgf@intersect@boundingbox@ifoverlap@UNUSED{%
+ \let\pgf@intersect@next=\pgfutil@secondoftwo%
+ \ifdim\pgf@xa<\pgf@xb%
+ \else%
+ \ifdim\pgf@x>\pgf@xc%
+ \else%
+ \ifdim\pgf@ya<\pgf@yb%
+ \else%
+ \ifdim\pgf@y>\pgf@yc%
+ \else%
+ \let\pgf@intersect@next=\pgfutil@firstoftwo%
+ \fi
+ \fi
+ \fi
+ \fi
+ \pgf@intersect@next
+}%
+\def\pgf@@intersectionofcurves#1#2#3#4#5#6#7#8{%
+ \pgf@intersect@boundingbox@reset%
+ \pgf@intersect@boundingbox@update{#1}%
+ \pgf@intersect@boundingbox@update{#2}%
+ \pgf@intersect@boundingbox@update{#3}%
+ \pgf@intersect@boundingbox@update{#4}%
+ \pgf@intersect@boundingbox@assign@b%
+ %
+ \pgf@intersect@boundingbox@reset%
+ \pgf@intersect@boundingbox@update{#5}%
+ \pgf@intersect@boundingbox@update{#6}%
+ \pgf@intersect@boundingbox@update{#7}%
+ \pgf@intersect@boundingbox@update{#8}%
+ \pgf@intersect@boundingbox@assign@a%
+ %
+ \pgf@intersect@boundingbox@a%
+ \pgf@intersect@boundingbox@b%
+ %
+ \pgf@intersect@boundingbox@ifoverlap{%
+ \pgf@@@intersectionofcurves{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
+ }{%
+ % no overlap -- no intersection.
+ }%
+}
+
+\def\pgf@@@intersectionofcurves#1#2#3#4#5#6#7#8{%
+ % compute DIFFERENCE vectors:
+ \advance\pgf@xc by-\pgf@xb%
+ \advance\pgf@yc by-\pgf@yb%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ \let\pgf@intersect@subdivde=\relax%
+ % check if both difference vectors are point wise
+ % less than tolerance (i.e. |v|_infty < eps ).
+ % That means that both bounding boxes are "small enough"
+ \ifdim\pgf@xc<\pgfintersectiontolerance\relax%
+ \ifdim\pgf@xa<\pgfintersectiontolerance\relax%
+ \ifdim\pgf@yc<\pgfintersectiontolerance\relax%
+ \ifdim\pgf@ya<\pgfintersectiontolerance\relax%
+ \pgfextract@process\pgf@intersect@solution@candidate{%
+ % set (x,y) = mean(the 4 points of the two bounding boxes):
+ \pgf@intersect@boundingbox@a%
+ \pgf@intersect@boundingbox@b%
+ \pgf@x=0.25\pgf@x%
+ \advance\pgf@x by0.25\pgf@xa%
+ \advance\pgf@x by0.25\pgf@xb%
+ \advance\pgf@x by0.25\pgf@xc%
+ \pgf@y=0.25\pgf@y%
+ \advance\pgf@y by0.25\pgf@ya%
+ \advance\pgf@y by0.25\pgf@yb%
+ \advance\pgf@y by0.25\pgf@yc%
+ }%
+ % We must avoid duplicate solutions.
+ \let\pgf@intersect@subdivde=\pgf@stop%
+ \pgf@ifsolution@duplicate\pgf@intersect@solution@candidate{}%
+ {%
+ \global\advance\pgf@intersect@solutions by1\relax%
+ \begingroup
+ \advance\pgf@time@a by\pgf@time@aa%
+ \divide\pgf@time@a by2\relax%
+ \advance\pgf@time@a by\pgf@intersect@time@offset pt\relax%
+ \edef\pgf@intersect@time@a{\pgfmath@tonumber{\pgf@time@a}}%
+ %
+ \advance\pgf@time@b by\pgf@time@bb%
+ \divide\pgf@time@b by2\relax%
+ \advance\pgf@time@b by\pgf@intersect@time@offset@b pt\relax%
+ \edef\pgf@intersect@time@b{\pgfmath@tonumber{\pgf@time@b}}%
+ %
+ \pgf@intersection@store@properties{pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions}%
+ \expandafter\global\expandafter\let%
+ \csname pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions\endcsname=%
+ \pgf@intersect@solution@candidate%
+ \ifpgf@intersect@sort%
+ \expandafter\xdef%
+ \csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname%
+ {\pgf@intersect@time@a}%
+ \fi%
+ \endgroup
+ }%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \ifx\pgf@intersect@subdivde\pgf@stop%
+ \else%
+ \pgf@intersect@subdivide@curve{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
+ \fi%
+}
+
+\def\pgf@intersect@subdivide@curve@b#1#2#3#4#5#6#7#8{%
+ \begingroup%
+ \advance\pgf@time@bb by\pgf@time@b\relax%
+ \divide\pgf@time@bb by2\relax%
+ \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@a%
+ \pgf@curve@subdivide@left{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}%
+ \endgroup%
+ \begingroup%
+ \advance\pgf@time@b by\pgf@time@bb\relax%
+ \divide\pgf@time@b by2\relax%
+ \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@a%
+ \pgf@curve@subdivide@right{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}%
+ \endgroup%
+}
+
+\def\pgf@intersect@subdivide@curve@a#1#2#3#4#5#6#7#8{%
+ \begingroup%
+ \advance\pgf@time@aa by\pgf@time@a\relax%
+ \divide\pgf@time@aa by2\relax%
+ \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b%
+ \pgf@curve@subdivide@left{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}%
+ \endgroup%
+ \begingroup%
+ \advance\pgf@time@a by\pgf@time@aa\relax%
+ \divide\pgf@time@a by2\relax%
+ \let\pgf@intersect@subdivide@curve=\pgf@intersect@subdivide@curve@b%
+ \pgf@curve@subdivide@right{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}%
+ \endgroup%
+}
+
+\def\pgf@intersect@boundingbox@reset{%
+ \pgf@xa=16000pt\relax%
+ \pgf@ya=16000pt\relax%
+ \pgf@xb=-16000pt\relax%
+ \pgf@yb=-16000pt\relax%
+}
+
+\def\pgf@intersect@boundingbox@update#1{%
+ #1\relax%
+ \ifdim\pgf@x<\pgf@xa\pgf@xa=\pgf@x\fi%
+ \ifdim\pgf@y<\pgf@ya\pgf@ya=\pgf@y\fi%
+ \ifdim\pgf@x>\pgf@xb\pgf@xb=\pgf@x\fi%
+ \ifdim\pgf@y>\pgf@yb\pgf@yb=\pgf@y\fi%
+}
+
+% The following subroutines are part of a conversion from pgfbasic
+% math to FPU. This transition is necessary due to the restricted
+% accuracy of pgfbasic. In order to limit the error rate of the
+% transition pgfbasic -> FPU, I chose to
+% keep the old "pattern" of sorts \advance\pgf@xa by0.5\pgf@y etc and
+% simply adapt to some FPU call.
+%
+% The following routines constitute the "adapter":
+
+\def\pgf@float@adapter@setxy{%
+ \pgfmathfloatparsenumber{\pgf@sys@tonumber\pgf@x}\let\pgf@fpu@x=\pgfmathresult
+ \pgfmathfloatparsenumber{\pgf@sys@tonumber\pgf@y}\let\pgf@fpu@y=\pgfmathresult
+}%
+\def\pgf@float@adapter@mult#1=#2*#3{%
+ \pgfmathfloatmultiplyfixed@{#3}{#2}%
+ \let#1=\pgfmathresult
+}%
+\def\pgf@float@adapter@advance#1by#2*#3{%
+ \pgfmathfloatmultiplyfixed@{#3}{#2}%
+ \let\pgfutil@temp=\pgfmathresult
+ \pgfmathfloatadd@{#1}{\pgfutil@temp}%
+ \let#1=\pgfmathresult
+}%
+
+\def\pgf@float@adapter@tostring#1{%
+ \pgfmathfloattofixed{#1}\edef#1{\pgfmathresult pt }%
+}%
+
+\def\pgf@curve@subdivide@left#1#2#3#4{%
+ %
+ % The left curve (from t=0 to t=.5)
+ %
+ \begingroup
+ #1\relax%
+ \pgfutil@tempdima=\pgf@x%
+ \pgfutil@tempdimb=\pgf@y%
+ \pgf@float@adapter@setxy
+ \pgf@float@adapter@mult\pgf@fpu@xa=.5*\pgf@fpu@x \pgf@float@adapter@mult\pgf@fpu@ya=.5*\pgf@fpu@y%
+ \pgf@float@adapter@mult\pgf@fpu@xb=.25*\pgf@fpu@x \pgf@float@adapter@mult\pgf@fpu@yb=.25*\pgf@fpu@y%
+ \pgf@float@adapter@mult\pgf@fpu@xc=.125*\pgf@fpu@x\pgf@float@adapter@mult\pgf@fpu@yc=.125*\pgf@fpu@y%
+ #2\relax%
+ \pgf@float@adapter@setxy
+ \pgf@float@adapter@advance\pgf@fpu@xa by.5*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@ya by.5*\pgf@fpu@y%
+ \pgf@float@adapter@advance\pgf@fpu@xb by.5*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yb by.5*\pgf@fpu@y%
+ \pgf@float@adapter@advance\pgf@fpu@xc by.375*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yc by.375*\pgf@fpu@y%
+ #3\relax%
+ \pgf@float@adapter@setxy
+ \pgf@float@adapter@advance\pgf@fpu@xb by.25*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yb by.25*\pgf@fpu@y%
+ \pgf@float@adapter@advance\pgf@fpu@xc by.375*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yc by.375*\pgf@fpu@y%
+ #4\relax%
+ \pgf@float@adapter@setxy
+ \pgf@float@adapter@advance\pgf@fpu@xc by.125*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yc by.125*\pgf@fpu@y%
+ %
+ \pgf@float@adapter@tostring\pgf@fpu@xa
+ \pgf@float@adapter@tostring\pgf@fpu@ya
+ \pgf@float@adapter@tostring\pgf@fpu@xb
+ \pgf@float@adapter@tostring\pgf@fpu@yb
+ \pgf@float@adapter@tostring\pgf@fpu@xc
+ \pgf@float@adapter@tostring\pgf@fpu@yc
+ \edef\pgf@marshal{%
+ \noexpand\pgf@curve@subdivde@after%
+ {\noexpand\pgf@x=\the\pgfutil@tempdima\noexpand\pgf@y=\the\pgfutil@tempdimb}%
+ {\noexpand\pgf@x=\pgf@fpu@xa\noexpand\pgf@y=\pgf@fpu@ya}%
+ {\noexpand\pgf@x=\pgf@fpu@xb\noexpand\pgf@y=\pgf@fpu@yb}
+ {\noexpand\pgf@x=\pgf@fpu@xc\noexpand\pgf@y=\pgf@fpu@yc}%
+ }%
+ \expandafter
+ \endgroup
+ \pgf@marshal%
+}
+
+\def\pgf@curve@subdivide@right#1#2#3#4{%
+ %
+ % The right curve (from t=0.5 to t=1)
+ %
+ \begingroup
+ #1\relax%
+ \pgf@float@adapter@setxy
+ \pgf@float@adapter@mult\pgf@float@tmpa=.125*\pgf@fpu@x\pgf@float@adapter@mult\pgf@float@tmpb=.125*\pgf@fpu@y%
+ #2\relax%
+ \pgf@float@adapter@setxy
+ \pgf@float@adapter@advance\pgf@float@tmpa by.375*\pgf@fpu@x\pgf@float@adapter@advance\pgf@float@tmpb by.375*\pgf@fpu@y%
+ \pgf@float@adapter@mult\pgf@fpu@xa=.25*\pgf@fpu@x\pgf@float@adapter@mult\pgf@fpu@ya=.25*\pgf@fpu@y%
+ #3\relax%
+ \pgf@float@adapter@setxy
+ \pgf@float@adapter@advance\pgf@float@tmpa by.375*\pgf@fpu@x\pgf@float@adapter@advance\pgf@float@tmpb by.375*\pgf@fpu@y%
+ \pgf@float@adapter@advance\pgf@fpu@xa by.5*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@ya by.5*\pgf@fpu@y%
+ \pgf@float@adapter@mult\pgf@fpu@xb=.5*\pgf@fpu@x\pgf@float@adapter@mult\pgf@fpu@yb=.5*\pgf@fpu@y%
+ #4\relax%
+ \pgf@float@adapter@setxy
+ \pgf@float@adapter@advance\pgf@float@tmpa by.125*\pgf@fpu@x\pgf@float@adapter@advance\pgf@float@tmpb by.125*\pgf@fpu@y%
+ \pgf@float@adapter@advance\pgf@fpu@xa by.25*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@ya by.25*\pgf@fpu@y%
+ \pgf@float@adapter@advance\pgf@fpu@xb by.5*\pgf@fpu@x\pgf@float@adapter@advance\pgf@fpu@yb by.5*\pgf@fpu@y%
+ \let\pgf@fpu@xc=\pgf@fpu@x\let\pgf@fpu@yc=\pgf@fpu@y%
+ %
+ \pgf@float@adapter@tostring\pgf@float@tmpa
+ \pgf@float@adapter@tostring\pgf@float@tmpb
+ \pgf@float@adapter@tostring\pgf@fpu@xa
+ \pgf@float@adapter@tostring\pgf@fpu@ya
+ \pgf@float@adapter@tostring\pgf@fpu@xb
+ \pgf@float@adapter@tostring\pgf@fpu@yb
+ \pgf@float@adapter@tostring\pgf@fpu@xc
+ \pgf@float@adapter@tostring\pgf@fpu@yc
+ \edef\pgf@marshal{%
+ \noexpand\pgf@curve@subdivde@after%
+ {\noexpand\pgf@x=\pgf@float@tmpa\noexpand\pgf@y=\pgf@float@tmpb}%
+ {\noexpand\pgf@x=\pgf@fpu@xa\noexpand\pgf@y=\pgf@fpu@ya}
+ {\noexpand\pgf@x=\pgf@fpu@xb\noexpand\pgf@y=\pgf@fpu@yb}
+ {\noexpand\pgf@x=\pgf@fpu@xc\noexpand\pgf@y=\pgf@fpu@yc}%
+ }%
+ \expandafter
+ \endgroup
+ \pgf@marshal%
+}
+
+
+% A solution S1 is considered a duplicate of S2, if
+%
+% |x1 - x2|f < q and |y1 - y2|f < q
+%
+% where q is a small value (tolerance).
+%
+% #1 - the solution.
+%
+\def\pgf@ifsolution@duplicate#1{%
+ #1%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \let\pgf@intersect@next=\pgfutil@secondoftwo%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter>\pgf@intersect@solutions\relax%
+ \else%
+ \pgf@ifsolution@duplicate@{\pgfmathcounter}%
+ \repeatpgfmathloop%
+ \pgf@intersect@next%
+}
+
+\def\pgf@ifsolution@duplicate@#1{%
+ \pgf@process{\csname pgfpoint@g@intersect@solution@#1\endcsname}%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \ifdim\pgf@x<0pt\relax\pgf@x=-\pgf@x\fi%
+ \ifdim\pgf@y<0pt\relax\pgf@y=-\pgf@y\fi%
+ %
+ \pgf@x=\pgfintersectiontolerancefactor\pgf@x%
+ \pgf@y=\pgfintersectiontolerancefactor\pgf@y%
+ \ifdim\pgf@x<\pgfintersectiontolerance\relax%
+ \ifdim\pgf@y<\pgfintersectiontolerance\relax%
+ \let\pgf@intersect@next=\pgfutil@firstoftwo%
+ \fi%
+ \fi%
+}%
+
+\newif\ifpgf@intersect@solutions@sortfinish
+
+% Sort solutions according to their time index.
+%
+\def\pgfintersectionsolutionsortbytime{%
+ \pgf@intersect@solutions@sortfinishtrue%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter<\pgfintersectionsolutions\relax%
+ \pgfutil@tempcnta=\pgfmathcounter%
+ \advance\pgfutil@tempcnta by1\relax%
+ \ifdim\csname pgf@intersect@solution@\pgfmathcounter @time@a\endcsname pt>%
+ \csname pgf@intersect@solution@\the\pgfutil@tempcnta @time@a\endcsname pt\relax%
+ \pgf@intersect@solutions@sortfinishfalse%
+ %
+ \pgfintersectionsolutionsortbytime@swap{pgfpoint@intersect@solution@\pgfmathcounter}%
+ {pgfpoint@intersect@solution@\the\pgfutil@tempcnta}%
+ %
+ \pgfintersectionsolutionsortbytime@swap{pgf@intersect@solution@\pgfmathcounter @time@a}%
+ {pgf@intersect@solution@\the\pgfutil@tempcnta @time@a}%
+ %
+ \pgfintersectionsolutionsortbytime@swap{pgf@intersect@solution@props@\pgfmathcounter}%
+ {pgf@intersect@solution@props@\the\pgfutil@tempcnta}%
+ \fi%
+ \repeatpgfmathloop%
+ \ifpgf@intersect@solutions@sortfinish%
+ \else%
+ \expandafter\pgfintersectionsolutionsortbytime%
+ \fi%
+}
+
+\def\pgfintersectionsolutionsortbytime@swap#1#2{%
+ \pgfutil@namelet{pgf@intersect@temp}{#1}%
+ \pgfutil@namelet{#1}{#2}%
+ \pgfutil@namelet{#2}{pgf@intersect@temp}%
+}%
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryluamath.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryluamath.code.tex
new file mode 100644
index 0000000000..fe86ba6f4a
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryluamath.code.tex
@@ -0,0 +1,559 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Mi 8. Feb 20:49:06 CET 2017 %%%
+
+
+
+% Copyright 2011 by Christophe Jorssen and Mark Wibrow
+% Copyright 2014 by 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.
+%
+% $Id: pgflibraryluamath.code.tex,v 1.20 2015/06/05 06:23:21 cfeuersaenger Exp $
+%
+%
+% This is a library for a LUA math parser and LUA math operations.
+% Advantage compared to its TeX pendant: it is FASTER and has HIGHER
+% ACCURACY.
+% Disadvantage: any function declared by means of
+% \pgfmathdeclarefunction is NOT automatically transported to the LUA
+% side (at the time of this writing).
+% LUA functions need to be defined by means of LUA code
+%
+% function pgfluamathfunctions.myoperation(a,b)
+% return a*2*b
+% end
+%
+% this will automatically set up 'myoperation' for use in
+% \pgfluamathparse{myoperation(4,2)}
+%
+% The library has TWO use-cases which are more or less distinct: one
+% is to use LUA for all math function, but not for math expression
+% parsing -- this was still under control of the TeX math parser.
+% This approach works like the 'fpu' library.
+%
+% The second approach is to use LUA to parse all math expressions -
+% but if someone calls \pgfmathadd@{1}{2}, it would use the TeX
+% command. This approach is relatively lightweight because it does not
+% need to substitute all \pgfmath* macros.
+%
+% One can mix both modes.
+
+% *******************************************************************
+% Some luatex stuff. Should be put elsewhere (e.g. in
+% pgfutil-luatex-engine).
+
+\edef\pgfliblua@oldcatcodedoublequote{\the\catcode`\"}%
+\catcode`\"=12
+
+% We assume luatex version > 0.39:
+% - \directlua <general text> will work
+% - \directlua is the only luatex primitive that we can assume
+% accessible without being prefixed by the format via
+% tex.enableprimitives.
+% Ideas taken from the ifluatex package (Heiko Oberdiek)
+\let\pgfutil@ifluatex\iffalse
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax
+\else
+ \expandafter\let\csname pgfutil@ifluatex\expandafter\endcsname
+ \csname iftrue\endcsname
+\fi
+
+\pgfutil@ifluatex
+ \let\pgfutil@directlua\directlua
+ \pgfutil@directlua{%
+ tex.enableprimitives('pgfutil@',{'luaescapestring'})}
+\else
+ \def\pgfutil@directlua#1{}
+ \def\pgfutil@luaescapestring#1{}
+\fi
+
+\pgfutil@directlua{%
+ pgfluamathfunctions = require("pgfplotsoldpgfsupp.luamath.functions")
+ pgfluamathparser = require("pgfplotsoldpgfsupp.luamath.parser")}
+
+
+% Patch some configuration macros such that the modifications are
+% available in LUA as well:
+\pgfkeys{
+ /pgf/trig format/deg/.add code={}{\directlua{pgfluamathfunctions.setTrigFormat("deg")}\aftergroup\pgfmath@settrigformat},
+ /pgf/trig format/rad/.add code={}{\directlua{pgfluamathfunctions.setTrigFormat("rad")}\aftergroup\pgfmath@settrigformat},
+}
+% ... and reactivate the key:
+\pgfmathiftrigonometricusesdeg{%
+ \pgfkeys{/pgf/trig format/deg}%
+}{%
+ \pgfkeys{/pgf/trig format/rad}%
+}%
+
+% re-activates the current trig format. This is important after a TeX
+% group has been closed.
+\def\pgfmath@settrigformat{%
+ \pgfmathiftrigonometricusesdeg{%
+ \directlua{pgfluamathfunctions.setTrigFormat("deg")}%
+ }{%
+ \directlua{pgfluamathfunctions.setTrigFormat("rad")}%
+ }%
+}%
+
+\let\pgfmathsetseed@pgfbasic = \pgfmathsetseed
+\def\pgfmathsetseed#1{%
+ \pgfmathsetseed@pgfbasic{#1}%
+ \directlua{pgfluamathfunctions.setRandomSeed(pgfluamathfunctions.tonumber("\pgfmathresult"))}%
+}%
+
+% Patch 'declare function' such that it communicates the function
+% directly to LUA.
+\let\pgfmathnotifynewdeclarefunction@orig=\pgfmathnotifynewdeclarefunction
+\def\pgfmathnotifynewdeclarefunction#1#2#3{%
+ \pgfmathnotifynewdeclarefunction@orig{#1}{#2}{#3}%
+ %
+ % we have to check if '#3' contains control sequences.
+ % this is highly tricky as it may contain '#1'...
+ \begingroup
+ \toks0={#3}%
+ \xdef\pgf@marshal@glob{\the\toks0 }%
+ \endgroup
+ \pgfutil@command@to@string\pgf@marshal@glob\pgf@marshal
+ \expandafter\pgfutilifcontainsmacro\expandafter{\pgf@marshal}{%
+ \def\pgf@temp{1}%
+ }{%
+ \def\pgf@temp{0}%
+ }%
+ \if1\pgf@temp
+ % let lua produce an error when evaluating this function -- we cannot possibly expand the macro to its current state:
+ \directlua{pgfluamathparser.pushLocalExpressionFunction(%
+ "\pgfutil@luaescapestring{#1}",%
+ #2,%
+ "functionMustBeEvaluatedInTeX")}%
+ \else
+ \directlua{pgfluamathparser.pushLocalExpressionFunction(%
+ "\pgfutil@luaescapestring{#1}",%
+ #2,%
+ "\pgfutil@luaescapestring{#3}")}%
+ \fi
+ %
+ % ensure that the local function is removed at the end of the
+ % scope. To this end, we maintain a stack on the LUA side.
+ \aftergroup\pgfluamathparse@pop@local@function
+}%
+
+\def\pgfluamathparse@pop@local@function{%
+ \directlua{pgfluamathparser.popLocalExpressionFunction()}%
+}%
+
+% End of luatex stuff
+% *******************************************************************
+
+% Loading part: based on fpu library
+
+
+% if LUA failed to evaluate the expression, it will be evaluated in
+% TeX as fallback. This boolean defines if the error message shall be
+% shown or suppressed. The default is to suppress it and show any
+% resulting TeX errors.
+%
+% If LUA fails \pgfmathresult will be empty.
+%
+% This is actually only for debugging; it will be set implicitly when
+% activating/deactivating TeX fallback.
+\newif\ifpgfluamathshowerrormessage
+
+% Defines what happens if LUA failed to evaluate the expression: if
+% this is true, the TeX parser will be invoked as fallback.
+%
+% This happens
+% - for \chardef'ed boxes for which LUA lacks evaluation capabilities
+% - if the expression includes some function which is unavailable in
+% LUA (defined only in TeX)
+% - some special cases which simply haven't been added to the LUA
+% parser (yet).
+% At the time of this writing, this includes
+% -- arrays created via '{}' and indexed with '[]'
+% -- strings with "<str>"
+% -- 'scalar' function
+% -- hex/octal/binary input
+\newif\ifpgfluamathenableTeXfallback
+
+\newif\ifpgfluamathcomputationactive
+\newif\ifpgfluamathparseractive
+
+\def\pgfluamath@makecomputationactive{%
+ \ifpgfluamathcomputationactive
+ \else
+ \pgfluamath@checkuninstallcmd%
+ \pgfluamath@install%
+ \pgfluamathcomputationactivetrue
+ \fi}
+
+\def\pgfluamath@makecomputationinactive{%
+ \ifpgfluamathcomputationactive
+ \pgfluamath@uninstall%
+ \pgfluamathcomputationactivefalse
+ \fi}
+
+\let\pgfluamath@pgfmathparse\pgfmathparse
+\def\pgfluamath@makeparseractive{%
+ \ifpgfluamathparseractive
+ \else
+ \let\pgfluamath@pgfmathparse\pgfmathparse
+ \let\pgfmathparse\pgfluamathparse
+ \pgfluamathparseractivetrue
+ \fi}
+
+\def\pgfluamath@makeparserinactive{%
+ \ifpgfluamathparseractive
+ \let\pgfmathparse\pgfluamath@pgfmathparse
+ \pgfluamathparseractivefalse
+ \fi}
+
+\pgfqkeys{/pgf}{%
+ % Enable lua-side computation of \pgfmathresult
+ % (will be deactivated after the current TeX group)
+ luamath/.is choice,
+ luamath/only computation/.code={%
+ \pgfutil@ifluatex
+ \pgfluamath@makecomputationactive
+ \pgfluamath@makeparserinactive
+ \else
+ \pgfmath@error{Sorry, you need the luaTeX engine to use the
+ luamath library}%
+ \fi},
+ luamath/parser and computation/.code={%
+ \pgfutil@ifluatex
+ \pgfluamath@makecomputationactive
+ \pgfluamath@makeparseractive
+ \else
+ \pgfmath@error{Sorry, you need the luaTeX engine to use the
+ luamath library}%
+ \fi},
+ luamath/off/.code={%
+ \pgfluamath@makecomputationinactive
+ \pgfluamath@makeparserinactive},
+ luamath/.default=only computation,
+ %
+ % activates ONLY the parser. This is fast and does not replace the
+ % \pgfmath* functions.
+ % @see |parser and computation| which also allows to write
+ % \pgfmathadd{1}{2} to call LUA
+ luamath/parser/.code={%
+ \pgfutil@ifluatex
+ \pgfluamath@makeparseractive
+ \else
+ \pgfmath@error{Sorry, you need the luaTeX engine to use the
+ luamath library}%
+ \fi
+ },
+ luamath/output format/.is choice,
+ luamath/output format/fixed/.code= {\def\pgfluamath@outputformat@choice{0}},
+ % returns results for use in the FPU
+ luamath/output format/float/.code= {\def\pgfluamath@outputformat@choice{1}},
+ luamath/output format/fixed,
+ % this is merely useful for debugging purposes, I guess.
+ luamath/show error message/.is if=pgfluamathshowerrormessage,
+ luamath/enable TeX fallback/.is choice,
+ luamath/enable TeX fallback/true/.code={\pgfluamathenableTeXfallbacktrue\pgfluamathshowerrormessagefalse},
+ luamath/enable TeX fallback/false/.code={\pgfluamathenableTeXfallbackfalse\pgfluamathshowerrormessagetrue},
+ luamath/enable TeX fallback/.default=true,
+ luamath/enable TeX fallback=true,
+}
+
+\def\pgfluamath@uninstall@appendcmd#1{%
+ \expandafter\gdef\expandafter\pgfluamath@uninstall\expandafter{%
+ \pgfluamath@uninstall #1}}
+
+% If the uninstall command is already assembled, it will skip the
+% uninstall assemblation.
+\def\pgfluamath@checkuninstallcmd{%
+ \pgfutil@ifundefined{pgfluamath@uninstall}{%
+ \global\let\pgfluamath@uninstall=\pgfutil@empty
+ }{%
+ % We already HAVE an uninstall command (prepared globally).
+ % So: don't waste time assembling one!
+ \def\pgfluamath@uninstall@appendcmd##1{}%
+ \def\pgfluamath@prepareuninstallcmd##1{}%
+ }%
+}
+
+% This assembles an uninstall command globally ON FIRST USAGE.
+% See \pgfmathfloat@plots@checkuninstallcmd
+\def\pgfluamath@prepareuninstallcmd#1{%
+ \expandafter\global\expandafter\let
+ \csname pgfluamath@backup@\string#1\endcsname=#1%
+ \expandafter\gdef\expandafter\pgfluamath@uninstall\expandafter{%
+ \pgfluamath@uninstall
+ \expandafter\let\expandafter#1\csname pgfluamath@backup@\string#1\endcsname}%
+}
+
+\def\pgfluamath@install@function#1=#2{%
+ \pgfluamath@prepareuninstallcmd{#1}%
+ \let#1=#2%
+}
+
+\def\pgfluamath@install{%
+ \pgfluamath@install@function\pgfmathadd@=\pgfluamathadd@%
+ \pgfluamath@install@function\pgfmathsubtract@=\pgfluamathsubtract@%
+ \pgfluamath@install@function\pgfmathneg@=\pgfluamathneg@%
+ \pgfluamath@install@function\pgfmathmultiply@=\pgfluamathmultiply@%
+ \pgfluamath@install@function\pgfmathdivide@=\pgfluamathdivide@%
+ % \pgfluamath@install@function\pgfmathdiv@=\pgfluamathdiv@%
+ \pgfluamath@install@function\pgfmathfactorial@=\pgfluamathfactorial@%
+ \pgfluamath@install@function\pgfmathsqrt@=\pgfluamathsqrt@%
+ % \pgfluamath@install@function\pgfmathpow@=\pgfluamathpow@%
+ \pgfluamath@install@function\pgfmathe@=\pgfluamathe@%
+ \pgfluamath@install@function\pgfmathexp@=\pgfluamathexp@%
+ \pgfluamath@install@function\pgfmathln@=\pgfluamathln@%
+ \pgfluamath@install@function\pgfmathlogten@=\pgfluamathlogten@%
+ % \pgfluamath@install@function\pgfmathlogtwo@=\pgfluamathlogtwo@%
+ \pgfluamath@install@function\pgfmathabs@=\pgfluamathabs@%
+ \pgfluamath@install@function\pgfmathmod@=\pgfluamathmod@%
+ \pgfluamath@install@function\pgfmathMod@=\pgfluamathMod@%
+ \pgfluamath@install@function\pgfmathround@=\pgfluamathround@%
+ \pgfluamath@install@function\pgfmathfloor@=\pgfluamathfloor@%
+ \pgfluamath@install@function\pgfmathceil@=\pgfluamathceil@%
+ % \pgfluamath@install@function\pgfmathint@=\pgfluamathint@%
+ % \pgfluamath@install@function\pgfmathfrac@=\pgfluamathfrac@%
+ % \pgfluamath@install@function\pgfmathreal@=\pgfluamathreal@%
+ \pgfluamath@install@function\pgfmathgcd@=\pgfluamathgcd@%
+ \pgfluamath@install@function\pgfmathisprime@=\pgfluamathisprime@%
+ \pgfluamath@install@function\pgfmathpi@=\pgfluamathpi@%
+ \pgfluamath@install@function\pgfmathrad@=\pgfluamathrad@%
+ \pgfluamath@install@function\pgfmathdeg@=\pgfluamathdeg@%
+ \pgfluamath@install@function\pgfmathsin@=\pgfluamathsin@%
+ \pgfluamath@install@function\pgfmathcos@=\pgfluamathcos@%
+ \pgfluamath@install@function\pgfmathtan@=\pgfluamathtan@%
+ \pgfluamath@install@function\pgfmathsec@=\pgfluamathsec@%
+ \pgfluamath@install@function\pgfmathcosec@=\pgfluamathcosec@%
+ \pgfluamath@install@function\pgfmathcot@=\pgfluamathcot@%
+ \pgfluamath@install@function\pgfmathasin@=\pgfluamathasin@%
+ \pgfluamath@install@function\pgfmathacos@=\pgfluamathacos@%
+ \pgfluamath@install@function\pgfmathatan@=\pgfluamathatan@%
+ \pgfluamath@install@function\pgfmathatantwo@=\pgfluamathatantwo@%
+ \pgfluamath@install@function\pgfmathmax@=\pgfluamathmax@%
+ \pgfluamath@install@function\pgfmathmin@=\pgfluamathmin@%
+ % \pgfluamath@install@function\pgfmath@pi=\pgfluamathpi@%
+ % \pgfluamath@install@function\pgfmathpi=\pgfluamathpi@%
+ % \pgfluamath@install@function\pgfmathe@=\pgfluamathe@%
+ % \pgfluamath@install@function\pgfmathe=\pgfluamathe@%
+ % \pgfluamath@install@function\pgfmathlessthan@=\pgfluamathlessthan@%
+ % \pgfluamath@install@function\pgfmathless@=\pgfluamathlessthan@%
+ % \pgfluamath@install@function\pgfmathgreaterthan@=\pgfluamathgreaterthan@%
+ % \pgfluamath@install@function\pgfmathgreater@=\pgfluamathgreaterthan@%
+ % \pgfluamath@install@function\pgfmathpow@=\pgfluamathpow@
+ \pgfluamath@install@function\pgfmathrand@=\pgfluamathrand@
+ \pgfluamath@install@function\pgfmathrand=\pgfluamathrand@
+ \pgfluamath@install@function\pgfmathrnd@=\pgfluamathrnd@
+ \pgfluamath@install@function\pgfmathrnd=\pgfluamathrnd@
+ % \pgfluamath@install@function\pgfmathtrue@=\pgfluamathtrue@
+ % \pgfluamath@install@function\pgfmathfalse@=\pgfluamathfalse@
+ % \pgfluamath@install@function\pgfmathnot@=\pgfluamathnot@
+ % \pgfluamath@install@function\pgfmathhex@=\pgfluamathhex@
+ % \pgfluamath@install@function\pgfmathHex@=\pgfluamathHex@
+ % \pgfluamath@install@function\pgfmathoct@=\pgfluamathoct@
+ % \pgfluamath@install@function\pgfmathbin@=\pgfluamathbin@
+ % \pgfluamath@install@function\pgfmathand@=\pgfluamathand@
+ % \pgfluamath@install@function\pgfmathor@=\pgfluamathor@
+ % \pgfluamath@install@function\pgfmathfactorial@=\pgfluamathfactorial@
+ % \pgfluamath@install@function\pgfmathveclen@=\pgfluamathveclen@
+ % \pgfluamath@install@function\pgfmathcosh@=\pgfluamathcosh@
+ % \pgfluamath@install@function\pgfmathsinh@=\pgfluamathsinh@
+ % \pgfluamath@install@function\pgfmathtanh@=\pgfluamathtanh@
+ % \pgfluamath@install@function@unimplemented{ceil}%
+ % \pgfluamath@install@function@unimplemented{frac}%
+ % \pgfluamath@install@function@unimplemented{log2}%
+ % \pgfluamath@install@function@unimplemented{log10}%
+ % \pgfluamath@install@function@unimplemented{equalto}%
+ % \pgfluamath@install@function@unimplemented{random}%
+ % \pgfluamath@install@function@unimplemented{setseed}%
+ % \pgfluamath@install@function@unimplemented{Mod}%
+ % \pgfluamath@install@function@unimplemented{real}%
+ % \pgfluamath@install@function@unimplemented{notequal}%
+ \pgfluamath@install@function\pgfmathreciprocal=\pgfluamathreciprocal%
+ \pgfluamath@install@function\pgfpointnormalised=\pgfluamathpointnormalised
+}
+
+\def\pgfluamathgetresult#1{%
+ \edef\pgfmathresult{\pgfutil@directlua{tex.print(-1,#1)}}}
+
+\def\pgfluamathpi@{%
+ \pgfluamathgetresult{pgfluamathfunctions.pi()}}
+\def\pgfluamathe@{%
+ \pgfluamathgetresult{pgfluamathfunctions.e()}}
+\def\pgfluamathadd@#1#2{%
+ \pgfluamathgetresult{pgfluamathfunctions.add(#1,#2)}}
+\def\pgfluamathsubtract@#1#2{%
+ \pgfluamathgetresult{pgfluamathfunctions.substract(#1,#2)}}
+\def\pgfluamathneg@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.neg(#1)}}
+\def\pgfluamathmultiply@#1#2{%
+ \pgfluamathgetresult{pgfluamathfunctions.multiply(#1,#2)}}
+\def\pgfluamathdivide@#1#2{%
+ \pgfluamathgetresult{pgfluamathfunctions.divide(#1,#2)}}
+\def\pgfluamathabs@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.abs(#1)}}
+\def\pgfluamathround@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.round(#1)}}
+\def\pgfluamathfloor@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.floor(#1)}}
+\def\pgfluamathceil@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.ceil(#1)}}
+\def\pgfluamathgcd@#1#2{%
+ \pgfluamathgetresult{pgfluamathfunctions.gcd(#1,#2)}}
+\def\pgfluamathisprime@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.isprime(#1)}}
+\def\pgfluamathmax@#1{%
+ \pgfluamathgetresult{%
+ math.max(pgfluamathfunctions.split_braces_to_explist("#1"))}}
+\def\pgfluamathmin@#1{%
+ \pgfluamathgetresult{%
+ math.min(pgfluamathfunctions.split_braces_to_explist("#1"))}}
+\def\pgfluamathsin@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.Sin(#1)}}
+\def\pgfluamathcos@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.Cos(#1)}}
+\def\pgfluamathtan@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.Tan(#1)}}
+\def\pgfluamathmod@#1#2{%
+ \pgfluamathgetresult{pgfluamathfunctions.mod(#1,#2)}}
+\def\pgfluamathMod@#1#2{%
+ \pgfluamathgetresult{pgfluamathfunctions.Mod(#1,#2)}}
+\def\pgfluamathrad@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.rad(#1)}}
+\def\pgfluamathdeg@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.deg(#1)}}
+\def\pgfluamathatan@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.aTan(#1)}}
+\def\pgfluamathatantwo@#1#2{%
+ \pgfluamathgetresult{pgfluamathfunctions.aTan2(#1,#2)}}
+\def\pgfluamathasin@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.aSin(#1)}}
+\def\pgfluamathacos@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.aCos(#1)}}
+\def\pgfluamathcot@#1{%
+ \pgfluamathgetresult{1/pgfluamathfunctions.Tan(#1)}}
+\def\pgfluamathsec@#1{%
+ \pgfluamathgetresult{1/pgfluamathfunctions.Cos(#1)}}
+\def\pgfluamathcosec@#1{%
+ \pgfluamathgetresult{1/pgfluamathfunctions.Sin(#1)}}
+\def\pgfluamathexp@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.exp(#1)}}
+\def\pgfluamathln@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.log(#1)}}
+\def\pgfluamathlogten@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.log10(#1)}}
+\def\pgfluamathsqrt@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.sqrt(#1)}}
+\def\pgfluamathrnd@{%
+ \pgfluamathgetresult{pgfluamathfunctions.rnd()}}
+\def\pgfluamathrand@{%
+ \pgfluamathgetresult{pgfluamathfunctions.rand(-1,1)}}
+\def\pgfluamathfactorial@#1{%
+ \pgfluamathgetresult{pgfluamathfunctions.factorial(#1)}}
+\def\pgfluamathreciprocal#1{%
+ \pgfluamathgetresult{1/#1}}
+% \pgfluamath@install@function\pgfmath@pi=\pgfluamathpi@%
+% \pgfluamath@install@function\pgfmathpi=\pgfluamathpi@%
+% \pgfluamath@install@function\pgfmathe@=\pgfluamathe@%
+% \pgfluamath@install@function\pgfmathe=\pgfluamathe@%
+% \pgfluamath@install@function\pgfmathlessthan@=\pgfluamathlessthan@%
+% \pgfluamath@install@function\pgfmathless@=\pgfluamathlessthan@%
+% \pgfluamath@install@function\pgfmathgreaterthan@=\pgfluamathgreaterthan@%
+% \pgfluamath@install@function\pgfmathgreater@=\pgfluamathgreaterthan@%
+% \pgfluamath@install@function\pgfmathpow@=\pgfluamathpow@
+% \pgfluamath@install@function\pgfmathrand@=\pgfluamathrand@
+% \pgfluamath@install@function\pgfmathrand=\pgfluamathrand@
+% \pgfluamath@install@function\pgfmathrnd@=\pgfluamathrnd@
+% \pgfluamath@install@function\pgfmathrnd=\pgfluamathrnd@
+% \pgfluamath@install@function\pgfmathtrue@=\pgfluamathtrue@
+% \pgfluamath@install@function\pgfmathfalse@=\pgfluamathfalse@
+% \pgfluamath@install@function\pgfmathnot@=\pgfluamathnot@
+% \pgfluamath@install@function\pgfmathhex@=\pgfluamathhex@
+% \pgfluamath@install@function\pgfmathHex@=\pgfluamathHex@
+% \pgfluamath@install@function\pgfmathoct@=\pgfluamathoct@
+% \pgfluamath@install@function\pgfmathbin@=\pgfluamathbin@
+% \pgfluamath@install@function\pgfmathand@=\pgfluamathand@
+% \pgfluamath@install@function\pgfmathor@=\pgfluamathor@
+% \pgfluamath@install@function\pgfmathfactorial@=\pgfluamathfactorial@
+% \pgfluamath@install@function\pgfmathveclen@=\pgfluamathveclen@
+% \pgfluamath@install@function\pgfmathcosh@=\pgfluamathcosh@
+% \pgfluamath@install@function\pgfmathsinh@=\pgfluamathsinh@
+% \pgfluamath@install@function\pgfmathtanh@=\pgfluamathtanh@
+
+\def\pgfluamathpointnormalised#1{%
+ \pgf@process{#1}%
+ \pgfutil@directlua{%
+ pgfluamathfunctions.pointnormalised(%
+ \pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})}%
+ \ignorespaces}
+
+% Parser
+
+\newif\ifpgfluamathunitsdeclared
+
+% true if and only if LUA failed to evaluate the expression and the
+% expression was evaluated by means of the TeX parser as fallback.
+%
+% This happens
+% - for \chardef'ed boxes for which LUA lacks evaluation capabilities
+% - if the expression includes some function which is unavailable in
+% LUA (defined only in TeX)
+% - some special cases which simply haven't been added to the LUA
+% parser (yet).
+% At the time of this writing, this includes
+% -- arrays created via '{}' and indexed with '[]'
+% -- strings with "<str>"
+% -- 'scalar' function
+% -- hex/octal/binary input
+\newif\ifpgfluamathusedTeXfallback
+
+% Parses the math expression and defines \pgfmathresult and
+% \ifpgfmathunitsdeclared to contain the result.
+%
+% If \ifpgfluamathparseractive then the result is also assigned to
+% \pgfmathresult. Furthermore, if the expression cannot be evaluated (because LUA does not support
+% it), it will be evaluated by mean of TeX as fallback.
+%
+% @see \ifpgfluamathusedTeXfallback
+% @see \ifpgfluamathshowerrormessage
+\def\pgfluamathparse#1{%
+ \pgfluamathusedTeXfallbackfalse
+ \pgfutil@directlua{pgfluamathparser.texCallParser(
+ "\pgfutil@luaescapestring{#1}",
+ \pgfluamath@outputformat@choice,
+ \ifpgfluamathshowerrormessage true\else false\fi)%
+ }%
+ \ifx\pgfmathresult\pgfutil@empty
+ \ifpgfluamathenableTeXfallback
+ \pgfluamathusedTeXfallbacktrue
+ \pgfluamath@pgfmathparse{#1}%
+ \fi
+ \fi
+}
+
+\catcode`\"=\pgfliblua@oldcatcodedoublequote
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex
new file mode 100644
index 0000000000..aa3c0e8f36
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex
@@ -0,0 +1,1141 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%%
+
+
+
+% Copyright 2006 by Till Tantau
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryplothandlers.code.tex,v 1.17 2012/09/11 20:03:46 ludewich Exp $
+
+\newif\ifpgf@plot@started
+
+
+% This handler converts each plot stream command into a curveto
+% command, except for the first, which is converted to the previously
+% specified action.
+%
+% Example:
+%
+% \pgfpathmoveto{\pgfpointorigin}
+% \pgfsetlinetofirstplotpoint
+% \pgfplothandlercurveto
+% \pgfplotxyfile{mytable}
+
+\def\pgfplothandlercurveto{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@initial%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgf@plot@curveto@handler@finish%
+ \global\pgf@plot@startedfalse%
+ }%
+}
+
+\def\pgf@plot@curveto@handler@initial#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@plot@first@action{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
+ \xdef\pgf@plot@curveto@first{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
+ \global\let\pgf@plot@curveto@first@support=\pgf@plot@curveto@first%
+ \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@second%
+}
+
+\def\pgf@plot@curveto@handler@second#1{%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@curveto@second{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@curveto@handler@third%
+ \global\pgf@plot@startedtrue%
+}
+
+\def\pgf@plot@curveto@handler@third#1{%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@curveto@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ % compute difference vector:
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgf@plot@curveto@first}
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ % compute support directions:
+ \pgf@xa=\pgf@plottension\pgf@xa%
+ \pgf@ya=\pgf@plottension\pgf@ya%
+ % first marshal:
+ \pgf@process{\pgf@plot@curveto@second}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \advance\pgf@xb by-\pgf@xa%
+ \advance\pgf@yb by-\pgf@ya%
+ \advance\pgf@xc by\pgf@xa%
+ \advance\pgf@yc by\pgf@ya%
+ \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@curveto@first@support}%
+ {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@curveto@second}}%
+ {\pgf@marshal}%
+ % Prepare next:
+ \global\let\pgf@plot@curveto@first=\pgf@plot@curveto@second%
+ \global\let\pgf@plot@curveto@second=\pgf@plot@curveto@current%
+ \xdef\pgf@plot@curveto@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
+}
+
+\def\pgf@plot@curveto@handler@finish{%
+ \ifpgf@plot@started%
+ \pgfpathcurveto{\pgf@plot@curveto@first@support}{\pgf@plot@curveto@second}{\pgf@plot@curveto@second}%
+ \fi%
+}
+
+
+% This commands sets the tension for smoothing of plots.
+%
+% #1 = tension of curves. A value of 1 will yield a circle when the
+% control points are at quarters of a circle. A smaller value
+% will result in a tighter curve. Default is 0.5.
+%
+% Example:
+%
+% \pgfsetplottension{0.2}
+
+\def\pgfsetplottension#1{%
+ \pgf@x=#1pt\relax%
+ \pgf@x=0.2775\pgf@x\relax%
+ \edef\pgf@plottension{\pgf@sys@tonumber\pgf@x}}
+\pgfsetplottension{0.5}
+
+
+% This handler converts the plot stream command into a curveto
+% command that is closed using a closepath.
+%
+% Example:
+%
+% \pgfpathmoveto{\pgfpointorigin}
+% \pgfplothandlerclosedcurve
+% \pgfplotxyfile{mytable}
+
+\def\pgfplothandlerclosedcurve{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@initial%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgf@plot@closedcurve@handler@finish%
+ }%
+}
+
+\def\pgf@plot@closedcurve@handler@initial#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \xdef\pgf@plot@closedcurve@initial{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@second%
+ \global\pgf@plot@startedfalse%
+}
+
+\def\pgf@plot@closedcurve@handler@second#1{%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@closedcurve@after@initial{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ {\pgfpathmoveto{}}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@third%
+}
+
+\def\pgf@plot@closedcurve@handler@third#1{%
+ \global\pgf@plot@startedtrue%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@closedcurve@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ % compute difference vector:
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgf@plot@closedcurve@initial}
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ % compute support directions:
+ \pgf@xa=\pgf@plottension\pgf@xa%
+ \pgf@ya=\pgf@plottension\pgf@ya%
+ % first marshal:
+ \pgf@process{\pgf@plot@closedcurve@after@initial}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \advance\pgf@xb by-\pgf@xa%
+ \advance\pgf@yb by-\pgf@ya%
+ \advance\pgf@xc by\pgf@xa%
+ \advance\pgf@yc by\pgf@ya%
+ \global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@after@initial%
+ \global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current%
+ \xdef\pgf@plot@closedcurve@after@initial@presupport{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}%
+ \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@closedcurve@handler@fourth%
+}
+
+\def\pgf@plot@closedcurve@handler@fourth#1{%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@closedcurve@current{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ % compute difference vector:
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgf@plot@closedcurve@first}
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ % compute support directions:
+ \pgf@xa=\pgf@plottension\pgf@xa%
+ \pgf@ya=\pgf@plottension\pgf@ya%
+ % first marshal:
+ \pgf@process{\pgf@plot@closedcurve@second}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \advance\pgf@xb by-\pgf@xa%
+ \advance\pgf@yb by-\pgf@ya%
+ \advance\pgf@xc by\pgf@xa%
+ \advance\pgf@yc by\pgf@ya%
+ \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
+ {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}%
+ {\pgf@marshal}%
+ % Prepare next:
+ \global\let\pgf@plot@closedcurve@first=\pgf@plot@closedcurve@second%
+ \global\let\pgf@plot@closedcurve@second=\pgf@plot@closedcurve@current%
+ \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
+}
+
+\def\pgf@plot@closedcurve@handler@finish{%
+ \ifpgf@plot@started
+ %
+ % first, draw line from 2nd last to last:
+ %
+ \pgf@process{\pgf@plot@closedcurve@initial}%
+ % compute difference vector:
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgf@plot@closedcurve@first}%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ % compute support directions:
+ \pgf@xa=\pgf@plottension\pgf@xa%
+ \pgf@ya=\pgf@plottension\pgf@ya%
+ % first marshal:
+ \pgf@process{\pgf@plot@closedcurve@second}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \advance\pgf@xb by-\pgf@xa%
+ \advance\pgf@yb by-\pgf@ya%
+ \advance\pgf@xc by\pgf@xa%
+ \advance\pgf@yc by\pgf@ya%
+ \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
+ {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@second}}%
+ {\pgf@marshal}%
+ \xdef\pgf@plot@closedcurve@first@support{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
+ %
+ % second, draw line from last point to start:
+ %
+ \pgf@process{\pgf@plot@closedcurve@after@initial}%
+ % compute difference vector:
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgf@plot@closedcurve@second}%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ % compute support directions:
+ \pgf@xa=\pgf@plottension\pgf@xa%
+ \pgf@ya=\pgf@plottension\pgf@ya%
+ % first marshal:
+ \pgf@process{\pgf@plot@closedcurve@initial}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \advance\pgf@xb by-\pgf@xa%
+ \advance\pgf@yb by-\pgf@ya%
+ \advance\pgf@xc by\pgf@xa%
+ \advance\pgf@yc by\pgf@ya%
+ \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgf@plot@closedcurve@first@support}%
+ {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}{\noexpand\pgf@plot@closedcurve@initial}}%
+ {\pgf@marshal}%
+ %
+ % third, draw line from first to second point:
+ %
+ \edef\pgf@marshal{\noexpand\pgfpathcurveto{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
+ {\noexpand\pgf@plot@closedcurve@after@initial@presupport}{\noexpand\pgf@plot@closedcurve@after@initial}}%
+ {\pgf@marshal}%
+ \pgfpathclose%
+ \fi%
+}
+
+
+
+
+
+% This handler converts each point in a stream into a line from the
+% $y$-axis to the given points coordinate, resulting in a
+% ``comb.''
+%
+% Example:
+%
+% \pgfplothandlerxcomb
+% \pgfplotxyfile{mytable}
+
+\def\pgfplothandlerxcomb{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@xcomb@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend%
+ \pgfplotxzerolevelstreamstart
+ }%
+}
+
+\def\pgf@plot@xcomb@handler#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \begingroup
+ \pgfplotxzerolevelstreamnext
+ \endgroup
+ \pgf@yb=\pgf@x
+ \pgfpathmoveto{\pgfqpoint{\pgf@yb}{\pgf@ya}}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
+}
+
+
+% This handler converts each point in a stream into a line from the
+% $x$-axis straight up to the given points coordinate, resulting in a
+% ``comb.''
+%
+% Example:
+%
+% \pgfplothandlerycomb
+% \pgfplotxyfile{mytable}
+
+\def\pgfplothandlerycomb{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@ycomb@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend%
+ \pgfplotyzerolevelstreamstart
+ }%
+}
+
+\def\pgf@plot@ycomb@handler#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \begingroup
+ \pgfplotyzerolevelstreamnext
+ \endgroup
+ \pgf@yb=\pgf@x
+ \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yb}}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
+}
+
+% PGF Bar or comb plots usually draw something from zero to the current plot's coordinate.
+%
+% The 'zero' offset can be changed using an input stream.
+%
+% There are two such streams which can be configured independently.
+% The first one returns "zeros" for coordinate x, the second one
+% returns "zeros" for coordinate y.
+%
+% \pgfplotxzerolevelstreamstart
+% \pgfplotxzerolevelstreamnext % assigns \pgf@x globally
+% \pgfplotxzerolevelstreamnext
+% \pgfplotxzerolevelstreamnext
+% \pgfplotxzerolevelstreamend
+%
+% and
+% \pgfplotyzerolevelstreamstart
+% \pgfplotyzerolevelstreamnext % assigns \pgf@x globally
+% \pgfplotyzerolevelstreamend
+%
+\def\pgfplotxzerolevelstreamstart{\pgf@plotxzerolevelstreamstart}%
+\def\pgfplotxzerolevelstreamend{\pgf@plotxzerolevelstreamend}%
+\def\pgfplotxzerolevelstreamnext{\pgf@plotxzerolevelstreamnext}
+\def\pgfplotyzerolevelstreamstart{\pgf@plotyzerolevelstreamstart}%
+\def\pgfplotyzerolevelstreamend{\pgf@plotyzerolevelstreamend}%
+\def\pgfplotyzerolevelstreamnext{\pgf@plotyzerolevelstreamnext}
+
+% This zero level stream always returns '#1' (a dimension).
+\def\pgfplotxzerolevelstreamconstant#1{%
+ \edef\pgfplotxzerolevelstreamconstant@val{#1}%
+ \def\pgf@plotxzerolevelstreamstart{%
+ \global\let\pgf@plotxzerolevelstreamend=\relax
+ \gdef\pgf@plotxzerolevelstreamnext{\global\pgf@x=\pgfplotxzerolevelstreamconstant@val\relax}%
+ }%
+}%
+\pgfplotxzerolevelstreamconstant{0pt}%
+
+% This zero level stream always returns '#1'.
+\def\pgfplotyzerolevelstreamconstant#1{%
+ \edef\pgfplotyzerolevelstreamconstant@val{#1}%
+ \def\pgf@plotyzerolevelstreamstart{%
+ \global\let\pgf@plotyzerolevelstreamend=\relax
+ \gdef\pgf@plotyzerolevelstreamnext{\global\pgf@x=\pgfplotyzerolevelstreamconstant@val\relax}%
+ }%
+}%
+\pgfplotyzerolevelstreamconstant{0pt}%
+
+\def\pgfplotbarwidth{\pgfkeysvalueof{/pgf/bar width}}
+\def\pgfplotbarshift{\pgfkeysvalueof{/pgf/bar shift}}
+
+\pgfqkeys{/pgf}{%
+ bar width/.initial=10pt,
+ bar shift/.initial=0pt,
+ bar interval width/.initial=1,
+ bar interval shift/.initial=0.5,
+ %
+ % hook which is executed right before a new bar is begun.
+ at begin bar/.initial=,
+ % hook which is executed right after a bar path has been finished.
+ % In this context, the bar's path has not been used.
+ at end bar/.initial=,
+}
+
+% This handler places a rectangle at each point in the plot stream, a
+% rectangle which touches the x-axis at one end and the current point
+% at the other end:
+% --(X)--
+% | |
+% | |
+% | |
+% --(0)--
+% Example:
+%
+% \pgfplothandlerybar
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerybar{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@ybar@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend%
+ \pgfmathparse{\pgfplotbarwidth}%
+ \xdef\pgfplotbarwidth@{\pgfmathresult pt}%
+ \pgfmathparse{\pgfplotbarshift}%
+ \xdef\pgfplotbarshift@{\pgfmathresult pt}%
+ \pgfplotyzerolevelstreamstart
+ }%
+}
+
+\def\pgf@plot@ybar@handler#1{%
+ \pgfkeysvalueof{/pgf/at begin bar}%
+ \pgf@process{#1}%
+ \pgf@ya=\pgf@y
+ \expandafter\pgf@xb\pgfplotbarwidth@\relax
+ \pgf@xc=\pgf@x
+ \advance\pgf@xc by-.5\pgf@xb
+ \advance\pgf@xc by\pgfplotbarshift@\relax
+ \begingroup
+ \pgfplotyzerolevelstreamnext
+ \endgroup
+ \pgf@yb=\pgf@x
+ \advance\pgf@ya by-\pgf@yb
+ \pgfpathrectangle
+ {\pgfqpoint{\pgf@xc}{\pgf@yb}}%
+ {\pgfqpoint{\pgf@xb}{\pgf@ya}}%
+ \pgfkeysvalueof{/pgf/at end bar}%
+}
+
+% This handler places a rectangle at each point in the plot stream, a
+% rectangle which touches the y-axis at one end and the current point
+% at the other end:
+% ---------
+% | |
+% (0) (X)
+% | |
+% ---------
+% Example:
+%
+% \pgfplothandlerxbar
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerxbar{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@xbar@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend%
+ \pgfmathparse{\pgfplotbarwidth}%
+ \xdef\pgfplotbarwidth@{\pgfmathresult pt}%
+ \pgfmathparse{\pgfplotbarshift}%
+ \xdef\pgfplotbarshift@{\pgfmathresult pt}%
+ \pgfplotxzerolevelstreamstart
+ }%
+}
+
+\def\pgf@plot@xbar@handler#1{%
+ \pgfkeysvalueof{/pgf/at begin bar}%
+ \pgf@process{#1}%
+ \pgf@ya=\pgf@x
+ \expandafter\pgf@xb\pgfplotbarwidth@\relax
+ \pgf@xc=\pgf@y
+ \advance\pgf@xc by-.5\pgf@xb
+ \advance\pgf@xc by\pgfplotbarshift@\relax
+ \begingroup
+ \pgfplotxzerolevelstreamnext
+ \endgroup
+ \pgf@yb=\pgf@x
+ \advance\pgf@ya by-\pgf@yb
+ \pgfpathrectangle
+ {\pgfqpoint{\pgf@yb}{\pgf@xc}}%
+ {\pgfqpoint{\pgf@ya}{\pgf@xb}}%
+ \pgfkeysvalueof{/pgf/at end bar}%
+}
+
+% This handler is a variant of \pgfplothandlerybar which works with
+% intervals instead of points.
+%
+% Bars are drawn between successive input coordinates and the width is
+% determined relatively to the interval length.
+%
+% It looks like this:
+%
+% |---| |-----|
+% | | | |
+% | | | |
+% | | | |
+% (X)------(X)-----------(X)
+%
+% where (X) denotes the x-axis offsets of input coordinates.
+%
+% In more detail, if (x_i,y_i) and (x_{i+1},y_{i+1}) denote successive
+% input coordinates, the bar will be placed above the
+% interval [x_i,x_{i+1}], centered at
+%
+% x_i + \pgfkeysvalueof{/pgf/bar interval shift} * (x_{i+1} - x_i)
+%
+% with width
+%
+% \pgfkeysvalueof{/pgf/bar interval width} * (x_{i+1} - x_i).
+%
+% If you have N+1 input points, you will get N bars (one for each
+% interval). The y_i value of the last bar will be ignored.
+%
+% Example:
+%
+% \pgfplothandlerybarinterval
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerybarinterval{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler@first%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgfplotyzerolevelstreamend%
+ \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}%
+ \xdef\pgfplotbarintervalwidth@{\pgfmathresult}%
+ \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}%
+ \xdef\pgfplotbarintervalshift@{\pgfmathresult}%
+ \pgfplotyzerolevelstreamstart
+ }%
+}
+
+\def\pgf@plot@ybarinterval@handler@first#1{%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}%
+ \xdef\pgf@plot@barinterval@bar{\the\pgf@y}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@ybarinterval@handler%
+}
+\def\pgf@plot@ybarinterval@handler#1{%
+ \pgfkeysvalueof{/pgf/at begin bar}%
+ \pgf@process{#1}%
+ \pgf@ya=\pgf@plot@barinterval@bar
+ \xdef\pgf@plot@barinterval@bar{\the\pgf@y}%
+ \pgf@xc=\pgf@plot@barinterval@intervalstart\relax
+ \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@x}%
+ \pgf@xb=\pgf@x
+ \advance\pgf@xb by-\pgf@xc
+ \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb
+ \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb
+ \advance\pgf@xc by-.5\pgf@xb% center
+ \begingroup
+ \pgfplotyzerolevelstreamnext
+ \endgroup
+ \pgf@yb=\pgf@x
+ \advance\pgf@ya by-\pgf@yb
+ \pgfpathrectangle
+ {\pgfqpoint{\pgf@xc}{\pgf@yb}}%
+ {\pgfqpoint{\pgf@xb}{\pgf@ya}}%
+ \pgfkeysvalueof{/pgf/at end bar}%
+}
+
+% Like \pgfplothandlerybarinterval but for xbar.
+\def\pgfplothandlerxbarinterval{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler@first%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgfplotxzerolevelstreamend%
+ \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval width}}%
+ \xdef\pgfplotbarintervalwidth@{\pgfmathresult}%
+ \pgfmathparse{\pgfkeysvalueof{/pgf/bar interval shift}}%
+ \xdef\pgfplotbarintervalshift@{\pgfmathresult}%
+ \pgfplotxzerolevelstreamstart
+ }%
+}
+
+\def\pgf@plot@xbarinterval@handler@first#1{%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}%
+ \xdef\pgf@plot@barinterval@bar{\the\pgf@x}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@xbarinterval@handler%
+}
+\def\pgf@plot@xbarinterval@handler#1{%
+ \pgfkeysvalueof{/pgf/at begin bar}%
+ \pgf@process{#1}%
+ \pgf@ya=\pgf@plot@barinterval@bar
+ \xdef\pgf@plot@barinterval@bar{\the\pgf@x}%
+ \pgf@xc=\pgf@plot@barinterval@intervalstart\relax
+ \xdef\pgf@plot@barinterval@intervalstart{\the\pgf@y}%
+ \pgf@xb=\pgf@y
+ \advance\pgf@xb by-\pgf@xc
+ \advance\pgf@xc by\pgfplotbarintervalshift@\pgf@xb
+ \pgf@xb=\pgfplotbarintervalwidth@\pgf@xb
+ \advance\pgf@xc by-.5\pgf@xb% center
+ \begingroup
+ \pgfplotxzerolevelstreamnext
+ \endgroup
+ \pgf@yb=\pgf@x
+ \advance\pgf@ya by-\pgf@yb
+ \pgfpathrectangle
+ {\pgfqpoint{\pgf@yb}{\pgf@xc}}%
+ {\pgfqpoint{\pgf@ya}{\pgf@xb}}%
+ \pgfkeysvalueof{/pgf/at end bar}%
+}
+
+
+% This handler is very similar to \pgfplothandlerlineto, but it
+% produces CONSTANT connected pieces of the form
+%
+% x
+% |
+% x--- |
+% | x----
+% x-|
+%
+% Example:
+%
+% \pgfplothandlerconstantlineto
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerconstantlineto{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@const@line@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+\def\pgf@plot@const@line@handler#1{%
+ \pgf@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
+ \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}%
+}
+
+% A variant of \pgfplothandlerconstantlineto which places its mark on
+% the right line ends.
+%
+% |---x
+% ---x |
+% |--x
+% x
+%
+% Example:
+%
+% \pgfplothandlerconstantlinetomarkright
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerconstantlinetomarkright{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@right@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+\def\pgf@plot@const@line@mark@right@handler#1{%
+ \pgf@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
+ \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}%
+}
+
+% A variant of \pgfplothandlerconstantlineto which places its mark on
+% the middle of the line segment.
+%
+% ----x
+% |
+% --x--- |
+% | |--x----
+% x--
+%
+% Example:
+%
+% \pgfplothandlerconstantlinetomarkmid
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerconstantlinetomarkmid{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@mid@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+\def\pgf@plot@const@line@mark@mid@handler#1{%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ \pgf@plot@first@action{}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@const@line@mark@mid@handler@@%
+}
+\def\pgf@plot@const@line@mark@mid@handler@@#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgf@plot@const@line@handler@last
+ \pgf@xc=.5\pgf@xa
+ \advance\pgf@xc by.5\pgf@x
+ \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@y}}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@ya}}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
+ \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+}
+
+% This handler is in fact a variant of \pgfplothandlerconstantlineto,
+% but it does not draw vertical lines. It produces a sequence of
+% line-to and move-to operations such that plot marks are placed at
+% each right end:
+%
+% ---x
+% ---x
+% ---x
+% --x
+%
+% Example:
+%
+% \pgfplothandlerjumpmarkright
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerjumpmarkright{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkright@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+\def\pgf@plot@jumpmarkright@handler#1{%
+ \pgf@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
+ \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}%
+}
+
+% This handler is in fact a variant of \pgfplothandlerconstantlineto,
+% but it does not draw vertical lines. It produces a sequence of
+% line-to and move-to operations such that plot marks are placed at
+% each left end:
+%
+% x---
+% x---
+% x---
+% x--
+%
+% Example:
+%
+% \pgfplothandlerjumpmarkleft
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerjumpmarkleft{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@jumpmarkleft@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+\def\pgf@plot@jumpmarkleft@handler#1{%
+ \pgf@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
+ \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}%
+}
+
+% This handler is in fact a variant of
+% \pgfplothandlerconstantlinetomarkmid,
+% but it does not draw vertical lines. It produces a sequence of
+% line-to and move-to operations such that plot marks are placed like
+%
+% ----x
+%
+% --x--
+% --x----
+% x--
+%
+% Example:
+%
+% \pgfplothandlerjumpmarkmid
+% \pgfplotxyfile{mytable}
+\def\pgfplothandlerjumpmarkmid{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@jump@mark@mid@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+\def\pgf@plot@jump@mark@mid@handler#1{%
+ \pgf@process{#1}%
+ \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ \pgf@plot@first@action{}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@jump@mark@mid@handler@@%
+}
+\def\pgf@plot@jump@mark@mid@handler@@#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgf@plot@const@line@handler@last
+ \pgf@xc=.5\pgf@xa
+ \advance\pgf@xc by.5\pgf@x
+ \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@y}}%
+ \pgfpathmoveto{\pgfqpoint{\pgf@xc}{\pgf@ya}}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
+ \xdef\pgf@plot@const@line@handler@last{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+}
+
+
+% This handler converts each point in a stream into a line from the
+% origin to the point's coordinate, resulting in a ``star''.
+%
+% Example:
+%
+% \pgfplothandlerpolarcomb
+% \pgfplotxyfile{mytable}
+
+\def\pgfplothandlerpolarcomb{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@polarcomb@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+
+\def\pgf@plot@polarcomb@handler#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgfpathmoveto{\pgfpointorigin}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
+}
+
+
+
+
+% This handler draws a given mark at each point.
+%
+% #1 = some code to be executed at each point (with the coordinate
+% system translated to that point).
+% Typically, this code will be \pgfuseplotmark{whatever}.
+%
+% Example:
+%
+% \pgfplothandlermark{\pgfuseplotmark{*}}
+% \pgfplotxyfile{mytable}
+
+\def\pgfplothandlermark#1{%
+ \pgf@plothandlermark{%
+ \ifnum\pgf@plot@mark@count<\pgf@plot@mark@repeat\relax%
+ \else%
+ \global\pgf@plot@mark@count=0\relax%
+ #1%
+ \fi%
+ }%
+}
+
+\newcount\pgf@plot@mark@count
+\def\pgf@plot@mark@phase{0}
+
+\def\pgf@plothandlermark#1{%
+ \def\pgf@plot@mark{#1}%
+ \def\pgf@plotstreamstart{%
+ \global\pgf@plot@mark@count=\pgf@plot@mark@repeat\relax%
+ \global\advance\pgf@plot@mark@count by-\pgf@plot@mark@phase\relax%
+ \global\let\pgf@plotstreampoint=\pgf@plot@mark@handler%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+
+\def\pgf@plot@mark@handler#1{%
+ \global\advance\pgf@plot@mark@count by1\relax%
+ {\pgftransformshift{#1}\pgf@plot@mark}%
+}
+
+
+% Set the repeat count for marks. For example, if 3 is given as a
+% value, only every third point will get a mark.
+%
+% #1 = repeat count
+%
+% Example:
+%
+% \pgfsetplotmarkrepeat{2}
+
+\def\pgfsetplotmarkrepeat#1{\def\pgf@plot@mark@repeat{#1}}
+\pgfsetplotmarkrepeat{1}
+
+
+% Set the phase for marks. For example, if 3 is the repeat and 3 is
+% the phase, already the first point will be marked.
+%
+% #1 = the index of the first point that should be marked.
+%
+% Example:
+%
+% \pgfsetplotmarkphase{3}
+
+\def\pgfsetplotmarkphase#1{\def\pgf@plot@mark@phase{#1}}
+\pgfsetplotmarkphase{1}
+
+
+
+% This handler draws a given mark at those points whose number is
+% given in the (pgffor-like) list.
+%
+% #1 = some code to be executed at each point (with the coordinate
+% system translated to that point).
+% Typically, this code will be \pgfuseplotmark{whatever}.
+% #2 = list of positions like "1,2,4,...,9,10"
+%
+% Example:
+%
+% \pgfplothandlermarklisted{\pgfuseplotmark{*}}{1,2,4,...,9}
+% \pgfplotxyfile{mytable}
+
+\def\pgfplothandlermarklisted#1#2{%
+ \let\pgf@plot@mark@list=\pgfutil@empty%
+ \edef\pgf@marshal{\noexpand\foreach\noexpand\pgf@temp in{#2}}
+ \pgf@marshal{\xdef\pgf@plot@mark@list{\pgf@plot@mark@list(\pgf@temp)}}%
+ \pgf@plothandlermark{%
+ \edef\pgf@marshal{\noexpand\pgfutil@in@{(\the\pgf@plot@mark@count)}{\pgf@plot@mark@list}}%
+ \pgf@marshal%
+ \ifpgfutil@in@#1\fi}%
+}
+
+
+% Define a new plot mark for use with \pgfplotmark.
+%
+% #1 = a plot mark mnemonic
+% #2 = code for drawing the mark
+%
+% Example:
+%
+% \pgfdeclareplotmark{*}{\pgfpathcircle{\pgfpointorigin}{2pt}\pgfusepathqfill}
+
+\def\pgfdeclareplotmark#1#2{\expandafter\def\csname pgf@plot@mark@#1\endcsname{#2}}
+
+
+% Set the size of plot marks. For circles, this will be the radius,
+% for other shapes it should be about half the width/height.
+%
+% Example:
+%
+% \pgfsetplotmarksize{1pt}
+
+\def\pgfsetplotmarksize#1{\pgfmathsetlength\pgfplotmarksize{#1}}
+
+\newdimen\pgfplotmarksize
+\pgfplotmarksize=2pt
+
+
+% Insert a plot mark's code at the origin.
+%
+% #1 = plot mark mnemonic
+%
+% Example:
+%
+% \pgfuseplotmark{*}
+
+\def\pgfuseplotmark#1{\csname pgf@plot@mark@#1\endcsname}
+
+
+% A stroke-filled circle mark
+
+\pgfdeclareplotmark{*}
+{%
+ \pgfpathcircle{\pgfpointorigin}{\pgfplotmarksize}
+ \pgfusepathqfillstroke
+}
+
+
+% A plus-sign like mark
+
+\pgfdeclareplotmark{+}
+{%
+ \pgfpathmoveto{\pgfqpoint{-\pgfplotmarksize}{0pt}}
+ \pgfpathlineto{\pgfqpoint{\pgfplotmarksize}{0pt}}
+ \pgfpathmoveto{\pgfqpoint{0pt}{\pgfplotmarksize}}
+ \pgfpathlineto{\pgfqpoint{0pt}{-\pgfplotmarksize}}
+ \pgfusepathqstroke
+}
+
+
+% An x-shaped mark
+
+\pgfdeclareplotmark{x}
+{%
+ \pgfpathmoveto{\pgfqpoint{-.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}}
+ \pgfpathlineto{\pgfqpoint{.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}}
+ \pgfpathmoveto{\pgfqpoint{-.70710678\pgfplotmarksize}{.70710678\pgfplotmarksize}}
+ \pgfpathlineto{\pgfqpoint{.70710678\pgfplotmarksize}{-.70710678\pgfplotmarksize}}
+ \pgfusepathqstroke
+}
+
+% See pgflibraryplotmarks for more plot marks
+
+
+
+
+% This handler turns creates a series of straight line segements
+% between consecutive points, but leaving /pgf/gap around stream point
+% space.
+%
+% Example:
+%
+% \pgfplothandlergaplineto
+% \pgfplotxyfile{mytable}
+
+\pgfkeys{/pgf/gap around stream point/.initial=1.5pt}
+
+\def\pgfplothandlergaplineto{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@gap@lineto@handler@initial%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax%
+ }%
+}
+
+\def\pgf@plot@gap@lineto@handler@initial#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \xdef\pgf@plot@gap@lineto@last{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
+ \global\let\pgf@plotstreampoint=\pgf@plot@gap@lineto@handler%
+}
+
+\def\pgf@plot@gap@lineto@handler#1{%
+ % Ok, compute normalized line vector
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \xdef\pgf@plot@gap@lineto@next{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
+ \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@plot@gap@lineto@last}{\pgf@plot@gap@lineto@next}}}%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgfpathmoveto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap
+ around stream point}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgf@plot@gap@lineto@last}}%
+ \pgfpathlineto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap
+ around stream point}}{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}}{\pgf@plot@gap@lineto@next}}%
+ \global\let\pgf@plot@gap@lineto@last=\pgf@plot@gap@lineto@next%
+}
+
+
+
+
+% This handler works like \pgfplothandlergaplineto, only the last
+% point is connected to the first point, creating a closed curve
+% space.
+%
+% Example:
+%
+% \pgfplothandlergapcycle
+% \pgfplotxyfile{mytable}
+
+\def\pgfplothandlergapcycle{%
+ \def\pgf@plotstreamstart{%
+ \global\let\pgf@plotstreampoint=\pgf@plot@gap@cycle@handler@initial%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\pgf@plot@gap@cycle@handler@finish%
+ \global\let\pgf@plot@gap@cycle@first=\relax%
+ }%
+}
+
+\def\pgf@plot@gap@cycle@handler@initial#1{%
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \xdef\pgf@plot@gap@cycle@last{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
+ \global\let\pgf@plot@gap@cycle@first=\pgf@plot@gap@cycle@last%
+ \global\let\pgf@plotstreampoint=\pgf@plot@gap@cycle@handler%
+}
+
+\def\pgf@plot@gap@cycle@handler#1{%
+ % Ok, compute normalized line vector
+ \pgf@process{#1}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \xdef\pgf@plot@gap@cycle@next{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
+ \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@plot@gap@cycle@last}{\pgf@plot@gap@cycle@next}}}%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgfpathmoveto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap
+ around stream point}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}{\pgf@plot@gap@cycle@last}}%
+ \pgfpathlineto{\pgfpointadd{\pgfpointscale{\pgfkeysvalueof{/pgf/gap
+ around stream point}}{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}}{\pgf@plot@gap@cycle@next}}%
+ \global\let\pgf@plot@gap@cycle@last=\pgf@plot@gap@cycle@next%
+}
+
+\def\pgf@plot@gap@cycle@handler@finish{%
+ \ifx\pgf@plot@gap@cycle@first\relax%
+ \else
+ \pgf@plot@gap@cycle@handler{\pgf@plot@gap@cycle@first}%
+ \fi
+}
+
+
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.code.tex
new file mode 100644
index 0000000000..8a3f3228d4
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.code.tex
@@ -0,0 +1,90 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Sa 7. Dez 20:58:23 CET 2013 %%%
+
+
+
+% 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/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex
new file mode 100644
index 0000000000..a572afc552
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex
@@ -0,0 +1,450 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Sa 7. Dez 20:58:23 CET 2013 %%%
+
+
+
+%--------------------------------------------
+%
+% 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,
+}
+
+\begingroup
+ \catcode`\_=12
+ \gdef\pgfmanualpdf@underscore{_}%
+ \catcode`\ =13\relax\gdef\pgfmanualpdf@install@active@space{\def {\space}}%
+\endgroup
+
+\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\SPACE{\` \relax}%
+ \ifnum\the\catcode`\ =13 %
+ \pgfmanualpdf@install@active@space
+ \fi
+ \edef\#{}%
+ \def\printanat{@}%
+ \def\protect{}%
+ \def\textasciicircum{o}%
+ \def\_{\pgfmanualpdf@underscore}%
+ \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
+ %
+ \if@filesw
+ \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
+ \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}{%
+ \edef\pgfmanualpdflabel@@{\prefix\pgfmanualpdflabel@@}%
+ \expandafter\pgfmanual@handlespeciallabeltokens@in\expandafter{\pgfmanualpdflabel@@}%
+ \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname
+ \xdef\pgfmanual@glob{\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/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex
new file mode 100644
index 0000000000..07bfe1e424
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex
@@ -0,0 +1,1119 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Sa 7. Dez 20:58:23 CET 2013 %%%
+
+
+
+%--------------------------------------------
+%
+% 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/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmathfloat.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmathfloat.code.tex
new file mode 100644
index 0000000000..5ba17bc2d0
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfmathfloat.code.tex
@@ -0,0 +1,2665 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Fr 10. Nov 17:18:26 CET 2017 %%%
+
+
+
+% Copyright 2008 by Christian Feuersaenger
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+%
+% This file contains methods for basic floating point arithmetics, rounding
+% to arbitrary precision and number pretty printing.
+%
+
+
+\pgfkeys{
+ % The bug 3430171 (wrong minus sign spacing in pgfmathprintnumber)
+ % has been fixed in 2.10 CVS. Since it changes the spacing, its
+ % effects can be undone with this compatibility switch.
+ /pgf/compat/number printer/.is choice,
+ /pgf/compat/number printer/2.10/.code={%
+ \def\pgfmathprintnumber@begingroup{\bgroup}%
+ \def\pgfmathprintnumber@endgroup{\egroup}%
+ },
+ % I do not know the version number of the next release at this
+ % time. Please be so kind and KEEP THIS NAME INTACT. Add an alias
+ % if needed.
+ /pgf/compat/number printer/next after 2.10/.code={%
+ \def\pgfmathprintnumber@begingroup{\begingroup}%
+ \def\pgfmathprintnumber@endgroup{\endgroup}%
+ },
+ % activate the fix by default.
+ /pgf/compat/number printer/next after 2.10,%
+}
+
+
+\global\newif\ifpgfmathfloatcomparison
+\newif\ifpgfmathfloatroundhasperiod
+\newif\ifpgfmathprintnumberskipzeroperiod
+
+
+% used internally in grouped macros:
+\toksdef\pgfmathfloat@tmptoks=1
+\newif\ifpgfmathfloat@fixed@digits@after@period
+\newif\ifpgfmathfloatroundmayneedrenormalize
+\toksdef\pgfmathfloat@a@Mtok=0
+
+%% WARNING: avoid conflicting register names!
+\let\pgfmathfloat@a@S=\c@pgf@counta
+\let\pgfmathfloat@a@M=\pgf@xa
+\let\pgfmathfloat@a@E=\c@pgf@countb
+\let\pgfmathfloat@b@S=\c@pgf@countc
+\let\pgfmathfloat@b@M=\pgf@xb
+\let\pgfmathfloat@b@E=\c@pgf@countd
+
+% can be changed with options.
+\def\pgfmathfloat@round@precision{2}
+
+% I introduced this to acces the "original" precision in case a
+% formatted changes it locally... in this case, the formatter may
+% overwrite \pgfmathfloat@round@precision@orig to provide the original
+% one.
+% The default implementation here does nothing:
+\def\pgfmathfloat@round@precision@orig{\pgfmathfloat@round@precision}%
+
+\gdef\pgfmathfloat@glob@TMP{}
+
+
+% Computes a normalised floating point representation for #1 of the
+% form
+% [FLAGS] MANTISSE EXPONENT
+% meaning
+% [+-]X.XXXXXXX*10^C
+% where
+% X.XXXXXX is a mantissa with first number != 0, C is an integer and
+% FLAGS contains the sign and some other special cases.
+%
+% This method does NOT use TeX Registers to represent the numbers! The
+% computation is COMPLETELY STRING BASED.
+% This allows numbers such at 10000000 or 5.23e-10 to be represented
+% properly, although TeX-registers would produce overflow/underflow
+% errors in these cases.
+%
+% It is to be used to compute logs, because log(X*10^Y) = log(X) + log(10)*Y
+%
+% Arguments:
+% #1: an arbitrary number which shall be parsed. Maybe a macro.
+% Examples:
+% [+-]XXXXX.XXXXXX
+% [+-]XXXXX.XXXXXXeXXXX
+% [+-]0.0000XXXXXX
+% [+-]0.0000XXXXXXeXXXX
+% [+-]inf
+% nan
+% Maybe a macro containing such a number.
+%
+% Return value:
+% \pgfmathresult will be \def'ed to
+% FLAGS MANTISSE 'e' EXPONENT
+% where
+% FLAGS is a number in [0-5] where
+% 0 == '0' (the number is +- 0.0),
+% 1 == '+',
+% 2 == '-',
+% 3 == 'not a number'
+% 4 == '+ infinity'
+% 5 == '- infinity'
+%
+% MANTISSE is a normalised number 1 <= M < 10. It always contains a
+% period and at least one digit after the period.
+%
+% EXPONENT is an integer value.
+%
+% Example:
+% \pgfmathfloatparsenumber{1}
+% -> \pgfmathresult = 11.0e0
+% \pgfmathfloatparsenumber{141.212}
+% -> \pgfmathresult = 11.41212e2
+\def\pgfmathfloatparsenumber#1{%
+ \begingroup
+ \edef\pgfmathresult{#1}%
+ \expandafter\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
+ \endgroup
+}
+
+% The same as \pgfmathfloatparsenumber, but does not perform sanity checking.
+% 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, mantissa 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 mantissa 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{%
+ \expandafter\pgfmathfloat@decompose@Fmacro#1\relax{#2}%
+}%
+
+% Extracts the mantissa of #1 into the dimen register #2.
+\def\pgfmathfloatgetmantissa#1#2{%
+ \expandafter\pgfmathfloat@decompose@M#1\relax{#2}%
+}
+\let\pgfmathfloatgetmantisse=\pgfmathfloatgetmantissa
+% Extracts the mantissa of #1 into the token register #2.
+\def\pgfmathfloatgetmantissatok#1#2{%
+ \expandafter\pgfmathfloat@decompose@Mtok#1\relax{#2}%
+}
+\let\pgfmathfloatgetmantissetok=\pgfmathfloatgetmantissatok
+% 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>
+%
+% example:
+% \pgfmathfloatcreate{1}{2.0}{10}
+% \pgfmathfloat@to@FMeE@style\pgfmathresult
+% ->
+% \pgfmathresult is now '12.0e10' regardless of the internal float
+% format.
+\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,
+% mantissa and exponent.
+%
+% #4: integer register for the flags.
+% #5: dimen registers for the mantissa.
+% #6: integer register for the exponent.
+%
+% \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E
+% -> the three temp registers contain flags, mantissa 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 % keep space here.
+ #6=#3\relax%
+}
+
+% overloaded, #5 needs to be a token register for the mantissa.
+% @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, mantissa 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:
+% \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@Fmacro#1#2{%
+ \ifx#2Y%
+ \expandafter\pgfmathfloat@decompose@Fmacro@%
+ \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@Fmacro@#1Y#2e#3]\relax#4{\def#4{#1}}%
+\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, mantissa to macro #3 and exponent to macro #4.
+\def\pgfmathfloattomacro#1#2#3#4{%
+ \begingroup
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \xdef\pgfmathfloat@glob@TMP{%
+ \noexpand\def\noexpand#2{\the\pgfmathfloat@a@S}%
+ \noexpand\def\noexpand#3{\the\pgfmathfloat@a@Mtok}%
+ \noexpand\def\noexpand#4{\the\pgfmathfloat@a@E}%
+ }%
+ \endgroup
+ \pgfmathfloat@glob@TMP
+}
+
+
+% Defines \pgfmathresult as the floating point number encoded by
+% the flags #1, mantissa #2 and exponent #3.
+%
+% All arguments are characters and will be expanded using '\edef'.
+\def\pgfmathfloatcreate#1#2#3{%
+ \edef\pgfmathresult{#1Y#2e#3]}%
+}%
+% This is the character present in any low-level floating point
+% number. It is assumed to be the SECOND character of a float (after
+% the flags integer).
+\def\pgfmathfloat@POSTFLAGSCHAR{Y}
+
+
+
+% Converts a composed floating point representation to fixed point.
+%
+% Example:
+% \pgfmathfloattofixed{142e1}
+% -> \pgfmathresult = 42.0
+\def\pgfmathfloattofixed@#1{%
+ \begingroup
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifcase\pgfmathfloat@a@S
+ \def\pgfmathresult{0.0}%
+ \or
+ \expandafter\pgfmathfloattofixed@impl\the\pgfmathfloat@a@Mtok\relax
+ \or
+ \expandafter\pgfmathfloattofixed@impl\the\pgfmathfloat@a@Mtok\relax
+ \pgfmathfloat@a@Mtok=\expandafter{\pgfmathresult}%
+ \edef\pgfmathresult{-\the\pgfmathfloat@a@Mtok}%
+ \or\def\pgfmathresult{nan}%
+ \or\def\pgfmathresult{inf}%
+ \or\def\pgfmathresult{-inf}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+\let\pgfmathfloattofixed=\pgfmathfloattofixed@
+
+% Converts a float to an integer (in integer format).
+%
+% @see \pgfmathfloatint
+\def\pgfmathfloattoint#1{%
+ \pgfmathfloattofixed{#1}%
+ \expandafter\pgfmathfloattoint@@\pgfmathresult\relax
+}%
+\def\pgfmathfloattoint@@#1.#2\relax{%
+ \def\pgfmathresult{#1}%
+}%
+
+% Converts a floating point number to scientific format 1.234e5.
+%
+% This operation is very fast.
+\def\pgfmathfloattosci@#1{%
+ \begingroup
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifcase\pgfmathfloat@a@S
+ \def\pgfmathresult{0.0e0}%
+ \or
+ \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}%
+ \or
+ \edef\pgfmathresult{-\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}%
+ \or\def\pgfmathresult{nan}%
+ \or\def\pgfmathresult{inf}%
+ \or\def\pgfmathresult{-inf}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\let\pgfmathfloattosci=\pgfmathfloattosci@
+
+% Expands a floating point number to scientific format 1.234e5.
+%
+% This operation is very fast.
+\def\pgfmathfloatvalueof#1{\expandafter\pgfmathfloatvalueof@@#1@@}%
+
+% Make it fool proof such that the following arguments work:
+% \pgfmathfloatvalueof{1Y1.0e1} -> 1.0e1
+% \pgfmathfloatvalueof{2Y1.0e1} -> -1.0e1
+% and wrong arguments as well:
+% \pgfmathfloatvalueof{1} -> 1
+% \pgfmathfloatvalueof{1e2} -> 1e2
+\def\pgfmathfloatvalueof@@#1#2{%
+ \if#2Y%
+ % keep in mind that \pgfmathfloatvalueof should be expandable!
+ % We must not use \let here. Let's hope that #1 and #2 are
+ % single tokens (not something which was enclosed by curly
+ % braces...)
+ \expandafter\pgfmathfloatvalueof@@@\expandafter#1\expandafter#2%
+ \else
+ % Oh - no float!? Ok, we cannot report errors in this context.
+ % So: make it a feature and return the input argument as-is.
+ % Might be useful, in fact...
+ \expandafter\pgfmathfloatvalueof@abort\expandafter#1\expandafter#2%
+ \fi
+}
+\def\pgfmathfloatvalueof@@@#1Y#2e#3]@@{%
+ \ifcase#1 %
+ 0.0e0%
+ \or
+ #2e#3%
+ \or
+ -#2e#3%
+ \or nan%
+ \or inf%
+ \or -inf%
+ \fi
+}%
+\def\pgfmathfloatvalueof@abort#1@@{#1}%
+
+
+
+% Rounds a fixed point number #1 to \pgfmathfloat@round@precision digits precision and returns
+% the result into \pgfmathresult.
+%
+% Any trailing zeros after the period are discarded.
+% See \pgfmathroundtozerofill if you want trailing zeros and fixed
+% width.
+%
+% This method is PURELY text based and can work with arbirtrary
+% precision (well, limited to TeX's stack size and integer size).
+%
+% Examples:
+% \pgfmathroundto{1}
+% -> \pgfmathresult = '1'
+%
+% \pgfmathroundto{19999.9996}
+% -> \pgfmathresult = '20000'
+%
+% Arguments:
+% #1 may be either a number or a macro (\pgfmathresult is allowed) expanding to a number.
+%
+% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set.
+\def\pgfmathroundto#1{%
+ \pgfmathfloatroundhasperiodtrue
+ \begingroup
+ \pgfmathfloat@fixed@digits@after@periodfalse
+ \pgfmathroundto@impl{#1}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+
+% Overloaded method.
+%
+% This variant always uses a FIXED number behind the period and fills
+% in zeros if necessary.
+% Examples:
+% \pgfmathroundtozerofill{1}
+% -> \pgfmathresult = '1.00'
+%
+% \pgfmathroundtozerofill{19999.9996}
+% -> \pgfmathresult = '20000.00'
+%
+% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set.
+\def\pgfmathroundtozerofill#1{%
+ \pgfmathfloatroundhasperiodtrue
+ \begingroup
+ \pgfmathfloat@fixed@digits@after@periodtrue
+ \pgfmathroundto@impl{#1}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+% see \pgfmathprintnumber@fixed@style for docs
+\def\pgfmathprintnumber@fixed@styleDEFAULT#1#2#3e#4\relax{%
+ \begingroup
+ \pgfkeysgetvalue{/pgf/number format/set decimal separator}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP
+ \pgfkeysgetvalue{/pgf/number format/@dec sep mark}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK
+ \pgfkeysgetvalue{/pgf/number format/set thousands separator}\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP
+ \c@pgf@counta=#4\relax % it is the exponent here.
+ \ifnum#2=0
+ \c@pgf@counta=0
+ \fi
+ \def\pgfmathresult{}%
+ \ifpgfmathfloatroundhasperiod
+ \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@period#1\pgfmathfloat@EOI
+ \else
+ \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI%
+ \begingroup
+ \toks0=\expandafter{\pgfmathresult}%
+ \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }%
+ \endgroup
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@period#1.#2\pgfmathfloat@EOI{%
+ \ifpgfmathprintnumberskipzeroperiod
+ \def\pgfmathfloat@loc@TMPb{#1}%
+ \ifx\pgfmathfloatparsenumber@tok@ZERO\pgfmathfloat@loc@TMPb
+ \else
+ \def\pgfmathfloat@loc@TMPc{-0}%
+ \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb
+ \def\pgfmathresult{-}%
+ \else
+ \def\pgfmathfloat@loc@TMPc{+0}%
+ \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb
+ \def\pgfmathresult{+}%
+ \else
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI
+ \fi
+ \fi
+ \fi
+ \else
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI
+ \fi
+ \ifpgfmathprintnumber@thousand@sep@in@fractional
+ \let\pgfmathresultfractional\pgfutil@empty%
+ \pgfmathprintnumber@thousand@sep@in@fractional#2MMMM\@@
+ \else
+ \def\pgfmathresultfractional{#2}%
+ \fi
+ \begingroup
+ \toks0=\expandafter{\pgfmathresult}%
+ \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}%
+ \toks2=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP}%
+ \toks3=\expandafter{\pgfmathresultfractional}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 \the\toks3 }%
+ \endgroup
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+}%
+
+% assigns \pgfmathresult such that it contains the formatted result.
+% It assumes that none of the following tokens contains a period.
+\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod{%
+ \ifx\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP\pgfutil@empty
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}%
+ \else
+ \ifnum\c@pgf@counta<0\relax % exponent of the number in this context
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}%
+ \else
+ \ifnum\c@pgf@counta<\pgfkeysvalueof{/pgf/number format/min exponent for 1000 sep}\relax
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}%
+ \else
+ \advance\c@pgf@counta by1 % counta:= total number of digits, N.
+ \c@pgf@countb=\c@pgf@counta
+ \divide\c@pgf@countb by3 % countb := N DIV 3
+ \c@pgf@countc=\c@pgf@countb
+ \multiply\c@pgf@countc by3
+ \advance\c@pgf@counta by-\c@pgf@countc% now counta := N MOD 3
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printsign
+ }%
+ \fi
+ \fi
+ \fi
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT
+}
+\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printsign#1{%
+ \def\pgfmathfloat@loc@TMPb{#1}%
+ \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@MINUS
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}%
+ \let\pgfmathfloat@loc@TMPb=\pgfutil@empty
+ \else
+ \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@PLUS
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}%
+ \let\pgfmathfloat@loc@TMPb=\pgfutil@empty
+ \else
+ \ifpgfmathprintnumber@showpositive
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult +}%
+ \fi
+ \fi
+ \fi
+ \ifnum\c@pgf@counta>0 % \c@pgf@counta = N MOD 3 in this context
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printtrailingdigits\pgfmathfloat@loc@TMPb
+ }%
+ \else
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird\pgfmathfloat@loc@TMPb
+ }%
+ \fi
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT
+}
+\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printtrailingdigits#1#2{%
+ \ifcase\c@pgf@counta % = N MOD 3 in this context
+ % does not happen per construction
+ \or
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}%
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird#2%
+ }%
+ \or
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1#2}%
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird%
+ }%
+ \fi
+ \ifnum\c@pgf@countb>0\relax % \c@pgf@countb = N DIV 3 in this context
+ \begingroup
+ \toks0=\expandafter{\pgfmathresult}%
+ \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }%
+ \endgroup
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+ \fi
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT
+}
+\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird#1#2#3{%
+ \ifnum\c@pgf@countb>0\relax
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1#2#3}%
+ \advance\c@pgf@countb by-1
+ \ifnum\c@pgf@countb>0\relax
+ \begingroup
+ \toks0=\expandafter{\pgfmathresult}%
+ \toks1=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }%
+ \endgroup
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+ \fi
+ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{%
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird%
+ }%
+ \else
+ % in thise case, #1#2#3 are expected to be
+ % \pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI
+ %--------------------------------------------------
+ % \def\pgfmathfloat@loc@TMPb{\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI}%
+ % \def\pgfmathfloat@loc@TMPc{#1#2#3}%
+ % \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb
+ % \else
+ % \pgfmath@error{INTERNAL ERROR in fixed style - The input sequence did not terminate as expected; which indicates a wrong exponent argument provided to \string\pgfmathprintnumber@fixed@style}{}%
+ % \fi
+ %--------------------------------------------------
+ \let\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT=\relax
+ \fi
+ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT
+}
+
+% \pgfmathprintnumber@thousand@sep@in@fractional 01234525MMMM\@@
+% ->
+% 012<sep>345<sep>25
+\def\pgfmathprintnumber@thousand@sep@in@fractional#1#2#3#4{%
+ \if#4M%
+ % Ok, no further separator
+ \def\pgfmathprint@next{\pgfmathprintnumber@thousand@sep@in@fractional@finish#1#2#3#4}%
+ \else
+ \begingroup
+ \toks0=\expandafter{\pgfmathresultfractional}%
+ \toks1={#1#2#3}%
+ \toks2=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@THOUSAND@SEP}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 }%
+ \endgroup
+ \let\pgfmathresultfractional=\pgfmathfloat@glob@TMP
+ \def\pgfmathprint@next{\pgfmathprintnumber@thousand@sep@in@fractional#4}%
+ \fi
+ \pgfmathprint@next
+}%
+\def\pgfmathprintnumber@thousand@sep@in@fractional@finish#1M{%
+ \expandafter\def\expandafter\pgfmathresultfractional\expandafter{\pgfmathresultfractional #1}%
+ \pgfmathprintnumber@thousand@sep@in@fractional@finish@
+}%
+\def\pgfmathprintnumber@thousand@sep@in@fractional@finish@#1\@@{}%
+
+\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall#1{%
+ \def\pgfmathfloat@loc@TMPb{#1}%
+ \let\pgfmathfloat@loc@TMPc=\pgfutil@empty
+ \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@MINUS
+ \else
+ \ifx\pgfmathfloat@loc@TMPb\pgfmathfloatparsenumber@tok@PLUS
+ \else
+ \ifpgfmathprintnumber@showpositive
+ \def\pgfmathfloat@loc@TMPc{+}%
+ \fi
+ \fi
+ \fi
+ \expandafter\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall@\pgfmathfloat@loc@TMPc#1%
+}
+\def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall@#1\pgfmathfloat@EOI\pgfmathfloat@EOI\pgfmathfloat@EOI{%
+ \expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult #1}%
+}%
+
+% @deprecated. It has been replaced by \pgfmathprintnumber@fixed@styleDEFAULT
+% #1 maybe a macro
+\def\pgfmathprintnumber@fixed@stylePERIOD#1#2#3e#4\relax{%
+ \def\pgfmathresult{#1}%
+}
+
+% @deprecated. It has been replaced by \pgfmathprintnumber@fixed@styleDEFAULT
+% #1 maybe a macro
+\def\pgfmathprintnumber@fixed@styleCOMMA#1#2#3e#4\relax{%
+ \ifpgfmathfloatroundhasperiod
+ \expandafter\pgfmathprintnumber@fixed@styleCOMMA@impl#1\pgfmathfloat@EOI
+ \else
+ \def\pgfmathresult{#1}%
+ \fi
+}
+\def\pgfmathprintnumber@fixed@styleCOMMA@impl#1.#2\pgfmathfloat@EOI{\def\pgfmathresult{#1{,}#2}}
+
+% The default style to display fixed point numbers.
+%
+% It does not apply numerics, but it is responsable for typesetting the
+% rounded number.
+% It can access the \ifpgfmathfloatroundhasperiod boolean.
+%
+% Arguments:
+% #1#2#3e#4\relax
+
+% Input:
+% #1 the fixed point number to be displayed (maybe a macro).
+% #2#3e#4: the (possibly unformatted) floating point representation
+% which belongs to #1. This format is returned (only!) by
+% \pgfmathfloat@to@FMeE@style.
+% It is used to determine sign and exponent.
+\let\pgfmathprintnumber@fixed@style=\pgfmathprintnumber@fixed@styleDEFAULT
+
+
+% Rounds a normalized floating point number to \pgfmathfloat@round@precision
+% digits precision and writes the result to \pgfmathresult.
+%
+% This method uses \pgfmathroundto for the mantissa.
+%
+% @see pgfmathfloatroundzerofill
+%
+% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set to
+% whether the final mantissa #5 has a period or not.
+\def\pgfmathfloatround#1{%
+ \pgfmathfloatroundhasperiodtrue
+ \begingroup
+ \pgfmathfloat@fixed@digits@after@periodfalse
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \pgfmathfloatround@impl
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+% Overload.
+%
+% This method uses a fixed width for the mantissa and fills in zeros
+% if necessary.
+%
+% This method uses \pgfmathroundtozerofill for the mantissa.
+%
+% SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set to
+% whether the final mantissa #5 has a period or not.
+\def\pgfmathfloatroundzerofill#1{%
+ \pgfmathfloatroundhasperiodtrue
+ \begingroup
+ \pgfmathfloat@fixed@digits@after@periodtrue
+ \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \pgfmathfloatround@impl
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+\newif\ifpgfmathfloatround@allow@empty@mantissa
+\def\pgfmathfloatround@mantissa@ONE{1.0}%
+
+% #1: sign
+% #2: mantissa
+% #3: exponent
+% #4: CODE to display if the mantissa is drawn.
+% This code will be shown just before the exponent.
+% Example: #4=\cdot
+% #5: CODE to display if the mantissa is NOT draw. (unused currently)
+% Might be used to display '10^1' instead of '1*10^1'.
+% #6: CODE to display the exponent.
+\def\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax#4#5#6{%
+ \pgfkeysgetvalue{/pgf/number format/@sci exponent mark}\pgfmathfloatrounddisplaystyle@e@mark
+ \ifcase#1\relax
+ \pgfmathprintnumber@fixed@style{#2}#1#2e0\relax%
+ \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}%
+ \or\pgfmathprintnumber@fixed@style{#2}#1#2e0\relax%
+ \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}%
+ \or\pgfmathprintnumber@fixed@style{-#2}#1#2e0\relax%
+ \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}%
+ \or
+ \pgfmathfloatrounddisplaystyle@shared@impl@@{\hbox{NaN}}{}%
+ \or
+ \ifpgfmathprintnumber@showpositive
+ \pgfmathfloatrounddisplaystyle@shared@impl@@{+\infty}{}%
+ \else
+ \pgfmathfloatrounddisplaystyle@shared@impl@@{\infty}{}%
+ \fi
+ \or
+ \pgfmathfloatrounddisplaystyle@shared@impl@@{-\infty}{}%
+ \fi
+}
+
+% #1: the part before the exponent code
+% #2: the part for the exponent code.
+\def\pgfmathfloatrounddisplaystyle@shared@impl@#1#2{%
+ \pgfmathprintnumber@begingroup
+ \toks0={#1}%
+ \toks1=\expandafter{\pgfmathfloatrounddisplaystyle@e@mark #2}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }%
+ \pgfmathprintnumber@endgroup
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+}%
+% Same as \pgfmathfloatrounddisplaystyle@shared@impl@, but it also
+% inserts the '@dec sep mark' at the end.
+\def\pgfmathfloatrounddisplaystyle@shared@impl@@#1#2{%
+ \pgfmathprintnumber@begingroup
+ \toks0={#1}%
+ \toks1=\expandafter{\pgfmathfloatrounddisplaystyle@e@mark #2}%
+ \pgfkeysgetvalue{/pgf/number format/@dec sep mark}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK
+ \toks2=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}%
+ \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 }%
+ \pgfmathprintnumber@endgroup
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+}
+
+\def\pgfmathfloatrounddisplaystyle@std#1#2e#3\relax{%
+ \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{\cdot}{}{10^{#3}}%
+}
+\def\pgfmathfloatrounddisplaystyle@subscript#1#2e#3\relax{%
+ \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}{_{#3}}%
+}
+\def\pgfmathfloatrounddisplaystyle@superscript#1#2e#3\relax{%
+ \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}{^{#3}}%
+}
+\def\pgfmathfloatrounddisplaystyle@e#1#2e#3\relax{%
+ \ifnum#3<0\relax
+ \pgfmathprintnumber@begingroup
+ \count0=#3\relax
+ \multiply\count0 by-1
+ \xdef\pgfmathfloat@glob@TMP{e{-}\the\count0}%
+ \pgfmathprintnumber@endgroup%
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+ \else
+ \def\pgfmathresult{e{+}#3}%
+ \fi
+ \def\pgfmathfloat@loc@TMPb{\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}}%
+ \expandafter\pgfmathfloat@loc@TMPb\expandafter{\pgfmathresult}%
+}
+\def\pgfmathfloatrounddisplaystyle@E#1#2e#3\relax{%
+ \ifnum#3<0\relax
+ \pgfmathprintnumber@begingroup
+ \count0=#3\relax
+ \multiply\count0 by-1
+ \xdef\pgfmathfloat@glob@TMP{E{-}\the\count0}%
+ \pgfmathprintnumber@endgroup%
+ \let\pgfmathresult=\pgfmathfloat@glob@TMP
+ \else
+ \def\pgfmathresult{E{+}#3}%
+ \fi
+ \def\pgfmathfloat@loc@TMPb{\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}}%
+ \expandafter\pgfmathfloat@loc@TMPb\expandafter{\pgfmathresult}%
+}
+
+\def\pgfmathfloatrounddisplaystyle@generic#1#2e#3\relax{%
+ \begingroup
+ \pgfkeysvalueof {/pgf/number format/sci generic/@/.@cmd}{#3}{#1}{#2}\pgfeov
+ \pgfkeysgetvalue{/pgf/number format/sci generic/mantissa sep}\pgfmathdisplay@aftermantissa
+ \pgfkeysgetvalue{/pgf/number format/sci generic/empty mantissa sep}\pgfmathdisplay@nomantissa
+ \pgfkeysgetvalue{/pgf/number format/sci generic/exponent}\pgfmathdisplay@e
+ \toks0=\expandafter{\pgfmathdisplay@aftermantissa}%
+ \toks1=\expandafter{\pgfmathdisplay@nomantissa}%
+ \toks2=\expandafter{\pgfmathdisplay@e}%
+ \xdef\pgfmathfloat@glob@TMP{\noexpand\pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\noexpand\relax{\the\toks0}{\the\toks1}{\the\toks2}}%
+ \endgroup
+ \pgfmathfloat@glob@TMP
+}
+
+% A macro which takes the argument '<SIGN><MANTISSE>e<EXPONENT>' and
+% expands to the final TeX-representation for that floating point
+% number.
+%
+% PRECONDITION:
+% the floating point number has already been rounded properly and
+% the mantissa has been rounded correcty.
+%
+% The argument needs to be in the format returned by
+% \pgfmathfloat@to@FMeE@style and terminated by '\relax'.
+\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std
+\newif\ifpgfmathfloat@usezerofill@sci
+\newif\ifpgfmathfloat@usezerofill@fixed
+\newif\ifpgfmathprintnumber@assumemathmode
+\newif\ifpgfmathprintnumber@showpositive
+\newif\ifpgfmathprintnumber@frac@warn
+\newif\ifpgfmathprintnumber@frac@whole
+\newif\ifpgfmathparsenumber@comma@as@period
+
+\long\def\pgfmathfloatfrac@verbatim#1#2{#1/#2}%
+
+\let\pgfmathround@@orig=\pgfmathround@
+
+% 2 = compatible
+% 0 = no
+% 1 = yes
+\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed{2}%
+
+\newif\ifpgfmathprintnumber@thousand@sep@in@fractional
+\pgfkeys{%
+ /pgf/number format/.is family,
+ /pgf/number format,
+ fixed/.code= \pgfmath@set@number@printer{pgfmathprintnumber@FIXED},
+ sci/.code= \pgfmath@set@number@printer{pgfmathprintnumber@SCI},
+ std/.code= {\pgfmath@set@number@printer{pgfmathprintnumber@STD}\pgfmathprintnumber@STD@setparam{#1}},
+ std/.default=,%
+ relative round mode/.is choice,
+ relative round mode/fixed/.code={\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed{1}},
+ relative round mode/mantissa/.code={\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed{0}},
+ relative round mode/compatible/.code={\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed{2}},
+ % relative={<exponent base 10>}
+ relative/.code= {%
+ \pgfmath@set@number@printer{pgfmathprintnumber@RELATIVE}%
+ \pgfmathround@@orig{#1}%
+ \expandafter\pgfmathfloattoint@@\pgfmathresult\relax
+ \let\pgfmathprintnumber@RELATIVE@param=\pgfmathresult
+ },%
+ relative/.value required,
+ relative*/.style={/pgf/number format/relative={#1},/pgf/number format/relative round mode=fixed},
+ every relative/.style=std,
+ relative style/.style={/pgf/number format/every relative/.append style={#1}},
+ fixed relative/.code= \pgfmath@set@number@printer{pgfmathprintnumber@FIXED@RELATIVE},
+ int detect/.code= \pgfmath@set@number@printer{pgfmathprintnumber@INT@DETECT},
+ int trunc/.code= \pgfmath@set@number@printer{pgfmathprintnumber@INT@TRUNC},
+ frac/.code= \pgfmath@set@number@printer{pgfmathprintnumber@frac},%
+ frac TeX/.initial=\frac,
+ frac whole format/.code={\def\pgfmathresult{#1}},
+ frac denom/.initial=,
+ frac whole/.is if=pgfmathprintnumber@frac@whole,
+ frac whole=true,
+ frac shift/.initial=4,
+ frac warning/.is if=pgfmathprintnumber@frac@warn,
+ frac warning=true,
+ assume math mode/.is if=pgfmathprintnumber@assumemathmode,
+ assume math mode/.default=true,
+ fixed zerofill/.is if= pgfmathfloat@usezerofill@fixed,
+ fixed zerofill/.default=true,
+ sci zerofill/.is if= pgfmathfloat@usezerofill@sci,
+ sci zerofill/.default=true,
+ zerofill/.style= {/pgf/number format/fixed zerofill=#1,/pgf/number format/sci zerofill=#1},
+ zerofill/.default= true,
+ precision/.store in= \pgfmathfloat@round@precision,
+ sci precision/.code={%
+ \edef\pgfmathfloat@loc@TMPa{#1}%
+ \ifx\pgfmathfloat@loc@TMPa\pgfutil@empty
+ \def\pgfmathprintnumber@sci@precision{\pgfmathfloat@round@precision}%
+ \else
+ \let\pgfmathprintnumber@sci@precision=\pgfmathfloat@loc@TMPa
+ \fi
+ },%
+ sci precision/.default=,
+ sci precision=,
+ fixed default/.code= {\let\pgfmathprintnumber@fixed@style=\pgfmathprintnumber@fixed@styleDEFAULT},
+ set decimal separator/.initial=,
+ dec sep/.style={/pgf/number format/set decimal separator={#1}},
+ @dec sep mark/.initial=,
+ @sci exponent mark/.initial=,
+ set thousands separator/.initial=,
+ 1000 sep in fractionals/.is if=pgfmathprintnumber@thousand@sep@in@fractional,
+ 1000 sep in fractionals/.default=true,
+ 1000 sep/.style={/pgf/number format/set thousands separator={#1}},
+ min exponent for 1000 sep/.initial=0,
+ use period/.style= {/pgf/number format/set decimal separator={.},/pgf/number format/set thousands separator={{{,}}}},
+ use comma/.style= {/pgf/number format/set decimal separator={{{,}}},/pgf/number format/set thousands separator={.}},
+ showpos/.is if=pgfmathprintnumber@showpositive,
+ showpos/.default=true,
+ print sign/.is if=pgfmathprintnumber@showpositive,
+ print sign/.default=true,
+ read comma as period/.is if=pgfmathparsenumber@comma@as@period,
+ read comma as period/.default=true,
+ skip 0./.is if=pgfmathprintnumberskipzeroperiod,
+ skip 0./.default=true,
+ skip 0.= false,
+ use period,
+ sci 10^e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std},
+ sci 10e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std},
+ sci e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@e},
+ sci E/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@E},
+ sci subscript/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@subscript},
+ sci superscript/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@superscript},
+ sci generic/.code= {%
+ \let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@generic
+ \pgfkeysdefargs{/pgf/number format/sci generic/@}%
+ {##1##2##3}%
+ {\pgfqkeys{/pgf/number format/sci generic}{#1}}%
+ },
+ sci generic/mantissa sep/.initial=,%
+ sci generic/empty mantissa sep/.initial=,%
+ sci generic/mantisse sep/.style={/pgf/number format/sci generic/mantissa sep={#1}},%
+ sci generic/empty mantisse sep/.style={/pgf/number format/sci generic/empty mantissa sep={#1}},%
+ sci generic/exponent/.initial=,%
+ sci generic/.value required,
+ verbatim/.code={%
+ \pgfqkeys{/pgf/number format}{%
+ sci generic={mantissa sep=,exponent={e##1}},
+ 1000 sep=,
+ skip 0.=false,
+ print sign=false,
+ dec sep=.,
+ assume math mode,
+ frac TeX=\pgfmathfloatfrac@verbatim,
+ frac whole format/.code={\def\pgfmathresult{##1 }},
+ @dec sep mark=,
+ @sci exponent mark=,
+ }%
+ },
+% sci may skip mantissa/.is if=pgfmathfloatround@allow@empty@mantissa,
+% sci may skip mantissa/.default=true,
+}
+
+
+
+\def\pgfmathprintnumber@STD#1{%
+ % parse the input:
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathprintnumber@STD@issci\pgfmathresult\relax
+}
+
+\def\pgfmathprintnumber@STD@setparam#1{%
+ \edef\pgfmathfloat@loc@TMPb{#1}%
+ \ifx\pgfmathfloat@loc@TMPb\pgfutil@empty
+ % DEFAULT for lower and upper bound.
+ \def\pgfmathprintnumber@STD@getlowerbound{%
+ \c@pgf@counta=\pgfmathfloat@round@precision@orig\relax
+ \divide\c@pgf@counta by-2\relax
+ }%
+ \def\pgfmathprintnumber@STD@upperbound{4}%
+ \else
+ \expandafter\pgfutil@in@\expandafter:\expandafter{\pgfmathfloat@loc@TMPb}%
+ \ifpgfutil@in@
+ % we have -4:5 or something like that.
+ % parse both values:
+ \def\pgfmathfloat@loc@TMPa##1:##2\relax{%
+ \edef\pgfmathprintnumber@STD@getlowerbound{%
+ \noexpand\c@pgf@counta=##1\space
+ }%
+ \edef\pgfmathprintnumber@STD@upperbound{##2}%
+ }%
+ \expandafter\pgfmathfloat@loc@TMPa\pgfmathfloat@loc@TMPb\relax
+ \else
+ % we have just the lower bound:
+ \def\pgfmathprintnumber@STD@upperbound{4}%
+ \edef\pgfmathprintnumber@STD@getlowerbound{%
+ \noexpand\c@pgf@counta=\pgfmathfloat@loc@TMPb\space
+ }%
+ \fi
+ \fi
+}%
+
+\def\pgfmathprintnumber@STD@issci#1#2e#3\relax{%
+ \expandafter\ifnum#1<3
+ \expandafter\ifnum#3>\pgfmathprintnumber@STD@upperbound\relax
+ \pgfmathprintnumber@SCI@issci#1#2e#3\relax%
+ \else
+ \begingroup
+ \pgfmathprintnumber@STD@getlowerbound
+ \ifnum#3<\c@pgf@counta
+ \pgfmathprintnumber@SCI@issci#1#2e#3\relax%
+ \else
+ \pgfmathprintnumber@FIXED@issci#1#2e#3\relax%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \fi
+ \else% nan or inf:
+ \pgfmathfloatrounddisplaystyle#1#2e#3\relax%
+ \fi
+}
+
+\def\pgfmathprintnumber@RELATIVE#1{%
+ % parse the input:
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathprintnumber@RELATIVE@issci\pgfmathresult\relax
+}
+
+\def\pgfmathprintnumber@RELATIVE@choice@roundtofixed@warn{%
+ \immediate\write16{! Package pgf warning: the use of /pgf/number format/relative is discouraged (buggy). Please use 'relative*' instead or type \string\pgfkeys{/pgf/number format/relative round mode=fixed} into your preamble.}%
+ \global\let\pgfmathprintnumber@RELATIVE@choice@roundtofixed@warn=\relax
+}
+
+\def\pgfmathprintnumber@RELATIVE@issci#1#2e#3\relax{%
+ \begingroup
+ % format X / 10^{relative}:
+ \c@pgf@counta=#3\relax
+ \advance\c@pgf@counta by-\pgfmathprintnumber@RELATIVE@param\relax
+ \pgfmathfloatcreate{#1}{#2}{\the\c@pgf@counta}%
+ % OK, round it to the desired precision:
+ \if0\pgfmathprintnumber@RELATIVE@choice@roundtofixed
+ % relative round mode=mantissa
+ \def\b@round@fixed{0}%
+ \else
+ \if1\pgfmathprintnumber@RELATIVE@choice@roundtofixed
+ % relative round mode=fixed
+ \def\b@round@fixed{1}%
+ \else
+ \pgfmathprintnumber@RELATIVE@choice@roundtofixed@warn
+ % relative round mode=compatible
+ \ifnum\c@pgf@counta>0
+ % hm. for positive exponents, we should round the
+ % mantissa rather than only the fractional part.
+ \def\b@round@fixed{0}%
+ \else
+ % negative exponent -> round fixed representation:
+ \def\b@round@fixed{1}%
+ \fi
+ \fi
+ \fi
+ \if1\b@round@fixed
+ % round fixed representation:
+ \pgfmathfloattofixed\pgfmathresult
+ \expandafter\pgfmathroundto\expandafter{\pgfmathresult}%
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \pgfmathfloatroundhasperiodtrue% make sure the code below works:
+ \else
+ % round the mantissa:
+ \expandafter\pgfmathfloatround\expandafter{\pgfmathresult}%
+ \fi
+ % Now, compute result * 10^{relative} and format the result:
+ \pgfmathfloattoregisterstok\pgfmathresult\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifnum\pgfmathfloat@a@S=0
+ \pgfmathfloat@a@E=\pgfmathfloat@a@S % avoid 0 * 10^8
+ \else
+ \advance\pgfmathfloat@a@E by+\pgfmathprintnumber@RELATIVE@param\relax
+ \fi
+ \edef\pgfmathresultX{%
+ \the\pgfmathfloat@a@S
+ \the\pgfmathfloat@a@Mtok
+ \ifpgfmathfloatroundhasperiod\else.0\fi
+ e\the\pgfmathfloat@a@E}%
+ % call another formatter for the result (but avoid rounding inside of it):
+ \pgfqkeys{/pgf/number format}{/pgf/number format/every relative,
+ fixed zerofill=false,% useless here!
+ sci zerofill=false}%
+ \ifx\pgfmathprintnumber@issci\pgfmathprintnumber@RELATIVE@issci
+ \pgfmath@error{The '/pgf/number format/every relative' style should set a valid display style}%
+ \fi
+ \let\pgfmathfloat@round@precision@orig=\pgfmathfloat@round@precision
+ \def\pgfmathfloat@round@precision{9999}%
+ \expandafter\pgfmathprintnumber@issci\pgfmathresultX\relax%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+\def\pgfmathprintnumber@FIXED@RELATIVE#1{%
+ % parse the input:
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathprintnumber@FIXED@RELATIVE@issci\pgfmathresult\relax
+}
+
+\def\pgfmathprintnumber@FIXED@RELATIVE@issci#1#2e#3\relax{%
+ \begingroup
+ \pgfmathfloatcreate{#1}{#2}{#3}%
+ % we want the first <precision> digits - not the first
+ % <precision>+1 digits:
+ \c@pgf@counta=\pgfmathfloat@round@precision\relax
+ \advance\c@pgf@counta by-1
+ \edef\pgfmathfloat@round@precision{\the\c@pgf@counta}%
+ \pgfmathfloatround{\pgfmathresult}%
+ \pgfmathfloattoregisterstok\pgfmathresult\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \ifnum\pgfmathfloat@a@S=0
+ \pgfmathfloat@a@E=\pgfmathfloat@a@S % avoid 0 * 10^8
+ \fi
+ \edef\pgfmathresultX{%
+ \the\pgfmathfloat@a@S
+ \the\pgfmathfloat@a@Mtok
+ \ifpgfmathfloatroundhasperiod\else.0\fi
+ e\the\pgfmathfloat@a@E}%
+ \let\pgfmathfloat@round@precision@orig=\pgfmathfloat@round@precision
+ \pgfmathfloat@usezerofill@fixedfalse
+ \def\pgfmathfloat@round@precision{9999}% typeset all remaining digits!
+ \expandafter\pgfmathprintnumber@FIXED@issci\pgfmathresultX\relax%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+\def\pgfmathprintnumber@frac#1{%
+ % parse the input:
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloatgetfrac{\pgfmathresult}%
+ \expandafter\pgfmathprintnumber@frac@formatresult\pgfmathresult
+}
+\def\pgfmathprintnumber@frac@issci#1#2e#3\relax{%
+ \pgfmathfloatcreate{#1}{#2}{#3}%
+ \pgfmathfloatgetfrac{\pgfmathresult}%
+ \expandafter\pgfmathprintnumber@frac@formatresult\pgfmathresult
+}
+\def\pgfmathprintnumber@frac@formatresult#1#2#3{%
+ \begingroup
+ \pgfkeysgetvalue{/pgf/number format/frac TeX}\pgfmathresult
+ \toks0=\expandafter{\pgfmathresult}%
+ \def\pgfmathfloat@loc@TMPa{#1}%
+ \ifx\pgfmathfloat@loc@TMPa\pgfutil@empty
+ \ifpgfmathprintnumber@showpositive
+ \def\pgfmathfloat@loc@TMPa{+}%
+ \fi
+ \else
+ \ifx\pgfmathfloat@loc@TMPa-%
+ \else
+ \ifx\pgfmathfloat@loc@TMPa+%
+ \else
+ \ifpgfmathprintnumber@showpositive
+ \edef\pgfmathfloat@loc@TMPa{+\pgfmathfloat@loc@TMPa}%
+ \fi
+ \def\pgfmathfloat@loc@TMPb{\pgfkeysvalueof{/pgf/number format/frac whole format/.@cmd}}%
+ \expandafter\pgfmathfloat@loc@TMPb\pgfmathfloat@loc@TMPa\pgfeov
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \fi
+ \fi
+ \fi
+ \toks1=\expandafter{\pgfmathfloat@loc@TMPa}%
+ \edef\pgfmathresult{%
+ \the\toks1 \ifnum#2=0 \else\the\toks0 {#2}{#3}\fi%
+ }%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% Defines \pgfmathresult to contain three sets of braces containing
+% the sign (optionally containing any components >1), the numerator and the denominator for #1.
+%
+% \pgfmathfloatgetfrac{0.5} -> \pgfmathresult contains {}{1}{2}
+% \pgfmathfloatgetfrac{-0.5} -> \pgfmathresult contains {-}{1}{2}
+% \pgfmathfloatgetfrac{1.5} -> \pgfmathresult contains {1}{1}{2}
+%
+% special cases:
+% \pgfmathfloatgetfrac{0} -> \pgfmathresult contains {0}{0}{1}
+% \pgfmathfloatgetfrac{1} -> \pgfmathresult contains {1}{0}{1}
+%
+% The numerator and denominator is always a number (not empty)
+\def\pgfmathfloatgetfrac#1{%
+ \pgfutil@ifundefined{pgfmathfloatmultiply@}{%
+ \pgfmath@PackageError{Sorry, the number format 'frac' requires '\string\usetikzlibrary{fpu}' (and, optionally, \string\usepackage{fp}) in order to work correctly}%
+ \edef\pgfmathresult{{#1}{0}{1}}%
+ }{%
+ \pgfmathfloatgetfrac@{#1}%
+ }%
+}%
+\def\pgfmathfloatgetfrac@#1{%
+ \begingroup
+ \edef\pgfmathfloat@arg{#1}%
+ \expandafter\pgfmathfloat@decompose@tok\pgfmathfloat@arg\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \def\pgfmathfloat@loc@TMPa{0}%
+ \ifcase\pgfmathfloat@a@S
+ % #1 = 0:
+ \def\pgfmathresult{{0}{0}{1}}%
+ \or% #1 > 0
+ \pgfmathfloat@a@S=1
+ \def\pgfmathfloat@loc@TMPa{1}%
+ \or% #1 < 0
+ \pgfmathfloat@a@S=-1
+ \def\pgfmathfloat@loc@TMPa{1}%
+ \or
+ \edef\pgfmathresult{{}{NaN}{1}}%
+ \or
+ \edef\pgfmathresult{{}{\infty}{1}}%
+ \or
+ \edef\pgfmathresult{{-}{\infty}{1}}%
+ \fi
+ \if1\pgfmathfloat@loc@TMPa
+ \ifnum\pgfmathfloat@a@E<0
+ \def\pgfmathfloat@wholenumber{}%
+ \else
+ \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \pgfmathfloattofixed\pgfmathresult%
+ \def\pgfmathfloat@loc@TMPa##1.##2\relax{%
+ \def\pgfmathfloat@wholenumber{##1}%
+ \pgfmathfloatparsenumber{0.##2}%
+ }%
+ \expandafter\pgfmathfloat@loc@TMPa\pgfmathresult\relax
+ \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \fi
+ %
+ \def\pgfmathfloat@loc@TMPa##1.##2\relax{%
+ \def\pgfmathfloat@mantissa@first{##1}%
+ \def\pgfmathfloat@mantissa@ltone{0.##2}%
+ }%
+ \expandafter\pgfmathfloat@loc@TMPa\the\pgfmathfloat@a@Mtok\relax
+ %
+ \def\pgfmathfloat@loc@@to@int##1.##2\relax##3{%
+ ##3=##1
+ \ifdim0.##2pt>0.5pt
+ \advance##3 by1
+ \fi
+ }%
+ %
+ % alias registers names:
+ \let\pgfmathresultnumerator=\pgfmathfloat@b@S
+ \let\pgfmathresultdenom=\pgfmathfloat@b@E
+ %
+ \pgfkeysgetvalue{/pgf/number format/frac denom}\pgfmath@target@denominator
+ \ifx\pgfmath@target@denominator\pgfutil@empty
+ %
+ \pgfmathfloat@a@E=-\pgfmathfloat@a@E
+ \ifdim\pgfmathfloat@mantissa@ltone pt=0pt
+ \def\pgfmathfloat@factor{1}%
+ \edef\pgfmathfloat@scaled@numerator{\the\pgfmathfloat@a@Mtok}%
+ \else
+ % FIXME : this here is numerically instable.
+ %
+ % The errors of 1/r are magnified by 10^k which
+ % doesn't work.
+ \pgfutil@ifundefined{FPdiv}{%
+ \pgfmathfloatparsenumber{\pgfmathfloat@mantissa@ltone}%
+ \pgfmathfloatreciprocal@{\pgfmathresult}%
+ }{%
+ % \usepackage{fp}.
+ % yields higher absolute precision.
+ \FPmessagesfalse%
+ \FPdebugfalse%
+ \FPdiv\pgfmathresult{1}{\pgfmathfloat@mantissa@ltone}%
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ }%
+ \let\pgfmathfloat@inv=\pgfmathresult
+ \pgfmathfloatcreate{1}{1.0}{\pgfkeysvalueof{/pgf/number format/frac shift}}%
+ \let\pgfmathfloat@scalebaseten=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfmathfloat@inv}{\pgfmathfloat@scalebaseten}%
+ \let\pgfmathfloat@factor=\pgfmathresult
+ %
+ \expandafter\pgfmathfloatparsenumber\expandafter{\the\pgfmathfloat@a@Mtok}%
+ \let\pgfmathfloat@loc@TMPa=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfmathfloat@factor}{\pgfmathfloat@loc@TMPa}%
+ \pgfmathfloattofixed\pgfmathresult
+ \let\pgfmathfloat@scaled@numerator=\pgfmathresult
+ %
+ \pgfmathfloattofixed\pgfmathfloat@factor
+ \expandafter\pgfmathfloat@loc@@to@int\pgfmathresult\relax{\pgfmathfloat@b@S}%
+ \edef\pgfmathfloat@factor{\the\pgfmathfloat@b@S}%
+ \fi
+ %
+ %
+ \pgfmathresultdenom=\pgfmathfloat@factor\relax
+ \pgfmathfloat@multiply@ten@to@the@E\pgfmathresultdenom
+ %
+ \expandafter\pgfmathfloat@loc@@to@int\pgfmathfloat@scaled@numerator\relax{\pgfmathresultnumerator}%
+ %\message{scale = \pgfmathfloat@factor; Z = \the\pgfmathresultnumerator\space ( von \pgfmathfloat@scaled@numerator), N = \the\pgfmathresultdenom.}%
+ %
+ \pgfmathgreatestcommondivisor{\pgfmathresultnumerator}{\pgfmathresultdenom}%
+ \divide\pgfmathresultnumerator by\pgfmathresult\relax
+ \divide\pgfmathresultdenom by\pgfmathresult\relax
+ \ifpgfmathprintnumber@frac@warn
+ \ifnum\pgfmathresultdenom>1000
+ \pgfutil@ifundefined{FPdiv}{%
+ \pgfmathfloattosci@\pgfmathfloat@arg
+ \immediate\write16{! Package pgf /pgf/number format/frac warning=true: /pgf/number format/frac of `\pgfmathresult' = \the\pgfmathresultnumerator\space / \the\pgfmathresultdenom\space might be large due to instabilities. Try \string\usepackage{fp} to improve accuracy.}%
+ }{}%
+ \fi
+ \fi
+ \else
+ % use target denominator:
+ \pgfmathresultdenom=\pgfmath@target@denominator\relax
+ \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
+ \pgfmathfloattofixed\pgfmathresult
+ \pgf@xa=\pgfmathresult pt
+ \multiply\pgf@xa by\pgfmathresultdenom
+ \edef\pgfmathfloat@scaled@numerator{\pgf@sys@tonumber\pgf@xa}%
+ \expandafter\pgfmathfloat@loc@@to@int\pgfmathfloat@scaled@numerator\relax{\pgfmathresultnumerator}%
+ \fi
+ \ifpgfmathprintnumber@frac@whole
+ \else
+ \ifx\pgfmathfloat@wholenumber\pgfutil@empty
+ \else
+ \count0=\pgfmathfloat@wholenumber\relax
+ \multiply\count0 by\pgfmathresultdenom
+ \advance\pgfmathresultnumerator by\count0
+ \def\pgfmathfloat@wholenumber{}%
+ \fi
+ \fi
+ \ifnum\pgfmathfloat@a@S<0
+ \edef\pgfmathresult{{-\pgfmathfloat@wholenumber}{\the\pgfmathresultnumerator}{\the\pgfmathresultdenom}}%
+ \else
+ \edef\pgfmathresult{{\pgfmathfloat@wholenumber}{\the\pgfmathresultnumerator}{\the\pgfmathresultdenom}}%
+ \fi
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\def\pgfmathfloat@gobble@until@relax#1\relax{}
+
+% computes the greatest common divisor of two integer numbers (in
+% integer arithmetics).
+\def\pgfmathgreatestcommondivisor#1#2{%
+ \begingroup
+ \count0=#1\relax
+ \count1=#2\relax
+ \ifnum\count0=0
+ \edef\pgfmathresult{\the\count1}%
+ \else
+ \pgfmathgreatestcommondivisor@loop
+ \edef\pgfmathresult{\the\count0}%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+\def\pgfmathgreatestcommondivisor@loop{%
+ \ifnum\count1=0
+ \else
+ \ifnum\count0>\count1
+ \advance\count0 by-\count1
+ \else
+ \advance\count1 by-\count0
+ \fi
+ \expandafter\pgfmathgreatestcommondivisor@loop
+ \fi
+}%
+
+% multiplies a TeX register by 10^E where E is stored in the register
+% \pgfmathfloat@a@E (and it should be positive!)%
+%
+% #1 a TeX register
+\def\pgfmathfloat@multiply@ten@to@the@E#1{%
+ \ifnum\pgfmathfloat@a@E>0
+ \multiply#1 by10
+ \advance\pgfmathfloat@a@E by-1
+ \def\pgfmathfloat@multiply@ten@to@the@E@next{\pgfmathfloat@multiply@ten@to@the@E{#1}}%
+ \else
+ \let\pgfmathfloat@multiply@ten@to@the@E@next=\relax%
+ \fi
+ \pgfmathfloat@multiply@ten@to@the@E@next
+}%
+
+\def\pgfmathprintnumber@INT@TRUNC#1{%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathprintnumber@INT@TRUNC@issci\pgfmathresult\relax
+}
+
+\def\pgfmathprintnumber@INT@TRUNC@impl#1.#2\relax#3#4e#5\relax{%
+ \pgfmathfloatroundhasperiodfalse
+ \pgfmathprintnumber@fixed@style{#1}#3#4e#5\relax%
+}
+\def\pgfmathprintnumber@INT@TRUNC@issci#1#2e#3\relax{%
+ \ifnum#1<3\relax
+ \pgfmathfloatcreate{#1}{#2}{#3}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \expandafter\pgfmathprintnumber@INT@TRUNC@impl\pgfmathresult\relax#1#2e#3\relax
+ \else
+ \pgfmathfloatrounddisplaystyle#1#2e#3\relax%
+ \fi
+}
+
+% Invokes '#2' if '#1' is actually an integer or '#3' if not.
+%
+% As a side--effect, \pgfretval will be set to the integer value if it
+% actually *is* an integer. Otherwise, \pgfretval will contain the
+% parsed floating point number.
+%
+% #1 a number constant (not necessarily a parsed float).
+\def\pgfmathifisint#1#2#3{%
+ \gdef\pgfmathfloatisint@@{0}%
+ \begingroup
+ \pgfmathfloatparsenumber{#1}%
+ \let\pgfretval\pgfmathresult
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathfloatisint@\pgfmathresult\relax
+ \pgfmath@smuggleone\pgfretval
+ \endgroup
+ \if1\pgfmathfloatisint@@ #2\else #3\fi
+}%
+\def\pgfmathfloatisint@#1#2e#3\relax{%
+ \ifnum#1<3\relax
+ \pgfmathfloatcreate{#1}{#2}{#3}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \def\pgfmathfloat@round@precision{6}%
+ \expandafter\pgfmathroundto\expandafter{\pgfmathresult}%
+ \ifpgfmathfloatroundhasperiod
+ \else
+ \let\pgfretval\pgfmathresult%
+ \gdef\pgfmathfloatisint@@{1}%
+ \fi
+ \fi
+}
+
+\def\pgfmathprintnumber@INT@DETECT#1{%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathprintnumber@INT@DETECT@issci\pgfmathresult\relax
+}
+
+\def\pgfmathprintnumber@INT@DETECT@issci#1#2e#3\relax{%
+ \begingroup
+ \ifnum#1<3\relax
+ \pgfmathfloatcreate{#1}{#2}{#3}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \let\pgfmathfloat@round@precision@=\pgfmathfloat@round@precision
+ \def\pgfmathfloat@round@precision{6}%
+ \expandafter\pgfmathroundto\expandafter{\pgfmathresult}%
+ \let\pgfmathfloat@round@precision=\pgfmathfloat@round@precision@
+ \ifpgfmathfloatroundhasperiod
+ \pgfmathprintnumber@SCI@issci#1#2e#3\relax
+ \else
+ \expandafter\pgfmathprintnumber@fixed@style\expandafter{\pgfmathresult}#1#2e#3\relax
+ \fi
+ \else
+ \pgfmathfloatrounddisplaystyle#1#2e#3\relax%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+\def\pgfmathprintnumber@FIXED#1{%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathprintnumber@FIXED@issci\pgfmathresult\relax
+}
+
+\def\pgfmathprintnumber@FIXED@issci#1#2e#3\relax{%
+ \begingroup
+ \ifnum#1<3
+ \pgfmathfloatcreate{#1}{#2}{#3}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \ifpgfmathfloat@usezerofill@fixed
+ \expandafter\pgfmathroundtozerofill\expandafter{\pgfmathresult}%
+ \else
+ \expandafter\pgfmathroundto\expandafter{\pgfmathresult}%
+ \fi
+ \ifpgfmathfloatroundmayneedrenormalize
+ \pgfmathfloat@a@E=#3\relax
+ \advance\pgfmathfloat@a@E by1
+ \edef\pgfmathfloat@loc@TMPb{\noexpand\pgfmathprintnumber@fixed@style{\pgfmathresult}#1#2e\the\pgfmathfloat@a@E}%
+ \pgfmathfloat@loc@TMPb\relax%
+ \else
+ \expandafter\pgfmathprintnumber@fixed@style\expandafter{\pgfmathresult}#1#2e#3\relax%
+ \fi
+ \else% nan or inf:
+ \pgfmathfloatrounddisplaystyle#1#2e#3\relax%
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+
+\def\pgfmathprintnumber@SCI#1{%
+ \pgfmathfloatparsenumber{#1}%
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathprintnumber@SCI@issci\pgfmathresult\relax
+}
+
+\def\pgfmathprintnumber@SCI@issci#1#2e#3\relax{%
+ \begingroup
+ \pgfmathfloatcreate{#1}{#2}{#3}%
+ \edef\pgfmathfloat@round@precision{\pgfmathprintnumber@sci@precision}%
+ \ifpgfmathfloat@usezerofill@sci
+ \pgfmathfloatroundzerofill{\pgfmathresult}%
+ \else
+ \pgfmathfloatround{\pgfmathresult}%
+ \fi
+ \pgfmathfloat@to@FMeE@style\pgfmathresult
+ \expandafter\pgfmathfloatrounddisplaystyle\pgfmathresult\relax
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}
+
+% Prints argument #1 using the current pretty printer environment (all
+% variables in /pgf/number format).
+%
+% You may specify optional arguments with \pgfmathprintnumber[...].
+\def\pgfmathprintnumber{%
+ % \protect allows to supply \pgfmathprintnumber inside of latex
+ % captions. The \csname yields \relax in case protect is undefined.
+ \pgf@texdist@protect\pgfmathprintnumber@protected
+}%
+\def\pgfmathprintnumber@protected{%
+ \pgfutil@ifnextchar[%
+ {\pgfmathprintnumber@OPT}%
+ {\pgfmathprintnumber@noopt}%
+}
+
+\def\pgfmathprintnumber@noopt#1{%
+ \pgfmathprintnumber@{#1}%
+ \ifpgfmathprintnumber@assumemathmode
+ \pgfmathresult
+ \else
+ \pgfutilensuremath{\pgfmathresult}%
+ \fi
+}%
+\def\pgfmathprintnumber@OPT[#1]#2{%
+ \begingroup
+ \pgfqkeys{/pgf/number format}{#1}%
+ \pgfmathprintnumber@{#2}%
+ \ifpgfmathprintnumber@assumemathmode
+ \pgfmathresult
+ \else
+ \pgfutilensuremath{\pgfmathresult}%
+ \fi
+ \endgroup
+}%
+
+% As \pgfmathprintnumber, but it produces its output into the second
+% argument.
+\def\pgfmathprintnumberto{%
+ \pgfutil@ifnextchar[%
+ {\pgfmathprintnumberto@OPT}%
+ {\pgfmathprintnumberto@noopt}%
+}
+
+\def\pgfmathprintnumberto@noopt#1#2{%
+ \begingroup
+ \pgfmathprintnumber@{#1}%
+ \ifpgfmathprintnumber@assumemathmode
+ \global\let\pgfmathfloat@glob@TMP=\pgfmathresult
+ \else
+ \toks0=\expandafter{\pgfmathresult}%
+ \xdef\pgfmathfloat@glob@TMP{\noexpand\pgfutilensuremath{\the\toks0 }}%
+ \fi
+ \endgroup
+ \let#2=\pgfmathfloat@glob@TMP
+}%
+\def\pgfmathprintnumberto@OPT[#1]#2#3{%
+ \begingroup
+ \pgfqkeys{/pgf/number format}{#1}%
+ \pgfmathprintnumber@{#2}%
+ \ifpgfmathprintnumber@assumemathmode
+ \global\let\pgfmathfloat@glob@TMP=\pgfmathresult
+ \else
+ \toks0=\expandafter{\pgfmathresult}%
+ \xdef\pgfmathfloat@glob@TMP{\noexpand\pgfutilensuremath{\the\toks0 }}%
+ \fi
+ \endgroup
+ \let#3=\pgfmathfloat@glob@TMP
+}%
+
+
+% Changes the current number pretty printer to #1.
+%
+% #1 is the macro base name for the pretty print routine, without the
+% leading '\'.
+\def\pgfmath@set@number@printer#1{%
+ \expandafter\let\expandafter\pgfmathprintnumber@\csname #1\endcsname
+ \expandafter\let\expandafter\pgfmathprintnumber@issci\csname #1@issci\endcsname
+}
+
+\pgfkeys{/pgf/number format/std}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% IMPL
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% equals only itsself when compared with \ifx:
+\def\pgfmathfloat@EOI{\pgfmathfloat@EOI}%
+
+% Re-use counters internally.
+%
+% They are always grouped and only used inside of the rounding
+% routines.
+\let\c@pgfmathroundto@prec=\pgfmathfloat@b@S% ATTENTION: DOUBLE-USED REGISTERS!
+\let\c@pgfmathroundto@offsetbehindperiod=\pgfmathfloat@b@E
+\newcount\c@pgfmathroundto@lastzeros
+
+\newif\ifpgfmathround@impl@PREPERIOD@is@negative@zero
+
+% PRECONDITION:
+% \ifpgfmathfloatroundhasperiod=\iftrue holds outside of the
+% current TeX group.
+%
+% POSTCONDITION:
+% \ifpgfmathfloatroundhasperiod will be set correctly AFTER the
+% current TeX group.
+% \ifpgfmathfloatroundmayneedrenormalize will be set globally
+\def\pgfmathroundto@impl#1{%
+ \edef\pgfmathround@input{#1}%
+ \global\pgfmathfloatroundmayneedrenormalizefalse
+ \pgfmathfloat@tmptoks={}%
+ \let\pgfmathround@next=\pgfutil@empty
+ \let\pgfmathround@cur=\pgfutil@empty
+ \let\pgfmathresult=\pgfutil@empty
+ \expandafter\c@pgfmathroundto@prec\pgfmathfloat@round@precision\relax
+ \c@pgfmathroundto@lastzeros=0
+ \c@pgfmathroundto@offsetbehindperiod=-1 % means: no period found so far
+ \pgfmathround@impl@PREPERIOD@is@negative@zerotrue
+ \expandafter\pgfmathroundto@impl@ITERATE@NODOT@firstcall\pgfmathround@input\pgfmathfloat@EOI
+}
+
+% \pgfmathroundto implementation in WORDS:
+%
+% coarse idea:
+% 1. collect all digits/sign BEFORE the first period in REVERSE order
+% 2. then, collect UP TO \prec digits after the period in REVERSE order
+% Steps 1. and 2. lead to the digit [sign] sequence
+% "x_{-p} x_{-p+1} ... x_{-2} x_{-1} '.' x_0 ... x_r"
+% where 'r' is the total number of digits. The integer 'p' denotes the
+% ACTUALLY collected number of digits behind the period.
+%
+% Let 'k' be the desired precision.
+%
+% Please note that pgfmathroundto rounds the mantissa, that means |abs(x)|.
+%
+% There are exactly TWO cases:
+% 1. The case with p<=k and x_{-p-1} = end of input.
+% 2. The case with p=k and x_{-p-1} is a further, next character.
+%
+% Then, for case 1.):
+% discard any unused zeros at the tail of our number (possibly
+% including the period)
+%
+% and in case 2.)
+% if NEXT DIGIT < 5:
+% do exactly the same as in case 1.) above and discard any
+% following digits.
+% else
+% let q := -p
+% while(x_q = 9 and q<=r )
+% if q>=0
+% set x_q = '0'
+% else
+% discard digit x_q='9'
+% fi
+% ++q
+% if q=0
+% discard the period
+% fi
+% end while
+% if q = r+1
+% insert a '1'
+% else
+% set x_q = x_q + 1
+% fi
+% fi
+%
+% All these loops have been implemented in spaghetti-code below.
+% Sorry, I fear its hard to understand. In principle, everything is
+% realised using more or less finite state machines (with some number
+% counting logic).
+%
+% Some comments:
+% - The token register \pgfmathfloat@tmptoks is used to accumulate the REVERSED input number.
+% - \pgfmathfloat@EOI always denotes 'END OF INPUT'.
+% - in the second stage, we need to reverse \pgfmathfloat@tmptoks.
+% This is -again- done with \pgfmathfloat@tmptoks.
+
+\def\pgfmathroundto@impl@discard@period#1.#2\pgfmathfloat@EOI{%
+ \pgfmathfloatroundhasperiodfalse
+ \aftergroup\pgfmathfloatroundhasperiodfalse
+ \def\pgfmathresult{#1}%
+}
+
+\def\pgfmathroundto@impl@gobble@rest@and@start#1\pgfmathfloat@EOI{%
+ \pgfmathroundto@impl@start
+}
+\def\pgfmathroundto@impl@gobble@and@start\pgfmathfloat@EOI{%
+ \pgfmathroundto@impl@start
+}
+\def\pgfmathroundto@impl@gobble\pgfmathfloat@EOI{}%
+\def\pgfmathroundto@impl@gobble@rest#1\pgfmathfloat@EOI{}%
+
+% This method will be invoked as soon as the first step, the reverse
+% collection of up to PREC digits after the period, has finished.
+\def\pgfmathroundto@impl@start{%
+ \ifx\pgfmathround@next\pgfutil@empty
+ \ifnum\c@pgfmathroundto@offsetbehindperiod<0
+ % no period found.
+ \ifpgfmathfloat@fixed@digits@after@period
+ \ifnum\c@pgfmathroundto@prec=0\relax
+ \pgfmathfloatroundhasperiodfalse
+ \aftergroup\pgfmathfloatroundhasperiodfalse
+ \edef\pgfmathresult{\pgfmathround@input}%
+ \else
+ \pgfmathfloat@tmptoks=\expandafter{\pgfmathround@input.}%
+ \c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec
+ \pgfmathroundto@impl@append@zeros
+ \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}%
+ \fi
+ \else
+ \pgfmathfloatroundhasperiodfalse
+ \aftergroup\pgfmathfloatroundhasperiodfalse
+ \edef\pgfmathresult{\pgfmathround@input}%
+ \fi
+ \else
+ %\ifnum\c@pgfmathroundto@offsetbehindperiod>\c@pgfmathroundto@prec
+ % \pgfmath@error{Internal logic error in pgfmathroundto at [I] - should not have happened!?}{}%
+ %\fi
+ \pgfmathroundto@impl@finish@with@truncation
+ \fi
+ \else
+ %\ifnum\c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec
+ %\else
+ % \pgfmath@error{Internal logic error in pgfmathroundto at [II] - should not have happened!? I have offsetbehindperiod=\the\c@pgfmathroundto@offsetbehindperiod and prec = \the\c@pgfmathroundto@prec}{}%
+ %\fi
+ \expandafter\ifnum\pgfmathround@next<5\relax
+ \pgfmathroundto@impl@finish@with@truncation
+ \else
+ \multiply\c@pgfmathroundto@offsetbehindperiod by-1
+ \expandafter\pgfmathroundto@impl@ADD@ONE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI
+ \fi
+ \fi
+}
+
+% takes the current input and decides whether trailing zeros shall be
+% discarded or more zeros need to be filled in.
+\def\pgfmathroundto@impl@finish@with@truncation{%
+ \ifpgfmathfloat@fixed@digits@after@period
+ \expandafter\pgfmathroundto@impl@REVERSE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI
+ \ifnum\c@pgfmathroundto@lastzeros=\c@pgfmathroundto@offsetbehindperiod
+ \ifpgfmathround@impl@PREPERIOD@is@negative@zero
+ % write '0.0000' instead of '-0.0000':
+ \expandafter\pgfmathroundto@impl@discard@minus\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI
+ \fi
+ \fi
+ \ifnum\c@pgfmathroundto@prec=0\relax
+ \expandafter\pgfmathroundto@impl@discard@period\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI
+ \else
+ \advance\c@pgfmathroundto@prec by-\c@pgfmathroundto@offsetbehindperiod
+ \c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec
+ \pgfmathroundto@impl@append@zeros
+ \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}%
+ \fi
+ \else
+ \pgfmathroundto@impl@discard@suffix@zeros
+ \fi
+}
+
+\def\pgfmathroundto@impl@discard@minus-#1\pgfmathfloat@EOI{\pgfmathfloat@tmptoks={#1}}%
+
+% appends \c@pgfmathroundto@offsetbehindperiod zeros at the end of \pgfmathfloat@tmptoks.
+\def\pgfmathroundto@impl@append@zeros{%
+ \ifnum\c@pgfmathroundto@offsetbehindperiod>0
+ \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}%
+ \advance\c@pgfmathroundto@offsetbehindperiod by-1
+ \pgfmathroundto@impl@append@zeros
+ \fi
+}
+
+\def\pgfmathroundto@impl@ADD@ONE{%
+ \pgfmathfloat@tmptoks={}% no longer needed because its old value will be read from input
+ \pgfmathroundto@impl@ADD@ONE@ITERATE
+}
+\def\pgfmathroundto@impl@ADD@ONE@ITERATE{%
+ \pgfutil@ifnextchar\pgfmathfloat@EOI{%
+ \global\pgfmathfloatroundmayneedrenormalizetrue
+ \edef\pgfmathresult{1\the\pgfmathfloat@tmptoks}%
+ \pgfmathroundto@impl@gobble
+ }{%
+ \pgfutil@ifnextchar.{%
+ \ifnum\c@pgfmathroundto@prec=0
+ % silently discard period in special case precision=0
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot}%
+ \else
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@NEXT@COLLECT}%
+ \fi
+ \pgfmathround@nextcmd
+ }{%
+ \pgfutil@ifnextchar+{%
+ \global\pgfmathfloatroundmayneedrenormalizetrue
+ \edef\pgfmathresult{1\the\pgfmathfloat@tmptoks}%
+ \pgfmathroundto@impl@gobble@rest
+ }{%
+ \pgfutil@ifnextchar-{%
+ \global\pgfmathfloatroundmayneedrenormalizetrue
+ \edef\pgfmathresult{-1\the\pgfmathfloat@tmptoks}%
+ \pgfmathroundto@impl@gobble@rest
+ }{%
+ \pgfmathroundto@impl@ADD@ONE@NEXT
+ }%
+ }%
+ }%
+ }%
+}
+
+\def\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot.{%
+ \pgfmathfloatroundhasperiodfalse
+ \aftergroup\pgfmathfloatroundhasperiodfalse
+ \pgfmathroundto@impl@ADD@ONE@ITERATE
+}
+
+\def\pgfmathroundto@impl@ADD@ONE@NEXT@COLLECT#1{%
+ \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}%
+ \pgfmathroundto@impl@ADD@ONE@ITERATE
+}
+\def\pgfmathroundto@impl@ADD@ONE@NEXT#1{%
+ \ifnum#1=9
+ \ifnum\c@pgfmathroundto@offsetbehindperiod<0
+ \ifpgfmathfloat@fixed@digits@after@period
+ \pgfmathfloat@tmptoks=\expandafter{\expandafter0\the\pgfmathfloat@tmptoks}%
+ \else
+ % silently DROP digit
+ \fi
+ \else
+ \pgfmathfloat@tmptoks=\expandafter{\expandafter0\the\pgfmathfloat@tmptoks}%
+ \fi
+ \advance\c@pgfmathroundto@offsetbehindperiod by1
+ \ifnum\c@pgfmathroundto@offsetbehindperiod=0
+ \ifpgfmathfloat@fixed@digits@after@period
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE}%
+ \else
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE@gobble@dot}%
+ \fi
+ \else
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ADD@ONE@ITERATE}%
+ \fi
+ \else
+ % re-use this counter:
+ \c@pgfmathroundto@lastzeros=#1
+ \advance\c@pgfmathroundto@lastzeros by1
+ \edef\pgfmathresult{\the\c@pgfmathroundto@lastzeros\the\pgfmathfloat@tmptoks}%
+ \pgfmathfloat@tmptoks=\expandafter{\pgfmathresult}%
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@REVERSE@ITERATE}%
+ \fi
+ \pgfmathround@nextcmd
+}
+
+
+\def\pgfmathroundto@impl@discard@suffix@zeros{%
+ \ifnum\c@pgfmathroundto@lastzeros=\c@pgfmathroundto@offsetbehindperiod
+ \ifpgfmathround@impl@PREPERIOD@is@negative@zero
+ \pgfmathfloatroundhasperiodfalse
+ \aftergroup\pgfmathfloatroundhasperiodfalse
+ \def\pgfmathresult{0}% write '0' instead of '-0'
+ \else
+ \expandafter\pgfmathroundto@impl@discard@period\pgfmathround@input\pgfmathfloat@EOI
+ \fi
+ \else
+ \ifnum\c@pgfmathroundto@lastzeros=0
+ \expandafter\pgfmathroundto@impl@REVERSE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI
+ \else
+ \expandafter\pgfmathroundto@impl@discard@suffix@zeros@ITERATE\the\pgfmathfloat@tmptoks\pgfmathfloat@EOI
+ \fi
+ \fi
+}
+
+% PRECONDITION:
+% \c@pgfmathroundto@lastzeros > 0
+\def\pgfmathroundto@impl@discard@suffix@zeros@ITERATE#1{%
+ \advance\c@pgfmathroundto@lastzeros by-1
+ \ifnum\c@pgfmathroundto@lastzeros=0
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@REVERSE}%
+ \else
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@discard@suffix@zeros@ITERATE}%
+ \fi
+ \pgfmathround@nextcmd
+}
+
+% Usage:
+% \pgfmathroundto@impl@REVERSE#1\pgfmathfloat@EOI
+% -> writes #1 reversed into \pgfmathfloat@tmptoks
+\def\pgfmathroundto@impl@REVERSE{%
+ \pgfmathfloat@tmptoks={}%
+ \pgfmathroundto@impl@REVERSE@ITERATE
+}
+
+\def\pgfmathroundto@impl@REVERSE@ITERATE{%
+ \pgfutil@ifnextchar\pgfmathfloat@EOI{%
+ \edef\pgfmathresult{\the\pgfmathfloat@tmptoks}%
+ \pgfmathroundto@impl@gobble
+ }{%
+ \pgfmathroundto@impl@REVERSE@NEXT
+ }%
+}
+
+\def\pgfmathroundto@impl@REVERSE@NEXT#1{%
+ \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}%
+ \pgfmathroundto@impl@REVERSE@ITERATE
+}
+
+\def\pgfmathroundto@impl@BEGIN@DOT.{%
+ \pgfmathfloat@tmptoks=\expandafter{\expandafter.\the\pgfmathfloat@tmptoks}%
+ \c@pgfmathroundto@offsetbehindperiod=0
+ \pgfmathroundto@impl@ITERATE@DOT
+}
+\def\pgfmathroundto@impl@ITERATE@DOT{%
+ \pgfutil@ifnextchar\pgfmathfloat@EOI{%
+ % finished.
+ \pgfmathroundto@impl@gobble@and@start
+ }{%
+ \pgfmathroundto@impl@NEXT@DOT
+ }%
+}
+\def\pgfmathroundto@impl@NEXT@DOT#1{%
+ \ifnum\c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec
+ \def\pgfmathround@next{#1}%
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@gobble@rest@and@start}%
+ \else
+ \advance\c@pgfmathroundto@offsetbehindperiod by1
+ \ifnum#1=0
+ \advance\c@pgfmathroundto@lastzeros by1
+ \else
+ \c@pgfmathroundto@lastzeros=0
+ \fi
+ \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}%
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@DOT}%
+ \fi
+ \pgfmathround@nextcmd
+}%
+
+% in contrast to pgfmathroundto@impl@ITERATE@NODOT, this method here
+% checks also for signs
+\def\pgfmathroundto@impl@ITERATE@NODOT@firstcall#1{%
+ \def\pgfmathround@cur{#1}%
+ \ifx\pgfmathround@cur\pgfmathfloat@EOI
+ \pgfmathround@impl@PREPERIOD@is@negative@zerofalse
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@start}%
+ \else
+ \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@PERIOD
+ \pgfmathround@impl@PREPERIOD@is@negative@zerofalse
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@BEGIN@DOT.}%
+ \else
+ \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@MINUS
+ \else
+ \pgfmathround@impl@PREPERIOD@is@negative@zerofalse
+ \fi
+ \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}%
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@NODOT}%
+ \fi
+ \fi
+ \pgfmathround@nextcmd
+}
+
+\def\pgfmathroundto@impl@ITERATE@NODOT#1{%
+ \def\pgfmathround@cur{#1}%
+ \ifx\pgfmathround@cur\pgfmathfloat@EOI
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@start}%
+ \else
+ \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@PERIOD
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@BEGIN@DOT.}%
+ \else
+ \ifx\pgfmathround@cur\pgfmathfloatparsenumber@tok@ZERO
+ \else
+ \pgfmathround@impl@PREPERIOD@is@negative@zerofalse
+ \fi
+ \pgfmathfloat@tmptoks=\expandafter{\expandafter#1\the\pgfmathfloat@tmptoks}%
+ \def\pgfmathround@nextcmd{\pgfmathroundto@impl@ITERATE@NODOT}%
+ \fi
+ \fi
+ \pgfmathround@nextcmd
+}
+
+%--------------------------------------------
+% END of pgfmathroundto implementation.
+%--------------------------------------------
+
+
+% flags, mantissa and exponent has already been stored into
+% \pgfmathfloat@a@* [using ...@Mtok]
+%
+% PRECONDITION:
+% \ifpgfmathfloatroundhasperiod = \iftrue outside of the current
+% group
+%
+% POSTCONDITION:
+% \ifpgfmathfloatroundhasperiod will be set after the current TeX
+% group.
+\def\pgfmathfloatround@impl{%
+ \expandafter\pgfmathroundto@impl\expandafter{\the\pgfmathfloat@a@Mtok}%
+ \ifpgfmathfloatroundmayneedrenormalize
+ \ifpgfmathfloatroundhasperiod
+ \expandafter\pgfmathfloatround@impl@renormalize\pgfmathresult\pgfmathfloat@EOI%
+ \else
+ \expandafter\pgfmathfloatround@impl@renormalize\pgfmathresult.\pgfmathfloat@EOI%
+ \fi
+ \advance\pgfmathfloat@a@E by1
+ \fi
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgfmathresult}{\the\pgfmathfloat@a@E}%
+}
+
+\def\pgfmathfloatround@impl@renormalize#1#2.#3\pgfmathfloat@EOI{%
+ \pgfmathroundto@impl{#1.#2#3}%
+}
+
+
+
+
+
+% ATTENTION: this thing REQUIRES a period in the mantissa!
+% collects everything into \pgfmathresult
+\def\pgfmathfloattofixed@impl#1.#2\relax{%
+ \ifnum\pgfmathfloat@a@E<0
+ \ifcase-\pgfmathfloat@a@E
+ \or%e-1
+ \pgfmathfloat@a@Mtok={0.}%
+ \or%e-2
+ \pgfmathfloat@a@Mtok={0.0}%
+ \or%e-3
+ \pgfmathfloat@a@Mtok={0.00}%
+ \or%e-4
+ \pgfmathfloat@a@Mtok={0.000}%
+ \or%e-5
+ \pgfmathfloat@a@Mtok={0.0000}%
+ \or%e-6
+ \pgfmathfloat@a@Mtok={0.00000}%
+ \or%e-7
+ \pgfmathfloat@a@Mtok={0.000000}%
+ \or%e-8
+ \pgfmathfloat@a@Mtok={0.0000000}%
+ \or%e-9
+ \pgfmathfloat@a@Mtok={0.00000000}%
+ \or%e-10
+ \pgfmathfloat@a@Mtok={0.000000000}%
+ \else%<= -11
+ \pgfmathfloat@a@Mtok={0.0000000000}%
+ \advance\pgfmathfloat@a@E by10
+ \pgfutil@loop
+ \ifnum\pgfmathfloat@a@E<-1
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok 0}%
+ \advance\pgfmathfloat@a@E by1
+ \pgfutil@repeat
+ \fi
+ \def\pgfmathfloat@loc@TMPb{#2}%
+ \def\pgfmathfloat@loc@TMPc{0}%
+ \ifx\pgfmathfloat@loc@TMPb\pgfmathfloat@loc@TMPc
+ \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok #1}%
+ \else
+ \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok #1#2}%
+ \fi
+ \else
+ %--------------------------------------------------
+ % \ifnum\pgfmathfloat@a@E=0%
+ % \edef\pgfmathresult{#1.#2}%
+ % \else
+ % \pgfmathfloat@a@Mtok={#1}%
+ % \pgfmathfloattofixed@impl@collectmantissa#2\count\pgfmathfloat@a@E
+ % \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}%
+ % \fi
+ %--------------------------------------------------
+ \pgfmathfloat@a@Mtok{#1}%
+ \pgfmathfloattofixed@impl@pos#2000000000\pgfmathfloat@EOI
+ \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}%
+ \fi
+}
+
+% FIXME: this implementation here is very fast, but it introduces trailing zeros. Is that acceptable?
+\def\pgfmathfloattofixed@impl@pos#1#2#3#4#5#6#7#8#9\pgfmathfloat@EOI{%
+ \ifcase\pgfmathfloat@a@E
+ % e+0
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok .#1#2#3#4#5#6#7#8#9}%
+ \or%e+1
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1.#2#3#4#5#6#7#8#9}%
+ \or%e+2
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2.#3#4#5#6#7#8#9}%
+ \or%e+3
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3.#4#5#6#7#8#9}%
+ \or%e+4
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4.#5#6#7#8#9}%
+ \or%e+5
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5.#6#7#8#9}%
+ \or%e+6
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6.#7#8#9}%
+ \or%e+7
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7.#8#9}%
+ \or%e+8
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7#8.#9}%
+ \else%>=9
+ \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7#8}%
+ \advance\pgfmathfloat@a@E by-8
+ \pgfmathfloattofixed@impl@collectmantissa#9\count\pgfmathfloat@a@E
+ \fi
+}%
+
+\def\pgfmathfloattofixed@impl@collectmantissa#1#2\count#3{%
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok #1}%
+ \advance\pgfmathfloat@a@E by-1%
+ \def\pgfmathfloat@loc@TMPb{#2}%
+ \ifx\pgfmathfloat@loc@TMPb\pgfutil@empty
+ \pgfutil@loop
+ \ifnum\pgfmathfloat@a@E>0%
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok 0}%
+ \advance\pgfmathfloat@a@E by-1%
+ \pgfutil@repeat
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok .0}%
+ \else
+ \ifnum\pgfmathfloat@a@E=0
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok .#2}%
+ \else
+ \pgfmathfloattofixed@impl@collectmantissa#2\count#3%
+ \fi
+ \fi
+}
+
+
+% ============================================
+%
+%
+% \pgfmathfloatparsenumber implementation
+%
+%
+% ============================================
+
+% accepted parser tokens:
+\def\pgfmathfloatparsenumber@tok@ZERO{0}
+\def\pgfmathfloatparsenumber@tok@PLUS{+}
+\def\pgfmathfloatparsenumber@tok@MINUS{-}
+\def\pgfmathfloatparsenumber@tok@PERIOD{.}
+
+\newif\ifpgfmathfloatparsenumberpendingperiod
+
+\def\pgfflt@EOI{p@EOI}%
+\def\pgfflt@EOI@unexpanded{\pgfflt@EOI}%
+
+% Starts a finite-start-machine parser to read a number.
+%
+% The machine's state is represented by the macro which is currently
+% processed; state transitions are realised using \csname...#1\endcsname
+% constructions.
+%
+% It assigns \pgfmathfloat@a@S, \pgfmathfloat@a@Mtok, \pgfmathfloat@a@E.
+\def\pgfflt@impl#1{%
+ \pgfmathfloatparsenumberpendingperiodfalse
+ \pgfmathfloat@tmptoks={}% this register is used to collect PENDING ZEROS
+ \pgfmathfloat@a@E=0
+ % start parsing: check for sign:
+ \expandafter\ifx\csname pgfflt@#1\endcsname\relax
+ \pgfmathfloat@a@S=1
+ \expandafter\pgfflt@init\expandafter#1%
+ \else
+ \expandafter\expandafter\csname pgfflt@#1\endcsname
+ \fi
+}
+% State transitions:
+\expandafter\def\csname pgfflt@+\endcsname{%
+ \pgfmathfloat@a@S=1 %
+ \pgfflt@init}%
+\expandafter\def\csname pgfflt@-\endcsname{%
+ \pgfmathfloat@a@S=2 %
+ \pgfflt@init}%
+\expandafter\def\csname pgfflt@\pgfflt@EOI\endcsname{%
+ \pgfmathfloatparsenumber@handleerror{empty number}{}{}}%
+
+\pgfkeys{
+ /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 separator/.code 2 args={%
+ \pgfmath@error{Could not parse input '#1' as a floating point number, sorry. The unreadable part was near the decimal separator '#2'. Do you need the option 'read comma as period'?}{}%
+ },
+ /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
+ \pgfkeys{/pgf/fpu/handlers/#1={#2}{#3}}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfmathfloat@a@S=3
+ \pgfmathfloat@a@Mtok={0.0}%
+ \pgfmathfloat@a@E=0
+ \else
+ \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
+ \fi
+}
+\def\pgfflt@error#1\pgfflt@EOI{%
+ \begingroup
+ \pgfmathfloat@a@Mtok={#1}%
+ \xdef\pgfmathfloat@glob@TMP{%
+ \noexpand\pgfmathfloatparsenumber@handleerror
+ {invalid number}{\pgfmathresult}{\the\pgfmathfloat@a@Mtok}}%
+ \endgroup
+ \pgfmathfloat@glob@TMP
+}%
+
+
+
+% FROM: checksign.
+%
+\def\pgfflt@init#1{%
+ \expandafter\ifx\csname pgffltA@#1\endcsname\relax
+ \expandafter\pgfflt@error\expandafter#1%
+ \else
+ \expandafter\expandafter\csname pgffltA@#1\endcsname
+ \fi}
+% state transitions:
+\expandafter\def\csname pgffltA@0\endcsname{\pgfflt@leadingzero}% FIXME: inline optimization!
+\expandafter\def\csname pgffltA@1\endcsname{\pgfflt@nonzerodigit1}%
+\expandafter\def\csname pgffltA@2\endcsname{\pgfflt@nonzerodigit2}%
+\expandafter\def\csname pgffltA@3\endcsname{\pgfflt@nonzerodigit3}%
+\expandafter\def\csname pgffltA@4\endcsname{\pgfflt@nonzerodigit4}%
+\expandafter\def\csname pgffltA@5\endcsname{\pgfflt@nonzerodigit5}%
+\expandafter\def\csname pgffltA@6\endcsname{\pgfflt@nonzerodigit6}%
+\expandafter\def\csname pgffltA@7\endcsname{\pgfflt@nonzerodigit7}%
+\expandafter\def\csname pgffltA@8\endcsname{\pgfflt@nonzerodigit8}%
+\expandafter\def\csname pgffltA@9\endcsname{\pgfflt@nonzerodigit9}%
+\def\pgfflt@nonzerodigit#1{%
+ \pgfmathfloat@a@Mtok={#1}%
+ \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@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}%
+\expandafter\def\csname pgffltA@,\endcsname{% read ',9' like '0,9'
+ \pgfmathfloat@frenchinput{%
+ \pgfmathfloat@a@E=-1
+ \pgfflt@leadingzero@foundperiod
+ }%
+}%
+
+\def\pgfmathfloat@frenchinput#1{%
+ \ifpgfmathparsenumber@comma@as@period
+ \def\pgf@marshal{#1}%
+ \expandafter\pgf@marshal
+ \else
+ \expandafter\pgfflt@error@separator\expandafter,%
+ \fi
+}%
+\def\pgfflt@error@separator#1\pgfflt@EOI{%
+ \begingroup
+ \pgfmathfloat@a@Mtok={#1}%
+ \xdef\pgfmathfloat@glob@TMP{%
+ \noexpand\pgfmathfloatparsenumber@handleerror
+ {invalid separator}{\pgfmathresult}{\the\pgfmathfloat@a@Mtok}}%
+ \endgroup
+ \pgfmathfloat@glob@TMP
+}%
+
+\def\pgfflt@finish#1\pgfflt@EOI{}
+
+\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
+ \def\pgfflt@readnan@{\pgfflt@error #1#2}%
+ \expandafter\pgfflt@readnan@
+ \fi
+}
+\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
+ \def\pgfflt@readinf@{\pgfflt@error #1#2}%
+ \expandafter\pgfflt@readinf@
+ \fi
+}
+\def\pgfflt@leadingzero#1{%
+ \expandafter\ifx\csname pgffltB@#1\endcsname\relax
+ \expandafter\pgfflt@error\expandafter#1%
+ \else
+ \expandafter\expandafter\csname pgffltB@#1\endcsname
+ \fi}
+% State transitions:
+\expandafter\def\csname pgffltB@0\endcsname{\pgfflt@leadingzero}%
+\expandafter\def\csname pgffltB@1\endcsname{\pgfmathfloat@a@Mtok={1}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@2\endcsname{\pgfmathfloat@a@Mtok={2}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@3\endcsname{\pgfmathfloat@a@Mtok={3}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@4\endcsname{\pgfmathfloat@a@Mtok={4}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@5\endcsname{\pgfmathfloat@a@Mtok={5}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@6\endcsname{\pgfmathfloat@a@Mtok={6}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@7\endcsname{\pgfmathfloat@a@Mtok={7}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@8\endcsname{\pgfmathfloat@a@Mtok={8}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@9\endcsname{\pgfmathfloat@a@Mtok={9}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp}
+\expandafter\def\csname pgffltB@\pgfmathfloat@POSTFLAGSCHAR\endcsname{\pgfmathfloat@a@Mtok={0}\pgfflt@readlowlevelfloat}%
+\expandafter\def\csname pgffltB@.\endcsname{%
+ \pgfmathfloat@a@E=-1
+ \pgfflt@leadingzero@foundperiod}%
+\expandafter\def\csname pgffltB@,\endcsname{%
+ \pgfmathfloat@frenchinput{%
+ \pgfmathfloat@a@E=-1
+ \pgfflt@leadingzero@foundperiod
+ }%
+}%
+\expandafter\def\csname pgffltB@e\endcsname{%
+ \pgfmathfloat@a@S=0\relax%
+ \pgfmathfloat@a@Mtok={0.0}%
+ \pgfmathfloat@a@E=0%
+ \pgfflt@readexponent}%
+\let\pgffltB@E=\pgffltB@e
+\expandafter\def\csname pgffltB@\pgfflt@EOI\endcsname{%
+ \pgfmathfloat@a@S=0\relax%
+ \pgfmathfloat@a@Mtok={0.0}%
+ \pgfmathfloat@a@E=0}%
+
+\def\pgfflt@leadingzero@foundperiod#1{%
+ \expandafter\ifx\csname pgffltC@#1\endcsname\relax
+ \expandafter\pgfflt@error\expandafter#1%
+ \else
+ \expandafter\expandafter\csname pgffltC@#1\endcsname
+ \fi}
+% State transitions:
+\expandafter\def\csname pgffltC@0\endcsname{%
+ \advance\pgfmathfloat@a@E by-1
+ \pgfflt@leadingzero@foundperiod}%
+\expandafter\def\csname pgffltC@1\endcsname{\pgfmathfloat@a@Mtok={1}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@2\endcsname{\pgfmathfloat@a@Mtok={2}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@3\endcsname{\pgfmathfloat@a@Mtok={3}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@4\endcsname{\pgfmathfloat@a@Mtok={4}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@5\endcsname{\pgfmathfloat@a@Mtok={5}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@6\endcsname{\pgfmathfloat@a@Mtok={6}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@7\endcsname{\pgfmathfloat@a@Mtok={7}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@8\endcsname{\pgfmathfloat@a@Mtok={8}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@9\endcsname{\pgfmathfloat@a@Mtok={9}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}%
+\expandafter\def\csname pgffltC@e\endcsname{%
+ \pgfmathfloat@a@S=0\relax%
+ \pgfmathfloat@a@Mtok={0.0}%
+ \pgfmathfloat@a@E=0%
+ \pgfflt@readexponent}%
+\let\pgffltC@E=\pgffltC@e
+\expandafter\def\csname pgffltC@\pgfflt@EOI\endcsname{%
+ \pgfmathfloat@a@S=0\relax%
+ \pgfmathfloat@a@Mtok={0.0}%
+ \pgfmathfloat@a@E=0}%
+
+
+\def\pgfflt@positiveexp#1{%
+ \expandafter\ifx\csname pgffltD@#1\endcsname\relax
+ \expandafter\pgfflt@error\expandafter#1%
+ \else
+ \expandafter\expandafter\csname pgffltD@#1\endcsname
+ \fi}
+% State transitions:
+\expandafter\def\csname pgffltD@0\endcsname{%
+ \advance\pgfmathfloat@a@E by1
+ \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}%
+ \pgfflt@pendingzeros@positiveexp}%
+\expandafter\def\csname pgffltD@1\endcsname{\pgffltD@nonzerodigit1}%
+\expandafter\def\csname pgffltD@2\endcsname{\pgffltD@nonzerodigit2}%
+\expandafter\def\csname pgffltD@3\endcsname{\pgffltD@nonzerodigit3}%
+\expandafter\def\csname pgffltD@4\endcsname{\pgffltD@nonzerodigit4}%
+\expandafter\def\csname pgffltD@5\endcsname{\pgffltD@nonzerodigit5}%
+\expandafter\def\csname pgffltD@6\endcsname{\pgffltD@nonzerodigit6}%
+\expandafter\def\csname pgffltD@7\endcsname{\pgffltD@nonzerodigit7}%
+\expandafter\def\csname pgffltD@8\endcsname{\pgffltD@nonzerodigit8}%
+\expandafter\def\csname pgffltD@9\endcsname{\pgffltD@nonzerodigit9}%
+\expandafter\def\csname pgffltD@\pgfmathfloat@POSTFLAGSCHAR\endcsname{\pgfflt@readlowlevelfloat}%
+\expandafter\def\csname pgffltD@.\endcsname{\pgfflt@finish@number@after@period}% FIXME : inlining?
+\expandafter\def\csname pgffltD@,\endcsname{\pgfmathfloat@frenchinput{\pgfflt@finish@number@after@period}}%
+\expandafter\def\csname pgffltD@e\endcsname{\pgfflt@readexponent}% FIXME : inlining?
+\let\pgffltD@E=\pgffltD@e
+\expandafter\def\csname pgffltD@\pgfflt@EOI\endcsname{}% NOP
+\def\pgffltD@nonzerodigit#1{%
+ \advance\pgfmathfloat@a@E by1
+ \ifpgfmathfloatparsenumberpendingperiod
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}%
+ \pgfmathfloatparsenumberpendingperiodfalse
+ \fi
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}%
+ \pgfflt@positiveexp}%
+
+% Read a low-level floating point.
+% Since we are in the second state, \pgfmathfloat@a@Mtok contains the
+% FLAGS. The post-flags-char has also been read.
+\def\pgfflt@readlowlevelfloat#1e#2]\pgfflt@EOI{%
+ \pgfmathfloatparsenumberpendingperiodfalse
+ \pgfmathfloat@a@S=\the\pgfmathfloat@a@Mtok\relax
+ \pgfmathfloat@a@Mtok={#1}%
+ \pgfmathfloat@a@E=#2
+}%
+
+\def\pgfflt@readexponent#1\pgfflt@EOI{%
+ \afterassignment\pgfflt@readexponent@
+ \pgfmathfloat@b@E=#1 \pgfflt@EOI% the white space is important, otherwise \pgfflt@EOI will be expanded.
+}
+\def\pgfflt@readexponent@#1{%
+ \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E\relax
+ %
+ % sanity checking:
+ \def\pgfmathfloat@loc@TMPb{#1}%
+ \ifx\pgfmathfloat@loc@TMPb\pgfflt@EOI@unexpanded
+ \else
+ \def\pgfmathfloat@loc@TMPb{\pgfflt@error#1}%
+ \expandafter\pgfmathfloat@loc@TMPb
+ \fi
+}
+
+\def\pgfflt@pendingzeros@positiveexp#1{%
+ \expandafter\ifx\csname pgffltE@#1\endcsname\relax
+ \expandafter\pgfflt@error\expandafter#1%
+ \else
+ \expandafter\expandafter\csname pgffltE@#1\endcsname
+ \fi}
+% State transitions:
+\expandafter\def\csname pgffltE@0\endcsname{%
+ \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}%
+ \advance\pgfmathfloat@a@E by1
+ \pgfflt@pendingzeros@positiveexp}%
+\expandafter\def\csname pgffltE@1\endcsname{\pgffltE@nonzerodigit1}%
+\expandafter\def\csname pgffltE@2\endcsname{\pgffltE@nonzerodigit2}%
+\expandafter\def\csname pgffltE@3\endcsname{\pgffltE@nonzerodigit3}%
+\expandafter\def\csname pgffltE@4\endcsname{\pgffltE@nonzerodigit4}%
+\expandafter\def\csname pgffltE@5\endcsname{\pgffltE@nonzerodigit5}%
+\expandafter\def\csname pgffltE@6\endcsname{\pgffltE@nonzerodigit6}%
+\expandafter\def\csname pgffltE@7\endcsname{\pgffltE@nonzerodigit7}%
+\expandafter\def\csname pgffltE@8\endcsname{\pgffltE@nonzerodigit8}%
+\expandafter\def\csname pgffltE@9\endcsname{\pgffltE@nonzerodigit9}%
+\expandafter\def\csname pgffltE@.\endcsname{\pgfflt@finish@number@after@period}% FIXME : inlining?
+\expandafter\def\csname pgffltE@,\endcsname{\pgfmathfloat@frenchinput{\pgfflt@finish@number@after@period}}% FIXME : inlining?
+\def\pgffltE@e{\pgfflt@readexponent}% FIXME : inlining?
+\let\pgffltE@E=\pgffltE@e
+\expandafter\def\csname pgffltE@\pgfflt@EOI\endcsname{}% NOP
+\def\pgffltE@nonzerodigit#1{%
+ \advance\pgfmathfloat@a@E by1
+ \ifpgfmathfloatparsenumberpendingperiod
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}%
+ \pgfmathfloatparsenumberpendingperiodfalse
+ \fi
+ \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}%
+ \pgfmathfloat@tmptoks={}%
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}%
+ \pgfflt@positiveexp}%
+
+\def\pgfflt@finish@number@after@period#1{%
+ \expandafter\ifx\csname pgffltF@#1\endcsname\relax
+ \expandafter\pgfflt@error\expandafter#1%
+ \else
+ \expandafter\expandafter\csname pgffltF@#1\endcsname
+ \fi}
+% State transitions:
+\expandafter\def\csname pgffltF@0\endcsname{%
+ \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}%
+ \pgfflt@pendingzeros}%
+\expandafter\def\csname pgffltF@1\endcsname{\pgffltF@nonzerodigit1}%
+\expandafter\def\csname pgffltF@2\endcsname{\pgffltF@nonzerodigit2}%
+\expandafter\def\csname pgffltF@3\endcsname{\pgffltF@nonzerodigit3}%
+\expandafter\def\csname pgffltF@4\endcsname{\pgffltF@nonzerodigit4}%
+\expandafter\def\csname pgffltF@5\endcsname{\pgffltF@nonzerodigit5}%
+\expandafter\def\csname pgffltF@6\endcsname{\pgffltF@nonzerodigit6}%
+\expandafter\def\csname pgffltF@7\endcsname{\pgffltF@nonzerodigit7}%
+\expandafter\def\csname pgffltF@8\endcsname{\pgffltF@nonzerodigit8}%
+\expandafter\def\csname pgffltF@9\endcsname{\pgffltF@nonzerodigit9}%
+\def\pgffltF@e{\pgfflt@readexponent}%
+\let\pgffltF@E=\pgffltF@e
+\expandafter\def\csname pgffltF@\pgfflt@EOI\endcsname{}% NOP
+\def\pgffltF@nonzerodigit#1{%
+ \ifpgfmathfloatparsenumberpendingperiod
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}%
+ \pgfmathfloatparsenumberpendingperiodfalse
+ \fi
+ \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}%
+ \pgfmathfloat@tmptoks={}%
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}%
+ \pgfflt@finish@number@after@period}%
+
+
+\def\pgfflt@pendingzeros#1{%
+ \expandafter\ifx\csname pgffltG@#1\endcsname\relax
+ \expandafter\pgfflt@error\expandafter#1%
+ \else
+ \expandafter\expandafter\csname pgffltG@#1\endcsname
+ \fi}
+% State transitions:
+\expandafter\def\csname pgffltG@0\endcsname{%
+ \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}%
+ \pgfflt@pendingzeros}%
+\expandafter\def\csname pgffltG@1\endcsname{\pgffltG@nonzerodigit1}%
+\expandafter\def\csname pgffltG@2\endcsname{\pgffltG@nonzerodigit2}%
+\expandafter\def\csname pgffltG@3\endcsname{\pgffltG@nonzerodigit3}%
+\expandafter\def\csname pgffltG@4\endcsname{\pgffltG@nonzerodigit4}%
+\expandafter\def\csname pgffltG@5\endcsname{\pgffltG@nonzerodigit5}%
+\expandafter\def\csname pgffltG@6\endcsname{\pgffltG@nonzerodigit6}%
+\expandafter\def\csname pgffltG@7\endcsname{\pgffltG@nonzerodigit7}%
+\expandafter\def\csname pgffltG@8\endcsname{\pgffltG@nonzerodigit8}%
+\expandafter\def\csname pgffltG@9\endcsname{\pgffltG@nonzerodigit9}%
+\def\pgffltG@e{\pgfflt@readexponent}% FIXME: inlining?
+\let\pgffltG@E=\pgffltG@e
+\expandafter\def\csname pgffltG@\pgfflt@EOI\endcsname{}% NOP
+\def\pgffltG@nonzerodigit#1{%
+ \ifpgfmathfloatparsenumberpendingperiod
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}%
+ \pgfmathfloatparsenumberpendingperiodfalse
+ \fi
+ \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}%
+ \pgfmathfloat@tmptoks={}%
+ \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}%
+ \pgfflt@finish@number@after@period}%
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfutil-common-lists.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfutil-common-lists.tex
new file mode 100644
index 0000000000..fb09a855e6
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_pgfutil-common-lists.tex
@@ -0,0 +1,184 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Sa 7. Dez 20:58:23 CET 2013 %%%
+
+
+
+% Copyright 2013 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.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+%
+% This list here is a general re-implementation of the list used in
+% the PGF system layer.
+% It employs two collect-buffers to reduce the runtime.
+%
+% - It has preasymptotical runtime O(N), but is O(N^2) asymptotically.
+% - It requires only 5 macros per list.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Usage:
+% \pgfapplistnewempty\macro
+\def\pgfapplistnewempty#1{%
+ \expandafter\let\csname pgfapp@#1\endcsname=\pgfutil@empty
+ \expandafter\let\csname pgfapp@#1@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\let\csname pgfapp@#1@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname pgfapp@#1@smallbuf@c\endcsname{0}%
+ \expandafter\def\csname pgfapp@#1@bigbuf@c\endcsname{0}%
+}%
+
+% #1: the item to append
+% #2: the list as macro name
+\long\def\pgfapplistpushback#1\to#2{%
+ \begingroup
+ \c@pgf@counta=\csname pgfapp@#2@smallbuf@c\endcsname\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgf@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \expandafter\let\csname pgfapp@#2@smallbuf@c\endcsname=\pgf@glob@TMPa
+ \ifnum\csname pgfapp@#2@smallbuf@c\endcsname<40
+ \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfapp@#2@smallbuf\endcsname#1}%
+ \expandafter\edef\csname pgfapp@#2@smallbuf\endcsname{\the\t@pgf@toka}%
+ \else
+ \pgfapplistpushback@smallbufoverfl{#1}{#2}%
+ \fi
+}%
+\long\def\pgfapplistpushback@smallbufoverfl#1#2{%
+ \begingroup
+ \c@pgf@counta=\csname pgfapp@#2@bigbuf@c\endcsname\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgf@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \expandafter\let\csname pgfapp@#2@bigbuf@c\endcsname=\pgf@glob@TMPa
+ %
+ \ifnum\csname pgfapp@#2@bigbuf@c\endcsname<30
+ \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfapp@#2@bigbuf\endcsname}%
+ \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfapp@#2@smallbuf\endcsname#1}%
+ \expandafter\edef\csname pgfapp@#2@bigbuf\endcsname{\the\t@pgf@toka\the\t@pgf@tokb}%
+ \expandafter\let\csname pgfapp@#2@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname pgfapp@#2@smallbuf@c\endcsname{0}%
+ \else%
+ \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfapp@#2\endcsname}%
+ \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfapp@#2@bigbuf\endcsname}%
+ \t@pgf@tokc=\expandafter\expandafter\expandafter{\csname pgfapp@#2@smallbuf\endcsname#1}%
+ \expandafter\edef\csname pgfapp@#2\endcsname{\the\t@pgf@toka\the\t@pgf@tokb\the\t@pgf@tokc}%
+ \expandafter\let\csname pgfapp@#2@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname pgfapp@#2@smallbuf@c\endcsname{0}%
+ \expandafter\let\csname pgfapp@#2@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname pgfapp@#2@bigbuf@c\endcsname{0}%
+ \fi%
+}%
+\def\pgfapplist@flushbuffers#1{%
+ \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfapp@#1\endcsname}%
+ \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfapp@#1@bigbuf\endcsname}%
+ \t@pgf@tokc=\expandafter\expandafter\expandafter{\csname pgfapp@#1@smallbuf\endcsname}%
+ \expandafter\edef\csname pgfapp@#1\endcsname{\the\t@pgf@toka\the\t@pgf@tokb\the\t@pgf@tokc}%
+ \expandafter\let\csname pgfapp@#1@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname pgfapp@#1@smallbuf@c\endcsname{0}%
+ \expandafter\let\csname pgfapp@#1@bigbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname pgfapp@#1@bigbuf@c\endcsname{0}%
+}%
+
+\def\pgfapplistlet#1=#2{%
+ \pgfapplist@flushbuffers{#2}%
+ \expandafter\let\expandafter#1\csname pgfapp@#2\endcsname
+}%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% A variant of applist which has the same runtime requirements, but
+% does PUSH FRONT only.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% Usage:
+% \pgfprependlistnewempty{list}
+\def\pgfprependlistnewempty#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\pgfprependlistpushfront#1\to#2{%
+ \begingroup
+ \c@pgf@counta=\csname pgfpPRP@#2@smallbuf@c\endcsname\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgf@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \expandafter\let\csname pgfpPRP@#2@smallbuf@c\endcsname=\pgf@glob@TMPa
+ \ifnum\csname pgfpPRP@#2@smallbuf@c\endcsname<40
+ \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}%
+ \t@pgf@tokb={#1}%
+ \expandafter\edef\csname pgfpPRP@#2@smallbuf\endcsname{\the\t@pgf@tokb\the\t@pgf@toka}%
+ \else
+ \pgfprependlistpushfront@smallbufoverfl{#1}{#2}%
+ \fi
+}%
+\long\def\pgfprependlistpushfront@smallbufoverfl#1#2{%
+ \begingroup
+ \c@pgf@counta=\csname pgfpPRP@#2@bigbuf@c\endcsname\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgf@glob@TMPa{\the\c@pgf@counta}%
+ \endgroup
+ \expandafter\let\csname pgfpPRP@#2@bigbuf@c\endcsname=\pgf@glob@TMPa
+ %
+ \ifnum\csname pgfpPRP@#2@bigbuf@c\endcsname<30
+ \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@bigbuf\endcsname}%
+ \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}%
+ \t@pgf@tokc={#1}%
+ \expandafter\edef\csname pgfpPRP@#2@bigbuf\endcsname{\the\t@pgf@tokc\the\t@pgf@tokb\the\t@pgf@toka}%
+ \expandafter\let\csname pgfpPRP@#2@smallbuf\endcsname=\pgfutil@empty
+ \expandafter\def\csname pgfpPRP@#2@smallbuf@c\endcsname{0}%
+ \else%
+ \pgfprependlist@flushbuffers{#2}%
+ \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2\endcsname}%
+ \t@pgf@tokb={#1}%
+ \expandafter\edef\csname pgfpPRP@#2\endcsname{\the\t@pgf@tokb\the\t@pgf@toka}%
+ \fi%
+}%
+\def\pgfprependlist@flushbuffers#1{%
+ \t@pgf@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1\endcsname}%
+ \t@pgf@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@bigbuf\endcsname}%
+ \t@pgf@tokc=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@smallbuf\endcsname}%
+ \expandafter\edef\csname pgfpPRP@#1\endcsname{\the\t@pgf@tokc\the\t@pgf@tokb\the\t@pgf@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\pgfprependlistlet#1=#2{%
+ \pgfprependlist@flushbuffers{#2}%
+ \expandafter\let\expandafter#1\csname pgfpPRP@#2\endcsname
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzexternal.sty b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzexternal.sty
new file mode 100644
index 0000000000..55e56d8fdd
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzexternal.sty
@@ -0,0 +1,163 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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 25. Dez 18:14:20 CET 2012 %%%
+
+
+
+% 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]{\@ifnextchar\bgroup{\def\tikzexternal@realjob}{\let\tikzexternal@realjob=\jobname}}%
+
+\def\tikzsetnextfilename#1{\gdef\tikzexternal@nextfile{#1}}
+\def\tikzsetexternalprefix#1{\def\tikzexternal@filenameprefix{#1}}
+\def\tikzsetfigurename#1{\def\tikzexternal@figurename{#1}}%
+\def\tikzappendtofigurename#1{\expandafter\def\expandafter\tikzexternal@figurename\expandafter{\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
+ \pgfincludeexternalgraphics\tikzexternal@curfilename
+}%
+\def\tikzset#1{}\def\pgfkeys#1{}\def\pgfqkeys#1#2{}
+\long\def\beginpgfgraphicnamed#1#2\endpgfgraphicnamed{\pgfincludeexternalgraphics{#1}}
+\def\tikzifinpicture#1#2{#2}
+\def\pgfincludeexternalgraphics#1{%
+ \begingroup
+ \pgfexternalreaddpth{#1}%
+ \setbox1=\hbox{\includegraphics{#1}}%
+ \ifdim\pgfretval=0pt
+ \box1
+ \else
+ \dimen0=\pgfretval\relax
+ \hbox{\lower\dimen0 \box1 }%
+ \fi
+ \endgroup
+}
+\newread\r@pgf@reada
+\def\pgfexternalreaddpth#1{%
+ \edef\pgfexternalreaddpth@restore{%
+ \noexpand\endlinechar=\the\endlinechar\space
+ \noexpand\catcode`\noexpand\@=\the\catcode`\@\space
+ }%
+ \def\pgfretval{0pt}%
+ \endlinechar=-1 % suppress white space at end
+ \catcode`\@=11
+ \openin\r@pgf@reada=#1.dpth
+ \pgfincludeexternalgraphics@read@dpth
+ \pgfexternalreaddpth@restore
+}%
+\def\pgfincludeexternalgraphics@read@dpth{%
+ \ifeof\r@pgf@reada
+ \closein\r@pgf@reada
+ \else
+ \read\r@pgf@reada to\pgfincludeexternalgraphics@auxline
+ \ifx\pgfincludeexternalgraphics@auxline\empty
+ \else
+ \expandafter\pgfincludeexternalgraphics@read@dpth@line\pgfincludeexternalgraphics@auxline\pgfincludeexternalgraphics@read@dpth@line@EOI
+ \fi
+ \expandafter\pgfincludeexternalgraphics@read@dpth
+ \fi
+}%
+\long\def\pgfincludeexternalgraphics@read@dpth@line#1#2\pgfincludeexternalgraphics@read@dpth@line@EOI{%
+ \ifcat\noexpand#1\relax
+ \if@filesw
+ {\toks0={#1#2}%
+ \immediate\write\@auxout{\noexpand\def\noexpand\dpthimport{\the\toks0 }\noexpand\dpthimport }%
+ }%
+ \fi
+ \else%
+ \def\pgfretval{#1#2}%
+ \fi
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzexternalshared.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzexternalshared.code.tex
new file mode 100644
index 0000000000..ed1a6ff4fb
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzexternalshared.code.tex
@@ -0,0 +1,1732 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Di 12. Jul 21:02:29 CEST 2016 %%%
+
+
+
+% Copyright 2008-2010 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
+
+\newif\iftikzexternal@nestedflag
+\newif\iftikzexternal@verboseuptodate
+\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
+
+% must be numeric!
+\gdef\c@tikzexternal@version{2}
+
+% 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 '#1' if the external lib is currently externalizing the
+% current picture. It invokes '#2' if that is not the case.
+%
+% If the command is invoked outside of a picture, '#2' will be
+% invoked.
+\def\tikzifexternalizingcurrent#1#2{%
+ \ifpgf@external@grabshipout
+ \tikzexternalgetcurrentfilename\tikzexternal@temp
+ \ifx\tikzexternal@temp\pgfutil@empty
+ #2%
+ \else
+ \tikzifexternaljobnamematches\tikzexternal@temp{#1}{#2}%
+ \fi
+ \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\pgfactualjobname\endcsname}%
+ \ifx\pgf@tempa\pgf@tempb #2\else#3 \fi%
+}%
+
+
+\pgfutil@IfUndefined{pdfshellescape}{%
+ % let's hope that \usepackage{pdftexcmds} has been used...
+ \pgfutil@IfUndefined{pdf@shellescape}{%
+ \def\tikzexternalcheckshellescape{0}%
+ }{%
+ \let\tikzexternalcheckshellescape=\pdf@shellescape
+ }%
+}{%
+ \let\tikzexternalcheckshellescape=\pdfshellescape
+}%
+\ifnum\tikzexternalcheckshellescape=1
+ \def\tikzexternalcheckshellescape{\pgfkeysvalueof{/tikz/external/shell escape}\space}%
+\else
+ \def\tikzexternalcheckshellescape{}%
+\fi
+
+\newif\iftikzexternal@auto@detect@jobname
+
+\pgfqkeys{/tikz/external}{
+ figure list/.is if=tikzexternal@genfigurelist,
+ aux in dpth/.style={/pgf/images/aux in dpth=#1},%
+ disable dependency files/.code={%
+ \let\tikzexternalfiledependsonfile@ACTIVE=\tikzexternalfiledependsonfile
+ },
+ % 'mode' applies only if \jobname==real job name.
+ mode/.is choice,
+ mode/only graphics/.code = {%
+ \def\tikzexternal@opmode{0}%
+ \pgfkeysalso{/pgf/images/aux in dpth=true}%
+ },
+ 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}%
+ \pgfkeysalso{/pgf/images/aux in dpth=true}%
+ },
+ mode/list only/.code = {\def\tikzexternal@opmode{3}\tikzexternal@genfigurelisttrue},
+ mode/convert with system call/.code={%
+ \def\tikzexternal@opmode{4}%
+ \pgfkeysalso{/tikz/external/figure list=false,/pgf/images/aux in dpth=true}%
+ },
+ mode/list and make/.code = {%
+ \def\tikzexternal@opmode{5}%
+ \pgfkeysalso{/tikz/external/figure list=true,/pgf/images/aux in dpth=true}%
+ },
+ mode=convert with system call,
+ force remake/.is if=tikzexternal@force@remake,
+ force remake/.default=true,
+ %
+ % DEPRECATED: this here will work out-of-the box (provided that
+ % 'aux in dpth' is active):
+ failed ref warnings for/.initial={\ref,\cite,\pageref},
+ 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,
+ verbose up to date/.is if=tikzexternal@verboseuptodate,
+ verbose/.style={
+ verbose IO=#1,
+ verbose optimize=#1,
+ verbose up to date=#1,
+ },
+ shell escape/.initial=-shell-escape,
+ read main aux/.is if=pgfexternalreadmainaux,
+ image discarded text/.initial={%
+ [[ \textsc{Image Discarded Due To} \texttt{`/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
+ '}~]]%
+ \pgfutil@ifundefined{tikzexternal@warning@at@end}{%
+ \pgfutil@ifundefined{AtEndDocument}{}{%
+ \AtEndDocument{%
+ \message{! Package tikz Warning: Some images are not up-to-date and need to be generated. }%
+ }%
+ }%
+ \gdef\tikzexternal@warning@at@end{1}%
+ }{}%
+ },
+ 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 away text/.code={[ \textsc{\string#1\ optimized away because it does not contribute to exported PDF}]},
+ 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,
+ optimize command away=\pgfincludeexternalgraphics,
+ % 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}},
+ up to date check/.is choice,
+ up to date check/simple/.code={\def\tikzexternal@uptodate@mode{0}},
+ % md5 relies on \pdfmdfivesum of pdftex. It uses 'diff' as fallback if we do not have that command.
+ up to date check/md5/.code={\def\tikzexternal@uptodate@mode{1}},
+ up to date check/diff/.code={\def\tikzexternal@uptodate@mode{2}},
+ up to date check=md5,
+}
+
+\expandafter\def\csname tikzexternal@driver@pgfsys-pdftex.def\endcsname{%
+ \pgfutil@IfUndefined{directlua}{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+ }%
+ }{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+ }%
+ }%
+}%
+%--------------------------------------------------
+% \expandafter\def\csname tikzexternal@driver@pgfsys-dvipdfm.def\endcsname{%
+% \pgfkeyssetvalue{/tikz/external/system call}{%
+% latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+% && dvipdfm "\image".dvi %
+% }%
+% }%
+%--------------------------------------------------
+\expandafter\def\csname tikzexternal@driver@pgfsys-xetex.def\endcsname{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ xelatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+ }%
+}%
+\expandafter\def\csname tikzexternal@driver@pgfsys-dvips.def\endcsname{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource" %
+ && dvips -o "\image".ps "\image".dvi %
+ }%
+}%
+
+% Auto-select a suitable default value fo 'system call':
+\pgfutil@ifundefined{tikzexternal@driver@\pgfsysdriver}{%
+ % fallback. We do not know the driver here.
+ \csname tikzexternal@driver@pgfsys-pdftex.def\endcsname
+}{%
+ \csname tikzexternal@driver@\pgfsysdriver\endcsname
+}%
+
+
+\def\tikzsetfigurename#1{\pgfkeyssetvalue{/tikz/external/figure name}{#1}}%
+\def\tikzappendtofigurename#1{\pgfkeys{/tikz/external/figure name/.add={}{#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 command does need any argument, but it has two optional ones:
+%
+% 1. \tikzexternalize[<options>]
+%
+% 2. \tikzexternalize{<real job's name>}
+%
+% 3. \tikzexternalize[<options>]{<real job's name>}
+%
+% The <real job's name> is the job's file name, without the suffix
+% .tex .
+% If the <real job's name> is omitted, it will be deduced
+% automatically.
+%
+% The effect is:
+% 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@opt[#1]{%
+ \pgfutil@ifnextchar\bgroup{%
+ \tikzexternal@auto@detect@jobnamefalse
+ \tikzexternalize@opt@withname[#1]%
+ }{%
+ \tikzexternal@auto@detect@jobnametrue
+ \pgfutil@ifundefined{tikzexternalrealjob}{%
+ % ok, \tikzexternalrealjob is not known.
+ % Assume we are currently *not* externalizing.
+ \let\tikzexternalrealjob=\jobname
+ }{}%
+ \def\pgf@tempa{\tikzexternalize@opt@withname[#1]}%
+ \expandafter\pgf@tempa\expandafter{\tikzexternalrealjob}%
+ }%
+}%
+\def\tikzexternalize@opt@withname[#1]#2{%
+ \gdef\tikzexternalrealjob{#2}%
+ \if1\tikzexternalize@hasbeencalled
+ \else
+ \pgfqkeys{/tikz/external}{#1}%
+ \def\tikzexternal@realjob{#2}%
+ \tikzexternalauxlock@init
+ \pgfrealjobname{#2}%
+ \def\tikzexternalize@hasbeencalled{1}%
+ \tikzexternalenable
+ \def\tikzexternal@determineimgextension##1:##2\relax{\gdef\tikzexternalimgextension{##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
+ }%
+ \let\tikzexternalfiledependsonfile=\tikzexternalfiledependsonfile@ACTIVE
+ \let\tikzpicturedependsonfile=\tikzpicturedependsonfile@ACTIVE
+ \fi
+}
+\def\tikzexternalize@hasbeencalled{0}%
+
+\def\tikzifexternalizehasbeencalled#1#2{%
+ \if1\tikzexternalize@hasbeencalled
+ #1%
+ \else
+ #2%
+ \fi
+}%
+
+% If mode=`convert with system call', the boolean \ifpgfexternalreadmainaux
+% will be set depending on the current lock file.
+%
+% The idea is as follows: Suppose
+% pdflatex -shell-escape mainjob.tex
+% is running.
+%
+% While it runs,
+% a) it modifies its mainjob.aux file,
+% b) it issues pdflatex -jobname mainjob-figure0 mainjob.tex .
+%
+% The call (b) will try to read mainjob.aux in order to resolve \ref
+% commands. This may fail since the aux
+% file is not complete; it may be subject to output buffering. To
+% avoid such failure, a locking mechanism is established.
+%
+% The locking mechanisms causes (a) to write a lock command into
+% mainjob.auxlock
+% just before (b) is called. Then, (b) will check it. After (b) has
+% completed, the lock will be reset.
+%
+% Thus: mode=convert with system call does NOT support \ref commands
+% inside of images. You will need to call the externalization command
+% manually. In this case, it should work.
+%
+% The lock file allows to detect automatically whether an image is created by
+% 'convert with system call' or if the user issued the required command manually.
+%
+% @PRECONDITION : this command must be invoked AFTER
+% \tikzexternal@realjob has been defined but BEFORE \pgfrealjobname is
+% called.
+%
+% @POSTCONDITION : If \ifpgfexternalreadmainaux=\iffalse, we won't do
+% anything. Otherwise, it will be changed depending for 'mode=convert
+% with system call' if necessary.
+\def\tikzexternalauxlock@init{%
+ \if4\tikzexternal@opmode
+ % mode=convert with system call
+ \ifpgfexternalreadmainaux
+ % ohoh. This case needs care because the main.aux might
+ % not be ready at this time!
+ % check.
+ %
+ \edef\pgf@tempa{\expandafter\string\csname\tikzexternal@realjob\endcsname}%
+ \edef\pgf@tempb{\expandafter\string\csname\jobname\endcsname}%
+ \ifx\pgf@tempa\pgf@tempb
+ % we are *not* externalizing. Set lock into its
+ % initial "unlocked" state.
+ \tikzexternalauxlock@setlock{0}%
+ \else
+ % we are externalizing. Query the lock's value:
+ \tikzexternalauxlock@getlockvalue
+ \if1\tikzexternallocked
+ \pgfexternalreadmainauxfalse
+ % the main .aux file won't be read right now.
+ \else
+ \pgfexternalreadmainauxtrue
+ \fi
+ \fi
+ \else
+ % NO-OP. We won't read the main aux file anyway.
+ \def\tikzexternalauxlock@setlock##1{}%
+ \fi
+ \fi
+}
+% defines \tikzexternallocked to be either 0 or 1, depending on the
+% lock file.
+\def\tikzexternalauxlock@getlockvalue{%
+ \openin\r@pgf@reada=\tikzexternal@realjob.auxlock
+ \ifeof\r@pgf@reada
+ % no lock file. Unlock.
+ \def\tikzexternallocked{0}%
+ \else
+ % read first line...
+ \read\r@pgf@reada to\pgf@tempa
+ % ... and execute it.
+ \pgf@tempa
+ % it should contain a definition of \tikzexternallocked. If
+ % not, lock it anyway.
+ \pgfutil@ifundefined
+ {tikzexternallocked}
+ {\def\tikzexternallocked{1}}%
+ {}%
+ \fi
+ \closein\r@pgf@reada
+}%
+\def\tikzexternalauxlock@setlock#1{%
+ \immediate\openout\w@pgf@writea=\tikzexternal@realjob.auxlock
+ \immediate\write\w@pgf@writea{\noexpand\def\noexpand\tikzexternallocked{#1}}%
+ \immediate\closeout\w@pgf@writea
+}
+
+
+% this is a hook into pgfcoreexternal.code.tex:
+\def\pgf@external@grab@refundefinedtrue@code{%
+ \gdef\noexpand\tikzexternal@systemcall@reschedule@to@end@document{1}%
+}%
+
+% Expands to the default image extension (it is set by
+% \tikzexternalize).
+%
+% This image extension may not resemble the correct one; you may need
+% to overwrite this macro *after* \tikzexternalize in this case.
+%
+% The default setting uses the first registered image extension.
+\def\tikzexternalimgextension{}%
+
+% 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
+\let\tikzexternal@curfilename=\relax
+
+% 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
+ \global\tikzexternal@file@isuptodatetrue% may be set to false during checks.
+ \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
+ \let\tikzexternal@getnextfilename@resetglobals=\relax% NOP
+ \def\tikzexternal@protocol@to@file##1{}% NOP
+ \tikzexternal@getnextfilename#1%
+ \pgfmath@smuggleone#1%
+ \endgroup
+}%
+
+% Returns the file name of the current picture.
+%
+% It returns the empty string in case the command is invoked outside
+% of a picture.
+% #1 the macro which will contain the file name.
+% @see \tikzexternalgetnextfilename
+\def\tikzexternalgetcurrentfilename#1{%
+ \ifx\tikzexternal@curfilename\relax
+ % we are outside of a picture.
+ \let#1=\pgfutil@empty
+ \else
+ % we are inside of a picture.
+ \let#1=\tikzexternal@curfilename
+ \fi
+}
+
+% 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
+ %
+ \tikzexternal@getnextfilename@resetglobals%
+ %
+ \tikzexternal@protocol@to@file#1%
+}%
+
+\def\tikzexternal@getnextfilename@resetglobals{%
+ % Reset global flags:
+ \global\let\tikzexternal@nextfile=\pgfutil@empty
+ \global\tikzexternalexportnexttrue
+}%
+
+% #1: the image file name which should be protocolled. (can be a
+% macro)
+\def\tikzexternal@protocol@to@file#1{%
+ \ifpgf@external@grabshipout%
+ \else
+ \iftikzexternal@genfigurelist
+ \edef\tikzexternal@temp{#1}%
+ \ifx\tikzexternal@temp\pgfutil@empty
+ \else
+ \pgfutil@ifundefined{tikzexternal@listmode@openedfile}{%
+ \message{Opening '\tikzexternal@realjob.figlist' for writing.}%
+ \begingroup
+ \globaldefs=1
+ % this gets round '\outer\newwrite' in plain TeX:
+ \csname newwrite\endcsname\tikzexternal@outfile
+ \endgroup
+ \immediate\openout\tikzexternal@outfile=\tikzexternal@realjob.figlist\relax
+ \gdef\tikzexternal@listmode@openedfile{1}%
+ \if\tikzexternal@opmode5% mode='list and make'
+ \tikzexternal@list@and@make@prepare
+ \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@list@and@make@gentarget{#1}%
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+
+\def\tikzexternal@list@and@make@gentarget#1{%
+ \tikzexternal@assemble@systemcall{#1}{\pgf@tempa}%
+ \def\tikzexternal@tempb{\pgfutilstrreplace{^^J}{^^J\tikzexternal@TABchar}}%
+ \expandafter\tikzexternal@tempb\expandafter{\pgf@tempa}%
+ \let\pgf@tempa=\pgfretval
+ \iftikzexternal@verboseio
+ \immediate\write16{Writing '#1' to '\tikzexternal@realjob.makefile'.}%
+ \fi
+ \global\tikzexternal@file@isuptodatetrue% only check for force remake:
+ \tikzexternal@checkforceremake%
+ \immediate\write\tikzexternal@outmakefile{#1\tikzexternalimgextension: \iftikzexternal@file@isuptodate\else FORCEREMAKE\fi}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar\pgf@tempa}%
+ \immediate\write\tikzexternal@outmakefile{}%
+}
+
+\def\tikzexternal@list@and@make@prepare{%
+ \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\tikzexternalimgextension)}%
+ \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{}%
+ \immediate\write\tikzexternal@outmakefile{FORCEREMAKE:}%
+ \immediate\write\tikzexternal@outmakefile{}%
+ %
+ % support for .dep files and auto-dependencies:
+ \immediate\write\tikzexternal@outmakefile{include $(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar.\tikzexternaldepext)}%
+ \immediate\write\tikzexternal@outmakefile{}%
+ \tikzexternalmakefiledefaultdeprule
+ \immediate\write\tikzexternal@outmakefile{}%
+ \tikzexternal@outmakefile@pendingcommands
+ \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. =====}}%
+ }%
+}%
+\def\tikzexternaldepext{dep}
+
+\def\tikzexternalmakefiledefaultdeprule{%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p \tikzexternal@normal@dq $(dir $@)\tikzexternal@normal@dq}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar touch \tikzexternal@normal@dq $@\tikzexternal@normal@dq\space \tikzexternal@HASHchar\space will be filled later.}%
+}%
+
+% Invokes '#1' if a makefile is to be written and '#2' if not.
+\def\tikzexternalifwritesmakefile#1#2{%
+ \if5\tikzexternal@opmode #1\else #2\fi
+}%
+\def\tikzexternal@outmakefile@pendingcommands{}%
+
+% Will write something to the make file. If the makefile is not yet
+% opened, #1 will be written as soon as it *is* opened.
+\def\tikzexternalwritetomakefile#1{%
+ \if\tikzexternal@opmode5% mode='list and make'
+ \pgfutil@ifundefined{tikzexternal@outmakefile}{%
+ \expandafter\gdef\expandafter\tikzexternal@outmakefile@pendingcommands\expandafter{%
+ \tikzexternal@outmakefile@pendingcommands
+ \immediate\write\tikzexternal@outmakefile{#1}%
+ }%
+ }{%
+ \immediate\write\tikzexternal@outmakefile{#1}%
+ }%
+ \fi
+}%
+
+\def\tikzexternal@dep@file@name{}
+
+% Adds a dependency for the externalized picture file name `#1',
+% namely another file `#2'.
+%
+% #1: the fully qualified path name (without image extension) of the
+% external graphics for which we are adding a dependency.
+% #2: a file name. If this file gets changed, #1 shall be remade.
+%
+% This command will be actived as soons as \tikzexternalize has been
+% called.
+\def\tikzexternalfiledependsonfile@ACTIVE#1#2{%
+ \begingroup
+ \def\tikzpicturedependsonfile@name{#1}%
+ \ifx\tikzpicturedependsonfile@name\pgfutil@empty
+ % could be auto-generated: empty file name means "picture
+ % won't be externalized". Skip it.
+ \else
+ % if we encounter any dependencies while we externalize a
+ % picture, we have to write these things into the image's .dep
+ % file.
+ \tikzifexternalizingcurrent
+ {\tikzexternalfiledependsonfile@append@to@dep@file{#1}{#2}}%
+ {\tikzexternalfiledependsonfile@append@to@makefile{#1}{#2}}%
+ \fi
+ \endgroup
+}%
+\def\tikzexternalfiledependsonfile#1#2{}% NO-OP until \tikzexternalize has been called.
+
+% sub-routine of \tikzexternalfiledependsonfile which appends stuff to
+% the pictures .dep file.
+%
+% The file #1.dep is generated during the externalization of #1. If
+% you change and/or overwrite it in any other context, its information
+% might get lost (because #1 won't be regenerated).
+%
+% Consequently, this here has to be called if and only if #1 is about
+% to be externalized.
+\def\tikzexternalfiledependsonfile@append@to@dep@file#1#2{%
+ % write every dependency which is defined *INSIDE* of the current
+ % picture into the .dep file of the current picture:
+ \tikzexternalgetcurrentfilename\tikzpicturedependsonfile@name
+ \edef\tikzpicturedependsonfile@name{\tikzpicturedependsonfile@name.\tikzexternaldepext}%
+ %\edef\tikzpicturedependsonfile@name{#1.\tikzexternaldepext}%
+ \ifx\tikzexternal@dep@file@name\tikzpicturedependsonfile@name
+ % file is open and ready.
+ \else
+ % create new output file.
+ \pgfutil@ifundefined{tikzexternal@dep@file}{%
+ \begingroup
+ % this makes \tikzexternal@dep@file global:
+ \globaldefs=1
+ % this gets round '\outer\newwrite' in plain TeX:
+ \csname newwrite\endcsname\tikzexternal@dep@file
+ \endgroup
+ }{}%
+ \ifx\tikzexternal@dep@file@name\pgfutil@empty
+ \else
+ % it is already open. Close it.
+ \immediate\closeout\tikzexternal@dep@file
+ \fi
+ \global\let\tikzexternal@dep@file@name=\tikzpicturedependsonfile@name
+ \immediate\openout\tikzexternal@dep@file=\tikzexternal@dep@file@name\relax
+ \fi
+ \immediate\write\tikzexternal@dep@file{#1\tikzexternalimgextension: #2}%
+}
+
+% sub-routine of \tikzexternalfiledependsonfile which appends stuff to
+% the makefile of the current \jobname .
+%
+% This is used for dependencies which are recomputed by every run of
+% tex; we must not write them into #1.dep (for reasons explained in
+% the documentation of
+% \tikzexternalfiledependsonfile@append@to@dep@file)
+\def\tikzexternalfiledependsonfile@append@to@makefile#1#2{%
+ \edef\tikzexternal@temp{#1\tikzexternalimgextension: #2}%
+ \expandafter\tikzexternalwritetomakefile\expandafter{\tikzexternal@temp}%
+}
+
+% Adds a dependency for the NEXT picture which is about to be
+% externalized. If we are currently inside of a picture, the
+% dependency is added for this current picture.
+%
+% #1: a file name. If this file gets changed, the tikzpicture's
+% externalized graphics shall be remade.
+%
+% This command will be actived as soons as \tikzexternalize has been
+% called.
+\def\tikzpicturedependsonfile@ACTIVE#1{%
+ \begingroup
+ \tikzexternalgetcurrentfilename\tikzpicturedependsonfile@name
+ \ifx\tikzpicturedependsonfile@name\pgfutil@empty
+ \tikzexternalgetnextfilename\tikzpicturedependsonfile@name
+ \fi
+ \expandafter\tikzexternalfiledependsonfile\expandafter{\tikzpicturedependsonfile@name}{#1}%
+ \endgroup
+}%
+\def\tikzpicturedependsonfile#1{}% NO-OP until \tikzexternalize has been called.
+
+
+% 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
+}%
+
+
+% 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
+ \endgroup
+ \begingroup
+ \pgfkeysvalueof{/tikz/external/optimize away text/.@cmd}#1\pgfeov%
+ \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 the 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
+ \let\tikzexternal@curfilename=\relax
+}
+
+% 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
+ \pgfkeysvalueof{/tikz/external/optimize away text/.@cmd}tikzpicture\pgfeov%
+}
+
+% 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{\tikzexternal@forcegraphics@@@}%
+\def\tikzexternal@forcegraphics@@@{%
+ \if5\tikzexternal@opmode
+ \let\tikz@refundefinedtrue@@=\G@refundefinedtrue
+ \gdef\G@refundefinedtrue{%
+ \tikz@refundefinedtrue@@
+ \tikzexternal@forceremake@undefined@reference@handler
+ }%
+ \fi
+ \expandafter\pgfincludeexternalgraphics\expandafter{\tikzexternal@curfilename}%
+ \if5\tikzexternal@opmode
+ \global\let\G@refundefinedtrue=\tikz@refundefinedtrue@@
+ \fi
+ \tikzexternal@closeenvironments
+}
+
+\def\tikzexternal@forceremake@undefined@reference@handler{%
+ \immediate\write16{===== 'mode=list and make': encountered undefined reference in current picture. Adding dependency to FORCEREMAKE. Rerun make to update the picture.' ========^^J}%
+ \tikzpicturedependsonfile{FORCEREMAKE}%
+}%
+
+% 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{\tikzexternal@listmodepicture@@@}
+\def\tikzexternal@listmodepicture@@@{%
+ \pgfkeysvalueof{/tikz/external/image discarded text}%
+ \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{%
+ \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@list@and@makefile@mode@picture@
+}%
+\long\def\tikzexternal@list@and@makefile@mode@picture@#1{%
+ %
+ \tikzexternal@check@uptodate@mode{#1}%
+ %
+ \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@before@grab{%
+ \pgfutil@IfUndefined{TP@holdbox}{%
+ }{%
+ % \usepackage[absolute]{textpos}
+ % populates this box -- and would inject unwanted material into our images. Reset it:
+ \global\setbox\TP@holdbox\vbox{}%
+ }%
+}%
+
+\def\tikzexternal@externalizefig@GRAB{%
+ \ifpgf@external@grabshipout
+ \iftikzexternal@optimize
+ \tikzexternal@optimize@RESTORE
+ \fi
+ \tikzexternal@externalizefig@before@grab
+ \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
+ %
+ \tikzexternal@ensure@nonempty@floats
+ %
+ \let\tikzpicture=\tikzexternal@tikzpicture@replacement
+ \let\endtikzpicture=\tikzexternal@origendpicture
+ \iftikzexternal@optimize
+ \ifpgf@external@grabshipout
+ \tikzexternal@optimize@REPLACE
+ \fi
+ \fi
+ }%
+ \tikzpicture
+}%
+
+% If a sequence of floats containing JUST tikzpictures is
+% externalized, this results in EMPTY floats. Empty floats, in turn,
+% can confuse latex; it thinks it did something wrong.
+%
+% Solution: Avoid empty floats by writing junk into it.
+%
+% Note that this method is only invoked if \ifpgf@external@grabshipout
+% is true and if the text is OUTSIDE of the original shipout routine.
+% In other words: this text is being thrown away.
+%
+% see
+% http://tex.stackexchange.com/questions/54625/why-is-fixltx2e-incompatible-with-tikzexternalize
+\def\tikzexternal@ensure@nonempty@floats{%
+ tikzexternal: picture has been externalized. This text is required to avoid empty floats.
+}%
+
+% 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
+\catcode`\#=12
+\gdef\tikzexternal@HASHchar{#}
+\gdef\tikzexternal@TABchar{^^I}\gdef\tikzexternal@PERCENTchar{%}\xdef\tikzexternal@DOLLARchar{$}}
+
+% Creates the '/tikz/external/system call' command as string and
+% returns it into the (global!) macro #2.
+% #1: the image file name (as returned by
+% \tikzexternalgetnextfilename)
+% #2: the global return value macro
+%
+\def\tikzexternal@assemble@systemcall#1#2{%
+ \begingroup
+ \def\image{#1}%
+ \iftikzexternal@auto@detect@jobname
+ \edef\texsource{\string\def\string\tikzexternalrealjob{\tikzexternal@realjob}\string\input{\tikzexternal@realjob}}%
+ \else
+ \let\texsource=\tikzexternal@realjob
+ \fi
+ \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#2{\pgfkeysvalueof{/tikz/external/system call}}%
+ \endgroup
+}%
+\long\def\tikzexternal@externalizefig@systemcall@@#1{%
+ \tikzexternal@externalizefig@systemcall@uptodatecheck{#1}%
+ \tikzexternal@assemble@systemcall{\tikzexternal@curfilename}{\pgf@tempa}%
+ \global\let\tikzexternal@cursyscall=\pgf@tempa
+ \gdef\tikzexternal@typeset@picture@on@failure{1}%
+ \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!
+ %
+ \tikzexternalauxlock@setlock1%
+ \tikzexternal@externalizefig@systemcall@call{\tikzexternal@cursyscall}%
+ \tikzexternalauxlock@setlock0%
+ \expandafter\tikzexternal@externalizefig@systemcall@assertsuccess\expandafter{\tikzexternal@cursyscall}%
+ \pgfmath@smuggleone\pgf@filename
+ \endgroup
+ \fi
+ \ifx\pgf@filename\pgfutil@empty
+ \if1\tikzexternal@typeset@picture@on@failure
+ % 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
+ % Ah -- this picture failed, but the failure has already
+ % been handled somehow. Do not typeset it again!
+ %
+ % A use-case is that the picture has been rescheduled for
+ % \end{document}.
+ \gdef\tikzexternal@externalizefig@systemcall@next{\tikzexternal@closeenvironments}%
+ \fi
+ \else
+ % ok, take the image!
+ \gdef\tikzexternal@systemcall@reschedule@to@end@document{0}%
+ \expandafter\pgfincludeexternalgraphics\expandafter{\tikzexternal@curfilename}%
+ \if1\tikzexternal@systemcall@reschedule@to@end@document
+ \pgfutil@IfUndefined{AtVeryEndDocument}{%
+ }{%
+ \immediate\write16{===== The previous system call resulted in undefined references inside of the output file. Rescheduling it for \string\end{document}. ========}%
+ \expandafter\tikzexternal@externalizefig@systemcall@reschedule\expandafter{\tikzexternal@cursyscall}%
+ }%
+ \fi
+ \gdef\tikzexternal@externalizefig@systemcall@next{\tikzexternal@closeenvironments}%
+ \fi
+ \tikzexternal@externalizefig@systemcall@next
+}%
+
+\def\tikzexternal@externalizefig@systemcall@call#1{%
+ \iftikzexternal@verboseio
+ \immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}%
+ \fi
+ \pgfutil@shellescape{#1}%
+}%
+
+% Sets \iftikzexternal@file@isuptodate to false if one of the "force
+% remake" things is active.
+\def\tikzexternal@checkforceremake{%
+ \iftikzexternal@force@remake
+ \global\tikzexternal@file@isuptodatefalse
+ \else
+ \iftikzexternalremakenext
+ \global\tikzexternal@file@isuptodatefalse
+ \global\tikzexternalremakenextfalse
+ \fi
+ \fi
+}
+
+\pgfutil@IfUndefined{pdfmdfivesum}{%
+}{%
+ % predefine to this value. This does only make sense for pdftex.
+ % note that the latex library for 'external' loads \usepackage{pdftexcmds} which \let's this to \pdf@mdfivesum:
+ \let\tikzexternal@mdfivesum=\pdfmdfivesum
+}%
+
+\long\def\tikzexternal@computemdfivesum#1{%
+ \t@tikzexternal@tmpb={#1}%
+ \edef\tikzexternal@temp{\the\t@tikzexternal@tmpb}%
+ % \meaning results in a string of catcode 12 - which is expandable.
+ \edef\pgfretval{\tikzexternal@mdfivesum{\meaning\tikzexternal@temp}}%
+}
+\long\def\tikzexternal@computemdfivesum@diff@fallback#1{%
+ \t@tikzexternal@tmpb={#1}%
+ \edef\tikzexternal@temp{\the\t@tikzexternal@tmpb}%
+ % \meaning results in a string of catcode 12 - which is expandable.
+ \edef\pgfretval{\meaning\tikzexternal@temp}%
+}
+
+% Will be set dynamically, depending on 'up to date check'.
+%
+% It expands to code such that \tikzexternallastkey contains the
+% serialized version of '#1'.
+%
+% It is used as argument for \write{..}
+%
+% #1 the hash key to serialize.
+% \def\tikzexternal@hashfct@serialize
+\long\def\tikzexternal@hashfct@serialize@std#1{%
+ \noexpand\def\noexpand\tikzexternallastkey{#1}%
+}%
+
+% serializes using temporary token registers. Necessary if #1 contains
+% executable code.
+\long\def\tikzexternal@hashfct@serialize@tok#1{%
+ \noexpand\begingroup
+ % in order to allow '#' inside of the body, we have to use token registers:
+ \noexpand\toks0={#1}%
+ \noexpand\xdef\noexpand\tikzexternallastkey{\noexpand\the\noexpand\toks0 }%
+ \noexpand\endgroup
+}%
+
+\def\tikzexternal@check@uptodate@ext{.md5}
+
+\def\tikzexternal@check@uptodate@mode@warn@fallback{%
+ \message{! Package tikz Warning: The key 'up to date check=md5' is impossible, there is no macro to compute MD5. Falling back to 'up to date check=diff'.}%
+ %
+ % warn only once:
+ \global\let\tikzexternal@check@uptodate@mode@warn@fallback=\relax
+}%
+
+% assigns the boolean \iftikzexternal@file@isuptodate
+\long\def\tikzexternal@check@uptodate@mode#1{%
+ \if1\tikzexternal@uptodate@mode
+ % up to date check=md5:
+ % check if we CAN compute MD5 sums:
+ \pgfutil@IfUndefined{tikzexternal@mdfivesum}{%
+ % we cannot compute md5 sums - fallback to diff.
+ \tikzexternal@check@uptodate@mode@warn@fallback
+ \def\tikzexternal@uptodate@mode{2}%
+ }{}%
+ \fi
+ %
+ \ifcase\tikzexternal@uptodate@mode
+ % up to date check=simple
+ % nothing to do -- file existance is checked anyway.
+ \let\tikzexternal@hashfct=\pgfutil@empty
+ \let\tikzexternal@hashfct@serialize=\pgfutil@empty
+ \or
+ % up to date check=md5
+ \let\tikzexternal@hashfct=\tikzexternal@computemdfivesum
+ \let\tikzexternal@hashfct@serialize=\tikzexternal@hashfct@serialize@std
+ \or
+ \let\tikzexternal@hashfct=\tikzexternal@computemdfivesum@diff@fallback
+ \let\tikzexternal@hashfct@serialize=\tikzexternal@hashfct@serialize@tok
+ \fi
+ \ifx\tikzexternal@hashfct\pgfutil@empty
+ \else
+ \tikzpicturedependsonfile{\tikzexternal@curfilename\tikzexternal@check@uptodate@ext}%
+ \tikzexternal@hashfct{#1}%
+ \let\tikzexternal@lastkey@new=\pgfretval
+ \begingroup
+ % no '@' token in this macro: avoid messing up the catcodes in input files:
+ \global\let\tikzexternallastkey=\pgfutil@empty
+ \openin\r@pgf@reada=\tikzexternal@curfilename\tikzexternal@check@uptodate@ext\relax %
+ \ifeof\r@pgf@reada
+ \else
+ % read first line...
+ \endlinechar=-1 % older versions did not have a '%' at the end-of-line. Avoid spurious spaces.
+ \read\r@pgf@reada to\pgf@tempa
+ % ... and execute it.
+ \pgf@tempa
+ % it should contain a definition of \tikzexternallastkey.
+ \fi
+ \closein\r@pgf@reada
+ %
+ \let\tikzexternal@lastkey=\tikzexternallastkey
+ \pgfmath@smuggleone\tikzexternal@lastkey
+ \endgroup
+ % normalize catcodes. Unfortunately, they cannot be expected to be the same.
+ % \meaning will use catcode 12 for each token:
+ \edef\tikzexternal@lastkey@normalized{\meaning\tikzexternal@lastkey}%
+ \edef\tikzexternal@lastkey@new@normalized{\meaning\tikzexternal@lastkey@new}%
+ \iftikzexternal@verboseuptodate
+ \immediate\write16{Up-to-date check of \tikzexternal@curfilename: new \tikzexternal@lastkey@new@normalized; old \tikzexternal@lastkey@normalized.^^J}%
+ \fi
+ \ifx\tikzexternal@lastkey@normalized\tikzexternal@lastkey@new@normalized
+ \tikzexternal@file@isuptodatetrue
+ \else
+ \tikzexternal@file@isuptodatefalse
+ \immediate\openout\w@pgf@writea=\tikzexternal@curfilename\tikzexternal@check@uptodate@ext\relax%
+ \immediate\write\w@pgf@writea{\tikzexternal@hashfct@serialize{\tikzexternal@lastkey@new}\tikzexternal@PERCENTchar}%
+ \immediate\closeout\w@pgf@writea
+ \fi
+ \fi
+}
+
+% 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.
+% #1: the picture-content
+\long\def\tikzexternal@externalizefig@systemcall@uptodatecheck#1{%
+ \tikzexternal@check@uptodate@mode{#1}%
+ \tikzexternal@checkforceremake
+ \iftikzexternal@file@isuptodate
+ % 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
+ \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%
+ \tikzexternal@externalizefig@systemcall@handleexception{#1}%
+ \fi
+}%
+\def\tikzexternal@externalizefig@systemcall@handleexception@msg#1{%
+ \tikzerror{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}{}%
+}
+\def\tikzexternal@externalizefig@systemcall@handleexception@retry@later#1{%
+ \gdef\tikzexternal@systemcall@reschedule@to@end@document{0}%
+ \expandafter\pgfexternalreaddpth\expandafter{\tikzexternal@curfilename}%
+ \if1\tikzexternal@systemcall@reschedule@to@end@document
+ \pgfutil@IfUndefined{AtVeryEndDocument}{%
+ \tikzexternal@externalizefig@systemcall@handleexception@msg{#1}%
+ }{%
+ \immediate\write16{===== The last system call resulted in an EMPTY output file. Maybe it is part of \string\ref. Rescheduling it for \string\end{document}. ========}%
+ \gdef\tikzexternal@typeset@picture@on@failure{0}%
+ \tikzexternal@externalizefig@systemcall@reschedule{#1}%
+ }%
+ \else
+ \tikzexternal@externalizefig@systemcall@handleexception@msg{#1}%
+ \fi
+}
+
+% reschedules the externalization of the current file to
+% \AtVeryEndDocument.
+%
+% This hook allows to execute code AFTER the main .aux file is
+% finished; it will even re-read the main aux file.
+\def\tikzexternal@externalizefig@systemcall@reschedule#1{%
+ \t@tikzexternal@tmpb={%
+ \global\let\tikzexternal@externalizefig@systemcall@handleexception=\tikzexternal@externalizefig@systemcall@handleexception@msg%
+ % ... no auxlocks!
+ \tikzexternal@externalizefig@systemcall@call{#1}%
+ \tikzexternal@externalizefig@systemcall@assertsuccess{#1}%
+ }%
+ \xdef\pgfutil@tempa{%
+ \noexpand\def\noexpand\tikzexternal@curfilename{\tikzexternal@curfilename}%
+ \the\t@tikzexternal@tmpb
+ }%
+ \expandafter\AtVeryEndDocument\expandafter{\pgfutil@tempa}%
+ \gdef\tikzexternal@has@rescheduled@something{1}%
+}%
+\let\tikzexternal@externalizefig@systemcall@handleexception=\tikzexternal@externalizefig@systemcall@handleexception@retry@later%
+
+\def\tikzexternal@has@rescheduled@something{0}%
+\pgfutil@IfUndefined{AtVeryEndDocument}{}{%
+ \AtVeryEndDocument{%
+ \if1\tikzexternal@has@rescheduled@something
+ \immediate\write16{===== tikzexternal: \string\end{document} reached. Working on rescheduled images to resolve references... ========}%
+ \fi
+ }%
+}
+
+% Overwrite error message of pgf.
+% This happens if the generated image was empty, i.e. if there was no \shipout.
+\def\pgfexternal@error@no@shipout{%
+ \begingroup
+ \begingroup
+ % overwrite .dpth file in order to flag the file as "need to be scheduled
+ % for \AtVeryEndDocument" :
+ \immediate\openout\pgf@plotwrite=\pgfactualjobname.dpth
+ \let\w@pgfexternal@auxout=\pgf@plotwrite
+ \pgfexternalstorecommand@isexporting{\gdef\noexpand\tikzexternal@systemcall@reschedule@to@end@document{1}}%
+ \immediate\closeout\pgf@plotwrite
+ \endgroup
+ \tikzexternal@assemble@systemcall{\pgfactualjobname}{\pgf@tempa}%
+ \toks0=\expandafter{\pgf@tempa}%
+ \tikzerror{Sorry, image externalization failed: the resulting image was EMPTY. I tried to externalize '\pgfactualjobname', but it seems there is no such image in the document!?
+ \if\tikzexternal@opmode4 ^^J
+\space\space You are currently using 'mode=convert with system call'. This problem can happen if the image (or one of the images preceeding it) was declared inside of a \string\label{} (i.e. in the .aux file): 'convert with system call' has no access to the main aux file.^^J
+\space\space Possible solutions in this case:^^J
+\space\space (a) Try using 'mode=list and make',^^J
+\space\space (b) Issue the externalization command '\the\toks0' *manually* (also check the preceeding externalized images, perhaps the file name sequence is not correct).^^J
+\space\space Repeat: the resulting image was EMPTY, your attention is required
+\else
+ \if\tikzexternal@opmode5 ^^J
+\space\space You are currently using 'mode=list and make'. Possible solutions:^^J
+\space\space (a) Try to delete `\tikzexternal@realjob.makefile'. Perhaps it is not up-to-date.^^J
+\space\space (b) Perhaps pictures are declared inside of \string\label{} and the .aux file is not up-to-date. Re-run latex, perhaps re-generate the graphics as well.^^J
+\space\space Repeat: the resulting image was EMPTY, your attention is required
+ \fi
+\fi}%
+ \endgroup
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex
new file mode 100644
index 0000000000..e4ef015455
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex
@@ -0,0 +1,133 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 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
+%%%
+%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Date of this copy: Do 31. Dez 19:01:21 CET 2015 %%%
+
+
+
+% 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.
+
+% load this package in order to get \pdf@mdfivesum .
+% \pdf@mdfivesum is available for pdftex and lualatex and computes the
+% md5 sum. Note that pdftex has \pdfmdfivesum, but lualatex does not
+% have it.
+%
+% ... also used for \pdf@shellescape.
+\usepackage{pdftexcmds}
+\pgfutil@IfFileExists{atveryend.sty}{%
+ \usepackage{atveryend}%
+}{%
+ \message{! Package tikz Warning: \string\usepackage{atveryend} impossible. Automatic resolving of references within external files impossible.}%
+}%
+
+% source generic implementation:
+\input pgfplotsoldpgfsupp_tikzexternalshared.code.tex
+
+\pgfutil@IfUndefined{pdf@mdfivesum}{}{%
+ \let\tikzexternal@mdfivesum=\pdf@mdfivesum
+}%
+
+\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}%
+ }%
+ \t@tikzexternal@tmpa={}% release memory.
+ \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}%
+
+\def\tikzexternal@handle@landscape{%
+ \ltx@ifpackageloaded{pdflscape}{%
+ % Work around a bug in conjunction with pdflscape and
+ % external: without this optimize-away-instruction, the
+ % externalized image would be rotated - and it will be rotated
+ % once more again when it is included.
+ %
+ % if we "optimize it away", the landscape stuff will be
+ % omitted. I hope this is enough... might not be entirely
+ % fool-proof; perhaps we need to set it to \relax. For now, it
+ % will probably do the job
+ \tikzset{
+ external/.cd,
+ optimize command away=\landscape,
+ optimize command away=\endlandscape
+ }%
+ }{%
+ }%
+}%
+
+\AtBeginDocument{%
+ \pgfutil@ifundefined{tikzexternalrealjob}{%
+ \global\let\tikzexternalrealjob=\jobname
+ }{}%
+ \tikzexternal@handle@landscape
+}%
+
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_trig_format.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_trig_format.code.tex
new file mode 100644
index 0000000000..4ebb95439e
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsoldpgfsupp_trig_format.code.tex
@@ -0,0 +1,380 @@
+% This file contains patches to support 'trig format'
+%
+%%% 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.
+%%%
+%%% This file contains just the functionality for trig format (written by Christian Feuersaenger).
+%%%
+% Support for the contents of this file will NOT be done by the PGF/TikZ team.
+% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
+% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
+% This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\pgfkeys{
+ /pgf/trig format/.is choice,
+ /pgf/trig format/deg/.code={\def\pgfmath@trig@format@choice{0}},
+ /pgf/trig format/rad/.code={\def\pgfmath@trig@format@choice{1}},
+ /pgf/trig format/deg,
+}
+
+% Executes #1 if 'trig format=deg' and #2 otherwise.
+\def\pgfmathiftrigonometricusesdeg#1#2{%
+ \if0\pgfmath@trig@format@choice
+ #1%
+ \else
+ #2%
+ \fi
+}%
+
+\pgfutil@ifundefined{pgfmath@multiply@thousand}{%
+ % Oh - we are working against PGF 2.10 . Apply more patches:
+ %
+ \def\pgfmath@multiply@thousand#1.#2#3#4#5\relax{%
+ \edef\pgfmathresult{#1#2#3#4.#5}%
+ }%
+ % Defines \pgfmath@x to be the result of the table lookup for value
+ % '#1' in table '#2'
+ %
+ % #1: a value for which lookup should be performed
+ % #2: the table's prefix name
+ % #3: the table's size
+ \def\pgfmath@table@lookup#1#2#3{%
+ \pgfmath@x=#1\relax
+ \expandafter\pgfmath@table@lookup@\the\pgfmath@x\relax{#2}{#3}%
+ }
+ \def\pgfmath@table@lookup@#1.#2\relax#3#4{%
+ \edef\pgf@temp{\Pgf@geT#2}% strip 'pt' suffix.
+ %
+ % prepare constant interpolant (i.e. the value at node '#1'):
+ \pgfmath@x=\csname #3#1\endcsname pt %
+ %
+ \c@pgfmath@countc=#1 %
+ \advance\c@pgfmath@countc by1 %
+ \ifnum\c@pgfmath@countc<#4 %
+ % Ah - we have enough elements in the table.
+ %
+ % perform linear interpolation:
+ \pgfmath@ya=\csname #3\the\c@pgfmath@countc\endcsname pt %
+ \advance\pgfmath@ya by-\pgfmath@x %
+ \advance\pgfmath@x by0.\pgf@temp\pgfmath@ya
+ \fi
+ }%
+}{}%
+
+
+
+\def\pgfmath@scale@rad@to@deg#1{%
+ #1=57.29577#1\relax% 57.29577 = 360/(2*pi)
+}%
+\def\pgfmath@scale@deg@to@rad#1{%
+ #1=3.14159#1%
+ \divide#1180\relax%
+}%
+
+\def\pgfmathsin@#1{%
+ % Let #1 = a.b
+ % Then sin(#1) \approx (1-b)*sin(a) + b*sin(a+1)
+ %
+ \begingroup%
+ \expandafter\pgfmath@x#1pt\relax%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@rad@to@deg\pgfmath@x
+ \fi
+ \advance\pgfmath@x-90pt\relax%
+ \afterassignment\pgfmath@gobbletilpgfmath@
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@
+ \divide\c@pgfmath@counta360\relax%
+ \multiply\c@pgfmath@counta-360\relax%
+ \advance\pgfmath@x\c@pgfmath@counta pt\relax%
+ \ifdim\pgfmath@x<0pt\relax\pgfmath@x-\pgfmath@x\fi%
+ \ifdim\pgfmath@x<180pt\relax%
+ \else
+ \pgfmath@x-\pgfmath@x%
+ \advance\pgfmath@x360pt\relax%
+ \fi%
+ % Now 0 <= x < 179. So split x into integer and decimal...
+ %
+ \afterassignment\pgfmath@xa%
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\relax%
+ %
+ % ...if #1 is an integer, don't do anything fancy.
+ \ifdim\pgfmath@xa=0pt%
+ \expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname pt\relax%
+ \else%
+ \pgfmath@x-\pgfmath@xa%
+ \advance\pgfmath@x1pt\relax%
+ \expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname\pgfmath@x%
+ \advance\c@pgfmath@counta1\relax%
+ \ifnum\c@pgfmath@counta=181\relax\c@pgfmath@counta179\relax\fi%
+ \expandafter\advance\expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname\pgfmath@xa%
+ \fi%
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup
+}
+
+% \pgfmathcos
+%
+% Calculate the cosine of #1 (in degrees).
+%
+\def\pgfmathcos@#1{%
+ % Let x = a.b
+ % Then cos(x) \approx (1-b)*cos(a) + b*cos(a+1)
+ %
+ \begingroup%
+ \expandafter\pgfmath@x#1pt\relax%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@rad@to@deg\pgfmath@x
+ \fi
+ \afterassignment\pgfmath@gobbletilpgfmath@%
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@%
+ \divide\c@pgfmath@counta360\relax%
+ \multiply\c@pgfmath@counta-360\relax%
+ \advance\pgfmath@x\c@pgfmath@counta pt\relax%
+ \ifdim\pgfmath@x<0pt\relax\pgfmath@x-\pgfmath@x\fi%
+ \ifdim\pgfmath@x<180pt\relax%
+ \else%
+ \pgfmath@x-\pgfmath@x%
+ \advance\pgfmath@x360pt\relax%
+ \fi%
+ % Now 0 <= x < 179. So split x into integer and decimal...
+ %
+ \afterassignment\pgfmath@xa%
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\relax%
+ %
+ % ...if #1 is an integer, don't do anything fancy.
+ \ifdim\pgfmath@xa=0pt%
+ \expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname pt%
+ \else%
+ \pgfmath@x-\pgfmath@xa%
+ \advance\pgfmath@x1pt\relax%
+ \expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname\pgfmath@x%
+ \advance\c@pgfmath@counta1\relax%
+ \ifnum\c@pgfmath@counta=181\relax\c@pgfmath@counta179\relax\fi%
+ \expandafter\advance\expandafter\pgfmath@x\csname pgfmath@cos@\the\c@pgfmath@counta\endcsname\pgfmath@xa%
+ \fi%
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}
+
+\def\pgfmathasin@#1{%
+ \begingroup%
+ \pgfmath@x=#1pt %
+ \pgfmath@xa\pgfmath@x%
+ \edef\pgf@temp{\pgf@sys@tonumber\pgfmath@x}%
+ % compute lossless '*1000' operation:
+ \expandafter\pgfmath@multiply@thousand\pgf@temp 000\relax
+ \pgfmath@x=\pgfmathresult pt %
+ \ifdim\pgfmath@x<0pt\relax%
+ \pgfmath@x-\pgfmath@x%
+ \fi%
+ \pgfmath@table@lookup{\pgfmath@x}{pgfmath@acos@}{1001}%
+ \pgfmath@x=-\pgfmath@x
+ \advance\pgfmath@x90pt\relax%
+ \ifdim\pgfmath@xa<0pt\relax%
+ \pgfmath@x-\pgfmath@x%
+ \fi%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@deg@to@rad\pgfmath@x
+ \fi
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}
+\def\pgfmathacos@#1{%
+ \begingroup%
+ \pgfmath@x#1pt\relax%
+ \pgfmath@xa\pgfmath@x%
+ \edef\pgf@temp{\pgf@sys@tonumber\pgfmath@x}%
+ % compute lossless '*1000' operation:
+ \expandafter\pgfmath@multiply@thousand\pgf@temp 000\relax
+ \pgfmath@x=\pgfmathresult pt %
+ \ifdim\pgfmath@x<0pt\relax%
+ \pgfmath@x-\pgfmath@x%
+ \fi%
+ \pgfmath@table@lookup{\pgfmath@x}{pgfmath@acos@}{1001}%
+ \ifdim\pgfmath@xa<0pt\relax%
+ \pgfmath@x-\pgfmath@x%
+ \advance\pgfmath@x by180pt\relax%
+ \fi%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@deg@to@rad\pgfmath@x
+ \fi
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}
+
+\def\pgfmathatan@#1{%
+ \begingroup%
+ \expandafter\pgfmath@x#1pt\relax%
+ \pgfmath@xa\pgfmath@x%
+ \ifdim\pgfmath@x<0pt\relax%
+ \pgfmath@x-\pgfmath@x%
+ \fi%
+ \pgfmath@xb\pgfmath@x%
+ \ifdim\pgfmath@x>1pt\relax%
+ \edef\pgfmath@temp{\pgfmath@tonumber{\pgfmath@x}}%
+ \pgfmathreciprocal@{\pgfmath@temp}%
+ \pgfmath@x\pgfmathresult pt\relax%
+ \fi%
+ % compute lossless '*1000' operation:
+ \edef\pgf@temp{\pgf@sys@tonumber\pgfmath@x}%
+ \expandafter\pgfmath@multiply@thousand\pgf@temp 000\relax
+ \pgfmath@x=\pgfmathresult pt %
+ \pgfmath@table@lookup{\pgfmath@x}{pgfmath@atan@}{1001}%xxx
+ \ifdim\pgfmath@xb>1pt\relax%
+ \pgfmath@x=-\pgfmath@x%
+ \advance\pgfmath@x90pt%
+ \fi%
+ \ifdim\pgfmath@xa<0pt\relax%
+ \pgfmath@x-\pgfmath@x%
+ \fi%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@deg@to@rad\pgfmath@x
+ \fi
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}
+
+\expandafter\def\csname pgfmathatan2@\endcsname#1#2{%
+ % Note: first parameter is y (!), second is x (!)
+ \begingroup%
+ \pgfmath@y=#1pt\relax%
+ \ifdim\pgfmath@y<0pt\relax%
+ \pgfmath@y=-\pgfmath@y%
+ \fi%
+ \ifdim\pgfmath@y<0.001pt\relax%
+ \ifdim#2pt<0pt\relax%
+ \pgfmath@x=-180pt\relax%
+ \else%
+ \ifdim#2pt>0pt\relax%
+ \pgfmath@x=0pt\relax%
+ \else%
+ \ifdim#1pt<0pt%
+ \pgfmath@x=-90pt\relax%
+ \else%
+ \pgfmath@x=90pt\relax%
+ \fi%
+ \fi%
+ \fi%
+ \else%
+ \pgfmathabs@{#1}\let\pgfmath@tempa\pgfmathresult%
+ \pgfmathabs@{#2}\let\pgfmath@tempb\pgfmathresult%
+ \ifdim\pgfmath@tempa pt>\pgfmath@tempb pt%
+ \pgfmathdivide@{#2}{\pgfmath@tempa}%
+ \expandafter\pgfmathatan@\expandafter{\pgfmathresult}%
+ \pgfmath@x=90pt%
+ \advance\pgfmath@x by-\pgfmathresult pt\relax%
+ \else%
+ \pgfmathdivide@{\pgfmath@tempa}{#2}%
+ \expandafter\pgfmathatan@\expandafter{\pgfmathresult}%
+ \pgfmath@x=\pgfmathresult pt\relax%
+ \ifdim#2pt<0pt%
+ \advance\pgfmath@x by180pt\relax%
+ \fi%
+ \fi%
+ \ifdim#1pt<0pt\relax%
+ \pgfmath@x=-\pgfmath@x%
+ \fi%
+ \fi%
+ \if1\pgfmath@trig@format@choice
+ % trig format=rad
+ \pgfmath@scale@deg@to@rad\pgfmath@x
+ \fi
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}
+
+% FPU:
+
+
+\let\pgfmath@basic@sin@=\pgfmathsin@
+\let\pgfmath@basic@cos@=\pgfmathcos@
+\let\pgfmath@basic@tan@=\pgfmathtan@
+\let\pgfmath@basic@atan@=\pgfmathatan@
+\let\pgfmath@basic@asin@=\pgfmathasin@
+\let\pgfmath@basic@acos@=\pgfmathacos@
+\let\pgfmath@basic@cot@=\pgfmathcot@
+\let\pgfmath@basic@sec@=\pgfmathsec@
+\let\pgfmath@basic@cosec@=\pgfmathcosec@
+
+% Computes #1(#2) where #1 is a trigonometric function, i.e.
+% #1(#2) = #1( #2 + r*360 )
+%
+% #1 is a one-argument macro which assigns \pgfmathresult.
+\def\pgfmathfloatTRIG@#1#2{%
+ \if0\pgfmath@trig@format@choice
+ % trig format=deg
+ \expandafter\ifx\csname pgfmathfloatTRIG@NUM\endcsname\relax%
+ % Lazy evaluation:
+ \pgfmathfloatcreate{1}{3.6}{2}%
+ \global\let\pgfmathfloatTRIG@NUM=\pgfmathresult
+ \pgfmathfloatcreate{1}{2.77777777777778}{-3}%
+ \global\let\pgfmathfloatTRIG@NUM@INV=\pgfmathresult
+ \fi
+ \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@NUM}{\pgfmathfloatTRIG@NUM@INV}%
+ \else
+ % trig format=rad
+ \expandafter\ifx\csname pgfmathfloatTRIG@rad@NUM\endcsname\relax%
+ % Lazy evaluation:
+ \pgfmathfloatcreate{1}{6.28318530717959}{0}%
+ \global\let\pgfmathfloatTRIG@rad@NUM=\pgfmathresult
+ \pgfmathfloatcreate{1}{1.59154943091895}{-1}%
+ \global\let\pgfmathfloatTRIG@rad@NUM@INV=\pgfmathresult
+ \fi
+ \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@rad@NUM}{\pgfmathfloatTRIG@rad@NUM@INV}%
+ \fi
+ \pgfmathfloattofixed@{\pgfmathresult}%
+ \expandafter#1\expandafter{\pgfmathresult}%
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+}%
+
+\def\pgfmathfloatsin@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}}
+\let\pgfmathfloatsin=\pgfmathfloatsin@
+\def\pgfmathfloatcos@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}}
+\let\pgfmathfloatcos=\pgfmathfloatcos@
+\def\pgfmathfloatsec@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}}
+\let\pgfmathfloatsec=\pgfmathfloatsec@
+\def\pgfmathfloatcosec@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}}
+\let\pgfmathfloatcosec=\pgfmathfloatcosec@
+
+\def\pgfmathfloatatan@#1{%
+ \begingroup
+ \expandafter\ifx\csname pgfmathfloatatan@TMP\endcsname\relax%
+ \pgfmathfloatcreate{1}{1.6}{4}%
+ \global\let\pgfmathfloatatan@TMP=\pgfmathresult
+ \pgfmathfloatcreate{2}{1.6}{4}%
+ \global\let\pgfmathfloatatan@TMPB=\pgfmathresult
+ \fi
+ \pgfmathfloatgreaterthan@{#1}{\pgfmathfloatatan@TMP}%
+ \ifpgfmathfloatcomparison
+ \pgfmathiftrigonometricusesdeg{%
+ \pgfmathfloatcreate{1}{9.0}{1}%
+ }{%
+ \pgfmathfloatcreate{1}{1.570796326794}{0}%
+ }%
+ \else
+ \pgfmathfloatlessthan{#1}{\pgfmathfloatatan@TMPB}%
+ \ifpgfmathfloatcomparison
+ \pgfmathiftrigonometricusesdeg{%
+ \pgfmathfloatcreate{2}{9.0}{1}%
+ }{%
+ \pgfmathfloatcreate{2}{1.570796326794}{0}%
+ }%
+ \else
+ \pgfmathfloattofixed@{#1}%
+ \expandafter\pgfmath@basic@atan@\expandafter{\pgfmathresult}%
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \fi
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsplothandlers.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsplothandlers.code.tex
new file mode 100644
index 0000000000..f10082afb3
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsplothandlers.code.tex
@@ -0,0 +1,3083 @@
+%--------------------------------------------
+%
+% 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 2010 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/>.
+%
+%--------------------------------------------
+
+% 1. OVERVIEW
+%
+% Plot handlers are extended versions of the plot handlers of PGF with
+% backwards compatibility.
+%
+% To remind ourselfes: PGF plot handlers work like this
+% \pgfplotstreamstart
+% \pgfplotstreampoint{...}
+% \pgfplotstreampoint{...}
+% \pgfplotstreampoint{...}
+% \pgfplotstreampoint{...}
+% \pgfplotstreamend
+%
+% and that's it.
+%
+% PGFPlots plot handlers also contain these three macros. The tasks
+% are (of course) the same. In addition, they support a set of further
+% macros for every plot handler:
+%
+% \pgfplotsplothandlersurveystart
+% \pgfplotsplothandlersurveypoint
+% \pgfplotsplothandlersurveyend
+%
+% and serialization methods
+% \pgfplotsplothandlerserializepointto
+% \pgfplotsplothandlerdeserializepointfrom
+% \pgfplotsplothandlerserializestateto
+% \pgfplotsplothandlerdeserializepointfrom
+%
+% in addition, there are utility macros
+% \pgfplotsplothandlersurveydifflen#1#2
+% \pgfplotsplothandlersurveypointattime#1#2#3
+%
+% The idea is as follows:
+% During \addplot, PGFPLots performs a survey phase. Survey means:
+% nothing will be drawn, only stats will be collected. In this phase,
+% the \pgfplotsplothandlersurvey* methods will be invoked; followed by
+% a serialization.
+%
+% Then, when every plot has been surveyed, PGFPlots calls
+% \pgfplotsplothandlerdeserializestatefrom{<serialized state>}
+% \pgfplotstreamstart
+% foreach <serizalized point> {
+% \pgfplotsplothandlerdeserializepointfrom{<serialized point>}
+% apply data transformations
+% handle plot marks
+% \pgfplotstreampoint{\pgfplotsqpointxy{<x>}{<y}}
+% }
+% \pgfplotstreamend
+%
+% See below for details about the survey phase and the visualization
+% phase and the API of an axis.
+%
+% Thus, the PGF basic level streams can (but don't need to) make use
+% of the macros assigned by the
+% \pgfplotsplothandlerdeserializepointfrom and
+% \pgfplotsplothandlerdeserializestatefrom.
+%
+% Furthermore, a plot handler *can* redefine any of the survey and/or
+% serialization methods to add further functionality. But it doesn't
+% need to, it's ok if it only relies on x,y as standard pgf plot
+% handlers do.
+%
+% If it overwrites something, it should do so in its main method, the
+% one in which it also defines the \pgf@plotstreamstart etc. methods
+% (see pgfmoduleplot.code.tex for example). BUT: do NOT overwrite
+% these methods globally!
+%
+% 2. A Description of the two phases:
+%
+% THE SURVEY PHASE:
+% The survey phase works as follows.
+% PRECONDITION:
+% - we are `inside' of an axis.
+% - \addplot starts the survey phase.
+%
+% The following happens:
+% - the plot handler is determined and activated such that its
+% methods are usable ("class is instantiated")
+% - \pgfplots@PREPARE@COORD@STREAM is the internal, low level
+% entry point where pgfplots controls the survey phase.
+% - the coordinate input routine is initialised. It issues a
+% series of commands (all within the *same* TeX scope):
+% \pgfplots@coord@stream@start
+% \pgfplots@coord@stream@coord
+% \pgfplots@coord@stream@coord
+% \pgfplots@coord@stream@coord
+% \pgfplots@coord@stream@coord
+% \pgfplots@coord@stream@coord
+% \pgfplots@coord@stream@coord
+% ...
+% \pgfplots@coord@stream@end
+% - \pgfplotsplothandlersurveystart is called in
+% \pgfplots@coord@stream@start.
+% - \pgfplots@coord@stream@coord calls
+% \pgfplotsplothandlersurveypoint
+% - \pgfplots@coord@stream@end calls
+% \pgfplotsplothandlersurveyend
+% \pgfplotsplothandlerserializestateto<\macro>
+% Furthermore, it remembers the <\macro> such that it can be
+% deserialized later.
+% Then, the survey phase ends. The main point of interest is the
+% \pgfplotsplothandlersurveypoint routine, especially its
+% communication with the axis. It is described below.
+%
+% POSTCONDITION:
+% - the state of the axis is now aware of the new plot (limits,
+% stacking, ...).
+% - The plot's survey state is stored using its serialized
+% representation.
+%
+% THE VISUALIZATION PHASE:
+% FIXME
+%
+% 2.1 The API of an axis
+%
+% As described above, the coordinate input routine fires a lot of
+% \pgfplots@coord@stream@coord commands, which, in turn, invoke
+% \pgfplotsplothandlersurveypoint. Somehow this should update the
+% axis' state to reflect each point. But the 'data point' is a rather
+% abstract thing. Usually, it will contain at least (x,y) (or maybe z)
+% coordinates. But it may be more complex.
+%
+% So, the coordinate input routine provides whatever the user has
+% chosen. Let's assume, we are using \addplot table. Then, we can
+% access every cell in the current row (using \thisrow{<colname>} for
+% example). The plot handler knows how to extract its information from
+% this state. In general, the following steps are taken:
+% - the plot handler assembles coordinates.
+% - every assembled coordinate should be reported to the axis by
+% defining \pgfplots@current@point@[xyz] to its coordinates and
+% calling
+% \pgfplotsaxisparsecoordinate{}
+% This will apply coordinate filters, parse the single coordinates
+% and apply high level transformations and any logarithms.
+% It is some sort of advanced coordinate parser which works only for
+% (x,y) or for (x,y,z).
+% It yields (x,y,z). But the axis might need to change its
+% components! Thus, you also need to call
+% \pgfplotsaxispreparecoordinate{}.
+% This will, for example, apply the "stack plots" feature or the
+% 'data cs' feature.
+%
+% If necessary, the plot handler calls
+% \pgfplotsaxisparsecoordinate{} and
+% \pgfplotsaxispreparecoordinate{} multiple times, once for each
+% encountered coordinate.
+%
+% It might occasionally be too much to call
+% \pgfplotsaxispreparecoordinate.
+%
+% It might happen that a coordinate filter discards a coordinate.
+% This is returned in the \ifpgfplotsaxisparsecoordinateok boolean
+% and has to be checked by the plot handler.
+%
+% - the plot handler knows which of the coordinates contribute to the
+% final plot. It invokes
+% \ifpgfplotsaxisparsecoordinateok
+% \pgfplotsaxisupdatelimitsforcoordinate{<x>}{<y>}{<z>}
+% \fi
+% for each of these coordinates. This has to be done for final
+% coordinates only, i.e. after \pgfplotsaxispreparecoordinate.
+%
+% - eventually, the plot handler is satisfied and considers a data
+% point as "readily surveyed". It is allowed if this does *not*
+% happen inside of \pgfplotsplothandlersurveypoint, but it must
+% happen before \pgfplotsplothandlersurveyend is finished.
+%
+% The plot handler invokes \pgfplotsaxisdatapointsurveyed.
+% This tells the axis that it can perform its own surveying tasks
+% (see below) and furthermore, that it can serialize the data point.
+% Consequently, it will invoke
+% \pgfplotsplothandlerserializepointto{<\macro>}
+% and it will remember that \macro internally. This serialization is
+% employed to place plot marks and to apply z buffering techniques
+% (that's why it is done by the axis and not by the plot handler on
+% its own).
+%
+% The axis does its own surveying task, initiated by
+% \pgfplotsaxisdatapointsurveyed (which is, turn, invoked by the
+% plot handler). This command handles the |point meta| feature, that
+% is: it queries the |point meta| input source and updates the meta
+% limits. Furthermore, the error bar feature is processed at this
+% point (using the final data point's (x,y,z) coordinates as basis).
+% The |xtick=data| feature is also prepared at this stage.
+%
+% - Later, the coordinate input routine invokes
+% \pgfplots@coord@stream@end indicating the end-of-input. This will
+% finalize the survey phase.
+%
+% A simple example looks like this:
+% \pgfplotsplothandlersurveystart: does nothing in the simple example.
+% \pgfplotsplothandlersurveypoint:
+% parses the input format somehow to get (x,y,z) in raw, symbolic format
+% calls \pgfplotsaxisparsecoordinate
+% calls \pgfplotsaxispreparecoordinate
+% calls \ifpgfplotsaxisparsecoordinateok \pgfplotsaxisupdatelimitsforcoordinate{<x>}{<y>}{<z} \fi
+% calls \pgfplotsaxisdatapointsurveyed
+% \pgfplotsplothandlersurveyend: does nothing in the simple example.
+%
+% In fact, this is more or less the initial configuration used for
+% lineto or similar plot handlers.
+%
+% 2.2 Further Survey Phase API functions
+% \pgfplotssurveyphaseinputclass
+% expands to the actual name of the input method (like
+% 'coordinates', 'expression' or 'table')
+%
+% \pgfplotsplothandlernotifyscanlinecomplete
+% Called whenever an end-of-scanline marker has been processed, i.e.
+% whenever the 'empty line' key has been triggered. The default is to
+% do nothing.
+%
+% \pgfplotsaxissurveysetpointmeta
+% processes the 'point meta' key, i.e. it assigns
+% \pgfplots@current@point@meta. This macro can only be called once for
+% each coordinate (it will be deactivated afterwards). PGFPlots calls
+% it in \pgfplotsaxisdatapointsurveyed .
+%
+% \pgfplotsplothandlersurveyaddoptions{<options>}
+% which allows to change the current plot style from within API
+% functions. It sets <options> and remembers them for the
+% visualization phase.
+%
+% \pgfplotsaxisupdatelimitsforpointmeta{<meta>},
+% provided there is a point meta input handler (which is numeric).
+% Otherwise, the command is equal to \relax.
+%
+%
+% 3. Details about the VISUALIZATION phase
+%
+% The visualization phase consists of
+% <installation of the plot handler>
+% \pgfplotstreamstart
+% foreach serialized coordinate {
+% pgfplots calls \pgfplotsplothandlerdeserializestatefrom{<serialized repr>}
+% if coordinate is empty ("unbounded")
+% pgfplots call \pgfplotsplothandlervisualizejump
+% else
+% pgfplots calls \pgfplotsaxisvisphasetransformcoordinate
+% pgfplots calls \pgfplotsaxisvisphasepreparedatapoint
+% pgfplots calls either \pgfplotsqpointxyz or \pgfplotsqpointxy
+% fi
+% \pgfplotstreampoint
+% }
+% \pgfplotstreamend
+%
+% User defined plot handlers might need to invoke
+% \pgfplotsaxisvisphasetransformcoordinate on their own.
+%
+% During the visualization phase, the following macros can be used:
+%
+% - \pgfplotsaxisvisphasetransformpointmeta to set up point meta.
+% Use this only if there *is* point meta, see
+% \pgfplotsaxisifhaspointmeta{<true code>}{<false code>}.
+%
+% - \pgfplotsaxisvisphasegetpoint
+% does not take arguments. It takes the current point as input and
+% sets \pgf@x, \pgf@y to the final result.
+%
+% 4. API Functions of pgfplots to work with the visualization phases
+%
+% \pgfplotsifissurveyphase{<true code>}{<false code>}
+% \pgfplotsifisvisualizationphase{<true code>}{<false code>}
+%
+% \pgfplotsaxisfilteredcoordsaway
+% This macro expands to '1' if all points have been surveyed
+% successfully. It expands to '0' if at least one point has been
+% filtered away (for whatever reasons). This does not apply to
+% jumps.
+% \pgfplotsaxisplothasjumps
+% This macro expands to '1' if the current plot has jumps and '0'
+% if not.During the visualization phase, a jump is usually indicated
+% by an empty coordinate.
+% \pgfplotsaxisplothasunboundedpointmeta
+% This macro expands to '1' if the current plot has a point with
+% unbounded point meta and '0'
+% if not. Currently used by some plot handlers as synomym for
+% "visualize a jump"
+
+\def\pgfplotssurveyphaseinputclass{direct}
+
+\def\pgfplotsplothandlers@tikz@with@snap@to@nearest{%
+ \pgfplothandlerdiscard,%
+ \pgfplothandlermark,%
+ \pgfplothandlermarklisted,%
+ \pgfplothandlerxbar,%
+ \pgfplothandlerybar,%
+ \pgfplothandlerxbarinterval,%
+ \pgfplothandlerybarinterval%
+}%
+
+\def\pgfplotsplothandlers@tikz@std{%
+ \pgfplothandlerdiscard,%
+ \pgfplothandlermark,%
+ \pgfplothandlermarklisted,%
+ \pgfplothandlerxbar,%
+ \pgfplothandlerybar,%
+ \pgfplothandlerxbarinterval,%
+ \pgfplothandlerybarinterval,%
+ \pgfplothandlerlineto,%
+ \pgfplothandlercurveto,%
+ \pgfplothandlerconstantlineto,%
+ \pgfplothandlerconstantlinetomarkright,%
+ \pgfplothandlerconstantlinetomarkmid,%
+ \pgfplothandlerpolarcomb,%
+ \pgfplothandlerjumpmarkmid,%
+ \pgfplothandlerjumpmarkleft,%
+ \pgfplothandlerjumpmarkright%
+}%
+
+% Defines \pgfplotsretval to be the csname for the BACKUP of plot
+% handler #1.
+%
+% For example:
+% \pgfplotsplothandlers@get@tikz@backup@name{\pgfplothandlerlineto}
+% will return \pgfplotsretval={\\pgfplothandlerlineto@tikz}
+% (up to \escapechar)
+\def\pgfplotsplothandlers@get@tikz@backup@name#1{%
+ \begingroup
+ %\escapechar=-1 % drop the leading backslash
+ \expandafter\gdef\expandafter\pgfplotsretval\expandafter{\csname \string#1@tikz\endcsname}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% Takes the CURRENT \tikz@plot@handler and checks if it is an UNPATCHED tikz plot
+% handler. If so, it replaced it with the correct patched version.
+%
+% The motivation is that uf \tikz@plot@handler has been set outside of
+% an axis, it will not reflect the most recent changes (which are only
+% applied within an axis).
+\def\pgfplotsplothandlers@init@map@to@patched@versions{%
+ % iterate through all tikz plot handlers...
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsplothandlers@tikz@std}%
+ \as\pgfplots@loc@TMPa{%
+ % ... get the name of the backup (see \pgfplotsplothandlers@init)
+ \expandafter\pgfplotsplothandlers@get@tikz@backup@name\pgfplots@loc@TMPa
+ \expandafter\ifx\pgfplotsretval\tikz@plot@handler
+ % AH! \tikz@plot@handler is the same as some backup name!
+ % Replace it:
+ \expandafter\let\expandafter\tikz@plot@handler\pgfplots@loc@TMPa
+ \fi
+ }%
+}%
+
+\def\pgfplotsplothandlers@init{%
+ \def\pgfplotsplothandlers@init@##1{%
+ \pgfplotsutil@add@to@macro##1{%
+ \let\pgfplotsplothandlersurveydifflen=\pgfplotsplothandlersurveydifflen@snaptonearest
+ \let\pgfplotsplothandlersurveypointattime=\pgfplotsplothandlersurveypointattime@snaptonearest
+ }%
+ }%
+ \def\pgfplotsplothandlers@init@@##1{%
+ % create backup:
+ %
+ % if ##1 = \pgfplothandlerlineto, this defines
+ % \pgfplothandlerlineto@tikz as backup.
+ \pgfplotsplothandlers@get@tikz@backup@name{##1}%
+ \expandafter\let\pgfplotsretval=##1%
+ %
+ %
+ % assign more suitable names:
+ \pgfplotsutil@add@to@macro##1{%
+ \begingroup
+ \escapechar=-1 % drop the leading backslash
+ \edef\pgfplotsplothandlername{\string##1}%
+ \pgfmath@smuggleone\pgfplotsplothandlername
+ \endgroup
+ %
+ \def\pgfplotsplothandlerLUAfactory{function(axis, pointmetainputhandler) return pgfplots.GenericPlothandler.new("\pgfplotsplothandlername", axis,pointmetainputhandler) end}%
+ \def\pgfplotsplothandlerLUAvisualizerfactory{pgfplots.defaultPlotVisualizerFactory}%
+ }%
+ }%
+ % Patch all TikZ plot handlers:
+ % this here also creates backups
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsplothandlers@tikz@std}%
+ \as\pgfplots@loc@TMPa{%
+ \expandafter\pgfplotsplothandlers@init@@\expandafter{\pgfplots@loc@TMPa}%
+ }%
+ %
+ % Patch only selected ones:
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsplothandlers@tikz@with@snap@to@nearest}%
+ \as\pgfplots@loc@TMPa{%
+ \expandafter\pgfplotsplothandlers@init@\expandafter{\pgfplots@loc@TMPa}%
+ }%
+ %
+ \if1\b@pgfplots@compat@bar@width@units
+ \else
+ \def\pgfplotbarwidth{\pgfplots@bar@width@not@in@context}%
+ \def\pgfplotbarshift{\pgfplots@bar@shift@not@in@context}%
+ \pgfplotsutil@add@to@macro\pgfplothandlerxbar{%
+ \def\pgfplotbarwidth{\pgfplots@xbar@width}%
+ \def\pgfplotbarshift{\pgfplots@xbar@shift}%
+ }%
+ \pgfplotsutil@add@to@macro\pgfplothandlerybar{%
+ \def\pgfplotbarwidth{\pgfplots@ybar@width}%
+ \def\pgfplotbarshift{\pgfplots@ybar@shift}%
+ }%
+ \fi
+ %
+ \pgfplotsplothandlers@init@map@to@patched@versions
+ %
+}%
+
+\def\pgfplots@xbar@width{pgfplotsxbarwidth}
+\def\pgfplots@ybar@width{pgfplotsybarwidth}
+\def\pgfplots@xbar@shift{pgfplotsxbarshift}
+\def\pgfplots@ybar@shift{pgfplotsybarshift}
+\def\pgfplots@bar@width@not@in@context{pgfplotsbarwidthgeneric}
+\def\pgfplots@bar@shift@not@in@context{pgfplotsbarshiftgeneric}
+
+\pgfplotsmathdeclarepseudoconstant{pgfplotsxbarwidth}{\pgfplots@bar@mathparse@{y}{bar width}}%
+\pgfplotsmathdeclarepseudoconstant{pgfplotsybarwidth}{\pgfplots@bar@mathparse@{x}{bar width}}%
+\pgfplotsmathdeclarepseudoconstant{pgfplotsxbarshift}{\pgfplots@bar@mathparse@{y}{bar shift}}%
+\pgfplotsmathdeclarepseudoconstant{pgfplotsybarshift}{\pgfplots@bar@mathparse@{x}{bar shift}}%
+\pgfplotsmathdeclarepseudoconstant{pgfplotsbarwidthgeneric}{\pgfplots@bar@mathparse@{N}{bar width}}%
+\pgfplotsmathdeclarepseudoconstant{pgfplotsbarshiftgeneric}{\pgfplots@bar@mathparse@{N}{bar shift}}%
+
+\def\pgfplots@bar@mathparse@#1#2{%
+ \pgfmathparse{\pgfkeysvalueof{/pgf/#2}}%
+ \ifpgfmathunitsdeclared
+ \else
+ \edef\pgfplots@bar@direction@choice@{#1}%
+ \if N\pgfplots@bar@direction@choice@%
+ \if a\pgfplots@bar@direction@choice
+ \else
+ \if x\pgfplots@bar@direction@choice
+ \def\pgfplots@bar@direction@choice@{y}%
+ \else
+ \if y\pgfplots@bar@direction@choice
+ \def\pgfplots@bar@direction@choice@{x}%
+ \else
+ \pgfplotsthrow{invalid argument}{\pgfplots@bar@direction@choice@}{Sorry, the value of 'bar direction' is invalid}\pgfeov%
+ \fi
+ \fi
+ \fi
+ \fi
+ \if N\pgfplots@bar@direction@choice@%
+ \pgfplots@bar@mathparse@error{#1}{#2}%
+ \else
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \csname pgfplotstransformdirection\pgfplots@bar@direction@choice@\endcsname{\pgfplots@loc@TMPa}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \if\pgfplots@bar@direction@choice@ x%
+ \pgfqpointxy@orig{\pgfplots@loc@TMPa}{0}%
+ \edef\pgfmathresult{\pgf@sys@tonumber\pgf@x}%
+ \else
+ \pgfqpointxy@orig{0}{\pgfplots@loc@TMPa}%
+ \edef\pgfmathresult{\pgf@sys@tonumber\pgf@y}%
+ \fi
+ %\edef\pgfplots@loc@TMPa{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}%
+ %\expandafter\pgfmathveclen@\pgfplots@loc@TMPa
+ \fi
+ \fi
+}%
+
+\def\pgfplots@bar@mathparse@error#1#2{%
+ \pgfplotsthrow{invalid argument}{\pgfplots@bar@direction@choice@}{Sorry, the value '#2=\pgfkeysvalueof{/pgf/#2}' is given in terms of a unit -- but I do not know which axis! Next steps: either (a) set one of 'xbar' or 'ybar' before evaluating the value of '#2' or (b) define 'bar direction=x or y'}\pgfeov%
+}%
+
+% Resets the plot handler routines.
+%
+% This is necessary before installing a new plot handler!
+\def\pgfplotsresetplothandler{%
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@default
+ \let\pgfplotsplothandlerLUAfactory=\pgfplotsplothandlerLUAfactory@default
+ \let\pgfplotsplothandlerLUAvisualizerfactory=\pgfplotsplothandlerLUAvisualizerfactory@default
+ \let\pgfplotsplothandlername=\pgfplotsplothandlername@default
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@default
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@default
+ \let\pgfplotsplothandlerpointtokeys=\pgfplotsplothandlerpointtokeys@default
+ \let\pgfplotsplothandlerserializepointto=\pgfplotsplothandlerserializepointto@default
+ \let\pgfplotsplothandlerdeserializepointfrom=\pgfplotsplothandlerdeserializepointfrom@default
+ \let\pgfplotsplothandlerserializestateto=\pgfplotsplothandlerserializestateto@default
+ \let\pgfplotsplothandlerdeserializestatefrom=\pgfplotsplothandlerdeserializestatefrom@default
+ \let\pgfplotsplothandlervisualizejump=\pgfplotsplothandlervisualizejump@default
+ \let\pgfplotsplothandlernotifyscanlinecomplete=\relax
+ \let\pgfplotsplothandlersurveydifflen=\pgfplotsplothandlersurveydifflen@default
+ \let\pgfplotsplothandlersurveypointattime=\pgfplotsplothandlersurveypointattime@default
+ \let\pgfplotsplothandlertransformslopedattime=\pgfplotsplothandlertransformslopedattime@default
+ \let\pgfplotsplothandlerifcurrentpointcanbefirstlast=\pgfplotsplothandlerifcurrentpointcanbefirstlast@default
+ %
+ \let\pgfplotsplothandlersurveybeforesetpointmeta=\pgfplotsplothandlersurveybeforesetpointmeta@default
+ \let\pgfplotsplothandlersurveyaftersetpointmeta=\pgfplotsplothandlersurveyaftersetpointmeta@default
+}%
+
+\def\pgfplotsplothandlersurveybeforesetpointmeta@default{}
+\def\pgfplotsplothandlersurveyaftersetpointmeta@default{}
+
+% \pgfplotsplothandlersurveystart
+\def\pgfplotsplothandlersurveystart@default{}%
+
+% \pgfplotsplothandlername
+\def\pgfplotsplothandlername@default{%
+ [tikz@plot@handler: \meaning\pgf@plotstreamstart]%
+}%
+
+% This should expand to a LUA function which takes the axis and the point
+% meta handler.
+% Use empty if there is none.
+\def\pgfplotsplothandlerLUAfactory@default{}%
+
+% This should expand to a LUA function which takes an instance of
+% Plothandler and which should return a PlotVisualizer.
+% Use empty if there is none.
+%
+% @see LUA: pgfplots.PlotVisualizer
+\def\pgfplotsplothandlerLUAvisualizerfactory@default{}%
+
+% \pgfplotsplothandlerifcurrentpointcanbefirstlast : can be used to
+% check if the current point of a plot handler can be the global first
+% or last segment.
+% It will execute #1 if that is the case and #2 if not.
+\def\pgfplotsplothandlerifcurrentpointcanbefirstlast@default#1#2{#1}%
+
+
+% \pgfplotsplothandlersurveyend
+% Called at the end of each survey phase.
+\def\pgfplotsplothandlersurveyend@default{}
+
+% A callback which will be called as soon as a scanline is complete.
+%
+% The callback can differ from plot handler to plot handler; its
+% purpose is to update data structures.
+%
+% Implementational note for those who _call_ the callback: the
+% The callback will be triggered by the 'empty line' handling, see
+% \pgfplotsscanlinelengthinitzero. However, a coordinate generator can
+% safely invoke it directly. It must not be invoked twice for the same
+% scanline.
+%
+% FIXME: only 'empty line=scanline' currently calls this callback!
+\let\pgfplotsplothandlernotifyscanlinecomplete=\relax%
+
+% \pgfplotsplothandlersurveypoint is called for each encountered data
+% point.
+%
+% The data point as such is available using the current state of any
+% macros which are assigned during the survey phase (during \addplot).
+% This includes any table macros etc.
+% PGFPlots stores the x,y and z coordinates into \pgfplots@current@point@[xyz].
+% The point meta coordinate is in \pgfplots@current@point@meta.
+%
+% Note that since any currently assigned macro can be used here, the
+% new DV engine of PGF is also valid (and will be supported
+% eventually). This DV engine stores data point entries in keys,
+% namely those in the key path /data point. See the pgf manual.
+\def\pgfplotsplothandlersurveypoint@default{%
+ \ifpgfplots@LUA@backend@supported
+ \pgfplots@LUA@survey@point
+ \else
+ \pgfplotsplothandlersurveypoint@default@
+ \fi
+}%
+\def\pgfplotsplothandlersurveypoint@default@{%
+ % reset it. NOTE: this migh be done multiple times. But better one
+ % too much than one too few...
+ \def\pgfplots@set@perpointmeta@done{0}%
+ %
+ \pgfplotsplothandlersurveypoint@default@noreset@of@pointmeta
+}%
+\def\pgfplotsplothandlersurveypoint@default@noreset@of@pointmeta{%
+ \pgfplotsaxisparsecoordinate
+ \pgfplotsaxispreparecoordinate
+ \ifpgfplotsaxisparsecoordinateok
+ \pgfplotsaxisupdatelimitsforcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z
+ \fi
+ \pgfplotsaxisdatapointsurveyed
+}%
+
+% \pgfplotsplothandlerserializepointto{<\macro>}
+% should save a complete data point to <\macro> such that it can be
+% de-serialized later.
+%
+% #1: a macro name. Will be filled with (expandable) data.
+% The format can be arbitrary, but you should be able to extra it.
+%
+% @PRECONDITION
+% this macro will be invoked in a context where the current data
+% point has been processed completely, including any preparations.
+% The required data which should be saved depends on the plot
+% handler. Usually, all plot handlers require
+% \pgfplots@current@point@[xyz] and \pgfplots@current@point@meta.
+% This macro should only assign keys which have been defined or
+% validated by any of the plot handler relevant methods (including
+% the de-serialization or survey methods).
+\def\pgfplotsplothandlerserializepointto@default#1{%
+ % Store normalized point for list:
+ % We need
+ % xi,yi,zi;
+ % where zi may be empty.
+ %
+ % Note that per-point meta information is stored in
+ % \pgfplotsaxisserializedatapoint .
+ \edef#1{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}%
+}%
+
+% \pgfplotsplothandlerdeserializepointfrom{<\macro>}
+% the counterpart for \pgfplotsplothandlerserializepointto.
+% It restores the state as it was before the serialization.
+%
+% #1: the serialized information.
+\def\pgfplotsplothandlerdeserializepointfrom@default#1{%
+ \expandafter\pgfplotsplothandlerdeserializepointfrom@default@#1\relax
+}%
+
+% \pgfplotsplothandlerpointtokeys{<key prefix>}
+%
+% Takes the current point and copies its values to a set of keys.
+%
+% For example, if the current point has the three coordinates x=1,
+% y=2, z=3,
+% \pgfplotsplothandlerpointtokeys{/data point/first/}
+% will define the keys
+% /data point/first/x/.initial=1
+% /data point/first/y/.initial=2
+% /data point/first/z/.initial=3
+%
+\def\pgfplotsplothandlerpointtokeys@default#1{%
+ \pgfkeyslet{#1/x}\pgfplots@current@point@x
+ \pgfkeyslet{#1/y}\pgfplots@current@point@y
+ \pgfkeyslet{#1/z}\pgfplots@current@point@z
+}%
+
+\def\pgfplotsplothandlerdeserializepointfrom@default@#1,#2,#3\relax{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+}%
+% \pgfplotsplothandlerserializestateto{<\macro>}
+% should save the state of the current plot handler such that it can
+% be de-serialized later.
+%
+% The state does usually NOT contain a coordinate stream, this is
+% accomplished by \pgfplotsplothandlerserializepointto.
+%
+% #1: a macro name. Can be filled with anything, including
+% non-expandable macro invocations.
+\def\pgfplotsplothandlerserializestateto@default#1{%
+ \def#1{}%
+}%
+
+%
+\def\pgfplotsplothandlerdeserializestatefrom@default#1{%
+ #1%
+}%
+
+\def\pgfplotsplothandlervisualizejump@default{%
+ \pgfplotstreamend
+ \pgfplotstreamstart
+}%
+
+% \pgfplotsplothandlersurveypointattime#1#2#3
+%
+% sets the current environment to a point which is between points #2
+% and #3, using the fraction #1.
+%
+% #1 a fraction (a number between 0 and 1) in the format of
+% \pgfplotscoordmath{default}
+% #2 a serialized point denoting the start
+% #3 a serialized point denoting the end
+%
+% In other words: #1 = 0.0 should result in #2 and #1 = 1.0 should
+% result in #3.
+%
+% POSTCONDITION: the current point will be set to the point
+% in-between. The current point is set in terms of logical coordinates
+% (i.e. \pgfplots@current@point@x and its variants)
+\def\pgfplotsplothandlersurveypointattime@default#1#2#3{%
+ \begingroup
+ \pgfplotsplothandlerdeserializepointfrom{#2}%
+ \let\pgfplots@last@x=\pgfplots@current@point@x
+ \let\pgfplots@last@y=\pgfplots@current@point@y
+ \let\pgfplots@last@z=\pgfplots@current@point@z
+ \pgfplotsplothandlerdeserializepointfrom{#3}%
+ %
+ \def\pgfplots@loc@TMPa##1{%
+ \pgfplotscoordmath{##1}{op}{subtract}{{\csname pgfplots@current@point@##1\endcsname}{\csname pgfplots@last@##1\endcsname}}%
+ \let\pgfplots@diff=\pgfmathresult
+ \pgfplotscoordmath{##1}{parsenumber}{#1}%
+ \pgfplotscoordmath{##1}{op}{multiply}{{\pgfmathresult}{\pgfplots@diff}}%
+ \pgfplotscoordmath{##1}{op}{add}{{\csname pgfplots@last@##1\endcsname}{\pgfmathresult}}%
+ \expandafter\let\csname pgfplots@current@point@##1\endcsname=\pgfmathresult
+ }%
+ \pgfplots@loc@TMPa x%
+ \pgfplots@loc@TMPa y%
+ \ifpgfplots@curplot@threedim
+ \pgfplots@loc@TMPa z%
+ \fi
+ \xdef\pgfplots@glob@TMPb{%
+ \noexpand\def\noexpand\pgfplots@current@point@x{\pgfplots@current@point@x}%
+ \noexpand\def\noexpand\pgfplots@current@point@y{\pgfplots@current@point@y}%
+ \noexpand\def\noexpand\pgfplots@current@point@z{\pgfplots@current@point@z}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPb
+}%
+
+% \pgfplotsplothandlersurveydifflen#1#2
+%
+% computes the length between two points which are given in logical
+% coordinates.
+% #1 a serialized point
+% #2 a serialized point
+%
+% The return value is assigned to \pgfmathresult in
+% \pgfplotscoordmath{default} format.
+\def\pgfplotsplothandlersurveydifflen@default#1#2{%
+ \begingroup
+ \pgfplotsplothandlerdeserializepointfrom{#1}%
+ \let\pgfplots@last@x=\pgfplots@current@point@x
+ \let\pgfplots@last@y=\pgfplots@current@point@y
+ \let\pgfplots@last@z=\pgfplots@current@point@z
+ \pgfplotsplothandlerdeserializepointfrom{#2}%
+ \pgfplotscoordmathparsemacro{default}\pgfplots@last@x
+ \pgfplotscoordmathparsemacro{default}\pgfplots@last@y
+ \pgfplotscoordmathparsemacro{default}\pgfplots@current@point@x
+ \pgfplotscoordmathparsemacro{default}\pgfplots@current@point@y
+ \ifpgfplots@curplot@threedim
+ \pgfplotscoordmathparsemacro{default}\pgfplots@last@z
+ \pgfplotscoordmathparsemacro{default}\pgfplots@current@point@z
+ \fi
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@current@point@x}{\pgfplots@last@x}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfmathresult}}%
+ \let\pgfplots@diff@x=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@current@point@y}{\pgfplots@last@y}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfmathresult}}%
+ \let\pgfplots@diff@y=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@diff@x}{\pgfplots@diff@y}}%
+ \let\pgfplots@len=\pgfmathresult
+ \ifpgfplots@curplot@threedim
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@current@point@z}{\pgfplots@last@z}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfmathresult}}%
+ \let\pgfplots@diff@z=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@len}{\pgfplots@diff@z}}%
+ \let\pgfplots@len=\pgfmathresult
+ \fi
+ \pgfplotscoordmath{default}{op}{sqrt}{{\pgfplots@len}}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% \pgfplotsplothandlertransformslopedattime{<time fraction>}{<start>}{<end>}
+%
+% Installs a PGF rotation matrix such that it fits the gradient of the
+% current plot segment between <start> and <end>.
+%
+% #1: a fraction such that 0.0 is <start> and 1.0 is <end>
+% #2: the <start> point (a macro containing the result of \pgfplotsplothandlerserializepointto)
+% #3: the <end> point (a macro containing the result of \pgfplotsplothandlerserializepointto)
+%
+\def\pgfplotsplothandlertransformslopedattime@default#1#2#3{%
+ \pgf@process{%
+ \pgfplotsplothandlerdeserializepointfrom{#2}%
+ \pgfplotsaxisvisphasegetpoint
+ }%
+ \pgf@xa=\pgf@x% xb/yb = start point
+ \pgf@ya=\pgf@y%
+ \pgf@process{%
+ \pgfplotsplothandlerdeserializepointfrom{#3}%
+ \pgfplotsaxisvisphasegetpoint
+ }%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \ifpgfallowupsidedownattime%
+ \else%
+ \ifdim\pgf@x<0pt%
+ \pgf@x=-\pgf@x%
+ \pgf@y=-\pgf@y%
+ \fi%
+ \fi%
+ \pgfpointnormalised{}% x/y = normalised vector
+ \pgf@ya=-\pgf@y%
+ \pgftransformcm%
+ {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}%
+ {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}%
+}%
+
+
+
+\pgfplotsresetplothandler
+
+% The following two methods constitutes implementations for
+% 'node[pos=<faction>]' which do not interpolate. They only snap to
+% the nearest coordinate.
+%
+% For example, \addplot[scatter] ... node[pos=0.5] {} should use a
+% unit distance and should not interpolate between scatter points.
+\def\pgfplotsplothandlersurveydifflen@snaptonearest#1#2{%
+ % FIXME : this implies that #1 and #2 are "adjacent" in the
+ % coordinate stream!
+ \pgfplotscoordmath{default}{one}%
+}%
+\def\pgfplotsplothandlersurveypointattime@snaptonearest#1#2#3{%
+ \pgfplotscoordmath{default}{parsenumber}{0.5}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{#1}%
+ \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@loc@TMPa}{%
+ \pgfplotsplothandlerdeserializepointfrom{#2}%
+ }{%
+ \pgfplotsplothandlerdeserializepointfrom{#3}%
+ }%
+}%
+% ==================================
+
+% Defines
+% - a generic update limits routine,
+% \pgfplotsaxisupdatelimitsforcoordinate#1#2#3
+% if #3 is empty, it will assume a 2d point, otherwise a 3d point
+% and the axis will be three dimensional as well.
+% During \addplot, this auto-detection will be disabled in favor of
+% the '\addplot3' versus' \addplot' syntax.
+%
+\def\pgfplots@prepare@axis@API{%
+ \pgfplots@curplot@threedimtrue
+ \pgfplots@prepare@axis@API@
+ \let\pgfplotsaxisupdatelimitsforcoordinatethreedim=\pgfplotsaxisupdatelimitsforcoordinate@
+ \let\pgfplotsaxisparsecoordinatethreedim=\pgfplotsaxisparsecoordinate@
+ %
+ \pgfplots@curplot@threedimfalse
+ \pgfplots@prepare@axis@API@
+ \let\pgfplotsaxisupdatelimitsforcoordinatetwodim=\pgfplotsaxisupdatelimitsforcoordinate@
+ \let\pgfplotsaxisparsecoordinatetwodim=\pgfplotsaxisparsecoordinate@
+ %
+ \def\pgfplotsaxisupdatelimitsforcoordinate##1##2##3{%
+ \pgfplots@ifempty{##3}{%
+ \pgfplotsaxisupdatelimitsforcoordinatetwodim{##1}{##2}{}%
+ }{%
+ \global\pgfplots@threedimtrue
+ \pgfplotsaxisupdatelimitsforcoordinatethreedim{##1}{##2}{##3}%
+ }%
+ }%
+ \def\pgfplotsaxisparsecoordinate{%
+ \ifx\pgfplots@current@point@z\pgfutil@empty
+ \pgfplotsaxisparsecoordinatetwodim
+ \else
+ \global\pgfplots@threedimtrue
+ \pgfplotsaxisparsecoordinatethreedim%
+ \fi
+ }%
+}%
+\def\pgfplots@prepare@axis@API@{%
+ \begingroup
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \let\E=\noexpand
+ % Setup Just-In-Time-Macro Compilation:
+ % I compile a set of macros which is highly optimized for this
+ % particular axis configuration.
+ %
+ % \pgfplotsaxisupdatelimitsforcoordinate
+ % Updates the current x and y limits for point (#1,#2).
+ %
+ % To eliminate all those case distinctions, it is created with
+ % 'edef' and a lot of '\noexpand' calls here:
+ %
+ %
+ % The point coordinates are given in floating point format (FIXME)
+ %
+ % Please note that if user specified limits are given, automatic
+ % limits are only applied to points which fall into the user specified
+ % clipping region.
+ %
+ % PRECONDITIONS:
+ % - the input coordinates have been parsed correctly (floating point
+ % format for linear axis, log applied for logarithmic ones)
+ %
+ % Arguments:
+ % #1,#2,#3 the x,y and z coordinate. z is ignored for 2d plots.
+ \xdef\pgfplotsaxisupdatelimitsforcoordinate@##1##2##3{%
+%\E\tracingmacros=2\E\tracingcommands=2
+%\E\pgfplots@message{Updating limits for (##1,##2) ...}%
+ %
+ % VIM SEARCH PATTERN:
+ % [^E]\zs\\\ze[^E]
+ % -> this finds '\' which is neither '\E' nor is it prefixed
+ % by 'E'.
+ %
+ %
+ %
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDfalse
+ % check whether we need to clip limits:
+ \ifpgfplots@clip@limits@x
+ \ifpgfplots@autocompute@xmin
+ \else
+ \ifpgfplots@xislinear
+ \E\pgfmathfloatlessthan@{##1}{\E\pgfplots@xmin}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \else
+ \E\pgfplotsmathlessthan{##1}{\E\pgfplots@xmin}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \fi
+ \fi
+ \ifpgfplots@autocompute@xmax
+ \else
+ \ifpgfplots@xislinear
+ \E\pgfmathfloatlessthan@{\E\pgfplots@xmax}{##1}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \else
+ \E\pgfplotsmathlessthan{\E\pgfplots@xmax}{##1}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \fi
+ \fi
+ \fi
+ \ifpgfplots@clip@limits@y
+ \ifpgfplots@autocompute@ymin
+ \else
+ \ifpgfplots@yislinear
+ \E\pgfmathfloatlessthan@{##2}{\E\pgfplots@ymin}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \else
+ \E\pgfplotsmathlessthan{##2}{\E\pgfplots@ymin}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \fi
+ \fi
+ \ifpgfplots@autocompute@ymax
+ \else
+ \ifpgfplots@yislinear
+ \E\pgfmathfloatlessthan@{\E\pgfplots@ymax}{##2}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \else
+ \E\pgfplotsmathlessthan{\E\pgfplots@ymax}{##2}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \fi
+ \fi
+ \fi
+ \ifpgfplots@clip@limits@z
+ \ifpgfplots@curplot@threedim
+ \ifpgfplots@autocompute@zmin
+ \else
+ \ifpgfplots@zislinear
+ \E\pgfmathfloatlessthan@{##3}{\E\pgfplots@zmin}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \else
+ \E\pgfplotsmathlessthan{##3}{\E\pgfplots@zmin}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \fi
+ \fi
+ \ifpgfplots@autocompute@zmax
+ \else
+ \ifpgfplots@zislinear
+ \E\pgfmathfloatlessthan@{\E\pgfplots@zmax}{##3}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \else
+ \E\pgfplotsmathlessthan{\E\pgfplots@zmax}{##3}%
+ \E\ifpgfmathfloatcomparison
+ \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue
+ \E\fi
+ \fi
+ \fi
+ \fi
+ \fi
+ %
+ %
+ %
+ % Update limits:
+ \E\ifpgfplots@update@limits@for@one@point@ISCLIPPED
+ \E\else
+ \ifpgfplots@autocompute@xmin
+ \ifpgfplots@xislinear
+ \E\pgfplotsmathfloatmin{\E\pgfplots@xmin}{##1}%
+ \E\global\E\let\E\pgfplots@xmin=\E\pgfmathresult
+ \else
+ \E\pgfplotsmathmin{\E\pgfplots@xmin}{##1}%
+ \E\global\E\let\E\pgfplots@xmin=\E\pgfmathresult
+ \fi
+ \fi
+ \ifpgfplots@autocompute@xmax
+ \ifpgfplots@xislinear
+ \E\pgfplotsmathfloatmax{\E\pgfplots@xmax}{##1}%
+ \E\global\E\let\E\pgfplots@xmax=\E\pgfmathresult
+ \else
+ \E\pgfplotsmathmax{\E\pgfplots@xmax}{##1}%
+ \E\global\E\let\E\pgfplots@xmax=\E\pgfmathresult
+ \fi
+ \fi
+ \ifpgfplots@autocompute@ymin
+ \ifpgfplots@yislinear
+ \E\pgfplotsmathfloatmin{\E\pgfplots@ymin}{##2}%
+ \E\global\E\let\E\pgfplots@ymin=\E\pgfmathresult
+ \else
+ \E\pgfplotsmathmin{\E\pgfplots@ymin}{##2}%
+ \E\global\E\let\E\pgfplots@ymin=\E\pgfmathresult
+ \fi
+ \fi
+ \ifpgfplots@autocompute@ymax
+ \ifpgfplots@yislinear
+ \E\pgfplotsmathfloatmax{\E\pgfplots@ymax}{##2}%
+ \E\global\E\let\E\pgfplots@ymax=\E\pgfmathresult
+ \else
+ \E\pgfplotsmathmax{\E\pgfplots@ymax}{##2}%
+ \E\global\E\let\E\pgfplots@ymax=\E\pgfmathresult
+ \fi
+ \fi
+ \ifpgfplots@curplot@threedim
+ \ifpgfplots@autocompute@zmin
+ \ifpgfplots@zislinear
+ \E\pgfplotsmathfloatmin{\E\pgfplots@zmin}{##3}%
+ \E\global\E\let\E\pgfplots@zmin=\E\pgfmathresult
+ \else
+ \E\pgfplotsmathmin{\E\pgfplots@zmin}{##3}%
+ \E\global\E\let\E\pgfplots@zmin=\E\pgfmathresult
+ \fi
+ \fi
+ \ifpgfplots@autocompute@zmax
+ \ifpgfplots@zislinear
+ \E\pgfplotsmathfloatmax{\E\pgfplots@zmax}{##3}%
+ \E\global\E\let\E\pgfplots@zmax=\E\pgfmathresult
+ \else
+ \E\pgfplotsmathmax{\E\pgfplots@zmax}{##3}%
+ \E\global\E\let\E\pgfplots@zmax=\E\pgfmathresult
+ \fi
+ \fi
+ \fi
+ \E\fi
+ %
+ % Compute data range:
+ \ifpgfplots@autocompute@all@limits
+ % the data range will be acquired simply from the axis
+ % range, see below!
+ \else
+ % Attention: it is only done for linear axis!
+ \ifpgfplots@xislinear
+ \E\pgfplotsmathfloatmin{\E\pgfplots@data@xmin}{##1}%
+ \E\global\E\let\E\pgfplots@data@xmin=\E\pgfmathresult
+ \E\pgfplotsmathfloatmax{\E\pgfplots@data@xmax}{##1}%
+ \E\global\E\let\E\pgfplots@data@xmax=\E\pgfmathresult
+ \fi
+ \ifpgfplots@yislinear
+ \E\pgfplotsmathfloatmin{\E\pgfplots@data@ymin}{##2}%
+ \E\global\E\let\E\pgfplots@data@ymin=\E\pgfmathresult
+ \E\pgfplotsmathfloatmax{\E\pgfplots@data@ymax}{##2}%
+ \E\global\E\let\E\pgfplots@data@ymax=\E\pgfmathresult
+ \fi
+ \ifpgfplots@curplot@threedim
+ \ifpgfplots@zislinear
+ \E\pgfplotsmathfloatmin{\E\pgfplots@data@zmin}{##3}%
+ \E\global\E\let\E\pgfplots@data@zmin=\E\pgfmathresult
+ \E\pgfplotsmathfloatmax{\E\pgfplots@data@zmax}{##3}%
+ \E\global\E\let\E\pgfplots@data@zmax=\E\pgfmathresult
+ \fi
+ \fi
+ \fi
+%\E\pgfplots@message{Updated limits: (\E\pgfplots@xmin,\E\pgfplots@ymin) rectangle (\E\pgfplots@xmax,\E\pgfplots@ymax).}%
+%
+%\E\tracingmacros=0\E\tracingcommands=0
+ }%
+ %
+ % A routine which parses a coordinate.
+ % Here, 'coordinate' means (x,y) for a two dimensional plot and
+ % '(x,y,z)' for a three dimensional one.
+ %
+ % The preparation consists of
+ % - filtering.
+ % - coordinate parsing and high level transformations.
+ % - logs.
+ %
+ % It might happen that \pgfplotsaxisparsecoordinate is called
+ % multiple times for a single data "point" (for example, a quiver
+ % point might call it for the point where the vector starts and
+ % where the vector ends).
+ %
+ % @PRECONDITION
+ % - the plot's survey phase is running (has already been started)
+ % - \pgfplots@current@point@[xyz] contains the coordinates of the
+ % point. I assume they are unparsed.
+ %
+ %
+ % @POSTCONDITION
+ % - the axis' state will be updated.
+ % - the \pgfplots@current@point@[xyz] macros will contain parsed data.
+ % - \ifpgfplotsaxisparsecoordinateok will be true if and only
+ % if the data point has not been filtered away. If it has been
+ % filtered away, \pgfplots@current@point@[xyz] will be empty.
+ % - \pgfplots@current@point@[xyz]@unfiltered contain unparsed
+ % data.
+ %
+ % @see \pgfplotsaxispreparecoordinate
+ % @see \pgfplotsaxisdatapointsurveyed
+ \xdef\pgfplotsaxisparsecoordinate@{%
+ % 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
+ \E\let\E\pgfplots@current@point@z@unfiltered=\E\pgfplots@current@point@z
+ \E\def\E\pgfplots@unbounded@dir{}%
+ %
+ \E\pgfplots@invoke@prefilter
+ %
+ \E\expandafter\E\pgfplots@prepare@xcoord\E\expandafter{\E\pgfplots@current@point@x}%
+ \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{x}%
+ \E\let\E\pgfplots@current@point@x=\E\pgfmathresult
+ %
+ \E\expandafter\E\pgfplots@prepare@ycoord\E\expandafter{\E\pgfplots@current@point@y}%
+ \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfplots@current@point@y}{y}%
+ \E\let\E\pgfplots@current@point@y=\E\pgfmathresult
+ %
+ \ifpgfplots@curplot@threedim
+ \E\expandafter\E\pgfplots@prepare@zcoord\E\expandafter{\E\pgfplots@current@point@z}%
+ \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfplots@current@point@z}{z}%
+ \E\let\E\pgfplots@current@point@z=\E\pgfmathresult
+ \fi
+ %
+ \E\pgfplots@invoke@filter@xyz
+ %
+ \E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty
+ \E\else
+ % parse for numbers. Note that this might cause
+ % unnecessary overhead of logs (which are already
+ % normalized unless someone provided filters). But do it
+ % anyway to ensure that filters produce valid output.
+ \E\pgfplotscoordmath{x}{parsenumber}{\E\pgfplots@current@point@x}%
+ \E\let\E\pgfplots@current@point@x=\E\pgfmathresult
+ \E\pgfplotscoordmath{x}{if is bounded}{\E\pgfplots@current@point@x}%
+ {}%
+ {% 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\fi
+ %
+ \E\ifx\E\pgfplots@current@point@y\E\pgfutil@empty
+ \E\else
+ \E\pgfplotscoordmath{y}{parsenumber}{\E\pgfplots@current@point@y}%
+ \E\let\E\pgfplots@current@point@y=\E\pgfmathresult
+ \E\pgfplotscoordmath{y}{if is bounded}{\E\pgfplots@current@point@y}%
+ {}%
+ {% this clears nan, inf and -inf points.
+ \E\let\E\pgfplots@current@point@y=\E\pgfutil@empty
+ \E\def\E\pgfplots@unbounded@dir{y}%
+ }%
+ \E\fi
+ %
+ \ifpgfplots@curplot@threedim
+ %
+ \E\ifx\E\pgfplots@current@point@z\E\pgfutil@empty
+ \E\else
+ \E\pgfplotscoordmath{z}{parsenumber}{\E\pgfplots@current@point@z}%
+ \E\let\E\pgfplots@current@point@z=\E\pgfmathresult
+ \E\pgfplotscoordmath{z}{if is bounded}{\E\pgfplots@current@point@z}%
+ {}%
+ {% this clears nan, inf and -inf points.
+ \E\let\E\pgfplots@current@point@z=\E\pgfutil@empty
+ \E\def\E\pgfplots@unbounded@dir{z}%
+ }%
+ \E\fi
+ \fi
+ %
+ % check if coordinates are bounded:
+ \E\pgfplotsaxisparsecoordinateoktrue
+ \E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty
+ \E\pgfplotsaxisparsecoordinateokfalse
+ \E\else
+ \E\ifx\E\pgfplots@current@point@y\E\pgfutil@empty
+ \E\pgfplotsaxisparsecoordinateokfalse
+ \E\else
+ \ifpgfplots@curplot@threedim
+ \E\ifx\E\pgfplots@current@point@z\E\pgfutil@empty
+ \E\pgfplotsaxisparsecoordinateokfalse
+ \E\fi
+ \fi
+ \E\fi
+ \E\fi
+ %
+ }%
+ %
+ \endgroup
+}%
+
+% ==================================
+% The quiver plot handler.
+% It draws a lot of arrows.
+% Its input is (x_i,y_i); (u_i,v_i) for data point i and it draws a
+% vector in direction (u_i,v_i) starting from (x_i,y_i) .
+% It also supports 3D arrows (involving z_i and w_i).
+
+\newif\ifpgfplots@quiver@usetikz
+\newif\ifpgfplots@quiver@updatelimits
+
+\pgfplotsset{
+ % The 'quiver' plot handler for two- and three dimensional plots.
+ %
+ % User Interface:
+ % use /pgfplots/quiver to enable the plot handler.
+ % Then, provide `quiver/u value' or `quiver/u' to
+ % tell where to find the 'x' coordinates of the vectors, and similarly
+ % for 'v' and 'w' instead of 'u'.
+ quiver/.code={%
+ \let\tikz@plot@handler=\pgfplotsplothandlerquiver
+ \pgfqkeys{/pgfplots/quiver}{quiver legend,#1}%
+ },%
+ quiver/u value*/.initial=0,
+ quiver/v value*/.initial=0,
+ quiver/w value*/.initial=0,
+ quiver/u value is expr/.initial=0,
+ quiver/v value is expr/.initial=0,
+ quiver/w value is expr/.initial=0,
+ quiver/quiver legend/.style={
+ /pgfplots/legend image code/.code={%
+ \draw[x=0.6cm,y=0cm,z=0pt,##1,
+ /pgfplots/quiver/before arrow/.add code={}{
+ % quiver is a pgfplots-specific plot-handler. We need to
+ % fix the additional input data somehow.
+ %
+ % this is an *absolute* coordinate, interpreted
+ % relative to 'x', 'y', 'z'
+ \def\pgfplots@quiver@u{1}%
+ \def\pgfplots@quiver@v{1}%
+ \def\pgfplots@quiver@w{1}%
+ },%
+ ]
+ plot coordinates {
+ (0cm,0cm)
+ };%
+ }%
+ },
+ quiver/u filter/.code=,
+ quiver/v filter/.code=,
+ quiver/w filter/.code=,
+ quiver/u filter/.expression/.code=\pgfplots@install@filter@expression{quiver/u filter}{#1},
+ quiver/v filter/.expression/.code=\pgfplots@install@filter@expression{quiver/v filter}{#1},
+ quiver/w filter/.expression/.code=\pgfplots@install@filter@expression{quiver/w filter}{#1},
+ quiver/u value/.code =\pgfplots@set@source@for{quiver/u}{#1}{0},%
+ quiver/u/.code =\pgfplots@set@source@for{quiver/u}{#1}{1},%
+ quiver/v value/.code =\pgfplots@set@source@for{quiver/v}{#1}{0},%
+ quiver/v/.code =\pgfplots@set@source@for{quiver/v}{#1}{1},%
+ quiver/w value/.code =\pgfplots@set@source@for{quiver/w}{#1}{0},%
+ quiver/w/.code =\pgfplots@set@source@for{quiver/w}{#1}{1},%
+ quiver/before arrow/.code=,
+ quiver/after arrow/.code=,
+ quiver/every arrow/.style={},
+ quiver/arrow color/.initial=,
+ quiver/scale arrows/.initial=1,
+ quiver/update limits/.is if=pgfplots@quiver@updatelimits,
+ quiver/update limits=true,
+ quiver/colored/.code={%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfkeyslet{/pgfplots/quiver/arrow color}\pgfplots@loc@TMPa
+ \pgfkeysalso{/pgfplots/set point meta if empty=f(x)}%
+ \fi
+ },%
+ quiver/colored/.default=mapped color,
+}%
+
+\def\pgfplots@set@source@for#1#2#3{%
+ \pgfkeyssetvalue{/pgfplots/#1 value*}{#2}%
+ \pgfkeyssetvalue{/pgfplots/#1 is expr}{#3}%
+}%
+% To be used to create a simple parser for keys initialised by
+% \pgfplots@set@source@for:
+%
+% #1: the key path (relative to /pgfplots/) of the data.
+% Can be empty in which case /pgfplots/#2 is used to access data.
+% #2: the key name of the data
+% #3: a macro name which be will defined to be a parser for the data.
+%
+% The parser will check whether the '#2 is expr' key is set.
+% Furthermore, it defines /data point/#2 to be the result.
+%
+% Example:
+% \pgfplots@set@source@for{hist/data}{...}
+%
+% ->
+% \pgfplots@prepare@source@parser@for{hist/}{data}\parser
+%
+% then, invoking \parser
+% will define \pgfmathresult to be the argument provided to
+% \pgfplots@set@source@for.
+\def\pgfplots@prepare@source@parser@for#1#2#3{%
+ \pgfkeyslet{/data point/#1#2}\pgfutil@empty%
+ %
+ \pgfkeysgetvalue{/pgfplots/#1#2 value*}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % assume the '/data point/#1#2' is set by some input
+ % routine.
+ % Invoke math parser in this case.
+ \pgfkeyssetvalue{/pgfplots/#1#2 is expr}{1}%
+ \else
+ \pgfkeyslet{/data point/#1#2}\pgfplots@loc@TMPa
+ \fi
+ \def#3{%
+ \edef\pgfmathresult{\pgfkeysvalueof{/data point/#1#2}}%
+%\message{parse coordinate #1#2 (\pgfmathresult) ...^^J}%
+ }%
+ %
+ %
+ \pgfkeysifdefined{/pgfplots/#1#2 coord trafo/.@cmd}{%
+ \pgfkeysgetvalue{/pgfplots/#1#2 coord trafo/.@cmd}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key
+ \else
+ \t@pgfplots@toka=\expandafter{#3}%
+ \t@pgfplots@tokb={%
+ \def\pgfplots@loc@TMPa{\pgfkeysvalueof{/pgfplots/#1#2 coord trafo/.@cmd}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov%
+ }%
+ \t@pgfplots@tokc={%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \fi
+ }%
+ \edef#3{%
+ \the\t@pgfplots@toka
+ \the\t@pgfplots@tokb
+ \the\t@pgfplots@tokc
+ }%
+ \fi
+ }{}%
+ %
+ \t@pgfplots@toka=\expandafter{#3}%
+ \if1\pgfkeysvalueof{/pgfplots/#1#2 is expr}%
+ \t@pgfplots@tokc={%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathparse{\pgfmathresult}%
+ \fi
+ }%
+ \else
+ \t@pgfplots@tokc={%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \fi
+ }%
+ \fi
+ \edef#3{%
+ \the\t@pgfplots@toka
+ \the\t@pgfplots@tokc
+ }%
+ %
+ \pgfkeysgetvalue{/pgfplots/#1#2 filter/.@cmd}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key
+ \else
+ \t@pgfplots@toka=\expandafter{#3}%
+ \t@pgfplots@tokb={%
+ \def\pgfplots@loc@TMPa{\pgfkeysvalueof{/pgfplots/#1#2 filter/.@cmd}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov%
+ }%
+ \t@pgfplots@tokc={%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \fi
+ }%
+ \edef#3{%
+ \the\t@pgfplots@toka
+ \the\t@pgfplots@tokb
+ \the\t@pgfplots@tokc
+ }%
+ \fi
+ %
+ \iftrue
+ \t@pgfplots@toka=\expandafter{#3}%
+ \t@pgfplots@tokc={%
+%\message{parse coordinate (#1#2) = \pgfmathresult.^^J}%
+ }%
+ \edef#3{%
+ \the\t@pgfplots@toka
+ \the\t@pgfplots@tokc
+ }%
+ \fi
+}%
+
+% Invokes /pgfplots/#1 coord inv trafo on \pgfmathresult if that key
+% exists.
+% #1 the argument is in float (will become the 'default' coordmath
+% eventually).
+%
+% On output, it should either '#1' if there was no coord inv trafo or
+% the result of the trafo.
+\def\pgfplots@coord@trafo@inv@for#1{%
+ \def\pgfplots@loc@TMPb{/pgfplots/#1 coord inv trafo/.@cmd}%
+ \pgfkeysifdefined{\pgfplots@loc@TMPb}{%
+ \pgfkeysgetvalue{\pgfplots@loc@TMPb}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key
+ \else
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov
+ \fi
+ }{}%
+}
+% Like \pgfplots@coord@trafo@inv@for, but for the normal trafo
+% direction
+\def\pgfplots@coord@trafo@for#1{%
+ \def\pgfplots@loc@TMPb{/pgfplots/#1 coord trafo/.@cmd}%
+ \pgfkeysifdefined{\pgfplots@loc@TMPb}{%
+ \pgfkeysgetvalue{\pgfplots@loc@TMPb}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key
+ \else
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov
+ \fi
+ }{}%
+}
+\def\pgfplotsplothandlerquiver{%
+ \pgfplotsresetplothandler
+ \let\pgf@plotstreamstart=\pgfplotsplothandlervisbegin@quiver
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@quiver
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@quiver
+ \let\pgfplotsplothandlerserializepointto=\pgfplotsplothandlerserializepointto@quiver
+ \let\pgfplotsplothandlerdeserializepointfrom=\pgfplotsplothandlerdeserializepointfrom@quiver
+ \let\pgfplotsplothandlerpointtokeys=\pgfplotsplothandlerpointtokeys@quiver
+ \let\pgfplotsplothandlerquiver@vis@hook=\pgfutil@empty
+ \def\pgfplotsplothandlername{quiver}%
+ %
+ \ifpgfplots@xislinear \else \pgfplotsplothandlerquivererror \fi
+ \ifpgfplots@yislinear \else \pgfplotsplothandlerquivererror\fi
+ \pgfplotsifcurplotthreedim{%
+ \ifpgfplots@zislinear \else \pgfplotsplothandlerquivererror \fi
+ }{}%
+}%
+\def\pgfplotsplothandlerquivererror{\pgfplots@error{Sorry, quiver plots for logarithmic axes are not yet implemented. In fact, the implementation does something -- but it will probably change in future releases. Contact the mailing list if you have questions}}%
+
+\def\pgfplotsplothandlersurveystart@quiver{%
+ \pgfkeysgetvalue{/pgfplots/quiver/scale arrows}\pgfplots@quiver@scale
+ \ifx\pgfplots@quiver@scale\pgfutil@empty
+ \else
+ \def\pgfplots@loc@TMPa{1}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@quiver@scale
+ \let\pgfplots@quiver@scale=\pgfutil@empty
+ \else
+ \pgfmathparse{\pgfplots@quiver@scale}%
+ \pgfmathfloatparsenumber\pgfplots@quiver@scale
+ \let\pgfplots@quiver@scale=\pgfmathresult
+ \fi
+ \fi
+ %
+ \pgfplots@prepare@source@parser@for@quiver u\pgfplots@quiver@prepare@u%
+ \pgfplots@prepare@source@parser@for@quiver v\pgfplots@quiver@prepare@v%
+ \pgfplots@prepare@source@parser@for@quiver w\pgfplots@quiver@prepare@w%
+}%
+
+\def\pgfplots@prepare@source@parser@for@quiver#1#2{%
+ \pgfplots@prepare@source@parser@for{quiver/}{#1}{#2}%
+ \t@pgfplots@toka=\expandafter{#2}%
+ \t@pgfplots@tokb=\expandafter{\csname pgfplots@quiver@#1\endcsname}%
+ \edef#2{%
+ \the\t@pgfplots@toka
+ \noexpand\let\the\t@pgfplots@tokb=\noexpand\pgfmathresult
+ \ifx\pgfplots@quiver@scale\pgfutil@empty
+ \else
+ \noexpand\pgfmathfloatmultiply@{\pgfplots@quiver@scale}{\the\t@pgfplots@tokb}%
+ \noexpand\let\the\t@pgfplots@tokb=\noexpand\pgfmathresult
+ \fi
+ }%
+}%
+
+\def\pgfplotsplothandlersurveypoint@quiver{%
+ \pgfplots@quiver@prepare@u
+ \pgfplots@quiver@prepare@v
+ \pgfplotsifcurplotthreedim{%
+ \pgfplots@quiver@prepare@w
+ }{%
+ \let\pgfplots@quiver@w=\pgfutil@empty
+ }%
+ \pgfplotsaxisparsecoordinate
+ \pgfplotsaxispreparecoordinate
+ \ifpgfplotsaxisparsecoordinateok
+ \pgfplotsaxisupdatelimitsforcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z
+ %
+ \pgfmathadd@{\pgfplots@quiver@u}{\pgfplots@current@point@x}%
+ \let\pgfplots@quiver@u=\pgfmathresult
+ \pgfmathadd@{\pgfplots@quiver@v}{\pgfplots@current@point@y}%
+ \let\pgfplots@quiver@v=\pgfmathresult
+ \pgfplotsifcurplotthreedim{%
+ \pgfmathadd@{\pgfplots@quiver@w}{\pgfplots@current@point@z}%
+ \let\pgfplots@quiver@w=\pgfmathresult
+ }{}%
+ \ifpgfplots@quiver@updatelimits
+ \pgfplotsaxisupdatelimitsforcoordinate\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w
+ \fi
+ \fi
+ \pgfplotsaxisdatapointsurveyed
+}%
+\def\pgfplotsplothandlerserializepointto@quiver#1{%
+ \edef#1{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z>\pgfplots@quiver@u,\pgfplots@quiver@v,\pgfplots@quiver@w}%
+}%
+\def\pgfplotsplothandlerdeserializepointfrom@quiver#1{%
+ \expandafter\pgfplotsplothandlerdeserializepointfrom@quiver@#1\relax
+}%
+\def\pgfplotsplothandlerdeserializepointfrom@quiver@#1,#2,#3>#4,#5,#6\relax{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+ \def\pgfplots@quiver@u{#4}%
+ \def\pgfplots@quiver@v{#5}%
+ \def\pgfplots@quiver@w{#6}%
+}%
+\def\pgfplotsplothandlerpointtokeys@quiver#1{%
+ \pgfplotsplothandlerpointtokeys@default
+ \pgfkeyslet{#1/u}\pgfplots@quiver@u
+ \pgfkeyslet{#1/v}\pgfplots@quiver@v
+ \pgfkeyslet{#1/w}\pgfplots@quiver@w
+}%
+\def\pgfplotsplothandlervisbegin@quiver{%
+ \def\pgfplots@quiver@has@handled@point@meta{0}%
+ \pgfkeysgetvalue{/pgfplots/quiver/arrow color}\pgfplots@quiver@color
+ \ifx\pgfplots@quiver@color\pgfutil@empty
+ \else
+ % prepare the color data and define 'mapped color':
+ \def\pgfplots@quiver@has@handled@point@meta{1}%
+ \expandafter\def\expandafter\pgfplotsplothandlerquiver@vis@hook\expandafter{%
+ \pgfplotsplothandlerquiver@vis@hook
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}%
+ }%
+ % SEE BELOW AS WELL FOR HOW TO ENABLE THE COLOR.
+ \fi
+ %
+ %
+ \pgfkeysgetvalue{/pgfplots/quiver/every arrow/.@cmd}\pgfplots@quiver@everyarrow
+ \ifx\pgfplots@quiver@everyarrow\pgfplots@empty@style@key
+ % use PGF basic level methods to set the 'arrow color':
+ \ifx\pgfplots@quiver@color\pgfutil@empty
+ \else
+ \expandafter\def\expandafter\pgfplotsplothandlerquiver@vis@hook\expandafter{%
+ \pgfplotsplothandlerquiver@vis@hook
+ \pgfsetstrokecolor{\pgfkeysvalueof{/pgfplots/quiver/arrow color}}%
+ % for arrow heads:
+ \pgfsetfillcolor{\pgfkeysvalueof{/pgfplots/quiver/arrow color}}%
+ }%
+ \fi
+ \else
+ % 'every arrow' should provide a high level user interface.
+ % Use tikz instead of pgf. This is slower, but more powerful.
+ \pgfplots@quiver@usetikztrue
+ \pgfplotsaxisifhaspointmeta{%
+ % ASSERT(mapped color is available)
+ \if0\pgfplots@quiver@has@handled@point@meta%
+ % -> define mapped color
+ \expandafter\def\expandafter\pgfplotsplothandlerquiver@vis@hook\expandafter{%
+ \pgfplotsplothandlerquiver@vis@hook
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}%
+ }%
+ \def\pgfplots@quiver@has@handled@point@meta{1}%
+ \fi
+ }{}%
+ % use tikz methods to set the 'arrow color':
+ \ifx\pgfplots@quiver@color\pgfutil@empty
+ \else
+ \t@pgfplots@toka=\expandafter{\pgfplots@quiver@color}%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfkeysalso{/pgfplots/quiver/every arrow/.prefix style={\the\t@pgfplots@toka}}}%
+ \pgfplots@loc@TMPa
+ \fi
+ \fi
+ %
+ \global\let\pgf@plotstreampoint=\pgfplotsplothandlerquiver@vis%
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax
+}%
+
+\def\pgfplotsplothandlerquiver@vis#1{%
+ \pgfkeysvalueof{/pgfplots/quiver/before arrow/.@cmd}\pgfeov
+ \pgfplotsplothandlerquiver@vis@hook
+ \ifpgfplots@quiver@usetikz
+ \edef\pgfplotsplothandler@quiver@point{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ \draw[/pgfplots/quiver/every arrow] \pgfextra{\pgfplotsplothandlerquiver@vis@path{\pgfplotsplothandler@quiver@point}};
+ \else
+ \pgfplotsplothandlerquiver@vis@path{#1}%
+ \pgfusepath{stroke}%
+ \fi
+ \pgfkeysvalueof{/pgfplots/quiver/after arrow/.@cmd}\pgfeov
+}%
+\def\pgfplotsplothandlerquiver@vis@path#1{%
+ \pgfpathmoveto{#1}%
+ \pgfplotsaxisvisphasetransformcoordinate\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w
+ \pgfpathlineto{%
+ \pgfplotsifcurplotthreedim{%
+ \pgfplotsqpointxyz\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w
+ }{%
+ \pgfplotsqpointxy\pgfplots@quiver@u\pgfplots@quiver@v
+ }%
+ }%
+}%
+
+\newif\ifpgfplotsplothandlerhistogram@intervals
+\newif\ifpgfplotsplothandlerhistogram@cumulative
+\newif\ifpgfplotsplothandlerhistogram@density
+\pgfplotsset{
+ hist/.code={%
+ \let\tikz@plot@handler=\pgfplotsplothandlerhistogram
+ \pgfqkeys{/pgfplots/hist}{#1}%
+ },
+ hist/data value/.code =\pgfplots@set@source@for{hist/data}{#1}{0},%
+ hist/data/.code =\pgfplots@set@source@for{hist/data}{#1}{1},%
+ hist/data filter/.code=,
+ hist/data filter/.expression/.code=\pgfplots@install@filter@expression{hist/data filter}{#1},
+ hist/data value=\pgfkeysvalueof{/data point/y},
+% hist/data=y,
+ hist/data min/.initial=\pgfkeysvalueof{/pgfplots/xmin},
+ hist/data max/.initial=\pgfkeysvalueof{/pgfplots/xmax},
+ hist/bins/.initial=10,
+ hist/intervals/.is if=pgfplotsplothandlerhistogram@intervals,
+ hist/intervals/.default=true,
+ hist/intervals=true,
+ hist/cumulative/.is if=pgfplotsplothandlerhistogram@cumulative,
+ hist/cumulative/.default=true,
+ hist/density/.is if=pgfplotsplothandlerhistogram@density,
+ hist/density/.default=true,
+ hist/density=false,
+ hist/handler/.style={/tikz/ybar interval},
+ hist/symbolic coords/.style={%
+ /pgfplots/symbolic coords={hist/data}{#1},
+ /pgfplots/symbolic coords={x}{#1},
+ },%
+}%
+\def\pgfplotsplothandlerhistogram{%
+ \pgfplotsresetplothandler
+ \def\pgf@plotstreamstart{%
+ \pgfplotsset{/pgfplots/hist/handler}%
+ \pgfplotsresetplothandler
+ \tikz@plot@handler
+ \pgf@plotstreamstart
+ }%
+ %
+ % let \pgfplotsplothandlername to the one of the handler.
+ % Note that \pgfplotsplothandlername is the *visualization* layer
+ \begingroup
+ \pgfplotsset{/pgfplots/hist/handler}%
+ \pgfplotsresetplothandler
+ \tikz@plot@handler
+ \xdef\pgfplots@glob@TMPa{\pgfplotsplothandlername}%
+ \endgroup
+ \let\pgfplotsplothandlername=\pgfplots@glob@TMPa%
+ %
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@hist
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@hist
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@hist
+}%
+\def\pgfplotsplothandlersurveystart@hist{%
+ \pgfplots@prepare@source@parser@for{hist/}{data}{\pgfplotsplothandlerhistogram@parse}%
+ %
+ \pgfkeysgetvalue{/pgfplots/hist/data min}\pgfmathresult
+ \edef\pgfmathresult{\pgfmathresult}%
+ \ifx\pgfmathresult\pgfutil@empty\else
+ \pgfplots@coord@trafo@for{hist/data}%
+ \fi
+ \edef\pgfplotsplothandlerhistogram@datamin{\pgfmathresult}%
+ %
+ \pgfkeysgetvalue{/pgfplots/hist/data max}\pgfmathresult
+ \edef\pgfmathresult{\pgfmathresult}%
+ \ifx\pgfmathresult\pgfutil@empty\else
+ \pgfplots@coord@trafo@for{hist/data}%
+ \fi
+ \edef\pgfplotsplothandlerhistogram@datamax{\pgfmathresult}%
+ %
+ \ifx\pgfplotsplothandlerhistogram@datamin\pgfutil@empty
+ \pgfmathfloatcreate{1}{1.0}{2147483645}%
+ \let\pgfplotsplothandlerhistogram@datamin=\pgfmathresult
+ \def\pgfplotsplothandlerhistogram@datamin@autocompute{1}%
+ \else
+ \pgfmathfloatparsenumber{\pgfplotsplothandlerhistogram@datamin}%
+ \let\pgfplotsplothandlerhistogram@datamin=\pgfmathresult
+ \def\pgfplotsplothandlerhistogram@datamin@autocompute{0}%
+ \fi
+ \ifx\pgfplotsplothandlerhistogram@datamax\pgfutil@empty
+ \pgfmathfloatcreate{2}{1.0}{2147483645}%
+ \let\pgfplotsplothandlerhistogram@datamax=\pgfmathresult
+ \def\pgfplotsplothandlerhistogram@datamax@autocompute{1}%
+ \else
+ \pgfmathfloatparsenumber{\pgfplotsplothandlerhistogram@datamax}%
+ \let\pgfplotsplothandlerhistogram@datamax=\pgfmathresult
+ \def\pgfplotsplothandlerhistogram@datamax@autocompute{0}%
+ \fi
+ %
+ \edef\pgfplotsplothandlerhistogram@Nfixed{\pgfkeysvalueof{/pgfplots/hist/bins}}%
+ \c@pgf@counta=\pgfplotsplothandlerhistogram@Nfixed\relax
+ \advance\c@pgf@counta by-1
+ \edef\pgfplotsplothandlerhistogram@Nmax{\the\c@pgf@counta}%
+ %
+ \pgfmathfloatparsenumber{\pgfplotsplothandlerhistogram@Nfixed}%
+ \let\pgfplotsplothandlerhistogram@N=\pgfmathresult
+ %
+ \pgfplotsapplistXnewempty\pgfp@hist@@
+ \def\c@pgfplotsplothandlerhistogram@num{0}%
+ \c@pgfplots@coordindex=0
+}%
+
+\def\pgfplotsplothandlersurveypoint@hist@limits{%
+ \if1\pgfplotsplothandlerhistogram@datamin@autocompute
+ \pgfplotsmathfloatmin{\pgfplots@current@point@data}{\pgfplotsplothandlerhistogram@datamin}%
+ \let\pgfplotsplothandlerhistogram@datamin=\pgfmathresult
+ \fi
+ %
+ \if1\pgfplotsplothandlerhistogram@datamax@autocompute
+ \pgfplotsmathfloatmax{\pgfplots@current@point@data}{\pgfplotsplothandlerhistogram@datamax}%
+ \let\pgfplotsplothandlerhistogram@datamax=\pgfmathresult
+ \fi
+}%
+\def\pgfplotsplothandlersurveypoint@hist{%
+ % Note that at this point, the coordinate filtering does NOT
+ % apply. Perhaps it should...
+ \pgfplotsplothandlerhistogram@parse
+ \let\pgfplots@current@point@data=\pgfmathresult
+ %
+ \ifx\pgfplots@current@point@data\pgfutil@empty
+ \else
+ \pgfmathfloatiffinite\pgfplots@current@point@data{%
+ \pgfplotsplothandlersurveypoint@hist@limits
+ %
+ \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlerhistogram@num
+ %
+ % store parsed result.
+ \edef\pgfmathresult{{\pgfplots@current@point@data}}%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfp@hist@@
+ }{%
+ }%
+ \fi
+ \advance\c@pgfplots@coordindex by1
+}%
+\def\pgfplotsplothandlersurveyend@hist{%
+ \ifnum\c@pgfplotsplothandlerhistogram@num>0
+ \expandafter\pgfplotsplothandlersurveyend@hist@
+ \fi
+}%
+\def\pgfplotsplothandlersurveyend@hist@{%
+ \pgfmathfloatsubtract@{\pgfplotsplothandlerhistogram@datamax}{\pgfplotsplothandlerhistogram@datamin}%
+ \let\pgfplotsplothandlerhistogram@range=\pgfmathresult
+ \pgfmathfloatdivide@{\pgfplotsplothandlerhistogram@range}{\pgfplotsplothandlerhistogram@N}%
+ \let\pgfplotsplothandlerhistogram@h=\pgfmathresult
+ \pgfmathfloatreciprocal@{\pgfplotsplothandlerhistogram@h}%
+ \let\pgfplotsplothandlerhistogram@invh=\pgfmathresult
+ %
+ \pgfplotsarraynewempty{pgfp@hist}%
+ \pgfplotsarrayresize{pgfp@hist}{\pgfplotsplothandlerhistogram@Nfixed}%
+ \pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{%
+ \pgfplotsarrayset{\pgfplotsarrayforeachindex}\of{pgfp@hist}\to{0}%
+ }%
+ %
+ \pgfplotsapplistXlet\pgfplots@hist@data=\pgfp@hist@@
+ \pgfplotsapplistXnewempty\pgfp@hist@@
+ \expandafter\pgfplotsplothandlersurveyend@hist@loop\pgfplots@hist@data\pgfplots@EOI
+ \let\pgfplots@hist@data=\relax
+ %
+
+ % Calculate total count
+ \c@pgf@counta=0
+ \pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{%
+ \advance\c@pgf@counta by\pgfplots@hist@count\relax
+ \def\pgfplots@loc@TMPa{\pgfplotsarrayset{\pgfplotsarrayforeachindex}\of{pgfp@hist}\to}%
+ }%
+ \pgfmathfloatparsenumber{\the\c@pgf@counta}%
+ \let\pgfp@hist@totalcount=\pgfmathresult
+ \pgfmathfloatreciprocal@{\pgfp@hist@totalcount}%
+ \let\pgfp@hist@totalcount@inv=\pgfmathresult
+ %
+ \ifpgfplotsplothandlerhistogram@cumulative
+ \c@pgf@counta=0
+ \pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{%
+ \advance\c@pgf@counta by\pgfplots@hist@count\relax
+ \def\pgfplots@loc@TMPa{\pgfplotsarrayset{\pgfplotsarrayforeachindex}\of{pgfp@hist}\to}%
+ \ifpgfplotsplothandlerhistogram@density
+ \pgfmathfloatparsenumber{\the\c@pgf@counta}%
+ \pgfmathfloatmultiply@{\pgfmathresult}{\pgfp@hist@totalcount@inv}%
+ \pgfmathfloattosci@{\pgfmathresult}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
+ \else
+ \expandafter\pgfplots@loc@TMPa\expandafter{\the\c@pgf@counta}%
+ \fi
+ }%
+ \fi%
+ %
+ %% Density histogram
+ % Divide count in each bin by (totalcount*range/bins)
+ \ifpgfplotsplothandlerhistogram@density
+ \ifpgfplotsplothandlerhistogram@cumulative
+ \else
+ \pgfmathfloatmultiply@{\pgfp@hist@totalcount@inv}{\pgfplotsplothandlerhistogram@invh}%
+ \let\pgfp@hist@totalcount@times@h@inv=\pgfmathresult
+% FIXME : this here is a patch suggestion for
+% https://sourceforge.net/tracker/?func=detail&atid=1060656&aid=3609245&group_id=224188
+%
+% FIXME : this line would actually compute relative frequencies...
+% might not be too bad at all, but is no density
+%\let\pgfp@hist@totalcount@times@h@inv=\pgfp@hist@totalcount@inv
+ \pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{%
+ \pgfmathfloatparsenumber{\pgfplots@hist@count}%
+ \pgfmathfloatmultiply@{\pgfmathresult}{\pgfp@hist@totalcount@times@h@inv}%
+ \pgfmathfloattosci@{\pgfmathresult}%
+ \def\pgfplots@loc@TMPa{\pgfplotsarrayset{\pgfplotsarrayforeachindex}\of{pgfp@hist}\to}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
+ }%
+ \fi
+ \fi
+ %
+ %% End density histogram
+ \pgfplots@curplot@threedimfalse
+ %
+ \pgfplotsset{/pgfplots/hist/handler}%
+ \pgfplotsresetplothandler
+ \tikz@plot@handler
+ %
+ \pgfplotsplothandlersurveystart
+ %
+ \let\pgfplots@current@point@z=\pgfutil@empty
+ \pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{%
+ \pgfplotsplothandlerhistgetintervalstartfor\pgfplotsarrayforeachindex
+ \pgfplotsplothandlerhist@invtrafo
+ \let\pgfplots@current@point@x\pgfmathresult%
+ \let\pgfplots@current@point@y\pgfplots@hist@count%
+%\message{Survey point (\pgfplots@current@point@x,\pgfplots@current@point@y)^^J}%
+ \pgfplotsplothandlersurveypoint
+ }%
+ \ifpgfplotsplothandlerhistogram@intervals
+ % replicate last count.
+ \let\pgfmathresult\pgfplotsplothandlerhistogram@datamax%
+ \pgfplotsplothandlerhist@invtrafo
+ \let\pgfplots@current@point@x\pgfmathresult%
+ \let\pgfplots@current@point@y\pgfplots@hist@count%
+%\message{Survey point (\pgfplots@current@point@x,\pgfplots@current@point@y)^^J}%
+ \pgfplotsplothandlersurveypoint
+ \fi
+ %
+ \pgfplotsplothandlersurveyend
+}
+\def\pgfplotsplothandlerhist@invtrafo{%
+ % This here might be inefficient, because
+ % there needs to be a compatible "x coord trafo" as well -- and
+ % that transformation will (most likely) do the very same thing as
+ % the hist/data coord trafo.
+ %
+ % But I did not find a way to combine the transformations
+ % automatically without resorting to hackery.
+ %
+ % And: the performance impact might (hopefully) be small...
+ \pgfplots@coord@trafo@inv@for{hist/data}%
+}%
+\def\pgfplotsplothandlersurveyend@hist@loop#1{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@EOI
+ \else
+ \pgfplotsplothandlerhistgetbinfor@{#1}%
+ \expandafter\pgfplotsplothandlerhistadvancebin\expandafter{\pgfmathresult}%
+ %
+ \expandafter\pgfplotsplothandlersurveyend@hist@loop
+ \fi
+}%
+\def\pgfplotsplothandlerhistadvancebin#1{%
+ \pgfplotsarrayselect{#1}\of{pgfp@hist}\to\pgfplots@loc@TMPa%
+ \pgfplotsutil@advancestringcounter\pgfplots@loc@TMPa
+ \pgfplotsarrayletentry{#1}\of{pgfp@hist}=\pgfplots@loc@TMPa
+}%
+\def\pgfplotsplothandlerhistgetintervalstartfor#1{%
+ \pgfmathfloatparsenumber{#1}%
+ \expandafter\pgfplotsplothandlerhistgetintervalstartfor@\expandafter{\pgfmathresult}%
+}%
+\def\pgfplotsplothandlerhistgetintervalstartfor@#1{%
+ \pgfmathfloatmultiply@{\pgfplotsplothandlerhistogram@h}{#1}%
+ \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfplotsplothandlerhistogram@datamin}%
+}%
+\def\pgfplotsplothandlerhistgetbinfor#1{%
+ \pgfmathfloatparsenumber{#1}%
+ \expandafter\pgfplotsplothandlerhistgetbinfor@\expandafter{\pgfmathresult}%
+}%
+
+\def\pgfplotsplothandlerhistsettol#1{%
+ \begingroup
+ \pgfmathfloatparsenumber{#1}%
+ \global\let\pgfplotsplothandlerhisttol@parsed=\pgfmathresult
+ \endgroup
+}%
+\pgfplotsplothandlerhistsettol{1e-4}%
+
+\def\pgfplotsplothandlerhistgetbinfor@#1{%
+ \pgfmathfloatsubtract@{#1}{\pgfplotsplothandlerhistogram@datamin}%
+ \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplotsplothandlerhistogram@invh}%
+ \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfplotsplothandlerhisttol@parsed}%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \afterassignment\pgfplots@gobble@until@relax
+ \c@pgf@counta=\pgfmathresult\relax
+ \ifnum\pgfplotsplothandlerhistogram@Nfixed>\c@pgf@counta
+ \ifnum\c@pgf@counta<0
+ \def\pgfmathresult{0}%
+ \else
+ \def\pgfmathresult{\the\c@pgf@counta}%
+ \fi
+ \else
+ \let\pgfmathresult=\pgfplotsplothandlerhistogram@Nmax
+ \fi
+}%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+%
+% Contour plots
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+
+\newif\ifpgfplotsplothandlercontour@labels
+\newif\ifpgfplotsplothandlercontour@filled
+
+\def\pgfplotsplothandlercontour@axis@set@inverse#1#2#3#4{%
+ \pgfplotsutilifstringequal{#1}{#4}{%
+ \expandafter\def\csname pgfplotsplothandlercontour@axis@inv@#4\endcsname{x}%
+ }{%
+ \pgfplotsutilifstringequal{#2}{#4}{%
+ \expandafter\def\csname pgfplotsplothandlercontour@axis@inv@#4\endcsname{y}%
+ }{%
+ \pgfplotsutilifstringequal{#3}{#4}{%
+ \expandafter\def\csname pgfplotsplothandlercontour@axis@inv@#4\endcsname{z}%
+ }{%
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, the choice axes={#1}{#2}{#3} is illegal. Please use only values x, y, and z and ensure that there is a 1:1 correspondence}\pgfeov%
+ }%
+ }%
+ }%
+}
+
+\pgfplotsset{
+ contour prepared/.code={%
+ \let\tikz@plot@handler=\pgfplotsplothandlercontourprepared
+ \pgfqkeys{/pgfplots/contour}{%
+ every contour plot,%
+ #1,%
+ }%
+ },
+ contour prepared filled/.style={%
+ /pgfplots/contour prepared={draw color=mapped color!80!black,labels=false,filled=true},
+ },
+ contour filled/.code={%
+ \pgfqkeys{/pgfplots/contour}{%
+ every filled contour plot,%
+ /pgfplots/surf,%
+ /pgfplots/shader=interp,%
+ /pgfplots/colormap access=const,%
+ #1,%
+ }%
+ \let\tikz@plot@handler=\pgfplotsplothandlercontourfilled
+ },
+ % FIXME : should use \tikz@plot@handler instead of just the
+ % visualization thing!
+ contour/handler/.style={/tikz/sharp plot},
+ contour prepared format/.is choice,
+ contour prepared format/standard/.code= {\def\pgfplotsplothandlercontourprepared@format{s}},
+ contour prepared format/matlab/.code= {\def\pgfplotsplothandlercontourprepared@format{m}},
+ contour prepared format/standard,
+ contour/draw color/.initial=mapped color,
+ contour/fill color/.initial=mapped color,
+ contour/label distance/.initial=70pt,
+ contour/label node code/.code={%
+ \node {\pgfmathprintnumber{#1}};
+ },%
+ contour/labels/.is if=pgfplotsplothandlercontour@labels,
+ contour/labels=true,
+ %
+ % XXX : this here is dead code... it has been superseded by
+ % \pgfplotsplothandlercontourfilled:
+ contour/filled/.is if=pgfplotsplothandlercontour@filled,
+ contour/filled/.default=true,
+ % EXPERIMENTAL: WILL CHANGE EVENTUALLY!
+ % this is (only) used for contour filled:
+ % data limits={(xmin,ymin,zmin,cmin) (xmax,ymax,ymax,cmax}
+ contour/data limits/.initial=,% FIXME EXPERIMENTAL
+ contour/every filled contour plot/.style={
+ /pgfplots/area legend,
+ },
+ contour/every contour plot/.style={
+ /pgfplots/legend image post style={sharp plot},
+ },
+ contour/every contour label/.style={%
+ sloped,%
+ transform shape,%
+ inner sep=2pt,
+ font=\scriptsize,
+ every node/.style={mapped color!50!black,fill=white},%
+ /pgf/number format/relative*={\pgfplotspointmetarangeexponent},%
+ %every node/.style={yshift=10pt},%
+ },
+ contour/labels over line/.style={
+ /pgfplots/contour/every contour label/.append style={%
+ every node/.append style={%
+ fill=none,
+ anchor=base,
+ yshift=1pt,
+ },
+ },
+ },
+ contour/contour label style/.style={
+ /pgfplots/contour/every contour label/.append style={#1}},
+ %
+ %
+ % Styles to actually *compute* the contour.
+ % These are mostly placeholders here: As long as the
+ % algorithm is not ready, we have to resort to external tools.
+ %
+ % Shared parameters:
+ contour/number/.initial=5,
+ contour/levels/.initial=,
+ contour/levels from colormap/.initial=,
+ %
+ %
+ contour/contour dir/.is choice,
+ contour/contour dir/x/.style={/pgfplots/contour/axes={y}{z}{x}},
+ contour/contour dir/y/.style={/pgfplots/contour/axes={x}{z}{y}},
+ contour/contour dir/z/.style={/pgfplots/contour/axes={x}{y}{z}},
+ contour/axes/.code args={#1#2#3}{%
+ \edef\pgfplotsplothandlercontour@axis@x{#1}%
+ \edef\pgfplotsplothandlercontour@axis@y{#2}%
+ \edef\pgfplotsplothandlercontour@axis@z{#3}%
+ %
+ \edef\pgfplots@loc@TMPa{{\pgfplotsplothandlercontour@axis@x}{\pgfplotsplothandlercontour@axis@y}{\pgfplotsplothandlercontour@axis@z}}%
+ %
+ \expandafter\pgfplotsplothandlercontour@axis@set@inverse\pgfplots@loc@TMPa{x}%
+ \expandafter\pgfplotsplothandlercontour@axis@set@inverse\pgfplots@loc@TMPa{y}%
+ \expandafter\pgfplotsplothandlercontour@axis@set@inverse\pgfplots@loc@TMPa{z}%
+ %
+ },%
+ contour/contour dir=z,
+ %
+ %
+ % Interface to external tools:
+ contour external/.code={%
+ \edef\tikz@plot@handler{\noexpand\pgfplotsplothandlercontourexternal}%
+ \pgfqkeys{/pgfplots/contour external}{%
+ every contour plot,%
+ #1%
+ }%
+ },
+ contour external/scanline marks/.is choice,
+ contour external/scanline marks/false/.code={\def\pgfplotsplothandlercontourexternal@scanlinemode{0}},
+ contour external/scanline marks/if in input/.code={\def\pgfplotsplothandlercontourexternal@scanlinemode{1}},
+ contour external/scanline marks/required/.code={\def\pgfplotsplothandlercontourexternal@scanlinemode{2}},
+ contour external/scanline marks/true/.code={\def\pgfplotsplothandlercontourexternal@scanlinemode{2}},
+ contour external/scanline marks/if in input,
+ contour external/output point meta/.initial=,
+ contour external/file/.initial=,% auto-generate
+ contour external/script extension/.initial=script,
+ contour external/script/.initial=,% not yet initialised
+ contour external/cmd/.initial=,% not yet initialised
+ contour external/.search also=/pgfplots/contour,
+ contour gnuplot/.style={
+ contour external={%
+ scanline marks=required,
+ script={
+ unset surface;
+ \ifx\thecontourlevels\empty
+ set cntrparam levels \thecontournumber;
+ \else
+ set cntrparam levels discrete \thecontourlevels;
+ \fi
+ set contour;
+ set table \"\outfile\";
+ splot \"\infile\";
+ },
+ cmd={gnuplot \"\script\"},%
+ #1,%
+ },
+ },
+}%
+
+\def\pgfplotsplothandlercontourprepared{%
+ \pgfplotsresetplothandler
+ \pgfplotsset{empty line=jump}%
+ \let\pgf@plotstreamstart=\pgfplotsplothandlervisstart@contour
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@contour
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@contour
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@contour
+ \if m\pgfplotsplothandlercontourprepared@format
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@contourmatlabformat
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@contourmatlabformat
+ \pgfplotsaxisifhaspointmeta{}{%
+ \pgfplotsset{/pgfplots/point meta=explicit}%
+ }%
+ \fi
+ \pgfplotsplothandlercontour@prepare@point@meta
+ \def\pgfplotsplothandlersurveybeforesetpointmeta{%
+ % ensure that 'point meta=z' respects 'axes={y}{z}{x}' -- it
+ % should assign the 'x' coordinate as point meta!
+ % To this end, we have to convert to reordered axes
+ % temporarily.
+ \pgfplotsplothandlersurveypoint@contour@axes@std@to@reordered
+ \pgfplotsplothandlersurveybeforesetpointmeta@default
+ }%
+ \def\pgfplotsplothandlersurveyaftersetpointmeta{%
+ \pgfplotsplothandlersurveyaftersetpointmeta@default
+ % ... and undo the reordering after point meta has been set:
+ \pgfplotsplothandlersurveypoint@contour@axes@reordered@to@std
+ }%
+ \def\pgfplotsplothandlername{contour prepared}%
+}%
+
+\def\pgfplotsplothandlersurveystart@contour{%
+ \pgfplotsplothandlersurveystart@default
+ %
+ \pgfplotsplothandlersurveypoint@contour@prepare@axes x%
+ \pgfplotsplothandlersurveypoint@contour@prepare@axes y%
+ \pgfplotsplothandlersurveypoint@contour@prepare@axes z%
+}%
+
+\def\pgfplotsplothandlercontour@prepare@point@meta{%
+ \ifpgfplots@curplot@threedim
+ \pgfplotsset{/pgfplots/set point meta if empty=z}%
+ \else
+ \pgfplotsaxisifhaspointmeta{}{%
+ \pgfkeysgetvalue{/pgfplots/table/meta index}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+% FIXME : this here is reasonable, but it should be sanity checked!
+ \pgfkeyssetvalue{/pgfplots/table/meta index}{2}%
+ \fi
+ \pgfplotsset{/pgfplots/set point meta if empty=explicit}%
+ }%
+ %\pgfplots@error{Sorry, 'contour external' requires \string\addplot3 (or a non-empty `point meta' used as label data)}%
+ \fi
+ \def\pgfplotsplothandlercontour@empty@pointmeta@error@@{0}%
+}%
+\def\pgfplotsplothandlercontour@empty@pointmeta@error{%
+ \if0\pgfplotsplothandlercontour@empty@pointmeta@error@@
+ \def\pgfplotsplothandlercontour@empty@pointmeta@error@@{1}%
+ \def\pgfplots@current@point@meta{0}%
+ \pgfplotsthrow{invalid argument}{\pgfplots@current@point@meta}{Sorry, contour plots require non--empty `point meta'. Please use '\string\addplot3[contour ...] together with 'view={0}{90}' or provide a valid 'point meta=<value>' (for example `<value>=z'?)}\pgfeov%
+ \fi
+}%
+
+\def\pgfplotsplothandlersurveystart@contourmatlabformat{%
+ \def\c@pgfplotsplothandlercontourprepared@matlabformat@cur{0}%
+ \def\c@pgfplotsplothandlercontourprepared@matlabformat@count{0}%
+ \pgfmathfloatparsenumber{nan}%
+ \let\pgfplotsplothandlercontourprepared@matlabformat@meta=\pgfmathresult
+ %
+ \pgfplotsplothandlersurveystart@contour
+}
+\def\pgfplotsplothandlersurveypoint@contourmatlabformat{%
+ \ifnum\c@pgfplotsplothandlercontourprepared@matlabformat@cur=\c@pgfplotsplothandlercontourprepared@matlabformat@count\relax
+ \pgfmathfloatparsenumber{\pgfplots@current@point@y}%
+ \pgfmathfloattoint\pgfmathresult
+ \let\c@pgfplotsplothandlercontourprepared@matlabformat@count=\pgfmathresult
+ \def\c@pgfplotsplothandlercontourprepared@matlabformat@cur{0}%
+ %
+ \pgfmathfloatparsenumber{\pgfplots@current@point@x}%
+ \let\pgfplots@loc@TMPa=\pgfplotsplothandlercontourprepared@matlabformat@meta
+ \let\pgfplotsplothandlercontourprepared@matlabformat@meta=\pgfmathresult
+ %
+ \ifx\pgfplots@loc@TMPa\pgfplotsplothandlercontourprepared@matlabformat@meta
+ % oh. We have two successive segments of the SAME contour
+ % level. Call the jump handler:
+ \pgfplotsscanlinecomplete
+ \fi
+ %
+ \else
+ \let\pgfplots@current@point@z=\pgfplotsplothandlercontourprepared@matlabformat@meta
+ \let\pgfplots@current@point@meta=\pgfplotsplothandlercontourprepared@matlabformat@meta
+ \pgfplotsplothandlersurveypoint@contour
+ \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlercontourprepared@matlabformat@cur
+ \fi
+}%
+
+\def\pgfplotsplothandlersurveypoint@contour{%
+ %
+ \pgfplotsplothandlersurveypoint@contour@axes@reordered@to@std
+ %
+ \pgfplotsplothandlersurveypoint@default
+}
+
+\def\pgfplotsplothandlersurveyend@contour{%
+ \pgfplotsplothandlercontour@init@limits
+ \ifx\pgfplotsplothandlercontour@limits@low@meta\pgfutil@empty
+ \else
+ \pgfplotsaxisupdatelimitsforpointmeta\pgfplotsplothandlercontour@limits@low@meta
+ \fi
+}%
+
+\def\pgfplotsplothandlervisstart@contour{%
+ %
+ \ifpgfplotsplothandlercontour@labels
+ \pgfkeysgetvalue{/pgfplots/contour/label distance}\pgfplotsplothandlercontour@labeldist
+ \pgfmathparse{\pgfplotsplothandlercontour@labeldist}%
+ \edef\pgfplotsplothandlercontour@labeldist{\pgfmathresult pt}%
+ %
+ \pgfplotsapplistXnewempty\pgfplotsplothandlercontour@storedlabels
+ \let\pgfplotsplothandlercontour@handlesplinesegment=\pgfplotsplothandlercontour@handlesplinesegment@forlabels
+ \else
+ \def\pgfplotsplothandlercontour@handlesplinesegment##1##2##3{}%
+ \fi
+ %
+ \ifpgfplotsplothandlercontour@filled
+ \pgfseteorule
+ \let\pgfplotsplothandlercontour@sequence@sort@cmp=\pgfutil@empty
+ \pgfplotsapplistXnewempty\pgfplotsplothandlercontour@stored@lastcontourpath
+ \pgfplotsplothandlercontour@init@limits
+ \fi
+ %
+ \pgfplotsresetplothandler
+ \pgfplotsset{/pgfplots/contour/handler}%
+ \tikz@plot@handler
+ %
+ \def\pgfplotsplothandlercontour@haspendingjump{0}%
+ \let\pgfplotsplothandlervisualizejump=\pgfplotsplothandlercontour@jump
+ %
+ \let\pgfplotsplothandlercontour@handler@start=\pgf@plotstreamstart
+ \let\pgfplotsplothandlercontour@lastcontour=\pgfutil@empty
+ \global\let\pgf@plotstreampoint=\pgfplotsplothandlercontour@streampoint
+ \global\let\pgf@plotstreamend=\pgfplotsplothandlercontour@streamend
+}%
+
+\def\pgfplotsplothandlercontour@jump{%
+ \def\pgfplotsplothandlercontour@haspendingjump{1}%
+}%
+
+\def\pgfplotsplothandlercontour@streamend{%
+ \ifx\pgfplotsplothandlercontour@lastcontour\pgfutil@empty
+ \else
+ %
+ \def\pgfplotsplothandlercontour@haspendingjump{0}% important! (this is a different case than a jump)
+ \pgfplotsplothandlercontour@finishcontourline
+ %
+ \ifpgfplotsplothandlercontour@filled
+ \if0\pgfplotsplothandlercontour@processed@outer
+ \pgfplotsplothandlercontour@stream@bbcontour
+ \pgfplotsplothandlercontour@finishcontourline
+ \fi
+ \fi
+ %
+ \ifpgfplotsplothandlercontour@labels
+ \scope[/pgfplots/contour/every contour label]
+ \let\pgfplots@restore@drawmodes=\relax% FIXME : necessary?
+ \pgfplotsapplistXlet\pgfplotsplothandlercontour@storedlabels@=\pgfplotsplothandlercontour@storedlabels
+ \pgfplotsapplistXnewempty\pgfplotsplothandlercontour@storedlabels
+ \expandafter\pgfplotsplothandlercontourplacelabels\pgfplotsplothandlercontour@storedlabels@\pgfplots@EOI
+ \endscope
+ \fi
+ \fi
+}%
+\def\pgfplotsplothandlercontour@check@bbcontour{%
+ \ifpgfplotsplothandlercontour@filled
+ \if0\pgfplotsplothandlercontour@processed@outer
+ \pgfplotscoordmath{meta}{if less than}
+ {\pgfplotsplothandlercontour@act@contour}
+ {\pgfplotsplothandlercontour@limits@low@meta}
+ {%
+ % TRUE!
+ \pgfplotsplothandlercontour@stream@bbcontour@inbetween
+ }{}%
+ \fi
+ \fi
+}%
+\def\pgfplotsplothandlercontour@stream@bbcontour@inbetween{%
+ \def\pgfplotsplothandlercontour@processed@outer{1}%
+}%
+
+\def\pgfplotsplothandlercontour@stream@bbcontour{%
+%\message{contour: processing OUTER data limit contour...}%
+ \def\pgfplotsplothandlercontour@haspendingjump{0}% important
+ %
+ % forbid labels:
+ \let\pgfplotsplothandlercontour@stream@bbcontour@oldlabelsetting=\pgfplotsplothandlercontour@handlesplinesegment
+ \def\pgfplotsplothandlercontour@handlesplinesegment##1##2##3{}%
+ %
+ \let\pgfplots@current@point@meta=\pgfplotsplothandlercontour@limits@low@meta
+ \pgfplotsplothandlercontour@streampoint{%
+ \pgfplotsplothandlerpointxyz
+ \pgfplotsplothandlercontour@limits@low@x
+ \pgfplotsplothandlercontour@limits@low@y
+ \pgfplotsplothandlercontour@limits@low@z
+ }%
+ \pgfplotsplothandlercontour@streampoint{%
+ \pgfplotsplothandlerpointxyz
+ \pgfplotsplothandlercontour@limits@high@x
+ \pgfplotsplothandlercontour@limits@low@y
+ \pgfplotsplothandlercontour@limits@low@z
+ }%
+ \pgfplotsplothandlercontour@streampoint{%
+ \pgfplotsplothandlerpointxyz
+ \pgfplotsplothandlercontour@limits@high@x
+ \pgfplotsplothandlercontour@limits@high@y
+ \pgfplotsplothandlercontour@limits@low@z
+ }%
+ \pgfplotsplothandlercontour@streampoint{%
+ \pgfplotsplothandlerpointxyz
+ \pgfplotsplothandlercontour@limits@low@x
+ \pgfplotsplothandlercontour@limits@high@y
+ \pgfplotsplothandlercontour@limits@low@z
+ }%
+ \pgfplotsplothandlercontour@streampoint{%
+ \pgfplotsplothandlerpointxyz
+ \pgfplotsplothandlercontour@limits@low@x
+ \pgfplotsplothandlercontour@limits@low@y
+ \pgfplotsplothandlercontour@limits@low@z
+ }%
+ \def\pgfplotsplothandlercontour@processed@outer{1}%
+ %
+ % restore labels:
+ \let\pgfplotsplothandlercontour@handlesplinesegment=\pgfplotsplothandlercontour@stream@bbcontour@oldlabelsetting
+}%
+\def\pgfplotsplothandlercontourplacelabels#1{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@EOI
+ \else
+ %
+ \pgfplotsplothandlercontourplacelabels@act#1\relax
+ %
+ \expandafter\pgfplotsplothandlercontourplacelabels
+ \fi
+}%
+\def\pgfplotsplothandlercontourplacelabels@act#1,#2;#3,#4;#5\relax{%
+ \begingroup
+ \def\pgfplots@current@point@meta{#5}%
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}%
+ %
+ \pgftransformlineattime{0.5}{\pgfqpoint{#1}{#2}}{\pgfqpoint{#3}{#4}}%
+ \pgfkeysvalueof{/pgfplots/contour/label node code/.@cmd}#5\pgfeov
+ \endgroup
+}%
+
+\def\pgfplotsplothandlercontour@streampoint#1{%
+ \pgf@process{#1}%
+ % remember point:
+ \edef\pgfplotsplothandlercontour@act@canvas{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ %
+ \let\pgfplotsplothandlercontour@act@contour=\pgfplots@current@point@meta
+ \ifx\pgfplotsplothandlercontour@act@contour\pgfutil@empty
+ % oh. No Z data!? That should not happen!
+ \pgfplotsplothandlercontour@empty@pointmeta@error
+ \fi
+ \ifx\pgfplotsplothandlercontour@lastcontour\pgfutil@empty
+ % oh. its the very first point.
+ \def\pgfplotsplothandlercontour@haspendingjump{0}% important! (this is a different case than a jump)
+ \pgfplotsplothandlercontour@preparenewcontourline
+ \else
+ \ifx\pgfplotsplothandlercontour@lastcontour\pgfplotsplothandlercontour@act@contour
+ % belongs to the same contour.
+ \if1\pgfplotsplothandlercontour@haspendingjump
+ \pgfplotsplothandlercontour@finishcontourline
+ \pgfplotsplothandlercontour@preparenewcontourline
+ \fi
+ \else
+ % oh, a new contour line.
+ \def\pgfplotsplothandlercontour@haspendingjump{0}% important! (this is a different case than a jump)
+ \pgfplotsplothandlercontour@finishcontourline
+ \pgfplotsplothandlercontour@check@bbcontour
+ \pgfplotsplothandlercontour@preparenewcontourline
+ \fi
+ \fi
+ %
+ %
+ % handle difference vector for label placement:
+ \ifx\pgfplotsplothandlercontour@lastcanvas\pgfutil@empty
+ \else
+ \pgfplotsplothandlercontour@handlesplinesegment
+ {\pgfplotsplothandlercontour@lastcanvas}
+ {\pgfplotsplothandlercontour@act@canvas}%
+ {\pgfplotsplothandlercontour@act@contour}%
+ \fi
+ %
+ \pgfplotsplothandlercontour@handler@streampoint{\pgfplotsplothandlercontour@act@canvas}%
+ \let\pgfplotsplothandlercontour@lastlastcanvas=\pgfplotsplothandlercontour@lastcanvas
+ \let\pgfplotsplothandlercontour@lastcanvas=\pgfplotsplothandlercontour@act@canvas
+ \let\pgfplotsplothandlercontour@lastcontour=\pgfplotsplothandlercontour@act@contour
+ %
+ \ifpgfplotsplothandlercontour@filled
+ \t@pgfplots@toka=\expandafter{\expandafter{\pgfplotsplothandlercontour@act@canvas}}%
+ \expandafter\pgfplotsapplistXpushback\expandafter\pgf@plotstreampoint\the\t@pgfplots@toka
+ \to\pgfplotsplothandlercontour@stored@lastcontourpath
+ \fi
+ %
+ \ifx\pgf@plotstreampoint\pgfplotsplothandlercontour@streampoint
+ \else
+ \let\pgfplotsplothandlercontour@handler@streampoint=\pgf@plotstreampoint
+ \fi
+ \global\let\pgf@plotstreampoint=\pgfplotsplothandlercontour@streampoint
+ \global\let\pgf@plotstreamend=\pgfplotsplothandlercontour@streamend
+ % ATTENTION : if the low level plot handler introduces extra
+ % levels of scopes, this *will* fail!
+}%
+
+%
+% #1 : source
+% #2 : target
+% #3 : contour value
+\def\pgfplotsplothandlercontour@handlesplinesegment@forlabels#1#2#3{%
+ #2%
+ \pgf@xb=\pgf@x
+ \pgf@yb=\pgf@y
+ #1%
+ \pgf@xc=\pgf@x
+ \pgf@yc=\pgf@y
+ \pgfpointdiff
+ {\pgf@x=\pgf@xc \pgf@y=\pgf@yc}
+ {\pgf@x=\pgf@xb \pgf@y=\pgf@yb}%
+ \edef\pgfplots@loc@TMPa{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}%
+ \expandafter\pgfmath@basic@veclen@\pgfplots@loc@TMPa
+ \pgf@xa=\pgfmathresult pt
+ %
+ \advance\pgf@xa by\pgfplotsplothandlercontour@len\relax
+ \edef\pgfplotsplothandlercontour@len{\the\pgf@xa}%
+%\message{contour(\pgfplotsplothandlercontour@act@contour): cur len=\pgfplotsplothandlercontour@len > \pgfplotsplothandlercontour@labeldist ? [segment from #1--#2];}%
+ \ifdim\pgf@xa>\pgfplotsplothandlercontour@labeldist\relax
+ \def\pgfplotsplothandlercontour@haslabel{1}%
+ \edef\pgfplots@loc@TMPa{{\the\pgf@xc,\the\pgf@yc;\the\pgf@xb,\the\pgf@yb;{#3}}}%
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPa}\to\pgfplotsplothandlercontour@storedlabels
+ \advance\pgf@xa by-\pgfplotsplothandlercontour@labeldist\relax
+ \edef\pgfplotsplothandlercontour@len{\the\pgf@xa\relax}%
+ \fi
+}%
+
+% #1: the transformed point meta of the last contour.
+\def\pgfplotsplothandlercontour@filled@assert@is@sorted#1{%
+ \ifx\pgfplotsplothandlercontour@lastcontour\pgfutil@empty
+ \else
+ \ifx\pgfplotsplothandlercontour@sequence@sort@cmp\pgfutil@empty
+ % we need to determine the sorting:
+ \pgfplotscoordmath{float}{if less than}{\pgfplotsplothandlercontour@lastcontour}{\pgfplots@current@point@meta}{%
+ \def\pgfplotsplothandlercontour@sequence@sort@cmp{+}%
+ }{%
+ \pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@meta}{\pgfplotsplothandlercontour@lastcontour}{%
+ \def\pgfplotsplothandlercontour@sequence@sort@cmp{-}%
+ }{%
+ % undecided - the contours have the same label.
+ }%
+ }%
+ \else
+ \if +\pgfplotsplothandlercontour@sequence@sort@cmp
+ \pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@meta}{\pgfplotsplothandlercontour@lastcontour}{%
+ \pgfplotsplothandlercontour@filled@assert@is@sorted@fail{ASCENDING}%
+ }{%
+ }%
+ \else
+ \pgfplotscoordmath{float}{if less than}{\pgfplotsplothandlercontour@lastcontour}{\pgfplots@current@point@meta}{%
+ \pgfplotsplothandlercontour@filled@assert@is@sorted@fail{DESCENDING}%
+ }{%
+ }%
+ \fi
+ \fi
+ \fi
+}%
+\def\pgfplotsplothandlercontour@filled@assert@is@sorted@fail#1{%
+ \begingroup
+ \pgfplotscoordmath{float}{tostring}{\pgfplots@current@point@meta}%
+ \let\offending=\pgfmathresult
+ \pgfplotscoordmath{float}{tostring}{\pgfplotsplothandlercontour@lastcontour}%
+ \let\lastcontour=\pgfmathresult
+ \pgfplots@error{Sorry, filled contours implicitly assume that the contour levels are SORTED (in the given case, they appear to be sorted in #1 order). Please make sure your input data has sorted contour levels. The offending level is \offending; the previous contour level is \lastcontour}%
+ \endgroup
+}
+\def\pgfplotsplothandlercontour@preparenewcontourline{%
+ \if0\pgfplotsplothandlercontour@haspendingjump
+%\message{PREPARE NEW CONTOUR LEVEL (\pgfplots@current@point@meta).}%
+ % a completely new level has been
+ % started, not due to jumps inside of one level.
+ %
+ \let\pgfplotspointmetatransformed@lastcontour=\pgfplotspointmetatransformed
+ % thus, we need to compute 'mapped color':
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}%
+ \pgfsetstrokecolor{\pgfkeysvalueof{/pgfplots/contour/draw color}}%
+ \ifpgfplotsplothandlercontour@filled
+ \pgfplotsplothandlercontour@filled@assert@is@sorted{\pgfplotspointmetatransformed@lastcontour}%
+ \pgfsetfillcolor{\pgfkeysvalueof{/pgfplots/contour/fill color}}%
+ \fi
+ %
+ % furthermore, we need to handle the 'filled' style:
+ \ifpgfplotsplothandlercontour@filled
+ \pgfplotsapplistXlet\pgfplotsplothandlercontour@stored@lastcontourpath@=\pgfplotsplothandlercontour@stored@lastcontourpath
+ % flush:
+ \pgfplotsapplistXnewempty\pgfplotsplothandlercontour@stored@lastcontourpath
+ %
+ % process it:
+ \ifx\pgfplotsplothandlercontour@stored@lastcontourpath@\pgfutil@empty
+ % oh. This here is the very first contour. Nothing to do!
+ \else
+ % ok. This here is the i'th contour level, i>0.
+ % Thus, we have the 'i-1'th contour stored.
+ % REPLICATE its path to fill the space between the (i-1)'th contour and the i'th one!
+ \let\pgf@plotstreamstart=\pgfplotsplothandlercontour@handler@start
+ \pgf@plotstreamstart
+ \pgfplotsplothandlercontour@stored@lastcontourpath@
+ \pgf@plotstreamend
+ \fi
+ \fi
+ \else
+%\message{PREPARE NEW CONTOUR for the already begun level \pgfplots@current@point@meta.}%
+ \ifpgfplotsplothandlercontour@filled
+ \pgfplotsapplistXpushback\pgf@plotstreamstart\to\pgfplotsplothandlercontour@stored@lastcontourpath
+ \fi
+ \fi
+ %
+ \let\pgfplotsplothandlercontour@lastcanvas=\pgfutil@empty
+ \let\pgfplotsplothandlercontour@lastlastcanvas=\pgfutil@empty
+ \ifpgfplotsplothandlercontour@labels
+ \def\pgfplotsplothandlercontour@haslabel{0}%
+ %
+ % this here means that 20% of labeldist are already there.
+ % it moves the first label nearer to its start.
+ \pgf@xa=\pgfplotsplothandlercontour@labeldist\relax
+ \pgf@xa=0.2\pgf@xa
+ \edef\pgfplotsplothandlercontour@len{\the\pgf@xa}%
+ \fi
+ \def\pgfplotsplothandlercontour@haspendingjump{0}%
+ %
+ \pgfplotsplothandlercontour@handler@start
+ \let\pgfplotsplothandlercontour@handler@end=\pgf@plotstreamend
+ \let\pgfplotsplothandlercontour@handler@streampoint=\pgf@plotstreampoint
+}%
+\def\pgfplotsplothandlercontour@finishcontourline{%
+ \ifpgfplotsplothandlercontour@labels
+ \if0\pgfplotsplothandlercontour@haslabel
+ \ifx\pgfplotsplothandlercontour@lastlastcanvas\pgfutil@empty
+ \else
+ % force a label:
+%\message{FORCING A LABEL for contour \pgfplotsplothandlercontour@lastcontour\space from (\pgfplotsplothandlercontour@lastlastcanvas --\pgfplotsplothandlercontour@lastcanvas)}%
+ \edef\pgfplotsplothandlercontour@len{\pgfplotsplothandlercontour@labeldist}%
+ \pgfplotsplothandlercontour@handlesplinesegment
+ {\pgfplotsplothandlercontour@lastlastcanvas}
+ {\pgfplotsplothandlercontour@lastcanvas}%
+ {\pgfplotsplothandlercontour@lastcontour}%
+ \fi
+ \fi
+ \fi
+ \pgfplotsplothandlercontour@handler@end
+ %
+% \ifpgfplotsplothandlercontour@filled
+% \pgfpathclose % FIXME this is, in general, not good enough.
+% \fi
+ \if0\pgfplotsplothandlercontour@haspendingjump
+%\message{usepath{} to finalize level \pgfplotsplothandlercontour@lastcontour.}%
+ % flush paths if the complete contour level is ready.
+ % do *not* flush paths if we have just a new part of the
+ % existing contour level.
+ %
+ % This makes a difference for the filled contour.
+ \ifpgfplotsplothandlercontour@filled
+ \pgfusepath{fill,stroke}%
+ \else
+ \pgfusepath{stroke}%
+ \fi
+ \else
+%\message{usepath{} for level \pgfplotsplothandlercontour@lastcontour.}%
+ \ifpgfplotsplothandlercontour@filled
+ \pgfplotsapplistXpushback\pgf@plotstreamend\to\pgfplotsplothandlercontour@stored@lastcontourpath
+ \fi
+ \fi
+}%
+
+\def\pgfplotsplothandlercontour@init@limits{%
+ \def\pgfplotsplothandlercontour@processed@outer{0}%
+ \let\pgfplotsplothandlercontour@limits@low@meta=\pgfutil@empty
+ \let\pgfplotsplothandlercontour@limits@low@x=\pgfutil@empty
+ \let\pgfplotsplothandlercontour@limits@low@y=\pgfutil@empty
+ \let\pgfplotsplothandlercontour@limits@low@z=\pgfutil@empty
+ \let\pgfplotsplothandlercontour@limits@high@meta=\pgfutil@empty
+ \let\pgfplotsplothandlercontour@limits@high@x=\pgfutil@empty
+ \let\pgfplotsplothandlercontour@limits@high@y=\pgfutil@empty
+ \let\pgfplotsplothandlercontour@limits@high@z=\pgfutil@empty
+ %
+ \pgfkeysgetvalue{/pgfplots/contour/data limits}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \def\pgfplotsplothandlercontour@processed@outer{1}%
+ \else
+ \expandafter\pgfplotsplothandlercontour@init@limits@getboundingboxlow\pgfplots@loc@TMPa\pgfplots@EOI
+ \fi
+%\message{contour: I processed data limits to MIN = (\pgfplotsplothandlercontour@limits@low@x,\pgfplotsplothandlercontour@limits@low@y,\pgfplotsplothandlercontour@limits@low@z;\pgfplotsplothandlercontour@limits@low@meta) and MAX = (\pgfplotsplothandlercontour@limits@high@x,\pgfplotsplothandlercontour@limits@high@y,\pgfplotsplothandlercontour@limits@high@z;\pgfplotsplothandlercontour@limits@high@meta).}%
+}%
+\def\pgfplotsplothandlercontour@init@limits@getboundingboxlow(#1,#2,#3,#4){%
+ \def\pgfplotsplothandlercontour@init@limits@cur{low}%
+ \pgfplotsplothandlercontour@init@limits@read(#1,#2,#3,#4)%
+ \pgfutil@ifnextchar(%
+ \pgfplotsplothandlercontour@init@limits@getboundingboxhigh
+ {\pgfplots@error{Sorry, 'data limits=(xmin,ymin,zmin,contourmin) (xmax,ymax,zmax,contourmax)' has been expected, not \pgfkeysvalueof{/pgfplots/contour/data limits}}\pgfplots@gobble@until@EOI}%
+}%
+\def\pgfplotsplothandlercontour@init@limits@getboundingboxhigh(#1,#2,#3,#4){%
+ \def\pgfplotsplothandlercontour@init@limits@cur{high}%
+ \pgfplotsplothandlercontour@init@limits@read(#1,#2,#3,#4)%
+ \pgfutil@gobble
+}%
+\def\pgfplotsplothandlercontour@init@limits@read(#1,#2,#3,#4){%
+ % FIXME : logs and trafos and user interface!
+ \pgfplotscoordmath{x}{parsenumber}{#1}%
+ \pgfplotscoordmath{x}{datascaletrafo}\pgfmathresult
+ \expandafter\let\csname pgfplotsplothandlercontour@limits@\pgfplotsplothandlercontour@init@limits@cur @x\endcsname=\pgfmathresult
+ %
+ \pgfplotscoordmath{y}{parsenumber}{#2}%
+ \pgfplotscoordmath{y}{datascaletrafo}\pgfmathresult
+ \expandafter\let\csname pgfplotsplothandlercontour@limits@\pgfplotsplothandlercontour@init@limits@cur @y\endcsname=\pgfmathresult
+ %
+ \ifpgfplots@curplot@threedim
+ \pgfplotscoordmath{z}{parsenumber}{#3}%
+ \pgfplotscoordmath{z}{datascaletrafo}\pgfmathresult
+ \expandafter\let\csname pgfplotsplothandlercontour@limits@\pgfplotsplothandlercontour@init@limits@cur @z\endcsname=\pgfmathresult
+ \fi
+ %
+ \pgfplotscoordmath{meta}{parsenumber}{#4}%
+ \expandafter\let\csname pgfplotsplothandlercontour@limits@\pgfplotsplothandlercontour@init@limits@cur @meta\endcsname=\pgfmathresult
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% contour external implementation
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\pgfplotsplothandlercontourexternal{%
+ \pgfplotsresetplothandler
+ \def\pgfplotsplothandlername{contour external}%
+ %
+ \pgfplotsplothandlercontour@prepare@point@meta
+ %
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@contourexternal
+ \def\pgf@plotstreamstart{%
+ \pgfplotsplothandlercontourprepared
+ \pgf@plotstreamstart
+ }%
+}%
+\gdef\c@pgfplotsplothandlersurveystart@contourexternal@fileno{0}%
+\def\pgfplotsplothandlersurveystart@contourexternal{%
+ %
+ \pgfkeysgetvalue{/pgfplots/contour external/file}\pgfplotsplothandlercontourexternal@file
+ %
+ \ifx\pgfplotsplothandlercontourexternal@file\pgfutil@empty
+ \pgfutil@ifundefined{pgfactualjobname}{%
+ \let\pgfplots@loc@TMPa=\jobname
+ }{%
+ % be compatible with external lib:
+ \let\pgfplots@loc@TMPa=\pgfactualjobname
+ }%
+ \edef\pgfplotsplothandlercontourexternal@file{\pgfplots@loc@TMPa_contourtmp\c@pgfplotsplothandlersurveystart@contourexternal@fileno}%
+ \pgfplotsutil@advancestringcounter@global\c@pgfplotsplothandlersurveystart@contourexternal@fileno
+ \fi
+ %
+ \if0\pgfplotsplothandlercontourexternal@scanlinemode
+ \pgfplotsset{plot to file/scanline marks/false}%
+ \else
+ \pgfplotsset{plot to file/scanline marks/if in input}% the choice 'always' is unaware of existing end-of-scanline marks
+ \fi
+ \pgfplotsplothandlertofile{\pgfplotsplothandlercontourexternal@file.dat}%
+ \pgfplotsplothandlersurveystart
+ \let\pgfplotsplothandlersurveypoint@tofile=\pgfplotsplothandlersurveypoint
+ \let\pgfplotsplothandlersurveyend@tofile=\pgfplotsplothandlersurveyend
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@contourexternal
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@contourexternal
+ %
+ \pgfplotsplothandlersurveypoint@contour@prepare@axes x%
+ \pgfplotsplothandlersurveypoint@contour@prepare@axes y%
+ \pgfplotsplothandlersurveypoint@contour@prepare@axes z%
+}%
+
+% #1: either x, y, or z
+% POSTCONDITION:
+% The following three macros are defined:
+% \pgfplotsplothandlersurveypoint@contour@set@axes@x
+% \pgfplotsplothandlersurveypoint@contour@set@axes@y
+% \pgfplotsplothandlersurveypoint@contour@set@axes@z
+% they take no arguments and assign their result to \pgfmathresult.
+\def\pgfplotsplothandlersurveypoint@contour@prepare@axes#1{%
+ \expandafter\edef\csname pgfplotsplothandlersurveypoint@contour@set@axes@#1\endcsname{%
+ \noexpand\let\noexpand\pgfmathresult=\expandafter\noexpand\csname pgfplots@current@point@\csname pgfplotsplothandlercontour@axis@#1\endcsname\endcsname
+ }%
+ \expandafter\edef\csname pgfplotsplothandlersurveypoint@contour@set@axes@@#1\endcsname{%
+ \noexpand\let\noexpand\pgfmathresult=\expandafter\noexpand\csname pgfplots@current@point@\csname pgfplotsplothandlercontour@axis@inv@#1\endcsname\endcsname
+ }%
+ %
+%\message{axes #1: STD -> \expandafter\meaning\csname pgfplotsplothandlersurveypoint@contour@set@axes@#1\endcsname^^J}%
+%\message{axes #1: INV -> \expandafter\meaning\csname pgfplotsplothandlersurveypoint@contour@set@axes@@#1\endcsname^^J}%
+}
+
+\def\pgfplotsplothandlersurveypoint@contour@axes@reordered@to@std{%
+ \pgfplotsplothandlersurveypoint@contour@set@axes@@x
+ \let\pgfplotsplothandlersurveypoint@contour@set@axes@x@=\pgfmathresult
+ %
+ \pgfplotsplothandlersurveypoint@contour@set@axes@@y
+ \let\pgfplotsplothandlersurveypoint@contour@set@axes@y@=\pgfmathresult
+ %
+ \pgfplotsplothandlersurveypoint@contour@set@axes@@z
+ \let\pgfplotsplothandlersurveypoint@contour@set@axes@z@=\pgfmathresult
+ %
+ \let\pgfplots@current@point@x=\pgfplotsplothandlersurveypoint@contour@set@axes@x@
+ \let\pgfplots@current@point@y=\pgfplotsplothandlersurveypoint@contour@set@axes@y@
+ \let\pgfplots@current@point@z=\pgfplotsplothandlersurveypoint@contour@set@axes@z@
+}%
+\def\pgfplotsplothandlersurveypoint@contour@axes@std@to@reordered{%
+ \pgfplotsplothandlersurveypoint@contour@set@axes@x
+ \let\pgfplotsplothandlersurveypoint@contour@set@axes@x@=\pgfmathresult
+ %
+ \pgfplotsplothandlersurveypoint@contour@set@axes@y
+ \let\pgfplotsplothandlersurveypoint@contour@set@axes@y@=\pgfmathresult
+ %
+ \pgfplotsplothandlersurveypoint@contour@set@axes@z
+ \let\pgfplotsplothandlersurveypoint@contour@set@axes@z@=\pgfmathresult
+ %
+ \let\pgfplots@current@point@x=\pgfplotsplothandlersurveypoint@contour@set@axes@x@
+ \let\pgfplots@current@point@y=\pgfplotsplothandlersurveypoint@contour@set@axes@y@
+ \let\pgfplots@current@point@z=\pgfplotsplothandlersurveypoint@contour@set@axes@z@
+}%
+
+\def\pgfplotsplothandlersurveypoint@contourexternal{%
+ % temporarily disable updates to point meta limits. They should be
+ % updated during the contour prepared processing.
+ \let\pgfplotsplothandlercontourexternal@orig@perpointlimits@limits=\pgfplots@set@perpointmeta@limits
+ \let\pgfplots@set@perpointmeta@limits=\relax
+ %
+ \pgfplotsaxissurveysetpointmeta
+ \let\pgfplots@current@point@z=\pgfplots@current@point@meta
+ %
+ \let\pgfplots@set@perpointmeta@limits=\pgfplotsplothandlercontourexternal@orig@perpointlimits@limits
+ %
+ \pgfplotsplothandlersurveypoint@contour@axes@std@to@reordered
+ %
+%\message{contour gnuplot: collecting point (\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z) [\pgfplots@current@point@meta]...}%
+ \pgfplotsplothandlersurveypoint@tofile
+}%
+
+{
+\catcode`\`=12
+\catcode`\'=12
+\catcode`\"=12
+\catcode`\|=12
+\catcode`\;=12
+\catcode`\:=12
+\catcode`\#=12
+\gdef\pgfplotsplothandlersurveyend@contourexternal{%
+ \pgfplotsplothandlersurveyend@tofile
+ \if2\pgfplotsplothandlercontourexternal@scanlinemode
+ \if0\pgfplotsplothandlertofilegeneratedscanlinemarks
+ \pgfplots@error{Sorry, processing the input stream did not lead to end-of-scanline markers; the generated temporary file for 'contour external' does not contain any of them (indicating that matrix structure is lost). To fix this, you have the following options:^^J - Insert end-of-scanline markers into your input data (i.e. empty lines),^^J - provide two of the three options 'mesh/rows=<num matrix rows>, mesh/cols=<num matrix cols>, mesh/num points=<total number points>'}%
+ \fi
+ \fi
+ %
+ \begingroup
+ \let\numcoords=\pgfplots@current@point@coordindex%
+ \pgfplotsautocompletemeshkeys
+ \def\"{"}%
+ \def\|{|}%
+ \def\;{;}%
+ \def\:{:}%
+ \def\#{#}%
+ \def\'{'}%
+ \def\`{`}%
+ \edef\ordering{\pgfplots@plot@mesh@ordering}%
+ \edef\infile{\pgfplotsplothandlercontourexternal@file.dat}%
+ \edef\outfile{\pgfplotsplothandlercontourexternal@file.table}%
+ \edef\script{\pgfplotsplothandlercontourexternal@file.\pgfkeysvalueof{/pgfplots/contour external/script extension}}%
+ \edef\thecontourlevels{\pgfkeysvalueof{/pgfplots/contour/levels}}%
+ \edef\thecontournumber{\pgfkeysvalueof{/pgfplots/contour/number}}%
+ \immediate\openout\w@pgf@writea=\script
+ \immediate\write\w@pgf@writea{\pgfkeysvalueof{/pgfplots/contour external/script}}%
+ \immediate\closeout\w@pgf@writea
+ %
+ \pgfplots@shellescape{\pgfkeysvalueof{/pgfplots/contour external/cmd}}%
+ \endgroup
+ %
+ %
+ \pgfplotsplothandlercontourprepared
+ % the PREPARE steps in the coord stream start/end have already
+ % been done. we only need to init the plot handler survey
+ % start/end:
+ \def\pgfplots@coord@stream@start{\pgfplotsplothandlersurveystart}%
+ \def\pgfplots@coord@stream@end{\pgfplotsplothandlersurveyend}%
+ \pgfkeysgetvalue{/pgfplots/contour external/output point meta}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \ifpgfplots@curplot@threedim
+ \pgfplotssetpointmetainput{z}{}%
+ \else
+ \pgfplotssetpointmetainput{explicit}{}%
+ \fi
+ \else
+ \expandafter\pgfplots@pgfkeys@set@point@meta@value\expandafter{\pgfplots@loc@TMPa}%
+ \fi
+ \pgfplots@addplotimpl@file@streamit{\pgfplotsplothandlercontourexternal@file.table}%
+ \closein\r@pgfplots@reada
+}%
+}
+
+
+
+
+
+% the `plot unprocessed to file' plot handler simply copies the input data
+% UNPROCESSED to an output file.
+%
+% I use it as helper tool for `contour gnuplot'.
+%
+% this cannot be combined with other plot handlers unless the other
+% plot handlers controls that explicitly
+%
+% Immediately after the survey ends, this plot handler will set
+% \pgfplotsplothandlertofilegeneratedscanlinemarks to '1' or '0'.
+\pgfplotsset{
+ plot unprocessed to file/.code={
+ \edef\tikz@plot@handler{\noexpand\pgfplotsplothandlertofile{#1}}%
+ },
+ plot to file/scanline marks/.is choice,
+ plot to file/scanline marks/false/.code={\def\pgfplotsplothandlertofile@scanlinemarks{0}},
+ plot to file/scanline marks/if in input/.code={\def\pgfplotsplothandlertofile@scanlinemarks{1}},
+ plot to file/scanline marks/always/.code={\def\pgfplotsplothandlertofile@scanlinemarks{2}},
+ plot to file/scanline marks/true/.code={\def\pgfplotsplothandlertofile@scanlinemarks{2}},
+ plot to file/scanline marks/if in input,
+ plot to file/col sep/.initial=\pgfplots@SPACE,
+ plot to file/end-of-scanline content/.initial=,
+}
+
+\def\pgfplotsplothandlertofile#1{%
+ \edef\pgfplotsplothandlertofile@name{#1}%
+ \pgfplotsresetplothandler
+ \pgfplotsset{empty line=scanline}%
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@tofile
+ \def\pgfplotsplothandlername{plot to file}%
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@tofile
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@tofile
+ \let\pgfplotsplothandlernotifyscanlinecomplete=\pgfplotsplothandlernotifyscanlinecomplete@tofile
+ %
+ \if1\pgfplotsplothandlertofile@scanlinemarks
+ % plot to file/scanline marks=if in input
+ % check if we have mesh input:
+ \def\pgfplots@loc@TMP@has@mesh@information{0}%
+ \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplots@loc@TMPa
+ \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplots@loc@TMPb
+ \pgfkeysgetvalue{/pgfplots/mesh/num points}\pgfplots@loc@TMPc
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ \else
+ % has rows and num points:
+ \def\pgfplots@loc@TMP@has@mesh@information{1}%
+ \fi
+ \else
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ \else
+ % has cols and num points:
+ \def\pgfplots@loc@TMP@has@mesh@information{1}%
+ \fi
+ \else
+ % has rows,cols:
+ \def\pgfplots@loc@TMP@has@mesh@information{1}%
+ \fi
+ \fi
+ \if1\pgfplots@loc@TMP@has@mesh@information
+ % activate 'plot to file/scanline marks=always
+ % --> we have the required information!
+ \def\pgfplotsplothandlertofile@scanlinemarks{2}%
+ \fi
+ \fi
+ % NO \else here!
+ \if2\pgfplotsplothandlertofile@scanlinemarks
+ % plot to file/scanline marks=always
+ \pgfplotsautocompletemeshkeys%
+ \def\c@pgfplotsplothandlertofile@scanlinelength{0}%
+ \if\pgfplots@plot@mesh@ordering0%
+ % ordering = x varies= rowwise -> scanline is cols!
+ \pgfkeysgetvalue{/pgfplots/mesh/cols}\c@pgfplotsplothandlertofile@expectedscanline
+ \else
+ % ordering = y varies = colwise: scanline is rows!
+ \pgfkeysgetvalue{/pgfplots/mesh/rows}\c@pgfplotsplothandlertofile@expectedscanline
+ \fi
+ \fi
+ \pgfplotsplothandlertofile@scanlinependingfalse
+ \pgfkeysgetvalue{/pgfplots/plot to file/col sep}\pgfplotsplothandlertofile@colsep
+ \pgfkeysgetvalue{/pgfplots/plot to file/end-of-scanline content}\pgfplotsplothandlertofile@scanlinemark
+ %
+ %
+ \def\pgfplotsplothandlertofilegeneratedscanlinemarks{0}%
+}%
+\def\pgfplotsplothandlertofile@scanlinemarks@check{%
+ \if2\pgfplotsplothandlertofile@scanlinemarks
+ % plot to file/scanline marks=always
+ \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlertofile@scanlinelength
+ \ifnum\c@pgfplotsplothandlertofile@scanlinelength=\c@pgfplotsplothandlertofile@expectedscanline
+ \def\c@pgfplotsplothandlertofile@scanlinelength{0}%
+ \pgfplotsplothandlernotifyscanlinecomplete@tofile
+ \fi
+ \fi
+}%
+\newif\ifpgfplotsplothandlertofile@scanlinepending
+\def\pgfplotsplothandlernotifyscanlinecomplete@tofile{%
+ \if0\pgfplotsplothandlertofile@scanlinemarks
+ \else
+ \pgfplotsplothandlertofile@scanlinependingtrue
+ \fi
+}%
+\def\pgfplotsplothandlersurveypoint@tofile{%
+ \ifpgfplotsplothandlertofile@scanlinepending
+ \def\pgfplotsplothandlertofilegeneratedscanlinemarks{1}%
+ \immediate\write\w@pgf@writea{\pgfplotsplothandlertofile@scanlinemark}% end-of-scanline
+ \pgfplotsplothandlertofile@scanlinependingfalse
+ \fi
+ \pgfplotscoordmath{x}{parsenumber}{\pgfplots@current@point@x}%
+ \pgfplotscoordmath{x}{tostring}{\pgfmathresult}%
+ \let\pgfplots@current@point@x=\pgfmathresult
+ %
+ \pgfplotscoordmath{y}{parsenumber}{\pgfplots@current@point@y}%
+ \pgfplotscoordmath{y}{tostring}{\pgfmathresult}%
+ \let\pgfplots@current@point@y=\pgfmathresult
+ %
+ \ifpgfplots@curplot@threedim
+ \pgfplotscoordmath{z}{parsenumber}{\pgfplots@current@point@z}%
+ \pgfplotscoordmath{z}{tostring}{\pgfmathresult}%
+ \let\pgfplots@current@point@z=\pgfmathresult
+ \fi
+ %
+ \pgfplotsaxissurveysetpointmeta
+ \pgfplotsaxisifhaspointmeta{%
+ \pgfplotscoordmath{meta}{tostring}{\pgfplots@current@point@meta}%
+ \let\pgfplots@current@point@meta=\pgfmathresult
+ }{}%
+ %
+ \immediate\write\w@pgf@writea{%
+ \pgfplots@current@point@x\pgfplotsplothandlertofile@colsep
+ \pgfplots@current@point@y\pgfplotsplothandlertofile@colsep
+ \ifpgfplots@curplot@threedim\pgfplots@current@point@z\pgfplotsplothandlertofile@colsep\fi
+ \pgfplots@current@point@meta
+ }%
+ \advance\c@pgfplots@coordindex by1
+ \pgfplotsplothandlertofile@scanlinemarks@check
+}%
+\def\pgfplotsplothandlersurveyend@tofile{%
+ \immediate\closeout\w@pgf@writea
+}%
+\def\pgfplotsplothandlersurveystart@tofile{%
+ \immediate\openout\w@pgf@writea=\pgfplotsplothandlertofile@name\relax
+}%
+
+
+\input pgfplotsmeshplothandler.code.tex
+%
+%--------------------------------------------
+
+
+% Implementation of 'contour filled': it is actually just a small
+% wrapper around 'surf,shader=interp,colormap access=const' -- with
+% dedicated color map definitions.
+\def\pgfplotsplothandlercontourfilled{%
+ \pgfplotsplothandlermesh
+ \let\pgfplotsplothandlersurveyend@contourfilled@orig=\pgfplotsplothandlersurveyend
+ \def\pgfplotsplothandlersurveyend{%
+ \pgfplotsplothandlersurveyend@contourfilled@orig
+ \pgfplotsplothandlersurveyend@contourfilled
+ }%
+}%
+
+\def\pgfplotscontourfilledcolormap{internal:contourfilled}
+\pgfplotscreatecolormap{\pgfplotscontourfilledcolormap}{color=(black) color=(black)}
+
+\def\pgfplotsplothandlersurveyend@contourfilled{%
+ \pgfplotsplothandlersurveyaddoptions{
+ % ensure that the point meta of the contour makes its way into
+ % the colorbar and the associated color mapping.
+ %
+ % FIXME: that fails if there are more than one contours in the
+ % same axis (or someone else uses 'colorbar source')
+ colorbar source,%
+ %
+ % ensure that other plots to not "corrupt" our mapping:
+ point meta rel=per plot,%
+ }%
+ \def\pgfplots@contour@cm@options{%
+ colorbar style={%
+ /pgfplots/colormap access=const,
+ },%
+ }%
+ %
+ \pgfkeysgetvalue{/pgfplots/contour/levels}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % no levels.
+ % Ok, check the other keys in the order of precedence:
+ \pgfkeysgetvalue{/pgfplots/contour/levels from colormap}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % no 'levels from colormap'.
+ % Ok, check the other keys in the order of precedence:
+ \pgfkeysgetvalue{/pgfplots/contour/number}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % not sure if this is a use-case...
+ \pgfplots@log3{contour plot: skipping definition of suitable colormap (none of 'number', levels', 'levels from colormap' is set)}%
+ \t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}%
+ \edef\pgfplots@contour@cm@options{%
+ \the\t@pgfplots@toka%
+ % just copy the current colormap to ensure that it
+ % has the correct name:
+ colormap={\pgfplotscontourfilledcolormap}{of colormap={}},%
+ }%
+ \else
+ % Ah -- we have a number of samples!
+ \t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}%
+ \edef\pgfplots@contour@cm@options{%
+ \the\t@pgfplots@toka%
+ colormap={\pgfplotscontourfilledcolormap}{samples of colormap={\pgfplots@loc@TMPa}},%
+ }%
+ \fi
+ \else
+ % Ah - we want to take levels from a colormap definition!
+ % We only need to ensure that the colormap definition fits
+ % into the range [metamin:metamax]. Do that here:
+ \t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}%
+ \edef\pgfplots@contour@cm@options{%
+ \the\t@pgfplots@toka%
+ /utils/exec={%
+ \noexpand\edef\noexpand\pgfplots@targetpos@restore{%
+ of colormap/target pos min=\pgfkeysvalueof{/pgfplots/of colormap/target pos min},%
+ of colormap/target pos max=\pgfkeysvalueof{/pgfplots/of colormap/target pos max},%
+ of colormap/target pos min/insert=\ifpgfplots@createcolormap@target@pos@includes@limits@min true\else false\fi,%
+ of colormap/target pos max/insert=\ifpgfplots@createcolormap@target@pos@includes@limits@max true\else false\fi,%
+ \if c\pgfplots@ofcolorbar@sample@for@choice
+ of colormap/sample for=const,%
+ \else
+ of colormap/sample for=default,%
+ \fi
+ }%
+ },%
+ of colormap/target pos min*=\pgfplots@metamin,%
+ of colormap/target pos max*=\pgfplots@metamax,%
+ of colormap/sample for=const,%
+ colormap={\pgfplotscontourfilledcolormap}{%
+ \the\t@pgfplots@tokb
+ },%
+ /utils/exec={%
+ \noexpand\expandafter
+ \noexpand\pgfkeysalso
+ \noexpand\expandafter{\noexpand\pgfplots@targetpos@restore}%
+ },%
+ }%
+ \fi
+ \else
+ % Ah - we have a list of positions for the contours!
+ \t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}%
+ \edef\pgfplots@contour@cm@options{%
+ \the\t@pgfplots@toka%
+ colormap={\pgfplotscontourfilledcolormap}{%
+ of colormap={%
+ target pos min*=\pgfplots@metamin,
+ target pos max*=\pgfplots@metamax,
+ sample for=const,%
+ target pos={\pgfplots@loc@TMPa},
+ }%
+ },%
+ }%
+ \fi
+ %
+ \ifx\pgfplots@contour@cm@options\pgfutil@empty
+ \else
+ % move to "late options" such that we carry them outside of
+ % any \begingroup...\endgroup constructions:
+ \expandafter\pgfplotssetlateoptions\expandafter{\pgfplots@contour@cm@options}%
+%\message{contour filled: assembled options \meaning\pgfplots@contour@cm@options^^J}%
+ \fi
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsstackedplots.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsstackedplots.code.tex
new file mode 100644
index 0000000000..7f45bfb5be
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsstackedplots.code.tex
@@ -0,0 +1,688 @@
+%--------------------------------------------
+%
+% 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-2013 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 contains the implementation for stacked plots.
+%
+% Stacked plots always keep record of the last plotted coordinates.
+% Any new plot will be ADDED on top of the last plotted coordinates.
+%
+% Terminology: "last plotted coordinates" are called "zero levels"
+% because they actually work like shifts.
+%
+% Programming Structure:
+%
+% 1. We keep TWO lists of coordinates: a list of CURRENT zero level
+% coordinates and a list of NEXT zero level coordinates.
+%
+% The first one will be queried whenever a zero level coordinate is
+% requested.
+%
+% The second one will be used to form zero levels for the next plot.
+%
+% 2. At the beginning and end of the survey phase of each plot, the lists in 1.) are
+% initialised properly.
+%
+% 3.1 While plot coordinates are processed during the survey phase, the following methods
+% interact with the stacked API:
+% \pgfplots@stacked@preparepoint@inmacro
+% -> compute the 'stacked' sum.
+% This may need to be done with floating point arithmetics because
+% the data scaling trafo is not yet initialised
+% \pgfplots@stacked@rememberzerolevelpoint@for@next@plot
+% \pgfplots@stacked@getnextzerolevelpoint
+%
+%
+% 3.2 during the final visualization phase, we have
+% \pgfplots@stacked@visphasepreparedatapoint
+% -> takes coordinates as they will be given to Tikz. This method is
+% used to
+% - communicate zero level coordinates to Tikz
+% - implement the 'closed paths' option (allows filled stacked plots).
+%
+% 4. Zero levels are communicated to Tikz by
+% \pgfplots@stacked@initzerolevelhandler. This routine initialises an
+% input stream for Tikz plot handlers which produces a sequence of
+% zero levels. It is used by [xy]comb and [xy]bar.
+%
+%
+
+\let\pgfplots@stacked@zerolevelpoint@x=\pgfutil@empty
+\let\pgfplots@stacked@zerolevelpoint@y=\pgfutil@empty
+
+% this value is populated during the survey phase. It will be copied
+% to the visualization phase, i.e. it will be serialized along with
+% the survey'ed state:
+\newif\ifpgfplots@stacked@isfirstplot
+\newif\ifpgfplots@stacked@isinitialised
+
+% Pre-initialisation.
+% 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
+}%
+
+% Cleanup method. Truncates any global variables to reduce string
+% space.
+\def\pgfplots@stacked@finalize{%
+ \global\pgfplotslistnewempty\pgfplots@stacked@zerolevellist
+ \global\pgfplotslistnewempty\pgfplots@stacked@zerolevellist@neg
+ \global\pgfplotslistnewempty\pgfplots@stacked@nextzerolevellist@pos
+ \global\pgfplotslistnewempty\pgfplots@stacked@nextzerolevellist@neg
+ \pgfplots@stacked@isinitialisedfalse
+}%
+
+% (Re)defines the macro \pgfplots@stacked@getnextzerolevelpoint
+% at the beginning of each plot.
+%
+% The macro \pgfplots@stacked@getnextzerolevelpoint fills
+% \pgfplots@stacked@zerolevelpoint@[xy].
+%
+% ATTENTION: call \pgfplots@stacked@initialise before the first call
+% of beginplot!
+%
+% ATTENTION: install this before 'visualization depends on' - it
+% modifies \pgfplotsaxisserializedatapoint@private
+\def\pgfplots@stacked@beginplot{%
+%\message{pgfplots@stacked@beginplot: PLOT STARTED.}%
+ \ifpgfplots@stacked@isinitialised
+ \else
+ \pgfplots@error{LOGIC ERROR: please call \string\pgfplots@stacked@initialise.}%
+ \fi
+ \def\pgfplots@stacked@zerolevel@current{}%
+ \def\pgfplots@stacked@zerolevel@current@pos{}%
+ \def\pgfplots@stacked@zerolevel@current@neg{}%
+ \pgfplots@stacked@prepare@value@serialization
+ % accumulate this command here for \closedcycle:
+ \ifpgfplots@stacked@isfirstplot
+ \global\pgfplotslistnewempty\pgfplots@stacked@zerolevellist
+ \global\pgfplotslistnewempty\pgfplots@stacked@zerolevellist@neg
+ % only work with float if its really necessary - for
+ % example if the scaling trafo which maps to pgfmath is
+ % not yet initialised.
+ \pgfplots@stacked@zerolevel@fallback x%
+ \pgfplots@stacked@zerolevel@fallback y%
+ \pgfplots@stacked@zerolevel@fallback z%
+ %
+ \def\pgfplots@stacked@getnextzerolevelpoint{%
+ % keep \pgfplots@stacked@zerolevel@current = {}
+ % there is special handling in place which will use the
+ % '0' level in this case
+ %
+ % omit this:
+ %\pgfplots@stacked@ensure{}%
+ %\let\pgfplots@stacked@zerolevel@current=\pgfplotsretval
+ }%
+ \else
+ {\globaldefs=1
+ \pgfplotslistcopy\pgfplots@stacked@nextzerolevellist@pos\to\pgfplots@stacked@zerolevellist
+ \pgfplotslistcopy\pgfplots@stacked@nextzerolevellist@neg\to\pgfplots@stacked@zerolevellist@neg
+ }%
+ \def\pgfplots@stacked@getnextzerolevelpoint{%
+ %
+ \pgfplots@stacked@getnextzerolevelpoint@pos
+ %
+ \if P\pgfplots@stacked@negative@mode
+ % stack negative=on previous:
+ % just use one list in order to remember the
+ % zerolevel:
+ \expandafter\pgfplots@stacked@parsezerolevelpoint\expandafter{\pgfplots@stacked@zerolevel@current@pos}%
+ \else
+ % stack negative=separate:
+ % use two levels, one for '+' and one for '-':
+ \pgfplots@stacked@getnextzerolevelpoint@neg
+ %
+ \if+\pgfplots@stacked@sign
+ \expandafter\pgfplots@stacked@parsezerolevelpoint\expandafter{\pgfplots@stacked@zerolevel@current@pos}%
+ \else
+ \expandafter\pgfplots@stacked@parsezerolevelpoint\expandafter{\pgfplots@stacked@zerolevel@current@neg}%
+ \fi
+ \fi
+ }%
+ \fi
+ \global\pgfplotslistnewempty\pgfplots@stacked@nextzerolevellist@pos
+ \global\pgfplotslistnewempty\pgfplots@stacked@nextzerolevellist@neg
+}%
+
+\def\pgfplots@stacked@getnextzerolevelpoint@pos{%
+ \pgfplotslistcheckempty\pgfplots@stacked@zerolevellist
+ \ifpgfplotslistempty
+ \pgfplots@stacked@wrong@count@error
+ \else
+ {\globaldefs=1
+ \pgfplotslistpopfront\pgfplots@stacked@zerolevellist\to\pgfplots@stacked@zerolevel@current@pos
+ }%
+ \fi
+}%
+\def\pgfplots@stacked@getnextzerolevelpoint@neg{%
+ \pgfplotslistcheckempty\pgfplots@stacked@zerolevellist@neg
+ \ifpgfplotslistempty
+ \pgfplots@stacked@wrong@count@error
+ \else
+ {\globaldefs=1
+ \pgfplotslistpopfront\pgfplots@stacked@zerolevellist@neg\to\pgfplots@stacked@zerolevel@current@neg
+ }%
+ \fi
+}
+
+\def\pgfplots@stacked@zerolevel@fallback#1{%
+ \pgfplots@stacked@zerolevel@fallback@{#1}%
+ \expandafter\let\csname pgfplots@stacked@zerolevelpoint@#1\endcsname=\pgfmathresult%
+}%
+\def\pgfplots@stacked@zerolevel@fallback@#1{%
+ \ifpgfplots@datascaletrafo@initialised % FIXME : should be '!ifsurvey'
+ \def\pgfmathresult{0}%
+ \else
+ % note that log plots are special: their "stacked zero" is
+ % computed with \pgfplotscoordmath{default}
+ %
+ \pgfplots@if{pgfplots@#1islinear}{\pgfplotscoordmath{#1}{zero}}{\pgfplotscoordmath{default}{zero}}%
+ \fi
+}%
+
+% ATTENTION: install this before 'visualization depends on' - it
+% modifies \pgfplotsaxisserializedatapoint@private
+\def\pgfplots@stacked@visphase@beginplot{%
+%\message{pgfplots@stacked@beginplot: VISUALIZATION OF PLOT STARTED (phase = \pgfplots@visphase@name).^^J}%
+ \let\pgfplots@stacked@closedcycle@impl=\pgfutil@empty
+ \pgfplots@stacked@prepare@value@serialization
+}%
+
+\def\pgfplots@stacked@prepare@value@serialization{%
+ % This here is SIMILAR to 'visualization depends on'.
+ %
+ % The only difference is that 'visualization depends on' expands
+ % its arguments whereas this one here does not.
+ %
+ \pgfplotsset{%
+ visualization depends on=value \pgfplots@stacked@diff\as\pgfplots@stacked@diff
+ }%
+ %
+ %
+ % Modify the axis private parts such that a data point is
+ % serialized to the form
+ % {Z{<stacked zerolevel value>}{<point meta>};<x coordinate>,<y coordinate>,<z coordinate>}
+ %
+ % for example, a 2d data pont (0,1) without point meta is serialized to
+ % {Z{}{};0Y0.0e0],1Y1.0e0],}
+ %
+ % The deserialization looks for the magic token 'Z'. The next
+ % parameter is the zero level of the data point, the following one
+ % the "old" private serialization stuff (typically just point
+ % meta).
+ %
+ % Note that the zero level of a data point might have its own zero
+ % level (grand father) ... this would be part here as well, even
+ % if it is useless (?). This causes recursive references to all
+ % zero levels... and more memory for stacked plots.
+ %
+ % The zero'th level has an empty zero level point.
+ \expandafter\def\expandafter\pgfplotsaxisserializedatapoint@private\expandafter{%
+ \pgfplotsaxisserializedatapoint@private
+ % at deserialization time, this will become \pgfplots@stacked@zerolevel :
+ \t@pgfplots@toka=\expandafter{\pgfplots@stacked@zerolevel@current}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsretval}%
+ \edef\pgfplotsretval{%
+ Z{\the\t@pgfplots@toka}%
+ {\the\t@pgfplots@tokb}%
+ }%
+ }%
+ %
+ \pgfutil@ifundefined{pgfplotsaxisdeserializedatapointfrom@private@backup@}{}{%
+ \pgfplots@error{Illegal internal state encountered: the stacked plots serialization preparation has been invoked twice}%
+ }%
+ \let\pgfplotsaxisdeserializedatapointfrom@private@backup@=\pgfplotsaxisdeserializedatapointfrom@private
+ \def\pgfplotsaxisdeserializedatapointfrom@private##1{%
+ \pgfplotsaxisdeserializedatapointfrom@private@stacked@##1%
+ }%
+}%
+
+\def\pgfplotsaxisdeserializedatapointfrom@private@stacked@ Z#1#2{%
+ \def\pgfplots@stacked@zerolevel{#1}%
+ \pgfplotsaxisdeserializedatapointfrom@private@backup@{#2}%
+}%
+
+% #1: the result of \pgfplotsaxisserializedatapointtostring
+\def\pgfplots@stacked@parsezerolevelpoint#1{%
+ \begingroup
+ \pgfplotsaxisdeserializedatapointfrom#1% no braces here!
+% \pgfplotsplothandlerdeserializepointfrom{#1}%
+ \pgfplots@stacked@smuggle
+ \endgroup
+ % the value of \pgfplots@stacked@zerolevel@current will be configured as
+ % "visualization depends on".
+ % In other words: it is available later-on.
+ \def\pgfplots@stacked@zerolevel@current{#1}%
+}
+
+\def\pgfplots@stacked@smuggle\endgroup{%
+ \xdef\pgfplots@glob@TMPb{%
+ \noexpand\def\noexpand\pgfplots@stacked@zerolevelpoint@x{\pgfplots@current@point@x}%
+ \noexpand\def\noexpand\pgfplots@stacked@zerolevelpoint@y{\pgfplots@current@point@y}%
+ \noexpand\def\noexpand\pgfplots@stacked@zerolevelpoint@z{\pgfplots@current@point@z}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPb
+}%
+
+\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@survey@endplot{%
+%\message{Stacked plot survey phase end: isfirst = \ifpgfplots@stacked@isfirstplot true \else false\fi^^J}%
+ \ifpgfplots@stacked@isfirstplot
+ \pgfplotslistcheckempty\pgfplots@stacked@zerolevellist
+ \ifpgfplotslistempty
+ \else
+ \pgfplots@stacked@wrong@count@error
+ \fi
+ \if P\pgfplots@stacked@negative@mode
+ % stack negative=on previous:
+ \else
+ % stack negative=separate:
+ \pgfplotslistcheckempty\pgfplots@stacked@zerolevellist@neg
+ \ifpgfplotslistempty
+ \else
+ \pgfplots@stacked@wrong@count@error
+ \fi
+ \fi
+ \fi
+ \ifpgfplots@stacked@isfirstplot
+ \def\pgfplots@stacked@serialized@commands{\noexpand\pgfplots@stacked@isfirstplottrue}%
+ \else
+ \def\pgfplots@stacked@serialized@commands{\noexpand\pgfplots@stacked@isfirstplotfalse}%
+ \fi
+ \global\pgfplots@stacked@isfirstplotfalse
+}%
+
+\def\pgfplots@stacked@visphase@endplot{%
+%\message{Stacked plot vis phase end: isfirst = \ifpgfplots@stacked@isfirstplot true \else false\fi^^J}%
+ \ifpgfplots@stacked@isfirstplot
+ \let\pgfplots@stacked@closedcycle@impl=\pgfplots@path@closed@cycle@std
+ \else
+ \t@pgfplots@tokc=\expandafter{\pgfplots@stacked@closedcycle@impl}%
+ \edef\pgfplots@stacked@closedcycle@impl{%
+ [mark=none,/utils/exec=\noexpand\pgfplots@try@mirror@plot@handler]
+ --plot coordinates{\the\t@pgfplots@tokc}
+ --cycle
+ }%
+ \fi
+ \global\pgfplots@stacked@isfirstplotfalse
+}%
+
+% WARNING: when this method is called, NEITHER
+% \ifpgfplots@stacked@isfirstplot NOR the zero level lists are
+% initialised!
+\def\pgfplots@stacked@initzerolevelhandler{%
+ \if\pgfplots@stacked@dir x
+ \pgfplotxzerolevelstream@@list
+ \pgfplotyzerolevelstreamconstant{\pgfplots@ZERO@y}%
+ \else
+ \pgfplotxzerolevelstreamconstant{\pgfplots@ZERO@x}%
+ \pgfplotyzerolevelstream@@list
+ \fi
+}%
+
+% Provides public access to zero levels into some key-value pairs.
+% Returns the values into a set of keys in the /data point/ prefix.
+%
+% The values can be used in 'axis cs'.
+\def\pgfplotspointgetzerolevelcoordinates{%
+ \pgfplotspointgetnormalizedzerolevelcoordinates
+ \pgfplotspointgetcoordinatesfromnormalized[path=/data point/zero]%
+ \pgfplotspointgetcoordinatesfromnormalized[path=/data point/diff]%
+}
+
+% Same as \pgfplotsgetzerolevelcoordinates, but the resulting values
+% are for use in 'normalized axis cs'.
+%
+% This works for both stacked plots and normal plots.
+\def\pgfplotspointgetnormalizedzerolevelcoordinates{%
+ \begingroup
+ \ifpgfplots@stackedmode
+ % STATE:
+ % * \pgfplots@stacked@diff is the diff of the CURRENT point.
+ % * \pgfplots@stacked@zerolevel is the ENTIRE point of the
+ % zerolevel (consisting of its recursive zerolevel, its own diff, and its x,y coords)
+ % -> we need both
+ \let\pgfplots@stacked@diff@cur=\pgfplots@stacked@diff
+ \ifx\pgfplots@stacked@zerolevel\pgfutil@empty
+ \pgfplotspointgetnormalizedcoordinates%
+ \pgfplotsutilforeachcommasep{x,y,z}\as\pgfplots@loc@TMPa{%
+ \pgfkeysgetvalue{/data point/\pgfplots@loc@TMPa}\pgfplots@loc@TMPb
+ \expandafter\let\csname pgfplots@current@point@\pgfplots@loc@TMPa\endcsname=\pgfplots@loc@TMPb
+ }%
+ \pgfplotscoordmath{\pgfplots@stacked@dir}{zero}%
+ \expandafter\let\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname\pgfmathresult%
+ %
+ \let\pgfplots@current@point@meta=\pgfutil@empty
+ \pgfkeyssetvalue{/data point/zero/auto}{1}%
+ \else
+ %
+ \expandafter\pgfplotsaxisdeserializedatapointfrom\pgfplots@stacked@zerolevel%
+ \pgfkeyssetvalue{/data point/zero/auto}{0}%
+ \fi
+ %
+ \pgfplotscoordmath{x}{zero}\let\pgfplots@stacked@diff@x=\pgfmathresult%
+ \pgfplotscoordmath{y}{zero}\let\pgfplots@stacked@diff@y=\pgfmathresult%
+ \pgfplotscoordmath{z}{zero}\let\pgfplots@stacked@diff@z=\pgfmathresult%
+ \pgfutil@namelet{pgfplots@stacked@diff@\pgfplots@stacked@dir}{pgfplots@stacked@diff@cur}%
+ \else
+ % Ah - no stacked plot!? Well, than do "something useful":
+ % ... note that we have to use 'pgfbasic' here as that is the
+ % "transformed" format.
+ \pgfplotscoordmath{pgfbasic}{zero}\let\pgfplots@current@point@x=\pgfmathresult%
+ \pgfplotscoordmath{pgfbasic}{zero}\let\pgfplots@current@point@y=\pgfmathresult%
+ \pgfplotscoordmath{pgfbasic}{zero}\let\pgfplots@current@point@z=\pgfmathresult%
+ %
+ \pgfplotspointgetnormalizedcoordinates%
+ \pgfplotsutilforeachcommasep{x,y,z}\as\pgfplots@loc@TMPa{%
+ \pgfkeysgetvalue{/data point/\pgfplots@loc@TMPa}\pgfplots@loc@TMPb
+ \expandafter\let\csname pgfplots@stacked@diff@\pgfplots@loc@TMPa\endcsname=\pgfplots@loc@TMPb
+ }%
+ \pgfkeyssetvalue{/data point/zero/auto}{1}%
+ \fi
+ %
+ \xdef\pgfplots@glob@TMPd{%
+ \noexpand\pgfkeyssetvalue{/data point/zero/x}{\pgfplots@current@point@x}%
+ \noexpand\pgfkeyssetvalue{/data point/zero/y}{\pgfplots@current@point@y}%
+ \noexpand\pgfkeyssetvalue{/data point/zero/z}{\pgfplots@current@point@z}%
+ \noexpand\pgfkeyssetvalue{/data point/zero/meta}{\pgfplots@current@point@meta}%
+ \noexpand\pgfkeyssetvalue{/data point/zero/auto}{\pgfkeysvalueof{/data point/zero/auto}}%
+ \noexpand\pgfkeyssetvalue{/data point/diff/x}{\pgfplots@stacked@diff@x}%
+ \noexpand\pgfkeyssetvalue{/data point/diff/y}{\pgfplots@stacked@diff@y}%
+ \noexpand\pgfkeyssetvalue{/data point/diff/z}{\pgfplots@stacked@diff@z}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPd
+%
+%\message{pgfplotsgetzerolevelcoordinates returned x=\pgfkeysvalueof{/data point/zero/x}, y=\pgfkeysvalueof{/data point/zero/y}, diffx=\pgfkeysvalueof{/data point/diff/x}; diffy=\pgfkeysvalueof{/data point/diff/y}, diff=\pgfkeysvalueof{/data point/diff}^^J}%
+}%
+
+% PRECONDITION:
+% Is in invoked inside of a coord preparation routine, that means
+% - \pgfplots@current@point@[xyz]
+% - \ifpgfplots@curplot@threedim
+% are all set properly.
+%
+% POSTCONDITION:
+% - the zero level macro is set (for use in the visualizer)
+% - the closed cycle impl is updated
+% - the points as such are NOT touched
+\def\pgfplots@stacked@visphasepreparedatapoint{%
+ \ifx\pgfplots@stacked@zerolevel\pgfutil@empty
+ % this here is the case if we have the first encountered plot,
+ % i.e. the one on which others are stacked.
+ %
+ % Note that it is not necessarily the first one which is
+ % processed (compare reverse stacked plots).
+ \begingroup
+ % FIXME : eliminate this special handling by recording the
+ % correct '0' values during the survey phase!
+ \pgfutil@namelet{pgfplots@current@point@\pgfplots@stacked@dir}{pgfplots@logical@ZERO@\pgfplots@stacked@dir}%
+ \pgfplotsaxis@toPGF@coords
+ \if\pgfplots@stacked@dir x
+ \edef\pgfplots@stacked@PGF@zerolevel{\the\pgf@x}%
+ \else
+ \edef\pgfplots@stacked@PGF@zerolevel{\the\pgf@y}%
+ \fi
+ \pgfmath@smuggleone\pgfplots@stacked@PGF@zerolevel
+ \endgroup
+ %
+ \else
+ \begingroup
+ %\expandafter\pgfplotsplothandlerdeserializepointfrom\expandafter{\pgfplots@stacked@zerolevel}%
+ \expandafter\pgfplotsaxisdeserializedatapointfrom\pgfplots@stacked@zerolevel%
+ %
+ \pgfplots@stacked@logarithm@if@needed
+ %
+ % avoid endless recursion:
+ \let\pgfplots@stacked@visphasepreparedatapoint=\relax
+ \pgfplotsaxisvisphasegetpoint
+ \edef\pgfplots@current@point@x{\the\pgf@x}%
+ \edef\pgfplots@current@point@y{\the\pgf@y}%
+ % this here merely communicates
+ % \pgfplots@stacked@zerolevelpoint@x and @y outside of the
+ % group:
+ \pgfplots@stacked@smuggle
+ \endgroup
+ %
+ \if\pgfplots@stacked@dir x
+ \let\pgfplots@stacked@PGF@zerolevel=\pgfplots@stacked@zerolevelpoint@x%
+ \else
+ \let\pgfplots@stacked@PGF@zerolevel=\pgfplots@stacked@zerolevelpoint@y%
+ \fi
+ \t@pgfplots@toka=\expandafter{\pgfplots@stacked@closedcycle@impl}%
+ \edef\pgfplots@stacked@closedcycle@impl{%
+ (\pgfplots@stacked@zerolevelpoint@x,\pgfplots@stacked@zerolevelpoint@y)%
+ \the\t@pgfplots@toka}%
+ \fi
+}%
+
+% A special hook which is executed early in the visualization phase.
+% It will be invoked *before*
+% \pgfplots@stacked@visphasepreparedatapoint!
+%
+% Its purpose is to clear the data if necessary, i.e. it implements
+% /pgfplots/stacked ignores zero
+\def\pgfplots@stacked@visphase@stream@coord@{%
+ \ifpgfplots@stacked@ignores@zero
+ \edef\pgfplots@loc@TMPa{\pgfkeysvalueof{/pgfplots/stacked ignores zero/\pgfplots@visphase@name}}%
+ \def\pgfplots@loc@TMPb{true}%
+ % apply this feature only if it is active for the current
+ % visualization phase:
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \ifx\pgfplots@current@point@x\pgfutil@empty% this implements `unbounded coords=jump', for example
+ \else
+ \pgfplotscoordmath{\pgfplots@stacked@dir}{if is}{\pgfplots@stacked@diff}{0}{%
+ \let\pgfplots@current@point@x=\pgfutil@empty
+ \let\pgfplots@current@point@y=\pgfutil@empty
+ \let\pgfplots@current@point@z=\pgfutil@empty
+ }{%
+ }%
+ \fi
+ \fi
+ \fi
+}%
+
+% PRECONDITION:
+% Is in invoked inside of a coord preparation routine, that means
+% - \pgfplots@current@point@[xyz]
+% - \ifpgfplots@curplot@threedim
+% are all set properly.
+%
+% POSTCONDITION:
+% - \pgfplots@current@point@[xyz] are adjusted.
+\def\pgfplots@stacked@preparepoint@inmacro{%
+ \ifpgfplots@stacked@plus
+ \def\pgfplots@stacked@op{add}%
+ \else
+ \def\pgfplots@stacked@op{subtract}%
+ \fi
+ %
+ \pgfutil@namelet{pgfplots@stacked@diff}{pgfplots@current@point@\pgfplots@stacked@dir}%
+ %
+ \pgfmathfloatparsenumber{\pgfplots@stacked@diff}%
+ \expandafter\pgfmathfloatifflags\expandafter{\pgfmathresult}{2}{%
+ \def\pgfplots@stacked@sign{-}%
+ }{%
+ \def\pgfplots@stacked@sign{+}%
+ }%
+ \pgfplots@stacked@getnextzerolevelpoint
+ %
+ %
+ \pgfplots@if{pgfplots@\pgfplots@stacked@dir islinear}{%
+ \pgfplotscoordmath{\pgfplots@stacked@dir}{op}{\pgfplots@stacked@op}{%
+ {\csname pgfplots@stacked@zerolevelpoint@\pgfplots@stacked@dir\endcsname}%
+ {\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname}}%
+ }{%
+ % LOG. we need to compute log(zerolevel + current):
+ % FIXME : this might work, but is is hackery - because the
+ % coordmath framework handles log bases in a very stupid way.
+ % improve it somehow!
+ \edef\pgfmathresult{\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname}%
+ \pgfplotscoordmath{\pgfplots@stacked@dir}{exp}{\pgfmathresult}%
+ \pgfplotscoordmath{default}{parsenumber}{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{\pgfplots@stacked@op}{%
+ {\csname pgfplots@stacked@zerolevelpoint@\pgfplots@stacked@dir\endcsname}%
+ {\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname}%
+ }%
+ }%
+ %
+ % for logs, I remember just zerolevel+current; not its log.
+ \expandafter\let\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname=\pgfmathresult
+ %
+ % this here would also be ok, but it would only store the coords
+ % of the zero level...
+ %\pgfplotsplothandlerserializepointto\pgfplotsretval
+ %
+ \begingroup
+ %
+ % without this line, the "zerolevel" would also know all its zero
+ % levels recursively:
+ \pgfplots@stacked@strip@parents@zerolevel
+ %
+ \pgfplotsaxisserializedatapointtostring
+ %
+%\message{Current value is '\pgfplots@stacked@sign'. Serializing: \meaning\pgfplotsretval^^J}%
+ \if P\pgfplots@stacked@negative@mode
+ % stack negative=on previous:
+ % just track one list
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotsretval}\to\pgfplots@stacked@nextzerolevellist@pos
+ \else
+ % stack negative=separate:
+ % keep track of both separate zerolevel lists:
+ \if+\pgfplots@stacked@sign
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotsretval}\to\pgfplots@stacked@nextzerolevellist@pos
+ %
+ \pgfplots@stacked@ensure\pgfplots@stacked@zerolevel@current@neg
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotsretval}\to\pgfplots@stacked@nextzerolevellist@neg
+ \else
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotsretval}\to\pgfplots@stacked@nextzerolevellist@neg
+ %
+ \pgfplots@stacked@ensure\pgfplots@stacked@zerolevel@current@pos
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotsretval}\to\pgfplots@stacked@nextzerolevellist@pos
+ \fi
+ \fi
+ %
+ \endgroup
+ %
+ %
+ %
+ \pgfplots@stacked@logarithm@if@needed
+}
+
+\def\pgfplots@stacked@ensure#1{%
+ \ifx#1\pgfutil@empty
+ \pgfplots@stacked@zerolevel@fallback@{\pgfplots@stacked@dir}%
+ \expandafter\let\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname=\pgfmathresult
+ \else
+ \expandafter\pgfplotsaxisdeserializedatapointfrom#1% no braces
+ \fi
+ \pgfplotsaxisserializedatapointtostring
+%\message{UNUSED value serialized as \meaning\pgfplotsretval^^J}%
+}%
+
+%
+% We store the normal values for zero levels. Consequently, we may
+% need to (re)apply the log if we have a log axis.
+%
+% I am unsure of whether log+stacked is useful at all.
+\def\pgfplots@stacked@logarithm@if@needed{%
+ \pgfplots@if{pgfplots@\pgfplots@stacked@dir islinear}{%
+ }{%
+ \pgfplotscoordmath{\pgfplots@stacked@dir}{log}{\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname}%
+ \expandafter\let\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname=\pgfmathresult
+ }%
+}%
+
+% you can \let this here to \relax if you want to gain access to all
+% zero levels recursively:
+\def\pgfplots@stacked@strip@parents@zerolevel{%
+ \def\pgfplots@stacked@zerolevel@current{}%
+}
+
+% This here is a re-implementation of the stored plot processing.
+%
+% The idea is simple, although it requires quite some work:
+%
+% If we stack plots on top of each other, early drawing commands
+% (early plots) will be OVERDRAWN by later drawing commands (later
+% plots). This is especially unfortunate if we use filled bar plots
+% or comb plots.
+%
+% IDEA: draw plots in REVERSE order. The positioning, styles and
+% whatever must not be affected, only the sequence of drawing commands
+% shall change.
+%
+% So, this command here reverses the list.
+\def\pgfplots@stacked@finalize@stored@plots{%
+ \pgfplotslistnewempty\pgfplots@stored@plotlist@reversed
+ \begingroup
+ \pgfplotslistforeachungrouped\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{%
+ % Reverse sequence:
+ \expandafter\pgfplotslistpushfront\pgfplots@loc@TMPa\to\pgfplots@stored@plotlist@reversed
+ }%
+ % Now, overwrite the original list:
+ \global\let\pgfplots@stored@plotlist=\pgfplots@stored@plotlist@reversed
+ \global\let\pgfplots@stored@plotlist@reversed=\relax
+ \endgroup
+}%
+
+\def\pgfplots@stacked@path@closed@cycle{%
+ \pgfplots@stacked@closedcycle@impl
+}
+
+% PGF interfaces:
+%
+% these are relatively simple right now: assuming that the zero-level
+% streams are advanced if and only if the coordinate streams are
+% advanced, we can simply inject the *currect* zero level rather than
+% providing all at once.
+\def\pgfplotxzerolevelstream@@list{%
+ \def\pgf@plotxzerolevelstreamstart{%
+ \gdef\pgf@plotxzerolevelstreamnext{%
+ \global\pgf@x=\pgfplots@stacked@PGF@zerolevel\relax
+ }%
+ }%
+ \def\pgf@plotxzerolevelstreamend{%
+ }%
+}%
+
+\def\pgfplotyzerolevelstream@@list{%
+ \def\pgf@plotyzerolevelstreamstart{%
+ \gdef\pgf@plotyzerolevelstreamnext{%
+ \global\pgf@x=\pgfplots@stacked@PGF@zerolevel\relax
+ }%
+ }%
+ \def\pgf@plotyzerolevelstreamend{%
+ }%
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotssysgeneric.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotssysgeneric.code.tex
new file mode 100644
index 0000000000..155e05d9ae
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotssysgeneric.code.tex
@@ -0,0 +1,84 @@
+%--------------------------------------------
+% 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/>.
+%
+%--------------------------------------------
+
+% NOTE: tex4ht support is lousy. For example, \tikz \node {$10^{-6}$};
+% will already break -- because SVG does not support the html tag
+% &minus; produced by tex4ht (and TikZ apparently does not know how to
+% escape it somehow).
+\def\pgfplots@sys@beforenode{%
+ \pgfkeysifdefined{/tikz/tex4ht node/escape/.@cmd}{%
+ \ifpgfplots@has@cell@picture
+ \tikzset{tex4ht node/escape=true}%
+ \pgfplots@warning{ATTENTION: you may want to use '\string\pgfplotsset{cell picture=false}' in your preamble. Otherwise, tex4ht will produce TWO SVG files per plot.^^J}%
+ \fi
+ }{}%
+}%
+
+% see compat/show suggested version
+\newif\ifpgfplots@show@suggested@version
+\pgfplots@show@suggested@versiontrue
+
+\def\pgfplots@show@suggested@compat@value{%
+ \ifpgfplots@show@suggested@version
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/compat/current}\current
+ \pgfkeysgetvalue{/pgfplots/compat/mostrecent}\mostrecent
+ %
+ \def\b@isnewest{0}%
+ \def\b@shouldupgrade{0}%
+ \ifx\current\mostrecent
+ \def\b@isnewest{1}%
+ \else
+ \def\pgfplots@loc@TMPa{newest}%
+ \ifx\current\pgfplots@loc@TMPa
+ \def\b@isnewest{1}%
+ \else
+ \expandafter\pgfplotsutilifstringequal\expandafter{\current}{pre 1.3}{%
+ \def\b@shouldupgrade{1}%
+ }{}%
+ \expandafter\pgfplotsutilifstringequal\expandafter{\current}{default}{%
+ \def\b@shouldupgrade{1}%
+ }{}%
+ \fi
+ \fi
+ \if1\b@isnewest
+ \pgfplots@message{Package pgfplots notification 'compat/show suggested version=true': document has been generated with the most recent feature set (\string\pgfplotsset{compat=\mostrecent}).^^J}%
+ \else
+ \if1\b@shouldupgrade
+ \pgfplots@warning{running in backwards compatibility mode (unsuitable tick labels; missing features). Consider writing \string\pgfplotsset{compat=\mostrecent} into your preamble.^^J}%
+ \else
+ \pgfplots@message{Package pgfplots notification 'compat/show suggested version=true': you might benefit from \string\pgfplotsset{compat=\mostrecent} (current compat level: \current).^^J}%
+ \fi
+ \fi
+ \endgroup
+ \fi
+}
+
+\pgfutil@IfUndefined{AtBeginDocument}{%
+}{%
+ \AtBeginDocument{%
+ \pgfplots@show@suggested@compat@value
+ }%
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.code.tex
new file mode 100644
index 0000000000..4e33bacd63
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.code.tex
@@ -0,0 +1,3014 @@
+%--------------------------------------------
+%
+% Package pgfplotstable
+%
+% Provides support to read and work with abstract numeric tables of the
+% form
+%
+% COLUMN1 COLUMN2 COLUMN3
+% 1 2 3
+% 4 4 552
+% 1e124 0.00001 1.2345e-12
+% ...
+%
+% Copyright 2007-2010 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 high-level table manipulation and typesetting
+% package.
+%
+% see pgfplotstableshared.code.tex for the low level routines.
+
+
+\newif\ifpgfplotstabletypesetdebug
+\newif\ifpgfplotstable@sort
+\newif\ifpgfplotstabletypesetskipcoltypes
+\newif\ifpgfplotstabletypesetresult
+\newif\ifpgfplotstableuserow
+\newif\ifpgfplotstabletypeset@includeoutfiles
+\newif\ifpgfplotstabletypeset@force@remake
+\newif\ifpgfplotstable@disable@rowcolstyles
+
+\let\pgfplotstable@outfile=\w@pgf@writea
+
+\input pgfplotstable.coltype.code.tex
+
+% #1= floating point number
+% #2= TeX code to execute if #1 == 0
+% #3= TeX code to execute if #1 != 0
+\def\pgfplots@ifzero#1#2#3{%
+ \expandafter\pgfmathfloat@decompose@F#1\relax\pgfmathfloat@a@S
+ \ifnum\pgfmathfloat@a@S=0 #2\else#3\fi
+}%
+
+% just make sure no-one complaints if manual example are used without
+% booktabs loaded:
+\pgfutil@IfUndefined{toprule}{%
+ \def\toprule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\toprule}}%
+ \def\midrule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\midrule}}%
+ \def\bottomrule{\pgfplots@assert@LaTeX@package@loaded{booktabs}{\string\bottomrule}}%
+}{\relax}%
+
+% keys which are NOT predefined:
+% /pgfplots/table/alias/<col alias>/.initial={<real col>}
+% /pgfplots/table/columns/<col name>/.style={}
+% /pgfplots/table/display columns/<col index>/.style={}
+% /pgfplots/table/create on use/<col name>/.style={create options}
+\pgfkeys{%
+ /pgfplots/table/disable rowcol styles/.is if=pgfplotstable@disable@rowcolstyles,
+ /pgfplots/table/disable rowcol styles/.default=true,
+ /pgfplots/table/row predicate/.code={},
+ /pgfplots/table/skip rows between index/.style 2 args={%
+ /pgfplots/table/row predicate/.append code={%
+ \ifnum##1<#1\relax
+ \else
+ \ifnum##1<#2\relax
+ \pgfplotstableuserowfalse
+ \fi
+ \fi}
+ },
+ /pgfplots/table/select equal part entry of/.style 2 args={%
+ /pgfplots/table/row predicate/.code={%
+ \pgfplotstableuserowtrue
+ \begingroup
+ % this group re-uses counters as temporary variables.
+ \c@pgfplotstable@colindex=\pgfplotstablerows\relax
+ \divide\c@pgfplotstable@colindex by#2\relax
+ \edef\pgfplotstablepartsize{\the\c@pgfplotstable@colindex}%
+ % This here should create empty cells such that
+ % remaining entries are distributed equally:
+ \c@pgfplotstable@rowindex=\c@pgfplotstable@colindex
+ \multiply\c@pgfplotstable@rowindex by#2\relax
+ \ifnum\c@pgfplotstable@rowindex<\pgfplotstablerows\relax
+ \c@pgfplotstable@colindex=\pgfplotstablerows\relax
+ \advance\c@pgfplotstable@colindex by-\c@pgfplotstable@rowindex
+ \advance\c@pgfplotstable@colindex by\pgfplotstablepartsize
+ \edef\pgfplotstablepartsize{\the\c@pgfplotstable@colindex}%
+ \fi
+ %
+ \multiply\c@pgfplotstable@colindex by#1\relax
+ \ifnum##1<\c@pgfplotstable@colindex\relax
+ \aftergroup\pgfplotstableuserowfalse
+ \else
+ \advance\c@pgfplotstable@colindex by\pgfplotstablepartsize\relax
+ \ifnum##1<\c@pgfplotstable@colindex\relax
+ \else
+ \aftergroup\pgfplotstableuserowfalse
+ \fi
+ \fi
+ \endgroup
+ }%
+ },
+ % #1: colname
+ /pgfplots/table/unique/.code={%
+ \pgfkeys{/pgfplots/table/row predicate/.append code={%
+ \ifnum\pgfplotstablerow=0
+ \ifnum\pgfplotstablecol=0
+ \pgfutil@ifundefined{pgfplotstable@unique@bitlist@backup}{%
+ }{%
+ \pgfplots@error{It seems there are *multiple* 'unique' keys running on one table. That doesn't work correctly, I guess. Consider using '\string\pgfplotstableset{row predicate/.code={}}' to reset it.}%
+ }%
+ % PREPARE ONCE! Assemble the boolean results into
+ % a list which is used for the complete table:
+ \def\pgfplotstable@loc@TMPd{\pgfplotstablegetcolumnfromstruct{#1}\of}%
+ \expandafter\pgfplotstable@loc@TMPd\pgfplotstablename\to\pgfplotstable@unique@col
+ \pgfplotslistnewempty\pgfplotstable@unique@bitlist
+ \let\pgfplotstable@unique@LAST=\pgfutil@empty
+ \pgfplotslistforeachungrouped\pgfplotstable@unique@col\as\pgfplotstable@unique@cur{%
+ \def\pgfplotstable@unique@bit{1}%
+ \ifx\pgfplotstable@unique@LAST\pgfutil@empty
+ \else
+ \ifx\pgfplotstable@unique@LAST\pgfplotstable@unique@cur
+ \def\pgfplotstable@unique@bit{0}%
+ \fi
+ \fi
+ \ifpgfplotstabletypesetdebug
+ \pgfplots@message{unique={#1}: cur == last <=> ( \pgfplotstable@unique@cur\space == \pgfplotstable@unique@LAST ) = \pgfplotstable@unique@bit.}%
+ \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
+ \pgfutil@ifundefined{pgfplotstable@unique@bitlist@backup}{%
+ % this sanity checking is NOT fool proof: it
+ % fails if there are different occurances of
+ % unique in the same file
+ \pgfplotsthrow{invalid argument}{Sorry, the row predicate /pgfplots/table/unique={#1} has been used in the wrong context: it needs to be invoked for the very first processed column, not column no \pgfplotstablecol. Please provide it as argument to \string\pgfplotstabletypeset[unique={#1}] and not inside of column-specific styles}\pgfeov%
+ }{}%
+ \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
+ % cleanup:
+ {%
+ \count0=\pgfplotstablecol\relax \advance\count0 by1
+ \ifnum\count0=\pgfplotstablecols\relax
+ \count0=\pgfplotstablerow\relax \advance\count0 by1
+ \ifnum\count0=\pgfplotstablerows\relax
+ \global\let\pgfplotstable@unique@bitlist@backup=\relax
+ \fi
+ \fi
+ }%
+ }}%
+ },%
+ % columns={name1,name2}
+ % or
+ % columns={[index]2,name2,name3,[index]5}
+ /pgfplots/table/columns/.initial=,
+ %
+ % this choice allows
+ % \pgfplotstableset{
+ % column name={}, % means: the column's display name is an empty string!
+ % column name=\pgfkeysnovalue, % means: no value specified. In this case,
+ % the column's display name will default to column's name.
+ % }
+ /pgfplots/table/column name/.initial=\pgfkeysnovalue,
+ %
+ % this thing here allows to MODIFY 'column name'.
+ %
+ % Argument #1 is the current column name, that means after
+ % evaluating 'column name'. If this key changes anything, it
+ % should write its result back into 'column name'.
+ %
+ % That means you can use 'column name' to assign the name as such
+ % and 'assign column name' to generate final TeX code (for example
+ % to insert \multicolumn{1}{c}{#1} or so).
+ % default is empty which means no change.
+ %/pgfplots/table/assign column name/.code={
+ % \pgfkeyssetvalue{/pgfplots/table/column name}{#1}%
+ %},
+ %
+ %
+ %
+ % A style which inserts \multicolumn{1}{#1}{<column name>} for
+ % each column name.
+ % The column name as such can be set with the 'column name' option.
+ /pgfplots/table/multicolumn names/.style={%
+ /pgfplots/table/assign column name/.code={%
+ \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{1}{#1}{##1}}%
+ }%
+ },
+ /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}%
+ \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,
+ %
+ % 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
+ \else
+ \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
+ \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
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
+ },
+ }%
+ },
+ /pgfplots/table/sci sep align/.default=c,
+ %
+ % A style which can be used together with the 'dcolumn' package by
+ % David Carlisle.
+ % #1: the dcolumn type, defaults to 'D{.}{.}{2}'
+ % #2: the column name type, defaults to 'c'
+ /pgfplots/table/dcolumn/.style 2 args={%
+ /pgf/number format/assume math mode,
+ column type={#1},
+ multicolumn names=#2,
+ },
+ /pgfplots/table/dcolumn/.default={D{.}{.}{2}}{c},
+ /pgfplots/table/column type/.initial={c},
+ /pgfplots/table/every even row/.style={},
+ /pgfplots/table/every odd row/.style={},
+ /pgfplots/table/every last row/.style={},
+ /pgfplots/table/every first row/.style={},
+ /pgfplots/table/every head row/.style={},
+ /pgfplots/table/every first column/.style={},
+ /pgfplots/table/every last column/.style={},
+ /pgfplots/table/every even column/.style={},
+ /pgfplots/table/every column/.style={},
+ /pgfplots/table/every odd column/.style={},
+ /pgfplots/table/every nth row/.code 2 args={%
+ \pgfplotstabletypeset@append@every@nth@row{#1}{#2}%
+ },
+ /pgfplots/table/every nth row/.style 2 args/.code 2 args={%
+ \pgfplotstabletypeset@append@every@nth@row{#1}{#2}%
+ },
+ /pgfplots/table/before row/.initial=,
+ /pgfplots/table/after row/.initial=,
+ /pgfplots/table/begin table/.initial={\begin{tabular}},
+ /pgfplots/table/end table/.initial={\end{tabular}},
+ /pgfplots/table/outfile/.initial=,
+ /pgfplots/table/include outfiles/.is if=pgfplotstabletypeset@includeoutfiles,
+ /pgfplots/table/include outfiles/.default=true,
+ /pgfplots/table/force remake/.is if=pgfplotstabletypeset@force@remake,
+ /pgfplots/table/force remake/.default=true,
+ /pgfplots/table/write to macro/.initial=,
+ /pgfplots/table/typeset/.is if=pgfplotstabletypesetresult,
+ /pgfplots/table/typeset=true,
+ /pgfplots/table/skip coltypes/.is if=pgfplotstabletypesetskipcoltypes,
+ /pgfplots/table/skip coltypes/.default=true,
+ /pgfplots/table/debug/.is if=pgfplotstabletypesetdebug,
+ /pgfplots/table/debug level/.initial=0,%
+ %
+ % will be redefined by |assign cell content| for every cell:
+ /pgfplots/table/@cell content/.initial=,
+ %
+ % #1: the cells content as it has been found in the input table
+ % this command key should somehow fill |cell content|.
+ /pgfplots/table/assign cell content/.code={%
+ \def\pgfmathresult{#1}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathprintnumberto{#1}\pgfmathresult%
+ \fi
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
+ },
+ %
+ % this here is the default formatting. It uses
+ % \pgfmathprintnumber.
+ /pgfplots/table/assign cell content as number/.code={%
+ \def\pgfmathresult{#1}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathprintnumberto{#1}\pgfmathresult%
+ \fi
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
+ },
+ /pgfplots/table/numeric type/.code={%
+ \pgfkeysgetvalue{/pgfplots/table/assign cell content as number/.@cmd}\pgfplotstable@loc@TMPa%
+ \pgfkeyslet{/pgfplots/table/assign cell content/.@cmd}\pgfplotstable@loc@TMPa
+ },
+ /pgfplots/table/string type/.style={%
+ /pgfplots/table/assign cell content/.style={%
+ /pgfplots/table/@cell content={##1}%
+ }%
+ },%
+ /pgfplots/table/verb string type/.style={%
+ /pgfplots/table/text special chars={\#,\|},% FIXME: too limited ...
+ /pgfplots/table/assign cell content/.code={%
+ \def\pgfplotstable@loc@TMPa{##1}%
+ % hm... this here might be more robust instead of the line
+ % above. But not much, I suppose:
+ %\t@pgfplotstable@a={##1}%
+ %\edef\pgfplotstable@loc@TMPa{\the\t@pgfplotstable@a}%
+ \pgfplots@command@to@string\pgfplotstable@loc@TMPa\pgfplotstable@loc@TMPa
+ \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplotstable@loc@TMPa}%
+ }%
+ },%
+ /pgfplots/table/numeric as string type/.style={%
+ /pgfplots/table/assign cell content/.code={%
+ \def\pgfmathresult{##1}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathifisint{##1}{\let\pgfmathresult=\pgfretval}{\pgfmathfloattosci{\pgfretval}}%
+ \fi
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
+ }%
+ },%
+ /pgfplots/table/date type/.style={%
+ /pgfplots/table/assign cell content/.code={%
+ \begingroup
+ \pgfcalendardatetojulian{##1}\c@pgfplotstable@counta
+ \pgfcalendarjuliantodate{\c@pgfplotstable@counta}\year\month\day
+ \pgfcalendarjuliantoweekday\c@pgfplotstable@counta\c@pgf@countc
+ \edef\weekday{\the\c@pgf@countc }%
+ \edef\weekdayname{\pgfcalendarweekdayname\c@pgf@countc}%
+ \edef\weekdayshortname{\pgfcalendarweekdayshortname\c@pgf@countc}%
+ \edef\monthname{\pgfcalendarmonthname\month}%
+ \edef\monthshortname{\pgfcalendarmonthshortname\month}%
+ \xdef\pgfplots@glob@TMPa{#1}%
+ \endgroup
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPa%
+ }%
+ },%
+ /pgfplots/table/date type/.default={\year/\month/\day},%
+ /pgfplots/table/set content/.style={%
+ /pgfplots/table/postproc cell content/.style={%
+ /pgfplots/table/@cell content={#1}%
+ }%
+ },%
+ %
+ /pgfplots/table/postproc cell content/.code={},
+ /pgfplots/table/preproc cell content/.code={},
+ %
+ /pgfplots/table/clear infinite/.style={%
+ /pgfplots/table/preproc cell content/.append code={%
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \let\pgfmatharga=\pgfmathresult
+ {%
+ \pgfmathfloatgetflags\pgfmatharga\c@pgfplotstable@counta
+ \xdef\pgfplots@glob@TMPc{\the\c@pgfplotstable@counta}%
+ }%
+ \ifnum\pgfplots@glob@TMPc<3
+ \pgfmathfloattosci@\pgfmathresult
+ \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
+ \else
+ \pgfkeyslet{/pgfplots/table/@cell content}{\pgfutil@empty}%
+ \fi
+ \fi
+ }
+ },
+ /pgfplots/table/string replace/.style 2 args={%
+ /pgfplots/table/preproc cell content/.append code={%
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfmathresult\pgfplots@loc@TMPa
+ \def\pgfplots@loc@TMPb{#2}%
+ \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplots@loc@TMPb}%
+ \fi
+ }
+ },
+ /pgfplots/table/string replace*/.style 2 args={%
+ /pgfplots/table/preproc cell content/.append code={%
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ \def\pgfplots@loc@TMPa{\pgfplotsutilstrreplace{#1}{#2}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
+ \pgfkeyslet{/pgfplots/table/@cell content}{\pgfplotsretval}%
+ }
+ },
+ /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
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \let\pgfmatharga=\pgfmathresult
+ \pgfmathfloatcreate{2}{1.0}{0}%
+ \let\pgfmathargb=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfmatharga}{\pgfmathargb}%
+ \pgfmathfloattosci@\pgfmathresult
+ \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
+ \fi
+ }
+ },
+ /pgfplots/table/multiply with/.style={/pgfplots/table/multiply by={#1}},%
+ /pgfplots/table/multiply by/.code={%
+ \pgfmathfloatparsenumber{#1}%
+ \let\pgfplotstable@scale=\pgfmathresult
+ \pgfkeysalso{
+ /pgfplots/table/preproc cell content/.append code={%
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \let\pgfmatharga=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfmatharga}{\pgfplotstable@scale}%
+ \pgfmathfloattosci@\pgfmathresult
+ \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
+ \fi
+ }%
+ }%
+ },
+ /pgfplots/table/divide by/.code={%
+ \pgfkeysalso{/pgfplots/table/multiply by=#1}%
+ \let\pgfplotstable@divisor=\pgfplotstable@scale
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \let\pgfplotstable@ONE=\pgfmathresult
+ \pgfmathfloatdivide@{\pgfplotstable@ONE}{\pgfplotstable@divisor}%
+ \let\pgfplotstable@scale=\pgfmathresult
+ },
+ /pgfplots/table/sqrt/.style={%
+ /pgfplots/table/preproc cell content/.append code={%
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \let\pgfmatharga=\pgfmathresult
+ \pgfmathfloatsqrt@{\pgfmatharga}%
+ \pgfmathfloattosci@\pgfmathresult
+ \pgfkeyslet{/pgfplots/table/@cell content}{\pgfmathresult}%
+ \fi
+ }%
+ },
+ /pgfplots/table/empty cells with/.style={%
+ /pgfplots/table/postproc cell content/.append code={%
+ \ifnum\pgfplotstablepartno=0
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}%
+ \fi
+ \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/.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%
+ },
+ /pgfplots/table/create col/assign last/.style={
+ /pgfplots/table/create col/assign%
+ },
+ /pgfplots/table/create col/assign/.style={
+ /pgfplots/table/create col/next content={}%
+ },
+ /pgfplots/table/create col/next content/.initial={},
+ /pgfplots/table/create col/copy/.style={%
+ /pgfplots/table/create col/assign/.code={%
+ \getthisrow{#1}\pgfmathresult
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ },
+ /pgfplots/table/create col/set/.style={%
+ /pgfplots/table/create col/assign/.code={%
+ \def\pgfmathresult{#1}%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ },%
+ /pgfplots/table/create col/set list/.code={%
+ \pgfplots@assign@list\pgfmathaccumb{#1}%
+ \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}%
+ },%
+ /pgfplots/table/create col/expr accum/.code 2 args={%
+ \ifpgfplots@usefpu
+ \pgfkeysalso{/pgf/fpu=true,/pgf/fpu/output format=sci}%
+ \fi
+ \pgfkeysdef{/pgfplots/table/create col/assign}{%
+ \ifx\pgfmathaccuma\pgfutil@empty
+ \pgfmathparse{#2}%
+ \let\pgfmathaccuma=\pgfmathresult
+ \fi
+ \pgfmathparse{#1}%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ \let\pgfmathaccuma=\pgfmathresult
+ }%
+ },
+ /pgfplots/table/create col/expr/.style={%
+ /pgfplots/table/create col/expr accum={#1}{0}%
+ },%
+ /pgfplots/table/create col/copy column from table/.code 2 args={%
+ \pgfplotstablegetcolumn{#2}\of{#1}\to\pgfmathaccumb
+ \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfmathaccumb}%
+ },
+ /pgfplots/table/create col/@from list struct/.code={%
+ \pgfplotslistcopy#1\to\pgfmathaccumb
+ \pgfkeysdef{/pgfplots/table/create col/assign}{%
+ \pgfplotslistcheckempty\pgfmathaccumb
+ \ifpgfplotslistempty
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ \else
+ \pgfplotslistpopfront\pgfmathaccumb\to\pgfmathresult
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ \fi
+ }%
+ },
+ /pgfplots/table/create col/linear regression/.code={%
+ \pgfplotstable@linear@regression{#1}%
+ \pgfkeysalso{/pgfplots/table/create col/@from list struct=\pgfplotsretval}%
+ },
+ /pgfplots/table/create col/linear regression/.default=,%
+ /pgfplots/table/create col/linear regression/x/.initial=,%
+ /pgfplots/table/create col/linear regression/y/.initial=,%
+ /pgfplots/table/create col/linear regression/table/.initial=,%
+ /pgfplots/table/create col/linear regression/variance/.initial=,%
+ /pgfplots/table/create col/linear regression/variance list/.initial=,%
+ /pgfplots/table/create col/linear regression/variance src/.initial=,%
+ /pgfplots/table/create col/linear regression/xmode/.initial=,% auto
+ /pgfplots/table/create col/linear regression/ymode/.initial=,% auto
+ /pgfplots/table/create col/quotient/.style={%
+ /pgfplots/table/columns={#1},
+ /pgfplots/table/create col/assign first/.style={%
+ /pgfplots/table/create col/next content=
+ },%
+ /pgfplots/table/create col/assign/.code={%
+ \pgfmathfloatparsenumber{\prevrow{#1}}%
+ \let\pgfmatharga=\pgfmathresult
+ \pgfmathfloatparsenumber{\thisrow{#1}}%
+ \let\pgfmathargb=\pgfmathresult
+ \let\pgfmathaccuma=\pgfmathargb
+ \pgfplots@ifzero\pgfmathargb{%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ }{%
+ \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}%
+ \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ }%
+ },%
+ /pgfplots/table/create col/iquotient/.style={%
+ /pgfplots/table/columns={#1},
+ /pgfplots/table/create col/assign first/.style={%
+ /pgfplots/table/create col/next content=
+ },%
+ /pgfplots/table/create col/assign/.code={%
+ \pgfmathfloatparsenumber{\prevrow{#1}}%
+ \let\pgfmathargb=\pgfmathresult
+ \pgfmathfloatparsenumber{\thisrow{#1}}%
+ \let\pgfmatharga=\pgfmathresult
+ \let\pgfmathaccuma=\pgfmathargb
+ \pgfplots@ifzero\pgfmathargb{%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ }{%
+ \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}%
+ \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ }%
+ },%
+ %
+ % Produces 'log2( \prevrow{#1}/\thisrow{#1} )
+ %
+ % Assumeing that every row contains error(h) = O(h^alpha)
+ % and h_this = h_prev/2, this result in 'alpha', the convergence
+ % rate.
+ /pgfplots/table/create col/dyadic refinement rate/.style={%
+ /pgfplots/table/columns={#1},
+ /pgfplots/table/create col/assign first/.style={%
+ /pgfplots/table/create col/next content=
+ },%
+ /pgfplots/table/create col/assign/.code={%
+ \pgfmathfloatparsenumber{\prevrow{#1}}%
+ \let\pgfmatharga=\pgfmathresult
+ \pgfmathfloatparsenumber{\thisrow{#1}}%
+ \let\pgfmathargb=\pgfmathresult
+ \let\pgfmathaccuma=\pgfmathargb
+ \pgfplots@ifzero\pgfmathargb{%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ }{%
+ \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}%
+ \pgfmathlog@float{\pgfmathresult}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathmultiply@{1.442695}{\pgfmathresult}%
+ \fi
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ }%
+ },%
+ /pgfplots/table/create col/idyadic refinement rate/.style={%
+ /pgfplots/table/columns={#1},
+ /pgfplots/table/create col/assign first/.style={%
+ /pgfplots/table/create col/next content=
+ },%
+ /pgfplots/table/create col/assign/.code={%
+ \pgfmathfloatparsenumber{\prevrow{#1}}%
+ \let\pgfmathargb=\pgfmathresult
+ \pgfmathfloatparsenumber{\thisrow{#1}}%
+ \let\pgfmatharga=\pgfmathresult
+ \let\pgfmathaccuma=\pgfmathargb
+ \pgfplots@ifzero\pgfmathargb{%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ }{%
+ \pgfmathfloatdivide@{\pgfmatharga}{\pgfmathargb}%
+ \pgfmathlog@float{\pgfmathresult}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathmultiply@{1.442695}{\pgfmathresult}%
+ \fi
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ }%
+ },%
+ /pgfplots/table/create col/gradient/.style 2 args={%
+ /pgfplots/table/columns={#1,#2},
+ /pgfplots/table/create col/assign first/.code={%
+ \pgfmathfloatparsenumber{\thisrow{#1}}%
+ \let\pgfmathaccuma=\pgfmathresult
+ \pgfmathfloatparsenumber{\thisrow{#2}}%
+ \let\pgfmathaccumb=\pgfmathresult
+ \def\pgfmathresult{}% leave first empty.
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ },%
+ /pgfplots/table/create col/assign/.code={%
+ \let\pgfmathcur@x=\pgfmathaccuma
+ \let\pgfmathcur@y=\pgfmathaccumb
+ \pgfmathfloatparsenumber{\thisrow{#1}}%
+ \let\pgfmathnext@x=\pgfmathresult
+ \let\pgfmathaccuma=\pgfmathnext@x
+ \pgfmathfloatparsenumber{\thisrow{#2}}%
+ \let\pgfmathnext@y=\pgfmathresult
+ \let\pgfmathaccumb=\pgfmathnext@y
+ \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}%
+ \let\pgfmathdiff@x=\pgfmathresult
+ \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}%
+ \let\pgfmathdiff@y=\pgfmathresult
+ \pgfplots@ifzero\pgfmathdiff@x{%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ }{%
+ \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}%
+ \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ },%
+ },%
+ /pgfplots/table/create col/gradient loglog/.style 2 args={%
+ /pgfplots/table/columns={#1,#2},
+ /pgfplots/table/create col/assign first/.code={%
+ \pgfmathlog{\thisrow{#1}}%
+ \let\pgfmathaccuma=\pgfmathresult
+ \pgfmathlog{\thisrow{#2}}%
+ \let\pgfmathaccumb=\pgfmathresult
+ \def\pgfmathresult{}% leave first empty.
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ },%
+ /pgfplots/table/create col/assign/.code={%
+ \let\pgfmathcur@x=\pgfmathaccuma
+ \let\pgfmathcur@y=\pgfmathaccumb
+ \pgfmathlog{\thisrow{#1}}%
+ \let\pgfmathnext@x=\pgfmathresult
+ \let\pgfmathaccuma=\pgfmathresult
+ \pgfmathlog{\thisrow{#2}}%
+ \let\pgfmathnext@y=\pgfmathresult
+ \let\pgfmathaccumb=\pgfmathresult
+ \pgfplots@loop@CONTINUEtrue
+ \ifx\pgfmathcur@x\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi
+ \ifx\pgfmathcur@y\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi
+ \ifx\pgfmathnext@x\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi
+ \ifx\pgfmathnext@y\pgfutil@empty \pgfplots@loop@CONTINUEfalse\fi
+ \ifpgfplots@loop@CONTINUE
+ \pgfmathsubtract@{\pgfmathnext@x}{\pgfmathcur@x}%
+ \let\pgfmathdiff@x=\pgfmathresult
+ \pgfmathsubtract@{\pgfmathnext@y}{\pgfmathcur@y}%
+ \let\pgfmathdiff@y=\pgfmathresult
+ % FPU is more robust:
+ \pgfmathfloatparsenumber\pgfmathdiff@x\let\pgfmathdiff@x=\pgfmathresult
+ \pgfmathfloatparsenumber\pgfmathdiff@y\let\pgfmathdiff@y=\pgfmathresult
+ \pgfplots@ifzero\pgfmathdiff@x{%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ }{%
+ \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}%
+ \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ \else
+ % \pgfmathfloatcreate{3}{0.0}{0}%
+ % \pgfmathfloattosci@\pgfmathresult
+ % \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ \fi
+ },%
+ },%
+ /pgfplots/table/create col/gradient semilogx/.style 2 args={%
+ /pgfplots/table/columns={#1,#2},
+ /pgfplots/table/create col/assign first/.code={%
+ \pgfmathfloatparsenumber{\thisrow{#1}}
+ \pgfmathfloatln@{\pgfmathresult}%
+ \let\pgfmathaccuma=\pgfmathresult
+ \pgfmathfloatparsenumber{\thisrow{#2}}%
+ \let\pgfmathaccumb=\pgfmathresult
+ \def\pgfmathresult{}% leave first empty.
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ },%
+ /pgfplots/table/create col/assign/.code={%
+ \let\pgfmathcur@x=\pgfmathaccuma
+ \let\pgfmathcur@y=\pgfmathaccumb
+ \pgfmathfloatparsenumber{\thisrow{#1}}
+ \pgfmathfloatln@{\pgfmathresult}%
+ \let\pgfmathnext@x=\pgfmathresult
+ \let\pgfmathaccuma=\pgfmathresult
+ %
+ \pgfmathfloatparsenumber{\thisrow{#2}}%
+ \let\pgfmathnext@y=\pgfmathresult
+ \let\pgfmathaccumb=\pgfmathresult
+ \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}%
+ \let\pgfmathdiff@x=\pgfmathresult
+ \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}%
+ \let\pgfmathdiff@y=\pgfmathresult
+ \pgfplots@ifzero\pgfmathdiff@x{%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ }{%
+ \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}%
+ \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ },%
+ },%
+ /pgfplots/table/create col/gradient semilogy/.style 2 args={%
+ /pgfplots/table/columns={#1,#2},
+ /pgfplots/table/create col/assign first/.code={%
+ \pgfmathfloatparsenumber{\thisrow{#1}}%
+ \let\pgfmathaccuma=\pgfmathresult
+ \pgfmathfloatparsenumber{\thisrow{#2}}
+ \pgfmathfloatln@{\pgfmathresult}%
+ \let\pgfmathaccumb=\pgfmathresult
+ \def\pgfmathresult{}% leave first empty.
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ },%
+ /pgfplots/table/create col/assign/.code={%
+ \let\pgfmathcur@x=\pgfmathaccuma
+ \let\pgfmathcur@y=\pgfmathaccumb
+ \pgfmathfloatparsenumber{\thisrow{#2}}
+ \pgfmathfloatln@{\pgfmathresult}%
+ \let\pgfmathnext@y=\pgfmathresult
+ \let\pgfmathaccumb=\pgfmathresult
+ %
+ \pgfmathfloatparsenumber{\thisrow{#1}}%
+ \let\pgfmathnext@x=\pgfmathresult
+ \let\pgfmathaccuma=\pgfmathresult
+ \pgfmathfloatsubtract@{\pgfmathnext@x}{\pgfmathcur@x}%
+ \let\pgfmathdiff@x=\pgfmathresult
+ \pgfmathfloatsubtract@{\pgfmathnext@y}{\pgfmathcur@y}%
+ \let\pgfmathdiff@y=\pgfmathresult
+ \pgfplots@ifzero\pgfmathdiff@x{%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfutil@empty%
+ }{%
+ \pgfmathfloatdivide@{\pgfmathdiff@y}{\pgfmathdiff@x}%
+ \expandafter\pgfmathfloattosci@\expandafter{\pgfmathresult}%
+ \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult%
+ }%
+ },%
+ },%
+ /pgfplots/table/typeset cell/.code={%
+ \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax
+ \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1\\}%
+ \else
+ \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1&}%
+ \fi
+ },
+ % this can be omitted to omit the header row:
+ /pgfplots/table/output empty row/.style={%
+ /pgfplots/table/typeset cell/.code={%
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfutil@empty%
+ }%
+ },
+ /pgfplots/table/reset styles/.style={
+ /pgfplots/table/every table/.code=,
+ /pgfplots/table/every odd column/.code=,
+ /pgfplots/table/every column/.code=,
+ /pgfplots/table/every even column/.code=,
+ /pgfplots/table/every first column/.code=,
+ /pgfplots/table/every last column/.code=,
+ /pgfplots/table/every head row/.code=,
+ /pgfplots/table/every odd row/.code=,
+ /pgfplots/table/every even row/.code=,
+ /pgfplots/table/every first row/.code=,
+ /pgfplots/table/every last row/.code=,
+ /pgfplots/table/postproc cell content/.code=,
+ /pgfplots/table/preproc cell content/.code=,
+ },
+ /pgfplots/table/colnames from/.initial=,% for \pgfplotstabletranspose
+ /pgfplots/table/input colnames to/.initial=colnames,% for \pgfplotstabletranspose
+ /pgfplots/table/sort/.is if=pgfplotstable@sort,
+ /pgfplots/table/sort/.default=true,
+ /pgfplots/table/sort key/.initial=[index]0,%
+ % the argument of `sort cmp' will be evaluates as style in the key
+ % path /pgfplots/. See pgfplotsutil.code.tex for available
+ % styles.
+ /pgfplots/table/sort cmp/.initial=float <,
+ /pgfplots/table/sort key from/.initial=,
+}
+% 'function graph cut y'={<epsilon>}{<options>}{comma-separated-list of specs where to get yi}
+%
+% fills the column with x1,...,xN such that yi(xi) == epsilon where
+%
+% In other words, it computes cuts points between the line
+% y == epsilon and one or more other plots yi(x) and returns the 'x'
+% values of the cuts.
+%
+% Example:
+% \pgfplotstableset{
+% create on use/cut/.style={create col/function graph cut y={7e-4}{x=Basis,ymode=log,xmode=log}{{table=regtable,y=special-L2}}},
+%}
+\pgfkeysdefnargs{/pgfplots/table/create col/function graph cut y}{3}{\pgfplotstable@fgc@init{#1}{#2}{#3}{y}{x}}
+\pgfkeysdefnargs{/pgfplots/table/create col/function graph cut x}{3}{\pgfplotstable@fgc@init{#1}{#2}{#3}{x}{y}}
+\pgfkeys{%
+ /pgfplots/table/create col/function graph cut/xmode/.is choice,
+ /pgfplots/table/create col/function graph cut/xmode/linear/.code={\def\pgfplotstable@fgc@xmode{0}},%
+ /pgfplots/table/create col/function graph cut/xmode/log/.code={\def\pgfplotstable@fgc@xmode{1}},%
+ /pgfplots/table/create col/function graph cut/ymode/.is choice,
+ /pgfplots/table/create col/function graph cut/ymode/linear/.code={\def\pgfplotstable@fgc@ymode{0}},%
+ /pgfplots/table/create col/function graph cut/ymode/log/.code={\def\pgfplotstable@fgc@ymode{1}},%
+ /pgfplots/table/create col/function graph cut/x/.initial=,
+ /pgfplots/table/create col/function graph cut/y/.initial=,
+ /pgfplots/table/create col/function graph cut/table/.initial=,
+ % foreach={\d in {1,2,3,4}}{{table\d}}
+ /pgfplots/table/create col/function graph cut/foreach/.initial=,
+}
+
+
+\pgfkeyslet{/pgfplots/table/TeX comment}\pgfplots@PERCENT@TEXT
+\pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent@EMPTY
+
+
+% A helper macro to automatically remove the "hangover" created by
+% 'colortbl'.
+% This allows compatibility between my 'sci sep align' and 'dec sep align'
+% implementations and \rowcolor. Otherwise, the hangover
+% would overwrite digits near the separator.
+%
+% @remark This does also work if colortbl is not loaded.
+\def\pgfplotstableresetcolortbloverhangright{%
+ \pgfutil@ifundefined{CT@row@color}{\relax}{%
+ \global\let\pgfplots@origrowcolorcmd=\CT@row@color
+ \gdef\CT@row@color{%
+ \pgfplots@origrowcolorcmd
+ \@tempdimc=0pt
+ \global\let\CT@row@color=\pgfplots@origrowcolorcmd
+ }%
+ }%
+}%
+\def\pgfplotstableresetcolortbloverhangleft{%
+ \pgfutil@ifundefined{CT@row@color}{\relax}{%
+ \global\let\pgfplots@origrowcolorcmd=\CT@row@color
+ \gdef\CT@row@color{%
+ \pgfplots@origrowcolorcmd
+ \@tempdimb=0pt
+ \global\let\CT@row@color=\pgfplots@origrowcolorcmd
+ }%
+ }%
+}%
+
+
+% \pgfplotstablesave[<options>]{<\tablename>}{file name}
+\def\pgfplotstablesave{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotstablesave@impl
+ }{%
+ \pgfplotstablesave@impl[]%
+ }%
+}
+
+\def\pgfplotstablesave@impl[#1]#2#3{%
+ \pgfplotstabletypeset[%
+ reset styles,%
+ disable rowcol styles,%
+ begin table={},%
+ end table={},%
+ typeset cell/.code={%
+ \begingroup
+ \t@pgfplots@toka={##1}%
+ \ifcase\pgfplotstableread@OUTCOLSEP@CASE\relax
+ % 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
+ % col sep=comma:
+ \t@pgfplots@tokb={,}%
+ \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \or
+ % col sep=semicolon:
+ \t@pgfplots@tokb={;}%
+ \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \or
+ % col sep=colon:
+ \t@pgfplots@tokb={:}%
+ \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \or
+ % 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}%
+ \or
+ % col sep=&:
+ \xdef\pgfplots@glob@TMPc{\the\t@pgfplots@toka&}%
+ \fi
+ \endgroup
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfplots@glob@TMPc%
+ },%
+ before row=,%
+ after row=,%
+ skip coltypes,%
+ typeset=false,%
+ string type,%
+ TeX comment=,%
+ columns=,%
+ font=,%
+ /pgfplots/table/col sep/.is choice,%
+ /pgfplots/table/col sep/space/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{0}},%
+ /pgfplots/table/col sep/comma/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{1}},%
+ /pgfplots/table/col sep/semicolon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{2}},%
+ /pgfplots/table/col sep/colon/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{3}},%
+ /pgfplots/table/col sep/braces/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{4}},%
+ /pgfplots/table/col sep/tab/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{5}},%
+ /pgfplots/table/col sep/&/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{6}},%
+ /pgfplots/table/col sep/ampersand/.code = {\def\pgfplotstableread@OUTCOLSEP@CASE{6}},%
+ /pgfplots/table/col sep=space,%
+ /pgfplots/table/in col sep/.is choice,%
+ /pgfplots/table/in col sep/space/.code = {\def\pgfplotstableread@COLSEP@CASE{0}},%
+ /pgfplots/table/in col sep/comma/.code = {\def\pgfplotstableread@COLSEP@CASE{1}},%
+ /pgfplots/table/in col sep/semicolon/.code = {\def\pgfplotstableread@COLSEP@CASE{2}},%
+ /pgfplots/table/in col sep/colon/.code = {\def\pgfplotstableread@COLSEP@CASE{3}},%
+ /pgfplots/table/in col sep/braces/.code = {\def\pgfplotstableread@COLSEP@CASE{4}},%
+ /pgfplots/table/in col sep/tab/.code = {\def\pgfplotstableread@COLSEP@CASE{5}},%
+ /pgfplots/table/in col sep/&/.code = {\def\pgfplotstableread@COLSEP@CASE{6}},%
+ /pgfplots/table/in col sep/ampersand/.code = {\def\pgfplotstableread@COLSEP@CASE{6}},%
+ /pgfplots/table/in col sep=space,%
+ % WARNING: you NEED a '%' before '#1':
+ #1,%
+ /pgfplots/table/include outfiles=false,
+ /pgfplots/table/outfile={#3}%
+ ]{#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>. 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{%
+ \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{%
+ \ifx#3\pgfutil@undefined
+ \else
+ \ifx#3\relax
+ \else
+ % oh - there *is* already such a table. The 'getcolumnbyname' method suffers from a flaw in 'ifexists' that I do not want to fix right now.
+ % To work around that flaw, I merely clear the old table here:
+ % let's hope that '#3' really *was* a table and not some other junk...
+ \pgfplotslistforeachungrouped#3\as\pgfplotstable@loc@TMPa{%
+ \expandafter\let\csname\string#3@\pgfplotstable@loc@TMPa\endcsname=\relax%
+ }%
+ \fi
+ \fi
+ %
+ \pgfplotsscanlinelengthinitzero
+ % create a temporary column with the desired number of rows:
+ \pgfutil@in@\pgfplotstablegetrowsof{#2}%
+ \ifpgfutil@in@
+ #2%
+ \let\pgfplotstable@loc@TMPa=\pgfmathresult
+ \else
+ \def\pgfplotstable@loc@TMPa{#2}%
+ \fi
+ %
+ % let the table contain one column named '@@@@@temporary@column@':
+ \pgfplotslistnew#3{@@@@@temporary@column@\\}%
+ % populate the temporary column with enough rows:
+ \ifnum\pgfplotstable@loc@TMPa>0
+ \expandafter\pgfplots@assign@list\csname\string#3@@@@@@temporary@column@\endcsname{1,...,\pgfplotstable@loc@TMPa}%
+ \else
+ \expandafter\pgfplotslistnewempty\csname\string#3@@@@@@temporary@column@\endcsname%
+ \fi
+ %
+ % now, create all real columns:
+ \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.}%
+ \else
+ \expandafter\pgfplots@assign@list\expandafter\pgfplotstablenew@cols\expandafter{\pgfplotstable@colnames}%
+ % make sure every requested column exists:
+ \pgfutil@loop
+ \pgfplotslistcheckempty\pgfplotstablenew@cols
+ \ifpgfplotslistempty
+ \pgfplots@loop@CONTINUEfalse
+ \else
+ \pgfplots@loop@CONTINUEtrue
+ \fi
+ \ifpgfplots@loop@CONTINUE
+ \pgfplotslistpopfront\pgfplotstablenew@cols\to\pgfplotstablenew@col
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstablenew@col}\of#3\to\pgfplotstable@loc@TMPa
+ \pgfutil@repeat
+ % remove the temporary column:
+ % FIXME this should be done after the '\fi'. But that will
+ % lead to an error because empty tables are currently
+ % unsupported!
+ \pgfplotslistpopfront#3\to\pgfplotstable@loc@TMPa
+ \fi
+ \pgfplotsscanlinelengthcleanup
+ \pgfplotstable@copy@to@globalbuffers#3{newlycreatedtable}%
+ \endgroup
+ \pgfplotstable@copy@globalbuffers@to#3%
+}%
+
+% \pgfplotstablevertcat{<table1>}{<table2>}
+% appends the contents of <table2> to <table1>. To be more precise,
+% only columns which exist already in <table1> will be used.
+%
+% If <table1> is undefined, <table2> will be copied completely to
+% <table1>.
+%
+% #1 a table macro.
+% #2 either a file name or a table macro.
+\long\def\pgfplotstablevertcat#1#2{%
+ \pgfplotstable@isloadedtable{#2}{%
+ \pgfplotstable@isloadedtable{#1}{%
+ % for each column in '#1':
+ \pgfplotslistforeachungrouped#1\as\pgfplotstable@loc@TMPa{%
+ % for each row in the corresponding column of '#2':
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@loc@TMPa}\of{#2}\to\pgfplotstable@loc@TMPb
+ \pgfplotslistforeachungrouped\pgfplotstable@loc@TMPb\as\pgfplotstable@loc@TMPc{%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPc}%
+ \edef\pgfplotstable@loc@TMPd{%
+ \noexpand\pgfplotslistpushback{\the\t@pgfplots@toka}\noexpand\to\expandafter\noexpand\csname\string#1@\pgfplotstable@loc@TMPa\endcsname
+ }%
+ \pgfplotstable@loc@TMPd
+ }%
+ }%
+ }{%
+ \pgfplotstablecopy{#2}\to{#1}%
+ }%
+ }{%
+ % FIXME : restore memory here !? SCOPING BUG
+ \pgfplotstableread{#2}\pgfplotstable@tmptbl
+ \pgfplotstablevertcat{#1}{\pgfplotstable@tmptbl}%
+ }%
+}
+
+% \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[]}}%
+\long\def\pgfplotstabletranspose@opt[#1]#2#3{%
+ \pgfplotstable@isloadedtable{#3}{%
+ \pgfplotstabletranspose@[#1]{#2}{#3}%
+ }{%
+ \pgfplotstableread{#3}\pgfplotstable@tmptbl
+ \pgfplotstabletranspose@[#1]{#2}{\pgfplotstable@tmptbl}%
+ }%
+}%
+
+
+% Creates a new column named #1 and appends it to table #2.
+%
+% The column entries will be created using the command keys
+% 'create col/assign'
+% 'create col/assign last'
+%
+% The key 'create col/assign' will be invoked for every row of table #2.
+% It is supposed to assign the key 'create col/next content'.
+% During evaluation of 'create col/assign', the macro '\thisrow{<col name>}'
+% expands to the current row's value of the column named by <col name>.
+% Furthermore, '\nextrow{<col name>}' expands to the \emph{next} row's
+% value of the designated column.
+%
+% Since the "next row" is not available if we are currently processing
+% the last row, 'create col/assign last' is used in for the last row's
+% value.
+%
+% You can use
+% - \thisrow{<col name>},
+% - \getthisrow{<col name>}{\macro}
+% - \nextrow{<col name>},
+% - \getnextrow{<col name>}{\macro}
+%
+% FIXME this documentation is incomplete. Please refer to pgfplotstable.pdf .
+\def\pgfplotstablecreatecol{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotstablecreatecol@opt
+ }{%
+ \pgfplotstablecreatecol@opt[]%
+ }%
+}%
+
+
+% Typesets a table.
+%
+% \pgfplotstabletypeset[<options>]<\tablestructure>
+% or
+% \pgfplotstabletypeset[<options>]{<file name>}
+%
+% If you do not select any columns, the complete table is drawn.
+%
+% There are several options and styles which are available in
+% <options>, see the declaration above.
+%
+% ATTENTION: the default implementation employs
+% \begin{tabular}...\end{tabular} and is therefor only usable with
+% LaTeX!
+%
+% You will need to reconfigure the tables.
+%
+% 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
+ }{%
+ \pgfplotstabletypeset@opt[]%
+ }%
+}
+\long\def\pgfplotstabletypeset@opt[#1]{%
+ \begingroup
+ \ifpgfplots@table@options@areset
+ \else
+ \pgfplotstableset{#1}%
+ \fi
+ \pgfplotstablecollectoneargwithpreparecatcodes{%
+ \pgfplotstabletypeset@opt@collectarg[#1]%
+ }%
+}
+\long\def\pgfplotstabletypeset@opt@collectarg[#1]#2{%
+ \pgfplotstable@isloadedtable{#2}%
+ {\pgfplotstabletypeset@opt@[#1]{#2}}%
+ {\pgfplotstabletypesetfile@opt@[#1]{#2}}%
+}
+
+
+% Like \pgfplotstabletypeset, but the first argument is a file name.
+% This is the same now; it will be recognised automatically.
+\let\pgfplotstabletypesetfile=\pgfplotstabletypeset
+\long\def\pgfplotstabletypesetfile@opt@[#1]#2{%
+ %\begingroup <--- is already opened!
+ \ifpgfplots@table@options@areset
+ \else
+ \pgfplotstableset@every@table{#2}{#1}%
+ \pgfplots@table@options@aresettrue
+ \fi
+ \ifpgfplotstabletypeset@force@remake
+ \pgfplotstabletypeset@includeoutfilesfalse
+ \else
+ \ifpgfplotstabletypeset@includeoutfiles
+ \pgfplotstabletypeset@includeoutfilesfalse
+ \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename
+ \ifx\pgfplotstable@outfilename\pgfutil@empty
+ \else
+ \openin\r@pgfplots@reada=\pgfplotstable@outfilename\relax
+ \ifeof\r@pgfplots@reada
+ \else
+ \pgfplotstabletypeset@includeoutfilestrue
+ \fi
+ \closein\r@pgfplots@reada
+ \fi
+ \fi
+ \fi
+ \ifpgfplotstabletypeset@includeoutfiles
+ \input \pgfplotstable@outfilename\relax
+ \else
+ \pgfplotstableread{#2}\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
+ \def\pgfplots@loc@TMPa{\pgfutil@empty}%
+ \else
+ \expandafter\ifx\pgfplots@loc@TMPa\relax
+ % is it really defined? NO! Sanity checking here:
+ \def\pgfplots@loc@TMPa{\pgfutil@empty}%
+ \fi
+ \fi
+ \expandafter\pgfmath@smuggleone\pgfplots@loc@TMPa
+ \endgroup
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% IMPLEMENTATION
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%%%%%%%%%%%%
+
+
+% #1: the original value
+% #2: the output macro
+\long\def\pgfplotstabletypeset@getfinalentry#1#2{%
+ \begingroup
+ \def\pgfkeysdefaultpath{/pgfplots/table/}%
+ \def\pgfplotstablepartno{0}%
+ \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}%
+ \pgfkeyssetvalue{/pgfplots/table/@unprocessed cell content}{#1}%
+ \ifpgfplotstable@disable@rowcolstyles
+ \else
+ \def\pgfplots@loc@TMPb##1{%
+ \edef\pgfplotstable@loc@TMPa{/pgfplots/table/every row ##1\pgfplotstablerow\space column ##1\pgfplotstablecol}%
+ \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{%
+ \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}%
+ }{}%
+ \edef\pgfplotstable@loc@TMPa{/pgfplots/table/every row ##1\pgfplotstablerow\space column \pgfplotstable@colname@for@styles}%
+ \pgfkeysifdefined{\pgfplotstable@loc@TMPa/.@cmd}{%
+ \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}%
+ }{}%
+ }%
+ \pgfplots@loc@TMPb{}%
+ % also accept the same with the 'row no' style:
+ \pgfplots@loc@TMPb{no }%
+ \pgfplotstable@debug@notify@cellcontent@afterrowcolstyles%
+ \fi
+ \pgfplotstable@debug@notify@cellcontent%
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \pgfkeyslet{/pgfplots/table/@cell content after rowcol styles}\pgfmathresult%
+ \pgfkeysgetvalue{/pgfplots/table/preproc cell content/.@cmd}\pgfplotstable@assigncell
+ \expandafter\pgfplotstable@assigncell\pgfmathresult\pgfeov
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \pgfkeyslet{/pgfplots/table/@preprocessed cell content}\pgfmathresult%
+ \pgfplotstable@debug@notify@cellcontent@preprocessed%
+ %
+ \pgfkeysgetvalue{/pgfplots/table/assign cell content/.@cmd}\pgfplotstable@assigncell
+ \expandafter\pgfplotstable@assigncell\pgfmathresult\pgfeov
+ \pgfplotstable@debug@notify@cellcontent@assigned%
+ %
+ \pgfkeysgetvalue{/pgfplots/table/postproc cell content/.@cmd}\pgfplotstable@postproccellcontent
+ \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 '&' ?
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \expandafter\pgfutil@in@\expandafter&\expandafter{\pgfmathresult}%
+ \ifpgfutil@in@
+ \expandafter\pgfplotstabletypeset@postproc@separately\pgfmathresult\pgfplotstable@EOI
+ \else
+ \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov
+ \fi
+ \fi
+ \pgfplotstable@debug@notify@cellcontent@postprocessed%
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \let#2=\pgfmathresult
+}%
+
+\def\pgfplotstable@debug@notify@cellcontent{}%
+\def\pgfplotstable@debug@notify@cellcontent@preprocessed{}%
+\def\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles{}%
+\def\pgfplotstable@debug@notify@cellcontent@assigned{}%
+\def\pgfplotstable@debug@notify@cellcontent@postprocessed{}%
+\def\pgfplotstable@debug@notify@preprocess@incol#1{}%
+\def\pgfplotstable@debug@notify@preprocess@col#1{}%
+\def\pgfplotstable@debug@notify@preprocessed@col#1{}%
+\def\pgfplotstable@debug@notify@balancingcell{}%
+
+\def\pgfplotstable@debug@notify@cellcontent@ACTIVE{%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \toks0=\expandafter{\pgfmathresult}%
+ \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: Before cell content processing: `\the\toks0'}%
+ \endgroup
+}%
+\def\pgfplotstable@debug@notify@cellcontent@preprocessed@ACTIVE{%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \toks0=\expandafter{\pgfmathresult}%
+ \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After '@preproc cell content : `\the\toks0'}%
+ \endgroup
+}%
+\def\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles@ACTIVE{%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \toks0=\expandafter{\pgfmathresult}%
+ \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After applying 'every row * column [no] *' styles : `\the\toks0'}%
+ \endgroup
+}%
+\def\pgfplotstable@debug@notify@cellcontent@assigned@ACTIVE{%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \toks0=\expandafter{\pgfmathresult}%
+ \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After 'assign cell content : `\the\toks0'}%
+ \endgroup
+}%
+\def\pgfplotstable@debug@notify@cellcontent@postprocessed@ACTIVE{%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult%
+ \toks0=\expandafter{\pgfmathresult}%
+ \immediate\write16{Row \pgfplotstablerow/out \the\c@pgfplotstable@counta: After 'postproc cell content : `\the\toks0'}%
+ \endgroup
+}
+\def\pgfplotstable@debug@notify@balancingcell@ACTIVE{%
+ \immediate\write16{Row --/out \the\c@pgfplotstable@counta: Inserting empty cell to balance rows}%
+}%
+\def\pgfplotstable@debug@notify@preprocess@incol@ACTIVE#1{%
+ \begingroup
+ \toks0=\expandafter{#1}%
+ \immediate\write16{>=== Loading input column `\the\toks0' <===}%
+ \endgroup
+}%
+\def\pgfplotstable@debug@notify@preprocess@col@ACTIVE#1{%
+ \begingroup
+ \toks0=\expandafter{#1}%
+ \immediate\write16{>=== Preprocessing output column `\the\toks0' <===}%
+ \endgroup
+}%
+\def\pgfplotstable@debug@notify@preprocessed@col@ACTIVE#1{%
+ \begingroup
+ \toks0=\expandafter{#1}%
+ \immediate\write16{>=== output column `\the\toks0' prepared, ok. <===}%
+ \endgroup
+}%
+\def\pgfplotstable@debug@activate{%
+ \ifnum\pgfkeysvalueof{/pgfplots/table/debug level}>0
+ \let\pgfplotstable@debug@notify@preprocess@incol=\pgfplotstable@debug@notify@preprocess@incol@ACTIVE
+ \let\pgfplotstable@debug@notify@preprocess@col=\pgfplotstable@debug@notify@preprocess@col@ACTIVE
+ \let\pgfplotstable@debug@notify@preprocessed@col=\pgfplotstable@debug@notify@preprocessed@col@ACTIVE
+ \let\pgfplotstable@debug@notify@cellcontent=\pgfplotstable@debug@notify@cellcontent@ACTIVE
+ \let\pgfplotstable@debug@notify@cellcontent@preprocessed=\pgfplotstable@debug@notify@cellcontent@preprocessed@ACTIVE
+ \let\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles=\pgfplotstable@debug@notify@cellcontent@afterrowcolstyles@ACTIVE
+ \let\pgfplotstable@debug@notify@cellcontent@assigned=\pgfplotstable@debug@notify@cellcontent@assigned@ACTIVE
+ \let\pgfplotstable@debug@notify@cellcontent@postprocessed=\pgfplotstable@debug@notify@cellcontent@postprocessed@ACTIVE
+ \let\pgfplotstable@debug@notify@balancingcell=\pgfplotstable@debug@notify@balancingcell@ACTIVE
+ \fi
+}%
+
+% This routine invokes 'postproc cell content' for columns which
+% contain the column separator '&'.
+%
+% #1&#2 is the formatted number, the result of 'dec sep align
+% #3 is the (unformatted) input number.
+\def\pgfplotstabletypeset@postproc@separately#1&#2\pgfplotstable@EOI{%
+ \def\pgfmathresult{#1}%
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
+ \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfplotstable@entry@a
+ %
+ \def\pgfplotstablepartno{1}%
+ \def\pgfmathresult{#2}%
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
+ \expandafter\pgfplotstable@postproccellcontent\pgfplotstabletypeset@rawinput\pgfeov
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@entry@a}%
+ \t@pgfplots@tokb=\expandafter{\pgfmathresult}%
+ \edef\pgfmathresult{\the\t@pgfplots@toka&\the\t@pgfplots@tokb}%
+ \pgfkeyslet{/pgfplots/table/@cell content}\pgfmathresult
+}
+
+% processes the option 'assign column name'
+% FIXME : seems to be deprecated
+\def\pgfplotstabletypeset@assign@final@colname#1#2{%
+ \pgfkeysifdefined{/pgfplots/table/assign column name/.@cmd}{%
+ \pgfkeyssetvalue{/pgfplots/table/column name}{#1}%
+ \pgfkeysvalueof{/pgfplots/table/assign column name/.@cmd}#1\pgfeov
+ \pgfkeysgetvalue{/pgfplots/table/column name}{#2}%
+ }{}%
+}
+\def\pgfplotstabletypeset@nocolname{\pgfkeysnovalue}
+
+% checks if #1 contains invalid chars for pgfkeys and sets
+% \ifpgfutil@in@ to true if that is the case.
+\def\pgfplotstable@checkspecialchars@pgfkeys#1\pgfplotstable@EOI{%
+ \pgfutil@in@/{#1}%
+ \ifpgfutil@in@
+ \else
+ \pgfutil@in@={#1}%
+ \ifpgfutil@in@
+ \else
+ \pgfutil@in@,{#1}%
+ \fi
+ \fi
+}%
+
+% Upon execution, \pgfplotsretval contains a set of /pgfplots/table
+% keys from 'every nth row' styles.
+%
+% @PRECONDITION this macro assumes it is run in \pgfplotstabletypeset.
+\def\pgfplots@each@nth@styles{\let\pgfplotsretval\pgfutil@empty}%
+
+% Defines an 'every nth row' style for an integer #1.
+%
+% #1: integer
+% #2: style arguments
+%
+% All these styles are accumulated into the macro
+% \pgfplots@each@nth@styles.
+\def\pgfplotstabletypeset@append@every@nth@row#1#2{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ % chech for the special 'each nth row={3[+1]}{...} format:
+ \expandafter\pgfutil@in@\expandafter[\expandafter{\pgfplots@loc@TMPa}%
+ \ifpgfutil@in@
+ \expandafter\pgfplotstabletypeset@append@every@nth@row@getshift\pgfplots@loc@TMPa%
+ \t@pgfplots@toka={#2}%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplotstabletypeset@append@every@nth@row@{\pgfplots@loc@TMPa}{\the\t@pgfplots@toka}{\pgfplots@loc@TMPb}%
+ }%
+ \pgfplots@loc@TMPa
+ \else
+ \expandafter\pgfplotstabletypeset@append@every@nth@row@\expandafter{\pgfplots@loc@TMPa}{#2}{0}%
+ \fi
+}%
+\def\pgfplotstabletypeset@append@every@nth@row@getshift#1[#2]{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifnum#2<0
+ \c@pgf@countc=#1\relax
+ \advance\c@pgf@countc by#2
+ \edef\pgfplots@loc@TMPb{\the\c@pgf@countc}%
+ \else
+ \def\pgfplots@loc@TMPb{#2}%
+ \fi
+}%
+% #3 is an additional shift. It is usually 0
+\def\pgfplotstabletypeset@append@every@nth@row@#1#2#3{%
+ \expandafter\def\expandafter\pgfplots@each@nth@styles\expandafter{%
+ \pgfplots@each@nth@styles
+ \expandafter\pgfplotsmathmodint\expandafter{\the\c@pgfplotstable@rowindex}{#1}%
+ \ifnum\pgfmathresult=#3\relax
+ \ifx\pgfplotsretval\pgfutil@empty
+ \def\pgfplotsretval{#2}%
+ \else
+ \expandafter\def\expandafter\pgfplotsretval\expandafter{\pgfplotsretval,%
+ #2}%
+ \fi
+ \fi
+ }%
+}
+
+\def\pgfplotstable@insertemptycells@forbalance{%
+ \pgfutil@loop
+ \ifnum\c@pgfplotstable@counta<\pgfplotstable@firstnumrows\relax
+ \pgfplotstable@debug@notify@balancingcell
+ % let's hope @getfinalentry handles empty strings!
+ \pgfplotstabletypeset@getfinalentry{}{\pgfplotstable@entry}%
+ \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed
+ \pgfplotslistpushback\to\pgfplotstable@col@processed
+ \advance\c@pgfplotstable@counta by1\relax
+ \pgfutil@repeat
+}
+
+% TODO
+% - replace grouped list foreach by popfront-loop and use arrays
+% directly -> group only the pgfkeys eval
+\long\def\pgfplotstabletypeset@opt@[#1]#2{%
+ %\begingroup <--- is already opened!
+ %--------------------------------------------------
+ % \pgfutil@ifundefined{#2}{%
+ % \pgfplots@error{There is no such table '\string#2' loaded into memory. Maybe you meant to use '\string\pgfplotstabletypesetfile{\string#2}' instead of '\string\pgfplotstabletypeset{\string#2}'?}%
+ % \pgfplotslistnewempty#2
+ % }{}%
+ %--------------------------------------------------
+ \def\pgfplotstablename{#2}% the name of the actual table struct
+ \def\pgfplotstablecolname{\pgfplotstable@colname}%
+ \def\pgfplotstablecol{\the\c@pgfplotstable@colindex}%
+ \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}%
+ \def\pgfplotstablecols{\the\c@pgfplotstable@numcols}%
+ \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}%
+ \ifpgfplots@table@options@areset
+ \else
+ \pgfplotstablegetname{#2}\pgfplotstable@loc@TMPa
+ \expandafter\pgfplotstableset@every@table\expandafter{\pgfplotstable@loc@TMPa}{#1}%
+ \fi
+ \pgfkeysgetvalue{/pgfplots/table/outfile}\pgfplotstable@outfilename
+ \pgfkeysgetvalue{/pgfplots/table/TeX comment}\pgfplots@TeX@comment
+ \ifpgfplotstabletypeset@force@remake
+ \pgfplotstabletypeset@includeoutfilesfalse
+ \else
+ \ifpgfplotstabletypeset@includeoutfiles
+ \pgfplotstabletypeset@includeoutfilesfalse
+ \ifx\pgfplotstable@outfilename\pgfutil@empty
+ \else
+ \pgfplots@logfileopen{\pgfplotstable@outfilename}%
+ \openin\r@pgfplots@reada=\pgfplotstable@outfilename\relax
+ \ifeof\r@pgfplots@reada \else\pgfplotstabletypeset@includeoutfilestrue \fi
+ \closein\r@pgfplots@reada
+ \fi
+ \fi
+ \fi
+ \ifpgfplotstabletypeset@includeoutfiles
+ \def\pgfplots@loc@TMPa{%
+ \input \pgfplotstable@outfilename\relax
+ \endgroup
+ }%
+ \else
+ \def\pgfplots@loc@TMPa{%
+ \pgfplotstabletypeset@opt@prepare{#2}%
+ }%
+ \fi
+ \pgfplots@loc@TMPa
+}%
+\def\pgfplotstabletypeset@opt@prepare#1{%
+ %
+ % Prepare outfile and debug options:
+ \let\pgfplotstable@notify@finished@line=\pgfutil@empty
+ %
+ % FLUSH assumes that \pgfplotstable@curline is finished. It
+ % appends all its contents as-is to \pgfplotstable@result.
+ %
+ % Furthermore, it calls \pgfplotstable@notify@finished@line which
+ % in turn may invoke additional output routines for the debug and
+ % outfile options.
+ %
+ % Finally, it resets \pgfplotstable@curline.
+ \def\pgfplotstable@curline@FLUSH{%
+ \pgfplotstable@notify@finished@line
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@result}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}%
+ \edef\pgfplotstable@result{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \let\pgfplotstable@curline=\pgfutil@empty
+ }%
+ \ifpgfplotstabletypesetdebug
+ \immediate\write16{------- PGFPLOTSTABLE DEBUG MODE: --------}%
+ \expandafter\def\expandafter\pgfplotstable@notify@finished@line\expandafter{\pgfplotstable@notify@finished@line
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
+ \immediate\write16{\the\t@pgfplots@toka\pgfplots@TeX@comment}%
+ }%
+ \pgfplotstable@debug@activate
+ \fi
+ \ifx\pgfplotstable@outfilename\pgfutil@empty
+ \else
+ \immediate\openout\pgfplotstable@outfile=\pgfplotstable@outfilename\relax
+ \expandafter\def\expandafter\pgfplotstable@notify@finished@line\expandafter{\pgfplotstable@notify@finished@line
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
+ \immediate\write\pgfplotstable@outfile{\the\t@pgfplots@toka\pgfplots@TeX@comment}%
+ }%
+ \fi
+ %
+ % Start operation:
+ \pgfkeysgetvalue{/pgfplots/table/columns}{\pgfplotstable@colnames}%
+ \ifx\pgfplotstable@colnames\pgfutil@empty
+ \pgfplotstablegetcolumnlist#1\to\pgfplotstable@colnames
+ \else
+ \expandafter\pgfplotslistnew\expandafter\pgfplotstable@colnames\expandafter{\pgfplotstable@colnames}%
+ \fi
+ %
+ %
+ \ifpgfplotstable@sort
+ % make sure any columns exist (especially create on use).
+ % this can be done by calling getcolumnbyname once for every
+ % column:
+ \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{%
+ \pgfplotstable@is@colname\pgfplotstable@colname
+ \ifpgfplotstableread@foundcolnames
+ \else
+ \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#1\to\pgfplotstable@colname
+ \fi
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@colname}\of#1\to\pgfplotstable@col
+ }%
+ \let\pgfplotstable@colname=\relax
+ \let\pgfplotstable@col=\relax
+ %
+ \def\pgfplots@loc@TMPa{%
+ \pgfplotstablesort\pgfplotstable@sortedtbl{#1}%
+ \pgfplotstabletypeset@opt@@{\pgfplotstable@sortedtbl}%
+ }%
+ \else
+ \def\pgfplots@loc@TMPa{%
+ \pgfplotstabletypeset@opt@@{#1}%
+ }%
+ \fi
+ \pgfplots@loc@TMPa
+}
+\def\pgfplotstabletypeset@opt@@#1{%
+ \global\pgfplotslistnewempty\pgfplotstabletypeset@final@colnames
+ \global\pgfplotslistnewempty\pgfplotstabletypeset@final@coltypes
+ \global\pgfplotslistnewempty\pgfplotstabletypeset@final@cols
+ \let\c@pgfplotstable@numcols=\c@pgf@counta
+ \let\c@pgfplotstable@numrows=\c@pgf@countd
+ \let\c@pgfplotstable@rowindex=\c@pgf@countc
+ \let\c@pgfplotstable@colindex=\c@pgf@countb
+ \pgfplotslistsize\pgfplotstable@colnames\to\c@pgfplotstable@numcols
+ \def\pgfplotstable@firstnumrows{-1}%
+ \c@pgfplotstable@numrows=-1\relax
+ \c@pgfplotstable@colindex=0\relax
+ % FOREACH COLUMN:
+ \pgfplotslistforeach\pgfplotstable@colnames\as\pgfplotstable@colname{%
+ \pgfplotstable@debug@notify@preprocess@incol\pgfplotstable@colname
+ %
+ \c@pgfplotstable@rowindex=0\relax
+ \pgfplotstable@is@colname\pgfplotstable@colname
+ \ifpgfplotstableread@foundcolnames
+ \else
+ \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#1\to\pgfplotstable@colname
+ \fi
+ \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplotstable@colname}\of#1\to\pgfplotstable@col
+ %
+ % Init number of *input* rows here. This may not be the same
+ % as the number of *output* rows (see the row predicate
+ % below).
+ %
+ % Accessable with \pgfplotstablerows in style keys.
+ \ifnum\c@pgfplotstable@numrows=-1\relax
+ \pgfplotslistsize\pgfplotstable@col\to\c@pgfplotstable@numrows
+ \global\c@pgfplotstable@numrows=\c@pgfplotstable@numrows
+ \fi
+ %
+ %
+ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % Set keys for columns!
+ \ifodd\c@pgfplotstable@colindex
+ \t@pgfplots@toka={every odd column}%
+ \else
+ \t@pgfplots@toka={every even column}%
+ \fi
+ \ifnum\c@pgfplotstable@colindex=0\relax
+ \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first column}%
+ \fi
+ % save this now before we increment '\c@pgfplotstable@colindex':
+ \edef\pgfplotstable@displaycolkey{display columns/\the\c@pgfplotstable@colindex/.try,every col no \the\c@pgfplotstable@colindex/.try}%
+ %
+ \global\advance\c@pgfplotstable@colindex by1\relax
+ \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols
+ \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last column}%
+ \fi
+ % 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>':
+ \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka}%
+ \else
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname}%
+ \expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\t@pgfplots@tokb\pgfplotstable@EOI
+ \ifpgfutil@in@
+ \edef\pgfplotstable@colname@for@styles{{\the\t@pgfplots@tokb}}%
+ \else
+ \edef\pgfplotstable@colname@for@styles{\the\t@pgfplots@tokb}%
+ \fi
+ \edef\pgfplotstable@loc@TMPa{every column,\the\t@pgfplots@toka,columns/\pgfplotstable@colname@for@styles/.try}%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@displaycolkey}%
+ \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}%
+ \fi
+ \expandafter\pgfplotstableset\expandafter{\pgfplotstable@loc@TMPa}%
+ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ \pgfkeysgetvalue{/pgfplots/table/column name}{\pgfplotstable@colname@out}%
+ \ifx\pgfplotstable@colname@out\pgfplotstabletypeset@nocolname
+ \let\pgfplotstable@colname@out=\pgfplotstable@colname
+ \fi
+ \expandafter\pgfplotstabletypeset@assign@final@colname\expandafter{\pgfplotstable@colname@out}\pgfplotstable@colname@out
+ %
+ \pgfplotstable@debug@notify@preprocess@col\pgfplotstable@colname@out
+ %
+ \expandafter\pgfplotslistpushbackglobal\pgfplotstable@colname@out\to\pgfplotstabletypeset@final@colnames
+ \pgfkeysgetvalue{/pgfplots/table/column type}{\pgfplotstable@coltype}%
+ \expandafter\pgfplotslistpushbackglobal\pgfplotstable@coltype\to\pgfplotstabletypeset@final@coltypes
+ %
+ \pgfplotslistnewempty\pgfplotstable@col@processed
+ \c@pgfplotstable@counta=0
+ \pgfplotslistforeachungrouped\pgfplotstable@col\as\pgfplotstable@entry{%
+ \pgfplotstableuserowtrue
+ \edef\pgfplotstable@loc@TMPa{\noexpand\pgfkeysvalueof{/pgfplots/table/row predicate/.@cmd}\the\c@pgfplotstable@rowindex}%
+ \pgfplotstable@loc@TMPa\pgfeov
+ \ifpgfplotstableuserow
+ \ifnum\pgfplotstable@firstnumrows=-1\relax
+ \else
+ \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)}%
+ \pgfplotstableuserowfalse
+ \fi
+ \fi
+ \ifpgfplotstableuserow
+ \expandafter\pgfplotstabletypeset@getfinalentry\expandafter{\pgfplotstable@entry}{\pgfplotstable@entry}%
+ \expandafter\pgfplotslistpushback\pgfplotstable@entry\to\pgfplotstable@col@processed
+ \advance\c@pgfplotstable@counta by1\relax
+ \fi
+ \fi
+ \advance\c@pgfplotstable@rowindex by1\relax
+ }%
+ \ifnum\pgfplotstable@firstnumrows=-1\relax
+ \xdef\pgfplotstable@firstnumrows{\the\c@pgfplotstable@counta}%
+ \else
+ % balance columns:
+ \pgfplotstable@insertemptycells@forbalance
+ \fi
+ %
+ \pgfplotstable@debug@notify@preprocessed@col\pgfplotstable@colname@out
+ %
+ \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols
+ \global\advance\c@pgfplotstable@colindex by1\relax
+ }%
+ %
+ \pgfplotstable@disable@column@styles
+ %
+ \pgfplotslistcheckempty\pgfplotstabletypeset@final@colnames
+ \ifpgfplotslistempty
+ \let\pgfplotstable@result=\pgfutil@empty
+ \else
+ % Ok, I have now everything which will come into the final table.
+ %
+ % But I have it column-oriented; I need to transpose the storage.
+ %
+ % The following code assembles a
+ % \begin{tabular}{}
+ % ...
+ % \end{tabular}
+ % statement piece after piece.
+ %
+ %\message{I have now \meaning\pgfplotstabletypeset@final@colnames, and \meaning\pgfplotstabletypeset@final@cols.}%
+ % Step 1: column names.
+ \c@pgfplotstable@colindex=0\relax
+ \c@pgfplotstable@rowindex=-1\relax
+ \let\pgfplotstable@result=\pgfutil@empty
+ %
+ \pgfkeysgetvalue{/pgfplots/table/font}{\pgfplotstable@font}%
+ \ifx\pgfplotstable@font\pgfutil@empty
+ \else
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@font}%
+ \edef\pgfplotstable@curline{\noexpand\begingroup\the\t@pgfplots@toka}%
+ \pgfplotstable@curline@FLUSH
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/table/begin table}{\pgfplotstable@entry}%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}%
+ \edef\pgfplotstable@curline{\the\t@pgfplots@toka}%
+ %
+ \ifpgfplotstabletypesetskipcoltypes
+ \else
+ % STEP 1.1: collect column types:
+ \def\pgfplotstable@resulttypes{}%
+ \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@coltypes\as\pgfplotstable@coltype{%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@resulttypes}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@coltype}%
+ \edef\pgfplotstable@resulttypes{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ }%
+ \ifx\pgfplotstable@resulttypes\pgfutil@empty
+ \else
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@resulttypes}%
+ \edef\pgfplotstable@curline{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}%
+ \fi
+ \fi
+ \ifx\pgfplotstable@curline\pgfutil@empty
+ \else
+ \pgfplotstable@curline@FLUSH
+ \fi
+ %
+ % Step 1.2: Collect FIRST ROW (column names)
+ \begingroup
+ \pgfplotstableset{every head row}%
+ \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}%
+ \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@before}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}%
+ \xdef\pgfplots@glob@TMPc{%
+ \noexpand\def\noexpand\pgfplotstable@before{\the\t@pgfplots@toka}%
+ \noexpand\def\noexpand\pgfplotstable@after{\the\t@pgfplots@tokb}%
+ }%
+ \pgfkeysgetvalue{/pgfplots/table/typeset cell/.@cmd}\pgfplots@loc@TMPa
+ \global\let\pgfplots@glob@TMPd=\pgfplots@loc@TMPa
+ \endgroup
+ \pgfplots@glob@TMPc
+ \let\pgfplotstable@headrow@typesetcell=\pgfplots@glob@TMPd
+ % insert 'before row' here:
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@before}%
+ \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
+ % typeset the cell:
+ \expandafter\pgfplotstable@headrow@typesetcell\pgfplotstable@colname@out\pgfeov
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ %
+ % append this cell:
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
+ \t@pgfplots@tokb=\expandafter{\pgfmathresult}%
+ \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ }%
+ % insert 'after row' here:
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}%
+ \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ %
+ \pgfplotstable@curline@FLUSH
+ %
+ %\message{I have now \meaning\pgfplotstable@result.}%
+ % Step 2: column contents.
+ % I will first convert \pgfplotstabletypeset@final@cols into an array.
+ \c@pgfplotstable@colindex=0\relax
+ \pgfplotsarraynewempty\pgfplotstabletypeset@final@cols@array
+ \pgfplotslistforeachungrouped\pgfplotstabletypeset@final@cols\as\pgfplotstable@col@processed{%
+ \expandafter\pgfplotsarraypushback\expandafter{\pgfplotstable@col@processed}\to\pgfplotstabletypeset@final@cols@array
+ }%
+ % init numrows:
+ \pgfplotsarrayselect\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array\to\pgfplotstable@col@processed
+ \pgfplotslistsize\pgfplotstable@col@processed\to\c@pgfplotstable@numrows
+ %
+ % Now, we loop over every column as long as there are still rows
+ % left. We assemble rows while we go.
+ %
+ \c@pgfplotstable@rowindex=0\relax
+ \ifnum\c@pgfplotstable@colindex<\c@pgfplotstable@numcols
+ \pgfplots@loop@CONTINUEtrue
+ \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
+ \pgfplotslistcheckempty\pgfplotstable@col@processed
+ \ifpgfplotslistempty
+ % assume that each column has the same number of entries
+ % (normalised tables):
+ \pgfplots@loop@CONTINUEfalse
+ \else
+ \ifnum\c@pgfplotstable@colindex=0\relax
+ % Install styles for the next row.
+ \begingroup
+ \ifodd\c@pgfplotstable@rowindex
+ \t@pgfplots@toka={every odd row}%
+ \else
+ \t@pgfplots@toka={every even row}%
+ \fi
+ \ifnum\c@pgfplotstable@rowindex=0\relax
+ \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every first row}%
+ \fi
+ \ifpgfplotstable@disable@rowcolstyles
+ \else
+ \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,every row no \the\c@pgfplotstable@rowindex/.try}%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}%
+ %
+ \ifnum\c@pgfplotstable@rowindex=0\relax
+ \else
+ % process 'every nth row' styles:
+ \begingroup
+ \pgfplots@each@nth@styles
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \t@pgfplots@tokb=\expandafter{\pgfplotsretval}%
+ \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}%
+ \fi
+ \fi
+ \fi
+ % misuse as temporary variable:
+ \c@pgfplotstable@colindex=\c@pgfplotstable@rowindex
+ \advance\c@pgfplotstable@colindex by1\relax
+ \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numrows
+ \t@pgfplots@toka=\expandafter{\the\t@pgfplots@toka,every last row}%
+ \fi
+ \expandafter\pgfplotstableset\expandafter{\the\t@pgfplots@toka}%
+ \pgfkeysgetvalue{/pgfplots/table/before row}{\pgfplotstable@before}%
+ \pgfkeysgetvalue{/pgfplots/table/after row}{\pgfplotstable@after}%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@before}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}%
+ \xdef\pgfplots@glob@TMPc{%
+ \noexpand\def\noexpand\pgfplotstable@before{\the\t@pgfplots@toka}%
+ \noexpand\def\noexpand\pgfplotstable@after{\the\t@pgfplots@tokb}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPc
+ % insert 'before row' here:
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@before}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@curline}%
+ \edef\pgfplotstable@curline{\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
+ \fi
+ %
+ %
+ \pgfplotslistpopfront\pgfplotstable@col@processed\to\pgfplotstable@entry
+ \pgfplotsarrayletentry\c@pgfplotstable@colindex\of\pgfplotstabletypeset@final@cols@array=\pgfplotstable@col@processed
+ \advance\c@pgfplotstable@colindex by1\relax
+ % typeset the cell:
+ \pgfkeysgetvalue{/pgfplots/table/typeset cell/.@cmd}\pgfplots@loc@TMPa
+ \expandafter\pgfplots@loc@TMPa\pgfplotstable@entry\pgfeov
+ \pgfkeysgetvalue{/pgfplots/table/@cell content}\pgfmathresult
+ %
+ % append this cell:
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
+ \t@pgfplots@tokb=\expandafter{\pgfmathresult}%
+ \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ %
+ \ifnum\c@pgfplotstable@colindex=\c@pgfplotstable@numcols\relax
+ \c@pgfplotstable@colindex=0\relax
+ % insert 'after row' here:
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@after}%
+ \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \advance\c@pgfplotstable@rowindex by1\relax
+ \pgfplotstable@curline@FLUSH
+ \fi
+ %\message{I have now \meaning\pgfplotstable@result.}%
+ \fi
+ \pgfutil@repeat
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@curline}%
+ \pgfkeysgetvalue{/pgfplots/table/end table}{\pgfplotstable@entry}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@entry}%
+ \edef\pgfplotstable@curline{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
+ \ifx\pgfplotstable@curline\pgfutil@empty
+ \else
+ \pgfplotstable@curline@FLUSH
+ \fi
+ %
+ \ifx\pgfplotstable@font\pgfutil@empty
+ \else
+ \edef\pgfplotstable@curline{\noexpand\endgroup}%
+ \pgfplotstable@curline@FLUSH
+ \fi
+ \ifx\pgfplotstable@outfilename\pgfutil@empty
+ \else
+ \immediate\closeout\pgfplotstable@outfile
+ \fi
+ %\message{I have now \meaning\pgfplotstable@result.}%
+ \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
+ \fi
+ \pgfkeysgetvalue{/pgfplots/table/write to macro}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \global\let\pgfplots@glob@TMPa=\relax
+ \else
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@result}%
+ \xdef\pgfplots@glob@TMPa{\noexpand\def\expandafter\noexpand\pgfplots@loc@TMPa{\the\t@pgfplots@toka}}%
+ \fi
+ \endgroup
+ \pgfplots@glob@TMPa% execute 'write to macro' if set.
+}%
+
+\def\pgfplotstable@disable@column@styles@error#1{%
+ \pgfplotsthrow{invalid argument}\pgfplots@loc@TMPa{Sorry, the key '#1' has been assigned while processing row options. However, it needs to be invoked while processing column options. If your options depend on specific row indices, consider using \string\pgfplotstablerow\space and \string\pgfplotstablerows}\pgfeov%
+}%
+\def\pgfplotstable@disable@column@styles@#1{%
+ \pgfkeysdef{/pgfplots/table/#1/.code}{\pgfplotstable@disable@column@styles@error{#1}}%
+ \pgfkeysdef{/pgfplots/table/#1/.append code}{\pgfplotstable@disable@column@styles@error{#1}}%
+ \pgfkeysdefargs{/pgfplots/table/#1/.add code}{##1##2}{\pgfplotstable@disable@column@styles@error{#1}}%
+ \pgfkeysdef{/pgfplots/table/#1/.append style}{\pgfplotstable@disable@column@styles@error{#1}}%
+}
+\def\pgfplotstable@disable@column@styles{%
+ \pgfplotstable@disable@column@styles@{postproc cell content}%
+ \pgfplotstable@disable@column@styles@{preproc cell content}%
+ \pgfplotstable@disable@column@styles@{assign cell content}%
+}%
+
+\newif\ifpgfplotstable@isfirstrow
+\newif\ifpgfplotstable@islastrow
+\newif\ifpgfplotstablecreatecol@isreallynew
+
+\def\pgfplotstablecreatecol@opt[#1]#2#3{%
+ \begingroup
+ \pgfkeysinterruptkeyfilter
+ \def\pgfplotstablename{#3}% the name of the table struct
+ \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
+ \else
+ \expandafter\pgfplotslistnew\expandafter\pgfplotstable@colnames\expandafter{\pgfplotstable@colnames}%
+ \fi
+ \pgfplotslistnewempty\pgfplotstable@colnames@real
+ \t@pgfplots@toka=\expandafter{#2}% this should handle macro names in '#2'.
+ \edef\pgfplotstable@newcolname{\the\t@pgfplots@toka}%
+ \global\pgfplotstablecreatecol@isreallynewtrue
+ \c@pgf@countd=0
+ \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{%
+ \pgfplotstable@is@colname\pgfplotstable@colname
+ \ifpgfplotstableread@foundcolnames
+ \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@colname}\to\pgfplotstable@colnames@real
+ \else
+ \pgfplotstablegetcolumnnamebyindex\pgfplotstable@colname\of#2\to\pgfplotstable@colname
+ \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@colname}\to\pgfplotstable@colnames@real
+ \fi
+ \ifx\pgfplotstable@colname\pgfplotstable@newcolname
+ \global\pgfplotstablecreatecol@isreallynewfalse
+ \fi
+ \expandafter\edef\csname pgfplotstablecreate@index@to@name@\the\c@pgf@countd\endcsname{\pgfplotstable@colname}%
+ \advance\c@pgf@countd by1
+ }%
+ \edef\pgfplotstablecols{\the\c@pgf@countd}%
+ \pgfplotstable@isfirstrowtrue
+ \pgfplotstable@islastrowfalse
+ \pgfplotslistnewempty\pgfplotstable@newcol
+ %
+ \let\c@pgfplotstable@numrows=\c@pgf@countd
+ \let\c@pgfplotstable@rowindex=\c@pgf@countc
+ \c@pgfplotstable@numrows=-1\relax
+ \c@pgfplotstable@rowindex=0\relax
+ \def\pgfplotstablerow{\the\c@pgfplotstable@rowindex}%
+ \def\pgfplotstablerows{\the\c@pgfplotstable@numrows}%
+ %
+ \def\prevrow##1{\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\pgfplotstable@rowno@impl##1##2{%
+ \pgfutil@ifundefined{pgfplotstablecreate@index@to@name@##1}{%
+ \csname ##2row\endcsname{colindex##1}%
+ }{%
+ \csname ##2row\endcsname{\csname pgfplotstablecreate@index@to@name@##1\endcsname}%
+ }%
+ }%
+ \def\prevrowno##1{\pgfplotstable@rowno@impl{##1}{prev}}%
+ \def\thisrowno##1{\pgfplotstable@rowno@impl{##1}{this}}%
+ \def\nextrowno##1{\pgfplotstable@rowno@impl{##1}{next}}%
+ %
+ \def\getprevrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@prev@##1\endcsname}%
+ \def\getthisrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@cur@##1\endcsname}%
+ \def\getnextrow##1##2{\expandafter\let\expandafter##2\csname pgfplotstablecreate@next@##1\endcsname}%
+ %
+ \pgfplots@loop@CONTINUEtrue
+ % allow this here to accumulate something.
+ \pgfutil@ifundefined{pgfmathaccuma}{%
+ \let\pgfmathaccuma=\pgfutil@empty
+ }{}%
+ \pgfutil@ifundefined{pgfmathaccumb}{%
+ \let\pgfmathaccumb=\pgfutil@empty
+ }{}%
+ \pgfutil@loop% loop over each row until there are no more rows.
+ \ifpgfplots@loop@CONTINUE
+ \ifnum\c@pgfplotstable@numrows=-1\relax
+ \pgfplotslistfront\pgfplotstable@colnames\to\pgfplotstable@colname
+ \expandafter\pgfplotslistsize\csname\string#3@\pgfplotstable@colname\endcsname\to\c@pgfplotstable@numrows
+ \fi
+ \pgfplotslistforeachungrouped\pgfplotstable@colnames\as\pgfplotstable@colname{%
+ \expandafter\pgfplotstableresolvecolname\expandafter{\pgfplotstable@colname}\of#3\to\pgfplotstable@real@colname
+ \ifpgfplotstable@isfirstrow
+ \expandafter\pgfplotslistcheckempty\csname\string#3@\pgfplotstable@real@colname\endcsname
+ \ifpgfplotslistempty
+ % the table is completely empty. break.
+ \pgfplots@loop@CONTINUEfalse
+ \else
+ \expandafter\let\csname pgfplotstablecreate@prev@\pgfplotstable@colname\endcsname=\pgfutil@empty
+ \expandafter\pgfplotslistpopfront\csname\string#3@\pgfplotstable@real@colname\endcsname\to\pgfplotstable@entry
+ \expandafter\let\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname=\pgfplotstable@entry
+ \fi
+ \else
+ \expandafter\let\expandafter\pgfplotstable@prev\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname
+ \expandafter\let\csname pgfplotstablecreate@prev@\pgfplotstable@colname\endcsname=\pgfplotstable@prev
+ %
+ \expandafter\let\expandafter\pgfplotstable@next\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname
+ \expandafter\let\csname pgfplotstablecreate@cur@\pgfplotstable@colname\endcsname=\pgfplotstable@next
+ \fi
+ \expandafter\pgfplotslistcheckempty\csname\string#3@\pgfplotstable@real@colname\endcsname
+ \ifpgfplotslistempty
+ \expandafter\let\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname=\pgfutil@empty
+ \pgfplotstable@islastrowtrue
+ \else
+ \expandafter\pgfplotslistpopfront\csname\string#3@\pgfplotstable@real@colname\endcsname\to\pgfplotstable@entry
+ \expandafter\let\csname pgfplotstablecreate@next@\pgfplotstable@colname\endcsname=\pgfplotstable@entry
+ \fi
+ }%
+ \ifpgfplots@loop@CONTINUE
+ % Compute content:
+ %
+ \begingroup
+ \ifpgfplotstable@isfirstrow
+ \pgfkeysvalueof{/pgfplots/table/create col/assign first/.@cmd}\pgfeov
+ \else
+ \ifpgfplotstable@islastrow
+ \pgfkeysvalueof{/pgfplots/table/create col/assign last/.@cmd}\pgfeov
+ \else
+ \pgfkeysvalueof{/pgfplots/table/create col/assign/.@cmd}\pgfeov
+ \fi
+ \fi
+ \pgfkeysgetvalue{/pgfplots/table/create col/next content}{\pgfplotstable@entry}%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@entry}%
+ \t@pgfplots@tokb=\expandafter{\pgfmathaccuma}%
+ \xdef\pgfplots@glob@TMPc{%
+ \noexpand\def\noexpand\pgfplotstable@entry{\the\t@pgfplots@toka}%
+ \noexpand\def\noexpand\pgfmathaccuma{\the\t@pgfplots@tokb}%
+ }%
+ \pgfmath@smuggleone\pgfmathaccumb
+ \endgroup
+ \pgfplots@glob@TMPc
+ \expandafter\pgfplotslistpushback\expandafter{\pgfplotstable@entry}\to\pgfplotstable@newcol
+ %
+ \ifpgfplotstable@islastrow
+ \pgfplots@loop@CONTINUEfalse
+ \fi
+ \fi
+ \pgfplotstable@isfirstrowfalse
+ \advance\c@pgfplotstable@rowindex by1\relax
+ \pgfutil@repeat
+ \endpgfkeysinterruptkeyfilter
+ \global\let\pgfplots@glob@TMPc=\pgfplotstable@newcol
+ \global\let\pgfplots@glob@TMPb=\pgfplotstable@newcolname
+ \endgroup
+ \ifpgfplotstablecreatecol@isreallynew
+ \expandafter\pgfplotslistpushback\expandafter{\pgfplots@glob@TMPb}\to#3%
+ \fi
+ \expandafter\let\csname\string#3@\pgfplots@glob@TMPb\endcsname=\pgfplots@glob@TMPc
+}%
+
+
+%-----------------------------------------------------------
+%
+% Implementation of '/pgfplots/table/create col/function graph cut y':
+%
+%-----------------------------------------------------------
+
+% create on use/cut/.style={create col/function graph cut y={7e-4}{x=Basis,ymode=log,xmode=log}{{table=regtable,y=special-L2}}},
+% #1 = value of fixed line (I call it epsilon)
+% #2 = options
+% #3 = specification where to get the y from. It is a comma separated
+% list of key-value sets, on set for every y(x) graph which shall be
+% used.
+% #4 = the direction in which the line does NOT vary (either 'x' or 'y')
+% #5 = the direction in which the line DOES vary (either 'x' or 'y')
+\def\pgfplotstable@fgc@init#1#2#3#4#5{%
+ \def\pgfplotstable@fgc@xmode{0}%
+ \def\pgfplotstable@fgc@ymode{0}%
+ %
+ \pgfkeysalso{/pgf/fpu=true}%
+ %
+ \pgfqkeys{/pgfplots/table/create col/function graph cut}{#2}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table
+ \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!
+ \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
+ %
+ \ifnum\csname pgfplotstable@fgc@#4mode\endcsname=1
+ \pgfmathparse{ln(#1)}%
+ \else
+ \pgfmathparse{#1}%
+ \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 ...}%
+ \pgfplotslistcheckempty\pgfmathaccumb
+ \ifpgfplotslistempty
+ \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}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
+ % acquire any sources:
+ \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/table}\pgfplotstable@fgc@table
+ \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/x}\pgfplotstable@fgc@x
+ \pgfkeysgetvalue{/pgfplots/table/create col/function graph cut/y}\pgfplotstable@fgc@y
+ \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
+ \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
+ \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
+%
+% POSTCONDITION:
+% - \pgfplotstable@fgc@abscissafirst and \pgfplotstable@fgc@abscissasecond
+% contain the abscissa values
+%
+\def\pgfplotstable@fgc@getassociated#1#2{%
+ \c@pgfplotstable@counta=\pgfplotstable@fgc@index
+ \pgfplotslistselect\c@pgfplotstable@counta\of#1\to\pgfplotstable@fgc@abscissasecond
+ \advance\c@pgfplotstable@counta by-1
+ \pgfplotslistselect\c@pgfplotstable@counta\of#1\to\pgfplotstable@fgc@abscissafirst
+ \pgfmathfloatparsenumber{\pgfplotstable@fgc@abscissafirst}%
+ \let\pgfplotstable@fgc@abscissafirst=\pgfmathresult
+ \pgfmathfloatparsenumber{\pgfplotstable@fgc@abscissasecond}%
+ \let\pgfplotstable@fgc@abscissasecond=\pgfmathresult
+ \if1#2
+ \pgfmathln@{\pgfplotstable@fgc@abscissafirst}%
+ \let\pgfplotstable@fgc@abscissafirst=\pgfmathresult
+ \pgfmathln@{\pgfplotstable@fgc@abscissasecond}%
+ \let\pgfplotstable@fgc@abscissasecond=\pgfmathresult
+ \fi
+}%
+
+% Search for the (first) interval in #1 containing epsilon and return
+% \pgfplotstable@fgc@first and \pgfplotstable@fgc@second.
+%
+% #1 : the list of values.
+% #2 : the mode (0 = linear, 1 = log)
+%
+% PRECONDITION:
+% - \pgfplotstable@fgc@eps contains the value to search for
+%
+% POSTCONDITION
+% On success,
+% - \pgfplotstable@fgc@first and \pgfplotstable@fgc@second contain the interval.
+% - \pgfplotstable@fgc@index contains the index of the @second coordinate.
+% - \pgfplotstable@fgc@lastwasless is
+% 1 if \pgfplotstable@fgc@second < eps
+% 0 if \pgfplotstable@fgc@second >= eps
+% If there was no such interval,
+% \pgfplotstable@fgc@second will be empty.
+\def\pgfplotstable@fgc@findintervalwitheps#1#2{%
+ \global\let\pgfplotstable@fgc@first=\pgfutil@empty
+ \global\let\pgfplotstable@fgc@second=\pgfutil@empty
+ \global\def\pgfplotstable@fgc@lastwasless{2}%
+ \global\def\pgfplotstable@fgc@break{0}%
+ \global\def\pgfplotstable@fgc@index{0}%
+ \pgfplotslistforeach#1\as\pgfplotstable@fgc@val{%
+ \if\pgfplotstable@fgc@break0
+ \pgfmathfloatparsenumber{\pgfplotstable@fgc@val}%
+ \let\pgfplotstable@fgc@val=\pgfmathresult
+ \ifnum#2=1
+ \pgfmathln@{\pgfplotstable@fgc@val}%
+ \let\pgfplotstable@fgc@val=\pgfmathresult
+ \fi
+ \pgfmathfloatlessthan@{\pgfplotstable@fgc@val}{\pgfplotstable@fgc@eps}%
+ \ifpgfmathfloatcomparison
+ \pgfplotstable@fgc@findintervalwitheps@updateresult 01%
+ \else
+ \pgfplotstable@fgc@findintervalwitheps@updateresult 10%
+ \fi
+ \fi
+ }%
+}%
+
+% #1 : the value of \pgfplotstable@fgc@lastwasless for which the loop
+% shall break.
+% #2 : the next value for \pgfplotstable@fgc@lastwasless
+\def\pgfplotstable@fgc@findintervalwitheps@updateresult#1#2{%
+ \if\pgfplotstable@fgc@lastwasless#1
+ % found it !
+ \global\let\pgfplotstable@fgc@second=\pgfplotstable@fgc@val
+ \global\def\pgfplotstable@fgc@break{1}%
+ \else
+ \global\let\pgfplotstable@fgc@first=\pgfplotstable@fgc@val
+ \c@pgfplotstable@counta=\pgfplotstable@fgc@index
+ \advance\c@pgfplotstable@counta by1
+ \xdef\pgfplotstable@fgc@index{\the\c@pgfplotstable@counta}%
+ \fi
+ \global\def\pgfplotstable@fgc@lastwasless{#2}%
+}%
+
+
+
+\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{%
+ \t@pgfplots@toka=\expandafter{\pgfplots@colname}%
+ \ifnum\pgfplotstablecol=0
+ \edef\pgfplotstable@colnames{{\the\t@pgfplots@toka}}%
+ \else
+ \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\pgfplotstabletranspose@outcolnames@foundit{0}%
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotstable@colnames}\as\pgfplots@colname{%
+ \ifx\pgfplots@colname\pgfplotstabletranspose@outcolnames
+ \def\pgfplotstabletranspose@outcolnames@foundit{1}%
+ \fi
+ }%
+ \if1\pgfplotstabletranspose@outcolnames@foundit
+ \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
+ %
+ % The column NAMES are collected into this list:
+ \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
+ \fi
+ \advance\c@pgfplotstable@rowindex by1
+ \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
+ \fi
+ \advance\c@pgfplotstable@rowindex by1
+ }%
+ \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}%
+}%
+
+% #1: keys
+\def\pgfplotstable@linear@regression#1{%
+ \begingroup
+ \pgfqkeys{/pgfplots/table/create col/linear regression}{/pgf/fpu,#1}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/x}{\pgfplotstable@xsrc}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/y}{\pgfplotstable@ysrc}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/table}{\pgfplotstable@table}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/xmode}{\pgfplotstable@xmode}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/ymode}{\pgfplotstable@ymode}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance}{\pgfplotstable@variance@colname}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance list}{\pgfplotstable@variance@list}%
+ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance src}{\pgfplotstable@variance@table}%
+ %
+ \ifx\pgfplotstable@table\pgfutil@empty
+ \pgfutil@ifundefined{pgfplotstablename}{}{% query the name of the actual table struct
+ \let\pgfplotstable@table=\pgfplotstablename
+ }%
+ \fi
+ \ifx\pgfplotstable@table\pgfutil@empty
+ \pgfplots@error{Sorry, I couldn't determine a value for create col/linear regression/table. Which table should I load?}%
+ \fi
+ \ifx\pgfplotstable@xsrc\pgfutil@empty
+ \pgfplotsifinaddplottablestruct{%
+ \pgfutil@ifundefined{pgfplots@plot@tbl@x}{}{%
+ \let\pgfplotstable@xsrc=\pgfplots@plot@tbl@x
+ \ifx\pgfplotstable@ysrc\pgfutil@empty
+ \pgfplotstablegetcolsof\pgfplots@table
+ \ifnum\pgfplotsretval=2
+ \else
+ \pgfplotsthrow{invalid argument}{\pgfplotstable@ysrc}{Sorry, I don't which column should be used as `y' for the linear regression. Please provide 'linear regression={y=<colname>}'}\pgfeov%
+ \fi
+ \fi
+ }%
+ }{}%
+ \fi
+ \ifx\pgfplotstable@xsrc\pgfutil@empty
+ \def\pgfplotstable@xsrc{[index]0}%
+ \fi
+ \ifx\pgfplotstable@ysrc\pgfutil@empty
+ \def\pgfplotstable@ysrc{[index]1}%
+ \fi
+ %
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@xsrc}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotstable@ysrc}%
+ \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
+ \edef\pgfplots@loc@TMPb{{\the\t@pgfplots@tokc}\noexpand\of{\the\t@pgfplots@toka}}%
+ \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@X
+ \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPb\to\pgfplotstable@Y
+ %
+ \edef\pgfplotstable@xmode{\pgfplotstable@xmode}%
+ \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@xmode}{x}%%
+ \edef\pgfplotstable@ymode{\pgfplotstable@ymode}%
+ \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@ymode}{y}%%
+ %
+ \ifx\pgfplotstable@variance@list\pgfutil@empty
+ % check 'variance' key (loaded from table)
+ \pgfplotslistnewempty\pgfplotstable@VARIANCE
+ \ifx\pgfplotstable@variance@colname\pgfutil@empty
+ \else
+ \ifx\pgfplotstable@variance@table\pgfutil@empty
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@colname}%
+ \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
+ \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@VARIANCE
+ \else
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@variance@colname}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@table}%
+ \edef\pgfplotstable@loc@TMPa{%
+ \noexpand\pgfplotstablegetcolumn{\the\t@pgfplots@toka}\noexpand\of{\the\t@pgfplots@tokb}\noexpand\to\noexpand\pgfplotstable@VARIANCE}%
+ \pgfplotstable@loc@TMPa
+ \fi
+ \fi
+ \else
+ % load from list:
+ \expandafter\pgfplotslistnew\expandafter\pgfplotstable@VARIANCE\expandafter{\pgfplotstable@variance@list}%
+ \fi
+ %
+ \pgfplotslistnewempty\pgfplotstable@Xparsed
+ %
+ \pgfmathfloatcreate{0}{0.0}{0}%
+ \let\pgfplotstable@S=\pgfmathresult
+ \let\pgfplotstable@Sxx=\pgfmathresult
+ \let\pgfplotstable@Sx=\pgfmathresult
+ \let\pgfplotstable@Sy=\pgfmathresult
+ \let\pgfplotstable@Sxy=\pgfmathresult
+ \pgfutil@loop
+ \pgfplotslistcheckempty\pgfplotstable@X
+ \ifpgfplotslistempty
+ \pgfplots@loop@CONTINUEfalse
+ \else
+ \pgfplots@loop@CONTINUEtrue
+ \fi
+ \ifpgfplots@loop@CONTINUE
+ \pgfplotslistpopfront\pgfplotstable@X\to\pgfplotstable@x
+ \pgfplotslistpopfront\pgfplotstable@Y\to\pgfplotstable@y
+ %
+ \pgfplotstableparsex{\pgfplotstable@x}%
+ \let\pgfplotstable@x=\pgfmathresult
+ \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@Xparsed
+ \pgfplotstableparsey{\pgfplotstable@y}%
+ \let\pgfplotstable@y=\pgfmathresult
+ %
+ \pgfplotslistcheckempty\pgfplotstable@VARIANCE
+ \ifpgfplotslistempty
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \let\pgfplotstable@invsqr=\pgfmathresult
+ \else
+ \pgfplotslistpopfront\pgfplotstable@VARIANCE\to\pgfplotstable@variance
+ \pgfmathfloatparsenumber{\pgfplotstable@variance}%
+ \let\pgfplotstable@variance=\pgfmathresult
+ \pgfmathfloatmultiply@{\pgfplotstable@variance}{\pgfplotstable@variance}%
+ \let\pgfplotstable@sqr=\pgfmathresult
+ \pgfmathfloatreciprocal@{\pgfplotstable@sqr}%
+ \let\pgfplotstable@invsqr=\pgfmathresult
+ \fi
+ %
+ \pgfmathfloatadd@{\pgfplotstable@S}{\pgfplotstable@invsqr}%
+ \let\pgfplotstable@S=\pgfmathresult
+ %
+ \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@invsqr}%
+ \let\pgfplots@table@accum=\pgfmathresult
+ \pgfmathfloatadd@{\pgfplotstable@Sx}{\pgfplots@table@accum}%
+ \let\pgfplotstable@Sx=\pgfmathresult
+ %
+ \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}%
+ \let\pgfplots@table@accum=\pgfmathresult
+ \pgfmathfloatadd@{\pgfplotstable@Sxx}{\pgfplots@table@accum}%
+ \let\pgfplotstable@Sxx=\pgfmathresult
+ %
+ \pgfmathfloatmultiply@{\pgfplotstable@y}{\pgfplotstable@invsqr}%
+ \let\pgfplots@table@accum=\pgfmathresult
+ \pgfmathfloatadd@{\pgfplotstable@Sy}{\pgfplots@table@accum}%
+ \let\pgfplotstable@Sy=\pgfmathresult
+ %
+ \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}%
+ \let\pgfplots@table@accum=\pgfmathresult
+ \pgfmathfloatadd@{\pgfplotstable@Sxy}{\pgfplots@table@accum}%
+ \let\pgfplotstable@Sxy=\pgfmathresult
+ \pgfutil@repeat
+ %
+ \pgfmathparse{\pgfplotstable@S * \pgfplotstable@Sxx - \pgfplotstable@Sx *\pgfplotstable@Sx}%
+ \let\pgfplotstable@delta=\pgfmathresult
+ %
+ \pgfmathparse{(\pgfplotstable@S * \pgfplotstable@Sxy - \pgfplotstable@Sx * \pgfplotstable@Sy) / \pgfplotstable@delta}%
+ \let\pgfplotstable@a=\pgfmathresult
+ %
+ \pgfmathparse{(\pgfplotstable@Sxx * \pgfplotstable@Sy - \pgfplotstable@Sx * \pgfplotstable@Sxy) / \pgfplotstable@delta}%
+ \let\pgfplotstable@b=\pgfmathresult
+ %
+ \pgfplotslistnewempty\pgfplotstable@RESULT
+ \pgfplotslistforeachungrouped\pgfplotstable@Xparsed\as\pgfplotstable@x{%
+ \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@a}%
+ \let\pgfplotstable@tmp=\pgfmathresult
+ \pgfmathfloatadd@{\pgfplotstable@tmp}{\pgfplotstable@b}%
+ \ifx\pgfplotstableparseylogbase\pgfutil@empty
+ \else
+ \pgfplotstableparseyinv@{\pgfmathresult}%
+ \fi
+ \pgfmathfloattosci{\pgfmathresult}%
+ \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@RESULT
+ }%
+ \pgfmathfloattosci\pgfplotstable@a
+ \let\pgfplotstable@a=\pgfmathresult
+ %
+ \pgfmathfloattosci\pgfplotstable@b
+ \let\pgfplotstable@b=\pgfmathresult
+ %
+ \global\let\pgfplotstableregressiona\pgfplotstable@a%
+ \global\let\pgfplotstableregressionb\pgfplotstable@b%
+ \let\pgfplotsretval=\pgfplotstable@RESULT
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotstable@linear@regression@prepare@mode#1#2{%
+ \expandafter\def\csname pgfplotstableparse#2\endcsname##1{\pgfmathfloatparsenumber{##1}}%
+ \expandafter\def\csname pgfplotstableparse#2logbase\endcsname{}%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \def\pgfplots@loc@TMPb{auto}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \def\pgfplots@loc@TMPa{}% auto == empty string
+ \fi
+ %
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % `auto' mode.
+ \pgfplotsifinaxis{%
+ \pgfplots@if{pgfplots@#2islinear}{%
+ \def\pgfplots@loc@TMPa{linear}%
+ }{%
+ \def\pgfplots@loc@TMPa{log}%
+ }%
+ }{%
+ \def\pgfplots@loc@TMPa{linear}%
+ }%
+ \fi
+ %
+ \def\pgfplots@loc@TMPb{linear}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \else
+ \def\pgfplots@loc@TMPb{log}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \pgfplotsmathdefinemacrolnbase{pgfplotstableparse#2}{\pgfkeysvalueof{/pgfplots/log basis #2}}%
+ \else
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, the value '#1' is unexpected for 'linear regression/#2mode'}\pgfeov%
+ \fi
+ \fi
+}%
+
+
+% Sorts table #3 according to options defined in #1 and writes result
+% to #2.
+%
+% \pgfplotstablesort[sort key=<colname>]\result{<input table>}
+% \pgfplotstablesort[sort key=<colname>,sort key source=<\table>]\result{<input table>}
+\def\pgfplotstablesort{\pgfutil@ifnextchar[{\pgfplotstablesort@opt}{\pgfplotstablesort@opt[]}}
+\def\pgfplotstablesort@opt[#1]#2{%
+ \begingroup
+ \pgfplotstableset{#1}%
+ \pgfplotstablecollectoneargwithpreparecatcodes{%
+ \pgfplotstablesort@{#2}%
+ }%
+}
+\def\pgfplotstablesort@#1#2{%
+ \pgfkeysgetvalue{/pgfplots/table/sort key}\pgfplotstable@sort@key@colname
+ \pgfkeysgetvalue{/pgfplots/table/sort key from}\pgfplotstable@sort@key@table
+ \pgfkeysgetvalue{/pgfplots/table/sort cmp}\pgfplotstable@sort@cmp
+ %
+ %
+ \pgfplotstable@isloadedtable{#2}{%
+ \pgfplotstablegetrowsof{#2}%
+ \let\pgfplotstable@numrows=\pgfplotsretval
+ %
+ \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp{#2}%
+ \def\pgfplotstable@table{#2}%
+ \let\pgfplotstable@input@colnames=#2\relax
+ }{%
+ \pgfplotstableread{#2}\pgfp@tmp@in
+ \pgfplotstablegetrowsof\pgfp@tmp@in
+ \let\pgfplotstable@numrows=\pgfplotsretval
+ \def\pgfplotstable@table{\pgfp@tmp@in}%
+ \let\pgfplotstable@input@colnames=\pgfp@tmp@in
+ %
+ \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp\pgfp@tmp@in
+ }%
+ %
+ \ifx\pgfplotstable@sort@key@colname\pgfutil@empty
+ \else
+ \ifx\pgfplotstable@sort@key@table\pgfutil@empty
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@sort@key@colname}%
+ \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
+ \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@sort@key
+ \else
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@sort@key@colname}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotstable@sort@key@table}%
+ \edef\pgfplotstable@loc@TMPa{%
+ \noexpand\pgfplotstablegetcolumn{\the\t@pgfplots@toka}\noexpand\of{\the\t@pgfplots@tokb}\noexpand\to\noexpand\pgfplotstable@sort@key}%
+ \pgfplotstable@loc@TMPa
+ \fi
+ \fi
+ \pgfplotsarraynewempty\pgfplotstable@sort@key@array
+ \pgfplotslistforeachungrouped{\pgfplotstable@sort@key}\as\pgfplotstable@loc@TMPa{%
+ \expandafter\pgfplotsarraypushback\expandafter{\pgfplotstable@loc@TMPa}\to\pgfplotstable@sort@key@array
+ }%
+ %
+ %
+ % use a side effect: columns are integers, they are stored as
+ % '\pgfp@tmp@<index>'. Thus, column names and array indices are
+ % essentially the same! That simplifies the operation and explains
+ % why we transposed the table.
+ % We simply interprete the transposed table as array. We don't
+ % even need to copy anything.
+ \pgfplotsarrayresize{\pgfp@tmp}{\pgfplotstable@numrows}%
+ % Oh, we also need the index to access the sort key. Well, then we
+ % did not win anything.
+ \pgfplotsarrayforeachungrouped\pgfp@tmp\as\pgfplotstable@loc@TMPa{%
+ \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}%
+ \edef\pgfplotstable@loc@TMPa{\pgfplotsarrayforeachindex:{\the\t@pgfplots@toka}}%
+ \pgfplotsarrayletentry{\pgfplotsarrayforeachindex}\of\pgfp@tmp=\pgfplotstable@loc@TMPa
+ }%
+ % extract current row index and row content:
+ \def\pgfplotstable@sort@extractindex##1:##2{%
+ \def\pgfmathresult{##1}%
+ \def\pgfplotstable@row{##2}%
+ }%
+ %
+ \expandafter\pgfplotsset\expandafter{\pgfplotstable@sort@cmp}%
+ \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotstable@sort@cmp@routine
+ \def\pgfplotstable@sort@iflt##1##2##3##4{\pgfplotstable@sort@cmp@routine{##1}{##2}{##3}{##4}\pgfeov}%
+ %
+ \pgfkeysdefargs{/pgfplots/iflessthan}{##1##2##3##4}{%
+ \expandafter\pgfplotstable@sort@extractindex##1%
+ \pgfplotsarrayselect{\pgfmathresult}\of\pgfplotstable@sort@key@array\to\pgfplotstable@arga
+ \expandafter\pgfplotstable@sort@extractindex##2%
+ \pgfplotsarrayselect{\pgfmathresult}\of\pgfplotstable@sort@key@array\to\pgfplotstable@argb
+ \pgfplotstable@sort@iflt{\pgfplotstable@arga}{\pgfplotstable@argb}{##3}{##4}%
+ }%
+ \pgfkeysdef{/pgfplots/array/unscope pre}{%
+ % remove the row index:
+ \pgfplotsarrayforeachungrouped\pgfp@tmp\as\pgfplotstable@loc@TMPa{%
+ \expandafter\pgfplotstable@sort@extractindex\pgfplotstable@loc@TMPa%
+ \pgfplotsarrayletentry{\pgfplotsarrayforeachindex}\of\pgfp@tmp=\pgfplotstable@row
+ }%
+ % restore original form:
+ \pgfplotstabletranspose[input colnames to=,colnames from=]\pgfp@tmp@result\pgfp@tmp
+ % technical, transport result out of the current scope ...
+ \pgfplotstable@copy@to@globalbuffers\pgfp@tmp@result{\pgfplotstablenameof\pgfp@tmp}%
+ % ... and use this lowlevel thing to transport the original column names.
+ \global\let\pgfplotstable@colnames@glob=\pgfplotstable@input@colnames
+ }%
+ \pgfkeysdef{/pgfplots/array/unscope post}{}%
+ \pgfplotsarraysort{\pgfp@tmp}%
+ \endgroup
+ \pgfplotstable@copy@globalbuffers@to{#1}%
+}%
+
+\pgfutil@IfUndefined{pgfcalendardatetojulian}{%
+ \def\pgfcalendardatetojulian#1#2{\pgfplots@error{Sorry, you need to use \string\usepackage{pgfcalendar} before using date specific methods}}%
+}{}%
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.coltype.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.coltype.code.tex
new file mode 100644
index 0000000000..8c0000b324
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.coltype.code.tex
@@ -0,0 +1,93 @@
+%--------------------------------------------
+%
+% Package numtable.
+%
+% This file provides support for column types in LaTeX tabular
+% environments, i.e.
+%
+%\begin{tabular}{>{\pgfplotstablecoltype}c<{\endpgfplotstablecoltype}}
+% 1 \\
+% 2 \\
+% 3 \\
+%\end{tabular}
+%
+%
+%
+% 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/>.
+%
+%--------------------------------------------
+
+
+
+% If I did not get it wrong, the tabular package, initialised with a
+% column type like
+% >{\pgfplotstablecoltype}c<{\endpgfplotstablecoltype}
+% yields
+%
+% \pgfplotstablecoltype \ignorespaces <content> \unskip \endpgfplotstablecoltype
+% OR
+% \pgfplotstablecoltype \ignorespaces <content> \\ \endpgfplotstablecoltype
+%
+% So, I define \pgfplotstablecoltype to skip \ignorespaces and \unskip and simply
+% get <content>.
+\def\pgfplotstablecoltype{%
+ \begingroup
+ \let\pgfplotstablecoltype@content=\empty
+ \pgfutil@ifnextchar[{%
+ \pgfplotstablecoltype@
+ }{%
+ \pgfplotstablecoltype@until@end@start
+ }%
+}%
+\def\pgfplotstablecoltype@[#1]{%
+ \pgfqkeys{/pgf/number format}{#1}%
+ \pgfplotstablecoltype@until@end@start
+}%
+
+\def\pgfplotstablecoltype@until@end@start\ignorespaces{%
+ \pgfplotstablecoltype@until@end
+}%
+\def\pgfplotstablecoltype@until@end{%
+ \pgfutil@ifnextchar\\{%
+ \pgfplotstablecoltype@finish%
+ }{%
+ \pgfutil@ifnextchar{\unskip}{%
+ \pgfplotstablecoltype@finish%
+ }{%
+ \pgfplotstablecoltype@next
+ }%
+ }%
+}
+\def\pgfplotstablecoltype@next#1{%
+ \expandafter\def\expandafter\pgfplotstablecoltype@content\expandafter{\pgfplotstablecoltype@content#1}%
+ \pgfplotstablecoltype@until@end
+}
+\def\pgfplotstablecoltype@finish{%
+%\message{COLLECTED \meaning\pgfplotstablecoltype@content}%
+ \edef\pgfplotstablecoltype@content{\pgfplotstablecoltype@content}%
+ %
+ % trim white space:
+ \expandafter\pgfkeys@spdef\expandafter\pgfplotstablecoltype@content\expandafter{\pgfplotstablecoltype@content}%
+ %
+ \ifx\pgfplotstablecoltype@content\pgfutil@empty
+ \else
+ \pgfmathprintnumber{\pgfplotstablecoltype@content}%
+ \fi
+ \endgroup
+}%
+
+%\def\pgfplotstablecoltype{\message{COLLECT}}%
+\def\endpgfplotstablecoltype{}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.sty b/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.sty
new file mode 100644
index 0000000000..948a9885fa
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.sty
@@ -0,0 +1,39 @@
+%--------------------------------------------
+%
+% Package pgfplotstable.sty
+%
+% Copyright 2007-2011 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/>.
+%
+%--------------------------------------------
+\IfFileExists{pgfplots.revision.tex}{\input pgfplots.revision.tex } {%
+ \def\pgfplotsrevision{0}%
+ \def\pgfplotsversion{0.0}%
+ \def\pgfplotsversiondatetime{2014-07-01 00:00:00 +100}%
+ \def\pgfplotsrevisiondatetime{2014-07-01 00:00:00 +100}%
+ \def\pgfplotsversiondate{2014/07/01}%
+ \def\pgfplotsrevisiondate{2014/07/01}%
+}
+\ProvidesPackage{pgfplotstable}[\pgfplotsversiondate\space v\pgfplotsversion\space Table typesetting and Pretty-printing (\pgfplotsrevision)]
+
+\RequirePackage{pgfplots}
+
+\def\pgfplots@texdist@protect{\protect}%
+
+\input pgfplotstable.code.tex
+
+\RequirePackage{array} % for |dec sep align|
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.tex
new file mode 100644
index 0000000000..c445da336b
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotstable.tex
@@ -0,0 +1,38 @@
+%--------------------------------------------
+%
+% Package pgfplots
+%
+% 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/>.
+%
+%--------------------------------------------
+% ATTENTION:
+% you MAY need one of
+% \def\pgfsysdriver{pgfsys-dvipdfm.def}
+% \def\pgfsysdriver{pgfsys-pdftex.def}
+% \def\pgfsysdriver{pgfsys-dvips.def}
+%
+% BEFORE the first \input pgf.tex, \input tikz.tex or
+% \input pgfplots.tex
+% Default is
+% 'dvips' for 'tex'
+% 'pdftex' for 'pdftex'
+% -> dvipdfm needs special attention.
+%
+\input pgfplots.tex%
+%
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotstableshared.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotstableshared.code.tex
new file mode 100644
index 0000000000..b8f63abe8a
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotstableshared.code.tex
@@ -0,0 +1,2111 @@
+%--------------------------------------------
+%
+% Package pgfplotstable
+%
+% Provides support to read and work with abstact numeric tables of the
+% form
+%
+% COLUMN1 COLUMN2 COLUMN3
+% 1 2 3
+% 4 4 552
+% 1e124 0.00001 1.2345e-12
+% ...
+%
+% Copyright 2007-2010 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 high-level table manipulation and typesetting
+% package.
+%
+%
+% ---------------------------------------------
+% Implementation notes for programmers:
+% ---------------------------------------------
+%
+% The table data structure consists of
+% 1. A name which must be a valid TeX macro like '\table'
+% 2. A column list in the \pgfplotslist format.
+% In fact, the column list is stored in the table's name:
+% \pgfplotslistnewempty\table
+% 3. A "file name" stored in
+% \csname\string<\namemacro>@@table@name\endcsname
+% 4. 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
+\newtoks\t@pgfplotstable@a
+\newif\ifpgfplots@addplotimpl@readcompletely
+% 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
+\newif\ifpgfplotstable@trimcells
+\newif\ifpgfplotstable@search@path@implicit@CWD
+
+\pgfkeys{%
+ /pgfplots/table/every table/.style={},
+ /pgfplots/table/.unknown/.code={%
+ \pgfplotstable@error@pkg{Sorry, I do not know the key `\pgfkeyscurrentkeyRAW' and I am going to ignore it. Perhaps you need \string\usepackage{pgfplotstable}? (The table typesetting parts are a separate package)}%
+ },%
+ /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/search path/.initial=.,
+ /pgfplots/table/search path/implicit ./.is if=pgfplotstable@search@path@implicit@CWD,
+ /pgfplots/table/search path/implicit .=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/.style={
+ x error plus index={#1},%
+ x error minus index={#1}%
+ },
+ /pgfplots/table/y error index/.style={
+ y error plus index={#1},%
+ y error minus index={#1}%
+ },
+ /pgfplots/table/z error index/.style={
+ z error plus index={#1},%
+ z error minus index={#1}%
+ },
+ /pgfplots/table/x error/.style={
+ x error plus={#1},%
+ x error minus={#1}%
+ },
+ /pgfplots/table/y error/.style={
+ y error plus={#1},%
+ y error minus={#1}%
+ },
+ /pgfplots/table/z error/.style={
+ z error plus={#1},%
+ z error minus={#1}%
+ },
+ /pgfplots/table/x error expr/.style={
+ x error plus expr={#1},%
+ x error minus expr={#1}%
+ },
+ /pgfplots/table/y error expr/.style={
+ y error plus expr={#1},%
+ y error minus expr={#1}%
+ },
+ /pgfplots/table/z error expr/.style={
+ z error plus expr={#1},%
+ z error minus expr={#1}%
+ },
+ /pgfplots/table/x error plus index/.initial=,
+ /pgfplots/table/y error plus index/.initial=,
+ /pgfplots/table/z error plus index/.initial=,
+ /pgfplots/table/x error plus/.initial=,
+ /pgfplots/table/y error plus/.initial=,
+ /pgfplots/table/z error plus/.initial=,
+ /pgfplots/table/x error plus expr/.initial=,
+ /pgfplots/table/y error plus expr/.initial=,
+ /pgfplots/table/z error plus expr/.initial=,
+ /pgfplots/table/x error minus index/.initial=,
+ /pgfplots/table/y error minus index/.initial=,
+ /pgfplots/table/z error minus index/.initial=,
+ /pgfplots/table/x error minus/.initial=,
+ /pgfplots/table/y error minus/.initial=,
+ /pgfplots/table/z error minus/.initial=,
+ /pgfplots/table/x error minus expr/.initial=,
+ /pgfplots/table/y error minus expr/.initial=,
+ /pgfplots/table/z error minus expr/.initial=,
+ /pgfplots/table/ignore chars/.initial=,
+ /pgfplots/table/white space chars/.initial=,
+ /pgfplots/table/text special chars/.initial=,
+ /pgfplots/table/comment chars/.initial=,
+ /pgfplots/table/skip first n/.initial=0,
+ /pgfplots/table/trim cells/.is if=pgfplotstable@trimcells,
+ /pgfplots/table/trim cells/.default=true,
+ /pgfplots/table/read completely/.is choice,
+ /pgfplots/table/read completely/true/.code= \pgfplots@addplotimpl@readcompletelytrue\def\pgfplots@addplotimpl@readcompletely@auto{0},
+ /pgfplots/table/read completely/false/.code=\pgfplots@addplotimpl@readcompletelyfalse\def\pgfplots@addplotimpl@readcompletely@auto{0},
+ /pgfplots/table/read completely/auto/.code=\pgfplots@addplotimpl@readcompletelyfalse\def\pgfplots@addplotimpl@readcompletely@auto{1},
+ /pgfplots/table/read completely/.default=true,
+ /pgfplots/table/read completely=auto,
+ /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/&/.code = {\def\pgfplotstableread@COLSEP@CASE{6}\pgfplotstable@trimcellstrue},
+ /pgfplots/table/col sep/ampersand/.code = {\def\pgfplotstableread@COLSEP@CASE{6}\pgfplotstable@trimcellstrue},
+ /pgfplots/table/col sep=space,
+ /pgfplots/table/format/.is choice,
+ /pgfplots/table/format/auto/.code = {\def\pgfplotstableread@FORMAT@CASE{0}},
+ /pgfplots/table/format/inline/.code = {\def\pgfplotstableread@FORMAT@CASE{1}},
+ /pgfplots/table/format/file/.code = {\def\pgfplotstableread@FORMAT@CASE{2}},
+ /pgfplots/table/format=auto,
+ /pgfplots/table/row sep/.code={%
+ \pgfplotsutilifstringequal{#1}{\\}{%
+ \def\pgfplotstableread@ROWSEP@CASE{1}%
+ }{%
+ \pgfplotsutilifstringequal{#1}{crcr}{%
+ \def\pgfplotstableread@ROWSEP@CASE{1}%
+ }{%
+ \pgfplotsutilifstringequal{#1}{newline}{%
+ \def\pgfplotstableread@ROWSEP@CASE{0}%
+ }{%
+ {%
+ \t@pgfplots@tokc={#1}%
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, the choice `row sep=\the\t@pgfplots@tokc' is not known. Maybe you misspelled it? Try `\string\\' or `newline'.}\pgfeov%
+ }%
+ }%
+ }%
+ }%
+ },%
+ /pgfplots/table/row sep=newline,
+}
+
+\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
+ },%
+ /pgfplots/exception/table columns unbalanced/.code={%
+ \ifx\pgfplotsexceptionmsg\relax
+ \pgfplots@error{#1}%
+ \else
+ \pgfplots@error{\pgfplotsexceptionmsg}%
+ \fi
+ },
+}
+
+% \pgfplotstableread[OPTIONS] {FILE} to \name
+%
+% This method reads a table from FILE to macro \name.
+%
+% FILE is something like
+% G Basis dof L2 A Lmax cgiter maxlevel eps
+% 5 5 5 8.31160034e-02 0.00000000e+00 1.80007647e-01 2 2 -1
+% 17 17 17 2.54685628e-02 0.00000000e+00 3.75580565e-02 5 3 -1
+% ...
+%
+% A number format line is also understood:
+% G Basis dof L2 A Lmax cgiter maxlevel eps
+% $flags int int int sci:8 sci:8 sci:8 int int std:8
+% 5 5 5 8.31160034e-02 0.00000000e+00 1.80007647e-01 2 2 -1
+%
+% or a three-column-gnuplot file with 2 comment headers like
+% #Curve 0, 20 points
+% #x y type
+% 0.00000 0.00000 i
+% 0.52632 0.50235 i
+%
+% The table data is stored columnwise in lists and can be accessed
+% with the other methods of this package.
+%
+% \pgfplotstableread[<options>]{<file>}{<\macro>}
+% \pgfplotstableread[<options>]{<file>} to listener{<\macro>}
+% \pgfplotstableread* ...
+%
+% The '*' does not protect its local variables with TeX groups,
+% everything is added to the current scope (useful to the 'to
+% listener' thing.
+%
+% The 'to listener' variant does NOT assemble a table data structure.
+% Instead, it processes the input table row-wise and invokes <\macro>
+% after each complete row. During the evaluation of <\macro>, the
+% following methods can be used to query values:
+% \pgfplotstablereadgetcolindex{<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
+ }{%
+ \pgfplotstableread@impl[]%
+ }%
+}
+
+% BACKWARDS COMPATIBILITY
+\let\pgfnumtableread=\pgfplotstableread
+
+% Invokes #2 if '#1' is an already loaded table and #3 if not.
+\long\def\pgfplotstable@isloadedtable#1#2#3{%
+ \ifcase\pgfplotstableread@ROWSEP@CASE\relax
+ % row sep=newline
+ \let\pgfplots@loc@TMPa=\pgfplotstableread@NL@other%
+ \or
+ % row sep=crcr
+ \def\pgfplots@loc@TMPa{\\}%
+ \fi
+ %
+ \expandafter\pgfutil@in@\expandafter{\pgfplots@loc@TMPa}{#1}%
+ \ifpgfutil@in@
+ % Hah! it contains the row separator! This is NO macro name!
+ % -> it is an inline table definition. Don't try to
+ % assemble a macro name (may run into out-of-memory)
+ #3\relax%
+ \else
+ % ok, the early-out was not met. Make check:
+ \pgfplotsutil@ifdefinedui@withsuffix{#1}{@@table@name}{#2}{#3}%
+ \fi
+}%
+
+% If the colum name `#1' is a `create on use' speicifcation, #2 is
+% invoked, #3 otherwise.
+\long\def\pgfplotstableifiscreateonuse#1#2#3{%
+ \pgfkeysifdefined{/pgfplots/table/create on use/#1/.@cmd}{#2}{%
+ \pgfutil@in@{create col/}{#1}%
+ \ifpgfutil@in@
+ #2%
+ \else
+ #3%
+ \fi
+ }%
+}%
+
+% Defines \pgfplotsretval to be a column name which does not already
+% occur in the column names of table #1.
+\def\pgfplotstablegenerateuniquecolnamefor#1{%
+ \begingroup
+ \c@pgf@countd=0
+ \pgfplotstableforeachcolumn{#1}\as\pgfplots@loc@TMPa{%
+ \def\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \edef\pgfplots@loc@TMPb{autocol\the\c@pgf@countd}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \advance\c@pgf@countd by1
+ \fi
+ }%
+ \edef\pgfplotsretval{autocol\the\c@pgf@countd}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}
+
+% Returns a column vector in form of \pgfplotslist
+% into #3.
+%
+% #1: the column name (not a macro)
+% #2: the table structure
+% #3: the output macro name.
+%
+% @throw `no such element' on error
+\def\pgfplotstablegetcolumnbyname#1\of#2\to#3{%
+ \let#3=\pgfutil@empty% just for sanity checking.
+ \pgfplotstable@getcol{#1}\of{#2}\to{#3}\getcolmethod{STD}%
+}
+
+% Declares a new getcolmethod class #1.
+% The argument '#1' can then be used as argument for
+% \pgfplotstable@getcol...\getcolmethod{#1}.
+%
+% #2: a set of keys which redefine the behavior.
+% See below for available choices.
+\def\pgfplotstable@definegetcolmethod#1#2{%
+ \edef\pgfplotstable@definegetcolmethod@{#1}%
+ \pgfqkeys{/pgfplots/table/@getcol}{%
+ % Checks if column '#1' exists in table `#2' and invokes `#3' if that
+ % is the case and `#4' if not.
+ %
+ % Note that the check is only for physically existent colums, no alias
+ % or create on use is checked here.
+ % #1: colname
+ % #2: table struct
+ % #3: true code
+ % #4: false code
+ % FIXME : THIS IS BUGGY: the macro may exist, but is it
+ % (still) part of the table!? Currently, there is a workaround
+ % such that \pgfplotstablenew cleans up and avoids that case..
+ % and we have no "drop column" currently.
+ ifexists =\pgfutil@ifundefined{\string##2@##1}{##4}{##3},
+ %
+ % Low level method to return (the actual content) of column #1 of
+ % table #2 to macro #3.
+ % #1: colname
+ % #2: table struct
+ % #3: result macro
+ getexisting =\expandafter\let\expandafter##3\csname\string##2@##1\endcsname,
+ %
+ % no arguments, the value is a boolean (0 or 1)
+ createonuse =1,
+ %
+ % error handling.
+ % #1: colname
+ % #2: table struct
+ % #3: result macro
+ lazyforbidden=\pgfplotstablegetcolumnbyname@impl@createonuseforbidden{##1}\of{##2}\to{##3},
+ noalias =\pgfplotstablegetcolumnbyname@impl@nosuchalias{##1}\of{##2}\to{##3},
+ nocol =\pgfplotstablegetcolumnbyname@impl@nocolumn{##1}\of{##2}\to{##3},
+ #2%
+ }%
+}%
+\pgfqkeys{/pgfplots/table/@getcol}{%
+ ifexists/.code ={\expandafter\def\csname pgfplotstable@getcol@ifexists@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2##3##4{#1}},%
+ getexisting/.code ={\expandafter\def\csname pgfplotstable@getcol@getexisting@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},%
+ createonuse/.code ={\expandafter\def\csname pgfplotstable@getcol@createonuse@\pgfplotstable@definegetcolmethod@\endcsname{#1}},%
+ lazyforbidden/.code ={\expandafter\def\csname pgfplotstable@getcol@lazyforbidden@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},%
+ noalias/.code ={\expandafter\def\csname pgfplotstable@getcol@noalias@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},%
+ nocol/.code ={\expandafter\def\csname pgfplotstable@getcol@nocol@\pgfplotstable@definegetcolmethod@\endcsname##1\of##2\to##3{#1}},%
+}%
+
+\pgfplotstable@definegetcolmethod{STD}{}%
+\pgfplotstable@definegetcolmethod{getptr}{%
+ ifexists =\pgfutil@ifundefined{pgfplotstblread@colindex@for@name#1}{#4}{#3},%
+ getexisting =\edef#3{\csname pgfplotstblread@colindex@for@name#1\endcsname},%
+}
+\pgfplotstable@definegetcolmethod{resolvename}{%
+ getexisting =\edef#3{#1},%
+}
+
+% The low level implementation of \pgfplotstablegetcolumnbyname.
+%
+% #4: is a getcolmethod declared with \pgfplotstable@definegetcolmethod
+%
+% ATTENTION: this macro should be expandable! It is also used inside
+% of \thisrow{}.
+\def\pgfplotstable@getcol#1\of#2\to#3\getcolmethod#4{%
+ \csname pgfplotstable@getcol@ifexists@#4\endcsname{#1}\of{#2}{%
+ \csname pgfplotstable@getcol@getexisting@#4\endcsname{#1}\of{#2}\to#3%
+ }{%
+ % Oh, there is no column '#1' in table '#2'!
+ %
+ % Ok, then check for special features.
+ %
+ % 1. 'create col/...'
+ % 2. 'create on use'
+ % 3. 'alias'
+ %
+ % WARNING : this code has been REPLICATED in
+ % *** \pgfplotstablereadvalueofcolname ***
+ \if1\csname pgfplotstable@getcol@createonuse@#4\endcsname%
+ \pgfutil@in@{create col/}{#1}%
+ \ifpgfutil@in@
+ \pgfplotstablegenerateuniquecolnamefor{#2}%
+ \def\pgfplotstable@loc@TMPa##1{%
+ \pgfkeysdef{/pgfplots/table/create on use/##1}{\pgfkeysalso{#1}}%
+ \pgfplotstablecreatecol[/pgfplots/table/create on use/##1]{##1}{#2}%
+ % and return the newly generated col:
+ \csname pgfplotstable@getcol@getexisting@#4\endcsname{##1}\of{#2}\to#3%
+ }%
+ \expandafter\pgfplotstable@loc@TMPa\expandafter{\pgfplotsretval}%
+ \else
+ \pgfplotstable@getcol@next{#1}\of{#2}\to{#3}\getcolmethod{#4}%
+ \fi
+ \else
+ \pgfplotstable@getcol@next{#1}\of{#2}\to{#3}\getcolmethod{#4}%
+ \fi
+ }%
+}%
+\def\pgfplotstable@getcol@next#1\of#2\to#3\getcolmethod#4{%
+ \pgfkeysifdefined{/pgfplots/table/create on use/#1/.@cmd}{%
+ % aah - a 'create on use' style exists. Apply it!
+ \if1\csname pgfplotstable@getcol@createonuse@#4\endcsname%
+ \pgfplotstablecreatecol[/pgfplots/table/create on use/#1]{#1}{#2}%
+ % and return the newly generated col:
+ \csname pgfplotstable@getcol@getexisting@#4\endcsname{#1}\of{#2}\to#3%
+ \else
+ \csname pgfplotstable@getcol@lazyforbidden@#4\endcsname{#1}\of{#2}\to#3%
+ \fi
+ }{%
+ % ok, then it is either an alias or it simply doesn't exist
+ \pgfkeysifdefined{/pgfplots/table/alias/#1}{%
+ \csname pgfplotstable@getcol@ifexists@#4\endcsname{\pgfkeysvalueof{/pgfplots/table/alias/#1}}\of{#2}{%
+ \csname pgfplotstable@getcol@getexisting@#4\endcsname{\pgfkeysvalueof{/pgfplots/table/alias/#1}}\of{#2}\to#3%
+ }{%
+ \csname pgfplotstable@getcol@noalias@#4\endcsname{#1}\of{#2}\to{#3}%
+ }%
+ }{%
+ \csname pgfplotstable@getcol@nocol@#4\endcsname{#1}\of{#2}\to{#3}%
+ }%
+ }%
+}
+\def\pgfplotstablegetcolumnbyname@impl@createonuseforbidden#1\of#2\to#3{%
+ \pgfplotstablegetcolumnbyname@impl@nocolumn@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@
+}
+
+\def\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@#1{%
+ \space Note that I found a 'create on use/#1' style, but unfortunately, I can't evaluate it in this context. Please use the 'read completely' key such that it is processed earlier (see the manual for details)%
+}%
+\def\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable#1{}%
+
+\def\pgfplotstablegetcolumnbyname@impl@nosuchalias#1\of#2\to#3{
+ \pgfplotstablegetcolumnbyname@impl@nosuchalias@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable
+}%
+
+\def\pgfplotstablegetcolumnbyname@impl@nosuchalias@#1\of#2\to#3#4{%
+ \pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve aliased column '\pgfkeysvalueof{/pgfplots/table/alias/#1}' from table '\pgfplotstablenameof{#2}'. The original request was for '#1', which does not exist either.#4{#1}}\pgfeov%
+}%
+
+\def\pgfplotstablegetcolumnbyname@impl@nocolumn#1\of#2\to#3{%
+ \pgfplotstablegetcolumnbyname@impl@nocolumn@{#1}\of{#2}\to{#3}\pgfplotstablegetcolumnbyname@impl@createonuseforbiddentext@disable
+}%
+\def\pgfplotstablegetcolumnbyname@impl@nocolumn@#1\of#2\to#3#4{%
+ \pgfplotsthrow{no such element}{#3}{Sorry, could not retrieve column '#1' from table '\pgfplotstablenameof{#2}'. Please check spelling (or introduce name aliases).#4{#1}}\pgfeov%
+}%
+
+
+% Retrieves the column *NAME* '#1' of table #2 and writes it into
+% '#3'.
+%
+% If there is no such column, column aliases will be checked. Finally
+% if there are no aliases, the command fails with an error.
+%
+% The 'create on use' statements can't be used in this context.
+% @see \pgfplotstablegetcolumnbyname
+%
+% #1: a column name (not a macro)
+% #2: the table structure
+% #3: a macro name which will be filled with the (probably modified)
+% column name into #2.
+\def\pgfplotstableresolvecolname#1\of#2\to#3{%
+ \let#3=\pgfutil@empty% just for sanity checking.
+ \pgfplotstable@getcol{#1}\of{#2}\to{#3}\getcolmethod{resolvename}%
+}
+
+% 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...
+\long\def\pgfplotstablegetcolumn#1\of#2\to#3{%
+ \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
+ \expandafter\pgfplotstablegetcolumnnamebyindex\pgfplotstable@loc@TMPc\of{#2}\to\pgfplotstable@loc@TMPc
+ \fi
+ \expandafter\pgfplotstablegetcolumnbyname\pgfplotstable@loc@TMPc\of#2\to{#3}%
+}%
+
+% Defines #3 to be the column name of the column with index '#1'.
+%
+% #1: a column index (starting with 0)
+% #2: a loaded table structure
+% #3: an output macro name.
+\def\pgfplotstablegetcolumnnamebyindex#1\of#2\to#3{%
+ \pgfplotslistselect#1\of#2\to#3\relax
+}%
+
+% Defines #3 to be the column index of the column with name '#1'.
+%
+% #1: a column name
+% #2: a loaded table structure
+% #3: an output macro name which will be filled with the index (or -1
+% if there is no such index)
+\def\pgfplotstablegetcolumnindexforname#1\of#2\to#3{%
+ \def#3{-1}%
+ \edef\pgfplotstablegetcolumnindexforname@@{#1}%
+ \pgfplotstableforeachcolumn{#2}\as\pgfplotstablegetcolumnindexforname@{%
+ \relax
+ \ifx\pgfplotstablegetcolumnindexforname@\pgfplotstablegetcolumnindexforname@@
+ \edef#3{\pgfplotstablecol}%
+ \fi
+ }%
+}%
+\def\pgfplotstablegetcolumnbyindex#1\of#2\to#3{%
+ \pgfplotslistselect#1\of#2\to#3\relax
+ \expandafter\pgfplotstablegetcolumnbyname#3\of#2\to{#3}%
+}
+
+\def\pgfplotstablecopy#1\to#2{%
+ \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}%
+ \expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname
+ }%
+}
+
+% Returns the file name of table '#1' into macro #2.
+\def\pgfplotstablegetname#1#2{%
+ \expandafter\let\expandafter#2\csname\string#1@@table@name\endcsname
+}
+
+% expands to the table file name of table '#1'
+\def\pgfplotstablenameof#1{%
+ \csname\string#1@@table@name\endcsname
+}
+
+% 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}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% IMPLEMENTATION
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newif\ifpgfplotstableread@curline@contains@colnames
+\newif\ifpgfplotstableread@foundcolnames
+\newif\ifpgfplotstableread@skipline
+
+% A method which is necessary to work with inline table data.
+%
+% It does nothing if format=file.
+%
+% It needs to be invoked BEFORE the inline table data has been
+% seen the first time. "Seen" means collected as argument!
+%
+% The macro changes \catcodes in order to implement the 'row sep=newline',
+% some special 'col sep' choices and the 'ignore chars' features.
+%
+% ATTENTION: this changes the processing of ALL following newline
+% characters.
+% @see \pgfplotstablecollectoneargwithpreparecatcodes
+\def\pgfplotstablereadpreparecatcodes{%
+ \ifx\pgfplotstablereadrestorecatcodes\relax
+ \edef\pgfplotstablereadrestorecatcodes{%
+ \noexpand\pgfplotstableuninstallignorechars
+ \noexpand\catcode`\noexpand\^^M=\the\catcode`\^^M\noexpand\space
+ \noexpand\catcode`\noexpand\ =\the\catcode`\ \noexpand\space
+ \noexpand\catcode`\noexpand\;=\the\catcode`\;\noexpand\space
+ \noexpand\catcode`\noexpand\:=\the\catcode`\:\noexpand\space
+ \noexpand\catcode`\noexpand\^^I=\the\catcode`\^^I\noexpand\space
+ \noexpand\let\noexpand\pgfplotstablereadrestorecatcodes=\noexpand\relax
+ }%
+ \ifcase\pgfplotstableread@FORMAT@CASE\relax
+ % format=auto
+ \pgfplotstablereadpreparecatcodes@
+ \or
+ % format=inline
+ \pgfplotstablereadpreparecatcodes@
+ \fi
+ \fi
+}
+\let\pgfplotstablereadrestorecatcodes=\relax
+\def\pgfplotstablereadpreparecatcodes@{%
+ \if0\pgfplotstableread@ROWSEP@CASE\relax
+ % row sep = newline
+ \catcode`\^^M=12
+ \fi
+ \ifcase\pgfplotstableread@COLSEP@CASE\relax
+ % col sep=space:
+ \catcode`\ =10
+ \or
+ % col sep=comma:
+ \or
+ % col sep=semicolon:
+ \catcode`\;=12
+ \or
+ % col sep=colon:
+ \catcode`\:=12
+ \or
+ % col sep=brace:
+ \or
+ % col sep=tab:
+ \catcode`\^^I=12
+ \fi
+ \pgfplotstableinstallignorechars
+}%
+
+% Logically, this routine does
+% \pgfplotstablereadpreparecatcodes
+% #1
+% and that's all. However, It makes sure that any white space
+% characters (especially newlines) between '#1' and the following
+% argument are gobbled!
+%
+% To show the problem, consider
+% \pgfplotstabletypeset[<options>]
+% \loadedtable
+%
+% and we want to set the catcodes *before* \loadedtable is seen.
+% Well, there is a newline character after ']'! If we change the
+% catcodes, this newline will be considered as character and will make
+% up the first argument, the \loadedtable will be ignored.
+%
+% \pgfplotstablecollectoneargwithpreparecatcodes avoids this problem
+% by gobbling all space (newline) characters *before* collecting the
+% directly following argument token. Furthermore, it restores the
+% catcodes directly after the argument has been collected.
+%
+% @see \pgfplotstablecollectoneargwithpreparecatcodesnorestore
+\long\def\pgfplotstablecollectoneargwithpreparecatcodes#1{%
+ \begingroup
+ \t@pgfplotstable@a{{#1}}% this allows '#' characters in '#1'
+ \def\pgfplotstablecollectoneargwithpreparecatcodes@@{%
+ \pgfplotstablereadpreparecatcodes
+ \expandafter\pgfplotstablecollectoneargwithpreparecatcodes@end\the\t@pgfplotstable@a%
+ }%
+ % equivalent to
+ %\let\pgfplotstable@loc@TMPa=<next token>\pgfplotstablecollectoneargwithpreparecatcodes@@<next token>
+ \futurelet\pgfplotstable@loc@TMPa\pgfplotstablecollectoneargwithpreparecatcodes@@
+ % this employs a side effect: \futurelet gobbles any spaces
+ % (including newlines).
+}%
+\long\def\pgfplotstablecollectoneargwithpreparecatcodes@end#1#2{%
+ \endgroup
+ #1{#2}%
+}%
+
+% An overloaded method of
+% \pgfplotstablecollectoneargwithpreparecatcodes which does not
+% restore the catcodes after collecting one arg.
+\long\def\pgfplotstablecollectoneargwithpreparecatcodesnorestore#1{%
+ \t@pgfplotstable@a{{#1}}%
+ \def\pgfplotstablecollectoneargwithpreparecatcodes@@{%
+ \expandafter\pgfplotstablereadpreparecatcodes\t@pgfplotstable@a
+ }%
+ % equivalent to
+ %\let\pgfplotstable@loc@TMPa=<next token>\pgfplotstablecollectoneargwithpreparecatcodes@@<next token>
+ \futurelet\pgfplotstable@loc@TMPa\pgfplotstablecollectoneargwithpreparecatcodes@@
+}%
+
+% Accept one of
+% \pgfplotstableread[#1]{<file>}{<\macro>}
+% \pgfplotstableread[#1]{<file>} to listener{<\macro>}
+% or
+% \pgfplotstableread[#1]{<file>} to {<\macro>} (DEPRECATED)
+\long\def\pgfplotstableread@impl[#1]{%
+ \ifpgfplots@tableread@use@begingroup
+ \begingroup
+ \def\endgroup@@pgfplotstableread{\endgroup}%
+ \else
+ \let\endgroup@@pgfplotstableread=\relax%
+ \fi
+ % set options here, although we can't evaluate 'every table' yet
+ % (the file name is not yet known).
+ % But #1 may contain input format specifiers which are important
+ % for \catcodes, BEFORE we have read the second argument:
+ \pgfplotstableset{#1}%
+ %
+ \pgfplotstablecollectoneargwithpreparecatcodes{%
+ \pgfplotstableread@impl@collectfirstarg{#1}%
+ }%
+}%
+\long\def\pgfplotstableread@impl@collectfirstarg#1#2{%
+ \pgfplotsutil@ifnextchar t{%
+ \pgfplotstableread@impl@@{#1}{#2}%
+ }{%
+ \pgfplotstableread@impl@{#1}{#2}%
+ }%
+}%
+
+
+% I don't know why; but I started with
+% >> \pgfplotstableread[]{file} to \macro
+% That ' to ' is really ugly. This here is for backwards
+% compatibility:
+\long\def\pgfplotstableread@impl@@#1#2to {%
+ \pgfutil@ifnextchar l{%
+ \pgfplotstableread@impl@@listener{#1}{#2}%
+ }{%
+ \pgfplotstableread@impl@{#1}{#2}%
+ }%
+}%
+\long\def\pgfplotstableread@impl@@listener#1#2listener#3{%
+ \pgfplots@tableread@to@listenertrue
+ \pgfplotstableread@impl@{#1}{#2}{#3}%
+ \pgfplots@tableread@to@listenerfalse
+}%
+
+\newif\ifpgfplotstableread@inline
+\long\def\pgfplotstableread@checkinlineformat@CRCR#1\\#2\pgfplotstable@EOI{%
+ \def\pgfplotstable@loc@TMPa{#2}%
+ \ifx\pgfplotstable@loc@TMPa\pgfutil@empty
+ \pgfplotstableread@inlinefalse
+ \else
+ \pgfplotstableread@inlinetrue
+ \let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@CRCR
+ \fi
+}%
+\long\def\pgfplotstableread@loop@next@CRCR#1\\{%
+ \long\def\pgfplotstable@LINE{#1}%
+ \pgfplotstableread@loop@processnextline
+ \pgfplotstableread@loop@over@lines
+}%
+\begingroup
+\catcode`\^^M=12\relax%
+\gdef\pgfplotstableread@NL@other{^^M}%
+\long\gdef\pgfplotstableread@checkinlineformat@NL@#1^^M#2\pgfplotstable@EOI{%
+ \def\pgfplotstable@loc@TMPa{#2}%
+ \ifx\pgfplotstable@loc@TMPa\pgfutil@empty%
+ \pgfplotstableread@inlinefalse%
+ \else%
+ \pgfplotstableread@inlinetrue%
+ \let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@NL%
+ \fi%
+}%
+\long\gdef\pgfplotstableread@checkinlineformat@NL#1{%
+ \pgfplotstableread@checkinlineformat@NL@ #1^^M\pgfplotstable@EOI%
+}%
+\long\gdef\pgfplotstableread@loop@next@NL#1^^M{%
+ \long\def\pgfplotstable@LINE{#1}%
+ \pgfplotstableread@loop@processnextline%
+ \pgfplotstableread@loop@over@lines%
+}%
+\endgroup
+
+% #1: options.
+% #2: the table content (file name or inline data)
+% #3: the result macro.
+\long\def\pgfplotstableread@impl@#1#2#3{%
+ \ifcase\pgfplotstableread@FORMAT@CASE\relax
+ % format=auto
+ \ifcase\pgfplotstableread@ROWSEP@CASE\relax
+ % row sep=newline
+ \pgfplotstableread@checkinlineformat@NL{#2}%
+ \or
+ % row sep=crcr
+ \pgfplotstableread@checkinlineformat@CRCR #2\\\pgfplotstable@EOI
+ \fi
+ \or
+ % format=inline
+ \pgfplotstableread@inlinetrue
+ \ifcase\pgfplotstableread@ROWSEP@CASE\relax
+ % row sep=newline
+ \let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@NL
+ \or
+ % row sep=crcr
+ \let\pgfplotstableread@loop@next=\pgfplotstableread@loop@next@CRCR
+ \fi
+ \or
+ \pgfplotstableread@inlinefalse
+ \fi
+ %
+ \ifpgfplotstableread@inline
+ \else
+ \if1\pgfplotstableread@ROWSEP@CASE
+ % row sep=crcr
+ \pgfplotsthrow{unsupported operation}{Sorry, the choice 'row sep=crcr' is currently only available for inline tables, not for external files}\pgfeov
+ \fi
+ \fi
+ %
+ % optimizations:
+ \pgfkeysgetvalue{/pgfplots/table/comment chars}\pgfplots@loc@TMPd
+ \ifx\pgfplots@loc@TMPd\pgfutil@empty
+ \let\pgfplotstableread@checkspecial@line@default=\relax
+ \fi
+ \pgfkeysgetvalue{/pgfplots/table/skip first n}\pgfplots@loc@TMPd
+ \ifx\pgfplots@loc@TMPd\pgfutil@empty \let\pgfplotstableread@check@skipfirstn=\relax \fi
+ \ifnum\pgfplots@loc@TMPd=0 \let\pgfplotstableread@check@skipfirstn=\relax \fi
+ %
+ \ifpgfplotstableread@inline
+ \def\pgfplotstableread@impl@fCLOSE{}%
+ \let\pgfplotstableread@loop@over@lines=\pgfplotstableread@loop@over@lines@frominline%
+ \long\def\pgfplotstableread@start@loop{%
+ \pgfplotstableread@loop@over@lines #2\pgfplotstable@EOI
+ }%
+ \def\pgfplotstableread@ready{1}%
+ \def\pgfplotstableread@filename{<inline_table>}%
+ \else
+ \def\pgfplotstableread@ready{1}%
+ \def\pgfplotstableread@filename{#2}%
+ \pgfplotstableread@openfile
+ \def\pgfplotstableread@impl@fCLOSE{%
+ \closein\r@pgfplots@reada
+ }%
+ \let\pgfplotstableread@loop@over@lines=\pgfplotstableread@loop@over@lines@fromfile%
+ \def\pgfplotstableread@start@loop{\pgfplotstableread@loop@over@lines}%
+ \pgfplotstableinstallignorechars
+ \fi
+ \edef\pgfplotstableread@oldendlinechar{\the\endlinechar}%
+ \endlinechar=-1 % do not append a white space after each line for file input
+%\pgfplots@message{ATTEMPTING TO READ \pgfplotstableread@filename}%
+ %
+ \def\pgfplots@loc@TMPa{\pgfplotstableread@impl@prepare{#1}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotstableread@filename}{#3}%
+ %
+ \if1\pgfplotstableread@ready
+ \pgfplotstableread@start@loop
+ %
+ \pgfplotstableread@impl@fCLOSE%
+ %
+ \pgfplotstableread@finish
+ %
+ \fi
+ \endlinechar=\pgfplotstableread@oldendlinechar
+ \pgfplotsscanlinelengthcleanup
+ \expandafter\pgfplotstable@copy@to@globalbuffers@simple\expandafter{\pgfplotstableread@filename}%
+ \endgroup@@pgfplotstableread
+ \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.
+ \pgfplotstable@copy@globalbuffers@to#3%
+ \fi
+}
+
+{\catcode`\"=12 \gdef\pgfplots@dquote{"}}
+
+% gets the search path (after applying some basic sanity checks)
+\def\pgfplotstable@get@search@path{%
+ \pgfkeysgetvalue{/pgfplots/table/search path}\pgfplotsretval
+ \ifx\pgfplotsretval\pgfutil@empty
+ \def\pgfplotsretval{.}%
+ \pgfkeyslet{/pgfplots/table/search path}\pgfplotsretval
+ \fi
+ %
+ \ifpgfplotstable@search@path@implicit@CWD
+ \def\b@pgfplotstable@search@contains@cwd{0}%
+ \def\pgfplotstable@loc@TMPd{.}%
+ \def\pgfplotstable@loc@TMPc{./}%
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsretval}\as\pgfplotstable@loc@TMPa{%
+ \ifx\pgfplotstable@loc@TMPa\pgfplotstable@loc@TMPd
+ \def\b@pgfplotstable@search@contains@cwd{1}%
+ \fi
+ \ifx\pgfplotstable@loc@TMPa\pgfplotstable@loc@TMPc
+ \def\b@pgfplotstable@search@contains@cwd{1}%
+ \fi
+ }%
+ %
+ \if0\b@pgfplotstable@search@contains@cwd
+ \t@pgfplotstable@a=\expandafter{\pgfplotsretval}%
+ \edef\pgfplotsretval{.,\the\t@pgfplotstable@a}%
+ \pgfkeyslet{/pgfplots/table/search path}\pgfplotsretval
+ \fi
+ \fi
+}
+
+\def\pgfplotstable@search@path@add@slash#1{%
+ \def\pgfplotsretval{#1/}%
+ \def\pgfplotstable@loc@TMPd{./}%
+ \def\pgfplotstable@loc@TMPc{.//}%
+ \ifx\pgfplotsretval\pgfplotstable@loc@TMPd
+ % Ah -- we have #1='.' Do NOT use a slash at all in order to
+ % not disable the processing of TEXINPUTS (if pdftex finds ./
+ % , it will NOT evaluated TEXINPUTS as it seems)
+ \let\pgfplotsretval=\pgfutil@empty
+ \fi
+ \ifx\pgfplotsretval\pgfplotstable@loc@TMPc
+ \let\pgfplotsretval=\pgfutil@empty
+ \fi
+}%
+
+%
+% POSTCONDITION:
+% - \r@pgfplots@reada is the opened result file (or eof if there is no
+% such file).
+% - \pgfplotstableread@filename is the first found file path.
+\def\pgfplotstable@search@and@open@file{%
+ \pgfplotstable@get@search@path
+ %
+ \let\pgfplotstableread@filename@name=\pgfplotstableread@filename
+ %
+ \def\b@pgfplotstable@search@done{0}%
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsretval}\as\pgfplotstable@loc@TMPa{%
+ \ifx\pgfplotstable@loc@TMPa\pgfutil@empty
+ % silently skip empty entries in the list.
+ \else
+ \if0\b@pgfplotstable@search@done
+ %
+ \expandafter\pgfplotstable@search@path@add@slash\expandafter{\pgfplotstable@loc@TMPa}%
+ %
+ \t@pgfplotstable@a=\expandafter{\pgfplotsretval}%
+ \t@pgfplots@tokc=\expandafter{\pgfplotstableread@filename@name}%
+ \edef\pgfplotstableread@filename{\the\t@pgfplotstable@a\the\t@pgfplots@tokc}%
+ %
+ \openin\r@pgfplots@reada=\pgfplotstableread@filename.tex
+ \ifeof\r@pgfplots@reada
+ \openin\r@pgfplots@reada=\pgfplotstableread@filename\relax
+ \else
+ \pgfplots@warning{%
+ You requested to open table '\pgfplotstableread@filename', but there is also a '\pgfplotstableread@filename.tex'.
+ TeX will automatically append the suffix '.tex', so I will now open '\pgfplotstableread@filename.tex'.
+ Please make sure you don't accidentally load TeX files - this may produce unrecoverable errors.}%
+ \closein\r@pgfplots@reada
+ \openin\r@pgfplots@reada=\pgfplotstableread@filename\relax
+ \fi
+ %
+ \ifeof\r@pgfplots@reada
+ \else
+ \def\b@pgfplotstable@search@done{1}%
+ \fi
+ \fi
+ \fi
+ }%
+ %
+ \if0\b@pgfplotstable@search@done
+ \let\pgfplotstableread@filename=\pgfplotstableread@filename@name
+ \fi
+}%
+
+% Opens \pgfplotstableread@filename.
+\def\pgfplotstableread@openfile{%
+ \def\pgfplotstable@loc@TMPa{\pgfutil@in@{ }}%
+ \expandafter\pgfplotstable@loc@TMPa\expandafter{\pgfplotstableread@filename}%
+ \ifpgfutil@in@
+ \t@pgfplots@toka=\expandafter{\pgfplotstableread@filename}%
+ \edef\pgfplotstableread@filename{\pgfplots@dquote\the\t@pgfplots@toka\pgfplots@dquote}%
+ \fi
+ \let\pgfplotstableread@old@crcr=\\%
+ \def\\{\string\\}% just to make sure we don't try to open inline table data...
+ %
+ \pgfplotstable@search@and@open@file
+ %
+ \ifeof\r@pgfplots@reada
+ \pgfplotsthrow{no such table file}{\pgfplots@loc@TMPa}{\pgfplotstableread@filename}{Could not read table file '\pgfplotstableread@filename' in 'search path=\pgfkeysvalueof{/pgfplots/table/search path}'. In case you intended to provide inline data: maybe TeX screwed up your end-of-lines? Try `row sep=crcr' and terminate your lines with `\string\\' (refer to the pgfplotstable manual for details)}\pgfeov%
+ \global\let\pgfplotstable@colnames@glob=\pgfplots@loc@TMPa
+ \def\pgfplotstableread@ready{0}%
+ \fi
+ \pgfplots@logfileopen{\pgfplotstableread@filename}%
+ \let\\=\pgfplotstableread@old@crcr
+}
+
+\def\pgfplotstableinstallignorechars{%
+ \ifx\pgfplotstableuninstallignorechars\pgfutil@empty
+ \pgfkeysgetvalue{/pgfplots/table/ignore chars}\pgfplotstable@loc@TMPa
+ \ifx\pgfplotstable@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{9}%
+ \fi
+ \pgfkeysgetvalue{/pgfplots/table/white space chars}\pgfplotstable@loc@TMPa
+ \ifx\pgfplotstable@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{10}%
+ \fi
+ \pgfkeysgetvalue{/pgfplots/table/text special chars}\pgfplotstable@loc@TMPa
+ \ifx\pgfplotstable@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotstableinstallignorechars@\pgfplotstable@loc@TMPa{12}%
+ \fi
+ \ifx\pgfplotstableuninstallignorechars\pgfutil@empty
+ \else
+ \expandafter\def\expandafter\pgfplotstableuninstallignorechars\expandafter{%
+ \pgfplotstableuninstallignorechars
+ \let\pgfplotstableuninstallignorechars=\pgfutil@empty
+ }%
+ \fi
+ \fi
+}%
+\let\pgfplotstableuninstallignorechars\pgfutil@empty%
+% #1 macro containing the characters as comma-separated list
+% #2 the catcode to assign
+\def\pgfplotstableinstallignorechars@#1#2{%
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{#1}\as\pgfplotstable@loc@TMPa{%
+ \t@pgfplots@toka=\expandafter{\pgfplotstableuninstallignorechars}%
+ \edef\pgfplotstableuninstallignorechars{%
+ \the\t@pgfplots@toka
+ \noexpand\catcode`\expandafter\noexpand\pgfplotstable@loc@TMPa=\expandafter\the\expandafter\catcode\expandafter`\pgfplotstable@loc@TMPa\noexpand\space
+ }%
+ \expandafter\catcode\expandafter`\pgfplotstable@loc@TMPa=#2\relax
+ }%
+}%
+
+% #1: any options to set (respect \ifpgfplots@table@options@areset )
+% #2: the file name (if any)
+% #3: the output macro (or listener)
+\def\pgfplotstableread@impl@prepare#1#2#3{%
+ \ifpgfplots@table@options@areset
+ \else
+ \pgfplotstableset@every@table{#2}{#1}%
+ \fi
+ %
+ \def\pgfplotstablename{\pgfplotstable@colnames@glob}% provide the name of the actual table struct (during \pgfplotstableread, only partial functionality is available!)
+ %
+ % 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\relax}%
+ \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.
+%
+% #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\relax
+ \c@pgfplotstable@counta=0\relax%
+ \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{%
+ \def\pgfplotstable@loc@TMPb{%
+ \expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname%
+ }%
+ \expandafter\pgfplotstable@loc@TMPb\csname\string#1@\pgfplotstable@loc@TMPa\endcsname
+ \advance\c@pgfplotstable@counta by1\relax
+ }%
+ \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%
+ \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as\pgfplotstable@loc@TMPa{%
+ \def\pgfplotstable@loc@TMPb{%
+ \expandafter\let\csname\string#1@\pgfplotstable@loc@TMPa\endcsname}%
+ \expandafter\pgfplotstable@loc@TMPb\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname
+%\message{Column '\pgfplotstable@loc@TMPa' has entries: \expandafter\meaning\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname}%
+ \expandafter\global\expandafter\let\csname pgfp@numtable@glob@col@\the\c@pgfplotstable@counta\endcsname=\pgfutil@empty
+ \advance\c@pgfplotstable@counta by1\relax
+ }%
+ \global\let\pgfplotstable@colnames@glob=\pgfutil@empty
+ \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@countreset\pgfplotstableread@curcol%
+ \pgfutil@loop
+ \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@fromfile{%
+ \ifeof\r@pgfplots@reada
+%\pgfplots@message{EOF}%
+ \else
+ \read\r@pgfplots@reada to\pgfplotstable@LINE
+ \ifeof\r@pgfplots@reada
+ \else
+ \pgfplotstableread@loop@processnextline
+ \fi
+ \expandafter\pgfplotstableread@loop@over@lines
+ \fi
+}%
+\def\pgfplotstableread@loop@over@lines@frominline{%
+ \pgfutil@ifnextchar\pgfplotstable@EOI{%
+ \pgfutil@gobble
+ }{%
+ \pgfplotstableread@loop@next
+ }%
+}%
+
+\def\pgfplotstableread@check@skipfirstn{%
+ \ifnum\pgfplotstableread@lineno<\pgfkeysvalueof{/pgfplots/table/skip first n} %
+ \pgfplotstableread@skiplinetrue
+ \fi
+}%
+
+% PRECONDITION:
+% \pgfplotstable@LINE contains the current input line.
+\def\pgfplotstableread@loop@processnextline{%
+ \expandafter\pgfplotstableread@checkspecial@line\pgfplotstable@LINE\pgfplotstable@EOI
+ \pgfplotstableread@check@skipfirstn
+ \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}%
+ \edef\pgfplotstablecols{\thepgfplotstableread@numcols}%
+ \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
+ \pgfplotsscanlinelengthincrease
+ \pgfplotstableread@foundcolnamesfalse
+ \pgfplotstableread@countreset\pgfplotstableread@curcol
+ % Leave column name lists empty...
+ \pgfplotstableread@impl@DO\pgfplotstableread@impl@nextrow@NEXT\pgfplotstable@LINE
+ \fi
+%\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
+ \pgfplotsthrow{table columns unbalanced}{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')}\pgfeov%
+ \fi
+ \ifpgfplots@tableread@to@listener
+ \ifpgfplotstableread@curline@contains@colnames
+ \else
+ % report row!
+ \pgfplotstable@listener
+ \fi
+ \fi
+ \pgfplotstableread@countadvance\pgfplotstableread@usablelineno
+ \fi
+ \pgfplotstableread@countadvance\pgfplotstableread@lineno
+}%
+
+% WARNING: this routine is also used in pgfplots.code.tex ...
+\def\pgfplotstableread@checkspecial@line{%
+ \futurelet\pgfplotstableread@tmp\pgfplotstableread@checkspecial@line@
+}%
+\def\pgfplotstableread@checkspecial@line@{%
+ \pgfplotstableread@skiplinefalse
+ \let\pgfplotstableread@checkspecial@line@@\pgfplotstableread@impl@gobble%
+ %
+ \let\pgfplotstableread@tmpb=##%
+ \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb
+ \pgfplotstableread@skiplinetrue
+ \else
+ \let\pgfplotstableread@tmpb=$%
+ \let\pgfplotstableread@tmpb=\pgfplotstable@EOI%
+ \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb
+ \pgfplotstableread@skiplinetrue
+ \pgfplotsscanlinecomplete% the line is empty; same as \par!
+ \else
+ \let\pgfplotstableread@tmpb=\par%
+ \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb
+ \pgfplotstableread@skiplinetrue
+ \pgfplotsscanlinecomplete% the line is empty;
+ \else
+ \pgfplotstableread@checkspecial@line@default%
+ \fi
+ \fi
+ \fi
+ \pgfplotstableread@checkspecial@line@@
+}%
+\def\pgfplotstableread@checkspecial@line@default{%
+ % this routine can be optimized away
+ \pgfkeysgetvalue{/pgfplots/table/comment chars}\pgfplots@loc@TMPd
+ \ifx\pgfplots@loc@TMPd\pgfutil@empty
+ \else
+ \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots@loc@TMPd}\as\pgfplots@loc@TMPd{%
+ \expandafter\let\expandafter\pgfplotstableread@tmpb\pgfplots@loc@TMPd
+ \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb
+ \pgfplotstableread@skiplinetrue
+ \fi
+ }%
+ \fi
+}%
+
+%--------------------------------------------------
+% \def\pgfplotstableread@checkspecial@line{%
+% \pgfutil@ifnextchar##{%
+% \pgfplotstableread@skiplinetrue
+% \pgfplotstableread@impl@gobble
+% }{%
+% \pgfutil@ifnextchar${%
+% \pgfplotstableread@process@flags@line
+% }{%
+% \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
+% \pgfplotstableread@impl@gobble
+% }%
+% }%
+% }%
+% }%
+% }
+%--------------------------------------------------
+
+\def\pgfplotstableread@create@column@lists{%
+ \pgfutil@loop
+ \ifnum\pgfplotstableread@curcol<\pgfplotstableread@numcols\relax
+ \def\pgfplots@loc@TMPa{\pgfplotsapplistXnewempty[to global]}%
+ \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@countreset\pgfplotstableread@curcol
+ \pgfutil@loop
+ \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
+}
+
+\long\def\pgfplotstableread@impl@gobble#1\pgfplotstable@EOI{}%
+
+\def\pgfplotstable@EOI{\pgfplotstable@EOI}%
+
+% A loop command which processes every single entry in a raw data row #2
+% and invokes the macro #1{<arg>} for each found column entry.
+%
+% Columns are separated by the /pgfplots/table/col sep character.
+%
+% #1: a command which takes precisely one argument. It will be called
+% for each found column entry
+%
+% #2: a macro containing a raw data line with <col sep> separated
+% entries.
+\long\def\pgfplotstableread@impl@DO#1#2{%
+ \ifpgfplotstable@trimcells
+ \long\def\pgfplotstableread@impl@ITERATE@NEXT@##1{%
+ \pgfkeys@spdef\pgfplotstableread@impl@ITERATE@NEXT@@@{##1}%
+ \expandafter#1\expandafter{\pgfplotstableread@impl@ITERATE@NEXT@@@}%
+ }%
+ \else
+ \let\pgfplotstableread@impl@ITERATE@NEXT@=#1\relax
+ \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}%
+ \or
+ % col sep=&:
+ \let\pgfplotstableread@impl@ITERATE@NEXT=\pgfplotstableread@impl@ITERATE@NEXT@AMPERSAND
+ \long\def\pgfplotstableread@impl@DO@##1{\pgfplotstableread@impl@ITERATE##1&\pgfplotstable@EOI}%
+ \fi
+ }%
+}%
+\long\def\pgfplotstableread@impl@ITERATE{%
+ \pgfutil@ifnextchar\pgfplotstable@EOI{%
+ \pgfplotstableread@impl@gobble
+ }{%
+ \pgfplotstableread@impl@ITERATE@NEXT
+ }%
+}%
+\long\def\pgfplotstableread@impl@ITERATE@NEXT#1 {%
+ \pgfplotstableread@impl@ITERATE@NEXT@{#1}%
+ \pgfplotstableread@impl@ITERATE
+}%
+\long\def\pgfplotstableread@impl@ITERATE@NEXT@COMMA#1,{%
+ \pgfplotstableread@impl@ITERATE@NEXT@{#1}%
+ \pgfplotstableread@impl@ITERATE
+}%
+\long\def\pgfplotstableread@impl@ITERATE@NEXT@SEMICOLON#1;{%
+ \pgfplotstableread@impl@ITERATE@NEXT@{#1}%
+ \pgfplotstableread@impl@ITERATE
+}%
+\long\def\pgfplotstableread@impl@ITERATE@NEXT@COLON#1:{%
+ \pgfplotstableread@impl@ITERATE@NEXT@{#1}%
+ \pgfplotstableread@impl@ITERATE
+}%
+\long\def\pgfplotstableread@impl@ITERATE@NEXT@BRACE#1{%
+ \pgfplotstableread@impl@ITERATE@NEXT@{#1}%
+ \pgfplotstableread@impl@ITERATE
+}%
+\long\def\pgfplotstableread@impl@ITERATE@NEXT@AMPERSAND#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:
+% when using
+%
+% \pgfplotstableread{<file>} to listener<\macro>
+%
+% -> <\macro> can than use the methods
+%
+% \pgfplotstablereadgetcolindex{<index>}{<\content>}
+% performs \let\content=<content of column no <index> >
+\def\pgfplotstablereadgetcolindex@#1#2{%
+ \pgfutil@ifundefined{pgfplotstblread@colcontent@no#1}{%
+ \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
+ }%
+}%
+
+\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:
+%
+% \let\ptr=\pgfutil@empty
+% \def\macro{%
+% \ifx\ptr\empty
+% \pgfplotstablereadgetptrtocolname{<my col>}{\ptr}%
+% \fi
+% \pgfplotstablereadevalptr{\ptr}{\content}%
+% -> do something with \content!
+% }
+%
+% \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{%
+ \def#2{0}%
+ \pgfplotstable@getcol{#1}\of{\pgfplotstableread@filename}\to{#2}\getcolmethod{getptr}%
+}%
+
+% As \pgfplotstablereadgetptrtocolname, but this here accesses columns
+% by index.
+\def\pgfplotstablereadgetptrtocolindex@#1#2{\edef#2{#1}}%
+
+% \pgfplotstablereadevalptr{<\ptr>}{<\content}
+% 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\thepgfplotstableread@curcol\endcsname{#1}%
+ \pgfplotstableread@countadvance\pgfplotstableread@curcol
+}
+
+\long\def\pgfplotstableread@impl@nextrow@NEXT#1{%
+%\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@\thepgfplotstableread@curcol\endcsname
+ \pgfplotstableread@countadvance\pgfplotstableread@curcol
+ \else
+ \begingroup
+ \t@pgfplots@tokc={#1}%
+ \pgfplotsthrow{table columns unbalanced}{Table '\pgfplotstableread@filename' appears to have too many columns in line \thepgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. PGFPlots found that the number of columns is larger than the previously determined number of columns. Please verify that every cell entry is separated correctly (use braces {<cell entry>} if necessary. Also verify that column names are plain ASCII.). This error is not critical}\pgfeov%
+ \endgroup
+ \fi
+}
+
+
+
+\long\def\pgfplotstableread@impl@collectcolnames@NEXT#1{%
+ \edef\pgfplotstable@loc@TMPa{#1}%
+ \ifx\pgfplotstable@loc@TMPa\pgfutil@empty
+ \edef\pgfplotstable@loc@TMPa{\thepgfplotstableread@curcol}%
+ \pgfplotswarning{empty column name}{\pgfplotstableread@filename}{\pgfplotstable@loc@TMPa'}\pgfeov%
+ \fi
+ \expandafter\pgfplotstableread@impl@collectcolnames@NEXT@\expandafter{\pgfplotstable@loc@TMPa}%
+}
+\long\def\pgfplotstableread@impl@collectcolnames@NEXT@#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 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\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.
+ \expandafter\edef\csname pgfplotstblread@colindex@for@name#1\endcsname{\thepgfplotstableread@curcol}%
+ \fi
+ \pgfplotstableread@countadvance\pgfplotstableread@curcol
+}
+
+
+
+
+\long\def\pgfplotstableread@impl@countcols@and@identifynames@NEXT#1{%
+ \pgfplotstableread@countadvance\pgfplotstableread@curcol
+ \ifpgfplotstable@search@header
+ \ifpgfplotstableread@curline@contains@colnames
+ \else
+ \def\pgfplotstableread@CURTOK{#1}%
+ % can we safely use the \pgfmathfloatparsenumber here? I
+ % doubt it -- what if the header contains macros?
+ %
+ % there is no (simple) expandable "to lower case". check
+ % for the most common forms here.
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@nan
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@NaN
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@NAN
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@inf
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@Inf
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@INF
+ \else
+ \pgfplotstableread@isnumber@ITERATE#1\pgfplotstable@EOI
+ \fi\fi\fi\fi\fi\fi
+%\ifpgfplotstableread@curline@contains@colnames\pgfplots@message{'#1' is a column name!}\else\pgfplots@message{'#1' is NO column name!}\fi
+ \fi
+ \fi
+}
+\def\pgfplotstableread@isnumber@nan{nan}
+\def\pgfplotstableread@isnumber@NaN{NaN}
+\def\pgfplotstableread@isnumber@NAN{NAN}
+\def\pgfplotstableread@isnumber@inf{inf}
+\def\pgfplotstableread@isnumber@INF{INF}
+\def\pgfplotstableread@isnumber@Inf{Inf}
+\def\pgfplotstableread@isnumber@plus{+}
+\def\pgfplotstableread@isnumber@minus{-}
+\def\pgfplotstableread@isnumber@zero{0}
+\def\pgfplotstableread@isnumber@one{1}
+\def\pgfplotstableread@isnumber@two{2}
+\def\pgfplotstableread@isnumber@three{3}
+\def\pgfplotstableread@isnumber@four{4}
+\def\pgfplotstableread@isnumber@five{5}
+\def\pgfplotstableread@isnumber@six{6}
+\def\pgfplotstableread@isnumber@seven{7}
+\def\pgfplotstableread@isnumber@eight{8}
+\def\pgfplotstableread@isnumber@nine{9}
+\def\pgfplotstableread@isnumber@e{e}
+\def\pgfplotstableread@isnumber@E{E}
+\def\pgfplotstableread@isnumber@period{.}
+
+\def\pgfplotstableread@isnumber@ITERATE#1{%
+ \def\pgfplotstableread@CURTOK{#1}%
+ \ifx\pgfplotstableread@CURTOK\pgfplotstable@EOI
+ \def\pgfplotstableread@NEXT{}%
+ \else
+ \def\pgfplotstableread@NEXT{\pgfplotstableread@isnumber@ITERATE}%
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@plus
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@minus
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@zero
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@one
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@two
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@three
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@four
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@five
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@six
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@seven
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@eight
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@nine
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@e
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@E
+ \else
+ \ifx\pgfplotstableread@CURTOK\pgfplotstableread@isnumber@period
+ \else
+%\message{NO ITS NOT! Token: '\meaning\pgfplotstableread@CURTOK'}%
+ % it's no number, so it is a column name.
+ \pgfplotstableread@curline@contains@colnamestrue
+ \def\pgfplotstableread@NEXT{\pgfplotstableread@impl@gobble}%
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \fi
+ \pgfplotstableread@NEXT
+}
+
+\def\pgfplotstable@error#1{\pgfplotsthrow{unsupported operation}{#1}\pgfeov}%
+
+
+\def\pgfplotstableset{%
+ \pgfqkeys{/pgfplots/table}%
+}%
+
+% Accepts a macro #1 which contains an argument denoting a column
+% name.
+%
+% 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.
+%
+% Otherwise, \ifpgfplotstableread@foundcolnames is set to true.
+\def\pgfplotstable@is@colname#1{%
+ \expandafter\pgfplotstabletypeset@is@colname@#1\pgfplotstable@EOI
+ \ifpgfplotstableread@foundcolnames
+ \else
+ \let#1=\pgfplotstable@loc@TMPa
+ \fi
+}%
+\def\pgfplotstabletypeset@is@colname@{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotstabletypeset@is@colname@index
+ }{%
+ \pgfplotstableread@foundcolnamestrue
+ \pgfplotstabletypeset@is@colname@name
+ }%
+}
+\def\pgfplotstabletypeset@is@colname@index@@{index}%
+\def\pgfplotstabletypeset@is@colname@index[#1]#2\pgfplotstable@EOI{%
+ \def\pgfplotstable@loc@TMPa{#1}%
+ \ifx\pgfplotstable@loc@TMPa\pgfplotstabletypeset@is@colname@index@@
+ \pgfplotstableread@foundcolnamesfalse
+ \edef\pgfplotstable@loc@TMPa{#2}%
+ \else
+ \pgfplotstableread@foundcolnamestrue
+ \fi
+}%
+\def\pgfplotstabletypeset@is@colname@name#1\pgfplotstable@EOI{}%
+
+% calls \pgfplotstableset{every table={#1}} where '#1' is the table
+% file name.
+%
+% Note that 'every table' is usually set *AFTER* any other option. In
+% other words: settings in 'every table' have higher precedence than
+% those provided, for example, at
+% \pgfplotstabletypeset[<options>]{...}.
+%
+% Why? Well, the <options> need to be set *before* the file name
+% argument is read. After all, it might contain an inline table for
+% which \catcodes need to be adjusted -- and <options> might explain
+% how.
+%
+% REMARK: An early attempt to change the precendence for 'every table'
+% was to set <options> again after 'every table'. But that is
+% incompatible with, for example '/.add={}{}' key handlers.
+%
+% This macro does nothing if 'every table' is empty.
+%
+% #1: the table name (argument to 'every table')
+% #2: The <options> which have already been set.
+\long\def\pgfplotstableset@every@table#1#2{%
+ \pgfkeysgetvalue{/pgfplots/table/every table/.@cmd}\pgfplotstable@loc@TMPa
+ \ifx\pgfplotstable@loc@TMPa\pgfplots@empty@style@key
+ \else
+ \pgfplotstableset{/pgfplots/table/every table={#1}}%,#2}%
+ \fi
+}%
+
+\def\pgfplotstabletypeset{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotstabletypeset@opt
+ }{%
+ \pgfplotstabletypeset@opt[]%
+ }%
+}
+\long\def\pgfplotstabletypeset@opt[#1]#2{%
+ \pgfplotstable@error@pkg{Please load \string\usepackage{pgfplotstable} before using \string\pgfplotstabletypeset}%
+}
+\let\pgfplotstabletypesetfile=\pgfplotstabletypeset
+
+\def\pgfplotstablecreatecol{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotstablecreatecol@opt
+ }{%
+ \pgfplotstablecreatecol@opt[]%
+ }%
+}%
+\def\pgfplotstablecreatecol@opt[#1]#2#3{%
+ \pgfplotstable@error@pkg{Please load \string\usepackage{pgfplotstable} before using \string\pgfplotstablecreatecol}%
+}%
+
+% 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
+}%
+\let\pgfplotstableforeachcolumn@orig=\pgfplotstableforeachcolumn
+
+% 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#1\as#2#3{%
+ \pgfplotstableforeachcolumn@orig\pgfplotstable@colnames@glob\as{#2}{#3}%
+}%
+
+% 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}
+
+% Defines \pgfmathresult (and now also \pgfplotsretval) to be the number of rows in table #1.
+%
+% #1 may be either a loaded table structure (a macro name) or a table
+% file name. In the latter case, the file will be loaded temporarily.
+\long\def\pgfplotstablegetrowsof#1{%
+ \pgfplotstable@isloadedtable{#1}{%
+ % ah - it is an already loaded table!
+ \begingroup
+ \pgfplotslistfront#1\to\pgfplotstablegetrows@@
+ \expandafter\pgfplotslistsize\csname\string#1@\pgfplotstablegetrows@@\endcsname\to\c@pgfplotstable@counta
+ \edef\pgfmathresult{\the\c@pgfplotstable@counta}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ }{%
+ % ah - it is a file name.
+ \begingroup
+ \pgfplotstableread{#1}\pgfplotstablegetrows@
+ \pgfplotstablegetrowsof{\pgfplotstablegetrows@}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ }%
+ \let\pgfplotsretval=\pgfmathresult
+}%
+
+% Defines \pgfplotsretval to contain the number of columns in table
+% #1.
+%
+% #1 may be either a loaded table structure (a macro name) or a table
+% file name. In the latter case, the file will be loaded temporarily.
+\long\def\pgfplotstablegetcolsof#1{%
+ \pgfplotstable@isloadedtable{#1}{%
+ % ah - it is an already loaded table!
+ \begingroup
+ \pgfplotslistsize#1\to\c@pgfplotstable@counta
+ \edef\pgfplotsretval{\the\c@pgfplotstable@counta}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ }{%
+ % ah - it is a file name.
+ \begingroup
+ \pgfplotstableread{#1}\pgfplots@table
+ \pgfplotstablegetcolsof{\pgfplots@table}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ }%
+ \let\pgfmathresult=\pgfplotsretval
+}
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotstexio.lua b/graphics/pgf/contrib/pgfplots/tex/pgfplotstexio.lua
new file mode 100644
index 0000000000..cffb518c92
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotstexio.lua
@@ -0,0 +1,500 @@
+-- This file has dependencies to BOTH, the TeX part of pgfplots and the LUA part.
+-- It is the only LUA component with this property.
+--
+-- Its purpose is to encapsulate the communication between TeX and LUA in a central LUA file
+--
+--
+-- Here is the idea how the TeX backend communicates with the LUA backend:
+--
+-- * TeX can call LUA methods in order to "do something". The reverse direction is not true: LUA cannot call TeX methods.
+--
+-- * the only way that LUA can read TeX input values or write TeX output values is the top layer (at the time of this writing: only pgfplotstexio.lua ).
+--
+-- * The LUA backend has one main purpose: scalability and performance.
+-- Its purpose is _not_ to run a standalone visualization.
+--
+-- The precise meaning of "scalability" is: the LUA backend should do as much
+-- as possible which is done for single coordinates. Coordinates constitute
+-- "scalability": the number of coordinates can become arbitrarily large.
+--
+-- "Performance" is related to scalability. But it is more: some dedicated
+-- utility function might have a TeX backend and will be invoked whenever it
+-- is needed. Candidates are colormap functions, z buffer arithmetics etc.
+--
+-- Thus, the best way to ensure "scalability" is to move _everything_ which is to be done for a single coordinate to LUA.
+--
+-- Sometimes, this will be impossible or too expensive.
+-- Here, "Performance" might still be optimized by some dedicated LUA function.
+--
+--
+-- Unfortunately, the LUA backend does not simplify the code base - it makes it more complicated.
+-- This is due to the way it is used: one needs to know when the TeX backend
+-- delegates all its work to LUA. It is also due to the fact that it
+-- duplicates code: the same code is present in TeX and in LUA. I chose to keep
+-- the two code bases close to each other. This has a chance to simplify maintenance: if I know
+-- how something works in TeX, and I find some entry point in LUA, it will
+-- hopefully be closely related.
+--
+--
+-- It follows an overview over entry points into the LUA backend:
+--
+-- * \begin{axis}. It invokes \pgfplots@prepare@LUA@api .
+-- The purpose is to define the global pgfplots.gca "_g_et _c_urrent _a_xis" and to transfer some key presets.
+--
+-- Log message: "lua backend=true: Activating LUA backend for axis."
+--
+-- * \end{axis}. It invokes \pgfplots@LUA@visualization@update@axis .
+-- The purpose is to transfer results of the survey phase to LUA; in particular axis properties like
+-- the view direction, data scale transformations, axis wide limits and some related properties.
+-- This has nothing to do with coordinates; the survey phase of coordinates is handled in a different way (see below).
+--
+-- Eventually, \pgfplots@LUA@cleanup will clear the global pgfplots.gca .
+--
+-- * \addplot . This has much to do with scalability, so much of its functionality is done in the LUA backend.
+--
+-- Keep in mind that \addplot is part of the survey phase: it collects coordinates and updates axis limits.
+-- Afterwards, it stores the survey results in the current axis.
+--
+-- The survey phase currently has two different ways to communicate with the LUA backend:
+--
+-- 1. PARTIAL MODE. In this mode, the coordinate stream comes from TeX:
+-- some TeX code generates the coordinates. Whenever the stream is ready,
+-- it will invoke \pgfplots@LUA@survey@point . This, in turn, calls the
+-- LUA backend in order to complete the survey (which boils down to
+-- pgfplots.texSurveyPoint). PARTIAL MODE saves lots of time, but its
+-- scalability is limited due to the intensive use of TeX, it is less
+-- powerful than COMPLETE MODE.
+--
+-- 2. COMPLETE MODE. In this mode, the entire coordinate stream is on the
+-- LUA side. The TeX code will merely call start the survey phase, call
+-- LUA, and end the survey phase. This is the most efficient
+-- implementation. At the time of this writing, it is limited to `\addplot
+-- expression`: the code for `\addplot expression` tries to transfer the
+-- entire processing to the LUA backend. If it succeeds, it will do
+-- nothing on the TeX side.
+--
+-- Both PARTIAL MODE and COMPLETE MODE call
+-- \pgfplots@LUA@survey@start : transfer plot type and current axis arguments to LUA
+-- and
+-- \pgfplots@LUA@survey@end : copy LUA axis arguments back to TeX.
+--
+-- Eventually, the axis will initiate the visualization phase for each plot. This is done by
+-- a) \pgfplots@LUA@visualization@init : it calls pgfplots.texVisualizationInit() and results in the log message
+-- "lua backend=true: Activating partial LUA backend for visualization of plot 0".
+-- b) \pgfplots@LUA@visualization@of@current@plot : it transfers control
+-- to LUA (pgfplots.texVisualizePlot) and does as much with the
+-- coordinates as possible. Eventually, it streams the result back to
+-- TeX which will visualize the stream by means of PGF's plot streams.
+-- This is somewhat complicated since it modifies the TeX streaming.
+local pgfplotsmath = pgfplots.pgfplotsmath
+local tex=tex
+local tostring=tostring
+local error=error
+local table=table
+local string=string
+local pairs=pairs
+local pcall=pcall
+local type=type
+local lpeg = require("lpeg")
+local math = math
+
+do
+-- all globals will be read from/defined in pgfplots:
+local _ENV = pgfplots
+
+local pgftonumber = pgfluamathfunctions.tonumber
+
+-- will be assigned by pgfplots at boot time.
+LOAD_TIME_CATCODETABLE = nil
+
+-- Called during \addplot, i.e. during the survey phase. It is only called in PARTIAL MODE (see above).
+function texSurveyPoint(x,y,z,meta)
+ local pt = Coord.new()
+ pt.x[1] = x
+ pt.x[2] = y
+ pt.x[3] = z
+ pt.meta = meta
+
+ gca.currentPlotHandler:surveypoint(pt)
+end
+
+-- Called during \addplot, i.e. during the survey phase. It is only called in PARTIAL MODE (see above).
+function texSurveyAddJump()
+ local pt = Coord.new()
+ pt.x[1] = nil
+ pt.x[2] = nil
+ pt.x[3] = nil
+ pt.meta = nil
+
+ gca:addSurveyedJump(gca.currentPlotHandler, pt)
+end
+
+-- Copies survey results of the current plot back to TeX. It prints a couple of executable TeX statements as result.
+-- @see \pgfplots@LUA@survey@end
+function texSurveyEnd()
+ local result = gca:surveyToPgfplots(gca.currentPlotHandler, true)
+ --log("returning " .. result .. "\n\n")
+
+ tex.sprint(LOAD_TIME_CATCODETABLE, result);
+ gca.currentPlotHandler=nil
+end
+
+-- A performance optimization: point meta transformation is done on the LUA side.
+--
+-- expands to the transformed point meta
+function texPerpointMetaTrafo(metaStr)
+ local meta = pgftonumber(metaStr)
+ local transformed = gca.currentPlotHandler:visualizationTransformMeta(meta);
+ tex.sprint(LOAD_TIME_CATCODETABLE, tostringfixed(transformed));
+end
+
+-- Called at the beginning of each plot visualization.
+--
+-- expands to '1' if LUA is available for this plot and '0' otherwise.
+-- @see texVisualizePlot
+function texVisualizationInit(plotNum, plotIs3d)
+ if not plotNum or plotIs3d==nil then error("arguments must not be nil") end
+
+ local currentPlotHandler = gca.plothandlers[plotNum+1]
+ gca.currentPlotHandler = currentPlotHandler;
+ if currentPlotHandler then
+ currentPlotHandler.plotIs3d = plotIs3d
+ currentPlotHandler:visualizationPhaseInit();
+ tex.sprint("1")
+ else
+ -- ok, this plot has no LUA support.
+ tex.sprint("0")
+ end
+end
+
+local pgfXyCoordSerializer = function(pt)
+ -- FIXME : it is unsure of whether this here really an improvement - or if it would be faster to compute that stuff in TeX...
+ if pt.pgfXY ~=nil then
+ return "{" .. tostringfixed(pt.pgfXY[1]) .. "}{" .. tostringfixed(pt.pgfXY[2]) .. "}"
+ else
+ return "{0}{0}"
+ end
+end
+
+-- Actually does as much of the visualization of the current plot: it transforms all coordinates to some point where the TeX visualization mode continues.
+--
+-- It expands to the resulting coordinates. Note that these coordinates are already mapped somehow (typically: to fixed point)
+-- @see texVisualizationInit
+function texVisualizePlot(visualizerFactory)
+ if not visualizerFactory then error("arguments must not be nil") end
+ if type(visualizerFactory) ~= "function" then error("arguments must be a function (a factory)") end
+
+ local currentPlotHandler = gca.currentPlotHandler
+ if not currentPlotHandler then error("Illegal state: The current plot has no LUA plot handler!") end
+
+ local visualizer = visualizerFactory(currentPlotHandler)
+
+ local result = visualizer:getVisualizationOutput()
+ local result_str = currentPlotHandler:getCoordsInTeXFormat(gca, result, pgfXyCoordSerializer)
+ --log("returning " .. result_str .. "\n\n")
+ tex.sprint(LOAD_TIME_CATCODETABLE, result_str)
+end
+
+-- Modifies the Surveyed coordinate list.
+-- Expands to nothing
+function texApplyZBufferReverseScanline(scanLineLength)
+ local currentPlotHandler = gca.currentPlotHandler
+ if not currentPlotHandler then error("This function cannot be used in the current context") end
+
+ currentPlotHandler:reverseScanline(scanLineLength)
+end
+
+-- Modifies the Surveyed coordinate list.
+-- Expands to nothing
+function texApplyZBufferReverseTransposed(scanLineLength)
+ local currentPlotHandler = gca.currentPlotHandler
+ if not currentPlotHandler then error("This function cannot be used in the current context") end
+
+ currentPlotHandler:reverseTransposed(scanLineLength)
+end
+
+-- Modifies the Surveyed coordinate list.
+-- Expands to nothing
+function texApplyZBufferReverseStream()
+ local currentPlotHandler = gca.currentPlotHandler
+ if not currentPlotHandler then error("This function cannot be used in the current context") end
+
+ currentPlotHandler:reverseStream(scanLineLength)
+end
+
+-- Modifies the Surveyed coordinate list.
+--
+-- Note that this is UNRELATED to mesh/surface plots! They have their own (patch-based) z buffer.
+--
+-- Expands to nothing
+function texApplyZBufferSort()
+ local currentPlotHandler = gca.currentPlotHandler
+ if not currentPlotHandler then error("This function cannot be used in the current context") end
+
+ currentPlotHandler:sortCoordinatesByViewDepth()
+end
+
+-- Modifies the Surveyed coordinate list.
+-- Expands to the resulting coordinates
+function texGetSurveyedCoordsToPgfplots()
+ local currentPlotHandler = gca.currentPlotHandler
+ if not currentPlotHandler then error("This function cannot be used in the current context") end
+
+ tex.sprint(LOAD_TIME_CATCODETABLE, currentPlotHandler:surveyedCoordsToPgfplots(gca))
+end
+
+function texColorMapSetScaleOrderZ(mapName, scaleOrderZ)
+ local colormap = ColorMaps[mapName];
+ if colormap then
+ colormap:setScaleOrderZ(scaleOrderZ)
+ end
+end
+
+-- Performance optimization: computes the colormap lookup.
+function texColorMapPrecomputed(mapName, inMin, inMax, x)
+ local colormap = ColorMaps[mapName];
+ if colormap then
+ local result = colormap:findPrecomputed(
+ pgftonumber(inMin),
+ pgftonumber(inMax),
+ pgftonumber(x))
+
+ local str = ""
+ for i = 1,#result do
+ if i>1 then str = str .. "," end
+ str = str .. tostringfixed(result[i])
+ end
+ tex.sprint(LOAD_TIME_CATCODETABLE, str)
+ end
+end
+
+-- Performance optimization: computes the colormap lookup.
+function texColorMapFindPiecewiseConst(mapName, inMin, inMax, x)
+ local colormap = ColorMaps[mapName];
+ if colormap then
+ local result = colormap:findPiecewiseConst(
+ pgftonumber(inMin),
+ pgftonumber(inMax),
+ pgftonumber(x))
+
+ local str = ""
+ for i = 1,#result do
+ if i>1 then str = str .. "," end
+ str = str .. tostringfixed(result[i])
+ end
+ tex.sprint(LOAD_TIME_CATCODETABLE, str)
+ end
+end
+
+local function isStripPrefixOrSuffixChar(char)
+ return char == ' ' or char == '{' or char == "}"
+end
+
+-- Expressions can be something like
+-- ( {(6+(sin(3*(x+3*y))+1.25)*cos(x))*cos(y)},
+-- {(6+(sin(3*(x+3*y))+1.25)*cos(x))*sin(y)},
+-- {((sin(3*(x+3*y))+1.25)*sin(x))} );
+--
+-- These result in expressions = { " {...}", " {...}", " {...} " }
+-- -> this function removes the surrounding braces and the white spaces.
+local function removeSurroundingBraces(expressions)
+ for i=1,#expressions do
+ local expr = expressions[i]
+ local startIdx
+ local endIdx
+ startIdx=1
+ while startIdx<#expr and isStripPrefixOrSuffixChar(string.sub(expr,startIdx,startIdx)) do
+ startIdx = startIdx+1
+ end
+ endIdx = #expr
+ while endIdx > 0 and isStripPrefixOrSuffixChar(string.sub(expr,endIdx,endIdx)) do
+ endIdx = endIdx-1
+ end
+
+ expr = string.sub(expr, startIdx, endIdx )
+ expressions[i] = expr
+ end
+end
+
+-------------
+-- A parser for foreach statements - at least those which are supported in this LUA backend.
+--
+local samplesAtToDomain
+do
+ local P = lpeg.P
+ local C = lpeg.C
+ local V = lpeg.V
+ local match = lpeg.match
+ local space_pattern = P(" ")^0
+
+ local Exp = V"Exp"
+ local comma = P"," * space_pattern
+ -- this does not catch balanced braces. Ok for now... ?
+ local argument = C( ( 1- P"," )^1 ) * space_pattern
+ local grammar = P{ "initialRule",
+ initialRule = space_pattern * Exp * -1,
+ Exp = lpeg.Ct(argument * comma * argument * comma * P"..." * space_pattern * comma *argument )
+ }
+
+ -- Converts very simple "samples at" values to "domain=A:B, samples=N"
+ --
+ -- @param foreachString something like -5,-4,...,5
+ -- @return a table where
+ -- [0] = domain min
+ -- [1] = domain max
+ -- [2] = samples
+ -- It returns nil if foreachString is no "very simple value of 'samples at'"
+ samplesAtToDomain = function(foreachString)
+ local matches = match(grammar,foreachString)
+
+ if not matches or #matches ~= 3 then
+ return nil
+ else
+ local arg1 = matches[1]
+ local arg2 = matches[2]
+ local arg3 = matches[3]
+ arg1= pgfluamathparser.pgfmathparse(arg1)
+ arg2= pgfluamathparser.pgfmathparse(arg2)
+ arg3= pgfluamathparser.pgfmathparse(arg3)
+
+ if not arg1 or not arg2 or not arg3 then
+ return nil
+ end
+
+ if arg1 > arg2 then
+ return nil
+ end
+
+ local domainMin = arg1
+ local h = arg2-arg1
+ local domainMax = arg3
+
+ -- round to the nearest integer (using +0.5, should be ok)
+ local samples = math.floor((domainMax - domainMin)/h + 0.5) + 1
+
+ return domainMin, domainMax, samples
+ end
+ end
+end
+
+-- This is the code which attempts to transfer control from `\addplot expression' to LUA.
+--
+-- If it succeeds, the entire plot stream and the entire survey phase has been done in LUA.
+--
+-- generates TeX output '1' on success and '0' on failure
+-- @param debugMode one of a couple of strings: "off", "verbose", or "compileerror"
+function texAddplotExpressionCoordinateGenerator(
+ is3d,
+ xExpr, yExpr, zExpr,
+ sampleLine,
+ domainxmin, domainxmax,
+ domainymin, domainymax,
+ samplesx, samplesy,
+ variablex, variabley,
+ samplesAt,
+ debugMode
+)
+ local plothandler = gca.currentPlotHandler
+ local coordoutputstream = SurveyCoordOutputStream.new(plothandler)
+
+ if samplesAt and string.len(samplesAt) >0 then
+ -- "samples at" has higher priority than domain.
+ -- Use it!
+
+ domainxmin, domainxmax, samplesx = samplesAtToDomain(samplesAt)
+ if not domainxmin then
+ -- FAILURE: could not convert "samples at".
+ -- Fall back to a TeX based survey.
+ log("log", "LUA survey failed: The value of 'samples at= " .. tostring(samplesAt) .. "' is unsupported by the LUA backend (currently, only 'samples at={a,b,...,c}' is supported).\n")
+ tex.sprint("0")
+ return
+ end
+
+ else
+ domainxmin= pgftonumber(domainxmin)
+ domainxmax= pgftonumber(domainxmax)
+ samplesx= pgftonumber(samplesx)
+ end
+
+ local expressions
+ local domainMin
+ local domainMax
+ local samples
+ local variableNames
+
+ -- allow both, even if sampleLine=1. We may want to assign a dummy value to y.
+ variableNames = { variablex, variabley }
+
+ if sampleLine==1 then
+ domainMin = { domainxmin }
+ domainMax = { domainxmax }
+ samples = { samplesx }
+ else
+ local domainymin = pgftonumber(domainymin)
+ local domainymax = pgftonumber(domainymax)
+ local samplesy = pgftonumber(samplesy)
+
+ domainMin = { domainxmin, domainymin }
+ domainMax = { domainxmax, domainymax }
+ samples = { samplesx, samplesy }
+ end
+ if is3d then
+ expressions = {xExpr, yExpr, zExpr}
+ else
+ expressions = {xExpr, yExpr}
+ end
+ removeSurroundingBraces(expressions)
+
+ local generator = AddplotExpressionCoordinateGenerator.new(
+ coordoutputstream,
+ expressions,
+ domainMin, domainMax,
+ samples,
+ variableNames)
+
+ local messageOnFailure
+ local compileErrorOnFailure
+ if debugMode == "compileerror" then
+ compileErrorOnFailure = true
+ messageOnFailure = true
+ elseif debugMode == "off" or debugMode == "verbose" then
+ messageOnFailure = true
+ compileErrorOnFailure = false
+ elseif debugMode == "off and silent" then
+ messageOnFailure = false
+ compileErrorOnFailure = false
+ else
+ error("Got unknown debugMode = " .. debugMode )
+ end
+
+ local success
+ if compileErrorOnFailure then
+ success = generator:generateCoords()
+ else
+ local resultOfGenerator
+ success, resultOfGenerator = pcall(generator.generateCoords, generator)
+ if success then
+ -- AH: "pcall" returned 'true'. In this case, 'success' is the boolean returned by generator
+ success = resultOfGenerator
+ end
+
+ if messageOnFailure and not success and type(resultOfGenerator) ~= "boolean" then
+ log("log", "LUA survey failed: " .. resultOfGenerator .. ". Use \\pgfplotsset{lua debug} to see more.\n")
+ end
+ end
+
+ if not type(success) == 'boolean' then error("Illegal state: expected boolean result") end
+
+ if success then
+ tex.sprint("1")
+ else
+ tex.sprint("0")
+ end
+end
+
+-- Creates the default plot visualizer factory. It simply applies data scale trafos.
+function defaultPlotVisualizerFactory(plothandler)
+ return PlotVisualizer.new(plothandler)
+end
+
+end
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsticks.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsticks.code.tex
new file mode 100644
index 0000000000..f5acfd81ef
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsticks.code.tex
@@ -0,0 +1,2585 @@
+%--------------------------------------------
+%
+% 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/>.
+%
+%--------------------------------------------
+
+\newif\ifpgfplots@log@tick@isminor@tick@pos
+% Checks whether the tick position given as #1.#2=log10(T) belongs to
+% T=i*10^j with an integer i>1.
+%
+% If T=i*10^j, \ifpgfplots@log@tick@isminor@tick@pos will be set to true and
+% \pgfmathresult will contain T.
+%
+% Otherwise, \ifpgfplots@log@tick@isminor@tick@pos will be set to false and
+% pgfmathresult to #1.#2
+%
+% Arguments:
+% #1.#2 the value log10(T)
+%
+% Implementation:
+% if T = i*10^j, log10(T) = log10(i) + j.
+% That means if log10(T) in \Z, we have T = 10^j. If not, we need to
+% check wether i is an integer. Please note that log10(i) < 1.
+%
+% Further note: log(T) < 0 <=> j<0.
+% In case j<0, we have
+% #1.#2 = j + log(i)
+% = - ( -j - log(i) )
+% = - ( -j - 1 + (1-log(i)) )
+% = #1 '.' #2 [ up to the '0.'
+% that means #1 = j-1 and #2 = 1-log(i).
+\def\pgfplots@is@log@tick@a@minor@tick@pos#1.#2\relax{%
+ \pgfmathapproxequalto@{#1.#2}{#1.0}%
+ \ifpgfmathcomparison
+ % in MOST cases, this here will be true:
+ \pgfplots@log@tick@isminor@tick@posfalse
+ \def\pgfmathresult{#1.#2}%
+ \else
+ % I guess this won't happen too often. In fact, it's a very
+ % special case.
+ \begingroup
+ \c@pgf@counta=#1\relax
+ \ifdim#1.#2pt<0pt %
+ \advance\c@pgf@counta by-1
+ \pgfmathsubtract@{1}{0.#2}%
+ \expandafter\pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi\pgfmathresult\relax
+ \ifpgfplots@log@tick@isminor@tick@pos
+ \aftergroup\pgfplots@log@tick@isminor@tick@postrue
+ \edef\pgfmathresult{\pgfmathresult e\the\c@pgf@counta}%
+ \else
+ \aftergroup\pgfplots@log@tick@isminor@tick@posfalse
+ \def\pgfmathresult{#1.#2}%
+ \fi
+ \else
+ \pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi0.#2\relax
+ \ifpgfplots@log@tick@isminor@tick@pos
+ \aftergroup\pgfplots@log@tick@isminor@tick@postrue
+ \edef\pgfmathresult{\pgfmathresult e\the\c@pgf@counta}%
+ \else
+ \aftergroup\pgfplots@log@tick@isminor@tick@posfalse
+ \def\pgfmathresult{#1.#2}%
+ \fi
+ \fi
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \fi
+}
+
+% expects a positive number.
+\def\pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi0.#1\relax{%
+ \pgfplots@log@tick@isminor@tick@postrue
+ \pgfmathapproxequalto@{0.#1}{0.3010299956639}%
+ \ifpgfmathcomparison
+ \def\pgfmathresult{2}%
+ \else
+ \pgfmathapproxequalto@{0.#1}{0.4771212547196}%
+ \ifpgfmathcomparison
+ \def\pgfmathresult{3}%
+ \else
+ \pgfmathapproxequalto@{0.#1}{0.6020599913279}%
+ \ifpgfmathcomparison
+ \def\pgfmathresult{4}%
+ \else
+ \pgfmathapproxequalto@{0.#1}{0.698970004}%
+ \ifpgfmathcomparison
+ \def\pgfmathresult{5}%
+ \else
+ \pgfmathapproxequalto@{0.#1}{0.7781512503}%
+ \ifpgfmathcomparison
+ \def\pgfmathresult{6}%
+ \else
+ \pgfmathapproxequalto@{0.#1}{0.8450980400}%
+ \ifpgfmathcomparison
+ \def\pgfmathresult{7}%
+ \else
+ \pgfmathapproxequalto@{0.#1}{0.9030899869}%
+ \ifpgfmathcomparison
+ \def\pgfmathresult{8}%
+ \else
+ \pgfmathapproxequalto@{0.#1}{0.954242509439}%
+ \ifpgfmathcomparison
+ \def\pgfmathresult{9}%
+ \else
+ \pgfplots@log@tick@isminor@tick@posfalse
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+}
+
+% Checks whether we need to create a separate 'tick scale label',
+% a node with ' * 10^3' on the side of the axis:
+%
+% PRECONDITION:
+% Axis limits for #1 are given. I need their values before any data
+% scale transformation has been applied.
+% If
+% \pgfplots@#1min@unscaled@as@float
+% and
+% \pgfplots@#1max@unscaled@as@float
+% exist; I will use these macros.
+% Otherwise, I will use \pgfplots@#1min and \pgfplots@#1max;
+% assuming that no data scale transformation is active.
+% FIXME : does that need further attention?
+\def\pgfplots@init@scaled@tick@for#1{%
+ \global\def\pgfplots@glob@TMPa{0}%
+ \expandafter\pgfplotslistcheckempty\csname pgfplots@prepared@tick@positions@major@#1\endcsname
+ \ifpgfplotslistempty
+ % we have no tick labels. Omit the tick scale label as well!
+ \else
+ \begingroup
+ \ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname\relax
+ % CASE 0 : scaled #1 ticks=false: do nothing here.
+ \or
+ % CASE 1 : scaled #1 ticks=true:
+ %--------------------------------
+ % the \pgfplots@xmin@unscaled@as@float is set just before the data
+ % scale transformation is initialised.
+ %
+ % The variables are empty if there is no datascale transformation.
+ \expandafter\let\expandafter\pgfplots@cur@min@unscaled\csname pgfplots@#1min@unscaled@as@float\endcsname
+ \expandafter\let\expandafter\pgfplots@cur@max@unscaled\csname pgfplots@#1max@unscaled@as@float\endcsname
+ %
+ \ifx\pgfplots@cur@min@unscaled\pgfutil@empty
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@#1min\endcsname}%
+ \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}%
+ \let\pgfplots@cur@min@unscaled=\pgfmathresult
+ \edef\pgfplots@loc@TMPa{\csname pgfplots@#1max\endcsname}%
+ \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}%
+ \let\pgfplots@cur@max@unscaled=\pgfmathresult
+ \fi
+ %
+ \expandafter\pgfmathfloat@decompose@E\pgfplots@cur@min@unscaled\relax\pgfmathfloat@a@E
+ \expandafter\pgfmathfloat@decompose@E\pgfplots@cur@max@unscaled\relax\pgfmathfloat@b@E
+ \pgfplots@init@scaled@tick@normalize@exponents
+ \ifnum\pgfmathfloat@b@E<\pgfmathfloat@a@E
+ \pgfmathfloat@b@E=\pgfmathfloat@a@E
+ \fi
+ \xdef\pgfplots@glob@TMPa{\pgfplots@scale@ticks@above@exponent}%
+ \ifnum\pgfplots@glob@TMPa<\pgfmathfloat@b@E
+ % ok, scale it:
+ \multiply\pgfmathfloat@b@E by-1
+ \xdef\pgfplots@glob@TMPa{\the\pgfmathfloat@b@E}%
+ \else
+ \xdef\pgfplots@glob@TMPa{\pgfplots@scale@ticks@below@exponent}%
+ \ifnum\pgfplots@glob@TMPa>\pgfmathfloat@b@E
+ % ok, scale it:
+ \multiply\pgfmathfloat@b@E by-1
+ \xdef\pgfplots@glob@TMPa{\the\pgfmathfloat@b@E}%
+ \else
+ % no scaling necessary:
+ \xdef\pgfplots@glob@TMPa{0}%
+ \fi
+ \fi
+ \or
+ % CASE 2 : scaled #1 ticks=base 10:
+ %--------------------------------
+ \c@pgf@counta=\csname pgfplots@scaled@ticks@#1@arg\endcsname\relax
+ %\multiply\c@pgf@counta by-1
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \or
+ % CASE 3 : scaled #1 ticks=real:
+ %--------------------------------
+ \pgfmathfloatparsenumber{\csname pgfplots@scaled@ticks@#1@arg\endcsname}%
+ \global\let\pgfplots@glob@TMPa=\pgfmathresult
+ \or
+ % CASE 4 : scaled #1 ticks=manual:
+ \expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfplots@scaled@ticks@#1@arg\endcsname
+ \fi
+ \endgroup
+ \fi
+ \expandafter\let\csname pgfplots@tick@scale@#1\endcsname=\pgfplots@glob@TMPa%
+}
+
+% Handles the case that one of the limits is 0 (or unbounded, although
+% that might not be a use-case at all).
+%
+% Note that 0 = 0*10^A (naturally). In this case, A can be undefined,
+% and we want to use B's exponent (only) for the decision here.
+%
+% INPUT:
+% - \pgfplots@cur@min@unscaled,
+% - \pgfplots@cur@max@unscaled,
+% - \pgfmathfloat@a@E
+% - \pgfmathfloat@b@E
+%
+% Output:
+% normalized values of \pgfmathfloat@a@E and \pgfmathfloat@b@E
+\def\pgfplots@init@scaled@tick@normalize@exponents{%
+ \pgfmathfloatgetflags\pgfplots@cur@min@unscaled\pgfmathfloat@a@S
+ \pgfmathfloatgetflags\pgfplots@cur@max@unscaled\pgfmathfloat@b@S
+ \ifcase\pgfmathfloat@a@S%
+ % min = 0.
+ \ifcase\pgfmathfloat@b@S
+ % max =0
+ % normalize to 0 * 10^0 !
+ \pgfmathfloat@a@E=0 %
+ \pgfmathfloat@b@E=0 %
+ \or
+ % max > 0
+ % since 0 = 0 * 10^A for any A, tick scaling is based on
+ % B only.
+ \pgfmathfloat@a@E=\pgfmathfloat@b@E
+ \or
+ % max < 0
+ \pgfmathfloat@a@E=\pgfmathfloat@b@E
+ \else
+ % max is unbounded. normalize exponent to something
+ % useful:
+ \pgfmathfloat@a@E=0 %
+ \pgfmathfloat@b@E=0 %
+ \fi
+ \or
+ % min>0
+ \ifcase\pgfmathfloat@b@S
+ % max =0
+ % since 0 = 0 * 10^B for any B, tick scaling is based on
+ % A only.
+ \pgfmathfloat@b@E=\pgfmathfloat@a@E
+ \or
+ % max > 0
+ \or
+ % max < 0
+ \else
+ % max is unbounded. normalize exponent to something
+ % useful:
+ \pgfmathfloat@b@E=\pgfmathfloat@a@E
+ \fi
+ \or
+ % min<0
+ \ifcase\pgfmathfloat@b@S
+ % max =0
+ % since 0 = 0 * 10^B for any B, tick scaling is based on
+ % A only.
+ \pgfmathfloat@b@E=\pgfmathfloat@a@E
+ \or
+ % max > 0
+ \or
+ % max < 0
+ \else
+ % max is unbounded. normalize exponent to something
+ % useful:
+ \pgfmathfloat@b@E=\pgfmathfloat@a@E
+ \fi
+ \else
+ % min is unbounded:
+ % normalize somehow.
+ \pgfmathfloat@a@E=0 %
+ \pgfmathfloat@b@E=0 %
+ \fi
+}
+
+% x-axis tick labels for #1th tick
+% #1: the axis (x,y or z)
+% #2: the value
+% #3,#4+#5: arguments for \pgfplotspointonorientedsurfaceabwithbshift
+% #5: ticknumber
+\def\pgfplots@show@ticklabel#1#2(#3,#4+#5)#6{%
+ \begingroup%
+ \edef\pgfmathresult{#2}%
+ \pgfkeyslet{/pgfplots/sloped/at position}\pgfmathresult%
+ \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}%
+ \edef\pgfplots@show@ticklabel@coord@y@new{\pgfmathresult}%
+ %
+ \pgfplots@show@ticklabel@{#1}{#2}%
+ \let\nexttick=\tick
+ \ifx\pgfplots@show@ticklabel@LASTTICK\pgfutil@empty
+ % its the first call. Simply remember arguments and wait
+ % for interval boundary before proceeding.
+ \else
+ % acquire options of first interval boundary:
+ \pgfplots@show@ticklabel@LASTTICK
+ % compute new node position:
+ \pgfmathparse{0.5*(\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%
+ \pgfplots@show@ticklabel@@{#1}
+ {\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@show@ticklabel@coord@x}{\pgfplots@show@ticklabel@coord@y}{#5}}%
+ \fi
+ \xdef\pgfplots@show@ticklabel@LASTTICK{%
+ \noexpand\def\noexpand\pgfplots@show@ticklabel@tick{\nexttick}%
+ \noexpand\def\noexpand\pgfplots@show@ticklabel@coord@x{\pgfplots@show@ticklabel@coord@x@new}%
+ \noexpand\def\noexpand\pgfplots@show@ticklabel@coord@y{\pgfplots@show@ticklabel@coord@y@new}%
+ \noexpand\edef\noexpand\pgfplots@show@ticklabel@num{#6}%
+ }%
+ \else
+ \let\ticknum=#6\relax%
+ \pgfplots@show@ticklabel@{#1}{#2}%
+ \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceabwithbshift{#3}{#4}{#5}}%
+ \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
+ %
+ % 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\pgf@pos@transform\pgf@x\pgf@y}%
+ {\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{%
+%\message{using \string\pgfplotsqpointoutsideofaxisrel{\csname pgfplots@#1ticklabelaxisspec\endcsname}{#2}{#3}^^J}%
+ \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.
+%
+% #1: axis (x or y)
+% #2: tick value.
+\def\pgfplots@show@ticklabel@#1#2{%
+ \csname ifpgfplots@apply@datatrafo@#1\endcsname
+ \pgfplotscoordmath{#1}{datascaletrafo inverse}{#2}%
+ \ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname
+ \or
+ \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}%
+ \or
+ \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}%
+ \or
+ \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}%
+ \or
+ % scaled #1 ticks=manual. Invoke manual tick scaling code:
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@tick@scale@#1\endcsname
+ \begingroup
+ \pgfkeys{/pgf/fpu=true}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \pgfmathfloatparsenumber\pgfmathresult%
+ \fi
+ % .. and this here provides \tick as fixed point repr:
+ \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
+ \let\tick=\pgfmathresult
+ \else
+ \edef\tick{#2}%
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \ifnum\csname pgfplots@scaled@ticks@#1@choice\endcsname=0
+ \else
+ \pgfmathfloatparsenumber{#2}%
+ \ifnum\csname pgfplots@scaled@ticks@#1@choice\endcsname=3
+ \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}%
+ \else
+ \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}%
+ \fi
+ \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
+ \let\tick=\pgfmathresult
+ \fi
+ }{}%
+ \fi
+ \pgfplots@coord@inv@trafo@apply{#1}{\tick}%
+ \let\tick=\pgfmathresult
+}%
+
+\def\pgfplots@user@ticklabel@list@x{%
+ \pgfplotslistselectorempty\ticknum\of\pgfplots@xticklabels\to\tick
+ \pgfplots@ticklabel@typeset@arg\tick
+}
+\def\pgfplots@user@ticklabel@list@y{%
+ \pgfplotslistselectorempty\ticknum\of\pgfplots@yticklabels\to\tick
+ \pgfplots@ticklabel@typeset@arg\tick
+}
+\def\pgfplots@user@ticklabel@list@z{%
+ \pgfplotslistselectorempty\ticknum\of\pgfplots@zticklabels\to\tick
+ \pgfplots@ticklabel@typeset@arg\tick
+}
+\def\pgfplots@user@extra@ticklabel@list@x{%
+ \pgfplotslistselectorempty\ticknum\of\pgfplots@extra@xticklabels\to\tick
+ \pgfplots@ticklabel@typeset@arg\tick
+}
+\def\pgfplots@user@extra@ticklabel@list@y{%
+ \pgfplotslistselectorempty\ticknum\of\pgfplots@extra@yticklabels\to\tick
+ \pgfplots@ticklabel@typeset@arg\tick
+}
+\def\pgfplots@user@extra@ticklabel@list@z{%
+ \pgfplotslistselectorempty\ticknum\of\pgfplots@extra@zticklabels\to\tick
+ \pgfplots@ticklabel@typeset@arg\tick
+}
+
+\def\pgfplots@limit@max@reg#1{%
+ \if\pgfkeysvalueof{/pgfplots/#1 dir/value}n%
+ \csname pgfplots@#1max@reg\endcsname
+ \else
+ \csname pgfplots@#1min@reg\endcsname
+ \fi
+}%
+\def\pgfplots@limit@min@reg#1{%
+ \if\pgfkeysvalueof{/pgfplots/#1 dir/value}n%
+ \csname pgfplots@#1min@reg\endcsname
+ \else
+ \csname pgfplots@#1max@reg\endcsname
+ \fi
+}%
+
+% Check if a label does not cross the x-axis
+\def\pgfplots@ytick@check@tickshow{%
+ \pgfplots@tickshowtrue
+ %
+ \pgfplots@if@has@axis@shift x{%
+ \pgfplots@hide@obscured@ytickfalse
+ }{}%
+ %
+ \ifpgfplots@hide@obscured@ytick
+ \if\pgfplots@yaxislinesnum2% center
+ \ifcase\pgfplots@xaxislinesnum\relax
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@limit@min@reg{y}}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@limit@max@reg{y}}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \or
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@limit@min@reg{y}}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{%
+ }%
+ \or
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@logical@ZERO@y pt}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \or
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@limit@max@reg{y}}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \fi
+ \fi
+ \fi
+}
+\def\pgfplots@ztick@check@tickshow{%
+ \pgfplots@tickshowtrue
+ %
+ \pgfplots@if@has@axis@shift x{%
+ \pgfplots@if@has@axis@shift y{%
+ \pgfplots@hide@obscured@ztickfalse
+ }{}%
+ }{}%
+ %
+ \ifpgfplots@hide@obscured@ztick
+ \if\pgfplots@zaxislinesnum2% center
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@logical@ZERO@z pt}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \fi
+ \fi
+}%
+
+% Fills the macros
+% \pgfplots@tick@LOWER@b \pgfplots@tick@end@a
+% \pgfplots@tick@UPPER@b \pgfplots@tick@end@b
+% with coordinates such that
+% (\pgfplots@tick@LOWER@b,\pgfplots@tmpa) -- (\pgfplots@tick@end@a,\pgfplots@tmpa)
+% produces a correct tick line.
+%
+% The '@b' variant is only used in case of \pgfplots@ytickposnum = 0
+%
+% #1 : the current axis (x or y).
+% #2 : the 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@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}%
+ %
+ %(\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#2, 0pt)
+ \edef\pgfplots@tick@UPPER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}%
+ \or
+ % left
+ % (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt);
+ \edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}%
+ \or
+ % center
+ % (\pgfplots@ZERO@x -\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt);
+ \edef\pgfplots@tick@LOWER@b{\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB \endcsname}%
+ \or
+ % right
+ % (\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#2, 0pt);
+ \edef\pgfplots@tick@UPPER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}%
+ \else
+ % FALL BACK. never used, I guess?
+ % (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt);
+ \edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}%
+ \fi
+ %
+ \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax
+ \def\pgfplots@tick@offset{0}%
+ \or
+ \edef\pgfplots@tick@offset{#2}%
+ \or
+ \pgfmathmultiply@{0.5}{#2}%
+ \let\pgfplots@tick@offset=\pgfmathresult%
+ \fi
+ %
+ \edef\pgfplots@tick@LOWER@shiftbeg{-\pgfplots@tick@offset}%
+ \pgfmathadd@{\pgfplots@tick@LOWER@shiftbeg}{#2}%
+ \let\pgfplots@tick@LOWER@shiftend=\pgfmathresult
+ %
+ \edef\pgfplots@tick@UPPER@shiftbeg{\pgfplots@tick@offset}%
+ \pgfmathsubtract@{\pgfplots@tick@UPPER@shiftbeg}{#2}%
+ \let\pgfplots@tick@UPPER@shiftend=\pgfmathresult
+ %
+ % Assemble the \pgfplots@drawticklines@for@placecomputedtick
+ % command.
+ \def\pgfplots@drawticklines@for@placecomputedtick@LOWER{%
+ \pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@LOWER@b}{\pgfplots@tick@LOWER@shiftbeg pt}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@LOWER@b}{\pgfplots@tick@LOWER@shiftend pt}}%
+ }%
+ \def\pgfplots@drawticklines@for@placecomputedtick@UPPER{%
+ \pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@UPPER@b}{\pgfplots@tick@UPPER@shiftbeg pt}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@UPPER@b}{\pgfplots@tick@UPPER@shiftend pt}}%
+ }%
+%\message{place computed tick: LOWEROK=\pgfplots@drawticklines@for@placecomputedtick@LOWEROK; UPPEROK=\pgfplots@drawticklines@for@placecomputedtick@UPPEROK.}%
+}%
+
+
+\newif\ifpgfplots@needsminorloop
+
+\def\pgfplots@draw@tick@scale@label@for#1{%
+ \csname ifpgfplots@#1islinear\endcsname
+ \begingroup
+ \def\pgfplots@temp@isbaseten{0}%
+ \ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname
+ \global\let\pgfplots@glob@TMPa=\pgfutil@empty
+ \or
+ \xdef\pgfplots@glob@TMPa{\csname pgfplots@tick@scale@#1\endcsname}%
+ \def\pgfplots@temp@isbaseten{1}%
+ \or
+ \xdef\pgfplots@glob@TMPa{\csname pgfplots@tick@scale@#1\endcsname}%
+ \def\pgfplots@temp@isbaseten{1}%
+ \or
+ \xdef\pgfplots@glob@TMPa{\csname pgfplots@tick@scale@#1\endcsname}%
+ % real:
+ \or
+ % manual:
+ \global\def\pgfplots@glob@TMPa{dummyargument}%
+ \fi
+ \if1\pgfplots@temp@isbaseten
+ \expandafter\c@pgf@counta\pgfplots@glob@TMPa\relax
+ \multiply\c@pgf@counta by-1
+ \ifnum\c@pgf@counta=0\relax
+ \global\let\pgfplots@glob@TMPa=\pgfutil@empty
+ \else
+ \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
+ \fi
+ \fi
+ \endgroup
+ \ifx\pgfplots@glob@TMPa\pgfutil@empty
+ \else
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/#1tick scale label code/.@cmd}\pgfplots@loc@TMPa
+ \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}}%
+ %
+ \pgfplots@change@pgfpoints@to@descriptioncs
+ %
+ \node[%
+ /pgfplots/every tick label,%
+ /pgfplots/every #1 tick label,%
+ /pgfplots/every #1 tick scale label]
+ {\pgfplots@tick@scale@labels};
+ \fi
+ \endgroup
+ \fi
+ \fi
+}
+
+% Check if the current tick position, stored in \pgfplots@tmpa,
+% does not cross the y-axis.
+%
+% This is just a special case for centered axis lines.
+\def\pgfplots@xtick@check@tickshow{%
+ \pgfplots@tickshowtrue
+ %
+ \pgfplots@if@has@axis@shift y{%
+ \pgfplots@hide@obscured@xtickfalse
+ }{}%
+ %
+ \ifpgfplots@hide@obscured@xtick
+ \if\pgfplots@xaxislinesnum2% center
+ \ifcase\pgfplots@yaxislinesnum\relax
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@limit@min@reg{x}}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@limit@max@reg{x}}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \or
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@limit@min@reg{x}}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \or
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@logical@ZERO@x pt}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \or
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@limit@max@reg{x}}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{}%
+ \fi
+ \fi
+ \fi
+}
+
+% Draws extra ticks including grid lines, tick lines and tick labels
+% along the current oriented surface.
+%
+% See \pgfplots@drawticklines@onorientedsurf@ for a description of the
+% oriented surface.
+%
+% #1 : tick position list
+\def\pgfplots@draw@extra@ticks@onorientedsurf{%
+ \expandafter\pgfplots@draw@extra@ticks@onorientedsurf@\pgfplotspointonorientedsurfaceA
+}%
+% #1: axis (x or y)
+% #2: tick position list
+\def\pgfplots@draw@extra@ticks@onorientedsurf@#1#2{%
+ \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\pgfplots@ticklabel@pos@orig\csname pgfplots@#1ticklabel@pos\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}%
+ % use a scope here such that line width and draw color can be set.
+ \scope[/pgfplots/.cd,/pgfplots/every extra #1 tick]
+ \expandafter\let\expandafter\pgfplots@ticklabel@pos@\csname pgfplots@#1ticklabel@pos\endcsname
+ \ifx\pgfplots@ticklabel@pos@\pgfplots@ticklabel@pos@orig
+ \else
+ \pgfplots@init@ticklabelaxisspec
+ \fi
+ \pgfplots@prepare@tick@coordlists@for{#1}{#2}%
+ \pgfplots@drawgridlines@onorientedsurf%
+ \pgfplots@drawticklines@onorientedsurf%
+ \pgfplots@drawticklabels@onorientedsurf%
+ \endscope
+ \endgroup
+}
+
+% Computes final major and minor tick positions into global lists
+% \pgfplots@prepared@tick@positions@major@x
+% and
+% \pgfplots@prepared@tick@positions@minor@x.
+%
+% Both lists contain entries of the form {<index>}{<logical position>}
+% @see \pgfplots@prepared@tick@pos@unpack
+%
+% #1: the axis
+% #2: the tick list.
+%
+% PRECONDITION:
+% - \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
+ \expandafter\let\expandafter\ifpgfplots@minorticks\csname ifpgfplots@#1minorticks\endcsname
+ \expandafter\let\expandafter\ifpgfplots@minorgrids\csname ifpgfplots@#1minorgrids\endcsname
+ % these lists need to be global such that I can fill them inside
+ % of \foreach statements. And, yes: I have also added a TeX group
+ % on my own (but that's not the problem).
+ \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@major
+ %\global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@major@tickindices
+ \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@minor
+ %
+ \pgfplots@prepare@tick@coordlists@for@handletolerance#1%
+ %
+ \edef\pgfplots@loc@TMPa{#2}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \ifpgfplots@minorticks
+ \pgfplots@needsminorlooptrue
+ \else
+ \ifpgfplots@minorgrids
+ \pgfplots@needsminorlooptrue
+ \else
+ \pgfplots@needsminorloopfalse
+ \fi
+ \fi
+ \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@minor@tick@list
+ \ifx\pgfplots@minor@tick@list\pgfutil@empty
+ \else
+ \pgfplots@needsminorloopfalse
+ \fi
+ %
+ \ifpgfplots@needsminorloop
+ \ifpgfplots@islinear
+ \pgfkeysgetvalue{/pgfplots/minor #1 tick num}\pgfplots@minor@tick@num
+ \begingroup
+ \c@pgf@counta=\pgfplots@minor@tick@num\relax
+ \advance\c@pgf@counta by1\relax
+ \pgfplots@tmpa=\csname pgfplots@tick@distance@#1\endcsname pt %
+ \divide\pgfplots@tmpa by\c@pgf@counta
+ \edef\pgfmathresult{\pgf@sys@tonumber{\pgfplots@tmpa}}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \let\pgfplots@minor@tick@dist=\pgfmathresult
+ \else
+ \def\pgfplots@minor@tick@num{9}%
+ \fi
+ \fi
+ %
+ % Prepare the [xy]tick[min|max] key processing:
+ \let\pgfplots@checktickminmax=\pgfutil@empty
+ \expandafter\ifx\csname pgfplots@#1tickmin\endcsname\pgfutil@empty
+ \else
+ \expandafter\def\expandafter\pgfplots@checktickminmax\expandafter{%
+ \pgfplots@checktickminmax
+ \pgfplots@prepare@tick@coordlists@for@checktickmin#1%
+ }%
+ \fi
+ \expandafter\ifx\csname pgfplots@#1tickmax\endcsname\pgfutil@empty
+ \else
+ \expandafter\def\expandafter\pgfplots@checktickminmax\expandafter{%
+ \pgfplots@checktickminmax
+ \pgfplots@prepare@tick@coordlists@for@checktickmax#1%
+ }%
+ \fi
+ %
+ % compute the last index because it won't receive minor ticks:
+ \gdef\pgfplots@glob@TMPd{-1}%
+ \foreach \x in {#2} {%
+ \pgfplotsutil@advancestringcounter@global\pgfplots@glob@TMPd
+ }%
+ \let\c@pgfplots@ticknum@last=\pgfplots@glob@TMPd
+ %
+ \gdef\pgfplots@glob@TMPa{0}%
+ \foreach \x in {#2} {%
+ \let\pgfplots@ticknum=\pgfplots@glob@TMPa
+ %
+ \pgfplots@prepare@tick@coordlists@for@assign\pgfplots@tmpa=\x
+ \csname pgfplots@#1tick@check@tickshow\endcsname
+ \pgfplots@prepare@tick@coordlists@for@checkdatalimits#1%
+ \pgfplots@checktickminmax
+ %
+ \ifpgfplots@tickshow
+ \edef\x{{\pgfplots@ticknum}{\x}}%
+ \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@major
+ %\expandafter\pgfplotslistpushbackglobal\pgfplots@ticknum\to\pgfplots@prepared@tick@positions@major@tickindices
+ \fi
+ % X-Axis ticks bottom and top
+ \ifpgfplots@needsminorloop
+ \ifnum\pgfplots@ticknum=\c@pgfplots@ticknum@last\relax
+ \else
+ % SEE BELOW for the 'minor #1tick' feature -- it has a
+ % separate loop.
+ \foreach \pgfplots@i in {1,...,\pgfplots@minor@tick@num} {%
+ % XXX : bug 165 [minor ticks] minor tick drawn after the last xtick
+ % seems to be here. Does that harm?
+ \ifpgfplots@islinear
+ \pgfmathmultiply@{\pgfplots@i}{\pgfplots@minor@tick@dist}%
+ \else
+ % in log:
+ % log( i*10^k ) = log\pgfplots@i + k\log10 -> draw ticks for i=1..9
+ \pgfplotscoordmath{#1}{log unsigned int}{\pgfplots@i}%
+ \pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}%
+ \fi
+ \pgfplots@prepare@tick@coordlists@for@advance\pgfplots@tmpa by\pgfmathresult
+ \pgfplots@tickshowtrue
+ \pgfplots@prepare@tick@coordlists@for@checkdatalimits#1%
+ \pgfplots@checktickminmax
+ \ifpgfplots@tickshow
+ \pgfplots@prepare@tick@coordlists@for@tofixed\pgfplots@tmpa
+ \c@pgf@counta=\pgfplots@ticknum\relax
+ \advance\c@pgf@counta by\pgfplots@i\relax
+ \edef\x{{\the\c@pgf@counta}{\pgfmathresult}}%
+ \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@minor
+ \fi
+ }%
+ \fi
+ \fi
+ \pgfplotsutil@advancestringcounter\pgfplots@ticknum
+ % carry \ticknum outside of this scope:
+ \global\let\pgfplots@glob@TMPa=\pgfplots@ticknum
+ }%
+ %
+ \ifx\pgfplots@minor@tick@list\pgfutil@empty
+ \else
+ % handle the 'minor #1tick' feature:
+ \def\pgfplots@loc@TMPa{\foreach \x in }%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@minor@tick@list} {%
+ \let\pgfplots@ticknum=\pgfplots@glob@TMPa
+ %
+ \pgfplots@prepare@tick@coordlists@for@assign\pgfplots@tmpa=\x
+ \pgfplots@tickshowtrue
+ \pgfplots@prepare@tick@coordlists@for@checkdatalimits#1%
+ \pgfplots@checktickminmax
+ \ifpgfplots@tickshow
+ \edef\x{{\pgfplots@ticknum}{\x}}%
+ \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@minor
+ \fi
+ \pgfplotsutil@advancestringcounter\pgfplots@ticknum
+ % carry \ticknum outside of this scope:
+ \global\let\pgfplots@glob@TMPa=\pgfplots@ticknum
+ }%
+ \fi
+ \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
+}%
+
+% The following set of macros can be used to replace the TeX register
+% arithmetics used to speed up the computations inside of
+% \pgfplots@prepare@tick@coordlists@for by something different.
+%
+% FIXME : that is no clean programming! Perhaps a new math class
+% should be used here, and implemented during the complete tick
+% preparation!?
+%
+% Keep in mind that these tick positions are in "transformed
+% range", i.e. they are expected to be in the range -16000...16000. At
+% the time of this modification, only the smithchart lib needs special
+% handling here... does this justify a re-design?
+\def\pgfplots@prepare@tick@coordlists@for@assign#1=#2{%
+ #1=#2pt
+}%
+\def\pgfplots@prepare@tick@coordlists@for@advance#1by#2{%
+ \advance#1 by#2 pt %
+}%
+\def\pgfplots@prepare@tick@coordlists@for@tofixed#1{%
+ \edef\pgfmathresult{\pgf@sys@tonumber{#1}}%
+}%
+\def\pgfplots@prepare@tick@coordlists@for@handletolerance#1{%
+ \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
+}%
+\def\pgfplots@prepare@tick@coordlists@for@checktickmin#1{%
+ \ifdim\pgfplots@tmpa<\csname pgfplots@#1tickmin\endcsname pt
+ \pgfplots@tickshowfalse
+ \fi
+}%
+\def\pgfplots@prepare@tick@coordlists@for@checktickmax#1{%
+ \ifdim\pgfplots@tmpa>\csname pgfplots@#1tickmax\endcsname pt
+ \pgfplots@tickshowfalse
+ \fi
+}%
+\def\pgfplots@prepare@tick@coordlists@for@checkdatalimits#1{%
+ \ifdim\pgfplots@tmpa<\csname pgfplots@#1min@reg\endcsname
+ \pgfplots@tickshowfalse
+ \else
+ \ifdim\pgfplots@tmpa>\csname pgfplots@#1max@reg\endcsname
+ \pgfplots@tickshowfalse
+ \fi
+ \fi
+}%
+
+% Unpacks entries of the \pgfplots@prepared@tick@positions@* lists.
+%
+% Defines \pgfplots@tick to be the actual tick position and
+% \pgfplots@ticknum to be its index.
+%
+% Usage:
+% \expandafter\pgfplots@prepared@tick@pos@unpack\entry
+\def\pgfplots@prepared@tick@pos@unpack#1#2{%
+ \def\pgfplots@tick{#2}%
+ \def\pgfplots@ticknum{#1}%
+}
+
+% Draws grid lines at the a-positions of the currently set oriented
+% surface.
+%
+% Tick positions are taken out of the already precomputed list
+% \pgfplots@prepared@tick@positions@major@...
+%
+% See \pgfplots@drawticklines@onorientedsurf@ for a description of the
+% oriented surface.
+%
+% #1 : the verbatim axis name (either 'x' or 'y')
+% #2 : the index of the axis (either 0 or 1)
+\def\pgfplots@drawgridlines@onorientedsurf{%
+ \expandafter\pgfplots@drawgridlines@onorientedsurf@\pgfplotspointonorientedsurfaceA
+}%
+\def\pgfplots@drawgridlines@onorientedsurf@#1{%
+ \pgfplots@if{pgfplots@shownothingof@\pgfplotspointonorientedsurfaceB}{%
+ \relax
+ }{%
+ \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
+ % I support only ONE layer for both, minor and major
+ % grid lines -- no distinction! I am lazy... FIXME
+ \pgfplotsgetlayerforstyle{%
+ every axis grid,%
+ every minor grid,%
+ every axis #1 grid,%
+ every major grid,%
+ every minor #1 grid,%
+ every major #1 grid%
+ }%
+ \pgfplotsonlayer{\pgfplotsretval}{#1 grid style}%
+ \scope
+ \pgfplots@drawgridlines@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{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curgridpos
+ \pgfplots@drawgridlines@onorientedsurf@fromto\pgfplots@tick
+ }%
+ \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{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curgridpos
+ \pgfplots@drawgridlines@onorientedsurf@fromto\pgfplots@tick
+ }%
+ \endpgfextra;
+ }{}%
+ %
+ \endscope
+ \endpgfplotsonlayer
+ \fi
+ }{}%
+ \endgroup
+ }%
+}
+
+% Should draw a single grid line on the actual oriented surface.
+% #1 the value of the grid line.
+%
+% PRECONDITION
+% \pgfplots@ticknum contains the index of the current tick.
+\def\pgfplots@drawgridlines@onorientedsurf@fromto#1{%
+ \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}%
+}%
+
+% Implements 'axis x line shift' and its friends.
+%
+% It is called by grid line drawing instructions, tick lines, and tick
+% labels and installs a common shift. The purpose is to shift the
+% _entire_ axis along the outer normal.
+%
+% The operation is supposed to be used when an oriented surf is
+% installed.
+%
+% #1 used to determine the axis for which the outer normal is to be
+% determined. #1 is the 'a' value of the current oriented surf, i.e.
+% one of 0, 1, 2, or v.
+%
+% #2 same as '#1', but this here determines the 'b' value of the
+% current oriented surf.
+%
+% exactly one of '#1' or '#2' must be 'v' such that a unique line can
+% be identified.
+\def\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf#1#2{%
+ \if v#1%
+ \let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceA%
+ \if v#2%
+ \pgfplots@error{Exactly one of '#1' or '#2' must be 'v', not both}%
+ \fi
+ \else
+ \if v#2%
+ \let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceB%
+ \else
+ \pgfplots@error{One of '#1' or '#2' must be 'v'}%
+ \fi
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/axis \pgfplots@loc@TMPa\space line shift}\pgfplots@loc@TMPb
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \else
+ % in this case, we KNOW that is is
+ % (a) parsed and
+ % (b) nonzero and
+ % (c) a dimension WITHOUT unit
+ % See \pgfplots@init@axis@shift
+ \ifpgfplots@separate@axis@lines
+ \else
+ \pgfplots@error{Internal error encountered: separate axis lines=false but axis shift found}%
+ \fi
+ \pgftransformshift{%
+ \expandafter\pgfqpointscale\expandafter{\pgfplots@loc@TMPb}{%
+ \begingroup
+ \pgf@process{%
+ \pgfplotspointonorientedsurfaceabtolinespec{#1}{#2}%
+ \expandafter\pgfplotspointouternormalvectorofaxis\expandafter{\pgfplotsretval}%
+ }%
+ \endgroup
+ }%
+ }%
+ \fi
+}%
+\let\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf@orig=\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf
+
+% Draws ticks on the currently active "oriented surface".
+%
+% The oriented surface is two dimensional and has been initialised
+% with \pgfplotspointonorientedsurfaceabsetupfor*** somehow.
+%
+% The idea is now the following:
+% - the tick positions change along the FIRST coordinate of this
+% surface:
+%
+% x ---- x ---- x ---- x
+% --> FIRST -->
+%
+% - the tick lines are drawn along the SECOND coordinate of this
+% surface:
+%
+% | ---- | ---- | ---- | | SECOND
+% | | | | v
+%
+% for example,
+% \pgfplotspointonorientedsurfaceab@setupfor@xyZ{1}
+% \pgfplots@drawticklines@onorientedsurf
+% will draw ticks at x-positions designated by \pgfplots@xtick. The
+% small tick lines will be drawn along the y axis. For each processed
+% point, the z coordinate will be fixed to '1'.
+%
+% Another example:
+% \pgfplotspointonorientedsurfaceab@setupfor@yxZ{-1}
+% \pgfplots@drawticklines@onorientedsurf
+% will draw ticks at y-positions designated by \pgfplots@ytick. The
+% small tick lines will be drawn along the x axis. For each processed
+% point, the z coordinate will be fixed to '-1'.
+%
+% Tick positions are taken out of the already precomputed list
+% \pgfplots@prepared@tick@positions@major@...
+\def\pgfplots@drawticklines@onorientedsurf{%
+ \expandafter\pgfplots@drawticklines@onorientedsurf@\pgfplotspointonorientedsurfaceA
+}%
+
+\def\pgfplots@drawticklines@INSTALLCLIP@onorientedsurf#1{%
+ \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf{#1}%
+}%
+\def\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf#1{%
+ \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf{#1}%
+}%
+% Avoids tick lines which are too thick by introducing a clipping
+% region. Tick lines (and grid lines) won't extend to the left or
+% right of axis #1.
+\def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1{%
+ \ifpgfplots@enable@tick@line@clipping
+ % this is LEGACY SUPPORT only. I did not want to change
+ % existing bounding boxes.
+ % Starting with 'compat=1.11', this is OFF.
+ \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf@{#1}%
+ \fi
+}
+\def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf@#1{%
+ \pgfinterruptboundingbox%
+ \begingroup
+ % the case ||e_b|| == 0 should never happen here! Should be
+ % caught before entering this routine.
+ \let\pgfplots@loc@LENGTH=\pgfmathresult
+ \expandafter\let\expandafter\pgfplots@loc@MIN\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname
+ \expandafter\let\expandafter\pgfplots@loc@MAX\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname
+ \pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MIN}{-5cm}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MIN}{-5cm}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MAX}{5cm}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MAX}{5cm}}%
+ \pgfusepath{clip}%
+ \endgroup
+ \endpgfinterruptboundingbox%
+}%
+
+\def\pgfplots@drawticklines@onorientedsurf@#1{%
+ \pgfplots@if{pgfplots@shownothingof@\pgfplotspointonorientedsurfaceB}{%
+ \relax
+ }{%
+ \begingroup
+ % FIXME : the case of centered axis lines is missing here.
+ % 0 = lower limit,
+ % 1 = upper limit
+ % 2 = centered...
+ % Currently, "0" is also used for centered axis lines.
+ \if 2\csname pgfplots@\pgfplotspointonorientedsurfaceA axislinesnum\endcsname
+ % centered axis lines need no complicated visibility
+ % checks. They need tick lines in *any* case.
+ % So, enabled them here!
+ \def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{1}%
+ %
+ % UPPEROK is unnecessary in this context - for centered
+ % axis lines, it will be disabled anyway because the
+ % styles like 'axis x line*' set \pgfplots@xticknum to
+ % center - and that means that no tick lines will be drawn
+ % (see below).
+ \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}%
+ \else
+ \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}%
+ }%
+ \fi
+ \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
+ \fi
+ \ifcase\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname\relax
+ % both
+ \or
+ % lower
+ \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}%
+ \or
+ % 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
+ \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
+ %
+ % There is only ONE layer for both, minor and major
+ % tick lines -- no distinction!
+ \pgfplotsgetlayerforstyle{%
+ every tick,%
+ every minor tick,%
+ every #1 tick,%
+ every major tick,%
+ every minor #1 tick,%
+ every major #1 tick%
+ }%
+ \pgfplotsonlayer{\pgfplotsretval}{#1tick style}%
+ \scope
+ \pgfplots@drawticklines@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
+ \let\pgfplots@subtickwidth@=\pgfmathresult
+ \let\pgfplots@subtickwidth=\pgfmathresult
+ \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@subtickwidth@}%
+ \if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1%
+ \begingroup
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v0%
+ \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos
+ \let\pgfplots@curtickpos=\pgfplots@tick
+ \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}%
+ \pgfplots@drawticklines@for@placecomputedtick@LOWER
+ }%
+ \endgroup
+ \fi
+ %
+ \if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1%
+ \begingroup
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v1%
+ \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos
+ \let\pgfplots@curtickpos=\pgfplots@tick
+ \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}%
+ \pgfplots@drawticklines@for@placecomputedtick@UPPER
+ }%
+ \endgroup
+ \fi
+ \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
+ \let\pgfplots@tickwidth@=\pgfmathresult
+ \let\pgfplots@tickwidth=\pgfmathresult
+ \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@tickwidth@}%
+ \if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1%
+ \begingroup
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v0%
+ \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos
+ \let\pgfplots@curtickpos=\pgfplots@tick
+ \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}%
+ \pgfplots@drawticklines@for@placecomputedtick@LOWER
+ }%
+ \endgroup
+ \fi
+ %
+ \if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1%
+ \begingroup
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v1%
+ \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos
+ \let\pgfplots@curtickpos=\pgfplots@tick
+ \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}%
+ \pgfplots@drawticklines@for@placecomputedtick@UPPER
+ }%
+ \endgroup
+ \fi
+ \endpgfextra;
+ }{}%
+ %
+ \endscope
+ \endpgfplotsonlayer
+ \endgroup
+ }%
+}
+
+% 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.
+\def\pgfplots@drawticklabels@onorientedsurf{%
+ \expandafter\pgfplots@drawticklabels@onorientedsurf@\pgfplotspointonorientedsurfaceA
+}
+\def\pgfplots@drawticklabels@onorientedsurf@#1{%
+ \begingroup
+ \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
+ \pgfplots@if{pgfplots@#1majorticks}{%
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \pgfplots@init@scaled@tick@for{#1}%
+ }{\relax}%
+ \begingroup
+ \pgfplotsgetlayerforstyle{every tick label,every #1 tick label}%
+ \pgfplotsonlayer\pgfplotsretval{#1tick label style}%
+ \pgfkeysalso{/tikz/every node/.append style={/pgfplots/every tick label,/pgfplots/every #1 tick label}}%
+ \pgfplots@drawticklabels@onorientedsurf@prepareanchor#1%
+ %
+ \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%<-- backw. compat, is usually empty.
+ \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}%
+ % special handling for reversed axes.
+ \pgfmathmultiply{-1}{\pgfplots@tick@offset}%
+ \let\pgfplots@tick@offset=\pgfmathresult
+ \fi
+ \edef\pgfplots@tick@offset{-\pgfplots@tick@offset}%
+ %\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}%
+ \else
+ \if0\pgfplots@ticklabelside
+ \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname%
+ \pgfplots@tickposchoiceb%<-- backw. compat, is usually empty.
+ %\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}%
+ \edef\pgfplots@tick@offset{-\pgfplots@tick@offset}%
+ \else
+ \if1\pgfplots@ticklabelside
+ \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname%
+ \pgfplots@tickposchoicea%<-- backw. compat, is usually empty.
+ %\pgfmathadd@{\pgfplots@tick@origin}{\pgfplots@tick@offset}%
+ \else
+ % FIXME : ticklabelside == 2 is, in principle,
+ % a valid choice. It is the case handled with
+ % "if 2 == pgfplots@#1axislinesnum" above,
+ % isn't it!?
+ \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB\endcsname%
+ % FIXME : is that correct!?
+ \pgfplots@tickposchoiceb%<-- backw. compat, is usually empty.
+ %\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}%
+ %\edef\pgfplots@tick@offset{-\pgfplots@tick@offset}%
+ %
+ \if2\pgfplots@ticklabelside
+ \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.}%
+ \fi
+ \fi
+ \fi
+ \fi
+ %\let\pgfplots@tick@origin=\pgfmathresult%
+ \edef\pgfplots@tick@offset{\pgfplots@tick@offset pt}%
+ %
+ % make sure the \pgfmathlogtologten method works even for
+ % non-standard 'log basis #1':
+ \def\pgfmathlogtologten@{\pgfplotscoordmath{#1}{log to log 10}}%
+ %
+ \xdef\pgfplots@show@ticklabel@LASTTICK{}%
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf{v}{\pgfplots@ticklabelside}%
+ \pgfplotslistforeachungrouped\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos
+ \let\pgfplots@curtickpos=\pgfplots@tick
+ %\expandafter\pgfplotslistpopfront\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname\to\pgfplots@ticknum
+ \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}%
+ \pgfplots@show@ticklabel
+ {#1}{\pgfplots@curtickpos}(\pgfplots@curtickpos,\pgfplots@tick@origin+\pgfplots@tick@offset)%
+ {\pgfplots@ticknum}%
+ }%
+ \pgfplots@ticklabel@maxtickdimen@finish{#1}%
+ \endpgfplotsonlayer
+ \endgroup
+ \pgfplots@draw@tick@scale@label@for #1%
+ }%
+ {\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
+ \pgfplotspointouternormalvectorofaxis@ifdependson@v{\pgfplotsticklabelaxisspec{#1}}{%
+ \tikzset{every node/.append code={%
+ \tikz@addtransform{%
+ \pgftransformshift{%
+ \pgfplotspointouternormalvectorofticklabelaxis{#1}%
+ \pgfqpointscale{-\pgfplots@loc@TMPc}{}%
+ }%
+ }%
+ }%
+ }%
+ }{%
+ \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
+ %
+ %
+ %
+ % suppress this warning. We cannot avoid it currently.
+ \pgfkeysgetvalue{/pgfplots/warning/missing near ticklabel at/.@cmd}\pgfplots@loc@neartickllabel@at
+ \pgfkeysdef{/pgfplots/warning/missing near ticklabel at}{}%
+ %
+ \pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec
+ {#1}%
+ {\pgfplotspointouternormalvectorofticklabelaxis{#1}}%
+ %
+ \pgfkeyslet{/pgfplots/warning/missing near ticklabel at/.@cmd}\pgfplots@loc@neartickllabel@at%
+}%
+
+\newif\ifpgfplots@checkuniform@isfirst
+% Checks whether the argument to xtick or ytick is a UNIFORM tick
+% sequence.
+%
+% A uniform tick sequence is 0,...,10 and 3,4,5 and -5,-4,-2 but
+% NOT 0,2,4 or 4,10.
+%
+% Furthermore, any NON-integer tick arguments are also assumed to be
+% NOT uniform.
+%
+% INPUT:
+% #1: a tick argument (i.e. something which can be put to
+% \foreach \x in {#1})
+%
+% OUTPUT:
+% \pgfplots@isuniformticktrue
+% or
+% \pgfplots@isuniformtickfalse
+% depending on the check.
+% This variable will be set globally.
+\def\pgfplots@checkisuniformLOGtick#1{%
+ \begingroup
+ \global\pgfplots@isuniformticktrue
+ \pgfplots@checkuniform@isfirsttrue
+ \foreach \x in {#1}{%
+ \pgfmathmultiply@\x\reciproclogten
+ \let\cur=\pgfmathresult
+ % check whether
+ % \cur - last == 1 (last = \pgfplots@glob@TMPb)
+ \ifpgfplots@checkuniform@isfirst
+ \global\pgfplots@checkuniform@isfirstfalse
+ \else
+ \pgfmathsubtract@\cur\pgfplots@glob@TMPb%
+ \pgfmathapproxequalto@\pgfmathresult{1.0}%
+ \ifpgfmathcomparison
+ \else
+ \global\pgfplots@isuniformtickfalse
+ \breakforeach
+ \fi
+ \fi
+ \global\let\pgfplots@glob@TMPb=\cur
+ }%
+ \endgroup
+}
+
+% Checks whether the linear tick sequence #1 is a uniform tick.
+%
+% It also assigns pgfplots@tick@distance@#1 as the distance.
+%
+% see \pgfplots@checkisuniformLOGtick for details.
+%
+% #1: a tick sequence (expanded)
+% #2: a macro which will be filled with the tick distance. This is
+% only valid if \pgfplots@isuniformticktrue.
+\def\pgfplots@checkisuniformLINEARtick#1#2{%
+ \begingroup
+ \global\pgfplots@isuniformticktrue
+ \pgfplots@checkuniform@isfirsttrue
+ \global\let\pgfplots@glob@TMPb=\pgfutil@empty
+ \global\def\pgfplots@glob@TMPa{1}%
+ \foreach \x in {#1}{%
+ \ifx\pgfplots@glob@TMPb\pgfutil@empty
+ \else
+ \pgfmathsubtract@\x\pgfplots@glob@TMPb
+ \ifpgfplots@checkuniform@isfirst
+ % remember first distance h = x_1 - x_0
+ \global\let\pgfplots@glob@TMPa=\pgfmathresult
+ \global\pgfplots@checkuniform@isfirstfalse
+ \else
+ % check whether x_i - x_{i-1} = h
+ \pgfmathapproxequalto@\pgfmathresult\pgfplots@glob@TMPa%
+ \ifpgfmathcomparison
+ \else
+ \global\pgfplots@isuniformtickfalse
+ \breakforeach
+ \fi
+ \fi
+ \fi
+ \global\let\pgfplots@glob@TMPb=\x%
+ }%
+ \endgroup
+ \let#2=\pgfplots@glob@TMPa
+}
+
+% helper method which computes log10*\x foreach \x in {#1}.
+% The result will be \xdef'ed into #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} {%
+ \pgfplotscoordmath{#3}{log to display log}{\pgfplots@loc@TMPb}%
+ \pgfplotscoordmath{#3}{tofixed}{\pgfmathresult}%
+ \ifx#2\pgfutil@empty
+ \xdef#2{\pgfmathresult}%
+ \else
+ \xdef#2{#2,\pgfmathresult}%
+ \fi
+ }%
+}
+
+% This is part of \pgfplots@assign@default@tick@foraxis and relies on
+% its temporary variables.
+%
+% INPUT:
+% \MIN : the lower axis limit of #1 (a TeX register, in transformed range)
+% \MAX : same with upper axis limit of #1
+% \desirednumticks: the number of ticks to use
+% OUTPUT:
+% \H : will contain the (transformed) distance between adjacent ticks
+% \aftergroup\pgfplots@isuniformticktrue set if it applies
+%
+%
+\def\pgfplots@ticks@compute@tick@distance#1{%
+ % compute step size 'H':
+ \H=\MAX
+ \advance\H by-\MIN
+ \ifdim\H<0pt \H=-1\H \fi
+%\message{Axis limit #1: [\the\MIN:\the\MAX], diff = \the\H.^^J}%
+ \c@pgf@counta=\desirednumticks
+ \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^^J}%
+ %
+ % SEARCH for the NEXT FEASABLE H.
+ \edef\Hmacro{\pgf@sys@tonumber\H}%
+ \ifpgfplots@cur@is@linear
+ % CASE LINEAR AXIS
+ \ifpgfplots@is@datascaled
+ % This here works if the scaling trafo is linear.
+ \pgfplotscoordmath{#1}{datascaletrafo noshift inverse}{\Hmacro}%
+ \let\Hmacro=\pgfmathresult
+ \else
+ \pgfmathfloatparsenumber{\Hmacro}%
+ \let\Hmacro=\pgfmathresult
+ \fi
+%\message{Got T^{-1}(H#1) = \Hmacro^^J}%
+ %
+ \pgfplots@assign@default@tick@foraxis@normalizetickdist#1\Hmacro
+ \let\Hmacro=\pgfmathresult
+ %
+ % Ok, we are ready.
+ % Now, convert everything into the fixed point data
+ % range:
+ \ifpgfplots@is@datascaled
+ \pgfplotscoordmath{#1}{datascaletrafo noshift}{\Hmacro}%
+ \H=\pgfmathresult pt
+ \else
+ \pgfmathfloattofixed\Hmacro
+ \H=\pgfmathresult pt
+ \fi
+ %
+%\message{snapped-to-nicest = \Hmacro^^J}%
+ \aftergroup\pgfplots@isuniformticktrue
+ \else
+ % CASE LOG AXIS
+ %
+ % search for the "best" H= j* log(10), j an integer.
+ %
+ % And prefer j=1 if that is possible (otherwise minor
+ % ticks are not useful).
+ \pgfmath@basic@multiply@{\Hmacro}{\pgfplots@loc@log@from@display@log@scale}%
+ \let\Hmacrobaseten=\pgfmathresult
+ \expandafter\H\pgfmathresult pt
+%\message{ [ H / log(10) = \pgfmathresult ]}%
+ \ifdim\H<2pt
+ \H=1pt
+ \else
+ \ifnum\H<1pt
+ \H=1pt
+ \else
+ \expandafter\pgfmathfloor\expandafter{\pgfmathresult}%
+ \expandafter\H\pgfmathresult pt
+ \fi
+ \fi
+ \ifdim\H=1pt
+ \aftergroup\pgfplots@isuniformticktrue
+ \pgfplots@isuniformticktrue
+ \else
+ \aftergroup\pgfplots@isuniformtickfalse
+ \pgfplots@isuniformtickfalse
+ \fi
+%\message{final H=\pgf@sys@tonumber{\H} * log(10)}%
+ \H=\pgfplots@loc@log@to@display@log@scale\H
+ \fi
+ %
+}
+
+% This is part of \pgfplots@assign@default@tick@foraxis
+%
+% It overwrites the internal macros of
+% \pgfplots@assign@default@tick@foraxis
+\def\pgfplots@assign@default@tick@foraxis@autoadjust@result#1{%
+ \pgfplots@if{pgfplots@#1islinear}{%
+ \begingroup
+ \def\pgfplots@tick@returnval@ready{1}%
+ \pgfutil@ifundefined{pgfplots@assign@default@tick@foraxis@recurselevel}{%
+ \def\pgfplots@assign@default@tick@foraxis@recurselevel{1}%
+ }{%
+ \pgfplotsutil@advancestringcounter\pgfplots@assign@default@tick@foraxis@recurselevel
+ }%
+ \ifnum\pgfplots@assign@default@tick@foraxis@recurselevel<15
+ \c@pgf@counta=\axisdefaulttryminticks\relax
+ \advance\c@pgf@counta by1
+ \edef\axisdefaulttryminticks{\the\c@pgf@counta}%
+%\message{**TOO FEW TICK LABELS FOR #1. RECURSION with try min ticks=\axisdefaulttryminticks.**^^J}%
+ % 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
+ \else
+ \pgfplotswarning{tick computation failed}{#1}{\axisdefaulttryminticks}\pgfeov%
+ \def\pgfplots@tick@returnval@ready{0}%
+ \fi
+ \pgfmath@smuggleone\pgfplots@tick@returnval@ready
+ \endgroup
+ }{%
+ % Case logarithmic axes and too few ticks.
+ \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.
+ \MIN\csname pgfplots@#1min\endcsname pt
+ \H=\MAX
+ \advance\H by-\MIN
+ \ifdim\H<0pt \H=-1\H \fi
+ \H=\pgfplots@loc@log@from@display@log@scale \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
+ \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}%
+ \pgfplots@assign@default@tick@foraxis@normalizetickdist#1\pgfmathresult
+ %
+ \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=\pgfplots@loc@log@from@display@log@scale \MIN
+ \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=\pgfplots@loc@log@to@display@log@scale\MIN\relax
+ \H=\pgfplots@loc@log@to@display@log@scale\H\relax
+ \MINH=\MIN\relax
+ \advance\MINH by\H\relax
+ }%
+}%
+
+% The key 'xtick distance' can have any value. This routine avoids
+% 'dimension too large' programmatically
+\def\pgfplots@assign@default@tick@foraxis@cap#1#2{%
+ \ifpgfplots@is@datascaled
+ \pgfplotscoordmath{#1}{datascaletrafo noshift inverse}{16000}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscoordmath{#1}{min}{\pgfplots@loc@TMPb}{#2}%
+ \edef\pgfplots@loc@TMPc{#2}%
+ \ifx\pgfplots@loc@TMPc\pgfmathresult
+ \def\pgfplotsretval{0}%
+ \else
+ \def\pgfplotsretval{1}%
+ \fi
+ \else
+ \pgfplotscoordmath{#1}{parsenumber}{16000}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscoordmath{#1}{parsenumber}{#2}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult
+ \pgfplotscoordmath{#1}{min}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}%
+ %
+ \ifx\pgfplots@loc@TMPc\pgfmathresult
+ \def\pgfplotsretval{0}%
+ \else
+ \def\pgfplotsretval{1}%
+ \fi
+ \fi
+ %
+ \ifx1\pgfplotsretval
+ \pgfplotswarning{dimension too large in ticks}{#1}{#2}{\pgfmathresult}\pgfeov%
+ \fi
+}
+
+% This macro is NECESSARILY part of
+% \pgfplots@assign@default@tick@foraxis:
+%
+% OUTPUT:
+% \csname pgfplots@#1tick\endcsname
+% \csname pgfplots@tick@distance@#1\endcsname
+% FIXME : some \aftergroup trickery...
+\def\pgfplots@assign@default@tick@foraxis@compute#1{%
+ % Ok, we have either log or linear axis and need default
+ % ticks MIN,MIN+H,...,MAX.
+ \let\MINH=\pgf@xa
+ \let\H=\pgf@xb
+ \let\MAX=\pgf@ya
+ \let\MIN=\pgf@yb
+ %
+ \MAX=\csname pgfplots@#1max\endcsname pt %
+ \advance\MAX by0.001pt % avoid round errors
+ %\expandafter\MIN\the\c@pgf@counta pt
+ \MIN=\csname pgfplots@#1min\endcsname pt %
+ %
+ \pgfkeysgetvalue{/pgfplots/#1tick distance}\Hmacro
+ \ifx\Hmacro\pgfutil@empty
+ \pgfplots@ticks@compute@tick@distance#1%
+ \def\b@pgfplots@ticks@computed@tick@distance@is@final{0}%
+ \else
+ % ah - a user argument. OK, prefer that one over the default:
+ \pgfplotscoordmath{default}{parse}{abs(\Hmacro)}%
+ \let\Hmacro=\pgfmathresult
+ \pgfplots@assign@default@tick@foraxis@cap{#1}{\Hmacro}%
+ \let\Hmacro=\pgfmathresult
+ \ifpgfplots@cur@is@linear
+ \ifpgfplots@is@datascaled
+ \pgfplotscoordmath{#1}{datascaletrafo noshift}{\pgfmathresult}%
+ \else
+ \pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}%
+ \fi
+ \H=\pgfmathresult pt
+ \pgfplots@isuniformticktrue
+ \aftergroup\pgfplots@isuniformticktrue
+ \else
+ \pgfplotscoordmath{#1}{log}{\pgfmathresult}%
+ \let\Hmacro=\pgfmathresult
+ \H=\pgfmathresult pt
+ %
+ % we don't know it. check it.
+ \pgfplots@isuniformtickfalse
+ \aftergroup\pgfplots@isuniformtickfalse
+ \fi
+ \def\b@pgfplots@ticks@computed@tick@distance@is@final{1}%
+ \fi
+%\message{Got H=\the\H\space(\Hmacro)^^J}%
+ %
+ % OK, now compute MIN/MAX :
+ \ifpgfplots@cur@is@linear
+ % The following code is carried out in floating point
+ % arithmetics because it requires large data ranges.
+ %
+ % I want to compute MIN@new := I*H where I is chosen
+ % such that MIN = I*H + rest with rest < H.
+ % The problem is the possibly large range of MIN. I
+ % can't work completely in the transformed datarange,
+ % so numbers get too large.
+ %
+ % So, compute I := int( MIN / H ) (integer truncation)
+ % in float arithmetics and then MIN@new := I*H
+ \pgfmathfloatdivide@{\csname pgfplots@#1min@unscaled@as@float\endcsname}{\Hmacro}%
+ \pgfmathfloatint@{\pgfmathresult}%
+ \pgfmathfloatmultiply@{\pgfmathresult}{\Hmacro}%
+ \let\MIN@new=\pgfmathresult
+ %
+ % Now, convert everything into the fixed point data
+ % range:
+ \ifpgfplots@is@datascaled
+ \pgfplotscoordmath{#1}{datascaletrafo}{\MIN@new}%
+ \MIN=\pgfmathresult pt
+ \else
+ \pgfmathfloattofixed\MIN@new
+ \MIN=\pgfmathresult pt
+ \fi
+ %
+ % And, since we have used finite precision, I is most
+ % 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\relax
+ \else
+ % Now, we want to activate the Tick set
+ % {lowest, lowest+H, ..., highest}
+ %
+ % Where
+ % lowest = I * log(10) + rest, |rest| < log(10).
+ % this is conceptionally different from the approach for
+ % linear axes, because H = j*log(10).
+ %
+ % remember the original xmin in MINH:
+ \MINH=\MIN
+ %
+ % and compute I and I*log(10) here:
+ \MIN=\pgfplots@loc@log@from@display@log@scale \MIN
+ \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
+ \MIN=\pgfplots@loc@log@to@display@log@scale pt
+ \multiply\MIN by\c@pgf@counta
+ \ifpgfplots@isuniformtick
+ \else
+ % This here is a special case to move the first tick
+ % near the lower axis limit.
+ %
+ % "Near" means either directly above or directly below ymin.
+ %
+ % My application example is as follows:
+ % Let H = 2*log(10).
+ % Furthermore, ymin = 3e-6, ymax= 8e-2. That means we can choose either
+ % 10^{-5}, 10^{-3}, 10^{-1}
+ % or
+ % 10^{-4}, 10^{-2}
+ % as ticks. Well, I prefer the first one.
+ %
+ % HEURISTICS: start as near to ymin as possible!
+ %
+ % We check here if we can come nearer to ymin if we
+ % shift the current tick by log(10):
+ % if( ymin - I * log(10) < 0.5*H -> use I+1, that means add log(10).
+ %
+ % that's equivalent to
+ % 2*(ymin - I * log(10)) - H < 0.
+ \advance\MINH by-\MIN
+ \multiply\MINH by2
+ \advance\MINH by-\H
+ %
+ \ifdim\MINH<0pt
+ \advance\MIN \pgfplots@loc@log@to@display@log@scale pt
+ \fi
+ \fi
+ \fi
+ \MINH=\MIN
+ \advance\MINH by\H
+ % Ok, now it can happen that only ONE tick label is placed in
+ % this range.
+ % That's useless, so check for it.
+ %
+ % That's the case if
+ % MIN < ORIGMIN && MAX < MIN+2 H
+ % MIN < ORIGMIN by construction (ok, MIN <= ORIGMIN by
+ % construction, but I don't care about this case).
+ % So: check only the second condition.
+%\message{Got MIN=\pgf@sys@tonumber\MIN; H=\pgf@sys@tonumber\H; MAX=\pgf@sys@tonumber\MAX.^^J}%
+ \def\pgfplots@tick@returnval@ready{0}%
+ %
+ \pgfplots@tmpa=\MINH
+ \advance\pgfplots@tmpa by\H
+ \ifdim\MAX<\pgfplots@tmpa
+ \if1\b@pgfplots@ticks@computed@tick@distance@is@final
+ % OK, we cannot auto adjust tick labels -- if if there are
+ % too few of them.
+ \else
+ \pgfplots@assign@default@tick@foraxis@autoadjust@result#1%
+ \fi
+ \fi
+ %
+ % assert that we have at least a minimal tick distance.
+ % FIXME :this minimum might actually be too small...
+ \ifdim\MINH=\MIN
+ \pgfplotsthrow{dimension too small in ticks}{#1}\pgfeov%
+ %
+ % make sure that the compilation succeeds:
+ \H=1pt %
+ \advance\MINH by\H
+ \fi
+ %
+ \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
+%\message{final H=\the\H; returning \pgfplots@glob@TMPa.}%
+ \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa
+ \expandafter\let\csname pgfplots@tick@distance@#1\endcsname=\pgfplots@glob@TMPb
+}%
+
+% Computes tick positions using the current axis limits.
+%
+% Parameters:
+% /pgfplots/max space between ticks
+% Determines the maximum space which is not filled by at least one
+% tick label (approximate, there is some rounding internally)
+% /pgfplots/try min ticks
+% see manual
+%
+% Idea:
+% We want ticks at each
+% { i*H, i in \Z }.
+% Of course, there shouldn't be TOO MUCH ticks.
+%
+% Our heuristics is to set
+% desirednumticks = round(ACTUAL WIDTH / (max space between ticks) )
+% and generate H = (axis range) / (desirednumticks).
+%
+% Since not all step sizes H look well, restrict H to a set of allowed
+% step sizes such as
+% { 1, 1/2, 1/5, 1/10 },
+% or, to be more precise:
+% { 1*10^e, 2*10^e, 5*10^e }
+% -> round to the nearest matching number!
+% This yields H (for example as 2*10^e). Then, compute i*H, i \in \Z
+%
+% The data scaling transformation T(x) makes things more complicated.
+% Now, T(x) = q * x - p and we need to check for problems with large
+% numbers:
+% - q* H = ( T(Max) - T(Min) ) / desirednumticks = q * (Max - Min) / desirednumticks.
+% - Using floating point arithmetics, (Max-Min)/desirednumticks (unscaled!)
+% is analysed to restrict H to {1*10^e, 2*10^e, 5*10^e}.
+% - So, we get q * H (we can't use the 'p' shift of the affine trafo here).
+% - The next problem is to compute { I*H, I in \Z } because
+% I = trunc( Min / H ) = trunc( ( T(Min) + p ) / (q*H) ).
+% This can be seen by Min = I*H + rest and thus T(Min) = I*q*H + q*rest -p.
+% The Problem: (T(min)+p ) / (q*H) can be TOO BIG for pgfmath.
+% -> for the data scaling case, I will use floating point
+% arithmetics to compute that last step.
+% I will acquire \pgfplots@[xy]min@unscaled@as@float here.
+%
+%
+%
+%
+%
+% For log-plots,
+% H in { j*log(10), j=1,2,3,... }
+% where the usual case should be j = 1.
+%
+% Then, the resulting tick is
+% TICK={MIN,MIN+H,...,MAX}
+% where
+% MIN = I*H
+% is chosen such that
+% axis minimum limit = I*H + rest; |rest| < H.
+%
+% Again, log plots follow a slightly different approach: here,
+% MIN = I * log(10)
+% is chosen such that
+% axis minimum limit = I*log(10) + rest; |rest| < log(10)
+% while H = j*log(10), j>=1.
+%
+%
+% PRECONDITION:
+% - limits are correct
+% - axis width/height is set correctly
+%
+% POSTCONDITION:
+% - Tick for axis #1 is assigned
+% - \ifpgfplots@determinedefaultvalues@needs@check@uniformtick is set
+%
+% REMARKS:
+% - this algorithms works also if the data range has been transformed
+% with a LINEAR transformation.
+% ATTENTION: as of 2008-05-15, the scaling trafo is AFFINE LINEAR.
+% That means we have to eliminate the 'affine' shifting before the
+% algorithms works correctly.
+\def\pgfplots@assign@default@tick@foraxis#1{%
+ \begingroup
+ % Shortcut-names:
+ \expandafter\let\expandafter\ifpgfplots@is@datascaled\csname ifpgfplots@apply@datatrafo@#1\endcsname
+ % Attention here: use UNSHIFTET scalings, see remark above
+ \expandafter\let\expandafter\ifpgfplots@cur@is@linear\csname ifpgfplots@#1islinear\endcsname
+ %
+ \let\desirednumticks=\c@pgf@countd
+ \let\Wr=\pgf@xc
+ \Wr=\csname pgfplotspoint#1axislength\endcsname\relax
+ % r = max place without ticks in pt -> choose desirednumticks >= W/r
+ \divide\Wr by\axisdefaulttickwidth\relax
+ \afterassignment\pgfplots@gobble@until@relax
+ \desirednumticks=\the\Wr\relax
+ \advance\desirednumticks by1
+ \ifpgfplots@cur@is@linear
+ \ifnum\axisdefaulttryminticks>\desirednumticks\relax
+ \desirednumticks=\axisdefaulttryminticks\relax
+ \fi
+ \else
+ \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{#1}%
+ \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa
+ \fi
+ \fi
+ \ifpgfplots@cur@is@linear
+ \else
+ \pgfplotscoordmath{#1}{parsenumber}{1}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{#1}{log from display log}{\pgfplots@loc@TMPa}%
+ \pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@loc@log@from@display@log@scale=\pgfmathresult
+ %
+ \pgfplotscoordmath{#1}{log to display log}{\pgfplots@loc@TMPa}%
+ \pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@loc@log@to@display@log@scale=\pgfmathresult
+ \fi
+ %
+ \expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfutil@empty
+ %
+ % OK, automatically compute ticks:
+ \pgfplots@assign@default@tick@foraxis@compute#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
+ \ifpgfplots@isuniformtick
+ \aftergroup\pgfplots@determinedefaultvalues@needs@check@uniformtickfalse
+ \else
+ % in this case, we better check...
+ \aftergroup\pgfplots@determinedefaultvalues@needs@check@uniformticktrue
+ \fi
+ \else
+ \expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfplots@#1tick\endcsname
+ \gdef\pgfplots@glob@TMPb{}% will be computed later, in 'check uniform tick'
+ \aftergroup\pgfplots@determinedefaultvalues@needs@check@uniformticktrue
+ \fi
+ \endgroup
+ \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa
+ \expandafter\let\csname pgfplots@tick@distance@#1\endcsname=\pgfplots@glob@TMPb
+%\message{pgfplots.sty: #1tick set to \csname pgfplots@#1tick\endcsname [#1min=\csname pgfplots@#1min\endcsname, #1max=\csname pgfplots@#1max\endcsname].}%
+}
+
+% Takes the distance between adjacent ticks as floating point number
+% and returns a normalized tick distance.
+%
+%
+% The idea is to get "nice" (human readable) distances instead of
+% strange fractions or real numbers.
+%
+% The result will be assigned to \pgfmathresult (in float).
+%
+% #1 the axis (x or y or z)
+% #2 the unnormalized tick distance computed so far
+%
+% Example:
+% \pgfmathfloatparsenumber{x}{1234}
+% \pgfplots@assign@default@tick@foraxis@normalizetickdist{x}{\pgfmathresult}
+% \pgfmathfloatotfixed\pgfmathresult
+% -->
+%
+% \pgfmathresult={1200}
+% or something like that.
+\def\pgfplots@assign@default@tick@foraxis@normalizetickdist#1#2{%
+ \begingroup
+ \let\H=\pgf@xb
+ \expandafter\pgfmathfloat@decompose#2\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E
+ % modify the mantisse:
+ \ifdim\H<2pt
+ \ifdim\H<1.5pt
+ \H=1.0pt
+ \else
+ \H=2.0pt
+ \fi
+ \else
+ \ifdim\H<4.9999pt
+ \ifdim\H<3.5pt
+ \H=2.0pt\relax
+ \else
+ \H=5.0pt\relax
+ \fi
+ \else
+ \ifdim\H<7.5pt
+ \H=5.0pt\relax
+ \else
+ \H=1.0pt\relax
+ \advance\pgfmathfloat@a@E by1
+ \fi
+ \fi
+ \fi
+ \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgf@sys@tonumber{\H}}{\the\pgfmathfloat@a@E}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% Helper method for
+% \pgfplots@apply@data@scale@trafo@to@options@for
+% #1: the ticks
+% #2: the trafo routine (not necessarily a single macro, but should
+% take one arg)
+% #3: the output macro name
+\long\def\pgfplots@apply@data@scale@trafo@to@user@ticks#1#2\to#3{%
+ \pgfplots@transform@csv@list{#1}\to{#3}\with{%
+ \pgfplotscoordmath{float}{parse}{\pgfmathresult}%
+ %\pgfmathfloatparsenumber{\pgfmathresult}%
+ #2{\pgfmathresult}%
+ }%
+}%
+
+% A helper macro which expects a \foreach-list '#1'. applies some transformation '#3' and stores results into a new csv list '#2'.
+% '#3' is some macro. Its input is '\pgfmathresult', its expected output is '\pgfmathresult'
+\long\def\pgfplots@transform@csv@list#1\to#2\with#3{%
+ \let#2=\pgfutil@empty
+ \foreach \pgfplots@loc@TMPb in {#1} {%
+ \let\pgfmathresult=\pgfplots@loc@TMPb
+ #3%
+ \ifx#2\pgfutil@empty
+ \xdef#2{\pgfmathresult}%
+ \else
+ \xdef#2{#2,\pgfmathresult}%
+ \fi
+ }%
+ %
+}%
+
+% Helper method for
+% \pgfplots@apply@data@scale@trafo@to@options@for
+% #1: the ticks ALREADY IN FLOAT FORMAT
+% #2: the trafo macro name
+% #3: the output macro name
+\long\def\pgfplots@apply@data@scale@trafo@to@user@ticks@isfloat#1#2\to#3{%
+ \let#3=\pgfutil@empty
+ \foreach \pgfplots@loc@TMPb in {#1} {%
+ #2{\pgfplots@loc@TMPb}%
+ \ifx#3\pgfutil@empty
+ \xdef#3{\pgfmathresult}%
+ \else
+ \xdef#3{#3,\pgfmathresult}%
+ \fi
+ }%
+ %
+}%
+
+% 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/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.code.tex
new file mode 100644
index 0000000000..743f4545ee
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.code.tex
@@ -0,0 +1,2203 @@
+%
+%
+%
+%--------------------------------------------
+%
+% 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/>.
+%
+%--------------------------------------------
+
+\newif\ifpgfplots@usefpu
+\pgfkeys{%
+ /pgfplots/use fpu/.is if=pgfplots@usefpu,
+ /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'!
+\def\pgfplotsqaftergroupeach#1{%
+ \pgfplotsqaftergroupeach@#1\pgfplots@EOI
+}
+\def\pgfplotsqaftergroupeach@#1{%
+ \gdef\pgfplots@TMP{#1}%
+ \ifx\pgfplots@TMP\pgfplots@EOI
+ \else
+ \aftergroup#1%
+ \expandafter\pgfplotsqaftergroupeach@
+ \fi
+}
+
+\def\pgfplotsaftergroupcollectinto#1#2\pgfplots@EOI{%
+ \def#1{#2}%
+}%
+
+% Assigns list contents #2 to a list macro #1.
+%
+% The list contents may be provided in one of two formats:
+% 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{%
+ \pgfplotslistnew#1{#2}%
+}%
+
+\def\pgfplots@shellescape@lua@eightseven#1{%
+ \pgfplotsutil@directlua{os.execute("\pgfplotsutil@luaescapestring{#1}")}%
+}%
+\def\pgfplots@shellescape#1{%
+ \immediate\write18{#1}%
+}%
+\pgfutil@IfUndefined{directlua}{%
+}{%
+ \pgfutil@IfUndefined{lastsavedimageresourcepages}{%
+ \pgfplots@log3{Found old luatex which supports write18 (shell-escape)}%
+ }{%
+ \pgfplots@log3{Found new luatex: initializing lua commands instead of write18 (shell-escape)}%
+ \let\pgfplots@shellescape=\pgfplots@shellescape@lua@eightseven
+ }%
+}%
+
+% Sets the boolean \ifpgfplots@is@old@list@format to true if and only
+% if the input is a list in the format '{first\\second\\}'.
+%
+%
+% Usage:
+% \pgfplots@check@backwards@compatible@list@format <argument>'\\'\pgfplots@EOI
+% you NEED to append '\\\pgfplots@EOI' at the end.
+\def\pgfplots@check@backwards@compatible@list@format#1\pgfplots@EOI{%
+ \pgfplotslist@check@backslash@list#1\pgfplotslist@EOI
+ \ifpgfplotslist@is@backslash@terminated
+ \pgfplots@is@old@list@formattrue
+ \else
+ \pgfplots@is@old@list@formatfalse
+ \fi
+}%
+
+% Issues an error message if the **LaTeX** package '#1' is not loaded
+% (An error is also raised if the document is not a LaTeX document).
+% #1: the required LaTeX package
+% #2: the feature which requires this package
+\def\pgfplots@assert@LaTeX@package@loaded#1#2{%
+ \pgfutil@IfUndefined{@ifpackageloaded}{%
+ \pgfplots@error{Sorry, #2 only works with LaTeX (it relies on the LaTeX package #1)}%
+ }{%
+ \pgfutil@IfUndefined{ver@#1.sty}% this here has been extracted from ltclass.dtx. \@ifpackageloaded is only usable in preamble.
+ {\pgfplots@error{Sorry, use need \string\usepackage{#1} in your preamble for '#2'}}%
+ {\relax}%
+ }%
+}%
+\def\pgfplots@assert@tikzinternal@exists#1{%
+ \pgfutil@IfUndefined{#1}{%
+ \pgfplots@error{Sorry, pgfplots relies on the existance of the tikz internal macro '#1'.
+ Unfortunately, this does no longer exist ... you will need to get an updated version of pgfplots to fix this problem.}%
+ \expandafter\let\csname #1\endcsname=\pgfutil@empty
+ }{}%
+}%
+
+
+% A future-version compatibility method which checks whether the
+% macro '#2' exists.
+%
+% We assume that '#2' usually contains the value of the tikz key '#1'.
+% Example:
+% /tikz/variable is usually stored into '\tikz@plot@var'.
+%
+% However, this may change in future versions.
+%
+% So, we do the following:
+% 1. check whether '#2' exists, if yet: ok.
+% 2. if not, check whether the value is stored directly into '/tikz/#1'.
+% 3. if not, check whether the value is stored directly into '/pgf/#1'.
+% 4. If everything fails, provide an error message.
+%
+% #1: a tikz key without key prefix (/tikz/ and /pgf/ will be prepended).
+% #2: a macro name WITHOUT backslash.
+% #3: the default value if everything fails.
+\def\pgfplots@gettikzinternal@keyval#1#2#3{%
+ \pgfutil@IfUndefined{#2}{%
+ \pgfkeysifdefined{/tikz/#1}{%
+ \pgfkeysgetvalue{/tikz/#1}\pgfplots@TMP
+ \expandafter\let\csname #1\endcsname=\pgfplots@TMP
+ }{%
+ \pgfkeysifdefined{/pgf/#1}{%
+ \pgfkeysgetvalue{/pgf/#1}\pgfplots@TMP
+ \expandafter\let\csname #1\endcsname=\pgfplots@TMP
+ }{%
+ \expandafter\def\csname #1\endcsname{#3}%
+ {\t@pgfplots@tokc={#3}%
+ \pgfplots@warning{Sorry, could not find value of '/tikz/#1'. Assuming '\the\t@pgfplots@tokc'.}%
+ }%
+ }%
+ }%
+ }{}%
+}%
+
+\def\pgfplots@getcurrent@plothandler#1{%
+ \pgfutil@IfUndefined{tikz@plot@handler}{%
+ \pgfplots@error{Sorry, can't get the current plot handler. It appears that tikz and pgfplots is no longer compatible!? You will need to get a newer version of pgfplots.}%
+ \let#1=\pgfplothandlerlineto
+ }{%
+ \let#1=\tikz@plot@handler
+ }%
+}
+
+
+
+% Converts an arbitrary command (without arguments) to a string in which all characters
+% have category 12.
+%
+% #1: a macro name (which takes no arguments)
+% #2: a macro name which will be assigned to '#1' converted to string.
+%
+% This uses '\meaning#1' hackery.
+\def\pgfplots@command@to@string#1#2{%
+ \expandafter\pgfplots@command@to@string@@\meaning#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}%
+}%
+\def\pgfplotscommandtostring#1#2{\pgfplots@command@to@string{#1}{#2}}%
+
+\begingroup
+\catcode`\|=0
+\catcode`\\=12
+|gdef|pgfplots@backslash@as@other{\}%
+|endgroup
+
+% As \pgfplots@command@to@string, but it works for commands accepting
+% arguments. More precisely, #2 will be a string (!) of the form
+% <argument pattern>{ <body> }
+% such that you can write
+% \def\test #2
+% into a file to restore the original macro. This IGNORES \long
+% (sorry)
+\def\pgfplots@command@with@args@to@string#1#2{%
+ \expandafter\PGFPLOTS@CS@WITH@ARGS@TO@STRING\meaning#1\EOI{#2}%
+}%
+{
+\let\CATCODE=\catcode
+\let\LONG=\long
+\CATCODE`\m=12
+\CATCODE`\a=12
+\CATCODE`\c=12
+\CATCODE`\r=12
+\CATCODE`\o=12
+\CATCODE`\:=12
+\CATCODE`\-=12
+\CATCODE`\>=12
+\LONG\gdef\PGFPLOTS@CS@WITH@ARGS@TO@STRING #1macro:#2->#3\EOI#4{\def#4{#2{#3}}}%
+}%
+
+% 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{%
+ {\toks0={#1}% this construction is necessary to handle '#' characters in '#1'
+ \xdef\pgfplotsutil@@arg@ifdefined{\the\toks0}%
+ }%
+ \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{%
+ {\toks0={#1}%
+ \xdef\pgfplotsutil@@arg@ifdefined{\the\toks0}%
+ }%
+ \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{%
+ \begingroup
+ \escapechar=-1
+ \xdef\pgfplots@glob@TMPa{\string#1}%
+ \endgroup
+ \let#2=\pgfplots@glob@TMPa
+}
+
+{
+\catcode`\%=12
+\gdef\pgfplots@PERCENT@TEXT{%}
+\catcode`\^^I=12
+\gdef\pgfplots@SPACE{ }
+\gdef\pgfplots@TAB{^^I}
+\catcode`\#=12 \gdef\pgfplots@ROUTE{#}}
+
+% Usage:
+% \pgfplots@if{pgfplots@scaled@ticks}{true-code}{false-code}
+%
+% it is to be used if the tex boolean is only known as string, not as
+% macro.
+\def\pgfplots@if#1#2#3{%
+ \csname if#1\endcsname
+ #2%
+ \else
+ #3%
+ \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}%
+ \else
+ \edef\pgfmathresult{#2}%
+ \fi
+}%
+\def\pgfplotsmathmax#1#2{%
+ \ifdim#1 pt>#2 pt
+ \edef\pgfmathresult{#1}%
+ \else
+ \edef\pgfmathresult{#2}%
+ \fi
+}%
+\def\pgfplotsmathlessthan#1#2{\ifdim#1pt<#2pt \pgfmathfloatcomparisontrue\else\pgfmathfloatcomparisonfalse\fi}
+
+% Re-define two-argument function for min and max.
+% The pgfmath engine now uses a variable number of arguments.
+\def\pgfplotsmathfloatmax#1#2{%
+ \pgfmathfloatlessthan{#1}{#2}%
+ \ifpgfmathfloatcomparison
+ \edef\pgfmathresult{#2}%
+ \else
+ \edef\pgfmathresult{#1}%
+ \fi
+}
+\def\pgfplotsmathfloatmin#1#2{%
+ \pgfmathfloatlessthan{#1}{#2}%
+ \ifpgfmathfloatcomparison
+ \edef\pgfmathresult{#1}%
+ \else
+ \edef\pgfmathresult{#2}%
+ \fi
+}
+
+% Defines \pgfmathresult to be #1 * 10^{#2}.
+%
+% #1 a macro without unit suffix.
+% #2 an integer number (may be a register)
+\def\pgfplotsmathmultiplypowten@#1#2{%
+ \begingroup
+ \pgf@xa=#1pt
+ \ifnum#2<0
+ \ifcase-#2
+ \or\divide\pgf@xa by10
+ \or\divide\pgf@xa by100
+ \or\divide\pgf@xa by1000
+ \or\divide\pgf@xa by10000
+ \or\divide\pgf@xa by100000
+ \fi
+ \else
+ \ifcase#2
+ \or\multiply\pgf@xa by10
+ \or\multiply\pgf@xa by100
+ \or\multiply\pgf@xa by1000
+ \or\multiply\pgf@xa by10000
+ \or\multiply\pgf@xa by100000
+ \fi
+ \fi
+ \edef\pgfmathresult{\pgf@sys@tonumber{\pgf@xa}}%
+ \pgfmath@smuggleone\pgfmathresult
+ \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.
+\long\def\pgfplots@foreach@to@list#1\to#2{%
+ \global\pgfplotslistnewempty\pgfplots@glob@TMPa
+ \begingroup
+ \foreach \pgfplots@i in {#1} {%
+ \expandafter\pgfplotslistpushbackglobal\pgfplots@i\to\pgfplots@glob@TMPa
+ }%
+ \endgroup
+ \pgfplotslistcopy\pgfplots@glob@TMPa\to#2\relax
+}
+
+
+% 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{%
+ \pgfkeysvalueof{#1}#2\pgfeov
+}
+
+% Usage:
+% \pgfplots@letcsname pgfplots@xtick={pgfplots@kram@x}
+% -> invokes \csname ... \endcsname for both args.
+\def\pgfplots@letcsname#1=#2{%
+ \expandafter\let\expandafter\pgfplots@loc@TMPc\csname #2\endcsname
+ \expandafter\let\csname #1\endcsname=\pgfplots@loc@TMPc
+}%
+
+% Inside of a pgfplots axis, this method (together with
+% \pgfplotsqpointxyz for 3d axes) is THE
+% point method. If you override the mapping to PGF coordinates here,
+% all other \pgfplotspoint* commands should inherit the changes as well.
+\def\pgfplotsqpointxy#1#2{%
+ \global\pgf@x=#1\pgf@xx%
+ \global\advance\pgf@x by #2\pgf@yx%
+ \global\pgf@y=#1\pgf@xy%
+ \global\advance\pgf@y by #2\pgf@yy}
+
+% Inside of a pgfplots axis, this method (together with
+% \pgfplotsqpointxy for 2d axes) is THE
+% point method. If you override the mapping to PGF coordinates here,
+% all other \pgfplotspoint* commands should inherit the changes as well.
+\def\pgfplotsqpointxyz#1#2#3{%
+ \global\pgf@x=#1\pgf@xx%
+ \global\advance\pgf@x by #2\pgf@yx%
+ \global\advance\pgf@x by #3\pgf@zx%
+ \global\pgf@y=#1\pgf@xy%
+ \global\advance\pgf@y by #2\pgf@yy%
+ \global\advance\pgf@y by #3\pgf@zy}
+
+% A "quick" quick variant of \pgfqpointxy which assumes that
+% the X unit vector is ( e_xx,0 )^T and the Y unit vector is ( 0,
+% e_yy)^T.
+%
+% In words, the unit vectors are orthogonal. This is the usual case
+% for two-dimensional plots and shall be optimized.
+\def\pgfplotsqpointxy@orthogonal#1#2{%
+ \global\pgf@x=#1\pgf@xx%
+ \global\pgf@y=#2\pgf@yy
+}
+
+
+% Takes a domain as input and generates a foreach argument which
+% samples from the domain.
+% Writes the result to \pgfplotsretval
+% INPUT:
+% #1:#2 the domain
+% #3: the number of samples
+% OUTPUT:
+% \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)/(#3-1)}%
+ \edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfmathresult,...,\pgfplots@loc@TMPb}%
+}
+
+{
+ \catcode`\;=\active
+ \catcode`\:=\active
+ \gdef\pgfplots@activesemicolon{;}%
+ \gdef\pgfplots@activecolon{:}%
+}
+
+% checks whether ';' is active and replaces a sequence of commands
+% accordingly.
+%
+% @see \pgfplots@appendto@activesemicolon@switcher
+\def\pgfplots@checkandpreparefor@active@semicolon{%
+ \ifnum\the\catcode`\;=\active\relax
+ \pgfplots@checkandpreparefor@active@semicolon@
+ \fi
+}%
+\def\pgfplots@checkandpreparefor@active@semicolon@{}%
+
+% Adds all commands '#1' to the sequence of commands which will be
+% issued in case ';' is active.
+\def\pgfplots@appendto@activesemicolon@switcher#1{%
+ \expandafter\def\expandafter\pgfplots@checkandpreparefor@active@semicolon@\expandafter{%
+ \pgfplots@checkandpreparefor@active@semicolon@
+ #1%
+ }%
+}%
+
+% 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{%
+ \pgfplots@for@reset@break{%
+ \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{%
+ \pgfplots@for@reset@break{%
+ \pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2,\pgfplots@EOI
+ }%
+}%
+% A variant of \pgfplotsforeachentryinCSV where a trailing comma
+% indicates the end of input.
+% Example:
+%
+% \pgfplotsforeachentryinCSV{\value}{1,2,3,4.5,6.7,10,}{The value is \value\par}
+% ^
+%
+% It is permissable to provide an empty list (without trailing comma)
+%
+% This loop can be nested.
+\long\def\pgfplotsforeachentryinCSVisterminated#1#2#3{%
+ \pgfplots@for@reset@break{%
+ \pgfplotsforeachentryinCSVisterminated@loop{#1}{#3}#2\pgfplots@EOI
+ }%
+}%
+% #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{#1}{#2}%
+ }%
+}%
+\long\def\pgfplotsforeachentryinCSV@next#1#2#3,{%
+ \def#1{#3}%
+ #2\relax
+ \ifpgffor@continue
+ \expandafter\pgfplotsforeachentryinCSVisterminated@loop
+ \else
+ \expandafter\pgfplots@gobble@until@EOI
+ \fi
+ {#1}{#2}%
+}%
+
+
+% Discards any token up to (and including) \relax.
+\def\pgfplots@gobble@until@relax#1\relax{}%
+\def\pgfplots@gobble@until@EOI#1\pgfplots@EOI{}%
+
+% A (simple) replacement for \foreach which
+% 1. does NOT scope the argument
+% 2. allows to use PGF Math routines for loops ( '...' notation)
+% instead of TeX registers.
+%
+% Usage:
+% \pgfplotsforeachungrouped \x in {1,2,3,4,5} {<code>}
+%
+% Some details:
+% 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{%
+ \pgfutil@ifnextchar/{\pgfplotsforeachungrouped@{#1}}{\pgfplotsforeachungrouped@{#1}/{}}%
+}%
+
+% accept both
+% \pgfplotsforeachungrouped\x in{1,...,5}{a}
+% \pgfplotsforeachungrouped\x in {1,...,5}{a}
+\long\def\pgfplotsforeachungrouped@#1/#2in{%
+ \pgfutil@ifnextchar\bgroup{%
+ \pgfplotsforeachungrouped@@{#1}{#2}%
+ }{%
+ \pgfplots@error{Found unexpected characters: expected 'in '.}%
+ }%
+}
+
+\long\def\pgfplots@for@reset@break#1{%
+ \ifpgffor@continue
+ \pgffor@continuetrue
+ #1\relax
+ \pgffor@continuetrue
+ \else
+ \pgffor@continuetrue
+ #1\relax
+ \pgffor@continuefalse
+ \fi
+}%
+
+% Defines \pgfplotsretval to contain a 'domain' argument if '#1' is
+% actually a domain listing. In this case, '\pgfplotsretvalb' will be
+% set to the number of samples.
+%
+% If #1 is no valid domain argument, \pgfplotsretval will be set to
+% empty.
+\def\pgfplotsforeachtodomain#1{%
+ \begingroup
+ \long\def\pgfplotsforeachungroupednonuniform@##1##2##3{%
+ \def\pgfplotsretval{}%
+ \def\pgfplotsretvalb{}%
+ }%
+ \long\def\pgfplotsforeachungroupedslashed@##1/##2##3##4{%
+ \def\pgfplotsretval{}%
+ \def\pgfplotsretvalb{}%
+ }%
+ \long\def\pgfplotsforeachungroupeduniform@##1##2,##3,...,##4\relax##5{%
+ \edef\pgfplotsretval{##2:##4}%
+ \pgfkeys{/pgf/fpu}%
+ \pgfmathparse{##3-##2}%
+ \let\pgfplots@h=\pgfmathresult
+ \pgfmathparse{(##4-##2)/\pgfplots@h + 1}%
+ \pgfmathfloattofixed\pgfmathresult
+ \afterassignment\pgfplotsforeachtodomain@@
+ \c@pgf@counta=\pgfmathresult
+ }%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungrouped \noexpand\x\space in{#1}{}}%
+ \pgfplots@loc@TMPa
+ %
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand\pgfplotsretval{\pgfplotsretval}%
+ \noexpand\def\noexpand\pgfplotsretvalb{\pgfplotsretvalb}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+\def\pgfplotsforeachtodomain@@.#1\relax{%
+ \pgf@xa=0.#1pt %
+ \ifnum\pgf@xa>0.01pt % FIXME : threshold is chosen in a bad way... should be relative to number range!
+ % this is not an integer! We cannot convert it to a domain.
+ \def\pgfplotsretval{}%
+ \def\pgfplotsretvalb{}%
+ \else
+ % ok, it is an integer. Return it as number samples!
+ % \pgfplotsretval already contains the domain.
+ \edef\pgfplotsretvalb{\the\c@pgf@counta}%
+ \fi
+}%
+
+\long\def\pgfplotsforeachungrouped@@#1#2#3#4{%
+ \pgfplots@for@reset@break{%
+ %
+ \def\pgfplots@foreach@loc@TMPa{#2}%
+ \ifx\pgfplots@foreach@loc@TMPa\pgfutil@empty
+ \pgfplotsforeachungrouped@isuniform{#3}%
+ \ifpgfplots@loc@tmp
+ % special handling:
+ % \foreach #1 in {a,b,...,c} can be improved:
+ \pgfplotsforeachungroupeduniform@{#1}#3\relax{#4}%
+ \else
+ % invoke \foreach #1 in {#3} and transport results:
+ \pgfplotsforeachungroupednonuniform@#1{#3}{#4}%
+ \fi
+ \else
+ % invoke \foreach #1/#2 in {#3} and transport results:
+ \pgfplotsforeachungroupedslashed@#1/#2{#3}{#4}%
+ \fi
+ }%
+}
+\let\pgfplots@original@pgfmathadd@=\pgfmathadd@
+
+\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}%
+ % 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
+ \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
+ {0}% #7 : the loop variable
+ }%
+ \pgfplots@foreach@loc@TMPc
+}%
+
+% This here is much more accurate and does not suffer from the
+% numerical stability issues of the other loop.
+%
+% #1: comparison fct
+% #2: lower limit
+% #3: upper limit
+% #4: the loop macro name
+% #5: h
+% #6: code to invoke
+% #7: the loop variable (number samples)
+\long\def\pgfplotsforeachungroupeduniform@loop@mathengine@precise#1#2#3#4#5#6#7{%
+ \pgflibraryfpuifactive{%
+ \pgfmathfloatparsenumber{#7}%
+ }{%
+ \edef\pgfmathresult{#7}%
+ }%
+ \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{#5}%
+ \expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#2}%
+ \let#4=\pgfmathresult
+ #1{#4}{#3}% substitute this by integer arithmetics
+ \ifdim\pgfmathresult pt=0pt %
+ \def\pgfplotsforeach@loc@TMP@{\pgfutil@in@{.0\relax}}%
+ \expandafter\pgfplotsforeach@loc@TMP@\expandafter{#4\relax}%
+ \ifpgfutil@in@
+ % ah - our current loop variable has .0 as suffix.
+ % Strip it.
+ \def\pgfplotsforeach@loc@TMP@##1.0\relax{%
+ \def#4{##1}%
+ }%
+ \expandafter\pgfplotsforeach@loc@TMP@#4\relax
+ \fi
+ #6\relax
+ \def\pgfplotsforeach@loc@TMP@{#7}%
+ \pgfplotsutil@advancestringcounter\pgfplotsforeach@loc@TMP@
+ %
+ \t@pgfplots@tokc={{#1}{#2}{#3}{#4}{#5}{#6}}%
+ % loop!
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungroupeduniform@loop@mathengine
+ \the\t@pgfplots@tokc{\pgfplotsforeach@loc@TMP@}}%
+ \expandafter\pgfplots@loc@TMPa
+ \fi
+}%
+\long\def\pgfplotsforeachungroupeduniform@loop@mathengine@legacy#1#2#3#4#5#6#7{%
+ #1{#2}{#3}%
+ \ifpgffor@continue
+ \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
+ \def#4{#2}%
+ \fi
+ #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\expandafter\expandafter\pgfplots@loc@TMPa
+ \fi
+ \fi
+}%
+
+\let\pgfplotsforeachungroupeduniform@loop@mathengine=\pgfplotsforeachungroupeduniform@loop@mathengine@legacy
+
+
+\long\def\pgfplotsforeachungroupednonuniform@#1#2#3{%
+ \pgfplotsapplistXXglobalnewempty
+ \foreach\pgfplots@foreach@loc@TMPa in {#2} {%
+ \expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfplots@foreach@loc@TMPa,}%
+ }%
+ \pgfplotsapplistXXgloballet\pgfplots@foreach@loc@TMPa
+ \pgfplotsapplistXXglobalclear
+ \expandafter\pgfplotsforeachentryinCSVisterminated\expandafter\pgfplots@foreach@loc@TMPa\expandafter{\pgfplots@foreach@loc@TMPa}{%
+ \let#1=\pgfplots@foreach@loc@TMPa
+ #3%
+ }%
+}
+\long\def\pgfplotsforeachungroupedslashed@#1/#2#3#4{%
+ \pgfplotsapplistXXglobalnewempty
+ \foreach\pgfplots@foreach@loc@TMPa/\pgfplots@foreach@loc@TMPb in {#3} {%
+ \edef\pgfplots@foreach@loc@TMPa{\pgfplots@foreach@loc@TMPa/\pgfplots@foreach@loc@TMPb}%
+ \expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfplots@foreach@loc@TMPa,}%
+ }%
+ \pgfplotsapplistXXgloballet\pgfplots@foreach@loc@TMPa
+ \pgfplotsapplistXXglobalclear
+ \expandafter\pgfplotsforeachentryinCSVisterminated\expandafter\pgfplots@foreach@loc@TMPa\expandafter{\pgfplots@foreach@loc@TMPa}{%
+ \expandafter\pgfplotsforeachungroupedslashed@@\pgfplots@foreach@loc@TMPa\pgfplots@EOI
+ \let#1=\pgfplots@foreach@loc@TMPa
+ \let#2=\pgfplots@foreach@loc@TMPb
+ #4%
+ }%
+}
+\def\pgfplotsforeachungroupedslashed@@#1/#2\pgfplots@EOI{%
+ \def\pgfplots@foreach@loc@TMPa{#1}%
+ \def\pgfplots@foreach@loc@TMPb{#2}%
+}%
+
+% 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}%
+ \expandafter\pgfplotsforeachungrouped@isuniform@\pgfplots@foreach@loc@TMPa,,,,\relax
+}%
+\def\pgfplotsforeachungrouped@isuniform@#1,#2,#3,#4,#5\relax{%
+ \def\pgfplots@foreach@loc@TMPa{#5}%
+ \def\pgfplots@foreach@loc@TMPb{,,,}%
+ \pgfplots@loc@tmpfalse
+ \ifx\pgfplots@foreach@loc@TMPa\pgfplots@foreach@loc@TMPb
+ \def\pgfplots@foreach@loc@TMPa{#3}%
+ \def\pgfplots@foreach@loc@TMPb{...}%
+ \ifx\pgfplots@foreach@loc@TMPa\pgfplots@foreach@loc@TMPb
+ \pgfutil@in@,{#4}%
+ \ifpgfutil@in@
+ \else
+ % ok, we REALLY have a uniform range!
+ \pgfplots@loc@tmptrue
+ \fi
+ \fi
+ \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.
+%
+% Example:
+% \pgfplotsforeachlogarithmicformatresultwith{\pgfmathfloattofixed{\pgfmathresult}}
+%
+% #1: is code which modifies \pgfmathresult.
+\def\pgfplotsforeachlogarithmicformatresultwith#1{%
+ \def\pgfplotsforeachlogarithmicungrouped@finalizeresult{#1}%
+}
+
+% \pgfplotsforeachlogarithmicungrouped[<samples>] \x/\logx in {a:b} {#3}
+% \pgfplotsforeachlogarithmicungrouped[<samples>][<math id>] \x/\logx in {a:b} {#3}
+%
+% samples \x between a and b using a logarithmic scale.
+%
+% During '#3', \x will contain the sample and \logx the logarithm of
+% \x.
+%
+% Both, #1 and #2 will be provided as floating point numbers unless
+% configured otherwise with \pgfplotsforeachlogarithmicsetoutput,
+% see above.
+%
+% Arithmethics will be carried out with the math class '<math id>'
+% (defaults to '\pgfplotsforeachlogarithmicmathid').
+% This macro should expand to something which is usable inside of
+% \pgfplotscoordmath{<math id>}{....}
+% the default is 'float'
+%
+% FIXME : THIS CAN'T BE NESTED YET!
+\def\pgfplotsforeachlogarithmicungrouped[#1]{%
+ \pgfutil@ifnextchar[{%
+ \pgfplotsforeachlogarithmicungrouped@[#1]%
+ }{%
+ \pgfplotsforeachlogarithmicungrouped@[#1][\pgfplotsforeachlogarithmicmathid]%
+ }%
+}%
+\def\pgfplotsforeachlogarithmicungrouped@[#1][#2]#3/#4{\pgfplotsforeachlogarithmicungrouped@@[#1][#2]{#3}{#4}}%
+\long\def\pgfplotsforeachlogarithmicungrouped@@[#1][#2]#3#4in #5#6{%
+ % define
+ % \pgfplots@foreachlog@loc@TMPd = N in fixed point
+ % \pgfplots@foreachlog@loc@TMPc = N-1 in float :
+ \edef\pgfplots@plot@samples@@{#1}%
+ \pgfplotscoordmath{#2}{one}%
+ \let\pgfplots@foreachlog@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{#2}{parsenumber}{\pgfplots@plot@samples@@}%
+ \pgfplotscoordmath{#2}{op}{subtract}{{\pgfmathresult}{\pgfplots@foreachlog@loc@TMPa}}%
+ \let\pgfplots@foreachlog@loc@TMPc=\pgfmathresult
+ %
+ \edef\pgfplots@loc@TMPb{#5}%
+ \expandafter\pgfplotsforeachlogarithmicungrouped@readdomain\pgfplots@loc@TMPb\relax{#2}%
+ \pgfplotscoordmath{#2}{if is bounded}{\pgfplots@foreachlog@loc@TMPb}{%
+ }{%
+ \pgfplotsforeachlogarithmicmath@unbounded@domain{#5}%
+ \pgfplotscoordmath{#2}{parsenumber}{-10000}%
+ \let\pgfplots@foreachlog@loc@TMPb=\pgfmathresult
+ }%
+ \pgfplotscoordmath{#2}{if is bounded}{\pgfplots@foreachlog@loc@TMPa}{%
+ }{%
+ \pgfplotsforeachlogarithmicmath@unbounded@domain{#5}%
+ \pgfplotscoordmath{#2}{parsenumber}{-10000}%
+ \let\pgfplots@foreachlog@loc@TMPa=\pgfmathresult
+ }%
+ % compute mesh width into \pgfplots@foreachlog@loc@TMPc:
+ % \pgfplots@foreachlog@loc@TMPc := h := ( log(xmax) - log(xmin) ) / (N-1)
+ \pgfplotscoordmath{#2}{op}{subtract}{{\pgfplots@foreachlog@loc@TMPb}{\pgfplots@foreachlog@loc@TMPa}}%
+ \pgfplotscoordmath{#2}{op}{divide}{{\pgfmathresult}{\pgfplots@foreachlog@loc@TMPc}}%
+ \let\pgfplots@foreachlog@loc@TMPc=\pgfmathresult
+ %
+ % apply local scoping here:
+ \edef\pgfplots@foreachlog@loc@TMPd{%
+ \noexpand\c@pgf@counta=\the\c@pgf@counta\noexpand\relax
+ }%
+ \long\def\pgfplots@foreachlog@loc@TMPf{#6}%
+ \c@pgf@counta=0
+ \pgfutil@loop
+ \ifnum\c@pgf@counta<\pgfplots@plot@samples@@
+ % compute exp(log(min) + i * h)
+ \edef\pgfplots@loc@TMPa{\the\c@pgf@counta}%
+ \pgfplotscoordmath{#2}{parsenumber}{\pgfplots@loc@TMPa}%
+ \pgfplotscoordmath{#2}{op}{multiply}{{\pgfmathresult}{\pgfplots@foreachlog@loc@TMPc}}%
+ \pgfplotscoordmath{#2}{op}{add}{{\pgfmathresult}{\pgfplots@foreachlog@loc@TMPa}}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotsforeachlogarithmicungrouped@finalizeresult%
+ \let#4=\pgfmathresult
+ \pgfplotscoordmath{#2}{exp}{\pgfplots@loc@TMPa}%
+ \pgfplotsforeachlogarithmicungrouped@finalizeresult%
+ \let#3=\pgfmathresult
+ %
+ % ok, invoke it!
+ % -> store \c@pgf@counta before doing so. We need to scope
+ % manually here.
+ \edef\pgfplots@foreachlog@loc@TMPe{\the\c@pgf@counta}%
+ \pgfplots@foreachlog@loc@TMPf\relax
+ \c@pgf@counta=\pgfplots@foreachlog@loc@TMPe\relax
+ \advance\c@pgf@counta by 1
+ \pgfutil@repeat
+ % restore scoped variables:
+ \pgfplots@foreachlog@loc@TMPd
+}
+
+\def\pgfplotsforeachlogarithmicmath@unbounded@domain#1{%
+ \pgfplots@error{Sorry, the provided domain #1 is unsuitable for logarithmic sampling (applying the log results in unbounded values)}%
+}%
+
+% can be used to convert the number format from float to something
+% else.
+\def\pgfplotsforeachlogarithmicungrouped@finalizeresult{}%
+
+
+\def\pgfplotsforeachlogarithmicmathid{float}
+
+% defines
+% \pgfplots@foreachlog@loc@TMPa := log(firstintervalpt)
+% and
+% \pgfplots@foreachlog@loc@TMPb := log(secondintervalpt)
+\def\pgfplotsforeachlogarithmicungrouped@readdomain#1:#2\relax#3{%
+ \pgfplotscoordmath{default}{parse}{#1}%
+ \pgfplotscoordmath{#3}{log}{\pgfmathresult}%
+ \let\pgfplots@foreachlog@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{default}{parse}{#2}%
+ \pgfplotscoordmath{#3}{log}{\pgfmathresult}%
+ \let\pgfplots@foreachlog@loc@TMPb=\pgfmathresult
+}
+
+% invokes '#2' if #1 expands (\edef) to the empty string or '#3' if not.
+\def\pgfplots@ifempty#1#2#3{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty #2\else #3\fi
+}%
+
+{
+ \catcode`\#=12
+ \catcode`\1=12
+ \gdef\pgfplotsutil@add@to@macro@@one{#1}%
+ \gdef\pgfplotsutil@add@to@macro@@two{#1#2}%
+}
+
+\def\pgfplotsutil@ifmacrodependsononearg#1#2#3{%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfutil@in@{\pgfplotsutil@add@to@macro@@one}{\meaning#1}}%
+ \pgfplots@loc@TMPa
+ \ifpgfutil@in@
+ #2%
+ \else
+ #3%
+ \fi
+}%
+
+\def\pgfplotsutil@ifmacrodependsontwoargs#1#2#3{%
+ \edef\pgfplots@util@add@to@macro@@{\noexpand\pgfutil@in@{\pgfplotsutil@add@to@macro@@two}{\meaning#1}}%
+ \pgfplots@util@add@to@macro@@
+ \ifpgfutil@in@
+ #2%
+ \else
+ #3%
+ \fi
+}%
+
+% Appends '#2' to macro '#1'.
+%
+% #1: a macro which takes either no arguments or exactly one.
+% #2: some token text. May depend on '#1' if #1 is a macro which
+% depends on one arg.
+\def\pgfplotsutil@add@to@macro#1#2{%
+ \pgfplotsutil@ifmacrodependsononearg#1{%
+ \pgfplotsutil@ifmacrodependsontwoargs#1{%
+ \pgfplotsutil@add@to@macro@twoargs{#1}{#2}%
+ }{%
+ \pgfplotsutil@add@to@macro@onearg{#1}{#2}%
+ }%
+ }{%
+ \pgfplotsutil@add@to@macro@noargs{#1}{#2}%
+ }%
+}%
+
+\def\pgfplotsutil@add@to@macro@twoargs#1#2{%
+ \t@pgfplots@tokc=\expandafter{#1{##1}{##2}}%
+ \t@pgfplots@tokb={#2}%
+ \edef\pgfplots@util@add@to@macro@@{\the\t@pgfplots@tokc\the\t@pgfplots@tokb}%
+ \expandafter\def\expandafter#1\expandafter##\expandafter1\expandafter##\expandafter2\expandafter{\pgfplots@util@add@to@macro@@}%
+}
+
+\def\pgfplotsutil@add@to@macro@onearg#1#2{%
+ \t@pgfplots@tokc=\expandafter{#1{##1}}%
+ \t@pgfplots@tokb={#2}%
+ \edef\pgfplots@util@add@to@macro@@{\the\t@pgfplots@tokc\the\t@pgfplots@tokb}%
+ \expandafter\def\expandafter#1\expandafter##\expandafter1\expandafter{\pgfplots@util@add@to@macro@@}%
+}
+
+\def\pgfplotsutil@add@to@macro@noargs#1#2{%
+ \t@pgfplots@tokc=\expandafter{#1}%
+ \t@pgfplots@tokb=\expandafter{#2}%
+ \edef#1{\the\t@pgfplots@tokc\the\t@pgfplots@tokb}%
+}
+\def\pgfplots@logfileopen#1{%
+ \immediate\write-1{PGFPlots: reading {#1}}%
+ \pgfutil@IfUndefined{tikzifexternalizingcurrent}{%
+ % version not up-to-date or external lib not loaded?
+ }{%
+ % adjust the .dep file only if we are externalizing.
+ % Otherwise, it may be overwritten by \pgfplotstableread
+ % commands which are *before* the tikzpicture (and the picture
+ % will be replaced by its graphics)
+ \tikzifexternalizingcurrent{\tikzpicturedependsonfile{#1}}{}%
+ }%
+}%
+
+% Expands #2 using \edef and invokes #1 with the resulting string.
+%
+% DEPRECATED
+% Example:
+% \pgf@xa=7.9pt
+% \pgfplotsutil@edef@invoke\pgfmathexp@{{\pgf@sys@tonumber{\pgf@xa}}}%
+% will invoke
+% \pgfmathexp@{7.9}
+\def\pgfplotsutil@edef@invoke#1#2{%
+ \edef\pgfutil@edef@invoke@{#2}%
+ \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
+ \ifnum\c@pgf@counta=2
+ \ifodd\c@pgf@countb
+ \def\pgfmathresult{1}%
+ \else
+ \def\pgfmathresult{0}%
+ \fi
+ \else
+ \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
+ \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.
+\def\pgfplotsutil@advancestringcounter#1{%
+ \begingroup
+ \c@pgf@counta=#1\relax
+ \advance\c@pgf@counta by1
+ \edef#1{\the\c@pgf@counta}%
+ \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
+}%
+
+% String comparison of '#1' and '#2'.
+% Defines
+% \pgfplotsretval=0 if #1 == #2
+% \pgfplotsretval=1 if #1 < #2
+% \pgfplotsretval=2 if #1 > #2
+\def\pgfplotsutilstrcmp#1#2{%
+ \begingroup
+ \def\pgfplots@strcmp@arga{#1}%
+ \pgfplots@command@to@string\pgfplots@strcmp@arga\pgfplots@strcmp@arga
+ \def\pgfplots@strcmp@argb{#2}%
+ \pgfplots@command@to@string\pgfplots@strcmp@argb\pgfplots@strcmp@argb
+ %
+ %
+ \def\pgfplotsretval{0}%
+ %
+ \pgfplotsloop{%
+ \if0\pgfplotsretval
+ % get next token of arga:
+ \expandafter\pgfplotsutilstrcmp@popfront\pgfplots@strcmp@arga\relax\relax
+ \let\pgfplots@strcmp@arga=\pgfplots@strcmp@rest
+ \let\pgfplots@strcmp@arga@=\pgfplots@strcmp@cur
+ %
+ % get next token of argb:
+ \expandafter\pgfplotsutilstrcmp@popfront\pgfplots@strcmp@argb\relax\relax
+ \let\pgfplots@strcmp@argb=\pgfplots@strcmp@rest
+ \let\pgfplots@strcmp@argb@=\pgfplots@strcmp@cur
+ %
+ % if one of them is empty: set retval and break loop.
+ \ifx\pgfplots@strcmp@arga@\pgfplotsutilstrcmp@relaxtext
+ \ifx\pgfplots@strcmp@argb@\pgfplotsutilstrcmp@relaxtext
+ \else
+ \def\pgfplotsretval{1}%
+ \fi
+ \pgfplotsloopcontinuefalse
+ \else
+ \ifx\pgfplots@strcmp@argb@\pgfplotsutilstrcmp@relaxtext
+ \def\pgfplotsretval{2}%
+ \pgfplotsloopcontinuefalse
+ \else
+ \pgfplotsloopcontinuetrue
+ \fi
+ \fi
+ \else
+ \pgfplotsloopcontinuefalse
+ \fi
+ }{%
+ %
+ \ifnum\expandafter`\pgfplots@strcmp@arga@<\expandafter`\pgfplots@strcmp@argb@
+ \def\pgfplotsretval{1}%
+ \let\pgfplots@strcmp@arga=\pgfutil@empty
+ \else
+ \ifnum\expandafter`\pgfplots@strcmp@arga@>\expandafter`\pgfplots@strcmp@argb@
+ \def\pgfplotsretval{2}%
+ \let\pgfplots@strcmp@arga=\pgfutil@empty
+ \fi
+ \fi
+ }%
+ %
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsutilstrcmp@relaxtext{\relax}%
+\def\pgfplotsutilstrcmp@popfront#1#2\relax{%
+ \def\pgfplots@strcmp@cur{#1}%
+ \def\pgfplots@strcmp@rest{#2}%
+}%
+
+% Takes two dimensional cartesian coordinates #1,#2 and
+% defines the macros #3 and #4 to contain the associated polar
+% coordinates.
+%
+% #1: x
+% #2: y
+% #3: a macro which will be filled with the angle (in degrees)
+% #4: a macro which will be filled with the radius
+\def\pgfplotsmathcarttopol#1#2#3#4{%
+ \pgfplotsmathcarttopol@{#1}{#2}{#3}{#4}{default}%
+}%
+\def\pgfplotsmathcarttopolbasic#1#2#3#4{%
+ \pgfplotsmathcarttopol@{#1}{#2}{#3}{#4}{pgfbasic}%
+}%
+% #5: the math engine to use (\pgfplotscoordmath argument)
+\def\pgfplotsmathcarttopol@#1#2#3#4#5{%
+ \begingroup
+ \pgfplotscoordmath{#5}{parsenumber}{#1}%
+ \let\pgfplots@x=\pgfmathresult
+ \pgfplotscoordmath{#5}{parsenumber}{#2}%
+ \let\pgfplots@y=\pgfmathresult
+ \pgfplotscoordmath{#5}{op}{veclen}{{\pgfplots@x}{\pgfplots@y}}%
+ \let\pgfplots@r=\pgfmathresult
+ \pgfplotscoordmath{#5}{op}{atan2}{{\pgfplots@y}{\pgfplots@x}}%
+ \let\pgfplots@deg=\pgfmathresult
+ \xdef\pgfplots@glob@TMPa{\noexpand\def\noexpand#3{\pgfplots@deg}\noexpand\def\noexpand#4{\pgfplots@r}}%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+% Takes two dimensional polar coordinates #1,#2 and
+% defines the macros #3 and #4 to contain the associated cartesian
+% coordinates.
+%
+% #1: angle (in degrees)
+% #2: radius
+% #3: a macro which will be filled with the x value
+% #4: a macro which will be filled with the y value
+\def\pgfplotsmathpoltocart#1#2#3#4{%
+ \pgfplotsmathpoltocart@{#1}{#2}{#3}{#4}{default}%
+}%
+\def\pgfplotsmathpoltocartbasic#1#2#3#4{%
+ \pgfplotsmathpoltocart@{#1}{#2}{#3}{#4}{pgfbasic}%
+}%
+% #5: the math engine to use (\pgfplotscoordmath argument)
+\def\pgfplotsmathpoltocart@#1#2#3#4#5{%
+ \begingroup
+ \pgfplotscoordmath{#5}{parsenumber}{#1}%
+ \let\pgfplots@deg=\pgfmathresult
+ \pgfplotscoordmath{#5}{parsenumber}{#2}%
+ \let\pgfplots@r=\pgfmathresult
+ \pgfplotscoordmath{#5}{op}{sin}{{\pgfplots@deg}}%
+ \pgfplotscoordmath{#5}{op}{multiply}{{\pgfplots@r}{\pgfmathresult}}%
+ \let\pgfplots@y=\pgfmathresult
+ \pgfplotscoordmath{#5}{op}{cos}{{\pgfplots@deg}}%
+ \pgfplotscoordmath{#5}{op}{multiply}{{\pgfplots@r}{\pgfmathresult}}%
+ \let\pgfplots@x=\pgfmathresult
+ \xdef\pgfplots@glob@TMPa{\noexpand\def\noexpand#3{\pgfplots@x}\noexpand\def\noexpand#4{\pgfplots@y}}%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+
+
+\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}%
+ }%
+}%
+
+\def\pgfplotsmathfloatln@#1{%
+ \pgfmathfloatln@{#1}%
+}
+
+% Defines a macro which computes ln(x)/ln(#2) in float.
+%
+% #1: a macro name without backslash
+% #2: the log base as fixed point number. Maybe the empty string in
+% which case the natural log is used.
+%
+% It will define the macros:
+% <macro>##1 -> calls \pgfmathfloatparsenumber and then the '@' variant:
+% <macro>@##1 -> expects and returns result in float
+% <macro>@tofixed##1 -> expects result in float, returns it in fixed (or an empty string)
+% <macro>inv@##1 -> the inverse (exponential) function, expects float, returns float
+% %
+% <macro>logbase -> the basis as number
+% <macro>logofbasefixed -> log(#2)
+% <macro>invlogofbasefixed -> 1/log(#2)
+% <macro>logofbasefloat -> log(#2) in float
+% <macro>invlogofbasefloat -> 1/log(#2) in float
+\def\pgfplotsmathdefinemacrolnbase#1#2{%
+ \expandafter\edef\csname #1logbase\endcsname{#2}%
+ \expandafter\ifx\csname #1logbase\endcsname\pgfutil@empty
+ \expandafter\edef\csname #1logbase\endcsname{2.718281828459}%
+ \expandafter\def\csname #1logofbasefixed\endcsname{1}%
+ \expandafter\def\csname #1invlogofbasefixed\endcsname{1}%
+ \else
+ \pgfmathlog@{\csname #1logbase\endcsname}%
+ \expandafter\let\csname #1logofbasefixed\endcsname\pgfmathresult%
+ \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}%
+ \expandafter\let\csname #1invlogofbasefixed\endcsname\pgfmathresult%
+ \fi
+ %
+ \pgfmathfloatparsenumber{\csname #1logofbasefixed\endcsname}%
+ \expandafter\let\csname #1logofbasefloat\endcsname\pgfmathresult%
+ \pgfmathfloatparsenumber{\csname #1invlogofbasefixed\endcsname}%
+ \expandafter\let\csname #1invlogofbasefloat\endcsname\pgfmathresult%
+ %
+ \expandafter\def\csname #1@tofixed\endcsname##1{%
+ \pgfmathlog@float{##1}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \expandafter\pgfmath@basic@multiply@\expandafter
+ {\pgfmathresult}%
+ {\csname #1invlogofbasefixed\endcsname}%
+ \fi
+ }%
+ \expandafter\def\csname #1@\endcsname##1{%
+ \expandafter\csname #1@tofixed\endcsname{##1}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfmathfloatcreate{3}{0.0}{0}%
+ \else
+ \pgfmathfloatparsenumber{\pgfmathresult}%
+ \fi
+ }%
+ \expandafter\def\csname #1\endcsname##1{%
+ \pgfmathfloatparsenumber{##1}%
+ \csname #1@\endcsname{\pgfmathresult}%
+ }%
+ %
+ \expandafter\def\csname #1inv@\endcsname##1{%
+ \expandafter\pgfmathfloatmultiply@\expandafter{##1}{\csname #1logofbasefloat\endcsname}%
+ \pgfmathfloatexp@{\pgfmathresult}%
+ }%
+}%
+
+% Tests if string '#2' starts with pattern '#1'.
+%
+% If so, it executes #3 and defines \pgfplotsretval to contain the
+% suffix which is not equal to #1. Otherwise it executes #4.
+\def\pgfplotsutilifstartswith#1#2#3#4{%
+ \def\pgfplotsutilifstartswith@ ##1#1##2\pgfplots@EOI{%
+ \def\pgfplotsutil@tmp{##1}%
+ \ifx\pgfplotsutil@tmp\pgfutil@empty
+ % Ah - a hit!
+ %
+ % define \pgfplotsretval to be the suffix...
+ \def\pgfplotsutil@tmp#1####1\pgfplots@EOI{%
+ \def\pgfplotsretval{####1}%
+ }%
+ \pgfplotsutil@tmp#2\pgfplots@EOI
+ %
+ % ... and execute the <true> code:
+ #3\relax
+ \else
+ % hm. No such prefix.
+ #4\relax
+ \fi
+ }%
+ \pgfplotsutilifstartswith@#2--#1\pgfplots@EOI
+}%
+
+% 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
+}%
+
+% Checks if the token sequence #1 (unexpanded) contains a macro and
+% invokes #2 if so and #3 if not.
+\def\pgfplotsutilifcontainsmacro#1#2#3{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfutil@in@{\pgfplots@backslash@as@other}{\pgfplots@loc@TMPa}}%
+ \pgfplots@loc@TMPa
+ \ifpgfutil@in@
+ \def\pgfplots@loc@TMPa{#2}%
+ \else
+ \def\pgfplots@loc@TMPa{#3}%
+ \fi
+ \pgfplots@loc@TMPa
+}%
+
+% this command is in pgfplotscore.code.tex:
+% \pgfplotsiffileexists
+
+% EXPERIMENTAL OPTIMIZATION:
+\let\pgfmathparsex@orig=\pgfmathparse
+\def\pgfmathparsex#1{%
+ \begingroup
+ \message{WORKING ON #1...}%
+ \tracingmacros=2 \tracingcommands=2
+ \let\pgfmath@parse@@@operator\relax
+ \let\pgfmath@parse@@operator\relax
+ \let\pgfmath@parse@operator\relax
+ \let\pgfmath@stack@push@operand\pgfutil@gobble
+ \let\pgfmath@base=\pgfmath@empty
+ \let\pgfmath@number=\pgfmath@empty
+ \let\pgfmath@parse@number@failed=\relax
+ \edef\pgfmath@expression{#1}%
+ \expandafter\pgfmathparsex@first\pgfmath@expression\pgfmathparsex@EOI%
+ \if1\pgfmathparsex@recover@
+ \xdef\pgfmathparsex@@{\noexpand\pgfmathparsex@orig{\pgfmath@expression}}%
+ \else
+ \xdef\pgfmathparsex@@{\noexpand\def\noexpand\pgfmathresult{\pgfmathresult}}%
+ \fi
+ \endgroup
+ \pgfmathparsex@@
+}%
+\def\pgfmathparsex@first#1#2\pgfmathparsex@EOI{%
+ \def\pgfmath@token@next{#1}%
+ \pgfmath@parse@number{#2}%
+}%
+\def\pgfmathparsex@recover{\def\pgfmathparsex@recover@{1}}%
+\def\pgfmathparsex@recover@{0}%
+
+
+% compares YYYY-MM-DD < YYYY-MM-DD
+%
+% \pgfplotsutilifdatelessthan 2010-01-01\cmp 2011-01-01\relax{<true>}{<false>}
+\long\def\pgfplotsutilifdatelessthan#1-#2-#3\cmp #4-#5-#6\relax#7#8{%
+ \long\def\pgfplotsutilifdatelessthan@true{#7}%
+ \long\def\pgfplotsutilifdatelessthan@false{#8}%
+ \ifnum#1<#4\relax
+ \pgfplotsutilifdatelessthan@true
+ \else
+ \ifnum#1>#4\relax
+ \pgfplotsutilifdatelessthan@false
+ \else
+ \ifnum#2<#5\relax
+ \pgfplotsutilifdatelessthan@true
+ \else
+ \ifnum#2>#5\relax
+ \pgfplotsutilifdatelessthan@false
+ \else
+ \ifnum#3<#6\relax
+ \pgfplotsutilifdatelessthan@true
+ \else
+ \pgfplotsutilifdatelessthan@false
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+\long\def\pgfplotsutilifdategreaterthan#1-#2-#3\cmp #4-#5-#6\relax#7#8{%
+ \long\def\pgfplotsutilifdatelessthan@true{#7}%
+ \long\def\pgfplotsutilifdatelessthan@false{#8}%
+ \ifnum#1>#4\relax
+ \pgfplotsutilifdatelessthan@true
+ \else
+ \ifnum#1<#4\relax
+ \pgfplotsutilifdatelessthan@false
+ \else
+ \ifnum#2>#5\relax
+ \pgfplotsutilifdatelessthan@true
+ \else
+ \ifnum#2<#5\relax
+ \pgfplotsutilifdatelessthan@false
+ \else
+ \ifnum#3>#6\relax
+ \pgfplotsutilifdatelessthan@true
+ \else
+ \pgfplotsutilifdatelessthan@false
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+\pgfkeys{%
+ % /pgfplots/iflessthan{#1}{#2}{#3}{#4}:
+ % #1: arg1 (a macro containing the first argument)
+ % #2: arg2 (a macro containing the second argument)
+ % #3: code to invoke in case arg1<arg2
+ % #4: code to invoke in case arg1>=arg2
+ % the iflessthan method will be invoked within local scopes.
+ /pgfplots/fixed </.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{\ifdim##1pt<##2pt\relax##3\else ##4\fi},%
+ },
+ /pgfplots/fixed <,
+ /pgfplots/fixed >/.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{\ifdim##1pt>##2pt\relax##3\else ##4\fi},%
+ },
+ /pgfplots/int </.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{\ifnum##1<##2\relax##3\else ##4\fi},%
+ },
+ /pgfplots/int >/.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{\ifnum##1>##2\relax##3\else ##4\fi},%
+ },
+ /pgfplots/float </.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{%
+ \pgfmathfloatparsenumber{##1}%
+ \let\pgfplots@iflt@arga=\pgfmathresult
+ %
+ \pgfmathfloatparsenumber{##2}%
+ \let\pgfplots@iflt@argb=\pgfmathresult
+ %
+ \pgfmathfloatlessthan@{\pgfplots@iflt@arga}{\pgfplots@iflt@argb}%
+ \ifpgfmathfloatcomparison
+ ##3%
+ \else
+ ##4%
+ \fi
+ }%
+ },%
+ /pgfplots/float >/.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{%
+ \pgfmathfloatparsenumber{##1}%
+ \let\pgfplots@iflt@arga=\pgfmathresult
+ %
+ \pgfmathfloatparsenumber{##2}%
+ \let\pgfplots@iflt@argb=\pgfmathresult
+ %
+ \pgfmathfloatgreaterthan@{\pgfplots@iflt@arga}{\pgfplots@iflt@argb}%
+ \ifpgfmathfloatcomparison
+ ##3%
+ \else
+ ##4%
+ \fi
+ }%
+ },%
+ %
+ % compares YYYY-MM-DD < YYYY-MM-DD
+ /pgfplots/date </.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{%
+ \edef\pgfplotsarray@ltdate{##1\noexpand\cmp ##2}%
+ \expandafter\pgfplotsutilifdatelessthan\pgfplotsarray@ltdate\relax{##3}{##4}%
+ }%
+ },%
+ /pgfplots/date >/.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{%
+ \edef\pgfplotsarray@ltdate{##1\noexpand\cmp ##2}%
+ \expandafter\pgfplotsutilifdategreaterthan\pgfplotsarray@ltdate\relax{##3}{##4}%
+ }%
+ },%
+ %
+ /pgfplots/string </.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{%
+ \t@pgfplots@toka=\expandafter{##1}%
+ \t@pgfplots@tokb=\expandafter{##2}%
+ \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}{\the\t@pgfplots@tokb}}%
+ \expandafter\pgfplotsutilstrcmp\pgfplots@loc@TMPa
+ \if1\pgfplotsretval ##3\else ##4\fi
+ }%
+ },%
+ /pgfplots/string >/.style={%
+ /pgfplots/iflessthan/.code args={##1##2##3##4}{%
+ \t@pgfplots@toka=\expandafter{##1}%
+ \t@pgfplots@tokb=\expandafter{##2}%
+ \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}{\the\t@pgfplots@tokb}}%
+ \expandafter\pgfplotsutilstrcmp\pgfplots@loc@TMPa
+ \if2\pgfplotsretval ##3\else ##4\fi
+ }%
+ },%
+}
+
+% defines \pgfplotsretval to be
+%
+% \ifpgfpicture #1\else #2\fi
+%
+% and handles the '/pgfplots/invoke before crossref tikzpicture' key.
+%
+% #1 first argument to \ifpgfpicture
+% #2 second argument to \ifpgfpicture
+\def\pgfplots@assemble@ref@picture#1#2{%
+ \begingroup
+ \pgfkeysgetvalue{/pgfplots/invoke before crossref tikzpicture}\pgfplots@loc@TMPa
+ \pgfkeysgetvalue{/pgfplots/invoke after crossref tikzpicture}\pgfplots@loc@TMPb
+ \toks0={#1}%
+ \toks1=\expandafter{\pgfplots@loc@TMPa}%
+ \toks2={#2}%
+ \toks3=\expandafter{\pgfplots@loc@TMPb}%
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\ifpgfpicture
+ \the\toks0 %
+ \noexpand\else
+ \the\toks1
+ \the\toks2
+ \the\toks3
+ \noexpand\fi
+ }%
+ \endgroup
+ \let\pgfplotsretval=\pgfplots@glob@TMPa
+}%
+
+\def\pgfplots@auxwrite@latex#1{%
+ \if@filesw
+ \immediate\write\@auxout{#1}%
+ \fi
+}%
+\pgfutil@IfUndefined{if@filesw}{%
+ \def\pgfplots@auxwrite#1{}%
+}{%
+ \let\pgfplots@auxwrite=\pgfplots@auxwrite@latex
+}%
+
+% sorts three elements.
+%
+% #1,#2,#3 are three macros containing the input.
+% On output, these macros are redefined to represent the sorted range.
+% The values of these macros must be a <dimen>, followed by anything
+% else (but no \relax please)
+%
+% Example:
+% \def\A{10pt furthervalues}
+% \def\B{4pt value of b}
+% \def\C{1pt value of c}
+% \pgfplotsutilsortthree\A\B\C
+% ->
+% \A={1pt value of c}
+% \B={4pt value of b}
+% \C={10pt furthervalues}
+%
+% It uses insertion sort.
+\def\pgfplotsutilsortthree#1#2#3{%
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xb=#2\relax
+ \ifdim\pgf@xa>\pgf@xb
+ \let\pgfplots@loc@TMPa=#2%
+ \let#2=#1%
+ \let#1=\pgfplots@loc@TMPa%
+ \fi
+ % first two are sorted.
+ %
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#2\relax
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xb=#3\relax
+ \let\pgfplots@loc@TMPa=#3%
+ \ifdim\pgf@xa>\pgf@xb
+ \let#3=#2%
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax
+ \ifdim\pgf@xa>\pgf@xb
+ \let#2=#1%
+ \let#1=\pgfplots@loc@TMPa%
+ \else
+ \let#2=\pgfplots@loc@TMPa%
+ \fi
+ \fi
+ % ok.
+}%
+
+% Like \pgfplotsutilsortthree, but for four elements (of the same
+% form, see \pgfplotsutilsortthree).
+%
+% It uses insertion sort.
+\def\pgfplotsutilsortfour#1#2#3#4{%
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xb=#2\relax
+ \ifdim\pgf@xa>\pgf@xb
+ \let\pgfplots@loc@TMPa=#2%
+ \let#2=#1%
+ \let#1=\pgfplots@loc@TMPa%
+ \fi
+ % first two are sorted.
+ %
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#2\relax
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xb=#3\relax
+ \let\pgfplots@loc@TMPa=#3%
+ \ifdim\pgf@xa>\pgf@xb
+ \let#3=#2%
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax
+ \ifdim\pgf@xa>\pgf@xb
+ \let#2=#1%
+ \let#1=\pgfplots@loc@TMPa%
+ \else
+ \let#2=\pgfplots@loc@TMPa%
+ \fi
+ \fi
+ % ok, first three are sorted.
+ %
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#3\relax
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xb=#4\relax
+ \let\pgfplots@loc@TMPa=#4%
+ \ifdim\pgf@xa>\pgf@xb
+ \let#4=#3%
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#2\relax
+ \ifdim\pgf@xa>\pgf@xb
+ \let#3=#2%
+ \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#1\relax
+ \ifdim\pgf@xa>\pgf@xb
+ \let#2=#1%
+ \let#1=\pgfplots@loc@TMPa%
+ \else
+ \let#2=\pgfplots@loc@TMPa%
+ \fi
+ \else
+ \let#3=\pgfplots@loc@TMPa%
+ \fi
+ \fi
+ % ok, first four are sorted.
+}%
+
+% A variant of \pgfutil@ifnextchar which allows the '#' character
+% inside of either '#2' or '#3'.
+%
+% It is slightly more expensive and relies on \t@pgfplots@tokc
+\long\def\pgfplotsutil@ifnextchar#1#2#3{%
+ \let\pgfplotsutil@reserved@d=#1%
+ \t@pgfplots@tokc={#2}%
+ \edef\pgfplotsutil@reserved@a{\the\t@pgfplots@tokc}%
+ \t@pgfplots@tokc={#3}%
+ \def\pgfplotsutil@reserved@b{\the\t@pgfplots@tokc}%
+ \futurelet\pgfplotsutil@let@token\pgfplotsutil@ifnch}
+\def\pgfplotsutil@ifnch{%
+ \ifx\pgfplotsutil@let@token\pgfplotsutil@sptoken
+ \let\pgfplotsutil@reserved@c\pgfplotsutil@xifnch
+ \else
+ \ifx\pgfplotsutil@let@token\pgfplotsutil@reserved@d
+ \let\pgfplotsutil@reserved@c\pgfplotsutil@reserved@a
+ \else
+ \let\pgfplotsutil@reserved@c\pgfplotsutil@reserved@b
+ \fi
+ \fi
+ \pgfplotsutil@reserved@c}
+{%
+ \def\:{\global\let\pgfplotsutil@sptoken= } \:
+ \def\:{\pgfplotsutil@xifnch} \expandafter\gdef\: {\futurelet\pgfplotsutil@let@token\pgfplotsutil@ifnch}
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% basic 3d linear algebra utils.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Converts a 3d vectors to string.
+% #1: a vector which expands to the form 'x,y,z'
+% on output, \pgfplotsretval will contain the result vector.
+% #3: the argument for \pgfplotscoordmath (such as 'default')
+%
+\def\pgfplotsmathvectortostring#1#2{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotsmathvectorcompwiseop@unary\pgfplots@loc@TMPa\pgfplots@EOI{#2}{{tostring}}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% Reads a 3d vector's coordinates.
+% #1: a vector which expands to the form 'x,y,z'
+% on output, \pgfplotsretval will contain the result vector.
+% #2: the argument for \pgfplotscoordmath (such as 'default')
+%
+% Example:
+% \pgfplotsmathvectorfromstring{1,4,5}{default}
+% will parse each component
+\def\pgfplotsmathvectorfromstring#1#2{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotsmathvectorcompwiseop@unary\pgfplots@loc@TMPa\pgfplots@EOI{#2}{{parsenumber}}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% Takes two 3d vectors and subtracts them.
+% #1: a vector which expands to the form 'x,y,z'
+% #2: a vector which expands to the form 'x,y,z'
+% on output, \pgfplotsretval will contain the difference vector.
+% #3: the argument for \pgfplotscoordmath (such as 'default')
+%
+\def\pgfplotsmathvectorsubtract#1#2#3{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1:#2}%
+ \expandafter\pgfplotsmathvectorcompwiseop@binary\pgfplots@loc@TMPa\pgfplots@EOI{#3}{subtract}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsmathvectorcompwiseop@binary#1,#2,#3:#4,#5,#6\pgfplots@EOI#7#8{%
+ \def\Ax{#1}%
+ \def\Ay{#2}%
+ \def\Az{#3}%
+ \def\Bx{#4}%
+ \def\By{#5}%
+ \def\Bz{#6}%
+ \pgfplotscoordmath{#7}{op}{#8}{{\Ax}{\Bx}}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{#8}{{\Ay}{\By}}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{#8}{{\Az}{\Bz}}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult
+ \edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc}%
+}%
+
+% #5: an operation ENCLOSED IN BRACES!
+% like '{tostring}' or '{op}{<someunaryop>}'
+\def\pgfplotsmathvectorcompwiseop@unary#1,#2,#3\pgfplots@EOI#4#5{%
+ \def\Ax{#1}%
+ \def\Ay{#2}%
+ \def\Az{#3}%
+ \pgfplotscoordmath{#4}#5{\Ax}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{#4}#5{\Ay}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscoordmath{#4}#5{\Az}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult
+ \edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc}%
+}%
+
+% Takes two 3d vectors and adds them.
+% #1: a vector which expands to the form 'x,y,z'
+% #2: a vector which expands to the form 'x,y,z'
+% on output, \pgfplotsretval will contain the added vector.
+% #3: the argument for \pgfplotscoordmath (such as 'default')
+%
+\def\pgfplotsmathvectoradd#1#2#3{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1:#2}%
+ \expandafter\pgfplotsmathvectorcompwiseop@binary\pgfplots@loc@TMPa\pgfplots@EOI{#3}{add}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% Takes two 3d vectors and applies a component-wise operation.
+% #1: a vector which expands to the form 'x,y,z'
+% #2: a vector which expands to the form 'x,y,z'
+% on output, \pgfplotsretval will contain a boolean vector with three
+% entries.
+% #3: a scalar operation which takes two arguments (such as "add", "subtract", "equal")
+% #4 the argument for \pgfplotscoordmath (such as 'default')
+%
+% Example: \pgfplotsmathvectorcompwise{1,1,1}{0,1,0}{add}{pgfbasic}
+% -> \pgfplotsretval={1.0,2.0,1.0}
+\def\pgfplotsmathvectorcompwise#1#2#3#4{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1:#2}%
+ \expandafter\pgfplotsmathvectorcompwiseop@binary\pgfplots@loc@TMPa\pgfplots@EOI{#4}{#3}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% Defines \pgfplotsretval to x+y+z
+% #1: a vector which expands to the form 'x,y,z'
+% on output, \pgfplotsretval will contain the result scalar.
+% #2: the argument for \pgfplotscoordmath (such as 'default')
+%
+% Example:
+% \pgfplotsmathvectorsum{1,4,5}{default}
+% \pgfplotsretval = 10 (in that format)
+\def\pgfplotsmathvectorsum#1#2{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotsmathvectorsum@\pgfplots@loc@TMPa\pgfplots@EOI{#2}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+\def\pgfplotsmathvectorsum@#1,#2,#3\pgfplots@EOI#4{%
+ \def\Ax{#1}%
+ \def\Ay{#2}%
+ \def\Az{#3}%
+ \pgfplotscoordmath{#4}{op}{add}{{\Ax}{\Ay}}%
+ \let\pgfplotsretval=\pgfmathresult
+ \pgfplotscoordmath{#4}{op}{add}{{\pgfplotsretval}{\Az}}%
+ \let\pgfplotsretval=\pgfmathresult
+}%
+
+% Computes the euclidean scalar product of two 3d vectors #1 and #2 in math
+% format #3.
+\def\pgfplotsmathvectorscalarproduct#1#2#3{%
+ \pgfplotsmathvectorscaleindividually{#1}{#2}{#3}%
+ \pgfplotsmathvectorsum{\pgfplotsretval}{#3}%
+}%
+
+% takes a vector #1 and defines three new macros
+% \csname #2x\endcsname,
+% \csname #2y\endcsname,
+% \csname #2z\endcsname,
+% with the components.
+% #3: the math format
+\def\pgfplotsmathvectortocomponents#1#2#3{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotsmathvectortocomponents@\pgfplots@loc@TMPa\pgfplots@EOI{#3}{#2}%
+}%
+\def\pgfplotsmathvectortocomponents@#1,#2,#3\pgfplots@EOI#4#5{%
+ \expandafter\def\csname #5x\endcsname{#1}%
+ \expandafter\def\csname #5y\endcsname{#2}%
+ \expandafter\def\csname #5z\endcsname{#3}%
+}%
+
+
+% Takes two 3d vectors and computes their cross product.
+% #1: a vector which expands to the form 'x,y,z'
+% #2: a vector which expands to the form 'x,y,z'
+% on output, \pgfplotsretval will contain the result vector.
+% #3: the argument for \pgfplotscoordmath (such as 'default')
+%
+\def\pgfplotsmathvectorcrossprod#1#2#3{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1:#2}%
+ \expandafter\pgfplotsmathvectorcrossprod@\pgfplots@loc@TMPa\pgfplots@EOI{#3}%
+%\message{\string\pgfplotsmathvectorcrossprod{#1}{#2} = \pgfplotsretval^^J}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsmathvectorcrossprod@#1,#2,#3:#4,#5,#6\pgfplots@EOI#7{%
+ \def\Ax{#1}%
+ \def\Ay{#2}%
+ \def\Az{#3}%
+ \def\Bx{#4}%
+ \def\By{#5}%
+ \def\Bz{#6}%
+ %
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Ay}{\Bz}}\let\AyBz=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Az}{\By}}\let\AzBy=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Az}{\Bx}}\let\AzBx=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Ax}{\Bz}}\let\AxBz=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Ax}{\By}}\let\AxBy=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Ay}{\Bx}}\let\AyBx=\pgfmathresult
+ %
+ \pgfplotscoordmath{#7}{op}{subtract}{{\AyBz}{\AzBy}}\let\pgfplots@loc@TMPa=\pgfmathresult%
+ \pgfplotscoordmath{#7}{op}{subtract}{{\AzBx}{\AxBz}}\let\pgfplots@loc@TMPb=\pgfmathresult%
+ \pgfplotscoordmath{#7}{op}{subtract}{{\AxBy}{\AyBx}}\let\pgfplots@loc@TMPc=\pgfmathresult%
+ \edef\pgfplotsretval{\pgfplots@loc@TMPa,\pgfplots@loc@TMPb,\pgfplots@loc@TMPc}%
+}%
+
+% Takes two 3d vectors and defines a new vector (Ax*Bx,Ay*By,Az*Bz)
+% #1: a vector which expands to the form 'x,y,z'
+% #2: a vector which expands to the form 'x,y,z'
+% on output, \pgfplotsretval will contain the result vector.
+% #3: the argument for \pgfplotscoordmath (such as 'default')
+%
+\def\pgfplotsmathvectorscaleindividually#1#2#3{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1:#2}%
+ \expandafter\pgfplotsmathvectorscaleindividually@\pgfplots@loc@TMPa\pgfplots@EOI{#3}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsmathvectorscaleindividually@#1,#2,#3:#4,#5,#6\pgfplots@EOI#7{%
+ \def\Ax{#1}%
+ \def\Ay{#2}%
+ \def\Az{#3}%
+ \def\Bx{#4}%
+ \def\By{#5}%
+ \def\Bz{#6}%
+ %
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Ax}{\Bx}}\let\Cx=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Ay}{\By}}\let\Cy=\pgfmathresult
+ \pgfplotscoordmath{#7}{op}{multiply}{{\Az}{\Bz}}\let\Cz=\pgfmathresult
+ %
+ \edef\pgfplotsretval{\Cx,\Cy,\Cz}%
+}%
+
+% #1 a vector as x,y,z
+% #2 the math format of its components
+\def\pgfplotspointfromcsvvector#1#2{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotspointfromcsvvector@\pgfplots@loc@TMPa\pgfplots@EOI{#2}
+ \endgroup
+}%
+\def\pgfplotspointfromcsvvector@#1,#2,#3\pgfplots@EOI#4{%
+ \pgfplotscoordmath{#4}{tofixed}{#1}\let\Ax=\pgfmathresult
+ \pgfplotscoordmath{#4}{tofixed}{#2}\let\Ay=\pgfmathresult
+ \pgfplotscoordmath{#4}{tofixed}{#3}\let\Az=\pgfmathresult
+ \pgfplotsqpointxyz\Ax\Ay\Az
+ \pgf@process{}%
+}%
+
+% #1 a vector as (x,y,z)
+% #2 a coordmath value
+% defines \pgfplotsretval to contain the vector length
+\def\pgfplotsmathvectorlength#1#2{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotsmathvectorlength@\pgfplots@loc@TMPa\pgfplots@EOI{#2}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsmathvectorlength@#1,#2,#3\pgfplots@EOI#4{%
+ \begingroup
+ \def\Ax{#1}%
+ \def\Ay{#2}%
+ \def\Az{#3}%
+ %
+ \pgfplotscoordmath{#4}{op}{multiply}{{\Ax}{\Ax}}\let\Axx=\pgfmathresult
+ \pgfplotscoordmath{#4}{op}{multiply}{{\Ay}{\Ay}}\let\Ayy=\pgfmathresult
+ \pgfplotscoordmath{#4}{op}{multiply}{{\Az}{\Az}}\let\Azz=\pgfmathresult
+ %
+ \pgfplotscoordmath{#4}{op}{add}{{\Axx}{\Ayy}}%
+ \pgfplotscoordmath{#4}{op}{add}{{\Azz}{\pgfmathresult}}%
+ \pgfplotscoordmath{#4}{op}{sqrt}{{\pgfmathresult}}%
+ \let\pgfplotsretval=\pgfmathresult
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% #1 a vector as (x,y,z)
+% #2 a scale
+% #3 a coordmath value
+% defines \pgfplotsretval to contain the scaled vector
+\def\pgfplotsmathvectorscale#1#2#3{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1:#2}%
+ \expandafter\pgfplotsmathvectorscale@\pgfplots@loc@TMPa\pgfplots@EOI{#3}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsmathvectorscale@#1,#2,#3:#4\pgfplots@EOI#5{%
+ \begingroup
+ \def\Ax{#1}%
+ \def\Ay{#2}%
+ \def\Az{#3}%
+ \pgfplotscoordmath{#5}{parsenumber}{#4}\let\S\pgfmathresult
+ %
+ \pgfplotscoordmath{#5}{op}{multiply}{{\Ax}{\S}}\let\Ax=\pgfmathresult
+ \pgfplotscoordmath{#5}{op}{multiply}{{\Ay}{\S}}\let\Ay=\pgfmathresult
+ \pgfplotscoordmath{#5}{op}{multiply}{{\Az}{\S}}\let\Az=\pgfmathresult
+ %
+ \edef\pgfplotsretval{\Ax,\Ay,\Az}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+% Takes an input vector #1 = x,y,z and applies the inverse data scale
+% trafo.
+%
+% The result is \pgfplotsretval; it will be in '#2' coordmath for
+% every component.
+\def\pgfplotsmathvectordatascaletrafoinverse#1#2{%
+ \begingroup
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfplotsmathvectordatascaletrafoinverse@\pgfplots@loc@TMPa\pgfplots@EOI{#2}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}
+\def\pgfplotsmathvectordatascaletrafoinverse@#1,#2,#3\pgfplots@EOI#4{%
+ \begingroup
+ \def\Ax{#1}%
+ \def\Ay{#2}%
+ \def\Az{#3}%
+ \ifpgfplots@apply@datatrafo@x
+ \pgfplotscoordmath{x}{datascaletrafo inverse}{\Ax}\let\Ax=\pgfmathresult
+ \fi
+ \ifpgfplots@apply@datatrafo@y
+ \pgfplotscoordmath{y}{datascaletrafo inverse}{\Ay}\let\Ay=\pgfmathresult
+ \fi
+ \ifpgfplots@curplot@threedim
+ \ifpgfplots@apply@datatrafo@z
+ \pgfplotscoordmath{z}{datascaletrafo inverse}{\Az}\let\Az=\pgfmathresult
+ \fi
+ \fi
+ \pgfplotsmathvectorfromstring{\Ax,\Ay,\Az}{#4}%
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+
+
+{
+\catcode`\"=12
+\gdef\pgfplotsDQ{"}%
+\catcode`\|=12
+\gdef\pgfplotsVERTBAR{|}%
+\catcode`\#=12
+\gdef\pgfplotsHASH{#}%
+\catcode`\%=12 \gdef\pgfplotsPERCENT{%}}
+
+% swaps the content of two macros
+\def\pgfplotsutil@swap#1#2{%
+ \let\pgfplotsutil@swap@=#1%
+ \let#1=#2%
+ \let#2=\pgfplotsutil@swap@
+}%
+
+\def\pgfplots@boolval#1{%
+ \pgfplots@if{#1}{true}{false}%
+}%
+
+\input pgfplotsliststructure.code.tex
+\input pgfplotsliststructureext.code.tex
+\input pgfplotsarray.code.tex
+\input pgfplotsmatrix.code.tex
+\input pgfplotstableshared.code.tex
+\input pgfplotsdeque.code.tex
+\input pgfplotsbinary.code.tex
+\input pgfplotsutil.verb.code.tex
+
+\usepgfplotslibrary{surfshading}
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.lua b/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.lua
new file mode 100644
index 0000000000..40ac83bb38
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.lua
@@ -0,0 +1,139 @@
+local math=math
+local string=string
+local type=type
+local tostring = tostring
+local tonumber = tonumber
+local setmetatable = setmetatable
+local getmetatable = getmetatable
+local print=print
+local pairs = pairs
+local table=table
+local texio=texio
+
+do
+local _ENV = pgfplots
+---------------------------------------
+--
+
+log=texio.write_nl
+
+local stringfind = string.find
+local stringsub = string.sub
+local tableinsert = table.insert
+
+-- Splits 'str' at delimiter and returns a table of strings
+function stringsplit( str, delimiter )
+ if not str or not delimiter then error("arguments must not be nil") end
+ local result = { }
+ local start = 1
+ local findStart, findEnd = stringfind( str, delimiter, start )
+ while findStart do
+ tableinsert( result, stringsub( str, start, findStart-1 ) )
+ start = findEnd + 1
+ findStart, findEnd = stringfind( str, delimiter, start )
+ end
+ tableinsert( result, stringsub( str, start ) )
+ return result
+end
+
+function stringOrDefault(str, default)
+ if str == nil or type(str) == 'string' and string.len(str) == 0 then
+ return default
+ end
+ return tostring(str)
+end
+
+
+pgfplotsmath = {}
+
+function pgfplotsmath.isfinite(x)
+ if pgfplotsmath.isnan(x) or x == pgfplotsmath.infty or x == -pgfplotsmath.infty then
+ return false
+ end
+ return true
+end
+
+local isnan = function(x)
+ return x ~= x
+end
+
+pgfplotsmath.isnan = isnan
+
+local infty = 1/0
+pgfplotsmath.infty = infty
+
+local nan = math.sqrt(-1)
+pgfplotsmath.nan = nan
+
+---------------------------------------
+--
+
+
+-- Creates and returns a new class object.
+--
+-- Usage:
+-- complexclass = newClass()
+-- function complexclass:constructor()
+-- self.re = 0
+-- self.im = 0
+-- end
+--
+-- instance = complexclass.new()
+--
+function newClass()
+ local result = {}
+
+ -- we need this such that *instances* (which will have 'result' as meta table)
+ -- will "inherit" the class'es methods.
+ result.__index = result
+ local allocator= function (...)
+ local self = setmetatable({}, result)
+ self:constructor(...)
+ return self
+ end
+ result.new = allocator
+ return result
+end
+
+
+
+-- Create a new class that inherits from a base class
+--
+-- base = pgfplots.newClass()
+-- function base:constructor()
+-- self.variable= 'a'
+-- end
+--
+-- sub = pgfplots.newClassExtends(base)
+-- function sub:constructor()
+-- -- call super constructor.
+-- -- it is ABSOLUTELY CRUCIAL to use <baseclass>.constructor here - not :constructor!
+-- base.constructor(self)
+-- end
+--
+-- instance = base.new()
+--
+-- instance2 = sub.new()
+--
+-- @see newClass
+function newClassExtends( baseClass )
+ if not baseClass then error "baseClass must not be nil" end
+
+ local new_class = newClass()
+
+ -- The following is the key to implementing inheritance:
+
+ -- The __index member of the new class's metatable references the
+ -- base class. This implies that all methods of the base class will
+ -- be exposed to the sub-class, and that the sub-class can override
+ -- any of these methods.
+ --
+ local mt = {} -- getmetatable(new_class)
+ mt.__index = baseClass
+ setmetatable(new_class,mt)
+
+ return new_class
+end
+
+
+end
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.verb.code.tex b/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.verb.code.tex
new file mode 100644
index 0000000000..8590ba908d
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfplotsutil.verb.code.tex
@@ -0,0 +1,97 @@
+%--------------------------------------------
+%
+% Package pgfplots
+%
+% Copyright 2007-2011 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 source file contains helper utilities for verbatim character
+% processing.
+
+
+%
+% USAGE:
+% \beginpgfplotsverbatim[result/.code={\message{I read #1}}]
+% <verbatim code>
+% \endpgfplotsverbatim
+%
+% The verbatim code MUST start at the line after the ']' (or after
+% \beginpgfplotsverbatim if there is no ']')
+\def\beginpgfplotsverbatim{\pgfutil@ifnextchar[{\beginpgfplotsverbatim@}{\beginpgfplotsverbatim@[]}}
+\def\beginpgfplotsverbatim@[#1]{%
+ \begingroup
+ \pgfqkeys{/pgfplots/verb}{#1}%
+ \pgfplots@verbatim@prepare@collect
+ \beginpgfplotsverbatim@gobbleuntileol
+}
+
+\begingroup
+\catcode`\|=0
+\catcode`\\=12
+|gdef|endpgfplotsverbatim{\endpgfplotsverbatim}%
+|endgroup
+
+\expandafter\long\expandafter\def\expandafter\pgfplots@verbatim@collect@until\expandafter#\expandafter1\endpgfplotsverbatim{%
+ \begingroup
+ \pgfplots@verbatim@newline@handler
+ \xdef\pgfplots@glob@TMPa{#1}%
+ \endgroup
+ \pgfkeysgetvalue{/pgfplots/verb/result/.@cmd}\pgfplots@loc@TMPb
+ \global\let\pgfplots@glob@TMPb=\pgfplots@loc@TMPb
+ \endgroup% restore old catcodes etc.
+ \expandafter\pgfplots@glob@TMPb\expandafter{\pgfplots@glob@TMPa}\pgfeov%
+}%
+
+\begingroup
+\long\def\pgfplots@loc@TMPa{
+}%^^M}%
+\catcode`\^^M=13 %
+\gdef\beginpgfplotsverbatim@gobbleuntileol^^M{\pgfplots@verbatim@collect@until}%
+\gdef\pgfplots@verbatim@newline@toHATHATJ{\def^^M{^^J}}%
+\xdef\pgfplots@verbatim@newline@IDENTITY{\noexpand\long\noexpand\def\noexpand^^M{\pgfplots@loc@TMPa}}%
+\endgroup
+
+\pgfkeys{
+ /pgfplots/verb/result/.code={%
+ \pgfplots@error{Please use \string\beginpgfplotsverbatim[result/.code=....] to configure what to do with the content of \string\beginpgfplotsverbatim...\endpgfplotsverbatim\space (or use \string\pgfplotsset{verb/.cd,result/.code=....} in your preamble)}%
+ },
+ /pgfplots/verb/newline handler/.is choice,
+ /pgfplots/verb/newline handler/to outfile/.code=
+ {\let\pgfplots@verbatim@newline@handler=\pgfplots@verbatim@newline@toHATHATJ},
+ /pgfplots/verb/newline handler/identity/.code=
+ {\let\pgfplots@verbatim@newline@handler=\pgfplots@verbatim@newline@IDENTITY},
+ /pgfplots/verb/newline handler/identity,
+}
+
+\def\pgfplots@verbatim@prepare@collect{%
+ \def\do##1{\catcode`##1=12 }\dospecials
+ \catcode`\^^M=13
+ \catcode`\^^J=12
+ \catcode`\^^I=12
+}%
+
+\def\pgfplots@verbatim@restore@catcodes{%
+ \catcode`\^^M=5
+ \catcode`\^^J=10
+ \catcode`\^^I=10
+ % this is important to get \scantokens to work: otherwise, it will
+ % eat up the ^^M chars:
+ \endlinechar=`\^^M
+ \newlinechar=\endlinechar
+}%
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfregressiontest.sty b/graphics/pgf/contrib/pgfplots/tex/pgfregressiontest.sty
new file mode 100644
index 0000000000..a6ed64ffbc
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfregressiontest.sty
@@ -0,0 +1,159 @@
+%--------------------------------------------------
+% Provides a feature for fully automated regression testing of PGF or derived works.
+%
+% DEPRECATED.
+% The idea might be interesting, but it is simply did not work and is
+% too complicated. Don't use it.
+%
+% Idea:
+% - it is based on the 'external' lib of pgf (which automatically exports each tikzpicture to pdf).
+% - modification: in addition to the pdf export, call imagemagick's convert
+% tool to export to png as well and compare the png to a reference image.
+% - pgfregressiontest.sty provides two modes:
+% 1) the REFERENCE GENERATION mode
+% - each image knows a reference revision tag (or the system default)
+% - the 'system call' makes a "checkout" of the desired revision,
+% generates the image and returns to the original revision
+% - the images are stored with a unique prefix.
+% 2) the COMPARISON mode
+% - each tikzpicture is compared to its reference image. If there
+% is none, it should be generated.
+% - if the comparison fails, a protocol is generated and the user
+% is alerted.
+
+%--------------------------------------------------
+%
+\ProvidesPackage{pgfregressiontest}[2010/10/31 Version 0.1]
+
+\RequirePackage{tikz}
+\usetikzlibrary{external}
+
+\def\pgfregression@invokecmdkey#1#2{%
+ \pgfkeysvalueof{/pgf/regression/#1/.@cmd}#2\pgfeov
+}%
+
+\newif\ifpgfregressionpreamble
+\pgfregressionpreambletrue
+
+\def\pgfregressiontestset{\pgfqkeys{/pgf/regression}}%
+
+\pgfqkeys{/pgf/regression}{%
+ % will be set in \begin{document}
+ system call original/.initial=<not yet set>,
+ %
+ % 'rev checkout' can be used to manually change the environment
+ % state before actually generating the image.
+ % Example:
+ % 'rev checkout=cd ~/code/tex/pgfplots ; git checkout 1.3'
+ % or something like this.
+ %
+ % Use 'rev restore' to immediately undo the effects. All that
+ % stuff is executed in one shell environment, i.e. you can define
+ % and use shell variables.
+ rev checkout/.code=\def\pgfregression@revcheckout{#1},
+ rev checkout={},
+ rev restore/.code=\def\pgfregression@revrestore{#1},
+ rev restore={},
+ reference prefix/.initial=reference_images/,
+ protocol file/.initial=\jobname.protocol.sh,
+ convert to png/.initial={convert "\image.pdf" "\image.png"},%
+ reference mode/.code={
+ \def\pgfregr@replacement@syscall{%
+ \ifx\pgfregression@revcheckout\pgfutil@empty
+ \else
+ \pgfregression@revcheckout;^^J%
+ @echo "'rev checkout' was successful, generating pdf...";^^J%
+ \fi
+ mkdir -p \pgfkeysvalueof{/pgf/regression/reference prefix};^^J%
+ \pgfkeysvalueof{/pgf/regression/system call original}; EXITCODE=$$?; \\^^J%
+ \ifx\pgfregression@revrestore\pgfutil@empty
+ \else
+ \pgfregression@revrestore; \\^^J%
+ echo "'rev restore' was successful.";^^J%
+ \fi
+ @if [ "$$EXITCODE" != "0" ]; then echo "pdf generation failed; Abort"; false; fi;^^J%
+ \pgfkeysvalueof{/pgf/regression/convert to png};^^J%
+ }%
+ \def\pgfregr@style{%
+ \message{^^Jpgfregressiontest: Running in REFERENCE GENERATION mode.^^J}%
+ \pgfqkeys{/pgf/regression}{%
+ /tikz/external/prefix=\pgfkeysvalueof{/pgf/regression/reference prefix},
+ }%
+ }%
+ \ifpgfregressionpreamble
+ \else
+ \pgfkeyslet{/tikz/external/system call}\pgfregr@replacement@syscall
+ \pgfregr@style
+ \fi
+ },
+ comparison mode/.code={
+ \def\pgfregr@replacement@syscall{%
+ \pgfkeysvalueof{/pgf/regression/system call original};^^J%
+ \pgfkeysvalueof{/pgf/regression/convert to png};^^J%
+ diff "\image.png" "\expandafter\expandafter\expandafter\pgfregr@get@reference@image@for\image\relax.png";^^J%
+ if [ ! $? -eq 0 ]; then ^^J
+ echo 'echo "file \image.pdf differs from \expandafter\expandafter\expandafter\pgfregr@get@reference@image@for\image\relax.pdf (displaying differences now)".' >> \pgfkeysvalueof{/pgf/regression/protocol file};^^J
+ echo 'convert "\image.png" "\expandafter\expandafter\expandafter\pgfregr@get@reference@image@for\image\relax.png" -compose difference -composite -colorspace gray miff:- | display' >>\pgfkeysvalueof{/pgf/regression/protocol file};^^J%
+ else^^J
+ rm -f "\image.png";^^J%
+ fi;^^J%
+ }%
+ \def\pgfregr@style{%
+ \message{^^Jpgfregressiontest: Running in COMPARISON mode.^^J}%
+ \expandafter\def\expandafter\pgfregr@get@reference@image@for\tikzexternal@filenameprefix####1\relax{%
+ \pgfkeysvalueof{/pgf/regression/reference prefix}####1%
+ }%
+ }%
+ \ifpgfregressionpreamble
+ \else
+ \pgfkeyslet{/tikz/external/system call}\pgfregr@replacement@syscall
+ \pgfregr@style
+ \fi
+ },
+ comparison mode,
+}
+
+% Check for "command line arguments".
+% if 'pdflatex '\def\referencemode{1}\input{filename}' has been used,
+% the 'reference mode' will be enabled. Otherwise we are in
+% 'comparison mode'.
+\expandafter\ifx\csname referencemode\endcsname\relax
+ \pgfregressiontestset{comparison mode}%
+ \message{^^Jpgfregressiontest: use pdflatex '\string\def\string\referencemode{1}\string\input{\jobname}' to enable reference generation.^^J}%
+\else
+ \pgfregressiontestset{reference mode}%
+\fi
+
+
+\AtBeginDocument{%
+ \tikzifexternalizehasbeencalled{}{%
+ \PackageError{pgfregressiontest}{%
+ Please call \string\tikzexternalize\space somewhere in your preamble. I can only perform my tests together with image externalization}{}%
+ }%
+ \pgfkeysgetvalue{/tikz/external/system call}\pgfregression@temp
+ \pgfkeyslet{/pgf/regression/system call original}\pgfregression@temp
+ %
+ \pgfkeyslet{/tikz/external/system call}\pgfregr@replacement@syscall
+ \pgfregr@style
+ %
+ \immediate\openout\w@pgf@writea=\pgfkeysvalueof{/pgf/regression/protocol file} %
+ \immediate\closeout\w@pgf@writea
+ %
+ \global\pgfregressionpreamblefalse
+}
+
+\AtEndDocument{%
+ \openin\r@pgf@reada=\pgfkeysvalueof{/pgf/regression/protocol file} %
+ \ifeof\r@pgf@reada
+ \else
+ \message{
+ ^^J%
+ ======================================^^J%
+ There have been regression errors.^^J%
+ Use^^J%
+ >> bash \pgfkeysvalueof{/pgf/regression/protocol file}^^J%
+ to visualize them.^^J%
+ ======================================^^J%
+ }%
+ \fi
+}%
diff --git a/graphics/pgf/contrib/pgfplots/tex/pgfsys-luatexpatch.def b/graphics/pgf/contrib/pgfplots/tex/pgfsys-luatexpatch.def
new file mode 100644
index 0000000000..6865ae1556
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/pgfsys-luatexpatch.def
@@ -0,0 +1,441 @@
+% This file has been shipped with pgfplots in order to fix incompatibilities with the new luatex. The next version of PGF will include the "correct" file.
+%
+%
+
+\ifnum\luatexversion<95
+ \immediate\write-1{luatex driver of PGF: detected lua version \the\luatexversion; falling back to old pdftex driver^^J}%
+ \input pgfsys-pdftex.def
+ \expandafter\endinput
+\fi
+
+% Copyright 2006 by Till Tantau
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+%\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/systemlayer/pgfsys-luatex.def,v 1.35 2014/10/11 09:23:31 vibrovski Exp $
+
+
+% Driver commands for pdf
+
+%
+% Load common pdf commands:
+%
+\input pgfsys-common-pdf.def
+
+%
+% pdftex-specific stuff:
+%
+\def\pgfsys@invoke#1{\pdfextension literal{#1}}
+
+% Synced hboxes
+\def\pgfsys@hboxsynced#1{%
+ {%
+ \pgfsys@beginscope%
+ \setbox\pgf@hbox=\hbox{%
+ \hskip\pgf@pt@x%
+ \raise\pgf@pt@y\hbox{%
+ \pgf@pt@x=0pt%
+ \pgf@pt@y=0pt%
+ \pgflowlevelsynccm%
+ \pgfsys@hbox#1}%
+ \hss%
+ }%
+ \wd\pgf@hbox=0pt%
+ \ht\pgf@hbox=0pt%
+ \dp\pgf@hbox=0pt%
+ \box\pgf@hbox%
+ \pgfsys@endscope%
+ }%
+}
+
+
+
+\def\pgfsys@imagesuffixlist{.pdf:.jpg:.jpeg:.png:}
+\def\pgfsys@defineimage{% width, height, page number
+ \ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{ width \pgf@imagewidth }\fi%
+ \ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{ height \pgf@imageheight }\fi%
+ \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{ page \pgf@imagepage }\fi%
+ \ifx\saveimageresource\@undefined% old version of lualatex
+ \ifx\pgf@imagepage\pgfutil@empty\else%
+ \pgfwarning{Page selection not supported. Ignoring page selection}%
+ \fi%
+ \setbox\pgfutil@tempboxa=\hbox{%
+ \pdfimage \pgf@imageheight \pgf@imagewidth {\pgf@filename}}%
+ \pdfform\pgfutil@tempboxa%
+ \edef\pgf@image{\noexpand\pdfrefform\the\pdflastform}%
+ \else% new version
+ {\saveimageresource \pgf@imageheight \pgf@imagewidth attr
+ {/Interpolate \pgf@imageinterpolate\space\pgf@imagemask} \pgf@imagepage
+ {\pgf@filename}}%
+ \edef\pgf@image{\noexpand\useimageresource\the\lastsavedimageresourceindex}%
+ \fi
+}%
+\def\pgfsys@definemask#1{%
+ \ifx\pgf@maskmatte\pgfutil@empty%
+ \else%
+ \edef\pgf@maskmatte{/Matte [\pgf@maskmatte]}%
+ \fi%
+ \edef\pgf@attr{{\pgf@maskmatte\space /Decode [1 0]}}%
+ \immediate\saveimageresource attr \pgf@attr {\pgf@filename}%
+ \edef\pgf@mask{/SMask \the\lastsavedimageresourceindex\space 0 R}%
+}
+\def\pgfsys@horishading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathparse{#2}%
+ \setbox\pgfutil@tempboxa=\hbox to\pgf@max{\vbox to\pgfmathresult pt{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{\pgfpoint{\pgf@max}{#2}}%
+ \immediate\saveboxresource resources {%
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace /DeviceRGB
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@doma\space0 \pgf@domb\space0]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >>}\pgfutil@tempboxa% <<
+ \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}%
+ }%
+}
+\def\pgfsys@vertshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathparse{#2}%
+ \setbox\pgfutil@tempboxa=\hbox to\pgfmathresult pt{\vbox to\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{\pgfpoint{#2}{\pgf@max}}%
+ \immediate\saveboxresource resources {%
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace /DeviceRGB
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [0 \pgf@doma\space0 \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >>}\pgfutil@tempboxa% <<
+ \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}%
+ }%
+}
+\def\pgfsys@radialshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \setbox\pgfutil@tempboxa=\hbox to2\pgf@max{\vbox to2\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
+ \advance\pgf@xa by \pgf@x%
+ \advance\pgf@ya by \pgf@y%
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \immediate\saveboxresource resources {%
+ /Shading << /Sh << /ShadingType 3
+ /ColorSpace /DeviceRGB
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [true false] >> >>}\pgfutil@tempboxa% <<
+ \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}%
+ }%
+}%
+\def\pgfsys@functionalshading#1#2#3#4{%
+ {%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{#3}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \setbox\pgfutil@tempboxa=\hbox to\pgf@x{\vbox to\pgf@y{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgf@sys@bp@correct{\pgf@xb}%
+ \pgf@sys@bp@correct{\pgf@yb}%
+ \pgf@xc=-\pgf@xa%
+ \pgf@yc=-\pgf@ya%
+ % Now build the function
+ \pdfextension obj
+ stream
+ attr
+ {
+ /FunctionType 4
+ /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}]
+ /Range [0 1 0 1 0 1]
+ }
+ {{#4}}%
+ \edef\pgf@temp@num{\the\numexpr\pdffeedback lastobj\relax}%
+ \saveboxresource resources {%
+ /Shading << /Sh << /ShadingType 1
+ /ColorSpace /DeviceRGB
+ /Matrix [1 0 0 1 \pgf@sys@tonumber{\pgf@xc}\space\pgf@sys@tonumber{\pgf@yc}]
+ /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}]
+ /Function \pgf@temp@num\space 0 R
+ >> >>}\pgfutil@tempboxa% <<
+ \expandafter\xdef\csname @pgfshading#1!\endcsname{%
+ \leavevmode%
+ \noexpand\useboxresource\the\lastsavedboxresourceindex%
+ \noexpand\pdfextension refobj \pgf@temp@num%
+ }%
+ }%
+}
+
+
+
+% Patterns
+
+\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{%
+ % Start building the pattern dictionary:
+ \pgf@xa=#2\relax%
+ \pgf@ya=#3\relax%
+ \pgf@xb=#4\relax%
+ \pgf@yb=#5\relax%
+ \pgf@xc=#6\relax%
+ \pgf@yc=#7\relax%
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgf@sys@bp@correct\pgf@ya%
+ \pgf@sys@bp@correct\pgf@xb%
+ \pgf@sys@bp@correct\pgf@yb%
+ \pgf@sys@bp@correct\pgf@xc%
+ \pgf@sys@bp@correct\pgf@yc%
+ % Now create the pattern object:
+ \immediate\pdfextension obj stream
+ attr
+ {
+ /Type /Pattern
+ /PatternType 1
+ /PaintType \ifnum#9=0 2 \else 1 \fi
+ /TilingType 1
+ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb]
+ /XStep \pgf@sys@tonumber\pgf@xc\space
+ /YStep \pgf@sys@tonumber\pgf@yc\space
+ /Resources << >> %<<
+ }
+ {#8}%
+ \pgfutil@addpdfresource@patterns{/pgfpat#1\space \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
+}
+
+\def\pgfsys@setpatternuncolored#1#2#3#4{%
+ \pgfsysprotocol@literal{/pgfprgb cs #2 #3 #4 /pgfpat#1\space scn}%
+}
+
+\def\pgfsys@setpatterncolored#1{%
+ \pgfsysprotocol@literal{/Pattern cs /pgfpat#1\space scn}%
+}
+
+% System layer for meta patterns
+% Takes 15(!) arguments
+% #1 pattern name
+% #2 #3 bounding box lower left
+% #4 #5 bounding box upper right
+% #6 #7 tile size
+% #8 #9 #10 #11 #12 #13 transformation matrix
+% #14 protocoled text
+% #15 pattern type
+\def\pgfsys@declarepattern@meta#1#2#3#4#5#6#7{%
+ % Start building the pattern dictionary:
+ \pgf@xa=#2\relax%
+ \pgf@ya=#3\relax%
+ \pgf@xb=#4\relax%
+ \pgf@yb=#5\relax%
+ \pgf@xc=#6\relax%
+ \pgf@yc=#7\relax%
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgf@sys@bp@correct\pgf@ya%
+ \pgf@sys@bp@correct\pgf@xb%
+ \pgf@sys@bp@correct\pgf@yb%
+ \pgf@sys@bp@correct\pgf@xc%
+ \pgf@sys@bp@correct\pgf@yc%
+ \pgfsys@@declarepattern@meta{#1}}
+
+\def\pgfsys@@declarepattern@meta#1#2#3#4#5#6#7#8#9{%
+ \pgfutil@tempdima=#6\relax%
+ \pgfutil@tempdimb=#7\relax%
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgf@sys@bp@correct\pgf@ya%
+ % Now create the pattern object:
+ \immediate\pdfextension obj stream
+ attr
+ {
+ /Type /Pattern
+ /PatternType 1
+ /PaintType \ifnum#9=0 2 \else 1 \fi
+ /TilingType 1
+ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb]
+ /XStep \pgf@sys@tonumber\pgf@xc\space
+ /YStep \pgf@sys@tonumber\pgf@yc\space
+ /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb]
+ /Resources << >> %<<
+ }
+ {#8}%
+ \pgfutil@addpdfresource@patterns{/pgfpat#1\space \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
+ }
+
+
+
+\def\pgfsys@papersize#1#2{\pageheight#2\relax\pagewidth#1\relax}
+
+\def\pgfsys@global@papersize#1#2{\global\pageheight#2\relax\global\pagewidth#1\relax}
+
+\ifx\paperheight\@undefined
+ \def\pgfsys@thepageheight{\pageheight}
+ \def\pgfsys@thepagewidth{\pagewidth}
+\fi
+
+
+%
+% Position tracking
+%
+\def\pgfsys@markposition#1{%
+ \savepos%
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutil@writetoaux\expandafter{%
+ \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\lastxpos}{\the\lastypos}}%
+}
+
+\def\pgfsyspdfmark#1#2#3{%
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}%
+ \pgfutil@check@rerun{#1}{{#2}{#3}}%
+}
+
+\def\pgfsys@getposition#1#2{%
+ \edef\pgf@marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@#1\endcsname}%
+ \pgf@marshal%
+}
+
+\def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfqpoint{\hoffset}{\voffset}}
+
+
+%
+% Opacity masks
+%
+\def\pgfsys@fadingfrombox#1#2{%
+ {%
+ \pgf@sys@pdf@check@resources%
+ \pgf@x=-.5\wd#2%
+ \pgf@y=-.5\ht#2%
+ \advance\pgf@y by.5\dp#2%
+ \expandafter\xdef\csname pgfsmasktrans@#1\endcsname{%
+ \noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+ \saveboxresource resources { \pgf@sys@pdf@possible@resources } #2%
+ \expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\lastsavedboxresourceindex}%
+ }%
+}
+\def\pgfsys@usefading#1#2#3#4#5#6#7{%
+ \expandafter\ifx\csname pgfsmaskxform@#1\endcsname\relax%
+ \pgferror{Undefined fading '#1'}%
+ \else%
+ {%
+ \expandafter\ifx\csname pgfsmaks@#1\endcsname\relax%
+ \pgf@sys@pdf@install@mask{#1}%
+ \fi%
+ \pgftransformreset%
+ \pgftransformcm{#2}{#3}{#4}{#5}{\pgfpoint{#6}{#7}}%
+ \csname pgfsmasktrans@#1\endcsname%
+ {%
+ \pgflowlevelsynccm%
+ \pgfsys@invoke{/pgfsmask\csname pgfsmask@#1\endcsname\space gs}%
+ }%
+ \pgftransforminvert%
+ \pgflowlevelsynccm%
+ }%
+ \fi
+}
+
+\def\pgf@sys@pdf@install@mask#1{%
+ \setbox\pgfutil@tempboxa=\hbox{\useboxresource\csname pgfsmaskxform@#1\endcsname}
+ \immediate\saveboxresource%
+ attr {
+ /Group
+ <<
+ /S /Transparency
+ /CS /DeviceGray
+ >>
+ }% <<
+ \pgfutil@tempboxa%
+ \pgfutil@addpdfresource@extgs{%
+ /pgfsmask\the\lastsavedboxresourceindex\space
+ <<
+ /SMask
+ <<
+ /S /Luminosity
+ /G \the\lastsavedboxresourceindex\space 0 R
+ >>
+ >> } %<<
+ \expandafter\xdef\csname pgfsmask@#1\endcsname{\the\lastsavedboxresourceindex}%
+}
+
+%
+% Transparency groups
+%
+\def\pgfsys@transparencygroupfrombox#1{%
+ \pgf@sys@pdf@check@resources%
+ \saveboxresource
+ attr { /Group << /S /Transparency
+ /I \ifpgfsys@transparency@group@isolated true \else false \fi
+ /K \ifpgfsys@transparency@group@knockout true \else false \fi >> } %<<
+ resources { \pgf@sys@pdf@possible@resources }
+ #1%
+ \setbox#1=\hbox{\useboxresource\lastsavedboxresourceindex}%
+}
+
+
+
+
+%
+% Resource management
+%
+
+\def\pgf@sys@setuppdfresources@plain{%
+ % This command will setup pdf resource in plain and in latex
+ % mode. ConTeXt has its own handler
+ % Page resources (they are kept in objects and only written at the
+ % very end)
+ \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@extgs@objnum{\the\numexpr\pdffeedback lastobj\relax}
+ \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@pattern@objnum{\the\numexpr\pdffeedback lastobj\relax}
+ \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@colrospaces@objnum{\the\numexpr\pdffeedback lastobj\relax}
+ \def\pgf@sys@pdf@possible@resources{%
+ /ColorSpace \pgf@sys@pdf@colrospaces@objnum\space 0 R
+ /Pattern \pgf@sys@pdf@pattern@objnum\space 0 R
+ /ExtGState \pgf@sys@pdf@extgs@objnum\space 0 R
+ }
+ \let\pgf@sys@pdf@check@resources=\relax%
+ \def\pgf@sys@pdf@install@pageresources{
+ {
+ \edef\temp{
+ \pgf@sys@pdf@possible@resources
+ }
+ \expandafter\global\expandafter\pdfvariable pageresources\expandafter{\temp}
+ }
+ }
+ \pgf@sys@pdf@install@pageresources
+ \expandafter\pgfutil@everybye\expandafter{%
+ \the\pgfutil@everybye%
+ \immediate \pdfextension obj useobjnum \pgf@sys@pdf@extgs@objnum {<<\pgf@sys@pgf@resource@list@extgs>>}%<<
+ \immediate \pdfextension obj useobjnum \pgf@sys@pdf@pattern@objnum {<<\pgf@sys@pgf@resource@list@patterns>>}%<<
+ \immediate \pdfextension obj useobjnum \pgf@sys@pdf@colrospaces@objnum {<<\pgf@sys@pgf@resource@list@colorspaces>>}%<<
+ }
+ \let\pgf@sys@pgf@resource@list@extgs=\pgfutil@empty%
+ \let\pgf@sys@pgf@resource@list@patterns=\pgfutil@empty%
+ \let\pgf@sys@pgf@resource@list@colorspaces=\pgfutil@empty%
+ \def\pgf@sys@addpdfresource@extgs@plain##1{\xdef\pgf@sys@pgf@resource@list@extgs{\pgf@sys@pgf@resource@list@extgs\space##1}}
+ \def\pgf@sys@addpdfresource@patterns@plain##1{\xdef\pgf@sys@pgf@resource@list@patterns{\pgf@sys@pgf@resource@list@patterns\space##1}}
+ \def\pgf@sys@addpdfresource@colorspaces@plain##1{\xdef\pgf@sys@pgf@resource@list@colorspaces{\pgf@sys@pgf@resource@list@colorspaces\space##1}}
+}
+\pgfutil@setuppdfresources % possibly call the above
+
+\pgfutil@addpdfresource@colorspaces{ /pgfprgb [/Pattern /DeviceRGB] }
+
+\def\pgfsys@color@unstacked#1{%
+ \pdfextension literal{\csname\string\color@#1\endcsname}%
+}
+
+\endinput
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/contrib/pgfplots/tex/plothandler.lua b/graphics/pgf/contrib/pgfplots/tex/plothandler.lua
new file mode 100644
index 0000000000..59dfbb2c77
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/plothandler.lua
@@ -0,0 +1,998 @@
+--
+-- This file contains parts of pgfplotscoordprocessing.code.tex and pgfplotsplothandlers.code.tex .
+--
+-- It contains
+--
+-- pgfplots.Axis
+-- pgfplots.Coord
+-- pgfplots.Plothandler
+--
+-- and some related classes.
+
+local math=math
+local pgfplotsmath = pgfplots.pgfplotsmath
+local type=type
+local tostring=tostring
+local error=error
+local table=table
+
+do
+-- all globals will be read from/defined in pgfplots:
+local _ENV = pgfplots
+-----------------------------------
+
+local pgftonumber =pgfluamathfunctions.tonumber
+
+Coord = newClass()
+
+function Coord:constructor()
+ self.x = { nil, nil, nil }
+ self.unboundedDir = nil
+ self.meta= nil
+ self.metatransformed = nil -- assigned during vis phase only
+ self.unfiltered = nil
+ self.pgfXY = nil -- assigned during visphase only
+ return self
+end
+
+function Coord:copy(other)
+ for i = 1,#other.x do self.x[i] = other.x[i] end
+ self.meta = other.meta
+ self.metatransformed = other.metatransformed
+ self.unfiltered = nil -- not needed
+end
+
+function Coord:__tostring()
+ local result = '(' .. stringOrDefault(self.x[1], "--") ..
+ ',' .. stringOrDefault(self.x[2], "--") ..
+ ',' .. stringOrDefault(self.x[3], "--") ..
+ ') [' .. stringOrDefault(self.meta, "--") .. ']'
+
+ if not self.x[1] and self.unfiltered then
+ result = result .. "(was " .. tostring(self.unfiltered) .. ")"
+ end
+ return result
+end
+
+-- a reference to a Coord which is returned by math expressions involving 'x', 'y', or 'z'
+-- see surveystart()
+local pseudoconstant_pt = nil
+local function pseudoconstant_x() return pseudoconstant_pt.x[1] end
+local function pseudoconstant_y() return pseudoconstant_pt.x[2] end
+local function pseudoconstant_z() return pseudoconstant_pt.x[3] end
+local function pseudoconstant_rawx() return pgftonumber(pseudoconstant_pt.unfiltered.x[1]) end
+local function pseudoconstant_rawy() return pgftonumber(pseudoconstant_pt.unfiltered.x[2]) end
+local function pseudoconstant_rawz() return pgftonumber(pseudoconstant_pt.unfiltered.x[3]) end
+local function pseudoconstant_meta() return pseudoconstant_pt.meta end
+
+-- @return the old value
+local function updatePseudoConstants(pt)
+ local old = pseudoconstant_pt
+ pseudoconstant_pt = pt
+ return old
+end
+
+-------------------------------------------------------
+
+LinearMap = newClass()
+
+-- A map such that
+-- [inMin,inMax] is mapped linearly to [outMin,outMax]
+--
+function LinearMap:constructor(inMin, inMax, outMin, outMax)
+ if not inMin or not inMax or not outMin or not outMax then error("arguments must not be nil") end
+ if inMin == inMax then
+ self.map = function (x) return inMin end
+ else
+ if inMin > inMax then error("linear map received invalid input domain " .. tostring(inMin) .. ":" .. tostring(inMax)) end
+ self.offset = outMin - (outMax-outMin)*inMin/(inMax-inMin)
+ self.scale = (outMax-outMin)/(inMax-inMin)
+ end
+end
+
+function LinearMap:map(x)
+ return x*self.scale + self.offset
+end
+
+PointMetaMap = newClass()
+
+function PointMetaMap:constructor(inMin,inMax, warnForfilterDiscards)
+ if not inMin or not inMax or warnForfilterDiscards == nil then error("arguments must not be nil") end
+ self._mapper = LinearMap.new(inMin,inMax, 0, 1000)
+ self.warnForfilterDiscards = warnForfilterDiscards
+end
+
+function PointMetaMap:map(meta)
+ if pgfplotsmath.isfinite(meta) then
+ local result = self._mapper:map(meta)
+ result = math.max(0, result)
+ result = math.min(1000, result)
+ return result
+ else
+ if self.warnForfilterDiscards then
+ log("The per point meta data '" .. tostring(meta) .. " (and probably others as well) is unbounded - using the minimum value instead.\n")
+ self.warnForfilterDiscards=false
+ end
+ return 0
+ end
+end
+
+
+
+-------------------------------------------------------
+
+-- Abstract base class of all plot handlers.
+-- It offers basic functionality for the survey phase.
+Plothandler = newClass()
+
+-- @param name the plot handler's name (a string)
+-- @param axis the parent axis
+-- @param pointmetainputhandler an instance of PointMetaHandler or nil if there is none
+function Plothandler:constructor(name, axis, pointmetainputhandler)
+ if not name or not axis then
+ error("arguments must not be nil")
+ end
+ self.axis = axis
+ self.config = PlothandlerConfig.new()
+ self.name = name
+ self.coordindex = 0
+ self.metamin = math.huge
+ self.metamax = -math.huge
+ self.autocomputeMetaMin = true
+ self.autocomputeMetaMax = true
+ self.coords = {}
+ self.pointmetainputhandler = pointmetainputhandler
+ self.pointmetamap = nil -- will be set later
+ self.filteredCoordsAway = false
+ self.plotHasJumps = false
+ self.hasUnboundedPointMeta = false
+ -- will be set before the visualization phase starts. At least.
+ self.plotIs3d = false
+
+ -- do not use the global one. It may be outdated.
+ self.stringToFunctionMap = pgfluamathfunctions.stringToFunctionMap
+
+ return self
+end
+
+function Plothandler:__tostring()
+ return 'plot handler ' .. self.name
+end
+
+-- @see \pgfplotsplothandlersurveybeforesetpointmeta
+function Plothandler:surveyBeforeSetPointMeta()
+end
+
+-- @see \pgfplotsplothandlersurveyaftersetpointmeta
+function Plothandler:surveyAfterSetPointMeta()
+end
+
+-- PRIVATE
+--
+-- appends a fully surveyed point
+function Plothandler:addSurveyedPoint(pt)
+ table.insert(self.coords, pt)
+ -- log("addSurveyedPoint(" .. tostring(pt) .. ") ...\n")
+end
+
+
+-- PRIVATE
+--
+-- assigns the point meta value by means of the PointMetaHandler
+function Plothandler:setperpointmeta(pt)
+ if pt.meta == nil and self.pointmetainputhandler ~= nil then
+ self.pointmetainputhandler:assign(pt)
+ end
+end
+
+-- PRIVATE
+--
+-- updates point meta limits
+function Plothandler:setperpointmetalimits(pt)
+ if self.pointmetainputhandler ~= nil and self.pointmetainputhandler:isPointMetaBounded(pt.meta) then
+ if not type(pt.meta) == 'number' then error("got unparsed input "..tostring(pt)) end
+ if self.autocomputeMetaMin then
+ self.metamin = math.min(self.metamin, pt.meta )
+ end
+
+ if self.autocomputeMetaMax then
+ self.metamax = math.max(self.metamax, pt.meta )
+ end
+ else
+ -- FIXME : the TeX code also checks for 'bounded point meta' if there is no point meta input!?
+ self.hasUnboundedPointMeta = true
+ end
+end
+
+-- @see \pgfplotsplothandlersurveystart
+function Plothandler:surveystart()
+ self.stringToFunctionMap["x"] = pseudoconstant_x
+ self.stringToFunctionMap["y"] = pseudoconstant_y
+ self.stringToFunctionMap["z"] = pseudoconstant_z
+ self.stringToFunctionMap["rawx"] = pseudoconstant_rawx
+ self.stringToFunctionMap["rawy"] = pseudoconstant_rawy
+ self.stringToFunctionMap["rawz"] = pseudoconstant_rawz
+ self.stringToFunctionMap["meta"] = pseudoconstant_meta
+end
+
+-- @see \pgfplotsplothandlersurveyend
+-- returns executable TeX code to communicate return values.
+function Plothandler:surveyend()
+ -- empty by default.
+ return ""
+end
+
+-- @see \pgfplotsplothandlersurveypoint
+function Plothandler:surveypoint(pt)
+ updatePseudoConstants(nil)
+
+ local updateLimits = self.config.updateLimits
+ local current = self.axis:parsecoordinate(pt, self.config.filterExpressionByDir)
+
+ -- this here defines the math functions for x, y, or z.
+ -- FIXME: are there any hidden callers which rely on these constants in parsecoordinate!?
+ updatePseudoConstants(current)
+
+ if current.x[1] ~= nil then
+ current = self.axis:preparecoordinate(current)
+ if updateLimits then
+ self.axis:updatelimitsforcoordinate(current)
+ end
+ end
+ self.axis:datapointsurveyed(current, self)
+
+ self.coordindex = self.coordindex + 1;
+end
+
+-- PUBLIC
+--
+-- @return a string containing all surveyed coordinates in the format which is accepted \pgfplotsaxisdeserializedatapointfrom
+function Plothandler:surveyedCoordsToPgfplots(axis)
+ return self:getCoordsInTeXFormat(axis, self.coords)
+end
+
+-- PUBLIC
+--
+-- @return a string containing all coordinates in the format which is accepted \pgfplotsaxisdeserializedatapointfrom
+-- @param extraSerializer a function which takes an instance of Coord and returns a string. can be nil.
+function Plothandler:getCoordsInTeXFormat(axis, coords, extraSerializer)
+ if not axis then error("arguments must not be nil") end
+ local result = {}
+ for i = 1,#coords,1 do
+ local pt = coords[i]
+ local ptstr = self:serializeCoordToPgfplots(pt)
+ local axisPrivate = axis:serializeCoordToPgfplotsPrivate(pt)
+ if extraSerializer then
+ axisPrivate = extraSerializer(pt) .. "{" .. axisPrivate .. "}"
+ end
+ local serialized = "{" .. axisPrivate .. ";" .. ptstr .. "}"
+ table.insert(result, serialized)
+ end
+ return table.concat(result)
+end
+
+-- PRIVATE
+--
+-- does the same as \pgfplotsplothandlerserializepointto
+function Plothandler:serializeCoordToPgfplots(pt)
+ return
+ toTeXstring(pt.x[1]) .. "," ..
+ toTeXstring(pt.x[2]) .. "," ..
+ toTeXstring(pt.x[3])
+end
+
+function Plothandler:visualizationPhaseInit()
+ if self.pointmetainputhandler ~=nil then
+ local rangeMin
+ local rangeMax
+ if self.config.pointmetarel == PointMetaRel.axiswide then
+ rangeMin = self.axis.axiswidemetamin
+ rangeMax = self.axis.axiswidemetamax
+ else
+ rangeMin = self.metamin
+ rangeMax = self.metamax
+ end
+ self.pointmetamap = PointMetaMap.new(rangeMin, rangeMax, self.config.warnForfilterDiscards)
+ end
+end
+
+-- PRECONDITION: visualizationPhaseInit() has been called some time before.
+function Plothandler:visualizationTransformMeta(meta)
+ if meta == nil then
+ log("could not access the 'point meta' (used for example by scatter plots and color maps). Maybe you need to add '\\addplot[point meta=y]' or something like that?\n")
+ return 1
+ else
+ return self.pointmetamap:map(meta)
+ end
+end
+
+-- Modifies coords inplace.
+-- @return nothing.
+-- see \pgfplots@apply@zbuffer@sort@coordinates
+function Plothandler:sortCoordinatesByViewDepth()
+ local coords = self.coords
+
+ local axis = self.axis
+ local viewdir = axis.viewdir
+
+ -- Step 1: compute view depth for every coordinate
+ local getVertexDepth = axis.getVertexDepth
+ for i=1,#coords do
+ local vertexDepth = getVertexDepth(axis,coords[i])
+ coords[i].vertexDepth = vertexDepth
+ end
+
+ -- Step 2: sort (inplace)
+ local comparator = function(ptA, ptB)
+ return ptA.vertexDepth > ptB.vertexDepth
+ end
+ table.sort(coords, comparator)
+
+ -- Step 3: cleanup: do not leave 'vertexDepth' inside of the array
+ for i=1,#coords do
+ coords[i].vertexDepth = nil
+ end
+end
+
+-------------------------------------------------------
+-- Generic plot handler: one which has the default survey phase
+-- It is actually the same as Plothandler...
+
+GenericPlothandler = newClassExtends(Plothandler)
+
+function GenericPlothandler:constructor(name, axis, pointmetainputhandler)
+ Plothandler.constructor(self,name, axis, pointmetainputhandler)
+end
+
+
+-------------------------------------------------------
+
+UnboundedCoords = { discard="d", jump="j" }
+
+PointMetaRel = { axiswide = 0, perplot =1 }
+
+
+-- contains static configuration entities.
+PlothandlerConfig = newClass()
+
+function PlothandlerConfig:constructor()
+ self.unboundedCoords = UnboundedCoords.discard
+ self.warnForfilterDiscards=true
+ self.pointmetarel = PointMetaRel.axiswide
+ self.updateLimits = true
+ self.filterExpressionByDir = {"", "", ""}
+ return self
+end
+
+-------------------------------------------------------
+-- a PlotVisualizer takes an input Plothandler and visualizes its results.
+--
+-- "Visualize" can mean
+-- * apply the plot handler's default visualization phase
+-- * visualize just plot marks at each of the collected coordinates
+-- * visualize just error bars at each collected coordinate
+-- * ...
+--
+
+-- this class offers basic visualization support. "Basic" means that it will merely transform and finalize input coordinates.
+PlotVisualizer = newClass()
+-- @param sourcePlotHandler an instance of Plothandler
+function PlotVisualizer:constructor(sourcePlotHandler)
+ if not sourcePlotHandler then error("arguments must not be nil") end
+ self.axis = sourcePlotHandler.axis
+ self.sourcePlotHandler=sourcePlotHandler
+ if sourcePlotHandler.plotIs3d then
+ self.qpointxyz = self.axis.qpointxyz
+ else
+ self.qpointxyz = self.axis.qpointxy
+ end
+end
+
+-- Visualizes the results.
+--
+-- @return any results. The format of the results is currently a list of Coord, but I am unsure of whether it will stay this way.
+--
+-- Note that a PlotVisualizer does _not_ modify self.sourcePlotHandler.coords
+function PlotVisualizer:getVisualizationOutput()
+ local result = {}
+ local coords = self.sourcePlotHandler.coords
+
+ -- standard z buffer choices (not mesh + sort) is currently handled in TeX
+ -- as well as other preparations
+
+ -- FIXME : stacked plots?
+ -- FIXME : error bars?
+
+ for i = 1,#coords do
+ local result_i
+ local result_i = Coord.new()
+ result_i:copy(coords[i])
+
+ if result_i.x[1] ~= nil then
+ self:visphasegetpoint(result_i)
+ else
+ self:notifyJump(result_i)
+ end
+
+ result[i] = result_i
+ end
+
+ return result
+end
+
+-- PROTECTED
+-- resembles \pgfplotsplothandlervisualizejump -- or at least that part which can be done in LUA.
+-- It does not visualize anything, but it can be used to modify the coordinate
+function PlotVisualizer:notifyJump(pt)
+ -- do nothing.
+end
+
+function PlotVisualizer:visphasegetpoint(pt)
+ pt.untransformed = {}
+ for j = 1,#pt.x do
+ pt.untransformed[j] = pt.x[j]
+ end
+
+ self.axis:visphasetransformcoordinate(pt)
+
+ -- FIXME : prepare data point (only for stacked)
+
+ pt.pgfXY = self.qpointxyz(pt.x)
+end
+
+
+
+-------------------------------------------------------
+
+-- An abstract base class for a handler of point meta.
+-- @see \pgfplotsdeclarepointmetasource
+PointMetaHandler = newClass()
+
+-- @param isSymbolic
+-- expands to either '1' or '0'
+-- A numeric source will be processed numerically in float
+-- arithmetics. Thus, the output of the @assign routine should be
+-- a macro \pgfplots@current@point@meta in float format.
+--
+-- The output of a numeric point meta source will result in meta
+-- limit updates and the final map to [0,1000] will be
+-- initialised automatically.
+--
+-- A symbolic input routine won't be processed.
+-- Default is '0'
+--
+-- @param explicitInput
+-- 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'
+--
+function PointMetaHandler:constructor(isSymbolic, explicitInput)
+ self.isSymbolic =isSymbolic
+ self.explicitInput = explicitInput
+ return self
+end
+
+-- During the survey phase, this macro is expected to assign
+-- \pgfplots@current@point@meta
+-- 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 the issymbolic boolean is true)
+-- The default implementation is
+-- \let\pgfplots@current@point@meta=\pgfutil@empty
+--
+function PointMetaHandler.assign(pt)
+ error("This instance of PointMetaHandler is not implemented")
+end
+
+-- see \pgfplotsifpointmetaisbounded
+function PointMetaHandler:isPointMetaBounded(meta)
+ if meta == nil then
+ return false
+ end
+
+ if self.isSymbolic then
+ if meta == "" then
+ return false
+ else
+ return true
+ end
+
+ else
+ -- check the number:
+ return pgfplotsmath.isfinite(meta)
+ end
+end
+
+
+-- A PointMetaHandler which merely acquires values of either x,y, or z.
+CoordAssignmentPointMetaHandler = newClassExtends( PointMetaHandler )
+function CoordAssignmentPointMetaHandler:constructor(dir)
+ PointMetaHandler.constructor(self, false,false)
+ if not dir then error "nil argument for 'dir' is unsupported." end
+ self.dir=dir
+end
+
+function CoordAssignmentPointMetaHandler:assign(pt)
+ if not pt then error("arguments must not be nil") end
+ pt.meta = pgftonumber(pt.x[self.dir])
+end
+
+XcoordAssignmentPointMetaHandler = CoordAssignmentPointMetaHandler.new(1)
+YcoordAssignmentPointMetaHandler = CoordAssignmentPointMetaHandler.new(2)
+ZcoordAssignmentPointMetaHandler = CoordAssignmentPointMetaHandler.new(3)
+
+-- A class of PointMetaHandler which takes the 'Coord.meta' as input
+ExplicitPointMetaHandler = newClassExtends( PointMetaHandler )
+function ExplicitPointMetaHandler:constructor()
+ PointMetaHandler.constructor(self, false,true)
+end
+
+function ExplicitPointMetaHandler:assign(pt)
+ if pt.unfiltered ~= nil and pt.unfiltered.meta ~= nil then
+ pt.meta = pgftonumber(pt.unfiltered.meta)
+ end
+end
+
+-- a point meta handler which evaluates a math expression.
+-- ATTENTION: the expression cannot depend on TeX macro values
+ExpressionPointMetaHandler = newClassExtends( PointMetaHandler )
+
+-- @param expression an expression. It can rely on functions which are only available in plot context (in plot expression, x and y are typically defined)
+function ExpressionPointMetaHandler:constructor(expression)
+ PointMetaHandler.constructor(self, false,false)
+ self.expression = expression
+end
+
+function ExpressionPointMetaHandler:assign(pt)
+ pt.meta = pgfluamathparser.pgfmathparse(self.expression)
+ if not pt.meta then
+ error("point meta=" .. self.expression .. ": expression has been rejected.")
+ end
+end
+
+
+-------------------------------------------------------
+
+DatascaleTrafo = newClass()
+
+function DatascaleTrafo:constructor(exponent, shift)
+ self.exponent=exponent
+ self.shift=shift
+ self.scale = math.pow(10, exponent)
+end
+
+function DatascaleTrafo:map(x)
+ return self.scale * x - self.shift
+end
+
+
+-------------------------------------------------------
+
+-- An axis.
+Axis = newClass()
+
+function Axis:constructor()
+ self.is3d = false
+ self.clipLimits = { true, true, true}
+ self.autocomputeAllLimits = true -- FIXME : redundant!?
+ self.autocomputeMin = { true, true, true }
+ self.autocomputeMax = { true, true, true }
+ self.isLinear = { true, true, true }
+ self.min = { math.huge, math.huge, math.huge }
+ self.max = { -math.huge, -math.huge, -math.huge }
+ self.datamin = { math.huge, math.huge, math.huge }
+ self.datamax = { -math.huge, -math.huge, -math.huge }
+ self.axiswidemetamin = { math.huge, math.huge }
+ self.axiswidemetamax = { -math.huge, -math.huge }
+ -- will be populated by the TeX code:
+ self.plothandlers = {}
+ -- needed during visualization phase:
+ self.datascaleTrafo={}
+ -- needed during visualization phase: a vector of 3 elements, each is a vector of 2 elements.
+ -- self.unitvectors[1] is (\pgf@xx,\pgf@xy)
+ self.unitvectors={}
+ -- needed during visualization phase -- but only for 3d!
+ self.viewdir = {}
+ return self
+end
+
+function Axis:getVertexDepth(pt)
+ local vertexDepth = 0
+ local vertex = pt.x
+ local viewdir = self.viewdir
+ if vertex[1] == nil then
+ -- an empty coordinate. Get rid of it.
+ return 0
+ end
+
+ if #vertex ~=3 then
+ error("Cannot compute vertex depth of " .. tostring(pt) .. ": expected a 3d point but got " .. tostring(#vertex))
+ end
+ if not viewdir or #viewdir~=3 then error("got unexpected view dir " ..tostring(viewdir) ) end
+
+ for k = 1,3 do
+ local component = vertex[k]
+ vertexDepth = vertexDepth + component*viewdir[k]
+ end
+
+ return vertexDepth
+end
+
+function Axis:setunitvectors(unitvectors)
+ if not unitvectors or #unitvectors ~= 3 then error("got illegal arguments " .. tostring(unitvectors)) end
+ self.unitvectors = unitvectors
+
+ local pgfxx = unitvectors[1][1]
+ local pgfxy = unitvectors[1][2]
+ local pgfyx = unitvectors[2][1]
+ local pgfyy = unitvectors[2][2]
+ local pgfzx = unitvectors[3][1]
+ local pgfzy = unitvectors[3][2]
+
+ self.qpointxyz = function(xyz)
+ local result = {}
+ result[1] = xyz[1] * pgfxx + xyz[2] * pgfyx + xyz[3] * pgfzx
+ result[2] = xyz[1] * pgfxy + xyz[2] * pgfyy + xyz[3] * pgfzy
+ return result
+ end
+
+ if pgfxy==0 and pgfyx ==0 then
+ self.qpointxy = function(xy)
+ local result = {}
+ result[1] = xy[1] * pgfxx
+ result[2] = xy[2] * pgfyy
+ return result
+ end
+ else
+ self.qpointxy = function(xyz)
+ local result = {}
+ result[1] = xyz[1] * pgfxx + xyz[2] * pgfyx
+ result[2] = xyz[1] * pgfxy + xyz[2] * pgfyy
+ return result
+ end
+ end
+end
+
+-- PRIVATE
+--
+-- applies user transformations and logs
+--
+-- @see \pgfplots@prepared@xcoord
+function Axis:preparecoord(dir, value)
+ -- FIXME : user trafos, logs (switches off LUA backend)
+ return value
+end
+
+function Axis:filtercoord(dir, ptCoords, filterExpressionByDir)
+ if not dir or not ptCoords or not filterExpressionByDir then error("Arguments must not be nil") end
+ local result = ptCoords.x[dir]
+ if filterExpressionByDir[dir]:len() > 0 then
+
+ for j = 1,#ptCoords.x do
+ ptCoords.x[j] = pgftonumber(ptCoords.x[j])
+ end
+ local old = updatePseudoConstants(ptCoords)
+
+ result = pgfluamathparser.pgfmathparse(filterExpressionByDir[dir])
+
+ updatePseudoConstants(old)
+ end
+ return result
+end
+
+-- PRIVATE
+-- @see \pgfplotsaxisserializedatapoint@private
+function Axis:serializeCoordToPgfplotsPrivate(pt)
+ return toTeXstring(pt.meta)
+end
+
+
+-- PRIVATE
+--
+function Axis:validatecoord(dir, point)
+ if not dir or not point then error("arguments must not be nil") end
+ local result = pgftonumber(point.x[dir])
+
+ if result == nil then
+ result = nil
+ elseif result == pgfplotsmath.infty or result == -pgfplotsmath.infty or pgfplotsmath.isnan(result) then
+ result = nil
+ point.unboundedDir = dir
+ end
+
+ point.x[dir] = result
+end
+
+-- PRIVATE
+--
+-- @see \pgfplotsaxisparsecoordinate
+function Axis:parsecoordinate(pt, filterExpressionByDir)
+ -- replace empty strings by 'nil':
+ for i = 1,3 do
+ pt.x[i] = stringOrDefault(pt.x[i], nil)
+ end
+ pt.meta = stringOrDefault(pt.meta)
+
+ if pt.x[3] ~= nil then
+ self.is3d = true
+ end
+
+ local result = Coord.new()
+
+ local unfiltered = Coord.new()
+ unfiltered.x = {}
+ unfiltered.meta = pt.meta
+ for i = 1,3 do
+ unfiltered.x[i] = pt.x[i]
+ end
+ result.unfiltered = unfiltered
+
+ -- copy values such that filtercoord can access them in the same order as the TeX impl.
+ for i = 1,self:loopMax() do
+ result.x[i] = pt.x[i]
+ end
+
+ -- FIXME : self:prefilter(pt[i])
+ for i = 1,self:loopMax() do
+ result.x[i] = self:preparecoord(i, pt.x[i])
+ result.x[i] = self:filtercoord(i, result, filterExpressionByDir)
+ end
+ -- FIXME : result.x = self:xyzfilter(result.x)
+
+ for i = 1,self:loopMax() do
+ self:validatecoord(i, result)
+ end
+
+ local resultIsBounded = true
+ for i = 1,self:loopMax() do
+ if result.x[i] == nil then
+ resultIsBounded = false
+ end
+ end
+
+ if not resultIsBounded then
+ result.x = { nil, nil, nil}
+ end
+
+ return result
+end
+
+-- PROTECTED
+--
+-- @see \pgfplotsaxispreparecoordinate
+function Axis:preparecoordinate(pt)
+ -- the default "preparation" is to return it as is (no number parsing)
+ --
+ -- FIXME : data cs! Stacking!
+ return pt
+end
+
+-- PRIVATE
+--
+-- returns either 2 if this axis is 2d or 3 otherwise
+--
+-- FIXME : shouldn't this depend on the current plot handler!?
+function Axis:loopMax()
+ if self.is3d then return 3 else return 2 end
+end
+
+-- PRIVATE:
+--
+-- updates axis limits for pt
+-- @param pt an instance of Coord
+function Axis:updatelimitsforcoordinate(pt)
+ local isClipped = false
+ for i = 1,self:loopMax(),1 do
+ if self.clipLimits[i] then
+ if not self.autocomputeMin[i] then
+ isClipped = isClipped or pt.x[i] < self.min[i]
+ end
+ if not self.autocomputeMax[i] then
+ isClipped = isClipped or pt.x[i] > self.max[i]
+ end
+ end
+ end
+
+ if not isClipped then
+ for i = 1,self:loopMax(),1 do
+ if self.autocomputeMin[i] then
+ self.min[i] = math.min(pt.x[i], self.min[i])
+ end
+
+ if self.autocomputeMax[i] then
+ self.max[i] = math.max(pt.x[i], self.max[i])
+ end
+ end
+ end
+
+ -- Compute data range:
+ if self.autocomputeAllLimits then
+ -- the data range will be acquired simply from the axis
+ -- range, see below!
+ else
+ for i = 1,self:loopMax(),1 do
+ self.datamin[i] = math.min(pt.x[i], self.min[i])
+ self.datamax[i] = math.max(pt.x[i], self.max[i])
+ end
+ end
+end
+
+-- PRIVATE
+--
+-- unfinished, see its fixmes
+function Axis:addVisualizationDependencies(pt)
+ -- FIXME : 'visualization depends on'
+ -- FIXME : 'execute for finished point'
+ return pt
+end
+
+-- PROTECTED
+--
+-- indicates that a data point has been surveyed by the axis and that it can be consumed
+function Axis:datapointsurveyed(pt, plothandler)
+ if not pt or not plothandler then error("arguments must not be nil") end
+ if pt.x[1] ~= nil then
+ plothandler:surveyBeforeSetPointMeta()
+ plothandler:setperpointmeta(pt)
+ plothandler:setperpointmetalimits(pt)
+ plothandler:surveyAfterSetPointMeta()
+
+ -- FIXME : error bars
+ -- FIXME: collect first plot as tick
+
+ -- note that that TeX code would also remember the first/last coordinate in a stream.
+ -- This is unnecessary here.
+
+ local serialized = self:addVisualizationDependencies(pt)
+ plothandler:addSurveyedPoint(serialized)
+ else
+ -- COORDINATE HAS BEEN FILTERED AWAY
+ if plothandler.config.unboundedCoords == UnboundedCoords.discard then
+ plothandler.filteredCoordsAway = true
+ if plothandler.config.warnForfilterDiscards then
+ local reason
+ if pt.unboundedDir == nil then
+ reason = "of a coordinate filter."
+ else
+ reason = "it is unbounding (in " .. tostring(pt.unboundedDir) .. ")."
+ end
+ log("NOTE: coordinate " .. tostring(pt) .. " has been dropped because " .. reason .. "\n")
+ end
+ elseif plothandler.config.unboundedCoords == UnboundedCoords.jump then
+ if pt.unboundedDir == nil then
+ plothandler.filteredCoordsAway = true
+ if plothandler.config.warnForfilterDiscards then
+ local reason = "of a coordinate filter."
+ log("NOTE: coordinate " .. tostring(pt) .. " has been dropped because " .. reason .. "\n")
+ end
+ else
+ self:addSurveyedJump(plothandler, pt)
+ end
+ end
+ end
+
+ -- note that the TeX variant would increase the coord index here.
+ -- We do it it surveypoint.
+end
+
+function Axis:addSurveyedJump(plothandler, pt)
+ plothandler.plotHasJumps = true
+
+ local serialized = self:addVisualizationDependencies(pt)
+ plothandler:addSurveyedPoint(serialized)
+end
+
+local function axisLimitToTeXString(name, value)
+ if value == math.huge or value == -math.huge then
+ return ""
+ end
+ return "\\gdef" .. name .. "{" .. toTeXstring(value) .. "}"
+end
+
+local function toTeXxyzCoord(namePrefix, pt )
+ local x = toTeXstring(pt.x[1])
+ local y = toTeXstring(pt.x[2])
+ local z = toTeXstring(pt.x[3])
+ return
+ "\\gdef" .. namePrefix .. "@x{" .. x .. "}" ..
+ "\\gdef" .. namePrefix .. "@y{" .. y .. "}" ..
+ "\\gdef" .. namePrefix .. "@z{" .. z .. "}";
+end
+
+local function findFirstValidCoord(coords)
+ for i=1,#coords do
+ local pt = coords[i]
+ if pt.x[1] ~=nil then
+ return pt
+ end
+ end
+ return nil
+end
+
+local function findLastValidCoord(coords)
+ for i=#coords,1,-1 do
+ local pt = coords[i]
+ if pt.x[1] ~=nil then
+ return pt
+ end
+ end
+ return nil
+end
+
+-- PUBLIC
+--
+-- @return a set of (private) key-value pairs such that the TeX code of pgfplots can
+-- access survey results of the provided plot handler
+--
+-- @param plothandler an instance of Plothandler
+function Axis:surveyToPgfplots(plothandler)
+ local plothandlerResult = plothandler:surveyend()
+ local firstCoord = findFirstValidCoord(plothandler.coords) or Coord.new()
+ local lastCoord = findLastValidCoord(plothandler.coords) or Coord.new()
+
+ local result =
+ plothandlerResult ..
+ toTeXxyzCoord("\\pgfplots@currentplot@firstcoord", firstCoord) ..
+ toTeXxyzCoord("\\pgfplots@currentplot@lastcoord", lastCoord) ..
+ axisLimitToTeXString("\\pgfplots@metamin", plothandler.metamin) ..
+ axisLimitToTeXString("\\pgfplots@metamax", plothandler.metamax) ..
+ "\\c@pgfplots@coordindex=" .. tostring(plothandler.coordindex) .. " " ..
+ axisLimitToTeXString("\\pgfplots@xmin", self.min[1]) ..
+ axisLimitToTeXString("\\pgfplots@ymin", self.min[2]) ..
+ axisLimitToTeXString("\\pgfplots@xmax", self.max[1]) ..
+ axisLimitToTeXString("\\pgfplots@ymax", self.max[2]);
+ if self.is3d then
+ result = result ..
+ axisLimitToTeXString("\\pgfplots@zmin", self.min[3]) ..
+ axisLimitToTeXString("\\pgfplots@zmax", self.max[3]) ..
+ "\\global\\pgfplots@threedimtrue ";
+ end
+ if plothandler.plotHasJumps then
+ result = result ..
+ "\\def\\pgfplotsaxisplothasjumps{1}"
+ else
+ result = result ..
+ "\\def\\pgfplotsaxisplothasjumps{0}"
+ end
+ if plothandler.hasUnboundedPointMeta then
+ result = result ..
+ "\\def\\pgfplotsaxisplothasunboundedpointmeta{1}"
+ else
+ result = result ..
+ "\\def\\pgfplotsaxisplothasunboundedpointmeta{0}"
+ end
+ if plothandler.filteredCoordsAway then
+ result = result ..
+ "\\def\\pgfplotsaxisfilteredcoordsaway{1}"
+ else
+ result = result ..
+ "\\def\\pgfplotsaxisfilteredcoordsaway{0}"
+ end
+
+ return result
+end
+
+-- resembles \pgfplotsaxisvisphasetransformcoordinate
+function Axis:visphasetransformcoordinate(pt)
+ for i = 1,#pt.x do
+ pt.x[i] = self.datascaleTrafo[i]:map( pt.x[i] )
+ end
+end
+
+-- will be set by TeX code (in \begin{axis})
+gca = nil
+
+
+end
diff --git a/graphics/pgf/contrib/pgfplots/tex/statistics.lua b/graphics/pgf/contrib/pgfplots/tex/statistics.lua
new file mode 100644
index 0000000000..ff264858d0
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/statistics.lua
@@ -0,0 +1,400 @@
+-- This file has dependencies to BOTH, the TeX part of pgfplots and the LUA part.
+-- It is the only LUA component with this property.
+--
+-- Its purpose is to encapsulate the communication between TeX and LUA in a central LUA file
+
+local pgfplotsmath = pgfplots.pgfplotsmath
+local error=error
+local table=table
+local string=string
+local tostring=tostring
+local type=type
+local io=io
+local mathfloor=math.floor
+local mathceil=math.ceil
+local pgfmathparse = pgfplots.pgfluamathparser.pgfmathparse
+
+do
+-- all globals will be read from/defined in pgfplots:
+local _ENV = pgfplots
+
+local pgftonumber =pgfluamathfunctions.tonumber
+
+function texBoxPlotSurveyPoint(data)
+ gca.currentPlotHandler:semiSurveyedValue(data)
+end
+
+-------------------------------------------------------
+
+PercentileEstimator = newClass()
+
+function PercentileEstimator:constructor()
+end
+
+function PercentileEstimator:getIndex(data, i)
+ local idx = i
+ if idx < 1 then idx = 1 end
+ if idx > #data then idx = #data end
+
+ local result = data[idx]
+ if not result then
+ error("Box plot percentile estimator '" .. tostring(self) .." accessed illegal array index " .. tostring(idx) .. " in array of length " .. tostring(#data))
+ end
+ return result
+end
+
+
+-- @param percentile the requested percentile. Use 0.5 for the median, 0.25 for the first quartile, 0.95 for the 95% percentile etc.
+function PercentileEstimator:getValue(percentile, data)
+ error("Use implementation of PercentileEstimator, not interface")
+end
+
+-- LegacyPgfplotsPercentileEstimator is a minimally repaired percentile estimator as it has been shipped with pgfplots.10 .
+-- I decided to mark it as deprecated because it is non-standard and not comparable with other programs.
+LegacyPgfplotsPercentileEstimator = newClassExtends(PercentileEstimator)
+function LegacyPgfplotsPercentileEstimator:constructor()
+end
+function LegacyPgfplotsPercentileEstimator:__tostring()
+ return "estimator=legacy";
+end
+function LegacyPgfplotsPercentileEstimator:getValue(percentile, data)
+ if not percentile or not data then error("Arguments must not be nil") end
+ local numCoords = #data
+ local h = numCoords * percentile
+
+ local offset_low = mathfloor(h)
+ local isInt = ( h==offset_low )
+
+ local offset_high = offset_low+1
+
+ local x_low = self:getIndex(data, offset_low)
+ local x_up = self:getIndex(data, offset_high)
+ local res = x_low
+ if not isInt then
+ res = 0.5 * (res + x_up)
+ end
+ return res
+end
+
+-- LegacyBadPgfplotsPercentileEstimator is _the_ percentile estimator as it has been shipped with pgfplots 1.10.
+-- It has bugs and is non-standard. Don't use it.
+LegacyBadPgfplotsPercentileEstimator = newClassExtends(PercentileEstimator)
+function LegacyBadPgfplotsPercentileEstimator:constructor()
+end
+function LegacyBadPgfplotsPercentileEstimator:__tostring()
+ return "estimator=legacy*";
+end
+function LegacyBadPgfplotsPercentileEstimator:getValue(percentile, data)
+ if not percentile or not data then error("Arguments must not be nil") end
+ local numCoords = #data
+ local h = (numCoords-1) * percentile
+
+ local offset_low = mathfloor(h)
+ local isInt = ( h==offset_low )
+
+ local offset_high = offset_low+1
+
+ local x_low = self:getIndex(data, offset_low+1)
+ local x_up = self:getIndex(data, offset_high+1)
+ local res = x_low
+ if not isInt then
+ res = 0.5 * (res + x_up)
+ end
+ return res
+end
+----------------
+
+ParameterizedPercentileEstimator = newClassExtends(PercentileEstimator)
+
+function ParameterizedPercentileEstimator:__tostring()
+ return "estimator=" .. tostring(self.typeFlag) ;
+end
+
+function ParameterizedPercentileEstimator:constructor( typeFlag )
+ -- http://en.wikipedia.org/wiki/Quantile
+ self.typeFlag = typeFlag
+
+ local getIndex = self.getIndex
+
+ local stdLookup = function(data, h )
+ local h_low = mathfloor(h)
+ local x_low = getIndex(self, data, h_low )
+ local x_up = getIndex(self, data, h_low +1 )
+ return x_low + (h - h_low) * (x_up - x_low)
+ end
+
+ if typeFlag == 1 then
+ -- R1
+ self.getValue = function(self, percentile, data)
+ local h= #data * percentile
+ return getIndex(self, data, mathceil(h) )
+ end
+ elseif typeFlag == 2 then
+ -- R2
+ self.getValue = function(self, percentile, data)
+ local h= #data * percentile + 0.5
+ return 0.5*(getIndex(self, data, mathceil(h-0.5)) + getIndex(self, data, mathfloor(h+0.5) ) )
+ end
+ elseif typeFlag == 3 then
+ -- R3
+ self.getValue = function(self, percentile, data)
+ local h= #data * percentile
+ return getIndex(self, data, pgfluamathfunctions.round(h) )
+ end
+ elseif typeFlag == 4 then
+ -- R4
+ self.getValue = function(self, percentile, data)
+ local h= #data * percentile
+ return stdLookup(data,h)
+ end
+ elseif typeFlag == 5 then
+ -- R5
+ self.getValue = function(self, percentile, data)
+ local h= #data * percentile + 0.5
+ return stdLookup(data,h)
+ end
+ elseif typeFlag == 6 then
+ -- R6
+ self.getValue = function(self, percentile, data)
+ local h= (#data +1) * percentile
+ return stdLookup(data,h)
+ end
+ elseif typeFlag == 7 then
+ -- R7 (Excel)
+ self.getValue = function(self, percentile, data)
+ local h= (#data -1) * percentile + 1
+ return stdLookup(data,h)
+ end
+ elseif typeFlag == 8 then
+ -- R8
+ self.getValue = function(self, percentile, data)
+ local h= (#data + 1/3) * percentile + 1/3
+ return stdLookup(data,h)
+ end
+ elseif typeFlag == 9 then
+ -- R9
+ self.getValue = function(self, percentile, data)
+ local h= (#data + 1/4) * percentile + 3/8
+ return stdLookup(data,h)
+ end
+ else
+ error("Got unsupported type '" .. tostring(typeFlag) .. "'")
+ end
+end
+
+
+getPercentileEstimator = function(estimatorName)
+ if estimatorName == "legacy" then
+ return LegacyPgfplotsPercentileEstimator.new()
+ elseif estimatorName == "legacy*" then
+ return LegacyBadPgfplotsPercentileEstimator.new()
+ elseif estimatorName == "R1" then
+ return ParameterizedPercentileEstimator.new(1)
+ elseif estimatorName == "R2" then
+ return ParameterizedPercentileEstimator.new(2)
+ elseif estimatorName == "R3" then
+ return ParameterizedPercentileEstimator.new(3)
+ elseif estimatorName == "R4" then
+ return ParameterizedPercentileEstimator.new(4)
+ elseif estimatorName == "R5" then
+ return ParameterizedPercentileEstimator.new(5)
+ elseif estimatorName == "R6" then
+ return ParameterizedPercentileEstimator.new(6)
+ elseif estimatorName == "R7" then
+ return ParameterizedPercentileEstimator.new(7)
+ elseif estimatorName == "R8" then
+ return ParameterizedPercentileEstimator.new(8)
+ elseif estimatorName == "R9" then
+ return ParameterizedPercentileEstimator.new(9)
+ end
+
+ error("Unknown estimator '" .. tostring(estimatorName) .. "'")
+end
+
+BoxPlotRequest = newClass()
+
+-- @param lowerQuartialPercent: typically 0.25
+-- @param upperQuartialPercent: typically 0.75
+-- @param whiskerRange: typically 1.5
+-- @param estimator: an instance of PercentileEstimator
+-- @param morePercentiles: either nil or an array of percentiles to compute
+function BoxPlotRequest:constructor(lowerQuartialPercent, upperQuartialPercent, whiskerRange, estimator, morePercentiles)
+ if not lowerQuartialPercent or not upperQuartialPercent or not whiskerRange or not estimator then error("Arguments must not be nil") end
+ self.lowerQuartialPercent = pgftonumber(lowerQuartialPercent)
+ self.upperQuartialPercent = pgftonumber(upperQuartialPercent)
+ self.whiskerRange = pgftonumber(whiskerRange)
+ self.estimator = estimator
+ if not morePercentiles then
+ self.morePercentiles = {}
+ else
+ self.morePercentiles = morePercentiles
+ end
+end
+
+-------------------------------------------------------
+
+BoxPlotResponse = newClass()
+
+function BoxPlotResponse:constructor()
+ self.lowerWhisker = nil
+ self.lowerQuartile = nil
+ self.median = nil
+ self.upperQuartile = nil
+ self.upperWhisker = nil
+ self.average = nil
+ self.morePercentiles = {}
+ self.outliers = {}
+end
+
+-- @param boxPlotRequest an instance of BoxPlotRequest
+-- @param data an indexed array with float values
+-- @return an instance of BoxPlotResponse
+function boxPlotCompute(boxPlotRequest, data)
+ if not boxPlotRequest or not data then error("Arguments must not be nil") end
+
+ for i = 1,#data do
+ local data_i = data[i]
+ if data_i == nil or type(data_i) ~= "number" then
+ error("Illegal input array at index " .. tostring(i) .. ": " .. tostring(data_i))
+ end
+ end
+
+ table.sort(data)
+
+ local sum = 0
+ for i = 1,#data do
+ sum = sum + data[i]
+ end
+
+ local numCoords = #data
+
+ local lowerWhisker
+ local lowerQuartile = boxPlotRequest.estimator:getValue(boxPlotRequest.lowerQuartialPercent, data)
+ local median = boxPlotRequest.estimator:getValue(0.5, data)
+ local upperQuartile = boxPlotRequest.estimator:getValue(boxPlotRequest.upperQuartialPercent, data)
+
+ local morePercentileValues = {}
+ for i = 1,#boxPlotRequest.morePercentiles do
+ morePercentileValues[i] = boxPlotRequest.estimator:getValue(boxPlotRequest.morePercentiles[i], data)
+ end
+
+ local upperWhisker
+ local average = sum / numCoords
+
+ local whiskerRange = boxPlotRequest.whiskerRange
+ local whiskerWidth = whiskerRange*(upperQuartile - lowerQuartile)
+ local upperWhiskerValue = upperQuartile + whiskerWidth
+ local lowerWhiskerValue = lowerQuartile - whiskerWidth
+
+ local outliers = {}
+ for i = 1,numCoords do
+ local current = data[i]
+ if current < lowerWhiskerValue then
+ table.insert(outliers, current)
+ else
+ lowerWhisker = current
+ break
+ end
+ end
+
+ for i = numCoords,1,-1 do
+ local current = data[i]
+ if upperWhiskerValue < current then
+ table.insert(outliers, current)
+ else
+ upperWhisker = current
+ break
+ end
+ end
+
+ local result = BoxPlotResponse.new()
+ result.lowerWhisker = lowerWhisker
+ result.lowerQuartile = lowerQuartile
+ result.median = median
+ result.upperQuartile = upperQuartile
+ result.upperWhisker = upperWhisker
+ result.average = average
+ result.morePercentiles = morePercentileValues
+ result.outliers = outliers
+
+ return result
+end
+
+-------------------------------------------------------
+-- Replicates the survey phase of \pgfplotsplothandlerboxplot
+BoxPlotPlothandler = newClassExtends(Plothandler)
+
+-- drawDirection : either "x" or "y".
+function BoxPlotPlothandler:constructor(boxPlotRequest, drawDirection, drawPosition, axis, pointmetainputhandler)
+ if not boxPlotRequest or not drawDirection or not drawPosition then error("Arguments must not be nil") end
+ Plothandler.constructor(self,"boxplot", axis, pointmetainputhandler)
+ self.boxPlotRequest = boxPlotRequest
+
+ local function evaluateDrawPosition()
+ local result = pgfmathparse(drawPosition)
+ return result
+ end
+
+ if drawDirection == "x" then
+ self.boxplotsetxy = function (a,b) return a,evaluateDrawPosition() + b end
+ elseif drawDirection == "y" then
+ self.boxplotsetxy = function (a,b) return evaluateDrawPosition() + b,a end
+ else
+ error("Illegal argument drawDirection="..tostring(drawDirection) )
+ end
+end
+
+function BoxPlotPlothandler:surveystart()
+ self.boxplotInput = {}
+ self.boxplotSurveyMode = true
+end
+
+
+function BoxPlotPlothandler:surveyend()
+ self.boxplotSurveyMode = false
+
+ local computed = boxPlotCompute( self.boxPlotRequest, self.boxplotInput )
+
+ local texResult =
+ "\\pgfplotsplothandlersurveyend@boxplot@set{lower whisker}{" .. toTeXstring(computed.lowerWhisker) .. "}" ..
+ "\\pgfplotsplothandlersurveyend@boxplot@set{lower quartile}{" .. toTeXstring(computed.lowerQuartile) .. "}" ..
+ "\\pgfplotsplothandlersurveyend@boxplot@set{median}{" .. toTeXstring(computed.median) .. "}" ..
+ "\\pgfplotsplothandlersurveyend@boxplot@set{upper quartile}{" .. toTeXstring(computed.upperQuartile) .. "}" ..
+ "\\pgfplotsplothandlersurveyend@boxplot@set{upper whisker}{" .. toTeXstring(computed.upperWhisker) .. "}" ..
+ "\\pgfplotsplothandlersurveyend@boxplot@set{sample size}{" .. toTeXstring(# self.boxplotInput) .. "}"
+
+ self.boxplotInput = nil
+ Plothandler.surveystart(self)
+
+ local outliers = computed.outliers
+ for i =1,#outliers do
+ local outlier = outliers[i]
+ local pt = Coord.new()
+ -- this here resembles \pgfplotsplothandlersurveypoint@boxplot@prepared when it is invoked during boxplot:
+ local X,Y = self.boxplotsetxy(outlier, 0)
+ pt.x = { X, Y, nil }
+ Plothandler.surveypoint(self,pt)
+ end
+ Plothandler.surveyend(self)
+
+ return texResult
+end
+
+function BoxPlotPlothandler:semiSurveyedValue(data)
+ local result = pgftonumber(data)
+ if result then
+ table.insert( self.boxplotInput, result )
+ end
+end
+
+function BoxPlotPlothandler:surveypoint(pt)
+ if self.boxplotSurveyMode then
+ error("Unsupported Operation encountered: box plot survey in LUA are only in PARTIAL mode (i.e. only if almost all has been prepared in TeX. Use 'lua backend=false' to get around this.")
+ else
+ Plothandler.surveypoint(self,pt)
+ end
+end
+
+-------------------------------------------------------
+
+end
diff --git a/graphics/pgf/contrib/pgfplots/tex/streamer.lua b/graphics/pgf/contrib/pgfplots/tex/streamer.lua
new file mode 100644
index 0000000000..39baf5ceca
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/streamer.lua
@@ -0,0 +1,195 @@
+-- Contains coordinate streamers, i.e. classes which generate coordinates and stream them to some output stream
+
+local math=math
+local pgfplotsmath = pgfplots.pgfplotsmath
+local type=type
+local tostring=tostring
+local error=error
+local table=table
+
+do
+-- all globals will be read from/defined in pgfplots:
+local _ENV = pgfplots
+-----------------------------------
+
+CoordOutputStream = newClass()
+
+function CoordOutputStream:constructor()
+end
+
+-- @param pt an instance of Coord
+function CoordOutputStream:coord(pt)
+end
+
+-----------------------------------
+
+SurveyCoordOutputStream = newClassExtends(CoordOutputStream)
+
+function SurveyCoordOutputStream:constructor(targetPlothandler)
+ if not targetPlothandler then error("arguments must not be nil") end
+ self.plothandler= targetPlothandler
+end
+
+function SurveyCoordOutputStream:coord(pt)
+ self.plothandler:surveypoint(pt)
+end
+
+-------------
+-- This is a partial reimplementation of \addplot expression: it samples points -- but entirely in LUA. Only the results are serialized back to TeX.
+
+AddplotExpressionCoordinateGenerator = newClass()
+
+function AddplotExpressionCoordinateGenerator:constructor(coordoutputstream, expressionsByDimension, domainMin, domainMax, samples, variableNames)
+ if not coordoutputstream or not expressionsByDimension or not domainMin or not domainMax or not samples or not variableNames then error("arguments must not be nil") end
+ if #variableNames ~= 2 then error("Expected 2 variableNames") end
+ self.coordoutputstream = coordoutputstream
+ self.is3d = #expressionsByDimension == 3
+ self.expressions = expressionsByDimension
+ self.domainMin = domainMin
+ self.domainMax = domainMax
+ self.samples = samples
+ self.variableNames = variableNames
+
+ -- log("initialized " .. tostring(self) .. "\n")
+end
+
+-- @return true on success or false if the operation cannot be carried out.
+-- this method is a replicate of \pgfplots@addplotimpl@expression@@
+function AddplotExpressionCoordinateGenerator:generateCoords()
+ local stringToFunctionMap = pgfluamathfunctions.stringToFunctionMap
+ -- create a backup of the 'x' and 'y' math expressions which
+ -- have been defined in \pgfplots@coord@stream@start:
+ local old_global_function_x = stringToFunctionMap["x"]
+ local old_global_function_y = stringToFunctionMap["y"]
+
+ local coordoutputstream = self.coordoutputstream
+ local is3d = self.is3d
+ local expressions = self.expressions
+ local xExpr = expressions[1]
+ local yExpr = expressions[2]
+ local zExpr = expressions[3]
+
+ local domainMin = self.domainMin
+ local domainMax = self.domainMax
+ local samples = self.samples
+ local h = {}
+ for i = 1,#domainMin do
+ h[i] = (domainMax[i] - domainMin[i]) / (samples[i]-1)
+ end
+
+ local variableNames = self.variableNames
+
+ local x,y
+ local sampleLine = #samples==1
+
+ local function pseudoconstantx() return x end
+ local pseudoconstanty
+ if sampleLine then
+ if yExpr ~= variableNames[2] then
+ -- suppress the warning - we want to allow (x,y,x^2) in this case.
+ pseudoconstanty = function() return 0 end
+ else
+ local didWarn = false
+ pseudoconstanty = function()
+ if not didWarn then
+ log("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\n")
+ didWarn = true
+ end
+ return 0
+ end
+ end
+ else
+ pseudoconstanty = function() return y end
+ end
+
+ local pgfmathparse = pgfluamathparser.pgfmathparse
+ local prepareX
+ if xExpr == variableNames[1] then
+ prepareX = function() return x end
+ else
+ prepareX = function() return pgfmathparse(xExpr) end
+ end
+
+ local prepareY
+ if yExpr == variableNames[2] then
+ prepareY = function() return y end
+ else
+ prepareY = function() return pgfmathparse(yExpr) end
+ end
+
+ local function computeXYZ()
+ stringToFunctionMap[variableNames[1]] = pseudoconstantx
+ stringToFunctionMap[variableNames[2]] = pseudoconstanty
+ local X = prepareX()
+ local Y = prepareY()
+ local Z = nil
+ if is3d then
+ Z = pgfmathparse(zExpr)
+ else
+ -- FIXME BUG: we need to do something else with 'Z' if this is a 2d plot inside of a 3d axis!
+ end
+
+ local pt = Coord.new()
+ pt.x = { X, Y, Z}
+
+ -- restore 'x' and 'y'
+ -- FIXME : defining the resulting x/y coordinates as 'x' and 'y' constants was a really really bad idea in the first place :-(
+ stringToFunctionMap["x"] = old_global_function_x
+ stringToFunctionMap["y"] = old_global_function_y
+
+ coordoutputstream:coord(pt)
+ end
+
+ if not sampleLine then
+ local xmin = domainMin[1]
+ local ymin = domainMin[2]
+ local hx = h[1]
+ local hy = h[2]
+ local max_i = samples[1]-1
+ local max_j = samples[2]-1
+ -- samples twodimensionally (a lattice):
+ for j = 0,max_j do
+ -- FIXME : pgfplots@plot@data@notify@next@y
+ y = ymin + j*hy
+ -- log("" .. j .. "\n")
+ for i = 0,max_i do
+ -- FIXME : pgfplots@plot@data@notify@next@x
+ x = xmin + i*hx
+ computeXYZ()
+ end
+ -- FIXME : \pgfplotsplothandlernotifyscanlinecomplete
+ end
+ else
+ local xmin = domainMin[1]
+ local hx = h[1]
+ local max_i = samples[1]-1
+ for i = 0,max_i do
+ -- FIXME : pgfplots@plot@data@notify@next@x
+ x = xmin + i*hx
+ computeXYZ()
+ end
+ end
+
+ stringToFunctionMap[variableNames[1]] = nil
+ stringToFunctionMap[variableNames[2]] = nil
+ return true
+end
+
+function AddplotExpressionCoordinateGenerator:__tostring()
+ local result = "AddplotExpressionCoordinateGenerator[\n"
+ result = result .. "\n variable(s)=" .. self.variableNames[1] .. " " .. self.variableNames[2]
+ result = result .. "\n expressions="
+ for i = 1,#self.expressions do
+ result = result .. self.expressions[i] ..", "
+ end
+ result = result .. "\n domain=" .. self.domainMin[1] .. ":" .. self.domainMax[1]
+ result = result .. "\n samples=" .. self.samples[1]
+ if #self.domainMin == 2 then
+ result = result .. "\n domain y=" .. self.domainMin[2] .. ":" .. self.domainMax[2]
+ result = result .. "\n samples y=" .. self.samples[2]
+ end
+ result = result .. "]"
+ return result
+end
+
+end
diff --git a/graphics/pgf/contrib/pgfplots/tex/t-pgfplots.tex b/graphics/pgf/contrib/pgfplots/tex/t-pgfplots.tex
new file mode 100644
index 0000000000..4347f6c7e4
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/t-pgfplots.tex
@@ -0,0 +1,81 @@
+%--------------------------------------------
+%
+% 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/>.
+%
+%--------------------------------------------
+
+\writestatus{loading}{ConTeXt User Module / Pgfplots}
+
+\unprotect
+
+\input pgfplots.revision.tex
+\startmodule [pgfplots]
+
+% regarding the t-prefix: ensure that we do not accidentally load the plain tex tikz.tex file...
+\usemodule[t][tikz]
+\usetikzlibrary[plotmarks]
+
+\edef\tikzatcode{\the\catcode`\@}
+\edef\tikzbarcode{\the\catcode`\|}
+\edef\tikzexclaimcode{\the\catcode`\!}
+\catcode`\@=11
+\catcode`\|=12
+\catcode`\!=12
+
+
+
+\input pgfplots.code.tex
+
+\def\pgfplotsincludegraphics[#1]#2{\externalfigure[#2][#1]}
+\pgfkeys{/pgfplots/plot graphics/includegraphics cmd=\pgfplotsincludegraphics}
+
+
+\let\pgfplots@ORIG@tikz@installcommands@before@context=\tikz@installcommands
+
+\def\tikz@installcommands{%
+ \pgfplots@ORIG@tikz@installcommands@before@context
+ %
+ \let\startaxis=\pgfplots@environment@axis
+ \let\stopaxis=\endpgfplots@environment@axis
+ %
+ \let\startsemilogxaxis=\pgfplots@environment@semilogxaxis
+ \let\stopsemilogxaxis=\endpgfplots@environment@semilogxaxis
+ %
+ \let\startsemilogyaxis=\pgfplots@environment@semilogyaxis
+ \let\stopsemilogyaxis=\endpgfplots@environment@semilogyaxis
+ %
+ \let\startloglogaxis=\pgfplots@environment@loglogaxis
+ \let\stoploglogaxis=\endpgfplots@environment@loglogaxis
+ %
+ \def\startpgfplotsinterruptdatabb{\pgfplotsinterruptdatabb}%
+ \def\stoppgfplotsinterruptdatabb{\endpgfplotsinterruptdatabb}%
+}%
+
+\catcode`\@=\tikzatcode
+\catcode`\|=\tikzbarcode
+\catcode`\!=\tikzexclaimcode
+
+\stopmodule
+
+\protect
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/t-pgfplotstable.tex b/graphics/pgf/contrib/pgfplots/tex/t-pgfplotstable.tex
new file mode 100644
index 0000000000..7351363a09
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/t-pgfplotstable.tex
@@ -0,0 +1,41 @@
+%--------------------------------------------
+%
+% Package pgfplotstable
+%
+% It is based on Till Tantau's PGF package.
+%
+% Copyright 2007/2008 by Christian Feuersänger.
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see <http://www.gnu.org/licenses/>.
+%
+%--------------------------------------------
+
+\writestatus{loading}{ConTeXt User Module / Pgfplotstable}
+
+\unprotect
+
+\startmodule [pgfplotstable]
+
+\usemodule[pgfplots]
+
+% FIXME :
+%\def\pgfplots@texdist@protect{\protect}%
+
+\input pgfplotstable.code.tex
+
+
+\stopmodule
+
+\protect
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarycolorbrewer.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarycolorbrewer.code.tex
new file mode 100644
index 0000000000..b106a506f9
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarycolorbrewer.code.tex
@@ -0,0 +1,536 @@
+% Color schemes as obtained from http://colorbrewer2.org/
+%
+% Apache-Style Software License for ColorBrewer software and ColorBrewer Color
+% Schemes
+%
+% Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State
+% University.
+%
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+%
+% Redistribution and use in source and binary forms, with or without
+% modification, are permitted provided that the following conditions are met:
+% 1. Redistributions as source code must retain the above copyright notice, this
+% list of conditions and the following disclaimer.
+% 2. The end-user documentation included with the redistribution, if any, must
+% include the following acknowledgment: This product includes color
+% specifications and designs developed by Cynthia Brewer
+% (http://colorbrewer.org/). Alternately, this acknowledgment may appear in the
+% software itself, if and wherever such third-party acknowledgments normally
+% appear.
+% 3. The name "ColorBrewer" must not be used to endorse or promote products
+% derived from this software without prior written permission. For written
+% permission, please contact Cynthia Brewer at cbrewer@psu.edu.
+% 4. Products derived from this software may not be called "ColorBrewer", nor
+% may "ColorBrewer" appear in their name, without prior written permission of
+% Cynthia Brewer.
+
+% =============================================================================
+% sequential color schemes
+% =============================================================================
+
+% Multi hue
+
+\pgfutil@definecolor{BuGn-A}{RGB}{247,252,253}
+\pgfutil@definecolor{BuGn-B}{RGB}{237,248,251}
+\pgfutil@definecolor{BuGn-C}{RGB}{229,245,249}
+\pgfutil@definecolor{BuGn-D}{RGB}{204,236,230}
+\pgfutil@definecolor{BuGn-E}{RGB}{178,226,226}
+\pgfutil@definecolor{BuGn-F}{RGB}{153,216,201}
+\pgfutil@definecolor{BuGn-G}{RGB}{102,194,164}
+\pgfutil@definecolor{BuGn-H}{RGB}{65,174,118}
+\pgfutil@definecolor{BuGn-I}{RGB}{44,162,95}
+\pgfutil@definecolor{BuGn-J}{RGB}{35,139,69}
+\pgfutil@definecolor{BuGn-K}{RGB}{0,109,44}
+\pgfutil@definecolor{BuGn-L}{RGB}{0,88,36}
+\pgfutil@definecolor{BuGn-M}{RGB}{0,68,27}
+
+\pgfutil@definecolor{BuPu-A}{RGB}{247,252,253}
+\pgfutil@definecolor{BuPu-B}{RGB}{237,248,251}
+\pgfutil@definecolor{BuPu-C}{RGB}{224,236,244}
+\pgfutil@definecolor{BuPu-D}{RGB}{191,211,230}
+\pgfutil@definecolor{BuPu-E}{RGB}{179,205,227}
+\pgfutil@definecolor{BuPu-F}{RGB}{158,188,218}
+\pgfutil@definecolor{BuPu-G}{RGB}{140,150,198}
+\pgfutil@definecolor{BuPu-H}{RGB}{140,107,177}
+\pgfutil@definecolor{BuPu-I}{RGB}{136,86,167}
+\pgfutil@definecolor{BuPu-J}{RGB}{136,65,157}
+\pgfutil@definecolor{BuPu-K}{RGB}{129,15,124}
+\pgfutil@definecolor{BuPu-L}{RGB}{110,1,107}
+\pgfutil@definecolor{BuPu-M}{RGB}{77,0,75}
+
+\pgfutil@definecolor{GnBu-A}{RGB}{247,252,240}
+\pgfutil@definecolor{GnBu-B}{RGB}{240,249,232}
+\pgfutil@definecolor{GnBu-C}{RGB}{224,243,219}
+\pgfutil@definecolor{GnBu-D}{RGB}{204,235,197}
+\pgfutil@definecolor{GnBu-E}{RGB}{186,228,188}
+\pgfutil@definecolor{GnBu-F}{RGB}{168,221,181}
+\pgfutil@definecolor{GnBu-G}{RGB}{123,204,196}
+\pgfutil@definecolor{GnBu-H}{RGB}{78,179,211}
+\pgfutil@definecolor{GnBu-I}{RGB}{67,162,202}
+\pgfutil@definecolor{GnBu-J}{RGB}{43,140,190}
+\pgfutil@definecolor{GnBu-K}{RGB}{8,104,172}
+\pgfutil@definecolor{GnBu-L}{RGB}{8,88,158}
+\pgfutil@definecolor{GnBu-M}{RGB}{8,64,129}
+
+\pgfutil@definecolor{OrRd-A}{RGB}{255,247,236}
+\pgfutil@definecolor{OrRd-B}{RGB}{254,240,217}
+\pgfutil@definecolor{OrRd-C}{RGB}{254,232,200}
+\pgfutil@definecolor{OrRd-D}{RGB}{253,212,158}
+\pgfutil@definecolor{OrRd-E}{RGB}{253,204,138}
+\pgfutil@definecolor{OrRd-F}{RGB}{253,187,132}
+\pgfutil@definecolor{OrRd-G}{RGB}{252,141,89}
+\pgfutil@definecolor{OrRd-H}{RGB}{239,101,72}
+\pgfutil@definecolor{OrRd-I}{RGB}{227,74,51}
+\pgfutil@definecolor{OrRd-J}{RGB}{215,48,31}
+\pgfutil@definecolor{OrRd-K}{RGB}{179,0,0}
+\pgfutil@definecolor{OrRd-L}{RGB}{153,0,0}
+\pgfutil@definecolor{OrRd-M}{RGB}{127,0,0}
+
+\pgfutil@definecolor{PuBu-A}{RGB}{255,247,251}
+\pgfutil@definecolor{PuBu-B}{RGB}{241,238,246}
+\pgfutil@definecolor{PuBu-C}{RGB}{236,231,242}
+\pgfutil@definecolor{PuBu-D}{RGB}{208,209,230}
+\pgfutil@definecolor{PuBu-E}{RGB}{189,201,225}
+\pgfutil@definecolor{PuBu-F}{RGB}{166,189,219}
+\pgfutil@definecolor{PuBu-G}{RGB}{116,169,207}
+\pgfutil@definecolor{PuBu-H}{RGB}{54,144,192}
+\pgfutil@definecolor{PuBu-I}{RGB}{43,140,190}
+\pgfutil@definecolor{PuBu-J}{RGB}{5,112,176}
+\pgfutil@definecolor{PuBu-K}{RGB}{4,90,141}
+\pgfutil@definecolor{PuBu-L}{RGB}{3,78,123}
+\pgfutil@definecolor{PuBu-M}{RGB}{2,56,88}
+
+\pgfutil@definecolor{PuBuGn-A}{RGB}{255,247,251}
+\pgfutil@definecolor{PuBuGn-B}{RGB}{246,239,247}
+\pgfutil@definecolor{PuBuGn-C}{RGB}{236,226,240}
+\pgfutil@definecolor{PuBuGn-D}{RGB}{208,209,230}
+\pgfutil@definecolor{PuBuGn-E}{RGB}{189,201,225}
+\pgfutil@definecolor{PuBuGn-F}{RGB}{166,189,219}
+\pgfutil@definecolor{PuBuGn-G}{RGB}{103,169,207}
+\pgfutil@definecolor{PuBuGn-H}{RGB}{54,144,192}
+\pgfutil@definecolor{PuBuGn-I}{RGB}{28,144,153}
+\pgfutil@definecolor{PuBuGn-J}{RGB}{2,129,138}
+\pgfutil@definecolor{PuBuGn-K}{RGB}{1,108,89}
+\pgfutil@definecolor{PuBuGn-L}{RGB}{1,100,80}
+\pgfutil@definecolor{PuBuGn-M}{RGB}{1,70,54}
+
+\pgfutil@definecolor{PuRd-A}{RGB}{247,244,249}
+\pgfutil@definecolor{PuRd-B}{RGB}{241,238,246}
+\pgfutil@definecolor{PuRd-C}{RGB}{231,225,239}
+\pgfutil@definecolor{PuRd-D}{RGB}{212,185,218}
+\pgfutil@definecolor{PuRd-E}{RGB}{215,181,216}
+\pgfutil@definecolor{PuRd-F}{RGB}{201,148,199}
+\pgfutil@definecolor{PuRd-G}{RGB}{223,101,176}
+\pgfutil@definecolor{PuRd-H}{RGB}{231,41,138}
+\pgfutil@definecolor{PuRd-I}{RGB}{221,28,119}
+\pgfutil@definecolor{PuRd-J}{RGB}{206,18,86}
+\pgfutil@definecolor{PuRd-K}{RGB}{152,0,67}
+\pgfutil@definecolor{PuRd-L}{RGB}{145,0,63}
+\pgfutil@definecolor{PuRd-M}{RGB}{103,0,31}
+
+\pgfutil@definecolor{RdPu-A}{RGB}{255,247,243}
+\pgfutil@definecolor{RdPu-B}{RGB}{254,235,226}
+\pgfutil@definecolor{RdPu-C}{RGB}{253,224,221}
+\pgfutil@definecolor{RdPu-D}{RGB}{252,197,192}
+\pgfutil@definecolor{RdPu-E}{RGB}{251,180,185}
+\pgfutil@definecolor{RdPu-F}{RGB}{250,159,181}
+\pgfutil@definecolor{RdPu-G}{RGB}{247,104,161}
+\pgfutil@definecolor{RdPu-H}{RGB}{221,52,151}
+\pgfutil@definecolor{RdPu-I}{RGB}{197,27,138}
+\pgfutil@definecolor{RdPu-J}{RGB}{174,1,126}
+\pgfutil@definecolor{RdPu-K}{RGB}{122,1,119}
+\pgfutil@definecolor{RdPu-L}{RGB}{122,1,119}
+\pgfutil@definecolor{RdPu-M}{RGB}{73,0,106}
+
+\pgfutil@definecolor{YlGn-A}{RGB}{255,255,229}
+\pgfutil@definecolor{YlGn-B}{RGB}{255,255,204}
+\pgfutil@definecolor{YlGn-C}{RGB}{247,252,185}
+\pgfutil@definecolor{YlGn-D}{RGB}{217,240,163}
+\pgfutil@definecolor{YlGn-E}{RGB}{194,230,153}
+\pgfutil@definecolor{YlGn-F}{RGB}{173,221,142}
+\pgfutil@definecolor{YlGn-G}{RGB}{120,198,121}
+\pgfutil@definecolor{YlGn-H}{RGB}{65,171,93}
+\pgfutil@definecolor{YlGn-I}{RGB}{49,163,84}
+\pgfutil@definecolor{YlGn-J}{RGB}{35,132,67}
+\pgfutil@definecolor{YlGn-K}{RGB}{0,104,55}
+\pgfutil@definecolor{YlGn-L}{RGB}{0,90,50}
+\pgfutil@definecolor{YlGn-M}{RGB}{0,69,41}
+
+\pgfutil@definecolor{YlGnBu-A}{RGB}{255,255,217}
+\pgfutil@definecolor{YlGnBu-B}{RGB}{255,255,204}
+\pgfutil@definecolor{YlGnBu-C}{RGB}{237,248,177}
+\pgfutil@definecolor{YlGnBu-D}{RGB}{199,233,180}
+\pgfutil@definecolor{YlGnBu-E}{RGB}{161,218,180}
+\pgfutil@definecolor{YlGnBu-F}{RGB}{127,205,187}
+\pgfutil@definecolor{YlGnBu-G}{RGB}{65,182,196}
+\pgfutil@definecolor{YlGnBu-H}{RGB}{29,145,192}
+\pgfutil@definecolor{YlGnBu-I}{RGB}{44,127,184}
+\pgfutil@definecolor{YlGnBu-J}{RGB}{34,94,168}
+\pgfutil@definecolor{YlGnBu-K}{RGB}{37,52,148}
+\pgfutil@definecolor{YlGnBu-L}{RGB}{12,44,132}
+\pgfutil@definecolor{YlGnBu-M}{RGB}{8,29,88}
+
+\pgfutil@definecolor{YlOrBr-A}{RGB}{255,255,229}
+\pgfutil@definecolor{YlOrBr-B}{RGB}{255,255,212}
+\pgfutil@definecolor{YlOrBr-C}{RGB}{255,247,188}
+\pgfutil@definecolor{YlOrBr-D}{RGB}{254,227,145}
+\pgfutil@definecolor{YlOrBr-E}{RGB}{254,217,142}
+\pgfutil@definecolor{YlOrBr-F}{RGB}{254,196,79}
+\pgfutil@definecolor{YlOrBr-G}{RGB}{254,153,41}
+\pgfutil@definecolor{YlOrBr-H}{RGB}{236,112,20}
+\pgfutil@definecolor{YlOrBr-I}{RGB}{217,95,14}
+\pgfutil@definecolor{YlOrBr-J}{RGB}{204,76,2}
+\pgfutil@definecolor{YlOrBr-K}{RGB}{153,52,4}
+\pgfutil@definecolor{YlOrBr-L}{RGB}{140,45,4}
+\pgfutil@definecolor{YlOrBr-M}{RGB}{102,37,6}
+
+\pgfutil@definecolor{YlOrRd-A}{RGB}{255,255,204}
+\pgfutil@definecolor{YlOrRd-B}{RGB}{255,255,178}
+\pgfutil@definecolor{YlOrRd-C}{RGB}{255,237,160}
+\pgfutil@definecolor{YlOrRd-D}{RGB}{254,217,118}
+\pgfutil@definecolor{YlOrRd-E}{RGB}{254,204,92}
+\pgfutil@definecolor{YlOrRd-F}{RGB}{254,178,76}
+\pgfutil@definecolor{YlOrRd-G}{RGB}{253,141,60}
+\pgfutil@definecolor{YlOrRd-H}{RGB}{252,78,42}
+\pgfutil@definecolor{YlOrRd-I}{RGB}{240,59,32}
+\pgfutil@definecolor{YlOrRd-J}{RGB}{227,26,28}
+\pgfutil@definecolor{YlOrRd-K}{RGB}{189,0,38}
+\pgfutil@definecolor{YlOrRd-L}{RGB}{177,0,38}
+\pgfutil@definecolor{YlOrRd-M}{RGB}{128,0,38}
+
+% -----------------------------------------------------------------------------
+% Single hue
+
+\pgfutil@definecolor{Blues-A}{RGB}{247,251,255}
+\pgfutil@definecolor{Blues-B}{RGB}{239,243,255}
+\pgfutil@definecolor{Blues-C}{RGB}{222,235,247}
+\pgfutil@definecolor{Blues-D}{RGB}{198,219,239}
+\pgfutil@definecolor{Blues-E}{RGB}{189,215,231}
+\pgfutil@definecolor{Blues-F}{RGB}{158,202,225}
+\pgfutil@definecolor{Blues-G}{RGB}{107,174,214}
+\pgfutil@definecolor{Blues-H}{RGB}{66,146,198}
+\pgfutil@definecolor{Blues-I}{RGB}{49,130,189}
+\pgfutil@definecolor{Blues-J}{RGB}{33,113,181}
+\pgfutil@definecolor{Blues-K}{RGB}{8,81,156}
+\pgfutil@definecolor{Blues-L}{RGB}{8,69,148}
+\pgfutil@definecolor{Blues-M}{RGB}{8,48,107}
+
+\pgfutil@definecolor{Greens-A}{RGB}{247,252,245}
+\pgfutil@definecolor{Greens-B}{RGB}{237,248,233}
+\pgfutil@definecolor{Greens-C}{RGB}{229,245,224}
+\pgfutil@definecolor{Greens-D}{RGB}{199,233,192}
+\pgfutil@definecolor{Greens-E}{RGB}{186,228,179}
+\pgfutil@definecolor{Greens-F}{RGB}{161,217,155}
+\pgfutil@definecolor{Greens-G}{RGB}{116,196,118}
+\pgfutil@definecolor{Greens-H}{RGB}{65,171,93}
+\pgfutil@definecolor{Greens-I}{RGB}{49,163,84}
+\pgfutil@definecolor{Greens-J}{RGB}{35,139,69}
+\pgfutil@definecolor{Greens-K}{RGB}{0,109,44}
+\pgfutil@definecolor{Greens-L}{RGB}{0,90,50}
+\pgfutil@definecolor{Greens-M}{RGB}{0,68,27}
+
+\pgfutil@definecolor{Greys-A}{RGB}{255,255,255}
+\pgfutil@definecolor{Greys-B}{RGB}{247,247,247}
+\pgfutil@definecolor{Greys-C}{RGB}{240,240,240}
+\pgfutil@definecolor{Greys-D}{RGB}{217,217,217}
+\pgfutil@definecolor{Greys-E}{RGB}{204,204,204}
+\pgfutil@definecolor{Greys-F}{RGB}{189,189,189}
+\pgfutil@definecolor{Greys-G}{RGB}{150,150,150}
+\pgfutil@definecolor{Greys-H}{RGB}{115,115,115}
+\pgfutil@definecolor{Greys-I}{RGB}{99,99,99}
+\pgfutil@definecolor{Greys-J}{RGB}{82,82,82}
+\pgfutil@definecolor{Greys-K}{RGB}{37,37,37}
+\pgfutil@definecolor{Greys-L}{RGB}{37,37,37}
+\pgfutil@definecolor{Greys-M}{RGB}{0,0,0}
+
+\pgfutil@definecolor{Oranges-A}{RGB}{255,245,235}
+\pgfutil@definecolor{Oranges-B}{RGB}{254,237,222}
+\pgfutil@definecolor{Oranges-C}{RGB}{254,230,206}
+\pgfutil@definecolor{Oranges-D}{RGB}{253,208,162}
+\pgfutil@definecolor{Oranges-E}{RGB}{253,190,133}
+\pgfutil@definecolor{Oranges-F}{RGB}{253,174,107}
+\pgfutil@definecolor{Oranges-G}{RGB}{253,141,60}
+\pgfutil@definecolor{Oranges-H}{RGB}{241,105,19}
+\pgfutil@definecolor{Oranges-I}{RGB}{230,85,13}
+\pgfutil@definecolor{Oranges-J}{RGB}{217,71,1}
+\pgfutil@definecolor{Oranges-K}{RGB}{166,54,3}
+\pgfutil@definecolor{Oranges-L}{RGB}{140,45,4}
+\pgfutil@definecolor{Oranges-M}{RGB}{127,39,4}
+
+\pgfutil@definecolor{Purples-A}{RGB}{252,251,253}
+\pgfutil@definecolor{Purples-B}{RGB}{242,240,247}
+\pgfutil@definecolor{Purples-C}{RGB}{239,237,245}
+\pgfutil@definecolor{Purples-D}{RGB}{218,218,235}
+\pgfutil@definecolor{Purples-E}{RGB}{203,201,226}
+\pgfutil@definecolor{Purples-F}{RGB}{188,189,220}
+\pgfutil@definecolor{Purples-G}{RGB}{158,154,200}
+\pgfutil@definecolor{Purples-H}{RGB}{128,125,186}
+\pgfutil@definecolor{Purples-I}{RGB}{117,107,177}
+\pgfutil@definecolor{Purples-J}{RGB}{106,81,163}
+\pgfutil@definecolor{Purples-K}{RGB}{84,39,143}
+\pgfutil@definecolor{Purples-L}{RGB}{74,20,134}
+\pgfutil@definecolor{Purples-M}{RGB}{63,0,125}
+
+\pgfutil@definecolor{Reds-A}{RGB}{255,245,240}
+\pgfutil@definecolor{Reds-B}{RGB}{254,229,217}
+\pgfutil@definecolor{Reds-C}{RGB}{254,224,210}
+\pgfutil@definecolor{Reds-D}{RGB}{252,187,161}
+\pgfutil@definecolor{Reds-E}{RGB}{252,174,145}
+\pgfutil@definecolor{Reds-F}{RGB}{252,146,114}
+\pgfutil@definecolor{Reds-G}{RGB}{251,106,74}
+\pgfutil@definecolor{Reds-H}{RGB}{239,59,44}
+\pgfutil@definecolor{Reds-I}{RGB}{222,45,38}
+\pgfutil@definecolor{Reds-J}{RGB}{203,24,29}
+\pgfutil@definecolor{Reds-K}{RGB}{165,15,21}
+\pgfutil@definecolor{Reds-L}{RGB}{153,0,13}
+\pgfutil@definecolor{Reds-M}{RGB}{103,0,13}
+
+
+% =============================================================================
+% diverging color schemes
+% =============================================================================
+
+\pgfutil@definecolor{BrBG-A}{RGB}{84,48,5}
+\pgfutil@definecolor{BrBG-B}{RGB}{140,81,10}
+\pgfutil@definecolor{BrBG-C}{RGB}{166,97,26}
+\pgfutil@definecolor{BrBG-D}{RGB}{191,129,45}
+\pgfutil@definecolor{BrBG-E}{RGB}{216,179,101}
+\pgfutil@definecolor{BrBG-F}{RGB}{223,194,125}
+\pgfutil@definecolor{BrBG-G}{RGB}{246,232,195}
+\pgfutil@definecolor{BrBG-H}{RGB}{245,245,245}
+\pgfutil@definecolor{BrBG-I}{RGB}{199,234,229}
+\pgfutil@definecolor{BrBG-J}{RGB}{128,205,193}
+\pgfutil@definecolor{BrBG-K}{RGB}{90,180,172}
+\pgfutil@definecolor{BrBG-L}{RGB}{53,151,143}
+\pgfutil@definecolor{BrBG-M}{RGB}{1,133,113}
+\pgfutil@definecolor{BrBG-N}{RGB}{1,102,94}
+\pgfutil@definecolor{BrBG-O}{RGB}{0,60,48}
+
+\pgfutil@definecolor{PiYG-A}{RGB}{142,1,82}
+\pgfutil@definecolor{PiYG-B}{RGB}{197,27,125}
+\pgfutil@definecolor{PiYG-C}{RGB}{208,28,139}
+\pgfutil@definecolor{PiYG-D}{RGB}{222,119,174}
+\pgfutil@definecolor{PiYG-E}{RGB}{233,163,201}
+\pgfutil@definecolor{PiYG-F}{RGB}{241,182,218}
+\pgfutil@definecolor{PiYG-G}{RGB}{253,224,239}
+\pgfutil@definecolor{PiYG-H}{RGB}{247,247,247}
+\pgfutil@definecolor{PiYG-I}{RGB}{230,245,208}
+\pgfutil@definecolor{PiYG-J}{RGB}{184,225,134}
+\pgfutil@definecolor{PiYG-K}{RGB}{161,215,106}
+\pgfutil@definecolor{PiYG-L}{RGB}{127,188,65}
+\pgfutil@definecolor{PiYG-M}{RGB}{77,172,38}
+\pgfutil@definecolor{PiYG-N}{RGB}{77,146,33}
+\pgfutil@definecolor{PiYG-O}{RGB}{39,100,25}
+
+\pgfutil@definecolor{PRGn-A}{RGB}{64,0,75}
+\pgfutil@definecolor{PRGn-B}{RGB}{118,42,131}
+\pgfutil@definecolor{PRGn-C}{RGB}{123,50,148}
+\pgfutil@definecolor{PRGn-D}{RGB}{153,112,171}
+\pgfutil@definecolor{PRGn-E}{RGB}{175,141,195}
+\pgfutil@definecolor{PRGn-F}{RGB}{194,165,207}
+\pgfutil@definecolor{PRGn-G}{RGB}{231,212,232}
+\pgfutil@definecolor{PRGn-H}{RGB}{247,247,247}
+\pgfutil@definecolor{PRGn-I}{RGB}{217,240,211}
+\pgfutil@definecolor{PRGn-J}{RGB}{166,219,160}
+\pgfutil@definecolor{PRGn-K}{RGB}{127,191,123}
+\pgfutil@definecolor{PRGn-L}{RGB}{90,174,97}
+\pgfutil@definecolor{PRGn-M}{RGB}{0,136,55}
+\pgfutil@definecolor{PRGn-N}{RGB}{27,120,55}
+\pgfutil@definecolor{PRGn-O}{RGB}{0,68,27}
+
+% These colors are defined in reverse order compared to <http://colorbrewer2.org>.
+% For more details have a look at the comments in
+% <https://sourceforge.net/p/pgfplots/bugs/108/>
+\pgfutil@definecolor{PuOr-A}{RGB}{45,0,75}
+\pgfutil@definecolor{PuOr-B}{RGB}{84,39,136}
+\pgfutil@definecolor{PuOr-C}{RGB}{94,60,153}
+\pgfutil@definecolor{PuOr-D}{RGB}{128,115,172}
+\pgfutil@definecolor{PuOr-E}{RGB}{153,142,195}
+\pgfutil@definecolor{PuOr-F}{RGB}{178,171,210}
+\pgfutil@definecolor{PuOr-G}{RGB}{216,218,235}
+\pgfutil@definecolor{PuOr-H}{RGB}{247,247,247}
+\pgfutil@definecolor{PuOr-I}{RGB}{254,224,182}
+\pgfutil@definecolor{PuOr-J}{RGB}{253,184,99}
+\pgfutil@definecolor{PuOr-K}{RGB}{241,163,64}
+\pgfutil@definecolor{PuOr-L}{RGB}{224,130,20}
+\pgfutil@definecolor{PuOr-M}{RGB}{230,97,1}
+\pgfutil@definecolor{PuOr-N}{RGB}{179,88,6}
+\pgfutil@definecolor{PuOr-O}{RGB}{127,59,8}
+
+\pgfutil@definecolor{RdBu-A}{RGB}{103,0,31}
+\pgfutil@definecolor{RdBu-B}{RGB}{178,24,43}
+\pgfutil@definecolor{RdBu-C}{RGB}{202,0,32}
+\pgfutil@definecolor{RdBu-D}{RGB}{214,96,77}
+\pgfutil@definecolor{RdBu-E}{RGB}{239,138,98}
+\pgfutil@definecolor{RdBu-F}{RGB}{244,165,130}
+\pgfutil@definecolor{RdBu-G}{RGB}{253,219,199}
+\pgfutil@definecolor{RdBu-H}{RGB}{247,247,247}
+\pgfutil@definecolor{RdBu-I}{RGB}{209,229,240}
+\pgfutil@definecolor{RdBu-J}{RGB}{146,197,222}
+\pgfutil@definecolor{RdBu-K}{RGB}{103,169,207}
+\pgfutil@definecolor{RdBu-L}{RGB}{67,147,195}
+\pgfutil@definecolor{RdBu-M}{RGB}{5,113,176}
+\pgfutil@definecolor{RdBu-N}{RGB}{33,102,172}
+\pgfutil@definecolor{RdBu-O}{RGB}{5,48,97}
+
+\pgfutil@definecolor{RdGy-A}{RGB}{103,0,31}
+\pgfutil@definecolor{RdGy-B}{RGB}{178,24,43}
+\pgfutil@definecolor{RdGy-C}{RGB}{202,0,32}
+\pgfutil@definecolor{RdGy-D}{RGB}{214,96,77}
+\pgfutil@definecolor{RdGy-E}{RGB}{239,138,98}
+\pgfutil@definecolor{RdGy-F}{RGB}{244,165,130}
+\pgfutil@definecolor{RdGy-G}{RGB}{253,219,199}
+\pgfutil@definecolor{RdGy-H}{RGB}{255,255,255}
+\pgfutil@definecolor{RdGy-I}{RGB}{224,224,224}
+\pgfutil@definecolor{RdGy-J}{RGB}{186,186,186}
+\pgfutil@definecolor{RdGy-K}{RGB}{153,153,153}
+\pgfutil@definecolor{RdGy-L}{RGB}{135,135,135}
+\pgfutil@definecolor{RdGy-M}{RGB}{64,64,64}
+\pgfutil@definecolor{RdGy-N}{RGB}{77,77,77}
+\pgfutil@definecolor{RdGy-O}{RGB}{26,26,26}
+
+\pgfutil@definecolor{RdYlBu-A}{RGB}{165,0,38}
+\pgfutil@definecolor{RdYlBu-B}{RGB}{215,48,39}
+\pgfutil@definecolor{RdYlBu-C}{RGB}{215,25,28}
+\pgfutil@definecolor{RdYlBu-D}{RGB}{244,109,67}
+\pgfutil@definecolor{RdYlBu-E}{RGB}{252,141,89}
+\pgfutil@definecolor{RdYlBu-F}{RGB}{253,174,97}
+\pgfutil@definecolor{RdYlBu-G}{RGB}{254,224,144}
+\pgfutil@definecolor{RdYlBu-H}{RGB}{255,255,191}
+\pgfutil@definecolor{RdYlBu-I}{RGB}{224,243,248}
+\pgfutil@definecolor{RdYlBu-J}{RGB}{171,217,233}
+\pgfutil@definecolor{RdYlBu-K}{RGB}{145,191,219}
+\pgfutil@definecolor{RdYlBu-L}{RGB}{116,173,209}
+\pgfutil@definecolor{RdYlBu-M}{RGB}{44,123,182}
+\pgfutil@definecolor{RdYlBu-N}{RGB}{69,117,180}
+\pgfutil@definecolor{RdYlBu-O}{RGB}{49,54,149}
+
+\pgfutil@definecolor{RdYlGn-A}{RGB}{165,0,38}
+\pgfutil@definecolor{RdYlGn-B}{RGB}{215,48,39}
+\pgfutil@definecolor{RdYlGn-C}{RGB}{215,25,28}
+\pgfutil@definecolor{RdYlGn-D}{RGB}{244,109,67}
+\pgfutil@definecolor{RdYlGn-E}{RGB}{252,141,89}
+\pgfutil@definecolor{RdYlGn-F}{RGB}{253,174,97}
+\pgfutil@definecolor{RdYlGn-G}{RGB}{254,224,139}
+\pgfutil@definecolor{RdYlGn-H}{RGB}{255,255,191}
+\pgfutil@definecolor{RdYlGn-I}{RGB}{217,239,139}
+\pgfutil@definecolor{RdYlGn-J}{RGB}{166,217,106}
+\pgfutil@definecolor{RdYlGn-K}{RGB}{145,207,96}
+\pgfutil@definecolor{RdYlGn-L}{RGB}{102,189,99}
+\pgfutil@definecolor{RdYlGn-M}{RGB}{26,150,65}
+\pgfutil@definecolor{RdYlGn-N}{RGB}{26,152,80}
+\pgfutil@definecolor{RdYlGn-O}{RGB}{0,104,55}
+
+\pgfutil@definecolor{Spectral-A}{RGB}{158,1,66}
+\pgfutil@definecolor{Spectral-B}{RGB}{213,62,79}
+\pgfutil@definecolor{Spectral-C}{RGB}{215,25,28}
+\pgfutil@definecolor{Spectral-D}{RGB}{244,109,67}
+\pgfutil@definecolor{Spectral-E}{RGB}{252,141,89}
+\pgfutil@definecolor{Spectral-F}{RGB}{253,174,97}
+\pgfutil@definecolor{Spectral-G}{RGB}{254,224,139}
+\pgfutil@definecolor{Spectral-H}{RGB}{255,255,191}
+\pgfutil@definecolor{Spectral-I}{RGB}{230,245,152}
+\pgfutil@definecolor{Spectral-J}{RGB}{171,221,164}
+\pgfutil@definecolor{Spectral-K}{RGB}{153,213,148}
+\pgfutil@definecolor{Spectral-L}{RGB}{102,194,165}
+\pgfutil@definecolor{Spectral-M}{RGB}{43,131,186}
+\pgfutil@definecolor{Spectral-N}{RGB}{50,136,189}
+\pgfutil@definecolor{Spectral-O}{RGB}{94,79,162}
+
+
+% =============================================================================
+% qualitative color schemes
+% =============================================================================
+
+\pgfutil@definecolor{Accent-A}{RGB}{127,201,127}
+\pgfutil@definecolor{Accent-B}{RGB}{190,174,212}
+\pgfutil@definecolor{Accent-C}{RGB}{253,192,134}
+\pgfutil@definecolor{Accent-D}{RGB}{255,255,153}
+\pgfutil@definecolor{Accent-E}{RGB}{56,108,176}
+\pgfutil@definecolor{Accent-F}{RGB}{240,2,127}
+\pgfutil@definecolor{Accent-G}{RGB}{191,91,23}
+\pgfutil@definecolor{Accent-H}{RGB}{102,102,102}
+
+\pgfutil@definecolor{Dark2-A}{RGB}{27,158,119}
+\pgfutil@definecolor{Dark2-B}{RGB}{217,95,2}
+\pgfutil@definecolor{Dark2-C}{RGB}{117,112,179}
+\pgfutil@definecolor{Dark2-D}{RGB}{231,41,138}
+\pgfutil@definecolor{Dark2-E}{RGB}{102,166,30}
+\pgfutil@definecolor{Dark2-F}{RGB}{230,171,2}
+\pgfutil@definecolor{Dark2-G}{RGB}{166,118,29}
+\pgfutil@definecolor{Dark2-H}{RGB}{102,102,102}
+
+\pgfutil@definecolor{Paired-A}{RGB}{166,206,227}
+\pgfutil@definecolor{Paired-B}{RGB}{31,120,180}
+\pgfutil@definecolor{Paired-C}{RGB}{178,223,138}
+\pgfutil@definecolor{Paired-D}{RGB}{51,160,44}
+\pgfutil@definecolor{Paired-E}{RGB}{251,154,153}
+\pgfutil@definecolor{Paired-F}{RGB}{227,26,28}
+\pgfutil@definecolor{Paired-G}{RGB}{253,191,111}
+\pgfutil@definecolor{Paired-H}{RGB}{255,127,0}
+\pgfutil@definecolor{Paired-I}{RGB}{202,178,214}
+\pgfutil@definecolor{Paired-J}{RGB}{106,61,154}
+\pgfutil@definecolor{Paired-K}{RGB}{255,255,153}
+\pgfutil@definecolor{Paired-L}{RGB}{177,89,40}
+
+\pgfutil@definecolor{Pastel1-A}{RGB}{251,180,174}
+\pgfutil@definecolor{Pastel1-B}{RGB}{179,205,227}
+\pgfutil@definecolor{Pastel1-C}{RGB}{204,235,197}
+\pgfutil@definecolor{Pastel1-D}{RGB}{222,203,228}
+\pgfutil@definecolor{Pastel1-E}{RGB}{254,217,166}
+\pgfutil@definecolor{Pastel1-F}{RGB}{255,255,204}
+\pgfutil@definecolor{Pastel1-G}{RGB}{229,216,189}
+\pgfutil@definecolor{Pastel1-H}{RGB}{253,218,236}
+\pgfutil@definecolor{Pastel1-I}{RGB}{242,242,242}
+
+\pgfutil@definecolor{Pastel2-A}{RGB}{179,226,205}
+\pgfutil@definecolor{Pastel2-B}{RGB}{253,205,172}
+\pgfutil@definecolor{Pastel2-C}{RGB}{203,213,232}
+\pgfutil@definecolor{Pastel2-D}{RGB}{244,202,228}
+\pgfutil@definecolor{Pastel2-E}{RGB}{230,245,201}
+\pgfutil@definecolor{Pastel2-F}{RGB}{255,242,174}
+\pgfutil@definecolor{Pastel2-G}{RGB}{241,226,204}
+\pgfutil@definecolor{Pastel2-H}{RGB}{204,204,204}
+
+\pgfutil@definecolor{Set1-A}{RGB}{228,26,28}
+\pgfutil@definecolor{Set1-B}{RGB}{55,126,184}
+\pgfutil@definecolor{Set1-C}{RGB}{77,175,74}
+\pgfutil@definecolor{Set1-D}{RGB}{152,78,163}
+\pgfutil@definecolor{Set1-E}{RGB}{255,127,0}
+\pgfutil@definecolor{Set1-F}{RGB}{255,255,51}
+\pgfutil@definecolor{Set1-G}{RGB}{166,86,40}
+\pgfutil@definecolor{Set1-H}{RGB}{247,129,191}
+\pgfutil@definecolor{Set1-I}{RGB}{153,153,153}
+
+\pgfutil@definecolor{Set2-A}{RGB}{102,194,165}
+\pgfutil@definecolor{Set2-B}{RGB}{252,141,98}
+\pgfutil@definecolor{Set2-C}{RGB}{141,160,203}
+\pgfutil@definecolor{Set2-D}{RGB}{231,138,195}
+\pgfutil@definecolor{Set2-E}{RGB}{166,216,84}
+\pgfutil@definecolor{Set2-F}{RGB}{255,217,47}
+\pgfutil@definecolor{Set2-G}{RGB}{229,196,148}
+\pgfutil@definecolor{Set2-H}{RGB}{179,179,179}
+
+\pgfutil@definecolor{Set3-A}{RGB}{141,211,199}
+\pgfutil@definecolor{Set3-B}{RGB}{255,255,179}
+\pgfutil@definecolor{Set3-C}{RGB}{190,186,218}
+\pgfutil@definecolor{Set3-D}{RGB}{251,128,114}
+\pgfutil@definecolor{Set3-E}{RGB}{128,177,211}
+\pgfutil@definecolor{Set3-F}{RGB}{253,180,98}
+\pgfutil@definecolor{Set3-G}{RGB}{179,222,105}
+\pgfutil@definecolor{Set3-H}{RGB}{252,205,229}
+\pgfutil@definecolor{Set3-I}{RGB}{217,217,217}
+\pgfutil@definecolor{Set3-J}{RGB}{188,128,189}
+\pgfutil@definecolor{Set3-K}{RGB}{204,235,197}
+\pgfutil@definecolor{Set3-L}{RGB}{255,237,111}
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarycolortol.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarycolortol.code.tex
new file mode 100644
index 0000000000..21a1e4c781
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarycolortol.code.tex
@@ -0,0 +1,277 @@
+
+% Color schemes as obtained from <http://www.sron.nl/~pault/>
+% and <http://www.sron.nl/~pault/colourschemes.pdf> respectively
+
+% =============================================================================
+% colors from palette I
+\pgfutil@definecolor{colortol-P1-A}{RGB}{51,34,136}
+\pgfutil@definecolor{colortol-P1-B}{RGB}{68,119,170}
+\pgfutil@definecolor{colortol-P1-C}{RGB}{102,153,204}
+\pgfutil@definecolor{colortol-P1-D}{RGB}{136,204,238}
+\pgfutil@definecolor{colortol-P1-E}{RGB}{68,170,153}
+\pgfutil@definecolor{colortol-P1-F}{RGB}{17,119,51}
+\pgfutil@definecolor{colortol-P1-G}{RGB}{153,153,51}
+\pgfutil@definecolor{colortol-P1-H}{RGB}{221,204,119}
+\pgfutil@definecolor{colortol-P1-I}{RGB}{102,17,0}
+\pgfutil@definecolor{colortol-P1-J}{RGB}{204,102,119}
+\pgfutil@definecolor{colortol-P1-K}{RGB}{170,68,102}
+\pgfutil@definecolor{colortol-P1-L}{RGB}{136,34,85}
+\pgfutil@definecolor{colortol-P1-M}{RGB}{170,68,153}
+% color for data gaps
+\pgfutil@definecolor{colortol-P1-gap}{RGB}{221,221,221}
+
+
+% -----------------------------------------------------------------------------
+% colors from palette II
+% bright
+\pgfutil@definecolor{colortol-P2light-A}{RGB}{119,170,221}
+\pgfutil@definecolor{colortol-P2light-B}{RGB}{119,204,204}
+\pgfutil@definecolor{colortol-P2light-C}{RGB}{136,204,170}
+\pgfutil@definecolor{colortol-P2light-D}{RGB}{221,221,119}
+\pgfutil@definecolor{colortol-P2light-E}{RGB}{221,170,119}
+\pgfutil@definecolor{colortol-P2light-F}{RGB}{221,119,136}
+\pgfutil@definecolor{colortol-P2light-G}{RGB}{204,153,187}
+% medium
+\pgfutil@definecolor{colortol-P2-A}{RGB}{68,119,170}
+\pgfutil@definecolor{colortol-P2-B}{RGB}{68,170,170}
+\pgfutil@definecolor{colortol-P2-C}{RGB}{68,170,119}
+\pgfutil@definecolor{colortol-P2-D}{RGB}{170,170,68}
+\pgfutil@definecolor{colortol-P2-E}{RGB}{170,119,68}
+\pgfutil@definecolor{colortol-P2-F}{RGB}{170,68,85}
+\pgfutil@definecolor{colortol-P2-G}{RGB}{170,68,136}
+% dark
+\pgfutil@definecolor{colortol-P2dark-A}{RGB}{17,68,119}
+\pgfutil@definecolor{colortol-P2dark-B}{RGB}{17,119,119}
+\pgfutil@definecolor{colortol-P2dark-C}{RGB}{17,119,68}
+\pgfutil@definecolor{colortol-P2dark-D}{RGB}{119,119,17}
+\pgfutil@definecolor{colortol-P2dark-E}{RGB}{119,68,17}
+\pgfutil@definecolor{colortol-P2dark-F}{RGB}{119,17,34}
+\pgfutil@definecolor{colortol-P2dark-G}{RGB}{119,17,85}
+
+
+% -----------------------------------------------------------------------------
+% colors from palette III
+\pgfutil@definecolor{colortol-P3-blue}{RGB}{68,119,170}
+\pgfutil@definecolor{colortol-P3-cyan}{RGB}{102,204,238}
+\pgfutil@definecolor{colortol-P3-green}{RGB}{34,136,51}
+\pgfutil@definecolor{colortol-P3-yellow}{RGB}{204,187,68}
+\pgfutil@definecolor{colortol-P3-red}{RGB}{238,102,119}
+\pgfutil@definecolor{colortol-P3-pink}{RGB}{170,51,119}
+% color for data gaps
+\pgfutil@definecolor{colortol-P3-gray}{RGB}{187,187,187}
+
+
+% =============================================================================
+% colors from diverging and sequential palettes
+% sequential palette
+% (same as `YlOrBr' colormap from `ColorBrewer' library)
+\pgfutil@definecolor{colortol-seq-A}{RGB}{255,255,229}
+\pgfutil@definecolor{colortol-seq-B}{RGB}{255,251,213}
+\pgfutil@definecolor{colortol-seq-C}{RGB}{255,247,188}
+\pgfutil@definecolor{colortol-seq-D}{RGB}{254,227,145}
+\pgfutil@definecolor{colortol-seq-E}{RGB}{254,217,142}
+\pgfutil@definecolor{colortol-seq-F}{RGB}{254,196,79}
+\pgfutil@definecolor{colortol-seq-G}{RGB}{251,154,41}
+\pgfutil@definecolor{colortol-seq-H}{RGB}{236,112,20}
+\pgfutil@definecolor{colortol-seq-I}{RGB}{217,95,14}
+\pgfutil@definecolor{colortol-seq-J}{RGB}{204,76,2}
+\pgfutil@definecolor{colortol-seq-K}{RGB}{153,52,4}
+\pgfutil@definecolor{colortol-seq-L}{RGB}{140,45,4}
+\pgfutil@definecolor{colortol-seq-M}{RGB}{102,37,6}
+% color for data gaps
+\pgfutil@definecolor{colortol-seq-gap}{RGB}{136,136,136}
+
+
+% -----------------------------------------------------------------------------
+% diverging palettes
+% -----------------------------------------------------------------------------
+% (similar to `RdYlBu' colormap from `ColorBrewer' library)
+\pgfutil@definecolor{colortol-div-A}{RGB}{0,139,206}
+\pgfutil@definecolor{colortol-div-B}{RGB}{61,82,161}
+\pgfutil@definecolor{colortol-div-C}{RGB}{58,137,201}
+\pgfutil@definecolor{colortol-div-D}{RGB}{119,183,229}
+\pgfutil@definecolor{colortol-div-E}{RGB}{153,199,236}
+\pgfutil@definecolor{colortol-div-F}{RGB}{180,221,247}
+\pgfutil@definecolor{colortol-div-G}{RGB}{230,245,254}
+\pgfutil@definecolor{colortol-div-H}{RGB}{255,250,210}
+\pgfutil@definecolor{colortol-div-I}{RGB}{255,227,170}
+\pgfutil@definecolor{colortol-div-J}{RGB}{249,189,126}
+\pgfutil@definecolor{colortol-div-K}{RGB}{245,162,117}
+\pgfutil@definecolor{colortol-div-L}{RGB}{237,135,94}
+\pgfutil@definecolor{colortol-div-M}{RGB}{210,77,62}
+\pgfutil@definecolor{colortol-div-N}{RGB}{208,50,50}
+\pgfutil@definecolor{colortol-div-O}{RGB}{174,28,62}
+% color for data gaps
+\pgfutil@definecolor{colortol-div-gap}{RGB}{102,102,102}
+
+
+% (reversed `RdBu-9' colormap from `ColorBrewer' library)
+\pgfutil@definecolor{colortol-div2-A}{RGB}{33,102,172}
+\pgfutil@definecolor{colortol-div2-B}{RGB}{67,147,195}
+\pgfutil@definecolor{colortol-div2-C}{RGB}{146,197,222}
+\pgfutil@definecolor{colortol-div2-D}{RGB}{209,229,240}
+\pgfutil@definecolor{colortol-div2-E}{RGB}{247,247,247}
+\pgfutil@definecolor{colortol-div2-F}{RGB}{253,219,199}
+\pgfutil@definecolor{colortol-div2-G}{RGB}{244,165,130}
+\pgfutil@definecolor{colortol-div2-H}{RGB}{214,96,77}
+\pgfutil@definecolor{colortol-div2-I}{RGB}{178,24,43}
+% color for data gaps
+\pgfutil@definecolor{colortol-div2-gaps}{RGB}{255,238,153}
+
+
+% (similar to `PRGn-9' colormap from `ColorBrewer' library,
+% where only color G has changed. (PRGn-J = 166,219,160))
+\pgfutil@definecolor{colortol-div3-A}{RGB}{118,42,131}
+\pgfutil@definecolor{colortol-div3-B}{RGB}{153,112,171}
+\pgfutil@definecolor{colortol-div3-C}{RGB}{194,165,207}
+\pgfutil@definecolor{colortol-div3-D}{RGB}{231,212,232}
+\pgfutil@definecolor{colortol-div3-E}{RGB}{247,247,247}
+\pgfutil@definecolor{colortol-div3-F}{RGB}{217,240,211}
+\pgfutil@definecolor{colortol-div3-G}{RGB}{172,211,158}
+\pgfutil@definecolor{colortol-div3-H}{RGB}{90,174,97}
+\pgfutil@definecolor{colortol-div3-I}{RGB}{27,120,55}
+% color for data gaps
+\pgfutil@definecolor{colortol-div3-gaps}{RGB}{255,238,153}
+
+
+% =============================================================================
+% colors for the rainbow palette (from the TechNote)
+\pgfutil@definecolor{colortol-rainbow-A}{RGB}{120,28,129}
+\pgfutil@definecolor{colortol-rainbow-B}{RGB}{136,46,114}
+\pgfutil@definecolor{colortol-rainbow-C}{RGB}{177,120,166}
+\pgfutil@definecolor{colortol-rainbow-D}{RGB}{214,193,222}
+\pgfutil@definecolor{colortol-rainbow-E}{RGB}{65,59,147}
+\pgfutil@definecolor{colortol-rainbow-F}{RGB}{64,64,150}
+\pgfutil@definecolor{colortol-rainbow-G}{RGB}{63,71,155}
+\pgfutil@definecolor{colortol-rainbow-H}{RGB}{63,78,161}
+\pgfutil@definecolor{colortol-rainbow-I}{RGB}{63,86,167}
+\pgfutil@definecolor{colortol-rainbow-J}{RGB}{63,96,174}
+\pgfutil@definecolor{colortol-rainbow-K}{RGB}{64,101,177}
+\pgfutil@definecolor{colortol-rainbow-L}{RGB}{65,108,183}
+\pgfutil@definecolor{colortol-rainbow-M}{RGB}{66,119,189}
+\pgfutil@definecolor{colortol-rainbow-N}{RGB}{70,131,193}
+\pgfutil@definecolor{colortol-rainbow-O}{RGB}{82,137,199}
+\pgfutil@definecolor{colortol-rainbow-P}{RGB}{72,139,194}
+\pgfutil@definecolor{colortol-rainbow-Q}{RGB}{73,140,194}
+\pgfutil@definecolor{colortol-rainbow-R}{RGB}{75,145,192}
+\pgfutil@definecolor{colortol-rainbow-S}{RGB}{77,149,190}
+\pgfutil@definecolor{colortol-rainbow-T}{RGB}{82,157,183}
+\pgfutil@definecolor{colortol-rainbow-U}{RGB}{83,158,182}
+\pgfutil@definecolor{colortol-rainbow-V}{RGB}{85,161,177}
+\pgfutil@definecolor{colortol-rainbow-W}{RGB}{87,163,173}
+\pgfutil@definecolor{colortol-rainbow-X}{RGB}{91,167,167}
+\pgfutil@definecolor{colortol-rainbow-Y}{RGB}{95,170,159}
+\pgfutil@definecolor{colortol-rainbow-Z}{RGB}{98,172,155}
+\pgfutil@definecolor{colortol-rainbow-AA}{RGB}{99,173,153}
+\pgfutil@definecolor{colortol-rainbow-AB}{RGB}{109,179,136}
+\pgfutil@definecolor{colortol-rainbow-AC}{RGB}{110,179,135}
+\pgfutil@definecolor{colortol-rainbow-AD}{RGB}{125,184,116}
+\pgfutil@definecolor{colortol-rainbow-AE}{RGB}{127,185,114}
+\pgfutil@definecolor{colortol-rainbow-AF}{RGB}{134,187,106}
+\pgfutil@definecolor{colortol-rainbow-AG}{RGB}{145,189,97}
+\pgfutil@definecolor{colortol-rainbow-AH}{RGB}{161,190,86}
+\pgfutil@definecolor{colortol-rainbow-AI}{RGB}{177,190,78}
+\pgfutil@definecolor{colortol-rainbow-AJ}{RGB}{181,189,76}
+\pgfutil@definecolor{colortol-rainbow-AK}{RGB}{190,188,72}
+\pgfutil@definecolor{colortol-rainbow-AL}{RGB}{199,185,68}
+\pgfutil@definecolor{colortol-rainbow-AM}{RGB}{202,184,67}
+\pgfutil@definecolor{colortol-rainbow-AN}{RGB}{211,179,63}
+\pgfutil@definecolor{colortol-rainbow-AO}{RGB}{216,175,61}
+\pgfutil@definecolor{colortol-rainbow-AP}{RGB}{217,173,60}
+\pgfutil@definecolor{colortol-rainbow-AQ}{RGB}{222,167,58}
+\pgfutil@definecolor{colortol-rainbow-AR}{RGB}{223,165,58}
+\pgfutil@definecolor{colortol-rainbow-AS}{RGB}{227,156,55}
+\pgfutil@definecolor{colortol-rainbow-AT}{RGB}{229,148,53}
+\pgfutil@definecolor{colortol-rainbow-AU}{RGB}{230,142,52}
+\pgfutil@definecolor{colortol-rainbow-AV}{RGB}{230,139,51}
+\pgfutil@definecolor{colortol-rainbow-AW}{RGB}{231,133,50}
+\pgfutil@definecolor{colortol-rainbow-AX}{RGB}{231,124,48}
+\pgfutil@definecolor{colortol-rainbow-AY}{RGB}{231,116,47}
+\pgfutil@definecolor{colortol-rainbow-AZ}{RGB}{231,109,46}
+\pgfutil@definecolor{colortol-rainbow-BA}{RGB}{230,104,45}
+\pgfutil@definecolor{colortol-rainbow-BB}{RGB}{230,100,44}
+\pgfutil@definecolor{colortol-rainbow-BC}{RGB}{232,96,28}
+\pgfutil@definecolor{colortol-rainbow-BD}{RGB}{217,33,32}
+\pgfutil@definecolor{colortol-rainbow-BE}{RGB}{220,5,12}
+% ---
+\pgfutil@definecolor{colortol-rainbow-BF}{RGB}{25,101,176}
+\pgfutil@definecolor{colortol-rainbow-BG}{RGB}{123,175,222}
+\pgfutil@definecolor{colortol-rainbow-BH}{RGB}{78,178,101}
+\pgfutil@definecolor{colortol-rainbow-BI}{RGB}{144,201,135}
+\pgfutil@definecolor{colortol-rainbow-BJ}{RGB}{202,224,171}
+\pgfutil@definecolor{colortol-rainbow-BK}{RGB}{247,238,85}
+\pgfutil@definecolor{colortol-rainbow-BL}{RGB}{246,193,65}
+\pgfutil@definecolor{colortol-rainbow-BM}{RGB}{241,147,45}
+% color for data gaps
+\pgfutil@definecolor{colortol-rainbow-gap}{RGB}{119,119,119}
+
+
+% -----------------------------------------------------------------------------
+% rainbow continuous palette
+\pgfutil@definecolor{colortol-rainbow-cont-A}{rgb}{0.47200,0.10893,0.50761}
+\pgfutil@definecolor{colortol-rainbow-cont-B}{rgb}{0.34213,0.09855,0.49621}
+\pgfutil@definecolor{colortol-rainbow-cont-C}{rgb}{0.28275,0.14652,0.52189}
+\pgfutil@definecolor{colortol-rainbow-cont-D}{rgb}{0.25545,0.22543,0.57205}
+\pgfutil@definecolor{colortol-rainbow-cont-E}{rgb}{0.24671,0.31603,0.63730}
+\pgfutil@definecolor{colortol-rainbow-cont-F}{rgb}{0.25077,0.40567,0.70361}
+\pgfutil@definecolor{colortol-rainbow-cont-G}{rgb}{0.26491,0.48682,0.75045}
+\pgfutil@definecolor{colortol-rainbow-cont-H}{rgb}{0.28782,0.55584,0.75812}
+\pgfutil@definecolor{colortol-rainbow-cont-I}{rgb}{0.31885,0.61177,0.72118}
+\pgfutil@definecolor{colortol-rainbow-cont-J}{rgb}{0.35763,0.65539,0.65239}
+\pgfutil@definecolor{colortol-rainbow-cont-K}{rgb}{0.40379,0.68838,0.57183}
+\pgfutil@definecolor{colortol-rainbow-cont-L}{rgb}{0.45673,0.71262,0.49478}
+\pgfutil@definecolor{colortol-rainbow-cont-M}{rgb}{0.51545,0.72969,0.42849}
+\pgfutil@definecolor{colortol-rainbow-cont-N}{rgb}{0.57835,0.74051,0.37454}
+\pgfutil@definecolor{colortol-rainbow-cont-O}{rgb}{0.64317,0.74507,0.33179}
+\pgfutil@definecolor{colortol-rainbow-cont-P}{rgb}{0.70698,0.74240,0.29822}
+\pgfutil@definecolor{colortol-rainbow-cont-Q}{rgb}{0.76646,0.73065,0.27175}
+\pgfutil@definecolor{colortol-rainbow-cont-R}{rgb}{0.81822,0.70734,0.25045}
+\pgfutil@definecolor{colortol-rainbow-cont-S}{rgb}{0.85937,0.66972,0.23257}
+\pgfutil@definecolor{colortol-rainbow-cont-T}{rgb}{0.88791,0.61535,0.21650}
+\pgfutil@definecolor{colortol-rainbow-cont-U}{rgb}{0.90305,0.54279,0.20076}
+\pgfutil@definecolor{colortol-rainbow-cont-V}{rgb}{0.90520,0.45244,0.18413}
+\pgfutil@definecolor{colortol-rainbow-cont-W}{rgb}{0.89577,0.34756,0.16585}
+\pgfutil@definecolor{colortol-rainbow-cont-X}{rgb}{0.87679,0.23541,0.14585}
+\pgfutil@definecolor{colortol-rainbow-cont-Y}{rgb}{0.85054,0.12858,0.12484}
+
+
+% -----------------------------------------------------------------------------
+% colors for the extended rainbow palette (from the website)
+\pgfutil@definecolor{colortol-rainbow-ext-low-A}{RGB}{232,236,251}
+\pgfutil@definecolor{colortol-rainbow-ext-low-B}{RGB}{221,216,239}
+\pgfutil@definecolor{colortol-rainbow-ext-low-C}{RGB}{209,193,225}
+\pgfutil@definecolor{colortol-rainbow-ext-low-D}{RGB}{195,168,209}
+\pgfutil@definecolor{colortol-rainbow-ext-low-E}{RGB}{181,143,194}
+\pgfutil@definecolor{colortol-rainbow-ext-low-F}{RGB}{167,120,180}
+\pgfutil@definecolor{colortol-rainbow-ext-low-G}{RGB}{155,98,167}
+\pgfutil@definecolor{colortol-rainbow-ext-low-H}{RGB}{140,78,153}
+% ---
+\pgfutil@definecolor{colortol-rainbow-ext-A}{RGB}{111,76,155}
+\pgfutil@definecolor{colortol-rainbow-ext-B}{RGB}{96,89,169}
+\pgfutil@definecolor{colortol-rainbow-ext-C}{RGB}{85,104,184}
+\pgfutil@definecolor{colortol-rainbow-ext-D}{RGB}{78,121,197}
+\pgfutil@definecolor{colortol-rainbow-ext-E}{RGB}{77,138,198}
+\pgfutil@definecolor{colortol-rainbow-ext-F}{RGB}{78,150,188}
+\pgfutil@definecolor{colortol-rainbow-ext-G}{RGB}{84,158,179}
+\pgfutil@definecolor{colortol-rainbow-ext-H}{RGB}{89,165,169}
+\pgfutil@definecolor{colortol-rainbow-ext-I}{RGB}{96,171,158}
+\pgfutil@definecolor{colortol-rainbow-ext-J}{RGB}{105,177,144}
+\pgfutil@definecolor{colortol-rainbow-ext-K}{RGB}{119,183,125}
+\pgfutil@definecolor{colortol-rainbow-ext-L}{RGB}{140,188,104}
+\pgfutil@definecolor{colortol-rainbow-ext-M}{RGB}{166,190,84}
+\pgfutil@definecolor{colortol-rainbow-ext-N}{RGB}{190,188,72}
+\pgfutil@definecolor{colortol-rainbow-ext-O}{RGB}{209,181,65}
+\pgfutil@definecolor{colortol-rainbow-ext-P}{RGB}{221,170,60}
+\pgfutil@definecolor{colortol-rainbow-ext-Q}{RGB}{228,156,57}
+\pgfutil@definecolor{colortol-rainbow-ext-R}{RGB}{231,140,53}
+\pgfutil@definecolor{colortol-rainbow-ext-S}{RGB}{230,121,50}
+\pgfutil@definecolor{colortol-rainbow-ext-T}{RGB}{228,99,45}
+\pgfutil@definecolor{colortol-rainbow-ext-U}{RGB}{223,72,40}
+\pgfutil@definecolor{colortol-rainbow-ext-V}{RGB}{218,34,34}
+% ---
+\pgfutil@definecolor{colortol-rainbow-ext-high-A}{RGB}{184,34,30}
+\pgfutil@definecolor{colortol-rainbow-ext-high-B}{RGB}{149,33,27}
+\pgfutil@definecolor{colortol-rainbow-ext-high-C}{RGB}{114,30,23}
+\pgfutil@definecolor{colortol-rainbow-ext-high-D}{RGB}{82,26,19}
+% color for data gaps
+\pgfutil@definecolor{colortol-rainbow-ext-gaps}{RGB}{102,102,102}
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarydateplot.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarydateplot.code.tex
new file mode 100644
index 0000000000..04bcb776a2
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/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/graphics/pgf/contrib/pgfplots/tex/tikzlibrarydecorations.softclip.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarydecorations.softclip.code.tex
new file mode 100644
index 0000000000..7544d66d31
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarydecorations.softclip.code.tex
@@ -0,0 +1,517 @@
+%--------------------------------------------
+%
+% 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 2013 by Christian Feuersaenger
+%
+% 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 library adds support for a "soft clip" decoration. It applies
+% clipping to an input path, but rather than simply instructing the
+% display driver to clip the path, it computes a new clip path from
+% the input.
+%
+% This library is (currently) on top of tikz.
+
+\pgfutil@IfUndefined{pgfplotsset}{%
+ \pgferror{Please load pgfplots before pgfplots.fillbetween.}%
+ \endinput
+}{}%
+
+\usetikzlibrary{intersections}
+
+\pgfplots@iffileexists{pgflibraryfillbetween.code.tex}{%
+ \usepgflibrary{fillbetween}
+}{%
+ \pgfplotsusecompatibilityfile{pgflibraryfillbetween.code.tex}%
+}%
+
+\pgfutil@IfUndefined{pgfintersectiongetsolutiontimes}{%
+ \pgfplotsusecompatibilityfile{pgflibraryintersections.code.tex}%
+}{}%
+
+
+\pgfkeys{
+ % soft clip={(axis cs:0,0) rectangle (axis cs:1,1)}
+ % or
+ % soft clip={A}
+ % where 'A' is defined using 'name path=A' somewhere
+ /pgf/decoration/soft clip path/.code={%
+ % FIXME : I would rather NOT evaluate path arguments in this
+ % context! Who knows how people set keys!? But alas, we cannot
+ % evaluate late because the CM is reset while working on
+ % decorations ... (see below)
+ \tikzlibsoftclip@setkey{\tikzlibsoftclip@setkey@assign}#1\pgf@stop
+ },
+ /pgf/decoration/every soft clipped path/.style={},%
+}
+
+% #1 a macro containing a soft path
+\def\tikzlibsoftclip@setkey@assign#1{%
+ \let\pgf@decoration@soft@clip=#1%
+}%
+
+\tikzlibsoftclip@setkey@assign{\pgfutil@empty}%
+
+\pgfdeclaredecoration{soft clip}{replace}{
+
+ \state{replace}[width=\pgfdecoratedpathlength,
+ persistent precomputation={%
+ % This here is an earlier draft... but alas, the
+ % transformation matrix has been reset in this context,
+ % and we cannot define the clip path dynamically here.
+ % I left it to document that.
+ %
+ %\pgfkeysgetvalue{/pgf/decoration/soft clip path}\pgf@temp
+ %\def\tikz@marshal{\tikzlibsoftclip@setkey{\tikzlibsoftclip@setkey@assign}}%
+ %\expandafter\tikz@marshal\pgf@temp\pgf@stop
+ }
+ ]{%
+ \ifx\pgf@decoration@soft@clip\pgfutil@empty
+ \pgfplotsthrow{invalid argument}
+ {\pgf@decoration@soft@clip}%
+ {The mandatory argument 'soft clip path=(A) rectangle (B)' has not been set}%
+ \pgfeov
+ \else
+ \tikzset{/pgf/decoration/every soft clipped path}%
+ \pgfpathcomputesoftclippath{\pgfdecoratedpath}{\pgf@decoration@soft@clip}%
+ \pgfsetpathandBB{\pgfretval}%
+ \fi
+ }
+}
+
+% ---------------------------------------------------------------------------------
+%
+% SOFT-CLIPPING.
+%
+% "softclip" means to get rid of those parts of a path which are
+% outside of a clip path.
+%
+% An example is to trim at the beginning and/or end of a
+% path as part of fill-between ("poor-mans-clipping").
+%
+% The difference to "real" clipping is that it is applied to the
+% path, not to the viewer -- the path can still be drawn with any
+% decorations, line widths, etc.
+%
+% Another difference is that this feature is (considerably) less sophisticated.
+%
+% #1: the input path
+% #2: the clip path (if it is empty, no clipping will be applied)
+% OUTPUT:
+% \pgfretval is #1 with modifications
+\def\pgfpathcomputesoftclippath#1#2{%
+ \ifx#2\pgfutil@empty
+ \let\pgfretval=#1%
+ \else
+ \ifx#1\pgfutil@empty
+ \let\pgfretval=#1%
+ \else
+ \pgfpathcomputesoftclippath@{#1}{#2}%
+ \fi
+ \fi
+}
+
+\def\pgfpathcomputesoftclippath@#1#2{%
+ \begingroup
+ \pgfprocessround{#1}{#1}%
+ \pgfprocessround{#2}{#2}%
+ %
+ %
+ \pgfpathcomputesoftclippath@is@first@outside@of@path{#1}{#2}%
+ \let\b@pgffill@is@outside@clip=\pgfretval
+ %
+%\message{computing soft clip path for ^^J\meaning#1 and ^^J\meaning#2^^J first point of input is outside of clip path=\b@pgffill@is@outside@clip^^J}%
+ %
+ % FIXME : it might be that I need to sort them ... !? but
+ % other tests indicate that I should not!?
+ %\pgfintersectionsortbyfirstpath
+ \pgf@intersect@sortfalse
+ \pgfintersectionofpaths%
+ {%
+ \pgfsetpath#1%
+ }%
+ {%
+ \pgfsetpath#2%
+ }%
+ %
+%\message{... num intersections = \pgfintersectionsolutions^^J}%
+ %
+ \ifnum\pgfintersectionsolutions=0 %
+ \if1\b@pgffill@is@outside@clip
+ % entire path is outside of the clipped area.
+ \let\pgfretval=\pgfutil@empty
+ \else
+ \let\pgfretval=#1%
+ \fi
+ \else
+ % split the first involved path into the
+ % segments induced by the intersection points:
+ \pgfcomputeintersectionsegments{1}%
+ \let\pgfpathfilled@a@segments=\pgfretval
+ %
+ % Now, create a new path which contains only those
+ % segments which are INSIDE of the clip path.
+ %
+ % I assume that I can rely on "even/odd" matching: if the
+ % first is inside, the second is outside, the third
+ % inside, etc.
+ \pgfapplistnewempty{pgfretval@tmp}%
+ \def\c@pgfpathfilled@counter{0}%
+ \pgfmathloop
+ \ifnum\c@pgfpathfilled@counter<\pgfpathfilled@a@segments\relax
+ \if0\b@pgffill@is@outside@clip
+ \expandafter\let\expandafter\pgf@loc@path@a\csname pgf@intersect@path@split@a@\c@pgfpathfilled@counter\endcsname
+ \expandafter\pgfapplistpushback\pgf@loc@path@a\to{pgfretval@tmp}%
+ \fi
+ \pgfpathfillbetween@negate\b@pgffill@is@outside@clip
+ %
+ \pgfutil@advancestringcounter\c@pgfpathfilled@counter
+ \repeatpgfmathloop
+ \pgfapplistlet\pgfretval={pgfretval@tmp}%
+ \fi
+ %
+ \global\let\pgf@glob@TMPa=\pgfretval%
+ \endgroup
+ \let\pgfretval=\pgf@glob@TMPa
+}
+
+% #1: input path (non-empty)
+% #2: soft clip path
+% Defines "\def\pgfretval{1}" if (the first point of #1 is outside or on the path #2)
+% Defines "\def\pgfretval{0}" if (the first point of #1 is inside of the path #2)
+\def\pgfpathcomputesoftclippath@is@first@outside@of@path#1#2{%
+ % APPROACH: shoot a line starting at the first coordinate of the
+ % first path through "the middle of #2". Then make an even/odd
+ % check on the number of intersections.
+ %
+ % FIXME : for now, I only support (x,y) rectangle (X,Y) anyway --
+ % optimize for that case!? This here might be too complex...
+ \begingroup
+ \expandafter\pgfpathfillbetween@get@first@coord#1\pgf@stop
+ \let\pgfpathfilled@a@firstcoord=\pgfretval%
+ %
+ % Get some point "in the middle of #2":
+ \pgfpathcomputesoftclippath@accum@pseudo@mean#2%
+ \edef\pgfpathfilled@b@center{\noexpand\pgfqpoint\pgfretval}%
+ %
+ % We have to shoot *through* #2, not just into the middle of #2.
+ % Consequently, we need to know how big #2 is:
+ \pgfpathcomputesoftclippath@is@first@outside@of@path@getBB#2%
+ \let\pgf@size@hint=\pgfretval
+ %
+ % Now, compute a target point such that our shot goes through it:
+ \pgfqpointscale{%
+ \pgf@size@hint
+ }{%
+ \pgfpointnormalised{%
+ \pgfpointdiff%
+ {\expandafter\pgfqpoint\pgfpathfilled@a@firstcoord}%
+ {\pgfpathfilled@b@center}%
+ }%
+ }%
+ % collect intermediate results as \pgf@xa/\pgf@ya are overwritten:
+ \edef\pgf@direction@vector{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfpointadd{\pgfpathfilled@b@center}{\pgf@direction@vector}%
+ \edef\pgfpathfilled@shoot@line@trg{{\the\pgf@x}{\the\pgf@y}}%
+ %
+ % this here is our path!
+ \edef\pgf@direction@path{%
+ \noexpand\pgfsyssoftpath@movetotoken\pgfpathfilled@a@firstcoord
+ \noexpand\pgfsyssoftpath@linetotoken\pgfpathfilled@shoot@line@trg
+ }%
+ %
+ % ... ok, compute intersections. This should be fairly fast as
+ % our second path has just 1 segment, i.e. it will be O(N) where N
+ % is the number of segments in #2.
+ \pgf@intersect@sortfalse
+ \pgfintersectionofpaths%
+ {%
+ \pgfsetpath#2%
+ }%
+ {%
+ \pgfsetpath\pgf@direction@path%
+ }%
+ %
+ \ifnum\pgfintersectionsolutions=0 %
+ % this must not happen! We have taken great care such that we
+ % *have* at least 1 intersection points!
+ \pgferror{Illegal state encountered: the computation of a softpath failed. The failure occurred while computing whether the first input coordinate is inside of the clip path (found no intersections)}%
+ \fi
+ %
+ \pgfpathcomputesoftclippath@if@is@first@on@boundary{%
+ % AH! The first point is ON the boundary of the clip path.
+ % This is equivalent to the condition that the first
+ % intersection point equals the first point.
+ %
+ % In this case, we say that it is OUTSIDE of the clip path!
+ %
+ % This is actually related to
+ % 1. the fact that the input path is splitted into segments
+ % induced by the intersection points in order to apply
+ % soft-clipping.
+ % 2. the fact that the clipping is based on an even/odd
+ % matching (in/out).
+ %
+ % In that setup, we want to skip the segment until the first
+ % intersection point - after all, it is "empty" anyway.
+ %
+ % To this end, we have to say that this first (empty) segment
+ % is OUTSIDE:
+ \def\pgfretval{1}%
+ }{%
+ \ifodd\pgfintersectionsolutions\relax%
+ \def\pgfretval{0}%
+ \else
+ \def\pgfretval{1}%
+ \fi
+ }%
+ \pgfmath@smuggleone\pgfretval
+ \endgroup
+}
+
+\def\pgfpathcomputesoftclippath@if@is@first@on@boundary#1#2{%
+ \pgfpathcomputesoftclippath@compute@infty@norm{%
+ \pgfpointdiff%
+ {\expandafter\pgfqpoint\pgfpathfilled@a@firstcoord}%
+ {\pgfpointintersectionsolution{1}}%
+ }%
+ \ifdim\pgf@x<\pgfintersectiontolerance\relax
+ % YES: the first point IS on the boundary: the first
+ % intersection solution == first point.
+ #1%
+ \else
+ % No, it is NOT equal to the first intersection solution - and
+ % thus NOT on the boundary.
+ #2%
+ \fi
+}%
+
+% Defines \pgf@x to be the infty norm of vector #1
+\def\pgfpathcomputesoftclippath@compute@infty@norm#1{%
+ \pgf@process{#1}%
+ \ifdim\pgf@x<0sp \global\pgf@x=-\pgf@x\fi
+ \ifdim\pgf@y<0sp \global\pgf@y=-\pgf@y\fi
+ \ifdim\pgf@x<\pgf@y
+ \global\pgf@x=\pgf@y
+ \fi
+}
+
+% Defines \pgfretval to be a *scalar* "size indicator" (1-norm) of the bounding
+% box of #1.
+%
+% #1: a macro containing a softpath.
+\def\pgfpathcomputesoftclippath@is@first@outside@of@path@getBB#1{%
+ \begingroup
+ \pgf@getpathsizes\pgf@interrupt@pathsizes
+ % we only need the path size here:
+ \pgf@relevantforpicturesizefalse
+ %
+ % FIXME : CODE CLEANUP NEEDED
+ \def\pgfsetpathBB@protocol@lastmoveto##1##2{}%
+ \expandafter\pgfsetpath@loop#1\pgf@stop
+ \pgfpointdiff
+ {\pgfqpoint\pgf@pathminx\pgf@pathminy}%
+ {\pgfqpoint\pgf@pathmaxx\pgf@pathmaxy}%
+ % compute |v|_1 = x + y (both components are non-negative anyway):
+ \pgf@xa=\pgf@x
+ \advance\pgf@xa by\pgf@y
+ \xdef\pgf@glob@TMPa{\pgf@sys@tonumber\pgf@xa}%
+ \pgf@setpathsizes\pgf@interrupt@pathsizes
+ \endgroup
+ \let\pgfretval=\pgf@glob@TMPa
+}%
+
+% Defines \pgfretval to be of a "pseudo" mean of path #1.
+%
+% Here, "pseudo" refers to the fact that the mean will only be
+% accumulated over the "first couple of coordinates" to avoid numeric
+% overflows in TeX's math engine.
+\def\pgfpathcomputesoftclippath@accum@pseudo@mean#1{%
+ \begingroup
+ \let\pgfsyssoftpath@movetotoken\pgfpathcomputesoftclippath@accum@pseudo@mean@
+ \let\pgfsyssoftpath@linetotoken\pgfpathcomputesoftclippath@accum@pseudo@mean@
+ \let\pgfsyssoftpath@closepathtoken\pgfpathcomputesoftclippath@accum@pseudo@mean@
+ \let\pgfsyssoftpath@curvetotoken\pgfpathcomputesoftclippath@accum@pseudo@mean@
+ \let\pgfsyssoftpath@curvetosupportatoken\pgfpathcomputesoftclippath@accum@pseudo@mean@relax
+ \let\pgfsyssoftpath@curvetosupportbtoken\pgfpathcomputesoftclippath@accum@pseudo@mean@relax
+ \c@pgf@countc=0 %
+ \pgf@xa=0pt %
+ \pgf@ya=0pt %
+ #1%
+ \divide\pgf@xa by\c@pgf@countc
+ \divide\pgf@ya by\c@pgf@countc
+ \edef\pgfretval{{\the\pgf@xa}{\the\pgf@ya}}%
+ \pgfmath@smuggleone\pgfretval
+ \endgroup
+}%
+\def\pgfpathcomputesoftclippath@accum@pseudo@mean@relax#1#2{}
+\def\pgfpathcomputesoftclippath@accum@pseudo@mean@#1#2{%
+ \ifnum\c@pgf@countc<4
+ % avoid overflows. 4 must be sufficient for now.
+ \advance\pgf@xa by#1\relax
+ \advance\pgf@ya by#2\relax
+ \advance\c@pgf@countc by1 %
+ \fi
+}
+
+
+% #1: of the form '{<x>}{<y>}'
+% #2: of the form '{<x>}{<y>}'
+\def\pgfpathfillbetween@check@x@less@than#1#2{%
+ \edef\pgf@temp{#1#2}%
+ \expandafter\pgfpathfillbetween@check@x@less@than@\pgf@temp
+}%
+
+% #1: x1
+% #2: y1
+% #3: x2
+% #4: y2
+\def\pgfpathfillbetween@check@x@less@than@#1#2#3#4{%
+ \ifdim#1>#3\relax
+ % <=
+ \def\pgfretval{0}%
+ \else
+ \def\pgfretval{1}%
+ \fi
+}%
+
+\def\pgfpathfillbetween@negate#1{%
+ \if0#1%
+ \def#1{1}%
+ \else
+ \def#1{0}%
+ \fi
+}
+
+\pgfkeys{
+ /tikz/soft clip assign/name/.code={\tikzgetnamedpath{#1}},
+ /tikz/soft clip assign/path/.code={\tikzlibsoftclip@setkey@@#1\pgf@stop},
+}
+
+%
+% \tikzlibsoftclip@setkey{<\macro>} <path name>\pgf@stop
+%
+% OR
+%
+% \tikzlibsoftclip@setkey{<\macro>} (<A>) rectangle (<B>)\pgf@stop
+%
+% #1: a macro which is called with the resulting clip path as argument #1.
+\def\tikzlibsoftclip@setkey#1#2\pgf@stop{%
+ \pgfutil@in@{=}{#2}%
+ \ifpgfutil@in@
+ \pgfqkeys{/tikz/soft clip assign}{#2}%
+ \else
+ \def\pgf@temp{#2}%
+ \pgfplots@command@to@string\pgf@temp\pgf@temp
+ %
+ \tikzifisnamedpath{\pgf@temp}{%
+ \pgfkeysalso{/tikz/soft clip assign/name={#2}}%
+ }{%
+ \pgfkeysalso{/tikz/soft clip assign/path={#2}}%
+ }%
+ \fi
+ #1{\pgfretval}%
+}
+
+\def\tikzlibsoftclip@setkey@@{%
+ %
+ \tikz@scan@one@point\tikzlibsoftclip@setkey@bb@scan@a
+}%
+
+\def\tikzlibsoftclip@setkey@bb@scan@a#1{%
+ \def\tikzlibsoftclip@setkey@bb@a{#1}%
+ \pgfutil@ifnextchar r{%
+ \tikzlibsoftclip@setkey@bb@scan@rectangle
+ }{%
+ \tikzlibsoftclip@setkey@@error
+ }%
+}%
+
+\def\tikzlibsoftclip@setkey@bb@scan@rectangle rectangle{%
+ \tikz@scan@one@point\tikzlibsoftclip@setkey@bb@scan@b
+}%
+
+\def\tikz@gobble@until@stop#1\pgf@stop{}%
+
+\def\tikzlibsoftclip@setkey@bb@scan@b#1{%
+ \def\tikzlibsoftclip@setkey@bb@b{#1}%
+ \pgfutil@ifnextchar \pgf@stop{%
+ \tikzlibsoftclip@setkey@@activate
+ \tikz@gobble@until@stop
+ }{%
+ \tikzlibsoftclip@setkey@@error
+ }%
+}%
+
+\def\tikzlibsoftclip@setkey@@error#1\pgf@stop{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \pgfplotsthrow{invalid argument}
+ {\pgfplots@loc@TMPa}%
+ {fill between: the argument of 'soft clip' has an unexpected format near '\pgfplots@loc@TMPb'; expected '(<pt>) rectangle (<pt>)'}%
+ \pgfeov
+}%
+
+% INPUT:
+% - two PGF points \tikzlibsoftclip@setkey@bb@a and \tikzlibsoftclip@setkey@bb@b.
+%
+% POSTCONDITION: \pgfretval contains the resulting path.
+\def\tikzlibsoftclip@setkey@@activate{%
+ % Expand points to {<x>}{<y>} ...
+ \pgf@process{\tikzlibsoftclip@setkey@bb@a}%
+ \edef\tikzlibsoftclip@setkey@bb@a{{\the\pgf@x}{\the\pgf@y}}%
+ \pgf@process{\tikzlibsoftclip@setkey@bb@b}%
+ \edef\tikzlibsoftclip@setkey@bb@b{{\the\pgf@x}{\the\pgf@y}}%
+ %
+ \pgfinterruptpath
+ \pgf@relevantforpicturesizefalse%
+ \expandafter\pgfqpoint\tikzlibsoftclip@setkey@bb@a
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \expandafter\pgfqpoint\tikzlibsoftclip@setkey@bb@b
+ \pgf@xb=\pgf@x
+ \pgf@yb=\pgf@y
+ %
+ \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}}%
+ \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}}%
+ \pgfpathclose
+ \pgfgetpath\pgfplots@loc@TMPa
+ \global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa
+ \endpgfinterruptpath
+ %
+ \let\pgfretval=\pgfplots@glob@TMPa
+}%
+% ---------------------------------------------------------------------------------
+
+% Executes #2 if #1 is a named path and #3 otherwise.
+\def\tikzifisnamedpath#1#2#3{%
+ \pgfutil@IfUndefined{tikz@intersect@path@name@#1}{%
+ \def\tikz@next{#3}%
+ }{%
+ \def\tikz@next{#2}%
+ }%
+ \tikz@next
+}%
+
+
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibraryfillbetween.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibraryfillbetween.code.tex
new file mode 100644
index 0000000000..d5a153c055
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibraryfillbetween.code.tex
@@ -0,0 +1,577 @@
+%--------------------------------------------
+%
+% 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 2013 by Christian Feuersaenger
+%
+% 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 library adds support for high-level instructions for "fill area
+% between two arbitrary plots of functions".
+%
+% It activates the syntax \pgfpathfillbetween
+% where A and B are two plots named by 'name path='.
+%
+% In fact, this here is not much more than a low-level invocation of
+% \pgfpathfillbetween
+% and a couple of styles. It could become a TikZ library because it
+% actually works on any two named paths, but it has its restrictions
+% regarding the supported input paths: both need to be plots of
+% functions (non-intersecting, should have at most one function value
+% for each canvas X coord)
+
+\pgfutil@IfUndefined{pgfplotsset}{%
+ \pgferror{Please load pgfplots before pgfplots.fillbetween.}%
+ \endinput
+}{}%
+
+\usetikzlibrary{intersections}
+\usetikzlibrary{decorations.softclip}
+
+% COMPATIBILITY WITH PGF RELEASE:
+\pgfutil@IfUndefined{pgfintersectiongetsolutiontimes}{%
+ \pgfplotsusecompatibilityfile{pgflibraryintersections.code.tex}%
+}{}%
+\def\tikz@key@name@path@wrong#1#2{%
+ \tikz@addmode{%
+ \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round%
+ \pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath%
+ \ifx\tikz@intersect@namedpaths\pgfutil@empty%
+ \else%
+ \tikz@intersect@namedpaths%
+ \pgfutil@ifundefined{tikz@intersect@path@name@#1}{}%
+ {%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@intersect@@temppath%
+ \expandafter\expandafter\expandafter{\csname tikz@intersect@path@name@#1\endcsname}%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@intersect@temppath%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@intersect@temppath\tikz@intersect@temppath}%
+ }%
+ \fi%
+ \tikz@intersect@addto@path@names{#1}{#2}%
+ }%
+}%
+
+\def\tikz@key@name@path@new#1#2{%
+ \tikz@addmode{%
+ \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round%
+ \pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath%
+ \ifx\tikz@intersect@namedpaths\pgfutil@empty%
+ \else%
+ \tikz@intersect@namedpaths%
+ \fi%
+ \tikz@intersect@addto@path@names{#1}{#2}%
+ }%
+}%
+
+\ifx\tikz@key@name@path@wrong\tikz@key@name@path
+ \immediate\write16{Package pgfplots: loading complementary 'name path' implementation for your pgf version...}
+ \let\tikz@key@name@path=\tikz@key@name@path@new
+\fi
+
+% ------------------------------------------------------------
+
+\newif\iftikzfillbetween@optimize@name@intersections
+
+\pgfkeys{%
+ /tikz/fill between/of/.code=\tikzlibraryfillbetween@parse#1\pgf@stop,
+ %
+ /tikz/fill between/on layer/.initial=pre main,
+ /tikz/fill between/every segment/.style={},
+ /tikz/fill between/every odd segment/.style={},
+ /tikz/fill between/every even segment/.style={},
+ /tikz/fill between/every last segment/.style={},
+ %
+ % Allows to add path instructions *after* the segment.
+ % If you want to add some *before* the segment, you can rely on
+ % 'every segment no 0/.style={ ... suitable tikz options ... }'
+ /tikz/fill between/path after segment/.initial={},
+ %
+ % soft clip={(axis cs:0,0) rectangle (axis cs:1,1)}
+ /tikz/fill between/soft clip/.style={
+ /tikz/fill between/soft clip first={#1},%
+ /tikz/fill between/soft clip second={#1},%
+ },%
+ /tikz/fill between/soft clip first/.initial=,%
+ /tikz/fill between/soft clip second/.initial=,
+ %
+ % #1: drawing options.
+ /tikz/fill between/@draw style/.style={
+ /pgf/fill between/result stream/begin/.code={%
+ \gdef\tikzsegmentindex{0}%
+ \xdef\tikzsegmentindices{##1}%
+ \c@pgf@countc=##1 %
+ \advance\c@pgf@countc by-1 %
+ \xdef\tikzsegmentlastindex{\the\c@pgf@countc}%
+ },%
+ /pgf/fill between/result stream/next ready/.code={%
+ \let\pgflibraryfill@path=\pgfretval
+ \def\pgfplots@loc@TMPa{%
+ /tikz/fill between/every segment,
+ #1,%
+ /tikz/fill between/every segment no \tikzsegmentindex/.try,
+ }%
+ \ifodd\tikzsegmentindex\relax
+ \expandafter\def\expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@loc@TMPa
+ /tikz/fill between/every odd segment,
+ }%
+ \else
+ \expandafter\def\expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@loc@TMPa
+ /tikz/fill between/every even segment,
+ }%
+ \fi
+ %
+ \ifnum\tikzsegmentindex=\tikzsegmentlastindex\relax
+ \expandafter\def\expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@loc@TMPa
+ /tikz/fill between/every last segment,
+ }%
+ \fi
+ %
+ \expandafter\fill\expandafter[\pgfplots@loc@TMPa]
+ \pgfextra
+ \pgfsetpathandBB{\pgflibraryfill@path}%
+ \pgfkeysgetvalue{/tikz/fill between/path after segment}\tikz@fillbetween@post@segment
+ \expandafter
+ \endpgfextra
+ \tikz@fillbetween@post@segment
+ ;%
+ \pgfplotsutil@advancestringcounter@global\tikzsegmentindex
+ },%
+ /pgf/fill between/result stream/end/.code=,%
+ },
+ /tikz/fill between/.search also={/pgf/fill between,/pgfplots},
+ /tikz/fill between/optimize name intersections/.is if=tikzfillbetween@optimize@name@intersections,
+ %
+ % FIXME : this optimization needs much more work... I believe it
+ % would be stable enough, but it covers too few cases.
+ %/tikz/fill between/optimize name intersections=true,
+ %
+ %
+ %
+ %--------------------------------------------------
+ % /pgfplots/execute at begin axis@@/.add={%
+ % \def\b@pgfplotslibraryfill@added
+ % }{%
+ %
+ % },%
+ %--------------------------------------------------
+}
+
+\def\tikzlibraryfillbetween@parse#1 and #2\pgf@stop{%
+ \def\tikz@fillbetween@a{#1}%
+ \def\tikz@fillbetween@b{#2}%
+}%
+
+% \tikzfillbetween[<options>]{<draw style>}
+%
+% <options> must contain 'of=<A> and <B>' and may configure how the
+% area is computed.
+%
+% <draw style> affects every drawn region.
+%
+\def\tikzfillbetween{\pgfutil@ifnextchar[{\tikzfillbetween@opt}{\tikzfillbetween@opt[]}}
+\def\tikzfillbetween@opt[#1]#2{%
+ \begingroup
+ \pgfqkeys{/tikz/fill between}{%
+ % prepare the low-level path generation instruction(s):
+ /tikz/fill between/@draw style={#2},%
+ %
+ % set up input options:
+ #1,%
+ }%
+ % automagically try to use the correct layer:
+ \pgfkeysgetvalue{/tikz/fill between/on layer}\tikzlibraryfillbetween@path@layer@name
+ \tikzlibraryfillbetween@determine@layer
+ %
+ \ifx\tikzlibraryfillbetween@path@layer@name\pgfutil@empty \else
+ \pgfonlayer{\tikzlibraryfillbetween@path@layer@name}%
+ \fi
+ %
+ \tikzlibraryfillbetween@path@generatepath
+ %
+ \ifx\tikzlibraryfillbetween@path@layer@name\pgfutil@empty \else
+ \endpgfonlayer%
+ \fi
+ %
+ \endgroup
+}%
+
+% Defines \tikzlibraryfillbetween@path@layer@name
+\def\tikzlibraryfillbetween@determine@layer{%
+ \ifx\tikzlibraryfillbetween@path@layer@name\pgfutil@empty
+ \else
+ \pgfutil@IfUndefined{pgf@layerlist}{%
+ % hm. No layers active!? A pity...
+ \tikzlibraryfillbetween@path@warn@layer
+ \let\tikzlibraryfillbetween@path@layer@name\pgfutil@empty%
+ }{%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfutil@in@{\tikzlibraryfillbetween@path@layer@name}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgf@layerlist}%
+ \ifpgfutil@in@
+ \else
+ \tikzlibraryfillbetween@path@warn@layer
+ \let\tikzlibraryfillbetween@path@layer@name\pgfutil@empty%
+ \fi
+ }%
+ \fi
+}%
+
+\def\tikzlibraryfillbetween@path@warn@layer{%
+ \pgfplots@warning{'fill between': Could not activate graphics layer '\tikzlibraryfillbetween@path@layer@name'. Filled path will be on top of the other ones. Please ensure that '\tikzlibraryfillbetween@path@layer@name' is somewhere in the layer list (or set '/tikz/fill between/on layer=').}%
+}%
+
+\def\tikzlibraryfillbetween@parse@softclip{%
+ \pgfkeysgetvalue{/tikz/fill between/soft clip first}\pgf@temp
+ \pgfkeysgetvalue{/tikz/fill between/soft clip second}\pgf@tempb
+ \ifx\pgf@temp\pgf@tempb
+ % Ah - both have the same value!
+ \ifx\pgf@temp\pgfutil@empty
+ % ... and both are empty.
+ \pgffillbetweensetsoftclippath{\pgfutil@empty}%
+ \else
+ % ... and both contain some path! Process it (once):
+ \def\tikz@marshal{\tikzlibsoftclip@setkey{\pgffillbetweensetsoftclippath}}%
+ \expandafter\tikz@marshal\pgf@temp\pgf@stop
+ \fi
+ \else
+ % handle 'soft clip first':
+ \ifx\pgf@temp\pgfutil@empty
+ \pgffillbetweensetsoftclippathfirst{\pgfutil@empty}%
+ \else
+ \def\tikz@marshal{\tikzlibsoftclip@setkey{\pgffillbetweensetsoftclippathfirst}}%
+ \expandafter\tikz@marshal\pgf@temp\pgf@stop
+ \fi
+ %
+ % handle 'soft clip second':
+ \pgfkeysgetvalue{/tikz/fill between/soft clip second}\pgf@tempb
+ \ifx\pgf@tempb\pgfutil@empty
+ \pgffillbetweensetsoftclippathsecond{\pgfutil@empty}%
+ \else
+ \def\tikz@marshal{\tikzlibsoftclip@setkey{\pgffillbetweensetsoftclippathsecond}}%
+ \expandafter\tikz@marshal\pgf@tempb\pgf@stop
+ \fi
+ \fi
+}%
+
+\def\tikzlibraryfillbetween@path@generatepath{%
+ %
+ \tikzlibraryfillbetween@parse@softclip
+ %
+ \tikzlibraryfillbetween@path@check
+ \expandafter\let\expandafter\tikz@fillbetween@a@path
+ \csname tikz@intersect@path@name@\tikz@fillbetween@a\endcsname
+ \expandafter\let\expandafter\tikz@fillbetween@b@path
+ \csname tikz@intersect@path@name@\tikz@fillbetween@b\endcsname
+ %
+ \iftikzfillbetween@optimize@name@intersections
+ \ifpgfpathfillbetween@split
+ \tikzfillbetween@optimize@name@intersections\tikz@fillbetween@a\tikz@fillbetween@b
+ \fi
+ \fi
+ %
+ \pgfpathfillbetween{\tikz@fillbetween@a@path}{\tikz@fillbetween@b@path}%
+}%
+
+\def\tikzlibraryfillbetween@path@check{%
+ \pgfutil@IfUndefined{tikz@intersect@path@name@\tikz@fillbetween@a}{%
+ \pgferror
+ {fill between: the mandatory argument 'of=<name path A> and <name path B> is missing or has empty arguments. Please ensure that the option has been set and that both path names have been assigned (perhaps you need 'name path global=\tikz@fillbetween@a' somewhere?)}%
+ }{}%
+ \pgfutil@IfUndefined{tikz@intersect@path@name@\tikz@fillbetween@b}{%
+ \pgferror
+ {fill between: the mandatory argument 'of=<name path A> and <name path B> is missing or has empty arguments. Please ensure that the option has been set and that both path names have been assigned (perhaps you need 'name path global=\tikz@fillbetween@b' somewhere?)}%
+ }{}%
+}
+
+
+%-----------------------------------------
+%
+% Utilities to work with path segments
+%
+%-----------------------------------------
+
+% Defines \pgfretval such that it contains the named path '#1'
+\def\tikzgetnamedpath#1{%
+ \pgfutil@IfUndefined{tikz@intersect@path@name@#1}{%
+ \pgferror{There is no named path called '#1'. Perhaps you misspelled it?}%
+ }{%
+ \expandafter\let\expandafter\pgfretval
+ \csname tikz@intersect@path@name@#1\endcsname
+ }%
+}%
+
+\def\tikznamecurrentpath#1{%
+ \pgfgetpath\pgf@temp
+ \pgfprocessround\pgf@temp\pgf@tempb%
+ \expandafter\global\expandafter\let\csname tikz@intersect@path@name@#1\endcsname=\pgf@tempb
+}%
+
+% ---------------------------------------------------------------------------------------
+
+\newif\iftikzpathsegments@reverse
+\def\tikzlibrarysegments@parse#1 and #2\pgf@stop{%
+ \def\tikz@path@segments@a{#1}%
+ \def\tikz@path@segments@b{#2}%
+}%
+
+
+\pgfkeys{
+ % allows to append intersection segments to the current path by
+ % writing
+ % \path[intersection segments={of=first and second, sequence=A0 -- B1 -- B3 A3[reverse] -- A1}];
+ /tikz/intersection segments/.code={%
+ \tikzpathintersectionsegments[#1]%
+ },
+ /tikz/segments/of/.code=\tikzlibrarysegments@parse#1\pgf@stop,
+ /tikz/segments/of={} and {},
+ /tikz/segments/sequence/.initial=A0 -- B1,
+ /tikz/segments/reverse/.is if=tikzpathsegments@reverse,
+ /tikz/segments/reverse/.default=true,
+}
+
+% Programmatic method to do the same as 'intersection
+% segments={<options>}
+%
+% #1: <options>
+\def\tikzpathintersectionsegments[#1]{%
+ \begingroup
+ \pgfqkeys{/tikz/segments}{#1}%
+ \tikzgetnamedpath{\tikz@path@segments@a}%
+ \let\tikz@path@segments@A=\pgfretval
+ \tikzgetnamedpath{\tikz@path@segments@b}%
+ \let\tikz@path@segments@B=\pgfretval
+ %
+ % this macro will be called whenever we need an intersection
+ % segment. Perhaps we do not need it at all
+ \def\tikz@ensurehascomputedintersection{%
+ % compute intersections using the PGF intersection lib...
+ \pgfintersectionofpaths{\pgfsetpath\tikz@path@segments@A}{\pgfsetpath\tikz@path@segments@B}%
+ %
+ \ifnum\pgfintersectionsolutions=0 %
+ \pgferror{The argument of 'sequence' requests an intersection segment -- but the two input paths do not intersect. Please use A* or B* to select the whole path}%
+ \def\b@tikz@select@all{1}%
+ \else
+ %
+ % ... and compute the intersection *segments* for both input
+ % paths...
+ \pgfcomputeintersectionsegments1%
+ \pgfcomputeintersectionsegments2%
+ \fi
+ \let\tikz@ensurehascomputedintersection=\relax
+ }%
+ %
+ \pgfkeysgetvalue{/tikz/segments/sequence}\tikz@sequence
+ %
+ \def\b@tikz@isect@nextismoveto{1}%
+ \let\pgfpointlastofsetpath=\pgfutil@empty
+ \expandafter\tikzpathintersectionsegments@parse@loop\tikz@sequence\pgf@stop
+ \pgfmath@smuggleone\pgfpointlastofsetpath
+ \endgroup
+ \tikz@make@last@position{\pgfpointlastofsetpath}%
+}%
+
+\def\tikzpathintersectionsegments@parse@loop{%
+ \pgfutil@ifnextchar-{%
+ \tikz@isect@p@lineto
+ }{%
+ \pgfutil@ifnextchar A{%
+ \tikz@isect@p@next
+ }{%
+ \pgfutil@ifnextchar B{%
+ \tikz@isect@p@next
+ }{%
+ \pgfutil@ifnextchar L{%
+ \tikz@isect@p@next
+ }{%
+ \pgfutil@ifnextchar R{%
+ \tikz@isect@p@next
+ }{%
+ \pgfutil@ifnextchar\pgf@stop{%
+ \tikz@isect@finish
+ }{%
+ \tikz@isect@p@error
+ }%
+ }%
+ }%
+ }%
+ }%
+ }%
+}%
+
+\def\tikz@isect@finish\pgf@stop{}%
+
+\def\tikz@isect@p@lineto--{%
+ \def\b@tikz@isect@nextismoveto{0}%
+ \tikzpathintersectionsegments@parse@loop
+}%
+
+\def\tikz@isect@p@error#1\pgf@stop{%
+ \pgferror{The argument of 'sequence' has an unexpected format near '#1'. Please write something like A0 -- B1 -- A1}%
+}
+
+\def\tikz@isect@p@next#1#2{%
+ \def\tikz@temp{#2}%
+ \def\tikz@@temp{-}%
+ \ifx\tikz@@temp\tikz@temp
+ % also accept minus signs without curly braces, i.e.
+ % L-2 instead of L{-2}
+ \def\tikz@next{\tikz@isect@p@next@{#1}{#2}}%
+ \else
+ \def\tikz@next{\tikz@isect@p@next@{#1}{#2}{}}%
+ \fi
+ \tikz@next
+}%
+\def\tikz@isect@p@next@#1#2#3{%
+ \pgfutil@ifnextchar[{%
+ \tikz@isect@p@next@opt{#1}{#2#3}%
+ }{%
+ \tikz@isect@p@next@opt{#1}{#2#3}[]%
+ }%
+}%
+
+\def\tikz@isect@p@next@opt#1#2[#3]{%
+ \begingroup
+ %
+ % set keys (if any):
+ \def\tikz@temp{#3}%
+ \ifx\tikz@temp\pgfutil@empty
+ \else
+ \pgfqkeys{/tikz/segments}{#3}%
+ \fi
+ %
+ \def\tikz@indexshift{}%
+ \if A#1%
+ % FIRST function (0-based index)
+ \def\tikz@path{1}%
+ \def\tikz@path@ab{A}%
+ \else
+ \if B#1%
+ % SECOND function (0-based index)
+ \def\tikz@path{2}%
+ \def\tikz@path@ab{B}%
+ \else
+ \if L#1%
+ % FIRST function (1-based index)
+ \def\tikz@path{1}%
+ \def\tikz@indexshift{-1}%
+ \def\tikz@path@ab{A}%
+ \else
+ \if R#1%
+ % SECOND function (1-based index)
+ \def\tikz@path{2}%
+ \def\tikz@indexshift{-1}%
+ \def\tikz@path@ab{B}%
+ \else
+ \def\tikz@path{}%
+ \pgferror{The argument of 'sequence' has an unexpected format near '#1#2': expected L#2 or R#2}%
+ \fi
+ \fi
+ \fi
+ \fi
+ %
+ % parse arguments:
+ \def\pgfmathresult{#2}%
+ \def\tikz@temp{*}%
+ \ifx\pgfmathresult\tikz@temp
+ \def\b@tikz@select@all{1}%
+ \else
+ \def\b@tikz@select@all{0}%
+ \tikz@ensurehascomputedintersection
+ \pgfmathparse{round(#2)}%
+ \let\tikz@index=\pgfmathresult
+ \ifx\tikz@indexshift\pgfutil@empty
+ \else
+ \afterassignment\pgfutil@gobble@until@relax
+ \c@pgf@countc=\tikz@index\relax
+ \ifnum\c@pgf@countc<0 \else
+ % the index shift is ONLY for positive numbers: we
+ % want to start indexing at 1, not at 0 -- and the
+ % negative ones start at -1 anyway.
+ \advance\c@pgf@countc by\tikz@indexshift\relax
+ \edef\tikz@index{\the\c@pgf@countc}%
+ \fi
+ \fi
+ \fi
+ %
+ %
+ % PROCESS IT:
+ \ifx\tikz@path\pgfutil@empty
+ \let\pgfpointlastofsetpath=\pgfutil@empty
+ \else
+ \if1\b@tikz@select@all%
+ % ok... select the *entire* path.
+ % #1 = A|B :
+ \expandafter\let\expandafter\pgfretval\csname tikz@path@segments@\tikz@path@ab\endcsname
+ \else
+ \pgfgetintersectionsegmentpath{\tikz@path}{\tikz@index}%
+ \fi
+ \iftikzpathsegments@reverse
+ \pgf@reverse@path\pgfretval
+ \fi
+ \if0\b@tikz@isect@nextismoveto
+ \pgfpathreplacefirstmoveto\pgfretval
+ \fi
+ \pgfaddpathandBB\pgfretval
+ \fi
+ \pgfmath@smuggleone\pgfpointlastofsetpath
+ \endgroup
+ \def\b@tikz@isect@nextismoveto{1}%
+ \tikzpathintersectionsegments@parse@loop
+}%
+
+\def\tikzfillbetween@optimize@name@intersections#1#2{%
+ \edef\tikzfillbetween@precached@intersectionofpaths@A{#1}%
+ \edef\tikzfillbetween@precached@intersectionofpaths@B{#2}%
+ \pgfkeys{%
+ /tikz/name intersections/.add code={%
+ \let\pgfintersectionofpaths=\tikzfillbetween@precached@intersectionofpaths
+ }{%
+ \let\pgfintersectionofpaths=\pgfintersectionofpaths@orig
+ }
+ }%
+}%
+
+\let\pgfintersectionofpaths@orig=\pgfintersectionofpaths
+
+\def\tikzfillbetween@precached@intersectionofpaths@log{%
+ \immediate\write-1{fill between: outcome of 'name intersections={of=\tikz@intersect@path@a\space and \tikz@intersect@path@b}' has been computed from available information of fill between}%
+}
+\def\tikzfillbetween@precached@intersectionofpaths#1#2{%
+ \def\pgf@loc@TMPa{0}%
+ \ifx\tikz@intersect@path@a\tikzfillbetween@precached@intersectionofpaths@A
+ \ifx\tikz@intersect@path@b\tikzfillbetween@precached@intersectionofpaths@B
+ \def\pgf@loc@TMPa{1}%
+ \fi
+ \fi
+ \ifx\tikz@intersect@path@b\tikzfillbetween@precached@intersectionofpaths@A
+ \ifx\tikz@intersect@path@a\tikzfillbetween@precached@intersectionofpaths@B
+ \def\pgf@loc@TMPa{1}%
+ \fi
+ \fi
+ %
+ \if1\pgf@loc@TMPa
+ \tikzfillbetween@precached@intersectionofpaths@log
+ \relax
+ \else
+ \pgfintersectionofpaths@orig{#1}{#2}%
+ \fi
+}%
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.clickable.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.clickable.code.tex
new file mode 100644
index 0000000000..1f93500e02
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.clickable.code.tex
@@ -0,0 +1,1393 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for dynamic content in PDF files
+% (clickable plots)
+%
+% 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@ifundefined{pgfplotsset}{%
+ \PackageError{pgfplots}{Sorry, \string\usetikzlibrary{pgfplots.clickable} needs to hook into PGFPlots routines, disabling it -- please provide the command AFTER \string\usepackage{pgfplots}}{}%
+ \endinput
+}{%
+}%
+
+
+\edef\pgfplotscatcodeDQ{\the\catcode`\"}%
+\catcode`\"=12
+\newif\ifpgfplots@clickable
+\newif\ifpgfplots@annot@printable
+
+\pgfqkeys{/pgfplots}{
+ @backgroundpath@hook/.add code={}{\pgfplots@create@clickable@plotarea@hook},
+ clickable/.is if=pgfplots@clickable,
+ clickable/.default=true,
+ clickable=true,
+ /pgfplots/execute at begin axis/.add={}{%
+ \pgfplots@clickable@beginaxis
+ },%
+ clickable coords code/.code={%
+ \def\pgfplots@clickable@init@@{%
+ \pgfplots@clickable@startcoordcollect
+ \pgfplotsset{%
+ /pgfplots/execute at end plot@@/.add={}{%
+ \pgfplots@clickable@endcoordcollect
+ },
+ /pgfplots/execute for finished point/.add={}{%
+ \pgfplots@clickable@coordcollect{#1}%
+ },%
+ }%
+ \let\pgfplots@clickable@init@@=\relax
+ }%
+ \pgfkeysalso{%
+ /pgfplots/execute at begin plot@@/.add={}{%
+ \pgfplots@clickable@init@@
+ },
+ }%
+ },
+ clickable coords/.style={
+ clickable coords code={\def\pgfplotsretval{#1}},
+ },
+ clickable coords/.default={(xy)},
+ annot/js fillColor/.initial={["RGB",1,1,.855]},
+ annot/point format/.initial={(\%.1f, \%.1f)},
+ annot/point format 3d/.initial={(\%.1f, \%.1f, \%.1f)},
+ annot/slope format/.initial={\%.1f*x \%+.1f},
+ annot/printable/.is if=pgfplots@annot@printable,
+ annot/printable/.default=true,
+ % Available are:
+% Times-Roman font.Times
+% Times-Bold font.TimesB
+% Times-Italic font.TimesI
+% Times-BoldItalic font.TimesBI
+% Helvetica font.Helv
+% Helvetica-Bold font.HelvB
+% Helvetica-Oblique font.HelvI
+% Helvetica-BoldOblique font.HelvBI
+% Courier font.Cour
+% Courier-Bold font.CourB
+% Courier-Oblique font.CourI
+% Courier-BoldOblique font.CourBI
+% Symbol font.Symbol
+% ZapfDingbats font.ZapfD
+ annot/font/.initial={font.Times},
+% annot/font={"CMR10"},
+ annot/textSize/.initial=11,
+ annot/richtext/.initial=true,
+ annot/richtext/.default=true,
+ annot/popup size generic/.initial=auto,
+ annot/popup size snap/.initial=auto,
+ clickable coords size/.style={
+ /pgfplots/annot/popup size snap={#1},
+ },
+ annot/popup size/.style={
+ /pgfplots/annot/popup size generic={#1},
+ /pgfplots/annot/popup size snap={#1},
+ },
+ annot/width/.initial=,
+ annot/height/.initial=,
+ annot/jsname/.initial=,
+ annot/dim/.initial=2,
+ annot/xmin/.initial=,
+ annot/xmax/.initial=,
+ annot/ymin/.initial=,
+ annot/ymax/.initial=,
+ annot/zmin/.initial=,
+ annot/zmax/.initial=,
+ annot/xscale/.initial=, % "log" or "linear" or "log:<basis>"
+ annot/yscale/.initial=,
+ annot/zscale/.initial=,
+ annot/minminmin/.initial=,
+ annot/xaxis/.initial=,
+ annot/yaxis/.initial=,
+ annot/zaxis/.initial=,
+ % format:
+ % [<plot1coords>, <plot2coords>,...,<plotncoords>]
+ % with <ploticoords> = [<coord>,<coord>,....,<coord>]
+ % and <coord> = [ <x>, <y>, "text" ]
+ % for example:
+ % [[[0.0e0,-4.0849609e-1,": (0,0)"],[1.25e-1,-3.7412109e-1,": (3,1)"],[2.5e-1,-3.0849609e-1,": (2,1)"],[3.75e-1,-2.1162109e-1,": (3,3)"],[5.0e-1,-8.3496094e-2,": (1,1)"],[6.25e-1,7.5878906e-2,": (3,5)"],[7.5e-1,2.6650391e-1,": (2,3)"],[8.75e-1,4.8837891e-1,": (3,7)"],[1.0e0,7.4150391e-1,": (0,1)"]]]
+ annot/collected plots/.initial=,
+ annot/snap dist/.initial=4,
+ every semilogy axis/.append style={/pgfplots/annot/point format={(\%.1f, \%.1e)}},
+ every semilogx axis/.append style={/pgfplots/annot/point format={(\%.1e, \%.1f)}},
+ every loglog axis/.append style={/pgfplots/annot/point format={(\%.1e, \%.1e)}},
+}
+
+\pgfkeysifdefined{/pgfplots/annot/xy pattern}{%
+}{%
+ \pgfkeyssetvalue{/pgfplots/annot/xy pattern}{(xy)}%
+}%
+\pgfkeysifdefined{/pgfplots/annot/no such coord}{%
+}{%
+ \pgfkeyssetvalue{/pgfplots/annot/no such coord}{--}%
+}%
+
+% ATTENTION:
+% The eforms package creates \begin{Form} and \end{Form} in \AtBeginDocument and \AtEndDocument!
+\def\pgfplots@glob@TMPa{pgfsys-pdftex.def}
+\ifx\pgfplots@glob@TMPa\pgfsysdriver
+ \RequirePackage[pdftex]{insdljs}
+ \RequirePackage[pdftex]{eforms}
+\else
+\def\pgfplots@glob@TMPa{pgfsys-dvipdfm.def}
+\ifx\pgfplots@glob@TMPa\pgfsysdriver
+ \RequirePackage[dvipdfm]{insdljs}
+ \RequirePackage[dvipdfm]{eforms}
+\else
+\def\pgfplots@glob@TMPa{pgfsys-dvips.def}
+\ifx\pgfplots@glob@TMPa\pgfsysdriver
+ \RequirePackage[dvips]{insdljs}
+ \RequirePackage[dvips]{eforms}
+\else
+\def\pgfplots@glob@TMPa{pgfsys-textures.def}
+\ifx\pgfplots@glob@TMPa\pgfsysdriver
+ \RequirePackage[textures]{insdljs}
+ \RequirePackage[textures]{eforms}
+\else
+ \RequirePackage{insdljs}
+ \RequirePackage{eforms}
+\fi\fi\fi\fi
+
+% Work-around for a bug in \begindljs of acrotex:
+% if " is active, \begindljs will be wrong.
+%--------------------------------------------------
+% HAS BEEN FIXED IN THE MEANTIME
+% \def\begindljs
+% {%
+% \iwvo{\string\begingroup}
+% {\uccode`c=`\%\uppercase{\iwvo{\string\obeyspaces\string\obeylines\string\global\string\let\string^\string^M=\string\jsR c}}}
+% {\escapechar=-1 \lccode`C=`\%\lowercase{\iwvo{\string\\catcode`\string\\"=12C}}}
+% }
+%--------------------------------------------------
+
+% Bugfix to fix incompatibility when '<' and '>' are active (as for
+% \usepackage[spanish]{babel}:
+\def\write@objs@BUGGY
+{%
+ \iwvo{\begingroup}
+ {\lccode`C=`\%\lowercase{\iwvo{\string\ccpdftex C}}}
+ {\lccode`C=`\%\lowercase{\iwvo{\string\input{dljscc.def}C\the\dljsobjtoks}}}
+ \iwvo{\endgroup}
+ \iwvo{\string\endinput}%
+}
+\def\write@objs@CORRECT
+{%
+ \iwvo{\begingroup}
+ \iwvo{\string\catcode`\string\<=12 }
+ \iwvo{\string\catcode`\string\>=12 }
+ {\lccode`C=`\%\lowercase{\iwvo{\string\ccpdftex C}}}
+ {\lccode`C=`\%\lowercase{\iwvo{\string\input{dljscc.def}C\the\dljsobjtoks}}}
+ \iwvo{\endgroup}
+ \iwvo{\string\endinput}%
+}
+\pgfutil@IfUndefined{write@objs}{}{%
+ \ifx\write@objs\write@objs@BUGGY
+ \let\write@objs=\write@objs@CORRECT
+ \fi
+}%
+
+\def\pgfplots@clickable@no{0}
+
+% This catcode-hackery is too much for me, I don't get '|' to work in
+% conjunction with ltxdoc document style.
+% So, I simply use \pgfplotsVERTBAR instead... *sigh*.
+
+% this here is a bugfix to resolve an incompatibility between insdljs
+% an \usepackage[spanish]{babel}:
+\def\@roman#1{\romannumeral #1}%
+
+% FIXME : write this stuff DIRECTLY into a pdf using \pdfobj! I don't
+% need ANY TeX code inside of the methods. Maybe I can even use some
+% sort of "include external .js file" command instead of /S /Javascript /JS
+%
+% FIXME : collect this stuff using \beginpgfplotsverbatim ...
+% \endpgfplotsverbatim to avoid the \catcode problems! Who knows
+% whether there are more of them...
+%
+% FIXME : using '\jobname' here produces a bug in insdljs :-(
+% The problem: insdljs creates a macro named 'dlsj\jobname' or
+% something like that, but if fails to use '\csname' properly. So:
+% only normal letters are allowed inside of the argument here.
+\begin{insDLJS}[processAnnotatedPlot]{pgfplotsJS}{pgfplots Clickable Plot Code}
+/*********************************************************************************
+ * function sprintf() - written by Kevin van Zonneveld as part of the php to javascript
+ * conversion project.
+ *
+ * More info at: http://kevin.vanzonneveld.net/techblog/article/phpjs_licensing/
+ *
+ * This is version: 1.33
+ * php.js is copyright 2008 Kevin van Zonneveld.
+ *
+ * Portions copyright Michael White (http://crestidg.com), _argos, Jonas
+ * Raoni Soares Silva (http://www.jsfromhell.com), Legaev Andrey, Ates Goral
+ * (http://magnetiq.com), Philip Peterson, Martijn Wieringa, Webtoolkit.info
+ * (http://www.webtoolkit.info/), Carlos R. L. Rodrigues
+ * (http://www.jsfromhell.com), Ash Searle (http://hexmen.com/blog/),
+ * Erkekjetter, GeekFG (http://geekfg.blogspot.com), Johnny Mast
+ * (http://www.phpvrouwen.nl), marrtins, Alfonso Jimenez
+ * (http://www.alfonsojimenez.com), Aman Gupta, Arpad Ray
+ * (mailto:arpad@php.net), Karol Kowalski, Mirek Slugen, Thunder.m, Tyler
+ * Akins (http://rumkin.com), d3x, mdsjack (http://www.mdsjack.bo.it), Alex,
+ * Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev),
+ * Allan Jensen (http://www.winternet.no), Andrea Giammarchi
+ * (http://webreflection.blogspot.com), Arno, Bayron Guevara, Ben Bryan,
+ * Benjamin Lupton, Brad Touesnard, Brett Zamir, Cagri Ekin, Cord, David,
+ * David James, DxGx, FGFEmperor, Felix Geisendoerfer
+ * (http://www.debuggable.com/felix), FremyCompany, Gabriel Paderni, Howard
+ * Yeend, J A R, Leslie Hoare, Lincoln Ramsay, Luke Godfrey, MeEtc
+ * (http://yass.meetcweb.com), Mick@el, Nathan, Nick Callen, Ozh, Pedro Tainha
+ * (http://www.pedrotainha.com), Peter-Paul Koch
+ * (http://www.quirksmode.org/js/beat.html), Philippe Baumann, Sakimori,
+ * Sanjoy Roy, Simon Willison (http://simonwillison.net), Steve Clay, Steve
+ * Hilder, Steven Levithan (http://blog.stevenlevithan.com), T0bsn, Thiago
+ * Mata (http://thiagomata.blog.com), Tim Wiel, XoraX (http://www.xorax.info),
+ * Yannoo, baris ozdil, booeyOH, djmix, dptr1988, duncan, echo is bad, gabriel
+ * paderni, ger, gorthaur, jakes, john (http://www.jd-tech.net), kenneth,
+ * loonquawl, penutbutterjelly, stensi
+ *
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+// ATTENTION: this method has been masked such that special characters of TeX and javascript
+// don't produce problems.
+function sprintf( ) {
+ // Return a formatted string
+ //
+ // + discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_sprintf/
+ // + version: 804.1712
+ // + original by: Ash Searle (http://hexmen.com/blog/)
+ // + namespaced by: Michael White (http://crestidg.com)
+ // * example 1: sprintf("\pgfplotsPERCENT01.2f", 123.1);
+ // * returns 1: 123.10
+
+ var regex = /\pgfplotsPERCENT\pgfplotsPERCENT\pgfplotsVERTBAR\pgfplotsPERCENT(\d+\$)?([-+\pgfplotsHASH0 ]*)(\*\d+\$\pgfplotsVERTBAR\*\pgfplotsVERTBAR\d+)?(\.(\*\d+\$\pgfplotsVERTBAR\*\pgfplotsVERTBAR\d+))?([scboxXuidfegEG])/g;
+ var a = arguments, i = 0, format = a[i++];
+
+ // pad()
+ var pad = function(str, len, chr, leftJustify) {
+ var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
+ return leftJustify ? str + padding : padding + str;
+ };
+
+ // justify()
+ var justify = function(value, prefix, leftJustify, minWidth, zeroPad) {
+ var diff = minWidth - value.length;
+ if (diff > 0) {
+ if (leftJustify \pgfplotsVERTBAR\pgfplotsVERTBAR !zeroPad) {
+ value = pad(value, minWidth, ' ', leftJustify);
+ } else {
+ value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
+ }
+ }
+ return value;
+ };
+
+ // formatBaseX()
+ var formatBaseX = function(value, base, prefix, leftJustify, minWidth, precision, zeroPad) {
+ // Note: casts negative numbers to positive ones
+ var number = value >>> 0;
+ prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] \pgfplotsVERTBAR\pgfplotsVERTBAR '';
+ value = prefix + pad(number.toString(base), precision \pgfplotsVERTBAR\pgfplotsVERTBAR 0, '0', false);
+ return justify(value, prefix, leftJustify, minWidth, zeroPad);
+ };
+
+ // formatString()
+ var formatString = function(value, leftJustify, minWidth, precision, zeroPad) {
+ if (precision != null) {
+ value = value.slice(0, precision);
+ }
+ return justify(value, '', leftJustify, minWidth, zeroPad);
+ };
+
+ // finalFormat()
+ var doFormat = function(substring, valueIndex, flags, minWidth, _, precision, type) {
+ if (substring == '\pgfplotsPERCENT\pgfplotsPERCENT') return '\pgfplotsPERCENT';
+
+ // parse flags
+ var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false;
+ for (var j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) {
+ case ' ': positivePrefix = ' '; break;
+ case '+': positivePrefix = '+'; break;
+ case '-': leftJustify = true; break;
+ case '0': zeroPad = true; break;
+ case '\pgfplotsHASH': prefixBaseX = true; break;
+ }
+
+ // parameters may be null, undefined, empty-string or real valued
+ // we want to ignore null, undefined and empty-string values
+ if (!minWidth) {
+ minWidth = 0;
+ } else if (minWidth == '*') {
+ minWidth = +a[i++];
+ } else if (minWidth.charAt(0) == '*') {
+ minWidth = +a[minWidth.slice(1, -1)];
+ } else {
+ minWidth = +minWidth;
+ }
+
+ // Note: undocumented perl feature:
+ if (minWidth < 0) {
+ minWidth = -minWidth;
+ leftJustify = true;
+ }
+
+ if (!isFinite(minWidth)) {
+ throw new Error('sprintf: (minimum-)width must be finite');
+ }
+
+ if (!precision) {
+ precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void(0);
+ } else if (precision == '*') {
+ precision = +a[i++];
+ } else if (precision.charAt(0) == '*') {
+ precision = +a[precision.slice(1, -1)];
+ } else {
+ precision = +precision;
+ }
+
+ // grab value using valueIndex if required?
+ var value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];
+
+ switch (type) {
+ case 's': return formatString(String(value), leftJustify, minWidth, precision, zeroPad);
+ case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad);
+ case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
+ case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
+ case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
+ case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad).toUpperCase();
+ case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
+ case 'i':
+ case 'd': {
+ var number = parseInt(+value);
+ var prefix = number < 0 ? '-' : positivePrefix;
+ value = prefix + pad(String(Math.abs(number)), precision, '0', false);
+ return justify(value, prefix, leftJustify, minWidth, zeroPad);
+ }
+ case 'e':
+ case 'E':
+ case 'f':
+ case 'F':
+ case 'g':
+ case 'G':
+ {
+ var number = +value;
+ var prefix = number < 0 ? '-' : positivePrefix;
+ var method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
+ var textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) \pgfplotsPERCENT 2];
+ value = prefix + Math.abs(number)[method](precision);
+ return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform]();
+ }
+ default: return substring;
+ }
+ };
+
+ return format.replace(regex, doFormat);
+}
+/*********************************************************************************/
+
+% see https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Inheritance
+
+var lastPoint = null;
+var posOnMouseDownX = -1;
+var posOnMouseDownY = -1;
+
+// preallocation.
+var tmpArray1 = new Array(3);
+var tmpArray2 = new Array(3);
+
+var clickablePatternForXY="\pgfkeysvalueof{/pgfplots/annot/xy pattern}";
+var clickableStringNoSuchCoord = "\pgfkeysvalueof{/pgfplots/annot/no such coord}";
+
+var nan = Number.NaN;
+var NAN = Number.NaN;
+var inf = Number.POSITIVE_INFINITY;
+var INF = Number.POSITIVE_INFINITY;
+
+var pgfplotsAxisRegistry = new Object();
+pgfplotsAxisRegistry["rectangle"] = function( axisAnnotObj ) { return new PGFPlotsAxis( axisAnnotObj ); }
+pgfplotsAxisRegistry["ternary"] = function( axisAnnotObj ) { return new PGFPlotsTernaryAxis( axisAnnotObj ); }
+
+function PGFPlotsClassExtend( child, superClass )
+{
+ for (var property in superClass.prototype) {
+ if (typeof child.prototype[property] == "undefined")
+ child.prototype[property] = superClass.prototype[property];
+ }
+ return child;
+}
+
+function PGFPlotsCreateAxisFor( axisAnnotObj, docObject )
+{
+ var ret = null;
+ if( pgfplotsAxisRegistry[axisAnnotObj.axisType] ) {
+ ret = pgfplotsAxisRegistry[axisAnnotObj.axisType](axisAnnotObj);
+ ret.docObject = docObject;
+ }
+ return ret;
+}
+
+function ClickableCoord(canvasx,canvasy, realx,realy, text)
+{
+ this.dim=2;
+ this.canvasx=canvasx;
+ this.canvasy=canvasy;
+ this.realx=realx;
+ this.realy=realy;
+ this.text=text;
+}
+ClickableCoord.prototype =
+{
+ dim : 0,
+ canvasx : 0,
+ canvasy : 0,
+ realx : 0,
+ realy : 0,
+ realz : 0,
+ text : "",
+ sourcePlotIdx : -1,
+ sourceCoordIdx : -1,
+
+ isSnapToNearestCoord : function() {
+ return this.sourcePlotIdx >= 0;
+ },
+
+ /**
+ * Takes an already existing TextField, changes its value to point.text and places it at (x,y).
+ * Additional \c displayOpts will be used to format it.
+ */
+ draw : function( docObject, canvas, displayOpts )
+ {
+ var charsX = 1;
+ var charsY = 1.5;
+ var popupSize = ( this.isSnapToNearestCoord() ? displayOpts.popupSizeSnap : displayOpts.popupSizeGeneric );
+ if( popupSize == "auto" ) {
+ charsX = Math.max( 5,this.text.length )/2;
+
+ } else {
+ var commaOff = popupSize.indexOf( "," );
+ if( commaOff >= 0 ) {
+ charsX = popupSize.substring( 0, commaOff );
+ charsY = popupSize.substring( commaOff+1 );
+ } else
+ charsX = popupSize;
+ }
+ // console.println( this.text );
+
+ if( !displayOpts.richText )
+ canvas.value = ""+this.text;
+ else {
+ canvas.richText=true;
+ var xmlValue = "<?xml version=\"1.0\"?>"+
+ "<body> " + % xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"Acrobat:9.3.2\" xfa:spec=\"2.0.2\">" +
+ %"<p>"+
+ "<span>"+ % style="font-size:9.0pt;text-align:left;color:#7E0000;font-weight:normal;font-style:normal;font-family:Helvetica,sans-serif;font-stretch:normal"
+ this.text +
+ "</span>"+
+ %"</p>"+
+ "</body>";
+ canvas.richValue = util.xmlToSpans(xmlValue);
+% debug helper:
+% spans= new Array();
+% spans[0] = new Object();
+% spans[0].text = this.text;
+% spans[0].textColor = ["RGB",0.5,0,0];
+% canvas.richValue = spans;
+% console.println(util.spansToXML(canvas.richValue));
+ }
+ var R = canvas.rect;
+ R[0] = this.canvasx;
+ R[1] = this.canvasy;
+ R[2] = R[0] + charsX*displayOpts.textSize;
+ R[3] = R[1] - charsY*displayOpts.textSize;
+ canvas.rect = R;
+ canvas.textFont = displayOpts.textFont;
+ canvas.textSize = displayOpts.textSize;
+ canvas.multiline = true;
+ canvas.fillColor = displayOpts.fillColor;//["RGB",1,1,.855];
+ canvas.doNotSpellCheck = true;
+ canvas.readonly = true;
+ if( displayOpts.printable )
+ canvas.display = display.visible;
+ else
+ canvas.display = display.noPrint;
+
+ var mark = docObject.getField( canvas.name + "mark");
+ if( mark ) {
+ R = mark.rect;
+ R[0]=this.canvasx-2;
+ R[1]=this.canvasy-2;
+ R[2]=R[0]+4;
+ R[3]=R[1]+4;
+ mark.value="";
+ mark.rect = R;
+ mark.fillColor = ["RGB",0,0,0];
+ mark.doNotSpellCheck = true;
+ mark.readonly = true;
+ if( displayOpts.printable )
+ mark.display = display.visible;
+ else
+ mark.display = display.noPrint;
+ }
+ }
+}
+
+
+
+function PGFPlotsAxis(properties) {
+ for (var property in properties)
+ this[property] = properties[property];
+}
+PGFPlotsAxis.prototype = {
+ /**
+ * @return an instance of ClickableCoord or null.
+ * The returned canvas coordinates are NOT yet initialised.
+ */
+ findNearest : function( point, rect, startSearchAt )
+ {
+ var actx;
+ var acty;
+ var minSoFar = 1e324;
+ var minPtSoFar = null;
+ var tmpPt = null;
+ var dist =0;
+ var startPlot = 0;
+ var startCoord = 0;
+ var collectedPlots = this.collectedPlots;
+ if( point.dim > 2 )
+ tmpPt = new ClickableCoord(0,0,0,0,"");
+
+ if( startSearchAt != null && startSearchAt.isSnapToNearestCoord() ) {
+ startPlot = startSearchAt.sourcePlotIdx;
+ startCoord= startSearchAt.sourceCoordIdx;
+ }
+ for( var i = startPlot; i<collectedPlots.length; ++i ) {
+ for( var j = startCoord; j<collectedPlots[i].length; ++j ) {
+ if( point.dim == 2 ) {
+ actx = collectedPlots[i][j][0] - point.realx;
+ acty = collectedPlots[i][j][1] - point.realy;
+ } else {
+ // dim > 2 should be compared using CANVAS coordinates, not real coordinates:
+ tmpPt.realx = collectedPlots[i][j][0];
+ tmpPt.realy = collectedPlots[i][j][1];
+ if( collectedPlots[i][j].length-1 >= 3 )
+ tmpPt.realz = collectedPlots[i][j][2];
+ else
+ tmpPt.realz = 0;
+ this.computeCanvasFor( tmpPt, rect );
+ actx = tmpPt.canvasx - point.canvasx;
+ acty = tmpPt.canvasy - point.canvasy;
+ }
+ dist = actx*actx + acty*acty;
+ if( dist < minSoFar ) {
+ if( minPtSoFar == null )
+ minPtSoFar = new ClickableCoord(-1,-1,0,0,"");
+ minPtSoFar.realx = collectedPlots[i][j][0];
+ minPtSoFar.realy = collectedPlots[i][j][1];
+ if( collectedPlots[i][j].length-1 >= 3 )
+ minPtSoFar.realz = collectedPlots[i][j][2];
+ else
+ minPtSoFar.realz = 0;
+ minPtSoFar.text= collectedPlots[i][j][ collectedPlots[i][j].length-1 ];
+ minPtSoFar.sourcePlotIdx = i;
+ minPtSoFar.sourceCoordIdx = j;
+ minSoFar = dist;
+ }
+ }
+ }
+ if( minPtSoFar )
+ this.computeCanvasFor(minPtSoFar,rect);
+ return minPtSoFar;
+ },
+
+ /**
+ * Returns either a ClickableCoord describing the point under the mouse cursor or a snap--to--nearest result near the mouse cursor.
+ *
+ * @param this the axis in which we shall search.
+ * @param x,y the input canvas coordinates
+ * @param canvas a pointer to the Drawing object (TextField) whose 'rect' field is the drawing canvas.
+ * @param startSearch either null or an instance of ClickableCoord for which isSnapToNearestCoord() returns true.
+ * If it is not null, the next matching point *after* it will be returned (or null if there is no matching snap--to--nearest coord after it).
+ * @return an instance of ClickableCoord or null in case the startSearch!=null and there are no further matches.
+ */
+ findClickableCoord : function( x,y, canvas, startSearch )
+ {
+ // Get and modify bounding box. The mouse movement is only accurate up to one point
+ // (mouseX and mouseY are integers), so the bounding box should be an integer as well.
+ var rect = canvas.rect; // rect = [ mincanvasx mincanvasy maxcanvasx maxcanvasy ]; relative to upper left corner
+ rect[0] = Math.round(rect[0]);
+ rect[1] = Math.round(rect[1]);
+ rect[2] = Math.round(rect[2]);
+ rect[3] = Math.round(rect[3]);
+ canvas.rect= rect;
+
+ var realx=-1;
+ var realy=-1;
+ if( this.dim == 2 ) {
+ // the following code inverts computeCanvasFor():
+ var minminminx = rect[0] + this.minminmin[0];
+ var minminminy = rect[3] + this.minminmin[1];
+ var vecx = x - minminminx;
+ var vecy = y - minminminy;
+ var A = [
+ [this.xaxis[0], this.yaxis[0]],
+ [this.xaxis[1], this.yaxis[1]] ];
+ var b = [ vecx, vecy ];
+
+ var rowpermut = [0, 1];
+ if( Math.abs(A[0][0]) < 0.0001 ) {
+ rowpermut[0] = 1;
+ rowpermut[1] = 0;
+ }
+ var pivot = -A[rowpermut[1]][0] / A[rowpermut[0]][0];
+ var unity = (b[rowpermut[1]] + pivot*b[rowpermut[0]]) / (A[rowpermut[1]][1] + pivot * A[rowpermut[0]][1]);
+ var unitx = (b[rowpermut[0]] - A[rowpermut[0]][1] * unity) / A[rowpermut[0]][0];
+
+ realx = this.xmin + unitx * (this.xmax - this.xmin);
+ realy = this.ymin + unity * (this.ymax - this.ymin);
+ //console.println( "unitx = " + unitx + "; unity " + unity );
+ }
+
+
+ var point = new ClickableCoord( x,y, realx, realy, clickablePatternForXY);
+ point.dim = this.dim;
+
+ if( startSearch && !startSearch.isSnapToNearestCoord() ) {
+ console.println( "WARNING: startSearch().isSnapToNearestCoord() has been expected!" );
+ startSearch = null;
+ }
+
+ var nearestClickableCoord = this.findNearest( point, rect, startSearch );
+ if( nearestClickableCoord ) {
+ if( getDist( point.canvasx,point.canvasy, nearestClickableCoord.canvasx, nearestClickableCoord.canvasy ) < this.snapDist ) {
+ return nearestClickableCoord;
+ }
+ }
+ if( startSearch )
+ point = null;
+ if( this.dim > 2 ) { // we didn't find a snap--to--nearest point.
+ point.text = clickableStringNoSuchCoord;
+ }
+
+ return point;
+ },
+
+ /**
+ * Takes point's real coordinates and computes its canvas coordinates. The result is written back into \c point.
+ */
+ computeCanvasFor : function( point, rect)
+ {
+ var unitx = (point.realx - this.xmin) / (this.xmax -this.xmin);
+ var unity = (point.realy - this.ymin) / (this.ymax -this.ymin);
+
+ point.canvasx = rect[0] + this.minminmin[0] + this.xaxis[0] * unitx + this.yaxis[0] * unity;
+ point.canvasy = rect[3] + this.minminmin[1] + this.xaxis[1] * unitx + this.yaxis[1] * unity;
+ if( this.dim >= 3 ) {
+ var unitz = (point.realz - this.zmin) / (this.zmax -this.zmin);
+ point.canvasx += this.zaxis[0] * unitz;
+ point.canvasy += this.zaxis[1] * unitz;
+ }
+ },
+
+ handleDragNDrop : function( formName, displayOpts )
+ {
+ if( this.dim == 3 )
+ return;
+
+ var result = this.docObject.getField( formName + "-result");
+ var result2 = this.docObject.getField( formName + "-result2");
+ var resultmark = this.docObject.getField( formName + "-resultmark");
+ var result2mark = this.docObject.getField( formName + "-result2mark");
+ var slope = this.docObject.getField( formName + "-slope" );
+ if( !result ) {
+ console.println( "WARNING: there is no TextField \"" + formName + "-result\" to display results for interactive element \"" + formName + "\"");
+ return;
+ }
+
+ var a = this.docObject.getField(formName);
+ if( ! a ) {
+ console.println( "Warning: there is no form named \"" + formName + "\"" );
+ return;
+ }
+ // dragging the mouse results in slope computation:
+ // placeClickableCoord shows the endpoint coords and returns the (transformed) coordinates into tmpArray1 and tmpArray2:
+ this.placeClickableCoord(
+ this.findClickableCoord( posOnMouseDownX, posOnMouseDownY, a, null ),
+ result, displayOpts, tmpArray1 );
+ this.placeClickableCoord(
+ this.findClickableCoord( mouseX, mouseY, a, null ),
+ result2, displayOpts, tmpArray2 );
+
+ var m = ( tmpArray2[1] - tmpArray1[1] ) / ( tmpArray2[0] - tmpArray1[0] );
+ var n = tmpArray1[1] - m * tmpArray1[0];
+
+ var slopePoint = new ClickableCoord(
+ 0.5 * ( mouseX + posOnMouseDownX ),
+ 0.5 * ( mouseY + posOnMouseDownY ),
+ -1,-1,
+ sprintf( displayOpts.slopeFormat, m, n ));
+ slopePoint.draw(
+ this.docObject,
+ slope,
+ displayOpts );
+
+ // FIXME! these document rights seem to forbid modifications to annotations, although they work for text fields!?
+ //var lineobj = this.getAnnot( a.page, formName + '-line' );
+ //console.println( 'lineobj = ' + lineobj );
+ //lineobj.points = [[mouseX,mouseY],[posOnMouseDownX,posOnMouseDownY]];
+ //lineobj.display = display.visible;
+ },
+
+ handleClick : function( formName, displayOpts )
+ {
+ var result = this.docObject.getField( formName + "-result");
+ var result2 = this.docObject.getField( formName + "-result2");
+ var resultmark = this.docObject.getField( formName + "-resultmark");
+ var result2mark = this.docObject.getField( formName + "-result2mark");
+ var slope = this.docObject.getField( formName + "-slope" );
+ if( !result ) {
+ console.println( "WARNING: there is no TextField \"" + formName + "-result\" to display results for interactive element \"" + formName + "\"");
+ return;
+ }
+ result2.display = display.hidden;
+ slope.display = display.hidden;
+ result2mark.display = display.hidden;
+
+ var a = this.docObject.getField(formName);
+ if( ! a ) {
+ console.println( "Warning: there is no form named \"" + formName + "\"" );
+ return;
+ }
+
+ var point = null;
+ var bSearchPoint = true;
+ if( lastPoint ) {
+ if( getDist( mouseX,mouseY, lastPoint.canvasx,lastPoint.canvasy) < this.snapDist ) {
+ if( lastPoint.isSnapToNearestCoord() )
+ ++lastPoint.sourceCoordIdx;
+ else
+ bSearchPoint = false;
+
+ } else
+ lastPoint = null; // no search restriction.
+ }
+ if( bSearchPoint )
+ point = this.findClickableCoord( mouseX, mouseY, a, lastPoint );
+
+ lastPoint = point;
+
+ // clicking twice onto the same point hides it:
+ if( point == null ) {
+ result.display = display.hidden;
+ resultmark.display = display.hidden;
+ return;
+ }
+
+ this.placeClickableCoord(
+ point,
+ result, displayOpts, null );
+ },
+
+ /**
+ * Changes all required Field values of \c plotRegionField, inserts the proper
+ * value and displays it at the pdf positions (x,y) .
+ *
+ * @param plotRegionField a reference to a Field object.
+ * @param x the x canvas coordinate where the annotation shall be placed and which is used to determine
+ * the annotation text.
+ * @param y the corresponding y coord.
+ * @param axis An object containing axis references.
+ * @param displayOpts An object for display flags.
+ * @param[out] retCoords will be filled with the point in axis coordinates (should have length axis.dim).
+ */
+ placeClickableCoord : function( point, textField, displayOpts, retCoords )
+ {
+ var transformedCoordx = point.realx;
+ var transformedCoordy = point.realy;
+
+ if( this.xscale.length >= 3 && this.xscale.substr(0,3) == "log" ) {
+ if( this.xscale.length > 4 ) // log:<basis>
+ point.realx = point.realx * Math.log( this.xscale.substr(4) );
+ else {
+ // pgfplots handles log plots base e INTERNALLY, but uses base 10 for display.
+ // convert to base 10:
+ transformedCoordx = point.realx / Math.log(10);
+ }
+ point.realx = Math.exp(point.realx);
+ }
+ if( this.yscale.length >= 3 && this.yscale.substr(0,3) == "log" ) {
+ if( this.yscale.length > 4 ) // log:<basis>
+ point.realy = point.realy * Math.log( this.yscale.substr(4) );
+ else {
+ // pgfplots handles log plots base e INTERNALLY, but uses base 10 for display.
+ // convert to base 10:
+ transformedCoordy = point.realy / Math.log(10);
+ }
+ point.realy = Math.exp(point.realy);
+ }
+ if( this.dim > 2 ) {
+ if( this.zscale.length >= 3 && this.zscale.substr(0,3) == "log" ) {
+ if( this.zscale.length > 4 ) // log:<basis>
+ point.realz = point.realz * Math.log( this.zscale.substr(4) );
+ else {
+ // pgfplots handles log plots base e INTERNALLY, but uses base 10 for display.
+ // convert to base 10:
+ transformedCoordz = point.realz / Math.log(10);
+ }
+ point.realz = Math.exp(point.realz);
+ }
+ }
+
+ // replace the text substring "(xy)" with the actual coordinates:
+ var coordOff = point.text.indexOf(clickablePatternForXY);
+ if( coordOff >= 0 ) {
+ point.text =
+ point.text.substring( 0, coordOff ) +
+ sprintf( displayOpts.pointFormat, point.realx,point.realy,point.realz) +
+ point.text.substr( coordOff+clickablePatternForXY.length );
+ }
+ point.draw( this.docObject, textField, displayOpts );
+
+ if( retCoords ) {
+ retCoords[0] = transformedCoordx;
+ retCoords[1] = transformedCoordy;
+ if( this.dim > 2 )
+ retCoords[2] = transformedCoordz;
+ }
+
+ }
+
+}
+
+function PGFPlotsTernaryAxis(properties) {
+ PGFPlotsAxis.call(this,properties);
+}
+PGFPlotsTernaryAxis.prototype = {
+ findClickableCoord : function( x,y, canvas, startSearch )
+ {
+ // Get and modify bounding box. The mouse movement is only accurate up to one point
+ // (mouseX and mouseY are integers), so the bounding box should be an integer as well.
+ var rect = canvas.rect; // rect = [ mincanvasx mincanvasy maxcanvasx maxcanvasy ]; relative to lower left corner
+ rect[0] = Math.round(rect[0]);
+ rect[1] = Math.round(rect[1]);
+ rect[2] = Math.round(rect[2]);
+ rect[3] = Math.round(rect[3]);
+ canvas.rect= rect;
+
+ var ternaryScale = 1 / ( rect[2] - rect[0] );
+ var X = ( x - rect[0] ) * ternaryScale;
+ var Y = ( y - rect[3] ) * ternaryScale;
+
+ var realx = 1.15470053837925 * Y; // 2/sqrt(3)
+ var realz = X - 0.5 * realx;
+ var realy = 1 - realx - realz;
+
+ if( realx < 0 \pgfplotsVERTBAR\pgfplotsVERTBAR realy < 0 \pgfplotsVERTBAR\pgfplotsVERTBAR realz < 0 )
+ return null;
+
+ var point = new ClickableCoord( x,y, realx, realy, clickablePatternForXY);
+ point.realz = realz;
+ point.dim = this.dim;
+
+ if( startSearch && !startSearch.isSnapToNearestCoord() ) {
+ console.println( "WARNING: startSearch().isSnapToNearestCoord() has been expected!" );
+ startSearch = null;
+ }
+
+ var nearestClickableCoord = this.findNearest( point, rect, startSearch );
+ if( nearestClickableCoord ) {
+ if( getDist( point.canvasx,point.canvasy, nearestClickableCoord.canvasx, nearestClickableCoord.canvasy ) < this.snapDist ) {
+ return nearestClickableCoord;
+ }
+ }
+ if( startSearch )
+ point = null;
+
+ return point;
+ },
+
+ /**
+ * Takes point's real coordinates and computes its canvas coordinates. The result is written back into \c point.
+ */
+ computeCanvasFor : function( point, rect)
+ {
+ var unitx = (point.realx - this.xmin) / (this.xmax -this.xmin);
+ var unity = (point.realy - this.ymin) / (this.ymax -this.ymin);
+ var unitz = (point.realz - this.zmin) / (this.zmax -this.zmin);
+
+ var ternaryScale = ( rect[2] - rect[0] );
+ point.canvasx = rect[0] + ternaryScale* 0.5 * (unitx + 2 * unitz);
+ point.canvasy = rect[3] + ternaryScale* 0.866025403784* unitx; // sqrt(3)/2
+ },
+}
+PGFPlotsClassExtend( PGFPlotsTernaryAxis, PGFPlotsAxis );
+
+
+
+function getVecLen( t1,t2 ) {
+ return Math.sqrt( t1*t1 + t2*t2);
+}
+function getDist( x1,y1, x2,y2 ) {
+ var t1 = (x1-x2);
+ var t2 = (y1-y2);
+ return getVecLen(t1,t2);
+}
+
+function axisMouseDown(formName )
+{
+ posOnMouseDownX = mouseX;
+ posOnMouseDownY = mouseY;
+}
+
+/**
+ * @param formName the name of the clickable button. It is expected to be as large as the underlying plot.
+ * @param axis an object with the fields
+ * - xmin, xmax
+ * - ymin, ymax
+ * - xscale, yscale
+ * @param displayOpts an object with the fields
+ * - pointFormat an sprintf format string to format the final point coordinates.
+ * The default is "(\pgfplotsPERCENT.2f,\pgfplotsPERCENT.2f)"
+ * - fillColor the fill color for the annotation. Options are
+ * transparent, gray, RGB or CMYK color. Default is
+ * ["RGB",1,1,.855]
+ * - textFont / textSize
+ */
+function axisMouseUp(formName, axisAnnotObj, displayOpts)
+{
+ var axis = PGFPlotsCreateAxisFor(axisAnnotObj,this);
+ if( axis == null )
+ return;
+
+ if( Math.abs( mouseX - posOnMouseDownX ) > 6 \pgfplotsVERTBAR\pgfplotsVERTBAR
+ Math.abs( mouseY - posOnMouseDownY ) > 6 )
+ {
+ axis.handleDragNDrop( formName, displayOpts );
+
+ } else {
+ axis.handleClick( formName, displayOpts );
+ }
+}
+
+
+\end{insDLJS}
+%--------------------------------------------------
+% function hideClickableTextfields() {
+% for (var i = 0; i < this.numFields; i++) {
+% var fieldName = this.getNthFieldName(i);
+% console.println("checking Field " + fieldName + " ... ");
+% if( fieldName.substr( 0, 13 ) == "clickableplot" && fieldName.indexOf( "-result", 12 ) >= 0 ) {
+% console.println("hiding Field " + fieldName + " ... ");
+% this.getField( fieldName ).display = display.hidden;
+% }
+% }
+% }
+% hideClickableTextfields();
+%--------------------------------------------------
+
+
+\pgfkeysdef{/pgfplots/annot/xy pattern}{\pgfplots@clickable@xypat@error}%
+\pgfkeysdef{/pgfplots/annot/xy pattern/.initial}{\pgfplots@clickable@xypat@error}%
+\def\pgfplots@clickable@xypat@error{\pgfplots@error{Sorry, \string\pgfplotsset{annot/xy pattern/.initial=...} can only be assigned *before* \string\usepgfplotslibrary{clickable}}}%
+
+\pgfkeysdef{/pgfplots/annot/no such coord}{\pgfplots@clickable@nosuchcoord@error}%
+\pgfkeysdef{/pgfplots/annot/no such coord/.initial}{\pgfplots@clickable@nosuchcoord@error}%
+\def\pgfplots@clickable@nosuchcoord@error{\pgfplots@error{Sorry, \string\pgfplotsset{annot/no such coord/.initial=...} can only be assigned *before* \string\usepgfplotslibrary{clickable}}}%
+
+\def\pgfplots@clickable@beginaxis{%
+ \pgfplotsapplistXglobalnewempty\pgfplots@clickable@collectedplots
+ \gdef\pgfplots@clickable@collectedplots@isempty{1}%
+}%
+
+\def\pgfplots@clickable@startcoordcollect{%
+ \pgfplotsapplistXnewempty\pgfplots@clickable@collectedplot
+ \def\pgfplots@clickable@collectedplot@isempty{1}%
+}%
+
+{\catcode`\|=0 |catcode`|\=12 |gdef|pgfplots@clickable@bslash{\}}%
+{
+\catcode`\"=13
+\catcode`\|=13
+\catcode`\#=12
+\gdef\pgfplots@clickable@coordcollect@handlechars{%
+ \def"{\string\\\string\"}%
+ \def\#{#}%
+ \expandafter\def\csname \string"\endcsname{\string\\\string\"}%
+ \def|{\string"}%
+ \def\n{\pgfplots@clickable@bslash\string\n}%
+ \def\r{\pgfplots@clickable@bslash\string\r}%
+ \def\t{\pgfplots@clickable@bslash\string\t}%
+ \def\\{\pgfplots@clickable@bslash\pgfplots@clickable@bslash}%
+}%
+}
+\def\pgfplots@clickable@coordcollect#1{%
+ \begingroup
+ \ifx\pgfplots@current@point@x\pgfutil@empty
+ \def\pgfmathresult{nan}%
+ \else
+ \pgfplotscoordmath{x}{tostring}\pgfplots@current@point@x
+ \fi
+ \let\pgfplots@current@point@x=\pgfmathresult
+ %
+ \ifx\pgfplots@current@point@y\pgfutil@empty
+ \def\pgfmathresult{nan}%
+ \else
+ \pgfplotscoordmath{y}{tostring}\pgfplots@current@point@y
+ \fi
+ \let\pgfplots@current@point@y=\pgfmathresult
+ %
+ \ifpgfplots@curplot@threedim
+ \ifx\pgfplots@current@point@z\pgfutil@empty
+ \def\pgfmathresult{nan}%
+ \else
+ \pgfplotscoordmath{z}{tostring}\pgfplots@current@point@z
+ \fi
+ \let\pgfplots@current@point@z=\pgfmathresult
+ \fi
+ %
+ \begingroup
+ \pgfplots@clickable@coordcollect@handlechars
+ #1%
+ \xdef\pgfplots@glob@TMPa{\pgfplotsretval}%
+%\message{I have '\pgfplotsretval'}%
+ \endgroup
+ \xdef\pgfplots@glob@TMPa{\if1\pgfplots@clickable@collectedplot@isempty\else,\fi[\pgfplots@current@point@x,\pgfplots@current@point@y\ifpgfplots@curplot@threedim,\pgfplots@current@point@z\fi,"\pgfplots@glob@TMPa"]}%
+ \endgroup
+ \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@glob@TMPa}\to\pgfplots@clickable@collectedplot
+ \def\pgfplots@clickable@collectedplot@isempty{0}%
+}%
+\def\pgfplots@clickable@endcoordcollect{%
+ \pgfplotsapplistXlet\pgfplots@clickable@collectedplot@=\pgfplots@clickable@collectedplot
+ \if1\pgfplots@clickable@collectedplots@isempty
+ \expandafter\pgfplotsapplistXglobalpushback\expandafter{\expandafter[\pgfplots@clickable@collectedplot@]}\to\pgfplots@clickable@collectedplots
+ \else
+ \expandafter\pgfplotsapplistXglobalpushback\expandafter{\expandafter,\expandafter[\pgfplots@clickable@collectedplot@]}\to\pgfplots@clickable@collectedplots
+ \fi
+ \gdef\pgfplots@clickable@collectedplots@isempty{0}%
+}%
+
+% Creates an area which is clickable. A click produces a popup which
+% contains information about the point under the cursor.
+%
+% The complete (!) context needs to be provided using key-value-pairs,
+% either in '#1' or set before invocation of \pgfplotsclickablecreate.
+%
+% This command actually creates an AcroForm which employs javascript
+% whenever it is clicked. A javascript Object is created which
+% represents the context (axis limits and options). This javascript
+% object is available at runtime.
+%
+% @remark This method is public and it is NOT restricted to pgfplots.
+% The pgfplots hook simply initialises the required key-value-pairs in
+% '#1'.
+% @remark This method does not draw anything. It initialises only a
+% clickable area and javascript code.
+%
+% The required key-value-pairs are documented in the pdf-manual or can
+% be seen above.
+%
+% @attention Complete key-value validation is NOT performed here. It
+% can happen that invalid options will produce javascript bugs when
+% opened with Acrobat Reader. Use the javascript console to find them.
+\def\pgfplotsclickablecreate[#1]{%
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfqkeys{/pgfplots/annot}{#1}%
+ \fi
+ \pgfkeysgetvalue{/pgfplots/annot/jsname}\pgfplots@clickable@uniquename
+ \ifx\pgfplots@clickable@uniquename\pgfutil@empty
+ \edef\pgfplots@clickable@uniquename{clickableplot\pgfplots@clickable@no}%
+ \begingroup
+ \c@pgf@counta=\pgfplots@clickable@no\relax
+ \advance\c@pgf@counta by1
+ \xdef\pgfplots@clickable@no{\the\c@pgf@counta}%
+ \endgroup
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/annot/collected plots}\pgfplots@clickable@collectedplots@@
+ \ifx\pgfplots@clickable@collectedplots@@\pgfutil@empty
+ \def\pgfplots@clickable@collectedplots@@{[]}%
+ \fi
+ %
+ \edef\pgfplots@clickable@expanded@args{%
+ {\pgfkeysvalueof{/pgfplots/annot/width}}%
+ {\pgfkeysvalueof{/pgfplots/annot/height}}%
+ {\pgfplots@clickable@uniquename}%
+ {{
+ axisType: "\pgfkeysvalueof{/pgfplots/axis type}",
+ dim: \pgfkeysvalueof{/pgfplots/annot/dim},
+ xmin: \pgfkeysvalueof{/pgfplots/annot/xmin},
+ xmax: \pgfkeysvalueof{/pgfplots/annot/xmax},
+ ymin: \pgfkeysvalueof{/pgfplots/annot/ymin},
+ ymax: \pgfkeysvalueof{/pgfplots/annot/ymax},
+ xscale: "\pgfkeysvalueof{/pgfplots/annot/xscale}",
+ yscale: "\pgfkeysvalueof{/pgfplots/annot/yscale}",
+ \ifnum\pgfkeysvalueof{/pgfplots/annot/dim}=3
+ zmin: \pgfkeysvalueof{/pgfplots/annot/zmin},
+ zmax: \pgfkeysvalueof{/pgfplots/annot/zmax},
+ zscale: "\pgfkeysvalueof{/pgfplots/annot/zscale}",
+ zaxis: \pgfkeysvalueof{/pgfplots/annot/z axis},
+ \fi
+ collectedPlots: \pgfplots@clickable@collectedplots@@,
+ snapDist: \pgfkeysvalueof{/pgfplots/annot/snap dist},
+ minminmin: \pgfkeysvalueof{/pgfplots/annot/minminmin},
+ xaxis: \pgfkeysvalueof{/pgfplots/annot/x axis},
+ yaxis: \pgfkeysvalueof{/pgfplots/annot/y axis}
+ }}%
+ {{
+ pointFormat: "\ifnum\pgfkeysvalueof{/pgfplots/annot/dim}=3 \pgfkeysvalueof{/pgfplots/annot/point format 3d}\else \pgfkeysvalueof{/pgfplots/annot/point format}\fi",
+ slopeFormat: "\pgfkeysvalueof{/pgfplots/annot/slope format}",
+ fillColor:\pgfkeysvalueof{/pgfplots/annot/js fillColor},
+ textFont:\pgfkeysvalueof{/pgfplots/annot/font},
+ textSize:\pgfkeysvalueof{/pgfplots/annot/textSize},
+ richText:\pgfkeysvalueof{/pgfplots/annot/richtext},
+ popupSizeGeneric:"\pgfkeysvalueof{/pgfplots/annot/popup size generic}",
+ popupSizeSnap:"\pgfkeysvalueof{/pgfplots/annot/popup size snap}",
+ printable: \ifpgfplots@annot@printable true\else false\fi
+ }}%
+ }%
+ \expandafter\pgfplots@create@clickable@plotarea\pgfplots@clickable@expanded@args
+}%
+
+% Defines either \def\pgfplotsretval{1} if the current axis is
+% clickable or \def\pgfplotsretval{0} if not.
+%
+% The initial configuration is `1' for any 2d axis, `1' for 3d axes
+% with 'clickable coords' and `0' for 3d axes without `clickable
+% coords'.
+%
+% Overwrite \pgfplotsclickable@check@enable@axistype@<theaxistype> to
+% make axis type specific things.
+\def\pgfplotsclickable@check@enable{%
+ \def\pgfplotsretval{1}%
+ \ifpgfplots@threedim
+ \ifx\pgfplots@clickable@collectedplots@@\pgfutil@empty
+ \def\pgfplotsretval{0}%
+ \fi
+ \fi
+ \csname pgfplotsclickable@check@enable@axistype@\pgfkeysvalueof{/pgfplots/axis type}\endcsname
+}%
+
+% This thing is invoked from within pgfplots. It prepares and invokes
+% \pgfplotsclickablecreate.
+%
+\def\pgfplots@create@clickable@plotarea@hook{%
+ \ifpgfplots@clickable
+ \begingroup
+ % communicate collected plot coordinates:
+ \pgfplotsapplistXgloballet\pgfplots@clickable@collectedplots@@=\pgfplots@clickable@collectedplots
+ \pgfplotsapplistXglobalnewempty\pgfplots@clickable@collectedplots
+ \t@pgfplots@tokc=\expandafter{\pgfplots@clickable@collectedplots@@}%
+ \edef\pgfplots@clickable@collectedplots@@{[\the\t@pgfplots@tokc]}%
+ \pgfkeyslet{/pgfplots/annot/collected plots}\pgfplots@clickable@collectedplots@@
+ %
+ \pgfplotsclickable@check@enable
+ \if1\pgfplotsretval
+ %
+ \pgfplotscoordmath{x}{datascaletrafo inverse}{\pgfplots@xmin}%
+ \pgfplotscoordmath{x}{tostring}{\pgfmathresult}%
+ \let\pgfplots@clickable@xmin=\pgfmathresult
+ \pgfplotscoordmath{x}{datascaletrafo inverse}{\pgfplots@xmax}%
+ \pgfplotscoordmath{x}{tostring}{\pgfmathresult}%
+ \let\pgfplots@clickable@xmax=\pgfmathresult
+ %
+ \pgfplotscoordmath{y}{datascaletrafo inverse}{\pgfplots@ymin}%
+ \pgfplotscoordmath{y}{tostring}{\pgfmathresult}%
+ \let\pgfplots@clickable@ymin=\pgfmathresult
+ \pgfplotscoordmath{y}{datascaletrafo inverse}{\pgfplots@ymax}%
+ \pgfplotscoordmath{y}{tostring}{\pgfmathresult}%
+ \let\pgfplots@clickable@ymax=\pgfmathresult
+ %
+ \ifpgfplots@threedim
+ \pgfplotscoordmath{z}{datascaletrafo inverse}{\pgfplots@zmin}%
+ \pgfplotscoordmath{z}{tostring}{\pgfmathresult}%
+ \let\pgfplots@clickable@zmin=\pgfmathresult
+ \pgfplotscoordmath{z}{datascaletrafo inverse}{\pgfplots@zmax}%
+ \pgfplotscoordmath{z}{tostring}{\pgfmathresult}%
+ \let\pgfplots@clickable@zmax=\pgfmathresult
+ \fi
+ %
+ % Convert to user interface of clickable lib:
+ \pgfplotspointbbdiagonal
+ \edef\pgfplots@clickable@wd{\the\pgf@x}%
+ \pgfkeyslet{/pgfplots/annot/width}\pgfplots@clickable@wd
+ \edef\pgfplots@clickable@ht{\the\pgf@y}%
+ \pgfkeyslet{/pgfplots/annot/height}\pgfplots@clickable@ht
+ \pgfkeyslet{/pgfplots/annot/xmin}\pgfplots@clickable@xmin
+ \pgfkeyslet{/pgfplots/annot/xmax}\pgfplots@clickable@xmax
+ \pgfkeyslet{/pgfplots/annot/ymin}\pgfplots@clickable@ymin
+ \pgfkeyslet{/pgfplots/annot/ymax}\pgfplots@clickable@ymax
+ \ifpgfplots@xislinear
+ \pgfkeyssetvalue{/pgfplots/annot/xscale}{linear}%
+ \else
+ \pgfkeyssetvalue{/pgfplots/annot/xscale}{log:\pgfkeysvalueof{/pgfplots/log basis x}}%
+ \fi
+ \ifpgfplots@yislinear
+ \pgfkeyssetvalue{/pgfplots/annot/yscale}{linear}%
+ \else
+ \pgfkeyssetvalue{/pgfplots/annot/yscale}{log:\pgfkeysvalueof{/pgfplots/log basis y}}%
+ \fi
+ \ifpgfplots@threedim
+ \pgfkeyslet{/pgfplots/annot/zmin}\pgfplots@clickable@zmin
+ \pgfkeyslet{/pgfplots/annot/zmax}\pgfplots@clickable@zmax
+ \ifpgfplots@zislinear
+ \pgfkeyssetvalue{/pgfplots/annot/zscale}{linear}%
+ \else
+ \pgfkeyssetvalue{/pgfplots/annot/zscale}{log:\pgfkeysvalueof{/pgfplots/log basis z}}%
+ \fi
+ \fi
+ %
+ % note that \pgfplotspointbblowerleft has *not* been
+ % transformed after \endtikzpicture in pgfplots.code.tex.
+ % That's why I can use it here:
+ \pgfpointdiff
+ \pgfplotspointbblowerleft
+ {\pgfplotspointminminmin}%
+ \pgf@sys@bp@correct\pgf@x \pgf@sys@bp@correct\pgf@y
+ \edef\pgfplots@loc@TMPa{[\pgf@sys@tonumber\pgf@x, \pgf@sys@tonumber\pgf@y]}%
+ \pgfkeyslet{/pgfplots/annot/minminmin}\pgfplots@loc@TMPa
+ %
+ \pgfplotspointxaxis
+ \pgf@sys@bp@correct\pgf@x \pgf@sys@bp@correct\pgf@y
+ \edef\pgfplots@loc@TMPa{[\pgf@sys@tonumber\pgf@x, \pgf@sys@tonumber\pgf@y]}%
+ \pgfkeyslet{/pgfplots/annot/x axis}\pgfplots@loc@TMPa
+ %
+ \pgfplotspointyaxis
+ \pgf@sys@bp@correct\pgf@x \pgf@sys@bp@correct\pgf@y
+ \edef\pgfplots@loc@TMPa{[\pgf@sys@tonumber\pgf@x, \pgf@sys@tonumber\pgf@y]}%
+ \pgfkeyslet{/pgfplots/annot/y axis}\pgfplots@loc@TMPa
+ %
+ \ifpgfplots@threedim
+ \pgfplotspointzaxis
+ \pgf@sys@bp@correct\pgf@x \pgf@sys@bp@correct\pgf@y
+ \edef\pgfplots@loc@TMPa{[\pgf@sys@tonumber\pgf@x, \pgf@sys@tonumber\pgf@y]}%
+ \pgfkeyslet{/pgfplots/annot/z axis}\pgfplots@loc@TMPa
+ \fi
+ %
+ \pgfkeyssetvalue{/pgfplots/annot/dim}{\ifpgfplots@threedim 3\else2\fi}%
+ %
+ %
+ \pgfinterruptboundingbox%
+ \pgftext[left,bottom,at=\lowerleftinnercorner]{\pgfplotsclickablecreate[]}%
+ \endpgfinterruptboundingbox%
+ \fi
+ \endgroup
+ \fi
+}
+
+% This is the low-level method which creates Acroforms and Javascript
+% code.
+% #1: width
+% #2: height
+% #3: name
+% #4: the axisAnnotObj object (see javascript docs above)
+% #5: the displayOpts object (see javascript docs above)
+\def\pgfplots@create@clickable@plotarea#1#2#3#4#5{%
+%\tracingmacros=2\tracingcommands=2
+ %\leavevmode
+ %--------------------------------------------------
+ % hyperref.sty implementation:
+ %--------------------------------------------------
+ % \PushButton[name=#3,borderwidth=0,bordersep=0,
+ % onclick={processAnnotatedPlot("#3", #4, #5);}]{\vbox to #2{\hsize=#1\vfill\hfill}}%
+ % \TextField[name=#3-result,hidden=true]{}%
+ %--------------------------------------------------
+ %
+ %--------------------------------------------------
+ % eforms.sty implementation:
+ % it allows more customization.
+ %--------------------------------------------------
+ %
+ % Hier kommen Annotation Directories zum Zuge!
+ % -> siehe Annotations in pdf reference
+ \def\pushButtonDefaults{
+ \W{0}% border width
+ \Border{0 0 0}%
+ }%
+ \def\textFieldDefaults{%
+ \W{1}% border width
+ \S{B}% border style ( one of SDBIU )
+ \F{2}% "display" bitflag. 2^1= hidden (see "Annotation Flags" in pdf reference)
+ %ATTENTION: \F 2 (hidden) produces INCOMPATIBILITIES with figure environment!?
+ % ---> ok, that has been fixed by recent versions of hyperref.
+ % (the pdf catalog may be incomplete in older hyperref pdftex drivers)
+ \Ff{1}% "Field characteristics" bitflag. 2^0 = "read-only"
+ }%
+ \pushButton[
+ %\A{/S/JavaScript/JS(processAnnotatedPlot("#3", #4, #5);)}%
+ \AA{
+ % /U = "mouse UP"
+ % /D = "mouse DOWN"
+ /U << /S/JavaScript/JS(axisMouseUp("#3", #4, #5);) >>
+ /D << /S/JavaScript/JS(axisMouseDown("#3");) >>
+ }%
+ ]
+ {#3}
+ {#1}{#2}%
+ \textField{#3-result}{0pt}{0pt}%
+ \textField{#3-result2}{0pt}{0pt}%
+ \textField{#3-resultmark}{0pt}{0pt}%
+ \textField{#3-result2mark}{0pt}{0pt}%
+ \textField{#3-slope}{0pt}{0pt}%
+ % Unfortunately, line annotations can't be created/changed in acrobat
+ % javascript due to right problems :-(
+ %--------------------------------------------------
+ % \hbox to 0pt{\vsize=0pt \pdfannot{
+ % /Subtype /Line
+ % /Open /false
+ % /NM (#3-line)
+ % /C
+ % /CA
+ % /Subj ()
+ % /Contents ()
+ % /L [0 0 0 0]
+ % /LE [/None /OpenArrow] % PDF 1.4
+ % % /Ff 194
+ % }}%
+ %--------------------------------------------------
+ %
+ %
+ %\setLinkBbox[%
+ % \Border{}%
+ % \A{/S/JavaScript/JS(processme("#3");)}%
+ % \rawPDF{/C[1 0 0] /NM (#3)}%
+ % ]%
+ % {#1}{#2}{}%
+}
+
+\catcode`\"=\pgfplotscatcodeDQ
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.colormaps.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.colormaps.code.tex
new file mode 100644
index 0000000000..297818b877
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.colormaps.code.tex
@@ -0,0 +1,359 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for additional colormaps, especially those
+% related to matlab (tm).
+%
+% Copyright 2011 by Christian Feuersänger and Patrick Häcker.
+%
+% 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/>.
+%
+%
+
+\pgfplotsset{
+ /pgfplots/colormap/autumn/.style={
+ /pgfplots/colormap={autumn}{rgb255=(255,0,0) rgb255=(255,255,0)}
+ },
+ /pgfplots/colormap/bled/.style={
+ /pgfplots/colormap={bled}{rgb255=(0,0,0) rgb255=(43,43,0) rgb255=(0,85,0) rgb255=(0,128,128) rgb255=(0,0,170) rgb255=(213,0,213) rgb255=(255,0,0)}
+ },
+ /pgfplots/colormap/bright/.style={
+ /pgfplots/colormap={bright}{rgb255=(0,0,0) rgb255=(78,3,100) rgb255=(2,74,255) rgb255=(255,21,181) rgb255=(255,113,26) rgb255=(147,213,114) rgb255=(230,255,0) rgb255=(255,255,255)}
+ },
+ /pgfplots/colormap/cold/.style={
+ /pgfplots/colormap={cold}{rgb255=(0,0,0) rgb255=(0,0,255) rgb255=(0,255,255) rgb255=(255,255,255)}
+ },
+ /pgfplots/colormap/copper/.style={
+ /pgfplots/colormap={copper}{[1cm]rgb255(0cm)=(0,0,0) rgb255(4cm)=(255,159,101) rgb255(5cm)=(255,199,127)}
+ },
+ /pgfplots/colormap/copper2/.style={
+ /pgfplots/colormap={copper2}{rgb255=(0,0,0) rgb255=(68,62,63) rgb255=(170,112,95) rgb255=(207,194,138) rgb255=(255,255,255)}
+ },
+ /pgfplots/colormap/earth/.style={
+ /pgfplots/colormap={earth}{rgb255=(0,0,0) rgb255=(0,28,15) rgb255=(42,39,6) rgb255=(28,73,33) rgb255=(67,85,24) rgb255=(68,112,46) rgb255=(81,129,83) rgb255=(124,137,87) rgb255=(153,147,122) rgb255=(145,173,164) rgb255=(144,202,180) rgb255=(171,220,177) rgb255=(218,229,168) rgb255=(255,235,199) rgb255=(255,255,255)}
+ },
+ /pgfplots/colormap/gray/.style={
+ /pgfplots/colormap={gray}{rgb255=(0,0,0) rgb255=(255,255,255)}
+ },
+ /pgfplots/colormap/hsv/.style={
+ /pgfplots/colormap={hsv}{rgb255=(255,0,0) rgb255=(255,255,0) rgb255=(0,255,0) rgb255=(0,255,255) rgb255=(0,0,255) rgb255=(255,0,255) rgb255=(255,0,0)}
+ },
+ /pgfplots/colormap/hsv2/.style={
+ /pgfplots/colormap={hsv2}{rgb255=(0,0,0) rgb255=(128,0,128) rgb255=(0,0,230) rgb255=(0,255,255) rgb255=(0,255,0) rgb255=(255,255,0) rgb255=(255,0,0)}
+ },
+ /pgfplots/colormap/pastel/.style={
+ /pgfplots/colormap={pastel}{rgb255=(0,0,0) rgb255=(120,0,5) rgb255=(0,91,172) rgb255=(215,35,217) rgb255=(120,172,78) rgb255=(255,176,24) rgb255=(230,255,0) rgb255=(255,255,255)}
+ },
+ /pgfplots/colormap/pink/.style={
+ /pgfplots/colormap={pink}{rgb255=(0,0,0) rgb255=(12,16,46) rgb255=(62,22,43) rgb255=(53,53,65) rgb255=(79,72,58) rgb255=(122,80,67) rgb255=(147,91,102) rgb255=(147,115,140) rgb255=(144,145,154) rgb255=(173,163,146) rgb255=(216,171,149) rgb255=(250,179,179) rgb255=(255,198,227) rgb255=(246,229,255) rgb255=(255,255,255)}
+ },
+ /pgfplots/colormap/sepia/.style={
+ /pgfplots/colormap={sepia}{rgb255(0cm)=(0,0,0) rgb255(1cm)=(26,13,0) rgb255(18cm)=(255,230,204) rgb255(20cm)=(255,255,255)}
+ },
+ /pgfplots/colormap/bone/.style={
+ /pgfplots/colormap={bone}{[1cm]rgb255(0cm)=(0,0,0) rgb255(3cm)=(84,84,116) rgb255(6cm)=(167,199,199) rgb255(8cm)=(255,255,255)}
+},
+ %--------------------------------------------------
+ % % mesh width is too fine for these:
+ % /pgfplots/colormap/dusk/.style={
+ % /pgfplots/colormap={dusk}{
+ % [1cm]rgb255(0cm)=(0,0,0)
+ % rgb255(114cm)=(0,0,128) rgb255(701cm)=(0,128,128)
+ % rgb255(1000cm)=(128,128,128) rgb255(1299cm)=(255,128,128)
+ % rgb255(1886cm)=(255,255,128) rgb255(2000cm)=(255,255,255)}
+ % },
+ % /pgfplots/colormap/hicontrast/.style={
+ % /pgfplots/colormap={hicontrast}{
+ % [1cm]rgb255(0cm)=(0,0,0) rgb255(114cm)=(0,0,255) rgb255(299cm)=(255,0,0) rgb255(413cm)=(255,0,255)
+ % rgb255(587cm)=(0,255,0) rgb255(701cm)=(0,255,255) rgb255(886cm)=(255,255,0)
+ % rgb255(1000cm)=(255,255,255)}
+ % },
+ %--------------------------------------------------
+ /pgfplots/colormap/spring/.style={
+ /pgfplots/colormap={spring}{rgb255=(255,0,255) rgb255=(255,255,0)}
+ },
+ /pgfplots/colormap/summer/.style={
+ /pgfplots/colormap={summer}{rgb255=(0,128,102) rgb255=(255,255,102)}
+ },
+ /pgfplots/colormap/temp/.style={
+ /pgfplots/colormap={temp}{rgb255=(36,0,217) rgb255=(25,29,247) rgb255=(41,87,255) rgb255=(61,135,255) rgb255=(87,176,255) rgb255=(117,211,255) rgb255=(153,235,255) rgb255=(189,249,255) rgb255=(235,255,255) rgb255=(255,255,235) rgb255=(255,242,189) rgb255=(255,214,153) rgb255=(255,172,117) rgb255=(255,120,87) rgb255=(255,61,61) rgb255=(247,40,54) rgb255=(217,22,48) rgb255=(166,0,33)}
+ },
+ /pgfplots/colormap/thermal/.style={
+ /pgfplots/colormap={thermal}{rgb255=(0,0,0) rgb255=(77,0,179) rgb255=(255,51,0) rgb255=(255,255,0) rgb255=(255,255,255)}
+ },
+ /pgfplots/colormap/winter/.style={
+ /pgfplots/colormap={winter}{rgb255=(0,0,255) rgb255=(0,255,128)}
+ },
+ /pgfplots/colormap/viridis high res/.style={%
+ /pgfplots/colormap={viridis high res}{%
+ rgb=(0.26700401, 0.00487433, 0.32941519)
+ rgb=(0.26851048, 0.00960483, 0.33542652)
+ rgb=(0.26994384, 0.01462494, 0.34137895)
+ rgb=(0.27130489, 0.01994186, 0.34726862)
+ rgb=(0.27259384, 0.02556309, 0.35309303)
+ rgb=(0.27380934, 0.03149748, 0.35885256)
+ rgb=(0.27495242, 0.03775181, 0.36454323)
+ rgb=(0.27602238, 0.04416723, 0.37016418)
+ rgb=(0.2770184 , 0.05034437, 0.37571452)
+ rgb=(0.27794143, 0.05632444, 0.38119074)
+ rgb=(0.27879067, 0.06214536, 0.38659204)
+ rgb=(0.2795655 , 0.06783587, 0.39191723)
+ rgb=(0.28026658, 0.07341724, 0.39716349)
+ rgb=(0.28089358, 0.07890703, 0.40232944)
+ rgb=(0.28144581, 0.0843197 , 0.40741404)
+ rgb=(0.28192358, 0.08966622, 0.41241521)
+ rgb=(0.28232739, 0.09495545, 0.41733086)
+ rgb=(0.28265633, 0.10019576, 0.42216032)
+ rgb=(0.28291049, 0.10539345, 0.42690202)
+ rgb=(0.28309095, 0.11055307, 0.43155375)
+ rgb=(0.28319704, 0.11567966, 0.43611482)
+ rgb=(0.28322882, 0.12077701, 0.44058404)
+ rgb=(0.28318684, 0.12584799, 0.44496 )
+ rgb=(0.283072 , 0.13089477, 0.44924127)
+ rgb=(0.28288389, 0.13592005, 0.45342734)
+ rgb=(0.28262297, 0.14092556, 0.45751726)
+ rgb=(0.28229037, 0.14591233, 0.46150995)
+ rgb=(0.28188676, 0.15088147, 0.46540474)
+ rgb=(0.28141228, 0.15583425, 0.46920128)
+ rgb=(0.28086773, 0.16077132, 0.47289909)
+ rgb=(0.28025468, 0.16569272, 0.47649762)
+ rgb=(0.27957399, 0.17059884, 0.47999675)
+ rgb=(0.27882618, 0.1754902 , 0.48339654)
+ rgb=(0.27801236, 0.18036684, 0.48669702)
+ rgb=(0.27713437, 0.18522836, 0.48989831)
+ rgb=(0.27619376, 0.19007447, 0.49300074)
+ rgb=(0.27519116, 0.1949054 , 0.49600488)
+ rgb=(0.27412802, 0.19972086, 0.49891131)
+ rgb=(0.27300596, 0.20452049, 0.50172076)
+ rgb=(0.27182812, 0.20930306, 0.50443413)
+ rgb=(0.27059473, 0.21406899, 0.50705243)
+ rgb=(0.26930756, 0.21881782, 0.50957678)
+ rgb=(0.26796846, 0.22354911, 0.5120084 )
+ rgb=(0.26657984, 0.2282621 , 0.5143487 )
+ rgb=(0.2651445 , 0.23295593, 0.5165993 )
+ rgb=(0.2636632 , 0.23763078, 0.51876163)
+ rgb=(0.26213801, 0.24228619, 0.52083736)
+ rgb=(0.26057103, 0.2469217 , 0.52282822)
+ rgb=(0.25896451, 0.25153685, 0.52473609)
+ rgb=(0.25732244, 0.2561304 , 0.52656332)
+ rgb=(0.25564519, 0.26070284, 0.52831152)
+ rgb=(0.25393498, 0.26525384, 0.52998273)
+ rgb=(0.25219404, 0.26978306, 0.53157905)
+ rgb=(0.25042462, 0.27429024, 0.53310261)
+ rgb=(0.24862899, 0.27877509, 0.53455561)
+ rgb=(0.2468114 , 0.28323662, 0.53594093)
+ rgb=(0.24497208, 0.28767547, 0.53726018)
+ rgb=(0.24311324, 0.29209154, 0.53851561)
+ rgb=(0.24123708, 0.29648471, 0.53970946)
+ rgb=(0.23934575, 0.30085494, 0.54084398)
+ rgb=(0.23744138, 0.30520222, 0.5419214 )
+ rgb=(0.23552606, 0.30952657, 0.54294396)
+ rgb=(0.23360277, 0.31382773, 0.54391424)
+ rgb=(0.2316735 , 0.3181058 , 0.54483444)
+ rgb=(0.22973926, 0.32236127, 0.54570633)
+ rgb=(0.22780192, 0.32659432, 0.546532 )
+ rgb=(0.2258633 , 0.33080515, 0.54731353)
+ rgb=(0.22392515, 0.334994 , 0.54805291)
+ rgb=(0.22198915, 0.33916114, 0.54875211)
+ rgb=(0.22005691, 0.34330688, 0.54941304)
+ rgb=(0.21812995, 0.34743154, 0.55003755)
+ rgb=(0.21620971, 0.35153548, 0.55062743)
+ rgb=(0.21429757, 0.35561907, 0.5511844 )
+ rgb=(0.21239477, 0.35968273, 0.55171011)
+ rgb=(0.2105031 , 0.36372671, 0.55220646)
+ rgb=(0.20862342, 0.36775151, 0.55267486)
+ rgb=(0.20675628, 0.37175775, 0.55311653)
+ rgb=(0.20490257, 0.37574589, 0.55353282)
+ rgb=(0.20306309, 0.37971644, 0.55392505)
+ rgb=(0.20123854, 0.38366989, 0.55429441)
+ rgb=(0.1994295 , 0.38760678, 0.55464205)
+ rgb=(0.1976365 , 0.39152762, 0.55496905)
+ rgb=(0.19585993, 0.39543297, 0.55527637)
+ rgb=(0.19410009, 0.39932336, 0.55556494)
+ rgb=(0.19235719, 0.40319934, 0.55583559)
+ rgb=(0.19063135, 0.40706148, 0.55608907)
+ rgb=(0.18892259, 0.41091033, 0.55632606)
+ rgb=(0.18723083, 0.41474645, 0.55654717)
+ rgb=(0.18555593, 0.4185704 , 0.55675292)
+ rgb=(0.18389763, 0.42238275, 0.55694377)
+ rgb=(0.18225561, 0.42618405, 0.5571201 )
+ rgb=(0.18062949, 0.42997486, 0.55728221)
+ rgb=(0.17901879, 0.43375572, 0.55743035)
+ rgb=(0.17742298, 0.4375272 , 0.55756466)
+ rgb=(0.17584148, 0.44128981, 0.55768526)
+ rgb=(0.17427363, 0.4450441 , 0.55779216)
+ rgb=(0.17271876, 0.4487906 , 0.55788532)
+ rgb=(0.17117615, 0.4525298 , 0.55796464)
+ rgb=(0.16964573, 0.45626209, 0.55803034)
+ rgb=(0.16812641, 0.45998802, 0.55808199)
+ rgb=(0.1666171 , 0.46370813, 0.55811913)
+ rgb=(0.16511703, 0.4674229 , 0.55814141)
+ rgb=(0.16362543, 0.47113278, 0.55814842)
+ rgb=(0.16214155, 0.47483821, 0.55813967)
+ rgb=(0.16066467, 0.47853961, 0.55811466)
+ rgb=(0.15919413, 0.4822374 , 0.5580728 )
+ rgb=(0.15772933, 0.48593197, 0.55801347)
+ rgb=(0.15626973, 0.4896237 , 0.557936 )
+ rgb=(0.15481488, 0.49331293, 0.55783967)
+ rgb=(0.15336445, 0.49700003, 0.55772371)
+ rgb=(0.1519182 , 0.50068529, 0.55758733)
+ rgb=(0.15047605, 0.50436904, 0.55742968)
+ rgb=(0.14903918, 0.50805136, 0.5572505 )
+ rgb=(0.14760731, 0.51173263, 0.55704861)
+ rgb=(0.14618026, 0.51541316, 0.55682271)
+ rgb=(0.14475863, 0.51909319, 0.55657181)
+ rgb=(0.14334327, 0.52277292, 0.55629491)
+ rgb=(0.14193527, 0.52645254, 0.55599097)
+ rgb=(0.14053599, 0.53013219, 0.55565893)
+ rgb=(0.13914708, 0.53381201, 0.55529773)
+ rgb=(0.13777048, 0.53749213, 0.55490625)
+ rgb=(0.1364085 , 0.54117264, 0.55448339)
+ rgb=(0.13506561, 0.54485335, 0.55402906)
+ rgb=(0.13374299, 0.54853458, 0.55354108)
+ rgb=(0.13244401, 0.55221637, 0.55301828)
+ rgb=(0.13117249, 0.55589872, 0.55245948)
+ rgb=(0.1299327 , 0.55958162, 0.55186354)
+ rgb=(0.12872938, 0.56326503, 0.55122927)
+ rgb=(0.12756771, 0.56694891, 0.55055551)
+ rgb=(0.12645338, 0.57063316, 0.5498411 )
+ rgb=(0.12539383, 0.57431754, 0.54908564)
+ rgb=(0.12439474, 0.57800205, 0.5482874 )
+ rgb=(0.12346281, 0.58168661, 0.54744498)
+ rgb=(0.12260562, 0.58537105, 0.54655722)
+ rgb=(0.12183122, 0.58905521, 0.54562298)
+ rgb=(0.12114807, 0.59273889, 0.54464114)
+ rgb=(0.12056501, 0.59642187, 0.54361058)
+ rgb=(0.12009154, 0.60010387, 0.54253043)
+ rgb=(0.11973756, 0.60378459, 0.54139999)
+ rgb=(0.11951163, 0.60746388, 0.54021751)
+ rgb=(0.11942341, 0.61114146, 0.53898192)
+ rgb=(0.11948255, 0.61481702, 0.53769219)
+ rgb=(0.11969858, 0.61849025, 0.53634733)
+ rgb=(0.12008079, 0.62216081, 0.53494633)
+ rgb=(0.12063824, 0.62582833, 0.53348834)
+ rgb=(0.12137972, 0.62949242, 0.53197275)
+ rgb=(0.12231244, 0.63315277, 0.53039808)
+ rgb=(0.12344358, 0.63680899, 0.52876343)
+ rgb=(0.12477953, 0.64046069, 0.52706792)
+ rgb=(0.12632581, 0.64410744, 0.52531069)
+ rgb=(0.12808703, 0.64774881, 0.52349092)
+ rgb=(0.13006688, 0.65138436, 0.52160791)
+ rgb=(0.13226797, 0.65501363, 0.51966086)
+ rgb=(0.13469183, 0.65863619, 0.5176488 )
+ rgb=(0.13733921, 0.66225157, 0.51557101)
+ rgb=(0.14020991, 0.66585927, 0.5134268 )
+ rgb=(0.14330291, 0.66945881, 0.51121549)
+ rgb=(0.1466164 , 0.67304968, 0.50893644)
+ rgb=(0.15014782, 0.67663139, 0.5065889 )
+ rgb=(0.15389405, 0.68020343, 0.50417217)
+ rgb=(0.15785146, 0.68376525, 0.50168574)
+ rgb=(0.16201598, 0.68731632, 0.49912906)
+ rgb=(0.1663832 , 0.69085611, 0.49650163)
+ rgb=(0.1709484 , 0.69438405, 0.49380294)
+ rgb=(0.17570671, 0.6978996 , 0.49103252)
+ rgb=(0.18065314, 0.70140222, 0.48818938)
+ rgb=(0.18578266, 0.70489133, 0.48527326)
+ rgb=(0.19109018, 0.70836635, 0.48228395)
+ rgb=(0.19657063, 0.71182668, 0.47922108)
+ rgb=(0.20221902, 0.71527175, 0.47608431)
+ rgb=(0.20803045, 0.71870095, 0.4728733 )
+ rgb=(0.21400015, 0.72211371, 0.46958774)
+ rgb=(0.22012381, 0.72550945, 0.46622638)
+ rgb=(0.2263969 , 0.72888753, 0.46278934)
+ rgb=(0.23281498, 0.73224735, 0.45927675)
+ rgb=(0.2393739 , 0.73558828, 0.45568838)
+ rgb=(0.24606968, 0.73890972, 0.45202405)
+ rgb=(0.25289851, 0.74221104, 0.44828355)
+ rgb=(0.25985676, 0.74549162, 0.44446673)
+ rgb=(0.26694127, 0.74875084, 0.44057284)
+ rgb=(0.27414922, 0.75198807, 0.4366009 )
+ rgb=(0.28147681, 0.75520266, 0.43255207)
+ rgb=(0.28892102, 0.75839399, 0.42842626)
+ rgb=(0.29647899, 0.76156142, 0.42422341)
+ rgb=(0.30414796, 0.76470433, 0.41994346)
+ rgb=(0.31192534, 0.76782207, 0.41558638)
+ rgb=(0.3198086 , 0.77091403, 0.41115215)
+ rgb=(0.3277958 , 0.77397953, 0.40664011)
+ rgb=(0.33588539, 0.7770179 , 0.40204917)
+ rgb=(0.34407411, 0.78002855, 0.39738103)
+ rgb=(0.35235985, 0.78301086, 0.39263579)
+ rgb=(0.36074053, 0.78596419, 0.38781353)
+ rgb=(0.3692142 , 0.78888793, 0.38291438)
+ rgb=(0.37777892, 0.79178146, 0.3779385 )
+ rgb=(0.38643282, 0.79464415, 0.37288606)
+ rgb=(0.39517408, 0.79747541, 0.36775726)
+ rgb=(0.40400101, 0.80027461, 0.36255223)
+ rgb=(0.4129135 , 0.80304099, 0.35726893)
+ rgb=(0.42190813, 0.80577412, 0.35191009)
+ rgb=(0.43098317, 0.80847343, 0.34647607)
+ rgb=(0.44013691, 0.81113836, 0.3409673 )
+ rgb=(0.44936763, 0.81376835, 0.33538426)
+ rgb=(0.45867362, 0.81636288, 0.32972749)
+ rgb=(0.46805314, 0.81892143, 0.32399761)
+ rgb=(0.47750446, 0.82144351, 0.31819529)
+ rgb=(0.4870258 , 0.82392862, 0.31232133)
+ rgb=(0.49661536, 0.82637633, 0.30637661)
+ rgb=(0.5062713 , 0.82878621, 0.30036211)
+ rgb=(0.51599182, 0.83115784, 0.29427888)
+ rgb=(0.52577622, 0.83349064, 0.2881265 )
+ rgb=(0.5356211 , 0.83578452, 0.28190832)
+ rgb=(0.5455244 , 0.83803918, 0.27562602)
+ rgb=(0.55548397, 0.84025437, 0.26928147)
+ rgb=(0.5654976 , 0.8424299 , 0.26287683)
+ rgb=(0.57556297, 0.84456561, 0.25641457)
+ rgb=(0.58567772, 0.84666139, 0.24989748)
+ rgb=(0.59583934, 0.84871722, 0.24332878)
+ rgb=(0.60604528, 0.8507331 , 0.23671214)
+ rgb=(0.61629283, 0.85270912, 0.23005179)
+ rgb=(0.62657923, 0.85464543, 0.22335258)
+ rgb=(0.63690157, 0.85654226, 0.21662012)
+ rgb=(0.64725685, 0.85839991, 0.20986086)
+ rgb=(0.65764197, 0.86021878, 0.20308229)
+ rgb=(0.66805369, 0.86199932, 0.19629307)
+ rgb=(0.67848868, 0.86374211, 0.18950326)
+ rgb=(0.68894351, 0.86544779, 0.18272455)
+ rgb=(0.69941463, 0.86711711, 0.17597055)
+ rgb=(0.70989842, 0.86875092, 0.16925712)
+ rgb=(0.72039115, 0.87035015, 0.16260273)
+ rgb=(0.73088902, 0.87191584, 0.15602894)
+ rgb=(0.74138803, 0.87344918, 0.14956101)
+ rgb=(0.75188414, 0.87495143, 0.14322828)
+ rgb=(0.76237342, 0.87642392, 0.13706449)
+ rgb=(0.77285183, 0.87786808, 0.13110864)
+ rgb=(0.78331535, 0.87928545, 0.12540538)
+ rgb=(0.79375994, 0.88067763, 0.12000532)
+ rgb=(0.80418159, 0.88204632, 0.11496505)
+ rgb=(0.81457634, 0.88339329, 0.11034678)
+ rgb=(0.82494028, 0.88472036, 0.10621724)
+ rgb=(0.83526959, 0.88602943, 0.1026459 )
+ rgb=(0.84556056, 0.88732243, 0.09970219)
+ rgb=(0.8558096 , 0.88860134, 0.09745186)
+ rgb=(0.86601325, 0.88986815, 0.09595277)
+ rgb=(0.87616824, 0.89112487, 0.09525046)
+ rgb=(0.88627146, 0.89237353, 0.09537439)
+ rgb=(0.89632002, 0.89361614, 0.09633538)
+ rgb=(0.90631121, 0.89485467, 0.09812496)
+ rgb=(0.91624212, 0.89609127, 0.1007168 )
+ rgb=(0.92610579, 0.89732977, 0.10407067)
+ rgb=(0.93590444, 0.8985704 , 0.10813094)
+ rgb=(0.94563626, 0.899815 , 0.11283773)
+ rgb=(0.95529972, 0.90106534, 0.11812832)
+ rgb=(0.96489353, 0.90232311, 0.12394051)
+ rgb=(0.97441665, 0.90358991, 0.13021494)
+ rgb=(0.98386829, 0.90486726, 0.13689671)
+ rgb=(0.99324789, 0.90615657, 0.1439362 )
+ },
+ },
+}
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.dateplot.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.dateplot.code.tex
new file mode 100644
index 0000000000..e4859785e3
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.dateplot.code.tex
@@ -0,0 +1,270 @@
+%--------------------------------------------
+%
+% 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
+ \ifnum\c@pgf@countb=60
+ \c@pgf@countb=#4 %
+ \advance\c@pgf@countb by1
+ \edef#4{\the\c@pgf@countb}%
+ \c@pgf@countb=0
+ \fi
+ \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}}%
+
+%--------------------------------------------------
+%This here extends it to SECONDS, but the precision is too low
+% \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
+% %
+% \def\pgfplots@loc@TMPc{#4}%
+% \ifx\pgfplots@loc@TMPc\pgfutil@empty
+% \else
+% \edef\pgfplots@loc@TMPc{\pgfplotslibdateplot@discard@trailing@colon #4}%
+% \pgf@xb=\pgfplots@loc@TMPc pt
+% \divide\pgf@xb by1440
+% \divide\pgf@xb by60
+% \advance\pgf@xa by\pgf@xb
+% \fi
+% %
+% \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@trailing@colon#1:{#1}%
+%--------------------------------------------------
+
+\let\pgfplots@calender@ZEROSHIFT=\pgfutil@empty
+\def\pgfplots@dateplot@ensure@ZEROSHIFT#1{%
+ \ifx\pgfplots@calender@ZEROSHIFT\pgfutil@empty
+ \ifx\pgfplots@global@dateplot@defaultshift\pgfutil@empty
+ \pgfplots@log4{dateplot: setting 'date ZERO={#1}' for this axis.}%
+ \pgfplots@dateplot@parse@ZEROSHIFT{#1}%
+ \global\let\pgfplots@global@dateplot@defaultshift=\pgfmathresult
+ \fi
+ %
+ \let\pgfplots@calender@ZEROSHIFT=\pgfplots@global@dateplot@defaultshift
+ \fi
+}%
+% defines \pgfplots@calender@ZEROSHIFT to be the zero shift
+\def\pgfplots@dateplot@get@ZEROSHIFT{%
+ \ifx\pgfplots@calender@ZEROSHIFT\pgfutil@empty
+ \ifx\pgfplots@global@dateplot@defaultshift\pgfutil@empty
+ % should never happen
+ \pgfplots@error{Illegal internal state: no 'date ZERO' value found}%
+ \def\pgfplots@calender@ZEROSHIFT{0}%
+ \else
+ \let\pgfplots@calender@ZEROSHIFT=\pgfplots@global@dateplot@defaultshift
+ \fi
+ \fi
+}%
+
+\def\pgfplots@dateplot@parse@ZEROSHIFT#1{%
+ \begingroup
+ \pgfcalendardatetojulian{#1}\c@pgf@counta
+ \edef\pgfmathresult{\the\c@pgf@counta}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+\expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{\pgfplots@notify@options@are@set
+ \global\let\pgfplots@global@dateplot@defaultshift=\pgfutil@empty
+}
+
+\pgfplotsset{
+ /pgfplots/date ZERO/.code={%
+ \pgfplots@dateplot@parse@ZEROSHIFT{#1}%
+ \let\pgfplots@calender@ZEROSHIFT=\pgfmathresult
+ },
+ /pgfplots/date coordinates in/.code={%
+ \pgfkeysdef{/pgfplots/#1 coord trafo}{%
+ \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\pgfplots@dateplot@ensure@ZEROSHIFT\expandafter{\pgfplotstempjuliandate}%
+ %
+ \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
+ }%
+ \pgfkeysdef{/pgfplots/#1 coord inv trafo}{%
+ \edef\pgfplotstempjuliandatenumeric{##1}%
+ \begingroup
+ \pgfplots@dateplot@get@ZEROSHIFT
+ %
+ \expandafter\pgfplotslibdateplot@number@to@julian@and@time\pgfplotstempjuliandatenumeric\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}%
+ \pgfkeysifdefined{/pgfplots/date default inv/#1}{%
+ \edef\pgfmathresult{\pgfkeysvalueof{/pgfplots/date default inv/#1}}%
+ }{%
+ \edef\pgfmathresult{\year-\month-\day\space\hour:\minute:\second}%
+ }%
+ }%
+ \pgfkeysifdefined{/pgfplots/#1ticklabel/.@cmd}{%
+ \pgfkeysalso{%
+ /pgfplots/#1ticklabel={\tick},%
+ /pgfplots/scaled #1 ticks=false,%
+ /pgfplots/plot coordinates/math parser=false,%
+ }%
+ }{%
+ % OK. The style can be used for other coordinates as well
+ % (like hist/data)
+ }%
+ %
+ \pgfkeysifdefined{/pgfplots/#1 is expr}{%
+ \pgfkeyssetvalue{/pgfplots/#1 is expr}{0}%
+ }{}%
+ %
+ % Allow a callback (optional)
+ \pgfkeysifdefined{/pgfplots/#1/@execute on coord trafo changed/.@cmd}{%
+ \pgfkeysalso {/pgfplots/#1/@execute on coord trafo changed}%
+ }{}%
+ },
+ /pgfplots/date coordinates in/.value required,
+ %
+ % #1: the argument for 'data coordinates in={#1}
+ % #2: the default for the inverse transformation. If there is
+ % none, a default will be chosen automatically (with full
+ % information)
+ /pgfplots/date coordinates default inverse/.style 2 args={%
+ /pgfplots/date default inv/#1/.initial=#2,
+ },
+ /pgfplots/date coordinates default inverse={x}{\year-\month-\day},
+ /pgfplots/date coordinates default inverse={y}{\year-\month-\day},
+ /pgfplots/date coordinates default inverse={z}{\year-\month-\day},
+}
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.decorations.softclip.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.decorations.softclip.code.tex
new file mode 100644
index 0000000000..06b3c62dfe
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.decorations.softclip.code.tex
@@ -0,0 +1,36 @@
+%--------------------------------------------
+%
+% 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 2013 by Christian Feuersaenger
+%
+% 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 library adds support for a "soft clip" decoration. It applies
+% clipping to an input path, but rather than simply instructing the
+% display driver to clip the path, it computes a new clip path from
+% the input.
+%
+% This library is (currently) on top of tikz.
+
+\usetikzlibrary{decorations.softclip}
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.external.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.external.code.tex
new file mode 100644
index 0000000000..dabbda099e
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.external.code.tex
@@ -0,0 +1,131 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for image externalization
+%
+% 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.
+%
+%
+
+% \pgfplots@glob@TMPa = 1 iff we can rely on the external lib shipped
+% with tikz:
+% -> see also below for a list of patches!
+\pgfplotsiffileexists{tikzlibraryexternal.code.tex}{%
+ \pgfplots@ifneedspgfcompabitibilitycode@has@pgf@one@zero@zero{%
+ \def\pgfplots@glob@TMPa{0}%
+ }{%
+ \def\pgfplots@glob@TMPa{1}%
+ }%
+}{%
+ \def\pgfplots@glob@TMPa{0}%
+}%
+
+\def\pgfplots@backw@compat@external@load{%
+ \immediate\write16{Package pgfplots external lib: loading complementary code for your PGF version...}
+ % Backwards compatibility:
+ \let\pgfplots@backw@compat@AtBeginDocument=\AtBeginDocument
+ \def\AtBeginDocument##1{}%
+ \input pgfplotsoldpgfsupp_pgfcoreexternal.code.tex
+ \input pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex
+ \let\AtBeginDocument=\pgfplots@backw@compat@AtBeginDocument
+}%
+
+
+\if1\pgfplots@glob@TMPa
+ \usetikzlibrary{external}%
+ %
+ % check for patches
+ \gdef\pgfplots@glob@TMPa{0}%
+ \pgfutil@ifundefined{c@tikzexternal@version}{%
+ \gdef\pgfplots@glob@TMPa{1}%
+ }{%
+ \gdef\pgfplots@glob@TMPa{0}%
+ }%
+ %
+ \if1\pgfplots@glob@TMPa
+ \pgfplots@backw@compat@external@load
+ \fi
+\else
+ \pgfplots@backw@compat@external@load
+\fi
+
+% This here is a section for patches.
+%
+% A patch contains software pieces which add individual functionality.
+%
+% The content is copyright Christian Feuersaenger. I added it to both
+% PGF and TikZ such that it can be distributed easily
+\expandafter\ifx\csname pgfsys@prepare@papersize\endcsname\relax
+ \immediate\write16{Package pgfplots external lib: patching system driver code for your PGF version...}
+ % Patch drivers.... this is needed since recent revisions.
+ \def\pgfsys@prepare@papersize#1#2{\pgfsys@papersize{#1}{#2}}
+ \begingroup
+ \expandafter\def\csname pgfplots@backw@ext@pgfsys-dvips.def\endcsname{%
+ \gdef\pgfsys@prepare@papersize##1##2{%
+ \expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument\special{papersize=##1,##2}}%
+ }
+ }%
+ \expandafter\def\csname pgfplots@backw@ext@pgfsys-dvipdfmx.def\endcsname{%
+ \gdef\pgfsys@prepare@papersize##1##2{%
+ \expandafter\gdef\expandafter\pgfsys@atbegindocument%
+ \expandafter{\pgfsys@atbegindocument
+ \special{papersize=##1,##2}%
+ }
+ }
+ }%
+ \expandafter\def\csname pgfplots@backw@ext@pgfsys-dvipdfm.def\endcsname{%
+ \gdef\pgfsys@prepare@papersize##1##2{%
+ \expandafter\gdef\expandafter\pgfsys@atbegindocument%
+ \expandafter{\pgfsys@atbegindocument
+ \special{papersize=##1,##2}%
+ }
+ }
+ }%
+ \csname pgfplots@backw@ext@\pgfsysdriver\endcsname
+ \endgroup
+\fi
+
+
+
+\def\tikzexternal@externalizefig@systemcall@call@old#1{%
+ \iftikzexternal@verboseio
+ \immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}%
+ \fi
+ \immediate\write18{#1}%
+}%
+
+\def\tikzexternal@externalizefig@systemcall@call@new#1{%
+ \iftikzexternal@verboseio
+ \immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}%
+ \fi
+ \pgfutil@shellescape{#1}%
+}%
+\ifx\tikzexternal@externalizefig@systemcall@call\tikzexternal@externalizefig@systemcall@call@old
+ \let\tikzexternal@externalizefig@systemcall@call=\tikzexternal@externalizefig@systemcall@call@new
+\fi
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.fillbetween.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.fillbetween.code.tex
new file mode 100644
index 0000000000..e548032e2d
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.fillbetween.code.tex
@@ -0,0 +1,240 @@
+%--------------------------------------------
+%
+% 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 2013 by Christian Feuersaenger
+%
+% 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 library adds support for high-level instructions for "fill area
+% between two arbitrary plots of functions".
+%
+% It activates the syntax
+%
+% \addplot fill between[of=A and B];
+%
+% where A and B are two plots named by 'name path='.
+%
+% In fact, this here is not much more than a low-level invocation of
+% \pgfpathfillbetween
+% and a couple of styles. It could become a TikZ library because it
+% actually works on any two named paths, but it has its restrictions
+% regarding the supported input paths: both need to be plots of
+% functions (non-intersecting, should have at most one function value
+% for each canvas X coord)
+
+\pgfutil@IfUndefined{pgfplotsset}{%
+ \pgferror{Please load pgfplots before pgfplots.fillbetween.}%
+ \endinput
+}{}%
+
+\usetikzlibrary{fillbetween}
+\usepgfplotslibrary{decorations.softclip}
+
+% Takes a domain #1:#2 and returns a new domain \pgfplotsretval:\pgfplotsretvalb which is larger.
+\def\pgfplots@softclip@enlarge#1#2{%
+ \begingroup
+ \pgfplotscoordmath{default}{parse}{0.1*(#2-#1)}\let\pgfplots@diff=\pgfmathresult
+ \pgfplotscoordmath{default}{if is}{\pgfplots@diff}{+}{%
+ % ok, max > min. Should always be the case.
+ \pgfplotscoordmath{default}{parse}{#1-\pgfplots@diff}\let\pgfplots@min=\pgfmathresult
+ \pgfplotscoordmath{default}{parse}{#2+\pgfplots@diff}\let\pgfplots@max=\pgfmathresult
+ }{%
+ \pgfplotscoordmath{default}{if is}{\pgfplots@diff}{0}{%
+ % ok, max == min. Very Strange.
+ \pgfplotscoordmath{default}{parse}{#1-1}\let\pgfplots@min=\pgfmathresult
+ \pgfplotscoordmath{default}{parse}{#2+1}\let\pgfplots@max=\pgfmathresult
+ }{%
+ % ok, max < min. Strange.
+ \pgfplotscoordmath{default}{parse}{#1+\pgfplots@diff}\let\pgfplots@min=\pgfmathresult
+ \pgfplotscoordmath{default}{parse}{#2-\pgfplots@diff}\let\pgfplots@max=\pgfmathresult
+ }%
+ }%
+ \global\let\pgfplots@glob@TMPa=\pgfplots@min
+ \global\let\pgfplots@glob@TMPb=\pgfplots@max
+ \endgroup
+ \let\pgfplotsretval=\pgfplots@glob@TMPa
+ \let\pgfplotsretvalb=\pgfplots@glob@TMPb
+}%
+
+\pgfkeys{
+ /pgfplots/every fill between plot/.style={/pgfplots/area legend,/tikz/fill,/pgfplots/on layer=pre main},
+ /tikz/soft clip assign/domain/.code args={#1:#2}{%
+ \pgfplotsifisvisualizationphase{%
+ \ifpgfplots@yislinear
+ \pgfplots@softclip@enlarge
+ {min(\pgfkeysvalueof{/pgfplots/ymin},\pgfplots@data@ymin)}%
+ {max(\pgfkeysvalueof{/pgfplots/ymax},\pgfplots@data@ymax)}%
+ \else
+ \pgfplots@softclip@enlarge{\pgfkeysvalueof{/pgfplots/ymin}}{\pgfkeysvalueof{/pgfplots/ymax}}%
+ \fi
+ \edef\pgfplots@loc@TMPa{%
+ (axis cs:#1,\pgfplotsretval)
+ rectangle (axis cs:#2,\pgfplotsretvalb)}%
+ \pgfkeysalso{/tikz/soft clip assign/path/.expand once=\pgfplots@loc@TMPa}%
+ }{}%
+ },%
+ /tikz/soft clip assign/y domain y/.style={/tikz/soft clip assign/domain y={#1}},
+ /tikz/soft clip assign/domain y/.code args={#1:#2}{%
+ \pgfplotsifisvisualizationphase{%
+ \ifpgfplots@yislinear
+ \pgfplots@softclip@enlarge
+ {min(\pgfkeysvalueof{/pgfplots/xmin},\pgfplots@data@xmin)}%
+ {max(\pgfkeysvalueof{/pgfplots/xmax},\pgfplots@data@xmax)}%
+ \else
+ \pgfplots@softclip@enlarge{\pgfkeysvalueof{/pgfplots/xmin}}{\pgfkeysvalueof{/pgfplots/xmax}}%
+ \fi
+ \edef\pgfplots@loc@TMPa{%
+ (axis cs:\pgfplotsretval,#1)
+ rectangle (axis cs:\pgfplotsretvalb,#2)}%
+ \pgfkeysalso{/tikz/soft clip assign/path/.expand once=\pgfplots@loc@TMPa}%
+ }{}%
+ },%
+ %
+ /pgfplots/execute at begin axis@@/.add={}{%
+ \gdef\b@pgfplotsfillbetween@list@has@set@layers{0}%
+ },
+}
+
+% The options are from
+% \addplot[#1] fill between[#2] #3;
+%
+% This method is invoked from the global \addplot dispatching.
+\def\pgfplotslibraryfillbetween@addplot#1#2#3{%
+ %
+ \pgfplots@start@plot@with@behavioroptions{/pgfplots/every fill between plot,#1}%
+ %
+ % '/tikz/fill between/on layer' is not really integrated into the option processing of pgfplots.
+ % improve it here (to some extend):
+ \pgfkeysgetvalue{/pgfplots/on layer}\pgfplots@loc@TMPa
+ \pgfkeyslet{/tikz/fill between/on layer}{\pgfplots@loc@TMPa}%
+ %
+ % FIXME: is this here an accident!?
+ \pgfkeysvalueof{/pgfplots/execute at end survey}%
+ \pgfplots@remember@survey@option@list
+ %
+ %
+ \pgfplotslibraryfillbetweenpreparecurrentlayer
+ %
+ \pgfplots@addplot@enqueue@coords{%
+ % precmd
+ }{%
+ % empty - this here is a TikZ instruction, not a "real" \addplot command
+ }{%
+ \def\b@pgfplots@fillbetween@clip@on@layer{0}%
+ \pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots@loc@TMPa
+ \edef\pgfplots@fillbetween@layer{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@fillbetween@layer\pgfutil@empty
+ \else
+ \ifpgfplots@clip
+ \def\b@pgfplots@fillbetween@clip@on@layer{1}%
+ % This here is messy: we have to clip on the other
+ % layer. I gave up to install this clip path once
+ % per axis, that's why I do it for each individual
+ % fillbetween - let us hope this is not too
+ % inefficient.
+ %
+ % I had to give up because the result appears to
+ % require a pattern of sorts
+ % \onlayer{L}
+ % \scope
+ % \clip ... ;
+ % \endonlayer
+ % ...
+ %
+ % \onlayer{L}
+ % \endscope
+ % \endonlayer
+ %
+ % which is forbidden in TeX -- and using
+ % \pgfsys@beginscope resulted in invalid PDF.
+ %
+ \pgfplotsonlayer{\pgfplots@loc@TMPa}%
+ \scope
+ \pgfplotspathaxisoutline
+ \pgfusepath{clip}%
+ \fi
+ \fi
+ %
+ % the path instruction:
+ \tikzfillbetween[#2]{%
+ /pgfplots/.search also=/tikz,%
+ /pgfplots/.cd,%
+ /tikz/fill between/every last segment/.append style={/tikz/fill between/path after segment={#3}},%
+ #1%
+ }%
+ %
+ \if1\b@pgfplots@fillbetween@clip@on@layer
+ \endscope
+ \endpgfplotsonlayer%
+ \fi
+ }{%
+ % post command.
+ }%
+}
+
+% ONLY TO BE USED AS LATER OPTION!
+\pgfkeysdef{/pgfplots/fill between/@ensure layers}{%
+ \ifpgfplots@layered@graphics
+ \else
+ \pgfplots@log3{fill between: activating layered graphics}%
+ \pgfplotsset{set layers}%
+ \pgfplots@set@options@of@layered@graphics
+ \fi
+}%
+
+% SIDE-EFFECT: modifies \b@pgfplotsfillbetween@list@has@set@layers and
+\def\pgfplotslibraryfillbetweenpreparecurrentlayer{%
+ \pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \if0\b@pgfplotsfillbetween@list@has@set@layers
+ %
+ \pgfplotssetlateoptions{fill between/@ensure layers}%
+ \gdef\b@pgfplotsfillbetween@list@has@set@layers{1}%
+ \fi
+ \fi
+}
+
+\def\pgfplots@tikzfillbetween{\pgfutil@ifnextchar[{\pgfplots@tikzfillbetween@opt}{\pgfplots@tikzfillbetween@opt[]}}
+\def\pgfplots@tikzfillbetween@opt[#1]#2{%
+ \pgfplots@addplot@enqueue@coords{%
+ % precmd
+ }{%
+ % empty - this here is a TikZ instruction, not a "real" \addplot command
+ }{%
+ % the path instruction:
+ \tikzfillbetween[#1]{#2}%
+ }{%
+ % post command.
+ }%
+}%
+
+\expandafter\def\expandafter\pgfplots@replace@path@commands\expandafter{\pgfplots@replace@path@commands
+ \let\pgfplots@orig@tikzfillbetween=\tikzfillbetween
+ \let\tikzfillbetween=\pgfplots@tikzfillbetween
+}%
+\expandafter\def\expandafter\pgfplots@restore@path@commands\expandafter{\pgfplots@restore@path@commands
+ \let\tikzfillbetween=\pgfplots@orig@tikzfillbetween
+}
+
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.groupplots.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.groupplots.code.tex
new file mode 100644
index 0000000000..a1a11127c2
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.groupplots.code.tex
@@ -0,0 +1,530 @@
+%--------------------------------------------
+%
+% 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@xlabels{}
+\def\pgfplots@group@ylabels{}
+\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{top},
+ /pgfplots/group/xticklabels at/edge bottom/.code=\def\pgfplots@group@xticklabels{lower},
+ /pgfplots/group/xticklabels at/edge left/.code=\def\pgfplots@group@xticklabels{left}, % TODO
+ /pgfplots/group/xticklabels at/edge right/.code=\def\pgfplots@group@xticklabels{right}, % TODO
+ /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{left},
+ /pgfplots/group/yticklabels at/edge right/.code=\def\pgfplots@group@yticklabels{right},
+ /pgfplots/group/yticklabels at/edge top/.code=\def\pgfplots@group@yticklabels{top}, % TODO
+ /pgfplots/group/yticklabels at/edge bottom/.code=\def\pgfplots@group@yticklabels{bottom}, % TODO
+ /pgfplots/group/yticklabels at=all,
+ /pgfplots/group/xlabels at/.is choice,
+ /pgfplots/group/xlabels at/all/.code=\def\pgfplots@group@xlabels{all},
+ /pgfplots/group/xlabels at/edge top/.code=\def\pgfplots@group@xlabels{top},
+ /pgfplots/group/xlabels at/edge bottom/.code=\def\pgfplots@group@xlabels{lower},
+ /pgfplots/group/xlabels at/edge right/.code=\def\pgfplots@group@xlabels{right}, % TODO
+ /pgfplots/group/xlabels at/edge left/.code=\def\pgfplots@group@xlabels{left},% TODO
+ /pgfplots/group/xlabels at=all,
+ /pgfplots/group/ylabels at/.is choice,
+ /pgfplots/group/ylabels at/all/.code=\def\pgfplots@group@ylabels{all},
+ /pgfplots/group/ylabels at/edge left/.code=\def\pgfplots@group@ylabels{left},
+ /pgfplots/group/ylabels at/edge right/.code=\def\pgfplots@group@ylabels{right},
+ /pgfplots/group/ylabels at/edge top/.code=\def\pgfplots@group@ylabels{top}, % TODO
+ /pgfplots/group/ylabels at/edge bottom/.code=\def\pgfplots@group@ylabels{bottom}, % TODO
+ /pgfplots/group/ylabels at=all,
+ /pgfplots/group/x descriptions at/.is choice,
+ /pgfplots/group/x descriptions at/all/.style={
+ /pgfplots/group/xlabels at=all,
+ /pgfplots/group/xticklabels at=all
+ },
+ /pgfplots/group/x descriptions at/edge bottom/.style={
+ /pgfplots/group/xlabels at=edge bottom,
+ /pgfplots/group/xticklabels at=edge bottom
+ },
+ /pgfplots/group/x descriptions at/edge top/.style={
+ /pgfplots/group/xlabels at=edge top,
+ /pgfplots/group/xticklabels at=edge top
+ },
+ /pgfplots/group/y descriptions at/.is choice,
+ /pgfplots/group/y descriptions at/all/.style={
+ /pgfplots/group/ylabels at=all,
+ /pgfplots/group/yticklabels at=all
+ },
+ /pgfplots/group/y descriptions at/edge left/.style={
+ /pgfplots/group/ylabels at=edge left,
+ /pgfplots/group/yticklabels at=edge left
+ },
+ /pgfplots/group/y descriptions at/edge right/.style={
+ /pgfplots/group/ylabels at=edge right,
+ /pgfplots/group/yticklabels at=edge right
+ },
+ /pgfplots/group/group name/.store in=\pgfplots@group@name,
+ /pgfplots/group/empty plot/.style={/pgfplots/hide axis=true},
+ /pgfplots/trim axis group left/.code={%
+ \pgfutil@ifundefined{pgfsettrimleft}{%
+ \pgfplots@error{Sorry, the 'trim axis group left' requires a more recent PGF version.}%
+ }{%
+ \pgfkeysalso{/tikz/trim left={(group c1r1.south west)}}%
+ }%
+ },%
+ /tikz/trim axis group left/.style={/pgfplots/trim axis group left},
+ /pgfplots/trim axis group right/.code={%
+ \pgfutil@ifundefined{pgfsettrimleft}{%
+ \pgfplots@error{Sorry, the 'trim axis group right' requires a more recent PGF version.}%
+ }{%
+ \pgfkeysalso{/pgfplots/trim axis right}%
+ }%
+ },%
+ /tikz/trim axis group right/.style={/pgfplots/trim axis group right},
+}
+\pgfkeys{
+ /pgfplots/warning/groupplots/too many plots/.code 2 args={%
+ \pgfplotsthrow@warning{You are adding more plots than you specified, current plots=#1\space vs. total allowed
+ plots=#2.}%
+ },
+}
+
+\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
+ \pgfplotswarning{groupplots/too many plots}{\the\pgfplots@group@current@plot}{\pgfplots@group@totalplots}\pgfeov
+ \else
+ %
+ % If there has been other plots before then end the plot
+ %
+ \ifnum0<\pgfplots@group@current@plot\relax
+ % DEBUG: \message{DEBUG: Ending plot}
+ \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%
+}
+
+%
+% Determine the labels of both x and y.
+%
+\def\pgfplots@group@determine@labels{%
+ \def\pgfplots@loc@TMPa{all}%
+ \def\pgfplots@loc@TMPb{lower}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@group@xlabels%
+ % xlabels at=all
+ % Do nothing as all should have xlabels
+ \fi
+ \gdef\pgfplots@glob@TMPa{}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels%
+ % xlabels at=lower
+ \ifnum1<\pgfplots@group@rows\relax
+ \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {%
+ \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {%
+ \ifnum\pgfplots@row=\pgfplots@group@rows\relax%
+ \else
+ \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{%
+ \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={%
+ /pgfplots/xlabel={},%
+ \ifpgfplots@units@use/pgfplots/x unit={}\fi
+ }%
+ }%
+ \fi
+ }%
+ }%
+ \fi%
+ \else
+ \def\pgfplots@loc@TMPb{top}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels%
+ % xlabels at=top
+ \ifnum1<\pgfplots@group@rows\relax
+ \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {%
+ \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {%
+ \ifnum\pgfplots@row=1 %
+ \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{%
+ \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xticklabel pos=upper}}%
+ \else
+ \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{%
+ \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={%
+ /pgfplots/xlabel={},%
+ \ifpgfplots@units@use/pgfplots/x unit={}\fi%
+ }%
+ }%
+ \fi
+ }%
+ }%
+ \fi%
+ \fi
+ \fi
+ %
+ % Defining styles for the y's
+ %
+ \ifx\pgfplots@loc@TMPa\pgfplots@group@ylabels%
+ % ylabels at=all
+ % Do nothing as all should have ylabels
+ \else
+ \def\pgfplots@loc@TMPb{left}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@group@ylabels%
+ % ylabels at=left
+ \ifnum1<\pgfplots@group@columns\relax
+ \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {%
+ \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/ylabel={},%
+ \ifpgfplots@units@use/pgfplots/y unit={}\fi%
+ }%
+ }%
+ }%
+ }%
+ \fi%
+ \else
+ \def\pgfplots@loc@TMPb{right}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@group@ylabels%
+ % ylabels at=right
+ \ifnum1<\pgfplots@group@columns\relax
+ \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {%
+ \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {%
+ \ifnum\pgfplots@column=\pgfplots@group@columns\relax
+ \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{%
+ \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/yticklabel pos=upper}}%
+ \else
+ \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{%
+ \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={%
+ /pgfplots/ylabel={},%
+ \ifpgfplots@units@use/pgfplots/y unit={}\fi%
+ }%
+ }%
+ \fi
+ }%
+ }%
+ \fi
+ \fi%
+ \fi
+ \fi
+ \expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa}%
+}
+
+%
+% Determine the ticklabels of both x and y.
+%
+\def\pgfplots@group@determine@ticklabels{%
+ \def\pgfplots@loc@TMPa{all}%
+ \def\pgfplots@loc@TMPb{top}%
+ \def\pgfplots@loc@TMPc{lower}%
+ \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={},/pgfplots/xtick scale label code/.code={}}}%
+ }%
+ \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={},/pgfplots/xtick scale label code/.code={}}}%
+ }%
+ \fi%
+ }%
+ \fi%
+ %
+ % Defining styles for the ytick's
+ %
+ \def\pgfplots@loc@TMPa{all}%
+ \def\pgfplots@loc@TMPb{left}%
+ \def\pgfplots@loc@TMPc{right}%
+ \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={}, /pgfplots/ytick scale label code/.code={}}}%
+ }%
+ \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={}, /pgfplots/ytick scale label code/.code={}}}%
+ }%
+ \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
+ %
+ % transport some items beyond this \endgroup:
+ \pgf@remember@layerlist@globally
+ \aftergroup\pgf@restore@layerlist@from@global
+ \endgroup
+ %
+ % ... and transport them beyond the next \endgroup as well (LaTeX
+ % introduces one for \end{groupplot}):
+ \aftergroup\pgf@restore@layerlist@from@global
+ \aftergroup\pgfplots@cell@picture@remembered
+}
+
+\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
+ %
+ \let\pgfplots@set@options@sanitizemode@old=\pgfplots@set@options@sanitizemode
+ \let\pgfplots@set@options@sanitize@old=\pgfplots@set@options@sanitize
+ \let\pgfplots@set@options@sanitize=\relax
+ \let\pgfplots@set@options@sanitizemode=\relax
+ \expandafter\pgfplots@set@options\expandafter{\pgfplots@group@rmopts}%
+ \let\pgfplots@set@options@sanitize=\pgfplots@set@options@sanitize@old
+ \let\pgfplots@set@options@sanitizemode=\pgfplots@set@options@sanitizemode@old
+ %
+ \pgfplots@group@individual@setup
+ \pgfplots@group@determine@ticklabels
+ \pgfplots@group@determine@labels
+ \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/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.patchplots.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.patchplots.code.tex
new file mode 100644
index 0000000000..fb9283571c
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.patchplots.code.tex
@@ -0,0 +1,2723 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for higher order patch plots.
+% It contains advanced patch plots like quadratic triangles,
+% biquadratic quadrilaterals, coons patches and others.
+% The basic implementation for patches supports already line, triangle
+% and rectangle (=2 triangles) patches.
+%
+% 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/>.
+%
+%--------------------------------------------
+
+ % NOTES:
+ % In general, a Bezier spline C:[0,1] -> \R of order n fulfills
+ % C'(0) = n ( P_1 - P_0 ),
+ % C'(1) = n ( P_n - P_{n-1} ).
+ % For n=3 and given P_0 and P_3, I can directly compute P_1 and P_2 once I know
+ % the derivatives at t=0 and t=1.
+ %
+ %
+ %
+%--------------------------------------------------
+% 4-point Lagrange interpolation on {0,1/3,2/3,1}:
+% C(x) =
+% a * (1/3 - x)/(1/3) * (2/3-x)/(2/3) * (1-x) +
+% b * (0 - x)/(0 - 1/3) * (2/3-x)/(2/3-1/3) * (1-x)/(1-1/3) +
+% c * (0 - x)/(0 - 2/3) * (1/3-x)/(1/3-2/3) * (1-x)/(1-2/3) +
+% d * (0 - x)/(0 - 1) * (1/3-x)/(1/3-1) * (2/3-x) /(2/3-1)
+%
+%
+% Derivative:
+%
+% (-9*c + 2*d + 72*c*x - 18*d*x - 81*c*x^2 + 27*d*x^2 +
+% a*(-11 + 36*x - 27*x^2) + 9*b*(2 - 10*x + 9*x^2))/2
+%
+% bezier control points are
+% P1 = (-5*a)/6 + 3*b - (3*c)/2 + d/3
+% = -0.833333 a + 3. b - 1.5 c + 0.333333 d
+%
+% P2 = 0.333333 (0.5 (2. a - 9. b + 18. c - 11. d) + 3. d)
+% = 0.333333 a - 1.5 b + 3. c - 0.833333 d
+%--------------------------------------------------
+
+
+
+% A quadratic spline in the ordering
+%
+% <left> <right> <middle>
+%
+% where <left> is the function value at the left end of the spline
+% segmment, <right> the function value at the right end, and <middle>
+% the function value in the middle of the spline segment.
+\pgfplotsdeclarepatchclass{quadratic spline}{%
+ get dimension=\def\pgfplotsretval{1},
+ supports global path=\def\pgfplotsretval{1},
+ new=\def\pgfplotspatchclass@qspline@no{A},
+ set next vertex={%
+ % EXPECTED ORDERING: first 2 corners, then 1 mid nodes
+ % (interpolatory).
+ % defines \pgfplotspatchclass@qspline@A ... \pgfplotspatchclass@qspline@C (3 points)
+ \expandafter\edef\csname pgfplotspatchclass@qspline@\pgfplotspatchclass@qspline@no\endcsname{#1}%
+ \if C\pgfplotspatchclass@qspline@no
+ \def\pgfplotspatchclass@qspline@no{A}%
+ \pgfplotspatchready
+ \else
+ \expandafter\let\expandafter\pgfplotspatchclass@qspline@no\csname pgfpptchindexnext@\pgfplotspatchclass@qspline@no\endcsname
+ \fi
+ },
+ if current point can be first last={%
+ \pgfplots@loc@tmptrue
+ \if A\pgfplotspatchclass@qspline@no
+ % Ah - the current point is the 'C' point, i.e. the
+ % control point (we have advanced the '@no' counter)
+ \pgfplots@loc@tmpfalse
+ \fi
+ \ifpgfplots@loc@tmp
+ #1\relax%
+ \else
+ #2\relax
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{0.5}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \pgfplotspatchready
+ },%
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@A\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qspline@C\endvertex #1%
+ },
+ fill path={%
+ \begingroup
+ % Draw the patch boundary using a bezier curves.
+ %
+ % Since I have lagrange points to describe the patch (i.e.
+ % points the patch passes through), I have to convert the
+ % lagrange representation to bezier.
+ %
+ % Furthermore, I convert to *cubic* bezier since pdf only
+ % supports cubic curves.
+ %
+ % See the docs for 'biquadratic::fill path' for more details,
+ % in does the same.
+ \def\pgfplots@edge{%
+ \ifx\pgfplotspatchclass@qspline@A\PA
+ \pgfplotsplothandlermesh@pathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}%
+ \fi
+ \pgfpathcurveto {%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}%
+ }{%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}%
+ }{%
+ \expandafter\pgfplotspointpatchvertex\PC\endvertex
+ }%
+ }%
+ \let\PA=\pgfplotspatchclass@qspline@A
+ \let\PB=\pgfplotspatchclass@qspline@C
+ \let\PC=\pgfplotspatchclass@qspline@B
+ \pgfplots@edge
+ \pgfplotsplothandlermesh@setlastpoint{\expandafter\pgfplotspointpatchvertex\PC\endvertex}%
+ \endgroup
+ },
+ triangulate class=\def\pgfplotsretval{line},
+ triangulate={%
+ \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass
+ \def\pgfplotsplothandlermesh@patchclass{line}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@B}%
+ \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@
+ },%
+ recursive refine@={%
+ \pgfplotspatchclass{\pgfplotspatchclassname}{new}%
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@A\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@B\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@C\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qspline@AC
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@AC}%
+ #1%
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@A\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@B\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qspline@C\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qspline@CB
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qspline@CB}%
+ #1%
+ %
+ },%
+ get pdf shading type=0,
+ get num vertices=\def\pgfplotsretval{3},
+}%
+
+\pgfplotsdeclarepatchclass{cubic spline}{%
+ get dimension=\def\pgfplotsretval{1},
+ supports global path=\def\pgfplotsretval{1},
+ new=\def\pgfplotspatchclass@cspline@no{A},
+ set next vertex={%
+ % EXPECTED ORDERING: first 2 corners, then 1 mid nodes
+ % (interpolatory).
+ % defines \pgfplotspatchclass@cspline@A ... \pgfplotspatchclass@cspline@D (4 points)
+ \expandafter\edef\csname pgfplotspatchclass@cspline@\pgfplotspatchclass@cspline@no\endcsname{#1}%
+ \if D\pgfplotspatchclass@cspline@no
+ \def\pgfplotspatchclass@cspline@no{A}%
+ \pgfplotspatchready
+ \else
+ \expandafter\let\expandafter\pgfplotspatchclass@cspline@no\csname pgfpptchindexnext@\pgfplotspatchclass@cspline@no\endcsname
+ \fi
+ },
+ if current point can be first last={%
+ \pgfplots@loc@tmpfalse
+ \if B\pgfplotspatchclass@cspline@no
+ % Ah - the current point is the 'A' point (we have
+ % advanced the '@no' counter)
+ \pgfplots@loc@tmptrue
+ \fi
+ \if C\pgfplotspatchclass@cspline@no
+ % Ah - the current point is the 'B' point (we have
+ % advanced the '@no' counter)
+ \pgfplots@loc@tmptrue
+ \fi
+ \ifpgfplots@loc@tmp
+ #1\relax%
+ \else
+ #2\relax
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{0.3333333}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{0.6666666}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \pgfplotspatchready
+ },%
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@A\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@C\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@cspline@D\endvertex #1%
+ },
+ fill path={%
+ % Draw the patch boundary using a bezier curve.
+ \pgfplotsplothandlermesh@pathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@cspline@A\endvertex}%
+ \pgfplotspathcubicfrominterpolation
+ {\pgfplotspatchclass@cspline@A}%
+ {\pgfplotspatchclass@cspline@C}%
+ {\pgfplotspatchclass@cspline@D}%
+ {\pgfplotspatchclass@cspline@B}%
+ \pgfplotsplothandlermesh@setlastpoint{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@cspline@B\endvertex}%
+ },
+ triangulate class=\def\pgfplotsretval{line},
+ triangulate={%
+ \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass
+ \def\pgfplotsplothandlermesh@patchclass{line}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@B}%
+ \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@
+ },%
+ recursive refine@={%
+ % The 4-point lagrangian interpolation formular is shown on
+ % the top of this page. What I do here is simply to evaluate
+ % C(i*1/9) for i =0,...,9:
+ % 0
+ % 0.493827 A +0.740741 C -0.296296 D +0.0617284 B
+ % 0.17284 A +1.03704 C -0.259259 D +0.0493827 B
+ % 1/3
+ % -0.0617284 A +0.740741 C +0.37037 D -0.0493827 B
+ % -0.0493827 A +0.37037 C +0.740741 D -0.0617284 B
+ % 2/3
+ % 0.0493827 A -0.259259 C +1.03704 D +0.17284 B
+ % 0.0617284 A -0.296296 C +0.740741 D +0.493827 B
+ % 1
+ \pgfplotspatchclass{\pgfplotspatchclassname}{new}%
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.493827}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.0617284}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.740741}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{-0.296296}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.17284}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.0493827}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{1.03704}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{-0.259259}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}%
+ #1%
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{-0.0617284}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{-0.0493827}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.740741}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.37037}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{-0.0493827}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{-0.0617284}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{0.37037}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.740741}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}%
+ #1%
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.0493827}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.17284}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{-0.259259}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{+1.03704}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AA
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@A\times{0.0617284}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@B\times{0.493827}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@C\times{-0.296296}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@cspline@D\times{0.740741}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@cspline@AB
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AA}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@cspline@AB}%
+ #1%
+ },
+ get pdf shading type=0,
+ get num vertices=\def\pgfplotsretval{4},
+}%
+
+\def\pgfplotspathcubicfrominterpolation#1#2#3#4{%
+ % switch basis from lagrange to bezier (see formular on top of
+ % this file)
+ \pgfpathcurveto {%
+ \begingroup
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexaddXY#1\times{-0.833333}%
+ \expandafter\pgfplotspatchvertexaddXY#2\times{3}%
+ \expandafter\pgfplotspatchvertexaddXY#3\times{-1.5}%
+ \expandafter\pgfplotspatchvertexaddXY#4\times{0.3333333}%
+ \pgfplotspatchvertexfinish\pgfplots@loc@TMPa
+ \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex
+ \endgroup
+ }{%
+ \begingroup
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexaddXY#1\times{0.333333}%
+ \expandafter\pgfplotspatchvertexaddXY#2\times{-1.5}%
+ \expandafter\pgfplotspatchvertexaddXY#3\times{3}%
+ \expandafter\pgfplotspatchvertexaddXY#4\times{-0.833333}%
+ \pgfplotspatchvertexfinish\pgfplots@loc@TMPa
+ \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex
+ \endgroup
+ }{%
+ \expandafter\pgfplotspointpatchvertex#4\endvertex
+ }%
+}%
+
+% make a linearized sequence around the edge of the quad.triangle.
+% note the ordering: first 3 corners, then 3 mid nodes:
+\def\pgfplots@qtri@next@A{D}%
+\def\pgfplots@qtri@next@B{E}%
+\def\pgfplots@qtri@next@C{F}%
+\def\pgfplots@qtri@next@D{B}%
+\def\pgfplots@qtri@next@E{C}%
+\def\pgfplots@qtri@next@F{A}%
+
+\def\pgfplots@qtri@rnext@A{F}%
+\def\pgfplots@qtri@rnext@B{D}%
+\def\pgfplots@qtri@rnext@C{E}%
+\def\pgfplots@qtri@rnext@D{A}%
+\def\pgfplots@qtri@rnext@E{B}%
+\def\pgfplots@qtri@rnext@F{C}%
+
+\def\pgfplotspatchclass@qtri@recursiverefine@newnames{%
+ \let\pgfplotspatchclass@qtri@A@=\pgfplotspatchclass@qtri@A%
+ \let\pgfplotspatchclass@qtri@B@=\pgfplotspatchclass@qtri@B%
+ \let\pgfplotspatchclass@qtri@C@=\pgfplotspatchclass@qtri@C%
+ \let\pgfplotspatchclass@qtri@D@=\pgfplotspatchclass@qtri@D%
+ \let\pgfplotspatchclass@qtri@E@=\pgfplotspatchclass@qtri@E%
+ \let\pgfplotspatchclass@qtri@F@=\pgfplotspatchclass@qtri@F%
+}%
+
+
+% A 3-point interpolatory patch which draws quadratic polynomial
+% splines (functions f(x), x 1d).
+\pgfplotsdeclarepatchclass{triangle quadr}{%
+ uses view depth=\def\pgfplotsretval{1},% used by the shader: we reorder corners.
+ new=\def\pgfplotspatchclass@qtri@no{A}\let\pgfplotspatchclass@qtrie@AB\relax,
+ set next vertex={%
+ % EXPECTED ORDERING: first 3 corners, then 3 mid nodes.
+ % defines \pgfplotspatchclass@qtri@A ... \pgfplotspatchclass@qtri@F (6 points)
+ \expandafter\edef\csname pgfplotspatchclass@qtri@\pgfplotspatchclass@qtri@no\endcsname{#1}%
+ \if F\pgfplotspatchclass@qtri@no
+ \def\pgfplotspatchclass@qtri@no{A}%
+ \pgfplotspatchready
+ \else
+ \expandafter\let\expandafter\pgfplotspatchclass@qtri@no\csname pgfpptchindexnext@\pgfplotspatchclass@qtri@no\endcsname
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ %
+ \def\pgfplotspatchclassx{0.5}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{0.5}%
+ \def\pgfplotspatchclassy{0.5}%
+ #1%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0.5}%
+ #1%
+ \pgfplotspatchready
+ %
+ %
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ %
+ \def\pgfplotspatchclassx{0.5}%
+ \def\pgfplotspatchclassy{0.5}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0.5}%
+ #1%
+ \def\pgfplotspatchclassx{0.5}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \pgfplotspatchready
+ },%
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@C\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@D\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@E\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@F\endvertex #1%
+ },
+ foreach cdata vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@C\endvertex #1%
+ },
+ fill path={%
+ \begingroup
+ % Draw the patch boundary using three bezier curves.
+ %
+ % Since I have lagrange points to describe the patch (i.e.
+ % points the patch passes through), I have to convert the
+ % lagrange representation to bezier.
+ %
+ % Furthermore, I convert to *cubic* bezier since pdf only
+ % supports cubic curves.
+ %
+ % See the docs for 'biquadratic::fill path' for more details,
+ % in does the same.
+ \def\pgfplots@edge{%
+ \ifx\pgfplotspatchclass@qtri@A\PA
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}%
+ \fi
+ \pgfpathcurveto {%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}%
+ }{%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}%
+ }{%
+ \expandafter\pgfplotspointpatchvertex\PC\endvertex
+ }%
+ }%
+ \let\PA=\pgfplotspatchclass@qtri@A
+ \let\PB=\pgfplotspatchclass@qtri@D
+ \let\PC=\pgfplotspatchclass@qtri@B
+ \pgfplots@edge
+ %
+ \let\PA=\pgfplotspatchclass@qtri@B
+ \let\PB=\pgfplotspatchclass@qtri@E
+ \let\PC=\pgfplotspatchclass@qtri@C
+ \pgfplots@edge
+ %
+ \let\PA=\pgfplotspatchclass@qtri@C
+ \let\PB=\pgfplotspatchclass@qtri@F
+ \let\PC=\pgfplotspatchclass@qtri@A
+ \pgfplots@edge
+ \endgroup
+ \pgfpathclose
+ },
+ %--------------------------------------------------
+ % stroke path={%
+ % \ifx\pgfplotspatchclass@qtrie@AB\relax
+ % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}%
+ % \pgfpathclose
+ % \else
+ % \if1\pgfplotspatchclass@qtrie@AB
+ % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}%
+ % \fi
+ % \if1\pgfplotspatchclass@qtrie@BC
+ % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@B\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}%
+ % \fi
+ % \if1\pgfplotspatchclass@qtrie@CA
+ % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@C\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@qtri@A\endvertex}%
+ % \fi
+ % \fi
+ % },
+ %--------------------------------------------------
+ stream to shader={%
+ % create a degenerate coons patch:
+ \begingroup
+%\message{EDGE INIT^^J}%
+ % this defines \Pcur and \Pnextseq :
+ \pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth
+ %
+ \pgfutil@namelet{Pstart}{pgfplotspatchclass@qtri@\Pcur}%
+ %
+ % see the docus for "fill path" about these 1.33333 and -0.33333 factors
+ \def\pgfplots@coonsedge{%
+%\message{EDGE \Pcur^^J}%
+ \expandafter\let\expandafter\PA\csname pgfplotspatchclass@qtri@\Pcur\endcsname
+ \edef\Pcur{\csname pgfplots@qtri@\Pnextseq next@\Pcur\endcsname}%
+%\message{---> \Pcur^^J}%
+ \expandafter\let\expandafter\PB\csname pgfplotspatchclass@qtri@\Pcur\endcsname
+ \edef\Pcur{\csname pgfplots@qtri@\Pnextseq next@\Pcur\endcsname}%
+%\message{---> \Pcur^^J}%
+ \expandafter\let\expandafter\PC\csname pgfplotspatchclass@qtri@\Pcur\endcsname
+ \ifx\PA\Pstart
+ \expandafter\pgfplotspatchvertex\PA\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ % degenerate: the "edge" \PA -- \PA collabses into one
+ % point.
+ % Per construction, the "edge" is the FOREGROUND.
+%\message{STREAMING COLLAPSED EDGE AT START POINT^^J}%
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \fi
+ \pgfplotslibrarysurfstreamcoord{%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}%
+ }{}%
+ \pgfplotslibrarysurfstreamcoord{%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}%
+ }{}%
+ \ifx\PC\Pstart
+ \else
+ \expandafter\pgfplotspatchvertex\PC\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \fi
+ }%
+ \pgfplots@coonsedge
+ %
+ \pgfplots@coonsedge
+ %
+ \pgfplots@coonsedge
+ %
+ %
+ \endgroup
+ },%
+ triangulate={%
+ \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass
+ \def\pgfplotsplothandlermesh@patchclass{triangle}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}11%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20%
+ % Ok. Now create 4 triangles. The ordering is not arbitrary
+ % (unless z buffer=sort is in effect). Let's assume that the
+ % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then
+ % this sequence here should have approximately the same depth
+ % ordering:
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}%
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}00%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}%
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}11%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F}%
+ \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@
+ },%
+ set edge visible={%
+ \ifcase#1
+ \edef\pgfplotspatchclass@qtrie@AB{#2}%
+ \or
+ \edef\pgfplotspatchclass@qtrie@BC{#2}%
+ \or
+ \edef\pgfplotspatchclass@qtrie@CA{#2}%
+ \fi
+ },
+ serialize except vertices={%
+ \ifx\pgfplotspatchclass@qtrie@AB\relax
+ \let\pgfplotsretval\pgfutil@empty%
+ \else
+ \edef\pgfplotsretval{%
+ \noexpand\def\noexpand\pgfplotspatchclass@qtrie@AB{\pgfplotspatchclass@qtrie@AB}%
+ \noexpand\def\noexpand\pgfplotspatchclass@qtrie@BC{\pgfplotspatchclass@qtrie@BC}%
+ \noexpand\def\noexpand\pgfplotspatchclass@qtrie@CA{\pgfplotspatchclass@qtrie@CA}%
+ }%
+ \fi
+ },%
+ deserialize except vertices=%
+ \let\pgfplotspatchclass@qtrie@AB\relax
+ #1,
+ recursive refine@={%
+ \pgfplotspatchclass@qtri@recursiverefine@newnames
+ %
+ \pgfplotspatchclass{\pgfplotspatchclassname}{new}%
+ %--------------------------------------------------
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01%
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11%
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20%
+ %--------------------------------------------------
+ % The ordering is not arbitrary
+ % (unless z buffer=sort is in effect). Let's assume that the
+ % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then
+ % this sequence here should have approximately the same depth
+ % ordering:
+ %
+ % I used the reference triangle and shape functions as listed in
+ % http://www.colorado.edu/engineering/CAS/courses.d/IFEM.d/
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@AD
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DF
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@AF
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@A@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@AF}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@AD}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DF}%
+ %
+ #1\pgfplotspatchclass@qtri@recursiverefine@newnames
+ %
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DF
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.25}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DE
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EF
+ %
+ %
+ %--------------------------------------------------
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}00%
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}10%
+ %--------------------------------------------------
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DF}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DE}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EF}%
+ % %
+ % %--------------------------------------------------
+ % % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01%
+ % % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11%
+ % %--------------------------------------------------
+ #1\pgfplotspatchclass@qtri@recursiverefine@newnames
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DB
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.25}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@DE
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@BE
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@D@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@B@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DB}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@BE}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@DE}%
+ %
+ #1\pgfplotspatchclass@qtri@recursiverefine@newnames
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EC
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@B\times{-.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@D\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@E\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@EF
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@A\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@C\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@qtri@F\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@qtri@CF
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@E@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@C@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@F@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EC}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@CF}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@qtri@EF}%
+ %
+ #1%
+ %
+ },%
+ get pdf shading type=6,
+ get num vertices=\def\pgfplotsretval{6},
+ get num cdata vertices=\def\pgfplotsretval{3},
+}%
+
+
+% see
+% \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth
+% and its documentation.
+%
+% POSTCONDITION:
+% \Pcur and \Pnextseq are defined.
+\def\pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth{%
+ \def\Pcur{A}%
+ \def\Pnextseq{}%
+ %
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@A\endvertex
+ \ifx\pgfplotspatchvertexdepth\pgfutil@empty
+ \else
+ % ah. We have view depth. Use it!
+ % The idea here is as follows.
+ % According to pdf standard, the COONS Shading is
+ % generated in the unit cube and then mapped to the
+ % shading. If u,v in [0,1] are the coordinates in the unit
+ % cube, pixel values for v=1 overwrite values for v=0.
+ % If pixel values have the same v, u=1 overwrites u=0.
+ % In other words, the loop is
+ % for v= 0 to Nv
+ % for u = 0 to Nu
+ % shade pixel for (u,v)
+ %
+ % BB-------CC <--v=1
+ % | |
+ % | |
+ % | |
+ % AA-------DD <--v=0
+ % | |
+ % u=0 u=1
+ %
+ %
+ % IDEA: re-order the sequence of vertices such that z
+ % buffering is obtained.
+ %
+ % APPROACH:
+ % the edge BB--CC collapses into just one point, namely
+ % the FOREGROUND point (i.e. it is drawn on top of
+ % everything else).
+ %
+ % The AA point is the second nearest foreground point.
+ % The sequence is chosen such that AA,BB is the first
+ % edge.
+ %
+ % What is to do (besides determining the vertices for AA
+ % and BB)? Well, make sure, that we can arrange them in
+ % the desired order. This involves a periodic "next vertex"
+ % algorithm which might either go forward
+ % or backward.
+ %
+ % sort according to depth.
+ % To do so, prepare macros \PA,\PB,\PC for use in
+ % \pgfplotsutilsortthree. FORMAT:
+ % \PA={<sortkey>pt <originalindex>}
+ \edef\PA{\pgfplotspatchvertexdepth pt A}%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@B\endvertex
+ \edef\PB{\pgfplotspatchvertexdepth pt B}%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@qtri@C\endvertex
+ \edef\PC{\pgfplotspatchvertexdepth pt C}%
+ \pgfplotsutilsortthree\PA\PB\PC
+ \def\toCHAR##1pt ##2{##2}% get original index
+ %
+ \edef\Pcur{\expandafter\toCHAR\PB}%%
+ \edef\Pnext{\csname pgfplots@qtri@next@\Pcur\endcsname}%
+ \edef\Pnext{\csname pgfplots@qtri@next@\Pnext\endcsname}%
+ \if\Pnext\PA
+ % ok, next(next(AA)) = BB.
+ % that means we have to advance forward.
+ \def\Pnextseq{}%
+ \else
+ % well, since we have a triangle, there only remains
+ % the backwards direction.
+ \def\Pnextseq{r}%
+ \fi
+%\message{FOREGROUND VERTEX = \PA.^^J}%
+%\message{SECOND NEAREST VERTEX = \PB.^^J}%
+ \fi
+}
+\def\pgfplotspatchclass@tri@to@coonspatch@findshadingsequence@for@depth@no@op{%
+ \def\Pcur{A}%
+ \def\Pnextseq{}%
+}
+
+% bilinear is the same as 'rectangle', but it uses a different shader.
+\pgfplotsdeclarepatchclass{bilinear}{%
+ allow matrix=\def\pgfplotsretval{1},
+ new=\def\pgfplotspatchclass@rect@no{0},
+ set next vertex={%
+ \ifcase\pgfplotspatchclass@rect@no\relax
+ \edef\pgfplotspatchclass@rect@A{#1}%
+ \def\pgfplotspatchclass@rect@no{1}%
+ \or
+ \edef\pgfplotspatchclass@rect@B{#1}%
+ \def\pgfplotspatchclass@rect@no{2}%
+ \or
+ \edef\pgfplotspatchclass@rect@C{#1}%
+ \def\pgfplotspatchclass@rect@no{3}%
+ \or
+ \edef\pgfplotspatchclass@rect@D{#1}%
+ \def\pgfplotspatchclass@rect@no{0}%
+ \pgfplotspatchready%
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \pgfplotspatchready
+ },%
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex,
+ first vertex before z buffer=\pgfplotspatchclass@rect@first@before@z@buffer,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@C\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex #1%
+ },
+ stream to shader={%
+ % create a coons patch:
+ \begingroup
+ \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth
+ {pgfplotspatchclass@rect@}{\Pcur}{\Pnextseq}%
+ %
+ \pgfutil@namelet{Pstart}{pgfplotspatchclass@rect@\Pcur}%
+ \def\pgfplots@coonsedge{%
+%\message{EDGE \Pcur^^J}%
+ \expandafter\let\expandafter\PA\csname pgfplotspatchclass@rect@\Pcur\endcsname
+ \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}%
+%\message{---> \Pcur^^J}%
+ \expandafter\let\expandafter\PB\csname pgfplotspatchclass@rect@\Pcur\endcsname
+ \ifx\PA\Pstart
+ \expandafter\pgfplotspatchvertex\PA\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \fi
+ %
+ % CONTROL POINT A+1/3(B-A)
+ \pgfplotslibrarysurfstreamcoord{%
+ \pgfpointadd
+ {\pgfqpointscale{0.6666666}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}%
+ {\pgfqpointscale{0.3333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ }{}%
+ % CONTROL POINT A+2/3(B-A)
+ \pgfplotslibrarysurfstreamcoord{%
+ \pgfpointadd
+ {\pgfqpointscale{0.3333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}%
+ {\pgfqpointscale{0.6666666}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ }{}%
+ \ifx\PB\Pstart
+ \else
+ \expandafter\pgfplotspatchvertex\PB\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \fi
+ }%
+ %
+ \pgfplots@coonsedge
+ %
+ \pgfplots@coonsedge
+ %
+ \pgfplots@coonsedge
+ %
+ \pgfplots@coonsedge
+ %
+ \endgroup
+ },%
+ fill path={%
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@A\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@B\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@C\endvertex}%
+ \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@rect@D\endvertex}%
+ \pgfpathclose
+ },
+ triangulate={%
+ \pgfplotscoordmath{meta}{parsenumber}{0.25}%
+ \let\pgfplots@loc@scale=\pgfmathresult
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\endvertex\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\endvertex\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\endvertex\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\endvertex\times{0.25}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@M
+ %
+ \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass
+ \def\pgfplotsplothandlermesh@patchclass{triangle}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20%
+ % Ok. Now create 4 triangles. The ordering is not arbitrary
+ % (unless z buffer=sort is in effect). Let's assume that the
+ % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then
+ % this sequence here should have approximately the same depth
+ % ordering:
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@M}%
+ \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@
+ },%
+ recursive refine@={%
+ \pgfplotspatchclass@rect@refine@{#1}%
+ },%
+ serialize except vertices=\let\pgfplotsretval\pgfutil@empty,%
+ deserialize except vertices=,
+ get pdf shading type=6,
+ get num vertices=\def\pgfplotsretval{4},
+}%
+
+\pgfplotsdeclarepatchclass{rectangle}{%
+ recursive refine@={%
+ \pgfplotspatchclass@rect@refine@{#1}%
+ },%
+}
+\def\pgfplotspatchclass@rect@refine@#1{%
+ \pgfplotspatchclass@rect@recursiverefine@newnames
+ %
+ \pgfplotspatchclass{\pgfplotspatchclassname}{new}%
+ %--------------------------------------------------
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01%
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11%
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20%
+ %--------------------------------------------------
+ % The ordering is not arbitrary
+ % (unless z buffer=sort is in effect). Let's assume that the
+ % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then
+ % this sequence here should have approximately the same depth
+ % ordering:
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.25}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.25}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@M
+ %
+ \expandafter\pgfplotspatchclass@rect@refine@@\expandafter{\pgfplotspatchclass@rect@M}{#1}%
+}
+\def\pgfplotspatchclass@rect@refine@@#1#2{%
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@AB
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@DA
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@AB}%
+ \pgfplotsplothandlermesh@setnextvertex{#1}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@DA}%
+ #2\pgfplotspatchclass@rect@recursiverefine@newnames
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@AB
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@BC
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@AB}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@BC}%
+ \pgfplotsplothandlermesh@setnextvertex{#1}%
+ #2\pgfplotspatchclass@rect@recursiverefine@newnames
+ %
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@CD
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@B\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@BC
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@BC}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@C@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@CD}%
+ \pgfplotsplothandlermesh@setnextvertex{#1}%
+ #2\pgfplotspatchclass@rect@recursiverefine@newnames
+ %
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@C\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@CD
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@D\times{0.5}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@rect@A\times{0.5}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@rect@DA
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@CD}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@DA}%
+ \pgfplotsplothandlermesh@setnextvertex{#1}%
+ #2\pgfplotspatchclass@rect@recursiverefine@newnames
+ %
+}%
+
+\def\pgfplotspatchclass@rect@recursiverefine@newnames{%
+ \let\pgfplotspatchclass@rect@A@=\pgfplotspatchclass@rect@A%
+ \let\pgfplotspatchclass@rect@B@=\pgfplotspatchclass@rect@B%
+ \let\pgfplotspatchclass@rect@C@=\pgfplotspatchclass@rect@C%
+ \let\pgfplotspatchclass@rect@D@=\pgfplotspatchclass@rect@D%
+}%
+
+
+% An arbitrary poligy specified in the sequence
+% D <-- C
+% | ^
+% v |
+% A --> B
+%
+\pgfkeyssetvalue{/pgfplots/vertex count}{0}%
+\pgfplotsdeclarepatchclass{polygon}{%
+ new=\def\pgfplotspatchclass@poly@no{0},
+ set next vertex={%
+ \pgfplotspatchclass@poly@checkcount
+ \expandafter\edef\csname pgfplotspatchclass@poly@\pgfplotspatchclass@poly@no\endcsname{#1}%
+ \pgfplotsutil@advancestringcounter\pgfplotspatchclass@poly@no
+ \ifnum\pgfplotspatchclass@poly@no=\pgfkeysvalueof{/pgfplots/vertex count} %
+ \def\pgfplotspatchclass@poly@no{0}%
+ \pgfplotspatchready%
+ \fi
+ },
+ first vertex=\expandafter\expandafter\expandafter\pgfplotspatchvertex\csname pgfplotspatchclass@poly@0\endcsname\endvertex,
+ foreach vertex={%
+ \pgfplotspatchclass@poly@foreach@loop{0}{#1}%
+ },
+ init pdf shading={%
+ \pgfplots@error{Sorry, patch type=polygon does not support shadings}%
+ },
+ serialize except vertices=\let\pgfplotsretval\pgfutil@empty,%
+ deserialize except vertices=,
+ get pdf shading type=4,
+ get num vertices=\def\pgfplotsretval{\pgfkeysvalueof{/pgfplots/vertex count}},
+}%
+\def\pgfplotspatchclass@poly@checkcount{%
+ \ifnum\pgfkeysvalueof{/pgfplots/vertex count}>0
+ \else
+ \pgfplots@error{Sorry, 'patch type=polygon' *requires* that 'vertex count=<num>' is set (note: it is allowed if multiple vertices have the same coordinates).}%
+ \fi
+}%
+\long\def\pgfplotspatchclass@poly@foreach@loop#1#2{%
+ \ifnum#1<\pgfkeysvalueof{/pgfplots/vertex count} %
+ \expandafter\expandafter\expandafter\pgfplotspatchvertex\csname pgfplotspatchclass@poly@#1\endcsname\endvertex #2%
+ \begingroup
+ \c@pgf@counta=#1 %
+ \advance\c@pgf@counta by1 %
+ \t@pgfplots@toka={#2}%
+ \xdef\pgfplots@glob@TMPc{\noexpand\pgfplotspatchclass@poly@foreach@loop{\the\c@pgf@counta}{\the\t@pgfplots@toka}}%
+ \endgroup
+ \else
+ \gdef\pgfplots@glob@TMPc{}%
+ \fi
+ \pgfplots@glob@TMPc
+}%
+
+\def\pgfplots@biquad@next@A{E}
+\def\pgfplots@biquad@next@B{F}
+\def\pgfplots@biquad@next@C{G}
+\def\pgfplots@biquad@next@D{H}
+\def\pgfplots@biquad@next@E{B}
+\def\pgfplots@biquad@next@F{C}
+\def\pgfplots@biquad@next@G{D}
+\def\pgfplots@biquad@next@H{A}
+
+
+\def\pgfplots@biquad@rnext@A{H}
+\def\pgfplots@biquad@rnext@B{E}
+\def\pgfplots@biquad@rnext@C{F}
+\def\pgfplots@biquad@rnext@D{G}
+\def\pgfplots@biquad@rnext@E{A}
+\def\pgfplots@biquad@rnext@F{B}
+\def\pgfplots@biquad@rnext@G{C}
+\def\pgfplots@biquad@rnext@H{D}
+
+\def\pgfplotspatchclass@biquad@recursiverefine@newnames{%
+ \let\pgfplotspatchclass@biquad@A@=\pgfplotspatchclass@biquad@A%
+ \let\pgfplotspatchclass@biquad@B@=\pgfplotspatchclass@biquad@B%
+ \let\pgfplotspatchclass@biquad@C@=\pgfplotspatchclass@biquad@C%
+ \let\pgfplotspatchclass@biquad@D@=\pgfplotspatchclass@biquad@D%
+ \let\pgfplotspatchclass@biquad@E@=\pgfplotspatchclass@biquad@E%
+ \let\pgfplotspatchclass@biquad@F@=\pgfplotspatchclass@biquad@F%
+ \let\pgfplotspatchclass@biquad@G@=\pgfplotspatchclass@biquad@G%
+ \let\pgfplotspatchclass@biquad@H@=\pgfplotspatchclass@biquad@H%
+ \let\pgfplotspatchclass@biquad@I@=\pgfplotspatchclass@biquad@I%
+}%
+
+
+% mathematica shape functions parameterized in
+% (xi,eta) in [-1,1]x[-1,1]:
+%f[xi_, eta_] =
+% a*1/4*(1 - xi) (1 - eta) xi*eta +
+% b 1/4 (-1 - xi) (1 - eta) xi*eta +
+% c* 1/4 (-1 - xi) (-1 - eta) xi*eta +
+% d *1/4 (1 - xi) (-1 - eta) xi*eta +
+% e * 1/2 (xi^2 - 1) (1 - eta) eta +
+% f*1/2 (-1 - xi) (eta^2 - 1) xi +
+% g* -1/2 (1 - xi^2) (-1 - eta) eta +
+% h* -1/2 (1 - xi) (1 - eta^2) xi +
+% i*(1 - xi^2) (1 - eta^2)
+% here, a,b,...,i are the 9 nodes.
+\pgfplotsdeclarepatchclass{biquadratic}{%
+ new=\def\pgfplotspatchclass@biquad@no{A}\let\pgfplotspatchclass@biquade@AB\relax,
+ set next vertex={%
+ % defines \pgfplotspatchclass@biquad@A ... \pgfplotspatchclass@biquad@I (9 points)
+ \expandafter\edef\csname pgfplotspatchclass@biquad@\pgfplotspatchclass@biquad@no\endcsname{#1}%
+ \if I\pgfplotspatchclass@biquad@no
+ \def\pgfplotspatchclass@biquad@no{A}%
+ \pgfplotspatchready
+ \else
+ \expandafter\let\expandafter\pgfplotspatchclass@biquad@no\csname pgfpptchindexnext@\pgfplotspatchclass@biquad@no\endcsname
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{0.5}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0.5}%
+ #1%
+ \def\pgfplotspatchclassx{0.5}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0.5}%
+ #1%
+ \def\pgfplotspatchclassx{0.5}%
+ \def\pgfplotspatchclassy{0.5}%
+ #1%
+ \pgfplotspatchready
+ },%
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@A\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@C\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@D\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@E\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@F\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@G\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@H\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@I\endvertex #1%
+ },
+ foreach cdata vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@C\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@biquad@D\endvertex #1%
+ },
+ fill path={%
+ \begingroup
+ % Visualize the patch boundary using four bezier curves.
+ %
+ % This involves a change from Lagrange to bezier
+ % representation of the boundary curves.
+ %
+ % Furthermore, pdf supports only **cubic** bezier curves. What
+ % I am doing here is
+ % a) change of basis from 3-point lagrange ---> 3 point quadratic bezier
+ % b) expression 3 point quadratic bezier ----> 4 point cubic bezier
+ %
+ % INPUT:
+ % 3 langrange points (i.e. the patch passes through them)
+ % \PA,\PB,\PC (start,middle,end)
+ %
+ % OUTPUT:
+ % \PA,bezier control 1, bezier control 2, \PC.
+ %
+ \def\pgfplots@edge{%
+ \ifx\pgfplotspatchclass@biquad@A\PA
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}%
+ \fi
+ \pgfpathcurveto {%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}%
+ }{%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}%
+ }{%
+ \expandafter\pgfplotspointpatchvertex\PC\endvertex
+ }%
+ }%
+ \let\PA=\pgfplotspatchclass@biquad@A
+ \let\PB=\pgfplotspatchclass@biquad@E
+ \let\PC=\pgfplotspatchclass@biquad@B
+ \pgfplots@edge
+ %
+ \let\PA=\pgfplotspatchclass@biquad@B
+ \let\PB=\pgfplotspatchclass@biquad@F
+ \let\PC=\pgfplotspatchclass@biquad@C
+ \pgfplots@edge
+ %
+ \let\PA=\pgfplotspatchclass@biquad@C
+ \let\PB=\pgfplotspatchclass@biquad@G
+ \let\PC=\pgfplotspatchclass@biquad@D
+ \pgfplots@edge
+ %
+ \let\PA=\pgfplotspatchclass@biquad@D
+ \let\PB=\pgfplotspatchclass@biquad@H
+ \let\PC=\pgfplotspatchclass@biquad@A
+ \pgfplots@edge
+ \endgroup
+ \pgfpathclose
+ },
+ %--------------------------------------------------
+ % stroke path={%
+ % \ifx\pgfplotspatchclass@biquade@AB\relax
+ % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}%
+ % \pgfpathclose
+ % \else
+ % \if1\pgfplotspatchclass@biquade@AB
+ % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}%
+ % \fi
+ % \if1\pgfplotspatchclass@biquade@BC
+ % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@B\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}%
+ % \fi
+ % \if1\pgfplotspatchclass@biquade@CA
+ % \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@C\endvertex}%
+ % \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@biquad@A\endvertex}%
+ % \fi
+ % \fi
+ % },
+ %--------------------------------------------------
+ stream to shader={%
+ \begingroup
+ %
+ % An early version of this shader used Coons patch shadings
+ % (which provides coordinates only for the 9 boundary
+ % vertices, not for the inner vertices). That is a little bit
+ % simpler than what you see in the following lines of code: a
+ % transformation to a tensor bezier shading.
+ %
+ % What we need is to map the 3x3 data from lagrangrian
+ % (interpolation) representation to 4x4 cubic bezier - and
+ % handle the four INNER nodes correctly.
+ %
+ % The algorithm to convert from 1d curves with 3 point langrange to 4 point
+ % bezier is well-known and relatively simple. Fortunately, the
+ % extension to 3x3 -> 4x4 can be boiled down to a successive
+ % application of the 1d algorithm - applied to horizontal and
+ % vertical lines in the data matrizes.
+ %
+ % NOTE: the algorithm in the following lines results in
+ % EXACTLY THE SAME four cubic boundary curves as the approach
+ % in 'fill path'. The only difference is that it also does the
+ % right thing for the inner node.
+ %
+ % STEP 1: ensure that the patch's coordinates are streamed in
+ % a sequence which is compatible with the DEPTH of the
+ % corners.
+ %
+ % we use
+ % \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth
+ % which works for bilinear, biquadratic, and bicubic
+ \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth
+ {pgfplotspatchclass@biquad@}{\Pcur}{\Pnextseq}%
+ %
+ % STEP 2:
+ % now, translate the result into our matrix form.
+ % This means to (a) identify the FIRST point which needs to be
+ % streamed (it is stored in \Pcur as 'A', 'B', 'C', or 'D')
+ % and (b) keep in mind that we have to take care of the
+ % sequence in which points are streamed ("forward" means to
+ % rotate the matrix elements and "backward" means to transpose
+ % the "forward" result).
+ %
+ % This can be seen as conversion from the "linearized"
+ % numbering to matrix indexing - while respecting the "start
+ % point".
+ %
+ % INPUT:
+ %
+ % D G C
+ % H I F
+ % A E B
+ %
+ \if A\Pcur
+ % Ah - the point "A" needs to be streamed as first.
+ %
+ % Well, this is simple: take the matrix as-is!
+ % simply copy 1:1
+ %
+ % i.e. convert
+ % D G C
+ % H I F
+ % A E B
+ %
+ % to
+ %
+ % AC BC CC
+ % AB BB CB
+ % AA BA CA
+ \let\P@AA=\pgfplotspatchclass@biquad@A
+ \let\P@BA=\pgfplotspatchclass@biquad@E
+ \let\P@CA=\pgfplotspatchclass@biquad@B
+ \let\P@AB=\pgfplotspatchclass@biquad@H
+ \let\P@BB=\pgfplotspatchclass@biquad@I
+ \let\P@CB=\pgfplotspatchclass@biquad@F
+ \let\P@AC=\pgfplotspatchclass@biquad@D
+ \let\P@BC=\pgfplotspatchclass@biquad@G
+ \let\P@CC=\pgfplotspatchclass@biquad@C
+ \fi
+ \if B\Pcur
+ % the "B" point needs to be streamed as first.
+ %
+ % i.e. reorder
+ % D G C
+ % H I F
+ % A E B
+ %
+ % to
+ % A H D AC BC CC
+ % E I G =: AB BB CB
+ % B F C AA BA CA
+ %
+ \let\P@AA=\pgfplotspatchclass@biquad@B
+ \let\P@BA=\pgfplotspatchclass@biquad@F
+ \let\P@CA=\pgfplotspatchclass@biquad@C
+ \let\P@AB=\pgfplotspatchclass@biquad@E
+ \let\P@BB=\pgfplotspatchclass@biquad@I
+ \let\P@CB=\pgfplotspatchclass@biquad@G
+ \let\P@AC=\pgfplotspatchclass@biquad@A
+ \let\P@BC=\pgfplotspatchclass@biquad@H
+ \let\P@CC=\pgfplotspatchclass@biquad@D
+ \fi
+ \if C\Pcur
+ % the "C" point needs to be streamed as first.
+ %
+ % i.e. reorder
+ % D G C
+ % H I F
+ % A E B
+ %
+ % to
+ % B E A AC BC CC
+ % F I H =: AB BB CB
+ % C G D AA BA CA
+ %
+ \let\P@AA=\pgfplotspatchclass@biquad@C
+ \let\P@BA=\pgfplotspatchclass@biquad@G
+ \let\P@CA=\pgfplotspatchclass@biquad@D
+ \let\P@AB=\pgfplotspatchclass@biquad@F
+ \let\P@BB=\pgfplotspatchclass@biquad@I
+ \let\P@CB=\pgfplotspatchclass@biquad@H
+ \let\P@AC=\pgfplotspatchclass@biquad@B
+ \let\P@BC=\pgfplotspatchclass@biquad@E
+ \let\P@CC=\pgfplotspatchclass@biquad@A
+ \fi
+ \if D\Pcur
+ % the "D" point needs to be streamed as first.
+ %
+ % i.e. reorder
+ % D G C
+ % H I F
+ % A E B
+ %
+ % to
+ % C F B AC BC CC
+ % G I E =: AB BB CB
+ % D H A AA BA CA
+ %
+ \let\P@AA=\pgfplotspatchclass@biquad@D
+ \let\P@BA=\pgfplotspatchclass@biquad@H
+ \let\P@CA=\pgfplotspatchclass@biquad@A
+ \let\P@AB=\pgfplotspatchclass@biquad@G
+ \let\P@BB=\pgfplotspatchclass@biquad@I
+ \let\P@CB=\pgfplotspatchclass@biquad@E
+ \let\P@AC=\pgfplotspatchclass@biquad@C
+ \let\P@BC=\pgfplotspatchclass@biquad@F
+ \let\P@CC=\pgfplotspatchclass@biquad@B
+ \fi
+ \ifx\Pnextseq\pgfutil@empty
+ \else
+ % reverse the ordering. This means to transpose the
+ % matrix:
+ \pgfplotspatchclass@biquad@transpose
+ \fi
+ %
+ %
+ % Step: convert to tensor bezier representation.
+ %
+ % Converting a 2d tensor product lagrangian interpoland to a
+ % 2d tensor product bezier interpoland can be achieved by
+ % means of 1d algorithms along LINES in the matrix.
+ %
+ % The underlying proof for this is related to the tensor
+ % product form: the U and V coordinates are orthogonal to each
+ % other, so we can redistribute all intermediate results. (I
+ % do not have the real proof, so this hand-waving argument has
+ % to be enough). I verified its results experimentally.
+ %
+ % Note that the underlying 1d operation is the same as for
+ % 'patch type=quadratic spline' . We only need to apply it to all
+ % lines in U direction and afterwards to all lines in V
+ % direction.
+ %
+ \def\pgfplotspatchvertexaddXY@expanded##1\times{%
+ \edef\pgfplots@loc@TMPa{##1}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplots@loc@TMPa\times
+ }%
+ %
+ % this macro operates on \pgfplots@line{[ABC]} and defines
+ % \pgfplots@line{[ABCD]} (i.e. one dimension more!)
+ \def\pgfplots@apply@to@line{%
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{B}\times{1.333333}%
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{C}\times{-0.333333}%
+ \pgfplotspatchvertexfinish\pgfplots@controlpoint@A
+ %
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{A}\times{-0.333333}%
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{B}\times{1.333333}%
+ \pgfplotspatchvertexfinish\pgfplots@controlpoint@B
+ %
+ % ... we output 4 points (cubic!).
+ % A= left endpoint (untouched)
+ % B= first control
+ % C= second control
+ % D= right endpoint (untouched, is formerly called 'C')
+ \edef\pgfplots@loc@TMPa{\pgfplots@line{C}}%
+ \expandafter\expandafter\expandafter\let\pgfplots@line{B}=\pgfplots@controlpoint@A
+ \expandafter\expandafter\expandafter\let\pgfplots@line{C}=\pgfplots@controlpoint@B
+ \expandafter\expandafter\expandafter\let\pgfplots@line{D}=\pgfplots@loc@TMPa
+ }%
+ %
+ \def\pgfplots@line##1{\csname P@##1A\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@##1B\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@##1C\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ % Now, we have a 3x4 matrix.
+ %
+ %
+ \def\pgfplots@line##1{\csname P@A##1\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@B##1\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@C##1\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@D##1\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ % OK. The tensor product representation is READY.
+ %
+ % in particular, we have a 4x4 matrix right now:
+ %
+ \pgfplotsplothandlermesh@shade@cubic@tensor
+ \endgroup
+ },%
+ triangulate={%
+ \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass
+ \def\pgfplotsplothandlermesh@patchclass{triangle}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20%
+ % Ok. Now create 4 triangles. The ordering is not arbitrary
+ % (unless z buffer=sort is in effect). Let's assume that the
+ % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then
+ % this sequence here should have approximately the same depth
+ % ordering:
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}%
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I}%
+ \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@
+ },%
+ %--------------------------------------------------
+ % set edge visible={%
+ % \ifcase#1
+ % \edef\pgfplotspatchclass@biquade@AB{#2}%
+ % \or
+ % \edef\pgfplotspatchclass@biquade@BC{#2}%
+ % \or
+ % \edef\pgfplotspatchclass@biquade@CA{#2}%
+ % \fi
+ % },
+ %--------------------------------------------------
+ serialize except vertices={%
+ \ifx\pgfplotspatchclass@biquade@AB\relax
+ \let\pgfplotsretval\pgfutil@empty%
+ \else
+ \edef\pgfplotsretval{%
+ \noexpand\def\noexpand\pgfplotspatchclass@biquade@AB{\pgfplotspatchclass@biquade@AB}%
+ \noexpand\def\noexpand\pgfplotspatchclass@biquade@BC{\pgfplotspatchclass@biquade@BC}%
+ \noexpand\def\noexpand\pgfplotspatchclass@biquade@CA{\pgfplotspatchclass@biquade@CA}%
+ }%
+ \fi
+ },%
+ deserialize except vertices=%
+ \let\pgfplotspatchclass@biquade@AB\relax
+ #1,
+ recursive refine@={%
+ \pgfplotspatchclass@biquad@recursiverefine@newnames
+ %
+ \pgfplotspatchclass{\pgfplotspatchclassname}{new}%
+ %--------------------------------------------------
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}01%
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}11%
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{set edge visible}20%
+ %--------------------------------------------------
+ % The ordering is not arbitrary
+ % (unless z buffer=sort is in effect). Let's assume that the
+ % AB edge is BACKGROUND and the CD edge is FOREGROUND. Then
+ % this sequence here should have approximately the same depth
+ % ordering:
+ %
+ % I used the reference triangle and shape functions as listed in
+ % http://www.colorado.edu/engineering/CAS/courses.d/IFEM.d/,
+ % see above for the definition of f[xi,eta]
+ %
+ % N[{f[-1/2, -1], f[0, -1/2], f[-1/2, 0], f[-1, -1/2], f[-1/2, -1/2]}]
+ % {0.375` a - 0.125` b + 0.75` e,
+ % 0.375` e - 0.125` g + 0.75` i,
+ % -0.125` f + 0.375` h + 0.75` i,
+ % 0.375` a - 0.125` d + 0.75` h,
+ % 0.140625` a - 0.046875` b + 0.015625` c - 0.046875` d +
+ % 0.28125` e - 0.09375` f - 0.09375` g + 0.28125` h +
+ % 0.5625` i}
+ %--------------------------------------------------
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AE
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EI
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HI
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AH
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.140625}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.046875}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.015625}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.046875}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.28125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.09375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.09375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.28125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@AEIH
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@A@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AE}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EI}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HI}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AH}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@AEIH}%
+ %
+ #1\pgfplotspatchclass@biquad@recursiverefine@newnames
+ %
+ % N[{f[1/2, -1], f[1, -1/2], f[1/2, 0], f[1/2, -1/2]}]
+ % {-0.125` a + 0.375` b + 0.75` e,
+ % 0.375` b - 0.125` c + 0.75` f,
+ % 0.375` f - 0.125` h + 0.75` i,
+ % -0.046875 a + 0.140625 b - 0.046875 c + 0.015625 d + 0.28125 e + 0.28125 f - 0.09375 g - 0.09375 h + 0.5625 i}
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EB
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@BF
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FI
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EI
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.046875}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.140625}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.046875}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.015625}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{0.28125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.28125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{-0.09375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.09375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@EBFI
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@E@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@B@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EB}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@BF}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FI}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EI}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@EBFI}%
+ %
+ #1\pgfplotspatchclass@biquad@recursiverefine@newnames
+ %
+ %
+ % N[ {f[1, 1/2], f[1/2, 1], f[0, 1/2], f[1/2, 1/2]}]
+ % {-0.125` b + 0.375` c + 0.75` f,
+ % 0.375` c - 0.125` d + 0.75` g,
+ % -0.125` e + 0.375` g + 0.75` i,
+ % 0.015625` a - 0.046875` b + 0.140625` c - 0.046875` d - 0.09375` e + 0.28125` f + 0.28125` g - 0.09375` h + 0.5625` i}
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FC
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@CG
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GI
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@FI
+ %
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{0.015625}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{-0.046875}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{0.140625}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{-0.046875}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.09375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{0.28125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.28125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{-0.09375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@IFCG
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@F@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@C@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FI}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@FC}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@CG}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GI}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@IFCG}%
+ %
+ #1\pgfplotspatchclass@biquad@recursiverefine@newnames
+ %
+ %
+ % N[{f[-1/2, 1], f[-1, 1/2], f[-1/2, 1/2]}]
+ % {-0.125 c + 0.375 d + 0.75 g,
+ % -0.125 a + 0.375 d + 0.75 h,
+ % -0.046875 a + 0.015625 b - 0.046875 c + 0.140625 d - 0.09375 e - 0.09375 f + 0.28125 g + 0.28125 h + 0.5625 i}
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GD
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@DH
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@GI
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HI
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@A\times{-0.046875}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@B\times{0.015625}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@C\times{-0.046875}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@D\times{0.140625}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@E\times{-0.09375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@F\times{-0.09375}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@G\times{0.28125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@H\times{0.28125}%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchclass@biquad@I\times{0.5625}%
+ \pgfplotspatchvertexfinish\pgfplotspatchclass@biquad@HIGD
+ %
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@H@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@I@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@G@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@D@}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HI}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GI}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@GD}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@DH}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@biquad@HIGD}%
+ %
+ #1%
+ %
+ },%
+ get pdf shading type*={%
+ \if1\b@pgfplotsplothandlermesh@enable@fixed@biquadratic
+ \def\pgfplotsretval{7}%
+ \else
+ \def\pgfplotsretval{6}%
+ \fi
+ },%
+ get num vertices=\def\pgfplotsretval{9},
+ get num cdata vertices=\def\pgfplotsretval{4},
+}%
+
+% set this to 0 to revert to an older implementation (which was buggy,
+% though)
+\def\b@pgfplotsplothandlermesh@enable@fixed@biquadratic{1}%
+
+
+% see docs in 'biquadratic::stream to shader' for details.
+% PRECONDITION: to be used inside of 'stream to shader'.
+\def\pgfplotspatchclass@biquad@coonsedge{%
+%\message{EDGE \Pcur^^J}%
+ \expandafter\let\expandafter\PA\csname pgfplotspatchclass@biquad@\Pcur\endcsname
+ \edef\Pcur{\csname pgfplots@biquad@\Pnextseq next@\Pcur\endcsname}%
+ \expandafter\let\expandafter\PB\csname pgfplotspatchclass@biquad@\Pcur\endcsname
+%\message{---> \Pcur^^J}%
+ \edef\Pcur{\csname pgfplots@biquad@\Pnextseq next@\Pcur\endcsname}%
+ \expandafter\let\expandafter\PC\csname pgfplotspatchclass@biquad@\Pcur\endcsname
+%\message{---> \Pcur^^J}%
+ \ifx\PA\Pstart
+ \expandafter\pgfplotspatchvertex\PA\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \fi
+ \pgfplotslibrarysurfstreamcoord{%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}%
+ }{}%
+ \pgfplotslibrarysurfstreamcoord{%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}%
+ }{}%
+ \ifx\PC\Pstart
+ \else
+ \expandafter\pgfplotspatchvertex\PC\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \fi
+}%
+\def\pgfplotspatchclass@biquad@innercontrolpoints{%
+ \begingroup
+ %
+ % This here computes the FOUR INNER CONTROL POINTS of a tensor
+ % cubic bezier patch (Shading Type 7).
+ %
+ %
+ % the following point coordinates have been acquired from
+ % biquadratic::recursive refine. See above for documentation.
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@A\times{0.375}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@B\times{-0.125}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@E\times{0.75}%
+ \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@AE
+ %
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@F\times{-0.125}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@H\times{0.375}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@HI
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@A\times{-0.125}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@B\times{0.375}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@E\times{0.75}%
+ \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@EB
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@F\times{0.375}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@H\times{-0.125}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@I\times{0.75}%
+ \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@FI
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@C\times{0.375}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@D\times{-0.125}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@G\times{0.75}%
+ \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@CG
+ %
+ \pgfplotspatchvertexaccumstart
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@C\times{-0.125}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@D\times{0.375}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@biquad@G\times{0.75}%
+ \pgfplotspatchvertexfinishXY\pgfplotspatchclass@biquad@GD
+ %
+ %
+ \let\PA=\pgfplotspatchclass@biquad@AE
+ \let\PB=\pgfplotspatchclass@biquad@HI
+ \let\PC=\pgfplotspatchclass@biquad@GD
+ \pgfplotspatchclass@biquad@innercontrolpoints@PREPARE\pgfplotspatchclass@biquad@@A\pgfplotspatchclass@biquad@@D
+ %
+ \let\PA=\pgfplotspatchclass@biquad@EB
+ \let\PB=\pgfplotspatchclass@biquad@FI
+ \let\PC=\pgfplotspatchclass@biquad@CG
+ \pgfplotspatchclass@biquad@innercontrolpoints@PREPARE\pgfplotspatchclass@biquad@@B\pgfplotspatchclass@biquad@@C
+ %
+ %
+ \let\Pcur=\Pstartidx
+ \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}%
+ %
+ \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}%
+ \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}%
+ %
+ \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}%
+ \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}%
+ %
+ \edef\Pcur{\csname pgfplots@rect@\Pnextseq next@\Pcur\endcsname}%
+ \pgfplotslibrarysurfstreamcoord{\csname pgfplotspatchclass@biquad@@\Pcur\endcsname}{}%
+ \endgroup
+}%
+\def\pgfplotspatchclass@biquad@innercontrolpoints@PREPARE#1#2{%
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}}%
+ \edef#1{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfpointadd
+ {\pgfqpointscale{1.333333}{\expandafter\pgfplotspointpatchvertex\PB\endvertex}}%
+ {\pgfqpointscale{-0.333333}{\expandafter\pgfplotspointpatchvertex\PA\endvertex}}%
+ \edef#2{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
+ %
+\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PA\endvertex}{1pt}\pgfusepath{fill}%
+\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PB\endvertex}{1pt}\pgfusepath{fill}%
+\pgfpathcircle{\expandafter\pgfplotspointpatchvertex\PC\endvertex}{1pt}\pgfusepath{fill}%
+\pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\PA\endvertex}%
+\pgfpathcurveto{#1}{#2}{\expandafter\pgfplotspointpatchvertex\PC\endvertex}%
+\pgfusepath{stroke}%
+}
+
+% Direct interface to coons patches (pdf shading type 6).
+% See manual and/or pdf reference
+\pgfplotsdeclarepatchclass{coons}{%
+ new=\def\pgfplotspatchclass@coons@no{A},
+ set next vertex={%
+ % defines \pgfplotspatchclass@coons@A ... \pgfplotspatchclass@coons@L (12 points)
+ \expandafter\edef\csname pgfplotspatchclass@coons@\pgfplotspatchclass@coons@no\endcsname{#1}%
+ \if L\pgfplotspatchclass@coons@no
+ \def\pgfplotspatchclass@coons@no{A}%
+ \pgfplotspatchready
+ \else
+ \expandafter\let\expandafter\pgfplotspatchclass@coons@no\csname pgfpptchindexnext@\pgfplotspatchclass@coons@no\endcsname
+ \fi
+ },
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@C\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@D\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@E\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@F\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@G\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@H\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@I\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@J\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@K\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@L\endvertex #1%
+ },
+ foreach cdata vertex={%
+ % 0, 3, 6, 9
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@D\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@G\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@coons@J\endvertex #1%
+ },
+ fill path={%
+ \pgfpathmoveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@A\endvertex}%
+ \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@B\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@C\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@D\endvertex}%
+ \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@E\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@F\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@G\endvertex}%
+ \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@H\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@I\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@J\endvertex}%
+ \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@K\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@L\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@coons@A\endvertex}%
+ \pgfpathclose
+ },
+ serialize except vertices=\let\pgfplotsretval\pgfutil@empty,%
+ deserialize except vertices=,
+ get pdf shading type=6,
+ get num vertices=\def\pgfplotsretval{12},
+ get num cdata vertices=\def\pgfplotsretval{4},
+}%
+
+% Direct interface to tensor product bezier patches (pdf shading type 7).
+% See manual and/or pdf reference
+\pgfplotsdeclarepatchclass{tensor bezier}{%
+ new=\def\pgfplotspatchclass@tensor@no{A},
+ set next vertex={%
+ % defines \pgfplotspatchclass@tensor@A ... \pgfplotspatchclass@tensor@P (16 points)
+ \expandafter\edef\csname pgfplotspatchclass@tensor@\pgfplotspatchclass@tensor@no\endcsname{#1}%
+ \if P\pgfplotspatchclass@tensor@no
+ \def\pgfplotspatchclass@tensor@no{A}%
+ \pgfplotspatchready
+ \else
+ \expandafter\let\expandafter\pgfplotspatchclass@tensor@no\csname pgfpptchindexnext@\pgfplotspatchclass@tensor@no\endcsname
+ \fi
+ },
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@B\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@C\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@D\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@E\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@F\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@G\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@H\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@I\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@J\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@K\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@L\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@M\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@N\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@O\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@P\endvertex #1%
+ },
+ foreach cdata vertex={%
+ % 0, 3, 6, 9
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@A\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@D\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@G\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@tensor@J\endvertex #1%
+ },
+ fill path={%
+ \pgfpathmoveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@A\endvertex}%
+ \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@B\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@C\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@D\endvertex}%
+ \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@E\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@F\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@G\endvertex}%
+ \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@H\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@I\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@J\endvertex}%
+ \pgfpathcurveto {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@K\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@L\endvertex}%
+ {\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@tensor@A\endvertex}%
+ \pgfpathclose
+ },
+ serialize except vertices=\let\pgfplotsretval\pgfutil@empty,%
+ deserialize except vertices=,
+ get pdf shading type=7,
+ get num vertices=\def\pgfplotsretval{16},
+ get num cdata vertices=\def\pgfplotsretval{4},
+}%
+
+% A bicubic patch with 16 points.
+%
+% It expects points in the order (i.e. in matrix ordering, row-wise):
+%
+% AD BD CD DD
+% AC BC CC DC
+% AB BB CB DB
+% AA BA CA DA
+%
+\pgfplotsdeclarepatchclass{bicubic}{%
+ new=\def\pgfplotspatchclass@bicubic@row{A}\def\pgfplotspatchclass@bicubic@col{A},
+ set next vertex={%
+ % defines \pgfplotspatchclass@bicubic@AA ... \pgfplotspatchclass@bicubic@DD (16 points)
+ \expandafter\edef\csname pgfplotspatchclass@bicubic@\pgfplotspatchclass@bicubic@row\pgfplotspatchclass@bicubic@col\endcsname{#1}%
+ \if D\pgfplotspatchclass@bicubic@row
+ \def\pgfplotspatchclass@bicubic@row{A}%
+ \if D\pgfplotspatchclass@bicubic@col
+ \def\pgfplotspatchclass@bicubic@col{A}%
+ \pgfplotspatchready
+ \else
+ \expandafter\let\expandafter\pgfplotspatchclass@bicubic@col\csname pgfpptchindexnext@\pgfplotspatchclass@bicubic@col\endcsname
+ \fi
+ \else
+ \expandafter\let\expandafter\pgfplotspatchclass@bicubic@row\csname pgfpptchindexnext@\pgfplotspatchclass@bicubic@row\endcsname
+ \fi
+ },
+ sample in unit cube={%
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{0.333333333}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{0.666666666}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0}%
+ #1%
+ %
+ %
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0.333333333}%
+ #1%
+ \def\pgfplotspatchclassx{0.333333333}%
+ \def\pgfplotspatchclassy{0.333333333}%
+ #1%
+ \def\pgfplotspatchclassx{0.666666666}%
+ \def\pgfplotspatchclassy{0.333333333}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0.333333333}%
+ #1%
+ %
+ %
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{0.666666666}%
+ #1%
+ \def\pgfplotspatchclassx{0.333333333}%
+ \def\pgfplotspatchclassy{0.666666666}%
+ #1%
+ \def\pgfplotspatchclassx{0.666666666}%
+ \def\pgfplotspatchclassy{0.666666666}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{0.666666666}%
+ #1%
+ %
+ %
+ \def\pgfplotspatchclassx{0}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{0.333333333}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{0.666666666}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ \def\pgfplotspatchclassx{1}%
+ \def\pgfplotspatchclassy{1}%
+ #1%
+ %
+ %
+ %
+ \pgfplotspatchready
+ },%
+ first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AA\endvertex,
+ foreach vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AA\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@BA\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@CA\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DA\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AB\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@BB\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@CB\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DB\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AC\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@BC\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@CC\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DC\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AD\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@BD\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@CD\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DD\endvertex #1%
+ },
+ foreach cdata vertex={%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AA\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DA\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@DD\endvertex #1%
+ \expandafter\pgfplotspatchvertex\pgfplotspatchclass@bicubic@AD\endvertex #1%
+ },
+ fill path={%
+ % Visualize the patch boundary using four bezier curves.
+ %
+ % This involves a change from Lagrange to bezier
+ % representation of the boundary curves.
+ %
+ \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@bicubic@AA\endvertex}%
+ \pgfplotspathcubicfrominterpolation
+ {\pgfplotspatchclass@bicubic@AA}
+ {\pgfplotspatchclass@bicubic@BA}
+ {\pgfplotspatchclass@bicubic@CA}
+ {\pgfplotspatchclass@bicubic@DA}%
+ \pgfplotspathcubicfrominterpolation
+ {\pgfplotspatchclass@bicubic@DA}
+ {\pgfplotspatchclass@bicubic@DB}
+ {\pgfplotspatchclass@bicubic@DC}
+ {\pgfplotspatchclass@bicubic@DD}%
+ \pgfplotspathcubicfrominterpolation
+ {\pgfplotspatchclass@bicubic@DD}
+ {\pgfplotspatchclass@bicubic@CD}
+ {\pgfplotspatchclass@bicubic@BD}
+ {\pgfplotspatchclass@bicubic@AD}%
+ \pgfplotspathcubicfrominterpolation
+ {\pgfplotspatchclass@bicubic@AD}
+ {\pgfplotspatchclass@bicubic@AC}
+ {\pgfplotspatchclass@bicubic@AB}
+ {\pgfplotspatchclass@bicubic@AA}%
+ \pgfpathclose
+ },
+ stream to shader={%
+ \begingroup
+ %
+ % AD BD CD DD
+ % AC BC CC DC
+ % AB BB CB DB
+ % AA BA CA DA
+ %
+ % STEP 1: ensure that the patch's coordinates are streamed in
+ % a sequence which is compatible with the DEPTH of the
+ % corners.
+ %
+ % we use
+ % \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth
+ % which works for bilinear, biquadratic, and bicubic
+ %
+ % define helper macros which are input for
+ % \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth:
+ \let\pgfplotspatchclass@rect@A=\pgfplotspatchclass@bicubic@AA
+ \let\pgfplotspatchclass@rect@B=\pgfplotspatchclass@bicubic@DA
+ \let\pgfplotspatchclass@rect@C=\pgfplotspatchclass@bicubic@DD
+ \let\pgfplotspatchclass@rect@D=\pgfplotspatchclass@bicubic@AD
+ \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth
+ {pgfplotspatchclass@rect@}{\Pcur}{\Pnextseq}%
+ %
+ %\message{using \Pcur\space(set = \Pnextseq)^^J}%
+ % now, translate the result into our matrix form.
+ % This means to (a) identify the FIRST point which needs to be
+ % streamed (it is stored in \Pcur as 'A', 'B', 'C', or 'D')
+ % and (b) keep in mind that we have to take care of the
+ % sequence in which points are streamed ("forward" means to
+ % rotate the matrix elements and "backward" means to transpose
+ % the "forward" result).
+ %
+ \if A\Pcur
+ % Ah - the point "AA" needs to be streamed as first.
+ %
+ % Well, this is simple: take the matrix as-is!
+ % simply copy 1:1
+ \let\P@AA=\pgfplotspatchclass@bicubic@AA
+ \let\P@BA=\pgfplotspatchclass@bicubic@BA
+ \let\P@CA=\pgfplotspatchclass@bicubic@CA
+ \let\P@DA=\pgfplotspatchclass@bicubic@DA
+ \let\P@AB=\pgfplotspatchclass@bicubic@AB
+ \let\P@BB=\pgfplotspatchclass@bicubic@BB
+ \let\P@CB=\pgfplotspatchclass@bicubic@CB
+ \let\P@DB=\pgfplotspatchclass@bicubic@DB
+ \let\P@AC=\pgfplotspatchclass@bicubic@AC
+ \let\P@BC=\pgfplotspatchclass@bicubic@BC
+ \let\P@CC=\pgfplotspatchclass@bicubic@CC
+ \let\P@DC=\pgfplotspatchclass@bicubic@DC
+ \let\P@AD=\pgfplotspatchclass@bicubic@AD
+ \let\P@BD=\pgfplotspatchclass@bicubic@BD
+ \let\P@CD=\pgfplotspatchclass@bicubic@CD
+ \let\P@DD=\pgfplotspatchclass@bicubic@DD
+ \fi
+ \if B\Pcur
+ % the "DA" point needs to be streamed as first.
+ %
+ % Reorder
+ % AD BD CD DD
+ % AC BC CC DC
+ % AB BB CB DB
+ % AA BA CA DA
+ % to
+ % AA AB AC AD
+ % BA BB BC BD
+ % CA CB CC CD
+ % DA DB DC DD
+ %
+ \let\P@AA=\pgfplotspatchclass@bicubic@DA
+ \let\P@BA=\pgfplotspatchclass@bicubic@DB
+ \let\P@CA=\pgfplotspatchclass@bicubic@DC
+ \let\P@DA=\pgfplotspatchclass@bicubic@DD
+ \let\P@AB=\pgfplotspatchclass@bicubic@CA
+ \let\P@BB=\pgfplotspatchclass@bicubic@CB
+ \let\P@CB=\pgfplotspatchclass@bicubic@CC
+ \let\P@DB=\pgfplotspatchclass@bicubic@CD
+ \let\P@AC=\pgfplotspatchclass@bicubic@BA
+ \let\P@BC=\pgfplotspatchclass@bicubic@BB
+ \let\P@CC=\pgfplotspatchclass@bicubic@BC
+ \let\P@DC=\pgfplotspatchclass@bicubic@BD
+ \let\P@AD=\pgfplotspatchclass@bicubic@AA
+ \let\P@BD=\pgfplotspatchclass@bicubic@AB
+ \let\P@CD=\pgfplotspatchclass@bicubic@AC
+ \let\P@DD=\pgfplotspatchclass@bicubic@AD
+ \fi
+ \if C\Pcur
+ % the "DD" point needs to be streamed as first.
+ %
+ % Reorder
+ % AD BD CD DD
+ % AC BC CC DC
+ % AB BB CB DB
+ % AA BA CA DA
+ % to
+ % DA CA BA AA
+ % DB CB BB AB
+ % DC CC BC AC
+ % DD CD BD AD
+ %
+ \let\P@AA=\pgfplotspatchclass@bicubic@DD
+ \let\P@BA=\pgfplotspatchclass@bicubic@CD
+ \let\P@CA=\pgfplotspatchclass@bicubic@BD
+ \let\P@DA=\pgfplotspatchclass@bicubic@AD
+ \let\P@AB=\pgfplotspatchclass@bicubic@DC
+ \let\P@BB=\pgfplotspatchclass@bicubic@CC
+ \let\P@CB=\pgfplotspatchclass@bicubic@BC
+ \let\P@DB=\pgfplotspatchclass@bicubic@AC
+ \let\P@AC=\pgfplotspatchclass@bicubic@DB
+ \let\P@BC=\pgfplotspatchclass@bicubic@CB
+ \let\P@CC=\pgfplotspatchclass@bicubic@BB
+ \let\P@DC=\pgfplotspatchclass@bicubic@AB
+ \let\P@AD=\pgfplotspatchclass@bicubic@DA
+ \let\P@BD=\pgfplotspatchclass@bicubic@CA
+ \let\P@CD=\pgfplotspatchclass@bicubic@BA
+ \let\P@DD=\pgfplotspatchclass@bicubic@AA
+ \fi
+ \if D\Pcur
+ % the "AD" point needs to be streamed as first.
+ %
+ % Reorder
+ % AD BD CD DD
+ % AC BC CC DC
+ % AB BB CB DB
+ % AA BA CA DA
+ % to
+ % DD DC DB DA
+ % CD CC CB CA
+ % BD BC BB BA
+ % AD AC AB AA
+ %
+ \let\P@AA=\pgfplotspatchclass@bicubic@AD
+ \let\P@BA=\pgfplotspatchclass@bicubic@AC
+ \let\P@CA=\pgfplotspatchclass@bicubic@AB
+ \let\P@DA=\pgfplotspatchclass@bicubic@AA
+ \let\P@AB=\pgfplotspatchclass@bicubic@BD
+ \let\P@BB=\pgfplotspatchclass@bicubic@BC
+ \let\P@CB=\pgfplotspatchclass@bicubic@BB
+ \let\P@DB=\pgfplotspatchclass@bicubic@BA
+ \let\P@AC=\pgfplotspatchclass@bicubic@CD
+ \let\P@BC=\pgfplotspatchclass@bicubic@CC
+ \let\P@CC=\pgfplotspatchclass@bicubic@CB
+ \let\P@DC=\pgfplotspatchclass@bicubic@CA
+ \let\P@AD=\pgfplotspatchclass@bicubic@DD
+ \let\P@BD=\pgfplotspatchclass@bicubic@DC
+ \let\P@CD=\pgfplotspatchclass@bicubic@DB
+ \let\P@DD=\pgfplotspatchclass@bicubic@DA
+ \fi
+ \ifx\Pnextseq\pgfutil@empty
+ \else
+ % reverse the ordering. This means to transpose the
+ % matrix:
+ \pgfplotspatchclass@bicubic@transpose
+ \fi
+ %
+ % Step: convert to tensor bezier representation.
+ %
+ % Converting a 2d tensor product lagrangian interpoland to a
+ % 2d tensor product bezier interpoland can be achieved by
+ % means of 1d algorithms along LINES in the matrix.
+ %
+ % The underlying proof for this is related to the tensor
+ % product form: the U and V coordinates are orthogonal to each
+ % other, so we can redistribute all intermediate results. (I
+ % do not have the real proof, so this hand-waving argument has
+ % to be enough). I verified its results experimentally.
+ %
+ % Note that the underlying 1d operation is the same as for
+ % 'patch type=cubic spline' . We only need to apply it to all
+ % lines in U direction and afterwards to all lines in V
+ % direction.
+ %
+ \def\pgfplotspatchvertexaddXY@expanded##1\times{%
+ \edef\pgfplots@loc@TMPa{##1}%
+ \expandafter\pgfplotspatchvertexaddXY\pgfplots@loc@TMPa\times
+ }%
+ %
+ % this macro operates on \pgfplots@line{[ABCD]}, see below:
+ \def\pgfplots@apply@to@line{%
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{A}\times{-0.833333}%
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{B}\times{3}%
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{C}\times{-1.5}%
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{D}\times{0.3333333}%
+ \pgfplotspatchvertexfinish\pgfplots@controlpoint@A
+ %
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{A}\times{0.333333}%
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{B}\times{-1.5}%
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{C}\times{3}%
+ \pgfplotspatchvertexaddXY@expanded\pgfplots@line{D}\times{-0.833333}%
+ \pgfplotspatchvertexfinish\pgfplots@controlpoint@B
+ %
+ \expandafter\expandafter\expandafter\let\pgfplots@line{B}=\pgfplots@controlpoint@A
+ \expandafter\expandafter\expandafter\let\pgfplots@line{C}=\pgfplots@controlpoint@B
+ }%
+ %
+ \def\pgfplots@line##1{\csname P@##1A\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@##1B\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@##1C\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@##1D\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ %
+ \def\pgfplots@line##1{\csname P@A##1\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@B##1\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@C##1\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ \def\pgfplots@line##1{\csname P@D##1\endcsname}%
+ \pgfplots@apply@to@line
+ %
+ % OK. The tensor product representation is READY.
+ %
+ \pgfplotsplothandlermesh@shade@cubic@tensor
+ \endgroup
+ },
+ triangulate={%
+ \let\pgfplotsplothandlermesh@patchclass@=\pgfplotsplothandlermesh@patchclass
+ \def\pgfplotsplothandlermesh@patchclass{triangle}%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
+ % Ok. Now create a lot of triangles.
+ %
+ % FIXME: The ordering is not arbitrary (unless z buffer=sort is in effect).
+ %
+ % ##1: the row index of the cell to be triangulated (either A,B,or C)
+ % ##2: the col index of the cell to be triangulated (either A,B,or C)
+ % ##3: the 1. 'set edge visible' value for the first triangle
+ % ##4: the 2. 'set edge visible' value for the first triangle
+ % ##5: the 3. 'set edge visible' value for the first triangle
+ % ##6: the 1. 'set edge visible' value for the second triangle
+ % ##7: the 2. 'set edge visible' value for the second triangle
+ % ##8: the 3. 'set edge visible' value for the second triangle
+ \def\pgfplots@bicubic@triangulate@cell##1##2##3##4##5##6##7##8{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}0##3%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}1##4%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}2##5%
+ \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@##1##2\endcsname}%
+ \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@\csname pgfpptchindexnext@##1\endcsname##2\endcsname}%
+ \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@\csname pgfpptchindexnext@##1\endcsname \csname pgfpptchindexnext@##2\endcsname\endcsname}%
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}0##6%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}1##7%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}2##8%
+ \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@##1\csname pgfpptchindexnext@##2\endcsname\endcsname}%
+ \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@##1##2\endcsname}%
+ \pgfplotsplothandlermesh@setnextvertex{\csname pgfplotspatchclass@bicubic@\csname pgfpptchindexnext@##1\endcsname \csname pgfpptchindexnext@##2\endcsname\endcsname}%
+ %
+ }%
+ %
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}20%
+ \pgfplots@bicubic@triangulate@cell AA100 100%
+ \pgfplots@bicubic@triangulate@cell BA100 000%
+ \pgfplots@bicubic@triangulate@cell CA110 000%
+ %
+ \pgfplots@bicubic@triangulate@cell AB000 100%
+ \pgfplots@bicubic@triangulate@cell BB000 000%
+ \pgfplots@bicubic@triangulate@cell CB010 000%
+ %
+ \pgfplots@bicubic@triangulate@cell AC000 101%
+ \pgfplots@bicubic@triangulate@cell BC000 001%
+ \pgfplots@bicubic@triangulate@cell CC010 001%
+ \let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@
+ },%
+ serialize except vertices=\let\pgfplotsretval\pgfutil@empty,%
+ deserialize except vertices=,
+ get pdf shading type=7,
+ get num vertices=\def\pgfplotsretval{16},
+ get num cdata vertices=\def\pgfplotsretval{4},
+}%
+
+% Transpose a bicubic matrix (4x4).
+%
+% Reorder
+% AD BD CD DD
+% AC BC CC DC
+% AB BB CB DB
+% AA BA CA DA
+% to
+% DA DB DC DD
+% CA CB CC CD
+% BA BB BC BD
+% AA AB AC AD
+\def\pgfplotspatchclass@bicubic@transpose{%
+ \pgfplotsutil@swap\P@AB\P@BA
+ \pgfplotsutil@swap\P@CA\P@AC
+ \pgfplotsutil@swap\P@DA\P@AD
+ \pgfplotsutil@swap\P@CB\P@BC
+ \pgfplotsutil@swap\P@BD\P@DB
+ \pgfplotsutil@swap\P@DC\P@CD
+}
+
+% Transpose a bicubic matrix (4x4).
+%
+% Reorder
+% AC BC CC
+% AB BB CB
+% AA BA CA
+% to
+% CA CB CC
+% BA BB BC
+% AA AB AC
+\def\pgfplotspatchclass@biquad@transpose{%
+ \pgfplotsutil@swap\P@AB\P@BA
+ \pgfplotsutil@swap\P@CA\P@AC
+ \pgfplotsutil@swap\P@CB\P@BC
+}
+
+% Expects that a 4x4 matrix in tensor bezier representation where
+% A = left end point
+% B = first control point
+% C = second control point
+% D = right end point
+%
+% and the coordinates are stored in \csname P@[ABCD][ABCD]\endcsname
+%
+% Streaming starts with \P@AA and is applied rowwise.
+\def\pgfplotsplothandlermesh@shade@cubic@tensor{%
+ % Stream it to the shader. Note that the shader has a
+ % DIFFERENT ordering; it expects points in the cyclic ordering
+ %
+ % AA BA CA DA DB DC DD CD BD AD AC AB BB CB CC BC
+ %
+ % note furthermore that only the corners have "point meta" in
+ % this shading :-(
+ %
+ \expandafter\pgfplotspatchvertex\P@AA\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@BA\endvertex}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@CA\endvertex}{\pgfplotspointmetatransformed}%
+ \expandafter\pgfplotspatchvertex\P@DA\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ %
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@DB\endvertex}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@DC\endvertex}{\pgfplotspointmetatransformed}%
+ \expandafter\pgfplotspatchvertex\P@DD\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ %
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@CD\endvertex}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@BD\endvertex}{\pgfplotspointmetatransformed}%
+ \expandafter\pgfplotspatchvertex\P@AD\endvertex
+ \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta
+ \pgfplotsaxisvisphasetransformpointmeta
+ \pgfplotslibrarysurfstreamcoord{\pgfqpoint\pgfplotspatchvertexx\pgfplotspatchvertexy}{\pgfplotspointmetatransformed}%
+ %
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@AC\endvertex}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@AB\endvertex}{\pgfplotspointmetatransformed}%
+ %
+ %
+ \pgfplotspatchclass{\pgfplotspatchclassname}{get pdf shading type}%
+ \if 7\pgfplotsretval
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@BB\endvertex}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@CB\endvertex}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@CC\endvertex}{\pgfplotspointmetatransformed}%
+ \pgfplotslibrarysurfstreamcoord{\expandafter\pgfplotspointpatchvertex\P@BC\endvertex}{\pgfplotspointmetatransformed}%
+ \else
+ % assume 'get pdf shading type=6' - it does not contain the
+ % inner vertices.
+ \fi
+}
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.polar.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.polar.code.tex
new file mode 100644
index 0000000000..116195a909
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.polar.code.tex
@@ -0,0 +1,799 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for polar coordinates.
+%
+% Copyright 2010 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/>.
+%
+% A polar axis lives in (ANGLE,LENGTH).
+% That is
+% x == ANGLE
+% y == LENGTH
+%
+%
+
+\pgfplotsdefineaxistype[polar]{polar}{%
+ \pgfplots@polaraxis@activate
+}%
+
+\newif\ifpgfplots@polaraxis@rellimits
+
+\pgfplotsset{
+ /pgfplots/every polar axis/.style={
+ grid=major,
+ xtick pos=right,
+ ytick pos=right,
+ every axis title shift=1.2\baselineskip,
+ legend style={anchor=center},
+ /pgfplots/polar labels,
+ },
+ /pgfplots/polar labels/.code={
+ % this is equivalent to 'use units=false'. But that key is only available if the units lib is loaded.
+ \pgfplots@units@usefalse
+ \if1\b@pgfplots@polaraxis@fix@positioning
+ \pgfkeysalso{%
+ every axis x label/.style={
+ at={(xticklabel cs:0.125)},
+ sloped={at position=45},
+ anchor=near ticklabel,
+ near ticklabel at=45,
+ },
+ every axis y label/.style={
+ at={(yticklabel cs:0.5)},
+ anchor=near ticklabel,
+ },
+ }%
+ \else
+ \pgfkeysalso{%
+ % is this a good choice? No, it is not.
+ % In fact, I believe that neither xlabel nor ylabel is a good idea for a polar plot.
+ % BUT: if we simply leave the defaults, they will be placed outside of the circle - and
+ % this will confuse the units library which (for some reason) always generates labels.
+ every axis x label/.style={
+ at={(rel axis cs:0,0.5)},
+ anchor=north,
+ },
+ every axis y label/.style={
+ at={(0.2,0.85)},
+ anchor=center,
+ },
+ }%
+ \fi
+ },
+ /pgfplots/polar labels style/.style={%
+ /pgfplots/polar labels/.append style={#1}%
+ },%
+ /pgfplots/xticklabel in circle/.style={
+ xtick align=inside,
+ xticklabel style={
+ rotate=90,
+ sloped like x axis={%
+ execute for upside down={\tikzset{anchor=north east}},
+ %allow upside down,
+ reset nontranslations=false},
+ anchor=south west,
+ %font=\tiny,
+ }
+ },
+}
+
+\def\pgfplots@polaraxis@activate{%
+ % FIXME : activating it results in strange output:
+ \pgfplots@LUA@backend@supportedfalse
+ %
+ \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy
+ \let\pgfplotsqpointxy=\pgfplotsqpointxy@polaraxis
+ \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy
+ \if1\b@pgfplots@polaraxis@fix@positioning
+ % this is needed in order to let
+ % \pgfplotspointonorientedsurfaceab work
+ \def\pgfplotsqpointxyz##1##2##3{%
+ % ignore z here.
+ \pgfplotsqpointxy{##1}{##2}%
+ }%
+ \fi
+ \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@polaraxis
+ \def\pgfplotspointouternormalvectorofaxis@ifdependson@v##1##2##3{##2}%
+ \def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf##1{}%
+ \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@polaraxis
+ \let\pgfplots@handle@invalid@range@defaultlimits=\pgfplots@handle@invalid@range@defaultlimits@polar%
+ \let\pgfplots@check@invalid@range=\pgfplots@check@invalid@range@polar
+ \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@polaraxis
+ \let\pgfplots@drawgridlines@onorientedsurf@fromto=\pgfplots@drawgridlines@onorientedsurf@fromto@polar
+ \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@polar%
+ \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@polar
+ \let\pgfplotsaxisifcontainspoint=\pgfplotsaxisifcontainspoint@polar
+ \let\pgfplots@prepare@axis@API=\pgfplots@prepare@axis@API@polar
+ \def\axisdefaultheight{\axisdefaultwidth}%
+ \let\pgfplots@initsizes=\pgfplots@initsizes@polar
+ \let\pgfplots@BB@for@plotbox@get@unit@scales@for@limits=\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@polar
+ \let\pgfplots@limits@ready=\pgfplots@limits@ready@polar
+ \let\pgfplots@assign@default@tick@foraxis@normalizetickdist=\pgfplots@assign@default@tick@foraxis@normalizetickdist@polar
+ \let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@@polar
+ \let\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf=\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf@polar
+ \let\pgfplots@enlarge@limit@for=\pgfplots@enlarge@limit@for@polar
+ \let\pgfplotstransformtoaxisdirection@=\pgfplotstransformtoaxisdirection@@polar
+ \def\pgfplots@xtick@disable@last@tick{0}%
+ \let\pgfplots@xtick@check@tickshow=\pgfplots@xtick@check@tickshow@polar%
+ \let\pgfplots@set@options@sanitize=\relax
+ \let\pgfplots@set@options@sanitizemode=\relax
+ \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@polar
+ %
+ % this here is set *before* 'every polar axis' is invoked.
+ \pgfplotsset{
+ enlarge x limits=false,
+ }%
+ \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{%
+ \pgfplots@notify@options@are@set
+ \pgfplotsset{separate axis lines}%
+ }%
+ \def\pgfplots@xticklabel@pos{}%
+ \def\pgfplots@yticklabel@pos{}%
+ \def\pgfplots@zticklabel@pos{}%
+ \def\pgfplots@init@ticklabelaxisspecfor##1##2{}%
+ \def\pgfplots@init@ticklabelaxisspec@twodim@for##1##2{}%
+ \def\pgfplots@xticklabelaxisspec{v10}%
+ \def\pgfplots@yticklabelaxisspec{0v0}%
+ \def\pgfplots@zticklabelaxisspec{00v}%
+ %
+ % cartesian cs
+ \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end}%
+ %
+}%
+
+\let\pgfplots@prepare@axis@API@orig=\pgfplots@prepare@axis@API
+\def\pgfplots@prepare@axis@API@polar{%
+ \pgfplots@prepare@axis@API@orig
+ \let\pgfplotsaxisupdatelimitsforcoordinatetwodim=\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar
+ \let\pgfplotsaxisupdatelimitsforcoordinatethreedim=\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar
+}%
+
+\let\pgfplotstransformtoaxisdirection@@orig=\pgfplotstransformtoaxisdirection@
+\def\pgfplotstransformtoaxisdirection@@polar[#1]#2{%
+ \if#2y%
+ \pgfplotstransformtoaxisdirection@@orig[#1]{#2}%
+ \else
+ % ah, the angle. Treat it with special care.
+ \pgfplots@sloped@allowupsidedownfalse
+ \pgfplots@sloped@resets@nontranslationstrue
+ %
+ \def\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfqkeys{/pgfplots/sloped}{#1}%
+ \fi
+ \ifpgfplots@sloped
+ %
+ \ifpgfplots@sloped@resets@nontranslations
+ \pgftransformresetnontranslations
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/sloped/at position}\pgfplots@loc@TMPd
+ \ifx\pgfplots@loc@TMPd\pgfutil@empty
+ \def\pgfplots@loc@TMPd{90}%
+ \else
+ \pgfmathparse{90+\pgfplots@loc@TMPd}%
+ \let\pgfplots@loc@TMPd=\pgfmathresult
+ \fi
+ \pgfpointpolar{\pgfplots@loc@TMPd}{1pt}%
+ %
+ \ifdim\pgf@x<0pt%
+ % oh. upside down.
+ \pgfkeysvalueof{/pgfplots/sloped/execute for upside down}%
+ \ifpgfplots@sloped@allowupsidedown
+ \else
+ % do not allow upside down labels:
+ \global\pgf@x=-\pgf@x%
+ \global\pgf@y=-\pgf@y%
+ \fi
+ \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}%
+ \fi
+ \fi
+}
+
+\def\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar#1#2#3{%
+ %
+ %
+ % Update limits:
+ % I do not respect x limits (since they are periodic).
+ % Consequently, I do not respect the clip limits options here (I
+ % suppose it is useless)
+ %
+ % for y (radius) limits, I always use the ABSOLUTE value:
+ \pgfmathfloatabs@{#2}%
+ \let\pgfplots@loc@limit=\pgfmathresult
+ %
+ \ifpgfplots@autocompute@ymax
+ \ifpgfplots@yislinear
+ \pgfplotsmathfloatmax{\pgfplots@ymax}{\pgfplots@loc@limit}%
+ \global\let\pgfplots@ymax=\pgfmathresult
+ \else
+ \pgfplotsmathmax{\pgfplots@ymax}{\pgfplots@loc@limit}%
+ \global\let\pgfplots@ymax=\pgfmathresult
+ \fi
+ \fi
+ %
+ % Compute data range:
+ \pgfplotsmathfloatmin{\pgfplots@data@xmin}{#1}%
+ \global\let\pgfplots@data@xmin=\pgfmathresult
+ \pgfplotsmathfloatmax{\pgfplots@data@xmax}{#1}%
+ \global\let\pgfplots@data@xmax=\pgfmathresult
+ \pgfplotsmathfloatmin{\pgfplots@data@ymin}{#2}%
+ \global\let\pgfplots@data@ymin=\pgfmathresult
+ \pgfplotsmathfloatmax{\pgfplots@data@ymax}{#2}%
+ \global\let\pgfplots@data@ymax=\pgfmathresult
+%\pgfplots@message{Updated limits: (\pgfplots@xmin,\pgfplots@ymin) rectangle (\pgfplots@xmax,\pgfplots@ymax).}%
+%
+%\tracingmacros=0\tracingcommands=0
+}%
+\def\pgfplotsaxisifcontainspoint@polar#1#2{%
+ \begingroup
+ \pgfmath@basic@mod@{\pgfplots@current@point@x}{360}%
+ \pgf@xa=\pgfmathresult pt %
+ %
+ \pgf@ya=\pgfplots@current@point@y pt %
+ \ifdim\pgf@ya<0pt
+ % absolute value:
+ \pgf@ya=-\pgf@ya
+ \fi
+%\message{ifcontainspoint(\the\pgf@xa,\pgfplots@current@point@y) limits = [\pgfplots@xmin@mod:\pgfplots@xmax@mod] x [\the\pgfplots@ymin@reg,\the\pgfplots@ymax@reg]^^J}%
+ %
+ % I assume that \pgfplots@[xyz]min@reg and min@reg are registers
+ % containing the limits.
+ \pgfplots@loop@CONTINUEfalse
+ \ifdim\pgf@ya<\pgfplots@ymin@reg
+ \else
+ \ifdim\pgf@ya>\pgfplots@ymax@reg
+ \else
+ \if1\b@pgfplots@polar@limit@around@zero
+ % check condition
+ % x <= max || x >= min
+ % <=> ! (x > max && x < min)
+ \pgfplots@loop@CONTINUEtrue
+ \ifdim\pgf@xa>\pgfplots@xmax@mod pt %
+ \ifdim\pgf@xa<\pgfplots@xmin@mod pt %
+ \pgfplots@loop@CONTINUEfalse
+ \fi
+ \fi
+ \else
+ \ifdim\pgf@xa<\pgfplots@xmin@mod pt %
+ \else
+ \ifdim\pgf@xa>\pgfplots@xmax@mod pt %
+ \else
+ \pgfplots@loop@CONTINUEtrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \ifpgfplots@loop@CONTINUE
+ \def\pgfplots@loc@TMPa{#1}%
+ \else
+ \def\pgfplots@loc@TMPa{#2}%
+ \fi
+ \expandafter\endgroup\pgfplots@loc@TMPa%
+}
+
+\def\pgfplots@check@invalid@range@polar{%
+ %
+ % A polar axis allows \addplot3, but it ignores the third
+ % coordinate.
+ \pgfplots@threedimfalse
+ %
+ \pgfplots@limits@are@computedtrue
+ \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin
+ \pgfplotscoordmath{x}{zero}%
+ \let\pgfplots@xmin=\pgfmathresult
+ \fi
+ \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax
+ \pgfplotscoordmath{x}{parsenumber}{360}%
+ \let\pgfplots@xmax=\pgfmathresult
+ \fi
+ \ifx\pgfplots@ymin\pgfplots@invalidrange@ymin
+ \pgfplotscoordmath{y}{zero}%
+ \let\pgfplots@ymin=\pgfmathresult
+ \fi
+ \ifx\pgfplots@ymax\pgfplots@invalidrange@ymax
+ \pgfplots@limits@are@computedfalse
+ \fi
+ \ifpgfplots@limits@are@computed
+ \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmin
+ \global\let\pgfplots@data@xmin=\pgfplots@xmin
+ \fi
+ \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmax
+ \global\let\pgfplots@data@xmax=\pgfplots@xmax
+ \fi
+ \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymin
+ \global\let\pgfplots@data@ymin=\pgfplots@ymin
+ \fi
+ \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymax
+ \global\let\pgfplots@data@ymax=\pgfplots@ymax
+ \fi
+ \ifpgfplots@clip@limits@x
+ \else
+ % there is a rare change that min > max.
+ % Handle that ...
+ \pgfplotscoordmath{x}{min}{\pgfplots@xmin}{\pgfplots@xmax}%
+ \global\let\pgfplots@xmin=\pgfmathresult
+ \pgfplotscoordmath{x}{max}{\pgfplots@xmin}{\pgfplots@xmax}%
+ \global\let\pgfplots@xmax=\pgfmathresult
+ \fi
+ \ifpgfplots@clip@limits@y
+ \else
+ %
+ \pgfplotscoordmath{y}{min}{\pgfplots@ymin}{\pgfplots@ymax}%
+ \global\let\pgfplots@ymin=\pgfmathresult
+ \pgfplotscoordmath{y}{max}{\pgfplots@ymin}{\pgfplots@ymax}%
+ \global\let\pgfplots@ymax=\pgfmathresult
+ %
+ \fi
+ \ifpgfplots@clip@limits@z
+ \else
+ \ifpgfplots@threedim
+ \pgfplotscoordmath{z}{min}{\pgfplots@zmin}{\pgfplots@zmax}%
+ \global\let\pgfplots@zmin=\pgfmathresult
+ \pgfplotscoordmath{z}{max}{\pgfplots@zmin}{\pgfplots@zmax}%
+ \global\let\pgfplots@zmax=\pgfmathresult
+ \fi
+ \fi
+ \else
+ \pgfplots@handle@invalid@range
+ \fi
+}%
+
+\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{%
+ \pgfpointxy@orig{#1}{#2}%
+}%
+\def\pgfplotscoordmathnotifydatascalesetfor@polar#1{%
+ \def\pgfplotscoordmathnotifydatascalesetfor##1{}%
+ \edef\pgfplotscoordmathnotifydatascalesetfor@{#1}%
+ \def\pgfplotscoordmathnotifydatascalesetfor@@{x}%
+ \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@
+ \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}%
+ \else
+ \def\pgfplotscoordmathnotifydatascalesetfor@@{y}%
+ \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@
+ \pgfplotscoordmath{#1}{datascaletrafo set shift}{0}%
+ \fi
+ \fi
+ \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@polar
+}%
+
+% #1: the "a" value on the oriented surf
+% #2: the "b" value.
+% #3: the shift along the normal.
+%
+\def\pgfplotspointonorientedsurfaceabwithbshift@polaraxis#1#2#3{%
+ % implement the shift in "b" direction explicitly:
+ %
+ \pgfplotspointonorientedsurfaceab{#1}{#2}%
+ \edef\pgfplots@loc@TMPe{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ \pgfpointadd
+ {\pgfplots@loc@TMPe}%
+ {%
+ \begingroup
+ % I need a '-' here because for polaraxis axes, the "b" axis
+ % points to the *outside* instead of the inside.
+ \pgf@xa=-#3\relax
+ \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}%
+ % oh. a reversed axis.
+ \pgf@xa=-\pgf@xa
+ \fi
+ \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfqpointscale{\pgfplots@loc@TMPa}{%
+ \if x\pgfplotspointonorientedsurfaceB
+ % the angle.
+ % FIXME : datascaling!
+ % FIXME : aspect ratios!
+ \pgfmath@basic@sin@{#2}%
+ \pgf@x=-\pgfmathresult pt
+ \pgfmath@basic@cos@{#2}%
+ \pgf@y=\pgfmathresult pt
+ \else
+ % the length.
+ % FIXME : datascaling!
+ % FIXME : aspect ratios!
+ % perhaps pgfpointpolarxy?
+ \if y\pgfplotspointonorientedsurfaceB
+ \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceA\space dir/value}%
+ \pgfqpointpolar{-#1}{-1pt}%
+ \else
+ \pgfqpointpolar{#1}{1pt}%
+ \fi
+ \else
+ \pgfpointorigin
+ \fi
+ \fi
+ }%
+ }%
+}
+
+
+\def\pgfplotsqpointxy@polaraxis#1#2{%
+ \pgf@process{%
+ \pgfplotsmathpoltocartbasic{#1}{#2}\x\y
+ \pgfqpointxy@orig\x\y
+%\message{pgfplotsqpointxy{#1}{#2} ---> (\x,\y) ---> (\the\pgf@x,\the\pgf@y)}%
+ }%
+}%
+\def\pgfplots@clippath@prepare@for@axistype@polaraxis{%
+ \def\pgfplots@clippath@install##1{%
+ \pgfpathmoveto
+ {\pgfplotsqpointxy\pgfplots@xmin\pgfplots@ymax}%
+ \pgfpatharcaxes{\pgfplots@xmin}{\pgfplots@xmax}
+ {\pgfqpointxy@orig{\pgfplots@ymax}{0}}%
+ {\pgfqpointxy@orig{0}{\pgfplots@ymax}}%
+ \if1\pgfplots@xtick@disable@last@tick
+ % we have min angle = max angle.
+ \ifdim\pgfplots@ymin pt=0pt
+ \else
+ \pgfseteorule
+ \pgfpathmoveto
+ {\pgfplotsqpointxy\pgfplots@xmin\pgfplots@ymin}%
+ \pgfpatharcaxes{\pgfplots@xmin}{\pgfplots@xmax}
+ {\pgfqpointxy@orig{\pgfplots@ymin}{0}}%
+ {\pgfqpointxy@orig{0}{\pgfplots@ymin}}%
+ \fi
+ \else
+ % we have min angle != max angle.
+ \ifdim\pgfplots@ymin pt=0pt
+ % Ok, then pass through origin:
+ \pgfpathlineto\pgfplotspointaxisorigin
+ \else
+ % complicated special case.
+ \pgfpathlineto
+ {\pgfplotsqpointxy\pgfplots@xmax\pgfplots@ymin}%
+ \pgfpatharcaxes{\pgfplots@xmax}{\pgfplots@xmin}
+ {\pgfqpointxy@orig{\pgfplots@ymin}{0}}%
+ {\pgfqpointxy@orig{0}{\pgfplots@ymin}}%
+ \fi
+ \pgfpathclose
+ \fi
+ \pgfplots@clippath@use@{##1}%
+ }%
+}%
+
+\def\pgfplotspointouternormalvectorofaxis@polaraxis#1#2#3\relax{%
+ \if v#1%
+ % ah, we want to find the outer normal for an ANGLE.
+ %
+ % That's tricky because we need the current value! What if we
+ % do not have one?
+ \pgfplotspointouternormalvectorofaxisgetv{#1#2#3}%
+ % in direction of the length.
+ \ifx\pgfplotsretval\pgfutil@empty
+ \pgfplotswarning{missing near ticklabel at}{}\pgfeov%
+ % oh, what a mess. We do not know the angle!
+ % this means the alignment will be wrong (most likely...)
+ \def\pgfplotsretval{0}%
+ \fi
+ % FIXME : datascaling!
+ % FIXME : aspect ratios!
+ % perhaps pgfpointpolarxy?
+ \if r\pgfkeysvalueof{/pgfplots/x dir/value}%
+ \pgfqpointpolar{-\pgfplotsretval}{-1pt}%
+ \else
+ \pgfqpointpolar{\pgfplotsretval}{1pt}%
+ \fi
+ \else
+ \if v#2%
+ \if#10%
+ \def\pgfplotsretval{\pgfplots@xmin}%
+ \else
+ \def\pgfplotsretval{\pgfplots@xmax}%
+ \fi
+ % in direction of the angle.
+ % FIXME : datascaling!
+ % FIXME : aspect ratios!
+ \pgfmath@basic@sin@{\pgfplotsretval}%
+ \pgf@x=-\pgfmathresult pt
+ \pgfmath@basic@cos@{\pgfplotsretval}%
+ \pgf@y=\pgfmathresult pt
+ \else
+ \pgfqpoint{0pt}{1pt}%
+ \fi
+ \fi
+ %\pgf@process{\pgfpointnormalised{}}%
+ \pgf@process{}%
+ \endgroup
+}%
+
+\def\pgfplotspoint@initialisation@axes@polar{%
+ %
+ \begingroup
+ \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}%
+ \xdef\pgfplotspointminminmin{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}%
+ \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
+ %
+ % the length of the "angle" axis is 2*pi*r .
+ % The radius, however, is the length of (0,ymax) which is (0pt,\pgf@xx*ymax):
+ \pgfmath@basic@multiply@{\pgf@sys@tonumber\pgf@xx}{\pgfplots@ymax}%
+ \pgfmathmultiply@{\pgfmathresult}{6.28318530717959}% 2*pi * r
+ \if0\pgfplots@xtick@disable@last@tick
+ % oh: minangle != maxangle. We have a partial circle.
+ % compute the arc length (<360 deg)
+ \pgf@xa=\pgfplots@xmax pt
+ \advance\pgf@xa by-\pgfplots@xmin pt
+ \divide\pgf@xa by360
+ \ifdim\pgf@xa<1pt
+ \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xa}%
+ \pgfmathmultiply@{\pgfmathresult}{\pgfplots@loc@TMPa}%
+ \fi
+ \fi
+ \xdef\pgfplotspointxaxislength{\pgfmathresult pt}%
+ %
+ \pgfpointdiff
+ {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}%
+ {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}%
+ \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}%
+ %
+ \global\let\pgfplotspointzaxis=\pgfpointorigin
+ \gdef\pgfplotspointzaxislength{0pt}%
+ \endgroup
+ %
+}
+\let\pgfplotspoint@initialisation@units@orig=\pgfplotspoint@initialisation@units
+\def\pgfplotspoint@initialisation@units@polar{%
+ \def\pgfplotspointunitx{%
+ \pgfplotspointouternormalvectorofaxisgetv{v10}% angle varying, radius at outer pos
+ \ifx\pgfplotsretval\pgfutil@empty
+ \def\pgfplotsretval{0}%
+ \fi
+ \if r\pgfkeysvalueof{/pgfplots/x dir/value}%
+ \edef\pgfplotsretval{-\pgfplotsretval}%
+ \fi
+ \pgfmath@basic@sin@{\pgfplotsretval}%
+ \pgf@x=-\pgfmathresult pt
+ \pgfmath@basic@cos@{\pgfplotsretval}%
+ \pgf@y=\pgfmathresult pt
+ }%
+ \def\pgfplotsunitxlength{1}%
+ \def\pgfplotsunitxinvlength{1}%
+ %
+ \def\pgfplotspointunity{%
+ % FIXME : what about 'x dir=reverse' !?
+ \pgfqpointpolar{\pgfplots@xmin}{1pt}%
+ }%
+ \def\pgfplotsunitylength{1}%
+ \def\pgfplotsunityinvlength{1}%
+}%
+
+\def\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf@polar#1#2{%
+ \if v#1%
+ \let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceA%
+ \if v#2%
+ \pgfplots@error{Exactly one of '#1' or '#2' must be 'v', not both}%
+ \fi
+ \else
+ \if v#2%
+ \let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceB%
+ \else
+ \pgfplots@error{One of '#1' or '#2' must be 'v'}%
+ \fi
+ \fi
+ %
+ \if x\pgfplots@loc@TMPa
+ \else
+ \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf@orig{#1}{#2}%
+ \fi
+}%
+\def\pgfplots@drawgridlines@onorientedsurf@fromto@polar#1{%
+ \if x\pgfplotspointonorientedsurfaceA
+ \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}%
+ \else
+ \if y\pgfplotspointonorientedsurfaceA\relax
+ \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}%
+ \pgf@x=#1\pgf@xx
+ \pgf@y=#1\pgf@yy
+ \edef\pgfplots@loc@TMPa{\the\pgf@x\space and \the\pgf@y}%
+ \def\pgfplots@loc@TMPb{\pgfpatharc{\pgfplots@xmin}{\pgfplots@xmax}}%
+ \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}%
+ \else
+ \fi
+ \fi
+}%
+
+\let\pgfplots@initsizes@original=\pgfplots@initsizes
+
+\def\pgfplots@initsizes@polar{%
+ % I copy-pasted most of this code, up to just one position where
+ % I introduced the modified scaling for polar axes
+ %----------------------------------
+ % INIT.
+ %
+ %
+ \pgfmath@basic@mod@{\pgfplots@xmin}{360}%
+ \let\pgfplots@xmin@mod=\pgfmathresult
+ \pgfmath@basic@mod@{\pgfplots@xmax}{360}%
+ \let\pgfplots@xmax@mod=\pgfmathresult
+ \ifdim\pgfplots@xmax@mod pt>\pgfplots@xmin@mod pt
+ \def\b@pgfplots@polar@limit@around@zero{0}%
+ \else
+ \def\b@pgfplots@polar@limit@around@zero{1}%
+ \fi
+ %
+ \pgfplots@initsizes@original
+}%
+
+\def\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@polar#1#2#3{%
+ % #1 is the angle ... and that does not need to be squeezed into
+ % the box.
+ %
+ % use only y (the radius).
+ \if1\b@pgfplots@plotbox@yisunit
+ % we do not need to compute max-min as for standard axes (because the inner part
+ % characterized by ymin does not enter the scaling).
+ %
+ % However, we have to keep in mind that our range is TWICE as
+ % large because [0,ymax] is just a radius, and we have to
+ % scale for the diameter.
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{2}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ %
+ \let\pgfmathresult=\pgfplots@ymax
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{\pgfmathresult}%
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{op}{multiply}{{\pgfmathresult}{\pgfplots@loc@TMPa}}%
+ \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{tofixed}{\pgfmathresult}%
+ \else
+ \def\pgfmathresult{2}% not 1: the factor 2 is for 2*radius
+ \fi
+ \let#1=\pgfmathresult
+ \let#2=\pgfmathresult
+ \def#3{1}% FIXME : z ?
+}%
+
+\def\pgfplots@handle@invalid@range@defaultlimits@polar{%
+ \def\pgfplots@loc@TMPa{0}%
+ \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin
+ \def\pgfplots@loc@TMPa{1}%
+ \fi
+ \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax
+ \def\pgfplots@loc@TMPa{1}%
+ \fi
+ \if\pgfplots@loc@TMPa1%
+ \pgfplotscoordmath{x}{parsenumber}{0}%
+ \global\let\pgfplots@xmin=\pgfmathresult
+ \pgfplotscoordmath{x}{parsenumber}{360}%
+ \global\let\pgfplots@xmax=\pgfmathresult
+ \global\let\pgfplots@data@xmin=\pgfplots@xmin
+ \global\let\pgfplots@data@xmax=\pgfplots@xmax
+ \fi
+ %
+ \pgfplotscoordmath{y}{parsenumber}{0}%
+ \global\let\pgfplots@ymin=\pgfmathresult
+ \pgfplotscoordmath{y}{parsenumber}{1}%
+ \global\let\pgfplots@ymax=\pgfmathresult
+ \global\let\pgfplots@data@ymin=\pgfplots@ymin
+ \global\let\pgfplots@data@ymax=\pgfplots@ymax
+}
+
+\let\pgfplots@show@ticklabel@@orig=\pgfplots@show@ticklabel@
+\def\pgfplots@show@ticklabel@@polar#1#2{%
+ \def\pgfmathresult{#2}%
+ \if#1x%
+ \ifdim#2pt>360pt
+ \pgfmath@basic@mod@{#2}{360}%
+ \fi
+ \fi
+ \def\pgfplots@loc@TMPa{\pgfplots@show@ticklabel@@orig{#1}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
+}%
+
+\let\pgfplots@xtick@check@tickshow@orig=\pgfplots@xtick@check@tickshow%
+\def\pgfplots@xtick@check@tickshow@polar{%
+ \if1\pgfplots@xtick@disable@last@tick
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfplots@tmpa}{\pgfplots@xmax pt}
+ {\pgfplots@loc@tick@placement@tolerance}
+ {%
+ \pgfplots@tickshowfalse
+ }{%
+ \pgfplots@xtick@check@tickshow@orig
+ }%
+ \else
+ \pgfplots@xtick@check@tickshow@orig
+ \fi
+}
+
+\let\pgfplots@enlarge@limit@for@orig=\pgfplots@enlarge@limit@for
+\def\pgfplots@enlarge@limit@for@polar#1{%
+ \if#1x%
+ % ignore 'enlarge x limits' (degrees).
+ \else
+ % allow 'enlarge y limits', but only for UPPER radius
+ \def\bool@pgfplots@loc@enlargelimits@min{0}%
+ \pgfplots@enlarge@limit@for@orig{#1}%
+ \fi
+}%
+
+\let\pgfplots@assign@default@tick@foraxis@normalizetickdist@orig=\pgfplots@assign@default@tick@foraxis@normalizetickdist
+\def\pgfplots@assign@default@tick@foraxis@normalizetickdist@polar#1#2{%
+ \if#1x%
+ % special handling for the angles:
+ \begingroup
+ \pgfmathfloattofixed{#2}%
+ \let\H=\pgf@xb
+ \H=\pgfmathresult pt
+ % only allow step sizes of
+ % 90, 45, 30, 15, 10, 5.
+ %
+ % Prefer the LARGER step size during the snap-to-nearest.
+ % The following decision boundaries are heuristics and have no
+ % mathematical foundation.
+ \ifdim\H>67pt
+ \H=90pt
+ \else
+ \ifdim\H>30pt
+ \H=45pt
+ \else
+ \ifdim\H>18pt
+ \H=30pt
+ \else
+ \ifdim\H>10pt
+ \H=15pt
+ \else
+ \ifdim\H>6pt
+ \H=10pt
+ \else
+ \H=5pt
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\H}%
+ \pgfmathfloatparsenumber{\pgfplots@loc@TMPa}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \else
+ \pgfplots@assign@default@tick@foraxis@normalizetickdist@orig{#1}{#2}%
+ \fi
+}%
+
+\let\pgfplots@limits@ready@orig=\pgfplots@limits@ready
+\def\pgfplots@limits@ready@polar{%
+ \pgfplots@limits@ready@orig
+ %
+ % Avoid tick labels at upper *and* lower angle range if both are the
+ % same:
+ \pgfmath@basic@subtract@{\pgfplots@xmax}{\pgfplots@xmin}%
+ \pgfmath@basic@mod@{\pgfmathresult}{360}%
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfmathresult pt}{0pt}%
+ {0.002pt}
+ {%
+ \def\pgfplots@xtick@disable@last@tick{1}%
+ }{%
+ }%
+ %
+}%
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.smithchart.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.smithchart.code.tex
new file mode 100644
index 0000000000..611b12bbba
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.smithchart.code.tex
@@ -0,0 +1,1678 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for smith charts.
+%
+% Copyright 2010 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/>.
+%
+% A smithchart maps the complex halfplane
+% H subset \C,
+% H := [0,infty] x [-infty,infty]
+% =~ \{ z = a+ j *b | a >=0, b \in \R }
+%
+% to the unit circle.
+%
+% A number z = a+jb is mapped to r(z) = (z-1) / (z+1) which is, per
+% definition, in the 2d unit circle.
+%
+% Grid lines (i.e. a==const or b==const) are mapped on circles.
+%
+% In PGFPlots, the a=Re(z) is the x axis and b = Im(z) is the y axis.
+%
+% - CARTESIAN INPUT
+% - tick/grid coordinates are from
+% - input coordinates can be either from H or (perhaps preferred) from
+% the unit circle.
+% this "preferred" needs to be discussed.
+% - the transformed data range is the unit circle (or a sequeezed variant)
+% - in order to compute limits etc., I should accept data in H. this
+% should simplify the logic to determine ticks etc considerably.
+% problem: this transformation appears to be quite difficult (?)
+% -> r(z) = (z-1)/(z+1)
+% in complex arithmetics (but the G-tutorial.pdf says something
+% about these circle equations!?)
+%
+% www.amanogawa.com/archive/docs/G-tutorial.pdf
+%
+%
+% Idea:
+% - work on H
+% - transform whereever necessary
+% - implement all pgfplots wrinkles in analogy to polar axes
+% - provide support for normalized input coords (combined with
+% untransformed limits or something like that)
+
+\pgfplotsdefineaxistype{smithchart}{%
+ \pgfplots@smithchartaxis@activate
+}%
+
+\newif\ifpgfplotspointisinsmithchartCS
+\newif\ifpgfplots@smithchart@showorigin
+\newif\ifpgfplots@smithchart@mirrored
+
+\pgfplotsset{
+ /pgfplots/xgrid each nth passes y/.initial=,% format: CSV list, each entry of the form '<at> | <at> ':' <eachnth> | <at> 'if <' <xvalue> | <at> ':' <eachnth> 'if <' <xvalue>'
+ /pgfplots/xgrid each nth passes y start/.initial=0,
+ /pgfplots/ygrid each nth passes x/.initial=,
+ /pgfplots/ygrid each nth passes x start/.initial=0,
+ %
+ /pgfplots/xgrid stop at y/.initial=,% individual stop map of the form '<xpos> ':' <stopaty>', separated by white space
+ /pgfplots/ygrid stop at x/.initial=,
+ %
+ % FIXME : this is undocumented:
+ /pgfplots/smithchart mirrored/.is if=pgfplots@smithchart@mirrored,
+ /pgfplots/smithchart mirrored/.default=true,
+ %
+ % this boolean may only be used inside of \addplot. It will be
+ % ignored otherwise.
+ /pgfplots/is smithchart cs/.is if=pgfplotspointisinsmithchartCS,
+ /pgfplots/is smithchart cs/.default=true,
+ /pgfplots/show origin/.is if=pgfplots@smithchart@showorigin,
+ /pgfplots/show origin/.default=true,
+ /pgfplots/show origin code/.code={%
+ \path[draw=black,fill=white] (0pt,0pt) circle (2.5pt);
+ \path[fill=black] (0pt,0pt) circle (0.5pt);
+ },
+ /pgfplots/every smithchart axis/.style={
+ grid=both,
+ xmin=0,
+ xmax=16000,% FIXME : more is not possible because some code uses the \pgfplots@xmin@reg registers... (ticks)
+ ymin=-16000,ymax=16000,
+ scaled ticks=false, % never draw the \cdot 10^4 labels
+ major tick style={draw=black},
+ xtick align=center,
+ ytick align=center,
+ every axis title shift=1.2\baselineskip,
+ legend style={anchor=center},
+ },
+ /pgfplots/default smithchart xtick/.code=,
+ /pgfplots/default smithchart ytick/.code=,
+ /pgfplots/default smithchart xytick/.code=,
+ /pgfplots/smithchart ticks by size/.code 2 args={%
+ \ifdim#1<14cm
+ \pgfkeysalso{/pgfplots/few smithchart ticks}%
+ \else
+ \ifdim#1<20cm
+ \pgfkeysalso{/pgfplots/many smithchart ticks}%
+ \else
+ \pgfkeysalso{/pgfplots/dense smithchart ticks}%
+ \fi
+ \fi
+ },
+ /pgfplots/few smithchart ticks*/.style={
+ default smithchart xtick/.style={
+ xtick={0.2,0.5,1,2,5},
+ },
+ default smithchart ytick/.style={
+ ytick={%
+ 0,%
+ 0.2, 0.5, 1, 2, 5,%
+ -0.2,-0.5,-1,-2,-5},
+ },
+ default smithchart xytick/.style={
+ xgrid each nth passes y={2},
+ ygrid each nth passes x={2},
+ },
+ },
+ /pgfplots/few smithchart ticks/.style={/pgfplots/few smithchart ticks*},
+ /pgfplots/few smithchart ticks*,% use it as initial config
+ /pgfplots/many smithchart ticks*/.style={
+ default smithchart xtick/.style={
+ xtick={
+ 0.1,0.2,0.3,0.4,0.5,1,1.5,2,3,4,5,10,20%
+ },
+ minor xtick={0.6,0.7,0.8,0.9,1.1,1.2,1.3,1.4,1.6,1.7,1.8,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50},
+ },
+ default smithchart ytick/.style={
+ ytick={%
+ 0,%
+ 0.1,0.2,...,1,1.5,2,3,4,5,10,20,%
+ -0.1,-0.2,...,-1,-1.5,-2,-3,-4,-5,-10,-20%
+ },
+ minor ytick={%
+ 1.1,1.2,1.3,1.4,1.6,1.7,1.8,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50,%
+ -1.1,-1.2,-1.3,-1.4,-1.6,-1.7,-1.8,-1.9,-2.2,-2.4,-2.6,-2.8,-3.2,-3.4,-3.6,-3.8,-4.5,-6,-7,-8,-9,-50%
+ },
+ },
+ default smithchart xytick/.style={
+ xgrid each nth passes y={1,2,4,5,10,20},
+ ygrid each nth passes x={1,2,3,5,10:3,20:3},
+ },
+ },
+ /pgfplots/many smithchart ticks/.style={
+ many smithchart ticks*,
+ every axis title shift=6pt,
+ yticklabel in circle,
+ show origin=true,
+ },
+ /pgfplots/dense smithchart ticks*/.style={
+ default smithchart xtick/.style={
+ %ygrid each nth passes x start=0,
+ xtick={
+ 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.2,1.4,1.6,1.8,2,3,4,5,10,20%
+ },
+ minor xtick={%
+ 0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,%
+ 0.22,0.24,0.26,0.28,0.32,0.34,0.36,0.38,0.42,0.44,0.46,0.48,%
+ 0.52,%
+ 0.55,0.65,0.75,0.85,0.95,%
+ %0.6,0.7,0.8,0.9,%
+ 1.1,1.3,1.5,1.7,1.9,%
+ 2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50},
+ },
+ default smithchart ytick/.style={
+ ytick={%
+ 0,%
+ 0.1,0.2,...,1,1.2,1.4,1.6,1.8,2,3,4,5,10,20,%
+ -0.1,-0.2,...,-1,-1.2,-1.4,-1.6,-1.8,-2,-3,-4,-5,-10,-20%
+ },
+ minor ytick={%
+ 0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,%
+ 0.22,0.24,0.26,0.28,0.32,0.34,0.36,0.38,0.42,0.44,0.46,0.48,%
+ 0.55,0.65,0.75,0.85,0.95,%
+ 1.1,1.3,1.5,1.7,1.9,2.2,2.4,2.6,2.8,3.2,3.4,3.6,3.8,4.5,6,7,8,9,50,%
+ -0.01,-0.02,-0.03,-0.04,-0.05,-0.06,-0.07,-0.08,-0.09,-0.11,-0.12,-0.13,-0.14,-0.15,-0.16,-0.17,-0.18,-0.19,%
+ -0.22,-0.24,-0.26,-0.28,-0.32,-0.34,-0.36,-0.38,-0.42,-0.44,-0.46,-0.48,%
+ -0.55,-0.65,-0.75,-0.85,-0.95,%
+ -1.1,-1.3,-1.5,-1.7,-1.9,-2.2,-2.4,-2.6,-2.8,-3.2,-3.4,-3.6,-3.8,-4.5,-6,-7,-8,-9,-50%
+ },
+ },
+ default smithchart xytick/.style={
+ xgrid each nth passes y={0.2 if < 0.2001,0.5 if < 0.50001,1 if < 1.001,2,4,5,10,20},
+ ygrid each nth passes x={0.2 if < 0.2001,0.52 if < 0.52001,1 if < 1.001,2,3,5,10:3,20:3},
+ },
+ },
+ /pgfplots/dense smithchart ticks/.style={
+ yticklabel in circle,
+ every axis title shift=6pt,
+ dense smithchart ticks*,
+ show origin=true,
+ every major grid/.style={black!60},
+ },
+ /pgfplots/yticklabel in circle/.style={
+ ytick align=inside,
+ yticklabel style={
+ rotate=90,
+ sloped like y axis={%
+ execute for upside down={\tikzset{anchor=north east}},
+ %allow upside down,
+ reset nontranslations=false},
+ anchor=south west,
+ %font=\tiny,
+ }
+ },
+ yticklabel around circle/.style={
+ ytick align=center,
+ yticklabel style={
+ rotate=90,
+ sloped like y axis={%
+ execute for upside down={\tikzset{anchor=south west}},
+ %allow upside down,
+ reset nontranslations=false},
+ anchor=south east,
+ %font=\tiny,
+ }
+ },
+ yticklabel around circle*/.style={
+ ytick align=center,
+ yticklabel style={
+ rotate=90,
+ sloped like y axis={%
+ execute for upside down={\tikzset{anchor=north west}},
+ %allow upside down,
+ reset nontranslations=false},
+ anchor=north east,
+ %font=\tiny,
+ }
+ }
+}
+
+\pgfkeys{
+ /pgfplots/warning/smithchart/no such tick/.code 2 args={%
+ \pgfplotsthrow@warning{There is no #1tick with index '#2'. Skipping it.}%
+ },
+}
+
+\def\pgfplots@smithchartaxis@activate{%
+ \def\axisdefaultwidth{207pt}%
+ \def\axisdefaultheight{207pt}%
+ \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy
+ \let\pgfplotsqpointxy=\pgfplotsqpointxy@smithchartaxis
+ \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy
+ \def\pgfplotsqpointxyz##1##2##3{\pgfplotsqpointxy{##1}{##2}}% FIXME
+ \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@smithchartaxis
+ \def\pgfplotspointouternormalvectorofaxis@ifdependson@v##1##2##3{##2}%
+ \def\pgfplots@drawticklines@INSTALLCLIP@onorientedsurf##1{}%
+ \let\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf=\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf@smithchartaxis
+ \def\pgfplots@visphase@notify@changeofcanvaslimits##1{}%
+ \def\pgfplots@avoid@empty@axis@range@for##1{}%
+ \def\pgfplotsaxisifcontainspoint##1##2{##1}%
+ \let\pgfplots@set@default@size@options=\pgfplots@set@default@size@options@smithchart%
+ %
+ \def\b@pgfplots@smithchart@defaultticks@x{0}%
+ \def\b@pgfplots@smithchart@defaultticks@y{0}%
+ \let\pgfplots@assign@default@tick@foraxis=\pgfplots@assign@default@tick@foraxis@smithchart
+ \def\pgfplots@checkisuniformLINEARtick##1##2{%
+ % don't do anything here. I suppose it is useless and is a
+ % waste of time for many ticks.
+ \global\pgfplots@isuniformtickfalse
+ }%
+ \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@smithchartaxis
+ %
+ % invalid range: do not clear plots. simply assign default limits.
+ \let\pgfplots@handle@invalid@range@defaultlimits=\pgfplots@handle@invalid@range@defaultlimits@smithchart%
+ \def\pgfplots@handle@invalid@range{\pgfplots@handle@invalid@range@defaultlimits}%
+ %
+ \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@smithchartaxis
+ \let\pgfplots@draw@axis@is@prepared=\pgfplots@draw@axis@is@prepared@smithchartaxis
+ \let\pgfplots@drawgridlines@onorientedsurf@fromto=\pgfplots@drawgridlines@onorientedsurf@fromto@smithchart
+ \let\pgfplots@drawaxis@innerlines@onorientedsurf=\pgfplots@drawaxis@innerlines@onorientedsurf@smithchart
+ \let\pgfplots@drawaxis@outerlines@separate@onorientedsurf=\pgfplots@drawaxis@outerlines@separate@onorientedsurf@smithchartaxis
+ \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@smithchart%
+ \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@smithchart
+ \expandafter\def\expandafter\pgfplots@create@axis@descriptions@\expandafter{%
+ \pgfplots@create@axis@descriptions@
+ \ifpgfplots@smithchart@showorigin
+ \pgfkeysvalueof{/pgfplots/show origin code/.@cmd}\pgfeov%
+ \fi
+ }%
+ \def\axisdefaultheight{\axisdefaultwidth}%
+ \let\pgfplots@BB@for@plotbox@get@unit@scales@for@limits=\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@smithchart
+ %\let\pgfplots@limits@ready=\pgfplots@limits@ready@smithchart
+ %\let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@@smithchart
+ %\def\pgfplots@xtick@disable@last@tick{0}%
+ \let\pgfplots@xtick@check@tickshow=\pgfplots@xtick@check@tickshow@smithchart%
+ \let\pgfplots@ytick@check@tickshow=\pgfplots@ytick@check@tickshow@smithchart%
+ \let\pgfplots@set@options@sanitize=\relax
+ \let\pgfplots@set@options@sanitizemode=\relax
+ \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@smithchart
+ %
+ \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{%
+ \pgfplots@notify@options@are@set
+ \pgfplotsset{%
+ separate axis lines,%
+ is smithchart cs=false,%
+ xtick pos=left,
+ ytick pos=left,
+ axis x line*=center,
+ disabledatascaling,
+ }%
+ \def\pgfplots@xtickposnum{2}%
+ %
+ \ifx\pgfplots@xtick\pgfutil@empty
+ \def\b@pgfplots@smithchart@defaultticks@x{1}%
+ \fi
+ \ifx\pgfplots@ytick\pgfutil@empty
+ \def\b@pgfplots@smithchart@defaultticks@y{1}%
+ \fi
+ \pgfplotscoordmath{default}{parsenumber}{0.002}%
+ \let\pgfplots@almost@zero@thresh=\pgfmathresult
+ }%
+ \def\pgfplots@xticklabel@pos{}%
+ \def\pgfplots@yticklabel@pos{}%
+ \def\pgfplots@zticklabel@pos{}%
+ \def\pgfplots@init@ticklabelaxisspecfor##1##2{}%
+ \def\pgfplots@init@ticklabelaxisspec@twodim@for##1##2{}%
+ \def\pgfplotspointonorientedsurfaceabmatchaxisline@warn##1{}% clear warning. It works for smith charts.
+ \def\pgfplots@xticklabelaxisspec{v20}%
+ \def\pgfplots@yticklabelaxisspec{0v0}%
+ \def\pgfplots@zticklabelaxisspec{00v}%
+ %
+ % cartesian cs
+ \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end}%
+ %
+ %
+ % Special treatment for
+ % \pgfplots@prepare@tick@coordlists@for: make sure we don't need
+ % to use the register arithmetics in \pgfplots@xmin@reg and its
+ % variants! I want an UNRESTRICTED max data range!
+ \def\pgfplots@prepare@tick@coordlists@for@assign##1=##2{\edef##1{##2}}%
+ \def\pgfplots@prepare@tick@coordlists@for@advance##1by##2{%
+ % THIS IS NEVER USED (at the time of this writing).
+ \edef\pgfplots@loc@TMPa{##2}%
+ \pgfplotscoordmath{default}{parsenumber}{##1}%
+ \pgfplotscoordmath{default}{op}{add}{{\pgfmathresult}{\pgfplots@loc@TMPa}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let##1=\pgfmathresult
+ }%
+ \def\pgfplots@prepare@tick@coordlists@for@tofixed##1{\edef\pgfmathresult{##1}}%
+ \def\pgfplots@prepare@tick@coordlists@for@handletolerance##1{}% does not apply to smithcharts.
+ \def\pgfplots@prepare@tick@coordlists@for@checktickmin##1{%
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tmpa}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@##1tickmin\endcsname}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscoordmath{default}{if less than}{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{%
+ \pgfplots@tickshowfalse
+ }{%
+ }%
+ }%
+ \def\pgfplots@prepare@tick@coordlists@for@checktickmax##1{%
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tmpa}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@##1tickmin\endcsname}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplotscoordmath{default}{if less than}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPa}{%
+ \pgfplots@tickshowfalse
+ }{%
+ }%
+ }%
+ \def\pgfplots@prepare@tick@coordlists@for@checkdatalimits##1{}% I won't do this here. Smithcharts are somewhat special.
+}%
+
+\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{%
+ \pgfpointxy@orig{#1}{#2}%
+}%
+\def\pgfplotscoordmathnotifydatascalesetfor@smithchart#1{%
+ \def\pgfplotscoordmathnotifydatascalesetfor##1{}%
+ \edef\pgfplotscoordmathnotifydatascalesetfor@{#1}%
+ \def\pgfplotscoordmathnotifydatascalesetfor@@{x}%
+ \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@
+ \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}%
+ \else
+ \def\pgfplotscoordmathnotifydatascalesetfor@@{y}%
+ \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@
+ \pgfplotscoordmath{#1}{datascaletrafo set shift}{0}%
+ \fi
+ \fi
+ \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@smithchart
+}%
+
+% #1: the "a" value on the oriented surf
+% #2: the "b" value.
+% #3: the shift along the normal.
+%
+\def\pgfplotspointonorientedsurfaceabwithbshift@smithchartaxis#1#2#3{%
+ % implement the shift in "b" direction explicitly:
+ \pgfpointadd
+ {\pgfplotspointonorientedsurfaceab{#1}{#2}}%
+ {%
+ \pgfplotspointonorientedsurfaceabtolinespec{v}{0}%
+ \afterassignment\pgfplots@gobble@until@relax
+ \pgf@xa=-#3\relax
+ \edef\pgfplots@shift@no@unit{\pgf@sys@tonumber\pgf@xa}%
+ \pgfqpointscale
+ {\pgfplots@shift@no@unit}
+ {\expandafter\pgfplotspointouternormalvectorofaxis\expandafter{\pgfplotsretval}}%
+ }%
+}
+
+
+% Computes the complex division
+% (A + j B) / (C + j D) = (A C + B D + j (B C - A D) ) / (C^2 + D^2)
+% and assigns the result to \pgfmathresult and \pgfmathresultim . Here
+% 'j = sqrt{-1}' is the imaginary unit.
+%
+% #1 : A
+% #2 : B
+% #3 : C
+% #4 : D
+%
+% The arithmetics is performed in \pgfplotscoordmath{default} (which
+% uses the floating point unit in the initial configuration)
+%
+% Numbers are expected to be already parsed (i.e. you need to invoke
+% \pgfplotscoordmath{default}{parsenumber}{#1}%
+% \let\A=\pgfmathresult
+% before)
+\def\pgfplotscoordmathcomplexdivision#1#2#3#4{%
+ \begingroup
+ \edef\pgfplots@A{#1}%
+ \edef\pgfplots@B{#2}%
+ \edef\pgfplots@C{#3}%
+ \edef\pgfplots@D{#4}%
+ %
+ %
+ % ok, compute it:
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@A}{\pgfplots@C}}%
+ \let\pgfplots@AC=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@A}{\pgfplots@D}}%
+ \let\pgfplots@AD=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@B}{\pgfplots@D}}%
+ \let\pgfplots@BD=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@B}{\pgfplots@C}}%
+ \let\pgfplots@BC=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@C}{\pgfplots@C}}%
+ \let\pgfplots@CC=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@D}{\pgfplots@D}}%
+ \let\pgfplots@DD=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@CC}{\pgfplots@DD}}%
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}%
+ \let\pgfplots@scale=\pgfmathresult
+ %
+ %
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@AC}{\pgfplots@BD}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@scale}}%
+ \let\pgfplots@x=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@BC}{\pgfplots@AD}}%
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@scale}}%
+ \let\pgfplots@y=\pgfmathresult
+ %
+ \xdef\pgfplots@glob@TMPa{%
+ \noexpand\def\noexpand\pgfmathresult{\pgfplots@x}%
+ \noexpand\def\noexpand\pgfmathresultim{\pgfplots@y}%
+ }%
+ \endgroup
+ \pgfplots@glob@TMPa
+}%
+
+\def\pgfplotsqpointxy@smithchartaxis#1#2{%
+ \pgf@process{%
+ \ifpgfplotspointisinsmithchartCS
+ \def\pgfplots@x{#1}%
+ \def\pgfplots@y{#2}%
+ \else
+ % compute rx + j* ry = (#1 + j * #2 -1) / (#1 + j*#2 + 1)
+ %
+ % I write
+ % #1 - 1 + j * #2 = A + j * B
+ % 1 + #1 + j * #2 = C + j * D
+ %
+ % -> rx + j * ry = (A + j B) / (C + j D) = (A C + B D + j (B C - A D) ) / (C^2 + D^2)
+ \pgfplotscoordmath{default}{parsenumber}{#1}%
+ \let\pgfplots@x=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{parsenumber}{#2}%
+ \let\pgfplots@D=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{one}%
+ \let\pgfplots@one=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@one}{\pgfplots@x}}%
+ \let\pgfplots@C=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@x}{\pgfplots@one}}%
+ \let\pgfplots@A=\pgfmathresult
+ %
+ \let\pgfplots@B=\pgfplots@D
+ %
+ \pgfplotscoordmathcomplexdivision\pgfplots@A\pgfplots@B\pgfplots@C\pgfplots@D
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@x=\pgfmathresult
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresultim}%
+ \let\pgfplots@y=\pgfmathresult
+ \fi
+ %
+ \pgfplotsqpointxy@smithchart@canvas\pgfplots@x\pgfplots@y
+%\message{pgfplotsqpointxy{#1}{#2} ---> (\pgfplots@x,\pgfplots@y) ---> (\the\pgf@x,\the\pgf@y)}%
+ }%
+}%
+
+\def\pgfplotsqpointxy@smithchart@canvas#1#2{%
+ \ifpgfplots@smithchart@mirrored
+ \pgfqpointxy@orig{-#1}{#2}%
+ \else
+ \pgfqpointxy@orig{#1}{#2}%
+ \fi
+}%
+
+\def\pgfplots@clippath@prepare@for@axistype@smithchartaxis{%
+ \def\pgfplots@clippath@install##1{%
+ \pgfpathellipse
+ {\pgfplotsqpointxy@smithchart@canvas{0}{0}}
+ {\pgfplotsqpointxy@smithchart@canvas{1}{0}}
+ {\pgfplotsqpointxy@smithchart@canvas{0}{1}}%
+ \pgfplots@clippath@use@{##1}%
+ }%
+}%
+
+\def\pgfplotspointouternormalvectorofaxis@smithchartaxis#1#2#3\relax{%
+ \if v#1%
+ \pgfqpoint{0pt}{1pt}%
+ \else
+ \if v#2%
+ \pgfplotspointouternormalvectorofaxisgetv{#1#2#3}%
+ \ifx\pgfplotsretval\pgfutil@empty
+ \def\pgfplotsretval{0}%
+ \fi
+ \pgfpointdiff
+ {\pgfplotsqpointxy@smithchart@canvas{0}{0}}%
+ {\pgfplotsqpointxy{0}{\pgfplotsretval}}%
+ \pgfpointnormalised{}%
+ \else
+ \pgfqpoint{0pt}{1pt}%
+ \fi
+ \fi
+ \pgf@process{}%
+ \endgroup
+}%
+
+\def\pgfplotspoint@initialisation@axes@smithchart{%
+ \begingroup
+ %\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}%
+ \gdef\pgfplotspointminminmin{\pgfplotsqpointxy@smithchart@canvas{0}{0}}%
+ %
+ % the "x" axis is the diameter of the circle (for fixed y=0)
+ \pgf@x=2\pgf@xx
+ \pgf@y=0pt
+ \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}%
+ %
+ \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}%
+ \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
+ %
+ % the length of the "y" axis is 2*pi*r (for fixed x=0, the outer
+ % circle).
+ % The radius is the length of (0,1) which is (0pt,\pgf@xx1):
+ \pgfmath@basic@multiply@{\pgf@sys@tonumber\pgf@xx}{1}%
+ \pgfmathmultiply@{\pgfmathresult}{6.28318530717959}% 2*pi * r
+ \xdef\pgfplotspointyaxislength{\pgfmathresult pt}%
+ %
+ \global\let\pgfplotspointzaxis=\pgfpointorigin
+ \gdef\pgfplotspointzaxislength{0pt}%
+ \endgroup
+ %
+ \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xx}%
+ \pgfmathdivide@{16000}{\pgfplots@loc@TMPa}%
+ \let\pgfplots@smithchart@axis@max@xradius@for@ycircle=\pgfmathresult
+ %
+ \ifdim\pgf@xx=\pgf@yy
+ \def\pgfplots@smithchart@axis@ratioxy{1}%
+ \def\pgfplots@smithchart@axis@ratioyx{1}%
+ \let\pgfplots@smithchart@axis@max@yradius@for@ycircle=\pgfplots@smithchart@axis@max@xradius@for@ycircle
+ \else
+ \edef\pgfplots@loc@TMPb{\pgf@sys@tonumber\pgf@yy}%
+ \pgfmathdivide@\pgfplots@loc@TMPa\pgfplots@loc@TMPb
+ \let\pgfplots@smithchart@axis@ratioxy=\pgfmathresult
+ \pgfmathdivide@\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \let\pgfplots@smithchart@axis@ratioyx=\pgfmathresult
+ %
+ \pgfmathdivide@{16000}{\pgfplots@loc@TMPb}%
+ \let\pgfplots@smithchart@axis@max@yradius@for@ycircle=\pgfmathresult
+ \fi
+}
+\let\pgfplotspoint@initialisation@units@orig=\pgfplotspoint@initialisation@units
+\def\pgfplotspoint@initialisation@units@smithchart{%
+ \pgfplotspoint@initialisation@units@orig
+ \def\pgfplotspointunity{%
+ \pgfplotspointouternormalvectorofaxisgetv{0v0}% x=0 (outer circle) and v varies (the yticks)
+ \ifx\pgfplotsretval\pgfutil@empty
+ \def\pgfplotsretval{0}%
+ \fi
+ \pgfpointnormalised{\pgfplotsqpointxy{0}{\ifx\pgfplotsretval\pgfutil@empty 0\else\pgfplotsretval\fi}}%
+ \pgf@xa=-\pgf@y
+ \global\pgf@y=\pgf@x
+ \global\pgf@x=\pgf@xa
+ }%
+ \def\pgfplotsunitylength{1}%
+ \def\pgfplotsunityinvlength{1}%
+}%
+
+\def\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf@smithchartaxis#1{%
+ %\pgfplots@clippath@install{\pgfusepath{clip}}%
+}%
+
+% At this time, the minor/major tick lists are initialised.
+\def\pgfplots@draw@axis@is@prepared@smithchartaxis{%
+ \pgfplots@gridlines@init@grid@stop@points@for xy%
+ \pgfplots@gridlines@init@grid@stop@points@for yx%
+ %
+ % and finalize x:
+ \def\pgfplots@finalize@constraints{1}%
+ \pgfplots@gridlines@init@grid@stop@points@for@computethem{x}{y}{\pgfplots@finalize@constraints}%
+}%
+
+
+% Initialises the '#1grid each nth passes #2' and '#1grid stop at #2'
+% features. All it does is to prepare the
+% method \pgfplots@get@current@grid@stop@point.
+%
+% The method is quite involved. Please refer to the manual for what it
+% is supposed to do, and refer to the code comments below for
+% implementational details.
+%
+% #1 either x or y
+% #2 either x or y
+\def\pgfplots@gridlines@init@grid@stop@points@for#1#2{%
+ %
+ \expandafter\let\csname pgfplots@#1grid@stop@points\endcsname=\relax
+ %
+ \pgfkeysgetvalue{/pgfplots/#1grid each nth passes #2}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ % we have no "xticknum -> xtickpos" lookup table yet.
+ \expandafter\def\csname b@pgfplots@#2ticknum@to@pos@lookup\endcsname{0}%
+ %
+ \pgfplotslistnewempty\pgfplots@loc@TMPd
+ % normalise the argument for 'ygrid each nth passes x': each list element
+ % should be of the form '<xtickpos>:<n>' where <n> means that each
+ % <n>th arc can pass.
+ \expandafter\pgfplotsutilforeachcommasep\pgfplots@loc@TMPa\as\entry{%
+ \expandafter\pgfplots@gridlines@init@grid@stop@points@for@normalise\entry\relax#1#2%
+ \expandafter\pgfplotslistpushback\entry\to\pgfplots@loc@TMPd
+ }%
+ \expandafter\let\csname pgfplots@#1grid@stop@points\endcsname=\pgfplots@loc@TMPd
+ %
+ % Ok.
+ %
+ % Now, the 'ygrid each nth passes x' feature relies *crucially* on grid line
+ % indices (for the 'each nth' feature).
+ %
+ % I sort the arcs according to their absolute magnitude and assign
+ % indices into the resulting arrays to normalize that stuff.
+ %
+ % The array is of the form
+ % A[i] = entry of \pgfplots@prepared@tick@positions@*
+ % and contains *both*, major and minor grid lines.
+ \pgfplotsarraynewempty\pgfplots@gridlines
+ \pgfplotscoordmath{default}{zero}%
+ \edef\elem{{-1}{\pgfmathresult}}% require 0 to be zero for symmetry even if there is no such tick pos
+ \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines
+ \pgfplots@if{pgfplots@#1majorgrids}{%
+ % insert all major tick positions, using their absolute value.
+ \expandafter
+ \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#1\endcsname\as\elem{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\elem
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}%
+ \pgfplotscoordmath{default}{op}{abs}{{\pgfmathresult}}%
+ \edef\elem{{\pgfplots@ticknum}{\pgfmathresult}}%
+ \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines
+ }%
+ }{}%
+ \pgfplots@if{pgfplots@#1minorgrids}{%
+ % now the same for minor grid positions:
+ \expandafter
+ \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#1\endcsname\as\elem{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\elem
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}%
+ \pgfplotscoordmath{default}{op}{abs}{{\pgfmathresult}}%
+ \edef\elem{{\pgfplots@ticknum}{\pgfmathresult}}%
+ \expandafter\pgfplotsarraypushback\elem\to\pgfplots@gridlines
+ }%
+ }{}%
+ % sort the array!
+ \pgfkeysgetvalue{/pgfplots/smithchart@sortlt/.@cmd}\pgfplots@loc@TMPa
+ \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplots@loc@TMPa
+ \pgfplotsarraysort\pgfplots@gridlines
+ %
+ % ok. Now it is sorted.
+ %
+ % I finally need a lookup
+ % \pgfplots@ticknum --> sort index.
+ % If the associated values have the same absolute value, the same
+ % sort index should be assigned.
+ %
+ % For example, the array might be associated to the following tick
+ % positions, sorted by absolute value:
+ % 0.0, 1.0, -1.0, 3.0, -3.0, 4.0, -4.0, 5.0, -5.0
+ % What I want is that
+ % 0.0 gets sort index 0
+ % 1.0 and -1.0 get sort index 1
+ % 3.0 and -3.0 get sort index 2
+ % 4.0 and -4.0 get sort index 3
+ % and so on. The array contains only absolute values, so that's
+ % not too difficult to check.
+ %
+ % Since each of the tick positions can be (uniquely) identified by
+ % its associated \pgfplots@ticknum value, I map \pgfplots@ticknum
+ % to the sort index.
+ \countdef\c@sortindex=\c@pgf@counta
+ \c@sortindex=\pgfkeysvalueof{/pgfplots/#1grid each nth passes #2 start} % this is assigned to the '0.0' gridline (if any)
+ \def\pgfplots@lasttickpos{}%
+ \pgfplotsarrayforeachungrouped\pgfplots@gridlines\as\elem{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\elem
+ \ifx\pgfplots@lasttickpos\pgfutil@empty
+ \else
+ \ifx\pgfplots@lasttickpos\pgfplots@tick
+ \else
+ \advance\c@sortindex by1
+ \fi
+ \fi
+ \expandafter\edef\csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname{\the\c@sortindex}%
+%\message{\pgfplots@ticknum\space(abs(tickpos) = \pgfplots@tick)---> sort index \csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname^^J}%
+ \let\pgfplots@lasttickpos=\pgfplots@tick
+ }%
+ %
+ % unfortunately, I can't free the \pgfplots@gridlines array
+ % without extensive overhead :-(
+ \fi
+ %
+ \expandafter\let\csname b@pgfplots@#1gridline@stopmap\endcsname\relax
+ \pgfkeysgetvalue{/pgfplots/#1grid stop at #2}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa,}% this inserts the final comma and handles any active ':' sign (for french babel)
+ \def\pgfplots@loc@TMPb{\pgfplots@gridlines@init@stop@maps #1#2}%
+ \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI%
+ \fi
+ %
+ %
+ % Now, compute all final stop positions. Also prepare the cross
+ % dependencies between x grids and y grids here (such that there
+ % is no grid line stopping in white space)
+ %
+ \if#1x%
+ \def\pgfplots@finalize@constraints{0}% we have to wait until y stop points are known.
+ \else
+ \def\pgfplots@finalize@constraints{1}%
+ \fi
+ \pgfplots@gridlines@init@grid@stop@points@for@computethem{#1}{#2}{\pgfplots@finalize@constraints}%
+}%
+% #1,#2,#3 the arguments for
+% \pgfplots@gridlines@preparation@get@current@grid@stop@point
+\def\pgfplots@gridlines@init@grid@stop@points@for@computethem#1#2#3{%
+ %
+ \expandafter\pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#1\endcsname\as\elem{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\elem
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}\let\pgfplots@tick=\pgfmathresult
+ \pgfplots@gridlines@preparation@get@current@grid@stop@point{#1}{#2}{\pgfplots@tick}{#3}%
+ \if1#3%
+ \pgfplots@gridlines@let{#1}{\pgfplots@tick@prepared}=\pgfplotsretval
+ \fi
+ }%
+ \expandafter\pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#1\endcsname\as\elem{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\elem
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@tick}\let\pgfplots@tick=\pgfmathresult
+ \pgfplots@gridlines@preparation@get@current@grid@stop@point{#1}{#2}{\pgfplots@tick}{#3}%
+ \if1#3%
+ \pgfplots@gridlines@let{#1}{\pgfplots@tick@prepared}=\pgfplotsretval
+ \fi
+ }%
+ \expandafter\def\csname b@pgfplots@#1gridline@stopmap\endcsname{1}%
+}
+
+\def\pgfplots@gridlines@init@stop@maps#1#2{%
+ \pgfutil@ifnextchar\pgfplots@EOI{%
+ \pgfutil@gobble
+ }{%
+ \pgfutil@ifnextchar,{%
+ \pgfplots@gridlines@init@stop@maps@next@@#1#2%
+ }{%
+ \pgfplots@gridlines@init@stop@maps@next#1#2%
+ }%
+ }%
+}%
+\def\pgfplots@gridlines@init@stop@maps@next#1#2#3:#4,{%
+ \pgfplotscoordmath{default}{parsenumber}{#4}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplots@gridlines@stopmap@prepare{#3}%
+ \pgfplots@gridlines@let{#1}{\pgfmathresult}=\pgfplots@loc@TMPa
+ \expandafter\def\csname b@pgfplots@#1gridline@stopmap\endcsname{1}%
+ %
+ \pgfplots@gridlines@init@stop@maps #1#2%
+}
+% just eat one empty comma:
+\def\pgfplots@gridlines@init@stop@maps@next@@#1#2,{\pgfplots@gridlines@init@stop@maps #1#2}%
+\def\pgfplots@gridlines@let#1#2=#3{%
+ \expandafter\let\csname pgfplots@#1gridline@stopmap@#2\endcsname=#3%
+ \if#1y%
+ % support symmetry:
+ % add -\pgfmathresult to the map.
+ % To disable this symmetry, use 'ygrid stop at x={0.2:4 -0.2:5}
+ % you can also use an empty value '-0.2:{}', that's also ok.
+ \expandafter\let\csname pgfplots@#1gridline@stopmap@-#2\endcsname=#3%
+ \fi
+}%
+
+\def\pgfplots@gridlines@stopmap@prepare@digits{2}%
+\def\pgfplots@gridlines@stopmap@prepare#1{%
+ \begingroup
+ \pgfmathfloatparsenumber{#1}%
+ \let\pgfmathfloat@round@precision=\pgfplots@gridlines@stopmap@prepare@digits%
+ \pgfmathfloatroundzerofill\pgfmathresult
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+\def\pgfplots@gridlines@stopmap@trunc@#1.#2#3#4\relax{%
+ \def\pgfmathresult{#1.#2#3}%
+}%
+
+\pgfkeysdefargs{/pgfplots/smithchart@sortlt}{#1#2#3#4}{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack#1%
+ \let\pgfplots@A=\pgfplots@tick
+ \expandafter\pgfplots@prepared@tick@pos@unpack#2%
+ \let\pgfplots@B=\pgfplots@tick
+ \pgfplotscoordmath{default}{if less than}{\pgfplots@A}{\pgfplots@B}{#3}{#4}%
+}%
+
+% initialise a lookuptable from ticknumber -> tick position (sort
+% of an array)
+%
+% This is only invoked if it is needed (if 'arc
+% limits={[index]4,[index]2}' or something like that is used, see the
+% manual).
+%
+% #1 either x or y
+% #2 either x or y
+\def\pgfplots@gridlines@init@grid@stop@points@for@init@ticknum@lookup#1#2{%
+ \c@pgf@counta=0
+ \pgfplots@if{pgfplots@#1majorgrids}{%
+ \expandafter
+ \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@major@#2\endcsname\as\elem{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\elem
+ \expandafter\let\csname pgfplots@#2tick@num@to@pos@\the\c@pgf@counta\endcsname=\pgfplots@tick
+ \advance\c@pgf@counta by1
+ }%
+ }{}%
+ \pgfplots@if{pgfplots@#1minorgrids}{%
+ \expandafter
+ \pgfplotslistforeachungrouped\csname pgfplots@prepared@tick@positions@minor@#2\endcsname\as\elem{%
+ \expandafter\pgfplots@prepared@tick@pos@unpack\elem
+ \expandafter\let\csname pgfplots@#2tick@num@to@pos@\the\c@pgf@counta\endcsname=\pgfplots@tick
+ \advance\c@pgf@counta by1
+ }%
+ }{}%
+ \expandafter\def\csname b@pgfplots@#2ticknum@to@pos@lookup\endcsname{1}%
+}%
+\def\pgfplots@gridlines@init@grid@stop@points@for@normalise#1\relax#2#3{%
+ \def\b@pgfplots@haslt{0}%
+ %
+ \pgfutil@in@{if <}{#1}%
+ \ifpgfutil@in@
+ % strip the white space between 'if' and '<':
+ \def\pgfplots@loc@TMPa##1if <##2\relax{\edef\entry{##1if<##2}}%
+ \expandafter\pgfplots@loc@TMPa\entry\relax
+ \def\b@pgfplots@haslt{1}%
+ \fi
+ %
+ \pgfutil@in@{if<}{#1}%
+ \ifpgfutil@in@
+ \def\b@pgfplots@haslt{1}%
+ \fi
+ %
+ \pgfutil@in@:{#1}%
+ \ifpgfutil@in@
+ \def\b@pgfplots@hascolon{1}%
+ \else
+ \def\b@pgfplots@hascolon{0}%
+ \fi
+ %
+ \if1\b@pgfplots@hascolon
+ \edef\entry{\entry\if0\b@pgfplots@haslt if<\fi}%
+ \else
+ \if1\b@pgfplots@haslt
+ \expandafter\pgfplots@gridlines@stop@at@unpack@@@\entry\relax
+ \edef\entry{\pgfplots@grid@stop@at:2if<\pgfplots@grid@stop@at@iflt}%
+ \else
+ \edef\entry{\entry:2if<}%
+ \fi%
+ \fi%
+ %
+ \pgfutil@in@{[index]}{#1}%
+ \ifpgfutil@in@
+ \if0\csname b@pgfplots@#3ticknum@to@pos@lookup\endcsname
+ \pgfplots@gridlines@init@grid@stop@points@for@init@ticknum@lookup#2#3%
+ \fi
+ \expandafter\pgfplots@gridlines@stop@at@unpack\entry\relax
+ \pgfutil@ifundefined{pgfplots@#3tick@num@to@pos@\pgfplots@grid@stop@at}{%
+ \pgfplotswarning{smithchart/no such tick}{#3}{\pgfplots@grid@stop@at}\pgfeov
+ \let\entry=\pgfutil@empty
+ }{%
+ \edef\entry{\csname pgfplots@#3tick@num@to@pos@\pgfplots@grid@stop@at\endcsname:\pgfplots@grid@stop@at@eachnth}%
+ }%
+ \fi
+ %
+ \expandafter\pgfplots@gridlines@stop@at@unpack\entry\relax
+ \pgfplotscoordmath{default}{parsenumber}\pgfplots@grid@stop@at
+ \let\pgfplots@grid@stop@at=\pgfmathresult
+ \ifx\pgfplots@grid@stop@at@iflt\pgfutil@empty
+ \else
+ \pgfplotscoordmath{default}{parsenumber}\pgfplots@grid@stop@at@iflt
+ \let\pgfplots@grid@stop@at@iflt=\pgfmathresult
+ \fi
+ \edef\entry{\pgfplots@grid@stop@at:\pgfplots@grid@stop@at@eachnth if<\pgfplots@grid@stop@at@iflt}%
+}%
+\def\pgfplots@gridlines@stop@at@unpack@@@#1if<#2\relax{%
+ \def\pgfplots@grid@stop@at{#1}%
+ \def\pgfplots@grid@stop@at@iflt{#2}%
+}%
+\def\pgfplots@gridlines@stop@at@unpack#1:#2if<#3\relax{%
+ \def\pgfplots@grid@stop@at{#1}%
+ \def\pgfplots@grid@stop@at@eachnth{#2}%
+ \def\pgfplots@grid@stop@at@iflt{#3}%
+}%
+
+% Returns the xtick position which should end the current arc.
+%
+% This is an INTERNAL preparation method. See
+% \pgfplots@get@current@grid@stop@point for the final one.
+%
+% Note that arcs correspond to ygrid lines.
+%
+% #1 either x or y
+% #2 either x or y
+% #3 the value of the current grid line
+% #4 a boolean which expands either to 0 or to 1.
+% The \pgfplots@get@current@grid@stop@point@handle@constraints method
+% will be invoked if and only if #4=1
+%
+% @POSTCONDITION On output,
+% - \pgfplotsretval will be filled with the
+% result. If the result is empty, no restriction is imposed.
+% Otherwise, it contains the #2tick value at which the current #1grid shall end.
+% The result is already processed with
+% \pgfplotscoordmath{default}{parsenumber}{<value>}
+% - \pgfplots@tick@prepared contains a rounded representation of #3.
+%
+% The method relies on the 'ygrid each nth passes x' feature, more specifically the
+% stuff prepared by \pgfplots@gridlines@init@grid@stop@points@for
+\def\pgfplots@gridlines@preparation@get@current@grid@stop@point#1#2#3#4{%
+ \def\pgfplotsretval{}%
+ %
+ \pgfplots@gridlines@stopmap@prepare{#3}%
+ \let\pgfplots@tick@prepared=\pgfmathresult
+ \pgfmathfloatabs@\pgfplots@tick@prepared
+ \let\pgfplots@tick@prepared@abs=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{op}{abs}{{#3}}%
+ \let\pgfplots@tick@abs=\pgfmathresult
+ %
+ % first: check the '#1grid stop at #2':
+ \expandafter\ifx\csname b@pgfplots@#1gridline@stopmap\endcsname\relax%
+ % ok. there is no such thing.
+ \else
+ % ah - process it!
+ \pgfutil@ifundefined{pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared}{%
+ }{%
+ \edef\pgfplotsretval{\csname pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared\endcsname}%
+ }%
+ \fi
+ %
+ \ifx\pgfplotsretval\pgfutil@empty
+ % the individual map failed. Ok, then check for the '#1grid each nth passes #2'
+ \expandafter\ifx\csname pgfplots@#1grid@stop@points\endcsname\relax
+ \else
+ % \pgfplots@ticknum is defined in this context here.
+ \pgfutil@ifundefined{pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum}{%
+ \pgfplots@warning{Sorry, I can't get the current arc limit for #1grid no \#\pgfplots@ticknum\space(value \pgfplots@tick). This seems like an internal error!?}%
+ }{%
+ % get the sort index for the current tick (which is
+ % uniquely identified by its \pgfplots@ticknum)
+ \expandafter\let\expandafter\pgfplots@k\csname pgfplots@#1tickpos@to@sortidx@\pgfplots@ticknum\endcsname
+ %
+ \expandafter\pgfplotslistforeachungrouped\csname pgfplots@#1grid@stop@points\endcsname\as\pgfplots@loc@TMPa{%
+ \ifx\pgfplotsretval\pgfutil@empty
+ % we found no final limit so far. proceed.
+ \expandafter\pgfplots@gridlines@stop@at@unpack\pgfplots@loc@TMPa\relax
+ \ifx\pgfplots@grid@stop@at@iflt\pgfutil@empty
+ \pgfplots@loop@CONTINUEtrue
+ \else
+ \pgfplotscoordmath{default}{if less than}{\pgfplots@tick@abs}{\pgfplots@grid@stop@at@iflt}{%
+ \pgfplots@loop@CONTINUEtrue
+ }{%
+ \pgfplots@loop@CONTINUEfalse
+ }%
+ \fi
+ %
+ \ifpgfplots@loop@CONTINUE
+ \pgfplotsmathmodint\pgfplots@k\pgfplots@grid@stop@at@eachnth
+ \ifnum\pgfmathresult=0
+ \c@pgf@counta=\pgfplots@k
+ \divide\c@pgf@counta by\pgfplots@grid@stop@at@eachnth\relax
+ \edef\pgfplots@k{\the\c@pgf@counta}%
+ \else
+ % found the final limit.
+ %
+ % Now, check the constraints which couple
+ % X and Y.
+ \let\pgfplotsretval=\pgfplots@grid@stop@at
+ \if1#4%
+ \pgfplots@get@current@grid@stop@point@handle@constraints #1#2{#3}%
+ \fi
+ \fi
+ \fi
+ \fi
+ }%
+ }%
+ \fi
+ \fi
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \expandafter\let\csname pgfplots@final@stop@point@for@#1tick@\pgfplots@tick@prepared\endcsname=\pgfplotsretval
+%\message{#1 grid line: storing end value for '#3' END[\pgfplots@tick@prepared] = \pgfplotsretval.^^J}%
+ \fi
+}%
+
+% PRECONDITION
+% \pgfplotsretval contains a non-zero constraint for the ygrid at #1.
+%
+% POSTCONDITION
+% either \pgfplotsretval is unchanged, or it is reset to
+% \pgfutil@empty if constraints are violated.
+%
+% The constraints are ONLY effective if BOTH, incomplete x- and y grid
+% lines are in effect. In that case, it should never happen that a
+% single grid line ends in a dead-end somewhere in white space.
+%
+% I enforce two constraints which apply only to ygrid to fix this
+% issue (this may be improved later).
+%
+% The idea is simple:
+% 1. suppose the grid line 'x=1' stops at 'y=5'.
+% Suppose further that the y grid line 'y=0.95' should stop at 'x=1'.
+% Is that acceptable? Yes, because |y| < 5.
+% Now, suppose an y grid line with |y| > 5 should stop at 'x=1'.
+% Is this allowed? NO! Because it would become a dead end since
+% the 'x=1' line ends at 'y=5'!
+%
+% So, whenever we consider ygrids and stop point candidates "x=X",
+% acquire the value Q where the x (!) grid line "x=X" stops.
+% If |y| > Q, the candidate "x=X" is rejected.
+%
+% 2. There might still be the case that x grid lines have dead-ends.
+% The current solution applies the idea first to all y grid lines,
+% and once the y grid lines are ready, it applies the same idea to
+% x grid lines.
+%
+% Uncomment the routine(s) and run the test cases to see what happens.
+\def\pgfplots@get@current@grid@stop@point@handle@constraints#1#2#3{%
+ \ifx\pgfplotsretval\pgfutil@empty
+ \else
+ \pgfplots@gridlines@stopmap@prepare{\pgfplotsretval}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ %
+%\message{checking ending '#1=#3' at '#2=\pgfplotsretval'. '#2=\pgfplots@loc@TMPa' stops}%
+ \pgfutil@ifundefined{pgfplots@final@stop@point@for@#2tick@\pgfplots@loc@TMPa}{%
+ % no constraint. Ok.
+%\message{ nowhere. No constraint.^^J}%
+ }{%
+%\message{ at \pgfplots@loc@TMPa. Feasible: }%
+ % Oh, a constraint. That means
+ % further work.
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@final@stop@point@for@#2tick@\pgfmathresult\endcsname
+ \pgfplotscoordmath{default}{op}{abs}{{#3}}%
+ \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@loc@TMPa}{%
+ % ok, we can use the found
+ % stop value.
+%\message{YES.^^J}%
+ }{%
+%\message{NO.^^J}%
+ % no, the stop value is
+ % invalid; it would stop in
+ % white space!
+ \let\pgfplotsretval=\pgfutil@empty
+ }%
+ }%
+ \fi
+}%
+
+% Returns the xtick position which should end the current arc.
+%
+% Note that arcs correspond to ygrid lines.
+%
+% #1 either x or y
+% #2 either x or y
+% #3 the value of the current grid line
+%
+% @POSTCONDITION On output, \pgfplotsretval will be filled with the
+% result. If the result is empty, no restriction is imposed.
+% Otherwise, it contains the #2tick value at which the current #1grid shall end.
+% The result is already processed with
+% \pgfplotscoordmath{default}{parsenumber}{<value>}
+%
+% The method relies on the 'ygrid each nth passes x' feature, more specifically the
+% stuff prepared by \pgfplots@gridlines@init@grid@stop@points@for
+%
+% Note that all work has already been done by
+% \pgfplots@gridlines@init@grid@stop@points@for. We only need to query
+% the result at this point.
+% @see \pgfplots@gridlines@init@grid@stop@points@for
+% @see \pgfplots@gridlines@preparation@get@current@grid@stop@point
+\def\pgfplots@get@current@grid@stop@point#1#2#3{%
+ \def\pgfplotsretval{}%
+ %
+ % check the '#1grid stop at #2':
+ \expandafter\ifx\csname b@pgfplots@#1gridline@stopmap\endcsname\relax%
+ % ok. there is no such thing.
+ \else
+ %
+ \pgfplots@gridlines@stopmap@prepare{#3}%
+ \let\pgfplots@tick@prepared=\pgfmathresult
+ \pgfmathfloatabs@\pgfplots@tick@prepared
+ \let\pgfplots@tick@prepared@abs=\pgfmathresult
+ %
+ % ah - process it!
+ \pgfutil@ifundefined{pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared}{%
+ \let\pgfplotsretval\pgfutil@empty
+ }{%
+ \edef\pgfplotsretval{\csname pgfplots@#1gridline@stopmap@\pgfplots@tick@prepared\endcsname}%
+ }%
+ \fi
+ %
+}%
+
+
+\def\pgfplots@smithchart@draw@xcircle#1{%
+ \pgfplotscoordmath{default}{one}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{parsenumber}{#1}%
+ \let\pgfplots@x=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@loc@TMPa}{\pgfplots@x}}%
+ \let\pgfplots@radius@inverse=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}%
+ \let\pgfplots@radius=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfplots@x}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@center=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@radius}%
+ \let\pgfplots@radius=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@radius@inverse}%
+ \let\pgfplots@radius@inverse=\pgfmathresult
+ %
+ % This here would suffice in case 'xgrid each nth passes y={}':
+% \pgfpathellipse
+% {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@center}{0}}
+% {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@radius}{0}}
+% {\pgfplotsqpointxy@smithchart@canvas{0}{\pgfplots@radius}}%
+ %
+ % but we also check for the 'xgrid each nth passes y' feature:
+ \pgfplots@get@current@grid@stop@point xy{\pgfplots@x}%
+ \let\pgfplots@arc@ends@at@y@arc@value\pgfplotsretval%
+ %
+ \ifx\pgfplots@arc@ends@at@y@arc@value\pgfutil@empty
+ % Ok. There is no specific end point -- simply use the
+ % (1,0) point (i.e. draw the full circle).
+ %
+ \pgfmathadd@{\pgfplots@center}{\pgfplots@radius}%
+ \let\pgfplots@start=\pgfmathresult%
+ \def\pgfplots@startim{0}%
+ \def\pgfplots@startangle{0}%
+ \let\pgfplots@end=\pgfplots@start
+ \let\pgfplots@endim=\pgfplots@startim
+ \def\pgfplots@endangle{360}%
+ \else
+ % Ok. The arc should end before it reaches the (1,0)
+ % point. Determine the exact position and the
+ % corresponding arc end angle.
+ %
+ % In general, the intersection between the circle for
+ % fixed x=A and fixed y=B is given by
+ %
+ % p + j * q = (A + j * B -1 ) / ( A + j*B +1)
+ % see http://www.siart.de/lehre/tutorien.xhtml#smishort
+ \pgfplotscoordmath{default}{one}%
+ \let\pgfplots@one=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{-1}%
+ \let\pgfplots@mone=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@x}{\pgfplots@mone}}%
+ \let\pgfplots@A@mone=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@x}{\pgfplots@one}}%
+ \let\pgfplots@A@one=\pgfmathresult
+ % oh - we should only draw a partial arc.
+ % Well, then compute its end point and the
+ % corresponding end angle.
+ \pgfplotscoordmathcomplexdivision
+ {\pgfplots@A@mone}{\pgfplots@arc@ends@at@y@arc@value}%
+ {\pgfplots@A@one}{\pgfplots@arc@ends@at@y@arc@value}%
+ \let\pgfplots@start=\pgfmathresult
+ \let\pgfplots@startim=\pgfmathresultim
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@start}%
+ \let\pgfplots@start=\pgfmathresult
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@startim}%
+ \let\pgfplots@startim=\pgfmathresult
+ %
+ \pgfplots@compute@angle@of@point@in@circle\pgfplots@start\pgfplots@startim{\pgfplots@center}{\pgfplots@radius}{\pgfplots@radius@inverse}%
+ \let\pgfplots@startangle=\pgfmathresult
+ \pgfmathsubtract@{360}{\pgfplots@startangle}%
+ \let\pgfplots@endangle=\pgfmathresult
+ \let\pgfplots@end=\pgfplots@start
+ \edef\pgfplots@endim{-\pgfplots@startim}%
+ \ifdim\pgfplots@startangle pt>\pgfplots@endangle pt
+ \let\pgfplots@loc@TMPa=\pgfplots@startangle
+ \let\pgfplots@startangle=\pgfplots@endangle
+ \let\pgfplots@endangle=\pgfplots@loc@TMPa
+ \fi
+ \fi
+ %
+%\message{X grid line \#\csname pgfplots@ticknum\endcsname \space at '#1': center = (\pgfplots@center,0); radius = \pgfplots@radius\space(start angle \pgfplots@startangle, end angle = \pgfplots@endangle; stops at y = \pgfplots@arc@ends@at@y@arc@value).^^J}%
+ %
+ % Now, compute the arc.
+ %
+ % first, compute the absolute x/y radii:
+ \pgf@xa=\pgfplots@radius\pgf@xx
+ \pgf@xb=\pgfplots@radius\pgf@yy
+ \edef\pgfplots@mirror@sign{\ifpgfplots@smithchart@mirrored -\fi}%
+ \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{\pgfplots@start}{\pgfplots@startim}}%
+ % note that the case startangle > endangle is
+ % automatically correct; patharc handles that.
+ %\edef\pgfplots@loc@TMPa{{\pgfplots@startangle}{\pgfplots@endangle}{\pgfplots@mirror@sign\the\pgf@xa\space and \the\pgf@xb}}%
+ %\expandafter\pgfpatharc\pgfplots@loc@TMPa
+ %
+ % prefer \pgfpatharctoprecomputed. It is faster and more accurate
+ \edef\pgfplots@loc@TMPa{%
+ {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@center}{0}}%
+ {\pgfplots@startangle}%
+ {\pgfplots@endangle}%
+ {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@end}{\pgfplots@endim}}%
+ {\pgfplots@mirror@sign\the\pgf@xa}%
+ {\the\pgf@xb}%
+ {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioxy}%
+ {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioyx}%
+ }%
+ \expandafter\pgfpatharctoprecomputed\pgfplots@loc@TMPa
+}
+
+\def\pgfplots@smithchart@draw@yarc#1{%
+ \pgfplotscoordmath{default}{parsenumber}{#1}%
+ \let\pgfplots@y\pgfmathresult
+ \pgfplotscoordmath{default}{op}{abs}{{\pgfplots@y}}%
+ \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@almost@zero@thresh}{%
+ \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{-1}{0}}%
+ \pgfpathlineto{\pgfplotsqpointxy@smithchart@canvas{1}{0}}%
+ }{%
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplots@y}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@signedradius=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@y}%
+ \ifdim\pgfplots@signedradius pt<0pt
+ \def\pgfplots@radius@sign{-}%
+ \edef\pgfplots@radius@inverse{-\pgfmathresult}%
+ \edef\pgfplots@radius{-\pgfplots@signedradius}%
+ \else
+ \def\pgfplots@radius@sign{}%
+ \edef\pgfplots@radius@inverse{\pgfmathresult}%
+ \let\pgfplots@radius=\pgfplots@signedradius
+ \fi
+ % this here is the correct, complete circle -- together
+ % with a clip path, you get what you want:
+ %\pgfpathellipse
+ % {\pgfplotsqpointxy@smithchart@canvas{1}{\pgfplots@signedradius}}
+ % {\pgfplotsqpointxy@smithchart@canvas{\pgfplots@signedradius}{0}}
+ % {\pgfplotsqpointxy@smithchart@canvas{0}{\pgfplots@signedradius}}%
+ % But I only want the arc (probably stopped earlier to
+ % improve qualtity of the chart)
+ %
+ % compute start point for the arc.
+ %
+ % To do so, we need to compute the intersection between
+ % the circle for fixed x=0 and the circle for y=#1.
+ %
+ % In general, the intersection between the circle for
+ % fixed x=A and fixed y=B is given by
+ %
+ % p + j * q = (A + j * B -1 ) / ( A + j*B +1)
+ % see http://www.siart.de/lehre/tutorien.xhtml#smishort
+ %
+ % inserting A = 0 and B = #1 yields the result
+ % p=\pgfplots@start
+ % q=\pgfplots@startim
+ % as follows:
+ \pgfplotscoordmath{default}{one}%
+ \let\pgfplots@one=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{-1}%
+ \let\pgfplots@mone=\pgfmathresult
+ \pgfplotscoordmathcomplexdivision{\pgfplots@mone}{\pgfplots@y}{\pgfplots@one}{\pgfplots@y}%
+ \let\pgfplots@start=\pgfmathresult
+ \let\pgfplots@startim=\pgfmathresultim
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@start}%
+ \let\pgfplots@start=\pgfmathresult
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@startim}%
+ \let\pgfplots@startim=\pgfmathresult
+ %
+ \pgfplots@compute@angle@of@point@in@circle\pgfplots@start\pgfplots@startim{1}{\pgfplots@signedradius}{\pgfplots@radius@inverse}%
+ \let\pgfplots@startangle=\pgfmathresult
+ %
+ %
+ % compute end angle.
+ \pgfplots@get@current@grid@stop@point yx{\pgfplots@y}%
+ \let\pgfplots@arc@ends@at@x@circle@value\pgfplotsretval%
+ %
+ \ifx\pgfplots@arc@ends@at@x@circle@value\pgfutil@empty
+ % Ok. There is no specific end point -- simply use the
+ % (1,0) point (i.e. draw the full arc).
+ %
+ % The "0 degree" angle in my circles is in the direction
+ % of (1,0) .
+ \ifdim\pgfplots@startim pt>0pt
+ % ok; this arc belongs to the upper hemisphere.
+ \def\pgfplots@endangle{270}%
+ \else
+ % ok; this arc belongs to the lower hemisphere.
+ \def\pgfplots@endangle{90}%
+ \fi
+ \def\pgfplots@end{1}%
+ \def\pgfplots@endim{0}%
+ \else
+ % Ok. The arc should end before it reaches the (1,0)
+ % point. Determine the exact position and the
+ % corresponding arc end angle.
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@arc@ends@at@x@circle@value}{\pgfplots@mone}}%
+ \let\pgfplots@A@mone=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{add}{{\pgfplots@arc@ends@at@x@circle@value}{\pgfplots@one}}%
+ \let\pgfplots@A@one=\pgfmathresult
+ % oh - we should only draw a partial arc.
+ % Well, then compute its end point and the
+ % corresponding end angle.
+ \pgfplotscoordmathcomplexdivision{\pgfplots@A@mone}{\pgfplots@y}{\pgfplots@A@one}{\pgfplots@y}%
+ \let\pgfplots@end=\pgfmathresult
+ \let\pgfplots@endim=\pgfmathresultim
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@end}%
+ \let\pgfplots@end=\pgfmathresult
+ \pgfplotscoordmath{default}{tofixed}{\pgfplots@endim}%
+ \let\pgfplots@endim=\pgfmathresult
+ %
+ \pgfplots@compute@angle@of@point@in@circle\pgfplots@end\pgfplots@endim{1}{\pgfplots@signedradius}{\pgfplots@radius@inverse}%
+ \let\pgfplots@endangle=\pgfmathresult
+ \fi
+ %
+ %
+ %
+ % Now, compute the arc.
+ %
+ % first, compute the absolute x/y radii:
+ %
+ % Note that for small y (like y=0.01), the arc is almost a
+ % straight line. Consequently, the ellipsis radius will be much larger
+ % than 16000, violating TeX's number range.
+ %
+ % To avoid that, I clip it to the highest allowed value.
+ % The final radius is
+ % \pgfplots@radius * \pgf@xx and \pgfplots@radius * \pgf@yy.
+ % the clipped value thus needs to respect the magnitude of \pgf@xx and \pgf@yy.
+ \ifdim\pgfplots@radius pt<\pgfplots@smithchart@axis@max@xradius@for@ycircle pt
+ \let\pgfplots@radius@x\pgfplots@radius
+ \else
+ \let\pgfplots@radius@x=\pgfplots@smithchart@axis@max@xradius@for@ycircle
+ \fi
+ \ifdim\pgfplots@radius pt<\pgfplots@smithchart@axis@max@yradius@for@ycircle pt
+ \let\pgfplots@radius@y\pgfplots@radius
+ \else
+ \let\pgfplots@radius@y=\pgfplots@smithchart@axis@max@yradius@for@ycircle
+ \fi
+%\message{Y grid line \#\csname pgfplots@ticknum\endcsname\space at '#1': center = (1,\pgfplots@signedradius); signedradius = \pgfplots@signedradius\space clipped radii = \pgfplots@radius@x*\the\pgf@xx\space and \pgfplots@radius@y*\the\pgf@yy\space ( start angle \pgfplots@startangle, end angle \pgfplots@endangle, arc limit: \ifx\pgfplots@arc@ends@at@x@circle@value\pgfutil@empty NONE\else \pgfplots@arc@ends@at@x@circle@value\fi)^^J}%
+ \pgf@xa=\pgfplots@radius@x\pgf@xx
+ \pgf@xb=\pgfplots@radius@y\pgf@yy
+ \edef\pgfplots@mirror@sign{\ifpgfplots@smithchart@mirrored -\fi}%
+ \pgfpathmoveto{\pgfplotsqpointxy@smithchart@canvas{\pgfplots@start}{\pgfplots@startim}}%
+ % note that the case startangle > endangle is
+ % automatically correct; patharc handles that.
+ %\edef\pgfplots@loc@TMPa{{\pgfplots@startangle}{\pgfplots@endangle}{\pgfplots@mirror@sign\the\pgf@xa\space and \the\pgf@xb}}%
+ %\expandafter\pgfpatharc\pgfplots@loc@TMPa
+ %
+ % prefer \pgfpatharctoprecomputed. It is faster and more accurate
+ \ifdim\pgfplots@startangle pt>\pgfplots@endangle pt
+ \let\pgfplots@loc@TMPa=\pgfplots@startangle
+% \let\pgfplots@startangle=\pgfplots@endangle
+% \let\pgfplots@endangle=\pgfplots@loc@TMPa
+ \fi
+ \edef\pgfplots@loc@TMPa{%
+ {\noexpand\pgfplotsqpointxy@smithchart@canvas{1}{\pgfplots@radius@sign\pgfplots@radius@y}}%
+ {\pgfplots@startangle}%
+ {\pgfplots@endangle}%
+ {\noexpand\pgfplotsqpointxy@smithchart@canvas{\pgfplots@end}{\pgfplots@endim}}%
+ {\pgfplots@mirror@sign\the\pgf@xa}%
+ {\the\pgf@xb}%
+ {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioxy}%
+ {\pgfplots@mirror@sign\pgfplots@smithchart@axis@ratioyx}%
+ }%
+ \expandafter\pgfpatharctoprecomputed\pgfplots@loc@TMPa
+ }%
+}
+
+\def\pgfplots@drawgridlines@onorientedsurf@fromto@smithchart#1{%
+ \if x\pgfplotspointonorientedsurfaceA
+ \pgfplots@smithchart@draw@xcircle{#1}%
+ \else
+ \pgfplots@smithchart@draw@yarc{#1}%
+ \fi
+}%
+
+% Given a circle with center point (#3,#4), we search for the angle
+% of the point (#1,#2). The point is expected to be on the circle.
+% The resulting angle is returned in \pgfmathresult
+%
+% #1 x coordinate of the point for which an angle is searched
+% #2 y coordinate of the point for which an angle is searched
+% #3 x coordinate of the circle's center point
+% #4 y coordinate of the circle's center point
+% #5 is either empty or it is expected to contain the inverse radius, 1/r
+% this information is available in my context, so I don't recompute
+% it.
+%
+% All coordinates are expected in standard TeX precision (numbers
+% without unit)
+\def\pgfplots@compute@angle@of@point@in@circle#1#2#3#4#5{%
+ %
+ % 1. compute diff vector from center=(1,\pgfplots@signedradius) to start:
+ \pgfmathsubtract@{#1}{#3}%
+ \let\pgfplots@D\pgfmathresult
+ \pgfmathsubtract@{#2}{#4}%
+ \let\pgfplots@Dim\pgfmathresult
+ %
+ % 2. compute the start angle.
+ % It is related to the angle between the point (1,0) and
+ % diff, which, in turn is given by
+ % < (1,0), (D,Dim) > = cos(alpha) ||(D,Dim)||
+ % < (1,0), (D,Dim) > = D
+ %
+ % Note that ||(D,Dim)|| = r, the radius of the involved circle
+ % around (#3,#4). If 1/r is already available, use it! Saves a lot
+ % of time.
+ %
+ \def\pgfplots@loc@TMPa{#5}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfmathveclen\pgfplots@D\pgfplots@Dim
+ \let\pgfplots@veclen=\pgfmathresult
+ \pgfmathreciprocal@\pgfplots@veclen
+ \let\pgfplots@inverseveclen=\pgfmathresult
+ \else
+ % oh, good -- we already have 1/||(D,Dim)||. Use it.
+ \def\pgfplots@inverseveclen{#5}%
+%\message{using already available inverseveclen '#5' }%
+ \fi
+ \pgfmathmultiply@{\pgfplots@D}{\pgfplots@inverseveclen}%
+%\message{D= (\pgfplots@D,\pgfplots@Dim).. acos(\pgfplots@D * \pgfplots@inverseveclen) = acos(\pgfmathresult)}%
+ \pgfmathacos@{\pgfmathresult}% the '-' comes from D<0 .
+%\message{= \pgfmathresult^^J}%
+ \let\pgfplots@tmpangle\pgfmathresult%
+ % ok. tmpangle is per definition less than 180; it is the
+ % smaller angle between (1,0) and (D,Dim).
+ %
+ % compute the angle relative to (1,0):
+ \ifdim\pgfplots@Dim pt<0pt
+ \pgfmathiftrigonometricusesdeg{%
+ \pgfmathsubtract@{360}{\pgfplots@tmpangle}%
+ }{%
+ \pgfmathsubtract@{6.28318530717959}{\pgfplots@tmpangle}%
+ }%
+ \fi
+}%
+
+\def\pgfplots@drawaxis@innerlines@onorientedsurf@smithchart#1#2#3{%
+ \if2\csname pgfplots@#1axislinesnum\endcsname
+ \draw[/pgfplots/every inner #1 axis line,%
+ decorate,%
+ #1discont,%
+ decoration={pre length=\csname #1disstart\endcsname, post length=\csname #1disend\endcsname}]
+ \pgfextra
+ \csname pgfplotspointonorientedsurfaceabsetupforset#3\endcsname{\csname pgfplots@logical@ZERO@#3\endcsname}{2}%
+ \if#1x%
+ \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}%
+ \pgfplots@drawgridlines@onorientedsurf@fromto{0}%
+ \else
+ \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}%
+ \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}%
+ \fi
+ \endpgfextra
+ ;
+ \fi
+}%
+\def\pgfplots@drawaxis@outerlines@separate@onorientedsurf@smithchartaxis#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}]
+ \if#1x
+ \draw decorate {
+ \pgfextra
+ % exchange roles of A <-> B axes:
+ \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}%
+ \pgfplots@drawgridlines@onorientedsurf@fromto{0}%
+ \endpgfextra
+ };
+ \else
+ \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{%
+ \draw decorate {
+ \pgfextra
+ % exchange roles of A <-> B axes:
+ \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}%
+ \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2min\endcsname}%
+ \endpgfextra
+ };
+ }{}%
+ %--------------------------------------------------
+ % \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{%
+ % \draw decorate {
+ % \pgfextra
+ % % exchange roles of A <-> B axes:
+ % \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}%
+ % \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2max\endcsname}%
+ % \endpgfextra
+ % };
+ % }{}%
+ %--------------------------------------------------
+ \fi
+ \endscope
+ \fi
+}%
+
+\def\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@smithchart#1#2#3{%
+ % In a smith chart, the size of the image is unrelated to the
+ % involved data limits.
+ %
+ % The factor 2 is because we want to fit the DIAMETER into the
+ % prescribed dimensions, not just the radius.
+ \def\pgfmathresult{2}%
+ \let#1=\pgfmathresult
+ \let#2=\pgfmathresult
+ \def#3{1}%
+}%
+
+\def\pgfplots@handle@invalid@range@defaultlimits@smithchart{%
+ \pgfplotscoordmath{x}{parsenumber}{0}%
+ \global\let\pgfplots@xmin=\pgfmathresult
+ \pgfplotscoordmath{x}{parsenumber}{16000}%
+ \global\let\pgfplots@xmax=\pgfmathresult
+ \global\let\pgfplots@data@xmin=\pgfplots@xmin
+ \global\let\pgfplots@data@xmax=\pgfplots@xmax
+ %
+ \pgfplotscoordmath{y}{parsenumber}{0}%
+ \global\let\pgfplots@ymin=\pgfmathresult
+ \pgfplotscoordmath{y}{parsenumber}{16000}%
+ \global\let\pgfplots@ymax=\pgfmathresult
+ \global\let\pgfplots@data@ymin=\pgfplots@ymin
+ \global\let\pgfplots@data@ymax=\pgfplots@ymax
+ \pgfplotsset{enlargelimits=false}%
+}
+
+\let\pgfplots@set@default@size@options@standard=\pgfplots@set@default@size@options
+\def\pgfplots@set@default@size@options@smithchart{%
+ \pgfplots@set@default@size@options@standard
+ \pgfplotsset{smithchart ticks by size={\pgfkeysvalueof{/pgfplots/width}}{\pgfkeysvalueof{/pgfplots/height}}}%
+ %
+ \if1\b@pgfplots@smithchart@defaultticks@x
+ \if1\b@pgfplots@smithchart@defaultticks@y
+ \pgfplotsset{default smithchart xytick}%
+ \fi
+ \fi
+}
+\def\pgfplots@assign@default@tick@foraxis@smithchart#1{%
+ % do nothing here. I don't know the algorithm yet... but for
+ % smithcharts, it may be sufficient to simply predefine several
+ % sets of ticks, depending on the final size.
+ %
+ % This is realized in
+ % \pgfplots@set@default@size@options@smithchart (which is invoked
+ % before the ticks are processed).
+ \pgfplots@determinedefaultvalues@needs@check@uniformtickfalse
+ \expandafter\let\csname pgfplots@tick@distance@#1\endcsname=\pgfutil@empty
+ %
+ \pgfplotsset{default smithchart #1tick}%
+ % ok, I expect the '#1tick' key to be set now. Process it.
+ % Note that the earlier processing of pgfplots has been bypassed
+ % at this point -- we need to preprocess the tick list *here*:
+ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname
+ \expandafter\pgfplots@assign@default@tick@foraxis@smithchart@\expandafter{\pgfplots@loc@TMPa}%
+ \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplotsretval
+ %
+ \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \expandafter\pgfplots@assign@default@tick@foraxis@smithchart@\expandafter{\pgfplots@loc@TMPa}%
+ \pgfkeyslet{/pgfplots/minor #1tick}\pgfplotsretval
+ \fi
+ %
+}%
+% #1: a \foreach list
+% on output, \pgfplotsretval contains a parsed list of positions
+\def\pgfplots@assign@default@tick@foraxis@smithchart@#1{%
+ \pgfplotsapplistXXglobalnewempty
+ \gdef\pgfplots@loc@TMPd{1}%
+ \foreach \pgfplots@loc@TMPb in {#1} {%
+ \ifx\pgfplots@loc@TMPb\pgfutil@empty
+ \else
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplots@loc@TMPb}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% per convention...
+ \edef\pgfmathresult{\if0\pgfplots@loc@TMPd,\fi\pgfmathresult}%
+ \gdef\pgfplots@loc@TMPd{0}%
+ \expandafter\pgfplotsapplistXXglobalpushback\expandafter{\pgfmathresult}%
+ \fi
+ }%
+ \pgfplotsapplistXXgloballet\pgfplotsretval
+ \pgfplotsapplistXXglobalclear
+}%
+
+\let\pgfplots@show@ticklabel@@orig=\pgfplots@show@ticklabel@
+\def\pgfplots@show@ticklabel@@smithchart#1#2{%
+ \def\pgfmathresult{#2}%
+ \if#1x%
+ \ifdim#2pt>360pt
+ \pgfmath@basic@mod@{#2}{360}%
+ \fi
+ \fi
+ \def\pgfplots@loc@TMPa{\pgfplots@show@ticklabel@@orig{#1}}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
+}%
+
+\def\pgfplots@xtick@check@tickshow@smithchart{%
+ \pgfplots@tickshowtrue
+}
+\def\pgfplots@ytick@check@tickshow@smithchart{%
+ \pgfplots@tickshowtrue
+}
+
+\let\pgfplots@limits@ready@orig=\pgfplots@limits@ready
+\def\pgfplots@limits@ready@smithchart{%
+ \pgfplots@limits@ready@orig
+ %
+ % Avoid tick labels at upper *and* lower angle range if both are the
+ % same:
+ \pgfmath@basic@sin@{\pgfplots@xmin}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfmath@basic@sin@{\pgfplots@xmax}%
+ \pgfplotsmath@ifapproxequal@dim
+ {\pgfmathresult pt}{\pgfplots@loc@TMPa pt}%
+ {0.002pt}
+ {%
+ \def\pgfplots@xtick@disable@last@tick{1}%
+ }{%
+ }%
+}%
+
+\def\smithchart{\smithchartaxis}
+\def\endsmithchart{\endsmithchartaxis}
+
+\def\startsmithchart{\smithchart}%
+\def\stopsmithchart{\endsmithchart}%
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.statistics.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.statistics.code.tex
new file mode 100644
index 0000000000..3931d85dae
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.statistics.code.tex
@@ -0,0 +1,1221 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for statistical plots (boxplots in the first version)
+%
+% Copyright 2007-2012 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/>.
+%
+%--------------------------------------------
+
+\catcode`\;=12
+\catcode`\"=12
+\newif\ifpgfplotsplothandlerboxplot@variable@width
+
+\ifpgfplots@LUA@supported
+ \pgfplotsutil@directlua{require("pgfplots.statistics")}%
+\fi
+
+\newif\ifpgfplots@boxplot@ensure@plot@mark
+\def\pgfplots@boxplot@ensure@plot@mark{%
+ \ifpgfplots@boxplot@ensure@plot@mark
+ \pgfplots@if@has@plot@marks{}{%
+ \tikzset{mark=*}%
+ }%
+ \fi
+}%
+
+\pgfplotsset{
+ boxplot/.code={%
+ \def\tikz@plot@handler{\pgfplotsplothandlerboxplot}%
+ \pgfplotsset{%
+ /pgfplots/every boxplot,
+ /pgfplots/boxplot/.cd,%
+ #1%
+ }%
+ \pgfplots@boxplot@ensure@plot@mark
+ },
+ boxplot prepared/.code={%
+ \def\tikz@plot@handler{\pgfplotsplothandlerboxplotprepared}%
+ \pgfplotsset{%
+ /pgfplots/every boxplot,
+ /pgfplots/boxplot/.cd,%
+ #1%
+ }%
+ \pgfplots@boxplot@ensure@plot@mark
+ },
+ boxplot/data value/.code =\pgfplots@set@source@for{boxplot/data}{#1}{0},%
+ boxplot/data/.code =\pgfplots@set@source@for{boxplot/data}{#1}{1},%
+ boxplot/data filter/.code=,
+ boxplot/data value=\pgfkeysvalueof{/data point/y},
+ %
+ every boxplot/.style={%
+ },
+ %
+ % 'auto' means "if possible".
+ % For boxplot prepared, this is equivalent to "disabled" (empty value).
+ % For boxplot, it means "compute it".
+ % Empty value means disabled.
+ boxplot/median/.initial=auto,
+ boxplot/lower quartile/.initial=auto,
+ boxplot/upper quartile/.initial=auto,
+ boxplot/lower whisker/.initial=auto,
+ boxplot/upper whisker/.initial=auto,
+ boxplot/average/.initial=,
+ %
+ % mainly used for compatibility.
+ boxplot/ensure mark/.is if=pgfplots@boxplot@ensure@plot@mark,
+ %
+ boxplot/estimator/.is choice,
+ boxplot/estimator/legacy/.code={\def\pgfplots@boxplot@estimator{legacy}},
+ %
+ boxplot/estimator/legacy*/.code={\def\pgfplots@boxplot@estimator{legacy*}},
+ boxplot/estimator/R1/.code={\def\pgfplots@boxplot@estimator{R1}},
+ boxplot/estimator/SAS3/.code={\def\pgfplots@boxplot@estimator{R1}},
+ boxplot/estimator/Maple1/.code={\def\pgfplots@boxplot@estimator{R1}},
+ %
+ boxplot/estimator/R2/.code={\def\pgfplots@boxplot@estimator{R2}},
+ boxplot/estimator/SAS5/.code={\def\pgfplots@boxplot@estimator{R2}},
+ boxplot/estimator/Maple2/.code={\def\pgfplots@boxplot@estimator{R2}},
+ %
+ boxplot/estimator/R3/.code={\def\pgfplots@boxplot@estimator{R3}},
+ boxplot/estimator/SAS2/.code={\def\pgfplots@boxplot@estimator{R3}},
+ %
+ boxplot/estimator/R4/.code={\def\pgfplots@boxplot@estimator{R4}},
+ boxplot/estimator/SAS1/.code={\def\pgfplots@boxplot@estimator{R4}},
+ boxplot/estimator/SciPy0-1/.code={\def\pgfplots@boxplot@estimator{R4}},
+ boxplot/estimator/Maple3/.code={\def\pgfplots@boxplot@estimator{R4}},
+ %
+ boxplot/estimator/R5/.code={\def\pgfplots@boxplot@estimator{R5}},
+ boxplot/estimator/SciPy12-12/.code={\def\pgfplots@boxplot@estimator{R5}},
+ boxplot/estimator/Maple4/.code={\def\pgfplots@boxplot@estimator{R5}},
+ %
+ boxplot/estimator/R6/.code={\def\pgfplots@boxplot@estimator{R6}},
+ boxplot/estimator/SAS4/.code={\def\pgfplots@boxplot@estimator{R6}},
+ boxplot/estimator/SciPy0-0/.code={\def\pgfplots@boxplot@estimator{R6}},
+ boxplot/estimator/Maple5/.code={\def\pgfplots@boxplot@estimator{R6}},
+ %
+ boxplot/estimator/R7/.code={\def\pgfplots@boxplot@estimator{R7}},
+ boxplot/estimator/Excel/.code={\def\pgfplots@boxplot@estimator{R7}},
+ boxplot/estimator/SciPy1-1/.code={\def\pgfplots@boxplot@estimator{R7}},
+ boxplot/estimator/Maple6/.code={\def\pgfplots@boxplot@estimator{R7}},
+ %
+ boxplot/estimator/R8/.code={\def\pgfplots@boxplot@estimator{R8}},
+ boxplot/estimator/SciPy13-13/.code={\def\pgfplots@boxplot@estimator{R8}},
+ boxplot/estimator/Maple7/.code={\def\pgfplots@boxplot@estimator{R8}},
+ %
+ boxplot/estimator/R9/.code={\def\pgfplots@boxplot@estimator{R9}},
+ boxplot/estimator/SciPy38-38/.code={\def\pgfplots@boxplot@estimator{R9}},
+ boxplot/estimator/Maple8/.code={\def\pgfplots@boxplot@estimator{R9}},
+ %
+ boxplot/estimator=legacy,
+ %
+ boxplot/lower quartile off/.initial=0.25,
+ boxplot/upper quartile off/.initial=0.75,
+ boxplot/whisker range/.initial=1.5,
+ %
+ %
+ % the size of whisker lines in axis units.
+ % The default is to make it relative to 'box extend'
+ boxplot/whisker extend/.initial=\pgfkeysvalueof{/pgfplots/boxplot/box extend}*0.8,
+ %
+ % the size of the box in axis units. Note that this has been
+ % chosen to fit the initial 'draw position':
+ boxplot/box extend/.initial=0.8,
+ % draw direction=x|y
+ boxplot/draw direction/.initial=x,
+ %
+ % Activates "dynamic size" feature
+ boxplot/variable width/.is if=pgfplotsplothandlerboxplot@variable@width,
+ boxplot/variable width/.default=true,
+ %
+ boxplot/sample size/.initial=auto,
+ %
+ % a transformation which is applied to anything related to
+ % sample size.
+ boxplot/variable width expr/.code=\pgfmathparse{sqrt(#1)},
+ %
+ % will be computed automatically if needed. If it is present, it
+ % will not contribute to the axis-wide limit unless it has been
+ % given axis-wide.
+ boxplot/sample size min/.initial=,
+ boxplot/sample size max/.initial=,
+ %
+ % this factor times 'box extend' is the size for
+ % 'sample size min'. The max value gets 'box extend'.
+ boxplot/variable width min target/.initial=0.2,
+ %
+ %
+ % defines where how the "free" position is chosen. The idea is to
+ % place one box at each "y" position and to number these
+ % 1,2,3,4,... . This should probably simplify tick (label) generation.
+ boxplot/draw position/.initial=1+\plotnumofactualtype,
+ %
+ % draw relative anchor=0:
+ % | |---| |
+ % | | | |
+ % |----|---|--|
+ %
+ % draw relative anchor=0.5:
+ % | |---| |
+ % |----| |--|
+ % | |---| |
+ %
+ % draw relative anchor=1:
+ % |----|---|--|
+ % | | | |
+ % | |---| |
+ boxplot/draw relative anchor/.initial=0.5,
+ %
+ boxplot/every whisker/.style={%
+ },
+ boxplot/every box/.style={%
+ },
+ boxplot/every median/.style={%
+ },
+ boxplot/every average/.style={%
+ /tikz/mark=diamond*,
+ },
+ boxplot/draw/lower whisker/.style={%
+ /pgfplots/boxplot/draw/whisker=%
+ {\pgfplotsboxplotvalue{lower quartile}}
+ {\pgfplotsboxplotvalue{lower whisker}}
+ },
+ boxplot/draw/upper whisker/.style={%
+ /pgfplots/boxplot/draw/whisker=%
+ {\pgfplotsboxplotvalue{upper quartile}}
+ {\pgfplotsboxplotvalue{upper whisker}}%
+ },
+ boxplot/draw/whisker/.code 2 args={%
+ \draw[/pgfplots/boxplot/every whisker/.try]
+ (boxplot cs:#1) -- (boxplot cs:#2)
+ (boxplot whisker cs:#2,0)
+ --
+ (boxplot whisker cs:#2,1)
+ ;
+ },%
+ %
+ boxplot/draw/box/.code={%
+ \draw[/pgfplots/boxplot/every box/.try]
+ (boxplot box cs:\pgfplotsboxplotvalue{lower quartile},0)
+ rectangle
+ (boxplot box cs:\pgfplotsboxplotvalue{upper quartile},1)
+ ;
+ },%
+ %
+ boxplot/draw/average/.code={%
+ \draw[/pgfplots/boxplot/every average/.try]
+ \pgfextra
+ % do NOT use \draw[mark=*] plot coordinates because
+ % boxplots uses the same plot handler to draw its
+ % outliers.
+ \pgftransformshift{%
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{average}}
+ {0.5}%
+ }%
+ \pgfuseplotmark{\tikz@plot@mark}%
+ \endpgfextra
+ ;
+ },
+ %
+ boxplot/draw/median/.code={%
+ \draw[/pgfplots/boxplot/every median/.try]
+ (boxplot box cs:\pgfplotsboxplotvalue{median},0)
+ --
+ (boxplot box cs:\pgfplotsboxplotvalue{median},1)
+ ;
+ },%
+}
+
+
+\def\pgfplotsplothandlerboxplot{%
+ \pgfplotsresetplothandler
+ \def\pgf@plotstreamstart{%
+ \pgfplotsset{/pgfplots/boxplot prepared}%
+ \pgfplotsresetplothandler
+ \tikz@plot@handler
+ \pgf@plotstreamstart
+ }%
+ \def\pgfplotsplothandlername{boxplot}%
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@boxplot
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@boxplot
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@boxplot
+ \def\pgfplotsplothandlerLUAfactory{%
+ function(axis, pointmetainputhandler)
+ return pgfplots.BoxPlotPlothandler.new(
+ pgfplots.BoxPlotRequest.new(
+ "\pgfkeysvalueof{/pgfplots/boxplot/lower quartile off}",
+ "\pgfkeysvalueof{/pgfplots/boxplot/upper quartile off}",
+ "\pgfkeysvalueof{/pgfplots/boxplot/whisker range}",
+ pgfplots.getPercentileEstimator("\pgfplots@boxplot@estimator")),
+ "\pgfkeysvalueof{/pgfplots/boxplot/draw direction}",
+ "\pgfkeysvalueof{/pgfplots/boxplot/draw position}",
+ axis, pointmetainputhandler)
+ end
+ }%
+}
+
+
+\def\pgfplotsplothandlersurveystart@boxplot{%
+ \pgfplots@prepare@source@parser@for{boxplot/}{data}{\pgfplotsplothandlerboxplot@parse}%
+ %
+ \pgfplotscoordmath{float}{zero}%
+ \let\pgfplotsplothandlerboxplot@sum=\pgfmathresult
+ %
+ \pgfplotscoordmath{float}{min limit}%
+ \let\pgfplotsplothandlerboxplot@last=\pgfmathresult
+ %
+ \def\b@pgfplotsplothandlerboxplot@issorted{1}%
+ %
+ \pgfplotsarraynewempty\pgfp@boxplot@@
+ \def\c@pgfplotsplothandlerboxplot@num{0}%
+ \c@pgfplots@coordindex=0
+}%
+
+\def\pgfplotsplothandlersurveyend@boxplot{%
+ \pgfplots@curplot@threedimfalse
+ %
+ \ifpgfplots@LUA@backend@supported
+ \else
+ \if0\b@pgfplotsplothandlerboxplot@issorted
+ \pgfplotsplothandlersurveyend@boxplot@sort
+ \fi
+ \fi
+ %
+ %
+ \edef\numcoords{\pgfplots@current@point@coordindex}%
+ %
+ %%
+ \pgfplotsset{%
+ /pgfplots/boxplot prepared={%
+ data value=\pgfplots@current@point@data,
+ },%
+ }%
+ \pgfplotsresetplothandler
+ %
+ \let\pgfplotsplothandlerboxplotprepared@normalize@values@@=\pgfplotsplothandlerboxplotprepared@normalize@values
+ \def\pgfplotsplothandlerboxplotprepared@normalize@values{\relax}%
+ %
+ \tikz@plot@handler
+ %
+ \pgfplotsplothandlersurveystart
+ %
+ \ifpgfplots@LUA@backend@supported
+ \else
+ % this will report outliers as point stream:
+ \pgfplotsplothandlersurveyend@boxplot@computestats
+ \fi
+ %
+ \let\pgfplotsplothandlerboxplotprepared@normalize@values=\pgfplotsplothandlerboxplotprepared@normalize@values@@
+ \pgfplotsplothandlerboxplotprepared@normalize@values
+ %
+ %
+ \pgfplotsplothandlersurveyend
+}%
+
+\def\pgfplotsplothandlersurveyend@boxplot@sort{%
+ \pgfkeys{/pgfplots/float <}%
+ \pgfplotsarraysort{\pgfp@boxplot@@}%
+}%
+
+\def\pgfplots@boxplot@fillarray{%
+ \def\pgfplots@loc@TMPa{\pgfplotsarrayset\c@pgfplots@coordindex\of{P}\to}%
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@current@point@data}%
+}
+
+%%%%
+
+\def\pgfplotsplothandler@boxplot@init@percentile@estimator{%
+ \def\pgfplots@loc@TMPb{legacy}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@boxplot@estimator
+ \let\pgfplotsplothandler@boxplot@percentile@estimator@=\pgfplotsplothandler@boxplot@percentile@estimator@legacy
+ \else
+ \def\pgfplots@loc@TMPb{legacy*}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@boxplot@estimator
+ \let\pgfplotsplothandler@boxplot@percentile@estimator@=\pgfplotsplothandler@boxplot@percentile@estimator@legacy@bad
+ \else
+ % first, strip 'R' and store the integer number into \pgfplotsretval:
+ \def\pgfplots@loc@TMPb##1##2{%
+ \def\pgfplotsretval{##2}%
+ }%
+ \expandafter\pgfplots@loc@TMPb\pgfplots@boxplot@estimator
+ \ifcase\pgfplotsretval\relax
+ % 0:
+ \pgfplots@error{illegal argument 'estimator=\pgfplots@boxplot@estimator' encountered.}%
+ \or
+ % R1:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{##1*##2}%
+ \let\h=\pgfmathresult
+ \pgfmathparse{ceil(\h)}%
+ \pgfmathfloattoint\pgfmathresult
+ \let\offset@low=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}%
+ }
+ % FIXME : implement 'ceil' in the FPU!
+ \pgfplots@error{The argument 'estimator=\pgfplots@boxplot@estimator' is only available in conjunction with 'lua backend' and lualatex.}%
+ \or
+ % R2:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{##1*##2 + 0.5}%
+ \let\h=\pgfmathresult
+ %
+ \pgfmathparse{ceil(\h-0.5)}%
+ \pgfmathfloattoint\pgfmathresult
+ \let\offset@low=\pgfmathresult
+ %
+ \pgfmathparse{floor(\h+0.5)}%
+ \pgfmathfloattoint\pgfmathresult
+ \let\offset@high=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}%
+ \let\x@low=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{##2}%
+ \let\x@high=\pgfmathresult
+ \pgfmathparse{0.5*(\x@low + \x@high)}%
+ }
+ % FIXME : implement 'ceil' in the FPU!
+ \pgfplots@error{The argument 'estimator=\pgfplots@boxplot@estimator' is only available in conjunction with 'lua backend' and lualatex.}%
+ \or
+ % R3:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{##1*##2}%
+ \let\h=\pgfmathresult
+ \pgfmathparse{round(\h)}%
+ \pgfmathfloattoint\pgfmathresult
+ \let\offset@low=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}%
+ }
+ \or
+ % R4:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{##1*##2}%
+ \let\h=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}%
+ }
+ \or
+ % R5:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{##1*##2 + 0.5}%
+ \let\h=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}%
+ }
+ \or
+ % R6:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{##1*(##2+1)}%
+ \let\h=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}%
+ }
+ \or
+ % R7:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{(##2-1) * ##1 + 1}%
+ \let\h=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}%
+ }
+ \or
+ % R8:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{(##2 + 1/3) * ##1 + 1/3}%
+ \let\h=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}%
+ }
+ \or
+ % R9:
+ \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{%
+ \pgfmathparse{(##2 + 1/4) * ##1 + 3/8}%
+ \let\h=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}%
+ }
+ \else
+ \pgfplots@error{illegal argument 'estimator=\pgfplots@boxplot@estimator' encountered.}%
+ \fi
+ \fi
+ \fi
+}%
+
+% #1: the percentile in question (like 0.5 for the median)
+% #2: the number of data points in the array \pgfp@boxplot@@
+% POSTCONDITION: \pgfmathresult contains the result.
+\def\pgfplotsplothandler@boxplot@percentile@estimator#1#2{%
+ \begingroup
+ \pgfkeys{/pgf/fpu}%
+ \pgfplotsplothandler@boxplot@percentile@estimator@{#1}{#2}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+}%
+
+% #1: the index
+% #2: the number of data points in the array \pgfp@boxplot@@
+%
+% POSTCONDITION: \pgfmathresult contains the result.
+\def\pgfplotsplothandler@boxplot@percentile@estimator@getIndex#1#2{%
+ \c@pgf@countd=#1\relax
+ \advance\c@pgf@countd by-1 % we have 0-based indices
+ \ifnum\c@pgf@countd<0 \c@pgf@countd=0 \fi
+ \ifnum\c@pgf@countd<#2\relax \else \c@pgf@countd=#2\relax \advance\c@pgf@countd by-1 \fi
+ \pgfplotsarrayselect\c@pgf@countd\of\pgfp@boxplot@@\to\pgfmathresult
+}%
+
+% #1: the index
+% #2: the number of data points in the array \pgfp@boxplot@@
+%
+% POSTCONDITION: \pgfmathresult contains the result.
+\def\pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad#1#2{%
+ \c@pgf@countd=#1\relax
+ %\advance\c@pgf@countd by-1 % we have 0-based indices
+ \ifnum\c@pgf@countd<0 \c@pgf@countd=0 \fi
+ \ifnum\c@pgf@countd<#2\relax \else \c@pgf@countd=#2\relax \advance\c@pgf@countd by-1 \fi
+ \pgfplotsarrayselect\c@pgf@countd\of\pgfp@boxplot@@\to\pgfmathresult
+}%
+
+\def\pgfplotsplothandler@boxplot@percentile@estimator@#1#2{%
+ \pgfplots@error{The estimator is uninitialized in this context. Call \string\pgfplotsplothandler@boxplot@init@percentile@estimator\space first.}%
+}
+
+% computes x_low + (h - h_low) * (x_up - x_low)
+% #1: the number of data points in the array \pgfp@boxplot@@
+\def\pgfplotsplothandler@boxplot@percentile@estimator@std@lookup#1{%
+ \pgfmathparse{floor(\h)}%
+ \let\h@low=\pgfmathresult
+ \pgfmathfloattoint\pgfmathresult
+ \let\offset@low=\pgfmathresult
+ \c@pgf@countd=\offset@low\relax
+ \advance\c@pgf@countd by1 %
+ \edef\offset@high{\the\c@pgf@countd}%
+ %
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{#1}%
+ \let\x@low=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{#1}%
+ \let\x@high=\pgfmathresult
+ \pgfmathparse{\x@low + (\h - \h@low) * (\x@high - \x@low)}%
+}%
+
+% implements 'estimator=legacy'
+\def\pgfplotsplothandler@boxplot@percentile@estimator@legacy#1#2{%
+ \pgfmathparse{#1*#2}%
+ \let\h=\pgfmathresult
+ \pgfmathparse{floor(\h)}%
+ \pgfmathfloattoint\pgfmathresult
+ \let\offset@low=\pgfmathresult
+ %
+ \pgfmathparse{\h > \offset@low}%
+ \ifpgfmathfloatcomparison
+ \def\b@is@int{0}%
+ \else
+ \def\b@is@int{1}%
+ \fi
+ %
+ \c@pgf@countd=\offset@low\relax
+ \advance\c@pgf@countd by1 %
+ \edef\offset@high{\the\c@pgf@countd}%
+ %
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{#2}%
+ \if0\b@is@int
+ \let\temp=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{#2}%
+ \pgfmathparse{0.5*(\temp + \pgfmathresult)}%
+ \fi
+}
+\def\pgfplotsplothandler@boxplot@percentile@estimator@legacy@bad#1#2{%
+ \pgfmathparse{#1*(#2-1)}%
+ \let\h=\pgfmathresult
+ \pgfmathparse{floor(\h)}%
+ \pgfmathfloattoint\pgfmathresult
+ \let\offset@low=\pgfmathresult
+ %
+ \pgfmathparse{\h > \offset@low}%
+ \ifpgfmathfloatcomparison
+ \def\b@is@int{0}%
+ \else
+ \def\b@is@int{1}%
+ \fi
+ %
+ \c@pgf@countd=\offset@low\relax
+ \advance\c@pgf@countd by1 %
+ \edef\offset@high{\the\c@pgf@countd}%
+ %
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad{\offset@low}{#2}%
+ \if0\b@is@int
+ \let\temp=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad{\offset@high}{#2}%
+ \pgfmathparse{0.5*(\temp + \pgfmathresult)}%
+ \fi
+}
+
+
+\def\pgfplotsplothandlersurveyend@boxplot@computestats{
+ %
+ \pgfplotsplothandler@boxplot@init@percentile@estimator
+ %
+ % hm. I once had the idea to support quartile-based whisker
+ % definitions... but I did not implement them.
+ \let\c@pgfplotsplothandlerboxplot@lowerwhisker=\pgfutil@empty
+ \let\c@pgfplotsplothandlerboxplot@upperwhisker=\pgfutil@empty
+ %
+ %
+ % These here are the VALUES that will be communicated to 'boxplot prepared'
+ % They need to be computed below.
+ \let\pgfplotsplothandlerboxplot@lowerwhisker=\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@lowerquartile=\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@median=\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@upperquartile=\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@upperwhisker=\pgfutil@empty
+ %
+ \pgfplotsplothandler@boxplot@percentile@estimator{\pgfkeysvalueof{/pgfplots/boxplot/lower quartile off}}{\numcoords}%
+ \let\pgfplotsplothandlerboxplot@lowerquartile=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator{\pgfkeysvalueof{/pgfplots/boxplot/upper quartile off}}{\numcoords}%
+ \let\pgfplotsplothandlerboxplot@upperquartile=\pgfmathresult
+ \pgfplotsplothandler@boxplot@percentile@estimator{0.5}{\numcoords}%
+ \let\pgfplotsplothandlerboxplot@median=\pgfmathresult
+ %
+ %
+ \pgfplotscoordmath{float}{parsenumber}{\numcoords}%
+ \let\pgfplots@boxplot@numcoords=\pgfmathresult
+ \pgfplotscoordmath{float}{op}{divide}{{\pgfplotsplothandlerboxplot@sum}{\pgfplots@boxplot@numcoords}}%
+ \let\pgfplotsplothandlerboxplot@average=\pgfmathresult
+ %
+ % communicate and set results to pgfkeys - and to the plot
+ % specification option list:
+ \pgfplotsplothandlersurveyend@boxplot@set{lower whisker}{\pgfplotsplothandlerboxplot@lowerwhisker}%
+ \pgfplotsplothandlersurveyend@boxplot@set{lower quartile}{\pgfplotsplothandlerboxplot@lowerquartile}%
+ \pgfplotsplothandlersurveyend@boxplot@set{median}{\pgfplotsplothandlerboxplot@median}%
+ \pgfplotsplothandlersurveyend@boxplot@set{average}{\pgfplotsplothandlerboxplot@average}%
+ \pgfplotsplothandlersurveyend@boxplot@set{upper quartile}{\pgfplotsplothandlerboxplot@upperquartile}%
+ \pgfplotsplothandlersurveyend@boxplot@set{upper whisker}{\pgfplotsplothandlerboxplot@upperwhisker}%
+ \pgfplotsplothandlersurveyend@boxplot@set{sample size}{\pgfplots@boxplot@numcoords}%
+ %
+ % Ok, now make sure that we use the FINAL variables from the user,
+ % i.e. that we respect manual overrides. This is only necessary
+ % for quartiles from what I see here.
+ \pgfplotsplothandlersurveyend@boxplot@get{\pgfplotsplothandlerboxplot@lowerquartile}{lower quartile}%
+ \pgfplotsplothandlersurveyend@boxplot@get{\pgfplotsplothandlerboxplot@upperquartile}{upper quartile}%
+ %
+ \pgfplotscoordmath{float}{parsenumber}{\pgfplotsboxplotvalue{whisker range}}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{float}{op}{subtract}{{\pgfplotsplothandlerboxplot@upperquartile}{\pgfplotsplothandlerboxplot@lowerquartile}}%
+ \pgfplotscoordmath{float}{op}{multiply}{{\pgfmathresult}{\pgfplots@loc@TMPa}}%
+ \let\pgfplots@boxplot@whisker@width=\pgfmathresult
+ \pgfplotscoordmath{float}{op}{add}{{\pgfplotsplothandlerboxplot@upperquartile}{\pgfplots@boxplot@whisker@width}}%
+ \let\pgfplotsplothandlerboxplot@upperwhisker@value=\pgfmathresult
+ \pgfplotscoordmath{float}{op}{subtract}{{\pgfplotsplothandlerboxplot@lowerquartile}{\pgfplots@boxplot@whisker@width}}%
+ \let\pgfplotsplothandlerboxplot@lowerwhisker@value=\pgfmathresult
+ %
+ \pgfplotsarrayforeachungrouped\pgfp@boxplot@@\as\pgfplots@current@point@data{%
+ \pgfplotsplothandlersurveyend@boxplot@computestats@valuebased
+ }%
+ %
+ \pgfplotsplothandlersurveyend@boxplot@set{lower whisker}{\pgfplotsplothandlerboxplot@lowerwhisker}%
+ \pgfplotsplothandlersurveyend@boxplot@set{upper whisker}{\pgfplotsplothandlerboxplot@upperwhisker}%
+ %
+}%
+
+% takes a key #1 which is expected in /pgfplots/boxplot/#1,
+% and overwrites its value with #2 if that is allowed.
+%
+% More specifically, if the current value of '#1' is 'auto', it is
+% replaced by #2. In all other cases, it will not be modified.
+%
+% The "replaced by #2" means to set the value right away and to modify
+% the plot's option list to reflect the new value.
+%
+% ---- NOTE: this routine is also invoked from the LUA BACKEND.
+\def\pgfplotsplothandlersurveyend@boxplot@set#1#2{%
+ \pgfkeysgetvalue{/pgfplots/boxplot/#1}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \def\pgfplots@loc@TMPc{auto}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPc
+ \edef\pgfmathresult{#2}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfplotscoordmath{float}{tostring}{#2}%
+ \edef\pgfplots@loc@TMPb{\noexpand\pgfplotsplothandlersurveyaddoptions{/pgfplots/boxplot/#1={\pgfmathresult}}}%
+ \pgfplots@loc@TMPb
+ \pgfplotsplothandlersurveyend@boxplot@log{#1}{\pgfmathresult}%
+ \fi
+ \fi
+}%
+
+\def\pgfplotsplothandlersurveyend@boxplot@log#1#2{%
+ \pgfplots@log3{boxplot: got #1=#2}%
+}%
+
+\def\pgfplotsplothandlersurveyend@boxplot@get#1#2{%
+ \pgfkeysgetvalue{/pgfplots/boxplot/#2}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \def\pgfplots@loc@TMPc{auto}%
+ \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPc
+ \else
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfmathparse{\pgfplots@loc@TMPa}%
+ \let#1=\pgfmathresult
+ \fi
+ \fi
+}
+
+\def\pgfplotsplothandlersurveyend@boxplot@computestats@valuebased{%
+ \ifx\pgfplotsplothandlerboxplot@lowerwhisker\pgfutil@empty
+ \pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@data}{\pgfplotsplothandlerboxplot@lowerwhisker@value}{%
+ % Ah. an outlier.
+ \pgfplotsplothandlerboxplot@outlier
+ }{%
+ \let\pgfplotsplothandlerboxplot@lowerwhisker=\pgfplots@current@point@data
+ }%
+ \fi
+ %
+ % FIXME : optimize this! We have an array so we COULD check it in
+ % reverse order!
+ % it would be so cool if we could simply check the list in reverse
+ % order. but not if it really is a singly-linked list...
+ \pgfplotscoordmath{float}{if less than}{\pgfplotsplothandlerboxplot@upperwhisker@value}{\pgfplots@current@point@data}{%
+ % Ah. an outlier.
+ \pgfplotsplothandlerboxplot@outlier
+ }{%
+ \ifx\pgfplotsplothandlerboxplot@upperwhisker\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@upperwhisker=\pgfplots@current@point@data
+ \else
+ \pgfplotscoordmath{float}{max}{\pgfplotsplothandlerboxplot@upperwhisker}{\pgfplots@current@point@data}%
+ \let\pgfplotsplothandlerboxplot@upperwhisker=\pgfmathresult
+ \fi
+ }%
+}
+
+\def\pgfplotsplothandlerboxplot@outlier{%
+ \def\pgfplots@current@point@x{0}%
+ \def\pgfplots@current@point@y{0}%
+ \def\pgfplots@current@point@z{0}%
+ \pgfplotsplothandlersurveypoint
+}%
+
+%%%
+
+\def\pgfplotsplothandlersurveypoint@boxplot{%
+ \pgfplotsplothandlerboxplot@parse
+ \let\pgfplots@current@point@data=\pgfmathresult
+ %
+ \ifx\pgfplots@current@point@data\pgfutil@empty
+ \else
+ \pgfplotscoordmath{float}{if is bounded}{\pgfplots@current@point@data}{%
+ %
+ \ifpgfplots@LUA@backend@supported
+ \pgfplotsplothandlerboxplot@LUA@survey@point
+ \else
+ \pgfplotsplothandlersurveypoint@boxplot@
+ \fi
+ }{%
+ }%
+ \fi
+}%
+
+\def\pgfplotsplothandlerboxplot@LUA@survey@point{%
+ \pgfplotsutil@directlua{pgfplots.texBoxPlotSurveyPoint("\pgfplots@current@point@data")}%
+}%
+\def\pgfplotsplothandlersurveypoint@boxplot@{%
+ \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlerboxplot@num
+ %
+ \if1\b@pgfplotsplothandlerboxplot@issorted
+ \pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@data}{\pgfplotsplothandlerboxplot@last}{%
+ \def\b@pgfplotsplothandlerboxplot@issorted{0}%
+ }{%
+ }%
+ \fi
+ %
+ %
+ \pgfplotscoordmath{float}{op}{add}{{\pgfplots@current@point@data}{\pgfplotsplothandlerboxplot@sum}}%
+ \let\pgfplotsplothandlerboxplot@sum=\pgfmathresult
+ %
+ % store parsed result.
+ \edef\pgfmathresult{\pgfplots@current@point@data}%
+ \expandafter\pgfplotsarraypushback\expandafter{\pgfmathresult}\to\pgfp@boxplot@@
+ %
+ \let\pgfplotsplothandlerboxplot@last=\pgfplots@current@point@data
+ %
+ \advance\c@pgfplots@coordindex by1
+}
+% =============================================================
+
+\def\pgfplotsplothandlerboxplotprepared{%
+ \ifpgfplots@stackedmode
+ \pgfplotsthrow{unsupported operation}{Sorry, 'stacked plots' are currently unsupported for box plots. See the manual for 'boxplot/draw position' for how to achieve the effect (using \string\plotnumofactualtype)}\pgfeov
+ \else
+ \pgfplotsplothandlerboxplotprepared@
+ \fi
+}
+\def\pgfplotsplothandlerboxplotprepared@{%
+ \pgfplotsresetplothandler
+ %
+ \def\pgfplotsplothandlername{boxplot prepared}%
+ %
+ \let\pgf@plotstreamstart=\pgfplotsplothandlervisstart@boxplot@prepared
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@boxplot@prepared
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@boxplot@prepared
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@boxplot@prepared
+ %
+ \pgfplotsplothandlerboxplotprepared@normalize@values
+ %
+ \pgfkeysgetvalue{/pgfplots/boxplot/draw direction}\pgfplots@loc@TMPa
+ \if x\pgfplotsboxplotvalue{draw direction}%
+ \else
+ \if y\pgfplotsboxplotvalue{draw direction}%
+ \else
+ \pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Invalid choice boxplot/draw direction=\pgfplots@loc@TMPa}\pgfeov%
+ \def\pgfplots@loc@TMPa{x}%
+ \fi
+ \fi
+ \csname pgfplotsplothandlerboxplotprepared@setxy@\pgfplots@loc@TMPa\endcsname
+ %
+ \def\pgfplotsboxplotpointab##1##2{%
+ \begingroup
+ \pgfkeys{/pgf/fpu}%
+ \pgfmathparse{##1}%
+ \let\pgfplotsplothandlerboxplot@@=\pgfmathresult
+ \pgfmathparse{\pgfplotsboxplotvalue{draw position} + ##2}%
+ \xdef\pgfplots@glob@TMPa{{\pgfplotsplothandlerboxplot@@}{\pgfmathresult}}%
+ \expandafter\pgfplotsboxplotpointab@\pgfplots@glob@TMPa{\pgfplotspointaxisxy}%
+ \pgf@process{}%
+ \endgroup
+ }%
+ \def\pgfplotsboxplotpointab@survey##1##2{%
+ \edef\pgfmathresult{##1}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfmathparse{\pgfmathresult}%
+ \fi
+ \let\pgfplotsplothandlerboxplot@@=\pgfmathresult
+ \pgfmathparse{\pgfplotsboxplotvalue{draw position} + ##2}%
+ \xdef\pgfplots@glob@TMPa{{\pgfplotsplothandlerboxplot@@}{\pgfmathresult}}%
+ \let\pgfplotsplothandlerboxplot@modified@draw@position=\pgfmathresult%
+ \expandafter\pgfplotsboxplotpointab@\pgfplots@glob@TMPa{\pgfplotsboxplotpointab@@define@current@xy}%
+ }%
+}%
+
+\def\pgfplotsplothandlerboxplotprepared@normalize@values{%
+ \def\pgfplots@loc@TMPa{auto}%
+ \pgfplotsforeachentryinCSV{\value}{%
+ lower whisker,%
+ lower quartile,%
+ median,%
+ average,%
+ upper quartile,%
+ upper whisker,%
+ sample size%
+ }{%
+ \pgfkeysgetvalue{/pgfplots/boxplot/\value}\pgfplots@loc@TMPb
+ \edef\pgfplots@loc@TMPb{\pgfplots@loc@TMPb}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ \pgfkeyslet{/pgfplots/boxplot/\value}\pgfutil@empty
+ \fi
+ }%
+}%
+
+\def\pgfplotsboxplotpointab@@define@current@xy#1#2{%
+ \edef\pgfplots@current@point@x{#1}%
+ \edef\pgfplots@current@point@y{#2}%
+}%
+
+\def\pgfplotsplothandlerboxplotprepared@setxy@x{%
+ \def\pgfplotsboxplotpointab@##1##2##3{%
+ ##3{##1}{##2}%
+ }%
+}%
+\def\pgfplotsplothandlerboxplotprepared@setxy@y{%
+ \def\pgfplotsboxplotpointab@##1##2##3{%
+ ##3{##2}{##1}%
+ }%
+}%
+
+\def\pgfplotsplothandlersurveypoint@boxplot@collect@limits{%
+ \pgfplotsaxisparsecoordinate
+ \pgfplotsaxispreparecoordinate
+ \ifpgfplotsaxisparsecoordinateok
+ \pgfplotsaxisupdatelimitsforcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z
+ \fi
+ %
+ % do NOT store the processed coordinate! the coordinate stream
+ % is ONLY for outliers.
+ %
+ % ... but update this stuff to avoid a "plot without coordinates"
+ % case
+ \pgfplotscoordstream@firstlast@update
+}
+
+\def\pgfplotsplothandlersurveystart@boxplot@prepared{%
+ \pgfplots@prepare@source@parser@for{boxplot/}{data}{\pgfplotsplothandlerboxplot@parse}%
+ %
+ \let\pgfplotsboxplotpointab=\pgfplotsboxplotpointab@survey
+ %
+ \pgfplotsplothandlersurveystart@default
+}
+
+\def\pgfplotsplothandlersurveypoint@boxplot@prepared{%
+ % seems the "parse" routine is stupid ... the /data point/ stuff
+ % is redefined although it should not. Strange...
+ \pgfkeyslet{/data point/x}\pgfplots@current@point@x
+ \pgfkeyslet{/data point/y}\pgfplots@current@point@y
+ \pgfkeyslet{/data point/z}\pgfplots@current@point@z
+ \pgfplotsplothandlerboxplot@parse
+ %
+ \pgfplotsboxplotpointab{\pgfmathresult}{0}%
+ %
+ \pgfplotsplothandlersurveypoint@default
+}
+
+\def\pgfplotsplothandlersurveyend@boxplot@prepared{%
+ \let\pgfplots@invoke@filter@xyz@old=\pgfplots@invoke@filter@xyz
+ \let\pgfplots@invoke@filter@xyz=\relax
+ \let\pgfplots@invoke@filter@old=\pgfplots@invoke@filter
+ \def\pgfplots@invoke@filter##1##2{}%
+ \let\pgfplots@invoke@prefilter@old=\pgfplots@invoke@prefilter
+ \let\pgfplots@invoke@prefilter=\relax
+ %
+ \pgfmathparse{\pgfplotsboxplotvalue{draw position}}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \ifpgfplots@usefpu
+ \pgfmathfloattofixed\pgfmathresult
+ \fi
+ % remember it for later - it might have been retrieved from some
+ % table column! If you used something like
+ % 'draw position=\thisrow{position}, the position of the LAST data point
+ % will be used (because we are in end survey here).
+ \edef\pgfplots@loc@TMPb{\noexpand\pgfplotsplothandlersurveyaddoptions{/pgfplots/boxplot/draw position=\pgfmathresult}}%
+ \pgfplots@loc@TMPb
+ %
+ % ... this here will make things faster if the FPU is active.
+ \pgfkeyslet{/pgfplots/boxplot/draw position}\pgfplots@loc@TMPa
+ %
+ %
+ %
+ %
+ \pgfplotsboxplotpointabwhisker
+ {\pgfplotsboxplotvalue{lower whisker}}
+ {0}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ \pgfplotsboxplotpointabwhisker
+ {\pgfplotsboxplotvalue{lower whisker}}
+ {1}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ %
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{lower quartile}}%
+ {0}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{lower quartile}}%
+ {1}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ %
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{median}}
+ {0}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{median}}
+ {1}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ %
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{average}}
+ {0}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{average}}
+ {1}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ %
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{upper quartile}}%
+ {0}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ \pgfplotsboxplotpointabbox
+ {\pgfplotsboxplotvalue{upper quartile}}%
+ {1}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ %
+ %
+ \pgfplotsboxplotpointabwhisker
+ {\pgfplotsboxplotvalue{upper whisker}}%
+ {1}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ \pgfplotsboxplotpointabwhisker
+ {\pgfplotsboxplotvalue{upper whisker}}%
+ {0}%
+ \pgfplotsplothandlersurveypoint@boxplot@collect@limits
+ %
+ \let\pgfplots@invoke@prefilter=\pgfplots@invoke@prefilter@old
+ \let\pgfplots@invoke@filter=\pgfplots@invoke@filter@old
+ \let\pgfplots@invoke@filter@xyz=\pgfplots@invoke@filter@xyz@old
+ %
+ \pgfplotsplothandlerboxplotsurvey@variable@width%
+ %
+ \pgfplotsplothandlersurveyend@default
+}%
+
+\def\pgfplotsplothandlerboxplotsurvey@variable@width{%
+ \ifnum\plotnumofactualtype=0 %
+ % Ah - the first boxplot in this axis. Init the global
+ % counter:
+ \pgfplotscoordmath{default}{max limit}%
+ \global\let\g@pgfplotsplothandlerboxplot@widthkey@min=\pgfmathresult
+ \pgfplotscoordmath{default}{min limit}%
+ \global\let\g@pgfplotsplothandlerboxplot@widthkey@max=\pgfmathresult
+ \fi
+ %
+ %
+ \ifpgfplotsplothandlerboxplot@variable@width
+ \pgfkeysgetvalue{/pgfplots/boxplot/sample size}\pgfmathresult
+ \edef\pgfmathresult{\pgfmathresult}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfplotsplothandlerboxplot@variable@width@expr{\pgfmathresult}%
+ %
+ \let\pgfplots@widthkey@=\pgfmathresult
+ %
+ \pgfkeysgetvalue{/pgfplots/boxplot/sample size min}\pgfmathresult
+ \edef\pgfplotsplothandlerboxplot@widthkey@min{\pgfmathresult}%
+ %
+ \pgfkeysgetvalue{/pgfplots/boxplot/sample size max}\pgfmathresult
+ \edef\pgfplotsplothandlerboxplot@widthkey@max{\pgfmathresult}%
+ %
+ %
+ \ifx\pgfplotsplothandlerboxplot@widthkey@min\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@widthkey@min=\g@pgfplotsplothandlerboxplot@widthkey@min
+ \def\pgfplotsplothandlerboxplot@widthkey@min@autocompute{1}%
+ \else
+ \pgfplotsplothandlerboxplot@variable@width@expr{\pgfplotsplothandlerboxplot@widthkey@min}%
+ \let\pgfplotsplothandlerboxplot@widthkey@min=\pgfmathresult
+ \def\pgfplotsplothandlerboxplot@widthkey@min@autocompute{0}%
+ \fi
+ \ifx\pgfplotsplothandlerboxplot@widthkey@max\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@widthkey@max=\g@pgfplotsplothandlerboxplot@widthkey@max
+ \def\pgfplotsplothandlerboxplot@widthkey@max@autocompute{1}%
+ \else
+ \pgfplotsplothandlerboxplot@variable@width@expr{\pgfplotsplothandlerboxplot@widthkey@max}%
+ \def\pgfplotsplothandlerboxplot@widthkey@max@autocompute{0}%
+ \fi
+ %
+ \if1\pgfplotsplothandlerboxplot@widthkey@max@autocompute
+ \pgfmathparse{max(\pgfplotsplothandlerboxplot@widthkey@max,\pgfplots@widthkey@)}%
+ \global\let\g@pgfplotsplothandlerboxplot@widthkey@max=\pgfmathresult
+ \let\pgfplotsplothandlerboxplot@widthkey@max=\pgfmathresult
+ %
+ \pgfmathparse{min(\pgfplotsplothandlerboxplot@widthkey@min,\pgfplots@widthkey@)}%
+ \global\let\g@pgfplotsplothandlerboxplot@widthkey@min=\pgfmathresult
+ \let\pgfplotsplothandlerboxplot@widthkey@min=\pgfmathresult
+ \fi
+ %
+ %
+ \fi
+ \fi
+ %
+%\message{sample size=\pgfplots@widthkey@. interval = \pgfplotsplothandlerboxplot@widthkey@min:\pgfplotsplothandlerboxplot@widthkey@max^^J}%
+}%
+
+\def\pgfplotsplothandlerboxplot@variable@width@expr#1{%
+ \begingroup
+ \pgfkeys{/pgf/fpu}%
+ \let\pgfmathresult=#1%
+ \pgfplotsboxplotvalue{variable width expr/.@cmd}#1\pgfeov
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \let#1=\pgfmathresult
+}%
+
+\def\pgfplotsplothandlerboxplotvisualization@variable@width{%
+ \ifpgfplotsplothandlerboxplot@variable@width
+ \pgfkeysgetvalue{/pgfplots/boxplot/sample size}\pgfmathresult
+ \edef\pgfmathresult{\pgfmathresult}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \else
+ \pgfplotsplothandlerboxplot@variable@width@expr{\pgfmathresult}%
+ \let\pgfplots@widthkey@=\pgfmathresult
+ %
+ \pgfkeysgetvalue{/pgfplots/boxplot/sample size min}\pgfmathresult
+ \edef\pgfplotsplothandlerboxplot@widthkey@min{\pgfmathresult}%
+ %
+ \pgfkeysgetvalue{/pgfplots/boxplot/sample size max}\pgfmathresult
+ \edef\pgfplotsplothandlerboxplot@widthkey@max{\pgfmathresult}%
+ %
+ %
+ \ifx\pgfplotsplothandlerboxplot@widthkey@min\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@widthkey@min=\g@pgfplotsplothandlerboxplot@widthkey@min
+ \else
+ \pgfplotsplothandlerboxplot@variable@width@expr{\pgfplotsplothandlerboxplot@widthkey@min}%
+ \fi
+ \ifx\pgfplotsplothandlerboxplot@widthkey@max\pgfutil@empty
+ \let\pgfplotsplothandlerboxplot@widthkey@max=\g@pgfplotsplothandlerboxplot@widthkey@max
+ \else
+ \pgfplotsplothandlerboxplot@variable@width@expr{\pgfplotsplothandlerboxplot@widthkey@max}%
+ \fi
+ %
+ \pgfkeysgetvalue{/pgfplots/boxplot/variable width min target}\pgfplots@widthkey@mintrg
+ \pgfkeysgetvalue{/pgfplots/boxplot/box extend}\pgfplots@loc@TMPa
+ %\message{sample size=\pgfplots@widthkey@. interval = \pgfplotsplothandlerboxplot@widthkey@min:\pgfplotsplothandlerboxplot@widthkey@max. Target = [\pgfplots@widthkey@mintrg:1]^^J}%
+ \begingroup
+ \pgfkeys{/pgf/fpu}%
+ \pgfmathparse{
+ (\pgfplots@widthkey@mintrg +
+ max(0,min(1,(\pgfplots@widthkey@ - \pgfplotsplothandlerboxplot@widthkey@min) /
+ (\pgfplotsplothandlerboxplot@widthkey@max - \pgfplotsplothandlerboxplot@widthkey@min)))
+ * (1-\pgfplots@widthkey@mintrg)) * \pgfplots@loc@TMPa}%
+ \pgfmathfloattofixed\pgfmathresult
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \pgfkeyslet{/pgfplots/boxplot/box extend}\pgfmathresult
+ \fi
+ \fi
+}%
+
+\def\pgfplotsplothandlervisstart@boxplot@prepared{%
+ %
+ \pgfplotsplothandlerboxplotvisualization@variable@width
+ %
+ \global\let\pgf@plotstreampoint=\pgfutil@gobble
+ \global\let\pgf@plotstreamspecial=\pgfutil@gobble%
+ \global\let\pgf@plotstreamend=\relax
+ %
+ \pgfplotsplothandlervisstart@boxplot@prepared@draw
+}%
+
+\def\pgfplotsplothandlervisstart@boxplot@prepared@draw{%
+ \def\b@pgfplots@boxplot@hasbox{1}%
+ \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{lower quartile}}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \def\b@pgfplots@boxplot@hasbox{0}%
+ \fi
+ \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{upper quartile}}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \def\b@pgfplots@boxplot@hasbox{0}%
+ \fi
+ %
+ \if0\b@pgfplots@boxplot@hasbox
+ % hm. we have no box. Very strange boxplot, I'd say.
+ %
+ % But anyway: if someone has whiskers without box,
+ % short-circuit the whiskers:
+ \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{lower whisker}}%
+ \edef\pgfplots@loc@TMPb{\pgfplotsboxplotvalue{upper whisker}}%
+ \pgfkeyslet{/pgfplots/boxplot/lower quartile}\pgfplots@loc@TMPb
+ \pgfkeyslet{/pgfplots/boxplot/upper quartile}\pgfplots@loc@TMPa
+ \fi
+ %
+ %
+ \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{lower whisker}}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotsboxplotvalue{draw/lower whisker/.@cmd}\pgfeov
+ \fi
+ %
+ \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{upper whisker}}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotsboxplotvalue{draw/upper whisker/.@cmd}\pgfeov
+ \fi
+ %
+ \if1\b@pgfplots@boxplot@hasbox
+ \pgfplotsboxplotvalue{draw/box/.@cmd}\pgfeov
+ \fi
+ %
+ \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{median}}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotsboxplotvalue{draw/median/.@cmd}\pgfeov
+ \fi
+ %
+ \edef\pgfplots@loc@TMPa{\pgfplotsboxplotvalue{average}}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \pgfplotsboxplotvalue{draw/average/.@cmd}\pgfeov
+ \fi
+}%
+
+\def\pgfplots@boxplot@cs@decompose#1{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \expandafter\pgfutil@in@\expandafter,\expandafter{\pgfplots@loc@TMPa}%
+ \ifpgfutil@in@
+ \def\pgfplots@loc@TMPb##1,##2\pgfplots@EOI{%
+ \def\pgfplots@boxplotcs@a{##1}%
+ \def\pgfplots@boxplotcs@b{##2}%
+ }%
+ \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI
+ \else
+ \let\pgfplots@boxplotcs@a=\pgfplots@loc@TMPa%
+ \def\pgfplots@boxplotcs@b{0}%
+ \fi
+}%
+
+\def\pgfplotsboxplotvalue#1{\pgfkeysvalueof{/pgfplots/boxplot/#1}}%
+
+\tikzaddtikzonlycommandshortcutlet\boxplotvalue\pgfplotsboxplotvalue
+
+% A helper which implements 'draw relative anchor'. It expands to a
+% math expression which is suitable as second argument for 'boxplot cs';
+% i.e. it needs to be added to 'boxplot/draw position'.
+%
+% More precisely, this macro is to be used in a context where lines of
+% 'box extend' length have to be drawn.
+%
+% The argument is shifted by 'draw relative anchor' and is scaled by
+% 'box extend'.
+%
+% #1: the coordinate. 0 is the means "lower part of the construct
+% which is to be drawn". 1 means the "upper part of that construct"
+% and 0.5 is in the middle.
+\def\pgfplots@boxplot@anchor@value#1{%
+ (#1-\pgfplotsboxplotvalue{draw relative anchor})*\pgfplotsboxplotvalue{box extend}%
+}
+
+% same as \pgfplots@boxplot@anchor@value, but for drawing constructs
+% which are at most 'whisker extend' long.
+\def\pgfplots@boxplot@anchor@value@whisker#1{%
+ (#1-\pgfplotsboxplotvalue{draw relative anchor})*\pgfplotsboxplotvalue{whisker extend}%
+}
+
+\def\pgfplotsboxplotpointabbox#1#2{%
+ \pgfplotsboxplotpointab{#1}{\pgfplots@boxplot@anchor@value{#2}}%
+}%
+\def\pgfplotsboxplotpointabwhisker#1#2{%
+ \pgfplotsboxplotpointab{#1}{\pgfplots@boxplot@anchor@value@whisker{#2}}%
+}%
+
+\tikzdeclarecoordinatesystem{boxplot}{%
+ \pgfplots@boxplot@cs@decompose{#1}%
+ \pgfplotsboxplotpointab{\pgfplots@boxplotcs@a}{\pgfplots@boxplotcs@b}%
+}%
+
+\tikzdeclarecoordinatesystem{boxplot box}{%
+ \pgfplots@boxplot@cs@decompose{#1}%
+ \pgfplotsboxplotpointabbox{\pgfplots@boxplotcs@a}{\pgfplots@boxplotcs@b}%
+}%
+
+\tikzdeclarecoordinatesystem{boxplot whisker}{%
+ \pgfplots@boxplot@cs@decompose{#1}%
+ \pgfplotsboxplotpointabwhisker{\pgfplots@boxplotcs@a}{\pgfplots@boxplotcs@b}%
+}%
+
+\catcode`\;=\pgfplots@oldcatcodesemicolon
+\catcode`\"=\pgfplots@oldcatcodedoublequote
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.ternary.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.ternary.code.tex
new file mode 100644
index 0000000000..cefa4fd82a
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.ternary.code.tex
@@ -0,0 +1,928 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for ternary plots (triangular axes).
+%
+% Copyright 2010 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 a library to draw ternary diagrams.
+%
+% A ternary diagram visualizes percentages of three components in a
+% triangle.
+%
+% Sometimes there is also contour data drawn on top of the ternary
+% diagram, i.e. data (x,y,z, T(x,y,z) ), but I can't do that yet.
+%
+% How to read a ternary diagram: http://csmres.jmu.edu/geollab/fichter/SedRx/readternary.html
+%
+% Another usage example: http://www.sv.vt.edu/classes/MSE2094_NoteBook/96ClassProj/experimental/ternary2.html
+%
+% Drawing ternary diagrams: http://staff.aist.go.jp/a.noda/programs/ternary/ternary-en.html
+%
+% computing these coordinates: http://www.gamedev.net/community/forums/topic.asp?topic_id=451357
+%
+
+\pgfplotsdefineaxistype{ternary}{%
+ \pgfplots@ternary@activate
+}%
+
+\newif\ifpgfplots@ternary@rellimits
+
+
+\pgfplotsset{
+ /pgfplots/ternary limits relative/.is if=pgfplots@ternary@rellimits,
+ /pgfplots/ternary limits relative=true,
+ /pgfplots/ternary limits relative/.default=true,
+ /pgfplots/ternary relative limits/.style={/pgfplots/ternary limits relative=#1},
+ /pgfplots/ternary start x/.initial=, % FIXME : implement
+ /pgfplots/ternary start y/.initial=,
+ /pgfplots/ternary start z/.initial=,
+ /pgfplots/every ternary axis/.style={
+ /pgfplots/tick align=outside,
+ grid=major,
+ xticklabel style={anchor=west},
+ % yticklabel style={anchor=south east},
+ % zticklabel style={anchor=north},
+ /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 axis z 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/every z tick scale label/.style={at={(yticklabel cs:0.95,5pt)},anchor=near yticklabel,inner sep=0pt},
+ /pgfplots/every axis title shift=15pt,
+ /pgfplots/every axis legend/.style={%
+ cells={anchor=center},
+ inner xsep=3pt,inner ysep=2pt,nodes={inner sep=2pt,text depth=0.15em},
+ shape=rectangle,%
+ fill=white,%
+ draw=black,
+ at={(1.03,1.03)},
+ anchor=north west,%
+ },
+ annot/point format 3d/.initial={(\%.2f, \%.2f, \%.2f)},
+ },
+}
+
+\def\pgfplots@ternary@activate{%
+ \let\pgfplotsqpointxy=\pgfplotsqpointxy@ternary
+ \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy
+ \let\pgfplotsqpointxyz=\pgfplotsqpointxyz@ternary
+ \let\pgfplots@draw@axis=\pgfplots@draw@axis@ternary
+ \def\pgfplots@drawaxis@outerlines@separate@onorientedsurf##1##2{}%
+ \def\pgfplots@drawaxis@innerlines@onorientedsurf##1##2##3{}%
+ \let\pgfplots@draw@axis@post=\pgfplots@draw@axis@post@ternary
+ \let\pgfplots@initsizes=\pgfplots@initsizes@ternary
+ \let\pgfplots@limits@ready=\pgfplots@limits@ready@ternary
+ \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@ternary
+ \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@ternary
+ \let\pgfplots@initsizes@setunitvector=\pgfplots@initsizes@setunitvector@ternary
+ \let\pgfplots@computeunitvectorlengths=\pgfplots@computeunitvectorlengths@ternary
+ \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@ternary
+ \let\pgfplots@prepare@ZERO@coordinates=\pgfplots@prepare@ZERO@coordinates@ternary
+ \def\pgfplots@scaleaxes@to@BB@##1##2{}%
+ \let\pgfplotsgetnormalforcurrentview=\relax
+ \def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf##1{}%
+ \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@ternary
+ %
+ \pgfkeys{/pgfplots/oriented surf installed/.add={}{%
+ \let\pgfplotspointonorientedsurfaceab@ternary@orig=\pgfplotspointonorientedsurfaceab
+ \let\pgfplotspointonorientedsurfaceab=\pgfplotspointonorientedsurfaceab@ternary
+ }}%
+ \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@ternary
+ \pgfkeyssetvalue{/pgfplots/view/az}{}%
+ \pgfkeyssetvalue{/pgfplots/view/el}{}%
+ \let\pgfplots@set@options@sanitize=\relax
+ \let\pgfplots@set@options@sanitizemode=\relax
+ %
+ \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{\pgfplots@notify@options@are@set
+ \ifpgfplots@ternary@rellimits
+ \pgfplotsset{scaled ticks=false,ticklabel style={/pgf/number format/precision=0}}%
+ \let\pgfplots@show@ticklabel@orig=\pgfplots@show@ticklabel@
+ \let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@ternary@relative
+ \fi
+ }%
+ %
+ % this here is set *before* 'every ternary axis' is invoked.
+ \pgfplotsset{
+ /pgfplots/footnotesize/.append style= {/pgfplots/every axis title shift=15pt},%
+ /pgfplots/tiny/.append style= {/pgfplots/every axis title shift=15pt},%
+ enlargelimits=false,
+ xmin=0,xmax=1,
+ ymin=0,ymax=1,
+ zmin=0,zmax=1,
+ annot/point format/.style={/pgfplots/annot/point format 3d={##1}},
+ }%
+ \def\pgfplots@xticklabel@pos{}%
+ \def\pgfplots@yticklabel@pos{}%
+ \def\pgfplots@zticklabel@pos{}%
+ %\def\pgfplots@xaxislinesnum{1}%
+ %\def\pgfplots@yaxislinesnum{3}%
+ %\def\pgfplots@zaxislinesnum{3}%
+ \def\pgfplotsifaxissurfaceisforeground##1##2##3{##2}%
+ \def\pgfplots@init@ticklabelaxisspecfor##1##2{}%
+ \def\pgfplots@xticklabelaxisspec{v00}%
+ \def\pgfplots@yticklabelaxisspec{0v0}%
+ \def\pgfplots@zticklabelaxisspec{00v}%
+ \def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@##1##2##3{%
+ \pgfplotspointonorientedsurfaceabtolinespec v##1%
+ \edef\pgfplots@loc@TMPe{\csname pgfplots@\pgfplotspointonorientedsurfaceA ticklabelaxisspec\endcsname}%
+ \ifx\pgfplots@loc@TMPe\pgfplotsretval
+%\message{pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@{##1}---> TRUE.}%
+ ##2%
+ \else
+%\message{pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@{##1}---> FALSE.}%
+ ##3%
+ \fi
+ }%
+ \def\pgfplots@ifgridlines@onorientedsurf@should@be@drawn##1##2{%
+ ##1% FIXME
+ }%
+ \def\pgfplotspointonorientedsurfaceabmatchaxisline##1##2{%
+ \pgfplotspointonorientedsurfaceabtolinespec v0% FIXME that's just a bad guess!
+ \edef\pgfplots@loc@TMPe{##1}%
+ \ifx\pgfplots@loc@TMPe\pgfplotsretval
+ \def##2{0}%
+ \else
+ \def##2{}%
+ \fi
+ }%
+ \let\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn=\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@%
+ %
+ %
+ % cartesian cs
+ \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end}
+}%
+
+\def\pgfplots@show@ticklabel@ternary@relative#1#2{%
+ \csname pgfplots@ternary@map@to@unit@#1\endcsname{#2}%
+ \pgfmathfloatparsenumber\pgfmathresult
+ \pgfmathfloatshift@\pgfmathresult{2}%
+ \let\tick=\pgfmathresult
+}%
+
+\def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{%
+ \pgfpointxy@orig{#1}{#2}%
+}%
+
+% This here is *the* key point why ternary axes can be processed with
+% almost the same code as rectangular axes.
+%
+% Recall that rectangular axes are drawn using "oriented surfaces",
+% the complete code is based on them. The "a" axis is the direction in
+% which we have tick positions and the "b" axis is the direction in
+% which tick lines (or grid lines) shall be drawn).
+%
+% Now, ternary axes do not directly fit into the "oriented surface"
+% framework. But they have a lot of structure which allows to use it
+% with a specialed "pointonorientedsurfaceab" routine: by noting that
+% - there are only three axes,
+% - the axis containing tick lines (and grid lines) *always* has one
+% component set to 0 (lower limit), and the remaining two components
+% sum to 1. Thus, we can simply use one value (for example the "a"
+% value) and compute the remaining one,
+% - \pgfplotspointonorientedsurfaceab is *always* invoked with
+% b set to either the lower or the upper limit.
+% The lower limit is easy, see above. The upper limit is mainly used
+% for grid lines, more precisely it denotes the target point of the grid line.
+% I use special handling to find this target point (by exchanging
+% coordinate components, see the implementation).
+%
+% #1: the "a" value on the oriented surf
+% #2: the "b" value. Note that *only* the lower *or* the upper limit
+% on the "b" axis are supported here!
+%
+\def\pgfplotspointonorientedsurfaceab@ternary#1#2{%
+ \let\pgfplotspointonorientedsurfaceab@ternary@fixedx=\pgfplotspointonorientedsurfaceabsetupfor@fixedx
+ \let\pgfplotspointonorientedsurfaceab@ternary@fixedy=\pgfplotspointonorientedsurfaceabsetupfor@fixedy
+ \let\pgfplotspointonorientedsurfaceab@ternary@fixedz=\pgfplotspointonorientedsurfaceabsetupfor@fixedz
+ %
+%\message{\string\pgfplotspointonorientedsurfaceab{#1}{#2} -----> }%
+ \ifpgfplots@ternary@next@is@unitinterval
+ \edef\pgfplotspointonorientedsurfaceab@ternary@A{#1}%
+ \edef\pgfplotspointonorientedsurfaceab@ternary@B{#2}%
+ \else
+ \csname pgfplots@ternary@map@to@unit@\pgfplotspointonorientedsurfaceA\endcsname{#1}%
+ \let\pgfplotspointonorientedsurfaceab@ternary@A=\pgfmathresult
+ %
+ \csname pgfplots@ternary@map@to@unit@\pgfplotspointonorientedsurfaceB\endcsname{#2}%
+ \let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfmathresult
+ \fi
+ \if0\pgfplotspointonorientedsurfacespecsymbol
+ \else
+ \pgfplots@error{Internal processing error: only \string\pgfplotspointonorientedsurfaceab\space for ternary axes works only for oriented surfs fixed to LOWER or UPPER axis limits.}%
+ \fi
+%\message{A=\pgfplotspointonorientedsurfaceab@ternary@A; B=\pgfplotspointonorientedsurfaceab@ternary@B -----> }%
+ \ifdim\pgfplotspointonorientedsurfaceab@ternary@B pt=0pt
+ \pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}%
+ \let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfmathresult
+ \expandafter\def\csname pgfplotspointonorientedsurfaceabsetupfor@fixed\pgfplotspointonorientedsurfaceN\endcsname{0}%
+ \else
+ %\let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceab@ternary@A
+ %\pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}%
+ %\let\pgfplotspointonorientedsurfaceab@ternary@A=\pgfmathresult
+ %\let\pgfplotspointonorientedsurfaceab@ternary@B=\pgfplots@loc@TMPa
+ \pgfmath@basic@subtract@{1}{\pgfplotspointonorientedsurfaceab@ternary@A}%
+ \def\pgfplotspointonorientedsurfaceab@ternary@B{0}%
+ \expandafter\let\csname pgfplotspointonorientedsurfaceabsetupfor@fixed\pgfplotspointonorientedsurfaceN\endcsname=\pgfmathresult%
+ \fi
+ %
+ \global\pgfplots@ternary@next@is@unitintervaltrue
+%\message{\string\pgfplotspointonorientedsurfaceab@orig{\pgfplotspointonorientedsurfaceab@ternary@A}{\pgfplotspointonorientedsurfaceab@ternary@B}[fixedsymbol=\pgfplotspointonorientedsurfacespecsymbol; a=\pgfplotspointonorientedsurfaceA,b=\pgfplotspointonorientedsurfaceB.]}%
+ \pgfplotspointonorientedsurfaceab@ternary@orig
+ {\pgfplotspointonorientedsurfaceab@ternary@A}%
+ {\pgfplotspointonorientedsurfaceab@ternary@B}%
+ %
+ \let\pgfplotspointonorientedsurfaceabsetupfor@fixedx=\pgfplotspointonorientedsurfaceab@ternary@fixedx
+ \let\pgfplotspointonorientedsurfaceabsetupfor@fixedy=\pgfplotspointonorientedsurfaceab@ternary@fixedy
+ \let\pgfplotspointonorientedsurfaceabsetupfor@fixedz=\pgfplotspointonorientedsurfaceab@ternary@fixedz
+}%
+
+\def\pgfplotspointonorientedsurfaceabwithbshift@ternary#1#2#3{%
+ % implement the shift in "b" direction explicitly:
+ %
+ \pgfplotspointonorientedsurfaceab@ternary{#1}{#2}%
+ \edef\pgfplots@loc@TMPe{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ \pgfpointadd
+ {\pgfplots@loc@TMPe}%
+ {%
+ \begingroup
+ % I need a '-' here because for ternary axes, the "b" axis
+ % points to the *outside* instead of the inside.
+ \pgf@xa=-#3\relax
+ \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}%
+ % oh. a reversed axis.
+ \pgf@xa=-\pgf@xa
+ \fi
+ \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xa}%
+ \pgfmath@basic@multiply@{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}{\pgfplots@loc@TMPa}%
+ \pgfmath@smuggleone\pgfmathresult
+ \endgroup
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfqpointscale{\pgfplots@loc@TMPa}{\csname pgfplotspointunit\pgfplotspointonorientedsurfaceB\endcsname}%
+ }%
+}
+
+
+\let\pgfplots@initsizes@ternary@orig=\pgfplots@initsizes
+\def\pgfplots@initsizes@ternary{%
+ \ifpgfplots@threedim
+ \else
+ \pgfplots@error{Sorry, 'axis type=ternary' needs a three dimensional axes. Make sure you supplied three dimensional coordinates (using \string\addplot3, for example). This error is critical; I can't recover}%
+ \fi
+ %
+ \pgfplots@initsizes@get@width@withoutlabels
+ \pgf@x=\pgfmathresult
+ \edef\pgfplots@width@ternary{\pgf@sys@tonumber\pgf@x}%
+ %
+ \pgfplots@initsizes@ternary@orig
+ %
+}%
+
+\let\pgfplots@limits@ready@original=\pgfplots@limits@ready
+
+\def\pgfplots@limits@ready@ternary{%
+ \pgfplots@limits@ready@original
+ %
+%\message{ternary with limits x=[\pgfplots@xmin:\pgfplots@xmax], y=[\pgfplots@ymin:\pgfplots@ymax]; z=[\pgfplots@zmin:\pgfplots@zmax].}%
+ \pgfplots@ternary@init@map@to@unit x%
+ \pgfplots@ternary@init@map@to@unit y%
+ \pgfplots@ternary@init@map@to@unit z%
+}%
+
+\def\pgfplots@ternary@init@map@to@unit#1{%
+ \begingroup
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@#1max\endcsname}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@#1min\endcsname}%
+ \let\pgfplots@map@to@unit@scale@diff=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@loc@TMPa}{\pgfmathresult}}%
+ \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfmathresult}}%
+ \let\pgfplots@map@to@unit@scale=\pgfmathresult
+ %
+ \expandafter\xdef\csname pgfplots@ternary@map@to@unit@#1\endcsname##1{%
+ \noexpand\pgfplotscoordmath{default}{parsenumber}{##1}%
+ \noexpand\pgfplotscoordmath{default}{op}{subtract}{{\noexpand\pgfmathresult}{\pgfplots@map@to@unit@scale@diff}}%
+ \noexpand\pgfplotscoordmath{default}{op}{multiply}{{\noexpand\pgfmathresult}{\pgfplots@map@to@unit@scale}}%
+ \noexpand\pgfplotscoordmath{default}{tofixed}{\noexpand\pgfmathresult}%
+ }%
+ \endgroup
+}
+
+\def\pgfplots@initsizes@setunitvector@ternary#1#2#3#4{%
+ % ternary axis are DIFFERENT here.
+ % They don't use the (xx,xy), (yx,yy), (zx,zy) vectors, so we can
+ % use them to implement *cartesian* coordinates.
+ %
+ % Thus, any \draw (0,0) inside of a ternary axis will yield
+ % cartesian coordinates.
+ %
+ % The relevant quantities to *draw* the diagram are the three
+ % axis, they are also prepared here.
+ %
+ \def#4{0}% whether we have (#1,0) or (0,#1)
+ \ifcase#2%
+ \pgfsetxvec{%
+ \pgfqpoint{\pgfplots@width@ternary pt}{0pt}%
+ }%
+ \pgfpointdiff
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001}
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100}%
+ \or
+ \pgfsetyvec{%
+ \pgfqpoint{0pt}{\pgfplots@width@ternary pt}%
+ }%
+ \pgfpointdiff
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100}
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010}%
+ \or
+ \pgfsetzvec{%
+ \pgfpointorigin
+ }%
+ \pgfpointdiff
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010}
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001}%
+ \fi
+ \expandafter\xdef\csname pgfplotspoint#1axis\endcsname{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
+ %
+%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).}%
+}%
+
+\def\pgfplots@computeunitvectorlengths@ternary{%
+ \pgfplots@computeunitvectorlengths@ternary@ x%
+ \pgfplots@computeunitvectorlengths@ternary@ y%
+ \pgfplots@computeunitvectorlengths@ternary@ z%
+}
+\def\pgfplots@computeunitvectorlengths@ternary@#1{%
+ \csname pgfplotspoint#1axis\endcsname
+ \pgfmathveclen{\pgf@x}{\pgf@y}%
+ \expandafter\let\csname pgfplots@#1@veclength\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
+ }%
+ \expandafter\xdef\csname pgfplotspoint#1axislength\endcsname{\pgfplots@x@veclength pt}%
+ %
+}%
+
+\newif\ifpgfplots@ternary@next@is@unitinterval
+
+% Deduce z = 1-x-y after transformation to relative coordinates.
+\def\pgfplotsqpointxy@ternary#1#2{%
+ \pgf@process{%
+ \ifpgfplots@ternary@next@is@unitinterval
+ \dimen1=#1pt
+ \dimen2=#2pt
+ \else
+ \pgfplots@ternary@map@to@unit@x{#1}%
+ \dimen1=\pgfmathresult pt
+ %
+ \pgfplots@ternary@map@to@unit@y{#2}%
+ \dimen2=\pgfmathresult pt
+ \fi
+ \dimen4=\dimen1
+ \advance\dimen4 by\dimen2
+ \dimen3=1pt
+ \advance\dimen3 by-\dimen4
+ %
+ \global\pgfplots@ternary@next@is@unitintervalfalse
+ \pgfplotsqpointxyz@ternary@
+ }%
+}%
+% gx(x,y,z) = 0.5 * (x + 2*z)/(x+y+z)
+% gy(x,y,z) = (sqrt(3) / 2) * x / (x+y+z)
+\def\pgfplotsqpointxyz@ternary#1#2#3{%
+ \pgf@process{%
+ \ifpgfplots@ternary@next@is@unitinterval
+ \dimen1=#1pt
+ \dimen2=#2pt
+ \dimen3=#3pt
+ \else
+ \pgfplots@ternary@map@to@unit@x{#1}%
+ \dimen1=\pgfmathresult pt
+ %
+ \pgfplots@ternary@map@to@unit@y{#2}%
+ \dimen2=\pgfmathresult pt
+ %
+ \pgfplots@ternary@map@to@unit@z{#3}%
+ \dimen3=\pgfmathresult pt
+ \fi
+ \global\pgfplots@ternary@next@is@unitintervalfalse
+ %
+ \pgfplotsqpointxyz@ternary@
+ }%
+}%
+\def\pgfplotsqpointxyz@ternary@{%
+ %\dimen1=#1
+ %\dimen2=#2
+ %\dimen3=#3
+ % FIXME . I didn't understand that stuff.
+ \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reversed
+ %\multiply\dimen1 by-1
+ %\advance\dimen1 by1pt
+ %\dimen1=#2
+ %\dimen2=#3
+ %\dimen3=#1
+ \fi
+ %--------------------------------------------------
+ % \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reversed
+ % \multiply\dimen2 by-1
+ % \advance\dimen2 by1pt
+ % \fi
+ % \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reversed
+ % \multiply\dimen3 by-1
+ % \advance\dimen3 by1pt
+ % \fi
+ %--------------------------------------------------
+ \pgfplotsqpointxyz@ternary@@%
+}%
+\def\pgfplotsqpointxyz@ternary@@{%
+ % Disable renormalization!?
+ %\dimen4=\dimen1
+ %\advance\dimen4 by\dimen2
+ %\advance\dimen4 by\dimen3
+ %\edef\pgfplots@ternary@sum{\pgf@sys@tonumber{\dimen4}}%
+ %\pgfmathapproxequalto@{1}{\pgfplots@ternary@sum}%
+ \pgfmathcomparisontrue
+ \ifpgfmathcomparison
+ \let\pgfplots@ternary@scale=\pgfplots@width@ternary
+ \else
+ \pgfmath@basic@divide@
+ {\pgfplots@width@ternary}%
+ {\pgfplots@ternary@sum}%
+ \let\pgfplots@ternary@scale=\pgfmathresult
+ \fi
+ %
+ \dimen4=2\dimen3
+ \advance\dimen4 by \dimen1
+ \divide\dimen4 by2
+ \pgf@x=\pgfplots@ternary@scale\dimen4
+ %
+ \dimen4=\dimen1
+ \dimen4=0.866025403784\dimen4 % *= sqrt(3)/2
+ \pgf@y=\pgfplots@ternary@scale\dimen4
+ %
+}%
+\def\pgfplotspoint@initialisation@units@ternary{%
+ \let\pgfplotspointunitx\pgfplotspointxaxis
+ \let\pgfplotspointunity\pgfplotspointyaxis
+ \let\pgfplotsunitxlength=\pgfplots@x@veclength
+ \let\pgfplotsunitylength=\pgfplots@y@veclength
+ \let\pgfplotsunitxinvlength=\pgfplots@x@inverseveclength
+ \let\pgfplotsunityinvlength=\pgfplots@y@inverseveclength
+ \ifpgfplots@threedim
+ \let\pgfplotspointunitz=\pgfplotspointzaxis
+ \let\pgfplotsunitzlength=\pgfplots@z@veclength
+ \let\pgfplotsunitzinvlength=\pgfplots@z@inverseveclength
+ \fi
+}%
+
+% POSTCONDITION: the macros
+% \pgfplotspointminminmin
+% \pgfplotspoint[xyz]axis
+% \pgfplotspoint[xyz]axislength
+% are defined (globally).
+\def\pgfplotspoint@initialisation@axes@ternary{%
+ \xdef\pgfplotspointminminmin{\noexpand\pgfpointorigin}%
+ %
+ \pgfpointdiff
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001}
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100}%
+ \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse
+ \pgfqpointscale{-1}{}%
+ \fi
+ \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
+ \pgfmathveclen{\pgf@x}{\pgf@y}%
+ \expandafter\let\csname pgfplots@x@veclength\endcsname=\pgfmathresult
+ \pgfplotsmath@ifzero{\pgfmathresult}{%
+ \expandafter\def\csname pgfplots@x@inverseveclength\endcsname{infty}%
+ }{%
+ \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@x@inverseveclength\endcsname=\pgfmathresult
+ }%
+ \xdef\pgfplotspointxaxislength{\pgfplots@x@veclength pt}%
+ %
+ \pgfpointdiff
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary100}
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010}%
+ \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse
+ \pgfqpointscale{-1}{}%
+ \fi
+ \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
+ \pgfmathveclen{\pgf@x}{\pgf@y}%
+ \expandafter\let\csname pgfplots@y@veclength\endcsname=\pgfmathresult
+ \pgfplotsmath@ifzero{\pgfmathresult}{%
+ \expandafter\def\csname pgfplots@y@inverseveclength\endcsname{infty}%
+ }{%
+ \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@y@inverseveclength\endcsname=\pgfmathresult
+ }%
+ \xdef\pgfplotspointyaxislength{\pgfplots@y@veclength pt}%
+ %
+ \pgfpointdiff
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary010}
+ {\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz@ternary001}%
+ \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse
+ \pgfqpointscale{-1}{}%
+ \fi
+ \xdef\pgfplotspointzaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
+ \pgfmathveclen{\pgf@x}{\pgf@y}%
+ \expandafter\let\csname pgfplots@z@veclength\endcsname=\pgfmathresult
+ \pgfplotsmath@ifzero{\pgfmathresult}{%
+ \expandafter\def\csname pgfplots@z@inverseveclength\endcsname{infty}%
+ }{%
+ \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}%
+ \expandafter\let\csname pgfplots@z@inverseveclength\endcsname=\pgfmathresult
+ }%
+ \xdef\pgfplotspointzaxislength{\pgfplots@z@veclength pt}%
+ %
+}
+\def\pgfplots@prepare@ZERO@coordinates@ternary{%
+ \ifpgfplots@xislinear
+ \ifpgfplots@apply@datatrafo@x
+ \pgfplotscoordmath{x}{parsenumber}{0}%
+ \pgfplotscoordmath{x}{datascaletrafo}{\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
+ \pgfplotscoordmath{y}{parsenumber}{0}%
+ \pgfplotscoordmath{y}{datascaletrafo}{\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
+ %
+ \ifpgfplots@threedim
+ \ifpgfplots@zislinear
+ \ifpgfplots@apply@datatrafo@z
+ \pgfplotscoordmath{z}{parsenumber}{0}%
+ \pgfplotscoordmath{z}{datascaletrafo}{\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
+ %
+ %
+ \global\pgfplots@ternary@next@is@unitintervaltrue
+ \pgfplotsqpointxyz100%
+ \xdef\pgfplots@ZERO@x{\the\pgf@x}%
+ \xdef\pgfplots@ZERO@y{\the\pgf@y}%
+ \xdef\pgfplotspointaxisorigin{\noexpand\pgf@x=\pgfplots@ZERO@x\space\noexpand\pgf@y=\pgfplots@ZERO@y\space}%
+}%
+
+
+\def\pgfplots@draw@axis@ternary{%
+ %
+ % this should become the line for varying y:
+ \pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmin}{0}%
+ \pgfplots@draw@axis@insurface yxz
+ %
+ % this should become the line for varying z:
+ \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}%
+ \pgfplots@draw@axis@insurface zyx
+ %
+ %
+ % this should become the line for varying x:
+ \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}%
+ \pgfplots@draw@axis@insurface xzy
+ %
+ \pgfplots@ternary@draw@axislines
+}%
+\def\pgfplots@ternary@draw@axislines{%
+ \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse
+ \pgfplots@separate@axis@linestrue
+ \fi
+ \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse
+ \pgfplots@separate@axis@linestrue
+ \fi
+ \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse
+ \pgfplots@separate@axis@linestrue
+ \fi
+ \ifpgfplots@separate@axis@lines
+ \scope[/pgfplots/every outer x axis line,
+ xdiscont,decoration={pre length=\csname xdisstart\endcsname, post length=\csname xdisend\endcsname}]
+ \draw decorate {
+ \pgfextra
+ \if r\pgfkeysvalueof{/pgfplots/x dir/value}% reverse
+ \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}%
+ \else
+ \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}%
+ \fi
+ \endpgfextra
+ };
+ \endscope
+ %
+ \scope[/pgfplots/every outer y axis line,
+ ydiscont,decoration={pre length=\csname ydisstart\endcsname, post length=\csname ydisend\endcsname}]
+ \draw decorate {
+ \pgfextra
+ \if r\pgfkeysvalueof{/pgfplots/y dir/value}% reverse
+ \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}%
+ \else
+ \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}%
+ \fi
+ \endpgfextra
+ };
+ \endscope
+ %
+ \scope[/pgfplots/every outer z axis line,
+ zdiscont,decoration={pre length=\csname zdisstart\endcsname, post length=\csname zdisend\endcsname}]
+ \draw decorate {
+ \pgfextra
+ \if r\pgfkeysvalueof{/pgfplots/z dir/value}% reverse
+ \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}%
+ \else
+ \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}%
+ \fi
+ \endpgfextra
+ };
+ \endscope
+ \else
+ \draw[
+ /pgfplots/every outer x axis line, % FIXME! these outer styles need much more attention :-(
+ /pgfplots/every outer y axis line]
+ \pgfextra{%
+ \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}%
+ \pgfpathclose
+ };
+ \fi
+}%
+\def\pgfplots@clippath@prepare@for@axistype@ternary{%
+ \def\pgfplots@clippath@install##1{%
+ \pgfpathmoveto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz001}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz100}%
+ \pgfpathlineto{\global\pgfplots@ternary@next@is@unitintervaltrue\pgfplotsqpointxyz010}%
+ \pgfpathclose
+ \pgfplots@clippath@use@{##1}%
+ }%
+}%
+
+\def\pgfplots@draw@axis@post@ternary{%
+ % do nothing. There is no 3d box to draw here.
+}%
+
+\def\pgfplotspointouternormalvectorofaxis@ternary#1#2#3\relax{%
+ \edef\pgfplots@loc@TMPa{\if r\pgfkeysvalueof{/pgfplots/x dir/value}-\fi}% reverse
+ \edef\pgfplots@loc@TMPb{\if r\pgfkeysvalueof{/pgfplots/y dir/value}-\fi}% reverse
+ \edef\pgfplots@loc@TMPc{\if r\pgfkeysvalueof{/pgfplots/z dir/value}-\fi}% reverse
+ \if v#1%
+ \pgfpointadd
+ {\pgfqpointscale{\pgfplots@loc@TMPb-1}{\pgfplotspointyaxis}}%
+ {\pgfqpointscale{\pgfplots@loc@TMPc}{\pgfplotspointzaxis}}%
+ \else
+ \if v#2%
+ \pgfpointadd
+ {\pgfqpointscale{\pgfplots@loc@TMPa}{\pgfplotspointxaxis}}%
+ {\pgfqpointscale{\pgfplots@loc@TMPc-1}{\pgfplotspointzaxis}}%
+ \else
+ \pgfpointadd
+ {\pgfqpointscale{\pgfplots@loc@TMPa-1}{\pgfplotspointxaxis}}%
+ {\pgfqpointscale{\pgfplots@loc@TMPb}{\pgfplotspointyaxis}}%
+ \fi
+ \fi
+ \pgf@process{\pgfpointnormalised{}}%
+ \endgroup
+}%
+
+
+\def\pgfplotsclickable@check@enable@axistype@ternaryaxis{%
+ \def\pgfplotsretval{1}%
+}%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
+% tieline plots
+%
+\pgfplotsset{
+ tieline/.code={%
+ \let\tikz@plot@handler=\pgfplotsplothandlertieline
+ \pgfkeysifdefined{/pgfplots/table/tie end x}{}{%
+ % provide these keys locally:
+ \pgfkeyslet{/pgfplots/table/tie end x}\pgfutil@empty%
+ \pgfkeyslet{/pgfplots/table/tie end y}\pgfutil@empty%
+ \pgfkeyslet{/pgfplots/table/tie end z}\pgfutil@empty%
+ \pgfkeyslet{/pgfplots/table/tie end x index}\pgfutil@empty%
+ \pgfkeyslet{/pgfplots/table/tie end y index}\pgfutil@empty%
+ \pgfkeyslet{/pgfplots/table/tie end z index}\pgfutil@empty%
+ }%
+ \pgfqkeys{/pgfplots/tieline}{#1}%
+ },
+ tieline/every tieline/.style={},
+ tieline/tieline style/.style={/pgfplots/tieline/every tieline/.append style={#1}},
+ tieline/every curve/.style={},
+ tieline/curve style/.style={/pgfplots/tieline/every curve/.append style={#1}},
+ tieline/each nth tie/.initial=,
+}
+\def\pgfplotsplothandlertieline{%
+ \pgfplotsresetplothandler
+ \let\pgf@plotstreamstart=\pgfplotsplothandlervisbegin@tieline
+ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@tieline
+ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@tieline
+ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@tieline
+}%
+\def\pgfplotsplothandlervisbegin@tieline{%
+ \pgfplotsapplistXnewempty\pgfp@binodal@A
+ \pgfplotsapplistXnewempty\pgfp@ties
+ \pgfplotsprependlistXnewempty{pgfp@binodal@B@reverse}
+ \def\b@pgfplotsplothandlersurveystart@tieline@even{1}%
+ %
+ \global\let\pgf@plotstreampoint=\pgfplotsplothandlervis@streampoint@tieline
+ \global\let\pgf@plotstreamend=\pgfplotsplothandlervis@streamend@tieline
+ %
+ \pgfkeysgetvalue{/pgfplots/tieline/each nth tie}\pgfplots@eachnth@tie
+ \ifx\pgfplots@eachnth@tie\pgfutil@empty
+ \def\pgfplots@eachnth@tie{1}%
+ \fi
+ \let\c@pgfplots@tiecounter=\c@pgfplotstable@counta
+ \c@pgfplots@tiecounter=0
+}%
+\def\pgfplotsplothandlervis@streampoint@tieline#1{%
+ \pgf@process{#1}%
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\pgfplots@stream@withmeta@
+ {\pgfplots@current@point@coordindex}%
+ {\the\pgf@x}{\the\pgf@y}%
+ {\pgfplots@current@point@meta}%
+ }%
+ \if1\b@pgfplotsplothandlersurveystart@tieline@even
+ \let\pgfplotsplothandlervis@streampoint@tieline@last=\pgfplots@loc@TMPa
+ \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfp@binodal@A
+ \def\b@pgfplotsplothandlersurveystart@tieline@even{0}%
+ \else
+ \expandafter\pgfplotsprependlistXpushfront\pgfplots@loc@TMPa\to{pgfp@binodal@B@reverse}%
+ %
+ \advance\c@pgfplots@tiecounter by1
+ \ifnum\pgfplots@eachnth@tie=\c@pgfplots@tiecounter
+ \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}%
+ \t@pgfplots@tokb=\expandafter{\pgfplotsplothandlervis@streampoint@tieline@last}%
+ \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\noexpand\pgfplotsplothandlertieline@finishtie}%
+ \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfp@ties
+ \c@pgfplots@tiecounter=0
+ \fi
+ %
+ \def\b@pgfplotsplothandlersurveystart@tieline@even{1}%
+ \fi
+}%
+\def\pgfplotsplothandlervis@streamend@tieline{%
+ \begingroup
+ \pgfplots@drawmodes@appendtrue
+ \path[/pgfplots/tieline/every curve]%
+ \pgfextra
+ \ifx\tikz@plot@handler\pgfplotsplothandlertieline
+ \let\tikz@plot@handler\pgfplothandlerlineto
+ \fi
+ \pgfplotsresetplothandler
+ \tikz@plot@handler
+ \pgf@plotstreamstart
+ %
+ \pgfplotsapplistXlet\pgfplots@loc@TMPa=\pgfp@binodal@A
+ \pgfplots@loc@TMPa
+ \pgfplotsapplistXnewempty\pgfp@binodal@A
+ \pgfplotsprependlistXlet\pgfplots@loc@TMPa={pgfp@binodal@B@reverse}%
+ \pgfplots@loc@TMPa
+ \pgfplotsprependlistXnewempty{pgfp@binodal@B@reverse}%
+ %
+ \pgf@plotstreamend
+ \endpgfextra;
+ \endgroup
+ %
+ %
+ \pgfplotsset{/pgfplots/tieline/every tieline}%
+ \ifx\tikz@plot@handler\pgfplotsplothandlertieline
+ \let\tikz@plot@handler\pgfplothandlerlineto
+ \fi
+ \pgfplotsresetplothandler
+ \tikz@plot@handler
+ \pgf@plotstreamstart
+ %
+ \def\pgfplotsplothandlertieline@finishtie{%
+ \pgfplotsplothandlervisualizejump
+ }%
+ \pgfplotsapplistXlet\pgfplots@loc@TMPa=\pgfp@ties
+ \pgfplots@loc@TMPa
+ \pgfplotsapplistXnewempty\pgfp@ties
+ %
+ \pgf@plotstreamend
+}%
+
+\def\pgfplotsplothandlersurveystart@tieline{%
+ \def\pgfplots@loc@TMPa{table}%
+ \ifx\pgfplotssurveyphaseinputclass\pgfplots@loc@TMPa
+ \else
+ \pgfplots@error{Sorry, 'tieline' plots are currently only supported for \string\addplot\space table}%
+ \fi
+ \def\b@pgfplotsplothandlersurveystart@tieline@init{0}%
+}%
+\def\pgfplotsplothandlersurveyend@tieline{%
+}%
+
+\def\pgfplotsplothandlersurveypoint@tieline@init{%
+ \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor x\pgfplotsplothandlertieline@Bx
+ \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor y\pgfplotsplothandlertieline@By
+ \ifpgfplots@curplot@threedim
+ \pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor z\pgfplotsplothandlertieline@Bz
+ \fi
+ %
+ \def\b@pgfplotsplothandlersurveystart@tieline@init{1}%
+}%
+\def\pgfplotsplothandlersurveypoint@tieline@init@find@tieendcolfor#1#2{%
+ \let#2=\relax
+ \pgfkeysgetvalue{/pgfplots/table/tie end #1}{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfkeysgetvalue{/pgfplots/table/tie end #1 index}{\pgfplots@loc@TMPa}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \edef#2{\noexpand\getthisrowno{\pgfplots@loc@TMPa}\noexpand\pgfmathresult}%
+ \fi
+ \else
+ \edef#2{\noexpand\getthisrow{\pgfplots@loc@TMPa}\noexpand\pgfmathresult}%
+ \fi
+ \ifx#2\relax
+ \pgfplotsplothandlersurveypoint@tieline@init@find@colindex@for #1\pgfplots@loc@ind
+ \c@pgf@countd=\pgfplots@loc@ind\relax
+ \advance\c@pgf@countd by3
+ \ifnum\c@pgf@countd<\pgfplotstablecols\relax
+ \else
+ \c@pgf@countd=0
+ \pgfplots@error{Sorry, I can't find the 'tie end #1 index' automatically. Please provide 'table[tie end #1={<colname>}]' or 'table[tie end #1 index=<col index>]' manually and verify the all, x,y and z components are correct}%
+ \fi
+ \edef\pgfplots@loc@ind{\the\c@pgf@countd}%
+ \pgfkeyslet{/pgfplots/table/tie end #1 index}\pgfplots@loc@ind
+ \edef#2{\noexpand\getthisrowno{\pgfplots@loc@ind}\noexpand\pgfmathresult}%
+ \fi
+}%
+
+\def\pgfplotsplothandlersurveypoint@tieline@init@find@colindex@for#1#2{%
+ \pgfkeysgetvalue{/pgfplots/table/#1}{\pgfplots@loc@TMPa}%
+ \pgfkeysgetvalue{/pgfplots/table/#1 index}{\pgfplots@loc@TMPb}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \let#2=\pgfplots@loc@TMPb
+ \else
+ \def\pgfplots@loc@TMPb{\expandafter\pgfplotstablegetcolumnindexforname\expandafter{\pgfplots@loc@TMPa}\of}%
+ \expandafter\pgfplots@loc@TMPb\pgfplotstablename\to#2%
+ \fi
+}%
+
+\def\pgfplotsplothandlersurveypoint@tieline{%
+ \if0\b@pgfplotsplothandlersurveystart@tieline@init
+ \pgfplotsplothandlersurveypoint@tieline@init
+ \fi
+ \pgfplotsplothandlersurveypoint@default
+ %
+ \pgfplotsplothandlertieline@Bx\let\pgfplots@current@point@x=\pgfmathresult
+ \pgfplotsplothandlertieline@By\let\pgfplots@current@point@y=\pgfmathresult
+ \ifpgfplots@curplot@threedim
+ \pgfplotsplothandlertieline@Bz\let\pgfplots@current@point@z=\pgfmathresult
+ \fi
+ \pgfplotsplothandlersurveypoint@default
+}%
+\endinput
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.units.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplots.units.code.tex
new file mode 100644
index 0000000000..084d076b28
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/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=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=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=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
diff --git a/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplotsclickable.code.tex b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplotsclickable.code.tex
new file mode 100644
index 0000000000..8cebcd18c2
--- /dev/null
+++ b/graphics/pgf/contrib/pgfplots/tex/tikzlibrarypgfplotsclickable.code.tex
@@ -0,0 +1,24 @@
+%--------------------------------------------
+%
+% Package pgfplots, library for dynamic content in PDF files
+% (clickable plots)
+%
+% 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/>.
+%
+%--------------------------------------------
+
+\usetikzlibrary{pgfplots.clickable}
+\endinput