diff options
Diffstat (limited to 'Master/texmf-dist/tex')
50 files changed, 19293 insertions, 4455 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex index 58664dc323d..c45b5a613f0 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplots.surfshading.code.tex @@ -55,6 +55,7 @@ /pgfplots/surf shading/south west corner/.initial={\pgfpointorigin},% /pgfplots/surf shading/north east corner/.initial={\pgfqpoint{6cm}{6cm}},% /pgfplots/surf shading/anchor/.initial=\pgfpointorigin,% + /pgfplots/surf shading/shading type/.initial=5,% triangles in form of lattice /pgfplots/surf shading/precision/.is choice, /pgfplots/surf shading/precision/pdf/.code={% % Lossless coordinate output. @@ -77,6 +78,7 @@ /pgfplots/surf shading/precision/ps},% /pgfplots/surf shading/precision/ps,% /pgfplots/surf shading/cols/.initial=,% + /pgfplots/surf shading/colorspace/.initial=rgb,% rgb or cmyk /pgfplots/surf shading/colormap/.initial={% << /FunctionType 2 @@ -124,22 +126,57 @@ 0 \pgfplotscolormappdfmax % map [0,2^BitsPerComponent-1] linearly to [0 1] for parametric color data }% \def\pgfplotslibrarysurf@count{0}% +\newcount\c@pgfplotslibrarysurf@no % driver specific: \def\pgfplotslibrarysurf@initstream{} \def\pgfplotslibrarysurf@advancestreamlen#1{}% \def\pgfplotslibrarysurfstreamstart{% - \pgfplotsapplistXnewempty\pgfplotslibrarysurf@binarystream@accum + \pgfplotslibrarysurf@translate@colorspace + \let\pgfplotslibrarysurf@colorspace=\pgfplotsretval + \pgfkeysgetvalue{/pgfplots/surf shading/shading type}\pgfplotslibrarysurf@type + \pgfplotsapplistXglobalnewempty\pgfplotslibrarysurf@binarystream@accum \pgfplotslibrarysurf@initstream \ifx\pgfplotslibrarysurf@filter@encode\pgfutil@empty \else \pgfkeysalso{/pgfplots/bin/\pgfplotslibrarysurf@filter@encode}% \fi + \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. + \def\pgfplotslibrarysurf@edgeflag{\pgfplotscharno{0}}% + \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 + \def\pgfplotslibrarysurf@edgeflag{\pgfplotscharno{0}}% + \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 + \def\pgfplotslibrarysurf@edgeflag{\pgfplotscharno{0}}% + \else + \pgfplotslibrarysurf@initstream@wrongtype + \fi +}% +\def\pgfplotslibrarysurf@initstream@wrongtype{% + \pgfplots@error{CRITICAL: shader=interp: got unsupported pdf shading type '\pgfplotslibrarysurf@type'. This may correct your pdf!}% }% \def\pgfplotslibrarysurfstreamend{% - \pgfplotsapplistXlet\pgfplotslibrarysurf@binarystream=\pgfplotslibrarysurf@binarystream@accum - \pgfplotsapplistXnewempty\pgfplotslibrarysurf@binarystream@accum + \pgfplotsapplistXgloballet\pgfplotslibrarysurf@binarystream=\pgfplotslibrarysurf@binarystream@accum + \pgfplotsapplistXglobalnewempty\pgfplotslibrarysurf@binarystream@accum }% % #1: a pgf point. @@ -195,11 +232,131 @@ \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa %\message{\pgfplotsbinaryresult.}% \t@pgfplots@tokc=\expandafter{\pgfplotsbinaryresult}% - \edef\pgfplots@loc@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}% - \expandafter\pgfplotsapplistXpushback\pgfplots@loc@TMPa\to\pgfplotslibrarysurf@binarystream@accum + \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 \pgfplotslibrarysurf@advancestreamlen{10}% } +\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 + \pgfplots@error{Sorry, the 'surfshading' lib failed to recognise the '/pgfplots/surf shading=\pgfplots@loc@TMPd\space choice... maybe you misspelled it?}% + \def\pgfplotsretval{RGB}% + \fi + \fi + \fi +}% + +% 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% + %\pgf@process{#1}% this here causes `{retaining \pgf@x}' messages and pollutes the save stack! Avoid it. See \tracingrestores=2 + #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}% + \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 + {% + % read fixed point input (in the range [0,1000]). + \pgf@xa=#2pt + % convert to integer (= *65536): + \c@pgf@counta=\pgf@xa + % provide map [0,1000] -> [0,2^16-1] + \divide\c@pgf@counta by1000 + % now, we have \c@pgf@counta in [0,2^16]. Simply strip it into + % the required range, that's ok. + \ifnum\c@pgf@counta<0 + \c@pgf@counta=0 + \else + \ifnum\c@pgf@counta>65535 + \c@pgf@counta=65535 + \fi + \fi + % Now, we have CDATA in the range [0,65535] + \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + %\message{ENCODING(C=\pgfplots@glob@TMPa\space for \the\pgf@xa)=}% + }% + \pgfplotsbinarysetbytes2% + \pgfplotsbinaryencodeunsigned\pgfplots@glob@TMPa + %\message{\pgfplotsbinaryresult.}% + \t@pgfplots@tokc=\expandafter{\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 + %\pgfplotslibrarysurf@advancestreamlen{10}% +} + \def\pgfplotslibrarysurfactivateshadefill{% \pgfplotssys@do@surfshading@fillpaths\pgfplots@loc@TMPa% \expandafter\pgfutil@addpdfresource@patterns\expandafter{\pgfplots@loc@TMPa}%% diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex index 06bade77b9e..4f414535eec 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex @@ -36,18 +36,22 @@ \def\use@@pgfplotslibrary#1{% \edef\pgf@list{#1}% \pgfutil@for\pgf@temp:=\pgf@list\do{% - \expandafter\ifx\csname pgfp@library@\pgf@temp @loaded\endcsname\relax% - \expandafter\global\expandafter\let\csname pgfp@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% - \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} - \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} - \catcode`\@=11 - \catcode`\|=12 - \pgfplots@iffileexists{tikzlibrarypgfplots.\pgf@temp.code.tex}{% - \input tikzlibrarypgfplots.\pgf@temp.code.tex}{% - \input pgflibrarypgfplots.\pgf@temp.code.tex}% - \catcode`\@=\csname tikz@library@#1@atcode\endcsname - \catcode`\|=\csname tikz@library@#1@barcode\endcsname - \fi% + \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}% + \ifx\pgf@temp\pgfutil@empty + \else + \expandafter\ifx\csname pgfp@library@\pgf@temp @loaded\endcsname\relax% + \expandafter\global\expandafter\let\csname pgfp@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} + \catcode`\@=11 + \catcode`\|=12 + \pgfplots@iffileexists{tikzlibrarypgfplots.\pgf@temp.code.tex}{% + \input tikzlibrarypgfplots.\pgf@temp.code.tex}{% + \input pgflibrarypgfplots.\pgf@temp.code.tex}% + \catcode`\@=\csname tikz@library@#1@atcode\endcsname + \catcode`\|=\csname tikz@library@#1@barcode\endcsname + \fi% + \fi }% } diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex new file mode 100644 index 00000000000..d6060e15e2b --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.colormaps.code.tex @@ -0,0 +1,99 @@ +%-------------------------------------------- +% +% 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)} + }, +} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex index 8ac9a7631c0..7e7e5232fc0 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex @@ -52,6 +52,12 @@ \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}% } @@ -94,8 +100,8 @@ \let\pgfplots@calender@ZEROSHIFT=\pgfmathresult }, date ZERO=2006-01-01, - /pgfplots/date coordinates in/.style={ - /pgfplots/#1 coord trafo/.code={% + /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' @@ -126,8 +132,8 @@ \fi \pgfmath@smuggleone\pgfmathresult \endgroup - }, - /pgfplots/#1 coord inv trafo/.code={% + }% + \pgfkeysdef{/pgfplots/#1 coord inv trafo}{% \begingroup \pgfplotslibdateplot@number@to@julian@and@time##1\julianto{\c@pgf@counta}\hourto\Hour\minuteto\Minute% \advance\c@pgf@counta by\pgfplots@calender@ZEROSHIFT\relax @@ -152,12 +158,43 @@ \def\Second{0}% \def\second{00}% \edef\lowlevel{##1}% - \edef\pgfmathresult{\year-\month-\day}% - }, - /pgfplots/#1ticklabel={\tick},% - /pgfplots/scaled #1 ticks=false, - /pgfplots/plot coordinates/math parser=false,% + \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/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex index 5086fef9d47..32b0e5f32ee 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex @@ -56,38 +56,58 @@ /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{upper}, + /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{upper}, + /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/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/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}, } @@ -200,9 +220,9 @@ }% \fi% \else - \def\pgfplots@loc@TMPb{upper}% + \def\pgfplots@loc@TMPb{top}% \ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels% - % xlabels at=upper + % xlabels at=top \ifnum1<\pgfplots@group@rows\relax \foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% @@ -264,7 +284,7 @@ % \def\pgfplots@group@determine@ticklabels{% \def\pgfplots@loc@TMPa{all} - \def\pgfplots@loc@TMPb{upper} + \def\pgfplots@loc@TMPb{top} \def\pgfplots@loc@TMPc{lower} \ifx\pgfplots@loc@TMPa\pgfplots@group@xticklabels% % Do nothing as all should have xticklabels diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex new file mode 100644 index 00000000000..4076e37281c --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.patchplots.code.tex @@ -0,0 +1,1783 @@ +%-------------------------------------------- +% +% 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 +%-------------------------------------------------- + + + +\pgfplotsdeclarepatchclass{quadratic spline}{% + allow matrix=0, + uses view depth=0, + 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 + }, + 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 + \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@qspline@A + \let\PB=\pgfplotspatchclass@qspline@C + \let\PC=\pgfplotspatchclass@qspline@B + \pgfplots@edge + \endgroup + }, + triangulate class=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=3, +}% + +\pgfplotsdeclarepatchclass{cubic spline}{% + allow matrix=0, + uses view depth=0, + 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 + }, + 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. + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@cspline@A\endvertex}% + % switch basis from lagrange to bezier (see formular on top of + % this file) + \pgfpathcurveto {% + \begingroup + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@A\times{-0.833333}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@C\times{3}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@D\times{-1.5}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@B\times{0.3333333}% + \pgfplotspatchvertexfinish\pgfplots@loc@TMPa + \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex + \endgroup + }{% + \begingroup + \pgfplotspatchvertexaccumstart + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@A\times{0.333333}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@C\times{-1.5}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@D\times{3}% + \expandafter\pgfplotspatchvertexaddXY\pgfplotspatchclass@cspline@B\times{-0.833333}% + \pgfplotspatchvertexfinish\pgfplots@loc@TMPa + \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex + \endgroup + }{% + \expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@cspline@B\endvertex + }% + }, + triangulate class=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=4, +}% + +% 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}{% + allow matrix=0, + uses view depth=1, + 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 + }, + 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% + }, + 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=6, +}% + + +% 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=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 + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex, + 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 + % + \pgf@xa=0pt + \pgf@ya=0pt + \pgf@yb=0pt + \pgfplotscoordmath{meta}{zero}% + \def\pgfplots@loc@accum@mean{% + \advance\pgf@xa by\pgfplotspatchvertexx\relax + \advance\pgf@ya by\pgfplotspatchvertexy\relax + \pgfplotscoordmath{meta}{op}{add}{{\pgfmathresult}{\pgfplotspatchvertexmeta}}% + \ifx\pgfplotspatchvertexdepth\pgfutil@empty + \else + \advance\pgf@yb by\pgfplotspatchvertexdepth pt\relax + \fi + }% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex \pgfplots@loc@accum@mean% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@B\endvertex \pgfplots@loc@accum@mean% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@C\endvertex \pgfplots@loc@accum@mean% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@D\endvertex \pgfplots@loc@accum@mean% + % + \divide\pgf@xa by4 + \divide\pgf@ya by4 + \divide\pgf@yb by4 + \pgfplotscoordmath{meta}{op}{multiply}{{\pgfmathresult}{\pgfplots@loc@scale}}% + \edef\pgfplotspatchclass@rect@M{{\the\pgf@xa}{\the\pgf@ya}{\pgfmathresult}\ifx\pgfplotspatchvertexdepth\pgfutil@empty\else \pgf@sys@tonumber\pgf@yb\fi}% + % + \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=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% +}% + +\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}{% + allow matrix=0, + 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 + }, + 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% + }, + 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 + \pgfplotspatchclass@rect@to@coonspatch@findshadingsequence@for@depth + {pgfplotspatchclass@biquad@}{\Pcur}{\Pnextseq}% + % + \let\Pstartidx\Pcur% + \pgfutil@namelet{Pstart}{pgfplotspatchclass@biquad@\Pcur}% + % + % create a tensor cubic bezier patch. + % + % Again, the outer boundary involves a map from 3 point lagrange + % representation to 4 point cubic bezier. + % + % The main complication arises to support the INNER node (\pgfplotspatchclass@biquad@I) . + % We need the four inner bezier control points to get it + % correctly. + % + % this here handles only the OUTER shaper. It is the same as + % for 'fill path'. + % See 'fill path' for docs. + % + \pgfplotspatchclass@biquad@coonsedge + % + \pgfplotspatchclass@biquad@coonsedge + % + \pgfplotspatchclass@biquad@coonsedge + % + \pgfplotspatchclass@biquad@coonsedge + % + % FIXME: + % \pgfplotspatchclass@biquad@innercontrolpoints + % + \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=6, + get num vertices=9, +}% + +% 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}{% + allow matrix=0, + 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=12, + get num cdata vertices=4, +}% + +% Direct interface to tensor product bezier patches (pdf shading type 7). +% See manual and/or pdf reference +\pgfplotsdeclarepatchclass{tensor bezier}{% + allow matrix=0, + 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=16, + get num cdata vertices=4, +}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex new file mode 100644 index 00000000000..7502dac1c36 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex @@ -0,0 +1,733 @@ +%-------------------------------------------- +% +% 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/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{% + \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy + \let\pgfplotsqpointxy=\pgfplotsqpointxy@polaraxis + \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy +% \def\pgfplotsqpointxyz##1##2##3{\pgfplotsqpointxy{##1}{##2}}% FIXME + \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@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@enlarge@limit@for=\pgfplots@enlarge@limit@for@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 +}% + +\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{% + \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 + % + % 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 + \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 + \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 + % + \pgfplotscoordmath{y}{min}{\pgfplots@ymin}{\pgfplots@ymax}% + \global\let\pgfplots@ymin=\pgfmathresult + \pgfplotscoordmath{y}{max}{\pgfplots@ymin}{\pgfplots@ymax}% + \global\let\pgfplots@ymax=\pgfmathresult + % + \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 + \pgfqpointpolar{#1}{1pt}% + \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% + \pgfplotspointouternormalvectorofaxisgetv{#1#2#3}% + % in direction of the length. + \ifx\pgfplotsretval\pgfutil@empty + \def\pgfplotsretval{0}% + \fi + % FIXME : datascaling! + % FIXME : aspect ratios! + % perhaps pgfpointpolarxy? + \pgfqpointpolar{\pgfplotsretval}{1pt}% + \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 + \pgfmath@basic@sin@{\pgfplotsretval}% + \pgf@x=-\pgfmathresult pt + \pgfmath@basic@cos@{\pgfplotsretval}% + \pgf@y=\pgfmathresult pt + }% + \def\pgfplotsunitxlength{1}% + \def\pgfplotsunitxinvlength{1}% + % + \def\pgfplotspointunity{% + \pgfqpointpolar{\pgfplots@xmin}{1pt}% + }% + \def\pgfplotsunitylength{1}% + \def\pgfplotsunityinvlength{1}% +}% + +\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 +}% + +\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{1}% + \else + \def\b@pgfplots@polar@limit@around@zero{0}% + \fi + % + \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 + \def\pgfplots@tmpZscale{1pt}% + \else + \def\pgfplots@tmpZscale{0pt}% + \let\pgfplots@view@el=\pgfutil@empty + \let\pgfplots@view@az=\pgfutil@empty + \fi + \ifx\pgfplots@view@az\pgfutil@empty + %\let\pgfplots@rectangle@width=\pgfutil@empty + %\let\pgfplots@rectangle@height=\pgfutil@empty + \def\pgfplots@view@dir@threedim@x{0}% + \def\pgfplots@view@dir@threedim@y{0}% + \def\pgfplots@view@dir@threedim@z{1}% + % + % FIXME HERE COMES THE polar MODIFICATION + %-------------------------------------------------- + % \pgfpointdiff + % {\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}} + % {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}% + %-------------------------------------------------- + % instead of scaling from (min) (max), we only need the UPPER + % bound -- in both, x and y directions (since we have a cycle. + % Furthermore, we need it twice since we are interested in the + % diameter, not the radius. + \global\pgf@x=\pgfplots@ymax pt % radius + \global\multiply\pgf@x by2 % diameter + \global\pgf@y=\pgf@x % same for y + % + % only used temporarily in this macro to compute the correct + % length for unit vectors: + \edef\pgfplots@initsizes@axisdiag@x{\the\pgf@x}% + \edef\pgfplots@initsizes@axisdiag@y{\the\pgf@y}% + % + \ifx\pgfplots@x\pgfutil@empty + \ifx\pgfplots@width\pgfutil@empty + \pgfplots@error{INTERNAL LOGIC ERROR! WIDTH NOT SET}% + \fi + \pgfplots@initsizes@getXscale\pgfplots@initsizes@axisdiag@x\into\pgfplots@tmpXscale + %\ifpgfplots@scale@only@axis + % \let\pgfplots@rectangle@width=\pgfplots@width + %\fi + \else + \def\pgfplots@tmpXscale{1}% + \fi + % + \ifx\pgfplots@y\pgfutil@empty + \ifx\pgfplots@height\pgfutil@empty + \pgfplots@error{INTERNAL LOGIC ERROR! HEIGHT NOT SET}% + \fi + \pgfplots@initsizes@getYscale\pgfplots@initsizes@axisdiag@y\into\pgfplots@tmpYscale + %\ifpgfplots@scale@only@axis + % \let\pgfplots@rectangle@height=\pgfplots@height + %\fi + \else + \def\pgfplots@tmpYscale{1}% + \fi + % + \edef\pgfplots@tmpXscale{\pgfplots@tmpXscale pt}% + \edef\pgfplots@tmpYscale{\pgfplots@tmpYscale pt}% + % + \pgfplots@initsizes@setunitvector{x}{0}{\pgfplots@tmpXscale}{\pgfplots@tmp@xisaxisparallel}% + \pgfplots@initsizes@setunitvector{y}{1}{\pgfplots@tmpYscale}{\pgfplots@tmp@yisaxisparallel}% + \pgfplots@initsizes@setunitvector{z}{2}{\pgfplots@tmpZscale}{\pgfplots@loc@TMPc}% + \else + % 3D case is currently always initialised 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}% + \if1\pgfplots@tmp@xisaxisparallel% + \def\pgfplots@tmp@yisaxisparallel{1}% + \fi + \fi +%\message{Pgfplots debug: initialised unit vectors to x=(\the\pgf@xx,\the\pgf@xy), y=(\the\pgf@yx,\the\pgf@yy), z=(\the\pgf@zx,\the\pgf@zy). }% + % + \let\pgfplotsmathfloatviewdepthxyz@=\pgfplotsmathfloatviewdepthxyz@infigure + \let\pgfplotsmathviewdepthxyz@=\pgfplotsmathviewdepthxyz@infigure + % + \pgfplotsmath@ifzero{\pgfplots@x@veclength}{\pgfplots@hide@xtrue\pgfplots@shownothingof@xtrue}{}% + \pgfplotsmath@ifzero{\pgfplots@y@veclength}{\pgfplots@hide@ytrue\pgfplots@shownothingof@ytrue}{}% + \ifpgfplots@threedim + \pgfplotsmath@ifzero{\pgfplots@z@veclength}{\pgfplots@hide@ztrue\pgfplots@shownothingof@ztrue}{}% + \else + \if1\pgfplots@tmp@xisaxisparallel% + \if1\pgfplots@tmp@yisaxisparallel% + % Optimize for axis-parallel case! + % puh. Did not make any measureable difference!? Ok... + \let\pgfplotsqpointxy=\pgfplotsqpointxy@orthogonal + \fi + \fi + \fi + % + % FIXME : unit vector ratio / axis equal +} + +\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/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex new file mode 100644 index 00000000000..7d24c53216d --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.smithchart.code.tex @@ -0,0 +1,1761 @@ +%-------------------------------------------- +% +% 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, + } + }, +} + +\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@initsizes=\pgfplots@initsizes@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}{% + \pgfplots@warning{There is no #3tick with index '\pgfplots@grid@stop@at'. Skipping it.}% + \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 + \pgfmathsubtract@{360}{\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@initsizes@smithchart{% + % I copy-pasted most of this code, up to just one position where + % I introduced the modified scaling for smithchart axes + %---------------------------------- + % INIT. + % + % + \def\pgfplots@minmax@reg@forbidden{\pgfplots@error{Sorry, an internal logic error occured during smithchart processing (a routine tried to access \string\pgfplots@xmin@reg\space or its variants). Please report this as bug, sorry}}% + \iffalse + \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 + \else + \let\pgfplots@xmin@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@xmax@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@ymin@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@ymax@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@zmin@reg=\pgfplots@minmax@reg@forbidden + \let\pgfplots@zmax@reg=\pgfplots@minmax@reg@forbidden + \fi + % + % + %----------------------------------------- + % PROCESS THE 'width' and 'height' options + %----------------------------------------- + % + % + \pgfkeysgetvalue{/pgfplots/view/az}{\pgfplots@view@az}% + \pgfkeysgetvalue{/pgfplots/view/el}{\pgfplots@view@el}% + \ifpgfplots@threedim + \def\pgfplots@tmpZscale{1pt}% + \else + \def\pgfplots@tmpZscale{0pt}% + \let\pgfplots@view@el=\pgfutil@empty + \let\pgfplots@view@az=\pgfutil@empty + \fi + \ifx\pgfplots@view@az\pgfutil@empty + %\let\pgfplots@rectangle@width=\pgfutil@empty + %\let\pgfplots@rectangle@height=\pgfutil@empty + \def\pgfplots@view@dir@threedim@x{0}% + \def\pgfplots@view@dir@threedim@y{0}% + \def\pgfplots@view@dir@threedim@z{1}% + % + % FIXME HERE COMES THE smithchart MODIFICATION + %-------------------------------------------------- + % \pgfpointdiff + % {\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}} + % {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}% + %-------------------------------------------------- + % instead of scaling from (min) (max), we only need the UPPER + % bound -- in both, x and y directions (since we have a cycle. + % Furthermore, we need it twice since we are interested in the + % diameter, not the radius. + \global\pgf@x=2 pt % radius + \global\pgf@y=\pgf@x % same for y + % + % only used temporarily in this macro to compute the correct + % length for unit vectors: + \edef\pgfplots@initsizes@axisdiag@x{\the\pgf@x}% + \edef\pgfplots@initsizes@axisdiag@y{\the\pgf@y}% + % + \ifx\pgfplots@x\pgfutil@empty + \ifx\pgfplots@width\pgfutil@empty + \pgfplots@error{INTERNAL LOGIC ERROR! WIDTH NOT SET}% + \fi + \pgfplots@initsizes@getXscale\pgfplots@initsizes@axisdiag@x\into\pgfplots@tmpXscale + %\ifpgfplots@scale@only@axis + % \let\pgfplots@rectangle@width=\pgfplots@width + %\fi + \else + \def\pgfplots@tmpXscale{1}% + \fi + % + \ifx\pgfplots@y\pgfutil@empty + \ifx\pgfplots@height\pgfutil@empty + \pgfplots@error{INTERNAL LOGIC ERROR! HEIGHT NOT SET}% + \fi + \pgfplots@initsizes@getYscale\pgfplots@initsizes@axisdiag@y\into\pgfplots@tmpYscale + %\ifpgfplots@scale@only@axis + % \let\pgfplots@rectangle@height=\pgfplots@height + %\fi + \else + \def\pgfplots@tmpYscale{1}% + \fi + % + \edef\pgfplots@tmpXscale{\pgfplots@tmpXscale pt}% + \edef\pgfplots@tmpYscale{\pgfplots@tmpYscale pt}% + % + \pgfplots@initsizes@setunitvector{x}{0}{\pgfplots@tmpXscale}{\pgfplots@tmp@xisaxisparallel}% + \pgfplots@initsizes@setunitvector{y}{1}{\pgfplots@tmpYscale}{\pgfplots@tmp@yisaxisparallel}% + \pgfplots@initsizes@setunitvector{z}{2}{\pgfplots@tmpZscale}{\pgfplots@loc@TMPc}% + \else + % 3D case is currently always initialised 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}% + \if1\pgfplots@tmp@xisaxisparallel% + \def\pgfplots@tmp@yisaxisparallel{1}% + \fi + \fi +%\message{Pgfplots debug: initialised unit vectors to x=(\the\pgf@xx,\the\pgf@xy), y=(\the\pgf@yx,\the\pgf@yy), z=(\the\pgf@zx,\the\pgf@zy). }% + % + \let\pgfplotsmathfloatviewdepthxyz@=\pgfplotsmathfloatviewdepthxyz@infigure + \let\pgfplotsmathviewdepthxyz@=\pgfplotsmathviewdepthxyz@infigure + % + \pgfplotsmath@ifzero{\pgfplots@x@veclength}{\pgfplots@hide@xtrue\pgfplots@shownothingof@xtrue}{}% + \pgfplotsmath@ifzero{\pgfplots@y@veclength}{\pgfplots@hide@ytrue\pgfplots@shownothingof@ytrue}{}% + \ifpgfplots@threedim + \pgfplotsmath@ifzero{\pgfplots@z@veclength}{\pgfplots@hide@ztrue\pgfplots@shownothingof@ztrue}{}% + \else + \if1\pgfplots@tmp@xisaxisparallel% + \if1\pgfplots@tmp@yisaxisparallel% + % Optimize for axis-parallel case! + % puh. Did not make any measureable difference!? Ok... + \let\pgfplotsqpointxy=\pgfplotsqpointxy@orthogonal + \fi + \fi + \fi + % + % FIXME : unit vector ratio / axis equal + % +} + +\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/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex new file mode 100644 index 00000000000..dfb520af190 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.ternary.code.tex @@ -0,0 +1,904 @@ +%-------------------------------------------- +% +% 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\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@ternary + \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@ternary + \let\pgfplots@initsizes@setunitvector=\pgfplots@initsizes@setunitvector@ternary + \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@ternary + \let\pgfplots@prepare@ZERO@coordinates=\pgfplots@prepare@ZERO@coordinates@ternary + \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 +%\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 + % + \pgfplots@initsizes@get@width@withoutlabels + \pgf@x=\pgfmathresult + \edef\pgfplots@width@ternary{\pgf@sys@tonumber\pgf@x}% + % + \pgfplots@initsizes@ternary@orig + % +}% + +\def\pgfplots@ternary@init@map@to@unit#1{% + \begingroup + \pgfmath@basic@subtract@ + {\csname pgfplots@#1max\endcsname} + {\csname pgfplots@#1min\endcsname}% + \pgfmath@basic@reciprocal@\pgfmathresult + \let\pgfplots@map@to@unit@scale=\pgfmathresult + % + \expandafter\xdef\csname pgfplots@ternary@map@to@unit@#1\endcsname##1{% + \noexpand\pgfmath@basic@subtract@{##1}{\csname pgfplots@#1min\endcsname}% + \noexpand\pgfmath@basic@multiply@{\noexpand\pgfmathresult}{\pgfplots@map@to@unit@scale}% + }% + \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 realize *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}% + \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}% + % +%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).}% +}% + +\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/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex index 1a0ce28dc03..59b69da9712 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex @@ -58,10 +58,12 @@ % % the elements won't be initialised. Use 'set' for each element. \def\pgfplotsarrayresize#1#2{% - \pgfplotsarray@@edef{#1@size}{#2}% + \c@pgfplotsarray@tmp=#2 + \pgfplotsarray@@edef{#1@size}{\the\c@pgfplotsarray@tmp}% } \def\pgfplotsarrayresizeglobal#1#2{% - \expandafter\xdef\csname\string#1@size\endcsname{#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 @@ -136,7 +138,7 @@ \def\pgfplotsarray@@let#1=#2{% \def\pgfplotsarray@TMP@@{\expandafter\let\csname\string#1\endcsname}% - \expandafter\pgfplotsarray@TMP@@\expandafter=\csname\string#2\endcsname + \expandafter\pgfplotsarray@TMP@@\csname\string#2\endcsname }% \def\pgfplotsarray@@#1#2{% @@ -178,6 +180,12 @@ \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 @@ -245,6 +253,23 @@ \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: @@ -296,11 +321,19 @@ \pgfplotsarray@@getsizeto{#1}{\pgfplotsarray@TMP}% \c@pgfplotsarray@tmp=0\relax \def\pgfplotsarrayforeachindex{\the\c@pgfplotsarray@tmp}% - \long\def\pgfplotsarray@TMPb{#3}% \pgfutil@loop \ifnum\c@pgfplotsarray@tmp<\pgfplotsarray@TMP\relax \expandafter\let\expandafter#2\expandafter=\csname\string#1@\the\c@pgfplotsarray@tmp\endcsname% - \pgfplotsarray@TMPb + \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% @@ -417,6 +450,9 @@ % [\pgfplotsarrayforeach\testarray\as\elem{\elem\space}] % %-------------------------------------------------- +% +% @see \pgfplotsutilsortthree +% @see \pgfplotsutilsortfour \def\pgfplotsarraysort{% \pgfutil@ifnextchar[{\pgfplotsarraysort@opt}{\pgfplotsarraysort@opt[]}% }% @@ -570,3 +606,64 @@ \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 +}% + diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex index b60ff65c4f7..34cb67bfe02 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex @@ -384,7 +384,9 @@ % Each single element will be grouped with TeX groups. \long\def\pgfplotslistforeach#1\as#2#3{% \begingroup - \long\def\pgfpl@@##1{\def#2{##1}% + \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 @@ -415,13 +417,14 @@ % -> iterate through argument until \pgfplotslistforeachungrouped@EOI % comes. \long\def\pgfplotslistforeachungrouped@#1#2\pgfpl@@#3{% - \def\pgfplots@loc@TMPa{#3}% - \ifx\pgfplots@loc@TMPa\pgfplotslistforeachungrouped@EOI + \def\pgfplotslist@loc@TMPa{#3}% + \ifx\pgfplotslist@loc@TMPa\pgfplotslistforeachungrouped@EOI % ok, terminate loop. \let\pgfplotslistforeachungrouped@next=\relax \else % perform loop iteration ... - \def#1{#3}% + \t@pgfplots@tokc={#3}% + \edef#1{\the\t@pgfplots@tokc}% this allows '#' inside of '#3' #2\relax % and continue iterating. \def\pgfplotslistforeachungrouped@next{\pgfplotslistforeachungrouped@{#1}{#2}}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex index bea65490068..fa90ea613f6 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex @@ -72,6 +72,8 @@ % - 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) +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -132,6 +134,9 @@ % 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 @@ -526,3 +531,85 @@ \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/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsmatrix.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsmatrix.code.tex new file mode 100644 index 00000000000..abc273378e0 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/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{% + \pgfplots@warning{Linear system is singular up to machine precision! Continuing with small threshold.}% +}% +\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/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex index b2c3d7bf946..b5480f58b5b 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex @@ -44,6 +44,7 @@ \newif\ifpgfplotstabletypeset@force@remake \newif\ifpgfplotstable@disable@rowcolstyles +\let\pgfplotstable@outfile=\w@pgf@writea \input pgfplotstable.coltype.code.tex @@ -341,6 +342,12 @@ /pgfplots/table/every last column/.style={}, /pgfplots/table/every even 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}}, @@ -464,6 +471,14 @@ \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}% @@ -501,7 +516,8 @@ \fi } }, - /pgfplots/table/multiply with/.code={% + /pgfplots/table/multiply with/.style={/pgfplots/table/multiply by={#1}},% + /pgfplots/table/multiply by/.code={% \pgfmathfloatparsenumber{#1}% \let\pgfplotstable@scale=\pgfmathresult \pgfkeysalso{ @@ -519,7 +535,7 @@ }% }, /pgfplots/table/divide by/.code={% - \pgfkeysalso{/pgfplots/table/multiply with=#1}% + \pgfkeysalso{/pgfplots/table/multiply by=#1}% \let\pgfplotstable@divisor=\pgfplotstable@scale \pgfmathfloatcreate{1}{1.0}{0}% \let\pgfplotstable@ONE=\pgfmathresult @@ -1349,13 +1365,36 @@ %%%%%%%%%%%%%%% +% #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% - \pgfkeysvalueof{/pgfplots/table/preproc cell content/.@cmd}#1\pgfeov + \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% @@ -1391,6 +1430,7 @@ \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{}% @@ -1412,6 +1452,13 @@ \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% @@ -1454,6 +1501,7 @@ \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 @@ -1506,6 +1554,60 @@ \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 @@ -1529,7 +1631,7 @@ % \pgfplotslistnewempty#2 % }{}% %-------------------------------------------------- - \def\pgfplotstablename{#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}% @@ -1702,10 +1804,11 @@ \t@pgfplots@tokb=\expandafter{\pgfplotstable@colname}% \expandafter\pgfplotstable@checkspecialchars@pgfkeys\the\t@pgfplots@tokb\pgfplotstable@EOI \ifpgfutil@in@ - \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/{\the\t@pgfplots@tokb}/.try}% + \edef\pgfplotstable@colname@for@styles{{\the\t@pgfplots@tokb}}% \else - \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/\the\t@pgfplots@tokb/.try}% + \edef\pgfplotstable@colname@for@styles{\the\t@pgfplots@tokb}% \fi + \edef\pgfplotstable@loc@TMPa{\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}% @@ -1901,6 +2004,21 @@ \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 @@ -1987,13 +2105,14 @@ \pgfplots@glob@TMPa% execute 'write to macro' if set. }% + \newif\ifpgfplotstable@isfirstrow \newif\ifpgfplotstable@islastrow \newif\ifpgfplotstablecreatecol@isreallynew \def\pgfplotstablecreatecol@opt[#1]#2#3{% \begingroup - \def\pgfplotstablename{#3}% + \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}% @@ -2525,7 +2644,7 @@ \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance src}{\pgfplotstable@variance@table}% % \ifx\pgfplotstable@table\pgfutil@empty - \pgfutil@ifundefined{pgfplotstablename}{}{% + \pgfutil@ifundefined{pgfplotstablename}{}{% query the name of the actual table struct \let\pgfplotstable@table=\pgfplotstablename }% \fi diff --git a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex index 4a31f8fc84d..37eed5ad6ce 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstableshared.code.tex @@ -56,7 +56,6 @@ \newif\ifpgfplotstable@firstline@is@header \newcount\c@pgfplotstable@counta \newtoks\t@pgfplotstable@a -\newwrite\pgfplotstable@outfile \newif\ifpgfplots@addplotimpl@readcompletely % should always be false; use only in grouped internal macros \newif\ifpgfplots@table@options@areset @@ -97,6 +96,8 @@ /pgfplots/table/z error expr/.initial=, /pgfplots/table/ignore chars/.initial=, /pgfplots/table/white space 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, @@ -481,9 +482,31 @@ \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}% @@ -664,7 +687,7 @@ }% }% \long\def\pgfplotstableread@impl@collectfirstarg#1#2{% - \pgfutil@ifnextchar t{% + \pgfplotsutil@ifnextchar t{% \pgfplotstableread@impl@@{#1}{#2}% }{% \pgfplotstableread@impl@{#1}{#2}% @@ -752,6 +775,15 @@ \pgfplotstableread@inlinefalse \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% @@ -877,6 +909,8 @@ \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 @@ -1024,10 +1058,17 @@ }% }% +\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 @@ -1055,6 +1096,7 @@ \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 @@ -1109,30 +1151,78 @@ % WARNING: this routine is also used in pgfplots.code.tex ... \def\pgfplotstableread@checkspecial@line{% - \pgfutil@ifnextchar##{% + \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 - \pgfplotstableread@impl@gobble - }{% - \pgfutil@ifnextchar${% - \pgfplotstableread@process@flags@line - }{% - \pgfutil@ifnextchar\pgfplotstable@EOI{% + \else + \let\pgfplotstableread@tmpb=$% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb + \let\pgfplotstableread@checkspecial@line@@=\pgfplotstableread@process@flags@line + \else + \let\pgfplotstableread@tmpb=\pgfplotstable@EOI% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb \pgfplotstableread@skiplinetrue \pgfplotsscanlinecomplete% the line is empty; same as \par! - \pgfplotstableread@impl@gobble - }{% - \pgfutil@ifnextchar\par{% + \else + \let\pgfplotstableread@tmpb=\par% + \ifx\pgfplotstableread@tmp\pgfplotstableread@tmpb \pgfplotstableread@skiplinetrue - \pgfplotsscanlinecomplete - \pgfplotstableread@impl@gobble - }{% - \pgfplotstableread@skiplinefalse - \pgfplotstableread@impl@gobble - }% - }% + \pgfplotsscanlinecomplete% the line is empty; + \else + \pgfplotstableread@checkspecial@line@default% + \fi + \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 +% }% +% }% +% }% +% }% +% } +%-------------------------------------------------- \long\def\pgfplotstableread@process@flags@line$flags {% %\pgfplots@message{Ignoring flags line ...}% @@ -1435,7 +1525,7 @@ \else \begingroup \t@pgfplots@tokc={#1}% - \pgfplotstable@error{Table '\pgfplotstableread@filename' has too much columns in line \thepgfplotstableread@lineno: Ignoring '\the\t@pgfplots@tokc'. Please verify that every cell entry is separated correctly (use braces {<cell entry>} if necessary). This error is not critical}% + \pgfplotstable@error{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}% \endgroup \fi } @@ -1648,17 +1738,14 @@ }% \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\as#1#2{% - \def\pgfplotstablecol{0}% - \pgfplotslistforeachungrouped\pgfplotstable@colnames@glob\as#1{% - #2\relax% - \pgfplotsutil@advancestringcounter\pgfplotstablecol - }% - \let\pgfplotstablecol=\relax +\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 diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex index 180ca8ce195..42499218fef 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex @@ -17,7 +17,7 @@ % #2: for normal processing. \def\pgfplots@ifneedspgfcompabitibilitycode#1#2{% %\pgfkeysifdefined{/pgf/number format/sci precision/.@cmd}{#2}{#1}% - \pgfutil@ifundefined{tikzifinpicture}{#1}{#2}% + \pgfutil@ifundefined{pgfmath@tonumber@notrailingzero}{#1}{#2}% }% \pgfplots@ifneedspgfcompabitibilitycode @@ -45,4 +45,6 @@ } {}% + + \endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex index 12d308255bd..dad89e7c7e1 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_misc.code.tex @@ -2,13 +2,14 @@ % ====================================================== % compatibility with PGF 2.0 % ====================================================== +\def\pgfutil@gobble@until@relax#1\relax{} \expandafter\ifx\csname w@pgf@writea\endcsname\relax -\newwrite\w@pgf@writea +\csname newwrite\endcsname\w@pgf@writea \fi \expandafter\ifx\csname r@pgf@reada\endcsname\relax -\newread\r@pgf@reada +\csname newread\endcsname\r@pgf@reada \fi \let\pgfutil@inputcheck=\r@pgf@reada @@ -442,3 +443,333 @@ \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/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex index 8f769db849b..5b9be1a3087 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfcoreexternal.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% @@ -27,16 +27,30 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreexternal.code.tex,v 1.9 2010/07/14 19:32:13 ludewich Exp $ +\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/basiclayer/pgfcoreexternal.code.tex,v 1.17 2010/09/01 08:56:40 ludewich 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/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: @@ -103,68 +117,68 @@ \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@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 \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@ + % 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% - } + \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 - }% + \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{% - \PackageError{pgf}{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'}% + \PackageError{pgf}{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'}% }% @@ -215,7 +229,7 @@ } \long\def\pgf@replacepicturebygraphic#1\endpgfgraphicnamed{% - \expandafter\pgfincludeexternalgraphics\expandafter{\pgf@filename}\unskip + \expandafter\pgfincludeexternalgraphics\expandafter{\pgf@filename}\unskip } % This is almost the same as \includegraphics{#1}, but it checks @@ -226,22 +240,22 @@ % 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 - \pgfkeysgetlet{/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 + \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 } % Defines \pgfexternaldepth to be the depth of the external picture @@ -252,81 +266,88 @@ % .dpth file (it appends it to the main aux file). % \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 + % 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 + \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{}% - -\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. - % - \ifx#1\pgfexternal@restore - #2% - \else - % do NOT execute #1#2! 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 - }% - \fi - \else% it is the depth (which is simply a number for backwards compatibility) - \def\pgfexternaldepth{#1#2}% - \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 + #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' into (expanded!) into the .dpth file of the currently +% Stores '#1' (expanded!) into the .dpth file of the currently % exported image. % -% Just before the image is included into the main document, '#1' will be -% invoked. -% % 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}}% + \immediate\write\w@pgfexternal@auxout{\noexpand\pgfexternal@restore{#1}}% }% @@ -337,10 +358,10 @@ % 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 + \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}% @@ -353,99 +374,115 @@ \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{% - \noexpand\immediate\noexpand\write16{\pgf@external@grab@refundefinedtrue@warning}% - \noexpand\G@refundefinedtrue - }% - \endgroup + \pgf@external@grab@refundefinedtrue@orig + \begingroup + \def\n{\pgfexternal@hat\pgfexternal@hat J}% + \pgfexternalstorecommand{% + \noexpand\immediate\noexpand\write16{\pgf@external@grab@refundefinedtrue@warning}% + \noexpand\G@refundefinedtrue + }% + \endgroup }% \def\pgf@external@grab@refundefinedtrue@warning{% - LaTeX Warning: External picture `\pgfactualjobname' contains undefined references\noexpand\on@line.\n + 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 + \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 + \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}% - \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 + \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}% - % - \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 - % + \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 - % - \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 + \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@papersize{\the\wd\pgfpic}{\the\dimen0}% + % \setbox0=\vbox{% - \kern -1truein % + % I admit that I don't know why there is this kerning: + \kern -\pgf@external@kern@top\relax% \hbox{% - \kern -1truein % + \kern -\pgf@external@kern@left\relax% \hbox to0pt{% \wd\pgfexternal@startupbox=0pt % \ht\pgfexternal@startupbox=0pt % @@ -453,29 +490,32 @@ \box\pgfexternal@startupbox% \pgfsys@atbegindocument\hss}% \box\pgfpic% - \kern 1truein }% - \kern1truein }% - % - % 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 - % + \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}% + \gdef\pgfexternal@did@a@shipout{1}% }% \ifpgfexternal@aux@in@dpth - \endgroup + \endgroup \fi } \def\pgfexternal@nointerlineskip{% - \ifvmode - \pgfexternal@nointerlineskip@orig - \else - \relax% \nointerlineskip in horizontal mode not allowed. Silently ignore the error message. - \fi + \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/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex index a1410e84a0f..59688c15a67 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeys.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% @@ -773,6 +773,7 @@ \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 @@ -924,7 +925,7 @@ \pgfkeys{/handlers/.expand twice/.code=\expandafter\expandafter\expandafter\pgfkeys@exp@call\expandafter\expandafter\expandafter{#1}} \pgfkeys{/handlers/.expanded/.code=\edef\pgfkeys@temp{#1}\expandafter\pgfkeys@exp@call\expandafter{\pgfkeys@temp}} -\def\pgfkeys@exp@call#1{\pgfkeysalso{\pgfkeyscurrentpath={#1}}} +\long\def\pgfkeys@exp@call#1{\pgfkeysalso{\pgfkeyscurrentpath={#1}}} % Try to set a key and do nothing if not define diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex index 82fb11cd2e9..0094344d89b 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfkeysfiltered.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex index 39c273655bf..c08f7dee2fe 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% @@ -750,7 +750,7 @@ % 100 <= m < 1000 % instead of 1 <= m < 10. % -% The 'extended precision' means we have higher accuracy when we apply pgfmath operations to mantisses. +% 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). % diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex index 054598b052e..1cb2e67de17 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryplothandlers.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex index 79d03962283..cabffe11ba6 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex index 366a3212cba..380a696a1df 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% @@ -143,6 +143,11 @@ /pdflinks/internal link prefix/.initial=pgf, } +\begingroup + \catcode`\_=12 + \gdef\pgfmanualpdf@underscore{_}% +\endgroup + \gdef\pgfmanualpdf@installreplacements{% \def\marg##1{{##1}}% \def\oarg##1{[##1]}% @@ -156,6 +161,7 @@ \def\printanat{@}% \def\protect{}% \def\textasciicircum{o}% + \def\_{\pgfmanualpdf@underscore}% \expandafter\edef\pgfmanual@verb@activebar{\pgfmanual@verb@bar}% }% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex index dc5c3867277..b6ca2c4e2e0 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.prettyprinter.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex index b8d956b6054..6ef0b8f63ff 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% @@ -54,6 +54,13 @@ % 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{} @@ -63,7 +70,7 @@ % meaning % [+-]X.XXXXXXX*10^C % where -% X.XXXXXX is a mantisse with first number != 0, C is an integer and +% 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 @@ -124,13 +131,13 @@ \let\pgfmathfloatqparsenumber=\pgfmathfloatparsenumber % Takes a floating point number #1 as input and writes flags to count -% register #2, mantisse to dimen register #3 and exponent to count +% register #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 mantisse into a token register. +% 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}% } @@ -144,14 +151,16 @@ \expandafter\pgfmathfloat@decompose@Fmacro#1\relax{#2}% }% -% Extracts the mantisse of #1 into the dimen register #2. -\def\pgfmathfloatgetmantisse#1#2{% +% Extracts the mantissa of #1 into the dimen register #2. +\def\pgfmathfloatgetmantissa#1#2{% \expandafter\pgfmathfloat@decompose@M#1\relax{#2}% } -% Extracts the mantisse of #1 into the token register #2. -\def\pgfmathfloatgetmantissetok#1#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}% @@ -189,14 +198,14 @@ % decomposes a lowlevel floating point representation into flags, -% mantisse and exponent. +% mantissa and exponent. % % #4: integer register for the flags. -% #5: dimen registers for the mantisse. +% #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, mantisse and exponent +% -> the three temp registers contain flags, mantissa and exponent \def\pgfmathfloat@decompose#1#2{% sanitize! \ifx#2Y% \expandafter\pgfmathfloat@decompose@% @@ -211,11 +220,11 @@ #6=#3\relax% } -% overloaded, #5 needs to be a token register for the mantisse. +% 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, mantisse and exponent +% -> the three temp registers contain flags, mantissa and exponent \def\pgfmathfloat@decompose@tok#1#2{% \ifx#2Y% \expandafter\pgfmathfloat@decompose@tok@% @@ -329,7 +338,7 @@ \pgfmathfloat@decompose@TMP }% % Takes a floating point number #1 as input and writes flags to macro -% #2, mantisse to macro #3 and exponent to macro #4. +% #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 @@ -344,7 +353,7 @@ % Defines \pgfmathresult as the floating point number encoded by -% the flags #1, mantisse #2 and exponent #3. +% the flags #1, mantissa #2 and exponent #3. % % All arguments are characters and will be expanded using '\edef'. \def\pgfmathfloatcreate#1#2#3{% @@ -490,7 +499,7 @@ \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 + \c@pgf@counta=#4\relax % it is the exponent here. \ifnum#2=0 \c@pgf@counta=0 \fi @@ -529,20 +538,30 @@ \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 #2}% - \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 }% + \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 + \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 @@ -579,7 +598,7 @@ \fi \fi \fi - \ifnum\c@pgf@counta>0 + \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 }% @@ -591,7 +610,8 @@ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT } \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printtrailingdigits#1#2{% - \ifcase\c@pgf@counta + \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{% @@ -603,7 +623,7 @@ \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@counteverythird% }% \fi - \ifnum\c@pgf@countb>0\relax + \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}% @@ -643,6 +663,32 @@ \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 @@ -680,7 +726,7 @@ % The default style to display fixed point numbers. % -% It does not apply numerics, but it is responsable to typeset the +% It does not apply numerics, but it is responsable for typesetting the % rounded number. % It can access the \ifpgfmathfloatroundhasperiod boolean. % @@ -699,12 +745,12 @@ % Rounds a normalized floating point number to \pgfmathfloat@round@precision % digits precision and writes the result to \pgfmathresult. % -% This method uses \pgfmathroundto for the mantisse. +% This method uses \pgfmathroundto for the mantissa. % % @see pgfmathfloatroundzerofill % % SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set to -% whether the final mantisse #5 has a period or not. +% whether the final mantissa #5 has a period or not. \def\pgfmathfloatround#1{% \pgfmathfloatroundhasperiodtrue \begingroup @@ -717,13 +763,13 @@ % Overload. % -% This method uses a fixed width for the mantisse and fills in zeros +% This method uses a fixed width for the mantissa and fills in zeros % if necessary. % -% This method uses \pgfmathroundtozerofill for the mantisse. +% This method uses \pgfmathroundtozerofill for the mantissa. % % SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set to -% whether the final mantisse #5 has a period or not. +% whether the final mantissa #5 has a period or not. \def\pgfmathfloatroundzerofill#1{% \pgfmathfloatroundhasperiodtrue \begingroup @@ -734,16 +780,16 @@ \endgroup } -\newif\ifpgfmathfloatround@allow@empty@mantisse -\def\pgfmathfloatround@mantisse@ONE{1.0}% +\newif\ifpgfmathfloatround@allow@empty@mantissa +\def\pgfmathfloatround@mantissa@ONE{1.0}% % #1: sign -% #2: mantisse +% #2: mantissa % #3: exponent -% #4: CODE to display if the mantisse is drawn. +% #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 mantisse is NOT draw. (unused currently) +% #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{% @@ -828,11 +874,11 @@ \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/mantisse sep}\pgfmathdisplay@aftermantisse - \pgfkeysgetvalue{/pgf/number format/sci generic/empty mantisse sep}\pgfmathdisplay@nomantisse + \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@aftermantisse}% - \toks1=\expandafter{\pgfmathdisplay@nomantisse}% + \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 @@ -845,7 +891,7 @@ % % PRECONDITION: % the floating point number has already been rounded properly and -% the mantisse has been rounded correcty. +% the mantissa has been rounded correcty. % % The argument needs to be in the format returned by % \pgfmathfloat@to@FMeE@style and terminated by '\relax'. @@ -859,6 +905,7 @@ \long\def\pgfmathfloatfrac@verbatim#1#2{#1/#2}% +\newif\ifpgfmathprintnumber@thousand@sep@in@fractional \pgfkeys{% /pgf/number format/.is family, /pgf/number format, @@ -866,6 +913,10 @@ sci/.code= \pgfmath@set@number@printer{pgfmathprintnumber@SCI}, std/.code= {\pgfmath@set@number@printer{pgfmathprintnumber@STD}\pgfmathprintnumber@STD@setparam{#1}}, std/.default=,% + % relative={<exponent base 10>} + relative/.code= {\pgfmath@set@number@printer{pgfmathprintnumber@RELATIVE}\def\pgfmathprintnumber@RELATIVE@param{#1}},% + relative/.value required, + every relative/.style=std, 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},% @@ -902,6 +953,8 @@ @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={{{,}}}}, @@ -926,13 +979,15 @@ {##1##2##3}% {\pgfqkeys{/pgf/number format/sci generic}{#1}}% }, - sci generic/mantisse sep/.initial=,% - sci generic/empty mantisse sep/.initial=,% + 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={mantisse sep=,exponent={e##1}}, + sci generic={mantissa sep=,exponent={e##1}}, 1000 sep=, skip 0.=false, print sign=false, @@ -944,8 +999,8 @@ @sci exponent mark=, }% }, -% sci may skip mantisse/.is if=pgfmathfloatround@allow@empty@mantisse, -% sci may skip mantisse/.default=true, +% sci may skip mantissa/.is if=pgfmathfloatround@allow@empty@mantissa, +% sci may skip mantissa/.default=true, } @@ -962,7 +1017,7 @@ \ifx\pgfmathfloat@loc@TMPb\pgfutil@empty % DEFAULT for lower and upper bound. \def\pgfmathprintnumber@STD@getlowerbound{% - \c@pgf@counta=\pgfmathfloat@round@precision\relax + \c@pgf@counta=\pgfmathfloat@round@precision@orig\relax \divide\c@pgf@counta by-2\relax }% \def\pgfmathprintnumber@STD@upperbound{4}% @@ -1008,6 +1063,55 @@ \fi } +\def\pgfmathprintnumber@RELATIVE#1{% + % parse the input: + \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult + \expandafter\pgfmathprintnumber@RELATIVE@issci\pgfmathresult\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: + \ifnum\c@pgf@counta>0 + % hm. for positive exponents, we should round the + % mantissa rather than only the fractional part. + \expandafter\pgfmathfloatround\expandafter{\pgfmathresult}% + \else + % negative exponent -> round fixed representation: + \pgfmathfloattofixed\pgfmathresult + \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% + \pgfmathfloatparsenumber{\pgfmathresult}% + \pgfmathfloatroundhasperiodtrue% make sure the code below works: + \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}% + \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@frac#1{% % parse the input: \pgfmathfloatparsenumber{#1}% @@ -1106,8 +1210,8 @@ \fi % \def\pgfmathfloat@loc@TMPa##1.##2\relax{% - \def\pgfmathfloat@mantisse@first{##1}% - \def\pgfmathfloat@mantisse@ltone{0.##2}% + \def\pgfmathfloat@mantissa@first{##1}% + \def\pgfmathfloat@mantissa@ltone{0.##2}% }% \expandafter\pgfmathfloat@loc@TMPa\the\pgfmathfloat@a@Mtok\relax % @@ -1126,7 +1230,7 @@ \ifx\pgfmath@target@denominator\pgfutil@empty % \pgfmathfloat@a@E=-\pgfmathfloat@a@E - \ifdim\pgfmathfloat@mantisse@ltone pt=0pt + \ifdim\pgfmathfloat@mantissa@ltone pt=0pt \def\pgfmathfloat@factor{1}% \edef\pgfmathfloat@scaled@numerator{\the\pgfmathfloat@a@Mtok}% \else @@ -1135,14 +1239,14 @@ % The errors of 1/r are magnified by 10^k which % doesn't work. \pgfutil@ifundefined{FPdiv}{% - \pgfmathfloatparsenumber{\pgfmathfloat@mantisse@ltone}% + \pgfmathfloatparsenumber{\pgfmathfloat@mantissa@ltone}% \pgfmathfloatreciprocal@{\pgfmathresult}% }{% % \usepackage{fp}. % yields higher absolute precision. \FPmessagesfalse% \FPdebugfalse% - \FPdiv\pgfmathresult{1}{\pgfmathfloat@mantisse@ltone}% + \FPdiv\pgfmathresult{1}{\pgfmathfloat@mantissa@ltone}% \pgfmathfloatparsenumber{\pgfmathresult}% }% \let\pgfmathfloat@inv=\pgfmathresult @@ -1519,7 +1623,7 @@ % % Let 'k' be the desired precision. % -% Please note that pgfmathroundto rounds the mantisse, that means |abs(x)|. +% 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. @@ -1864,7 +1968,7 @@ %-------------------------------------------- -% flags, mantisse and exponent has already been stored into +% flags, mantissa and exponent has already been stored into % \pgfmathfloat@a@* [using ...@Mtok] % % PRECONDITION: @@ -1895,7 +1999,7 @@ -% ATTENTION: this thing REQUIRES a period in the mantisse! +% ATTENTION: this thing REQUIRES a period in the mantissa! % collects everything into \pgfmathresult \def\pgfmathfloattofixed@impl#1.#2\relax{% \ifnum\pgfmathfloat@a@E<0 @@ -1942,7 +2046,7 @@ % \edef\pgfmathresult{#1.#2}% % \else % \pgfmathfloat@a@Mtok={#1}% - % \pgfmathfloattofixed@impl@collectmantisse#2\count\pgfmathfloat@a@E + % \pgfmathfloattofixed@impl@collectmantissa#2\count\pgfmathfloat@a@E % \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}% % \fi %-------------------------------------------------- @@ -1976,11 +2080,11 @@ \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@collectmantisse#9\count\pgfmathfloat@a@E + \pgfmathfloattofixed@impl@collectmantissa#9\count\pgfmathfloat@a@E \fi }% -\def\pgfmathfloattofixed@impl@collectmantisse#1#2\count#3{% +\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}% @@ -1995,7 +2099,7 @@ \ifnum\pgfmathfloat@a@E=0 \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok .#2}% \else - \pgfmathfloattofixed@impl@collectmantisse#2\count#3% + \pgfmathfloattofixed@impl@collectmantissa#2\count#3% \fi \fi } diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathparse.opt.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathparse.opt.code.tex deleted file mode 100644 index e74d47c814e..00000000000 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathparse.opt.code.tex +++ /dev/null @@ -1,122 +0,0 @@ -% A small optimization package which provides -% -% \beginpgfmathparsecheckfornumber -% ... -% \endpgfmathparsecheckfornumber -% -% in order to optimize \pgfmathparse. It works as follows: inside of -% the environment (which doesn't use scopes), \pgfmathparse is -% *replaced* by a different method which uses an extremely fast check -% to decide whether the input is a number number. Is so, it returns -% the number. Otherwise, it invokes the standard math parser. -% It is about 400% faster than \pgfmathparse if the argument *is* a -% number. -% -% The \endpgfmathparsecheckfornumber is optional (no groups are -% introduced) -% -% Copyright 2010 by Christian Feuersänger. -% -% Replaces \pgfmathparse by the fast number checker. -\def\beginpgfmathparsecheckfornumber{% - \let\pgfmathparse=\pgfmathparsehashedcheck -}% -\def\endpgfmathparsecheckfornumber{% - \let\pgfmathparse=\pgfmathparsehashedcheck@orig -}% - -\def\pgfmp@EOI{\pgfmp@EOI}% -\def\pgfmathparsehashedcheck@isnumber@gobble#1\pgfmp@EOI{} - -\newdimen\r@pgfmathparse@hashedcheck@ -\newcount\c@pgfmathparse@hashedcheck@ -\let\pgfmathparsehashedcheck@orig=\pgfmathparse - -\def\pgfmathparsehashedcheck#1{% - \edef\pgfmathparse@temp{#1}% - \expandafter\pgfmathparsehashedcheck@isnumber@loop\pgfmathparse@temp\pgfmp@EOI - \pgfmathparsehashedcheck@finalize{#1}% -}% -\def\pgfmathparsehashedcheck@finalize@isnonumber#1{% - \pgfmathparsehashedcheck@orig{#1}% - \let\pgfmathparsehashedcheck@finalize\pgfmathparsehashedcheck@finalize@isnumber -}% -\def\pgfmathparsehashedcheck@finalize@isnumber#1{% - \r@pgfmathparse@hashedcheck@=#1pt - \expandafter\pgfmathparsehashed@assign\the\r@pgfmathparse@hashedcheck@ - %-------------------------------------------------- - % % - % \let\KKK=\pgfmathresult - % \pgfmathparsehashedcheck@orig{#1}% - % \ifx\KKK\pgfmathresult - % \else - % \pgfplots@error{FAILED FOR #1: expected `\pgfmathresult'; got `\KKK' (temp = \pgf@temp)}% - % \fi - %-------------------------------------------------- -}% -{\catcode`\p=12\catcode`\t=12\gdef\PGF@TEMP{pt}} -\expandafter\def\expandafter\pgfmathparsehashed@assign\expandafter#\expandafter1\expandafter.\expandafter#\expandafter2\PGF@TEMP{% - \def\pgf@temp{#2}% - \ifx\pgf@temp0% - \def\pgfmathresult{#1}% - \else - \def\pgfmathresult{#1.#2}% - \fi -}% -\let\pgfmathparsehashedcheck@finalize\pgfmathparsehashedcheck@finalize@isnumber - -\expandafter\def\csname pgf@pp+\endcsname{1} -\expandafter\def\csname pgf@pp-\endcsname{1} -\expandafter\def\csname pgf@p0\endcsname{1} -\expandafter\def\csname pgf@p1\endcsname{1} -\expandafter\def\csname pgf@p2\endcsname{1} -\expandafter\def\csname pgf@p3\endcsname{1} -\expandafter\def\csname pgf@p4\endcsname{1} -\expandafter\def\csname pgf@p5\endcsname{1} -\expandafter\def\csname pgf@p6\endcsname{1} -\expandafter\def\csname pgf@p7\endcsname{1} -\expandafter\def\csname pgf@p8\endcsname{1} -\expandafter\def\csname pgf@p9\endcsname{1} -\expandafter\def\csname pgf@p.\endcsname{1} - -\pgfutil@ifundefined{ifcsname}{% - \def\pgfmathparsehashedcheck@isnumber@loop#1{% - \expandafter\ifx\csname pgf@pp\string#1\endcsname\relax - \expandafter\pgfmathparsehashedcheck@isnumber@loop - \else - \expandafter\pgfmathparsehashedcheck@isnumber@loop@\expandafter#1% - \fi - }% - \def\pgfmathparsehashedcheck@isnumber@loop@#1{% - \expandafter\ifx\csname pgf@p\string#1\endcsname\relax - \expandafter\pgfmathparsehashedcheck@isnumber@loop@ - \else - \expandafter\pgfmathparsehashedcheck@isnumber@endfalse\expandafter#1% - \fi - }% -}{% - \def\pgfmathparsehashedcheck@isnumber@loop#1{% - \ifcsname pgf@pp\string#1\endcsname - \expandafter\pgfmathparsehashedcheck@isnumber@loop - \else - \expandafter\pgfmathparsehashedcheck@isnumber@loop@\expandafter#1% - \fi - }% - \def\pgfmathparsehashedcheck@isnumber@loop@#1{% - \ifcsname pgf@p\string#1\endcsname - \expandafter\pgfmathparsehashedcheck@isnumber@loop@ - \else - \expandafter\pgfmathparsehashedcheck@isnumber@endfalse\expandafter#1% - \fi - }% -}% -\def\pgfmathparsehashedcheck@isnumber@endfalse#1{% - \ifx#1\pgfmp@EOI - \else - \let\pgfmathparsehashedcheck@finalize=\pgfmathparsehashedcheck@finalize@isnonumber - \expandafter\pgfmathparsehashedcheck@isnumber@gobble - \fi -}% - - -\endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty index 9025de703be..7dc97116753 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex index 757439ed17f..2d7a81b2bf5 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% @@ -46,7 +46,6 @@ \toksdef\t@tikzexternal@tmpa=0 \toksdef\t@tikzexternal@tmpb=1 -\newwrite\tikzexternal@outfile \newif\iftikzexternal@nestedflag \newif\iftikzexternal@verboseio \newif\iftikzexternal@genfigurelist @@ -132,6 +131,9 @@ \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 = {% @@ -175,7 +177,7 @@ shell escape/.initial=-shell-escape, read main aux/.is if=pgfexternalreadmainaux, image discarded text/.initial={% - [[ {\sc Image Discarded Due To} {\tt`/tikz/external/% + [[ \textsc{Image Discarded Due To} \texttt{`/tikz/external/% \ifcase\tikzexternal@opmode\relax mode=only graphics% \or @@ -215,6 +217,7 @@ \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 @@ -332,7 +335,7 @@ \tikzexternalenable \def\tikzexternal@determineimgextension##1:##2\relax{\gdef\tikzexternalimgextension{##1}}% \xdef\pgf@tempa{\pgfsys@imagesuffixlist}% - \expandafter\tikzexternal@determineimgextension\pgf@tempa\relax + \expandafter\tikzexternal@determineimgextension\pgf@tempa:\relax \pgfutil@ifundefined{includegraphics}{% \let\tikzexternal@orig@includegraphics=\relax }{% @@ -344,6 +347,14 @@ } \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. % @@ -459,27 +470,40 @@ \else \ifx#1\@EOI \else - \expandafter\let\csname tikzexternalauxlock@handleref@orig@\string#1\endcsname=#1% - \def#1{\tikzexternalauxlock@handleref@repl{#1}}% + {% + % strip the leading '\' + % this allows proper \protect ion when you write + % \caption{...\cite{..}} and #1=\cite + \escapechar=-1 + \xdef\pgf@temp{\string#1}% + }% + \expandafter\let\csname tikzexternalauxlock@handleref@orig@\pgf@temp\endcsname=#1% + \edef#1{\noexpand\pgf@texdist@protect\noexpand\tikzexternalauxlock@handleref@repl{\pgf@temp}}% \expandafter\expandafter\expandafter\tikzexternalauxlock@handleref@loop \fi \fi }% \def\tikzexternalauxlock@handleref@repl#1{\pgfutil@ifnextchar[{\tikzexternalauxlock@handleref@repl@{#1}}{\tikzexternalauxlock@handleref@repl@{#1}[]}}% \def\tikzexternalauxlock@handleref@repl@#1[#2]#3{% - \csname tikzexternalauxlock@handleref@orig@\string#1\endcsname{#3}% - \begingroup - \def\n{\pgfexternal@hat\pgfexternal@hat J}% - \tikzexternal@assemble@systemcall{\pgfactualjobname}{\pgf@tempa}% - \def\space{\noexpand\space}% - \pgfexternalstorecommand{% - \noexpand\begingroup - \noexpand\toks0={\pgf@tempa}% - \noexpand\immediate\noexpand\write16{\tikzexternalauxlock@handleref@warning{#3}{\noexpand\the\noexpand\toks0}}% - \noexpand\G@refundefinedtrue - \noexpand\endgroup + \tikzifexternalizingcurrent{% + % note that '#1' is NO control sequence! it is a protected string + \csname tikzexternalauxlock@handleref@orig@#1\endcsname{#3}% + \begingroup + \def\n{\pgfexternal@hat\pgfexternal@hat J}% + \tikzexternal@assemble@systemcall{\pgfactualjobname}{\pgf@tempa}% + \def\space{\noexpand\space}% + \pgfexternalstorecommand{% + \noexpand\begingroup + \noexpand\toks0={\pgf@tempa}% + \noexpand\immediate\noexpand\write16{\tikzexternalauxlock@handleref@warning{#3}{\noexpand\the\noexpand\toks0}}% + \noexpand\G@refundefinedtrue + \noexpand\endgroup + }% + \endgroup + }{% + % ok. We are not externalizing this part of the document. + % Throw the citation away without further notice. }% - \endgroup }% \def\tikzexternalauxlock@handleref@warning#1#2{% \n @@ -798,6 +822,11 @@ \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' @@ -818,6 +847,9 @@ \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 @@ -862,6 +894,7 @@ \def\tikzexternalmakefiledefaultdeprule{% \immediate\write\tikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}% + \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p $(dir $@)}% \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}% }% @@ -1056,7 +1089,9 @@ \iftikzexternal@verbose@optimize \immediate\write16{The command '\the\toks0' has been optimized away. Use '/tikz/external/optimize=false' to disable this.}% \fi - [ {\sc \string#1\ optimized away because it does not contribute to exported PDF}]% + \endgroup + \begingroup + \pgfkeysvalueof{/tikz/external/optimize away text/.@cmd}#1\pgfeov% \endgroup }% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex index 42056506818..badd22fd89d 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzlibraryexternal.code.tex @@ -14,7 +14,7 @@ %%% - nested \input commands have been updated %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 5. Aug 20:33:50 CEST 2010 %%% +%%% Date of this copy: Sa 30. Apr 21:00:37 CEST 2011 %%% diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex index 14e4d2e9c3d..bca33bab29e 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex @@ -33,6 +33,7 @@ \input pgfplotsutil.code.tex \input pgfplotscolormap.code.tex \input pgfplotsstackedplots.code.tex +\input pgfplotsplothandlers.code.tex \input pgfplotscoordprocessing.code.tex \input pgfplotsticks.code.tex @@ -47,12 +48,12 @@ \newif\ifpgfplots@has@label@information \newif\ifpgfplots@yislinear \newif\ifpgfplots@zislinear -\newif\ifpgfplots@axis@equal -\newif\ifpgfplots@axis@equal@image +\newif\ifpgfplots@unit@vector@rescale@keep@size \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 \newcount\pgfplots@numplots \newdimen\pgfplots@xmin@reg \newdimen\pgfplots@xmax@reg @@ -109,6 +110,7 @@ \newif\ifpgfplots@stacked@plus \newif\ifpgfplots@plot@file@skipfirst \newif\ifpgfplots@threedim +\newif\ifpgfplots@curplot@threedim \newif\ifpgfplotsthreedim \newif\ifpgfplots@curplot@isirrelevant \newif\ifpgfplots@colorbar @@ -116,6 +118,8 @@ \newif\ifpgfplots@translategnuplot \pgfplots@translategnuplottrue \let\pgfnodepartimagebox=\pgfnodeparttextbox +\newif\ifpgfplotsplothandlermesh@internaldepth +\newif\ifpgfplotsplothandlermesh@hide@refined@edges \newif\ifpgfplots@collect@firstplot@astick \newif\ifpgfplots@units@use @@ -127,6 +131,8 @@ \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{% @@ -167,19 +173,34 @@ 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={fill=.!80!black},mark=*\\% - every mark/.append style={fill=.!80!black},mark=square*\\% - every mark/.append style={fill=.!80!black},mark=triangle*\\% - mark=star\\% - every mark/.append style={fill=.!80!black},mark=diamond*\\% - every mark/.append style={fill=.!80!black},mark=otimes*\\% - mark=|\\% - every mark/.append style={fill=.!80!black},mark=pentagon*\\% - mark=text,text mark=p\\% - mark=text,text mark=a\\% + 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}} \pgfplotscreateplotcyclelist{exotic}{% teal,every mark/.append style={fill=teal!80!black},mark=*\\% orange,every mark/.append style={fill=orange!80!black},mark=square*\\% @@ -200,8 +221,6 @@ \pgfplots@letcsname{pgfp@cyclist@\string\coloredplotspeclist @}={pgfp@cyclist@color@}% %%%% -\def\pgfplotsset#{\pgfqkeys{/pgfplots}} - \def\pgfplotsdeprecatedstylecheck#1{% \pgfkeysifdefined{#1/.@cmd}{% \begingroup @@ -568,12 +587,12 @@ }, /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 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 y axis line/.append style={#1},% /pgfplots/every inner z axis line/.append style={#1}% }, /pgfplots/axis line style/.style={ @@ -717,6 +736,15 @@ /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, @@ -838,13 +866,6 @@ /pgfplots/colorbar/width/.initial=0.5cm, /pgfplots/colorbar addplot/.initial=\addplot graphics {};, /pgfplots/colorbar/draw/.code={% - % 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 \axis[every colorbar,colorbar shift,colorbar=false] \pgfkeysvalueof{/pgfplots/colorbar addplot}% \endaxis @@ -1101,6 +1122,17 @@ /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 length/.estore in=\pgfplots@subtickwidth, /pgfplots/minor tick length/.belongs to family=/pgfplots/tick, /pgfplots/major tick length/.estore in=\pgfplots@tickwidth, @@ -1285,6 +1317,21 @@ /pgfplots/anchor/.belongs to family=/pgfplots, /pgfplots/anchor/.store in= \pgfplots@anchorname, /pgfplots/anchor=south west, + /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, @@ -1462,8 +1509,6 @@ /pgfplots/ylabel shift={#1}, /pgfplots/zlabel shift={#1}, },% - /pgfplots/before end axis/.code=, - /pgfplots/after end axis/.code=, /pgfplots/extra description/.code=, % axis options: /pgfplots/at/.code={% @@ -1493,9 +1538,36 @@ /pgfplots/clip/.is if=pgfplots@clip, % will be used if it exists: %/pgfplots/axis background/.style={}, - /pgfplots/axis equal/.is if=pgfplots@axis@equal, + % + % 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 if=pgfplots@unit@vector@rescale@keep@size, + /pgfplots/unit rescale keep size/.default=true, + /pgfplots/unit rescale keep size=true, + /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 if=pgfplots@axis@equal@image, + /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=, @@ -1503,6 +1575,8 @@ /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=, @@ -1533,6 +1607,7 @@ /pgfplots/stack dir=plus, /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={}, @@ -1548,9 +1623,9 @@ /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 + % '#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. + % '#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 @@ -1567,31 +1642,31 @@ \def\pgfplots@restrict@to@domain@tmp{#2}% \ifx\pgfplots@restrict@to@domain@tmp\pgfutil@empty % we don't have an expression. - \pgfmathfloatparsenumber{\pgfmathresult}% \else % evaluate the expression! \pgfmathparse{#2}% \fi + \pgfplotscoordmath{default}{parsenumber}{\pgfmathresult}% \let\pgfplots@restrict@to@domain@tmp=\pgfmathresult - \pgfmathfloatlessthan@{\pgfplots@restrict@to@domain@tmp}{##1}% ##1 is the lower argument - \ifpgfmathfloatcomparison - \edef\pgfmathresult{\if0#4inf\else ##1\fi}% - \else - \pgfmathfloatgreaterthan@{\pgfplots@restrict@to@domain@tmp}{##2}% - \ifpgfmathfloatcomparison - \edef\pgfmathresult{\if0#4-inf\else ##2\fi}% - \else - \let\pgfmathresult=\pgfplots@restrict@to@domain@orig - \fi - \fi + % + \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}% + }% }% }% }% % when invoked, ##1 and ##2 will be the user-supplied args. \def\pgfplots@loc@TMPc##1:##2\relax{% - \pgfmathfloatparsenumber{##1}% + \pgfplotscoordmath{default}{parsenumber}{##1}% \let\pgfplots@rangea=\pgfmathresult - \pgfmathfloatparsenumber{##2}% + \pgfplotscoordmath{default}{parsenumber}{##2}% \edef\pgfplots@loc@TMPc{\pgfplots@rangea:\pgfmathresult}% \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPc\relax }% @@ -1599,11 +1674,14 @@ \expandafter\pgfplots@loc@TMPc\pgfplots@loc@TMPa\relax },% % -> keeps only the nth point, all other ones will get ''. - /pgfplots/each nth point/.style={% - /pgfplots/x filter/.append code={% + /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{#1}% + \edef\c@pgfplots@eachnthpoint@xfilter@cmp{#2}% \else \pgfplotsutil@advancestringcounter\c@pgfplots@eachnthpoint@xfilter \ifx\c@pgfplots@eachnthpoint@xfilter@cmp\c@pgfplots@eachnthpoint@xfilter @@ -1614,11 +1692,14 @@ \fi }% }, - /pgfplots/skip coords between index/.style 2 args={% - /pgfplots/x filter/.append code={% - \ifnum\coordindex<#1\relax + /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<#2\relax + \ifnum\coordindex<#3\relax \let\pgfmathresult=\pgfutil@empty \fi \fi} @@ -1647,6 +1728,7 @@ /pgfplots/samples y/.initial=,% empty -> use the same as 'samples'. For use in mesh plots. /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}}}, @@ -1662,9 +1744,17 @@ /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 end axis/.initial=, + /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, @@ -1684,16 +1774,31 @@ /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/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/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,% @@ -1720,6 +1825,7 @@ /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 @@ -2278,7 +2384,7 @@ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname% \def\pgfplots@nodes@near@coords@align{above}% \else - \pgfmathfloatifflags{\pgfplotspointmeta}{2}{% + \pgfplotscoordmath{meta}{if is}{\pgfplotspointmeta}{-}{% % \pgfplotspointmeta < 0 \def\pgfplots@nodes@near@coords@align{left}% }{% @@ -2292,7 +2398,7 @@ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname% \def\pgfplots@nodes@near@coords@align{above}% \else - \pgfmathfloatifflags{\pgfplotspointmeta}{2}{% + \pgfplotscoordmath{meta}{if is}{\pgfplotspointmeta}{-}{% % \pgfplotspointmeta < 0 \def\pgfplots@nodes@near@coords@align{below}% }{% @@ -2333,11 +2439,17 @@ },% },% /pgfplots/nodes near coords*/.default={\pgfmathprintnumber\pgfplotspointmeta}, + /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}, @@ -2354,6 +2466,9 @@ /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)};}, + }, /pgfplots/ybar/.style={ bar cycle list, xtick align=outside, @@ -2383,6 +2498,9 @@ /pgfplots/xbar legend/.style={ /pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0cm,0.8em) (2*\pgfplotbarwidth,0.6em)};}, }, + /pgfplots/single xbar 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)};}, + }, /pgfplots/xbar/.style={ bar cycle list, ytick align=outside, @@ -2444,6 +2562,7 @@ /pgfplots/xbar stacked/.style={ /pgfplots/set point meta if empty=x,% bar cycle list, + single xbar legend, stack plots=x, stack dir=#1, /tikz/xbar, @@ -2452,6 +2571,7 @@ /pgfplots/ybar stacked/.style={ /pgfplots/set point meta if empty=f(x),% bar cycle list, + single ybar legend, stack plots=y, stack dir=#1, /tikz/ybar, @@ -2460,6 +2580,7 @@ /pgfplots/xbar interval stacked/.style={ /pgfplots/set point meta if empty=x,% bar cycle list, + single xbar legend, stack plots=x, stack dir=#1, /tikz/xbar interval, @@ -2468,6 +2589,7 @@ /pgfplots/ybar interval stacked/.style={ /pgfplots/set point meta if empty=f(x),% bar cycle list, + single ybar legend, stack plots=y, stack dir=#1, /tikz/ybar interval, @@ -2496,6 +2618,29 @@ /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, + /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}% },% @@ -2508,6 +2653,9 @@ at={(0pt,0pt)}, rectangle }, + % 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, @@ -2531,6 +2679,44 @@ \pgfkeysalso{/pgfplots/mesh=#1}% \def\pgfplots@meshmode{s}% },% + /pgfplots/patch/.code={% + \pgfkeysalso{/pgfplots/surf=#1,/pgfplots/mesh input=patches,/pgfplots/every patch}% + },% + /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 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/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,% @@ -2566,7 +2752,7 @@ \pgfplotsplothandlermesh@defaultlegend@img{##1}% }% }, - /pgfplots/mesh/num points/.initial=\numcoords,% this is NOT part of the public interface. Don't change it. + /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}},% @@ -2592,6 +2778,7 @@ /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/clip marker paths/.is if=pgfplots@clip@marker@paths, @@ -2636,19 +2823,22 @@ /pgfplots/z coord trafo/.code={}, /pgfplots/z coord inv trafo/.code={}, % - % #1 = {<symbol1>,<symbol2>,....<symboln>} + % #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={% - \pgfplotsarraynew\pgfplots@symbolic@coords@inverse{#2}% - \pgfplotsarrayforeachungrouped\pgfplots@symbolic@coords@inverse\as\pgfplots@loc@TMPa{% - \expandafter\edef\csname pgfp@symb@coords@\pgfplots@loc@TMPa\endcsname{\pgfplotsarrayforeachindex}% + \expandafter\pgfplotsarraynew\csname pgfplots@symbolic@coords@#1@inverse\endcsname{#2}% + \expandafter\pgfplotsarrayforeachungrouped\csname pgfplots@symbolic@coords@#1@inverse\endcsname\as\pgfplots@loc@TMPa{% + \expandafter\edef\csname pgfp@symb@coords@#1@\pgfplots@loc@TMPa\endcsname{\pgfplotsarrayforeachindex}% }% \pgfkeysdef{/pgfplots/#1 coord trafo}{% - \pgfutil@ifundefined{pgfp@symb@coords@##1}{% + \pgfutil@ifundefined{pgfp@symb@coords@#1@##1}{% \pgfplots@error{Sorry, the input coordinate `##1' has not been defined with 'symbolic #1 coords={#2}... Maybe it has been misspelled?}% \def\pgfmathresult{0}% }{% - \edef\pgfmathresult{\csname pgfp@symb@coords@##1\endcsname}% + \edef\pgfmathresult{\csname pgfp@symb@coords@#1@##1\endcsname}% }% +%\message{#1 coord trafo{##1} --> \pgfmathresult^^J}% }% \pgfkeysdef{/pgfplots/#1 coord inv trafo}{% \begingroup @@ -2659,22 +2849,38 @@ \ifnum\count0<0 \count0=0 \else - \count1=\pgfplotsarraysizeof\pgfplots@symbolic@coords@inverse\relax + \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 - \pgfplotsarrayselect\count0 \of\pgfplots@symbolic@coords@inverse\to\pgfmathresult + \expandafter\pgfplotsarrayselect\expandafter\count\expandafter0\expandafter\of\csname pgfplots@symbolic@coords@#1@inverse\endcsname\to\pgfmathresult +%\message{#1 coord inv trafo{##1} -->\the\count0 --> \pgfmathresult^^J}% \pgfmath@smuggleone\pgfmathresult \endgroup }% - \pgfkeysalso{% - /pgfplots/#1ticklabel={\tick},% - /pgfplots/scaled #1 ticks=false,% - /pgfplots/plot coordinates/math parser=false,% + \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/symbolic x coords/.style={symbolic coords={x}{#1}},% /pgfplots/symbolic y coords/.style={symbolic coords={y}{#1}},% @@ -2712,6 +2918,7 @@ /pgfplots/colormap access/direct/.code={\def\pgfplots@colormap@access{d}},% /pgfplots/colormap access/map/.code={\def\pgfplots@colormap@access{m}},% /pgfplots/colormap access/map,% + %/pgfplots/colormap default colorspace/.initial=auto,% declared in pgfplotscolormap.code.tex /pgfplots/colormap/.code 2 args={% \pgfplotscreatecolormap{#1}{#2}% \pgfkeysalso{/pgfplots/colormap name=#1}% @@ -2719,6 +2926,9 @@ /pgfplots/colormap/hot/.style={ 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)} }, @@ -2737,6 +2947,12 @@ /pgfplots/colormap/violet/.style={ 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)} + }, + % + % + %% /pgfplots/scatter/.is choice, /pgfplots/scatter/false/.code={% \pgfplots@scatterplotenabledfalse @@ -2909,8 +3125,18 @@ /pgfplots/compat/anchors/pre 1.3/.code={\pgfplots@deprecated@anchorstrue},% FIXME: WAS \global /pgfplots/compat/anchors/1.3/.code= {\pgfplots@deprecated@anchorsfalse},% /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/newest/.style= {/pgfplots/compat/anchors/1.3},% /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/newest/.style= {/pgfplots/compat/empty line/1.4},% + /pgfplots/compat/empty line/default/.style={/pgfplots/compat/empty line/1.4},% + % /pgfplots/compat/labels/.is choice, /pgfplots/compat/labels/pre 1.3/.style={% /pgfplots/xlabel absolute, @@ -2919,14 +3145,41 @@ /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/newest/.style= {/pgfplots/compat/labels/1.3},% /pgfplots/compat/labels/default/.style= {/pgfplots/compat/labels/pre 1.3},% maintain backwards compatibility for labels :-( + % + % 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}}, + /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}}, + /pgfplots/compat/scaling/1.5/.style={/pgfplots/compat/scaling/1.4}, + /pgfplots/compat/scaling/newest/.style={/pgfplots/compat/scaling/1.4}, + /pgfplots/compat/scaling/default/.style={/pgfplots/compat/scaling/1.4}, + /pgfplots/compat/general/.is choice, + /pgfplots/compat/general/pre 1.3/.style={/pgfplots/log origin=infty},% + /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/newest},% + /pgfplots/compat/general/newest/.style={/pgfplots/log origin=0}, + /pgfplots/compat/general/default/.style={/pgfplots/compat/general/newest}, /pgfplots/compat/.style={% + % ATTENTION: *every* /pgfplots/compat/ setting needs to accept + % the same choices due to this construction: /pgfplots/compat/anchors=#1,% /pgfplots/compat/labels=#1,% + /pgfplots/compat/empty line=#1,% + /pgfplots/compat/scaling=#1,% + /pgfplots/compat/general=#1,% },% - /pgfplots/compat/.default=pre 1.3,% - /pgfplots/compat=default,% + /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={ @@ -3004,6 +3257,8 @@ },% } +\pgfkeysgetvalue{/pgfplots/colorbar/draw/.@cmd}\pgfplots@colorbar@draw@defaultimpl + % call % \pgfkeyslet{.../.@cmd}\pgfplots@cant@set@in@this@context % to replace a key with a generic error message. @@ -3014,10 +3269,10 @@ { -\pgfkeysdef{/pgfplots/empty command key}{}% -\pgfkeysgetvalue{/pgfplots/empty command key/.@cmd}\pgfplots@loc@TMPa +\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 @@ -3138,7 +3393,7 @@ % \pgfkeysgetvalue{/tikz/sloped/.@cmd}\pgfplots@loc@TMPa \pgfkeyslet{/tikz/sloped/orig/.@cmd}\pgfplots@loc@TMPa - \pgfkeysdef{/tikz/sloped}{\pgfkeysalso{/tikz/sloped like #1 axis}}% + \pgfkeysdef{/tikz/sloped}{\pgfkeysalso{/tikz/sloped like #1 axis={##1}}}% % \node [/pgfplots/every axis label,% @@ -3186,16 +3441,18 @@ \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% \draw decorate { \pgfextra - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@#2min\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#2min\endcsname}}% + % 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 - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@#2max\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#2max\endcsname}}% + % exchange roles of A <-> B axes: + \pgfplotspointonorientedsurfaceabsetupfor{#2}{#1}{\pgfplotspointonorientedsurfaceN}% + \pgfplots@drawgridlines@onorientedsurf@fromto{\csname pgfplots@#2max\endcsname}% \endpgfextra }; }{}% @@ -3215,52 +3472,50 @@ % drawn as box. \def\pgfplots@drawaxis@outerlines@cycledpath{% \draw[ - /pgfplots/every outer x axis line, % FIXME! these outer styles need much more attention :-( + /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] - % FIXME : replace this here with basic layer! This should also - % allow closed paths: - (\pgfplots@xmin, \pgfplots@ymin) + \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}}\endpgfextra \ifpgfplots@hide@y - { (\pgfplots@xmin, \pgfplots@ymax) } + { \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}\endpgfextra } \else - \ifcase\pgfplots@yaxislinesnum - decorate [ydiscont,decoration={pre length=\ydisstart, post length=\ydisend}] { -- (\pgfplots@xmin, \pgfplots@ymax) } - \or decorate [ydiscont,decoration={pre length=\ydisstart, post length=\ydisend}] { -- (\pgfplots@xmin, \pgfplots@ymax) } - \or { (\pgfplots@xmin, \pgfplots@ymax) } - \or { (\pgfplots@xmin, \pgfplots@ymax) } - \fi + 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) } + %{ (\pgfplots@xmax, \pgfplots@ymax) } + { \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}\endpgfextra } \else - \ifcase\pgfplots@xaxislinesnum - decorate [xdiscont,decoration={pre length=\xdisstart, post length=\xdisend}] { -- (\pgfplots@xmax, \pgfplots@ymax) } - \or { (\pgfplots@xmax, \pgfplots@ymax) } - \or { (\pgfplots@xmax, \pgfplots@ymax) } - \or decorate [xdiscont,decoration={pre length=\xdisstart, post length=\xdisend}] { -- (\pgfplots@xmax, \pgfplots@ymax) } - \fi + 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) } + %{ (\pgfplots@xmax, \pgfplots@ymin) } + { \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}\endpgfextra } \else - \ifcase\pgfplots@yaxislinesnum - decorate [ydiscont,decoration={pre length=\ydisend, post length=\ydisstart}] { -- (\pgfplots@xmax, \pgfplots@ymin) } - \or { (\pgfplots@xmax, \pgfplots@ymin) } - \or { (\pgfplots@xmax, \pgfplots@ymin) } - \or decorate [ydiscont,decoration={pre length=\ydisend, post length=\ydisstart}] { -- (\pgfplots@xmax, \pgfplots@ymin) } - \fi + 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) } + %{ (\pgfplots@xmin, \pgfplots@ymin) } + { \pgfextra\pgfpathmoveto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}}\endpgfextra } \else - \ifcase\pgfplots@xaxislinesnum - decorate [xdiscont,decoration={pre length=\xdisend, post length=\xdisstart}] { -- (\pgfplots@xmin, \pgfplots@ymin) } - \or decorate [xdiscont,decoration={pre length=\xdisend, post length=\xdisstart}] { -- (\pgfplots@xmin, \pgfplots@ymin) } - \or { (\pgfplots@xmin, \pgfplots@ymin) } - \or { (\pgfplots@xmin, \pgfplots@ymin) } - \fi% can't use cycle here! + decorate [xdiscont,decoration={pre length=\xdisend, post length=\xdisstart}] + %{ -- (\pgfplots@xmin, \pgfplots@ymin) } + { \pgfextra\pgfpathlineto{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}}\endpgfextra } \fi - ; % -- cycle; + % make sure that we do not have any of the axis discontinuities + % here - they should not be closed. + \if0\pgfplots@xaxisdiscontnum + \else + \if0\pgfplots@yaxisdiscontnum + \else + -- cycle + \fi + \fi + ;% }% % Assigns the macros @@ -3311,12 +3566,13 @@ \fi }% -\def\pgfplots@rememberplotspec@for@label{\pgfutil@ifnextchar[{\pgfplots@rememberplotspec@for@label@}{\pgfplots@rememberplotspec@for@label@[]}}% +\def\pgfplots@rememberplotspec@for@label{\pgfplotsutil@ifnextchar[{\pgfplots@rememberplotspec@for@label@}{\pgfplots@rememberplotspec@for@label@[]}}% \def\pgfplots@rememberplotspec@for@label@[#1]#2{% - \expandafter\gdef\csname pgfplots@last@plot@style@#1\endcsname{#2}% + \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{\pgfutil@ifnextchar[{\pgfplots@rememberplotspec@opt}{\pgfplots@rememberplotspec@opt[]}}% +\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 @@ -3410,8 +3666,19 @@ \axispath\path#1;% } \def\pgfplots@replacement@for@scope{\pgfutil@ifnextchar[{\pgfplots@replacement@for@scope@}{\pgfplots@replacement@for@scope@[]}}% -\def\pgfplots@replacement@for@scope@[#1]{\pgfplotsextra{\scope[#1]}}% -\def\pgfplots@replacement@for@endscope{\pgfplotsextra\endscope}% +\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. Try this: + \tikzset{#1}% +}% +\def\pgfplots@replacement@for@endscope{% + \endgroup + \pgfplotsextra\endscope% +}% { % A block which handles active semicolons. @@ -3463,23 +3730,54 @@ % Remembers the plotting command #2 and '#3=plot coordinates {...} ...'; % for later postprocessing of the coordinates. % -% #1: commands which should be executed before issueing the plotting +% #1: pre-commands which should be executed before issueing the plotting % command #2 #3. -% #2: -% the command which is responsable for drawing. +% #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: see above. +% #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{% - \pgfplotslistpushbackglobal{#1}{#2}{#3}{#4}\to\pgfplots@stored@plotlist + \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. @@ -3909,16 +4207,24 @@ {\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 @@ -3934,22 +4240,41 @@ \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 #2#1\endcsname +% \csname #3#2\endcsname % will be invoked. -\def\pgfplots@label#1#2{% +% \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 #2#1\string\endcsname + \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 }% - \expandafter\label\expandafter{#1}% + % + % this is a work-around to support the memoir class (it overwrites + % \label in sub + \let\sf@@memsub@label=\pgfplots@original@LaTeX@label@loadtime + % + \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}% @@ -3988,6 +4313,22 @@ }% }% +\def\pgfplotsplotfromname#1{% + \pgfplots@texdist@protect\pgfplotsplotfromname@{#1}% +}% +\def\pgfplotsplotfromname@#1{% + \pgfutil@ifundefined{pgfplots@show@ref@#1}{% + \pgfutil@ifundefined{ref}{% + \pgfplots@warning{There is no \string\addplot\space label `#1', sorry. I am skipping it}% + \string\pgfplotsplotfromname{#1}: ??% + }{% + \ref{\string\pgfplotsplotfromname{#1}}% + }% + }{% + \csname pgfplots@show@ref@#1\endcsname + }% +}% + \def\pgfplots@ifintikzpicture#1#2{% \pgfutil@ifundefined{filldraw}{#2}{#1}% }% @@ -4011,6 +4352,8 @@ } % 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% }% @@ -4073,7 +4416,7 @@ \pgfkeysdef{/pgfplots/@enlargelimits/rel}{\pgfkeysalso{true,value={#1}}}% \pgfkeysdef{/pgfplots/@enlargelimits/abs value}{% \begingroup - \pgfutil@namelet{pgfplots@datascaletrafo@\pgfplots@enlargelimits@curaxis}{pgfplots@datascaletrafo@\pgfplots@enlargelimits@curaxis @noshift}% + \pgfplotscoordmath{\pgfplots@enlargelimits@curaxis}{datascaletrafo set shift}{0}% \expandafter\csname pgfplotstransformcoordinate\pgfplots@enlargelimits@curaxis\endcsname{#1}% \pgfmath@smuggleone\pgfmathresult \endgroup @@ -4163,7 +4506,8 @@ % helper for \pgfplots@check@and@apply@datatrafo@for. % \def\pgfplots@compute@number@order@for@trafo@isfloat#1\tocount#2{% - \expandafter\pgfmathfloat@decompose@E#1\relax#2\relax + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmathfloat@decompose@E\pgfmathresult\relax#2\relax \advance#2 by1\relax } @@ -4187,167 +4531,177 @@ % initialise data scale transformation % T(x) = 10^{q-m} * x % - \begingroup - \let\data@max@order=\c@pgf@counta - \let\data@cur@order=\c@pgf@countb - \let\data@dimen=\pgf@xa - \let\data@tmp=\pgf@xb - \let\data@dimen@order=\c@pgf@countc - \let\data@EXPONENT=\c@pgf@countd - \expandafter\let\expandafter\pgfplots@display@min@float\csname pgfplots@#1min\endcsname - \expandafter\let\expandafter\pgfplots@display@max@float\csname pgfplots@#1max\endcsname - \expandafter\let\expandafter\pgfplots@data@min@float\csname pgfplots@data@#1min\endcsname - \expandafter\let\expandafter\pgfplots@data@max@float\csname pgfplots@data@#1max\endcsname - \expandafter\let\expandafter\pgfplots@actual@trafo\csname pgfplots@datascaletrafo@#1\endcsname - \ifpgfplots@autocompute@all@limits - \else - \pgfplotsmathfloatmax{\pgfplots@display@max@float}{\pgfplots@data@max@float}% - \let\pgfplots@data@max@float=\pgfmathresult - \pgfplotsmathfloatmin{\pgfplots@display@min@float}{\pgfplots@data@min@float}% - \let\pgfplots@data@min@float=\pgfmathresult - \fi - % - % Step 1: compute 'm', the data order - \pgfplots@compute@number@order@for@trafo@isfloat - \pgfplots@data@min@float - \tocount\data@cur@order - % - \data@max@order=\data@cur@order - % - \pgfplots@compute@number@order@for@trafo@isfloat - \pgfplots@data@max@float - \tocount\data@cur@order - % - \ifnum\data@cur@order>\data@max@order + \ifpgfplots@disabledatascaling + % this here is a waste of time, I know it. 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]}% + % Step 1: compute 'm', the data order + \pgfplots@compute@number@order@for@trafo@isfloat + \pgfplots@data@min@float + \tocount\data@cur@order + % \data@max@order=\data@cur@order - \fi - % - % Step 2: compute 'q', the #1-size of the axis. - \expandafter\ifx\csname pgfplots@#1\endcsname\pgfutil@empty - % We have 'width' or 'height'. % - % Use the order of these parameters. - \def\pgfplots@loc@TMPa{#1}% - \def\pgfplots@loc@TMPb{x}% - \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb - \data@dimen=\pgfplots@width\relax - \else - \def\pgfplots@loc@TMPb{y}% + \pgfplots@compute@number@order@for@trafo@isfloat + \pgfplots@data@max@float + \tocount\data@cur@order + % + \ifnum\data@cur@order>\data@max@order + \data@max@order=\data@cur@order + \fi + % + % Step 2: compute 'q', the #1-size of the axis. + %\expandafter\ifx\csname pgfplots@#1\endcsname\pgfutil@empty + % We have 'width' or 'height' (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@height\relax + \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 - \fi - \pgfplots@compute@number@order@for@trafo@isdimen - \data@dimen - \tocount\data@dimen@order - % This here is to avoid inaccuracies in the final - % axis rectangle size, see \pgfplots@initsizes: - %\advance\data@dimen@order by-1 - \else - % FIXME: - % we have either the 'x=1cm' or 'y=1cm' option! - % How should I initialise the trafo!? - \data@dimen@order=3 - \fi - % + \pgfplots@compute@number@order@for@trafo@isdimen + \data@dimen + \tocount\data@dimen@order + % This here is to avoid inaccuracies in the final + % axis rectangle size, see \pgfplots@initsizes: + %\advance\data@dimen@order by-1 + %\else + % FIXME: + % we have either the 'x=1cm' or 'y=1cm' option! + % How should I initialise the trafo!? + % \data@dimen@order=3 + %\fi + % %\message{Direction #1: data max order=\the\data@max@order; data dimen order=\the\data@dimen@order. }% - \data@EXPONENT=\data@dimen@order - \advance\data@EXPONENT by-\data@max@order - % Now, I introduce a loop which shall avoid cancellation of - % significant digits. - % - % Harmless Example: - % if we have data shift = -3 and - % max = 2e6, min = 1e6, then max-min = 1e6; T(max)-T(min) = 1e3 which is ok. - % In this case, the loop won't change anything. - % - % Critical Example: - % if we have data shift = -3 and - % max = 1980, min = 1930 then - % T(max) = 1.98 and T(min) = 1.93 - % and thus T(max)-T(min) = 0.05 . - % Considering that this is the axis range - % in which tick labels and plot points need to be computed, we - % only have two or three digits left! That happens because the - % prefix '19' is common and is cancelled in the subtraction. - % Idea: while T(max)-T(min) < O(10^2) -> increase shift by +1 - % (and make sure that T(max) < MAX_VALID_TEX_NUMBER). - % - \pgfplots@loop@CONTINUEtrue - \expandafter\edef\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname{0}% - \pgfutil@loop - \expandafter\edef\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname{\the\data@EXPONENT}% - \pgfplots@actual@trafo{\pgfplots@data@min@float}% - \let\pgfplots@min@fixed=\pgfmathresult - \ifpgfplots@loop@CONTINUE - \pgfplots@actual@trafo{\pgfplots@data@max@float}% - \let\pgfplots@max@fixed=\pgfmathresult - \expandafter\data@tmp\pgfplots@max@fixed pt + \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...}% - \ifdim\data@tmp<0pt - % I need absolute values here: - \multiply\data@tmp by-1\relax - \fi - \pgfmathsubtract@{\pgfplots@max@fixed}{\pgfplots@min@fixed}% - \expandafter\data@dimen\pgfmathresult pt - \pgfplots@loop@CONTINUEfalse - \ifdim\data@tmp<1500pt % a multiplication with '10' results in max = 15000 which is the upper limit. - \ifdim\data@dimen<100pt % I guess if max-min = O(100), we have quite good accuracy - \ifdim\data@dimen<0.0001pt - \else - \advance\data@EXPONENT by1 - \pgfplots@loop@CONTINUEtrue + \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 - \fi - %-------------------------------------------------- - % \ifdim\data@dimen>1200pt% FIXME : is this here ok!? CHECK IT! - % \ifdim\data@dimen>7999pt - % \advance\data@EXPONENT by-2 - % \else - % \advance\data@EXPONENT by-1 - % \fi - % \pgfplots@loop@CONTINUEfalse - % \fi - %-------------------------------------------------- - \pgfutil@repeat - \xdef\pgfplots@glob@TMPa{\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname}% - \xdef\pgfplots@glob@TMPb{\pgfplots@min@fixed}% - \endgroup -%\message{Initialising the data scale transformation in direction #1 to 10^\pgfplots@glob@TMPa*#1 - \pgfplots@glob@TMPb...}% - % COMPLETE INITIALISATION: - \ifpgfplots@disabledatascaling - % this here is a waste of time, I know it. One could really - % 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}% + %-------------------------------------------------- + % \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 - \expandafter\let\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname\pgfplots@glob@TMPa - \expandafter\let\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname\pgfplots@glob@TMPb% + % COMPLETE INITIALISATION: +%\message{Initialising the data scale transformation in direction #1 to 10^\pgfplots@glob@TMPa*#1 - \pgfplots@glob@TMPb...}% + \pgfplotscoordmath{#1}{datascaletrafo set params}{\pgfplots@glob@TMPa}{\pgfplots@glob@TMPb}% % % ... and apply transformation to any user input % % Transform axis limits: %\message{#1- display limits BEFORE data transformation: [\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname]}% - \expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1min\endcsname}% + \pgfplotscoordmath{#1}{datascaletrafo}{\csname pgfplots@#1min\endcsname}% \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult % - \expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1max\endcsname}% + \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]}% % 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 - \expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1tickmin\endcsname}% + \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 - \expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1tickmax\endcsname}% + \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]}% @@ -4357,7 +4711,6 @@ % this here should also work with 'xtick=\pgfutil@empty', the "No tick" command. \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \t@pgfplots@tokc=\expandafter{\csname pgfplots@datascaletrafo@#1\endcsname}% \def\pgfplots@loc@TMPb{data}% \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb % we have #1tick = data @@ -4367,15 +4720,19 @@ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@firstplot@coords@#1\endcsname \expandafter\pgfplotsutil@unify@short@csv@list\expandafter{\pgfplots@loc@TMPa}% \t@pgfplots@toka=\expandafter{\pgfplotsretval}% - \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}\the\t@pgfplots@tokc}% - \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks@isfloat\pgfplots@loc@TMPa\to\pgfplots@loc@TMPc + \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}}% + \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks@isfloat\pgfplots@loc@TMPa + {\pgfplotscoordmath{#1}{datascaletrafo}}% + \to\pgfplots@loc@TMPc % clear structure: \expandafter\global\expandafter\let\csname pgfplots@firstplot@coords@#1\endcsname=\pgfutil@empty \else \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}% %\message{Converting #1tick='\csname pgfplots@#1tick\endcsname'}% - \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}\the\t@pgfplots@tokc}% - \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\pgfplots@loc@TMPa\to\pgfplots@loc@TMPc + \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}}% + \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\pgfplots@loc@TMPa + {\pgfplotscoordmath{#1}{datascaletrafo}}% + \to\pgfplots@loc@TMPc \fi \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@loc@TMPc \fi @@ -4384,17 +4741,29 @@ \edef\pgfplots@loc@TMPa{\csname pgfplots@extra@#1tick\endcsname}% \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \t@pgfplots@tokc=\expandafter{\csname pgfplots@datascaletrafo@#1\endcsname}% - \edef\pgfplots@loc@TMPa{{\csname pgfplots@extra@#1tick\endcsname}\the\t@pgfplots@tokc}% - \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\pgfplots@loc@TMPa\to\pgfplots@loc@TMPc + \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 + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}}% + \expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\pgfplots@loc@TMPa + {\pgfplotscoordmath{#1}{datascaletrafo}}% + \to\pgfplots@loc@TMPc + \pgfkeyslet{/pgfplots/minor #1tick}\pgfplots@loc@TMPc + \fi + % % Transform any explicit axis unit scalings: % WILL BE DONE LATER! }{% % case apply trafo == false: - \expandafter\def\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname{0}% + \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}% \def\pgfplots@loc@TMPb{data}% \expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfplots@loc@TMPb \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@firstplot@coords@#1\endcsname @@ -4412,31 +4781,26 @@ \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: \pgfplots@warning{You have an axis with empty range. Replacing it with a default range and clearing all plots.}% - \ifpgfplots@xislinear - \pgfmathfloatcreate{0}{0.0}{0}% - \global\let\pgfplots@xmin=\pgfmathresult - \pgfmathfloatcreate{1}{1.0}{0}% - \global\let\pgfplots@xmax=\pgfmathresult - \global\let\pgfplots@data@xmin=\pgfplots@xmin - \global\let\pgfplots@data@xmax=\pgfplots@xmax - \else - \gdef\pgfplots@xmin{0}% - \gdef\pgfplots@xmax{1}% - \fi - \ifpgfplots@yislinear - \pgfmathfloatcreate{0}{0.0}{0}% - \global\let\pgfplots@ymin=\pgfmathresult - \pgfmathfloatcreate{1}{1.0}{0}% - \global\let\pgfplots@ymax=\pgfmathresult - \global\let\pgfplots@data@ymin=\pgfplots@ymin - \global\let\pgfplots@data@ymax=\pgfplots@ymax - \else - \gdef\pgfplots@ymin{0}% - \gdef\pgfplots@ymax{1}% - \fi + \pgfplots@handle@invalid@range@defaultlimits + % \pgfplots@threedimfalse \def\pgfplots@xtick{}% \def\pgfplots@ytick{}% @@ -4492,20 +4856,20 @@ \else % there is a rare change that min > max. % Handle that ... - \pgfplotsmathfloatmin{\pgfplots@xmin}{\pgfplots@xmax}% + \pgfplotscoordmath{x}{min}{\pgfplots@xmin}{\pgfplots@xmax}% \global\let\pgfplots@xmin=\pgfmathresult - \pgfplotsmathfloatmax{\pgfplots@xmin}{\pgfplots@xmax}% + \pgfplotscoordmath{x}{max}{\pgfplots@xmin}{\pgfplots@xmax}% \global\let\pgfplots@xmax=\pgfmathresult % - \pgfplotsmathfloatmin{\pgfplots@ymin}{\pgfplots@ymax}% + \pgfplotscoordmath{y}{min}{\pgfplots@ymin}{\pgfplots@ymax}% \global\let\pgfplots@ymin=\pgfmathresult - \pgfplotsmathfloatmax{\pgfplots@ymin}{\pgfplots@ymax}% + \pgfplotscoordmath{y}{max}{\pgfplots@ymin}{\pgfplots@ymax}% \global\let\pgfplots@ymax=\pgfmathresult % \ifpgfplots@threedim - \pgfplotsmathfloatmin{\pgfplots@zmin}{\pgfplots@zmax}% + \pgfplotscoordmath{z}{min}{\pgfplots@zmin}{\pgfplots@zmax}% \global\let\pgfplots@zmin=\pgfmathresult - \pgfplotsmathfloatmax{\pgfplots@zmin}{\pgfplots@zmax}% + \pgfplotscoordmath{z}{max}{\pgfplots@zmin}{\pgfplots@zmax}% \global\let\pgfplots@zmax=\pgfmathresult \fi \fi @@ -4532,31 +4896,6 @@ \def\pgfplots@determinedefaultvalues{% \pgfplots@check@invalid@range % - %-------------------------------------------------- - %FIXME - % \ifpgfplots@float@numerics@mode@x - % \pgfplotsmathfloatmin{\pgfplots@xmin}{\pgfplots@xmax}% - % \let\pgfplots@xmin=\pgfmathresult - % \pgfplotsmathfloatmax{\pgfplots@xmin}{\pgfplots@xmax}% - % \let\pgfplots@xmax=\pgfmathresult - % \else - % \pgfplotsmathmin{\pgfplots@xmin}{\pgfplots@xmax}% - % \let\pgfplots@xmin=\pgfmathresult - % \pgfplotsmathmax{\pgfplots@xmin}{\pgfplots@xmax}% - % \let\pgfplots@xmax=\pgfmathresult - % \fi - % \ifpgfplots@float@numerics@mode@y - % \pgfplotsmathfloatmin{\pgfplots@ymin}{\pgfplots@ymax}% - % \let\pgfplots@ymin=\pgfmathresult - % \pgfplotsmathfloatmax{\pgfplots@ymin}{\pgfplots@ymax}% - % \let\pgfplots@ymax=\pgfmathresult - % \else - % \pgfplotsmathmin{\pgfplots@ymin}{\pgfplots@ymax}% - % \let\pgfplots@ymin=\pgfmathresult - % \pgfplotsmathmax{\pgfplots@ymin}{\pgfplots@ymax}% - % \let\pgfplots@ymax=\pgfmathresult - % \fi - %-------------------------------------------------- %\message{untransformed: x = [\pgfplots@xmin:\pgfplots@xmax] y = [\pgfplots@ymin:\pgfplots@ymax]. }% % % @@ -4578,200 +4917,146 @@ % % From now on, we can always work with pgfmath. % We simply need to apply the data scaling trafo before doing so. - \pgfkeysgetvalue{/pgfplots/minor x tick num}\pgfplots@minor@xtick@num - \ifpgfplots@xislinear - \ifnum\pgfplots@minor@xtick@num=0\relax - \pgfplots@xminorticksfalse - \pgfplots@xminorgridsfalse - \else - \pgfplots@xminortickstrue - \fi - \fi - % \pgfplots@enlarge@limit@ifconfigured x \pgfplots@avoid@empty@axis@range@for x% % - \pgfkeysgetvalue{/pgfplots/minor y tick num}\pgfplots@minor@ytick@num - \ifpgfplots@yislinear - \ifnum\pgfplots@minor@ytick@num=0\relax - \pgfplots@yminorticksfalse - \pgfplots@yminorgridsfalse - \else - \pgfplots@yminortickstrue - \fi - \fi \pgfplots@enlarge@limit@ifconfigured y \pgfplots@avoid@empty@axis@range@for y% \ifpgfplots@threedim - \pgfkeysgetvalue{/pgfplots/minor z tick num}\pgfplots@minor@ztick@num - \ifpgfplots@zislinear - \ifnum\pgfplots@minor@ztick@num=0\relax - \pgfplots@zminorticksfalse - \pgfplots@zminorgridsfalse - \else - \pgfplots@zminortickstrue - \fi - \fi \pgfplots@enlarge@limit@ifconfigured z \pgfplots@avoid@empty@axis@range@for z% \fi % - % \pgfplots@initsizes % + \pgfplots@limits@ready + \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% +} +\def\pgfplots@init@ticks@ready{}% +\def\pgfplots@init@ticks@for#1{% \pgfplots@isuniformticktrue \pgfplots@determinedefaultvalues@needs@check@uniformticktrue - \ifx\pgfplots@xtick\pgfutil@empty - \pgfplots@assign@default@tick@foraxis{x}% + \expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfutil@empty + \pgfplots@assign@default@tick@foraxis{#1}% \fi \ifpgfplots@determinedefaultvalues@needs@check@uniformtick - \ifpgfplots@xislinear - \expandafter\pgfplots@checkisuniformLINEARtick\expandafter{\pgfplots@xtick}{\pgfplots@tick@distance@x}% - \else - \expandafter\pgfplots@checkisuniformLOGtick\expandafter{\pgfplots@xtick}% - \fi + \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname + \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 + \pgfplots@check@for@minor@ticks{#1}% \ifpgfplots@isuniformtick \else - \pgfplots@xminorticksfalse - \pgfplots@xminorgridsfalse + \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@loc@TMPb + \ifx\pgfplots@loc@TMPb\pgfutil@empty + \csname pgfplots@#1minorticksfalse\endcsname + \csname pgfplots@#1minorgridsfalse\endcsname + \fi \fi % - \if0\pgfplots@xaxislinesnum\else - % axis x line* != box - \let\pgfplots@xticklabel@pos=\pgfutil@empty - \fi - \if0\pgfplots@yaxislinesnum\else - % axis y line* != box - \let\pgfplots@yticklabel@pos=\pgfutil@empty + \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 - \if0\pgfplots@zaxislinesnum\else - % axis y line* != box - \let\pgfplots@zticklabel@pos=\pgfutil@empty + \expandafter\ifx\csname pgfplots@extra@#1ticklabel\endcsname\pgfutil@empty + \pgfutil@namelet{pgfplots@extra@#1ticklabel}{pgfplots@#1ticklabel}% \fi % - \ifx\pgfplots@xticklabel@pos\pgfutil@empty - \def\pgfplots@xticklabel@pos{% - \if3\pgfplots@xtickposnum% right - u% - \else - l% - \fi - }% + \if0\csname pgfplots@#1axislinesnum\endcsname\else + % axis x line* != box + \expandafter\let\csname pgfplots@#1ticklabel@pos\endcsname=\pgfutil@empty \fi - \ifx\pgfplots@yticklabel@pos\pgfutil@empty - \def\pgfplots@yticklabel@pos{% - \if3\pgfplots@ytickposnum% right + \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 - \ifx\pgfplots@zticklabel@pos\pgfutil@empty - \def\pgfplots@zticklabel@pos{% - \if3\pgfplots@ztickposnum% right - u% - \else - l% +}% + +\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 - }% - \fi - % - \ifx\pgfplots@xticklabel\pgfutil@empty - \ifpgfplots@xislinear - \def\pgfplots@xticklabel{\axisdefaultticklabel}% \else - \def\pgfplots@xticklabel{\axisdefaultticklabellog}% + \csname pgfplots@#1minortickstrue\endcsname \fi - \fi - \ifx\pgfplots@extra@xticklabel\pgfutil@empty - \let\pgfplots@extra@xticklabel=\pgfplots@xticklabel - \fi - % - % - % - \pgfplots@isuniformticktrue - \pgfplots@determinedefaultvalues@needs@check@uniformticktrue - \ifx\pgfplots@ytick\pgfutil@empty - \pgfplots@assign@default@tick@foraxis{y}% - \fi - \ifpgfplots@determinedefaultvalues@needs@check@uniformtick - \ifpgfplots@yislinear - \expandafter\pgfplots@checkisuniformLINEARtick\expandafter{\pgfplots@ytick}{\pgfplots@tick@distance@y}% - \else - \expandafter\pgfplots@checkisuniformLOGtick\expandafter{\pgfplots@ytick}% - \fi - \fi - \ifpgfplots@isuniformtick + }{% + }% + \ifx\pgfplots@loc@TMPb\pgfutil@empty \else - \pgfplots@yminorticksfalse - \pgfplots@yminorgridsfalse - \fi - % - \ifx\pgfplots@yticklabel\pgfutil@empty - \ifpgfplots@yislinear - \def\pgfplots@yticklabel{\axisdefaultticklabel}% - \else - \def\pgfplots@yticklabel{\axisdefaultticklabellog}% - \fi - \fi - \ifx\pgfplots@extra@yticklabel\pgfutil@empty - \let\pgfplots@extra@yticklabel=\pgfplots@yticklabel + \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@isuniformticktrue - \pgfplots@determinedefaultvalues@needs@check@uniformticktrue - \ifx\pgfplots@ztick\pgfutil@empty - \pgfplots@assign@default@tick@foraxis{z}% - \fi - \ifpgfplots@determinedefaultvalues@needs@check@uniformtick - \ifpgfplots@zislinear - \expandafter\pgfplots@checkisuniformLINEARtick\expandafter{\pgfplots@ztick}{\pgfplots@tick@distance@z}% - \else - \expandafter\pgfplots@checkisuniformLOGtick\expandafter{\pgfplots@ztick}% - \fi - \fi - \ifpgfplots@isuniformtick - \else - \pgfplots@zminorticksfalse - \pgfplots@zminorgridsfalse - \fi - % - \ifx\pgfplots@zticklabel\pgfutil@empty - \ifpgfplots@zislinear - \def\pgfplots@zticklabel{\axisdefaultticklabel}% - \else - \def\pgfplots@zticklabel{\axisdefaultticklabellog}% - \fi - \fi - \ifx\pgfplots@extra@zticklabel\pgfutil@empty - \let\pgfplots@extra@zticklabel=\pgfplots@zticklabel - \fi + \pgfplots@limits@ready@tostring{z}{min}% + \pgfplots@limits@ready@tostring{z}{max}% \fi - % - % - \pgfplots@prepare@ZERO@coordinates - % - \pgfplotspoint@initialisation - % - \pgfplots@decide@which@figure@surfaces@are@drawn - % - \pgfplots@define@threedim@marks - % - \pgfplots@clippath@prepare - % - \pgfplots@ticklabel@maxtickdimen@reset x% - \pgfplots@ticklabel@maxtickdimen@reset y% - \pgfplots@ticklabel@maxtickdimen@reset z% -} +}% + +% 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 +}% % Defines \pgfmathresult to be the desired width without axis labels. % @@ -4833,11 +5118,13 @@ {\pgf@sys@tonumber\pgf@xa}% {\pgf@sys@tonumber\pgf@xb}% }% -%\pgfplots@message{pgfplots.sty: Computing 'x' such that 'width = c + x*(xmax-xmin)'; -% c=estimated, -% width-c =\the\pgf@xa, -% x*(xmax[=\the\pgfplots@xcoordmaxTEX] - xmin[=\the\pgfplots@xcoordminTEX)]) = \the\pgf@xb -% -> x-scale =#2 }% +%-------------------------------------------------- +% \message{pgfplots.sty: Computing 'x' such that 'width = c + x*(xmax-xmin)'; +% c=estimated, +% width-c =\the\pgf@xa, +% x*(xmax - xmin)]) = \the\pgf@xb +% -> x-scale =\pgfmathresult }% +%-------------------------------------------------- \pgfmath@smuggleone\pgfmathresult \endgroup \let#2=\pgfmathresult @@ -4900,7 +5187,7 @@ \fi \fi \ifpgfplots@avoid@emptyrange@@range@is@approx@equal - \pgfplots@warning{Axis range for axis #1 is approximately empty; enlargeing it.}% + \pgfplots@warning{Axis range for axis #1 is approximately empty; enlarging it.}% % the case \pgfplots@@min ~= \pgfplots@@max % % enlarge \pgfplots@@max and shrink \min: @@ -4930,39 +5217,45 @@ % -> we need to enlarge limits in floating % point arithmetics. % - \pgfmathfloatcreate{0}{0.0}{0}% + \pgfplotscoordmath{#1}{parsenumber}{0}% \let\pgfplotsmath@zero=\pgfmathresult % \ifx\max@unscaled\pgfplotsmath@zero % max == 0 - \pgfmathfloatcreate{1}{1.0}{0}% + \pgfplotscoordmath{#1}{parsenumber}{1}% \let\max@unscaled=\pgfmathresult - \pgfmathfloatcreate{2}{1.0}{0}% + \pgfplotscoordmath{#1}{parsenumber}{-1}% \let\min@unscaled=\pgfmathresult \else % - \pgfmathfloatcreate{1}{1.2}{0}% + \pgfplotscoordmath{#1}{parsenumber}{1.2}% \let\pgfplotsmath@scalea=\pgfmathresult - \pgfmathfloatcreate{1}{8.0}{-1}% + \pgfplotscoordmath{#1}{parsenumber}{8e-1}% \let\pgfplotsmath@scaleb=\pgfmathresult % - \pgfmathfloatlessthan@{\pgfplotsmath@zero}{\max@unscaled}% - \ifpgfmathfloatcomparison - % 0 < max - \pgfmathfloatmultiply@{\max@unscaled}{\pgfplotsmath@scalea}% - \let\max@unscaled=\pgfmathresult - \pgfmathfloatmultiply@{\min@unscaled}{\pgfplotsmath@scaleb}% - \let\min@unscaled=\pgfmathresult - \else - \pgfmathfloatmultiply@{\max@unscaled}{\pgfplotsmath@scaleb}% - \let\max@unscaled=\pgfmathresult - \pgfmathfloatmultiply@{\min@unscaled}{\pgfplotsmath@scalea}% - \let\min@unscaled=\pgfmathresult - \fi + \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 - \csname pgfplots@datascaletrafo@#1\endcsname{\min@unscaled}% + \pgfplotscoordmath{#1}{datascaletrafo}{\min@unscaled}% \let\pgfplots@@min=\pgfmathresult - \csname pgfplots@datascaletrafo@#1\endcsname{\max@unscaled}% + \pgfplotscoordmath{#1}{datascaletrafo}{\max@unscaled}% \let\pgfplots@@max=\pgfmathresult \min@d=\pgfplots@@min pt \max@d=\pgfplots@@max pt @@ -5013,89 +5306,102 @@ \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: - % hasx := 'x' option non-empty - % hasy := 'y' option non-empty % W := 'width' option non-empty % H := 'height' option non-empty % - % hasx = 1 -> width is not interesting; we use 'x' option. - % hasx = 0 -> determine final width: % W H % 0 0 -> \axisdefaultwidth % 0 1 -> determine width out of H and the default aspect ratio % 1 X -> ok, use the user parameter. - % - % hasy = 1 -> height is not interesting, we use 'y' option. - % hasy = 0 -> determine final height: - % W H - % 0 0 -> \axisdefaultheight - % X 1 -> ok, use the user parameter - % 1 0 -> determine height out of W and the default aspect ratio - % - \ifx\pgfplots@x\pgfutil@empty - \ifx\pgfplots@y\pgfutil@empty - % hasx=0, hasy=0 - % - % -> KEEP ASPECT RATIO if just one W, or H is given! - \ifx\pgfplots@width\pgfutil@empty - \ifx\pgfplots@height\pgfutil@empty - % The case hasx=0, hasy=0, W=0 H=0: - \let\pgfplots@width=\axisdefaultwidth - \let\pgfplots@height=\axisdefaultheight - \else - % The case hasx=0, hasy=0, 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 hasx=0, hasy=0, 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 hasx=0, hasy=0, W=1 H=1: - \fi - \fi + % -> 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 - % hasx=0, hasy=1, W=0: - \ifx\pgfplots@width\pgfutil@empty - \let\pgfplots@width=\axisdefaultwidth - \fi + % 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@y\pgfutil@empty - % hasx=1, hasy=0, H=0 - \ifx\pgfplots@height\pgfutil@empty - \let\pgfplots@height=\axisdefaultheight - \fi + \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 +} +\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 @@ -5138,7 +5444,11 @@ \ifdim\pgfplots@loc@TMPa=0pt \def\pgfmathresult{0}% \else - \pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}% + \edef\pgf@marshal{% + {\expandafter\pgf@sys@tonumber\csname pgf@#1x\endcsname}% + {\expandafter\pgf@sys@tonumber\csname pgf@#1y\endcsname}% + }% + \expandafter\pgfmathveclen\pgf@marshal \fi \fi % The numbers 1/||e_x|| and 1/||e_y|| are used by the tick @@ -5170,17 +5480,18 @@ \def#4{0}% we DON'T have (#1,0) or (0,#1). At least I think so. % %\message{Setting unitvector(#1) to non-standard \csname pgfplots@#1\endcsname ...}% - % FIXME : that's wrong for 3D axes! \def\pgfplots@loc@TMPa(##1,##2){% - \pgfmathparse{##1}% + \pgfplotscoordmath{default}{parse}{##1}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% \let\pgfplots@loc@TMPb=\pgfmathresult - \pgfmathparse{##2}% + \pgfplotscoordmath{default}{parse}{##2}% + \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}% \let\pgfplots@loc@TMPc=\pgfmathresult % \pgfplots@if{pgfplots@apply@datatrafo@#1}{% - \csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname{\pgfplots@loc@TMPb}% + \pgfplotscoordmath{#1}{datascaletrafo noshift inverse to fixed}{\pgfplots@loc@TMPb}% \let\pgfplots@loc@TMPb=\pgfmathresult - \csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname{\pgfplots@loc@TMPc}% + \pgfplotscoordmath{#1}{datascaletrafo noshift inverse to fixed}{\pgfplots@loc@TMPc}% \let\pgfplots@loc@TMPc=\pgfmathresult }{}% \csname pgfset#1vec\endcsname{% @@ -5190,12 +5501,17 @@ }% \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb% % - \pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}% + \edef\pgf@marshal{% + {\expandafter\pgf@sys@tonumber\csname pgf@#1x\endcsname}% + {\expandafter\pgf@sys@tonumber\csname pgf@#1y\endcsname}% + }% + \expandafter\pgfmath@basic@veclen@\pgf@marshal + % \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult \pgfplotsmath@ifzero{\pgfmathresult}{% \expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}% }{% - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult }% \else @@ -5203,8 +5519,9 @@ \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}{% - \pgfmathparse{\csname pgfplots@#1\endcsname}% - \expandafter\expandafter\csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname\expandafter{\pgfmathresult}% + \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}% \begingroup @@ -5216,28 +5533,32 @@ \endgroup \ifcase#2\relax \pgfsetxvec{\pgfqpoint{\pgfplots@loc@TMPb}{0pt}}% - \pgfmathabs@{\pgfplots@glob@TMPb}% + \pgfmath@basic@abs@{\pgfplots@glob@TMPb}% \or \pgfsetyvec{\pgfqpoint{0pt}{\pgfplots@loc@TMPb}}% - \pgfmathabs@{\pgfplots@glob@TMPb}% + \pgfmath@basic@abs@{\pgfplots@glob@TMPb}% \or \pgfsetzvec{\pgfqpoint{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPb}}% \ifdim\pgfplots@loc@TMPb=0pt \def\pgfmathresult{0}% \else - \pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}% + \edef\pgf@marshal{% + {\expandafter\pgf@sys@tonumber\csname pgf@#1x\endcsname}% + {\expandafter\pgf@sys@tonumber\csname pgf@#1y\endcsname}% + }% + \expandafter\pgfmath@basic@veclen@\pgf@marshal \fi \fi \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult \pgfplotsmath@ifzero{\pgfmathresult}{% \expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}% }{% - \expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}% + \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult }% \fi \fi -%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).}% +%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).^^J}% }% % Applies the 'axis equal' feature. @@ -5256,142 +5577,337 @@ % transformation. All unit vector length above are only meaningful in % the UNTRANSFORMED range, so we have to mingle with the scaling % transformation. -\def\pgfplots@axis@equal@apply{% - % Step 1: compute the unit vector which STAYS CONSTANT. - % - % All other ones will be scaled to fit its length. - \ifpgfplots@threedim - \def\pgfplots@axis@equal@apply@reference{x}% - \pgfplots@if@unitveclenlessthan@untransformed xy{% - \pgfplots@if@unitveclenlessthan@untransformed xz{% - \def\pgfplots@axis@equal@apply@reference{x}% - }{}% - }{}% - \pgfplots@if@unitveclenlessthan@untransformed yx{% - \pgfplots@if@unitveclenlessthan@untransformed yz{% - \def\pgfplots@axis@equal@apply@reference{y}% - }{}% - }{}% - \pgfplots@if@unitveclenlessthan@untransformed zx{% - \pgfplots@if@unitveclenlessthan@untransformed zy{% - \def\pgfplots@axis@equal@apply@reference{z}% - }{}% - }{}% +\def\pgfplots@apply@unit@ratio{% + \pgfkeysgetvalue{/pgfplots/unit vector ratio}\pgfplots@unit@vector@ratio + \ifx\pgfplots@unit@vector@ratio\pgfutil@empty \else - \pgfplots@if@unitveclenlessthan@untransformed xy{% - \def\pgfplots@axis@equal@apply@reference{x}% - }{% - \def\pgfplots@axis@equal@apply@reference{y}% - }% - \fi -%\message{USING REFERENCE UNIT VECTOR FROM \pgfplots@axis@equal@apply@reference.}% - \if x\pgfplots@axis@equal@apply@reference - \else - \pgfplots@axis@equal@apply@for x - \fi - \if y\pgfplots@axis@equal@apply@reference - \else - \pgfplots@axis@equal@apply@for y - \fi - \ifpgfplots@threedim - \if z\pgfplots@axis@equal@apply@reference - \else - \pgfplots@axis@equal@apply@for z + \edef\pgfplots@unit@vector@ratio{\pgfplots@unit@vector@ratio\space1 1 }% + % + % 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 \fi }% -% Scales unit vector '#1' such that it has the same length as the unit -% vector in direction \pgfplots@axis@equal@apply@reference. +% 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 data limits for '#1' will be enlarged as well (for 'axis -% equal'). -\def\pgfplots@axis@equal@apply@for#1{% - \pgfmathmultiply@ - {\csname pgfplots@\pgfplots@axis@equal@apply@reference @veclength\endcsname} - {\csname pgfplots@#1@inverseveclength\endcsname}% - \global\let\pgfplots@glob@TMPa=\pgfmathresult - \pgfmathmultiply@ - {\csname pgfplots@\pgfplots@axis@equal@apply@reference @inverseveclength\endcsname} - {\csname pgfplots@#1@veclength\endcsname}% - \global\let\pgfplots@glob@TMPb=\pgfmathresult - % - % If the datascaling transformation is active (which is almost - % everytime the case here), we need to respect it here. +% 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{% % - % We only need to respect the SCALING, translations (shifts) are - % not interesting. + \begingroup + \let\pgfplots@ONE=\pgf@x + \global\pgfplots@ONE=1.002pt % - % We want that || T^{-1} e_ref || = || T^{-1} E_#1 ||. + \def\pgfplots@optimum@sofar@axis{}% + \let\pgfplots@optimum@sofar@value=\pgf@y + \global\pgfplots@optimum@sofar@value=16000pt % - % So: T^{-1} E_#1 := s* T^{-1} e_#1 where - % s = ||T^{-1} e_ref|| / || T^{-1} e_#1 || - % = |10^{scale_ref}| / |10^{scale_#1}| * || e_ref|| / ||e_#1||. - % - % Then, E_#1 = T ( T^{-1} E_#1 ) = s * e_#1. + %\pgfplots@apply@unit@ratio@find@reference@checkexplicitlimits % - % -> compute 's'! We already have the quotient of unit vectors. - % Now, acquire the scale quotients. + \ifx\pgfplots@optimum@sofar@axis\pgfutil@empty + \ifpgfplots@threedim + % 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 % - \begingroup - \def\pgfplots@tmp@exponentref{0}% - \def\pgfplots@tmp@exponentK{0}% - \pgfplots@if{pgfplots@apply@datatrafo@\pgfplots@axis@equal@apply@reference}{% - \pgfplots@letcsname{pgfplots@tmp@exponentref}={pgfplots@data@scale@trafo@EXPONENT@\pgfplots@axis@equal@apply@reference}% - }{}% - \pgfplots@if{pgfplots@apply@datatrafo@#1}{% - \pgfplots@letcsname{pgfplots@tmp@exponentK}={pgfplots@data@scale@trafo@EXPONENT@#1}% - }{}% - \c@pgf@counta=\pgfplots@tmp@exponentref - \advance\c@pgf@counta by-\pgfplots@tmp@exponentK - \ifnum\c@pgf@counta=0 + \ifx\pgfplots@optimum@sofar@axis\pgfutil@empty + \ifpgfplots@threedim + \def\pgfplots@optimum@sofar@axis{z}% \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 + \def\pgfplots@optimum@sofar@axis{y}% \fi - \xdef\pgfplots@glob@TMPc{\the\c@pgf@counta}% + \pgfplots@warning{The algorithm to realize 'unit vector ratio' failed! It could not determine the axis which shall be scaled and decided to use 'unit vector ratio axis=\pgfplots@optimum@sofar@axis'.}% + \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 +}% + +\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}% % - \if x#1 - \pgfsetxvec{\pgfplotsqpointxy{\pgfplots@glob@TMPa}{0}}% + % '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#1 - \pgfsetyvec{\pgfplotsqpointxy{0}{\pgfplots@glob@TMPa}}% + \if y\pgfplots@apply@unit@ratio@reference \else - \if z#1 - \pgfsetzvec{\pgfplotsqpointxyz{0}{0}{\pgfplots@glob@TMPa}}% - \fi + \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 % - % - % Update auxiliary data members: - % This is only complicated due to the scaling transformation. If we would not have the scaling trafo, the following - % code would simply copy the vector length and inverse vectors length from the reference axis. - \pgfplotsmathmultiplypowten@{\csname pgfplots@\pgfplots@axis@equal@apply@reference @veclength\endcsname}{\pgfplots@glob@TMPc}% - \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult - \pgfplotsmathmultiplypowten@{\csname pgfplots@\pgfplots@axis@equal@apply@reference @inverseveclength\endcsname}{-\pgfplots@glob@TMPc}% - \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult - % - % - \ifpgfplots@axis@equal@image +}% + + +% 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\pgfplots@loc@TMPa % - % Ok, now update the axis limits such that the axis' dimensions - % stay the same. + \pgfplots@getscale@unit@vector@reltoreference{#1}{#2}% + \global\let\pgfplots@glob@TMPa=\pgfmathresult % - % My idea is to add half of the new range to 'max' and - % subtract the other half from 'min': - % 1/s( xmax - xmin) = (xmax+0.5d) - (xmin-0.5d) = xmax - xmin +d - % with d = 1/s (xmax-xmin) - (xmax-xmin) = (1/s - 1) (xmax-xmin) +%\message{Rescaling '#1' by \pgfplots@glob@TMPa.^^J}% + \if x#1 + \pgfsetxvec{\pgfplotsqpointxy{\pgfplots@glob@TMPa}{0}}% + \else + \if y#1 + \pgfsetyvec{\pgfplotsqpointxy{0}{\pgfplots@glob@TMPa}}% + \else + \if z#1 + \pgfsetzvec{\pgfplotsqpointxyz{0}{0}{\pgfplots@glob@TMPa}}% + \fi + \fi + \fi + % + \pgfmathmultiply@{\csname pgfplots@#1@veclength\endcsname}{\pgfplots@glob@TMPa}% + \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult + % + \pgfmathreciprocal@\pgfplots@glob@TMPa + \global\let\pgfplots@glob@TMPb=\pgfmathresult + % + \pgfmathmultiply@{\csname pgfplots@#1@inverseveclength\endcsname}{\pgfplots@glob@TMPb}% + \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult % -%\message{'axis equal': Resizing data range for #1: from \csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname\ to}% + % + \pgfplots@apply@unit@vector@rescale@keep@size{#1}{\pgfplots@glob@TMPb}% + % + \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. +% +% My idea is to add half of the new range to 'max' and +% subtract the other half from 'min': +% 1/s( xmax - xmin) = (xmax+0.5d) - (xmin-0.5d) = xmax - xmin +d +% with d = 1/s (xmax-xmin) - (xmax-xmin) = (1/s - 1) (xmax-xmin) +% +% #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{% + \ifpgfplots@unit@vector@rescale@keep@size + % +%\message{'unit rescale keep size': Resizing data range for #1: 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@{\pgfplots@glob@TMPb}{1.0}% + \pgfmathsubtract@{#2}{1.0}% \pgf@xa=\pgfmathresult \pgf@xa \divide\pgf@xa by2 \xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}% @@ -5405,6 +5921,85 @@ % Update auxiliary data members: \pgfplots@visphase@notify@changeofcanvaslimits{#1}% \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||. + % + \pgfmathmultiply@ + {\csname pgfplots@\pgfplots@apply@unit@ratio@reference @veclength\endcsname} + {\csname pgfplots@#1@inverseveclength\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@#1@veclength\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 +%\message{\string\pgfplots@getscale@unit@vector@reltoreference{#1}{#2} (reference \pgfplots@apply@unit@ratio@reference) = \pgfmathresult.^^J}% } % should be invoked whenever \pgfplots@#1min or \pgfplots@#1max have @@ -5414,18 +6009,32 @@ \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}{% - \csname pgfplots@inverse@datascaletrafo@#1\endcsname{\csname pgfplots@#1min\endcsname}% + \pgfplotscoordmath{#1}{datascaletrafo inverse}{\csname pgfplots@#1min\endcsname}% \expandafter\let\csname pgfplots@#1min@unscaled@as@float\endcsname=\pgfmathresult - \csname pgfplots@inverse@datascaletrafo@#1\endcsname{\csname pgfplots@#1max\endcsname}% + \pgfplotscoordmath{#1}{datascaletrafo inverse}{\csname pgfplots@#1max\endcsname}% \expandafter\let\csname pgfplots@#1max@unscaled@as@float\endcsname=\pgfmathresult }{}% }% -% Invokes #3 if +% 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}% @@ -5437,15 +6046,19 @@ \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 @@ -5483,14 +6096,6 @@ \pgfplots@zmax@reg=\pgfplots@zmax pt % \fi % - \pgfpointdiff - {\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}} - {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}% - % only used temporarily in this macro to compute the correct - % length for unit vectors: - \edef\pgfplots@initsizes@axisdiag@x{\the\pgf@x}% - \edef\pgfplots@initsizes@axisdiag@y{\the\pgf@y}% - % % %----------------------------------------- % PROCESS THE 'width' and 'height' options @@ -5506,13 +6111,24 @@ % FIXME \let\pgfplots@view@el=\pgfutil@empty \let\pgfplots@view@az=\pgfutil@empty - \def\pgfplots@view@dir@threedim@x{0}% - \def\pgfplots@view@dir@threedim@y{0}% - \def\pgfplots@view@dir@threedim@z{1}% \fi \ifx\pgfplots@view@az\pgfutil@empty + % 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 + \def\pgfplots@view@dir@threedim@x{0}% + \def\pgfplots@view@dir@threedim@y{0}% + \def\pgfplots@view@dir@threedim@z{1}% + % + \pgfpointdiff + {\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}} + {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}% + % only used temporarily in this macro to compute the correct + % length for unit vectors: + \edef\pgfplots@initsizes@axisdiag@x{\the\pgf@x}% + \edef\pgfplots@initsizes@axisdiag@y{\the\pgf@y}% % \ifx\pgfplots@x\pgfutil@empty \ifx\pgfplots@width\pgfutil@empty @@ -5545,17 +6161,26 @@ \pgfplots@initsizes@setunitvector{x}{0}{\pgfplots@tmpXscale}{\pgfplots@tmp@xisaxisparallel}% \pgfplots@initsizes@setunitvector{y}{1}{\pgfplots@tmpYscale}{\pgfplots@tmp@yisaxisparallel}% \pgfplots@initsizes@setunitvector{z}{2}{\pgfplots@tmpZscale}{\pgfplots@loc@TMPc}% + \ifcase\pgfplots@scale@mode@choice\relax + % scale mode=auto : do nothing in this context. + \else + \pgfplots@scale@axisbox@to@widthheight + \fi + \ifpgfplots@threedim + \pgfplotsgetnormalforcurrentview + \fi \else - % 3D case is currently always initialised by `view': + % 3D case by `view': \let\pgfplots@x=\pgfutil@empty \let\pgfplots@y=\pgfutil@empty \let\pgfplots@z=\pgfutil@empty + % this invokes \pgfplots@scale@plotbox@to@widthheight automatically. \pgfplotssetaxesfromazel{\pgfplots@view@az}{\pgfplots@view@el}{\pgfplots@tmp@xisaxisparallel}% \if1\pgfplots@tmp@xisaxisparallel% \def\pgfplots@tmp@yisaxisparallel{1}% \fi \fi -%\message{Pgfplots debug: initialised unit vectors to x=(\the\pgf@xx,\the\pgf@xy), y=(\the\pgf@yx,\the\pgf@yy), z=(\the\pgf@zx,\the\pgf@zy). }% +%\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@x,\pgfplots@view@dir@threedim@y,\pgfplots@view@dir@threedim@z).^^J }% % \let\pgfplotsmathfloatviewdepthxyz@=\pgfplotsmathfloatviewdepthxyz@infigure \let\pgfplotsmathviewdepthxyz@=\pgfplotsmathviewdepthxyz@infigure @@ -5573,124 +6198,33 @@ \fi \fi \fi - \ifpgfplots@axis@equal@image - \pgfplots@axis@equaltrue - \fi - \ifpgfplots@axis@equal - \pgfplots@axis@equal@apply - \fi - % - % Determine final rectangle dimensions. - % 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. + \pgfplots@apply@unit@ratio % - \begingroup + \pgfplots@axis@apply@post@scale x + \pgfplots@axis@apply@post@scale y \ifpgfplots@threedim - \def\pgfplotspointmaxminmin{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}% - \def\pgfplotspointminmaxmin{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}% - \pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}% - \else - \def\pgfplotspointmaxminmin{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}% - \def\pgfplotspointminmaxmin{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}% - \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}% + \pgfplots@axis@apply@post@scale z \fi - \xdef\pgfplotspointminminmin{\global\pgf@x=\the\pgf@x\space\global\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{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% - \pgfmathveclen{\pgf@x}{\pgf@y}% - \xdef\pgfplotspointxaxislength{\pgfmathresult pt}% - % - \pgfpointdiff - {\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@ycoordminTEX}} - {\pgfplotspointminmaxmin}% - \xdef\pgfplotspointyaxis{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% - \pgfmathveclen{\pgf@x}{\pgf@y}% - \xdef\pgfplotspointyaxislength{\pgfmathresult pt}% +} +\def\pgfplots@axis@apply@post@scale#1{% % - \ifpgfplots@threedim - \pgfpointdiff - {\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@ycoordminTEX}} - {\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}% - \xdef\pgfplotspointzaxis{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% - \pgfmathveclen{\pgf@x}{\pgf@y}% - \xdef\pgfplotspointzaxislength{\pgfmathresult pt}% - % - \pgfpointscale - {0.5}% - {\pgfplotspointxaxis - \pgf@xa=\pgf@x - \pgf@xb=\pgf@y - \pgfplotspointyaxis% - \advance\pgf@xa by\pgf@x - \advance\pgf@xb by\pgf@y - \pgfplotspointzaxis% - \advance\pgf@xa by\pgf@x - \advance\pgf@xb by\pgf@y - \global\pgf@x=\pgf@xa - \global\pgf@y=\pgf@xb - }% - \xdef\pgfplotspointcenter{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + \pgfkeysgetvalue{/pgfplots/#1 post scale}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty \else - \global\let\pgfplotspointzaxis=\pgfpointorigin - \gdef\pgfplotspointzaxislength{0pt}% - \pgfpointscale - {0.5}% - {\pgfpointadd - \pgfplotspointxaxis% - \pgfplotspointyaxis% - }% - \xdef\pgfplotspointcenter{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + \pgfmathparse{\pgfmathresult}% + \ifdim\pgfmathresult pt=1pt + \else + \let\pgfplots@loc@TMPa=\pgfmathresult + \csname pgf@#1x\endcsname=\pgfmathresult\csname pgf@#1x\endcsname + \csname pgf@#1y\endcsname=\pgfmathresult\csname pgf@#1y\endcsname + % + \pgfmathmultiply@{\csname pgfplots@#1@veclength\endcsname}{\pgfplots@loc@TMPa}% + \expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult + % + \pgfmathdivide@{\csname pgfplots@#1@inverseveclength\endcsname}{\pgfplots@loc@TMPa}% + \expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult + \fi \fi - \endgroup } % This here is a low-weight node. It can ONLY be used during axis @@ -5980,14 +6514,28 @@ %% %% \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}% + % 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 @@ -6249,6 +6797,65 @@ }{}% }% + +% 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{% @@ -6285,6 +6892,8 @@ \fi } +\def\pgfplots@draw@axis@is@prepared{}% + % PRECONDITION: % \pgfplots@draw@axis@pre has been called. \def\pgfplots@draw@axis{% @@ -6341,8 +6950,8 @@ %\fi \else % Just use the 2d-point commands (assuming Z=0) - \let\pgfplotspointonorientedsurfaceabsetupforxyz=\pgfplotspointonorientedsurfaceabsetupforxy - \let\pgfplotspointonorientedsurfaceabsetupforyxz=\pgfplotspointonorientedsurfaceabsetupforyx + \let\pgfplotspointonorientedsurfaceabsetupfor@@xyz=\pgfplotspointonorientedsurfaceabsetupfor@@xy + \let\pgfplotspointonorientedsurfaceabsetupfor@@yxz=\pgfplotspointonorientedsurfaceabsetupfor@@yx \pgfplots@draw@axis@insurface@symmetric xyz \fi }% @@ -6614,10 +7223,33 @@ \expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{b}% \expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{f}% \fi + \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 strategie is as follows: + % 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 @@ -6635,20 +7267,6 @@ % \pgfplots@init@ticklabelaxisspecfor zx% \else - % FIXME : it might be better to implement that stuff here - % implicilty using the 3D algorithms. - % - % this here is the only important one: - \expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{b}% - % - \expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{b}% - \expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{f}% - \expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{b}% - \expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{f}% - \expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{f}% - \def\pgfplotsifaxislineisonconvexhull##1##2##3{##2}% ALWAYS TRUE - \def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@##1##2##3{##2}% ALWAYS TRUE - % \pgfplotspointcenter \edef\pgfplots@tmp@centerx{\the\pgf@x}% \edef\pgfplots@tmp@centery{\the\pgf@y}% @@ -6657,10 +7275,10 @@ % \pgfplots@init@ticklabelaxisspec@twodim@for yx% \fi -} +}% % A helper method which is to be invoked ONLY inside of -% \pgfplots@decide@which@figure@surfaces@are@drawn. +% \pgfplots@init@ticklabelaxisspec. % It does NOT work outside of it. % % It initialises the 'pgfplots@#1ticklabelaxisspec' macro according to @@ -6677,7 +7295,6 @@ % % POSTCONDITION: % - pgfplots@#1ticklabelaxisspec is set, -% - pgfplots@#1ticklabel@suggested@anchor is set % % @see also \pgfplots@init@ticklabelaxisspec@twodim@for \def\pgfplots@init@ticklabelaxisspecfor#1#2{% @@ -6783,7 +7400,7 @@ % #3 : the direction which is currently fixed. \def\pgfplots@draw@axis@insurface#1#2#3{% \pgfplots@if{pgfplots@hide@#1}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \pgfplots@drawgridlines@onorientedsurf % \pgfplots@drawticklines@onorientedsurf @@ -6796,7 +7413,7 @@ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}% \fi }% @@ -6808,32 +7425,32 @@ % with slightly optimized execution sequence. \def\pgfplots@draw@axis@insurface@symmetric#1#2#3{% \pgfplots@if{pgfplots@hide@#1}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \pgfplots@drawgridlines@onorientedsurf }% \pgfplots@if{pgfplots@hide@#2}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #2#1#3% \pgfplots@drawgridlines@onorientedsurf }% % \pgfplots@if{pgfplots@hide@#1}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \pgfplots@drawticklines@onorientedsurf }% \pgfplots@if{pgfplots@hide@#2}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #2#1#3% \pgfplots@drawticklines@onorientedsurf }% % \ifpgfplots@separate@axis@lines \pgfplots@if{pgfplots@hide@#1}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \pgfplots@drawaxis@outerlines@separate@onorientedsurf#1#2% \pgfplots@drawaxis@innerlines@onorientedsurf#1#2#3% }% % \pgfplots@if{pgfplots@hide@#2}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #2#1#3% \pgfplots@drawaxis@outerlines@separate@onorientedsurf#2#1% \pgfplots@drawaxis@innerlines@onorientedsurf#2#1#3% }% @@ -6844,11 +7461,11 @@ \fi % \pgfplots@if{pgfplots@hide@#1}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \pgfplots@drawticklabels@onorientedsurf }% \pgfplots@if{pgfplots@hide@#2}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #2#1#3% \pgfplots@drawticklabels@onorientedsurf }% % @@ -6856,7 +7473,7 @@ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}% \fi }% @@ -6864,7 +7481,7 @@ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#2tick\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #2#1#3% \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}% \fi }% @@ -6872,7 +7489,7 @@ \def\pgfplots@draw@axis@insurface@onlyticksandgrid#1#2#3{% \pgfplots@if{pgfplots@hide@#1}{\relax}{% - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \pgfplots@drawgridlines@onorientedsurf \pgfplots@drawticklines@onorientedsurf % @@ -6881,7 +7498,7 @@ \else \begingroup \let\pgfplots@drawticklabels@onorientedsurf=\relax - \csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname + \pgfplotspointonorientedsurfaceabsetupfor #1#2#3% \expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}% \endgroup \fi @@ -6944,7 +7561,9 @@ \endgroup \expandafter\pgfsettransformentries\pgfplots@glob@TMPa{0pt}{0pt}% % + % \pgfplots@draw@axis@pre + \pgfplots@draw@axis@is@prepared \scope % \pgfkeysifdefined{/pgfplots/axis background/.@cmd}{% @@ -6962,26 +7581,26 @@ \pgfplotspointbb@assertvaluesexist% } -% Defines \pgfplots@clippath@install. -% @PRECONDITION the axis limits must be ready. -\def\pgfplots@clippath@prepare{% - \def\pgfplots@clippath@use@##1{% - \ifx\pgfplotspoint@bb@@@\relax - % remember the axis dimensions as well: - \ifdim\pgf@pathmaxx=-16000pt - \else - \begingroup - \pgf@xa=\pgf@pathmaxx - \advance\pgf@xa by-\pgf@pathminx - \pgf@ya=\pgf@pathmaxy - \advance\pgf@ya by-\pgf@pathminy - \xdef\pgfplots@glob@TMPa{{\the\pgf@pathminx}{\the\pgf@pathminy}{\the\pgf@xa}{\the\pgf@ya}}% - \endgroup - \global\let\pgfplotspoint@bb@@@=\pgfplots@glob@TMPa - \fi +% 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 - ##1% - }% + \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. @@ -7212,18 +7831,60 @@ \endgroup \let\pgfplots@clippath@install=\pgfplots@glob@TMPa \fi - % FIXME : workaround clear path sizes at beginning! This shouldn't - % be necessary! - \expandafter\def - \expandafter\pgfplots@clippath@install - \expandafter##% - \expandafter1% - \expandafter{% - \expandafter\pgf@resetpathsizes - \pgfplots@clippath@install{##1}% - }% +}% +% 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 + \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% + % + % 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}% + \ifx\pgfplots@loc@TMPa\pgfplots@clippath@install@test + % the 'clip' path has been precomputed because it is often + % used: + \expandafter\pgfsys@invoke\expandafter{\pgfplots@clippath@install@clip@protocolled}% + % as far as I can see, this here is the only command which + % can't be protocolled: + \pgf@relevantforpicturesizefalse + \else + \pgf@resetpathsizes% FIXME: this here should not be necessary! + \pgfplots@clippath@install@pathcmd{##1}% + \fi + }% + % }% +\def\pgfplots@clippath@install@test{\pgfusepath{clip}X}% + \def\pgfplotspointbb@assertvaluesexist{% \ifx\pgfplotspoint@bb@@@\relax % (RE)COMPUTE: @@ -7295,7 +7956,7 @@ \def\pgfplots@filter@input@ticks@with@log#1#2{% \let\pgfplots@glob@TMPa=\pgfutil@empty \foreach \pgfplots@loc@TMPb in {#1} {% - \csname pgfplotsmathlog@#2@\endcsname{\pgfplots@loc@TMPb}% + \pgfplotscoordmath{#2}{log}{\pgfplots@loc@TMPb}% \ifx\pgfplots@glob@TMPa\pgfutil@empty \xdef\pgfplots@glob@TMPa{\pgfmathresult}% \else @@ -7321,14 +7982,17 @@ \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}% +% 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}} @@ -7347,10 +8011,11 @@ \let\pgfplots@loc@TMPc=\pgfmathresult% FIXME: is that necessary? I doubt it... but just to make sure... \csname ifpgfplots@#1islinear\endcsname \pgfplots@if{pgfplots@apply@datatrafo@#1}{% - \csname pgfplots@datascaletrafo@fromfixed@#1\endcsname{\pgfplots@loc@TMPc}% + \pgfplotscoordmath{#1}{parsenumber}{\pgfplots@loc@TMPc}% + \pgfplotscoordmath{#1}{datascaletrafo}{\pgfmathresult}% }{}% \else - \pgfmathlog@{\pgfplots@loc@TMPc}% + \pgfplotscoordmath{#1}{log}{\pgfplots@loc@TMPc}% \fi } @@ -7469,7 +8134,6 @@ % See also: % \pgfplots@check@and@apply@datatrafo@for \def\pgfplots@prepare@coord@filtering@for#1{% - \expandafter\let\csname pgfplotsmathlogtologten@#1@\endcsname=\pgfmathlogtologten@ \pgfkeysgetvalue{/pgfplots/#1 coord trafo/.@cmd}\pgfplots@loc@TMPc \expandafter\let\csname pgfplots@highlevel@trafo@#1\endcsname=\pgfplots@loc@TMPc \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key @@ -7527,6 +8191,7 @@ \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 @@ -7534,6 +8199,12 @@ \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 @@ -7545,6 +8216,7 @@ \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 @@ -7552,37 +8224,31 @@ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1min\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{parsenumber}{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult \fi \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1max\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{parsenumber}{\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 - \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{parsenumber}{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1tickmin\endcsname=\pgfmathresult \fi \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmax\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{parsenumber}{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult \fi \fi \else - \expandafter\let\csname pgfplotsmathlog@#1@\endcsname=\pgfmathlog@ - \expandafter\let\csname pgfplotsmathlogi@#1\endcsname=\logi - \expandafter\let\csname pgfplotsmathlog@#1@float\endcsname=\pgfmathlog@float - \expandafter\let\csname pgfplots@log@scale@todisplaylog@#1\endcsname=\logten - \expandafter\let\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname=\reciproclogten - \expandafter\def\csname pgfplotsmathlogscale@#1\endcsname{1}% - \expandafter\def\csname pgfplotsmathlogscale@#1@inv\endcsname{1}% + \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 @@ -7596,38 +8262,10 @@ % log basis x={} (initial setting:) \else % use a different basis. - % - % - \pgfmathlog@{\pgfplots@loc@TMPa}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \pgfmathparse{1/\pgfplots@loc@TMPa}% - \expandafter\let\csname pgfplotsmathlogscale@#1\endcsname=\pgfplots@loc@TMPa - \expandafter\let\csname pgfplotsmathlogscale@#1@inv\endcsname=\pgfmathresult - % - \expandafter\edef\csname pgfplotsmathlog@#1@\endcsname##1{% - \noexpand\pgfmathlog@{##1}% - \noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty - \noexpand\else - \noexpand\expandafter\noexpand\pgfmath@basic@multiply@\noexpand\expandafter - {\noexpand\pgfmathresult}% - {\pgfmathresult}% - \noexpand\fi - }% - \expandafter\edef\csname pgfplotsmathlog@#1@float\endcsname##1{% - \noexpand\pgfmathlog@float{##1}% - \noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty - \noexpand\else - \noexpand\expandafter\noexpand\pgfmath@basic@multiply@\noexpand\expandafter - {\noexpand\pgfmathresult}% - {\pgfmathresult}% - \noexpand\fi - }% + \pgfplotscoordmath{#1}{set log basis}{\pgfplots@loc@TMPa}% % % generate default ticks in the 'log basis', not base 10: - \expandafter\def\csname pgfplots@log@scale@todisplaylog@#1\endcsname{1}% - \expandafter\def\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname{1}% \pgfplotsset{/pgfplots/log basis ticks=#1}% - % % \ifdim\pgfkeysvalueof{/pgfplots/log basis #1}pt=10pt \else @@ -7638,39 +8276,6 @@ \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 - % - % recompute logtologten for this axis: - \pgfmath@basic@multiply@{\reciproclogten}{\pgfplots@loc@TMPa}% - \expandafter\edef\csname pgfplotsmathlogtologten@#1@\endcsname##1{% - \noexpand\pgfmath@basic@multiply@{##1}{\pgfmathresult}% - }% - \begingroup - % recompute \logi for the new basis. - \dimen1=\logi1pt \dimen1=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen1 - \dimen2=\logi2pt \dimen2=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen2 - \dimen3=\logi3pt \dimen3=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen3 - \dimen4=\logi4pt \dimen4=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen4 - \dimen5=\logi5pt \dimen5=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen5 - \dimen6=\logi6pt \dimen6=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen6 - \dimen7=\logi7pt \dimen7=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen7 - \dimen8=\logi8pt \dimen8=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen8 - \dimen9=\logi9pt \dimen9=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen9 - \xdef\pgfplots@glob@TMPa##1{% - \noexpand\ifcase##1 - \noexpand\or0 - \noexpand\or\pgf@sys@tonumber{\dimen1 }% - \noexpand\or\pgf@sys@tonumber{\dimen2 }% - \noexpand\or\pgf@sys@tonumber{\dimen3 }% - \noexpand\or\pgf@sys@tonumber{\dimen4 }% - \noexpand\or\pgf@sys@tonumber{\dimen5 }% - \noexpand\or\pgf@sys@tonumber{\dimen6 }% - \noexpand\or\pgf@sys@tonumber{\dimen7 }% - \noexpand\or\pgf@sys@tonumber{\dimen8 }% - \noexpand\or\pgf@sys@tonumber{\dimen9 }% - \noexpand\fi - }% - \endgroup - \expandafter\let\csname pgfplotsmathlogi@#1\endcsname=\pgfplots@glob@TMPa %%% % Ok, now, I have prepared everything for the new % log basis! @@ -7680,13 +8285,13 @@ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1min\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{log}{\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 - \csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{log}{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult \fi % @@ -7694,13 +8299,13 @@ \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmin\endcsname \ifx\pgfplots@loc@TMPa\pgfutil@empty \else - \csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}% + \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 - \csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{log}{\pgfplots@loc@TMPa}% \expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult \fi % @@ -7723,26 +8328,26 @@ \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}{% - \pgfmathfloatparsenumber{\pgfmathresult}% - \expandafter\pgfmathfloat@decompose@F\pgfmathresult\relax\c@pgf@counta - \ifnum\c@pgf@counta>2 % this clears nan, inf and -inf points. - \let\pgfmathresult=\pgfutil@empty - \def\pgfplots@unbounded@dir{#1}% - \else - \pgfmathfloattofixed{\pgfmathresult}% - \fi + \pgfplotscoordmath{#1}{parsenumber}{\pgfmathresult}% + % FIXME : check for unbounded arguments! }{% - \csname pgfplotsmathlog@#1@\endcsname{\pgfmathresult}% - \ifx\pgfmathresult\pgfutil@empty - % detect unbounded coords: + \pgfplotscoordmath{#1}{log}{\pgfmathresult}% + \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{}{% \def\pgfplots@unbounded@dir{#1}% - \fi + }% }% \fi }% @@ -7777,6 +8382,7 @@ } \def\pgfplots@create@axis@descriptions@{% + \begingroup \ifpgfplots@hide@x \else \ifpgfplots@units@use% @@ -7815,6 +8421,7 @@ \fi \fi \fi + \endgroup % \pgfkeysgetvalue{/pgfplots/title}\pgfplots@loc@TMPa \ifx\pgfplots@loc@TMPa\pgfutil@empty @@ -7827,215 +8434,6 @@ % } -\def\pgfplots@datascaletrafo@undoshift@x#1{% - \pgfmathsubtract@{#1}{\pgfplots@data@scale@trafo@SHIFT@x}% -}% -\def\pgfplots@datascaletrafo@redoshift@x#1{% - \pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@x}% -}% -\def\pgfplots@datascaletrafo@undoshift@y#1{% - \pgfmathsubtract@{#1}{\pgfplots@data@scale@trafo@SHIFT@y}% -}% -\def\pgfplots@datascaletrafo@redoshift@y#1{% - \pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@y}% -}% -\def\pgfplots@datascaletrafo@undoshift@z#1{% - \pgfmathsubtract@{#1}{\pgfplots@data@scale@trafo@SHIFT@z}% -}% -\def\pgfplots@datascaletrafo@redoshift@z#1{% - \pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@z}% -}% - -% DATA TRANSFORMATION T(x) = X - xmin -% -% Input: -% a number in the original data range, given in **floating** point representation -% Output: -% a fixed point number in transformed range -% stored in \pgfmathresult -% @see -% \pgfplots@datascaletrafo@fromfixed@x -\def\pgfplots@datascaletrafo@x#1{% - \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@x}% - \pgfmathfloattofixed{\pgfmathresult}% - \expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@x}% -} -\def\pgfplots@datascaletrafo@x@noshift#1{% - \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@x}% - \pgfmathfloattofixed{\pgfmathresult}% -} - -% Overloaded function. -% Input: -% a FIXED point number instead of a floating point one. -% @see \pgfplots@datascaletrafo@x -\def\pgfplots@datascaletrafo@fromfixed@x#1{% - \pgfmathfloatparsenumber{#1}% - \pgfplots@datascaletrafo@x{\pgfmathresult}% -} - -\def\pgfplots@datascaletrafo@y#1{% - \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@y}% - \pgfmathfloattofixed{\pgfmathresult}% - \expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@y}% -} -\def\pgfplots@datascaletrafo@fromfixed@y#1{% - \pgfmathfloatparsenumber{#1}% - \pgfplots@datascaletrafo@y{\pgfmathresult}% -} -\def\pgfplots@datascaletrafo@y@noshift#1{% - \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@y}% - \pgfmathfloattofixed{\pgfmathresult}% -} -\def\pgfplots@datascaletrafo@z#1{% - \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@z}% - \pgfmathfloattofixed{\pgfmathresult}% - \expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@z}% -} -\def\pgfplots@datascaletrafo@fromfixed@z#1{% - \pgfmathfloatparsenumber{#1}% - \pgfplots@datascaletrafo@z{\pgfmathresult}% -} -\def\pgfplots@datascaletrafo@z@noshift#1{% - \pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@z}% - \pgfmathfloattofixed{\pgfmathresult}% -} - -% INVERSE transformation x = T^{-1}( X ) -% Input: -% a fixed point number in transformed domain -% Output: -% a number in the data domain, given in floating point -% representation -% -% If the input number is approximately X=0, we will return x=0 as -% well. -% -% This allows to handle rounding inaccuracies and should not pose any -% problems. -\def\pgfplots@inverse@datascaletrafo@x#1{% - \begingroup - \pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@x}% - \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}% - \edef\pgfplots@data@scale@trafo@EXPONENT@x{-\pgfplots@data@scale@trafo@EXPONENT@x}% - \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@x}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -} -\def\pgfplots@inverse@datascaletrafo@x@noshift#1{% - \begingroup - \pgfmathapproxequalto@{#1}{0.0}% - \ifpgfmathcomparison - \pgfmathfloatcreate{0}{0.0}{0}% - \else - \pgfmathfloatparsenumber{#1}% - \edef\pgfplots@data@scale@trafo@EXPONENT@x{-\pgfplots@data@scale@trafo@EXPONENT@x}% - \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@x}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -} - -\def\pgfplots@inverse@datascaletrafo@y#1{% - \begingroup - \pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@y}% - \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}% - \edef\pgfplots@data@scale@trafo@EXPONENT@y{-\pgfplots@data@scale@trafo@EXPONENT@y}% - \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@y}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -} -% Overloaded function. This one does only apply the scaling, no shift. -\def\pgfplots@inverse@datascaletrafo@y@noshift#1{% - \begingroup - \pgfmathapproxequalto@{#1}{0.0}% - \ifpgfmathcomparison - \pgfmathfloatcreate{0}{0.0}{0}% - \else - \pgfmathfloatparsenumber{#1}% - \edef\pgfplots@data@scale@trafo@EXPONENT@y{-\pgfplots@data@scale@trafo@EXPONENT@y}% - \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@y}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -} - -\def\pgfplots@inverse@datascaletrafo@z#1{% - \begingroup - \pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@z}% - \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}% - \edef\pgfplots@data@scale@trafo@EXPONENT@z{-\pgfplots@data@scale@trafo@EXPONENT@z}% - \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@z}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -} -% Overloaded function. This one does only apply the scaling, no shift. -\def\pgfplots@inverse@datascaletrafo@z@noshift#1{% - \begingroup - \pgfmathapproxequalto@{#1}{0.0}% - \ifpgfmathcomparison - \pgfmathfloatcreate{0}{0.0}{0}% - \else - \pgfmathfloatparsenumber{#1}% - \edef\pgfplots@data@scale@trafo@EXPONENT@z{-\pgfplots@data@scale@trafo@EXPONENT@z}% - \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@z}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -} - -% Overloaded function. -% -% In contrast to \pgfplots@inverse@datascaletrafo@x, this method -% returns a number in FIXED point representation. -% @see \pgfplots@inverse@datascaletrafo@x -\def\pgfplots@inverse@datascaletrafo@tofixed@x#1{% - \pgfplots@inverse@datascaletrafo@x{#1}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% -} -\def\pgfplots@inverse@datascaletrafo@tofixed@y#1{% - \pgfplots@inverse@datascaletrafo@y{#1}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% -} -\def\pgfplots@inverse@datascaletrafo@tofixed@z#1{% - \pgfplots@inverse@datascaletrafo@z{#1}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% -} - -% Overloaded function. -% -% This one does only apply the scale, no shift. -\def\pgfplots@inverse@datascaletrafo@tofixed@x@noshift#1{% - \pgfplots@inverse@datascaletrafo@x@noshift{#1}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% -} -\def\pgfplots@inverse@datascaletrafo@tofixed@y@noshift#1{% - \pgfplots@inverse@datascaletrafo@y@noshift{#1}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% -} -\def\pgfplots@inverse@datascaletrafo@tofixed@z@noshift#1{% - \pgfplots@inverse@datascaletrafo@z@noshift{#1}% - \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% -} - % Invokes '#1' foreach key which should be saved by a color bar. % % The current key name is available as '##1', the macro under which @@ -8150,9 +8548,9 @@ \fi % % normalize format: - \pgfmathfloattosci\pgfplots@colorbar@src@metamin + \pgfplotscoordmath{meta}{tostring}{\pgfplots@colorbar@src@metamin}% \global\let\pgfplots@colorbar@src@metamin=\pgfmathresult - \pgfmathfloattosci\pgfplots@colorbar@src@metamax + \pgfplotscoordmath{meta}{tostring}{\pgfplots@colorbar@src@metamax}% \global\let\pgfplots@colorbar@src@metamax=\pgfmathresult % \pgfplots@assemble@ref@picture @@ -8176,9 +8574,12 @@ \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\pgfkeysvalueof{/pgfplots/colorbar/draw/.@cmd}\noexpand\pgfeov + \noexpand\pgfplots@colorbar@draw@ \ifx\pgfplots@colorbar@toname\pgfutil@empty \noexpand\pgfnodealias{current colorbar axis}{current axis}% \noexpand\pgfnodealias{current axis}{parent axis}% @@ -8200,6 +8601,44 @@ \pgfplots@label{\pgfplots@colorbar@toname}{pgfplots@colorbar@to@name@}% \fi }% + +\newif\ifpgfplotscolorbarCMYKworkaround +\pgfplotscolorbarCMYKworkaroundtrue + +\def\pgfplots@colorbar@draw@{% + \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/colorbar/draw/.@cmd}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfplots@colorbar@draw@defaultimpl + \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}{% + \pgfplots@warning{colorbar: The colormap '\pgfplots@loc@TMPb' has a CMYK colorspace which is not (yet) supported by PGF. I switched colorbar styles automatically to 'colorbar sampled={surf,shader=interp}' to generate a proper CMYK colorbar. Use \string\pgfplotscolorbarCMYKworkaroundfalse\space to disable this improvement. [This message won't be replicated for '\pgfplots@loc@TMPb']}% + \expandafter\gdef\csname pgfplots@colorbar@CMYK@\pgfplots@loc@TMPb\endcsname{1}% + }{}% + \pgfplotsset{colorbar sampled={surf,shader=interp}}% + \fi + \fi + \fi + \fi + % + % 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 + \pgfkeysvalueof{/pgfplots/colorbar/draw/.@cmd}\pgfeov +} \pgfkeysdef{/pgfplots/colorbar to name/at}{% % automatically search-and-replace 'parent axis' which % is not defined for a detached colorbar: @@ -8444,6 +8883,8 @@ {#1}% \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} @@ -8455,6 +8896,8 @@ \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}% @@ -8609,8 +9052,11 @@ \pgfkeysalso{/pgfplots/.search also=/tikz}% % \pgfplots@set@options@sanitize + \pgfplots@notify@options@are@set } +\def\pgfplots@notify@options@are@set{}% + \def\pgfplots@install@abbrev@commands{ \let\pgfplots@orig@path=\path \let\pgfplots@orig@plot=\plot @@ -8639,7 +9085,7 @@ \or2.197224 \fi }% - \def\axisdefaultticklabel{$\pgfmathprintnumber{\tick}$}% + \def\axisdefaultticklabel{\pgfmathprintnumber{\tick}}% \def\axisdefaultticklabellog{% \pgfkeysgetvalue{/pgfplots/log number format code/.@cmd}\pgfplots@log@label@style \expandafter\pgfplots@log@label@style\tick\pgfeov @@ -8651,6 +9097,13 @@ \let\addlegendentryexpanded=\pgfplots@addlegendentryexpanded } +\let\pgfplots@late@options=\pgfutil@empty +\def\pgfplotssetlateoptions#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 @@ -8681,11 +9134,19 @@ % \pgfplots@stored@current@cmd % \pgfplots@stored@current@data % \pgfplots@stored@current@postcmd -\def\pgfplots@stored@plotlist@EXTRACTENTRY#1#2#3#4{% - \def\pgfplots@stored@current@precmd{#1}% - \def\pgfplots@stored@current@cmd{#2}% +\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}% - \def\pgfplots@stored@current@postcmd{#4}% + % + \t@pgfplots@tokc={#4}% + \edef\pgfplots@stored@current@postcmd{\the\t@pgfplots@tokc}% + % } \def\pgfplots@init@cleared@structures{% @@ -8776,6 +9237,7 @@ \noexpand\def\noexpand\pgfplots@draw@image{% \noexpand\def\noexpand\tikz@plot@handler{\the\toks3}% \noexpand\pgfkeysdef{/pgfplots/legend image code}{\the\toks0}% + \noexpand\pgfkeyssetvalue{/pgfplots/mark list fill}{\pgfkeysvalueof{/pgfplots/mark list fill}}% \ifx\pgfplots@stylekey\pgfutil@empty \else \noexpand\pgfkeysdef{#2}{\the\toks4}% @@ -8803,21 +9265,32 @@ % % 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@}{\pgfplots@plot@label@[]}}% -\def\pgfplots@plot@label@[#1]#2{% +\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@#1\endcsname + \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={#2}: + % 1. prepare /pgfplots/refstyle={#3}: \pgfplots@auxwrite{% \noexpand\expandafter\noexpand\gdef - \noexpand\csname pgfplots@labelstyle@#2\noexpand\endcsname{\the\t@pgfplots@tokb}% + \noexpand\csname pgfplots@labelstyle@#3\noexpand\endcsname{\the\t@pgfplots@tokb}% }% - % 2. prepare \ref{#2} and \pageref{#2}: + % 2. prepare \ref{#3} and \pageref{#3}: % % There are several nasty things to consider: % a) macro expansion. Use \string to allow a safe \write @@ -8827,20 +9300,20 @@ % a "moving argument" like \caption or so, we need to use % proper '\protect'ion. % - % this here is the low-level implementation of \ref{#2}. Write it into + % 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@#2\noexpand\endcsname{% + \noexpand\csname pgfplots@show@ref@#3\noexpand\endcsname{% \the\t@pgfplots@toka }% }% % create the \label command: \let\label=\pgfplots@original@LaTeX@label - \pgfplots@label{#2}{pgfplots@show@ref@}% + \pgfplots@label[#1]{#3}{pgfplots@show@ref@}% \endgroup \else - \pgfplots@error{Can't create \string\label{#2}: it needs to be called after \string\addplot.}% + \pgfplots@error{Can't create \string\label{#3}: it needs to be called after \string\addplot.}% \fi }% @@ -8869,6 +9342,8 @@ % \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 ... @@ -8886,6 +9361,8 @@ \let\pgfplots@drawoptions=\tikz@options \let\pgfplots@drawmodes=\tikz@mode % + \pgfplots@check@for@default@plot@mark% + % % As of February 22, the final plot processing uses % foreach stored \addplot command : % \scope[current plot style] @@ -8901,26 +9378,45 @@ % inside of this scope, so we can check for that particular % case: \pgfkeys{/tikz/every path/.append code={% - \pgfutil@ifundefined{pgfplots@drawmodes}% - {\relax}% - {% - \let\tikz@mode=\pgfplots@drawmodes -% \let\tikz@options=\pgfplots@drawoptions - }% + \pgfplots@restore@drawmodes }% }% }% }% +\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 + }% +}% + +\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}% }% -\pgfutil@ifundefined{label}{\relax}{% -}% - % % \begin{axis}[#1] : % @@ -9046,15 +9542,21 @@ % \def\pgfplots@environment@opt[#1]{% \begingroup - \pgfutil@ifundefined{pgfplots@is@in@axis}{}{% + \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}% + \let\pgfpointxy@orig=\pgfpointxy + \let\pgfqpointxy@orig=\pgfqpointxy + \let\pgfpointxyz@orig=\pgfpointxyz + \let\pgfqpointxyz@orig=\pgfqpointxyz + \global\let\pgfplots@late@options=\pgfutil@empty \pgfplots@checkandpreparefor@active@semicolon + % \pgfplots@install@abbrev@commands \pgfplots@stacked@initialise % @@ -9072,6 +9574,8 @@ % \pgfplots@set@options{#1}% % + % + % % -------------------- % Allocations: % -------------------- @@ -9089,36 +9593,16 @@ \pgfplots@datascaletrafo@initialisedtrue% there is no trafo. \fi % - \ifpgfplots@xislinear - \pgfmathfloatcreate{1}{1.0}{2147483645}% - \let\pgfplots@invalidrange@xmin=\pgfmathresult - \pgfmathfloatcreate{2}{1.0}{2147483645}% - \let\pgfplots@invalidrange@xmax=\pgfmathresult - \else - \def\pgfplots@invalidrange@xmin{16300}% - \def\pgfplots@invalidrange@xmax{-16300}% - \fi - \ifpgfplots@yislinear - \pgfmathfloatcreate{1}{1.0}{2147483645}% - \let\pgfplots@invalidrange@ymin=\pgfmathresult - \pgfmathfloatcreate{2}{1.0}{2147483645}% - \let\pgfplots@invalidrange@ymax=\pgfmathresult - \else - \def\pgfplots@invalidrange@ymin{16300}% - \def\pgfplots@invalidrange@ymax{-16300}% - \fi - \ifpgfplots@zislinear - \pgfmathfloatcreate{1}{1.0}{2147483645}% - \let\pgfplots@invalidrange@zmin=\pgfmathresult - \pgfmathfloatcreate{2}{1.0}{2147483645}% - \let\pgfplots@invalidrange@zmax=\pgfmathresult - \else - \def\pgfplots@invalidrange@zmin{16300}% - \def\pgfplots@invalidrange@zmax{-16300}% - \fi - \pgfmathfloatcreate{1}{1.0}{2147483645}% + \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 - \pgfmathfloatcreate{2}{1.0}{2147483645}% + \pgfplotscoordmath{meta}{min limit}% \let\pgfplots@invalidrange@metamax=\pgfmathresult % % These numbers will ONLY be filled for linear axis! @@ -9179,7 +9663,7 @@ \def\pgfplots@axiswide@metamin@autocompute{1}% \else \def\pgfplots@axiswide@metamin@autocompute{0}% - \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@loc@TMPa}% \global\let\pgfplots@axiswide@metamin=\pgfmathresult \fi \pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots@loc@TMPa @@ -9187,7 +9671,7 @@ \def\pgfplots@axiswide@metamax@autocompute{1}% \else \def\pgfplots@axiswide@metamax@autocompute{0}% - \expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@loc@TMPa}% \global\let\pgfplots@axiswide@metamax=\pgfmathresult \fi % @@ -9217,6 +9701,12 @@ % Use \axispath instead: \let\path=\pgfplots@replacement@for@tikz@path \let\closedcycle=\pgfplots@path@closed@cycle + % + % defines \pgfplotsaxisupdatelimitsforcoordinate etc. + \pgfplots@prepare@axis@API + \pgfkeysvalueof{/pgfplots/execute at begin axis}% + \def\pgfplots@phase@name{s}% + % \let\pgfplots@orig@scope=\scope \let\pgfplots@orig@endscope=\endscope \let\scope=\pgfplots@replacement@for@scope @@ -9229,12 +9719,14 @@ % 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}% % % restore old \path command: \let\path=\pgfplots@orig@path @@ -9244,12 +9736,17 @@ % \pgfplotssurveyphase@setactiveplothandlers % + \expandafter\pgfplotsset\expandafter{\pgfplots@late@options}% + % %\end{axis}: % + \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 % % -------------------- % All plotting commands have been read. @@ -9257,23 +9754,30 @@ % -------------------- \pgfplots@BEGIN@init@and@draw@axis \pgfplots@stacked@initialise - \pgfplots@install@local@bar@handlers \global\pgfplotslistnewempty\pgfplots@stored@markerlist \ifpgfplots@stacked@reverse % This here applies any scaling trafos and assembles a % NEW \pgfplots@stored@plotlist! \pgfplots@stacked@finalize@stored@plots \fi - \pgfplotslistforeach\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{% + \pgfplotslistforeachungrouped\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{% \expandafter\pgfplots@stored@plotlist@EXTRACTENTRY\pgfplots@loc@TMPa -%\message{Processing stored plot with precommand '\meaning\pgfplots@stored@current@precmd'; pgfplots@plotcmd '\meaning\pgfplots@stored@current@cmd' postcommand '\meaning\pgfplots@stored@current@postcmd'}% +%\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 \pgfplots@stored@current@data% \else + \begingroup + % @see the stream preparation routines. + \pgfplots@stored@current@precmd + \pgfkeysvalueof{/pgfplots/execute at begin plot visualization}% + \ifpgfplots@threedim + \else + % axis = 2d and plot=3d is forbidden here. + \pgfplots@curplot@threedimfalse + \fi % % this code here means we REALLY have a plotting % command! @@ -9292,8 +9796,10 @@ \expandafter\pgfplots@coord@stream@finalize@storedcoords@START\pgfplots@stored@current@data\pgfplots@EOI \fi \endscope + \pgfkeysvalueof{/pgfplots/execute at end plot visualization}% + \pgfplots@stored@current@postcmd + \endgroup \fi - \pgfplots@stored@current@postcmd }% \global\pgfplotslistnewempty\pgfplots@stored@plotlist% delete contents. % @@ -9371,12 +9877,16 @@ \def\pgfplots@anchorname{image}% that means: no shift! }{}% % + \begingroup + \pgfplots@sys@beforenode + % \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}% % @@ -9504,5 +10014,8 @@ \tikzaddtikzonlycommandshortcutlet\loglogaxis\pgfplots@environment@loglogaxis \tikzaddtikzonlycommandshortcutlet\endloglogaxis\endpgfplots@environment@loglogaxis +\pgfplotsdefineaxistype{rectangle}{% + % do nothing, this is the default anyway. +}% \catcode`\;=\pgfplots@oldcatcodesemicolon diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex index 6abd1948238..e1bcc0a53d0 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex @@ -1,3 +1,3 @@ \def\pgfplotsrevision{% -1.4.1-1-g64c9e95 +1.5-1-gcc2f2d2 } diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex index 1331a3f284b..996dce22550 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex @@ -7,7 +7,7 @@ % % It is based on Till Tantau's PGF package. % -% Copyright 2007/2008 by Christian Feuersänger. +% 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 @@ -63,10 +63,15 @@ \pgf@zx=0pt \pgf@zy=0pt }% - \let\pgfpointxy@orig=\pgfpointxy - \let\pgfqpointxy@orig=\pgfqpointxy - \let\pgfpointxyz@orig=\pgfpointxyz - \let\pgfqpointxyz@orig=\pgfqpointxyz + % + % + \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. @@ -97,17 +102,9 @@ {\pgfqpointxy@orig{##1}{##2}}% }% }% - \edef\pgfplotspointunitx{\global\pgf@x=\the\pgf@xx\space\global\pgf@y=\the\pgf@xy\space}% - \edef\pgfplotspointunity{\global\pgf@x=\the\pgf@yx\space\global\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{\global\pgf@x=\the\pgf@zx\space\global\pgf@y=\the\pgf@zy\space}% - \let\pgfplotsunitzlength=\pgfplots@z@veclength - \let\pgfplotsunitzinvlength=\pgfplots@z@inverseveclength - \fi + \pgfplotspoint@initialisation@axes + \pgfplotspoint@initialisation@units + \pgfplotspoint@initialisation@center % % declare the '[xyz]ticklabel cs' \tikzdeclarecoordinatesystem{xticklabel}{\pgfplotspointticklabelcs{x}{##1}}% @@ -119,12 +116,167 @@ \pgfplotsdeclareborderanchorforticklabelaxis{y}{near yticklabel}% \pgfplotsdeclareborderanchorforticklabelaxis{z}{near zticklabel}% % - \pgfkeysdef{/tikz/sloped like x axis}{\tikz@addtransform{\pgfplotstransformtoaxisdirection{x}}}% - \pgfkeysdef{/tikz/sloped like y axis}{\tikz@addtransform{\pgfplotstransformtoaxisdirection{y}}}% - \pgfkeysdef{/tikz/sloped like z axis}{\tikz@addtransform{\pgfplotstransformtoaxisdirection{z}}}% + \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 @@ -253,7 +405,7 @@ % \pgfplotspointonorientedsurfaceN. % % Example: -% \pgfplotspointonorientedsurfaceabsetupforxyz +% \pgfplotspointonorientedsurfaceabsetupfor xyz % \pgfplotspointonorientedsurfaceabsetupforsetz{<lower z limit>}{0} % % -> @@ -264,7 +416,7 @@ % \pgfplotspointonorientedsurfacespecunordered = {vv0} % \pgfplotspointonorientedsurfaceab{3}{4} =\pgfqpointxyz{3}{4}{<lower z limit>} % -% \pgfplotspointonorientedsurfaceabsetupforyxz +% \pgfplotspointonorientedsurfaceabsetupfor yxz % \pgfplotspointonorientedsurfaceabsetupforsetz{<lower z limit>}{0} % -> % \pgfplotspointonorientedsurfaceA = y @@ -274,11 +426,32 @@ % \pgfplotspointonorientedsurfacespecunordered = {vv0} % \pgfplotspointonorientedsurfaceab{3}{4} =\pgfqpointxyz{4}{3}{<lower z limit>} % -% @see \pgfplotspointonorientedsurfaceabsetupforxyz +% @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\pgfplotspointonorientedsurfaceabsetupforxyz\ or its friends to do so.}% + \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 @@ -308,65 +481,78 @@ % 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\pgfplotspointonorientedsurfaceabsetupforxyz{% - \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{##1}{##2}{\pgfplotspointonorientedsurfaceabsetupfor@fixedZ}}% +\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\pgfplotspointonorientedsurfaceabsetupforyxz{% - \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{##2}{##1}{\pgfplotspointonorientedsurfaceabsetupfor@fixedZ}}% +\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\pgfplotspointonorientedsurfaceabsetupforxzy{% - \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{##1}{\pgfplotspointonorientedsurfaceabsetupfor@fixedY}{##2}}% +\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\pgfplotspointonorientedsurfaceabsetupforzxy{% - \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{##2}{\pgfplotspointonorientedsurfaceabsetupfor@fixedY}{##1}}% +\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\pgfplotspointonorientedsurfaceabsetupforyzx{% - \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{\pgfplotspointonorientedsurfaceabsetupfor@fixedX}{##1}{##2}}% +\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\pgfplotspointonorientedsurfaceabsetupforzyx{% - \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxyz{\pgfplotspointonorientedsurfaceabsetupfor@fixedX}{##2}{##1}}% +\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 -% \pgfplotspointonorientedsurfaceabsetupforzyx and -% \pgfplotspointonorientedsurfaceabsetupforyzx. +% \pgfplotspointonorientedsurfaceabsetupfor zyx and +% \pgfplotspointonorientedsurfaceabsetupfor yzx. % % #1: The fixed value for 'x' (a coordinate in transformed range). % #2: a one-character symbol describing 'x'. @@ -375,21 +561,21 @@ % 1 : x is the upper x-axis range. % 2 : other. \def\pgfplotspointonorientedsurfaceabsetupforsetx#1#2{% - \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedX{#1}% + \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedx{#1}% \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{#2}% }% \def\pgfplotspointonorientedsurfaceabsetupforsety#1#2{% - \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedY{#1}% + \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedy{#1}% \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{#2}% }% \def\pgfplotspointonorientedsurfaceabsetupforsetz#1#2{% - \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedZ{#1}% + \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedz{#1}% \edef\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{#2}% }% % Helper methods which should be used if no Z component exists (pure % 2d plots). -\def\pgfplotspointonorientedsurfaceabsetupforxy{% +\def\pgfplotspointonorientedsurfaceabsetupfor@@xy{% \def\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{0}% \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxy{##1}{##2}}% \def\pgfplotspointonorientedsurfaceA{x}% @@ -397,8 +583,9 @@ \def\pgfplotspointonorientedsurfaceN{z}% \edef\pgfplotspointonorientedsurfacespec{ab\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}% \edef\pgfplotspointonorientedsurfacespecunordered{vv\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}% + \pgfkeysvalueof{/pgfplots/oriented surf installed}% }% -\def\pgfplotspointonorientedsurfaceabsetupforyx{% +\def\pgfplotspointonorientedsurfaceabsetupfor@@yx{% \def\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol{0}% \def\pgfplotspointonorientedsurfaceab##1##2{\pgfplotsqpointxy{##2}{##1}}% \def\pgfplotspointonorientedsurfaceA{y}% @@ -406,6 +593,7 @@ \def\pgfplotspointonorientedsurfaceN{z}% \edef\pgfplotspointonorientedsurfacespec{ba\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}% \edef\pgfplotspointonorientedsurfacespecunordered{vv\pgfplotspointonorientedsurfaceabsetupfor@fixedsymbol}% + \pgfkeysvalueof{/pgfplots/oriented surf installed}% }% @@ -439,7 +627,7 @@ % (three-char-string). % % Example: -% \pgfplotspointonorientedsurfaceabsetupforxyz +% \pgfplotspointonorientedsurfaceabsetupfor xyz % \pgfplotspointonorientedsurfaceabsetupforsetz{<lower z limit>}{0} % -> the oriented surface is 'ab0' % ... @@ -734,22 +922,22 @@ % % Example: % \pgfplotspointonorientedsurfaceabsetupforsetz{\zmax}{1} -% \pgfplotspointonorientedsurfaceabsetupforyxz +% \pgfplotspointonorientedsurfaceabsetupfor yxz % \pgfplotspointonorientedsurfaceabmatchaxisline{v01}{\result} % -> \result will be 'v' because 'x=v' in '{v01} % % \pgfplotspointonorientedsurfaceabsetupforsety{\ymin}{0} -% \pgfplotspointonorientedsurfaceabsetupforxzy +% \pgfplotspointonorientedsurfaceabsetupfor xzy % \pgfplotspointonorientedsurfaceabmatchaxisline{v01}{\result} % -> \result will be '1' because 'z=1' in '{v01} % % \pgfplotspointonorientedsurfaceabsetupforsety{\ymax}{1} -% \pgfplotspointonorientedsurfaceabsetupforxzy +% \pgfplotspointonorientedsurfaceabsetupfor xzy % \pgfplotspointonorientedsurfaceabmatchaxisline{v01}{\result} % -> \result will be empty because 'y=0' in '{v01} % % \pgfplotspointonorientedsurfaceabsetupforsetx{\xmax}{1} -% \pgfplotspointonorientedsurfaceabsetupforyzx +% \pgfplotspointonorientedsurfaceabsetupfor yzx % \pgfplotspointonorientedsurfaceabmatchaxisline{10v}{\result} % -> \result will be 'v' because 'z=v' in '{10v} \def\pgfplotspointonorientedsurfaceabmatchaxisline#1#2{% @@ -835,11 +1023,17 @@ \let\pgfplots@loc@TMPa=\pgfutil@empty \fi \else - \pgfplots@error{The character '#1' is no valid element for a three-character axis line or surface description!}% + % return TRUE. + % I admit I am not sure at all if this works in all + % cases + \pgfplotspointonorientedsurfaceabmatchaxisline@warn{#1}% \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 @@ -931,7 +1125,17 @@ % % 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}% @@ -943,6 +1147,60 @@ \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 +\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} + % FIXME : this doesn't work if one of the three characters is '2' (for % center) \def\pgfplotspointouternormalvectorofaxis@#1#2#3\relax{% @@ -1032,39 +1290,39 @@ % #5: the shift along the outer unit normal. \def\pgfplotspointoutsideofaxis@#1#2#3\relax#4#5{% \if v#1% - \def\pgfplots@loc@point@orthogonal@to@v{% - \pgfplotspointoutsideofaxis@plug@trafo{x}{#4}\let\pgfplots@loc@TMPa=\pgfmathresult - \pgfplotspointoutsideofaxis@plug@getlimit{y}{#2}\let\pgfplots@loc@TMPb=\pgfmathresult + \pgfplotspointoutsideofaxis@plug@getlimit{y}{#2}\let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@loc@TMPa}{#2}% + % + \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@TMPc=\pgfmathresult + \pgfplotspointoutsideofaxis@plug@getlimit{z}{#3}\let\pgfplots@loc@TMPa=\pgfmathresult \else - \def\pgfplots@loc@TMPc{0}% + \def\pgfplots@loc@TMPa{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}% - }% + \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 \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}% - }% + \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 \fi \fi % @@ -1076,8 +1334,9 @@ % \pgf@process{% \pgfpointadd - {\pgfplots@loc@point@orthogonal@to@v} + {\pgfplotspointonorientedsurfaceab{\pgfplots@loc@A}{\pgfplots@loc@B}} {% + \pgfplotspointouternormalvectorofaxissetv{#1#2#3}{\pgfplots@loc@A}% \pgfqpointscale {\pgfplots@loc@distalong@normal}% {\pgfplotspointouternormalvectorofaxis{#1#2#3}}% @@ -1085,10 +1344,67 @@ }% \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: one of '0', '1' or '2' where +% #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. @@ -1103,29 +1419,65 @@ \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, +} % Installs a rotation transformation matrix such that labels or % whatever are aligned precisely in direction of one of the two/three % coordinate directions. % -% #1: the coordinate direction (one of x,y or z) +% \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 assumes \ifpgfallowupsidedownattime = false and -% \ifpgfresetnontranslationattime = true -\def\pgfplotstransformtoaxisdirection#1{% - \pgftransformresetnontranslations +% 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#1invlength\endcsname}{\csname pgfplotspointunit#1\endcsname}% + \pgfqpointscale{\csname pgfplotsunit#2invlength\endcsname}{\csname pgfplotspointunit#2\endcsname}% % - % do not allow upside down labels: \ifdim\pgf@x<0pt% - \global\pgf@x=-\pgf@x% - \global\pgf@y=-\pgf@y% + % 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% @@ -1136,6 +1488,7 @@ \pgftransformcm% {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}% {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}% + \fi } @@ -1194,6 +1547,10 @@ }% % 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' @@ -1310,31 +1667,48 @@ \pgf@ya=\pgf@y \pgf@pos@transform\pgf@xa\pgf@ya % - \edef\pgfplots@LEQ{% - % solve linear system - {\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@xa}% - {\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@ya}% - }% - % - % apply inverse matrix to right-hand-side (and compute RHS): - \pgf@sh@reanchor{#3}{center}% - \edef\pgfplots@loc@center{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% - \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}% - \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}}% + % 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}% + }% + % + \pgf@sh@reanchor{#3}{center}% + \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}% + \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 + \message{^^JPGFPlots warning: The ticklabel anchor cannot be determined, the normal vector -(\the\pgf@xb,\the\pgf@yb) and the unit #1 vector (\the\pgf@xa,\the\pgf@ya) are almost parallel (abs(cos(angle)) = \the\pgf@xc)!^^J}% + % 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 @@ -1439,13 +1813,38 @@ \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 - \expandafter\pgfplots@extract@plot@box@ratio\pgfplots@loc@TMPa{1}{1}{1}\pgfplots@EOI + % 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}% @@ -1468,7 +1867,7 @@ \pgfmathmultiply@{\cosaz}{\cosel}% \xdef\pgfplots@glob@TMPd{{\pgfmathresultNx}{\pgfmathresult}{\sinel}}% \endgroup -%\message{Setting x,y and z from {#1}{#2} to x = \meaning\pgfplots@glob@TMPa, y = \meaning\pgfplots@glob@TMPb, z = \meaning\pgfplots@glob@TMPc...n = \pgfplots@glob@TMPd.}% +%\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}% @@ -1479,16 +1878,60 @@ }% \expandafter\pgfplots@loc@TMPa\pgfplots@glob@TMPd\relax \def#3{0}% + \pgfplots@scale@plotbox@to@widthheight +}% + +\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 + \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 + \expandafter\ifx\csname pgfplots@view@dir@threedim@x\endcsname\relax + \else + n = (\pgfplots@view@dir@threedim@x,\pgfplots@view@dir@threedim@y,\pgfplots@view@dir@threedim@z),^^J + \fi + unit vector ratio=[\X\space\Y\space 1],^^J}% + \endgroup +}% + +% 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}}% + \let\pgfplots@BB@for@plotbox=\pgfplots@BB@for@plotbox@relative + \let\pgfplots@BB@for@plotbox@compute@post@scales=\pgfplots@BB@for@plotbox@compute@post@scales@relative \expandafter\pgfplots@scaleaxes@to@BB\pgfplots@loc@TMPa -%\message{After scaling: -% x = (\the\pgf@xx,\the\pgf@xy), -% y = (\the\pgf@yx,\the\pgf@yy), -% z = (\the\pgf@zx,\the\pgf@zy).}% -}% +} + + +% A variant of \pgfplots@scale@plotbox@to@widthheight which does not +% use the given x,y,z vectors to define the plot box. Instead, it uses +% the lower and upper axis limits. +\def\pgfplots@scale@axisbox@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}}% + \let\pgfplots@BB@for@plotbox=\pgfplots@BB@for@plotbox@computelimits + \let\pgfplots@BB@for@plotbox@compute@post@scales=\pgfplots@BB@for@plotbox@compute@post@scales@NOP + \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. @@ -1513,10 +1956,27 @@ % - the @veclength and @inverseveclength have been re-scaled as % well. \def\pgfplots@scaleaxes@to@BB#1#2{% - \begingroup - \pgfinterruptboundingbox - % STEP 1: compute the bounding box for UNITS. We just need the - % relative sizes: +%\message{before scaling:}\message@pgfplots@units + \if0\pgfplots@scale@mode@choice + % scale mode=auto + \def\pgfplots@scale@mode@choice{2}% stretch to fill + \fi + \if1\pgfplots@scale@mode@choice + % scale mode=none + \else + \pgfplots@scaleaxes@to@BB@{#1}{#2}% + \fi + % FIXME + % I suppose I should call \pgfplotsgetnormalforcurrentview now? + \pgfplots@computeunitvectorlengths +%\message{after scaling:}\message@pgfplots@units +}% +\def\pgfplots@BB@for@plotbox@relative{% + % We just need the + % relative sizes, i.e. + % "0" == lower axis limit + % "1" == upper axis limit + % \ifpgfplots@threedim \pgfpathmoveto{\pgfqpointxyz000}% \pgfpathmoveto{\pgfqpointxyz001}% @@ -1532,6 +1992,63 @@ \pgfpathmoveto{\pgfqpointxy10}% \pgfpathmoveto{\pgfqpointxy11}% \fi +}% +\let\pgfplots@BB@for@plotbox=\pgfplots@BB@for@plotbox@relative +\def\pgfplots@BB@for@plotbox@compute@post@scales@relative#1#2#3{% + % Consequently, we have to multiply with 1/(max-min): + \pgfmathsubtract@{\pgfplots@xmax}{\pgfplots@xmin}% + % compute 1/(xmax - xmin) in float for more recent versions (see /pgfplots/compat/scaling). + % I observed that it is much more accurate + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{\pgfmathresult}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{op}{reciprocal}{{\pgfmathresult}}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{tofixed}{\pgfmathresult}% + \let#1=\pgfmathresult + % + \pgfmathsubtract@{\pgfplots@ymax}{\pgfplots@ymin}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{\pgfmathresult}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{op}{reciprocal}{{\pgfmathresult}}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{tofixed}{\pgfmathresult}% + \let#2=\pgfmathresult + % + \ifpgfplots@threedim + \pgfmathsubtract@{\pgfplots@zmax}{\pgfplots@zmin}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{\pgfmathresult}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{op}{reciprocal}{{\pgfmathresult}}% + \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{tofixed}{\pgfmathresult}% + \else + \def\pgfmathresult{1}% + \fi + \let#3=\pgfmathresult +}% +\let\pgfplots@BB@for@plotbox@compute@post@scales=\pgfplots@BB@for@plotbox@compute@post@scales@relative +\def\pgfplots@BB@for@plotbox@computelimits{% + \ifpgfplots@threedim + \pgfpathmoveto{\pgfqpointxyz\pgfplots@xmin\pgfplots@ymin\pgfplots@zmin}% + \pgfpathmoveto{\pgfqpointxyz\pgfplots@xmin\pgfplots@ymin\pgfplots@zmax}% + \pgfpathmoveto{\pgfqpointxyz\pgfplots@xmin\pgfplots@ymax\pgfplots@zmin}% + \pgfpathmoveto{\pgfqpointxyz\pgfplots@xmin\pgfplots@ymax\pgfplots@zmax}% + \pgfpathmoveto{\pgfqpointxyz\pgfplots@xmax\pgfplots@ymin\pgfplots@zmin}% + \pgfpathmoveto{\pgfqpointxyz\pgfplots@xmax\pgfplots@ymin\pgfplots@zmax}% + \pgfpathmoveto{\pgfqpointxyz\pgfplots@xmax\pgfplots@ymax\pgfplots@zmin}% + \pgfpathmoveto{\pgfqpointxyz\pgfplots@xmax\pgfplots@ymax\pgfplots@zmax}% + \else + \pgfpathmoveto{\pgfqpointxy\pgfplots@xmin\pgfplots@ymin}% + \pgfpathmoveto{\pgfqpointxy\pgfplots@xmin\pgfplots@ymax}% + \pgfpathmoveto{\pgfqpointxy\pgfplots@xmax\pgfplots@ymin}% + \pgfpathmoveto{\pgfqpointxy\pgfplots@xmax\pgfplots@ymax}% + \fi +}% +\def\pgfplots@BB@for@plotbox@compute@post@scales@NOP#1#2#3{% + \let#1=\pgfutil@empty + \let#2=\pgfutil@empty + \let#3=\pgfutil@empty +}% +\def\pgfplots@scaleaxes@to@BB@#1#2{% + \begingroup + \pgfinterruptboundingbox + % 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 @@ -1541,62 +2058,156 @@ \pgf@ya=#1\relax \pgf@yb=#2\relax %\message{PGFPLOTS: the current unit vectors result in a UNIT BB of (\the\pgf@xa,\the\pgf@xb). Scaling it to (\the\pgf@ya,\the\pgf@yb)...}% - % STEP 2: compute the scales for x and y such - % that the UNIT-BB will have size #1,#2: - \pgfplotsutil@edef@invoke\pgfmathdivide@{% - {\pgf@sys@tonumber\pgf@ya}% - {\pgf@sys@tonumber\pgf@xa}% - }% - % TMPa = scalex - \global\let\pgfplots@glob@TMPa=\pgfmathresult - \pgfplotsutil@edef@invoke\pgfmathdivide@{% - {\pgf@sys@tonumber\pgf@yb}% - {\pgf@sys@tonumber\pgf@xb}% - }% - % TMPb = scaley - \global\let\pgfplots@glob@TMPb=\pgfmathresult + \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 + % Compute individual scaling factors for X and Y + % such that the UNIT-BB will have size #1,#2: + \pgfplotsutil@edef@invoke\pgfmathdivide@{% + {\pgf@sys@tonumber\pgf@ya}% + {\pgf@sys@tonumber\pgf@xa}% + }% + % TMPa = scalex + \global\let\pgfplots@glob@TMPa=\pgfmathresult + \pgfplotsutil@edef@invoke\pgfmathdivide@{% + {\pgf@sys@tonumber\pgf@yb}% + {\pgf@sys@tonumber\pgf@xb}% + }% + % TMPb = scaley + \global\let\pgfplots@glob@TMPb=\pgfmathresult + \global\let\pgfplots@glob@TMPc=\relax + \or + % scale mode=scale uniformly + % compute ONE common scale for both, X and Y. + % + \pgfplotsutil@edef@invoke\pgfmathdivide@{% + {\pgf@sys@tonumber\pgf@ya}% + {\pgf@sys@tonumber\pgf@xa}% + }% + \global\let\pgfplots@glob@TMPa=\pgfmathresult + \global\let\pgfplots@glob@TMPb=\pgfplots@glob@TMPa + \global\let\pgfplots@glob@TMPc=\relax + \ifdim\pgf@zy=0pt + \ifdim\pgf@yx=0pt + \pgfplots@prepare@vertical@rescaling@for@scale@uniformly@in@dir{y}\returninto\pgfplots@glob@TMPc + \else + \pgfplots@error@scale@uniformly@failed + \fi + \else + \ifdim\pgf@zx=0pt + \pgfplots@prepare@vertical@rescaling@for@scale@uniformly@in@dir{z}\returninto\pgfplots@glob@TMPc + \else + \pgfplots@error@scale@uniformly@failed + \fi + \fi + \fi \pgfusepath{discard}% \endpgfinterruptboundingbox \endgroup -%\message{got scalex = \pgfplots@glob@TMPa\space and scaley = \pgfplots@glob@TMPb.}% - \pgfmathsubtract@{\pgfplots@xmax}{\pgfplots@xmin}% - % compute 1/(xmax - xmin) in float. - % I observed that it is much more accurate (lead to scaling differences of up to 10pt!) - \pgfmathfloatparsenumber\pgfmathresult - \pgfmathfloatreciprocal@\pgfmathresult - \pgfmathfloattofixed\pgfmathresult - %\expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% -%\message{and 1/(xmax-xmin) = 1/(\pgfplots@xmax-\pgfplots@xmin) = \pgfmathresult.}% + % Ok, we know the W,H scalings now. + % + % But remember that we have worked with RELATIVE scales up to now. + % We have to convert them now, by interpreting "1 == upper limit" + % and "0 == lower limit" for every direction. + % + \pgfplots@BB@for@plotbox@compute@post@scales{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}% + % + % ok. Now apply all scalings. + % Let's hope all these temporary macros are still valid! +%\message{got scaleW = \pgfplots@glob@TMPa\space and scaleH = \pgfplots@glob@TMPb; scalex=\pgfplots@loc@TMPa, scaley=\pgfplots@loc@TMPb, scalez=\pgfplots@loc@TMPc.}% \pgf@xx=\pgfplots@glob@TMPa\pgf@xx \pgf@xy=\pgfplots@glob@TMPb\pgf@xy - \pgf@xx=\pgfmathresult\pgf@xx - \pgf@xy=\pgfmathresult\pgf@xy + \pgf@xx=\pgfplots@loc@TMPa\pgf@xx + \pgf@xy=\pgfplots@loc@TMPa\pgf@xy % - \pgfmathsubtract@{\pgfplots@ymax}{\pgfplots@ymin}% - \pgfmathfloatparsenumber\pgfmathresult - \pgfmathfloatreciprocal@\pgfmathresult - \pgfmathfloattofixed\pgfmathresult - %\expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% -%\message{and 1/(ymay-ymin) = 1/(\pgfplots@ymax-\pgfplots@ymin) = \pgfmathresult.}% \pgf@yx=\pgfplots@glob@TMPa\pgf@yx \pgf@yy=\pgfplots@glob@TMPb\pgf@yy - \pgf@yx=\pgfmathresult\pgf@yx - \pgf@yy=\pgfmathresult\pgf@yy + \pgf@yx=\pgfplots@loc@TMPb\pgf@yx + \pgf@yy=\pgfplots@loc@TMPb\pgf@yy % \ifpgfplots@threedim - \pgfmathsubtract@{\pgfplots@zmax}{\pgfplots@zmin}% - \pgfmathfloatparsenumber\pgfmathresult - \pgfmathfloatreciprocal@\pgfmathresult - \pgfmathfloattofixed\pgfmathresult - %\expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% -%\message{and 1/(zmaz-zmin) = 1/(\pgfplots@zmax-\pgfplots@zmin) = \pgfmathresult.}% \pgf@zx=\pgfplots@glob@TMPa\pgf@zx \pgf@zy=\pgfplots@glob@TMPb\pgf@zy - \pgf@zx=\pgfmathresult\pgf@zx - \pgf@zy=\pgfmathresult\pgf@zy - \fi - \pgfplots@computeunitvectorlengths -}% + \pgf@zx=\pgfplots@loc@TMPc\pgf@zx + \pgf@zy=\pgfplots@loc@TMPc\pgf@zy + \fi + \pgfplots@glob@TMPc +}% + +\def\pgfplots@error@scale@uniformly@failed{% + \pgfplots@error{Sorry, 'scale uniformly' failed because its actual implementation works only if y_x = 0 (for 2d axes) or if z_x = 0 (for 3d axes). The result will not fill the prescribed dimensions. For 2d axes, you may also want to consider the 'unit vector ratio' key}% +}% +\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 \pgfplots@glob@TMPa = \pgfplots@glob@TMPb). + % Let's call it "s". + % + % Consequently, a uniform scaling by "s" leads 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. + % + % In my opinion the ONLY way to achieve this goal is to + % modify axis limits for an axis whose unit vector is + % parallel to the canvas y axis, i.e. e_i = (0,*). To see + % this, remember that a rescaling of the other limits will + % also modify the width. + % + % 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 = \pgfplots@glob@TMPa + % and + % \pgfplots@glob@TMPa * \pgf@xb = s*h + % + \pgf@xc=\csname pgfplots@#1max\endcsname\csname pgf@#1y\endcsname% FIXME : what if we are working with relative coords? + \advance\pgf@xc by -\csname pgfplots@#1min\endcsname\csname pgf@#1y\endcsname + % + \advance\pgf@xb by-\pgf@xc + \pgf@xb=\pgfplots@glob@TMPa\pgf@xb + \advance\pgf@yb by-\pgf@xb + \pgf@xb=\pgfplots@glob@TMPa\pgf@xc + \pgfplotsutil@edef@invoke\pgfmathdivide@{% + {\pgf@sys@tonumber\pgf@yb}% + {\pgf@sys@tonumber\pgf@xb}% + }% + % 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: + \xdef#2{% + \noexpand\pgfplots@apply@unit@vector@rescale@keep@size{#1}{\pgfmathresult}% + }% +} \def\pgfplots@computeunitvectorlengths{% \pgfplotsutil@edef@invoke\pgfmathveclen@{% @@ -1641,6 +2252,746 @@ \fi }% +% Defines \pgfplots@view@dir@threedim@[xyz] 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 on the 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. +% +% 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 + \xdef\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 + \def\pgfplots@loc@TMPb##1##2{% + \xdef\pgfplots@view@dir@threedim@x{##1}% + \xdef\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 + % + \ifdim\pgf@xy>0pt + \ifdim\pgf@yy<0pt + \def\pgfplots@scale{-1}% + \fi + \fi + % + \fi + \else + \ifdim\pgf@xx<0pt + \ifdim\pgf@yx<0pt + % + \ifdim\pgf@xy<0pt + \ifdim\pgf@yy>0pt + \def\pgfplots@scale{-1}% + \fi + \fi + % + \fi + \fi + \fi + \ifdim\pgf@xy>0pt + \ifdim\pgf@yy>0pt + % + \ifdim\pgf@xx<0pt + \ifdim\pgf@yx>0pt + \def\pgfplots@scale{-1}% + \fi + \fi + % + \fi + \else + \ifdim\pgf@xy<0pt + \ifdim\pgf@yy<0pt + % + \ifdim\pgf@xx>0pt + \ifdim\pgf@yx<0pt + \def\pgfplots@scale{-1}% + \fi + \fi + % + \fi + \fi + \fi + \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@x}% + \global\let\pgfplots@view@dir@threedim@x\pgfmathresult + \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@y}% + \global\let\pgfplots@view@dir@threedim@y\pgfmathresult + \pgfmathmultiply@{\pgfplots@scale}{\pgfplots@view@dir@threedim@z}% + \global\let\pgfplots@view@dir@threedim@z\pgfmathresult + \endgroup + \else + \def\pgfplots@loc@TMPb##1##2##3{% + \xdef\pgfplots@view@dir@threedim@x{##1}% + \xdef\pgfplots@view@dir@threedim@y{##2}% + \xdef\pgfplots@view@dir@threedim@z{##3}% + }% + \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPc + \fi +%\message{\string\pgfplotsgetnormalforcurrentview: got (\pgfplots@view@dir@threedim@x,\pgfplots@view@dir@threedim@y,\pgfplots@view@dir@threedim@z)^^J}% +}% + +% ================================================================================== +% +% 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=\pgfmathparse{##1}, + parsenumber=\pgfmathfloatparsenumber{##1}\pgfmathfloattofixed{##1},% + zero= \pgfplotscoordmath{\pgfplotscoordmathid}{parsenumber}{0}, + 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 ##2\else ##3\fi + \else + \if##2+\ifdim##1pt>0pt ##2\else ##3\fi + \else + \if##2-\ifdim##1pt<0pt ##2\else ##3\fi + \else + \def\pgfplots@loc@TMPd{##1}\ifx\pgfplots@loc@TMPd\pgfutil@empty ##2\else ##3\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{{}{}}, + 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 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}},% + % + % 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}},% + % + % 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 required + % for 'datascaletrafo set params'. + 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) + % + \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 + }% + \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}}% + }% +}% + +\pgfplotsdeclarecoordmath{pgfbasic}{% + parsenumber=\pgfmathfloatparsenumber{#1}\pgfmathfloattofixed\pgfmathresult, + suffix=@basic@, + zero=\def\pgfmathresult{0}, + 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}\pgfmathparse{#1}\pgfmath@smuggleone\pgfmathresult\endgroup, + zero=\pgfmathfloatcreate{0}{0.0}{0},% + one=\pgfmathfloatcreate{1}{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\pgfmathresult{% + {\csname pgfplots@data@scale@trafo@EXPONENT@\pgfplotscoordmathid\endcsname}% + {\csname pgfplots@data@scale@trafo@SHIFT@\pgfplotscoordmathid\endcsname}% + }% + },% + 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. @@ -1654,59 +3005,55 @@ % Expands to the current value of 'point meta'. \def\pgfplotspointmetainputhandler{} +\def\pgfplotsaxisifhaspointmeta#1#2{% + \ifx\pgfplotspointmetainputhandler\pgfutil@empty #2\else #1\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: -% - \csname pgfpmeta@#1@assign\endcsname{} -% 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 -% -% - \csname pgfpmeta@#1@issymbolic\endcsname -> 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' -% -% - \csname pgfpmeta@#1@explicitinput\endcsname -> expands to either -% '1' or '0'. In case '1', it expects explicit input from the -% coordinate input routines. For example, 'plot file' will look for -% further input after the x,y,z coordinates. -% Default is '0' -% -% - \csname pgfpmeta@#1@initfor\endcsname##1{....} -% a macro used to initialise the point meta source when it is -% selected. -% This macro body is invoked by pgfplots when someone types -% 'point meta=x' -> will invoke 'pgfpmeta@x@initfor{}'. -% The first argument to initfor can be supplied by the user. -% PRECONDITION for 'initfor': -% - it will be invoked just before -% '\pgfplotspointmetainputhandler' will be changed. -% Default is to do nothing. +% 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 @@ -1722,16 +3069,66 @@ \pgfqkeys{/pgfplots/@declare point meta src}{#2}% }% \pgfqkeys{/pgfplots/@declare point meta src}{% - assign/.code= - {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @assign\endcsname{#1}},% + % + % a macro used to initialise the point meta source when it is + % selected. + % This macro body is invoked by pgfplots when someone types + % 'point meta=x' -> will invoke 'pgfpmeta@x@initfor{}'. + % The first argument to initfor can be supplied by the user. + % PRECONDITION for 'initfor': + % - it will be invoked just before + % '\pgfplotspointmetainputhandler' will be changed. + % Default is to do nothing. 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}},% }% @@ -1741,31 +3138,25 @@ \pgfplotsdeclarepointmetasource{}{} \pgfplotsdeclarepointmetasource{x}{assign={% \let\pgfplots@current@point@meta=\pgfplots@current@point@x - \ifpgfplots@xislinear - \else - \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% - \let\pgfplots@current@point@meta=\pgfmathresult - \fi}} + \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}% + \let\pgfplots@current@point@meta=\pgfmathresult + }} \pgfplotsdeclarepointmetasource{y}{assign={% \let\pgfplots@current@point@meta=\pgfplots@current@point@y - \ifpgfplots@yislinear - \else - \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% - \let\pgfplots@current@point@meta=\pgfmathresult - \fi}} + \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}% + \let\pgfplots@current@point@meta=\pgfmathresult + }} \pgfplotsdeclarepointmetasource{z}{assign={% \let\pgfplots@current@point@meta=\pgfplots@current@point@z - \ifpgfplots@zislinear - \else - \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% - \let\pgfplots@current@point@meta=\pgfmathresult - \fi}} + \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}% + \let\pgfplots@current@point@meta=\pgfmathresult + }} \pgfplotsdeclarepointmetasource{explicit}{% assign={% \ifx\pgfplots@current@point@meta\pgfutil@empty \else - \pgfmathfloatparsenumber{\pgfplots@current@point@meta}% + \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}% \let\pgfplots@current@point@meta=\pgfmathresult \fi }, @@ -1785,6 +3176,7 @@ \ifx\pgfplots@loc@TMPa\pgfutil@empty \else \pgfmathparse{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{meta}{parsenumber}{\pgfmathresult}% \let\pgfplots@current@point@meta=\pgfmathresult \fi },% @@ -1813,13 +3205,12 @@ }, }% - \pgfplotsdeclarepointmetasource{TeX code}{% assign={% \begingroup \let\pgfplotspointmeta=\pgfutil@empty \pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/code/.@cmd}{}% - \pgfmathfloatparsenumber{\pgfplotspointmeta}% + \pgfplotscoordmath{meta}{parsenumber}{\pgfplotspointmeta}% \let\pgfplots@current@point@meta=\pgfmathresult \pgfmath@smuggleone\pgfplots@current@point@meta \endgroup @@ -1859,15 +3250,7 @@ % copy operations. That experiment was not successfull (it was not % faster :-( ). However, the streaming methods still assign their % things globally... -\newif\ifpgfplots@coord@stream@isfirst \def\pgfplots@coord@stream@start{% - \global\pgfplots@coord@stream@isfirsttrue - \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 \let\pgfplots@current@point@x=\pgfutil@empty \let\pgfplots@current@point@y=\pgfutil@empty \let\pgfplots@current@point@z=\pgfutil@empty @@ -1888,15 +3271,24 @@ % \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 results all % others to be reset as well. \else - \ifpgfplots@coord@stream@isfirst + \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 - \global\pgfplots@coord@stream@isfirstfalse \fi \global\let\pgfplots@currentplot@lastcoord@x=\pgfplots@current@point@x \global\let\pgfplots@currentplot@lastcoord@y=\pgfplots@current@point@y @@ -1906,34 +3298,54 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Scanline management. The idea is to allow a simple syntax -% to provide matrix input - by means of scanlines. +% 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 following methods allow to update the scanline computation. +% 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. @@ -1942,13 +3354,72 @@ % 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 + \noexpand\pgfplotsplothandlernotifyscanlinecomplete + }% + \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 \def\pgfplots@scanlinelength{-1}% } -\def\pgfplotsscanlinelengthincrease{% +\def\pgfplotsscanlinelength@scanline@increase{% \advance\c@pgfplots@scanlineindex by1 } -\def\pgfplotsscanlinecomplete{% +\def\pgfplotsscanlinelength@scanline@complete{% \ifnum\pgfplots@scanlinelength>0 \ifnum\c@pgfplots@scanlineindex=0 % @@ -1973,7 +3444,7 @@ \fi \c@pgfplots@scanlineindex=0 } -\def\pgfplotsscanlinelengthcleanup{% +\def\pgfplotsscanlinelength@scanline@cleanup{% \ifnum\c@pgfplots@scanlineindex=0 % I assume the last scan line is already complete. \else @@ -1981,12 +3452,58 @@ \fi \let\pgfplotsscanlinelength=\pgfplots@scanlinelength } -\def\pgfplotsscanlinedisablechanges{% - \let\pgfplotsscanlinecomplete=\relax - \let\pgfplotsscanlinelengthincreas=\relax - \let\pgfplotsscanlinelengthcleanup=\relax - \let\pgfplotsscanlinelengthinitzero=\relax +% ------------------------------------------------------------------------------- +% +% 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 + \pgfplotsifinaxis{}{\let\pgfplotsaxisserializedatapoint=\relax}% +}% +\def\pgfplotsscanlinelength@nan@increase{% + \def\pgfplotsscanlinelength@nan@isfirst{0}% + \pgfplotsscanlinelength@nan@pendingwork +}% +\def\pgfplotsscanlinelength@nan@complete{% + \if1\pgfplotsscanlinelength@nan@isfirst + \else + \def\pgfplotsscanlinelength@nan@pendingwork{% + % 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 + % + \let\pgfplotsscanlinelength@nan@pendingwork=\relax + }% + \fi + \def\pgfplotsscanlinelength@nan@isfirst{1}% }% +\let\pgfplotsscanlinelength@nan@cleanup=\relax +% +% ------------------------------------------------------------------------------- + + +\def\pgfplotsaxisfilteredcoordsaway{0}% +\def\pgfplotsaxisplothasjumps{0}% +\newif\ifpgfplotsaxisparsecoordinateok % Initialises % \pgfplots@coord@stream@start @@ -2046,235 +3563,26 @@ % 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}% % + \ifpgfplots@curplot@threedim + \let\pgfplotsaxisupdatelimitsforcoordinate=\pgfplotsaxisupdatelimitsforcoordinatethreedim + \let\pgfplotsaxisparsecoordinate=\pgfplotsaxisparsecoordinatethreedim + \else + \let\pgfplotsaxisupdatelimitsforcoordinate=\pgfplotsaxisupdatelimitsforcoordinatetwodim + \let\pgfplotsaxisparsecoordinate=\pgfplotsaxisparsecoordinatetwodim + \fi \begingroup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \let\E=\noexpand % - % Setup Just-In-Time-Macro Compilation: - % I compile a set of macros which is highly optimized for this - % particular plot. - % - % 1.\pgfplots@update@limits@for@one@point - % 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 may be given in floating point format, see - % below. - % - % 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: - % \pgfplots@current@point@[xyz] - \xdef\pgfplots@update@limits@for@one@point{% -%\E\tracingmacros=2\E\tracingcommands=2 -%\E\pgfplots@message{Updating limits for (\E\pgfplots@current@point@x,\E\pgfplots@current@point@y) ...}% - % - % 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 - \ifpgfplots@autocompute@xmin - \else - \ifpgfplots@xislinear - \E\pgfmathfloatlessthan@{\E\pgfplots@current@point@x}{\E\pgfplots@xmin}% - \E\ifpgfmathfloatcomparison - \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue - \E\fi - \else - \E\pgfplotsmathlessthan{\E\pgfplots@current@point@x}{\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}{\E\pgfplots@current@point@x}% - \E\ifpgfmathfloatcomparison - \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue - \E\fi - \else - \E\pgfplotsmathlessthan{\E\pgfplots@xmax}{\E\pgfplots@current@point@x}% - \E\ifpgfmathfloatcomparison - \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue - \E\fi - \fi - \fi - \ifpgfplots@autocompute@ymin - \else - \ifpgfplots@yislinear - \E\pgfmathfloatlessthan@{\E\pgfplots@current@point@y}{\E\pgfplots@ymin}% - \E\ifpgfmathfloatcomparison - \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue - \E\fi - \else - \E\pgfplotsmathlessthan{\E\pgfplots@current@point@y}{\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}{\E\pgfplots@current@point@y}% - \E\ifpgfmathfloatcomparison - \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue - \E\fi - \else - \E\pgfplotsmathlessthan{\E\pgfplots@ymax}{\E\pgfplots@current@point@y}% - \E\ifpgfmathfloatcomparison - \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue - \E\fi - \fi - \fi - \ifpgfplots@curplot@threedim - \ifpgfplots@autocompute@zmin - \else - \ifpgfplots@zislinear - \E\pgfmathfloatlessthan@{\E\pgfplots@current@point@z}{\E\pgfplots@zmin}% - \E\ifpgfmathfloatcomparison - \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue - \E\fi - \else - \E\pgfplotsmathlessthan{\E\pgfplots@current@point@z}{\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}{\E\pgfplots@current@point@z}% - \E\ifpgfmathfloatcomparison - \E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue - \E\fi - \else - \E\pgfplotsmathlessthan{\E\pgfplots@zmax}{\E\pgfplots@current@point@z}% - \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}{\E\pgfplots@current@point@x}% - \E\global\E\let\E\pgfplots@xmin=\E\pgfmathresult - \else - \E\pgfplotsmathmin{\E\pgfplots@xmin}{\E\pgfplots@current@point@x}% - \E\global\E\let\E\pgfplots@xmin=\E\pgfmathresult - \fi - \fi - \ifpgfplots@autocompute@xmax - \ifpgfplots@xislinear - \E\pgfplotsmathfloatmax{\E\pgfplots@xmax}{\E\pgfplots@current@point@x}% - \E\global\E\let\E\pgfplots@xmax=\E\pgfmathresult - \else - \E\pgfplotsmathmax{\E\pgfplots@xmax}{\E\pgfplots@current@point@x}% - \E\global\E\let\E\pgfplots@xmax=\E\pgfmathresult - \fi - \fi - \ifpgfplots@autocompute@ymin - \ifpgfplots@yislinear - \E\pgfplotsmathfloatmin{\E\pgfplots@ymin}{\E\pgfplots@current@point@y}% - \E\global\E\let\E\pgfplots@ymin=\E\pgfmathresult - \else - \E\pgfplotsmathmin{\E\pgfplots@ymin}{\E\pgfplots@current@point@y}% - \E\global\E\let\E\pgfplots@ymin=\E\pgfmathresult - \fi - \fi - \ifpgfplots@autocompute@ymax - \ifpgfplots@yislinear - \E\pgfplotsmathfloatmax{\E\pgfplots@ymax}{\E\pgfplots@current@point@y}% - \E\global\E\let\E\pgfplots@ymax=\E\pgfmathresult - \else - \E\pgfplotsmathmax{\E\pgfplots@ymax}{\E\pgfplots@current@point@y}% - \E\global\E\let\E\pgfplots@ymax=\E\pgfmathresult - \fi - \fi - \ifpgfplots@curplot@threedim - \ifpgfplots@autocompute@zmin - \ifpgfplots@zislinear - \E\pgfplotsmathfloatmin{\E\pgfplots@zmin}{\E\pgfplots@current@point@z}% - \E\global\E\let\E\pgfplots@zmin=\E\pgfmathresult - \else - \E\pgfplotsmathmin{\E\pgfplots@zmin}{\E\pgfplots@current@point@z}% - \E\global\E\let\E\pgfplots@zmin=\E\pgfmathresult - \fi - \fi - \ifpgfplots@autocompute@zmax - \ifpgfplots@zislinear - \E\pgfplotsmathfloatmax{\E\pgfplots@zmax}{\E\pgfplots@current@point@z}% - \E\global\E\let\E\pgfplots@zmax=\E\pgfmathresult - \else - \E\pgfplotsmathmax{\E\pgfplots@zmax}{\E\pgfplots@current@point@z}% - \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}{\E\pgfplots@current@point@x}% - \E\global\E\let\E\pgfplots@data@xmin=\E\pgfmathresult - \E\pgfplotsmathfloatmax{\E\pgfplots@data@xmax}{\E\pgfplots@current@point@x}% - \E\global\E\let\E\pgfplots@data@xmax=\E\pgfmathresult - \fi - \ifpgfplots@yislinear - \E\pgfplotsmathfloatmin{\E\pgfplots@data@ymin}{\E\pgfplots@current@point@y}% - \E\global\E\let\E\pgfplots@data@ymin=\E\pgfmathresult - \E\pgfplotsmathfloatmax{\E\pgfplots@data@ymax}{\E\pgfplots@current@point@y}% - \E\global\E\let\E\pgfplots@data@ymax=\E\pgfmathresult - \fi - \ifpgfplots@curplot@threedim - \ifpgfplots@zislinear - \E\pgfplotsmathfloatmin{\E\pgfplots@data@zmin}{\E\pgfplots@current@point@z}% - \E\global\E\let\E\pgfplots@data@zmin=\E\pgfmathresult - \E\pgfplotsmathfloatmax{\E\pgfplots@data@zmax}{\E\pgfplots@current@point@z}% - \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 - }% -%\message{Assembled update-limits \ifpgfplots@curplot@threedim 3D\else 2D\fi macro to {\meaning\pgfplots@update@limits@for@one@point}}% +%\message{Assembled update-limits \ifpgfplots@curplot@threedim 3D\else 2D\fi macro to {\meaning\pgfplotsaxisupdatelimitsforcoordinate}}% \ifpgfplots@bb@isactive \else % we are inside of @@ -2282,205 +3590,107 @@ % .. % \endpgfinterruptboundingbox % -> don't change data limits! - \global\let\pgfplots@update@limits@for@one@point=\relax + \gdef\pgfplotsaxisupdatelimitsforcoordinate##1##2##3{}% \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % - % This here is the MAIN code of \pgfplots@process@one@point . - % It is inserted below into the right, into one of two prepared - % places. - \def\pgfplots@loc@surveypoint{% - \ifpgfplots@apply@datatrafo - \ifpgfplots@datascaletrafo@initialised - % apply data transformation directly. - \ifpgfplots@apply@datatrafo@x - \E\pgfplots@datascaletrafo@x\E\pgfplots@current@point@x - \E\let\E\pgfplots@current@point@x=\E\pgfmathresult - \fi - \ifpgfplots@apply@datatrafo@y - \E\pgfplots@datascaletrafo@y\E\pgfplots@current@point@y - \E\let\E\pgfplots@current@point@y=\E\pgfmathresult - \fi - \ifpgfplots@curplot@threedim - \ifpgfplots@apply@datatrafo@z - \E\pgfplots@datascaletrafo@z\E\pgfplots@current@point@z - \E\let\E\pgfplots@current@point@z=\E\pgfmathresult - \fi - \fi - \fi - \fi - % All following routines (limit updating/stacking/error - % bars) will use float numerics if necessary (controlled - % by ifs). - \ifpgfplots@stackedmode - \E\pgfplots@stacked@preparepoint@inmacro% - \ifpgfplots@datascaletrafo@initialised% is also true if there is no scale trafo. - \E\pgfplots@stacked@finishpoint - \else - % the finishpoint routine will be invoked at - % \endaxis. - \fi - \fi - % - % Prepare \pgfplots@current@point@meta (see the preparation - % routine above): - \E\pgfplots@set@perpointmeta - % - % update also axis / data limits: - % Arguments: \pgfplots@current@point@[xy] - \E\pgfplots@update@limits@for@one@point - \ifpgfplots@errorbars@enabled - % This thing gets the 'current@point@...' context, - % that means - % \pgfplots@current@point@[xy] - % \pgfplots@current@point@[xy]@error - % \pgfplots@current@point@[xy]@unfiltered - \E\pgfplots@PREPARE@errorbar@process@x% - \E\pgfplots@PREPARE@errorbar@process@y% - \E\pgfplots@PREPARE@errorbar@process@z% - \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 + % + % 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 - \fi - % - }% - \def\pgfplots@loc@performserizalization{% - % Store normalized point for list: - % We need - % xi,yi,zi,mi; - % where zi and mi may be empty. mi is the per-point meta - % information. It is used for per-coordinate marker - % modifications (like colormaps for scatter plots). - \E\edef\E\pgfplots@loc@TMPa{\E\pgfplots@current@point@x,\E\pgfplots@current@point@y,\E\pgfplots@current@point@z,\E\pgfplots@current@point@meta;}% - \E\expandafter\E\pgfplotsapplistXXpushback\E\expandafter{\E\pgfplots@loc@TMPa}% + \E\fi }% - % The following code assembles the command which is executed for - % each coordinate. % - % To eliminate all those case distinctions, it is created with - % 'edef' and a lot of '\noexpand' calls here: + % A macro which should be called once for every data point during the + % survey phase. % - % Arguments: - % \pgfplots@current@point@[xyz] - % \pgfplots@current@point@[xyz]@error (if in argument list) - \xdef\pgfplots@process@one@point{% - % These things are necessary for error bars 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@prepare@xcoord{\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\pgfplots@prepare@ycoord{\E\pgfplots@current@point@y}% - \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{y}% - \E\let\E\pgfplots@current@point@y=\E\pgfmathresult - % - \ifpgfplots@curplot@threedim - \E\pgfplots@prepare@zcoord{\E\pgfplots@current@point@z}% - \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{z}% - \E\let\E\pgfplots@current@point@z=\E\pgfmathresult - \fi - % - \E\pgfplots@invoke@filter@xyz - % - \ifpgfplots@xislinear - % NOTE: this handling of unbounded coords in the case of - % LOG coords is performed directly by - % \pgfplots@prepare@ycoord! - \E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty - \E\else - \E\pgfmathfloatparsenumber{\E\pgfplots@current@point@x}% - \E\expandafter\E\pgfmathfloat@decompose@F\E\pgfmathresult\E\relax\E\c@pgf@counta - \E\ifnum\E\c@pgf@counta>2 % this clears nan, inf and -inf points. - \E\let\E\pgfplots@current@point@x=\E\pgfutil@empty - \E\def\E\pgfplots@unbounded@dir{x}% - \E\else - \E\let\E\pgfplots@current@point@x=\E\pgfmathresult - \E\fi - \E\fi - \fi - % - \ifpgfplots@yislinear - \E\ifx\E\pgfplots@current@point@y\E\pgfutil@empty - \E\else - \E\pgfmathfloatparsenumber{\E\pgfplots@current@point@y}% - \E\expandafter\E\pgfmathfloat@decompose@F\E\pgfmathresult\E\relax\E\c@pgf@counta - \E\ifnum\E\c@pgf@counta>2 - \E\let\E\pgfplots@current@point@y=\E\pgfutil@empty - \E\def\E\pgfplots@unbounded@dir{y}% - \E\else - \E\let\E\pgfplots@current@point@y=\E\pgfmathresult - \E\fi - \E\fi - \fi - % - \ifpgfplots@curplot@threedim + % 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). % - \ifpgfplots@zislinear - \E\ifx\E\pgfplots@current@point@z\E\pgfutil@empty - \E\else - \E\pgfmathfloatparsenumber{\E\pgfplots@current@point@z}% - \E\expandafter\E\pgfmathfloat@decompose@F\E\pgfmathresult\E\relax\E\c@pgf@counta - \E\ifnum\E\c@pgf@counta>2 - \E\let\E\pgfplots@current@point@z=\E\pgfutil@empty - \E\def\E\pgfplots@unbounded@dir{z}% + % Prepare \pgfplots@current@point@meta (see the preparation + % routine above): + \E\pgfplots@set@perpointmeta + % + \ifpgfplots@errorbars@enabled + % This thing gets the 'current@point@...' context, + % that means + % \pgfplots@current@point@[xy] + % \pgfplots@current@point@[xy]@error + % \pgfplots@current@point@[xy]@unfiltered + \E\pgfplots@PREPARE@errorbar@process@x% + \E\pgfplots@PREPARE@errorbar@process@y% + \E\pgfplots@PREPARE@errorbar@process@z% + \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\let\E\pgfplots@current@point@z=\E\pgfmathresult + \E\t@pgfplots@tokc=\E\expandafter{\E\pgfplots@firstplot@coords@x,}% \E\fi - \E\fi - \fi - \fi - % - % check if coordinates are bounded: - \E\pgfplots@loc@tmptrue - \E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty - \E\pgfplots@loc@tmpfalse - \E\else - \E\ifx\E\pgfplots@current@point@y\E\pgfutil@empty - \E\pgfplots@loc@tmpfalse - \E\else - \ifpgfplots@curplot@threedim - \E\ifx\E\pgfplots@current@point@z\E\pgfutil@empty - \E\pgfplots@loc@tmpfalse + \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 - \E\fi - \E\fi - % - \E\ifpgfplots@loc@tmp - % coordinate is bounded AND non-empty, ok. - % insert the main 2d/3d code here: - \pgfplots@loc@surveypoint - \pgfplots@loc@performserizalization + \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 @@ -2488,6 +3698,7 @@ % 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) @@ -2502,6 +3713,7 @@ \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) @@ -2509,7 +3721,8 @@ }% \fi \E\else - \pgfplots@loc@performserizalization + \E\def\E\pgfplotsaxisplothasjumps{1}% + \E\pgfplotsaxisserializedatapoint \E\fi \fi \E\fi @@ -2517,13 +3730,21 @@ % increase \pgfplots@current@point@coordindex: \E\advance\E\c@pgfplots@coordindex by1 }% + % + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endgroup -%\message{Prepared macro \string\pgfplots@update@limits@for@one@point: {\meaning\pgfplots@update@limits@for@one@point}}% + % + \def\pgfplotsaxissurveysetpointmeta{\pgfplots@set@perpointmeta}% + % +%\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@ - \let\pgfplots@coord@stream@coord@=\pgfplots@process@one@point + \def\pgfplots@coord@stream@coord@{% + \def\pgfplots@set@perpointmeta@done{0}% + \pgfplotsplothandlersurveypoint + }% \def\pgfplots@coord@stream@end@{\pgfplots@PREPARE@COORD@STREAM@end@{#1}}% }% @@ -2539,6 +3760,16 @@ % optimized 'applistXX' structure: \pgfplotsapplistXXnewempty % + \csname pgfpmeta@\pgfplotspointmetainputhandler @activate\endcsname + \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}% + % + \pgfplots@prepare@visualization@dependencies % \ifpgfplots@errorbars@enabled % prepare error bar processing. @@ -2577,17 +3808,21 @@ \pgfplotsmathdeclarepseudoconstant{meta}{% \let\pgfmathresult=\pgfplots@current@point@meta \ifx\pgfmathresult\pgfutil@empty - \pgfmathfloatcreate{0}{0.0}{0}% + \pgfplotscoordmath{meta}{parsenumber}{0}% \fi }% - \csname pgfpmeta@\pgfplotspointmetainputhandler @activate\endcsname % % %%%%%%%%%%%%%% % % Define \pgfplots@set@perpointmeta properly: \def\pgfplots@set@perpointmeta{% - \csname pgfpmeta@\pgfplotspointmetainputhandler @assign\endcsname + \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! @@ -2597,37 +3832,43 @@ \ifx\pgfplots@metamin\pgfutil@empty \global\let\pgfplots@metamin=\pgfplots@invalidrange@metamin \t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb - \pgfplotsmathfloatmin{\pgfplots@metamin}{\pgfplots@current@point@meta}% + \pgfplotscoordmath{meta}{min}{\pgfplots@metamin}{\pgfplots@current@point@meta}% \global\let\pgfplots@metamin=\pgfmathresult }% \else - \pgfmathfloatparsenumber{\pgfplots@metamin}% + \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 - \pgfplotsmathfloatmax{\pgfplots@metamax}{\pgfplots@current@point@meta}% + \pgfplotscoordmath{meta}{max}{\pgfplots@metamax}{\pgfplots@current@point@meta}% \global\let\pgfplots@metamax=\pgfmathresult }% \else - \pgfmathfloatparsenumber{\pgfplots@metamax}% + \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@metamax}% \global\let\pgfplots@metamax=\pgfmathresult \fi % - \t@pgfplots@toka=\expandafter{\pgfplots@set@perpointmeta}% - \edef\pgfplots@set@perpointmeta{% - \the\t@pgfplots@toka + \edef\pgfplots@set@perpointmeta@limits{% \noexpand\ifx\noexpand\pgfplots@current@point@meta\noexpand\pgfutil@empty \noexpand\else \the\t@pgfplots@tokb \noexpand\fi }% + \def\pgfplotsaxisupdatelimitsforpointmeta##1{% + \begingroup + \def\pgfplots@current@point@meta{##1}% + \pgfplots@set@perpointmeta@limits + \endgroup + }% \else % there is no point meta: \global\let\pgfplots@metamin=\pgfutil@empty \global\let\pgfplots@metamax=\pgfutil@empty + \let\pgfplots@set@perpointmeta@limits=\relax + \def\pgfplotsaxisupdatelimitsforpointmeta##1{}% \fi }% % This is the \pgfplots@coord@stream@end@ routine which is invoked by @@ -2644,14 +3885,17 @@ % % #1,#2: see \pgfplots@PREPARE@COORD@STREAM \def\pgfplots@PREPARE@COORD@STREAM@end@#1{% + \pgfkeysvalueof{/pgfplots/execute at end survey}% + \pgfkeyssetvalue{/pgfplots/mesh/num points}{\pgfplots@current@point@coordindex}% + \pgfplotsplothandlersurveyend \ifx\pgfplots@metamin\pgfutil@empty \else \if\pgfplots@axiswide@metamin@autocompute1% - \pgfplotsmathfloatmin{\pgfplots@axiswide@metamin}{\pgfplots@metamin}% + \pgfplotscoordmath{meta}{min}{\pgfplots@axiswide@metamin}{\pgfplots@metamin}% \global\let\pgfplots@axiswide@metamin=\pgfmathresult \fi \if\pgfplots@axiswide@metamax@autocompute1% - \pgfplotsmathfloatmax{\pgfplots@axiswide@metamax}{\pgfplots@metamax}% + \pgfplotscoordmath{meta}{max}{\pgfplots@axiswide@metamax}{\pgfplots@metamax}% \global\let\pgfplots@axiswide@metamax=\pgfmathresult \fi \fi @@ -2677,7 +3921,7 @@ \ifpgfplots@stackedmode \pgfplots@stacked@endplot \fi - \ifpgfplots@coord@stream@isfirst + \ifx\pgfplots@currentplot@firstcoord@x\pgfutil@empty \pgfplots@warning{the current plot has no coordinates (or all have been filtered away)}% \else % Idea: use @@ -2688,10 +3932,12 @@ % to share plot specifications between error bars and plot % coordinates. Unfortunately, it is NOT sufficient to use % \tikzset - \pgfkeyssetvalue{/pgfplots/mesh/num points}{\pgfplots@current@point@coordindex}% \pgfplotspreparemeshkeydefaults% \pgfplots@PREPARE@COORD@STREAM@end@determinecoordsorting x% \pgfplots@PREPARE@COORD@STREAM@end@determinecoordsorting y% + \t@pgfplots@tokc=\expandafter{\pgfplots@addplot@survey@@optionlist,% + /pgfplots/.cd,/pgfplots/every axis plot post}% + \edef\pgfplots@addplot@survey@@optionlist{\the\t@pgfplots@tokc}% \ifpgfplots@curplot@isirrelevant % for \label commands: \expandafter\pgfplots@rememberplotspec@for@label\expandafter{\pgfplots@addplot@survey@@optionlist}% @@ -2703,12 +3949,8 @@ \t@pgfplots@toka=\expandafter{\pgfplots@addplot@survey@@optionlist}% % ATTENTION: do NOT call list macros from here on! % - \ifpgfplots@datascaletrafo@initialised - \pgfplots@addplot@get@named@startendpoints@command\pgfplots@loc@TMPa - \t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}% - \else - \t@pgfplots@tokc={}% - \fi + \pgfplotsplothandlerserializestateto\pgfplots@loc@TMPa + \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}% % SERIALIZE RESULT: % % everything which has been accumulated so far (including the @@ -2745,18 +3987,21 @@ \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}}% % \noexpand\pgfplots@initzerolevelhandler - \the\t@pgfplots@tokc% named start/end points (if already available) \noexpand\pgfplots@define@currentplotstyle@as{\the\t@pgfplots@toka}% remember 'current plot style' % per-point meta data ranges which apply only to % this plot: \noexpand\xdef\noexpand\pgfplots@metamin{\pgfplots@metamin}% \noexpand\xdef\noexpand\pgfplots@metamax{\pgfplots@metamax}% \noexpand\def\noexpand\pgfplotspointmetainputhandler{\pgfplotspointmetainputhandler}% + \noexpand\def\noexpand\pgfplots@serialized@state@plothandler{\the\t@pgfplots@tokb}% + \noexpand\def\noexpand\pgfplotsaxisfilteredcoordsaway{\pgfplotsaxisfilteredcoordsaway}% + \noexpand\def\noexpand\pgfplotsaxisplothasjumps{\pgfplotsaxisplothasjumps}% }% {% draw command: \noexpand\path% @@ -2803,234 +4048,363 @@ \pgfplots@end@plot }% -% PRECONDITION: must be called inside of -% \pgfplots@PREPARE@COORD@STREAM@end@. + +% 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'. % -% POSTCONDITION: -% assigns '/pgfplots/#1 coord sorting=[+-]' -% i.e. whether #1 (x or y or z) coordinates are in ascending (+) ordering or in -% descending order (-). -\def\pgfplots@PREPARE@COORD@STREAM@end@determinecoordsorting#1{% - \pgfplots@if{pgfplots@#1islinear}{% - \pgfmathfloatlessthan@ - {\csname pgfplots@currentplot@firstcoord@#1\endcsname} - {\csname pgfplots@currentplot@lastcoord@#1\endcsname}% - }{% - \pgfplotsmathlessthan - {\csname pgfplots@currentplot@firstcoord@#1\endcsname} - {\csname pgfplots@currentplot@lastcoord@#1\endcsname}% - }% - \ifpgfmathfloatcomparison - \pgfkeyssetvalue{/pgfplots/#1 coord sorting}{+}% +% #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 - \pgfkeyssetvalue{/pgfplots/#1 coord sorting}{-}% + \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 }% -% Assigns default values to 'rows' and 'cols' in case -% their values are empty. +% Defines a new coordinate transformation for use in +% \pgfplotsaxistransformcs. +% #1: the source coordinate system +% #2: the target coordinate system +% #3: the transformation code. % -% PRECONDITION: -% The values of -% - '/pgfplots/mesh/rows' -% - '/pgfplots/mesh/cols' -% - '/pgfplots/mesh/num points' -% - \pgfplotsscanlinelength -% - '/pgfplots/mesh/ordering' -% are assigned properly. +% @see \pgfplotsaxistransformcs for what #3 should do. % -% 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% +% 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}% }% -% 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. +\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% +}% + +\def\pgfplotsaxisserializedatapoint{% + \pgfplotsplothandlerserializepointto\pgfplotsaxisserializedatapoint@val + \pgfplotsaxisserializedatapoint@private + \t@pgfplots@toka=\expandafter{\pgfplotsaxisserializedatapoint@val}% + \t@pgfplots@tokb=\expandafter{\pgfplotsretval}% + \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb;\the\t@pgfplots@toka}}% + \expandafter\pgfplotsapplistXXpushback\expandafter{\pgfplots@loc@TMPa}% +}% +\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'. % -% 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. +% 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: -% 'rows' and 'cols' have useful integer values. -\def\pgfplotsautocompletemeshkeys{% - \pgfplots@autocomplete@meshkeys1% -}% -\def\pgfplots@autocomplete@meshkeys#1{% - \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsplothandlermesh@rows - \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsplothandlermesh@cols - \pgfkeysgetvalue{/pgfplots/mesh/num points}\pgfplotsplothandlermesh@numpoints - \edef\pgfplotsplothandlermesh@numpoints{\pgfplotsplothandlermesh@numpoints}% - \edef\pgfplotsplothandlermesh@cols{\pgfplotsplothandlermesh@cols}% - \edef\pgfplotsplothandlermesh@rows{\pgfplotsplothandlermesh@rows}% - \ifpgfplots@curplot@threedim - \ifx\pgfplotsplothandlermesh@rows\pgfutil@empty - \ifx\pgfplotsplothandlermesh@cols\pgfutil@empty - \pgfutil@ifundefined{pgfplotsscanlinelength}{\def\pgfplotsscanlinelength{-1}}{}% - \ifpgfplots@scanline@verbose - \ifnum\pgfplotsscanlinelength>0 - % we have scanlinelength set! Use it: - \message{PGFPlots: Scanline length is \pgfplotsscanlinelength.}% - \else - \ifnum\pgfplotsscanlinelength=-2 - \message{PGFPlots: Scanline length could not be determined 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, 'plot mesh' needs either '[mesh/rows=<N>]' or '[mesh/cols=<N>]' set - or at least '[mesh/num points=<N>]'. But it did not find any of them...}% - \def\pgfplotsplothandlermesh@cols{5}% - \def\pgfplotsplothandlermesh@rows{5}% - \else - % We don't have rows/cols. Well, try using - % sqrt(num points) for both of them! - \ifnum\pgfplotsplothandlermesh@numpoints<16380 - \pgfmath@basic@sqrt@{\pgfplotsplothandlermesh@numpoints}% - \else - \pgfmathfloatparsenumber{\pgfplotsplothandlermesh@numpoints}% - \pgfmathfloatsqrt@{\pgfmathresult}% - \pgfmathfloattofixed{\pgfmathresult}% - \fi - \begingroup - % Try whether this rows*rows yields numpoints: - \afterassignment\pgfplots@gobble@until@relax - \c@pgf@counta=\pgfmathresult\relax - \c@pgf@countb=\c@pgf@counta - \multiply\c@pgf@counta by\c@pgf@counta - \def\pgfplotsretval{1}% - \ifnum\c@pgf@counta=\pgfplotsplothandlermesh@numpoints\relax - % ok, rows*rows = numpoints. - \xdef\pgfplots@glob@TMPa{\the\c@pgf@countb}% - \else - % oh. Did not work. Check for rounding errors: - \c@pgf@counta=\c@pgf@countb - \advance\c@pgf@counta by1 - \c@pgf@countb=\c@pgf@counta - \multiply\c@pgf@counta by\c@pgf@counta - \ifnum\c@pgf@counta=\pgfplotsplothandlermesh@numpoints - % ok, (rows+1)*(rows+1) = numpoints. - \xdef\pgfplots@glob@TMPa{\the\c@pgf@countb}% - \else - % no... did not work. num points doesn't - % appear to be a squared number. - \def\pgfplotsretval{0}% - \xdef\pgfplots@glob@TMPa{5}% - \fi - \fi - \if\pgfplotsretval1 - \pgfplots@warning{% - 'plot mesh' did not find '[mesh/rows=<N>]' or '[mesh/cols=<N>]'. - Assuming [mesh/rows=\pgfplots@glob@TMPa,mesh/cols=\pgfplots@glob@TMPa] - as sqrt(num points) = sqrt(\pgfplotsplothandlermesh@numpoints) [ = \pgfmathresult].}% - \else - \pgfplots@error{Sorry, 'plot mesh' needs either '[mesh/rows=<N>]' or '[mesh/cols=<N>]' set, - but it did not find any of them. - I also tried rows = sqrt(num points) = sqrt(\pgfplotsplothandlermesh@numpoints) = \pgfmathresult\space without success.}% - \fi - \endgroup - \let\pgfplotsplothandlermesh@rows=\pgfplots@glob@TMPa - \let\pgfplotsplothandlermesh@cols=\pgfplots@glob@TMPa - \fi - \else - % #1=0 -> leave them empty. - \fi - \fi - \fi - \fi - \if1#1% - \ifx\pgfplotsplothandlermesh@rows\pgfutil@empty - \ifx\pgfplotsplothandlermesh@cols\pgfutil@empty - \else - % Compute 'rows' out of 'num points' and 'cols': - \ifx\pgfplotsplothandlermesh@numpoints\pgfutil@empty - \pgfplots@error{Sorry, matrix input needs a valid '[mesh/num points=<N>]' variable if only one of '[mesh/rows=<N>]' or '[mesh/cols=<N>]' is given.}% - \def\pgfplotsplothandlermesh@numpoints{100}% - \fi - \begingroup - \c@pgf@counta=\pgfplotsplothandlermesh@numpoints\relax - \divide\c@pgf@counta by\pgfplotsplothandlermesh@cols\relax - \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% - \endgroup - \let\pgfplotsplothandlermesh@rows=\pgfplots@glob@TMPa - \fi +% @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 - \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 + \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\pgfplots@empty@command@key + \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 - \c@pgf@counta=\pgfplotsplothandlermesh@numpoints\relax - \divide\c@pgf@counta by\pgfplotsplothandlermesh@rows\relax - \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% + \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 - \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{\pgfplots@warning{##1}}% - \or - % mesh/check=error - \def\pgfplots@loc@TMPa##1{\pgfplots@error{##1}}% - \fi - \pgfplots@loc@TMPa{the arguments of [mesh/rows=\pgfplotsplothandlermesh@rows,mesh/cols=\pgfplotsplothandlermesh@cols] assume \the\c@pgfplots@scanlineindex\space points, but I got actually N = \pgfplotsplothandlermesh@numpoints\space points! The data matrix appears to be incomplete or overcomplete!? [Use mesh/check=false to disable this message]}% - \fi + }{% + \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#2}% +}% +\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 - % 2d visualization has no mesh: - \edef\pgfplotsplothandlermesh@rows{\pgfplotsplothandlermesh@numpoints}% - \def\pgfplotsplothandlermesh@cols{1}% + \pgfplots@prepare@visualization@depends@on@preparetype@expr{#1}\as{#2}% + \fi +}% +\def\pgfplots@prepare@visualization@depends@on@preparetype@expr#1\as#2{% + \pgflibraryfpuifactive{% + \def#2{% + \pgfmathparse{#1}% + \pgfmathfloattofixed{\pgfmathresult}% + \expandafter\let\csname \string#2@value\endcsname=\pgfmathresult + }% + }{% + \def#2{% + \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{% + \begingroup + % remove spaces from #1: + \pgfkeys@spdef\pgfplots@loc@TMPa{#1}% + \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 + \let#2=\pgfplots@glob@TMPa +} + +\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 - % - \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}% +}% + +% 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}{-}}% }% % Prepares a macro \pgfplots@PREPARE@process@errorbar@for@dir##1 @@ -3100,7 +4474,7 @@ \E\else \E\let\E\pgfplots@current@point@@old\expandafter\E\csname pgfplots@current@point@#1\endcsname \E\let\expandafter\E\csname pgfplots@current@point@#1\endcsname=\E\pgfplots@error@coord - \E\pgfplots@update@limits@for@one@point + \E\pgfplotsaxisupdatelimitsforcoordinate\E\pgfplots@current@point@x\E\pgfplots@current@point@y\E\pgfplots@current@point@z \E\let\expandafter\E\csname pgfplots@current@point@#1\endcsname=\E\pgfplots@current@point@@old \E\edef\E\pgfplots@loc@TMPa{\the\t@pgfplots@toka}% \E\expandafter\E\pgfplots@streamerrorbarcoords\E\pgfplots@loc@TMPa @@ -3115,41 +4489,48 @@ \pgfplots@if{pgfplots@#1islinear}{% \ifcase\csname pgfplots@errorbars@#1mode\endcsname\relax % fixed absolute error. - \pgfmathfloatparsenumber{\csname pgfplots@errorbars@#1fixed\endcsname}% + \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% - \pgfmathfloatadd@ - {\csname pgfplots@current@point@#1\endcsname}% - {\csname pgfplots@error@coord@#1\endcsname}% + \def\pgfplots@loc@TMPb{add}% \else - \pgfmathfloatsubtract@ - {\csname pgfplots@current@point@#1\endcsname}% - {\csname pgfplots@error@coord@#1\endcsname}% + \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 \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname }% \or% fixed relative error: - \pgfmathfloatparsenumber{\csname pgfplots@errorbars@#1rel\endcsname}% + \pgfplotscoordmath{#1}{parsenumber}{\csname pgfplots@errorbars@#1rel\endcsname}% \let\pgfplots@loc@TMPb=\pgfmathresult % % +1: - \pgfmathfloatcreate{1}{1.0}{0}% + \pgfplotscoordmath{#1}{parsenumber}{1}% \let\pgfplots@loc@TMPa=\pgfmathresult % % Prepare '1 + err': - \pgfmathfloatadd@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% + \pgfplotscoordmath{#1}{op}{add}{% + {\pgfplots@loc@TMPa}% + {\pgfplots@loc@TMPb}% + }% \expandafter\let\csname pgfplots@error@coord@#1@+\endcsname=\pgfmathresult % % Prepare '1 - err': - \pgfmathfloatsubtract@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% + \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{% - \pgfmathfloatmultiply@ + \pgfplotscoordmath{#1}{op}{multiply}{% {\csname pgfplots@current@point@#1\endcsname} {\csname pgfplots@error@coord@#1@##1\endcsname}% + }% \let\pgfplots@error@coord=\pgfmathresult \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname }% @@ -3158,20 +4539,20 @@ \edef\pgfplots@error@coord{\csname pgfplots@current@point@#1@error\endcsname}% \ifx\pgfplots@error@coord\pgfutil@empty \else - \pgfmathfloatparsenumber{\pgfplots@error@coord}% + \pgfplotscoordmath{#1}{parsenumber}{\pgfplots@error@coord}% \let\pgfplots@error@coord=\pgfmathresult % remember result here - will be used in case % of '+' AND '-' error bars: \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult \if +##1% - \pgfmathfloatadd@ - {\csname pgfplots@current@point@#1\endcsname}% - {\pgfplots@error@coord}% + \def\pgfplots@loc@TMPb{add}% \else - \pgfmathfloatsubtract@ - {\csname pgfplots@current@point@#1\endcsname}% - {\pgfplots@error@coord}% + \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 \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname \fi @@ -3183,9 +4564,10 @@ \else \pgfmathparse{1##1\pgfplots@error@coord}% \let\pgfplots@error@coord=\pgfmathresult - \pgfmathfloatmultiply@ + \pgfplotscoordmath{#1}{multiply}{% {\csname pgfplots@current@point@#1\endcsname} {\pgfplots@error@coord}% + }% \let\pgfplots@error@coord=\pgfmathresult \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname \fi @@ -3204,52 +4586,58 @@ % \ifcase\csname pgfplots@errorbars@#1mode\endcsname % fixed absolute, log( x +- e_x ) - \pgfmathfloatparsenumber{\csname pgfplots@errorbars@#1fixed\endcsname}% + % + \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{% - \pgfmathfloatparsenumber{\csname pgfplots@current@point@#1@unfiltered\endcsname}% + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@current@point@#1@unfiltered\endcsname}% \let\pgfplots@loc@TMPa=\pgfmathresult \if +##1% - \pgfmathfloatadd@ - {\pgfplots@loc@TMPa}% - {\csname pgfplots@error@coord@#1\endcsname}% + \def\pgfplots@loc@op{add}% \else - \pgfmathfloatsubtract@ - {\pgfplots@loc@TMPa}% - {\csname pgfplots@error@coord@#1\endcsname}% + \def\pgfplots@loc@op{subtract}% \fi - \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% + \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 \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname }% \or% fixed relative, log( x ( 1+-e_x ) ) = log(x) + log(1+-e_x) - \pgfmathfloatparsenumber{\csname pgfplots@errorbars@#1rel\endcsname}% + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@errorbars@#1rel\endcsname}% \let\pgfplots@loc@TMPb=\pgfmathresult % % +1: - \pgfmathfloatcreate{1}{1.0}{0}% + \pgfplotscoordmath{default}{one}% \let\pgfplots@loc@TMPa=\pgfmathresult % % Prepare '1 + err': - \pgfmathfloatadd@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% - \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% - \ifx\pgfmathresult\pgfutil@empty + \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: - \pgfmathfloattofixed{\pgfplots@loc@TMPb}% - \pgfplots@error{Sorry, log(1+\pgfmathresult) is undefined. Please provide a different argument for '/pgfplots/error bar/#1 fixed relative'.}% + \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 - \fi + }% \expandafter\let\csname pgfplots@error@coord@#1@+\endcsname=\pgfmathresult % % Prepare '1 - err': - \pgfmathfloatsubtract@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% - \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% - \ifx\pgfmathresult\pgfutil@empty - % 1 + err <= 0 and log(1+err) is undefined: - \pgfmathfloattofixed{\pgfplots@loc@TMPb}% - \pgfplots@error{Sorry, log(1-\pgfmathresult) is undefined. Please provide a different argument for '/pgfplots/error bar/#1 fixed relative'.}% + \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 - \fi + }% \expandafter\let\csname pgfplots@error@coord@#1@-\endcsname=\pgfmathresult % \expandafter\def\csname pgfplots@PREPARE@errorbar@process@#1@\endcsname##1{% @@ -3268,23 +4656,24 @@ \edef\pgfplots@error@coord{\csname pgfplots@current@point@#1@error\endcsname}% \ifx\pgfplots@error@coord\pgfutil@empty \else - \pgfmathfloatparsenumber{\pgfplots@error@coord}% + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@error@coord}% \let\pgfplots@error@coord=\pgfmathresult % remember result here - will be used in case % of '+' AND '-' error bars: \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult - \pgfmathfloatparsenumber{\csname pgfplots@current@point@#1@unfiltered\endcsname}% + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@current@point@#1@unfiltered\endcsname}% \let\pgfplots@loc@TMPa=\pgfmathresult \if +##1% - \pgfmathfloatadd@ - {\pgfplots@loc@TMPa}% - {\pgfplots@error@coord}% + \def\pgfplots@loc@op{add}% \else - \pgfmathfloatsubtract@ - {\pgfplots@loc@TMPa}% - {\pgfplots@error@coord}% + \def\pgfplots@loc@op{subtract}% \fi - \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% + \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 \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname \fi @@ -3296,34 +4685,36 @@ \edef\pgfplots@error@coord{\csname pgfplots@current@point@#1@error\endcsname}% \ifx\pgfplots@error@coord\pgfutil@empty \else - \pgfmathfloatparsenumber{\pgfplots@error@coord}% + \pgfplotscoordmath{default}{parsenumber}{\pgfplots@error@coord}% \let\pgfplots@error@coord=\pgfmathresult % remember result here - will be used in case % of '+' AND '-' error bars: \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult % - \pgfmathfloatcreate{1}{1.0}{0}% + \pgfplotscoordmath{default}{one}% \let\pgfplots@loc@TMPa=\pgfmathresult \if +##1% - \pgfmathfloatadd@ - {\pgfplots@loc@TMPa}% - {\pgfplots@error@coord}% + \def\pgfplots@loc@op{add}% \else - \pgfmathfloatsubtract@ - {\pgfplots@loc@TMPa}% - {\pgfplots@error@coord}% + \def\pgfplots@loc@op{subtract}% \fi - \csname pgfplotsmathlog@#1@float\endcsname{\pgfmathresult}% + \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 - \ifx\pgfplots@error@coord\pgfutil@empty - % -> log( <= 0 ) -> do nothing. - \else - \pgfmath@basic@add@ + \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{% + \pgfplotscoordmath{#1}{op}{add}{% {\csname pgfplots@current@point@#1\endcsname} {\pgfplots@error@coord}% + }% \let\pgfplots@error@coord=\pgfmathresult \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname - \fi + }{% + % -> log( <= 0 ) -> do nothing. + }% \fi }% % @@ -3366,107 +4757,134 @@ % 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{% - \let\pgfplots@current@point@meta=\pgfutil@empty - \pgfutil@ifundefined{pgfplots@metamax}{\let\pgfplots@metamax=\pgfutil@empty}{} - \ifpgfplots@warn@for@filter@discards - \global\let\pgfplots@perpointmeta@unboundedwarning@stop=\relax - \def\pgfplots@perpointmeta@unboundedwarning##1{% - \ifx\pgfplots@perpointmeta@unboundedwarning@stop\relax - \begingroup - \pgfmathfloattofixed{##1}% - \pgfplots@warning{The per point meta data `\pgfmathresult' (##1) (and probably others as well) is unbounded - using the minimum value instead.}% - \endgroup - \gdef\pgfplots@perpointmeta@unboundedwarning@stop{1}% - \fi - }% - \else - \def\pgfplots@perpointmeta@unboundedwarning##1{}% - \fi - \if m\pgfplots@colormap@access - % colormap access=map - \ifx\pgfplots@metamax\pgfutil@empty - \def\pgfplots@perpointmeta@trafo##1{% - \pgfmathfloatiffinite{##1}{% - \pgfmathfloattofixed@{##1}% - }{% - \def\pgfmathresult{0}% - \pgfplots@perpointmeta@unboundedwarning{##1}% - }% + \def\pgfplotspointmetarangeexponent{1}% pre-fill + \pgfutil@ifundefined{pgfplots@perpointmeta@trafo}{% + \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}% + \pgfplots@warning{The per point meta data `\pgfmathresult' (##1) (and probably others as well) is unbounded - using the minimum value instead.}% + \endgroup + \gdef\pgfplots@perpointmeta@unboundedwarning@stop{1}% + \fi }% - \def\pgfplots@perpointmeta@traforange{0:1000}% - \edef\pgfplotspointmetarange{0:1000}% \else - % The transformation is - % - % phi(m) = ( m- meta_min) * 1000/ (meta_max-meta_min). - % - % -> precompute the scaling factor! - \edef\pgfplots@loc@TMPa{\pgfplotscolormaprange}% - \ifnum\pgfplots@loc@TMPa=1000 - \else - \pgfplots@error{LOGIC ERROR: sorry, I have hard-coded the assumption \string\pgfplotscolormaprange = 1000, but now it is \pgfplots@loc@TMPa.}% - \fi - \if\pgfplots@perpointmeta@rel@choice0% - % point meta rel=axis wide: - \edef\pgfplotspointmetarange{\pgfplots@axiswide@metamin:\pgfplots@axiswide@metamax}% - % Now, prepare the trafo as such. - % It assigns \pgfmathresult (in fixed point). + \def\pgfplots@perpointmeta@unboundedwarning##1{}% + \fi + \if m\pgfplots@colormap@access + % colormap access=map + \ifx\pgfplots@metamax\pgfutil@empty \def\pgfplots@perpointmeta@trafo##1{% - \pgfmathfloatiffinite{##1}{% - \pgfmathfloatsubtract@{##1}{\pgfplots@axiswide@metamin}% - \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}% - \expandafter\pgfmathfloattofixed@\expandafter{\pgfmathresult}% - }{% + \pgfplotscoordmath{meta}{if is}{##1}{u} + {% \def\pgfmathresult{0}% \pgfplots@perpointmeta@unboundedwarning{##1}% - }% - }% - \pgfmathfloatsubtract@{\pgfplots@axiswide@metamax}{\pgfplots@axiswide@metamin}% - \else - % point meta rel=per plot: - \edef\pgfplotspointmetarange{\pgfplots@metamin:\pgfplots@metamax}% - % Now, prepare the trafo as such. - % It assigns \pgfmathresult (in fixed point). - \def\pgfplots@perpointmeta@trafo##1{% - \pgfmathfloatiffinite{##1}{% - \pgfmathfloatsubtract@{##1}{\pgfplots@metamin}% - \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}% - \expandafter\pgfmathfloattofixed@\expandafter{\pgfmathresult}% }{% - \def\pgfmathresult{0}% - \pgfplots@perpointmeta@unboundedwarning{##1}% + \pgfplotscoordmath{meta}{tofixed}{##1}% }% }% - \pgfmathfloatsubtract@{\pgfplots@metamax}{\pgfplots@metamin}% + \def\pgfplots@perpointmeta@traforange{0:1000}% + \edef\pgfplotspointmetarange{0:1000}% + \else + % The transformation is + % + % phi(m) = ( m- meta_min) * 1000/ (meta_max-meta_min). + % + % -> precompute the scaling factor! + \edef\pgfplots@loc@TMPa{\pgfplotscolormaprange}% + \ifnum\pgfplots@loc@TMPa=1000 + \else + \pgfplots@error{LOGIC ERROR: sorry, I have hard-coded the assumption \string\pgfplotscolormaprange = 1000, but now it is \pgfplots@loc@TMPa.}% + \fi + \if\pgfplots@perpointmeta@rel@choice0% + % point meta rel=axis wide: + \pgfplots@perpointmeta@preparetrafo@initfrom{pgfplots@axiswide@}% + \else + \pgfplots@perpointmeta@preparetrafo@initfrom{pgfplots@}% + \fi \fi - \let\pgfplots@loc@TMPa=\pgfmathresult - \pgfmathfloatcreate{1}{1.0}{3}% - \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPa}% - \let\pgfplots@perpointmeta@trafo@factor=\pgfmathresult - % - % Expands to the transformation range as 'a:b': - \def\pgfplots@perpointmeta@traforange{0:1000}% - \fi - \else - % colormap access=direct - \def\pgfplots@perpointmeta@trafo##1{ - \pgfmathfloatiffinite{##1}{% - \pgfmathfloattofixed@{##1}% - }{% - \def\pgfmathresult{0}% - \pgfplots@perpointmeta@unboundedwarning{##1}% + \else + % colormap access=direct + \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:0}% - \edef\pgfplotspointmetarange{\pgfplots@metamin:\pgfplots@metamax}% - \fi - \edef\pgfplotspointmetatransformedrange{\pgfplots@perpointmeta@traforange}% + \def\pgfplots@perpointmeta@traforange{0:0}% + \edef\pgfplotspointmetarange{\pgfplots@metamin:\pgfplots@metamax}% + \fi + \edef\pgfplotspointmetatransformedrange{\pgfplots@perpointmeta@traforange}% + }{}% }% -\def\pgfplots@perpointmeta@trafo@APPLY{% + +% 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 #1max\endcsname}% + % Now, prepare the trafo as such. + % It assigns \pgfmathresult (in fixed point). + \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}}% + \pgfplotscoordmath{meta}{tofixed}{\pgfmathresult}% + }% + }% + \pgfplotscoordmath{meta}{op}{subtract}{{\csname #1metamax\endcsname}{\csname #1metamin\endcsname}}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{meta}{parsenumber}{1000}% + \pgfplotscoordmath{meta}{op}{divide}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% + \let\pgfplots@perpointmeta@trafo@factor=\pgfmathresult + % + % 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}% +} + +% 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{% \ifx\pgfplots@current@point@meta\pgfutil@empty% \pgfplots@error{could not access the 'point meta' (used for example by scatter plots and color maps). Maybe you need to add '\string\addplot[point meta=y]' or something like that?}% - \pgfmathfloatcreate{1}{1.0}{0}% + \pgfplotscoordmath{meta}{one}% \let\pgfplotspointmeta=\pgfmathresult \def\pgfplotspointmetatransformed{1.0}% \else @@ -3536,7 +4954,11 @@ \pgfplots@error{Sorry, I could not read the plot coordinates near '#1'. Please check for format mistakes.}% }% \long\def\pgfplots@foreach@plot@coord@ITERATE@gobbleone#1{\pgfplots@foreach@plot@coord@ITERATE}% -\def\pgfplots@foreach@plot@coord@NEXT(#1,#2){% +\def\pgfplots@foreach@plot@coord@NEXT(#1){% + \edef\pgfmathresult{#1}% + \expandafter\pgfplots@foreach@plot@coord@NEXT@\expandafter(\pgfmathresult)% +} +\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 @@ -3613,7 +5035,11 @@ }% } \long\def\pgfplots@foreach@plot@coord@threedim@ITERATE@gobbleone#1{\pgfplots@foreach@plot@coord@threedim@ITERATE}% -\def\pgfplots@foreach@plot@coord@threedim@NEXT(#1,#2,#3){% +\def\pgfplots@foreach@plot@coord@threedim@NEXT(#1){% + \edef\pgfmathresult{#1}% + \expandafter\pgfplots@foreach@plot@coord@threedim@NEXT@\expandafter(\pgfmathresult)% +} +\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 @@ -3668,42 +5094,168 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 % -% The same in normalized coordinates of the form -% x1,y1,z1,m1;x2,y2,z2,m2;...;xN,yN,zN,mN; -% if the plot is not threedim, zi is empty. +% 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 % -% The mi are Meta Values associated to point coordinates. They are -% usually empty, but can be used to realize per-point marker -% modifications (scatter plots, especially for colormaps). +% \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 - \pgfplots@foreach@plot@coord@NORMALIZED@ITERATE#1\pgfplots@EOI + \pgfplotscoordstream@firstlast@init + \pgfplots@foreach@plot@coord@NORMALIZED@ITERATE#1\pgfplots@EOI% \pgfplots@coord@stream@end }% - -% A looping command to loop through plot coordinates. -% For every point, #1{X}{Y} will be invoked. -% % No scoping is used during this operation, so you can access outer % variables. -\def\pgfplots@foreach@plot@coord@NORMALIZED@ITERATE{% - \pgfutil@ifnextchar\pgfplots@EOI{% - \pgfplots@foreach@plot@coord@FINISH% - }{% - \pgfplots@foreach@plot@coord@NORMALIZED@NEXT% - }% +\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 + \pgfplotscoordstream@firstlast@update + \expandafter\pgfplots@foreach@plot@coord@NORMALIZED@ITERATE + \fi } -\def\pgfplots@foreach@plot@coord@NORMALIZED@NEXT#1,#2,#3,#4;{% - \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 - \pgfplots@foreach@plot@coord@NORMALIZED@ITERATE + + +% 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 + \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?}% + }% + }% + }% + % + % 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: + \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 no \the\pgfplots@numplots/.try}% + \pgfplotsset{/pgfplots/every axis plot no \the\pgfplots@numplots/.try,/pgfplots/every axis plot post}% + \fi + % + % enable FPU after any \pgfplotsset operations. Otherwise things like + % linewidth=... which use the math parser might fail. + \ifpgfplots@usefpu + \pgfkeys{/pgf/fpu=true}% + \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 + \expandafter\def\expandafter\pgfplots@addplot@survey@@optionlist\expandafter{\pgfplots@addplot@survey@@optionlist,% + /pgfplots/point meta rel=per plot}% + \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@validate@plot@domain@arguments } +\long\def\pgfplotsplothandlersurveyaddoptions#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% + }% +}% -\newif\ifpgfplots@curplot@threedim % The main interface to draw a plot into an axis. % @@ -3775,56 +5327,54 @@ }% } -\long\def\pgfplots@addplotimplAPPEND+[{% +\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]{% - \pgfutil@ifnextchar p{% + \pgfplotsutil@ifnextchar p{% \pgfplots@addplotimpl@plot{#1}% }{% \pgfplots@addplotimpl@plot{#1}plot }% } -\def\pgfplots@addplotimpl@plot#1plot{% - \pgfutil@ifnextchar[{% +\long\def\pgfplots@addplotimpl@plot#1plot{% + \pgfplotsutil@ifnextchar[{% \pgfplots@addplotimpl@plot@withoptions{#1}% }{% \pgfplots@addplotimpl@plot@withoptions{#1}[]% }% } -\def\pgfplots@addplotimpl@plot@withoptions#1[#2]{ +\long\def\pgfplots@addplotimpl@plot@withoptions#1[#2]{ \begingroup% <-- This groups ends in \pgfplots@end@plot % - % make sure it is reset, just in case it is not supported by the - % input method. - \pgfplotsscanlinelengthinitzero - % - \pgfutil@ifnextchar c{% + \pgfplotsutil@ifnextchar c{% \pgfplots@addplotimpl@coordinates{#1}{#2}plot }{% - \pgfutil@ifnextchar f{% + \pgfplotsutil@ifnextchar f{% \pgfplots@addplotimpl@f{#1}{#2}% }{% - \pgfutil@ifnextchar t{% + \pgfplotsutil@ifnextchar t{% + \def\pgfplotssurveyphaseinputclass{table}% \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2}% \pgfplots@addplotimpl@table{#1,#2}% }{% - \pgfutil@ifnextchar ({% + \pgfplotsutil@ifnextchar ({% \pgfplots@addplotimpl@expression{#1}{#2}% }{% - \pgfutil@ifnextchar\bgroup{% + \pgfplotsutil@ifnextchar\bgroup{% \pgfplots@addplotimpl@expression@curly{#1}{#2}% }{% - \pgfutil@ifnextchar e{% + \pgfplotsutil@ifnextchar e{% \pgfplots@addplotimpl@expression@e{#1}{#2}% }{% - \pgfutil@ifnextchar g{% + \pgfplotsutil@ifnextchar g{% \pgfplots@addplotimpl@g{#1}{#2}% }{% - \pgfutil@ifnextchar s{% + \pgfplotsutil@ifnextchar s{% \pgfplots@addplotimpl@shell{#1}{#2}% }{% @@ -3839,8 +5389,8 @@ }% }% } -\def\pgfplots@addplotimpl@f#1#2f{% - \pgfutil@ifnextchar i{% +\long\def\pgfplots@addplotimpl@f#1#2f{% + \pgfplotsutil@ifnextchar i{% \pgfplots@addplotimpl@file{#1}{#2}% }{% \pgfplots@addplotimpl@function{#1}{#2}% @@ -3902,9 +5452,32 @@ \edef\pgfplots@plot@var@y{\expandafter\noexpand\csname \pgfplots@plot@var@y\endcsname}% \fi % - % Check if we have to sample a line. - \def\b@pgfplots@should@sample@LINE{0}% - \ifpgfplots@curplot@threedim + % 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}% @@ -3932,7 +5505,10 @@ \pgfkeyssetvalue{/pgfplots/mesh/rows}{\pgfkeysvalueof{/pgfplots/samples y}}% \pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/samples}}% \if1\b@pgfplots@should@sample@LINE + \pgfkeyssetvalue{/pgfplots/sample dim}{1}% \pgfkeyssetvalue{/pgfplots/mesh/cols}{1}% + \else + \pgfkeyssetvalue{/pgfplots/sample dim}{2}% \fi % }% @@ -3945,7 +5521,8 @@ \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@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2,/pgfplots/mesh/ordering/x varies}% + \def\pgfplotssurveyphaseinputclass{expression}% + \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2,/pgfplots/mesh input=lattice,/pgfplots/mesh/ordering/x varies}% \pgfplots@plot@expression@preparekeys % \pgfplots@PREPARE@COORD@STREAM{#5}% @@ -4008,7 +5585,11 @@ % macro: \edef\pgfplots@plot@data##1{% \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\pgfplots@plot@var@y in {\pgfplots@expression@ydomain} - {\noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@expression@xdomain} {##1}}}% + {% + \noexpand\pgfplotsforeachungrouped\expandafter\noexpand\tikz@plot@var in {\pgfplots@expression@xdomain} {##1}% + \noexpand\pgfplotsplothandlernotifyscanlinecomplete + }% + }% \else % sample a line: \def\pgfplots@plot@ydomain{0:0}% @@ -4044,6 +5625,7 @@ \fi \fi \if\pgfplots@samples@logarithmically1% + \def\pgfplotsforeachlogarithmicmathid{x}% use \pgfplotscoordmath{x} % sample logarithmically: \edef\pgfplots@plot@data##1{% \noexpand\pgfplotsforeachlogarithmicungrouped[\pgfplots@plot@samples] @@ -4114,6 +5696,11 @@ \let\pgfplots@addplotimpl@expression@pseudoconst@y=\pgfmathy@ % % + % 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 @@ -4151,13 +5738,14 @@ }% \expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb{#4}% \else - \def\pgfplots@loc@TMPa{\pgfplots@addplotimpl@expression@{#1}{#2}}% + \t@pgfplots@tokc={\pgfplots@addplotimpl@expression@{#1}{#2}}% + \def\pgfplots@loc@TMPa{\the\t@pgfplots@tokc}% this construction allows '#' in either '#1' or '#2' \expandafter\pgfplots@loc@TMPa\expandafter{\tikz@plot@var}{#3}{#4}% \fi }% % \addplot[#1] [#2] expression[#3] {#4} #5; \def\pgfplots@addplotimpl@expression@e#1#2expression{% - \pgfutil@ifnextchar[{% + \pgfplotsutil@ifnextchar[{% \pgfplots@addplotimpl@expression@e@{#1}{#2}% }{% \pgfplots@addplotimpl@expression@e@{#1}{#2}[]% @@ -4184,7 +5772,7 @@ \xdef\pgfplots@gnuplot@format{set format "%.7e";} } \def\pgfplots@addplotimpl@g#1#2g{% - \pgfutil@ifnextchar r{% + \pgfplotsutil@ifnextchar r{% \pgfplots@addplotimpl@graphics{#1}{#2}% }{% \pgfplots@addplotimpl@gnuplot{#1}{#2}% @@ -4196,7 +5784,7 @@ % \addplot[#1] plot[#2] function[#3] {#4} #5; \def\pgfplots@addplotimpl@function#1#2unction{% - \pgfutil@ifnextchar[{% + \pgfplotsutil@ifnextchar[{% \pgfplots@addplotimpl@function@opt{#1}{#2}% }{% \pgfplots@addplotimpl@function@opt{#1}{#2}[]% @@ -4207,6 +5795,7 @@ \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.}% @@ -4271,6 +5860,7 @@ \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.}% @@ -4395,7 +5985,7 @@ % \addplot[#1] plot[#2] shell[#3] {#4} #5; \def\pgfplots@addplotimpl@shell#1#2shell{% - \pgfutil@ifnextchar[{% + \pgfplotsutil@ifnextchar[{% \pgfplots@addplotimpl@shell@opt{#1}{#2}% }{% \pgfplots@addplotimpl@shell@opt{#1}{#2}[]% @@ -4404,6 +5994,7 @@ \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}% @@ -4440,7 +6031,7 @@ % \addplot[#1] [#2] file{#3} #4; \def\pgfplots@addplotimpl@file#1#2ile{% - \pgfutil@ifnextchar[{% + \pgfplotsutil@ifnextchar[{% \pgfplots@addplotimpl@file@opt{#1}{#2}% }{% \pgfplots@addplotimpl@file@opt{#1}{#2}[]% @@ -4452,6 +6043,7 @@ \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}% } @@ -4463,13 +6055,18 @@ \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=#3 + \openin\r@pgfplots@reada=#1 \ifeof\r@pgfplots@reada - \pgfplots@error{sorry, plot file{#3} could not be opened}% + \pgfplots@error{sorry, plot file{#1} could not be opened}% \else - \pgfplots@logfileopen{#3}% + \pgfplots@logfileopen{#1}% \let\pgfplots@current@point@x@error=\pgfutil@empty \let\pgfplots@current@point@y@error=\pgfutil@empty \let\pgfplots@current@point@z@error=\pgfutil@empty @@ -4490,7 +6087,6 @@ \fi \pgfplotsscanlinelengthcleanup \pgfplots@coord@stream@end - \endgroup }% \def\pgfplots@addplotimpl@file@readall{% \read\r@pgfplots@reada to\pgfplots@file@LINE @@ -4539,7 +6135,7 @@ \def\pgfplots@addplotimpl@graphics#1#2raphics{% - \pgfutil@ifnextchar[{% + \pgfplotsutil@ifnextchar[{% \pgfplots@addplotimpl@graphics@{#1}{#2}% }{% \pgfplots@addplotimpl@graphics@{#1}{#2}[]% @@ -4548,7 +6144,13 @@ % \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{% - \pgfplots@start@plot@with@behavioroptions{#1,/pgfplots/.cd,#2,% + \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,% @@ -4557,8 +6159,27 @@ /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 @@ -4638,7 +6259,7 @@ % package is used - with all its features, including comfortable % access to the previous and next row and accumulation features. \def\pgfplots@addplotimpl@table#1table{% - \pgfutil@ifnextchar[{% + \pgfplotsutil@ifnextchar[{% \pgfplots@addplotimpl@table@getopts{#1}% }{% \pgfplots@addplotimpl@table@getopts{#1}[]% @@ -4651,10 +6272,10 @@ \pgfplots@addplotimpl@table@installkeypath \pgfplotstableset{#2}% % - \pgfutil@ifnextchar s{% + \pgfplotsutil@ifnextchar s{% \pgfplots@addplotimpl@table@fromshell{#1}{#2}% }{% - \pgfutil@ifnextchar f{% + \pgfplotsutil@ifnextchar f{% \pgfplots@addplotimpl@table@fromstructure@gobble@space{#1}{#2}% }{% \pgfplots@addplotimpl@table@fromfile@gobble@space{#1}{#2}% @@ -4715,6 +6336,7 @@ % \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 .... !? @@ -4731,6 +6353,8 @@ % % % high level user interface functions: + \let\pgfplotstable@coordindex@old=\coordindex + \def\coordindex{\pgfplotstablerow}% \let\lineno=\coordindex% is the same here % \expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@plot@tbl@x}\of#3\to\addplot@tbl@x @@ -4778,6 +6402,8 @@ \let\pgfplots@current@point@z@error=\pgfutil@empty \fi % + \let\coordindex=\pgfplotstable@coordindex@old + % \pgfplots@PREPARE@COORD@STREAM{#4}% \pgfplots@coord@stream@start \pgfutil@loop @@ -5197,106 +6823,6 @@ \pgfshell[\pgfplots@plot@filename]{#3}\pgfplots@addplotimpl@table@fromfile{#1}{#2}{\pgfplots@plot@filename.out}#4;% }% -% A common routine which resets internal data structures for the -% survey phase, i.e. it is the shared implementation for all \addplot -% variations. -% -% It takes all options which are provided to \addplot, sets them (at -% least partially) and remembers them for the command serialization. -% -% #1: arguments to \addplot plot[#1] -% -> these are called 'behavior' options in the manual; they are set -% immediately. -% -% PRECONDITION: -% \pgfplots@addplotimpl@plot@withoptions has already been invoked -% -% POSTCONDITION: -% - internal datastructures are initialised (coordinate indexing, fpu) -% - all keys which are required for the current plot are determined -% (and set if necessary). -% They are stored into -% \pgfplots@addplot@survey@@optionlist. -% -\def\pgfplots@start@plot@with@behavioroptions#1{% - %\begingroup%<-- has been moved to \pgfplots@addplotimpl@plot@withoptions - \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?}% - }% - }% - }% - % - % 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! - % - % ATTENTION: starting with more recent versions (since the - % unstable version), I will also set /tikz keys here! This should - % work. It is well tested for the unstable... I hope it will also - % work for the master branch. - %\pgfkeysdef{/pgfplots/.unknown}{% -%\message{In \string\addplot[#1]: I am silently ignoring key `\pgfkeyscurrentkeyRAW' during the preparation phase.}% - %}% - % - % it is possible that '#1' contains 'forget plot'. So, we need to - % set the options before checking - % \ifpgfplots@curplot@isirrelevant: - \pgfplotsset{/pgfplots/every axis plot,#1}% - % - \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 no \the\pgfplots@numplots/.try}% - \pgfplotsset{/pgfplots/every axis plot no \the\pgfplots@numplots/.try,/pgfplots/every axis plot post}% - \fi - % - \ifpgfplots@usefpu - \pgfkeys{/pgf/fpu=true}% - \fi - \pgfplots@countplots@init - % - % hooks: - \pgfkeysvalueof{/pgfplots/execute at begin plot@@}% - \pgfkeysvalueof{/pgfplots/execute at begin plot}% - % - \if1\pgfplots@colorbar@set@src - \expandafter\def\expandafter\pgfplots@addplot@survey@@optionlist\expandafter{\pgfplots@addplot@survey@@optionlist,% - /pgfplots/point meta rel=per plot}% - \fi - % - \expandafter\def\expandafter\pgfplots@addplot@survey@@optionlist\expandafter{\pgfplots@addplot@survey@@optionlist,% - #1,/pgfplots/.cd,/pgfplots/every axis plot post}% - \pgfplots@validate@plot@domain@arguments -} - - % This is a backwards-compatibility method to ensure that % \axis[ybar] % and @@ -5310,7 +6836,7 @@ % So, this macro install special handlers to restore the old setting. \def\pgfplots@install@local@bar@handlers{% \pgfkeysgetvalue{/pgfplots/xbar/.@cmd}\pgfplotskeys@orig@xbar - \pgfkeysgetvalue{/pgfplots/ybar/.@cmd}\pgfplotskeys@orig@xbar + \pgfkeysgetvalue{/pgfplots/ybar/.@cmd}\pgfplotskeys@orig@ybar \pgfkeysgetvalue{/pgfplots/xbar interval/.@cmd}\pgfplotskeys@orig@xbari \pgfkeysgetvalue{/pgfplots/ybar interval/.@cmd}\pgfplotskeys@orig@ybari \pgfkeysdef{/pgfplots/xbar}{% @@ -5375,12 +6901,6 @@ }% }% % -% This macro may be overwritten inside of the \tikz@plot@handler -% macro. This here is just the default implementation. -% -% @INTERNAL HINT: I think the unstable version has another -% implementation. make sure it's not overwritten! -\def\pgfplotsplothandlername{\meaning\tikz@plot@handler}% % \def\pgfplots@countplots@init{% % @@ -5420,6 +6940,7 @@ \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 @@ -5504,6 +7025,9 @@ }% } +\def\pgfplots@invoke@prefilter{% + \pgfkeysvalueof{/pgfplots/pre filter/.@cmd}\pgfeov% +}% \def\pgfplots@invoke@filter#1#2{% \pgfkeysvalueof{/pgfplots/#2 filter/.@cmd}#1\pgfeov% }% @@ -5528,6 +7052,12 @@ \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}}% +} + \newif\ifpgfplots@record@marker@stream % Takes a sequence of PREPARED coordinates which are given in floating % point representation and applies the data scaling trafo (if @@ -5546,6 +7076,7 @@ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}% % + % \ifpgfplots@clip@limits \else % "clip marker paths=true" actually doesn't checks anything -- @@ -5554,6 +7085,9 @@ \pgfplots@clip@marker@pathstrue \fi % + \pgfplots@perpointmeta@preparetrafo + % + \pgfplots@prepare@visualization@dependencies % \def\pgfplots@loc@TMPa{0}% <-- if (collectmark positions) \ifpgfplots@scatterplotenabled @@ -5563,7 +7097,6 @@ \else \def\pgfplots@loc@TMPa{1}% \fi - % \if\pgfplots@loc@TMPa0% % mark=none : no need to waste time collecting marker % positions. @@ -5598,7 +7131,9 @@ \pgfplots@stacked@beginplot \fi \fi + \pgfplotsresetplothandler \pgfplots@basiclevel@plothandler + \expandafter\pgfplotsplothandlerdeserializestatefrom\expandafter{\pgfplots@serialized@state@plothandler}% \pgfplotstreamstart \let\pgfplots@data@scaletrafo@result=\pgfutil@empty \ifpgfplots@record@marker@stream @@ -5625,6 +7160,17 @@ %\expandafter\gdef\expandafter#1\expandafter{#1\pgfplotstreamend}% \fi }% + \def\pgfplots@visualize@performserialization{% + % ATTENTION: a similar thing is REPLICATED for stacked plots! + \t@pgfplots@tokb=\expandafter{\pgfplotsaxisdeserializedatapointfrom@private@lastvalue}% + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplots@stream@decode@and@apply + {\the\c@pgfplots@coordindex} + {\the\t@pgfplots@tokb}% + {\the\pgf@x}{\the\pgf@y} + }% + \expandafter\pgfplotsapplistXXpushback\expandafter{\pgfplots@loc@TMPa}% + }% \begingroup \let\E=\noexpand %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -5632,19 +7178,6 @@ % % Will be inserted in one of two possible places below (to collect % marker positions) - \def\pgfplots@visualize@performserizalization{% - % ATTENTION: this here is replicated for stacked plots! - \ifx\pgfplotspointmetainputhandler\pgfutil@empty - % we don't have per-point meta data. Nothing special to - % do: - \E\edef\E\pgfmathresult{\E\noexpand\E\pgfplots@stream@{\E\the\E\c@pgfplots@coordindex}{\E\the\E\pgf@x}{\E\the\E\pgf@y}}% - \E\expandafter\E\pgfplotsapplistXXpushback\E\expandafter{\E\pgfmathresult}% - \else - % Ok, then we need to process the meta data as well: - \E\edef\E\pgfmathresult{\E\noexpand\E\pgfplots@stream@withmeta@{\E\the\E\c@pgfplots@coordindex}{\E\the\E\pgf@x}{\E\the\E\pgf@y}{\E\pgfplots@current@point@meta}}% - \E\expandafter\E\pgfplotsapplistXXpushback\E\expandafter{\E\pgfmathresult}% - \fi - }% % 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 @@ -5655,109 +7188,119 @@ \ifpgfplots@curplot@threedim \E\pgfplotsqpointxyz{\E\pgfplots@current@point@x}{\E\pgfplots@current@point@y}{\E\pgfplots@current@point@z}% \else - \ifpgfplots@threedim - \E\pgfplotsqpointxyz{\E\pgfplots@current@point@x}{\E\pgfplots@current@point@y}{0.0}% - \else - \E\pgfplotsqpointxy{\E\pgfplots@current@point@x}{\E\pgfplots@current@point@y}% - \fi + \E\pgfplotsqpointxy{\E\pgfplots@current@point@x}{\E\pgfplots@current@point@y}% \fi + % \ifpgfplots@record@marker@stream - \E\pgf@xa=\E\pgfplots@current@point@x pt % FIXME : SCOPE REGISTERS!? - \E\pgf@ya=\E\pgfplots@current@point@y pt % - \ifpgfplots@curplot@threedim - \E\pgf@yb=\E\pgfplots@current@point@z pt % - \fi + % remember the position (x,y) for markers. + % remember it before \pgfplotstreampoint (which might change (x,y) ) \ifpgfplots@clip - \E\ifdim\E\pgf@xa<\E\pgfplots@xmin@reg - \E\else - \E\ifdim\E\pgf@xa>\E\pgfplots@xmax@reg - \E\else - \E\ifdim\E\pgf@ya<\E\pgfplots@ymin@reg - \E\else - \E\ifdim\E\pgf@ya>\E\pgfplots@ymax@reg - \E\else - \ifpgfplots@curplot@threedim - \E\ifdim\E\pgf@yb<\E\pgfplots@zmin@reg - \E\else - \E\ifdim\E\pgf@yb>\E\pgfplots@zmax@reg - \E\else - \pgfplots@visualize@performserizalization - \E\fi - \E\fi - \else - \pgfplots@visualize@performserizalization - \fi - \E\fi - \E\fi - \E\fi - \E\fi + % check for clip marker paths: + \E\pgfplotsaxisifcontainspoint{\E\pgfplots@visualize@performserialization}{}% \else - \pgfplots@visualize@performserizalization + \E\pgfplots@visualize@performserialization \fi \fi + % \E\pgfplotstreampoint{}% it will simply take \pgf@x and \pgf@y! + % \advance\c@pgfplots@coordindex by1 }% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endgroup % -%\message{Prepared macro \string \pgfplots@apply@data@scaletrafo@to@one@point {\meaning\pgfplots@apply@data@scaletrafo@to@one@point}}% +%\message{Prepared macro \string \pgfplotsaxisvisphasetransformcoordinate {\meaning\pgfplotsaxisvisphasetransformcoordinate}}% %\message{Prepared macro \string \pgfplots@coord@stream@finalize@currentpt {\meaning\pgfplots@coord@stream@finalize@currentpt}}% - \ifpgfplots@apply@datatrafo - \def\pgfplots@coord@stream@coord@{% - \pgfplots@apply@data@scaletrafo@to@one@point% - \pgfplots@coord@stream@finalize@currentpt - }% - \else - \def\pgfplots@coord@stream@coord@{% + \def\pgfplots@coord@stream@coord@{% + \ifx\pgfplots@current@point@x\pgfutil@empty% this realizes `unbounded coords=jump', for example + \pgfplotsplothandlervisualizejump + \else + \pgfplotsaxisvisphasetransformcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z% + \pgfplotsaxisvisphasepreparedatapoint \pgfplots@coord@stream@finalize@currentpt - }% - \fi - \if\pgfplots@unbounded@handler j% unbounded coords=jump - \t@pgfplots@tokb=\expandafter{\pgfplots@coord@stream@coord@}% - \edef\pgfplots@coord@stream@coord@{% - \noexpand\ifx\noexpand\pgfplots@current@point@x\noexpand\pgfutil@empty - \noexpand\pgfplots@plothandler@unbounded@visualize@jump - \noexpand\else - \the\t@pgfplots@tokb - \noexpand\fi - }% - \fi - % + \fi + }% } -\def\pgfplots@plothandler@unbounded@visualize@jump{% - \pgfplotstreamend - \pgfplotstreamstart +\def\pgfplots@check@for@default@plot@mark{% + % 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 + \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 + \fi }% -% Defines an optimized and matching \pgfplots@apply@data@scaletrafo@to@one@point + +% 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 - % The command which is called for every non-yet-finished point. + % + % \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: - % \pgfplots@current@point@[xyz] - % \pgfplots@current@point@[xyz]@error (if in argument list) - \xdef\pgfplots@apply@data@scaletrafo@to@one@point{% + % #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\pgfplots@datascaletrafo@x{\E\pgfplots@current@point@x}% - \E\let\E\pgfplots@current@point@x=\E\pgfmathresult + \E\pgfplotscoordmath{x}{datascaletrafo}{##1}% + \E\let##1=\E\pgfmathresult \fi \ifpgfplots@apply@datatrafo@y - \E\pgfplots@datascaletrafo@y{\E\pgfplots@current@point@y}% - \E\let\E\pgfplots@current@point@y=\E\pgfmathresult + \E\pgfplotscoordmath{y}{datascaletrafo}{##2}% + \E\let##2=\E\pgfmathresult \fi \ifpgfplots@curplot@threedim \ifpgfplots@apply@datatrafo@z - \E\pgfplots@datascaletrafo@z{\E\pgfplots@current@point@z}% - \E\let\E\pgfplots@current@point@z=\E\pgfmathresult + \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. @@ -5765,15 +7308,13 @@ \E\pgfplots@stacked@finishpoint% \E\pgfplots@stacked@rememberzerolevelpoint@for@next@plot{(\E\pgfplots@current@point@x,\E\pgfplots@current@point@y\ifpgfplots@threedim,\E\pgfplots@current@point@z\fi)}% \fi - % \t@pgfplots@tokc=\expandafter{\pgfplots@data@scaletrafo@result}% - % \edef\pgfplots@data@scaletrafo@result{\the\t@pgfplots@tokc(\pgfplots@current@point@x,\pgfplots@current@point@y)}% }% % \endgroup } \def\pgfplots@addplot@get@named@startendpoints@command#1{% - \ifpgfplots@coord@stream@isfirst + \ifx\pgfplots@currentplot@firstcoord@x\pgfutil@empty % empty plot. \def#1{% \pgfcoordinate{current plot begin}{\pgfplotspointaxisorigin}% @@ -5849,6 +7390,8 @@ \t@pgfplots@tokb=\expandafter{\pgfplots@stored@current@cmd[current plot style]}% \t@pgfplots@tokc=\expandafter{\pgfplots@recorded@marker@stream}% \edef\pgfplots@loc@TMPa{% + \noexpand\pgfkeysvalueof{/pgfplots/execute at begin plot visualization}% + \noexpand\def\noexpand\tikz@plot@mark{\tikz@plot@mark}% make sure we restore the environment setting \noexpand\pgfkeysdef{/tikz/current plot style}{\the\t@pgfplots@toka}% % de-activate the FPU here if it was active! I fear its number % format may cause errors when used in low-level @@ -5864,7 +7407,9 @@ \noexpand\pgfplots@install@plotmark@handler \the\t@pgfplots@tokc \noexpand\endpgfextra - ;}% + ;% + \noexpand\pgfkeysvalueof{/pgfplots/execute at end plot visualization}% + }% \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}% \t@pgfplots@tokb=\expandafter{\pgfplots@stored@current@precmd}% \edef\pgfplots@loc@TMPa{\the\t@pgfplots@tokb\the\t@pgfplots@toka}% @@ -5876,6 +7421,7 @@ \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% @@ -5905,6 +7451,9 @@ % \fi %-------------------------------------------------- \pgfplots@perpointmeta@preparetrafo + % + \pgfplots@prepare@visualization@dependencies + % % this here is the MAIN marker code. % It may be modified if scatter plot is enabled, see below. \def\pgfplots@loc@TMPa{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}} @@ -5923,7 +7472,7 @@ % Prepare arguments for '@pre/@post' macros: \t@pgfplots@toka={% \begingroup - \pgfplots@perpointmeta@trafo@APPLY + \pgfplotsaxisvisphasetransformpointmeta \pgfkeysvalueof{/pgfplots/scatter/@pre marker code/.@cmd}\pgfeov }% \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}% @@ -5958,18 +7507,18 @@ \def\pgfplots@errorbar@draw@float(#1,#2)(#3,#4){% \ifpgfplots@apply@datatrafo@x - \pgfplots@datascaletrafo@x{#1}% + \pgfplotscoordmath{x}{datascaletrafo}{#1}% \let\pgfplots@xarg=\pgfmathresult% - \pgfplots@datascaletrafo@x{#3}% + \pgfplotscoordmath{x}{datascaletrafo}{#3}% \let\pgfplots@error@xarg=\pgfmathresult% \else \def\pgfplots@xarg{#1}% \def\pgfplots@error@xarg{#3}% \fi \ifpgfplots@apply@datatrafo@y - \pgfplots@datascaletrafo@y{#2}% + \pgfplotscoordmath{y}{datascaletrafo}{#2}% \let\pgfplots@yarg=\pgfmathresult% - \pgfplots@datascaletrafo@y{#4}% + \pgfplotscoordmath{y}{datascaletrafo}{#4}% \let\pgfplots@error@yarg=\pgfmathresult% \else \def\pgfplots@yarg{#2}% @@ -5981,27 +7530,27 @@ } \def\pgfplots@errorbar@draw@float@threedim(#1,#2,#3)(#4,#5,#6){% \ifpgfplots@apply@datatrafo@x - \pgfplots@datascaletrafo@x{#1}% + \pgfplotscoordmath{x}{datascaletrafo}{#1}% \let\pgfplots@xarg=\pgfmathresult% - \pgfplots@datascaletrafo@x{#4}% + \pgfplotscoordmath{x}{datascaletrafo}{#4}% \let\pgfplots@error@xarg=\pgfmathresult% \else \def\pgfplots@xarg{#1}% \def\pgfplots@error@xarg{#4}% \fi \ifpgfplots@apply@datatrafo@y - \pgfplots@datascaletrafo@y{#2}% + \pgfplotscoordmath{y}{datascaletrafo}{#2}% \let\pgfplots@yarg=\pgfmathresult% - \pgfplots@datascaletrafo@y{#5}% + \pgfplotscoordmath{y}{datascaletrafo}{#5}% \let\pgfplots@error@yarg=\pgfmathresult% \else \def\pgfplots@yarg{#2}% \def\pgfplots@error@yarg{#5}% \fi \ifpgfplots@apply@datatrafo@z - \pgfplots@datascaletrafo@z{#3}% + \pgfplotscoordmath{z}{datascaletrafo}{#3}% \let\pgfplots@zarg=\pgfmathresult% - \pgfplots@datascaletrafo@z{#6}% + \pgfplotscoordmath{z}{datascaletrafo}{#6}% \let\pgfplots@error@zarg=\pgfmathresult% \else \def\pgfplots@zarg{#3}% @@ -6084,24 +7633,29 @@ \def\pgfplots@prepare@ZERO@coordinates{% \ifpgfplots@xislinear \ifpgfplots@apply@datatrafo@x - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfplots@datascaletrafo@x{\pgfmathresult}% + \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 - \global\let\pgfplots@logical@ZERO@x=\pgfplots@xmin% + \if\pgfplots@log@origin@choice@x0% + \global\let\pgfplots@logical@ZERO@x=\pgfplots@xmin% + \else + \gdef\pgfplots@logical@ZERO@x{1}% + \fi \fi % \ifpgfplots@yislinear \ifpgfplots@apply@datatrafo@y - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfplots@datascaletrafo@y{\pgfmathresult}% + \pgfplotscoordmath{y}{parsenumber}{0}% + \pgfplotscoordmath{y}{datascaletrafo}{\pgfmathresult}% \global\let\pgfplots@logical@ZERO@y=\pgfmathresult \else \gdef\pgfplots@logical@ZERO@y{0}% @@ -6111,14 +7665,18 @@ \pgfplotsmathmin{\pgfplots@logical@ZERO@y}{\pgfplots@ymax}% \global\let\pgfplots@logical@ZERO@y=\pgfmathresult \else - \global\let\pgfplots@logical@ZERO@y=\pgfplots@ymin% + \if\pgfplots@log@origin@choice@y0% + \global\let\pgfplots@logical@ZERO@y=\pgfplots@ymin% + \else + \gdef\pgfplots@logical@ZERO@y{1}% + \fi \fi % \ifpgfplots@threedim \ifpgfplots@zislinear \ifpgfplots@apply@datatrafo@z - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfplots@datascaletrafo@z{\pgfmathresult}% + \pgfplotscoordmath{z}{parsenumber}{0}% + \pgfplotscoordmath{z}{datascaletrafo}{\pgfmathresult}% \global\let\pgfplots@logical@ZERO@z=\pgfmathresult \else \gdef\pgfplots@logical@ZERO@z{0}% @@ -6128,7 +7686,11 @@ \pgfplotsmathmin{\pgfplots@logical@ZERO@z}{\pgfplots@zmax}% \global\let\pgfplots@logical@ZERO@z=\pgfmathresult \else - \global\let\pgfplots@logical@ZERO@z=\pgfplots@zmin% + \if\pgfplots@log@origin@choice@z0% + \global\let\pgfplots@logical@ZERO@z=\pgfplots@zmin% + \else + \gdef\pgfplots@logical@ZERO@z{1}% + \fi \fi \fi % @@ -6151,40 +7713,623 @@ % coordinates. \def\pgfplotsplothandlergraphics{% \def\pgf@plotstreamstart{% - \global\let\pgfplots@plot@handler@graphics@bb@first=\pgfutil@empty - \global\let\pgfplots@plot@handler@graphics@bb@second=\pgfutil@empty + \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\pgfplots@plothandler@unbounded@visualize@jump{% + \def\pgfplotsplothandlervisualizejump{% \pgfplots@error{Sorry, plot graphics does not support 'unbounded coords=jump'.}% }% }% }% \def\pgfplots@plot@handler@graphics@collectbb#1{% \pgf@process{#1}% - \ifx\pgfplots@plot@handler@graphics@bb@first\pgfutil@empty - % ok, this is the lower left corner. - \xdef\pgfplots@plot@handler@graphics@bb@first{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \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 - \ifx\pgfplots@plot@handler@graphics@bb@second\pgfutil@empty - % ok, this is the upper right corner. - \xdef\pgfplots@plot@handler@graphics@bb@second{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \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 - \pgfplots@error{Error using 'plot graphics': I encountered more than two coordinates!? I expected only the lower left and upper right corners!}% + \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@finish{% - \ifx\pgfplots@plot@handler@graphics@bb@first\pgfutil@empty +\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{true}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \def\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug{1}% + \else + \def\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug{0}% + \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 + % + % + \edef\pgfplotsretval{% + x={(\pgfplots@xx,\pgfplots@xy)},% + y={(\pgfplots@yx,\pgfplots@yy)},% + z={(\pgfplots@zx,\pgfplots@zy)},% + scale mode=scale uniformly,% + }% + % + \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] 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\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 + \ifx\pgfplots@plot@handler@graphics@pointmap@C@canvas\pgfutil@empty + \ifpgfplots@threedim + \pgfplots@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.}% + \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 + % + % + \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 + \fi + \endgroup +} + +\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 - \ifx\pgfplots@plot@handler@graphics@bb@second\pgfutil@empty - \pgfplots@error{Error using 'plot graphics': I got too few coordinates! I expected the lower left and upper right corners!}% - \xdef\pgfplots@plot@handler@graphics@bb@second{\noexpand\pgfqpoint{0pt}{0pt}}% - \fi \begingroup % determine the lower left / upper right corners. \pgfplots@plot@handler@graphics@bb@first @@ -6233,11 +8378,44 @@ \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 + % \def\pgfplots@loc@TMPa{\pgfkeysvalueof{/pgfplots/plot graphics/includegraphics cmd}}% - \expandafter\pgfplots@loc@TMPa\expandafter[\pgfplots@loc@TMPc,width=#1,height=#2]{\pgfplots@loc@TMPd}% + \expandafter\pgfplots@loc@TMPa\expandafter[\pgfplots@loc@TMPc]{\pgfplots@loc@TMPd}% \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 @@ -6263,668 +8441,6 @@ } -% The low-level tikz plot handler for 3D mesh and surface plots. -% -% It expects -% a) a coordinate stream which is a linearized matrix, iterated either -% rowwise or column wise, -% b) the current set of options in /pgfplots/mesh/. -% -% -% ATTENTION: -% this handler is NOT as general as the others. In particular, it -% can't be interrupted by TeX groups: every single statement, -% starting with streamstart and ending with stream end, must be in -% the same scope! -% -% As a consequence, you can't use this handler inside of (all) TikZ -% input streams. Try it out. It will work in pgfplots, however. -% -% Furthermore, it relies on a couple of pgfplots macros. This may -% change in future versions. -% It relies on: -% - \ifpgfplots@curplot@threedim -% - \pgfplots@current@point@meta -% -> it also invokes \pgfplots@perpointmeta@preparetrafo and its -% @APPLY counterpart which checks for -% - \pgfplots@metamax -% If you use it outside of pgfplots, use -% \global\let\pgfplots@metamax=\pgfutil@empty -% This is can be used without an initialised -% pgfplots axes - as long as \pgfplots@current@point@meta is in -% the range [0,1000]. -% - for the case 'shader=interp', a bounding box must be established -% before the plot is finished. This must be done using -% \def\pgfplotspointbbupperright{\pgfqpointxyz{2}{2}{0.9}} -% \def\pgfplotspointbblowerleft {\pgfqpointxyz{0}{0}{0.1}} -% or something like that. -% -% Besides these internals, it also relies on all public /pgfplots -% configuration keys related to mesh/surface plots. -% -% Please note that the 'z buffer' feature will not work without -% pgfplots (especially the z buffer=sort feature). -% -% Here is an example which compiles without a pgfplots axes: -% ---------------------------------------------------------- -% \begin{tikzpicture} -% \scope[ -% /pgfplots/.cd, -% surf, -% shader=faceted, -% mesh/rows=4, -% mesh/cols=4, -% mesh/num points=, -% /tikz/x={(0.44237cm,-0.07439cm)}, -% /tikz/y={(0.30942cm,0.23932cm)}, -% /tikz/z={(0.0cm,1.5cm)}, -% ] -% \makeatletter -% -% \global\let\pgfplots@metamax=\pgfutil@empty -% \pgfplots@curplot@threedimtrue -% -% \pgfplotsplothandlermesh -% \pgfplotstreamstart -% -% \def\rangea{0.21}% -% \def\rangeb{0.9}% -% -% \pgfmathparse{1000/(\rangeb-\rangea)} -% \let\factor=\pgfmathresult -% -% \def\simplecoordinate(#1,#2,#3){% -% \pgfmathparse{\factor*(#3 - \rangea)}% -% \let\pgfplots@current@point@meta=\pgfmathresult -% \pgfplotstreampoint{\pgfqpointxyz{#1}{#2}{#3}}% -% }% -% % for the case 'shaer=interp': -% \def\pgfplotspointbbupperright{\pgfqpointxyz{2}{2}{0.9}} -% \def\pgfplotspointbblowerleft {\pgfqpointxyz{0}{0}{0.1}} -% -% \simplecoordinate(0,3,0.7) -% \simplecoordinate(1,3,0.5) -% \simplecoordinate(2,3,0.58) -% \simplecoordinate(3,3,0.9) -% -% \simplecoordinate(0,2,0.68) -% \simplecoordinate(1,2,0.22) -% \simplecoordinate(2,2,0.25) -% \simplecoordinate(3,2,0.4) -% -% \simplecoordinate(0,1,0.6) -% \simplecoordinate(1,1,0.3) -% \simplecoordinate(2,1,0.21) -% \simplecoordinate(3,1,0.3) -% -% \simplecoordinate(0,0,0.8) -% \simplecoordinate(1,0,0.56) -% \simplecoordinate(2,0,0.5) -% \simplecoordinate(3,0,0.75) -% -% -% \pgfplotstreamend -% \pgfusepath{stroke} -% -% \endscope -% \end{tikzpicture} -% ---------------------------------------------------------- -% END OF EXAMPLE -% -> see also the legend image for mesh plots. -% -\def\pgfplotsplothandlermesh{% - \def\pgf@plotstreamstart{% -% \scope - \pgfplotsautocompletemeshkeys% - \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsplothandlermesh@rows - \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsplothandlermesh@cols - \pgfkeysgetvalue{/pgfplots/mesh/num points}\pgfplotsplothandlermesh@numpoints - % - \pgfutil@ifundefined{pgfplots@drawmodes}{% - \let\pgfplots@drawmodes=\tikz@mode - \let\pgfplots@drawoptions=\tikz@options - }{}% - % - \def\pgfplotsplothandlermesh@ONEDIMMODE{0}% - \ifnum\pgfplotsplothandlermesh@cols=1 - \def\pgfplotsplothandlermesh@ONEDIMMODE{1}% - \fi - \ifnum\pgfplotsplothandlermesh@rows=1 - \def\pgfplotsplothandlermesh@ONEDIMMODE{1}% - \fi - % - % - % Prepare color data source: - \ifx\pgfplotspointmetainputhandler\pgfutil@empty% - % oh. There is no color data!? Well... then use a constant - % color. - % - % This activates tikz colors: - %\tikz@options - \def\pgfplotsplothandlermesh@preparedrawforcurrent{% - \pgfplots@drawoptions - }% - \else - % Ok, we have color data. - % - % Prepare: - \pgfplots@perpointmeta@preparetrafo - \def\pgfplotsplothandlermesh@preparedrawforcurrent{% - \pgfplotscolormapdefinemappedcolor{\pgfplotsplothandlermesh@shader@cellcolor}% -% \pgfplotsplothandlermesh@setcolor{mapped color}% - % This activates tikz colors: -%\message{executing \meaning\pgfplots@drawoptions'}% - %\tikz@options - \pgfplots@drawoptions - }% - % - % Acquire the values for \tikz@mode@* [used for faceted] - \pgfplots@drawmodes - % - % Now, process the 'shader' key here: - \if\pgfplotsplothandlermesh@ONEDIMMODE1 - \def\pgfplots@meshmode{m}% 'mesh' - \fi - \if\pgfplots@meshmode m% mesh - % this is processed by the 'shader=flat' code below. - \def\pgfplotsplothandlermesh@shader{0}% 'flat' - \fi - \if\pgfplotsplothandlermesh@shader2% 'shader=interp' - \pgflibrarysurfshadingifactive - {}% - {% - \pgfutil@ifundefined{pgfplotsplothandlermesh@shader@warning}{% - \pgfplots@error{Sorry, surface shading (shader=interp) is NOT available for the selected driver `\pgfsysdriver'. I will use 'shader=flat' if you continue now}% - \gdef\pgfplotsplothandlermesh@shader@warning{x}% - }{}% - \def\pgfplotsplothandlermesh@shader{0}% - }% - \fi - \if\pgfplotsplothandlermesh@zbuffer@choice4% 'z buffer=sort': - \if\pgfplotsplothandlermesh@shader2% 'shader=interp' - \pgfplots@error{Sorry, 'shader=interp' does not support 'z buffer=sort'. If you continue now, 'shader=flat' will be used.}% - \def\pgfplotsplothandlermesh@shader{0}% 'flat' - \fi - \fi - \ifnum\pgfplotsplothandlermesh@shader<2 - % 0 == 'flat' - % 1 == 'faceted' - \if\pgfplotsplothandlermesh@flatmode c% 'flat corner': - % - % use colordata of ONE corner point. That's easy, not - % much to do. - \let\pgfplotsplothandlermesh@unpack=\pgfplotsplothandlermesh@unpack@corner - \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@preparedrawforcurrent}% - \t@pgfplots@tokb={% - \pgfplots@perpointmeta@trafo@APPLY - \let\pgfplotsplothandlermesh@shader@cellcolor=\pgfplotspointmetatransformed}% - \edef\pgfplotsplothandlermesh@preparedrawforcurrent{% - \the\t@pgfplots@tokb - \the\t@pgfplots@toka - }% - \else - % 'flat mean': - % - % use colordata as mean of all corners for shading. - \let\pgfplotsplothandlermesh@unpack=\pgfplotsplothandlermesh@unpack@mean@accum - \global\pgfplots@tmpa=0pt - \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@preparedrawforcurrent}% - \if\pgfplotsplothandlermesh@ONEDIMMODE0 - \t@pgfplots@tokb={\global\divide\pgfplots@tmpa by4 }% - \else - \t@pgfplots@tokb={\global\divide\pgfplots@tmpa by2 }% - \fi - \t@pgfplots@tokc={% - \edef\pgfplotsplothandlermesh@shader@cellcolor{\pgf@sys@tonumber\pgfplots@tmpa}% - \global\pgfplots@tmpa=0pt }% - \edef\pgfplotsplothandlermesh@preparedrawforcurrent{% - \the\t@pgfplots@tokb - \the\t@pgfplots@tokc - \the\t@pgfplots@toka - }% - \fi - \if\pgfplots@meshmode m% - % 'mesh' plot: stroke only and use the 'flat' code - % here just to define the color for each mesh - % segment. - \let\pgfplotsplothandlermesh@usepath=\pgfusepathqstroke - \else - % 'surf' plot: - \let\pgfplotsplothandlermesh@usepath=\pgfusepathqfillstroke - % the distinction between 'faceted' and 'flat' is - % technical: it is just the default draw color. - % - % 'flat,draw=black' is the same as 'faceted'. - \if\pgfplotsplothandlermesh@shader1% faceted - % make sure there is a the correct color. - \expandafter\def\expandafter\pgfplots@drawoptions\expandafter{% - \pgfplots@drawoptions - \pgfsetstrokecolor{\pgfkeysvalueof{/pgfplots/faceted color}}% - }% - \fi - \fi - \else - % 'shader=2': 'interp': - % very simple: defer work to surf library. Only - % provide the mapped colordata. - % - % This won't be used for mesh plots, neither in one - % nor in two dimensions. - \pgfkeyssetvalue{/pgfplots/surf shading/north east corner}{\pgfplotspointbbupperright}% - \pgfkeyssetvalue{/pgfplots/surf shading/south west corner}{\pgfplotspointbblowerleft}% - \pgfkeyssetvalue{/pgfplots/surf shading/anchor}{\pgfpointorigin}% - \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa - \expandafter\pgfplotscolormaptopdffunction\expandafter{\pgfplots@loc@TMPa}% - \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsretval - \let\pgfplotsplothandlermesh@unpack=\relax % unused. - \let\pgfplotsplothandlermesh@preparedrawforcurrent=\relax - \pgfkeyslet{/pgfplots/surf shading/cols}\pgfplotsplothandlermesh@cols - \if\pgfplots@plot@mesh@ordering0% - % ordering=x varies: - \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@shader@interp% - \else - % colwise: - % - % The low level shader NEEDS rowwise ordering. So, we need to transpose the data matrix. - % As usual in TeX, we should save macros as much as possible. I guess we NEED at least one macro for each matrix row. - % Idea: - % while we iterate colwise through the input data, accumulate row vectors. - % Then, process the row vectors. - % Since vectors are expensive (in terms of number of macros), we use fast "append" lists instead of vectors. - \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@shader@interp@incremental@transpose% - % - % init all required row vectors: - \c@pgfplots@scanlineindex=0 - \pgfutil@loop - \ifnum\c@pgfplots@scanlineindex<\pgfplotsplothandlermesh@rows\relax - \expandafter\pgfplotsapplistXnewempty\csname pgfp@transprow@\the\c@pgfplots@scanlineindex\endcsname% - \advance\c@pgfplots@scanlineindex by1 - \pgfutil@repeat - %\pgfkeyslet{/pgfplots/surf shading/cols}\pgfplotsplothandlermesh@rows - %\pgfplots@error{Sorry, the 'shader=interp' does not yet support 'mesh/ordering=colwise'... You can continue now, but the plot will be transposed.}% - \fi - \pgfplotslibrarysurfstreamstart - \let\pgfplotsplothandlermesh@usepath=\pgfusepathqfill - \fi - \fi - % PREPARE THE STREAM PROCESSING: - \def\pgfplots@plothandler@unbounded@visualize@jump{% - \pgfplotstreampoint{\global\pgf@x=-16000.0pt \global\pgf@y=-16000.0pt }% - }% - \let\pgfplotsplothandlermesh@check@unbounded=\pgfplotsplothandlermesh@check@unbounded@setbool - \if\pgfplotsplothandlermesh@ONEDIMMODE1% - % Special case: 1D mesh processing - \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@ONEDIM@draw% - \global\let\pgf@plotstreamspecial=\pgfutil@gobble% - \global\let\pgf@plotstreamend=\pgfplotsplothandlermesh@finish% - \let\pgfplotsplothandlermesh@draw@element=\pgfplotsplothandlermesh@draw@element@line - \def\pgfplotsplothandlermesh@process@element{% - \pgfplotsplothandlermesh@draw@element - \pgfplotsplothandlermesh@i - \pgfplotsplothandlermesh@im - }% - \if\pgfplots@unbounded@handler j% - % unbounded coords=jump: - % append checks for unbounded coords to - % \pgfplotsplothandlermesh@process@element - \t@pgfplots@tokb={% - \pgfplots@loc@tmptrue - \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@i\relax - \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@im\relax - }% - \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@process@element}% - \edef\pgfplotsplothandlermesh@process@element{% - \the\t@pgfplots@tokb - \noexpand\ifpgfplots@loc@tmp - \the\t@pgfplots@toka - \noexpand\fi - }% - \fi - \if\pgfplotsplothandlermesh@zbuffer@choice4% - % z buffer=sort: - % create a z buffer: - % the z buffer contains elements {<view depth>}{{<pt1>}{<pt2>}{<pt3>}{<pt4>}} - \pgfplotsarraynewempty\pgfplots@zbuffer@local - % - % and collect each point into the z buffer: - \def\pgfplotsplothandlermesh@process@element{% - \pgfplotsmathviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% FIXME relies on pgfplots macros - % assemble array element: - \edef\pgfplots@loc@TMPa{% - {\pgfmathresult}% - {% - {\pgfplotsplothandlermesh@i}% - {\pgfplotsplothandlermesh@im}% - }% - }% - \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPa\to\pgfplots@zbuffer@local - }% - \fi - \else - % ok, normal 2D mesh processing: - % - % And now finally: initialise the conversion from - % LINEARIZED COORD STREAM -> DATA MATRIX: - \if\pgfplots@plot@mesh@ordering0% - % x varies (=rowwise): - \let\pgfplotsplothandlermesh@scanlinelength=\pgfplotsplothandlermesh@cols - \else - % y varies (=colwise): - \let\pgfplotsplothandlermesh@scanlinelength=\pgfplotsplothandlermesh@rows - \fi - \def\pgfplotsplothandlermesh@process@element{% - \pgfplotsplothandlermesh@draw@element - \pgfplotsplothandlermesh@im@jm - \pgfplotsplothandlermesh@im@j - \pgfplotsplothandlermesh@i@j - \pgfplotsplothandlermesh@i@jm - }% - % Init memory: - % 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}% - % - \if2\pgfplotsplothandlermesh@shader - % shader=interp does not support z buffer=sort. - % It also has its own \pgf@plotstreampoint method, see - % above. - \def\pgfplots@plothandler@unbounded@visualize@jump{% - \pgfplots@error{Sorry, shader=interp does not support 'unbounded coords=jump'. Please use 'shader=flat' for this case.}% - }% - \else - \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@fillscanline% - \if\pgfplotsplothandlermesh@zbuffer@choice4% - % z buffer=sort: - % create a z buffer: - % the z buffer contains elements {<view depth>}{{<pt1>}{<pt2>}{<pt3>}{<pt4>}} - \pgfplotsarraynewempty\pgfplots@zbuffer@local - % - % and collect each point into the z buffer - % (instead of drawing it): - \def\pgfplotsplothandlermesh@process@element{% - \pgfplotsmathviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% FIXME relies on pgfplots macros - % assemble array element: - \edef\pgfplots@loc@TMPa{% - {\pgfmathresult}% - {% - {\pgfplotsplothandlermesh@im@jm}% - {\pgfplotsplothandlermesh@im@j}% - {\pgfplotsplothandlermesh@i@j}% - {\pgfplotsplothandlermesh@i@jm}% - }% - }% - \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPa\to\pgfplots@zbuffer@local - }% - \fi - \if\pgfplots@unbounded@handler j% - % unbounded coords=jump: - % append checks for unbounded coords to - % \pgfplotsplothandlermesh@process@element - \t@pgfplots@tokb={% - \pgfplots@loc@tmptrue - \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@i@j\relax - \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@i@jm\relax - \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@im@j\relax - \expandafter\pgfplotsplothandlermesh@check@unbounded\pgfplotsplothandlermesh@im@jm\relax - }% - \t@pgfplots@toka=\expandafter{\pgfplotsplothandlermesh@process@element}% - \edef\pgfplotsplothandlermesh@process@element{% - \the\t@pgfplots@tokb - \noexpand\ifpgfplots@loc@tmp - \the\t@pgfplots@toka - \noexpand\fi - }% - \fi - \fi - % - \global\let\pgf@plotstreamspecial=\pgfutil@gobble% - \global\let\pgf@plotstreamend=\pgfplotsplothandlermesh@finish% - \let\pgfplotsplothandlermesh@draw@element=\pgfplotsplothandlermesh@draw@element@rectangle - \fi - \c@pgfplots@scanlineindex=0 - }% -}% - -\def\pgfplotsplothandlermesh@check@unbounded@setbool#1#2\relax{% - \ifdim#1=-16000pt - \pgfplots@loc@tmpfalse - \fi -}% - -\long\def\pgfplotsplothandlermesh@defaultlegend@img#1{% - \scope[% - #1, - /pgfplots/mesh/rows=3, - /pgfplots/mesh/cols=3, - /pgfplots/mesh/num points=, - /tikz/x={(0.44237cm,-0.07439cm)}, - /tikz/y={(0.30942cm,0.23932cm)}, - /tikz/z={(0.0cm,1.5cm)}, - scale=0.4, - yshift=-0.7cm, - ] - \let\pgfplots@metamax=\pgfutil@empty - \pgfplots@curplot@threedimtrue - - \pgfplotsplothandlermesh - \pgfplotstreamstart - - \def\rangea{0.21}% - \def\rangeb{0.7}% - - \pgfmathparse{1000/(\rangeb-\rangea)} - \let\factor=\pgfmathresult - - \pgfutil@ifundefined{pgfqpointxyz@orig}{% - \let\pgfqpointxyz@orig=\pgfqpointxyz - }{}% - % - \def\simplecoordinate(##1,##2,##3){% - \pgfmathparse{\factor*(##3 - \rangea)}% - \pgfmathfloatparsenumber\pgfmathresult - \let\pgfplots@current@point@meta=\pgfmathresult - % pgfplots changes \pgfqpointxyz to - % \pgfplotspointdescriptionxy inside of legends, so use the - % '@orig' point command: - \pgfplotstreampoint{\pgfqpointxyz@orig{##1}{##2}{##3}}% - }% - % for the case 'shader=interp': - \def\pgfplotspointbbupperright{\pgfqpointxyz@orig{2}{2}{0.9}} - \def\pgfplotspointbblowerleft {\pgfqpointxyz@orig{0}{0}{0.1}} - - \simplecoordinate(0,2,0.7) - \simplecoordinate(1,2,0.5) - \simplecoordinate(2,2,0.43) - - \simplecoordinate(0,1,0.68) - \simplecoordinate(1,1,0.4) - \simplecoordinate(2,1,0.25) - - \simplecoordinate(0,0,0.6) - \simplecoordinate(1,0,0.35) - \simplecoordinate(2,0,0.21) - - \pgfplotstreamend - \pgfusepath{stroke} - \endscope -}% - -\def\pgfplotsplothandlermesh@finish{% - \ifnum\pgfplotsplothandlermesh@shader=2 - % shader=interp: - \ifx\pgf@plotstreampoint\pgfplotsplothandlermesh@shader@interp@incremental@transpose% - % This is the case for 'mesh/ordering=colwise'. We need to finish the transpose procedure: - \pgfplotsplothandlermesh@shader@interp@transpose@finish - \fi - \pgfplotslibrarysurfstreamend - \pgfplotslibrarysurfdrawinpicture - \else - \if\pgfplotsplothandlermesh@zbuffer@choice4% - % z buffer=sort: - % process the z buffer: - \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplotsplothandlermesh@zbuffer@sort@iflessthen - \pgfkeysdef{/pgfplots/array/unscope pre}{% - \pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{% - \expandafter\pgfplotsplothandlermesh@draw@zbufferelement\curelem% - }% - }% - \pgfkeysdef{/pgfplots/array/unscope post}{}% - \pgfplotsarraysort\pgfplots@zbuffer@local - \fi - \fi -% \endscope -}% - -% the pgf@plotstreampoint routine for the first scan line: -\def\pgfplotsplothandlermesh@fillscanline#1{% - \pgf@process{#1}% - \edef\pgfplotsplothandlermesh@i@j{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}}% - \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@i@j\to{lastscanline}% - \advance\c@pgfplots@scanlineindex by1 - \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax - % second line! - \global\let\pgf@plotstreampoint=\pgfplotsplothandlermesh@draw%% - \c@pgfplots@scanlineindex=0 - \fi -}% - -% This is the pgf@plotstreampoint for all scan lines starting with the -% second. -% -% We perform -% for i = 1 to rows (note the 1! 0 would be the first row) -% for j = 0 to cols -% get (i-1, j) from front of deque // remember: i: rows, j : cols. We iterate rowwise. -% push (i,j) to back of deque -% if j > 0 -% draw -% (i-1,j-1) [from last iteration] -- (i-1,j) [from deque] -% -- ( i,j-1) [from last iteration] -- ( i,j) [from #1] -% endif -% let (i-1,j-1) := (i-1,j) // for next iteration -% let ( i,j-1) := ( i,j) // for next iteration -% end -% end -% -% This is a SWEEP through the data matrix. -\def\pgfplotsplothandlermesh@draw#1{% - % NOTATION: - % 'im == (i-1)' - % 'jm == (j-1)' - \pgf@process{#1}% - \edef\pgfplotsplothandlermesh@i@j{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}}% FIXME relies on pgfplots macros -%\message{##\the\c@pgfplots@scanlineindex: prepare rectangle with corner \meaning\pgfplotsplothandlermesh@i@j.}% - \pgfplotsdequepopfront{lastscanline}\to\pgfplotsplothandlermesh@im@j - \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@i@j\to{lastscanline}% - \ifnum\c@pgfplots@scanlineindex>0 - \pgfplotsplothandlermesh@process@element - \fi - \let\pgfplotsplothandlermesh@im@jm=\pgfplotsplothandlermesh@im@j - \let\pgfplotsplothandlermesh@i@jm=\pgfplotsplothandlermesh@i@j - \advance\c@pgfplots@scanlineindex by1 - \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax - \c@pgfplots@scanlineindex=0 - \fi -}% -\def\pgfplotsplothandlermesh@shader@interp#1{% - \pgfplots@perpointmeta@trafo@APPLY - \pgfplotslibrarysurfstreamcoord{#1}{\pgfplotspointmetatransformed}% -}% -\def\pgfplotsplothandlermesh@shader@interp@incremental@transpose#1{% - \pgfplots@perpointmeta@trafo@APPLY - \pgf@process{#1}% - \edef\pgfplotsplothandlermesh@i{\noexpand\pgfplotsplothandlermesh@shader@interp@next{\the\pgf@x}{\the\pgf@y}{\pgfplotspointmetatransformed}}% - % - % Store the postprocessed point into the appropriate row vector: - \def\pgfplots@loc@TMPa{\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplotsplothandlermesh@i}\to} - \expandafter\pgfplots@loc@TMPa\csname pgfp@transprow@\the\c@pgfplots@scanlineindex\endcsname% - % - \advance\c@pgfplots@scanlineindex by1 - \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax - \c@pgfplots@scanlineindex=0 - \fi -}% -\def\pgfplotsplothandlermesh@shader@interp@transpose@finish{% - % Now, "execute" each row vector: - \def\pgfplotsplothandlermesh@shader@interp@next##1##2##3{% - \pgfplotslibrarysurfstreamcoord{\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@element#2\relax -}% -% a possible value for \pgfplotsplothandlermesh@draw@element -\def\pgfplotsplothandlermesh@draw@element@line#1#2{% - \pgfpathmoveto{\expandafter\pgfplotsplothandlermesh@unpack#1}% - \pgfpathlineto{\expandafter\pgfplotsplothandlermesh@unpack#2}% - \pgfplotsplothandlermesh@preparedrawforcurrent - \pgfplotsplothandlermesh@usepath -}% -% a possible value for \pgfplotsplothandlermesh@draw@element -\def\pgfplotsplothandlermesh@draw@element@rectangle#1#2#3#4{% - \pgfpathmoveto{\expandafter\pgfplotsplothandlermesh@unpack#1}% - \pgfpathlineto{\expandafter\pgfplotsplothandlermesh@unpack#2}% - \pgfpathlineto{\expandafter\pgfplotsplothandlermesh@unpack#3}% - \pgfpathlineto{\expandafter\pgfplotsplothandlermesh@unpack#4}% - \pgfplotsplothandlermesh@preparedrawforcurrent - \pgfpathclose - \pgfplotsplothandlermesh@usepath -}% - -\def\pgfplotsplothandlermesh@zbuffer@sort@iflessthen#1#2#3#4\pgfeov{% - \edef\pgfplots@loc@TMPa{#1}% - \expandafter\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@\pgfplots@loc@TMPa\relax - \let\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@a=\pgfmathresult - \edef\pgfplots@loc@TMPb{#2}% - \expandafter\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@\pgfplots@loc@TMPb\relax - \let\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@b=\pgfmathresult - \ifdim\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@b pt<\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@a pt% - #3\relax - \else - #4\relax - \fi -}% -\def\pgfplotsplothandlermesh@zbuffer@sort@iflessthen@#1#2{% - \def\pgfmathresult{#1}% -}% - -% #1: projected x coord -% #2: projected y coord -% #3: per point meta (if any) -\def\pgfplotsplothandlermesh@unpack@corner#1#2#3{% - \global\pgf@x=#1\relax - \global\pgf@y=#2\relax -}% -\def\pgfplotsplothandlermesh@unpack@mean@accum#1#2#3{% - \global\pgf@x=#1\relax - \global\pgf@y=#2\relax - \def\pgfplots@current@point@meta{#3}% - \pgfplots@perpointmeta@trafo@APPLY - \global\advance\pgfplots@tmpa by\pgfplotspointmetatransformed pt -}% -% same as above, just for one dim plots (rows == 1 || cols==1) -\def\pgfplotsplothandlermesh@ONEDIM@draw#1{% - \pgf@process{#1}% - \edef\pgfplotsplothandlermesh@i{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}}% - \ifnum\c@pgfplots@scanlineindex>0 - \pgfplotsplothandlermesh@process@element - \fi - \let\pgfplotsplothandlermesh@im=\pgfplotsplothandlermesh@i - \advance\c@pgfplots@scanlineindex by1 -}% % #1: a normalized coordinate stream. % @@ -6974,8 +8490,7 @@ \pgfplotsprependlistXnewempty{reversed}% }% \def\pgfplots@coord@stream@coord{% - \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z,\pgfplots@current@point@meta;}% - \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@loc@TMPa}\to{reversed}% + \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\to{reversed}% }% \def\pgfplots@coord@stream@end{% \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversed}% @@ -6997,8 +8512,7 @@ }% }% \def\pgfplots@coord@stream@coord{% - \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z,\pgfplots@current@point@meta;}% - \expandafter\pgfplots@zbuffer@local@SETCUR\expandafter{\pgfplots@loc@TMPa}% + \expandafter\pgfplots@zbuffer@local@SETCUR\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded}% \advance\c@pgfplots@scanlineindex by1 }% \def\pgfplots@coord@stream@end{% @@ -7010,7 +8524,7 @@ \pgfkeysdef{/pgfplots/array/unscope pre}{% \pgfplotsapplistXnewempty{\pgfp@sortedlist}% \pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{% - \expandafter\pgfplotsapplistXpushback\curelem\to{\pgfp@sortedlist}% + \expandafter\pgfplotsapplistXpushback\expandafter{\expandafter{\curelem}}\to{\pgfp@sortedlist}% }% \pgfplotsapplistXlet\pgfplots@loc@TMPa={\pgfp@sortedlist}% \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa @@ -7034,44 +8548,58 @@ % only need to know whether [xy] coordinates are sorted % ascending or descending. This information is already ready. % - \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}% + \if1\pgfplotsplothandlermesh@matrixinput + % mesh input=lattice + \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 - \pgfkeys{/pgfplots/z buffer=reverse x seq}% + \if1\pgfplots@reverse@y + \pgfkeys{/pgfplots/z buffer=reverse y seq}% + \else + \pgfkeys{/pgfplots/z buffer=none}% + \fi \fi +%\message{z buffer=auto mode chose z buffer= \ifcase\pgfplotsplothandlermesh@zbuffer@choice NONE \or reverse x seq \or reverse y seq \or reverse xy seq \or sort\or default \fi. mesh ordering = \ifcase\pgfplots@plot@mesh@ordering x varies/rowwise\or y varies/colwise\fi}% + % 'z buffer' is no longer 'auto' now: + \pgfplots@apply@zbuffer{#1}% + \endgroup \else - \if1\pgfplots@reverse@y - \pgfkeys{/pgfplots/z buffer=reverse y seq}% + % mesh input=patches + \ifpgfplots@threedim + \if\pgfplots@meshmode n% + \else + \pgfkeys{/pgfplots/z buffer=sort}% + \fi \else \pgfkeys{/pgfplots/z buffer=none}% \fi + \gdef\pgfplotsglobalretval{#1}% \fi -%\message{z buffer=auto mode chose z buffer= \ifcase\pgfplotsplothandlermesh@zbuffer@choice NONE \or reverse x seq \or reverse y seq \or reverse xy seq \or sort\or default \fi. mesh ordering = \ifcase\pgfplots@plot@mesh@ordering x varies/rowwise\or y varies/colwise\fi}% - % 'z buffer' is no longer 'auto' now: - \pgfplots@apply@zbuffer{#1}% - \endgroup \or % z buffer=default. \if\pgfplots@meshmode n% @@ -7079,10 +8607,8 @@ \gdef\pgfplotsglobalretval{#1}% \else % mesh=true - \begingroup \pgfkeysalso{/pgfplots/z buffer=auto}% \pgfplots@apply@zbuffer{#1}% - \endgroup \fi \fi }% @@ -7109,8 +8635,7 @@ \pgfplotsapplistXnewempty{\resultlist}% }% \def\pgfplots@coord@stream@coord{% - \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z,\pgfplots@current@point@meta;}% - \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@loc@TMPa}\to{reversedscanline}% + \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}% @@ -7145,8 +8670,7 @@ \pgfplotsprependlistXnewempty{resultlist}% }% \def\pgfplots@coord@stream@coord{% - \edef\pgfplots@loc@TMPa{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z,\pgfplots@current@point@meta;}% - \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPa}\to{\scanline}% + \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}% @@ -7175,12 +8699,14 @@ % A special '<' operation which returns true if the point coordinate % '#1' is BEHIND #2 with respect to the current 3D view. \def\pgfplots@apply@zbuffer@SORT@iflessthan#1#2#3#4\pgfeov{% - \edef\pgfplots@loc@TMPa{#1}% - \expandafter\pgfplots@apply@zbuffer@SORT@iflessthan@\pgfplots@loc@TMPa\relax + \pgfplotsaxisdeserializedatapointfrom{#1}% + \pgfplotsmathfloatviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% \let\pgfplots@apply@zbuffer@SORT@iflessthan@a=\pgfmathresult - \edef\pgfplots@loc@TMPb{#2}% - \expandafter\pgfplots@apply@zbuffer@SORT@iflessthan@\pgfplots@loc@TMPb\relax + % + \pgfplotsaxisdeserializedatapointfrom{#2}% + \pgfplotsmathfloatviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% \let\pgfplots@apply@zbuffer@SORT@iflessthan@b=\pgfmathresult + % \pgfmathfloatlessthan@{\pgfplots@apply@zbuffer@SORT@iflessthan@b}{\pgfplots@apply@zbuffer@SORT@iflessthan@a}% \ifpgfmathfloatcomparison #3\relax @@ -7189,14 +8715,6 @@ \fi }% -% returns the view depth of the provided serialized coordinate into -% \pgfmathresult -% -% FIXME : relies on the internal repr in -% \pgfplots@coord@stream@foreach@NORMALIZED : -\def\pgfplots@apply@zbuffer@SORT@iflessthan@#1,#2,#3,#4;{% - \pgfplotsmathfloatviewdepthxyz{#1}{#2}{#3}% -}% % Defines \pgfmathresult to be the view depth of a three component % vector. The third component will be used if and only if the boolean @@ -7321,7 +8839,7 @@ \if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname \else % ok, be fault tolerant and round to an integer: - \pgfmathfloattofixed{\pgfplotspointmeta}% + \pgfplotscoordmath{meta}{tofixed}{\pgfplotspointmeta}% \begingroup \pgfkeys{/pgf/number format/precision=0}% \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex index ec1642f9409..fe6106f4380 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex @@ -24,6 +24,8 @@ % %-------------------------------------------- +\def\pgfplotsset#{\pgfqkeys{/pgfplots}} + \def\pgfplots@error#1{\PackageError{pgfplots}{#1}{}}% \def\pgfplotstable@error@pkg#1{\PackageError{pgfplotstable}{#1}{}}% @@ -163,4 +165,6 @@ \pgfutil@ifundefined{pgfplots@texdist@protect}{% \def\pgfplots@texdist@protect{}% }{} + +\input pgfplotssysgeneric.code.tex \endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex new file mode 100644 index 00000000000..63cd7be107c --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex @@ -0,0 +1,2185 @@ +%-------------------------------------------- +% +% 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/>. +% +%-------------------------------------------- + +% 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) + \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 + \pgfplots@warning{% + mesh processing did not find '[mesh/rows=<N>]' or '[mesh/cols=<N>]'. + Assuming [mesh/rows=\pgfplotsplothandlermesh@rows,mesh/cols=\pgfplotsplothandlermesh@rows] + as sqrt(num points) = sqrt(\pgfplotsplothandlermesh@numpoints) [ = \pgfmathresult].}% + \else + \pgfplots@error{Sorry, 'plot mesh' needs either '[mesh/rows=<N>]' or '[mesh/cols=<N>]' set, + but it did not find any of them. + I also tried rows = sqrt(num points) = sqrt(\pgfplotsplothandlermesh@numpoints) = \pgfmathresult\space without success.}% + \fi + \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{\pgfplots@warning{##1}}% + \or + % mesh/check=error + \def\pgfplots@loc@TMPa##1{\pgfplots@error{##1}}% + \fi + \pgfplots@loc@TMPa{the arguments of [mesh/rows=\pgfplotsplothandlermesh@rows,mesh/cols=\pgfplotsplothandlermesh@cols] assume \the\c@pgfplots@scanlineindex\space points, but I got actually N = \pgfplotsplothandlermesh@numpoints\space points! The data matrix appears to be incomplete or overcomplete!? [Use mesh/check=false to disable this message]}% + \fi + \fi + \else + % 2d visualization has no mesh: + \edef\pgfplotsplothandlermesh@rows{\pgfplotsplothandlermesh@numpoints}% + \def\pgfplotsplothandlermesh@cols{1}% + \fi + % + \def\pgfplots@loc@TMPa{\pgfkeyssetvalue{/pgfplots/mesh/rows}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotsplothandlermesh@rows}% + \def\pgfplots@loc@TMPa{\pgfkeyssetvalue{/pgfplots/mesh/cols}}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotsplothandlermesh@cols}% +}% + +%% +%% Helper structs for patch plots (surfaces) + +\def\pgfplotspatchvertex#1#2#3#4\endvertex{% + \def\pgfplotspatchvertexstruct{{#1}{#2}{#3}#4}% + \def\pgfplotspatchvertexx{#1}% + \def\pgfplotspatchvertexy{#2}% + \def\pgfplotspatchvertexmeta{#3}% + \def\pgfplotspatchvertexdepth{#4}% +}% +\def\pgfplotspointpatchvertex#1#2#3#4\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 + \pgfplotscoordmath{meta}{zero}% +}% +\def\pgfplotspatchvertexadd#1#2#3#4\times#5{% + \global\pgf@x=#1 + \global\pgf@y=#2 + \advance\pgf@xa by#5\pgf@x + \advance\pgf@ya by#5\pgf@y + \let\pgfmathresult@=\pgfmathresult + \pgfplotscoordmath{meta}{parsenumber}{#5}% + \pgfplotscoordmath{meta}{op}{multiply}{{#3}{\pgfmathresult}}% + \pgfplotscoordmath{meta}{op}{add}{{\pgfmathresult@}{\pgfmathresult}}% + \def\pgfplotspatchvertexdepth{#4}% + \ifx\pgfplotspatchvertexdepth\pgfutil@empty + \else + \global\pgf@y=#4pt + \advance\pgf@yb by#5\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\times#5{% + \global\pgf@x=#1 + \global\pgf@y=#2 + \advance\pgf@xa by#5\pgf@x + \advance\pgf@ya by#5\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)}% + }% +}% + +\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=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}% + }% + },% + get num cdata vertices=\pgfplotspatchclass{\pgfplotspatchclassname}{get vertices}, + set edge visible=\expandafter\edef\csname pgfppatchedge@##1\endcsname{##2}, + uses view depth=0, + 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=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}% + },% + }% + }{}% + % + % + \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{\def\pgfplotsretval{#1}}},% + uses view depth/.code= + {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ uses view depth\endcsname{\def\pgfplotsretval{#1}}},% + 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}},% + % + % 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}},% + % + % 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 the 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}},% + % + % expands to the number of vertices. + get num vertices/.code= + {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ get num vertices\endcsname{\def\pgfplotsretval{#1}}},% + % + % expands to 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{\def\pgfplotsretval{#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{\def\pgfplotsretval{#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}},% +} + +\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=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 + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@line@A\endvertex, + foreach vertex={% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@line@A\endvertex #1% + \expandafter\pgfplotspatchvertex\pgfplotspatchclass@line@B\endvertex #1% + }, + fill path={% + \pgfpathmoveto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@line@A\endvertex}% + \pgfpathlineto{\expandafter\pgfplotspointpatchvertex\pgfplotspatchclass@line@B\endvertex}% + }, + serialize except vertices=\let\pgfplotsretval\pgfutil@empty,% + deserialize except vertices=, + get num vertices=2, + get pdf shading type=0, +}% + +\pgfplotsdeclarepatchclass{triangle}{% + allow matrix=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 + }, + 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=3, +}% +\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% +}% + + +\pgfplotsdeclarepatchclass{rectangle}{% + allow matrix=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 + }, + first vertex=\expandafter\pgfplotspatchvertex\pgfplotspatchclass@rect@A\endvertex, + 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}% + }% + \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@@% + },% + 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@D}% + \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}% + % + \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=4, +}% + +\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. +% +% #2: A macro name. It will be defined to be either A,B,C or D. +% #3: A macro name. 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{}% +} + +% The low-level tikz plot handler for 3D mesh and surface plots. +% +% It expects +% a) a coordinate stream which is a linearized matrix, iterated either +% rowwise or column wise, +% b) the current set of options in /pgfplots/mesh/. +% +% +% ATTENTION: +% this handler is NOT as general as the others. In particular, it +% can't be interrupted by TeX groups: every single statement, +% starting with streamstart and ending with stream end, must be in +% the same scope! +% +% As a consequence, you can't use this handler inside of (all) TikZ +% input streams. Try it out. It will work in pgfplots, however. +% +% Furthermore, it relies on a couple of pgfplots macros. This may +% change in future versions. +% It relies on: +% - \ifpgfplots@curplot@threedim +% - \pgfplots@current@point@meta +% -> it also invokes \pgfplots@perpointmeta@preparetrafo and its +% @APPLY counterpart which checks for +% - \pgfplots@metamax +% If you use it outside of pgfplots, use +% \global\let\pgfplots@metamax=\pgfutil@empty +% This is can be used without an initialised +% pgfplots axes - as long as \pgfplots@current@point@meta is in +% the range [0,1000]. +% - for the case 'shader=interp', a bounding box must be established +% before the plot is finished. This must be done using +% \def\pgfplotspointbbupperright{\pgfqpointxyz{2}{2}{0.9}} +% \def\pgfplotspointbblowerleft {\pgfqpointxyz{0}{0}{0.1}} +% or something like that. +% +% Besides these internals, it also relies on all public /pgfplots +% configuration keys related to mesh/surface plots. +% +% Please note that the 'z buffer' feature will not work without +% pgfplots (especially the z buffer=sort feature). +% +% Here is an example which compiles without a pgfplots axes: +% ---------------------------------------------------------- +% \begin{tikzpicture} +% \scope[ +% /pgfplots/.cd, +% surf, +% shader=faceted, +% mesh/rows=4, +% mesh/cols=4, +% mesh/num points=, +% /tikz/x={(0.44237cm,-0.07439cm)}, +% /tikz/y={(0.30942cm,0.23932cm)}, +% /tikz/z={(0.0cm,1.5cm)}, +% ] +% \makeatletter +% +% \global\let\pgfplots@metamax=\pgfutil@empty +% \pgfplots@curplot@threedimtrue +% +% \pgfplotsplothandlermesh +% \pgfplotstreamstart +% +% \def\rangea{0.21}% +% \def\rangeb{0.9}% +% +% \pgfmathparse{1000/(\rangeb-\rangea)} +% \let\factor=\pgfmathresult +% +% \def\simplecoordinate(#1,#2,#3){% +% \pgfmathparse{\factor*(#3 - \rangea)}% +% \let\pgfplots@current@point@meta=\pgfmathresult +% \pgfplotstreampoint{\pgfqpointxyz{#1}{#2}{#3}}% +% }% +% % for the case 'shaer=interp': +% \def\pgfplotspointbbupperright{\pgfqpointxyz{2}{2}{0.9}} +% \def\pgfplotspointbblowerleft {\pgfqpointxyz{0}{0}{0.1}} +% +% \simplecoordinate(0,3,0.7) +% \simplecoordinate(1,3,0.5) +% \simplecoordinate(2,3,0.58) +% \simplecoordinate(3,3,0.9) +% +% \simplecoordinate(0,2,0.68) +% \simplecoordinate(1,2,0.22) +% \simplecoordinate(2,2,0.25) +% \simplecoordinate(3,2,0.4) +% +% \simplecoordinate(0,1,0.6) +% \simplecoordinate(1,1,0.3) +% \simplecoordinate(2,1,0.21) +% \simplecoordinate(3,1,0.3) +% +% \simplecoordinate(0,0,0.8) +% \simplecoordinate(1,0,0.56) +% \simplecoordinate(2,0,0.5) +% \simplecoordinate(3,0,0.75) +% +% +% \pgfplotstreamend +% \pgfusepath{stroke} +% +% \endscope +% \end{tikzpicture} +% ---------------------------------------------------------- +% END OF EXAMPLE +% -> see also the legend image for mesh plots. +% +\def\pgfplotsplothandlermesh{% + \pgfkeysgetvalue{/pgfplots/patch type}\pgfplotsplothandlermesh@patchclass + \ifx\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@defaulttext + \let\pgfplotsplothandlermesh@patchclass=\pgfutil@empty + \fi + % FIXME : detect 1d mode here! + \ifx\pgfplotsplothandlermesh@patchclass\pgfutil@empty + % assign default patch class. + \if1\pgfplotsplothandlermesh@matrixinput + \def\pgfplotsplothandlermesh@patchclass{rectangle}% + \else + \def\pgfplotsplothandlermesh@patchclass{triangle}% + \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 + % + \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 + \fi + \def\pgf@plotstreamstart{% +% \scope + % + % this shouldn't be necessary, but it doesn't hurt either. + \pgfplots@perpointmeta@preparetrafo + % + \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: + \let\b@pgfplotsplothandlermesh@matrixoutput=\pgfplotsplothandlermesh@matrixinput + \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 + \if\pgfplotsplothandlermesh@zbuffer@choice4% 'z buffer=sort': + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + \if2\pgfplotsplothandlermesh@shader + \else + % 'shader!=interp' + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{get pdf shading type}% + \if4\pgfplotsretval + \else + \if5\pgfplotsretval + \else + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + \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) + \ifnum\pgfplotsplothandlermesh@shader>1 + % shader=interp or shader=faceted interp + % + % 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}% + \fi + \fi + \fi + % + \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!? Well... then use a constant + % color. + % + % This activates tikz colors: + %\tikz@options + \def\pgfplotsplothandlermesh@definecolor{% + \pgfplots@drawoptions + }% + \else + \pgfplotsplothandlermesh@init@cdata + \pgfplotsplothandlermesh@init@shader + \pgfplotsplothandlermesh@init@flat@color + \fi + % PREPARE THE STREAM PROCESSING: + % handling of jumps. + \pgfplotsplothandlermesh@init@jumphandling + % + % z buffering: + \pgfplotsplothandlermesh@init@zbuffer + % + \pgfplotsplothandlermesh@init@mesh@stream + % + \c@pgfplots@scanlineindex=0 + }% +}% +\def\pgfplotsplothandlermesh@patchclass@defaulttext{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{% + \pgfplotsmathviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% FIXME relies on pgfplots macros + \edef\pgfplotsretval{\pgfmathresult}% +}% + + +% 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 + \pgf@process{#1}% + % calls \pgfplotspatchready when ready + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set next vertex}{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\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 + \expandafter\pgfplotsplothandlermesh@PIPE@REFINE + \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@VISUALIZE +}% + +% Standard implementation for VISUALIZE +\def\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke{% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{fill path}% + \pgfplotsplothandlermesh@definecolor + \pgfplotsplothandlermesh@usepath +}% +\let\pgfplotsplothandlermesh@VISUALIZE@std=\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke + +\let\pgfplotsplothandlermesh@VISUALIZE=\pgfplotsplothandlermesh@VISUALIZE@std + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\pgfplotsplothandlermesh@init@DECODE{% + \if1\pgfplotsplothandlermesh@matrixinput + % mesh input=lattice + % 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 + \else + % y varies (=colwise): + \let\pgfplotsplothandlermesh@scanlinelength=\pgfplotsplothandlermesh@rows + \fi + % + \if1\pgfplotsplothandlermesh@ONEDIMMODE +%\message{initialised DECODE for 1d mode.^^J}% + \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@matrix@ONEDIMMODE + \else + \if0\b@pgfplotsplothandlermesh@matrixoutput + % 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}% + \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline +%\message{initialised DECODE for patch output (from matrix).^^J}% + \else + % SPECIAL HANDLING! + \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@to@shader +%\message{initialised DECODE for direct matrix output (from matrix).^^J}% + \fi + \fi + \else +%\message{initialised DECODE for patch output (from patch).^^J}% + \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 +\newif\ifpgfplotsplothandlermesh@patchtable@hascdata +\newif\ifpgfplotsplothandlermesh@patchtable@cdata@individual +\def\pgfplotsplothandlersurveystart@mesh@patchtable{% + \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{% + \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@default + \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@default + \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@default + \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{% + \pgfplotsplothandlermesh@patchtable:\pgfplotstablelineno\space\space could not read column no \the\c@pgf@countb: '\pgfplots@current@vertexindex' is no valid index into the array of \pgfplotsarraysizeof\pgfplots@verts\space coordinates% +}% +\def\pgfplotsplothandlermesh@patchtable@rowlistener{% + \pgfplotsplothandlermesh@patchtable@init% + \let\pgfplotsexceptionmsg=\pgfplotsplothandlermesh@patchtable@rowlistener@exceptionmsg + % + \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 + % + \pgfplotsarrayselect\pgfplots@current@vertexindex\of\pgfplots@verts\to\pgfplots@stored@pt + % + \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 + \let\pgfplotsexceptionmsg=\relax +} +\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{% + \if1\pgfplotsplothandlermesh@matrixinput + % mesh input=lattice + \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 + \else + % mesh input=patches + \pgfkeys{/pgfplots/mesh/ordering/x varies}% disable any special handling. + \fi +}% + + +\def\pgfplotsplothandlermesh@init@cdata{% + % Ok, we have color data. + % + % Prepare: + \def\pgfplotsplothandlermesh@definecolor{% + \pgfplotsplothandlermesh@get@flat@color + \pgfplotscolormapdefinemappedcolor{\pgfplotsretval}% + \pgfplots@drawoptions + }% + % + % Acquire the values for \tikz@mode@* [used for faceted] + \pgfplots@drawmodes +} + + +\let\pgfsetstrokecolor@orig=\pgfsetstrokecolor +\def\pgfplotsplothandlermesh@VISUALIZE@std@separate@fillstroke@setstrokecolor#1{% + \pgfsetstrokecolor@orig{.}% +}% +\def\pgfplotsplothandlermesh@VISUALIZE@std@separate@fillstroke{% + \pgfplotsplothandlermesh@get@flat@color + \pgfplotscolormapdefinemappedcolor{\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 +}% + +\def\pgfplotsplothandlermesh@VISUALIZE@interp{% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{stream to shader}% +}% + +\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{% + % + % Now, process the 'shader' key here: + \if\pgfplotsplothandlermesh@ONEDIMMODE1 + \def\pgfplots@meshmode{m}% 'mesh' + \fi + \if\pgfplots@meshmode m% mesh + % this is processed by the 'shader=flat' code below. + \def\pgfplotsplothandlermesh@shader{0}% 'flat' + \fi + \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 + % + % + \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/north east corner}{\pgfplotspointbbupperright}% + \pgfkeyssetvalue{/pgfplots/surf shading/south west corner}{\pgfplotspointbblowerleft}% + \pgfkeyssetvalue{/pgfplots/surf shading/anchor}{\pgfpointorigin}% + \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}% + \fi + \pgfkeyslet{/pgfplots/surf shading/shading type}\pgfplotsretval% + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa + \expandafter\pgfplotscolormaptopdffunction\expandafter{\pgfplots@loc@TMPa}% + \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsretval + \pgfplotscolormapgetcolorspace\pgfplots@loc@TMPa + \pgfkeyslet{/pgfplots/surf shading/colorspace}\pgfplotsretval + \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' + \let\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 + \if\pgfplotsplothandlermesh@flatmode c% 'flat corner': + % + % use colordata of ONE corner point. That's easy, not + % much to do. + \def\pgfplotsplothandlermesh@get@flat@color{% + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{first vertex}% + \let\pgfplots@current@point@meta=\pgfplotspatchvertexmeta + \pgfplotsaxisvisphasetransformpointmeta + \let\pgfplotsretval=\pgfplotspointmetatransformed% + }% + \else + % 'flat mean': + % + % use colordata as mean of all corners for shading. + \global\pgfplots@tmpa=0pt + \def\pgfplotsplothandlermesh@get@flat@color{% + \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 vertices}% + \global\divide\pgfplots@tmpa by\pgfplotsretval\relax + \edef\pgfplotsretval{\pgf@sys@tonumber\pgfplots@tmpa}% + \global\pgfplots@tmpa=0pt + }% + \fi + % + % + \if\pgfplots@meshmode m% + % 'mesh' plot: stroke only and use the 'flat' code + % here just to define the color for each mesh + % segment. + \let\pgfplotsplothandlermesh@usepath=\pgfusepathqstroke + \else + % 'surf' plot: + \let\pgfplotsplothandlermesh@usepath=\pgfusepathqfillstroke + \if\pgfplotsplothandlermesh@shader3% faceted interp + % it has an extra fill command (shading) + \let\pgfplotsplothandlermesh@usepath=\pgfusepathqstroke + \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=\pgfusepathqfill + \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 + % + \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\pgfusepathqstroke + \let\pgfplotsplothandlermesh@usepathfill=\relax + \let\pgfplotsplothandlermesh@usepathstroke=\pgfusepathqstroke + \else + \ifx\pgfplotsplothandlermesh@usepath\pgfusepathqfillstroke + \let\pgfplotsplothandlermesh@usepathfill=\pgfusepathqfillstroke + \let\pgfplotsplothandlermesh@usepathstroke=\pgfusepathqstroke + \else + \let\pgfplotsplothandlermesh@usepathfill=\relax + \let\pgfplotsplothandlermesh@usepathstroke=\relax + \fi + \fi + \fi + \fi +}% + + +\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 }% + }% + % + \if0\pgfplotsaxisplothasjumps + \pgfplotsplothandlermesh@PIPE@CHECKJUMP@disable + \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% + % 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% + % + \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 + \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}% +} + +{ +\dimen0=-16000.0pt +\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=, + /tikz/x={(0.44237cm,-0.07439cm)}, + /tikz/y={(0.30942cm,0.23932cm)}, + /tikz/z={(0.0cm,1.5cm)}, + scale=0.4, + yshift=-0.7cm, + ] + \let\pgfplots@metamax=\pgfutil@empty + \pgfplots@curplot@threedimtrue + + \pgfplotsplothandlermesh + \pgfplotstreamstart + + \def\rangea{0.21}% + \def\rangeb{0.7}% + + \pgfmathparse{1000/(\rangeb-\rangea)} + \let\factor=\pgfmathresult + + \pgfutil@ifundefined{pgfqpointxyz@orig}{% + \let\pgfqpointxyz@orig=\pgfqpointxyz + }{}% + % + \def\simplecoordinate(##1,##2,##3){% + \pgfmathparse{\factor*(##3 - \rangea)}% + \pgfmathfloatparsenumber\pgfmathresult + \let\pgfplots@current@point@meta=\pgfmathresult + % pgfplots changes \pgfqpointxyz to + % \pgfplotspointdescriptionxy inside of legends, so use the + % '@orig' point command: + \pgfplotstreampoint{\pgfqpointxyz@orig{##1}{##2}{##3}}% + }% + % for the case 'shader=interp': + \def\pgfplotspointbbupperright{\pgfqpointxyz@orig{2}{2}{0.9}} + \def\pgfplotspointbblowerleft {\pgfqpointxyz@orig{0}{0}{0.1}} + + \simplecoordinate(0,2,0.7) + \simplecoordinate(1,2,0.5) + \simplecoordinate(2,2,0.43) + + \simplecoordinate(0,1,0.68) + \simplecoordinate(1,1,0.4) + \simplecoordinate(2,1,0.25) + + \simplecoordinate(0,0,0.6) + \simplecoordinate(1,0,0.35) + \simplecoordinate(2,0,0.21) + + \pgfplotstreamend + \pgfusepath{stroke} + \endscope +}% + +\def\pgfplotsplothandlermesh@finish{% + \if\pgfplotsplothandlermesh@zbuffer@choice4% + % 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@VISUALIZE}% + \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 +}% + + +\def\pgfplotsplothandlermesh@PIPE@DECODE@to@shader#1{% + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotslibrarysurfstreamcoord + {#1}% + {\pgfplotspointmetatransformed}% +}% + +\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix@ONEDIMMODE#1{% + \let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input + \pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval + \pgf@process{#1}% + \edef\pgfplotsplothandlermesh@i{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\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 +}% + +% the pgf@plotstreampoint routine for the first scan line: +\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline#1{% + \pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval + \pgf@process{#1}% + \edef\pgfplots@loc@TMPa{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplotsretval}% + \expandafter\pgfplotsdequepushback\pgfplots@loc@TMPa\to{lastscanline}% + \advance\c@pgfplots@scanlineindex by1 + \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. +\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix#1{% + % NOTATION: + % 'im == (i-1)' + % 'jm == (j-1)' + \pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval + \pgf@process{#1}% + \edef\pgfplotsplothandlermesh@i@j{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\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 + \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}% + \fi + \let\pgfplotsplothandlermesh@im@jm=\pgfplotsplothandlermesh@im@j + \let\pgfplotsplothandlermesh@i@jm=\pgfplotsplothandlermesh@i@j + \advance\c@pgfplots@scanlineindex by1 + \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax + \c@pgfplots@scanlineindex=0 + \fi +}% +\def\pgfplotsplothandlermesh@shader@interp@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/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex new file mode 100644 index 00000000000..7506cabcf16 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex @@ -0,0 +1,2230 @@ +%-------------------------------------------- +% +% 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 +% +% 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 +% 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>}. +% +% 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. +% + +\def\pgfplotssurveyphaseinputclass{direct} + +% Resets the plot handler routines. +% +% This is necessary before installing a new plot handler! +\def\pgfplotsresetplothandler{% + \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@default + \let\pgfplotsplothandlername=\pgfplotsplothandlername@default + \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@default + \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@default + \let\pgfplotsplothandlerserializepointto=\pgfplotsplothandlerserializepointto@default + \let\pgfplotsplothandlerdeserializepointfrom=\pgfplotsplothandlerdeserializepointfrom@default + \let\pgfplotsplothandlerserializestateto=\pgfplotsplothandlerserializestateto@default + \let\pgfplotsplothandlerdeserializestatefrom=\pgfplotsplothandlerdeserializestatefrom@default + \let\pgfplotsplothandlervisualizejump=\pgfplotsplothandlervisualizejump@default + \let\pgfplotsplothandlernotifyscanlinecomplete=\relax +}% + +% \pgfplotsplothandlersurveystart +\def\pgfplotsplothandlersurveystart@default{}% + +% \pgfplotsplothandlername +\def\pgfplotsplothandlername@default{% + [tikz@plot@handler: \meaning\pgf@plotstreamstart]% +}% + +% \pgfplotsplothandlersurveyend +% Called at the end of each survey phase. +\def\pgfplotsplothandlersurveyend@default{} +\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{% + \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,mi; + % where zi and mi may be empty. mi is the per-point meta + % information. It is used for per-coordinate marker + % modifications (like colormaps for scatter plots). + \edef#1{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}% +}% + +% the counterpart for \pgfplotsplothandlerserializepointto. +% It should restore the state as it was before the serialization. +% +% #1: the serialized information. +\def\pgfplotsplothandlerdeserializepointfrom@default#1{% + \expandafter\pgfplotsplothandlerdeserializepointfrom@default@#1\relax +}% + +\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 +}% + +\pgfplotsresetplothandler + +% ================================== + +% 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 + \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 + \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 + \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\pgfplots@prepare@xcoord{\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\pgfplots@prepare@ycoord{\E\pgfplots@current@point@y}% + \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{y}% + \E\let\E\pgfplots@current@point@y=\E\pgfmathresult + % + \ifpgfplots@curplot@threedim + \E\pgfplots@prepare@zcoord{\E\pgfplots@current@point@z}% + \E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{z}% + \E\let\E\pgfplots@current@point@z=\E\pgfmathresult + \fi + % + \E\pgfplots@invoke@filter@xyz + % + \E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty + \E\else + \ifpgfplots@xislinear + \E\pgfplotscoordmath{x}{parsenumber}{\E\pgfplots@current@point@x}% + \E\let\E\pgfplots@current@point@x=\E\pgfmathresult + \else + % logs are already parsed (in prepare routine) + \fi + \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 + \ifpgfplots@yislinear + \E\pgfplotscoordmath{y}{parsenumber}{\E\pgfplots@current@point@y}% + \E\let\E\pgfplots@current@point@y=\E\pgfmathresult + \else + % logs are already parsed (in prepare routine) + \fi + \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 + \ifpgfplots@zislinear + \E\pgfplotscoordmath{z}{parsenumber}{\E\pgfplots@current@point@z}% + \E\let\E\pgfplots@current@point@z=\E\pgfmathresult + \else + % logs are already parsed (in prepare routine) + \fi + \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}{#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/u filter/.code=, + quiver/v filter/.code=, + quiver/w filter/.code=, + 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\pgfplotsplothandlerquiver@vis@hook=\pgfutil@empty + % + \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\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 powerfull. + \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 + \draw[/pgfplots/quiver/every arrow] \pgfextra{\pgfplotsplothandlerquiver@vis@path{#1}}; + \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 +\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 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/handler/.style={/tikz/ybar interval}, + hist/symbolic coords/.style={% + /pgfplots/symbolic coords={hist/data}{A,B,C,D,E,F,G,H,I,J}, + /pgfplots/symbolic coords={x}{A,B,C,D,E,F,G,H,I,J}, + },% +}% +\def\pgfplotsplothandlerhistogram{% + \pgfplotsresetplothandler + \def\pgf@plotstreamstart{% + \pgfplotsset{/pgfplots/hist/handler}% + \pgfplotsresetplothandler + \tikz@plot@handler + \pgf@plotstreamstart + }% + \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 + % + \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}% + \expandafter\pgfplots@loc@TMPa\expandafter{\the\c@pgf@counta}% + }% + \fi + % + \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 + +\pgfplotsset{ + contour prepared/.code={% + \let\tikz@plot@handler=\pgfplotsplothandlercontourprepared + \pgfqkeys{/pgfplots/contour}{% + #1,% + }% + }, + contour prepared filled/.style={% + /pgfplots/contour prepared={draw color=mapped color!80!black,labels=false,filled=true}, + }, + % 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, + contour/filled/.is if=pgfplotsplothandlercontour@filled, + contour/filled/.default=true, + contour/data limits/.initial=,% FIXME EXPERIMENTAL + 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, + % + % + % Interface to external tools: + contour external/.code={% + \edef\tikz@plot@handler{\noexpand\pgfplotsplothandlercontourexternal}% + \pgfqkeys{/pgfplots/contour external}{#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/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; set cntrparam levels \pgfkeysvalueof{/pgfplots/contour/number}; set contour; set table \"\outfile\"; splot \"\infile\";}, + cmd={gnuplot \"\script\"}, + #1,% + }, + }, +}% +\def\pgfplotsplothandlercontourprepared{% + \pgfplotsresetplothandler + \pgfplotsset{empty line=jump}% + \let\pgf@plotstreamstart=\pgfplotsplothandlervisstart@contour + \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@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\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}% +} +\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\pgfplotsplothandlercontourprepared@matlabformat@meta=\pgfmathresult + % + \else + \let\pgfplots@current@point@z=\pgfplotsplothandlercontourprepared@matlabformat@meta + \let\pgfplots@current@point@meta=\pgfplotsplothandlercontourprepared@matlabformat@meta + \pgfplotsplothandlersurveypoint@default + \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlercontourprepared@matlabformat@cur + \fi +}% +\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 + \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 +}% + + +\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. + % + % thus, we need to compute 'mapped color': + \pgfplotsaxisvisphasetransformpointmeta + \pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}% + \pgfsetstrokecolor{\pgfkeysvalueof{/pgfplots/contour/draw color}}% + \ifpgfplotsplothandlercontour@filled + \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 +}% +\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 + % +%\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}}% + \immediate\openout\w@pgf@writea=\script + \immediate\write\w@pgf@writea{\pgfkeysvalueof{/pgfplots/contour external/script}}% + \immediate\closeout\w@pgf@writea + % + \immediate\write18{\pgfkeysvalueof{/pgfplots/contour external/cmd}}% + \endgroup + % + % + \pgfplotsplothandlercontourprepared + \let\pgfplots@coord@stream@start=\relax% has already been done. + \def\pgfplots@coord@stream@end{\pgfplotsplothandlersurveyend}% + \ifpgfplots@curplot@threedim + \pgfplotssetpointmetainput{z}{}% + \else + \pgfplotssetpointmetainput{explicit}{}% + \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@TAB, + 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 diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex index 3c3e9dd7f6a..2276f571db9 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex @@ -46,32 +46,29 @@ % 2. At the beginning and end of each plot, the lists in 1.) are % initialised properly. % -% 3. While plot coordinates are processed, the following methods +% 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@finishpoint % -> 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). % -% \pgfplots@stacked@rememberzerolevelpoint@for@next@plot -% \pgfplots@stacked@getnextzerolevelpoint -% % 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. % % -% REMARK: -% the state of the boolean \ifpgfplots@datascaletrafo@initialised -% determines whether these routines expect and return floating point -% numbers or fixed point numbers. \let\pgfplots@stacked@zerolevelpoint@x=\pgfutil@empty \let\pgfplots@stacked@zerolevelpoint@y=\pgfutil@empty @@ -114,29 +111,25 @@ \let\pgfplots@stacked@closedcycle@impl=\pgfutil@empty \ifpgfplots@stacked@isfirstplot \global\pgfplotslistnewempty\pgfplots@stacked@zerolevellist - \def\pgfplots@stacked@zerolevelpoint@x{0}% - \def\pgfplots@stacked@zerolevelpoint@y{0}% - \def\pgfplots@stacked@zerolevelpoint@z{0}% % only work with float if its really necessary - for % example if the scaling trafo which maps to pgfmath is % not yet initialised. - \ifpgfplots@datascaletrafo@initialised + \ifpgfplots@datascaletrafo@initialised % FIXME : should be '!ifsurvey' + \def\pgfplots@stacked@zerolevelpoint@x{0}% + \def\pgfplots@stacked@zerolevelpoint@y{0}% + \def\pgfplots@stacked@zerolevelpoint@z{0}% \else - \ifpgfplots@xislinear - \pgfmathfloatcreate{0}{0.0}{0}% - \let\pgfplots@stacked@zerolevelpoint@x=\pgfmathresult - \fi - \ifpgfplots@yislinear - \pgfmathfloatcreate{0}{0.0}{0}% - \let\pgfplots@stacked@zerolevelpoint@y=\pgfmathresult - \fi - \ifpgfplots@threedim - \ifpgfplots@zislinear - \pgfmathfloatcreate{0}{0.0}{0}% - \let\pgfplots@stacked@zerolevelpoint@z=\pgfmathresult - \fi - \fi + \pgfplotscoordmath{x}{parsenumber}{0}% + \let\pgfplots@stacked@zerolevelpoint@x=\pgfmathresult + \let\pgfplots@stacked@zerolevelpoint@y=\pgfmathresult + \let\pgfplots@stacked@zerolevelpoint@z=\pgfmathresult + % + \pgfmathfloatcreate{0}{0.0}{0}% + \ifpgfplots@xislinear\else \let\pgfplots@stacked@zerolevelpoint@x=\pgfmathresult \fi + \ifpgfplots@yislinear\else \let\pgfplots@stacked@zerolevelpoint@y=\pgfmathresult \fi + \ifpgfplots@zislinear\else \let\pgfplots@stacked@zerolevelpoint@z=\pgfmathresult \fi \fi + % \def\pgfplots@stacked@getnextzerolevelpoint{}% will remain constant anyway. \else {\globaldefs=1 @@ -259,26 +252,27 @@ % - \pgfplots@current@point@[xyz] are adjusted. \def\pgfplots@stacked@preparepoint@inmacro{% \pgfplots@stacked@getnextzerolevelpoint + % \ifpgfplots@stacked@plus - \let\pgfplots@stacked@op=\pgfmath@basic@add@ + \def\pgfplots@stacked@op{add}% \else - \let\pgfplots@stacked@op=\pgfmath@basic@subtract@ + \def\pgfplots@stacked@op{subtract}% \fi \pgfplots@if{pgfplots@\pgfplots@stacked@dir islinear}{% - \ifpgfplots@datascaletrafo@initialised - \else - \ifpgfplots@stacked@plus - \let\pgfplots@stacked@op=\pgfmathfloatadd@ - \else - \let\pgfplots@stacked@op=\pgfmathfloatsubtract@ - \fi - \fi - }{}% - \edef\pgfplots@loc@TMPa{ - \noexpand\pgfplots@stacked@op - {\csname pgfplots@stacked@zerolevelpoint@\pgfplots@stacked@dir\endcsname}% - {\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname}}% - \pgfplots@loc@TMPa + \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): + \pgfplotscoordmath{\pgfplots@stacked@dir}{exp}{\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname}% + \pgfmathfloatparsenumber\pgfmathresult + \expandafter\let\csname pgfplots@current@point@\pgfplots@stacked@dir\endcsname=\pgfmathresult + \csname pgfmathfloat\pgfplots@stacked@op @\endcsname + {\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 \ifpgfplots@threedim \ifpgfplots@curplot@threedim @@ -289,6 +283,12 @@ \else \pgfplots@stacked@rememberzerolevelpoint@for@next@plot{(\pgfplots@current@point@x,\pgfplots@current@point@y)}% \fi + % + \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 + }% } % This here is a re-implementation of the stored plot processing. @@ -469,16 +469,11 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endgroup % - \ifpgfplots@apply@datatrafo - \def\pgfplots@coord@stream@coord@{% - \pgfplots@apply@data@scaletrafo@to@one@point% - \pgfplots@coord@stream@finalize@currentpt - }% - \else - \def\pgfplots@coord@stream@coord@{% - \pgfplots@coord@stream@finalize@currentpt - }% - \fi + \def\pgfplots@coord@stream@coord@{% + \pgfplotsaxisvisphasetransformcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z% + \pgfplotsaxisvisphasepreparedatapoint + \pgfplots@coord@stream@finalize@currentpt + }% } % This command gets called after the sequence reversal has been done. diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex index 46367c7c43e..de218f8bcb9 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex @@ -149,7 +149,7 @@ \def\pgfplots@init@scaled@tick@for#1{% \global\def\pgfplots@glob@TMPa{0}% \begingroup - \ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname + \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: @@ -213,9 +213,9 @@ % x-axis tick labels for #1th tick % #1: the axis (x,y or z) % #2: the value -% #3,#4: coordinates for \pgfplotspointonorientedsurfaceab +% #3,#4+#5: arguments for \pgfplotspointonorientedsurfaceabwithbshift % #5: ticknumber -\def\pgfplots@show@ticklabel#1#2(#3,#4)#5{% +\def\pgfplots@show@ticklabel#1#2(#3,#4+#5)#6{% \begingroup% \csname ifpgfplots@#1ticklabel@interval\endcsname % Special case for the INTERVAL feature: @@ -240,18 +240,19 @@ \let\pgfplots@show@ticklabel@coord@y=\pgfmathresult% \let\ticknum=\pgfplots@show@ticklabel@num\relax% \let\tick=\pgfplots@show@ticklabel@tick% - \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceab{\pgfplots@show@ticklabel@coord@x}{\pgfplots@show@ticklabel@coord@y}}% + \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{#5}% + \noexpand\edef\noexpand\pgfplots@show@ticklabel@num{#6}% }% \else - \let\ticknum=#5\relax% + \let\ticknum=#6\relax% \pgfplots@show@ticklabel@{#1}{#2}% - \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceab{#3}{#4}}% + \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceabwithbshift{#3}{#4}{#5}}% \fi \endgroup } @@ -469,7 +470,7 @@ % #2: tick value. \def\pgfplots@show@ticklabel@#1#2{% \csname ifpgfplots@apply@datatrafo@#1\endcsname - \csname pgfplots@inverse@datascaletrafo@#1\endcsname{#2}% + \pgfplotscoordmath{#1}{datascaletrafo inverse}{#2}% \ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname \or \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% @@ -480,7 +481,12 @@ \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}% @@ -590,10 +596,10 @@ }% % Fills the macros -% \pgfplots@tick@beg@a \pgfplots@tick@end@a -% \pgfplots@tick@beg@b \pgfplots@tick@end@b +% \pgfplots@tick@LOWER@b \pgfplots@tick@end@a +% \pgfplots@tick@UPPER@b \pgfplots@tick@end@b % with coordinates such that -% (\pgfplots@tick@beg@a,\pgfplots@tmpa) -- (\pgfplots@tick@end@a,\pgfplots@tmpa) +% (\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 @@ -602,56 +608,65 @@ % #2 : the current tick width % \def\pgfplots@prepare@tick@offsets@for@#1#2{% + % % FIXME : this stuff was ok for 2D. % For 3D, it works only for the cases of boxed axes or centered % axis lines. \ifcase\csname pgfplots@#1tickposnum\endcsname\relax % both %(\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt) - \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% - \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult + \edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% % %(\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#2, 0pt) - \edef\pgfplots@tick@beg@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% - \pgfmathadd@{\pgfplots@tick@beg@b}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@b=\pgfmathresult - \pgfmathsubtract@{\pgfplots@tick@beg@b}{#2}% - \let\pgfplots@tick@end@b=\pgfmathresult% + \edef\pgfplots@tick@UPPER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% \or % left % (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); - \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% - \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult + \edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% \or % center % (\pgfplots@ZERO@x -\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); - \pgfmathsubtract@{\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB \endcsname}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult% + \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@beg@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% - \pgfmathadd@{\pgfplots@tick@beg@b}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@b=\pgfmathresult - \pgfmathsubtract@{\pgfplots@tick@beg@b}{#2}% - \let\pgfplots@tick@end@b=\pgfmathresult% + \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@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% - \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult + \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{% + \if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1% + \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}}% + \fi + \if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1% + \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}}% + \fi + }% +%\message{place computed tick: LOWEROK=\pgfplots@drawticklines@for@placecomputedtick@LOWEROK; UPPEROK=\pgfplots@drawticklines@for@placecomputedtick@UPPEROK.}% }% @@ -771,11 +786,17 @@ \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% @@ -789,8 +810,8 @@ % and % \pgfplots@prepared@tick@positions@minor@x. % -% The major tick list contains tuples (canvas position,logical position) -% while the minor tick list contains just the canvas position. +% Both lists contain entries of the form {<index>}{<logical position>} +% @see \pgfplots@prepared@tick@pos@unpack % % #1: the axis % #2: the tick list. @@ -814,16 +835,10 @@ % 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@major@tickindices \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@minor % - \afterassignment\pgfplots@gobble@until@relax - \pgfplots@tmpa=\pgfkeysvalueof{/pgfplots/#1tick placement tolerance}pt\relax - \pgfplots@tmpa=\csname pgfplots@#1@inverseveclength\endcsname\pgfplots@tmpa - \edef\pgfplots@loc@tick@placement@tolerance{\the\pgfplots@tmpa}% - % - \advance\csname pgfplots@#1min@reg\endcsname by-\pgfplots@tmpa - \advance\csname pgfplots@#1max@reg\endcsname by\pgfplots@tmpa + \pgfplots@prepare@tick@coordlists@for@handletolerance#1% % \edef\pgfplots@loc@TMPa{#2}% \ifx\pgfplots@loc@TMPa\pgfutil@empty @@ -837,9 +852,15 @@ \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 - \expandafter\let\expandafter\pgfplots@minor@tick@num\csname pgfplots@minor@#1tick@num\endcsname + \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 @@ -860,18 +881,14 @@ \else \expandafter\def\expandafter\pgfplots@checktickminmax\expandafter{% \pgfplots@checktickminmax - \ifdim\pgfplots@tmpa<\csname pgfplots@#1tickmin\endcsname pt - \pgfplots@tickshowfalse - \fi + \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 - \ifdim\pgfplots@tmpa>\csname pgfplots@#1tickmax\endcsname pt - \pgfplots@tickshowfalse - \fi + \pgfplots@prepare@tick@coordlists@for@checktickmax#1% }% \fi % @@ -880,47 +897,39 @@ \foreach \x in {#2} {% \let\pgfplots@ticknum=\pgfplots@glob@TMPa % - \pgfplots@tmpa=\x pt % + \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 - \ifdim\pgfplots@tmpa<\csname pgfplots@#1min@reg\endcsname - \else - \ifdim\pgfplots@tmpa>\csname pgfplots@#1max@reg\endcsname - \else - \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@major - \expandafter\pgfplotslistpushbackglobal\pgfplots@ticknum\to\pgfplots@prepared@tick@positions@major@tickindices - \fi - \fi + \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 - % in log: - % log( i*10^k ) = log\pgfplots@i + k\log10 -> draw ticks for i=1..9 \ifpgfplots@needsminorloop + % SEE BELOW for the 'minor #1tick' feature -- it has a + % separate loop. \foreach \pgfplots@i in {1,...,\pgfplots@minor@tick@num} {% - \begingroup \ifpgfplots@islinear - \pgfplots@tmpa=\pgfplots@minor@tick@dist pt % - \pgfplots@tmpa=\pgfplots@i\pgfplots@tmpa + \pgfmathmultiply@{\pgfplots@i}{\pgfplots@minor@tick@dist}% \else - \pgfplots@tmpa=\csname pgfplotsmathlogi@#1\endcsname\pgfplots@i pt % + % 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 - \edef\pgfmathresult{\the\pgfplots@tmpa}% - \pgfmath@smuggleone\pgfmathresult - \endgroup - \advance\pgfplots@tmpa by\pgfmathresult\relax + \pgfplots@prepare@tick@coordlists@for@advance\pgfplots@tmpa by\pgfmathresult \pgfplots@tickshowtrue + \pgfplots@prepare@tick@coordlists@for@checkdatalimits#1% \pgfplots@checktickminmax \ifpgfplots@tickshow - \ifdim\pgfplots@tmpa<\csname pgfplots@#1min@reg\endcsname - \else - \ifdim\pgfplots@tmpa>\csname pgfplots@#1max@reg\endcsname - \else - \edef\pgfmathresult{\pgf@sys@tonumber{\pgfplots@tmpa}}% - \expandafter\pgfplotslistpushbackglobal\pgfmathresult\to\pgfplots@prepared@tick@positions@minor - \fi - \fi + \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 @@ -928,16 +937,99 @@ % 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 + %\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@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. % @@ -965,7 +1057,7 @@ \pgfplots@if{pgfplots@#1minorgrids}{\pgfplots@loop@CONTINUEtrue}{}% \ifpgfplots@loop@CONTINUE \scope - \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1 + \pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf#1% % \pgfplots@if{pgfplots@#1minorgrids}{% \draw[% @@ -975,8 +1067,8 @@ /pgfplots/every minor #1 grid]% \pgfextra \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curgridpos{% - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curgridpos + \pgfplots@drawgridlines@onorientedsurf@fromto\pgfplots@tick }% \endpgfextra; }{}% @@ -989,8 +1081,8 @@ /pgfplots/every major #1 grid]% \pgfextra \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curgridpos{% - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curgridpos + \pgfplots@drawgridlines@onorientedsurf@fromto\pgfplots@tick }% \endpgfextra; }{}% @@ -1002,6 +1094,16 @@ }% } +% 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}}% +}% + % Draws ticks on the currently active "oriented surface". % % The oriented surface is two dimensional and has been initialised @@ -1040,26 +1142,27 @@ \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{% \pgfinterruptboundingbox% \begingroup - \pgf@xa=5cm - \edef\pgfplots@loc@TMPc{\pgf@sys@tonumber{\pgf@xa}}% % the case ||e_b|| == 0 should never happen here! Should be % caught before entering this routine. - \pgfmathmultiply@{\pgfplots@loc@TMPc}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@loc@LENGTH=\pgfmathresult - \pgfmathsubtract@{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}{\pgfplots@loc@LENGTH}% - \let\pgfplots@loc@MIN=\pgfmathresult - \pgfmathadd@{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}{\pgfplots@loc@LENGTH}% - \let\pgfplots@loc@MAX=\pgfmathresult - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MIN}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MIN}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MAX}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MAX}}% + \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% @@ -1112,24 +1215,9 @@ % never used? \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% \fi - \begingroup - % Assemble the \pgfplots@drawticklines@for@placecomputedtick - % command. - \let\E=\noexpand - \xdef\pgfplots@drawticklines@for@placecomputedtick{% - \if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1% - \E\pgfpathmoveto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@beg@a}}% - \E\pgfpathlineto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@end@a}}% - \fi - \if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1% - \E\pgfpathmoveto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@beg@b}}% - \E\pgfpathlineto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@end@b}}% - \fi - }% - \endgroup \expandafter\let\expandafter\pgfplots@prepared@tick@positions@major@\csname pgfplots@prepared@tick@positions@major@#1\endcsname \expandafter\let\expandafter\pgfplots@prepared@tick@positions@minor@\csname pgfplots@prepared@tick@positions@minor@#1\endcsname - \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1 + \pgfplots@drawticklines@INSTALLCLIP@onorientedsurf#1 % \pgfplots@if{pgfplots@#1minorticks}{% \draw[% @@ -1140,19 +1228,13 @@ \pgfextra \pgfmathparse{\pgfplots@subtickwidth}% \let\pgfplots@subtickwidth@=\pgfmathresult - \pgfmathmultiply@{\pgfplots@subtickwidth@}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@subtickwidth@=\pgfmathresult \let\pgfplots@subtickwidth=\pgfmathresult - \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax - \def\pgfplots@tick@offset{0}% - \or - \let\pgfplots@tick@offset=\pgfplots@subtickwidth@% - \or - \pgfmathmultiply@{0.5}{\pgfplots@subtickwidth@}% - \let\pgfplots@tick@offset=\pgfmathresult% - \fi \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@subtickwidth@}% \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{% + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos + \let\pgfplots@curtickpos=\pgfplots@tick + \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% \pgfplots@drawticklines@for@placecomputedtick }% \endpgfextra; @@ -1167,19 +1249,13 @@ \pgfextra \pgfmathparse{\pgfplots@tickwidth}% \let\pgfplots@tickwidth@=\pgfmathresult - \pgfmathmultiply@{\pgfplots@tickwidth@}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@tickwidth@=\pgfmathresult \let\pgfplots@tickwidth=\pgfmathresult - \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax - \def\pgfplots@tick@offset{0}% - \or - \let\pgfplots@tick@offset=\pgfplots@tickwidth@% - \or - \pgfmathmultiply@{0.5}{\pgfplots@tickwidth@}% - \let\pgfplots@tick@offset=\pgfmathresult% - \fi \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@tickwidth@}% \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos + \let\pgfplots@curtickpos=\pgfplots@tick + \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% \pgfplots@drawticklines@for@placecomputedtick }% \endpgfextra; @@ -1263,7 +1339,7 @@ \fi \let\pgfplots@tick@offset=\pgfmathresult \pgfplots@ticklabel@maxtickdimen@extrashift{#1}{\pgfplots@tick@offset}% - \pgfmathmultiply@{\pgfplots@tick@offset}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% + %\pgfmathmultiply@{\pgfplots@tick@offset}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@tick@offset=\pgfmathresult }% % @@ -1277,38 +1353,50 @@ \pgfmathmultiply{-1}{\pgfplots@tick@offset}% \let\pgfplots@tick@offset=\pgfmathresult \fi - \pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + \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 - \pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + %\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 - \pgfmathadd@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + %\pgfmathadd@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% \else - % Should never happen. - \pgfplots@error{Internal logic error during tick label placement (got placement character '\pgfplots@ticklabelside'). - Please report this as a bug or verify your input arguments to #1ticklabel pos.}% - \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname% + \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB\endcsname% + % FIXME : is that correct!? \pgfplots@tickposchoiceb - \pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + %\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': - \expandafter\let\expandafter\pgfmathlogtologten@\csname pgfplotsmathlogtologten@#1@\endcsname + \def\pgfmathlogtologten@{\pgfplotscoordmath{#1}{log to log 10}}% % - \let\pgfplots@tick@origin=\pgfmathresult% \xdef\pgfplots@show@ticklabel@LASTTICK{}% \pgfplotslistforeachungrouped\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% - \expandafter\pgfplotslistpopfront\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname\to\pgfplots@ticknum + \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)% + {#1}{\pgfplots@curtickpos}(\pgfplots@curtickpos,\pgfplots@tick@origin+\pgfplots@tick@offset)% {\pgfplots@ticknum}% }% \pgfplots@ticklabel@maxtickdimen@finish{#1}% @@ -1394,9 +1482,21 @@ \let\pgfplots@loc@TMPc=\pgfmathresult \ifx\pgfplots@loc@TMPc\pgfutil@empty \else - \pgftransformshift{% - \pgfplotspointouternormalvectorofticklabelaxis{#1}% - \pgfqpointscale{-\pgfplots@loc@TMPc}{}% + \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 % @@ -1520,7 +1620,8 @@ \def\pgfplots@compute@tick@times@logten#1\to#2#3{% \global\let#2=\pgfutil@empty \foreach \pgfplots@loc@TMPb in {#1} {% - \pgfmathmultiply@{\pgfplots@loc@TMPb}{\csname pgfplots@log@scale@todisplaylog@#3\endcsname}% + \pgfplotscoordmath{#3}{log to display log}{\pgfplots@loc@TMPb}% + \pgfplotscoordmath{#3}{tofixed}{\pgfmathresult}% \ifx#2\pgfutil@empty \xdef#2{\pgfmathresult}% \else @@ -1611,8 +1712,6 @@ % 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\pgfplots@data@scale@trafo\csname pgfplots@datascaletrafo@#1@noshift\endcsname - \expandafter\let\expandafter\pgfplots@data@scale@inverse@trafo\csname pgfplots@inverse@datascaletrafo@#1@noshift\endcsname \expandafter\let\expandafter\ifpgfplots@cur@is@linear\csname ifpgfplots@#1islinear\endcsname % \let\desirednumticks=\c@pgf@countd @@ -1639,6 +1738,18 @@ \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, we have either log or linear axis and need default @@ -1648,12 +1759,13 @@ \let\MAX=\pgf@ya \let\MIN=\pgf@yb % compute step size 'H': - \expandafter\MAX\csname pgfplots@#1max\endcsname pt % + \MAX=\csname pgfplots@#1max\endcsname pt % \advance\MAX by0.001pt % avoid round errors %\expandafter\MIN\the\c@pgf@counta pt - \expandafter\MIN\csname pgfplots@#1min\endcsname pt % + \MIN=\csname pgfplots@#1min\endcsname pt % \H=\MAX \advance\H by-\MIN + \ifdim\H<0pt \H=-1\H \fi %\message{Axis limit #1: [\the\MIN:\the\MAX], diff = \the\H.}% \c@pgf@counta=\desirednumticks \advance\c@pgf@counta by-1 % @@ -1666,40 +1778,18 @@ % CASE LINEAR AXIS \ifpgfplots@is@datascaled % This here works if the scaling trafo is linear. - \expandafter\pgfplots@data@scale@inverse@trafo\expandafter{\Hmacro}% + \pgfplotscoordmath{#1}{datascaletrafo noshift inverse}{\Hmacro}% \let\Hmacro=\pgfmathresult \else \pgfmathfloatparsenumber{\Hmacro}% \let\Hmacro=\pgfmathresult \fi - \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E %\message{Got T^{-1}(H#1) = \Hmacro}% - % 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 - \aftergroup\pgfplots@isuniformticktrue - \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgf@sys@tonumber{\H}}{\the\pgfmathfloat@a@E}% + % + \pgfplots@assign@default@tick@foraxis@normalizetickdist#1\Hmacro \let\Hmacro=\pgfmathresult + % + \aftergroup\pgfplots@isuniformticktrue % The following code is carried out in floating point % arithmetics because it requires large data ranges. % @@ -1719,9 +1809,9 @@ % Now, convert everything into the fixed point data % range: \ifpgfplots@is@datascaled - \csname pgfplots@datascaletrafo@#1\endcsname{\MIN@new}% + \pgfplotscoordmath{#1}{datascaletrafo}{\MIN@new}% \MIN=\pgfmathresult pt - \pgfplots@data@scale@trafo\Hmacro + \pgfplotscoordmath{#1}{datascaletrafo noshift}{\Hmacro}% \H=\pgfmathresult pt \else \pgfmathfloattofixed\MIN@new @@ -1742,7 +1832,7 @@ % % And prefer j=1 if that is possible (otherwise minor % ticks are not useful). - \pgfmathmultiply@{\Hmacro}{\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname}% + \pgfmath@basic@multiply@{\Hmacro}{\pgfplots@loc@log@from@display@log@scale}% \let\Hmacrobaseten=\pgfmathresult \expandafter\H\pgfmathresult pt %\message{ [ H / log(10) = \pgfmathresult ]}% @@ -1764,7 +1854,7 @@ \pgfplots@isuniformtickfalse \fi %\message{final H=\pgf@sys@tonumber{\H} * log(10)}% - \H=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\H\relax + \H=\pgfplots@loc@log@to@display@log@scale\H % Now, we want to activate the Tick set % {lowest, lowest+H, ..., highest} % @@ -1777,14 +1867,14 @@ \MINH=\MIN % % and compute I and I*log(10) here: - \MIN=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname\MIN\relax + \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=\csname pgfplots@log@scale@todisplaylog@#1\endcsname pt + \MIN=\pgfplots@loc@log@to@display@log@scale pt \multiply\MIN by\c@pgf@counta \ifpgfplots@isuniformtick \else @@ -1814,7 +1904,7 @@ \advance\MINH by-\H % \ifdim\MINH<0pt - \advance\MIN \csname pgfplots@log@scale@todisplaylog@#1\endcsname pt + \advance\MIN \pgfplots@loc@log@to@display@log@scale pt \fi \fi \fi @@ -1846,6 +1936,7 @@ \expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPb\csname pgfplots@tick@distance@#1\endcsname \endgroup }{% + % Case logarithmic axes and too few ticks. \aftergroup\pgfplots@isuniformtickfalse % ok, do something special. % @@ -1855,10 +1946,11 @@ % So: apply basically the SAME code as above for linear % axis, just everything log 10! And keep in mind that all % coordinates are actually given as natural logarithms. - \expandafter\MIN\csname pgfplots@#1min\endcsname pt + \MIN\csname pgfplots@#1min\endcsname pt \H=\MAX \advance\H by-\MIN - \H=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname\H + \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 @@ -1873,31 +1965,8 @@ % SEARCH for the NEXT FEASABLE H. \edef\Hmacro{\pgf@sys@tonumber\H}% \pgfmathfloatparsenumber{\Hmacro}% - \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E - % Determine properly snapped mantisse... - \ifdim\H<2pt - \ifdim\H<1.5pt - \H=1.0pt - \else - \H=2.0pt - \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}% + \pgfplots@assign@default@tick@foraxis@normalizetickdist#1\pgfmathresult + % \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% \let\Hmacro=\pgfmathresult \H=\Hmacro pt % @@ -1909,7 +1978,7 @@ % -> I = round(xmin/H) % -> MIN = I * H % BUT EVERYTHING to log(10) basis! - \MIN=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname \MIN\relax + \MIN=\pgfplots@loc@log@from@display@log@scale \MIN \pgfmathlog@invoke@expanded\pgfmathdivide@{% {\pgf@sys@tonumber\MIN}% {\Hmacro}% @@ -1923,8 +1992,8 @@ \multiply\MIN by\c@pgf@counta\relax % % convert back to basis 'e': - \MIN=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\MIN\relax - \H=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\H\relax + \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 }% @@ -1947,16 +2016,69 @@ %\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\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 macro name +% #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{% \let#3=\pgfutil@empty \foreach \pgfplots@loc@TMPb in {#1} {% \pgfmathfloatparsenumber{\pgfplots@loc@TMPb}% - \expandafter#2\expandafter{\pgfmathresult}% + #2{\pgfmathresult}% \ifx#3\pgfutil@empty \xdef#3{\pgfmathresult}% \else diff --git a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvips.def b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvips.def index b45b779e003..e81a53a44d8 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvips.def +++ b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-dvips.def @@ -75,11 +75,15 @@ /PatternType 2 /Shading << - /ShadingType 5 + /ShadingType \pgfplotslibrarysurf@type\space /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space /BitsPerComponent 16 % Note: this here is the reason why I can't use ASCII85Decode - /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols} - /ColorSpace /DeviceRGB + \if5\pgfplotslibrarysurf@type + /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols} + \else + /BitsPerFlag 8 + \fi + /ColorSpace /Device\pgfplotslibrarysurf@colorspace /Decode [\pgfplotslibrarysurf@decode] /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap} /DataSource diff --git a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def index 63ec517b963..c94f05e585e 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def +++ b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def @@ -73,11 +73,15 @@ \def\pgfplotssys@do@surfshading@fillpaths#1{% \immediate\pdfobj stream attr {% % stream length will be computed automatically - /ShadingType 5 + /ShadingType \pgfplotslibrarysurf@type\space /BitsPerCoordinate \pgfplotslibrarysurf@bitspercoordinate\space /BitsPerComponent 16 - /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols} - /ColorSpace /DeviceRGB + \if5\pgfplotslibrarysurf@type + /VerticesPerRow \pgfkeysvalueof{/pgfplots/surf shading/cols} + \else + /BitsPerFlag 8 + \fi + /ColorSpace /Device\pgfplotslibrarysurf@colorspace /Decode [\pgfplotslibrarysurf@decode] /Function \pgfkeysvalueof{/pgfplots/surf shading/colormap} \ifx\pgfplotslibrarysurf@filter@decode\pgfutil@empty diff --git a/Master/texmf-dist/tex/generic/pgfplots/sys/pgfplotssysgeneric.code.tex b/Master/texmf-dist/tex/generic/pgfplots/sys/pgfplotssysgeneric.code.tex new file mode 100644 index 00000000000..cc79af2d013 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/sys/pgfplotssysgeneric.code.tex @@ -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/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\pgfplots@sys@beforenode{% + \pgfkeysifdefined{/tikz/tex4ht node/escape/.@cmd}{% + \tikzset{tex4ht node/escape=true}% + }{}% +}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex index b1496a8fc1b..838e0393e2e 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex @@ -25,6 +25,8 @@ % %-------------------------------------------- +\pgfkeyssetvalue{/pgfplots/colormap default colorspace}{auto} + % This package relies on pgfplots temporary registers and its array % data structure. @@ -53,6 +55,7 @@ \expandafter\pgfplotsarraynewempty\expandafter{\pgfplots@createcolormap@name}% \def\pgfplots@createcolormap@MIN{0}% NORMALIZATION: assume that lower-end is 0pt. \def\pgfplots@createcolormap@MAX{0}% To be computed. + \pgfplots@createcolormap@initcolorspace \let\pgfplots@createcolormap@LAST=\pgfplots@createcolormap@MIN % PARSE IT: \edef\pgfplots@loc@TMPa{#2}% @@ -75,8 +78,40 @@ \expandafter\let\csname\pgfplots@createcolormap@name @h\endcsname=\pgfplots@createcolormap@H \pgfmathreciprocal@{\pgfplots@createcolormap@H}% \expandafter\let\csname\pgfplots@createcolormap@name @invh\endcsname=\pgfmathresult + \expandafter\let\csname\pgfplots@createcolormap@name @col@comps\endcsname=\pgfplots@createcolormap@col@comps + \expandafter\let\csname\pgfplots@createcolormap@name @colspace\endcsname=\pgfplots@createcolormap@colspace %\pgfplots@colormap@showdebuginfofor{#1}% } +\def\pgfplots@createcolormap@initcolorspace{% + \pgfkeysgetvalue{/pgfplots/colormap default colorspace}\pgfplots@loc@TMPa + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + \def\pgfplots@loc@TMPb{auto}% + \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa + % colormap default colorspace=auto: same as empty. + \let\pgfplots@loc@TMPa=\pgfutil@empty + \fi + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % colormap default colorspace=auto: + \def\pgfplots@createcolormap@col@comps{}% to be filled from first point + \def\pgfplots@createcolormap@colspace{}% + \else + \def\pgfplots@loc@TMPb{rgb}% + \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa + % colormap default colorspace=rgb: + \def\pgfplots@createcolormap@colspace{rgb}% + \def\pgfplots@createcolormap@col@comps{3}% + \else + \def\pgfplots@loc@TMPb{cmyk}% + \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa + % colormap default colorspace=cmyk: + \def\pgfplots@createcolormap@colspace{cmyk}% + \def\pgfplots@createcolormap@col@comps{4}% + \else + \pgfplots@error{Sorry, the choice 'colormap default colorspace=\pgfplots@loc@TMPa' is unknown to pgfplots, please use one of 'auto,rgb,cmyk'}% + \fi + \fi + \fi +}% \def\pgfplots@createcolormap@seth[#1]{% \def\pgfplots@createcolormap@context{[#1]}% \pgfmathparse{#1}% @@ -101,7 +136,7 @@ {% \pgfutil@ifnextchar g{\pgfplots@createcolormap@grabgray}% {% - \pgfutil@ifnextchar c{\pgfplots@createcolormap@grabcolor}% + \pgfutil@ifnextchar c{\pgfplots@createcolormap@grabc}% { \expandafter\pgfutil@ifnextchar\pgfplots@activesemicolon{\pgfplots@createcolormap@grabsemicolon@active}% {\pgfplots@createcolormap@error}% @@ -177,6 +212,41 @@ \edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfmathresult}}% \expandafter\pgfplots@loc@TMPc\pgfplots@loc@TMPa \pgfplots@createcolormap@} + + +\def\pgfplots@createcolormap@grabcmyk myk{ + \def\pgfplots@createcolormap@colspace@actual{cmyk}% + \def\pgfplots@createcolormap@col@comps@actual{4}% + \pgfutil@ifnextchar2{% + \pgfplots@createcolormap@grabcmyk@two@five@five + }{% + \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabcmyk@ + \pgfplots@createcolormap@next + }% +} +\def\pgfplots@createcolormap@grabcmyk@(#1)=(#2,#3,#4,#5){% + \def\pgfplots@createcolormap@context{cmyk(#1)=(#2,#3,#4,#5)}% + \pgfplots@createcolormap@nextcolor{#1}{#2}{#3}{#4}{#5}% + \pgfplots@createcolormap@} +\def\pgfplots@createcolormap@grabcmyk@two@five@five255{% + \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabcmyk@two@five@five@ + \pgfplots@createcolormap@next +} +\def\pgfplots@createcolormap@grabcmyk@two@five@five@(#1)=(#2,#3,#4,#5){% + \def\pgfplots@createcolormap@context{cmyk255(#1)=(#2,#3,#4,#5)}% + \pgfplots@createcolormap@grabcmyk@two@five@five@rescale{#2}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplots@createcolormap@grabcmyk@two@five@five@rescale{#3}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfplots@createcolormap@grabcmyk@two@five@five@rescale{#4}% + \let\pgfplots@loc@TMPc=\pgfmathresult + \pgfplots@createcolormap@grabcmyk@two@five@five@rescale{#5}% + \def\pgfplots@loc@TMPd{\pgfplots@createcolormap@nextcolor{#1}}% + \edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}{\pgfmathresult}}% + \expandafter\pgfplots@loc@TMPd\pgfplots@loc@TMPa + \pgfplots@createcolormap@} + + \def\pgfplots@createcolormap@grabgray gray{% \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabgray@ \pgfplots@createcolormap@next @@ -185,7 +255,15 @@ \def\pgfplots@createcolormap@context{gray(#1)=(#2)}% \pgfplots@createcolormap@nextRGB{#1}{#2}{#2}{#2}% \pgfplots@createcolormap@} -\def\pgfplots@createcolormap@grabcolor color{% + +\def\pgfplots@createcolormap@grabc c{% + \pgfutil@ifnextchar m{% + \pgfplots@createcolormap@grabcmyk + }{% + \pgfplots@createcolormap@grabcolor + }% +}% +\def\pgfplots@createcolormap@grabcolor olor{% \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabcolor@ \pgfplots@createcolormap@next }% @@ -193,36 +271,105 @@ \def\pgfplots@createcolormap@context{color(#1)=(#2)}% \pgfutil@colorlet{pgf@tempcol}{#2}% \pgfutil@extractcolorspec{pgf@tempcol}{\pgf@tempcolor}% - \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}% - \expandafter\pgfplots@createcolormap@grabcolor@@\pgf@rgbcolor\relax{#1}}% + \ifx\pgfplots@createcolormap@colspace\pgfutil@empty + % This here is mainly for backwards compatibility... in older + % versions, rgb was the only choice. This should still work + % unless overruled explicitly. + \def\pgfplots@createcolormap@colspace{rgb}% + \def\pgfplots@createcolormap@col@comps{3}% + \fi + % convert the colorspace (if needed): + \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{\pgfplots@createcolormap@colspace}{\pgf@rgbcolor}% + % + \let\pgfplots@createcolormap@colspace@actual=\pgfplots@createcolormap@colspace + \let\pgfplots@createcolormap@col@comps@actual=\pgfplots@createcolormap@col@comps + % + \if4\pgfplots@createcolormap@col@comps + \let\pgfplots@loc@TMPa=\pgfplots@createcolormap@grabcolor@@@ + \else + \let\pgfplots@loc@TMPa=\pgfplots@createcolormap@grabcolor@@ + \fi + \expandafter\pgfplots@loc@TMPa\pgf@rgbcolor\relax{#1}% +}% \def\pgfplots@createcolormap@grabcolor@@#1,#2,#3\relax#4{% \pgfplots@createcolormap@nextRGB{#4}{#1}{#2}{#3}% \pgfplots@createcolormap@} +\def\pgfplots@createcolormap@grabcolor@@@#1,#2,#3,#4\relax#5{% + \pgfplots@createcolormap@nextcolor{#5}{#1}{#2}{#3}{#4}% + \pgfplots@createcolormap@} + \def\pgfplots@createcolormap@rgbrangeexception#1#2#3{% \pgfplots@error{Sorry, RGB[#1,#2,#3] is not supported. The allowed range is 0 <= r,g,b <= 1. The error occured near `\pgfplots@createcolormap@context'}% }% +\def\pgfplots@createcolormap@rangeexception#1#2{% + \pgfplots@error{Sorry, the color component at index #1 (value #2) is out of range. The allowed range is 0 <= value <= 1. The error occured near `\pgfplots@createcolormap@context'}% +} + % Ok, we parsed the next single spec. % #1: the width % #2,#3,#4 RGB values. \def\pgfplots@createcolormap@nextRGB#1#2#3#4{% + \def\pgfplots@createcolormap@colspace@actual{rgb}% + \def\pgfplots@createcolormap@col@comps@actual{3}% + \pgfplots@createcolormap@nextcolor{#1}{#2}{#3}{#4}{}% +}% + +% #1: h +% #2...#5: the color components (at least 3 non-empty, can be 4). +\def\pgfplots@createcolormap@nextcolor#1#2#3#4#5{% \ifdim#2pt<0pt - \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}% + \pgfplots@createcolormap@rangeexception0{#2}% \fi \ifdim#3pt<0pt - \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}% + \pgfplots@createcolormap@rangeexception1{#3}% \fi \ifdim#4pt<0pt - \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}% + \pgfplots@createcolormap@rangeexception2{#4}% \fi \ifdim#2pt>1pt - \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}% + \pgfplots@createcolormap@rangeexception0{#2}% \fi \ifdim#3pt>1pt - \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}% + \pgfplots@createcolormap@rangeexception1{#3}% \fi \ifdim#4pt>1pt - \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}% + \pgfplots@createcolormap@rangeexception2{#4}% + \fi + \if4\pgfplots@createcolormap@col@comps@actual + \ifdim#5pt<0pt + \pgfplots@createcolormap@rangeexception3{#5}% + \fi + \ifdim#5pt>1pt + \pgfplots@createcolormap@rangeexception3{#5}% + \fi + \fi + \def\pgfplots@loc@TMPb{\pgfplots@createcolormap@nextcolor@{#1}{#2}{#3}{#4}{#5}}% + \ifx\pgfplots@createcolormap@colspace@actual\pgfplots@createcolormap@colspace + \else + \ifx\pgfplots@createcolormap@colspace\pgfutil@empty + \let\pgfplots@createcolormap@colspace=\pgfplots@createcolormap@colspace@actual + \let\pgfplots@createcolormap@col@comps=\pgfplots@createcolormap@col@comps@actual + \else + % Oh. We need to convert the color space! + \edef\pgfplots@loc@TMPa{{\pgfplots@createcolormap@colspace@actual}{#2,#3,#4\if4\pgfplots@createcolormap@col@comps@actual,#5\fi}}% + \expandafter\pgfutil@convertcolorspec\pgfplots@loc@TMPa{\pgfplots@createcolormap@colspace}{\pgfplots@loc@TMPa}% + % invoke + % \pgfplots@createcolormap@nextcolor@{#1}{C1}{C2}{C3}{C4}. + % We need to compute C1 ... C4 : + \def\pgf@colmarshal{{#1}}% + \expandafter\pgf@uncomma\pgfplots@loc@TMPa,,% + \if4\pgfplots@createcolormap@col@comps + \else + % ok, we have C4={}. Append it: + \edef\pgf@colmarshal{\pgf@colmarshal{}}% + \fi + \def\pgfplots@loc@TMPb{\expandafter\pgfplots@createcolormap@nextcolor@\pgf@colmarshal}% + \fi \fi + \pgfplots@loc@TMPb +}% +\def\pgfplots@createcolormap@nextcolor@#1#2#3#4#5{% +%\message{processing color #1=(#2,#3,#4,#5) with \pgfplots@createcolormap@col@comps@actual\space components^^J}% % compute 'h': \pgfmathparse{#1}% \let\pgfplots@createcolormap@MAX=\pgfmathresult @@ -270,14 +417,19 @@ \ifdim\c@pgfplots@createcolormap pt=\pgfplots@loc@TMPb pt % omit the last. \else - \pgfmathparse{\pgfplots@createcolormap@lastR + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #2 - \pgfplots@createcolormap@lastR )}% - \let\pgfplots@createcolormap@nextR=\pgfmathresult - \pgfmathparse{\pgfplots@createcolormap@lastG + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #3 - \pgfplots@createcolormap@lastG )}% - \let\pgfplots@createcolormap@nextG=\pgfmathresult - \pgfmathparse{\pgfplots@createcolormap@lastB + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #4 - \pgfplots@createcolormap@lastB )}% + \pgfmathparse{\pgfplots@createcolormap@lastA + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #2 - \pgfplots@createcolormap@lastA )}% + \let\pgfplots@createcolormap@nextA=\pgfmathresult + \pgfmathparse{\pgfplots@createcolormap@lastB + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #3 - \pgfplots@createcolormap@lastB )}% + \let\pgfplots@createcolormap@nextB=\pgfmathresult + \pgfmathparse{\pgfplots@createcolormap@lastC + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #4 - \pgfplots@createcolormap@lastC )}% + \let\pgfplots@createcolormap@nextC=\pgfmathresult + \if4\pgfplots@createcolormap@col@comps + \pgfmathparse{\pgfplots@createcolormap@lastD + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #4 - \pgfplots@createcolormap@lastD )}% + \let\pgfplots@createcolormap@nextD=\pgfmathresult + \fi % \edef\pgfplots@loc@TMPa{% - \noexpand\pgfplotsarraypushback{\pgfplots@createcolormap@nextR,\pgfplots@createcolormap@nextG,\pgfmathresult}% + \noexpand\pgfplotsarraypushback{\pgfplots@createcolormap@nextA,\pgfplots@createcolormap@nextB,\pgfplots@createcolormap@nextC\if4\pgfplots@createcolormap@col@comps,\pgfplots@createcolormap@nextD\fi}% \noexpand\to}% \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}% \fi @@ -285,11 +437,12 @@ \fi \fi \fi - \def\pgfplots@loc@TMPa{\pgfplotsarraypushback{#2,#3,#4}\to}% + \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsarraypushback{#2,#3,#4\if4\pgfplots@createcolormap@col@comps,#5\fi}\noexpand\to}% \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}% - \edef\pgfplots@createcolormap@lastR{#2}% - \edef\pgfplots@createcolormap@lastG{#3}% - \edef\pgfplots@createcolormap@lastB{#4}% + \edef\pgfplots@createcolormap@lastA{#2}% + \edef\pgfplots@createcolormap@lastB{#3}% + \edef\pgfplots@createcolormap@lastC{#4}% + \edef\pgfplots@createcolormap@lastD{#5}% }% \def\pgfplots@createcolormap@nextRGB@consider@reinterpolation#1\relax{% \pgf@xa=#1pt @@ -318,19 +471,20 @@ % Shows debug info about colormap #1 into the console. \def\pgfplots@colormap@showdebuginfofor#1{% - \message{Debug info for color map '#1':}% - \message{(Transformed) Range: [0:\pgfplotscolormaprange]; }% - \message{H: \csname pgfpl@cm@#1@h\endcsname; }% - \message{H:^{-1}: \csname pgfpl@cm@#1@invh\endcsname; }% + \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; }% - \message{RGB Values: }% + \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 \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\elem{% \message{\#\the\c@pgf@counta: \elem; }% \advance\c@pgf@counta by1 }% + \message{^^J}% \endgroup } @@ -358,11 +512,15 @@ }% }% \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}% \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}% }% \endgroup \let#2=\pgfplots@glob@TMPa @@ -395,7 +553,11 @@ \def\pgfplots@loc@TMPb{}% \def\pgfplots@loc@TMPc{}% \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\cdata{% - \edef\cdata{\expandafter\pgfplotscolormaptopdffunction@convertcdata\cdata\relax}% + \if4\csname pgfpl@cm@#1@col@comps\endcsname + \edef\cdata{\expandafter\pgfplotscolormaptopdffunction@convertcdata@four\cdata\relax}% + \else + \edef\cdata{\expandafter\pgfplotscolormaptopdffunction@convertcdata\cdata\relax}% + \fi \ifnum\c@pgf@counta>0 \t@pgfplots@toka=\expandafter{\pgfplotsretval}% \xdef\pgfplotsretval{% @@ -428,6 +590,7 @@ \endgroup }% \def\pgfplotscolormaptopdffunction@convertcdata#1,#2,#3\relax{#1 #2 #3}% +\def\pgfplotscolormaptopdffunction@convertcdata@four#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}}% @@ -459,6 +622,7 @@ \def\pgfplotscolormaptoshadingspec#1#2#3{% \pgfplotscolormapassertexists{#1}% \begingroup + \def\pgfplots@rgb{rgb}% \pgfmathparse{#2}% \expandafter\pgfmathdivide@\expandafter{\pgfmathresult}{\pgfplotscolormaprange}% \let\pgfplots@loc@TMPb=\pgfmathresult @@ -467,12 +631,23 @@ \c@pgf@counta=0 \let#3=\pgfutil@empty \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\pgfplotscolormaptoshadingspec@TMP{% - \ifnum\c@pgf@counta=0 - \edef\pgfplots@loc@TMPc{rgb(0pt)=(\pgfplotscolormaptoshadingspec@TMP)}% - \else - \pgf@yb=\c@pgf@counta\pgf@ya - \edef\pgfplots@loc@TMPc{rgb(\the\pgf@yb)=(\pgfplotscolormaptoshadingspec@TMP)}% + \pgf@yb=\c@pgf@counta\pgf@ya + \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}% + \pgfplots@warning{I am about to convert colormap '#1' from \pgfplots@colspace\space to rgb (which might be lossy). Perhaps the choice 'colorbar sampled={surf,shader=interp}' yields better results since it supports \pgfplots@colspace.}% + }{% + }% + \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 @@ -485,6 +660,7 @@ \pgfmath@smuggleone#3% \endgroup }% +\def\pgfplotscolormaptoshadingspectorgb{1}% % The same as \pgfplotscolormaptoshadingspec, but this here yields the % *reversed* sequence. @@ -501,10 +677,20 @@ % end is fixed to '0'. \def\pgfplotscolormaprange{1000} -% Linearly maps the number #4 into the colormap #5 and returns the interpolated RGB triple -% into \pgfmathresult. +\def\pgfplotscolormapgetcolorspace#1{% + \edef\pgfplotsretval{\csname pgfpl@cm@#1@colspace\endcsname}% +}% +\def\pgfplotscolormapgetcolorcomps#1{% + \edef\pgfplotsretval{\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. This is required to +% [#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). @@ -564,6 +750,8 @@ % without '.0' suffix: \def\pgfplots@discardperiod##1.##2\relax{\def\pgfplotscolormapfind@intervalno{##1}}% \expandafter\pgfplots@discardperiod\pgfmathresult\relax + \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}% + \let\pgfplots@loc@factor=\pgfmathresult %\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange] yielded phi(#4) = \pgfplotscolormapfind@transformedx, situated in interval no \pgfplotscolormapfind@intervalno.}% % Step 2: interpolate the desired RGB value using vector valued % interpolation on the identified interval. @@ -573,7 +761,11 @@ \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].}% \edef\pgfplots@loc@TMPa{\pgfplotscolormapfind@rgb@LEFT:\pgfplotscolormapfind@rgb@RIGHT}% - \expandafter\pgfplotscolormapfind@interpolate\pgfplots@loc@TMPa\relax + \if4\csname pgfpl@cm@#5@col@comps\endcsname + \expandafter\pgfplotscolormapfind@interpolate@four\pgfplots@loc@TMPa\relax + \else + \expandafter\pgfplotscolormapfind@interpolate\pgfplots@loc@TMPa\relax + \fi \pgfmath@smuggleone\pgfmathresult \endgroup %\message{-> got finally mapping(#4, #5) = RGB'\pgfmathresult'.}% @@ -588,26 +780,33 @@ % R: \pgfmathsubtract@{#4}{#1}% \let\pgfplotscolormapfind@Cdiff=\pgfmathresult - \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}% - \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplotscolormapfind@Cdiff}% + \pgfmathmultiply@{\pgfplots@loc@factor}{\pgfplotscolormapfind@Cdiff}% \expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#1}% \let\RED=\pgfmathresult % G: \pgfmathsubtract@{#5}{#2}% \let\pgfplotscolormapfind@Cdiff=\pgfmathresult - \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}% - \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplotscolormapfind@Cdiff}% + \pgfmathmultiply@{\pgfplots@loc@factor}{\pgfplotscolormapfind@Cdiff}% \expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#2}% \let\GREEN=\pgfmathresult % B: \pgfmathsubtract@{#6}{#3}% \let\pgfplotscolormapfind@Cdiff=\pgfmathresult - \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}% - \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplotscolormapfind@Cdiff}% + \pgfmathmultiply@{\pgfplots@loc@factor}{\pgfplotscolormapfind@Cdiff}% \expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#3}% \let\BLUE=\pgfmathresult \edef\pgfmathresult{\RED,\GREEN,\BLUE}% }% +\def\pgfplotscolormapfind@interpolate@four#1,#2,#3,#4:#5,#6,#7,#8\relax{% + \pgfplotscolormapfind@interpolate#1,#2,#3:#5,#6,#7\relax + \let\CMY=\pgfmathresult + \pgfmathsubtract@{#8}{#4}% + \let\pgfplotscolormapfind@Cdiff=\pgfmathresult + \pgfmathmultiply@{\pgfplots@loc@factor}{\pgfplotscolormapfind@Cdiff}% + \expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#4}% + \let\K=\pgfmathresult + \edef\pgfmathresult{\CMY,\K}% +} % Performs a direct color access into color map '#2' using an index % '#1'. @@ -655,6 +854,7 @@ \fi }% + \pgfutil@definecolor{mapped color}{rgb}{0,0,0}% make sure this color exists. It will be overwritten if needed. \pgfplotscreatecolormap{hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)} @@ -670,7 +870,7 @@ {#1} {\pgfkeysvalueof{/pgfplots/colormap name}} %\message{Color for current point is RGB '\pgfmathresult' (determined using meta 'phi(\pgfplotspointmeta) = \pgfplotspointmetatransformed')}% - \def\pgfplots@loc@TMPb{\pgfutil@definecolor{mapped color}{rgb}}% + \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/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex index 60df282f8bb..2dacf8f7458 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex @@ -161,6 +161,7 @@ \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}}% % As \pgfplots@command@to@string, but it works for commands accepting % arguments. More precisely, #2 will be a string (!) of the form @@ -205,7 +206,9 @@ % \pgfplotsutil@ifdefinedui{\csname abc\endcsname} -> no % \pgfplotsutil@ifdefinedui{a_file_name} -> no \def\pgfplotsutil@ifdefinedui#1#2#3{% - \def\pgfplotsutil@@arg@ifdefined{#1}% + {\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}% @@ -214,7 +217,9 @@ % '#1' after '#1' has been normalized. % It invokes '#3' if '#1#2' is defined and '#4' if not. \def\pgfplotsutil@ifdefinedui@withsuffix#1#2#3#4{% - \def\pgfplotsutil@@arg@ifdefined{#1}% + {\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}% @@ -304,7 +309,7 @@ \edef\pgfmathresult{#2}% \fi }% -\def\pgfplotsmathlessthan#1#2{\ifdim#1 pt<#2 pt \pgfmathfloatcomparisontrue\else\pgfmathfloatcomparisonfalse\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. @@ -555,6 +560,7 @@ % 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 @@ -573,13 +579,24 @@ % scopes. % % This loop *can* be nested. -\def\pgfplotsforeachungrouped#1{\pgfplotsforeachungrouped@{#1}}% -\long\def\pgfplotsforeachungrouped@#1in #2#3{% - \pgfplotsforeachungrouped@isuniform{#2}% - \ifpgfplots@loc@tmp - \pgfplotsforeachungroupeduniform@{#1}#2\relax{#3}% +\def\pgfplotsforeachungrouped#1{% + \pgfutil@ifnextchar/{\pgfplotsforeachungrouped@{#1}}{\pgfplotsforeachungrouped@{#1}/{}}% +}% +\long\def\pgfplotsforeachungrouped@#1/#2in #3#4{% + \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 - \pgfplotsforeachungroupednonuniform@#1{#2}{#3}% + % invoke \foreach #1/#2 in {#3} and transport results: + \pgfplotsforeachungroupedslashed@#1/#2{#3}{#4}% \fi } \let\pgfplots@original@pgfmathadd@=\pgfmathadd@ @@ -659,6 +676,25 @@ #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>. @@ -741,6 +777,12 @@ % 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 +% '\pgfplotsforeachlogarithmicmathid'. +% This macro should expand to something which is usable inside of +% \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{....} +% the default is 'float' % % FIXME : THIS CAN'T BE NESTED YET! \def\pgfplotsforeachlogarithmicungrouped[#1]#2/#3{\pgfplotsforeachlogarithmicungrouped@[#1]{#2}{#3}}% @@ -749,18 +791,18 @@ % \pgfplots@foreach@loc@TMPd = N in fixed point % \pgfplots@foreach@loc@TMPc = N-1 in float : \edef\pgfplots@plot@samples@@{#1}% - \pgfmathfloatcreate{1}{1.0}{0}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{one}% \let\pgfplots@foreach@loc@TMPa=\pgfmathresult - \pgfmathfloatparsenumber{\pgfplots@plot@samples@@}% - \expandafter\pgfmathfloatsubtract@\expandafter{\pgfmathresult}{\pgfplots@foreach@loc@TMPa}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{parsenumber}{\pgfplots@plot@samples@@}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{op}{subtract}{{\pgfmathresult}{\pgfplots@foreach@loc@TMPa}}% \let\pgfplots@foreach@loc@TMPc=\pgfmathresult % \edef\pgfplots@loc@TMPb{#4}% \expandafter\pgfplotsforeachlogarithmicungrouped@readdomain\pgfplots@loc@TMPb\relax % compute mesh width into \pgfplots@foreach@loc@TMPc: % \pgfplots@foreach@loc@TMPc := h := ( log(xmax) - log(xmin) ) / (N-1) - \pgfmathfloatsubtract@{\pgfplots@foreach@loc@TMPb}{\pgfplots@foreach@loc@TMPa}% - \pgfmathfloatdivide@{\pgfmathresult}{\pgfplots@foreach@loc@TMPc}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{op}{subtract}{{\pgfplots@foreach@loc@TMPb}{\pgfplots@foreach@loc@TMPa}}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{op}{divide}{{\pgfmathresult}{\pgfplots@foreach@loc@TMPc}}% \let\pgfplots@foreach@loc@TMPc=\pgfmathresult % % apply local scoping here: @@ -772,13 +814,14 @@ \pgfutil@loop \ifnum\c@pgf@counta<\pgfplots@plot@samples@@ % compute exp(log(min) + i * h) - \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgf@counta}% - \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@foreach@loc@TMPc}% - \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfplots@foreach@loc@TMPa}% + \edef\pgfplots@loc@TMPa{\the\c@pgf@counta}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{parsenumber}{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{op}{multiply}{{\pgfmathresult}{\pgfplots@foreach@loc@TMPc}}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{op}{add}{{\pgfmathresult}{\pgfplots@foreach@loc@TMPa}}% \let\pgfplots@loc@TMPa=\pgfmathresult \pgfplotsforeachlogarithmicungrouped@finalizeresult% \let#3=\pgfmathresult - \pgfmathfloatexp@{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{exp}{\pgfplots@loc@TMPa}% \pgfplotsforeachlogarithmicungrouped@finalizeresult% \let#2=\pgfmathresult % @@ -798,16 +841,16 @@ \def\pgfplotsforeachlogarithmicungrouped@finalizeresult{}% +\def\pgfplotsforeachlogarithmicmathid{float} + % defines % \pgfplots@foreach@loc@TMPa := log(firstintervalpt) % and % \pgfplots@foreach@loc@TMPb := log(secondintervalpt) \def\pgfplotsforeachlogarithmicungrouped@readdomain#1:#2\relax{% - \pgfmathfloatparsenumber{#1}% - \pgfmathfloatln@{\pgfmathresult}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{log}{#1}% \let\pgfplots@foreach@loc@TMPa=\pgfmathresult - \pgfmathfloatparsenumber{#2}% - \pgfmathfloatln@{\pgfmathresult}% + \pgfplotscoordmath{\pgfplotsforeachlogarithmicmathid}{log}{#2}% \let\pgfplots@foreach@loc@TMPb=\pgfmathresult } @@ -820,7 +863,7 @@ \def\pgfplots@logfileopen#1{% \immediate\write-1{PGFPlots: reading {#1}}% \pgfutil@ifundefined{tikzifexternalizingcurrent}{% - % version not up-to-date!? + % 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 @@ -851,15 +894,23 @@ \begingroup \c@pgf@counta=#2\relax \c@pgf@countb=#1\relax - \c@pgf@countc=\c@pgf@countb - \ifnum\c@pgf@counta=0 - \pgfplots@error{Can't compute \the\c@pgf@countb\space mod \the\c@pgf@counta\space -- this yields division by zero (second argument is zero)!}% - \edef\pgfmathresult{#1}% + \ifnum\c@pgf@counta=2 + \ifodd\c@pgf@countb + \def\pgfmathresult{1}% + \else + \def\pgfmathresult{0}% + \fi \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}% + \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 @@ -967,6 +1018,81 @@ \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}{if is}{\pgfplots@r}{0}{% + \pgfplotscoordmath{#5}{parsenumber}{0}% + }{% + \pgfplotscoordmath{#5}{op}{divide}{{\pgfplots@x}{\pgfplots@r}}% + \let\pgfplots@quot=\pgfmathresult + \pgfplotscoordmath{#5}{op}{acos}{{\pgfplots@quot}}% + % + \pgfplotscoordmath{#5}{if is}{\pgfplots@y}{-}{% + \let\pgfplots@acos=\pgfmathresult + \pgfplotscoordmath{#5}{parsenumber}{-1}% + \pgfplotscoordmath{#5}{op}{multiply}{{\pgfmathresult}{\pgfplots@acos}}% + }{}% + }% + \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 : @@ -1184,17 +1310,17 @@ % #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/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/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/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/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}{% @@ -1303,12 +1429,136 @@ \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} +} + \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} diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.verb.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.verb.code.tex new file mode 100644 index 00000000000..8590ba908d6 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/util/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/Master/texmf-dist/tex/latex/pgfplots/bugtracker.sty b/Master/texmf-dist/tex/latex/pgfplots/bugtracker.sty index 69f9cbddd6c..50130daaa8c 100644 --- a/Master/texmf-dist/tex/latex/pgfplots/bugtracker.sty +++ b/Master/texmf-dist/tex/latex/pgfplots/bugtracker.sty @@ -101,12 +101,7 @@ }% \def\bugtracker@collect@status@opt#1[#2][#3]{% \begingroup - \bugtrackerset{#3}% - \def\bugtracker@temp{#2}% - \ifx\bugtracker@temp\pgfutil@empty - \else - \bugtrackerset{status=#2}% - \fi + \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 @@ -236,13 +231,14 @@ prio/.initial=5, source line/.initial=, status/.is choice, - status/open/.initial= {\def\bugtracker@status{open}}, - status/closed/.initial= {\def\bugtracker@status{closed}}, - status/cancelled/.initial= {\def\bugtracker@status{cancelled}}, - status/partially/.initial= {\def\bugtracker@status{partially}}, + 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/open/.initial=0, status order/closed/.initial=10, status order/cancelled/.initial=7, @@ -256,10 +252,19 @@ \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 [#2]\hspace{2em}}\protect\bugtrackerset{/bugtracker/typeset name={\pgfkeysvalueof{/bugtracker/name}}} + \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}] @@ -270,8 +275,19 @@ #1% \par }% - {\scriptsize Entry in {\ttfamily \jobname.tex:\pgfkeysvalueof{/bugtracker/source line}}}% - }% + %{\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} @@ -285,6 +301,12 @@ } +\lstdefinestyle{minimalexample}{ + basicstyle=\ttfamily\footnotesize, + columns=fullflexible, +} + + % a % \begin{minimal} % \end{minimal} @@ -307,26 +329,21 @@ \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}% + \bugtracker@bslash begin{lstlisting}[style=minimalexample]% ##1% \bugtracker@bslash end{lstlisting}% }% - \expandafter\bugtracker@minimal@typeset\expandafter{\bugtracker@temp{#1}}% + \def\bugtracker@temp@##1{\pgfkeysvalueof{/bugtracker/typeset minimal/.@cmd}{##1}\pgfeov}% + \expandafter\bugtracker@temp@\expandafter{\bugtracker@temp{#1}}% \endgroup - \end{minimal}% -}% -\long\def\bugtracker@minimal@typeset#1{% - \ifvmode - \noindent - \fi - \href{file:\bugtracker@minimal@filename@}{% - \vbox{% - \bugtracker@minimal@typeset@{#1}% - }% - }% }% \long\def\bugtracker@minimal@typeset@#1{% \scantokens{#1}% diff --git a/Master/texmf-dist/tex/latex/pgfplots/libs/tikzlibrarypgfplots.clickable.code.tex b/Master/texmf-dist/tex/latex/pgfplots/libs/tikzlibrarypgfplots.clickable.code.tex index a7df35d24c3..755a4089b0a 100644 --- a/Master/texmf-dist/tex/latex/pgfplots/libs/tikzlibrarypgfplots.clickable.code.tex +++ b/Master/texmf-dist/tex/latex/pgfplots/libs/tikzlibrarypgfplots.clickable.code.tex @@ -20,8 +20,122 @@ % %-------------------------------------------- +\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! @@ -51,12 +165,41 @@ % Work-around for a bug in \begindljs of acrotex: % if " is active, \begindljs will be wrong. -\def\begindljs +%-------------------------------------------------- +% 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{\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}}} + \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} @@ -72,10 +215,18 @@ \gdef\pgfplotsHASH{#}% \catcode`\%=12 \gdef\pgfplotsPERCENT{%}} +% 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: @@ -276,118 +427,562 @@ function sprintf( ) { } /*********************************************************************************/ +% see https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Inheritance -var lastMouseX = -1; -var lastMouseY = -1; +var lastPoint = null; var posOnMouseDownX = -1; var posOnMouseDownY = -1; // preallocation. -var tmpArray1 = new Array(2); -var tmpArray2 = new Array(2); +var tmpArray1 = new Array(3); +var tmpArray2 = new Array(3); -/** - * Takes an already existing TextField, changes its value to \c value and places it at (x,y). - * Additional \c displayOpts will be used to format it. - */ -function initTextField( x,y, textField, displayOpts, value ) +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, super ) { - textField.value = ""+value; - var R = textField.rect; - R[0] = x; - R[1] = y; - R[2] = R[0] + displayOpts.textSize/2*Math.max( 5,value.length ); - R[3] = R[1] - 1.5*displayOpts.textSize; - textField.rect = R; - textField.textFont = displayOpts.textFont; - textField.textSize = displayOpts.textSize; - textField.fillColor = displayOpts.fillColor;//["RGB",1,1,.855]; - textField.doNotSpellCheck = true; - textField.readonly = true; - if( displayOpts.printable ) - textField.display = display.visible; - else - textField.display = display.noPrint; + for (var property in super.prototype) { + if (typeof child.prototype[property] == "undefined") + child.prototype[property] = super.prototype[property]; + } + return child; } -/** - * 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 coordinate where the annotation shall be placed and which is used to determine - * the annotation text. - * @param y the corresponding y coord. - * @param axisAnnotObj An object containing axis references. - * @param displayOpts An object for display flags. - * @param[out] retCoords will be filled with the point in axis coordinates. - */ -function placeAnnot( plotRegionField, x,y, textField, axisAnnotObj, displayOpts, retCoords ) +function PGFPlotsCreateAxisFor( axisAnnotObj, docObject ) { - // 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 R = plotRegionField.rect; - R[0] = Math.round(R[0]); - R[1] = Math.round(R[1]); - R[2] = Math.round(R[2]); - R[3] = Math.round(R[3]); - plotRegionField.rect= R; - - var w = R[2] - R[0]; - var h = R[1] - R[3]; - - // compute position 0 <= mx <= 1, 0<= my <= 1 relative to lower(!) left corner. - var mx = x - R[0]; - var my = h - (R[1] - y); - - var unitx = mx / w; - var unity = my / h; - - var realx = axisAnnotObj.xmin + unitx * (axisAnnotObj.xmax - axisAnnotObj.xmin); - var realy = axisAnnotObj.ymin + unity * (axisAnnotObj.ymax - axisAnnotObj.ymin); - - var transformedCoordx = realx; - var transformedCoordy = realy; - - if( axisAnnotObj.xscale.length >= 3 && axisAnnotObj.xscale.substr(0,3) == "log" ) { - if( axisAnnotObj.xscale.length > 4 ) // log:<basis> - realx = realx * Math.log( axisAnnotObj.xscale.substr(4) ); - else { - // pgfplots handles log plots base e INTERNALLY, but uses base 10 for display. - // convert to base 10: - transformedCoordx = realx / Math.log(10); - } - realx = Math.exp(realx); + var ret = null; + if( pgfplotsAxisRegistry[axisAnnotObj.axisType] ) { + ret = pgfplotsAxisRegistry[axisAnnotObj.axisType](axisAnnotObj); + ret.docObject = docObject; } - if( axisAnnotObj.yscale.length >= 3 && axisAnnotObj.yscale.substr(0,3) == "log" ) { - if( axisAnnotObj.yscale.length > 4 ) // log:<basis> - realy = realy * Math.log( axisAnnotObj.yscale.substr(4) ); + 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 { - // pgfplots handles log plots base e INTERNALLY, but uses base 10 for display. - // convert to base 10: - transformedCoordy = realy / Math.log(10); + 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; } - realy = Math.exp(realy); } +} + + + +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; + } -// console.println( "w = " + w + "; h = " + h ); -// console.println( "mx = " + mx + "; my = " + my ); -// console.println( "unitx = " + unitx + "; unity " + unity ); + this.placeClickableCoord( + point, + result, displayOpts, null ); + }, - initTextField( x,y, textField, displayOpts, - //util.printf( "(\pgfplotsPERCENT.2f,\pgfplotsPERCENT.2f)", realx,realy ) - sprintf( displayOpts.pointFormat, realx,realy) ); + /** + * 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; + } - if( retCoords ) { - retCoords[0] = transformedCoordx; - retCoords[1] = transformedCoordy; } } +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 axisAnnotObj an object with the fields + * @param axis an object with the fields * - xmin, xmax * - ymin, ymax * - xscale, yscale @@ -399,67 +994,23 @@ function placeAnnot( plotRegionField, x,y, textField, axisAnnotObj, displayOpts, * ["RGB",1,1,.855] * - textFont / textSize */ -function processAnnotatedPlot(formName, axisAnnotObj, displayOpts, bMouseUp ) +function axisMouseUp(formName, axisAnnotObj, displayOpts) { - if( !bMouseUp ) { - posOnMouseDownX = mouseX; - posOnMouseDownY = mouseY; - return; - } - var result = this.getField( formName + "-result"); - var result2 = this.getField( formName + "-result2"); - var slope = this.getField( formName + "-slope" ); - if( !result ) { - console.println( "WARNING: there is no TextField \"" + formName + "-result\" to display results for interactive element \"" + formName + "\""); + var axis = PGFPlotsCreateAxisFor(axisAnnotObj,this); + if( axis == null ) return; - } - result2.display = display.hidden; - slope.display = display.hidden; - // clicking twice onto the same point hides it: - if( result.display != display.hidden && - Math.abs(lastMouseX - mouseX) < 5 && - Math.abs(lastMouseY - mouseY) < 5 ) + if( Math.abs( mouseX - posOnMouseDownX ) > 6 \pgfplotsVERTBAR\pgfplotsVERTBAR + Math.abs( mouseY - posOnMouseDownY ) > 6 ) { - result.display = display.hidden; - return; - } - lastMouseX = mouseX; - lastMouseY = mouseY; - - var a = this.getField(formName); - if( ! a ) { - console.println( "Warning: there is no form named \"" + formName + "\"" ); - return; - } - if( Math.abs( lastMouseX - posOnMouseDownX ) > 6 \pgfplotsVERTBAR\pgfplotsVERTBAR - Math.abs( lastMouseY - posOnMouseDownY ) > 6 ) - { - // dragging the mouse results in slope computation: - // placeAnnot shows the endpoint coords and returns the (transformed) coordinates into tmpArray1 and tmpArray2: - placeAnnot( a, posOnMouseDownX, posOnMouseDownY, result, axisAnnotObj, displayOpts, tmpArray1 ); - placeAnnot( a, lastMouseX, lastMouseY, result2, axisAnnotObj, displayOpts, tmpArray2 ); - - var m = ( tmpArray2[1] - tmpArray1[1] ) / ( tmpArray2[0] - tmpArray1[0] ); - var n = tmpArray1[1] - m * tmpArray1[0]; - - initTextField( - 0.5 * ( lastMouseX + posOnMouseDownX ), - 0.5 * ( lastMouseY + posOnMouseDownY ), - slope, - displayOpts, - sprintf( displayOpts.slopeFormat, m, n ) ); - - // 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 = [[lastMouseX,lastMouseY],[posOnMouseDownX,posOnMouseDownY]]; - //lineobj.display = display.visible; + axis.handleDragNDrop( formName, displayOpts ); } else { - placeAnnot( a, lastMouseX, lastMouseY, result, axisAnnotObj, displayOpts, null ); + axis.handleClick( formName, displayOpts ); } } + + \end{insDLJS} %-------------------------------------------------- % function hideClickableTextfields() { @@ -476,50 +1027,85 @@ function processAnnotatedPlot(formName, axisAnnotObj, displayOpts, bMouseUp ) %-------------------------------------------------- -\newif\ifpgfplots@clickable -\newif\ifpgfplots@annot@printable +\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}}}% -\pgfqkeys{/pgfplots}{ - @backgroundpath@hook/.add code={}{\ifpgfplots@threedim\else\pgfplots@create@clickable@plotarea@hook\fi}, - clickable/.is if=pgfplots@clickable, - clickable/.default=true, - clickable=true, - annot/js fillColor/.initial={["RGB",1,1,.855]}, - annot/point format/.initial={(\%.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/width/.initial=, - annot/height/.initial=, - annot/jsname/.initial=, - annot/xmin/.initial=, - annot/xmax/.initial=, - annot/ymin/.initial=, - annot/ymax/.initial=, - annot/xscale/.initial=, % "log" or "linear" or "log:<basis>" - annot/yscale/.initial=, - 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)}}, +\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. @@ -559,30 +1145,70 @@ function processAnnotatedPlot(formName, axisAnnotObj, displayOpts, bMouseUp ) \xdef\pgfplots@clickable@no{\the\c@pgf@counta}% \endgroup \fi - \edef\pgfplots@clickable@expanded@args{% FIXME : is that a good idea to do!? Are user-args expandable? + % + \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}% {{ - 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}" + 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: "\pgfkeysvalueof{/pgfplots/annot/point format}", + 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. @@ -590,53 +1216,103 @@ function processAnnotatedPlot(formName, axisAnnotObj, displayOpts, bMouseUp ) \def\pgfplots@create@clickable@plotarea@hook{% \ifpgfplots@clickable \begingroup - \ifpgfplots@apply@datatrafo@x - \pgfplots@inverse@datascaletrafo@x\pgfplots@xmin - \pgfmathfloattosci\pgfmathresult + % 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 - \pgfplots@inverse@datascaletrafo@x\pgfplots@xmax - \pgfmathfloattosci\pgfmathresult + \pgfplotscoordmath{x}{datascaletrafo inverse}{\pgfplots@xmax}% + \pgfplotscoordmath{x}{tostring}{\pgfmathresult}% \let\pgfplots@clickable@xmax=\pgfmathresult - \else - \let\pgfplots@clickable@xmin=\pgfplots@xmin - \let\pgfplots@clickable@xmax=\pgfplots@xmax - \fi - % - \ifpgfplots@apply@datatrafo@y - \pgfplots@inverse@datascaletrafo@y\pgfplots@ymin - \pgfmathfloattosci\pgfmathresult + % + \pgfplotscoordmath{y}{datascaletrafo inverse}{\pgfplots@ymin}% + \pgfplotscoordmath{y}{tostring}{\pgfmathresult}% \let\pgfplots@clickable@ymin=\pgfmathresult - \pgfplots@inverse@datascaletrafo@y\pgfplots@ymax - \pgfmathfloattosci\pgfmathresult + \pgfplotscoordmath{y}{datascaletrafo inverse}{\pgfplots@ymax}% + \pgfplotscoordmath{y}{tostring}{\pgfmathresult}% \let\pgfplots@clickable@ymax=\pgfmathresult - \else - \let\pgfplots@clickable@ymin=\pgfplots@ymin - \let\pgfplots@clickable@ymax=\pgfplots@ymax - \fi - \pgfplotspointbbdiagonal - \edef\pgfplots@clickable@wd{\the\pgf@x}% - \edef\pgfplots@clickable@ht{\the\pgf@y}% - % - % Convert to user interface of clickable lib: - \pgfkeyslet{/pgfplots/annot/width}\pgfplots@clickable@wd - \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}}% + % + \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 - \pgfinterruptboundingbox% - \pgftext[left,bottom,at=\lowerleftinnercorner]{\pgfplotsclickablecreate[]}% - \endpgfinterruptboundingbox% \endgroup \fi } @@ -684,14 +1360,16 @@ function processAnnotatedPlot(formName, axisAnnotObj, displayOpts, bMouseUp ) \AA{ % /U = "mouse UP" % /D = "mouse DOWN" - /U << /S/JavaScript/JS(processAnnotatedPlot("#3", #4, #5, 1);) >> - /D << /S/JavaScript/JS(processAnnotatedPlot("#3", #4, #5, 0);) >> + /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 :-( diff --git a/Master/texmf-dist/tex/latex/pgfplots/libs/tikzlibrarypgfplotsclickable.code.tex b/Master/texmf-dist/tex/latex/pgfplots/libs/tikzlibrarypgfplotsclickable.code.tex index e6fed68167d..8cebcd18c2a 100644 --- a/Master/texmf-dist/tex/latex/pgfplots/libs/tikzlibrarypgfplotsclickable.code.tex +++ b/Master/texmf-dist/tex/latex/pgfplots/libs/tikzlibrarypgfplotsclickable.code.tex @@ -20,5 +20,5 @@ % %-------------------------------------------- -\usepgfplotslibrary{clickable} +\usetikzlibrary{pgfplots.clickable} \endinput diff --git a/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty b/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty index d707b86e5b7..2b1070dc1f1 100644 --- a/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty +++ b/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty @@ -7,7 +7,7 @@ % % It is based on Till Tantau's PGF package. % -% Copyright 2007/2008/2009 by Christian Feuersänger. +% 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 @@ -23,13 +23,13 @@ % along with this program. If not, see <http://www.gnu.org/licenses/>. % %-------------------------------------------- -\def\pgfplotsversion{1.4.1} +\def\pgfplotsversion{1.5} \IfFileExists{pgfplots.revision.tex}{\input pgfplots.revision.tex } {\def\pgfplotsrevision{}} \ifx\pgfplotsrevision\pgfutil@empty \else \edef\pgfplotsrevision{\space(git show \pgfplotsrevision)}% \fi -\ProvidesPackage{pgfplots}[2010/07/14 Version \pgfplotsversion\pgfplotsrevision] +\ProvidesPackage{pgfplots}[2011/07/29 v\pgfplotsversion\pgfplotsrevision] % ATTENTION: % you MAY need one of diff --git a/Master/texmf-dist/tex/latex/pgfplots/pgfplotstable.sty b/Master/texmf-dist/tex/latex/pgfplots/pgfplotstable.sty index 186c41ad4ef..948e4497de2 100644 --- a/Master/texmf-dist/tex/latex/pgfplots/pgfplotstable.sty +++ b/Master/texmf-dist/tex/latex/pgfplots/pgfplotstable.sty @@ -2,7 +2,7 @@ % % Package pgfplotstable.sty % -% Copyright 2007/2008 by Christian Feuersänger. +% 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 @@ -18,7 +18,7 @@ % along with this program. If not, see <http://www.gnu.org/licenses/>. % %-------------------------------------------- -\ProvidesPackage{pgfplotstable}[2010/07/14 Part of pgfplots] +\ProvidesPackage{pgfplotstable}[2011/07/29 Part of pgfplots] \RequirePackage{pgfplots} diff --git a/Master/texmf-dist/tex/latex/pgfplots/pgfregressiontest.sty b/Master/texmf-dist/tex/latex/pgfplots/pgfregressiontest.sty new file mode 100644 index 00000000000..a6ed64ffbc1 --- /dev/null +++ b/Master/texmf-dist/tex/latex/pgfplots/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 +}% |