diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex | 1197 |
1 files changed, 327 insertions, 870 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex index d230e0d1ed7..a80e77884ce 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex @@ -64,7 +64,9 @@ \pgf@zy=0pt }% % - % + % The \pgfplotsqpointxyz method (or its 2d counterpart) are THE + % point method. If you override them, all other coordinate systems + % should inherit the changes as well. \edef\pgfplotsplothandlerpointxyz##1##2##3{% \ifpgfplots@curplot@threedim \noexpand\pgfplotsqpointxyz{##1}{##2}{##3}% @@ -765,33 +767,6 @@ \ifpgfplots@loc@tmp #2\else #3\fi }% -% Returns either '' (empty) or '-' (minus) for each of the two variing sides of the -% oriented surface described by #1. -% -% The output value #2 = '' means that the positive b axis points to -% the direction of the convex hull of the projected figure. -% -% The output value #2 = '-' means that the NEGATIVE b axis points to -% the direction of the convex hull of the projected figure. -% -% The output value #3 is also either '' or '-'. It refers to the -% direction of the 'n' axis of the surface which points to the convex -% hull of the projected figure. -% -% The returned values are used to decide how to align tick labels such -% that they are always outside of the convex hull of the projected -% axis. -% -% #1: three characters denoting an oriented surface. -% #2: a macro name. Will be filled either with '' (empty string) or -% '-', encoding the direction of the 'b' axis of surface #1 which -% points to the convex hull. -% #3: a macro name. It takes the same values as '#2', but it refers to -% the 'n' axis of surface #1. -\def\pgfplotsgetdirectionstoconvexhullforsurf#1#2#3{% - \pgfplotsgetdirectionstoconvexhullforsurf@#1\relax{#2}{#3}% -} - % Executes code '#2' if the axis line with 'b=#1' on the current % oriented surface shall be drawn. % If that is not the case, the code '#3' will be executed. @@ -1231,16 +1206,22 @@ \def\pgfplots@loc@naxis{y}% \fi \fi - \if0\pgfplots@loc@char@for@baxis% + \ifcase\pgfplots@loc@char@for@baxis\relax% + % case 0: % this means : the '##1' direction of the surface % orthogonal to the 'v' vector is on the lower axis % limit. Since I need a vector pointing to the OUTSIDE of % the axis, I need sign = -1 \def\pgfplots@loc@baxissign{-}% - \else + \or + % case 1: % in this case, the OUTSIDE area requires a plus sign - the b % axis already points to the inside. \def\pgfplots@loc@baxissign{+}% + \or + % case 2: we have the 'axis lines=centered' case. + % FIXME : + \def\pgfplots@loc@baxissign{+}% \fi \pgfplotsmath@ifzero{\csname pgfplots@\pgfplots@loc@baxis @veclength\endcsname}{% \def\pgfplots@loc@baxissign{0}% @@ -1250,16 +1231,22 @@ }% % % Now the same game for the other axis: - \if0\pgfplots@loc@char@for@naxis% + \ifcase\pgfplots@loc@char@for@naxis\relax + % case 0: % this means : the '##2' direction of the surface % orthogonal to the 'v' vector is on the lower axis % limit. Since I need a vector pointing to the OUTSIDE of % the axis, I need sign = -1 \def\pgfplots@loc@naxissign{-}% - \else + \or + % case 1: % in this case, the OUTSIDE area requires a plus sign - the n % axis already points to the inside. \def\pgfplots@loc@naxissign{+}% + \or + % case 2: centered. + % FIXME + \def\pgfplots@loc@naxissign{+}% \fi \pgfplotsmath@ifzero{\csname pgfplots@\pgfplots@loc@naxis @veclength\endcsname}{% \def\pgfplots@loc@naxissign{0}% @@ -1331,6 +1318,7 @@ \pgf@xa=#5pt\relax \edef\pgfplots@loc@distalong@normal{\pgf@sys@tonumber\pgf@xa}% % +%\message{pgfplotspointoutsideofaxis{#1#2#3}{#4}{#5}: A = \pgfplots@loc@A, B = \pgfplots@loc@B.^^J}% % \pgf@process{% \pgfpointadd @@ -1415,6 +1403,8 @@ \else \if#21% \expandafter\let\expandafter\pgfmathresult\csname pgfplots@#1max\endcsname + \else + \expandafter\let\expandafter\pgfmathresult\csname pgfplots@logical@ZERO@#1\endcsname \fi \fi }% @@ -1714,171 +1704,11 @@ \endgroup }% -% Takes azimuth (horizontal angle) '#1' and elongation (vertical -% angle) '#2' (both in degrees) and computes -% x,y and z vectors which define the view in the direction -% defined by '#1' and '#2'. -% -% 'azimuth' means a rotation around the viewport's x axis. 'elongation' means -% a rotation around the original coordinate system's z axis. -% -% The method works by computing -% Az = [ cos(azimuth) -sin(azimuth) 0; ... -% sin(azimuth) cos(azimuth) 0; ... -% 0 0 1 ]; -% -% -% Ax = [ 1 0 0; ... -% 0 cos(elevation) -sin(elevation) ;... -% 0 sin(elevation) cos(elevation) ]; -% -% v= Ax * Az; -% = [ ... -% cosaz -sinaz cosel sinaz sinel; ... -% sinaz cosaz cosel -sinel cosaz; ... -% 0 sinel cosel ]; -% -% Then, we use the rotated XZ plane as viewport, that means -% xvec = v * [1 0 0]' = <first column of v> -% zvec = v * [0 0 1]' = <third column of v> -% and we define the projection onto the twodimensional surface -% spanned by 'xvec' and 'zvec' as -% P( q ) = [ q^T xvec, q^T zvec ]' -% for q in R^3. -% As a consequence, we compute the three unit vectors as -% x = P( [1 0 0] ) -% = [ cosaz, sinaz sinel ]' -% y = P( [0 1 0] ) -% = [ sinaz, -sinel cosaz ]' -% z = P( [0 0 1] ) -% = [ 0, cosel]' -% -% Furthermore, the 3D view vector which points into the direction of the view -% is -% n = v * [0 1 0 ]' = <second column of v> = [-sinaz cosel, cosaz cosel, sinel]' -% because the normal view point was the XZ plane with y as its normal -% vector. -% The 3D vector n is returned by this routine as well - it is -% necessary for some kind of z buffering (determining what is -% foreground and what is background). -% -% INPUT: -% - #1 : azimuth ("yaw") -% - #2 : elevation ("pitch") -% OUTPUT: -% - #3 : a macro which will be set to '1' if and only if -% the viewport is the standard XY axis (i.e. azimuth=0, elevation=90). -% - [xyz] vectors, -% \pgfplots@[xyz]@veclength, -% \pgfplots@[xyz]@inverseveclength -% are set properly -% \pgfplots@view@dir@threedim@[xyz] will contain the three components -% of 'n' (without the suffix 'pt', but in units of 'pt'). -\def\pgfplotssetaxesfromazel#1#2#3{% - \begingroup - \pgfmathparse{#1}% - \let\pgfplots@az=\pgfmathresult - \pgfmathparse{#2}% - \edef\pgfplots@el{-\pgfmathresult}% - \pgfmathsin@{\pgfplots@az}% - \let\sinaz=\pgfmathresult - \pgfmathcos@{\pgfplots@az}% - \let\cosaz=\pgfmathresult - \pgfmathsin@{\pgfplots@el}% - \let\sinel=\pgfmathresult - \pgfmathcos@{\pgfplots@el}% - \let\cosel=\pgfmathresult - % x: - \pgfmathmultiply@{\sinaz}{\sinel}% - \xdef\pgfplots@glob@TMPa{\noexpand\pgfqpoint{\cosaz pt}{\pgfmathresult pt}}% - % y: - \pgfmathmultiply@{-\sinel}{\cosaz}% - \xdef\pgfplots@glob@TMPb{\noexpand\pgfqpoint{\sinaz pt}{\pgfmathresult pt}}% - % z: - \xdef\pgfplots@glob@TMPc{\noexpand\pgfqpoint{0pt}{\cosel pt}}% - % - \pgfkeysgetvalue{/pgfplots/x dir/value}\pgfplots@loc@dirvalue@x - \pgfkeysgetvalue{/pgfplots/y dir/value}\pgfplots@loc@dirvalue@y - \pgfkeysgetvalue{/pgfplots/z dir/value}\pgfplots@loc@dirvalue@z - \if r\pgfplots@loc@dirvalue@x - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% - \xdef\pgfplots@glob@TMPa{\noexpand\pgfqpointscale{-1}{\the\t@pgfplots@toka}}% - \fi - \if r\pgfplots@loc@dirvalue@y - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPb}% - \xdef\pgfplots@glob@TMPb{\noexpand\pgfqpointscale{-1}{\the\t@pgfplots@toka}}% - \fi - \if r\pgfplots@loc@dirvalue@z - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPc}% - \xdef\pgfplots@glob@TMPc{\noexpand\pgfqpointscale{-1}{\the\t@pgfplots@toka}}% - \fi - % - % Process 'plot box ratio': - \def\pgfplots@extract@plot@box@ratio##1##2##3##4\pgfplots@EOI{% - \pgfmathparse{##1}\let\pgfplots@plotboxratio@x=\pgfmathresult - \pgfmathparse{##2}\let\pgfplots@plotboxratio@y=\pgfmathresult - \pgfmathparse{##3}\let\pgfplots@plotboxratio@z=\pgfmathresult - }% - \def\pgfplots@extract@plot@box@ratio@spaces##1 ##2 ##3 ##4\pgfplots@EOI{% - \pgfplots@extract@plot@box@ratio{##1}{##2}{##3}{##4}\pgfplots@EOI - }% - \pgfkeysgetvalue{/pgfplots/plot box ratio}\pgfplots@loc@TMPa - % Auto-determine input format which is either '{x}{y}{z}' or 'x y z' - \def\pgfplots@loc@TMPb{% - \pgfutil@ifnextchar\bgroup{% - \pgfplots@loc@tmptrue - \pgfplots@gobble@until@EOI - }{% - \pgfplots@loc@tmpfalse - \pgfplots@gobble@until@EOI - }% - }% - \expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI - \ifpgfplots@loc@tmp - % Ah- braces format. - \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa{1}{1}{1}}% - \expandafter\pgfplots@extract@plot@box@ratio\pgfplots@loc@TMPa\pgfplots@EOI - \else - % Ah- space-separated - \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa\space 1 1 1}% - \expandafter\pgfplots@extract@plot@box@ratio@spaces\pgfplots@loc@TMPa\pgfplots@EOI - \fi - % - % process it: - \ifdim\pgfplots@plotboxratio@x pt=1pt - \else - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% - \xdef\pgfplots@glob@TMPa{\noexpand\pgfqpointscale{\pgfplots@plotboxratio@x}{\the\t@pgfplots@toka}}% - \fi - \ifdim\pgfplots@plotboxratio@y pt=1pt - \else - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPb}% - \xdef\pgfplots@glob@TMPb{\noexpand\pgfqpointscale{\pgfplots@plotboxratio@y}{\the\t@pgfplots@toka}}% - \fi - \ifdim\pgfplots@plotboxratio@z pt=1pt - \else - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPc}% - \xdef\pgfplots@glob@TMPc{\noexpand\pgfqpointscale{\pgfplots@plotboxratio@z}{\the\t@pgfplots@toka}}% - \fi - % - % n (3D!) - \pgfmathmultiply@{-\sinaz}{\cosel}% - \let\pgfmathresultNx=\pgfmathresult - \pgfmathmultiply@{\cosaz}{\cosel}% - \xdef\pgfplots@glob@TMPd{{\pgfmathresultNx}{\pgfmathresult}{\sinel}}% - \endgroup -%\message{Setting x,y and z from {#1}{#2} to^^J x = \meaning\pgfplots@glob@TMPa,^^J y = \meaning\pgfplots@glob@TMPb,^^J z = \meaning\pgfplots@glob@TMPc,^^J n = \pgfplots@glob@TMPd.^^J}% - \pgfsetxvec{\pgfplots@glob@TMPa}% - \pgfsetyvec{\pgfplots@glob@TMPb}% - \pgfsetzvec{\pgfplots@glob@TMPc}% - \def\pgfplots@loc@TMPa##1##2##3{% - \def\pgfplots@view@dir@threedim@x{##1}% - \def\pgfplots@view@dir@threedim@y{##2}% - \def\pgfplots@view@dir@threedim@z{##3}% - }% - \expandafter\pgfplots@loc@TMPa\pgfplots@glob@TMPd\relax - \def#3{0}% - \pgfplots@scale@plotbox@to@widthheight + +\def\pgfplotspointviewdir{% + %\pgfplotsmathvectordatascaletrafoinverse{\pgfplots@view@dir@threedim}{default}% + \let\pgfplotsretval=\pgfplots@view@dir@threedim + \pgfplotspointfromcsvvector{\pgfplotsretval}{default}% }% \def\message@pgfplots@units{% @@ -1889,542 +1719,21 @@ \fi \pgfmathparse{veclen(\pgf@xx,\pgf@xy)/\Z}\let\X=\pgfmathresult \pgfmathparse{veclen(\pgf@yx,\pgf@yy)/\Z}\let\Y=\pgfmathresult + \expandafter\ifx\csname pgfplots@view@dir@threedim\endcsname\relax + \def\normal{view = (---),^^J}% + \else + \pgfplotsmathvectortostring{\pgfplots@view@dir@threedim}{default}% + \edef\normal{view = (\pgfplotsretval),^^J}% + \fi \message{^^J x = (\the\pgf@xx,\the\pgf@xy),^^J y =(\the\pgf@yx,\the\pgf@yy),^^J z = (\the\pgf@zx,\the\pgf@zy),^^J - \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 + \normal 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 -} - - -% 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. -% -% The relative length of the input vectors is important for the 3D case: it -% will be scaled as-is. -% -% PRECONDITION -% - the x, y and z unit vectors have been set to the proper -% DIRECTIONS. Their relative vector lengths are set-up properly -% (i.e. y is twice as large as x and half as large as z or so). -% - \pgfplots@[xyz]@veclength and -% \pgfplots@[xyz]@inverseveclength -% are set correctly. -% - the \ifpgfplots@threedim boolean is set. -% - the data limits have been initialised and transformed according -% to the data transformation. -% -% POSTCONDITION -% - the unit vectors have been re-scaled such that the final plot -% has the desired dimensions. -% - the @veclength and @inverseveclength have been re-scaled as -% well. -\def\pgfplots@scaleaxes@to@BB#1#2{% -%\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}% - \pgfpathmoveto{\pgfqpointxyz010}% - \pgfpathmoveto{\pgfqpointxyz011}% - \pgfpathmoveto{\pgfqpointxyz100}% - \pgfpathmoveto{\pgfqpointxyz101}% - \pgfpathmoveto{\pgfqpointxyz110}% - \pgfpathmoveto{\pgfqpointxyz111}% - \else - \pgfpathmoveto{\pgfqpointxy00}% - \pgfpathmoveto{\pgfqpointxy01}% - \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 - % TMPb = height - \pgf@xb=\pgf@pathmaxy - \advance\pgf@xb by-\pgf@pathminy - \pgf@ya=#1\relax - \pgf@yb=#2\relax -%\message{PGFPLOTS: the current unit vectors result in a UNIT BB of (\the\pgf@xa,\the\pgf@xb). Scaling it to (\the\pgf@ya,\the\pgf@yb)...}% - \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 - % 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=\pgfplots@loc@TMPa\pgf@xx - \pgf@xy=\pgfplots@loc@TMPa\pgf@xy - % - \pgf@yx=\pgfplots@glob@TMPa\pgf@yx - \pgf@yy=\pgfplots@glob@TMPb\pgf@yy - \pgf@yx=\pgfplots@loc@TMPb\pgf@yx - \pgf@yy=\pgfplots@loc@TMPb\pgf@yy - % - \ifpgfplots@threedim - \pgf@zx=\pgfplots@glob@TMPa\pgf@zx - \pgf@zy=\pgfplots@glob@TMPb\pgf@zy - \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@{% - {\pgf@sys@tonumber\pgf@xx}% - {\pgf@sys@tonumber\pgf@xy}% - }% - \let\pgfplots@x@veclength=\pgfmathresult - \pgfplotsmath@ifzero{\pgfplots@x@veclength}{% - \def\pgfmathresult{infty}% - % this case will be caught in \pgfplots@initsizes - }{% - \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% - }% - \let\pgfplots@x@inverseveclength=\pgfmathresult - % - \pgfplotsutil@edef@invoke\pgfmathveclen@{% - {\pgf@sys@tonumber\pgf@yx}% - {\pgf@sys@tonumber\pgf@yy}% - }% - \let\pgfplots@y@veclength=\pgfmathresult - \pgfplotsmath@ifzero{\pgfplots@y@veclength}{% - \def\pgfmathresult{infty}% - % this case will be caught in \pgfplots@initsizes - }{% - \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% - }% - \let\pgfplots@y@inverseveclength=\pgfmathresult - % - \ifpgfplots@threedim - \pgfplotsutil@edef@invoke\pgfmathveclen@{% - {\pgf@sys@tonumber\pgf@zx}% - {\pgf@sys@tonumber\pgf@zy}% - }% - \let\pgfplots@z@veclength=\pgfmathresult - \pgfplotsmath@ifzero{\pgfplots@z@veclength}{% - \def\pgfmathresult{infty}% - % this case will be caught in \pgfplots@initsizes - }{% - \expandafter\pgfmath@basic@reciprocal@\expandafter{\pgfmathresult}% - }% - \let\pgfplots@z@inverseveclength=\pgfmathresult - \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}% -}% % ================================================================================== % @@ -2513,7 +1822,7 @@ 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 get params= \def\pgfmathresult{{0}{0}}, datascaletrafo= \edef\pgfmathresult{##1}, datascaletrafo inverse= \edef\pgfmathresult{##1}, datascaletrafo noshift inverse= \edef\pgfmathresult{##1}, @@ -2680,8 +1989,10 @@ #1\relax\pgfplotscoordmathnotifydatascalesetfor{\pgfplotscoordmathid}% }},% % - % Defines \pgfmathresult to contain the two parameters required - % for 'datascaletrafo set params'. + % Defines \pgfmathresult to contain the two parameters in the form + % {#1}{#2} required for 'datascaletrafo set params': + % #1: the EXPONENT (as integer) + % #2: the SHIFT (as fixed point number) datascaletrafo get params/.code= {\expandafter\def\csname pgfpmth\pgfplotsdeclarecoordmath@ datascaletrafo get params\endcsname{#1}},% datascaletrafo/.code= @@ -2738,6 +2049,7 @@ \pgfplotscoordmath{\pgfplotscoordmathid}{op}{reciprocal}{{\pgfmathresult}}% \let\pgfplots@loc@TMPb=\pgfmathresult% TMPb = 1/log_e(#2) % + % log_a(x) = log_e(x) / log_e(a) \expandafter\edef\csname pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @log\endcsname##1{% \noexpand\pgfplotscoordmath{\pgfplotscoordmathid}{log e}{##1}% \noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty @@ -2748,6 +2060,8 @@ }% \noexpand\fi }% + % + % a^x = exp(log_e(a^x)) = exp(x*log_e(a)) \expandafter\edef\csname pgfpmth\pgfplotsdeclarecoordmath@ @\pgfplotscoordmathid @exp\endcsname##1{% \noexpand\edef\noexpand\pgfmathresult{##1}% \noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty @@ -2859,7 +2173,15 @@ \pgfplotsdeclarecoordmath{pgfbasic}{% - parsenumber=\pgfmathfloatparsenumber{#1}\pgfmathfloattofixed\pgfmathresult, + parsenumber={% + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmathfloatgetflagstomacro\expandafter{\pgfmathresult}\pgfplotsretval + \ifnum\pgfplotsretval>2 + \let\pgfmathresult=\pgfutil@empty + \else + \pgfmathfloattofixed\pgfmathresult + \fi + }, suffix=@basic@, zero=\def\pgfmathresult{0}, one=\def\pgfmathresult{1}, @@ -3998,7 +3320,10 @@ \noexpand\pgfkeyssetvalue{/pgfplots/y coord sorting}{\pgfkeysvalueof{/pgfplots/y coord sorting}}% % \noexpand\pgfplots@initzerolevelhandler - \noexpand\pgfplots@define@currentplotstyle@as{\the\t@pgfplots@toka}% remember 'current plot style' + % remember 'current plot style': + \noexpand\pgfplots@define@currentplotstyle@as{% + \the\t@pgfplots@toka + }% % per-point meta data ranges which apply only to % this plot: \noexpand\xdef\noexpand\pgfplots@metamin{\pgfplots@metamin}% @@ -4007,6 +3332,7 @@ \noexpand\def\noexpand\pgfplots@serialized@state@plothandler{\the\t@pgfplots@tokb}% \noexpand\def\noexpand\pgfplotsaxisfilteredcoordsaway{\pgfplotsaxisfilteredcoordsaway}% \noexpand\def\noexpand\pgfplotsaxisplothasjumps{\pgfplotsaxisplothasjumps}% + \noexpand\pgfkeyssetvalue{/pgfplots/on layer}{\pgfkeysvalueof{/pgfplots/on layer}}% }% {% draw command: \noexpand\path% @@ -4471,7 +3797,7 @@ \fi \fi \begingroup - % no, assemble the macro which will invoke + % now, assemble the macro which will invoke % \pgfplots@streamerrorbarcoords: \let\E=\noexpand \expandafter\xdef\csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname{% @@ -4545,21 +3871,25 @@ \ifx\pgfplots@error@coord\pgfutil@empty \else \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% - \def\pgfplots@loc@TMPb{add}% - \else - \def\pgfplots@loc@TMPb{subtract}% - \fi - \pgfplotscoordmath{#1}{op}{\pgfplots@loc@TMPb}{% - {\csname pgfplots@current@point@#1\endcsname}% - {\pgfplots@error@coord}% + \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{% + \let\pgfplots@error@coord=\pgfmathresult + % remember result here - will be used in case + % of '+' AND '-' error bars: + \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult + \if +##1% + \def\pgfplots@loc@TMPb{add}% + \else + \def\pgfplots@loc@TMPb{subtract}% + \fi + \pgfplotscoordmath{#1}{op}{\pgfplots@loc@TMPb}{% + {\csname pgfplots@current@point@#1\endcsname}% + {\pgfplots@error@coord}% + }% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + }{% + % input is unbounded. Skip it. }% - \let\pgfplots@error@coord=\pgfmathresult - \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname \fi }% \or% explicit relative: @@ -4567,14 +3897,30 @@ \edef\pgfplots@error@coord{\csname pgfplots@current@point@#1@error\endcsname}% \ifx\pgfplots@error@coord\pgfutil@empty \else - \pgfmathparse{1##1\pgfplots@error@coord}% - \let\pgfplots@error@coord=\pgfmathresult - \pgfplotscoordmath{#1}{multiply}{% - {\csname pgfplots@current@point@#1\endcsname} - {\pgfplots@error@coord}% + \pgfplotscoordmath{#1}{parsenumber}{\pgfplots@error@coord}% + \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{% + \let\pgfplots@error@coord=\pgfmathresult + % compute ' 1 + value' or '1-value': + \pgfplotscoordmath{#1}{one}% + \if +##1% + \def\pgfplots@loc@TMPb{add}% + \else + \def\pgfplots@loc@TMPb{subtract}% + \fi + \pgfplotscoordmath{#1}{op}{\pgfplots@loc@TMPb}{% + {\pgfmathresult}% + {\pgfplots@error@coord}% + }% + \let\pgfplots@error@coord=\pgfmathresult + \pgfplotscoordmath{#1}{multiply}{% + {\csname pgfplots@current@point@#1\endcsname} + {\pgfplots@error@coord}% + }% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + }{% + % input is unbounded. Skip it. }% - \let\pgfplots@error@coord=\pgfmathresult - \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname \fi }% \fi @@ -4662,25 +4008,29 @@ \ifx\pgfplots@error@coord\pgfutil@empty \else \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 - \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@current@point@#1@unfiltered\endcsname}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \if +##1% - \def\pgfplots@loc@op{add}% - \else - \def\pgfplots@loc@op{subtract}% - \fi - \pgfplotscoordmath{default}{op}{\pgfplots@loc@op}{% - {\pgfplots@loc@TMPa}% - {\pgfplots@error@coord}% + \pgfplotscoordmath{default}{if is bounded}{\pgfmathresult}{% + \let\pgfplots@error@coord=\pgfmathresult + % remember result here - will be used in case + % of '+' AND '-' error bars: + \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult + \pgfplotscoordmath{default}{parsenumber}{\csname pgfplots@current@point@#1@unfiltered\endcsname}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \if +##1% + \def\pgfplots@loc@op{add}% + \else + \def\pgfplots@loc@op{subtract}% + \fi + \pgfplotscoordmath{default}{op}{\pgfplots@loc@op}{% + {\pgfplots@loc@TMPa}% + {\pgfplots@error@coord}% + }% + \pgfplotscoordmath{default}{tostring}{\pgfmathresult}% + \pgfplotscoordmath{#1}{log}{\pgfmathresult}% + \let\pgfplots@error@coord=\pgfmathresult + \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + }{% + % input is unbounded. Skip it. }% - \pgfplotscoordmath{default}{tostring}{\pgfmathresult}% - \pgfplotscoordmath{#1}{log}{\pgfmathresult}% - \let\pgfplots@error@coord=\pgfmathresult - \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname \fi }% % @@ -4691,34 +4041,38 @@ \ifx\pgfplots@error@coord\pgfutil@empty \else \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 - % - \pgfplotscoordmath{default}{one}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \if +##1% - \def\pgfplots@loc@op{add}% - \else - \def\pgfplots@loc@op{subtract}% - \fi - \pgfplotscoordmath{default}{op}{\pgfplots@loc@op}{% - {\pgfplots@loc@TMPa}% - {\pgfplots@error@coord}% - }% - \pgfplotscoordmath{default}{tostring}{\pgfmathresult}% - \pgfplotscoordmath{#1}{log}{\pgfmathresult}% - \let\pgfplots@error@coord=\pgfmathresult - \pgfplotscoordmath{#1}{if is bounded}{\pgfmathresult}{% - \pgfplotscoordmath{#1}{op}{add}{% - {\csname pgfplots@current@point@#1\endcsname} + \pgfplotscoordmath{default}{if is bounded}{\pgfmathresult}{% + \let\pgfplots@error@coord=\pgfmathresult + % remember result here - will be used in case + % of '+' AND '-' error bars: + \expandafter\let\csname pgfplots@current@point@#1@error\endcsname=\pgfmathresult + % + \pgfplotscoordmath{default}{one}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \if +##1% + \def\pgfplots@loc@op{add}% + \else + \def\pgfplots@loc@op{subtract}% + \fi + \pgfplotscoordmath{default}{op}{\pgfplots@loc@op}{% + {\pgfplots@loc@TMPa}% {\pgfplots@error@coord}% }% + \pgfplotscoordmath{default}{tostring}{\pgfmathresult}% + \pgfplotscoordmath{#1}{log}{\pgfmathresult}% \let\pgfplots@error@coord=\pgfmathresult - \csname pgfplots@PREPARE@errorbar@stream@it@#1\endcsname + \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 + }{% + % -> log( <= 0 ) -> do nothing. + }% }{% - % -> log( <= 0 ) -> do nothing. + % input is unbounded - do nothing. }% \fi }% @@ -4838,7 +4192,7 @@ % 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}% + \edef\pgfplotspointmetarange{\csname #1metamin\endcsname:\csname #1metamax\endcsname}% % Now, prepare the trafo as such. % It assigns \pgfmathresult (in fixed point). \def\pgfplots@perpointmeta@trafo##1{% @@ -4848,12 +4202,16 @@ }{% \pgfplotscoordmath{meta}{op}{subtract}{{##1}{\csname #1metamin\endcsname}}% \pgfplotscoordmath{meta}{op}{multiply}{{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}}% + \pgfplots@perpointmeta@trafo@clipresult \pgfplotscoordmath{meta}{tofixed}{\pgfmathresult}% }% }% \pgfplotscoordmath{meta}{op}{subtract}{{\csname #1metamax\endcsname}{\csname #1metamin\endcsname}}% \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{meta}{zero}% + \let\pgfplots@perpointmeta@lowerrange=\pgfmathresult \pgfplotscoordmath{meta}{parsenumber}{1000}% + \let\pgfplots@perpointmeta@upperrange=\pgfmathresult \pgfplotscoordmath{meta}{op}{divide}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% \let\pgfplots@perpointmeta@trafo@factor=\pgfmathresult % @@ -4867,6 +4225,24 @@ \edef\pgfplotspointmetarangeexponent{\the\c@pgf@countd}% } +\def\pgfplots@perpointmeta@trafo@clipresult{% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{meta}{if less than}{\pgfplots@loc@TMPa}{\pgfplots@perpointmeta@upperrange}{% + \pgfplotscoordmath{meta}{if less than}{\pgfplots@loc@TMPa}{\pgfplots@perpointmeta@lowerrange}{% + \let\pgfmathresult=\pgfplots@perpointmeta@lowerrange + }{% + \let\pgfmathresult=\pgfplots@loc@TMPa + }% + }{% + \let\pgfmathresult=\pgfplots@perpointmeta@upperrange + }% +}% + +% define it globally - this simplifies some mesh plots. +\pgfplotscoordmath{meta}{one}% +\let\pgfplotspointmeta=\pgfmathresult +\def\pgfplotspointmetatransformed{1000}% use the maximum because it is usually divided by 1000 + % A command which is readily available during the visualization phase of each plot. % % It takes existing point meta data and transforms it, i.e. it defines @@ -6548,6 +5924,11 @@ \ifpgfplots@curplot@threedim \pgfplots@addplotimpl@table@check@createonuse@for{z}% \fi + \pgfplots@addplotimpl@table@check@createonuse@for{x error}% + \pgfplots@addplotimpl@table@check@createonuse@for{y error}% + \ifpgfplots@curplot@threedim + \pgfplots@addplotimpl@table@check@createonuse@for{z error}% + \fi \pgfplots@addplotimpl@table@check@createonuse@for{meta}% \fi % @@ -7094,14 +6475,6 @@ \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}% % % - \ifpgfplots@clip@limits - \else - % "clip marker paths=true" actually doesn't checks anything -- - % it leaves the checks to the clip path. But since there is no - % clip path, it is adequate to use it here: - \pgfplots@clip@marker@pathstrue - \fi - % \pgfplots@perpointmeta@preparetrafo % \pgfplots@prepare@visualization@dependencies @@ -7120,22 +6493,29 @@ \pgfplots@record@marker@streamfalse \else % we need markers. - \ifx\pgfplots@basiclevel@plothandler\pgfplothandlerdiscard - \ifpgfplots@clip@marker@paths - % only marks: draw markers directly; no need for the - % two-pass-approach. - \let\pgfplots@basiclevel@plothandler=\relax - \pgfplots@install@plotmark@handler - \pgfplots@record@marker@streamfalse + \pgfkeysgetvalue{/pgfplots/mark layer}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % no special mark layer. Good! + \ifx\pgfplots@basiclevel@plothandler\pgfplothandlerdiscard + \ifpgfplots@clip@marker@paths + % only marks: draw markers directly; no need for the + % two-pass-approach. + \let\pgfplots@basiclevel@plothandler=\relax + \pgfplots@install@plotmark@handler + \pgfplots@record@marker@streamfalse + \else + % collect mark positions... they will be drawn after + % the clipped axis range. Clipping will only be + % applied to their *positions*, not their paths. + \pgfplots@record@marker@streamtrue + \fi \else - % collect mark positions... they will be drawn after - % the clipped axis range. Clipping will only be - % applied to their *positions*, not their paths. + % ok, mark!=none and we also have a plot handler. + % So, collect mark positions! \pgfplots@record@marker@streamtrue \fi \else - % ok, mark!=none and we also have a plot handler. - % So, collect mark positions! + % we need to prepare for a separate mark layer: \pgfplots@record@marker@streamtrue \fi \fi @@ -7234,8 +6614,17 @@ } % Takes the current point (defined by a set of macros) as input and defines \pgf@x and \pgf@y -% as the output point. +% as the output point. It also defines +% \pgfplots@current@point@x and its variants to contain the +% transformed canvas coords (those which can be given to +% \pgfplotsqpointxyz). +% +% Furthermore, it defines keys '/data point/x untransformed' to +% contain the untransformed coords. \def\pgfplotsaxisvisphasegetpoint{% + \pgfkeyslet{/data point/x untransformed}\pgfplots@current@point@x + \pgfkeyslet{/data point/y untransformed}\pgfplots@current@point@y + \pgfkeyslet{/data point/z untransformed}\pgfplots@current@point@z \pgfplotsaxisvisphasetransformcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z% \pgfplotsaxisvisphasepreparedatapoint \ifpgfplots@curplot@threedim @@ -7615,6 +7004,15 @@ \def\pgfplots@coord@stream@finalize@storedcoords@START@coords{#1}% \fi \pgfplots@assert@tikzinternal@exists{tikz@make@last@position}% + % + \ifpgfplots@clip + \else + % "clip marker paths=true" actually doesn't checks anything -- + % it leaves the checks to the clip path. But since there is no + % clip path, it is adequate to use it here: + \pgfplots@clip@marker@pathstrue + \fi + % \pgfplots@stored@current@cmd%[current plot style] <--- options are already set \pgfextra \tikzset{every plot/.try}% @@ -7633,19 +7031,30 @@ % \ifx\pgfplots@recorded@marker@stream\pgfutil@empty \else - \ifpgfplots@clip@marker@paths - % Draw markers on top of the plot lines: - % - \pgfplots@stored@current@cmd%[current plot style] <--- options are already set - \pgfextra - \pgfplots@install@plotmark@handler - \pgfplots@recorded@marker@stream - \endpgfextra - ; + \pgfkeysgetvalue{/pgfplots/mark layer}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \ifpgfplots@clip@marker@paths + % Draw markers on top of the plot lines: + % + \pgfplots@stored@current@cmd%[current plot style] <--- options are already set + \pgfextra + \pgfplots@install@plotmark@handler + \pgfplots@recorded@marker@stream + \endpgfextra + ; + \else + % sigh... ok, store the marker list (once more again). + % They need to be drawn after the clipped area. + % + % fortunately, the serialization is not expensive. + \pgfplots@stored@REMEMBER@MARK@COMMAND + \fi \else - % sigh... ok, store the marker list (once more again). - % They need to be drawn after the clipped area. - \pgfplots@stored@REMEMBER@MARK@COMMAND + % oh - we need a mark layer! + \pgfplotsonlayer{\pgfkeysvalueof{/pgfplots/mark layer}}{mark layer}% + \pgfplots@serialize@mark@command + \pgfplotsretval + \endpgfplotsonlayer \fi \fi \gdef\pgfplots@recorded@marker@stream{}% clear @@ -7658,6 +7067,33 @@ % - pgfplots@recorded@marker@stream exists % - current plot style is valid \def\pgfplots@stored@REMEMBER@MARK@COMMAND{% + \pgfplots@serialize@mark@command + \ifpgfplots@clip + \if2\pgfplots@clipmode + % clip mode=individual: + \global\let\pgfplots@stored@markerlist@last=\pgfplotsretval + \else + % clip mode=global + \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplotsretval}\to\pgfplots@stored@markerlist + \fi + \fi +}% + +\def\pgfplots@execute@at@begin@plot@visualization@internal{% + \global\let\pgfplots@stored@markerlist@last=\relax +}% + +\def\pgfplots@execute@at@end@plot@visualization@internal{% + \ifpgfplots@clip + \if2\pgfplots@clipmode + % clip=true and 'clip mode=individually' + \pgfplots@stored@markerlist@last + \global\let\pgfplots@stored@markerlist@last=\relax + \fi + \fi +}% + +\def\pgfplots@serialize@mark@command{% \pgfkeysgetvalue{/tikz/current plot style/.@cmd}{\pgfplots@loc@TMPa}% \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa\pgfeov}% \t@pgfplots@tokb=\expandafter{\pgfplots@stored@current@cmd[current plot style]}% @@ -7685,8 +7121,11 @@ }% \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}% - \expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@loc@TMPa}\to\pgfplots@stored@markerlist + \edef\pgfplotsretval{% + \noexpand\scope% make sure that 'fill opacity' and 'dotted' styles remain local! + \the\t@pgfplots@tokb + \the\t@pgfplots@toka + \noexpand\endscope}% }% \def\pgfplots@install@plotmark@handler{% @@ -7759,11 +7198,17 @@ \the\t@pgfplots@tokc }% \fi - \ifx\tikz@mark@list\pgfutil@empty% - \expandafter\pgfplothandlermark\expandafter{\pgfplots@loc@TMPa}% - \else - \expandafter\pgfplothandlermarklisted\expandafter{\pgfplots@loc@TMPa}{\tikz@mark@list}% - \fi + \def\pgfplots@loc@TMPb##1{% + \ifx\tikz@mark@list\pgfutil@empty% + \pgfplothandlermark{##1}% + \else + \pgfplothandlermarklisted{##1}{\tikz@mark@list}% + \fi + }% + \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}}% + \edef\pgfplots@basiclevel@plothandler{\the\t@pgfplots@tokc}% + % + \pgfplots@basiclevel@plothandler }% @@ -7980,7 +7425,7 @@ -% the low-level Tikz command which realizes 'plot graphics'. +% the low-level Tikz command which implements 'plot graphics'. % % It's current state is described by some pgfkeys options and two % coordinates. @@ -8324,11 +7769,21 @@ \fi % % + \if1\b@pgfplots@compat@plot@graphics@threedim + \pgfplots@warning{plot3 graphics is running in backwards compatibility mode. % + Use \string\pgfplotsset{compat=1.6} or higher to benefit from upgraded scaling capabilites.}% + \else + \fi + % \edef\pgfplotsretval{% x={(\pgfplots@xx,\pgfplots@xy)},% y={(\pgfplots@yx,\pgfplots@yy)},% z={(\pgfplots@zx,\pgfplots@zy)},% scale mode=scale uniformly,% + \if1\b@pgfplots@compat@plot@graphics@threedim + % this is the only strategy pre 1.6 + scale uniformly strategy=change vertical limits,% + \fi }% % \if1\pgfplotsplothandlergraphicspointmapcomputerequiredview@debug @@ -8382,6 +7837,8 @@ \def\n{^^J}% \def\t{^^I}% \immediate\write\w@pgf@writea{canvasmapmatrix=[\pgfplotsmatrix@text];^^Jcanvasmaprhs = [\pgfplotsrhs@text];^^J}% + % + \immediate\write\w@pgf@writea{key configuration = \pgfplotsretval;^^J}% \immediate\closeout\w@pgf@writea \endgroup }% @@ -8860,6 +8317,7 @@ %\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}% + \pgfmath@smuggleone\pgfplotsplothandlermesh@zbuffer@choice \endgroup \else % mesh input=patches @@ -8973,19 +8431,20 @@ % '#1' is BEHIND #2 with respect to the current 3D view. \def\pgfplots@apply@zbuffer@SORT@iflessthan#1#2#3#4\pgfeov{% \pgfplotsaxisdeserializedatapointfrom{#1}% - \pgfplotsmathfloatviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% - \let\pgfplots@apply@zbuffer@SORT@iflessthan@a=\pgfmathresult + \pgfplotsmathvectorfromstring{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}{default}% + \pgfplotsmathvectorscalarproduct{\pgfplots@view@dir@threedim}{\pgfplotsretval}{default}% + \let\pgfplots@apply@zbuffer@SORT@iflessthan@a=\pgfplotsretval % \pgfplotsaxisdeserializedatapointfrom{#2}% - \pgfplotsmathfloatviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% - \let\pgfplots@apply@zbuffer@SORT@iflessthan@b=\pgfmathresult + \pgfplotsmathvectorfromstring{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}{default}% + \pgfplotsmathvectorscalarproduct{\pgfplots@view@dir@threedim}{\pgfplotsretval}{default}% + \let\pgfplots@apply@zbuffer@SORT@iflessthan@b=\pgfplotsretval % - \pgfmathfloatlessthan@{\pgfplots@apply@zbuffer@SORT@iflessthan@b}{\pgfplots@apply@zbuffer@SORT@iflessthan@a}% - \ifpgfmathfloatcomparison + \pgfplotscoordmath{default}{if less than}{\pgfplots@apply@zbuffer@SORT@iflessthan@b}{\pgfplots@apply@zbuffer@SORT@iflessthan@a}{% #3\relax - \else + }{% #4\relax - \fi + }% }% @@ -8997,53 +8456,51 @@ % The arguments need to be numbers (will be parsed with % \pgfmathfloatparsenumber). % @see \pgfplotsmathviewdepthxyz +% DEPRECATED use \pgfplotsmathvectorviewdepth instead! \def\pgfplotsmathfloatviewdepthxyz#1#2#3{% + \begingroup \pgfmathfloatparsenumber{#1}\let\pgfplots@loc@TMPa=\pgfmathresult \pgfmathfloatparsenumber{#2}\let\pgfplots@loc@TMPb=\pgfmathresult \pgfmathfloatparsenumber{#3}\let\pgfplots@loc@TMPc=\pgfmathresult \edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}}% \expandafter\pgfplotsmathfloatviewdepthxyz@\pgfplots@loc@TMPa + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% #1: a 3d vector of the form x,y,z in 'default' coordmath format +% defines \pgfplotsretval to the view depth +% of the point +% +% Use \pgfplotsmathvectorfromstring{x,y,z}{default} to transform a +% vector into the requested format. +% +% Use \pgfplotscoordmath{default}{tofixed}{\pgfplotsretval} to +% transform the result into fixed point representation. +\def\pgfplotsmathvectorviewdepth#1{% + \pgfplotsmathvectorscalarproduct{#1}{\pgfplots@view@dir@threedim}{default}% }% \def\pgfplotsmathfloatviewdepthxyz@#1#2#3{% \pgfplots@error{Sorry, you can't use \string\pgfplotsmathfloatviewdepthxyz\space in this context.}% }% \def\pgfplotsmathfloatviewdepthxyz@infigure#1#2#3{% - \pgfmathfloatmultiplyfixed@{#1}{\pgfplots@view@dir@threedim@x}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \pgfmathfloatmultiplyfixed@{#2}{\pgfplots@view@dir@threedim@y}% - \let\pgfplots@loc@TMPb=\pgfmathresult - \pgfmathfloatadd@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% - \let\pgfplots@loc@TMPb=\pgfmathresult - \ifpgfplots@curplot@threedim - \pgfmathfloatmultiplyfixed@{#3}{\pgfplots@view@dir@threedim@z}% - \let\pgfplots@loc@TMPc=\pgfmathresult - \pgfmathfloatadd@{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}% - \let\pgfplots@loc@TMPb=\pgfmathresult - \fi - \let\pgfmathresult=\pgfplots@loc@TMPb + \pgfplotsmathvectorfromstring{\pgfplots@view@dir@threedim}{float}% + \pgfplotsmathvectorscalarproduct{#1,#2,#3}{\pgfplotsretval}{float}% FIXME : \pgfplots@view@dir@threedim might have a different math format! + \let\pgfmathresult=\pgfplotsretval }% % Similar to \pgfplotsmathfloatviewdepthxyz, but this always relies on % fixed point arithmetics. +% DEPRECATED use \pgfplotsmathvectorviewdepth instead \def\pgfplotsmathviewdepthxyz#1#2#3{\pgfplotsmathviewdepthxyz@{#1}{#2}{#3}} \def\pgfplotsmathviewdepthxyz@#1#2#3{% \pgfplots@error{Sorry, you can't use \string\pgfplotsmathviewdepthxyz\space in this context.}% } \def\pgfplotsmathviewdepthxyz@infigure#1#2#3{% - \pgfmath@basic@multiply@{#1}{\pgfplots@view@dir@threedim@x}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \pgfmath@basic@multiply@{#2}{\pgfplots@view@dir@threedim@y}% - \let\pgfplots@loc@TMPb=\pgfmathresult - \pgfmath@basic@add@{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}% - \let\pgfplots@loc@TMPb=\pgfmathresult - \ifpgfplots@curplot@threedim - \pgfmath@basic@multiply@{#3}{\pgfplots@view@dir@threedim@z}% - \let\pgfplots@loc@TMPc=\pgfmathresult - \pgfmath@basic@add@{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}% - \let\pgfplots@loc@TMPb=\pgfmathresult - \fi - \let\pgfmathresult=\pgfplots@loc@TMPb + \pgfplotsmathvectorfromstring{\pgfplots@view@dir@threedim@unitlength}{pgfbasic}% + \pgfplotsmathvectorscalarproduct{#1,#2,#3}{\pgfplotsretval}{pgfbasic}% FIXME : \pgfplots@view@dir@threedim might have a different math format! + \let\pgfmathresult=\pgfplotsretval }% |