diff options
author | Karl Berry <karl@freefriends.org> | 2015-01-31 21:37:06 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-01-31 21:37:06 +0000 |
commit | 84e0e95868a845e531157a1cb94f622da016e6a5 (patch) | |
tree | f880703d39c15193369f6e82eaa169755ae54e22 /Master/texmf-dist/tex/generic/pgfplots/libs | |
parent | 13673a964ccd149c582585f4df887a11457a430a (diff) |
pgfplots (31jan15)
git-svn-id: svn://tug.org/texlive/trunk@36178 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/libs')
4 files changed, 413 insertions, 179 deletions
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 4f414535eec..7ab01a3b03e 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.code.tex @@ -39,7 +39,7 @@ \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% + \pgfplotsiflibraryloaded{\pgf@temp}{}{% \expandafter\global\expandafter\let\csname pgfp@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} @@ -50,11 +50,45 @@ \input pgflibrarypgfplots.\pgf@temp.code.tex}% \catcode`\@=\csname tikz@library@#1@atcode\endcsname \catcode`\|=\csname tikz@library@#1@barcode\endcsname - \fi% + \expandafter\ifx\csname pgfp@library@#1@loadoptions\endcsname\relax + \else + \expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfp@library@\pgf@temp @loadoptions\endcsname + \expandafter\pgfplotsset\expandafter{\pgfplots@glob@TMPa}% + \fi + }% \fi }% } +\pgfkeys{ + % #1: library name + % #2: compatiblity presets which are controlled by the + % compatibility system but which belong to the library. + % + % FIXME : now as I wrote it, it might have been better to reverse + % the dependency... !? + /pgfplots/compat/library hook/.code 2 args={% + \pgfplotsiflibraryloaded{#1}{% + \pgfkeysalso{#2}% + }{% + \expandafter\ifx\csname pgfp@library@#1@loadoptions\endcsname\relax + \expandafter\def\csname pgfp@library@#1@loadoptions\endcsname{#2}% + \else + \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfp@library@#1@loadoptions\endcsname}% + \t@pgfplots@tokb={#2}% + \expandafter\edef\csname pgfp@library@#1@loadoptions\endcsname{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% + \fi + }% + }, +} + +\def\pgfplotsiflibraryloaded#1#2#3{% + \expandafter\ifx\csname pgfp@library@#1@loaded\endcsname\relax% + #3\relax + \else + #2\relax + \fi% +}% % Default loaded libraries: % Currently none diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex index 146153fca9b..55d8da81154 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 @@ -90,6 +90,39 @@ }% \def\pgfplotslibdateplot@discard@zero@dot 0.#1\to#2{\def#2{#1}}% +%-------------------------------------------------- +%This here extends it to SECONDS, but the precision is too low +% \def\pgfplotslibdateplot@map@time#1 #2:#3:#4\dateto#5\timeto#6{% +% \pgf@xa=#2pt +% \divide\pgf@xa by24 +% % +% \pgf@xb=#3pt +% \divide\pgf@xb by1440 +% \advance\pgf@xa by\pgf@xb +% % +% \def\pgfplots@loc@TMPc{#4}% +% \ifx\pgfplots@loc@TMPc\pgfutil@empty +% \else +% \edef\pgfplots@loc@TMPc{\pgfplotslibdateplot@discard@trailing@colon #4}% +% \pgf@xb=\pgfplots@loc@TMPc pt +% \divide\pgf@xb by1440 +% \divide\pgf@xb by60 +% \advance\pgf@xa by\pgf@xb +% \fi +% % +% \ifdim\pgf@xa<0pt +% \pgf@xa=0pt +% \else +% \ifdim\pgf@xa>1pt +% \pgf@xa=1pt +% \fi +% \fi +% \def#5{#1}% +% \edef#6{\pgf@sys@tonumber\pgf@xa}% +% }% +% \def\pgfplotslibdateplot@discard@trailing@colon#1:{#1}% +%-------------------------------------------------- + \pgfplotsset{ /pgfplots/date ZERO/.code={% \begingroup 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 index 2cf8ef5235d..6697ab0f4ad 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex @@ -72,6 +72,9 @@ } \def\pgfplots@polaraxis@activate{% + % FIXME : activating it results in strange output: + \pgfplots@LUA@backend@supportedfalse + % \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy \let\pgfplotsqpointxy=\pgfplotsqpointxy@polaraxis \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.statistics.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.statistics.code.tex index 8ccf4abf610..7fbf4f5ea44 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.statistics.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.statistics.code.tex @@ -19,24 +19,41 @@ % %-------------------------------------------- +\catcode`\;=12 +\catcode`\"=12 \newif\ifpgfplotsplothandlerboxplot@variable@width +\ifpgfplots@LUA@supported + \directlua{require("pgfplots.statistics")}% +\fi + +\newif\ifpgfplots@boxplot@ensure@plot@mark +\def\pgfplots@boxplot@ensure@plot@mark{% + \ifpgfplots@boxplot@ensure@plot@mark + \pgfplots@if@has@plot@marks{}{% + \tikzset{mark=*}% + }% + \fi +}% + \pgfplotsset{ boxplot/.code={% \def\tikz@plot@handler{\pgfplotsplothandlerboxplot}% - \pgfkeysalso{% + \pgfplotsset{% /pgfplots/every boxplot, - /pgfplots/boxplot/.cd, + /pgfplots/boxplot/.cd,% #1% }% + \pgfplots@boxplot@ensure@plot@mark }, boxplot prepared/.code={% \def\tikz@plot@handler{\pgfplotsplothandlerboxplotprepared}% - \pgfkeysalso{% + \pgfplotsset{% /pgfplots/every boxplot, - /pgfplots/boxplot/.cd, + /pgfplots/boxplot/.cd,% #1% }% + \pgfplots@boxplot@ensure@plot@mark }, boxplot/data value/.code =\pgfplots@set@source@for{boxplot/data}{#1}{0},% boxplot/data/.code =\pgfplots@set@source@for{boxplot/data}{#1}{1},% @@ -57,6 +74,53 @@ boxplot/upper whisker/.initial=auto, boxplot/average/.initial=, % + % mainly used for compatibility. + boxplot/ensure mark/.is if=pgfplots@boxplot@ensure@plot@mark, + % + boxplot/estimator/.is choice, + boxplot/estimator/legacy/.code={\def\pgfplots@boxplot@estimator{legacy}}, + % + boxplot/estimator/legacy*/.code={\def\pgfplots@boxplot@estimator{legacy*}}, + boxplot/estimator/R1/.code={\def\pgfplots@boxplot@estimator{R1}}, + boxplot/estimator/SAS3/.code={\def\pgfplots@boxplot@estimator{R1}}, + boxplot/estimator/Maple1/.code={\def\pgfplots@boxplot@estimator{R1}}, + % + boxplot/estimator/R2/.code={\def\pgfplots@boxplot@estimator{R2}}, + boxplot/estimator/SAS5/.code={\def\pgfplots@boxplot@estimator{R2}}, + boxplot/estimator/Maple2/.code={\def\pgfplots@boxplot@estimator{R2}}, + % + boxplot/estimator/R3/.code={\def\pgfplots@boxplot@estimator{R3}}, + boxplot/estimator/SAS2/.code={\def\pgfplots@boxplot@estimator{R3}}, + % + boxplot/estimator/R4/.code={\def\pgfplots@boxplot@estimator{R4}}, + boxplot/estimator/SAS1/.code={\def\pgfplots@boxplot@estimator{R4}}, + boxplot/estimator/SciPy0-1/.code={\def\pgfplots@boxplot@estimator{R4}}, + boxplot/estimator/Maple3/.code={\def\pgfplots@boxplot@estimator{R4}}, + % + boxplot/estimator/R5/.code={\def\pgfplots@boxplot@estimator{R5}}, + boxplot/estimator/SciPy12-12/.code={\def\pgfplots@boxplot@estimator{R5}}, + boxplot/estimator/Maple4/.code={\def\pgfplots@boxplot@estimator{R5}}, + % + boxplot/estimator/R6/.code={\def\pgfplots@boxplot@estimator{R6}}, + boxplot/estimator/SAS4/.code={\def\pgfplots@boxplot@estimator{R6}}, + boxplot/estimator/SciPy0-0/.code={\def\pgfplots@boxplot@estimator{R6}}, + boxplot/estimator/Maple5/.code={\def\pgfplots@boxplot@estimator{R6}}, + % + boxplot/estimator/R7/.code={\def\pgfplots@boxplot@estimator{R7}}, + boxplot/estimator/Excel/.code={\def\pgfplots@boxplot@estimator{R7}}, + boxplot/estimator/SciPy1-1/.code={\def\pgfplots@boxplot@estimator{R7}}, + boxplot/estimator/Maple6/.code={\def\pgfplots@boxplot@estimator{R7}}, + % + boxplot/estimator/R8/.code={\def\pgfplots@boxplot@estimator{R8}}, + boxplot/estimator/SciPy13-13/.code={\def\pgfplots@boxplot@estimator{R8}}, + boxplot/estimator/Maple7/.code={\def\pgfplots@boxplot@estimator{R8}}, + % + boxplot/estimator/R9/.code={\def\pgfplots@boxplot@estimator{R9}}, + boxplot/estimator/SciPy38-38/.code={\def\pgfplots@boxplot@estimator{R9}}, + boxplot/estimator/Maple8/.code={\def\pgfplots@boxplot@estimator{R9}}, + % + boxplot/estimator=legacy, + % boxplot/lower quartile off/.initial=0.25, boxplot/upper quartile off/.initial=0.75, boxplot/whisker range/.initial=1.5, @@ -188,6 +252,19 @@ \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@boxplot \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@boxplot \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@boxplot + \def\pgfplotsplothandlerLUAfactory{% + function(axis, pointmetainputhandler) + return pgfplots.BoxPlotPlothandler.new( + pgfplots.BoxPlotRequest.new( + "\pgfkeysvalueof{/pgfplots/boxplot/lower quartile off}", + "\pgfkeysvalueof{/pgfplots/boxplot/upper quartile off}", + "\pgfkeysvalueof{/pgfplots/boxplot/whisker range}", + pgfplots.getPercentileEstimator("\pgfplots@boxplot@estimator")), + "\pgfkeysvalueof{/pgfplots/boxplot/draw direction}", + "\pgfkeysvalueof{/pgfplots/boxplot/draw position}", + axis, pointmetainputhandler) + end + }% } @@ -202,18 +279,7 @@ % \def\b@pgfplotsplothandlerboxplot@issorted{1}% % - % FIXME : the decision to store the input points into a SINGLY - % LINKED LIST is based on the observation that huge TeX arrays - % (with one macro per index) run into out-of-memory easily. - % The list does not: it does not need that many macros and uses a - % different memory limit... - % - % However, the linked-list is bought off for a high price... the - % statistics computation takes linear time instead of constant. - % But we have linear time anyway, so it does not destroy the - % asymptotics... and it appears to be better to get it into main - % memory (?) - \pgfplotsapplistXnewempty\pgfp@boxplot@@ + \pgfplotsarraynewempty\pgfp@boxplot@@ \def\c@pgfplotsplothandlerboxplot@num{0}% \c@pgfplots@coordindex=0 }% @@ -221,11 +287,11 @@ \def\pgfplotsplothandlersurveyend@boxplot{% \pgfplots@curplot@threedimfalse % - \pgfplotsapplistXlet\pgfplots@boxplot@data=\pgfp@boxplot@@ - \pgfplotsapplistXnewempty\pgfp@boxplot@@ - % - \if0\b@pgfplotsplothandlerboxplot@issorted - \pgfplotsplothandlersurveyend@boxplot@sort + \ifpgfplots@LUA@backend@supported + \else + \if0\b@pgfplotsplothandlerboxplot@issorted + \pgfplotsplothandlersurveyend@boxplot@sort + \fi \fi % % @@ -246,9 +312,11 @@ % \pgfplotsplothandlersurveystart % - % this will report outliers as point stream: - \pgfplotsplothandlersurveyend@boxplot@computestats - \let\pgfplots@boxplot@data=\relax + \ifpgfplots@LUA@backend@supported + \else + % this will report outliers as point stream: + \pgfplotsplothandlersurveyend@boxplot@computestats + \fi % \let\pgfplotsplothandlerboxplotprepared@normalize@values=\pgfplotsplothandlerboxplotprepared@normalize@values@@ \pgfplotsplothandlerboxplotprepared@normalize@values @@ -258,40 +326,8 @@ }% \def\pgfplotsplothandlersurveyend@boxplot@sort{% - % how bad. we have to convert to array, sort, convert back to - % list... it would have been better if we had worked with arrays - % right away! But see the docs in front of the line - % '\pgfplotsapplistXnewempty\pgfp@boxplot@@' somewhere in this - % file... - % - \begingroup - \pgfplotsarraynewempty{P}% - \pgfplotsarrayresize{P}{\c@pgfplots@coordindex}% - % - \c@pgfplots@coordindex=0 - \let\pgfplotsplothandlersurveyend@boxplot@computestats@=\pgfplots@boxplot@fillarray - \expandafter\pgfplotsplothandlersurveyend@boxplot@computestats@loop\pgfplots@boxplot@data\pgfplots@EOI - % - \pgfkeysdef{/pgfplots/array/unscope pre}{% - \pgfplotsapplistXnewempty\pgfp@boxplot@@ - \pgfplotsarrayforeachungrouped{##1}\as\elem{% - \edef\elem{{\elem}}% - \expandafter\pgfplotsapplistXpushback\expandafter{\elem}\to\pgfp@boxplot@@ - }% - \pgfplotsapplistXlet\pgfplots@boxplot@data=\pgfp@boxplot@@ - \global\let\pgfplots@glob@boxplot@TMPd=\pgfplots@boxplot@data - }% - \pgfkeysdef{/pgfplots/array/unscope post}{% - }% - % - %\message{[}\pgfplotsarrayforeach{P}\as\elem{\message{\elem,}}\message{]^^J}% - % \pgfkeys{/pgfplots/float <}% - \pgfplotsarraysort{P}% - % - \endgroup - \let\pgfplots@boxplot@data=\pgfplots@glob@boxplot@TMPd - %\message{-> \meaning\pgfplots@boxplot@data^^J}% + \pgfplotsarraysort{\pgfp@boxplot@@}% }% \def\pgfplots@boxplot@fillarray{% @@ -301,47 +337,228 @@ %%%% -% -% OUTPUT: -% \pgfplotsretval: the result of #1 * #2 as integer -% \pgfplotsretvalb = 1 iff #1 * #2 is an integer (without loss) -\def\pgfplots@boxplot@get@quantile@offset#1#2{% - \pgfplotscoordmath{float}{parsenumber}{#2}% - \pgfplotscoordmath{float}{op}{multiply}{{\pgfmathresult}{#1}}% - \pgfplotscoordmath{float}{tofixed}{\pgfmathresult}% - \afterassignment\pgfplots@boxplot@get@quantile@remainder - \c@pgf@countd=\pgfmathresult\relax - \edef\pgfplotsretval{\the\c@pgf@countd}% +\def\pgfplotsplothandler@boxplot@init@percentile@estimator{% + \def\pgfplots@loc@TMPb{legacy}% + \ifx\pgfplots@loc@TMPb\pgfplots@boxplot@estimator + \let\pgfplotsplothandler@boxplot@percentile@estimator@=\pgfplotsplothandler@boxplot@percentile@estimator@legacy + \else + \def\pgfplots@loc@TMPb{legacy*}% + \ifx\pgfplots@loc@TMPb\pgfplots@boxplot@estimator + \let\pgfplotsplothandler@boxplot@percentile@estimator@=\pgfplotsplothandler@boxplot@percentile@estimator@legacy@bad + \else + % first, strip 'R' and store the integer number into \pgfplotsretval: + \def\pgfplots@loc@TMPb##1##2{% + \def\pgfplotsretval{##2}% + }% + \expandafter\pgfplots@loc@TMPb\pgfplots@boxplot@estimator + \ifcase\pgfplotsretval\relax + % 0: + \pgfplots@error{illegal argument 'estimator=\pgfplots@boxplot@estimator' encountered.}% + \or + % R1: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2}% + \let\h=\pgfmathresult + \pgfmathparse{ceil(\h)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}% + } + % FIXME : implement 'ceil' in the FPU! + \pgfplots@error{The argument 'estimator=\pgfplots@boxplot@estimator' is only available in conjunction with 'lua backend' and lualatex.}% + \or + % R2: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2 + 0.5}% + \let\h=\pgfmathresult + % + \pgfmathparse{ceil(\h-0.5)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + % + \pgfmathparse{floor(\h+0.5)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@high=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}% + \let\x@low=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{##2}% + \let\x@high=\pgfmathresult + \pgfmathparse{0.5*(\x@low + \x@high)}% + } + % FIXME : implement 'ceil' in the FPU! + \pgfplots@error{The argument 'estimator=\pgfplots@boxplot@estimator' is only available in conjunction with 'lua backend' and lualatex.}% + \or + % R3: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2}% + \let\h=\pgfmathresult + \pgfmathparse{round(\h)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{##2}% + } + \or + % R4: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R5: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*##2 + 0.5}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R6: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{##1*(##2+1)}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R7: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{(##2-1) * ##1 + 1}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R8: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{(##2 + 1/3) * ##1 + 1/3}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \or + % R9: + \def\pgfplotsplothandler@boxplot@percentile@estimator@##1##2{% + \pgfmathparse{(##2 + 1/4) * ##1 + 3/8}% + \let\h=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@std@lookup{##2}% + } + \else + \pgfplots@error{illegal argument 'estimator=\pgfplots@boxplot@estimator' encountered.}% + \fi + \fi + \fi }% -\def\pgfplots@boxplot@get@quantile@remainder#1\relax{% - \ifdim #1pt>0.001pt - \def\pgfplotsretvalb{0}% +% #1: the percentile in question (like 0.5 for the median) +% #2: the number of data points in the array \pgfp@boxplot@@ +% POSTCONDITION: \pgfmathresult contains the result. +\def\pgfplotsplothandler@boxplot@percentile@estimator#1#2{% + \begingroup + \pgfkeys{/pgf/fpu}% + \pgfplotsplothandler@boxplot@percentile@estimator@{#1}{#2}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + +% #1: the index +% #2: the number of data points in the array \pgfp@boxplot@@ +% +% POSTCONDITION: \pgfmathresult contains the result. +\def\pgfplotsplothandler@boxplot@percentile@estimator@getIndex#1#2{% + \c@pgf@countd=#1\relax + \advance\c@pgf@countd by-1 % we have 0-based indices + \ifnum\c@pgf@countd<0 \c@pgf@countd=0 \fi + \ifnum\c@pgf@countd<#2\relax \else \c@pgf@countd=#2\relax \advance\c@pgf@countd by-1 \fi + \pgfplotsarrayselect\c@pgf@countd\of\pgfp@boxplot@@\to\pgfmathresult +}% + +% #1: the index +% #2: the number of data points in the array \pgfp@boxplot@@ +% +% POSTCONDITION: \pgfmathresult contains the result. +\def\pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad#1#2{% + \c@pgf@countd=#1\relax + %\advance\c@pgf@countd by-1 % we have 0-based indices + \ifnum\c@pgf@countd<0 \c@pgf@countd=0 \fi + \ifnum\c@pgf@countd<#2\relax \else \c@pgf@countd=#2\relax \advance\c@pgf@countd by-1 \fi + \pgfplotsarrayselect\c@pgf@countd\of\pgfp@boxplot@@\to\pgfmathresult +}% + +\def\pgfplotsplothandler@boxplot@percentile@estimator@#1#2{% + \pgfplots@error{The estimator is uninitialized in this context. Call \string\pgfplotsplothandler@boxplot@init@percentile@estimator\space first.}% +} + +% computes x_low + (h - h_low) * (x_up - x_low) +% #1: the number of data points in the array \pgfp@boxplot@@ +\def\pgfplotsplothandler@boxplot@percentile@estimator@std@lookup#1{% + \pgfmathparse{floor(\h)}% + \let\h@low=\pgfmathresult + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + \c@pgf@countd=\offset@low\relax + \advance\c@pgf@countd by1 % + \edef\offset@high{\the\c@pgf@countd}% + % + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{#1}% + \let\x@low=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{#1}% + \let\x@high=\pgfmathresult + \pgfmathparse{\x@low + (\h - \h@low) * (\x@high - \x@low)}% +}% + +% implements 'estimator=legacy' +\def\pgfplotsplothandler@boxplot@percentile@estimator@legacy#1#2{% + \pgfmathparse{#1*#2}% + \let\h=\pgfmathresult + \pgfmathparse{floor(\h)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + % + \pgfmathparse{\h > \offset@low}% + \ifpgfmathfloatcomparison + \def\b@is@int{0}% \else - \def\pgfplotsretvalb{1}% + \def\b@is@int{1}% \fi -}% + % + \c@pgf@countd=\offset@low\relax + \advance\c@pgf@countd by1 % + \edef\offset@high{\the\c@pgf@countd}% + % + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@low}{#2}% + \if0\b@is@int + \let\temp=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex{\offset@high}{#2}% + \pgfmathparse{0.5*(\temp + \pgfmathresult)}% + \fi +} +\def\pgfplotsplothandler@boxplot@percentile@estimator@legacy@bad#1#2{% + \pgfmathparse{#1*(#2-1)}% + \let\h=\pgfmathresult + \pgfmathparse{floor(\h)}% + \pgfmathfloattoint\pgfmathresult + \let\offset@low=\pgfmathresult + % + \pgfmathparse{\h > \offset@low}% + \ifpgfmathfloatcomparison + \def\b@is@int{0}% + \else + \def\b@is@int{1}% + \fi + % + \c@pgf@countd=\offset@low\relax + \advance\c@pgf@countd by1 % + \edef\offset@high{\the\c@pgf@countd}% + % + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad{\offset@low}{#2}% + \if0\b@is@int + \let\temp=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator@getIndex@legacy@bad{\offset@high}{#2}% + \pgfmathparse{0.5*(\temp + \pgfmathresult)}% + \fi +} + \def\pgfplotsplothandlersurveyend@boxplot@computestats{ % - % compute TMPa := float(\numcoords - 1) - \pgfplotscoordmath{float}{one}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \pgfplotscoordmath{float}{parsenumber}{\numcoords}% - \let\pgfplots@boxplot@numcoords=\pgfmathresult - \pgfplotscoordmath{float}{op}{subtract}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% - \let\pgfplots@boxplot@numcoords@minus@one=\pgfmathresult - % - % compute the indices into the coordinate arrays: - \pgfplots@boxplot@get@quantile@offset{\pgfplots@boxplot@numcoords@minus@one}{\pgfplotsboxplotvalue{lower quartile off}}% - \let\c@pgfplotsplothandlerboxplot@lowerquartile=\pgfplotsretval - \let\b@pgfplotsplothandlerboxplot@lowerquartile@isint=\pgfplotsretvalb - \pgfplots@boxplot@get@quantile@offset{\pgfplots@boxplot@numcoords@minus@one}{0.5}% - \let\c@pgfplotsplothandlerboxplot@median=\pgfplotsretval - \let\b@pgfplotsplothandlerboxplot@median@isint=\pgfplotsretvalb - \pgfplots@boxplot@get@quantile@offset{\pgfplots@boxplot@numcoords@minus@one}{\pgfplotsboxplotvalue{upper quartile off}}% - \let\c@pgfplotsplothandlerboxplot@upperquartile=\pgfplotsretval - \let\b@pgfplotsplothandlerboxplot@upperquartile@isint=\pgfplotsretvalb + \pgfplotsplothandler@boxplot@init@percentile@estimator % % hm. I once had the idea to support quartile-based whisker % definitions... but I did not implement them. @@ -357,15 +574,16 @@ \let\pgfplotsplothandlerboxplot@upperquartile=\pgfutil@empty \let\pgfplotsplothandlerboxplot@upperwhisker=\pgfutil@empty % - \c@pgfplots@coordindex=0 % - \def\pgfplots@boxplot@@next@target{lowerquartile}% - \def\pgfplots@boxplot@next@@lowerquartile{median}% - \def\pgfplots@boxplot@next@@median{upperquartile}% - \def\pgfplots@boxplot@next@@upperquartile{}% - \let\pgfplotsplothandlersurveyend@boxplot@computestats@=\pgfplotsplothandlersurveyend@boxplot@computestats@quantile - \expandafter\pgfplotsplothandlersurveyend@boxplot@computestats@loop\pgfplots@boxplot@data\pgfplots@EOI + \pgfplotsplothandler@boxplot@percentile@estimator{\pgfkeysvalueof{/pgfplots/boxplot/lower quartile off}}{\numcoords}% + \let\pgfplotsplothandlerboxplot@lowerquartile=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator{\pgfkeysvalueof{/pgfplots/boxplot/upper quartile off}}{\numcoords}% + \let\pgfplotsplothandlerboxplot@upperquartile=\pgfmathresult + \pgfplotsplothandler@boxplot@percentile@estimator{0.5}{\numcoords}% + \let\pgfplotsplothandlerboxplot@median=\pgfmathresult % % + \pgfplotscoordmath{float}{parsenumber}{\numcoords}% + \let\pgfplots@boxplot@numcoords=\pgfmathresult \pgfplotscoordmath{float}{op}{divide}{{\pgfplotsplothandlerboxplot@sum}{\pgfplots@boxplot@numcoords}}% \let\pgfplotsplothandlerboxplot@average=\pgfmathresult % @@ -395,9 +613,9 @@ \pgfplotscoordmath{float}{op}{subtract}{{\pgfplotsplothandlerboxplot@lowerquartile}{\pgfplots@boxplot@whisker@width}}% \let\pgfplotsplothandlerboxplot@lowerwhisker@value=\pgfmathresult % - \c@pgfplots@coordindex=0 % - \let\pgfplotsplothandlersurveyend@boxplot@computestats@=\pgfplotsplothandlersurveyend@boxplot@computestats@valuebased - \expandafter\pgfplotsplothandlersurveyend@boxplot@computestats@loop\pgfplots@boxplot@data\pgfplots@EOI + \pgfplotsarrayforeachungrouped\pgfp@boxplot@@\as\pgfplots@current@point@data{% + \pgfplotsplothandlersurveyend@boxplot@computestats@valuebased + }% % \pgfplotsplothandlersurveyend@boxplot@set{lower whisker}{\pgfplotsplothandlerboxplot@lowerwhisker}% \pgfplotsplothandlersurveyend@boxplot@set{upper whisker}{\pgfplotsplothandlerboxplot@upperwhisker}% @@ -412,6 +630,8 @@ % % The "replaced by #2" means to set the value right away and to modify % the plot's option list to reflect the new value. +% +% ---- NOTE: this routine is also invoked from the LUA BACKEND. \def\pgfplotsplothandlersurveyend@boxplot@set#1#2{% \pgfkeysgetvalue{/pgfplots/boxplot/#1}\pgfplots@loc@TMPa \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% @@ -423,10 +643,15 @@ \pgfplotscoordmath{float}{tostring}{#2}% \edef\pgfplots@loc@TMPb{\noexpand\pgfplotsplothandlersurveyaddoptions{/pgfplots/boxplot/#1={\pgfmathresult}}}% \pgfplots@loc@TMPb + \pgfplotsplothandlersurveyend@boxplot@log{#1}{\pgfmathresult}% \fi \fi }% +\def\pgfplotsplothandlersurveyend@boxplot@log#1#2{% + \pgfplots@log3{boxplot: got #1=#2}% +}% + \def\pgfplotsplothandlersurveyend@boxplot@get#1#2{% \pgfkeysgetvalue{/pgfplots/boxplot/#2}\pgfplots@loc@TMPa \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% @@ -441,79 +666,6 @@ \fi } - -% Assuming that the input coordinates are in a LIST, we have to loop -% over that list. -\def\pgfplotsplothandlersurveyend@boxplot@computestats@loop#1{% - \def\pgfplots@loc@TMPa{#1}% - \ifx\pgfplots@loc@TMPa\pgfplots@EOI - \else - % - \let\pgfplots@current@point@data=\pgfplots@loc@TMPa - \pgfplotsplothandlersurveyend@boxplot@computestats@ - % - \advance\c@pgfplots@coordindex by1 % - \expandafter\pgfplotsplothandlersurveyend@boxplot@computestats@loop - \fi -}% - -% Really computes stats. -% -% This method computes ALL quantiles (one after the other). These are 0.25, -% 0.5, and 0.75. Perhaps I add quantile-based whiskers eventually. -% -% XXX : this method is quite inefficient because it iterates through a -% loop for what would be 3 arrays lookups otherwise. If I would have enough -% courage to store the points into an array, both this and the -% whisker-loop would be more efficient. But in TeX, arrays are not -% necessarily that efficient ... they run out of memory easily! -% -% The data is in \pgfplots@current@point@data. -\def\pgfplotsplothandlersurveyend@boxplot@computestats@quantile{% - % - \c@pgf@countd=\csname c@pgfplotsplothandlerboxplot@\pgfplots@boxplot@@next@target\endcsname\relax - \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplotsplothandlerboxplot@\pgfplots@boxplot@@next@target\endcsname - % - \ifnum\c@pgf@countd=\c@pgfplots@coordindex\relax - % Ah - we found the occurence of the current search target! - \expandafter\let\csname pgfplotsplothandlerboxplot@\pgfplots@boxplot@@next@target\endcsname=\pgfplots@current@point@data - % - \expandafter\let\expandafter\pgfplots@loc@TMPb\csname b@pgfplotsplothandlerboxplot@\pgfplots@boxplot@@next@target @isint\endcsname - \if 1\pgfplots@loc@TMPb - % accept the match! - % ... and search for the next search target. - \expandafter\let\expandafter\pgfplots@boxplot@@next@target\csname pgfplots@boxplot@next@@\pgfplots@boxplot@@next@target\endcsname - \else - % ... continue searching for the same target in order to - % compute the mean. - \fi - \else - \ifx\pgfplots@loc@TMPa\pgfutil@empty - \else - % Ah! this can *only* happen if we have to compute a - % mean between the previous and this data point. - % - % The current search target is 0.5 * (value + next): - \pgfplotscoordmath{float}{op}{add}{{\pgfplots@current@point@data}{\pgfplots@loc@TMPa}}% - \let\pgfplots@loc@TMPb=\pgfmathresult - \pgfplotscoordmath{float}{parsenumber}{0.5}% - \pgfplotscoordmath{float}{op}{multiply}{{\pgfmathresult}{\pgfplots@loc@TMPb}}% - % - \expandafter\let\csname pgfplotsplothandlerboxplot@\pgfplots@boxplot@@next@target\endcsname - =\pgfmathresult - % - % ... and search for the next search target. - \expandafter\let\expandafter\pgfplots@boxplot@@next@target\csname pgfplots@boxplot@next@@\pgfplots@boxplot@@next@target\endcsname - % - \fi - \fi - % - \ifx\pgfplots@boxplot@@next@target\pgfutil@empty - % stop searching. - \let\pgfplotsplothandlersurveyend@boxplot@computestats@=\relax - \fi -} - \def\pgfplotsplothandlersurveyend@boxplot@computestats@valuebased{% \ifx\pgfplotsplothandlerboxplot@lowerwhisker\pgfutil@empty \pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@data}{\pgfplotsplothandlerboxplot@lowerwhisker@value}{% @@ -524,6 +676,8 @@ }% \fi % + % FIXME : optimize this! We have an array so we COULD check it in + % reverse order! % it would be so cool if we could simply check the list in reverse % order. but not if it really is a singly-linked list... \pgfplotscoordmath{float}{if less than}{\pgfplotsplothandlerboxplot@upperwhisker@value}{\pgfplots@current@point@data}{% @@ -556,12 +710,19 @@ \else \pgfplotscoordmath{float}{if is bounded}{\pgfplots@current@point@data}{% % - \pgfplotsplothandlersurveypoint@boxplot@ + \ifpgfplots@LUA@backend@supported + \pgfplotsplothandlerboxplot@LUA@survey@point + \else + \pgfplotsplothandlersurveypoint@boxplot@ + \fi }{% }% \fi }% +\def\pgfplotsplothandlerboxplot@LUA@survey@point{% + \directlua{pgfplots.texBoxPlotSurveyPoint("\pgfplots@current@point@data")}% +}% \def\pgfplotsplothandlersurveypoint@boxplot@{% \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlerboxplot@num % @@ -577,8 +738,8 @@ \let\pgfplotsplothandlerboxplot@sum=\pgfmathresult % % store parsed result. - \edef\pgfmathresult{{\pgfplots@current@point@data}}% - \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfp@boxplot@@ + \edef\pgfmathresult{\pgfplots@current@point@data}% + \expandafter\pgfplotsarraypushback\expandafter{\pgfmathresult}\to\pgfp@boxplot@@ % \let\pgfplotsplothandlerboxplot@last=\pgfplots@current@point@data % @@ -1054,4 +1215,7 @@ \pgfplots@boxplot@cs@decompose{#1}% \pgfplotsboxplotpointabwhisker{\pgfplots@boxplotcs@a}{\pgfplots@boxplotcs@b}% }% + +\catcode`\;=\pgfplots@oldcatcodesemicolon +\catcode`\"=\pgfplots@oldcatcodedoublequote \endinput |