summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-12-30 22:58:39 +0000
committerKarl Berry <karl@freefriends.org>2011-12-30 22:58:39 +0000
commit44ccd75065152cd73c512645bc4dc6d258fe62cb (patch)
tree39e9b861199f3172d9cff378a68f2c773248db87 /Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex
parentb3370daebbffee05312803e74c40f6d0abbf08c4 (diff)
pgfplots 1.5.1 (29dec11)
git-svn-id: svn://tug.org/texlive/trunk@24977 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex301
1 files changed, 287 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex
index 996dce22550..d230e0d1ed7 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex
@@ -2520,7 +2520,6 @@
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%
@@ -2853,6 +2852,12 @@
}%
}%
+% Assumes that #2 is a macro, parses it as number with "coord math choice" #1, and overwrites it with the result.
+\def\pgfplotscoordmathparsemacro#1#2{%
+ \pgfplotscoordmath{#1}{parsenumber}{#2}\let#2=\pgfmathresult
+}%
+
+
\pgfplotsdeclarecoordmath{pgfbasic}{%
parsenumber=\pgfmathfloatparsenumber{#1}\pgfmathfloattofixed\pgfmathresult,
suffix=@basic@,
@@ -5502,8 +5507,12 @@
\pgfkeysgetvalue{/pgfplots/samples y}\pgfplots@plot@samples@y
\fi
%
- \pgfkeyssetvalue{/pgfplots/mesh/rows}{\pgfkeysvalueof{/pgfplots/samples y}}%
- \pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/samples}}%
+ \iftikz@plot@raw@gnuplot
+ % FIXME : verify this case
+ \else
+ \pgfkeyssetvalue{/pgfplots/mesh/rows}{\pgfkeysvalueof{/pgfplots/samples y}}%
+ \pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/samples}}%
+ \fi
\if1\b@pgfplots@should@sample@LINE
\pgfkeyssetvalue{/pgfplots/sample dim}{1}%
\pgfkeyssetvalue{/pgfplots/mesh/cols}{1}%
@@ -6355,7 +6364,15 @@
% high level user interface functions:
\let\pgfplotstable@coordindex@old=\coordindex
\def\coordindex{\pgfplotstablerow}%
- \let\lineno=\coordindex% is the same here
+ \def\lineno{\coordindex}% is the same here
+ % These macros are-unfortunately- not accessable here. And the
+ % worst is: error messages are impossible either because they are
+ % not executed... try to provide useful hints:
+ \def\thisrow##1{thisrow_unavailable_load_table_directly}%
+ \def\thisrowno##1{thisrowno_unavailable_load_table_directly}%
+ % this should work.
+ \def\getthisrow##1##2{\pgfplotstablegetelem{\coordindex}{##1}\of{#3}{##2}}%
+ \def\getthisrowno##1##2{\pgfplotstablegetelem{\coordindex}{[index]##1}\of{#3}{##2}}%
%
\expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@plot@tbl@x}\of#3\to\addplot@tbl@x
\expandafter\pgfplotstablegetcolumnbyname\expandafter{\pgfplots@plot@tbl@y}\of#3\to\addplot@tbl@y
@@ -7185,11 +7202,6 @@
%
% It is prepared here to eliminate if's.
\xdef\pgfplots@coord@stream@finalize@currentpt{%
- \ifpgfplots@curplot@threedim
- \E\pgfplotsqpointxyz{\E\pgfplots@current@point@x}{\E\pgfplots@current@point@y}{\E\pgfplots@current@point@z}%
- \else
- \E\pgfplotsqpointxy{\E\pgfplots@current@point@x}{\E\pgfplots@current@point@y}%
- \fi
%
\ifpgfplots@record@marker@stream
% remember the position (x,y) for markers.
@@ -7215,13 +7227,24 @@
\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
+ \pgfplotsaxisvisphasegetpoint
\pgfplots@coord@stream@finalize@currentpt
\fi
}%
}
+% Takes the current point (defined by a set of macros) as input and defines \pgf@x and \pgf@y
+% as the output point.
+\def\pgfplotsaxisvisphasegetpoint{%
+ \pgfplotsaxisvisphasetransformcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z%
+ \pgfplotsaxisvisphasepreparedatapoint
+ \ifpgfplots@curplot@threedim
+ \pgfplotsqpointxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}%
+ \else
+ \pgfplotsqpointxy{\pgfplots@current@point@x}{\pgfplots@current@point@y}%
+ \fi
+}%
+
\def\pgfplots@check@for@default@plot@mark{%
% make sure there is a mark set!
\pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}%
@@ -7335,6 +7358,250 @@
\fi
}%
+% This is the pgfplots implementation for 'node[pos=<fraction>]'.
+% Besides modifications of the transformation matrix, it also defines the COORDINATES of the point to
+% /data point/x
+% /data point/y
+% /data point/z
+% (or more keys which depend on the plot handler).
+\def\pgfplots@plot@timer{%
+ \pgfplotstransformplotattime{\tikz@time}%
+}
+
+% Installs a transformation matrix such that (0,0) is the point of the
+% current plot with fraction #1.
+%
+% This does actually nothing more than using
+% \pgfplotspointplotattime{#1} as shift and using the slope of the
+% curve at that point to set up the 'sloped' rotation (if enabled).
+\def\pgfplotstransformplotattime#1{%
+ \pgftransformshift{\pgfplotspointplotattime{#1}}%
+ \ifpgfresetnontranslationattime%
+ \pgftransformresetnontranslations%
+ \fi%
+ \ifpgfslopedattime%
+ \pgfplotsplothandlertransformslopedattime{#1}{\pgfplotspointplotattimefirst}{\pgfplotspointplotattimesecond}%
+ \fi%
+}
+
+\def\pgfplotspointplotattimeclearcache{%
+ \global\let\pgfplotspointplotattime@cache=\pgfutil@empty
+ \gdef\pgfplotspointplotattime@cachesize{0}%
+}%
+\pgfplotspointplotattimeclearcache
+\def\pgfplotspointplotattime@cachesize@max{20}
+
+% Checks if the cache for \pgfplotspointplotattime has a cached entry for '#1'.
+% POSTCONDITION:
+% if \ifpgfplots@loc@tmp is true, the value(s) from the cache have been retrieved successfully.
+% if \ifpgfplots@loc@tmp is false, there is not hit.
+\def\pgfplotspointplotattimegetfromcache#1{%
+ \pgf@xa=#1pt %
+ \pgfplotspointplotattime@cache
+ \pgfkeysifdefined{/data point/@pos \the\pgf@xa/segment \pgfkeysvalueof{/tikz/pos segment}}{%
+ \pgfkeysvalueof{/data point/@pos \the\pgf@xa/segment \pgfkeysvalueof{/tikz/pos segment}}%
+ \pgfplots@loc@tmptrue
+ }{%
+ \pgfplots@loc@tmpfalse
+ }%
+}%
+\def\pgfplotspointplotattimeaddtocache#1{%
+ \pgfplotsutil@advancestringcounter@global\pgfplotspointplotattime@cachesize
+ \ifnum\pgfplotspointplotattime@cachesize=\pgfplotspointplotattime@cachesize@max
+ \pgfplotspointplotattimeclearcache
+ \fi
+ \pgf@xa=#1pt %
+ \edef\pgfplots@loc@TMPa{%
+ \noexpand\gdef\noexpand\pgfplotspointplotattimefirst{\pgfplotspointplotattimefirst}%
+ \noexpand\gdef\noexpand\pgfplotspointplotattimesecond{\pgfplotspointplotattimesecond}%
+ \noexpand\gdef\noexpand\pgfplotspointplotattimecoords{\pgfplotspointplotattimecoords}%
+ }%
+ \t@pgfplots@toka=\expandafter{\pgfplotspointplotattime@cache}%
+ \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}%
+ \xdef\pgfplotspointplotattime@cache{%
+ \the\t@pgfplots@toka
+ \noexpand\pgfkeyssetvalue{/data point/@pos \the\pgf@xa/segment \pgfkeysvalueof{/tikz/pos segment}}{\the\t@pgfplots@tokb}%
+ }%
+}
+
+% Sets (\pgf@x,\pgf@y) to the point of the current plot with fraction #1.
+% For #1 = 0, this is the first point.
+% For #1 = 1, this is the last point.
+% For #1 = 0.5, it is the middle of the plot.
+% The argument '#1' is optional: if you leave it away, the current value of the 'pos' key will be used.
+% This method will work for most plot handlers, although some of them might be unsupported.
+%
+% As a side-effect, it defines the (global) macros
+% - \pgfplotspointplotattimefirst the start coordinate of the line segment containing #1
+% - \pgfplotspointplotattimesecond the end coordinate of the line segment containing #1
+% - \pgfplotspointplotattimecoords the coordinates of #1
+% The first two are interesting in order to allow the computation of gradients.
+% \pgfplotsplothandlerpointtokeys{/data point}%
+% for the \pgfplotspointplotattimecoords point
+%
+% Any of these macros can be decoded using
+% \pgfplotsplothandlerdeserializepointfrom\pgfplotspointplotattimesecond
+% \pgfplotsaxisvisphasegetpoint
+%
+% @see \pgfplotsplothandlerpointtokeys
+\def\pgfplotspointplotattime{%
+ \pgfutil@ifnextchar\bgroup{\pgfplotspointplotattime@}{\pgfplotspointplotattime@{\tikz@time}}%
+}
+\def\pgfplotspointplotattime@#1{%
+ \edef\pgfplots@loc@TMPa{#1}%
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \pgfplots@error{Sorry, the provided fraction of the plot is empty (maybe the argument of 'pos' has been cleared by the tikz node processing). Please provide a valid 'pos' argument}%
+ \else
+ \pgfplotspointplotattimegetfromcache{#1}%
+ \ifpgfplots@loc@tmp
+ % CACHE HIT!
+%\message{CACHE HIT for \string\pgfplotspointplotattime{#1}^^J}%
+ \else
+%\message{NO cache hit for \string\pgfplotspointplotattime{#1}^^J}%
+ \begingroup
+ %
+ \pgfkeysgetvalue{/tikz/pos segment}\pgfplots@pos@segment
+ %
+ % 1. compute the total length of the plot (by integrating along a linear spline)
+ %
+ \def\pgfplots@coord@stream@start@{%
+ \ifx\pgfplots@pos@segment\pgfutil@empty
+ \let\c@pgfplots@segments=\pgfutil@empty
+ \else
+ \def\c@pgfplots@segments{0}%
+ \c@pgf@countd=\pgfplots@pos@segment\relax
+ \edef\pgfplots@pos@segment{\the\c@pgf@countd}%
+ \fi
+ \pgfplotscoordmath{default}{zero}%
+ \let\pgfplots@len@total=\pgfmathresult
+ \let\pgfplots@last@processed=\pgfutil@empty
+ \def\pgfplots@last@was@empty{1}%
+ }%
+ \def\pgfplotspointattime@do{}%
+ \def\pgfplots@coord@stream@coord@{%
+%\message{plot at time (#1, segment \pgfplots@pos@segment): processing (\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z)^^J}%
+ \ifx\pgfplots@current@point@x\pgfutil@empty
+ \if1\pgfplots@last@was@empty
+ \else
+ % oh. a jump... start new length segment
+ \ifx\c@pgfplots@segments\pgfutil@empty
+ \else
+ \ifx\pgfplots@pos@segment\c@pgfplots@segments
+ \let\pgfplots@coord@stream@coord@=\relax
+ \fi
+ \pgfplotsutil@advancestringcounter\c@pgfplots@segments
+ \fi
+ \fi
+ \let\pgfplots@last@processed=\pgfutil@empty
+ \def\pgfplots@last@was@empty{1}%
+ \else
+ \ifx\pgfplots@pos@segment\c@pgfplots@segments
+ \ifx\pgfplots@last@processed\pgfutil@empty
+ \else
+ \pgfplotsplothandlerserializepointto{\pgfplots@cur}%
+ \pgfplotsplothandlersurveydifflen{\pgfplots@last@processed}{\pgfplots@cur}%
+ \pgfplotscoordmath{default}{op}{add}{{\pgfmathresult}{\pgfplots@len@total}}%
+ \let\pgfplots@len@total=\pgfmathresult
+%\message{plot at time (#1, segment \pgfplots@pos@segment): length \pgfplots@len@total^^J}%
+ \pgfplotspointattime@do
+ \fi
+ %
+ \pgfplotsplothandlerserializepointto{\pgfplots@last@processed}%
+ \fi
+ \def\pgfplots@last@was@empty{0}%
+ \fi
+ }%
+ \def\pgfplots@coord@stream@end@{}%
+ \let\pgfplots@coord@stream@coord@orig=\pgfplots@coord@stream@coord@
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@plot@timer@args}%
+ %
+ % Now, we have the total length. Now, try to find time #1!
+ \edef\pgfplots@time{#1}%
+ \pgfplotscoordmathparsemacro{default}{\pgfplots@time}%
+ %
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@time}{\pgfplots@len@total}}%
+ \let\pgfplots@len@thresh=\pgfmathresult
+ %
+ \pgfplotscoordmath{default}{zero}%
+ \let\pgfplots@len@last=\pgfmathresult
+ \let\pgfplots@len@last@last=\pgfplots@len@last
+%\message{plot at time (#1, segment \pgfplots@pos@segment): total length=\pgfplots@len@total; target len \pgfplots@len@thresh\space (#1)^^J}%
+ %
+ \def\pgfplots@HIT{0}%
+ \let\pgfplots@last@last=\pgfutil@empty
+ \let\pgfplots@coord@stream@coord@=\pgfplots@coord@stream@coord@orig
+ \def\pgfplotspointattime@do{%
+ \pgfplotscoordmath{default}{if less than}
+ {\pgfplots@len@thresh}
+ {\pgfplots@len@total}
+ {% HIT!
+ \def\pgfplots@HIT{1}%
+ \pgfplotspointattime@pointbetween@two
+ \let\pgfplots@coord@stream@coord@=\relax
+ }{%
+ }%
+ \let\pgfplots@len@last@last=\pgfplots@len@last
+ \let\pgfplots@len@last=\pgfplots@len@total
+ \let\pgfplots@last@last=\pgfplots@last@processed
+ \pgfplotsplothandlerserializepointto{\pgfplots@cur}%
+ }%
+ \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@plot@timer@args}%
+ \if\pgfplots@HIT0%
+ \let\pgfplots@last@processed=\pgfplots@last@last
+ \let\pgfplots@len@last=\pgfplots@len@last@last
+ \pgfplotspointattime@pointbetween@two
+ \fi
+ \endgroup
+ \pgfplotspointplotattimeaddtocache{#1}%
+ \fi
+ \pgfplotsplothandlerdeserializepointfrom\pgfplotspointplotattimecoords
+ \pgfplotscoordmath{x}{tofixed}{\pgfplots@current@point@x}%
+ \pgfplots@coord@inv@trafo@apply{x}{\pgfmathresult}%
+ \let\pgfplots@current@point@x=\pgfmathresult
+ \pgfplotscoordmath{y}{tofixed}{\pgfplots@current@point@y}%
+ \pgfplots@coord@inv@trafo@apply{y}{\pgfmathresult}%
+ \let\pgfplots@current@point@y=\pgfmathresult
+ \ifpgfplots@curplot@threedim
+ \pgfplotscoordmath{z}{tofixed}{\pgfplots@current@point@z}%
+ \pgfplots@coord@inv@trafo@apply{z}{\pgfmathresult}%
+ \let\pgfplots@current@point@z=\pgfmathresult
+ \fi
+ \pgfplotsplothandlerpointtokeys{/data point}%
+ \fi
+}
+\def\pgfplotspointattime@pointbetween@two{%
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@len@thresh}{\pgfplots@len@last}}%
+ \let\pgfplots@tmp=\pgfmathresult
+ \pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@len@total}{\pgfplots@len@last}}%
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfplots@tmp}{\pgfmathresult}}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfmathresult}%
+ \let\pgfplots@time@between@two=\pgfmathresult
+%\message{HIT between \pgfplots@len@last\space and \pgfplots@len@total\space (\pgfplots@time@between@two)^^J}%
+ \ifx\pgfplots@last@processed\pgfutil@empty
+ \pgfplotsplothandlerserializepointto{\pgfplots@cur}%
+ \else
+ \pgfplotsplothandlersurveypointattime{\pgfplots@time@between@two}{\pgfplots@last@processed}{\pgfplots@cur}%
+ \fi
+ \pgfplotsplothandlerserializepointto\pgfplots@loc@TMPa
+ \global\let\pgfplotspointplotattimecoords=\pgfplots@loc@TMPa
+ \pgfplotsaxisvisphasegetpoint
+ \global\let\pgfplotspointplotattimefirst=\pgfplots@last@processed
+ \global\let\pgfplotspointplotattimesecond=\pgfplots@cur
+}%
+
+
+% #1 : either x,y, or z
+% #2 : the argument on which the inv trafo shall be applied. It has to
+% be a fixed point number.
+\def\pgfplots@coord@inv@trafo@apply#1#2{%
+ \edef\pgfmathresult{#2}%
+ \pgfkeysgetvalue{/pgfplots/#1 coord inv trafo/.@cmd}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key
+ \else
+ \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov
+ \fi
+}%
+
% INPUT:
% either floating point or fixed point coordinates (depending on the
% state of the \ifpgfplots@apply@datatrafo boolean)
@@ -7356,8 +7623,14 @@
\pgfutil@ifundefined{pgfplotlastpoint}{}{%
\tikz@make@last@position{\pgfplotlastpoint}%
}%
+ \let\pgfplots@plot@timer@args=\pgfplots@coord@stream@finalize@storedcoords@START@coords
+ \pgfplotspointplotattimeclearcache
+ \let\tikz@timer=\pgfplots@plot@timer%
\endpgfextra
#2;
+ %
+ \pgfplotspointplotattimeclearcache
+ %
\ifx\pgfplots@recorded@marker@stream\pgfutil@empty
\else
\ifpgfplots@clip@marker@paths
@@ -7648,7 +7921,7 @@
\if\pgfplots@log@origin@choice@x0%
\global\let\pgfplots@logical@ZERO@x=\pgfplots@xmin%
\else
- \gdef\pgfplots@logical@ZERO@x{1}%
+ \gdef\pgfplots@logical@ZERO@x{0}%
\fi
\fi
%
@@ -7668,7 +7941,7 @@
\if\pgfplots@log@origin@choice@y0%
\global\let\pgfplots@logical@ZERO@y=\pgfplots@ymin%
\else
- \gdef\pgfplots@logical@ZERO@y{1}%
+ \gdef\pgfplots@logical@ZERO@y{0}%
\fi
\fi
%
@@ -7689,7 +7962,7 @@
\if\pgfplots@log@origin@choice@z0%
\global\let\pgfplots@logical@ZERO@z=\pgfplots@zmin%
\else
- \gdef\pgfplots@logical@ZERO@z{1}%
+ \gdef\pgfplots@logical@ZERO@z{0}%
\fi
\fi
\fi