diff options
37 files changed, 3148 insertions, 596 deletions
diff --git a/Master/texmf-dist/doc/generic/pgfplots/README b/Master/texmf-dist/doc/generic/pgfplots/README index 55645f9867b..b0fd857ca3b 100644 --- a/Master/texmf-dist/doc/generic/pgfplots/README +++ b/Master/texmf-dist/doc/generic/pgfplots/README @@ -23,7 +23,7 @@ Please take a look at and doc/latex/pgfplots/pgfplotstable.pdf. -Copyright 2007-2014 by Christian Feuersaenger. +Copyright 2007-2016 by Christian Feuersaenger. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +41,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. HISTORY: +1.14 +- new feature: 'contour filled' (compat=1.14) +- new feature: building colormaps from other colormaps (see "Building Colormaps based on other Colormaps" in the manual) +- new feature: non-uniform colormaps (compat=1.14) +- new feature: colormaps defined on position of arbitrary magnitude +- new feature: colorbar as legend +- new feature: 'colorbar style={xtick=data}' positions tick labels at colormap positions +- fixed bug: pgfplots now handles incompatible changes of luatex + loading \usepackage{pgfplots} _before_ pgf also allows makes older + PGF versions compatible with luatex +- fixed bug: incompatibility between units + groupplots (bug 119) +- fixed bug: 'axis line shift' did not respect labels +- fixed bug: layers for axis lines were not respected +- fixed bug: two axes with fillbetween in the same picture failed due to clip paths on layers +- fixed bug: quiver plots with 'every arrow' failed to evaluate arrow tip length arguments +- fixed bug: \usepgfplotslibrary{colorbrewer}: colormap 'PuOr' was defined in reverse order + 1.13: - fixed bug: incompatiblity between fillbetween and babel - fixed bug: 'compat=1.9' (or newer) failed to work with log bar plots diff --git a/Master/texmf-dist/doc/latex/pgfplots/TeX-programming-notes.pdf b/Master/texmf-dist/doc/latex/pgfplots/TeX-programming-notes.pdf Binary files differindex 000e79227eb..0a9421b1439 100644 --- a/Master/texmf-dist/doc/latex/pgfplots/TeX-programming-notes.pdf +++ b/Master/texmf-dist/doc/latex/pgfplots/TeX-programming-notes.pdf diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplots.doc.src.tar.bz2 b/Master/texmf-dist/doc/latex/pgfplots/pgfplots.doc.src.tar.bz2 Binary files differindex ab06c343729..57f078b3365 100644 --- a/Master/texmf-dist/doc/latex/pgfplots/pgfplots.doc.src.tar.bz2 +++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplots.doc.src.tar.bz2 diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplots.pdf b/Master/texmf-dist/doc/latex/pgfplots/pgfplots.pdf Binary files differindex e51abb3bf7a..11a64700402 100644 --- a/Master/texmf-dist/doc/latex/pgfplots/pgfplots.pdf +++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplots.pdf diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplotsexample.pdf b/Master/texmf-dist/doc/latex/pgfplots/pgfplotsexample.pdf Binary files differindex f0b934ed995..1b72555e8b1 100644 --- a/Master/texmf-dist/doc/latex/pgfplots/pgfplotsexample.pdf +++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplotsexample.pdf diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplotstable.pdf b/Master/texmf-dist/doc/latex/pgfplots/pgfplotstable.pdf Binary files differindex d18be381ebb..a6a6245c848 100644 --- a/Master/texmf-dist/doc/latex/pgfplots/pgfplotstable.pdf +++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplotstable.pdf diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplotstodo.pdf b/Master/texmf-dist/doc/latex/pgfplots/pgfplotstodo.pdf Binary files differindex 04ff8bf454c..91a1cd83c2b 100644 --- a/Master/texmf-dist/doc/latex/pgfplots/pgfplotstodo.pdf +++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplotstodo.pdf diff --git a/Master/texmf-dist/doc/plain/pgfplots/pgfplotsexample-plain.pdf b/Master/texmf-dist/doc/plain/pgfplots/pgfplotsexample-plain.pdf Binary files differindex d9d303f7657..0e1ee64ef75 100644 --- a/Master/texmf-dist/doc/plain/pgfplots/pgfplotsexample-plain.pdf +++ b/Master/texmf-dist/doc/plain/pgfplots/pgfplotsexample-plain.pdf diff --git a/Master/texmf-dist/scripts/pgfplots/matlab2pgfplots.m b/Master/texmf-dist/scripts/pgfplots/matlab2pgfplots.m index d8922238e18..cf9111e9acc 100644 --- a/Master/texmf-dist/scripts/pgfplots/matlab2pgfplots.m +++ b/Master/texmf-dist/scripts/pgfplots/matlab2pgfplots.m @@ -34,7 +34,7 @@ function matlab2pgfplots(varargin ) % parametric plots if x and y are not monotonically increasing. % % See -% http://tug.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/ +% http://www.ctan.org/pkg/pgfplots % for details about pgfplots. % % diff --git a/Master/texmf-dist/source/context/third/pgfplots/pgfplotstests.context.tar.bz2 b/Master/texmf-dist/source/context/third/pgfplots/pgfplotstests.context.tar.bz2 Binary files differindex 5687de7f7a9..44eb1f6715d 100644 --- a/Master/texmf-dist/source/context/third/pgfplots/pgfplotstests.context.tar.bz2 +++ b/Master/texmf-dist/source/context/third/pgfplots/pgfplotstests.context.tar.bz2 diff --git a/Master/texmf-dist/source/latex/pgfplots/pgfplotstests.tar.bz2 b/Master/texmf-dist/source/latex/pgfplots/pgfplotstests.tar.bz2 Binary files differindex 572d6708c6a..212fee8780d 100644 --- a/Master/texmf-dist/source/latex/pgfplots/pgfplotstests.tar.bz2 +++ b/Master/texmf-dist/source/latex/pgfplots/pgfplotstests.tar.bz2 diff --git a/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex b/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex index 426d07282d0..4347f6c7e45 100644 --- a/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex +++ b/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex @@ -31,7 +31,8 @@ \input pgfplots.revision.tex \startmodule [pgfplots] -\usemodule[tikz] +% regarding the t-prefix: ensure that we do not accidentally load the plain tex tikz.tex file... +\usemodule[t][tikz] \usetikzlibrary[plotmarks] \edef\tikzatcode{\the\catcode`\@} diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarycolorbrewer.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarycolorbrewer.code.tex index f5bbcd543e0..b106a506f91 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarycolorbrewer.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarycolorbrewer.code.tex @@ -349,21 +349,24 @@ \pgfutil@definecolor{PRGn-N}{RGB}{27,120,55} \pgfutil@definecolor{PRGn-O}{RGB}{0,68,27} -\pgfutil@definecolor{PuOr-A}{RGB}{127,59,8} -\pgfutil@definecolor{PuOr-B}{RGB}{179,88,6} -\pgfutil@definecolor{PuOr-C}{RGB}{230,97,1} -\pgfutil@definecolor{PuOr-D}{RGB}{224,130,20} -\pgfutil@definecolor{PuOr-E}{RGB}{241,163,64} -\pgfutil@definecolor{PuOr-F}{RGB}{253,184,99} -\pgfutil@definecolor{PuOr-G}{RGB}{254,224,182} +% These colors are defined in reverse order compared to <http://colorbrewer2.org>. +% For more details have a look at the comments in +% <https://sourceforge.net/p/pgfplots/bugs/108/> +\pgfutil@definecolor{PuOr-A}{RGB}{45,0,75} +\pgfutil@definecolor{PuOr-B}{RGB}{84,39,136} +\pgfutil@definecolor{PuOr-C}{RGB}{94,60,153} +\pgfutil@definecolor{PuOr-D}{RGB}{128,115,172} +\pgfutil@definecolor{PuOr-E}{RGB}{153,142,195} +\pgfutil@definecolor{PuOr-F}{RGB}{178,171,210} +\pgfutil@definecolor{PuOr-G}{RGB}{216,218,235} \pgfutil@definecolor{PuOr-H}{RGB}{247,247,247} -\pgfutil@definecolor{PuOr-I}{RGB}{216,218,235} -\pgfutil@definecolor{PuOr-J}{RGB}{178,171,210} -\pgfutil@definecolor{PuOr-K}{RGB}{153,142,195} -\pgfutil@definecolor{PuOr-L}{RGB}{128,115,172} -\pgfutil@definecolor{PuOr-M}{RGB}{94,60,153} -\pgfutil@definecolor{PuOr-N}{RGB}{84,39,136} -\pgfutil@definecolor{PuOr-O}{RGB}{45,0,75} +\pgfutil@definecolor{PuOr-I}{RGB}{254,224,182} +\pgfutil@definecolor{PuOr-J}{RGB}{253,184,99} +\pgfutil@definecolor{PuOr-K}{RGB}{241,163,64} +\pgfutil@definecolor{PuOr-L}{RGB}{224,130,20} +\pgfutil@definecolor{PuOr-M}{RGB}{230,97,1} +\pgfutil@definecolor{PuOr-N}{RGB}{179,88,6} +\pgfutil@definecolor{PuOr-O}{RGB}{127,59,8} \pgfutil@definecolor{RdBu-A}{RGB}{103,0,31} \pgfutil@definecolor{RdBu-B}{RGB}{178,24,43} 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 a8ed6e9f3da..76fb9fd67a2 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 @@ -156,14 +156,15 @@ \endgroup }% +\expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{\pgfplots@notify@options@are@set + \global\let\pgfplots@global@dateplot@defaultshift=\pgfutil@empty +} + \pgfplotsset{ /pgfplots/date ZERO/.code={% \pgfplots@dateplot@parse@ZEROSHIFT{#1}% \let\pgfplots@calender@ZEROSHIFT=\pgfmathresult }, - /pgfplots/execute at begin axis@@/.add={}{% - \global\let\pgfplots@global@dateplot@defaultshift=\pgfutil@empty - }, /pgfplots/date coordinates in/.code={% \pgfkeysdef{/pgfplots/#1 coord trafo}{% \begingroup diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex index 3259029cc67..dabbda099ed 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex @@ -109,4 +109,23 @@ \endgroup \fi + + +\def\tikzexternal@externalizefig@systemcall@call@old#1{% + \iftikzexternal@verboseio + \immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}% + \fi + \immediate\write18{#1}% +}% + +\def\tikzexternal@externalizefig@systemcall@call@new#1{% + \iftikzexternal@verboseio + \immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}% + \fi + \pgfutil@shellescape{#1}% +}% +\ifx\tikzexternal@externalizefig@systemcall@call\tikzexternal@externalizefig@systemcall@call@old + \let\tikzexternal@externalizefig@systemcall@call=\tikzexternal@externalizefig@systemcall@call@new +\fi + \endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex index 3c3243abab1..fea448143d7 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex @@ -51,7 +51,7 @@ \usepgfplotslibrary{decorations.softclip} \pgfkeys{ - /pgfplots/every fill between plot/.style={/pgfplots/area legend,/tikz/fill}, + /pgfplots/every fill between plot/.style={/pgfplots/area legend,/tikz/fill,/pgfplots/on layer=pre main}, /tikz/soft clip assign/domain/.code args={#1:#2}{% \pgfplotsifisvisualizationphase{% \edef\pgfplots@loc@TMPa{% @@ -71,41 +71,10 @@ },% % /pgfplots/execute at begin axis@@/.add={}{% - \gdef\pgfplotsfillbetween@list@of@layers@with@clippath{}% \gdef\b@pgfplotsfillbetween@list@has@set@layers{0}% }, } -% #1: the value of /tikz/fill between/on layer -\def\pgfplotsfillbetween@ensure@clipping@on@layer{% - \ifpgfplots@clip - \pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots@loc@TMPa - \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% - % - % check if 'pre main,' is inside of the already prepared layers: - \def\pgfplots@loc@TMPb{\expandafter\pgfutil@in@\expandafter{\pgfplots@loc@TMPa,}}% - \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplotsfillbetween@list@of@layers@with@clippath}% - % - \ifpgfutil@in@ - % ah - already prepared. Good, nothing left to do. - \else - \pgfplots@log3{fill between: found 'clip=true'. Preparing pgfplotsextra instruction with clip path for layer '\pgfplots@loc@TMPa'...}% - \xdef\pgfplotsfillbetween@list@of@layers@with@clippath{\pgfplots@loc@TMPa,\pgfplotsfillbetween@list@of@layers@with@clippath}% - % - \edef\pgfplots@loc@TMPb{% - \noexpand\pgfplotsextra{% - \noexpand\pgfplotsonlayer{\pgfplots@loc@TMPa}% - \noexpand\pgfplotspathaxisoutline - \noexpand\pgfusepath{clip}% - \noexpand\endpgfplotsonlayer - }% - }% - \pgfplots@loc@TMPb - % - \fi - \fi -}% - % The options are from % \addplot[#1] fill between[#2] #3; % @@ -114,6 +83,12 @@ % \pgfplots@start@plot@with@behavioroptions{/pgfplots/every fill between plot,#1}% % + % '/tikz/fill between/on layer' is not really integrated into the option processing of pgfplots. + % improve it here (to some extend): + \pgfkeysgetvalue{/pgfplots/on layer}\pgfplots@loc@TMPa + \pgfkeyslet{/tikz/fill between/on layer}{\pgfplots@loc@TMPa}% + % + % FIXME: is this here an accident!? \pgfkeysvalueof{/pgfplots/execute at end survey}% \pgfplots@remember@survey@option@list % @@ -125,6 +100,41 @@ }{% % empty - this here is a TikZ instruction, not a "real" \addplot command }{% + \def\b@pgfplots@fillbetween@clip@on@layer{0}% + \pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots@loc@TMPa + \edef\pgfplots@fillbetween@layer{\pgfplots@loc@TMPa}% + \ifx\pgfplots@fillbetween@layer\pgfutil@empty + \else + \ifpgfplots@clip + \def\b@pgfplots@fillbetween@clip@on@layer{1}% + % This here is messy: we have to clip on the other + % layer. I gave up to install this clip path once + % per axis, that's why I do it for each individual + % fillbetween - let us hope this is not too + % inefficient. + % + % I had to give up because the result appears to + % require a pattern of sorts + % \onlayer{L} + % \scope + % \clip ... ; + % \endonlayer + % ... + % + % \onlayer{L} + % \endscope + % \endonlayer + % + % which is forbidden in TeX -- and using + % \pgfsys@beginscope resulted in invalid PDF. + % + \pgfplotsonlayer{\pgfplots@loc@TMPa}% + \scope + \pgfplotspathaxisoutline + \pgfusepath{clip}% + \fi + \fi + % % the path instruction: \tikzfillbetween[#2]{% /pgfplots/.search also=/tikz,% @@ -132,6 +142,11 @@ /tikz/fill between/every last segment/.append style={/tikz/fill between/path after segment={#3}},% #1% }% + % + \if1\b@pgfplots@fillbetween@clip@on@layer + \endscope + \endpgfplotsonlayer% + \fi }{% % post command. }% @@ -148,7 +163,6 @@ }% % SIDE-EFFECT: modifies \b@pgfplotsfillbetween@list@has@set@layers and -% \pgfplotsfillbetween@list@of@layers@with@clippath \def\pgfplotslibraryfillbetweenpreparecurrentlayer{% \pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots@loc@TMPa \ifx\pgfplots@loc@TMPa\pgfutil@empty @@ -158,7 +172,6 @@ \pgfplotssetlateoptions{fill between/@ensure layers}% \gdef\b@pgfplotsfillbetween@list@has@set@layers{1}% \fi - \pgfplotsfillbetween@ensure@clipping@on@layer% \fi } diff --git a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex index 0f42923b753..2c0c06baec4 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex @@ -220,13 +220,13 @@ % Determine the labels of both x and y. % \def\pgfplots@group@determine@labels{% - \def\pgfplots@loc@TMPa{all} - \def\pgfplots@loc@TMPb{lower} + \def\pgfplots@loc@TMPa{all}% + \def\pgfplots@loc@TMPb{lower}% \ifx\pgfplots@loc@TMPa\pgfplots@group@xlabels% % xlabels at=all % Do nothing as all should have xlabels \fi - \gdef\pgfplots@glob@TMPa{} + \gdef\pgfplots@glob@TMPa{}% \ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels% % xlabels at=lower \ifnum1<\pgfplots@group@rows\relax @@ -235,7 +235,11 @@ \ifnum\pgfplots@row=\pgfplots@group@rows\relax% \else \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% - \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xlabel={}}}% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% + /pgfplots/xlabel={},% + \ifpgfplots@units@use/pgfplots/x unit={}\fi + }% + }% \fi }% }% @@ -252,7 +256,11 @@ \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xticklabel pos=upper}}% \else \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% - \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xlabel={}}}% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% + /pgfplots/xlabel={},% + \ifpgfplots@units@use/pgfplots/x unit={}\fi% + }% + }% \fi }% }% @@ -273,7 +281,11 @@ \foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% \foreach \pgfplots@column in {2,...,\pgfplots@group@columns} {% \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% - \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/ylabel={}}}% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% + /pgfplots/ylabel={},% + \ifpgfplots@units@use/pgfplots/y unit={}\fi% + }% + }% }% }% \fi% @@ -289,7 +301,11 @@ \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/yticklabel pos=upper}}% \else \expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% - \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/ylabel={}}}% + \pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% + /pgfplots/ylabel={},% + \ifpgfplots@units@use/pgfplots/y unit={}\fi% + }% + }% \fi }% }% @@ -297,7 +313,7 @@ \fi% \fi \fi - \expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa} + \expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa}% } % diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex index 55a91874293..df9a26d6839 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex @@ -17,6 +17,7 @@ % \pgfplotsarraycheckempty % \pgfplotsarrayforeach % \pgfplotsarraysort +% \pgfplotsarraybinarysearch % % and a subset also for global arrays: % \pgfplotsarraynewemptyglobal @@ -668,3 +669,65 @@ \pgfplotsarrayinsertionsort@@next }% +% applies a binary seach for value '#2' on array '#1', starting with +% index '#3' (inclusive) and ending in index '#4' (exclusive). +% +% Returns: \pgfplotsretval, the index of the search key, if it is +% contained in the array; otherwise, (-(insertion point) - 1). The +% insertion point is defined as the point at which the key would be +% inserted into the array: the index of the first element greater than +% the key, or a.length if all elements in the array are less than the +% specified key. Note that this guarantees that the return value will +% be >= 0 if and only if the key is found. +% +\def\pgfplotsarraybinarysearch#1#2#3#4{% + \begingroup + \edef\targetvalue{#2}% + \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotsarray@iflt + \let\mid=\c@pgf@counta + \let\left=\c@pgf@countb + \let\right=\c@pgf@countc + \left=#3\relax + \right=#4\relax + \advance\right by-1 % make it inclusive + \let\pgfplotsretval\pgfutil@empty + % + \pgfutil@loop + \ifnum\left>\right + \pgfplots@loop@CONTINUEfalse + \else + \pgfplots@loop@CONTINUEtrue + \fi + \ifpgfplots@loop@CONTINUE + \mid=\right + \advance\mid by -\left + \divide\mid by2 % + \advance\mid by\left + % + \pgfplotsarrayselect\mid\of#1\to\midvalue + \pgfplotsarray@iflt{\targetvalue}{\midvalue}{% + \right=\mid + \advance\right by-1 % + }{% + \pgfplotsarray@iflt{\midvalue}{\targetvalue}{% + \left=\mid + \advance\left by1 % + }{% + % found it! abort loop! + \left=\right + \advance\left by1 % + \edef\pgfplotsretval{\the\mid}% + }% + \pgfeov% + }% + \pgfeov% + \pgfutil@repeat + % + \ifx\pgfplotsretval\pgfutil@empty + \advance\left by1 % + \left=-\left + \edef\pgfplotsretval{\the\left}% + \fi + \pgfmath@smuggleone\pgfplotsretval + \endgroup +}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua index 28fd6ddd56b..e0df003e724 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua @@ -32,14 +32,16 @@ ColorMap.range =1000 -- h: mesh width between adjacent values -- colorspace: an instance of ColorSpace -- values: an array (1-based table) with color components. Each color component is supposed to be a table with K entries where K is colorspace:numComponents -function ColorMap:constructor( h, colorspace, values) - if not h or not colorspace or not values then error("arguments must not be nil")end +-- positions: either an empty array (in which case the colormap is uniform) or one position per value. Positions are in [0,1000] +function ColorMap:constructor( h, colorspace, values, positions) + if not h or not colorspace or not positions or not values then error("arguments must not be nil")end self.name = name self.h = h self.invh = 1/h self.colorspace = colorspace self.values = values + self.pos = positions local numComponents = self.colorspace.numComponents for i = 1,#self.values do diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua index ba719753dad..218b08c5dd3 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua @@ -15,7 +15,6 @@ local type=type local tostring=tostring local error=error local table=table -local pgfmathparse = pgfplots.pgfluamathparser.pgfmathparse do -- all globals will be read from/defined in pgfplots: @@ -55,8 +54,6 @@ function Coord:__tostring() return result end -local stringToFunctionMap = pgfluamathfunctions.stringToFunctionMap - -- a reference to a Coord which is returned by math expressions involving 'x', 'y', or 'z' -- see surveystart() local pseudoconstant_pt = nil @@ -151,6 +148,10 @@ function Plothandler:constructor(name, axis, pointmetainputhandler) self.hasUnboundedPointMeta = false -- will be set before the visualization phase starts. At least. self.plotIs3d = false + + -- do not use the global one. It may be outdated. + self.stringToFunctionMap = pgfluamathfunctions.stringToFunctionMap + return self end @@ -205,13 +206,13 @@ end -- @see \pgfplotsplothandlersurveystart function Plothandler:surveystart() - stringToFunctionMap["x"] = pseudoconstant_x - stringToFunctionMap["y"] = pseudoconstant_y - stringToFunctionMap["z"] = pseudoconstant_z - stringToFunctionMap["rawx"] = pseudoconstant_rawx - stringToFunctionMap["rawy"] = pseudoconstant_rawy - stringToFunctionMap["rawz"] = pseudoconstant_rawz - stringToFunctionMap["meta"] = pseudoconstant_meta + self.stringToFunctionMap["x"] = pseudoconstant_x + self.stringToFunctionMap["y"] = pseudoconstant_y + self.stringToFunctionMap["z"] = pseudoconstant_z + self.stringToFunctionMap["rawx"] = pseudoconstant_rawx + self.stringToFunctionMap["rawy"] = pseudoconstant_rawy + self.stringToFunctionMap["rawz"] = pseudoconstant_rawz + self.stringToFunctionMap["meta"] = pseudoconstant_meta end -- @see \pgfplotsplothandlersurveyend @@ -555,7 +556,7 @@ function ExpressionPointMetaHandler:constructor(expression) end function ExpressionPointMetaHandler:assign(pt) - pt.meta = pgfmathparse(self.expression) + pt.meta = pgfluamathparser.pgfmathparse(self.expression) if not pt.meta then error("point meta=" .. self.expression .. ": expression has been rejected.") end @@ -684,7 +685,7 @@ function Axis:filtercoord(dir, ptCoords, filterExpressionByDir) end local old = updatePseudoConstants(ptCoords) - result = pgfmathparse(filterExpressionByDir[dir]) + result = pgfluamathparser.pgfmathparse(filterExpressionByDir[dir]) updatePseudoConstants(old) end diff --git a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex index 4d44a17c005..a85aa649329 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex @@ -348,6 +348,7 @@ /pgfplots/table/every first column/.style={}, /pgfplots/table/every last column/.style={}, /pgfplots/table/every even column/.style={}, + /pgfplots/table/every column/.style={}, /pgfplots/table/every odd column/.style={}, /pgfplots/table/every nth row/.code 2 args={% \pgfplotstabletypeset@append@every@nth@row{#1}{#2}% @@ -930,12 +931,13 @@ /pgfplots/table/reset styles/.style={ /pgfplots/table/every table/.code=, /pgfplots/table/every odd column/.code=, + /pgfplots/table/every column/.code=, /pgfplots/table/every even column/.code=, /pgfplots/table/every first column/.code=, /pgfplots/table/every last column/.code=, /pgfplots/table/every head row/.code=, /pgfplots/table/every odd row/.code=, - /pgfplots/table/every even row/.code=, + /pgfplots/table/every even row/.code=,± /pgfplots/table/every first row/.code=, /pgfplots/table/every last row/.code=, /pgfplots/table/postproc cell content/.code=, @@ -1835,7 +1837,7 @@ \else \edef\pgfplotstable@colname@for@styles{\the\t@pgfplots@tokb}% \fi - \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,columns/\pgfplotstable@colname@for@styles/.try}% + \edef\pgfplotstable@loc@TMPa{every column,\the\t@pgfplots@toka,columns/\pgfplotstable@colname@for@styles/.try}% \t@pgfplots@toka=\expandafter{\pgfplotstable@loc@TMPa}% \t@pgfplots@tokb=\expandafter{\pgfplotstable@displaycolkey}% \edef\pgfplotstable@loc@TMPa{\the\t@pgfplots@toka,\the\t@pgfplots@tokb}% diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex index 1fefd8f12cd..3f3f4e23162 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex @@ -210,16 +210,64 @@ pgfluamathparser = nil} \pgfplotsusecompatibilityfile{pgflibraryluamath.code.tex} % ATTENTION: see 'pgfplots.lua' which ALSO loads these items + % FIXME : some .lua files reference outdated + % tonumber/tostring functions! \pgfutil@directlua{% pgfplots.pgfluamathfunctions = pgfluamathfunctions; - pgfplots.pgfluamathparser = pgfluamathparser} + pgfplots.pgfluamathparser = pgfluamathparser}% \let\pgfmathnotifynewdeclarefunction@orig=\PATCH@pgfmathnotifynewdeclarefunction@orig \let\pgfmathsetseed@pgfbasic=\PATCH@pgfmathsetseed@pgfbasic + \pgfplots@log4{luamath library shipped with pgf \pgfversion\space is outdated; using a substitute shipped with pgfplots}% \else \pgfplots@log4{luamath library shipped with pgf \pgfversion\space is up-to-date}% \fi \fi \fi +\def\pgf@plotgnuplot@luatex@eight@seven[#1]#2{% + \pgf@resample@plottrue% + \pgfutilpreparefilename{#1.gnuplot}% + \let\pgf@plotgnuplotfile=\pgfretval + \pgfutilpreparefilename{#1.table}% + \let\pgf@plottablefile=\pgfretval + \let\pgf@plottablefile@quoted=\pgfretvalquoted + % Check, whether it is up-to-date + \openin\pgfutil@inputcheck=\pgf@plotgnuplotfile\relax + \ifeof\pgfutil@inputcheck% + \else% + \pgfutil@read\pgfutil@inputcheck to\pgf@temp% ignored + \pgfutil@read\pgfutil@inputcheck to\pgf@plot@line% + \closein\pgfutil@inputcheck + \edef\pgf@plot@code{#2\space}% + \ifx\pgf@plot@code\pgf@plot@line% + \openin\pgfutil@inputcheck=\pgfretval\relax + \ifeof\pgfutil@inputcheck% + \else% + \closein\pgfutil@inputcheck + \pgf@resample@plotfalse% + \fi% + \fi% + \fi + \ifpgf@resample@plot% + \immediate\openout\pgf@plotwrite=\pgf@plotgnuplotfile\relax + \immediate\pgfutil@write\pgf@plotwrite{\pgf@gnuplot@head}% + \immediate\pgfutil@write\pgf@plotwrite{#2}% + \immediate\closeout\pgf@plotwrite% + \pgfutil@shellescape{% + \pgfkeysvalueof{/pgf/plot/gnuplot call} \pgf@plotgnuplotfile}% + \fi% +% \let\pgf@savedparsexyline=\pgf@parsexyline% +% \let\pgf@parsexyline=\pgf@parsegnuplotxyline% + \pgfplotxyfile{\pgf@plottablefile}% +% \let\pgf@parsexyline=\pgf@savedparsexyline% +} + +\pgfutil@IfUndefined{pgfutil@shellescape}{% + \def\pgfutil@shellescape{\pgfplots@shellescape}% + \let\pgf@plotgnuplot=\pgf@plotgnuplot@luatex@eight@seven +}{% + % ok, plot function is up-to-date +}% + \endinput diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex index f4d348e9592..607b6375aef 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex @@ -19,7 +19,7 @@ % with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: % This file comes without any warranty as the rest of pgfplots; there is no obligation for help. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Date of this copy: Do 31. Dez 19:01:21 CET 2015 %%% +%%% Date of this copy: Di 12. Jul 21:02:29 CEST 2016 %%% @@ -1282,11 +1282,21 @@ \fi }% +\def\tikzexternal@externalizefig@before@grab{% + \pgfutil@IfUndefined{TP@holdbox}{% + }{% + % \usepackage[absolute]{textpos} + % populates this box -- and would inject unwanted material into our images. Reset it: + \global\setbox\TP@holdbox\vbox{}% + }% +}% + \def\tikzexternal@externalizefig@GRAB{% - \iftikzexternal@optimize - \ifpgf@external@grabshipout + \ifpgf@external@grabshipout + \iftikzexternal@optimize \tikzexternal@optimize@RESTORE \fi + \tikzexternal@externalizefig@before@grab \fi \def\tikzpicture{% \def\tikzpicture{% make sure that nested \tikzpicture are processed normally. @@ -1473,7 +1483,7 @@ \iftikzexternal@verboseio \immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}% \fi - \immediate\write18{#1}% + \pgfutil@shellescape{#1}% }% % Sets \iftikzexternal@file@isuptodate to false if one of the "force diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfsys-luatexpatch.def b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfsys-luatexpatch.def new file mode 100644 index 00000000000..6aa0dbc7ab9 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfsys-luatexpatch.def @@ -0,0 +1,435 @@ +% This file has been shipped with pgfplots in order to fix incompatibilities with the new luatex. The next version of PGF will include the "correct" file. +% +% + +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +%\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/systemlayer/pgfsys-luatex.def,v 1.35 2014/10/11 09:23:31 vibrovski Exp $ + + +% Driver commands for pdf + +% +% Load common pdf commands: +% +\input pgfsys-common-pdf.def + +% +% pdftex-specific stuff: +% +\def\pgfsys@invoke#1{\pdfextension literal{#1}} + +% Synced hboxes +\def\pgfsys@hboxsynced#1{% + {% + \pgfsys@beginscope% + \setbox\pgf@hbox=\hbox{% + \hskip\pgf@pt@x% + \raise\pgf@pt@y\hbox{% + \pgf@pt@x=0pt% + \pgf@pt@y=0pt% + \pgflowlevelsynccm% + \pgfsys@hbox#1}% + \hss% + }% + \wd\pgf@hbox=0pt% + \ht\pgf@hbox=0pt% + \dp\pgf@hbox=0pt% + \box\pgf@hbox% + \pgfsys@endscope% + }% +} + + + +\def\pgfsys@imagesuffixlist{.pdf:.jpg:.jpeg:.png:} +\def\pgfsys@defineimage{% width, height, page number + \ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{ width \pgf@imagewidth }\fi% + \ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{ height \pgf@imageheight }\fi% + \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{ page \pgf@imagepage }\fi% + \ifx\saveimageresource\@undefined% old version of lualatex + \ifx\pgf@imagepage\pgfutil@empty\else% + \pgfwarning{Page selection not supported. Ignoring page selection}% + \fi% + \setbox\pgfutil@tempboxa=\hbox{% + \pdfimage \pgf@imageheight \pgf@imagewidth {\pgf@filename}}% + \pdfform\pgfutil@tempboxa% + \edef\pgf@image{\noexpand\pdfrefform\the\pdflastform}% + \else% new version + {\saveimageresource \pgf@imageheight \pgf@imagewidth attr + {/Interpolate \pgf@imageinterpolate\space\pgf@imagemask} \pgf@imagepage + {\pgf@filename}}% + \edef\pgf@image{\noexpand\useimageresource\the\lastsavedimageresourceindex}% + \fi +}% +\def\pgfsys@definemask#1{% + \ifx\pgf@maskmatte\pgfutil@empty% + \else% + \edef\pgf@maskmatte{/Matte [\pgf@maskmatte]}% + \fi% + \edef\pgf@attr{{\pgf@maskmatte\space /Decode [1 0]}}% + \immediate\saveimageresource attr \pgf@attr {\pgf@filename}% + \edef\pgf@mask{/SMask \the\lastsavedimageresourceindex\space 0 R}% +} +\def\pgfsys@horishading#1#2#3{% + {% + \pgf@parsefunc{#3}% + \pgfmathparse{#2}% + \setbox\pgfutil@tempboxa=\hbox to\pgf@max{\vbox to\pgfmathresult pt{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% + \pgf@process{\pgfpoint{\pgf@max}{#2}}% + \immediate\saveboxresource resources {% + /Shading << /Sh << /ShadingType 2 + /ColorSpace /DeviceRGB + /Domain [\pgf@pdfparseddomain] + /Coords [\pgf@doma\space0 \pgf@domb\space0] + /Function \pgf@pdfparsedfunction + /Extend [false false] >> >>}\pgfutil@tempboxa% << + \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}% + }% +} +\def\pgfsys@vertshading#1#2#3{% + {% + \pgf@parsefunc{#3}% + \pgfmathparse{#2}% + \setbox\pgfutil@tempboxa=\hbox to\pgfmathresult pt{\vbox to\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% + \pgf@process{\pgfpoint{#2}{\pgf@max}}% + \immediate\saveboxresource resources {% + /Shading << /Sh << /ShadingType 2 + /ColorSpace /DeviceRGB + /Domain [\pgf@pdfparseddomain] + /Coords [0 \pgf@doma\space0 \pgf@domb] + /Function \pgf@pdfparsedfunction + /Extend [false false] >> >>}\pgfutil@tempboxa% << + \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}% + }% +} +\def\pgfsys@radialshading#1#2#3{% + {% + \pgf@parsefunc{#3}% + \setbox\pgfutil@tempboxa=\hbox to2\pgf@max{\vbox to2\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% + \pgf@process{#2}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}% + \advance\pgf@xa by \pgf@x% + \advance\pgf@ya by \pgf@y% + \pgf@sys@bp@correct{\pgf@x}% + \pgf@sys@bp@correct{\pgf@y}% + \pgf@sys@bp@correct{\pgf@xa}% + \pgf@sys@bp@correct{\pgf@ya}% + \immediate\saveboxresource resources {% + /Shading << /Sh << /ShadingType 3 + /ColorSpace /DeviceRGB + /Domain [\pgf@pdfparseddomain] + /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb] + /Function \pgf@pdfparsedfunction + /Extend [true false] >> >>}\pgfutil@tempboxa% << + \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}% + }% +}% +\def\pgfsys@functionalshading#1#2#3#4{% + {% + \pgf@process{#2}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{#3}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@y by-\pgf@ya% + \setbox\pgfutil@tempboxa=\hbox to\pgf@x{\vbox to\pgf@y{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% + \pgf@sys@bp@correct{\pgf@xa}% + \pgf@sys@bp@correct{\pgf@ya}% + \pgf@sys@bp@correct{\pgf@xb}% + \pgf@sys@bp@correct{\pgf@yb}% + \pgf@xc=-\pgf@xa% + \pgf@yc=-\pgf@ya% + % Now build the function + \pdfextension obj + stream + attr + { + /FunctionType 4 + /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}] + /Range [0 1 0 1 0 1] + } + {{#4}}% + \edef\pgf@temp@num{\the\numexpr\pdffeedback lastobj\relax}% + \saveboxresource resources {% + /Shading << /Sh << /ShadingType 1 + /ColorSpace /DeviceRGB + /Matrix [1 0 0 1 \pgf@sys@tonumber{\pgf@xc}\space\pgf@sys@tonumber{\pgf@yc}] + /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}] + /Function \pgf@temp@num\space 0 R + >> >>}\pgfutil@tempboxa% << + \expandafter\xdef\csname @pgfshading#1!\endcsname{% + \leavevmode% + \noexpand\useboxresource\the\lastsavedboxresourceindex% + \noexpand\pdfextension refobj \pgf@temp@num% + }% + }% +} + + + +% Patterns + +\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{% + % Start building the pattern dictionary: + \pgf@xa=#2\relax% + \pgf@ya=#3\relax% + \pgf@xb=#4\relax% + \pgf@yb=#5\relax% + \pgf@xc=#6\relax% + \pgf@yc=#7\relax% + \pgf@sys@bp@correct\pgf@xa% + \pgf@sys@bp@correct\pgf@ya% + \pgf@sys@bp@correct\pgf@xb% + \pgf@sys@bp@correct\pgf@yb% + \pgf@sys@bp@correct\pgf@xc% + \pgf@sys@bp@correct\pgf@yc% + % Now create the pattern object: + \immediate\pdfextension obj stream + attr + { + /Type /Pattern + /PatternType 1 + /PaintType \ifnum#9=0 2 \else 1 \fi + /TilingType 1 + /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb] + /XStep \pgf@sys@tonumber\pgf@xc\space + /YStep \pgf@sys@tonumber\pgf@yc\space + /Resources << >> %<< + } + {#8}% + \pgfutil@addpdfresource@patterns{/pgfpat#1\space \the\numexpr\pdffeedback lastobj\relax\space 0 R}% +} + +\def\pgfsys@setpatternuncolored#1#2#3#4{% + \pgfsysprotocol@literal{/pgfprgb cs #2 #3 #4 /pgfpat#1\space scn}% +} + +\def\pgfsys@setpatterncolored#1{% + \pgfsysprotocol@literal{/Pattern cs /pgfpat#1\space scn}% +} + +% System layer for meta patterns +% Takes 15(!) arguments +% #1 pattern name +% #2 #3 bounding box lower left +% #4 #5 bounding box upper right +% #6 #7 tile size +% #8 #9 #10 #11 #12 #13 transformation matrix +% #14 protocoled text +% #15 pattern type +\def\pgfsys@declarepattern@meta#1#2#3#4#5#6#7{% + % Start building the pattern dictionary: + \pgf@xa=#2\relax% + \pgf@ya=#3\relax% + \pgf@xb=#4\relax% + \pgf@yb=#5\relax% + \pgf@xc=#6\relax% + \pgf@yc=#7\relax% + \pgf@sys@bp@correct\pgf@xa% + \pgf@sys@bp@correct\pgf@ya% + \pgf@sys@bp@correct\pgf@xb% + \pgf@sys@bp@correct\pgf@yb% + \pgf@sys@bp@correct\pgf@xc% + \pgf@sys@bp@correct\pgf@yc% + \pgfsys@@declarepattern@meta{#1}} + +\def\pgfsys@@declarepattern@meta#1#2#3#4#5#6#7#8#9{% + \pgfutil@tempdima=#6\relax% + \pgfutil@tempdimb=#7\relax% + \pgf@sys@bp@correct\pgf@xa% + \pgf@sys@bp@correct\pgf@ya% + % Now create the pattern object: + \immediate\pdfextension obj stream + attr + { + /Type /Pattern + /PatternType 1 + /PaintType \ifnum#9=0 2 \else 1 \fi + /TilingType 1 + /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb] + /XStep \pgf@sys@tonumber\pgf@xc\space + /YStep \pgf@sys@tonumber\pgf@yc\space + /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb] + /Resources << >> %<< + } + {#8}% + \pgfutil@addpdfresource@patterns{/pgfpat#1\space \the\numexpr\pdffeedback lastobj\relax\space 0 R}% + } + + + +\def\pgfsys@papersize#1#2{\pageheight#2\relax\pagewidth#1\relax} + +\def\pgfsys@global@papersize#1#2{\global\pageheight#2\relax\global\pagewidth#1\relax} + +\ifx\paperheight\@undefined + \def\pgfsys@thepageheight{\pageheight} + \def\pgfsys@thepagewidth{\pagewidth} +\fi + + +% +% Position tracking +% +\def\pgfsys@markposition#1{% + \savepos% + \edef\pgf@temp{#1}% + \expandafter\pgfutil@writetoaux\expandafter{% + \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\lastxpos}{\the\lastypos}}% +} + +\def\pgfsyspdfmark#1#2#3{% + \expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}% + \pgfutil@check@rerun{#1}{{#2}{#3}}% +} + +\def\pgfsys@getposition#1#2{% + \edef\pgf@marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@#1\endcsname}% + \pgf@marshal% +} + +\def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfqpoint{\hoffset}{\voffset}} + + +% +% Opacity masks +% +\def\pgfsys@fadingfrombox#1#2{% + {% + \pgf@sys@pdf@check@resources% + \pgf@x=-.5\wd#2% + \pgf@y=-.5\ht#2% + \advance\pgf@y by.5\dp#2% + \expandafter\xdef\csname pgfsmasktrans@#1\endcsname{% + \noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}% + \saveboxresource resources { \pgf@sys@pdf@possible@resources } #2% + \expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\lastsavedboxresourceindex}% + }% +} +\def\pgfsys@usefading#1#2#3#4#5#6#7{% + \expandafter\ifx\csname pgfsmaskxform@#1\endcsname\relax% + \pgferror{Undefined fading '#1'}% + \else% + {% + \expandafter\ifx\csname pgfsmaks@#1\endcsname\relax% + \pgf@sys@pdf@install@mask{#1}% + \fi% + \pgftransformreset% + \pgftransformcm{#2}{#3}{#4}{#5}{\pgfpoint{#6}{#7}}% + \csname pgfsmasktrans@#1\endcsname% + {% + \pgflowlevelsynccm% + \pgfsys@invoke{/pgfsmask\csname pgfsmask@#1\endcsname\space gs}% + }% + \pgftransforminvert% + \pgflowlevelsynccm% + }% + \fi +} + +\def\pgf@sys@pdf@install@mask#1{% + \setbox\pgfutil@tempboxa=\hbox{\useboxresource\csname pgfsmaskxform@#1\endcsname} + \immediate\saveboxresource% + attr { + /Group + << + /S /Transparency + /CS /DeviceGray + >> + }% << + \pgfutil@tempboxa% + \pgfutil@addpdfresource@extgs{% + /pgfsmask\the\lastsavedboxresourceindex\space + << + /SMask + << + /S /Luminosity + /G \the\lastsavedboxresourceindex\space 0 R + >> + >> } %<< + \expandafter\xdef\csname pgfsmask@#1\endcsname{\the\lastsavedboxresourceindex}% +} + +% +% Transparency groups +% +\def\pgfsys@transparencygroupfrombox#1{% + \pgf@sys@pdf@check@resources% + \saveboxresource + attr { /Group << /S /Transparency + /I \ifpgfsys@transparency@group@isolated true \else false \fi + /K \ifpgfsys@transparency@group@knockout true \else false \fi >> } %<< + resources { \pgf@sys@pdf@possible@resources } + #1% + \setbox#1=\hbox{\useboxresource\lastsavedboxresourceindex}% +} + + + + +% +% Resource management +% + +\def\pgf@sys@setuppdfresources@plain{% + % This command will setup pdf resource in plain and in latex + % mode. ConTeXt has its own handler + % Page resources (they are kept in objects and only written at the + % very end) + \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@extgs@objnum{\the\numexpr\pdffeedback lastobj\relax} + \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@pattern@objnum{\the\numexpr\pdffeedback lastobj\relax} + \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@colrospaces@objnum{\the\numexpr\pdffeedback lastobj\relax} + \def\pgf@sys@pdf@possible@resources{% + /ColorSpace \pgf@sys@pdf@colrospaces@objnum\space 0 R + /Pattern \pgf@sys@pdf@pattern@objnum\space 0 R + /ExtGState \pgf@sys@pdf@extgs@objnum\space 0 R + } + \let\pgf@sys@pdf@check@resources=\relax% + \def\pgf@sys@pdf@install@pageresources{ + { + \edef\temp{ + \pgf@sys@pdf@possible@resources + } + \expandafter\global\expandafter\pdfvariable pageresources\expandafter{\temp} + } + } + \pgf@sys@pdf@install@pageresources + \expandafter\pgfutil@everybye\expandafter{% + \the\pgfutil@everybye% + \immediate \pdfextension obj useobjnum \pgf@sys@pdf@extgs@objnum {<<\pgf@sys@pgf@resource@list@extgs>>}%<< + \immediate \pdfextension obj useobjnum \pgf@sys@pdf@pattern@objnum {<<\pgf@sys@pgf@resource@list@patterns>>}%<< + \immediate \pdfextension obj useobjnum \pgf@sys@pdf@colrospaces@objnum {<<\pgf@sys@pgf@resource@list@colorspaces>>}%<< + } + \let\pgf@sys@pgf@resource@list@extgs=\pgfutil@empty% + \let\pgf@sys@pgf@resource@list@patterns=\pgfutil@empty% + \let\pgf@sys@pgf@resource@list@colorspaces=\pgfutil@empty% + \def\pgf@sys@addpdfresource@extgs@plain##1{\xdef\pgf@sys@pgf@resource@list@extgs{\pgf@sys@pgf@resource@list@extgs\space##1}} + \def\pgf@sys@addpdfresource@patterns@plain##1{\xdef\pgf@sys@pgf@resource@list@patterns{\pgf@sys@pgf@resource@list@patterns\space##1}} + \def\pgf@sys@addpdfresource@colorspaces@plain##1{\xdef\pgf@sys@pgf@resource@list@colorspaces{\pgf@sys@pgf@resource@list@colorspaces\space##1}} +} +\pgfutil@setuppdfresources % possibly call the above + +\pgfutil@addpdfresource@colorspaces{ /pgfprgb [/Pattern /DeviceRGB] } + +\def\pgfsys@color@unstacked#1{% + \pdfextension literal{\csname\string\color@#1\endcsname}% +} + +\endinput + + +%%% Local Variables: +%%% mode: latex +%%% End: diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex index e3a6cfabb32..26c80cbe799 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex @@ -176,14 +176,13 @@ % It accepts the following formats: % \pgfplotscreateplotcyclelist{name}{[of colormap]}% % \pgfplotscreateplotcyclelist{name}{[of colormap=<colormap name>]}% -% \pgfplotscreateplotcyclelist{name}{[colors of colormap={<list>}{<colormap name>}]}% -% \pgfplotscreateplotcyclelist{name}{[indices of colormap={<list>}{<colormap name>}]}% +% \pgfplotscreateplotcyclelist{name}{[colors of colormap={<list> of <colormap name>}]}% +% \pgfplotscreateplotcyclelist{name}{[indices of colormap={<list> of <colormap name>}]}% +% \pgfplotscreateplotcyclelist{name}{[* of colormap as it is also available inside of colormap definitions]} % \pgfplotscreateplotcyclelist{name}{comma-separated-list} % \pgfplotscreateplotcyclelist{name}{'\\'-separated list(requires the last item to be terminated by '\\')} \def\pgfplotscreateplotcyclelist#1#2{% - \pgfkeysinterruptkeyfilter \pgfplotscreateplotcyclelist@check@specials{#1}{#2}#2\pgfplots@EOI% - \endpgfkeysinterruptkeyfilter }% \def\pgfplotscreateplotcyclelist@check@specials#1#2{% @@ -194,13 +193,39 @@ }% }% \def\pgfplotscreateplotcyclelist@check@specials@#1[#2]{% - \pgfqkeys{/pgfplots/@cycle}{result name={#1},#2}% + % the 'of colormap' feature uses the very same functionality as + % the related functionality in colormap definitions. + % We only replace two routines: + % + \begingroup + \let\pgfplots@createcolormap@special@process@single@define=\pgfplots@createcolormap@special@process@single@define@CYCLE + \let\pgfplots@createcolormap@special@process@list@separator=\pgfplots@createcolormap@special@process@list@separator@CYCLE + \pgfplots@of@colormap@getresult{#2}% + \global\let\pgfplots@glob@TMPa=\pgfplotsretval + \endgroup + % + \t@pgfplots@tokb={#1}% + \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% + \edef\pgfplots@loc@TMPa{\noexpand\pgfplotscreateplotcyclelist{\the\t@pgfplots@tokb}{\the\t@pgfplots@toka}}% +%\message{#2->^^J \meaning\pgfplots@loc@TMPa^^J}% + \pgfplots@loc@TMPa + % + % FIXME implement: + %-------------------------------------------------- + % \ifnum\pgfplots@glob@TMPb>\pgfkeysvalueof{/pgfplots/@cycle/max size} % + % % cycle lists have quadratic runtime. Use small ones! + % \pgfplotswarning{cycle list size limit reached}\pgfeov + % \breakforeach + % \fi + %-------------------------------------------------- + % \pgfutil@ifnextchar\pgfplots@EOI{% \pgfplots@gobble@until@EOI }{% \pgfplotscreateplotcyclelist@check@specials@gobble@error{#2}% }% }% + \def\pgfplotscreateplotcyclelist@check@specials@gobble@error#1#2\pgfplots@EOI{% \t@pgfplots@tokb={[#1]}% \t@pgfplots@toka={#2}% @@ -210,61 +235,8 @@ \expandafter\pgfplots@assign@list\csname pgfp@cyclist@\string#1@\endcsname{#2}% } -\def\pgfplotscreateplotcyclelist@check@specials@process@colormap@conversion#1#2{% - \pgfplots@color@of@colormap@parse{#1}% - \begingroup - \gdef\pgfplots@glob@TMPa{}% - \gdef\pgfplots@glob@TMPb{0}% - \def\pgfplots@loc@TMPa{\foreach \x in }% - \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@color@of@colormap@value}{% - \t@pgfplots@tokb=\expandafter{\pgfplots@color@of@colormap@name}% - \edef\currentValue{#2=\x\space of \the\t@pgfplots@tokb}% - % - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% - \t@pgfplots@tokb=\expandafter{\currentValue\\}% - \xdef\pgfplots@glob@TMPa{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% - % - \pgfplotsutil@advancestringcounter@global\pgfplots@glob@TMPb - \ifnum\pgfplots@glob@TMPb>\pgfkeysvalueof{/pgfplots/@cycle/max size} % - % cycle lists have quadratic runtime. Use small ones! - \pgfplotswarning{cycle list size limit reached}\pgfeov - \breakforeach - \fi - }% - \endgroup - \pgfkeysgetvalue{/pgfplots/@cycle/result name}\pgfplots@color@of@colormap@name - \t@pgfplots@tokb=\expandafter{\pgfplots@color@of@colormap@name}% - \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% - \edef\pgfplots@loc@TMPa{\noexpand\pgfplotscreateplotcyclelist{\the\t@pgfplots@tokb}{\the\t@pgfplots@toka}}% -%\message{got \meaning\pgfplots@loc@TMPa^^J}% - \pgfplots@loc@TMPa -}% - \pgfqkeys{/pgfplots/@cycle}{% - result name/.initial=, max size/.initial=80, - of colormap/.code={% - \pgfplotsutilifstringequal{#1}{\pgfkeysnovalue}{% - \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa - \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}% - \edef\pgfplots@loc@TMPa{% - \noexpand\pgfkeysalso{indices of colormap={0,...,\pgfplotscolormaplastindexof{\pgfplots@loc@TMPa}} of {\the\t@pgfplots@toka}}% - }% - \pgfplots@loc@TMPa - }{% - \pgfplotscolormapifdefined{#1}{% - \pgfkeysalso{indices of colormap={0,...,\pgfplotscolormaplastindexof{#1}} of {#1}}% - }{% - \pgfplots@error{There is no such colormap '#1'. Maybe you need to write \string\pgfplotsset{#1} first?}% - }% - }% - },% - colors of colormap/.code={% - \pgfplotscreateplotcyclelist@check@specials@process@colormap@conversion{#1}{color of colormap}% - }, - indices of colormap/.code={% - \pgfplotscreateplotcyclelist@check@specials@process@colormap@conversion{#1}{index of colormap}% - }, } \pgfplotscreateplotcyclelist{black white}{% @@ -696,19 +668,50 @@ }% % \if m\pgfplots@color@of@colormap@access - \expandafter\pgfplotscolormapfind\expandafter[\pgfplotspointmetatransformedrange] - [1.0] - {\pgfplots@color@of@colormap@value} - {\pgfplots@color@of@colormap@name} + % colormap access=map + \expandafter\pgfplotscolormapfind\expandafter[\pgfplotspointmetatransformedrange]% + {\pgfplots@color@of@colormap@value}% + {\pgfplots@color@of@colormap@name}% \else - \pgfplotscolormapgetindex{\pgfplots@color@of@colormap@value}{\pgfplots@color@of@colormap@name}% + \if c\pgfplots@color@of@colormap@access + % colormap access=piecewise constant + \expandafter\pgfplotscolormapfindpiecewiseconst\expandafter[\pgfplotspointmetatransformedrange]% + {\pgfplots@color@of@colormap@value}% + {\pgfplots@color@of@colormap@name}% + \else + % colormap access=direct + \pgfplotscolormapgetindex{\pgfplots@color@of@colormap@value}{\pgfplots@color@of@colormap@name}% + \fi \fi }% + +\def\pgfplots@createcolormap@special@process@list@separator@CYCLE{\\}% +\def\pgfplots@createcolormap@special@process@single@define@CYCLE{% + \edef\pgfplotsretval{% + /tikz/color/.define=% + {.}% + {\csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}% + {\pgfmathresult},% + /tikz/color=.,% + }% +}% \def\pgfplots@color@of@colormap#1{% - \pgfplots@color@of@colormap@define{#1}% - \def\pgfplots@loc@TMPb{\pgfutil@definecolor{.}{\csname pgfpl@cm@\pgfplots@color@of@colormap@name @colspace\endcsname}}% - \expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}% + \begingroup + \def\pgfplots@createcolormap@special@process@single@define{% + \edef\pgfplotsretval{% + \noexpand\pgfutil@definecolor{.}{\csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}{\pgfmathresult}% + }% + \let\pgfplots@createcolormap@special@process@single@define=\relax + }% + \pgfplots@of@colormap@getresult{#1}% + \global\let\pgfplots@glob@TMPa=\pgfplotsretval + \endgroup + \pgfplots@glob@TMPa \tikzset{color=.}% + %\pgfplots@color@of@colormap@define{#1}% + %\def\pgfplots@loc@TMPb{\pgfutil@definecolor{.}{\csname pgfpl@cm@\pgfplots@color@of@colormap@name @colspace\endcsname}}% + %\expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}% + %\tikzset{color=.}% } \newif\ifpgfplots@stackedmode @@ -1144,10 +1147,6 @@ xmax=1, ymin=\pgfkeysvalueof{/pgfplots/point meta min}, ymax=\pgfkeysvalueof{/pgfplots/point meta max}, - plot graphics/xmin=0,% - plot graphics/xmax=1, - plot graphics/ymin=\pgfkeysvalueof{/pgfplots/point meta min}, - plot graphics/ymax=\pgfkeysvalueof{/pgfplots/point meta max}, height=\pgfkeysvalueof{/pgfplots/parent axis height},% width=\pgfkeysvalueof{/pgfplots/colorbar/width}, xtick=\empty, @@ -1177,10 +1176,6 @@ ymax=1, xmin=\pgfkeysvalueof{/pgfplots/point meta min}, xmax=\pgfkeysvalueof{/pgfplots/point meta max}, - plot graphics/ymin=0,% - plot graphics/ymax=1, - plot graphics/xmin=\pgfkeysvalueof{/pgfplots/point meta min}, - plot graphics/xmax=\pgfkeysvalueof{/pgfplots/point meta max}, width=\pgfkeysvalueof{/pgfplots/parent axis width},% height=\pgfkeysvalueof{/pgfplots/colorbar/width}, xticklabel pos=left, @@ -1188,46 +1183,74 @@ colorbar horizontal/lowlevel, }% },% - % You might wonder why this special treatment with '/lowlevel' - % keys is necessary. Well, It turned out that using '##' inside of - % styles is incompatible with '.add code' -- and therefor also - % with '.append style'. This here is a work-around which works. - /pgfplots/colorbar vertical/lowlevel/.style={% - /pgfplots/colorbar addplot=\addplot graphics {};, - plot graphics/lowlevel draw/.code 2 args={% - \if\pgfkeysvalueof{/pgfplots/y dir/value}n% - \pgfplotscolormaptoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##2}\pgfplots@loc@TMPa - \else - \pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##2}\pgfplots@loc@TMPa - \fi - \def\pgfplots@loc@TMPb{\pgfdeclareverticalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}% - \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% - \pgfuseshading{tempshading}% + % + % this here used to be the default up to (and including) pgfplots 1.13. + % But it does not support the following use cases: + % * 'colormap access=const', + % * 'colorbar style={ytick=data}}' + % * CMYK shadings + % -> deprecated. + /pgfplots/colorbar pgfshading/.style={% + /pgfplots/colorbar, + /pgfplots/colorbar/draw/.code={% + \axis[every colorbar,colorbar shift,colorbar=false] + \pgfkeysvalueof{/pgfplots/colorbar addplot}% + \endaxis },% - }, - /pgfplots/colorbar horizontal/lowlevel/.style={% - /pgfplots/colorbar addplot=\addplot graphics {};, - plot graphics/lowlevel draw/.code 2 args={% - \if\pgfkeysvalueof{/pgfplots/x dir/value}n% - \pgfplotscolormaptoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##1}\pgfplots@loc@TMPa - \else - \pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##1}\pgfplots@loc@TMPa - \fi - \def\pgfplots@loc@TMPb{\pgfdeclarehorizontalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}% - \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% - \pgfuseshading{tempshading}% + % You might wonder why this special treatment with '/lowlevel' + % keys is necessary. Well, It turned out that using '##' inside of + % styles is incompatible with '.add code' -- and therefor also + % with '.append style'. This here is a work-around which works. + /pgfplots/colorbar vertical/lowlevel/.style={% + /pgfplots/colorbar addplot=\addplot graphics {};, + plot graphics/xmin=0,% + plot graphics/xmax=1, + plot graphics/ymin=\pgfkeysvalueof{/pgfplots/point meta min}, + plot graphics/ymax=\pgfkeysvalueof{/pgfplots/point meta max}, + plot graphics/lowlevel draw/.code 2 args={% + \if\pgfkeysvalueof{/pgfplots/y dir/value}n% + \pgfplotscolormaptoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{####2}\pgfplots@loc@TMPa + \else + \pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{####2}\pgfplots@loc@TMPa + \fi + \def\pgfplots@loc@TMPb{\pgfdeclareverticalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% + \pgfuseshading{tempshading}% + },% + }, + /pgfplots/colorbar horizontal/lowlevel/.style={% + /pgfplots/colorbar addplot=\addplot graphics {};, + plot graphics/ymin=0,% + plot graphics/ymax=1, + plot graphics/xmin=\pgfkeysvalueof{/pgfplots/point meta min}, + plot graphics/xmax=\pgfkeysvalueof{/pgfplots/point meta max}, + plot graphics/lowlevel draw/.code 2 args={% + \if\pgfkeysvalueof{/pgfplots/x dir/value}n% + \pgfplotscolormaptoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{####1}\pgfplots@loc@TMPa + \else + \pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{####1}\pgfplots@loc@TMPa + \fi + \def\pgfplots@loc@TMPb{\pgfdeclarehorizontalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}% + \pgfuseshading{tempshading}% + },% },% - },% + }, + /pgfplots/colorbar addplot/.initial=\pgfplots@error{COLORBAR SYSTEM UNDEFINED}, + /pgfplots/colorbar/draw/.code={\pgfplots@error{COLORBAR SYSTEM UNDEFINED}}, + % --> the default is now 'colorbar sampled', see below: + % + % instantiate SOME defaults: /pgfplots/colorbar right, /pgfplots/colorbar=false, + % /pgfplots/colorbar style/.style={/pgfplots/every colorbar/.append style={#1}}, /pgfplots/colorbar/width/.initial=0.5cm, - /pgfplots/colorbar addplot/.initial=\addplot graphics {};, - /pgfplots/colorbar/draw/.code={% - \axis[every colorbar,colorbar shift,colorbar=false] - \pgfkeysvalueof{/pgfplots/colorbar addplot}% - \endaxis - },% + % see \pgfplotscolorbardrawstandalone + /pgfplots/colorbar/standalone draw/.code={% + \pgfplots@colorbar@get@rid@of@at@parent@axis + \pgfplots@colorbar@draw@ + }, /pgfplots/every colorbar sampled line/.style={help lines}, /pgfplots/colorbar sampled line style/.style={/pgfplots/every colorbar sampled line/.append style={#1}}, /pgfplots/colorbar sampled line/.style={% @@ -1290,8 +1313,89 @@ }, }, % + % A style which display exactly 1 tick label for each distinct color. It is similar to 'colorbar as palette'. + % It is useful for non-uniform colormaps + /pgfplots/colorbar as legend/.style={ + /pgfplots/colorbar sampled={},% + /pgfplots/colorbar style={% + % FIXME: these styles could make use of some tuning ... + ticklabel style={/pgf/number format/precision=3,/pgf/number format/relative*=3}, + }, + /pgfplots/colorbar horizontal/lowlevel/.append code={% + \def\pgfplots@colorbar@as@legend@orientation{x}% + }, + /pgfplots/colorbar vertical/lowlevel/.append code={% + \def\pgfplots@colorbar@as@legend@orientation{y}% + }, + % + % ensure that our values + % \pgfplots@colorbar@as@legend@orientation are available while + % pgfplots processes the key filtering - otherwise we get + % "undefined keys" below + /pgfplots/colorbar horizontal/lowlevel/.belongs to family=/pgfplots/scale, + /pgfplots/colorbar vertical/lowlevel/.belongs to family=/pgfplots/scale, + % + /pgfplots/colorbar/draw/.add code={% + \begingroup + \pgfkeys{/pgf/fpu}% + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@CM + \begingroup + \pgfplotsset{every colorbar}% + \pgfmath@smuggleone\pgfplots@colorbar@as@legend@orientation + \endgroup + \pgfplotscolormapgetpositions[{\pgfkeysvalueof{/pgfplots/point meta min}}:{\pgfkeysvalueof{/pgfplots/point meta max}}]{\pgfplots@CM}% + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplotsarraynew\noexpand\positions{\pgfplotsretval}% + }% + \pgfplots@loc@TMPa + % + \c@pgf@countd=\pgfplotscolormaplastindexof{\pgfplots@CM}\relax + \edef\pgfplots@colorcount{\the\c@pgf@countd}% + \advance\c@pgf@countd by-1 % + % XXX : this here is tailored for use with + % * 'colormap access=const' and + % * 'sample for=const' + % where the last color is redundant and must not be + % displayed in 'colorbar as legend' --> make it more + % general! + \edef\pgfplots@colorcount@minus@one{\the\c@pgf@countd}% + % + % accumulate a list of formatted positions into this + % variable: + \def\pgfplots@loc@TMPc{}% + \pgfplotsforeachungrouped \x in {0,...,\pgfplots@colorcount} {% + \pgfplotsarrayselect{\x}\of\positions\to\pgfplotsretval + \edef\pgfplots@loc@TMPa{\noexpand\pgfmathprintnumber{\pgfplotsretval}} + \t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPc}% + \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}% + \edef\pgfplots@loc@TMPc{\the\t@pgfplots@toka \the\t@pgfplots@tokb,}% + }% + \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPc}% + \xdef\pgfplots@glob@TMPa{% + \noexpand\pgfplotsset{% + % this FORGETS the colormap positions intentionally... + colormap={@temp@CM}{indices of colormap={0,...,\pgfplots@colorcount@minus@one of \pgfplots@CM}}, + % ... and normalizes the number range. + point meta min=0,point meta max=1000, + colorbar style={ + surf,shader=interp, + colormap access=const, + \pgfplots@colorbar@as@legend@orientation tick=data, + % here we add the positions back into the + % tick label: + \pgfplots@colorbar@as@legend@orientation ticklabels={\the\t@pgfplots@tokb}, + }, + }% + }% + \endgroup + \pgfplots@glob@TMPa + }{% + % no 'append' section + },% + }, + % /pgfplots/colorbar sampled/.style={% - colorbar, + /pgfplots/colorbar, /pgfplots/colorbar/draw/.code={% \axis[ view={0}{90}, @@ -2209,6 +2313,9 @@ /pgfplots/samples at/.initial=,% empty -> use value of /tikz/samples at! /pgfplots/samples/.initial=,% empty -> use /tikz/samples! /pgfplots/samples y/.initial=,% empty -> use the same as 'samples'. For use in mesh plots. + /pgfplots/samples at colormap pos/.code={% + \pgfplots@colorbar@positions@to@samplesat + }, /pgfplots/variable/.code={\pgfkeysalso{/tikz/variable={#1}}}, /pgfplots/variable y/.initial=\y,% /pgfplots/sample dim/.initial=auto, @@ -3174,8 +3281,14 @@ % % ... just in case someone uses xbar stacked together with % 'bar shift': - /pgfplots/every node near coord/.append style={yshift={\pgfplotbarshift}},% + /pgfplots/every node near coord/.append style={% + /pgfplots/every node near coord bar shift=y, + /pgfplots/every node near coord bar shift/.code=, + },% }, + % + /pgfplots/every node near coord bar shift/.style={#1shift={\pgfplotbarshift}},% + % % Replaces the 'nodes near coords' CONFIGURATION by one suitable % for ybar stacked /pgfplots/nodes near coords ybar stacked configuration/.style={ @@ -3209,7 +3322,10 @@ % % ... just in case someone uses ybar stacked together with % 'bar shift': - /pgfplots/every node near coord/.append style={xshift={\pgfplotbarshift}},% + /pgfplots/every node near coord/.append style={% + /pgfplots/every node near coord bar shift=x, + /pgfplots/every node near coord bar shift/.code=, + },% }, % % @@ -3327,7 +3443,10 @@ \pgfusepath{stroke}}% }; },% - /pgfplots/every node near coord/.append style={xshift={\pgfplotbarshift}},% + /pgfplots/every node near coord/.append style={% + /pgfplots/every node near coord bar shift=x, + /pgfplots/every node near coord bar shift/.code=, + },% /tikz/ybar, }, /pgfplots/ybar/.default=2pt, @@ -3361,7 +3480,10 @@ \pgfusepath{stroke}}% }; },% - /pgfplots/every node near coord/.append style={yshift={\pgfplotbarshift}},% + /pgfplots/every node near coord/.append style={% + /pgfplots/every node near coord bar shift=y, + /pgfplots/every node near coord bar shift/.code=, + },% /tikz/xbar, }, /pgfplots/xbar/.default=2pt, @@ -3865,6 +3987,8 @@ /pgfplots/colormap access/direct/.code={\def\pgfplots@colormap@access{d}},% /pgfplots/colormap access/map/.code={\def\pgfplots@colormap@access{m}},% /pgfplots/colormap access/piecewise constant/.code={\def\pgfplots@colormap@access{c}},% + /pgfplots/colormap access/piecewise const/.code= {\def\pgfplots@colormap@access{c}},% + /pgfplots/colormap access/const/.code= {\def\pgfplots@colormap@access{c}},% /pgfplots/colormap access/piecewise linear/.style={/pgfplots/colormap access/map}, /pgfplots/colormap access/map,% %/pgfplots/colormap default colorspace/.initial=auto,% declared in pgfplotscolormap.code.tex @@ -3879,6 +4003,19 @@ \pgfkeysalso{#1}% \pgfkeyslet{/pgfplots/colormap name}\pgfplots@ensure@old@cm }, + % a backwards compatibility switch: + /pgfplots/colormap uniform/.is choice, + /pgfplots/colormap uniform/always/.code={\def\pgfplots@colormap@uniform@choice{0}}, + /pgfplots/colormap uniform/if requested/.code={\def\pgfplots@colormap@uniform@choice{1}}, + /pgfplots/colormap uniform/always, + % + % #1: a number X with 0<= x <=0.9 which defines the relative size + % of the extra interval used for 'colormap access=piecewise constant' + % The value #1=0 disables the extra interval. + /pgfplots/colormap access/extra interval width/.code={% + \pgfplotscolormapsetadditionalintervalwidth{\pgfkeysvalueof{/pgfplots/colormap name}}{#1}% + }, + % /pgfplots/colormap/hot/.style={ % attention: copied from pgfplots.colormap.code.tex: /pgfplots/colormap={hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)} @@ -3939,20 +4076,29 @@ % color of colormap={300} % color of colormap={300 of viridis} /pgfplots/color of colormap/.code={% - % colormap access=map - \def\pgfplots@color@of@colormap@access{m}% - \pgfplots@color@of@colormap{#1}% + \pgfplots@color@of@colormap{color of colormap={#1}}% + },% + /tikz/color of colormap/.style={/pgfplots/color of colormap={#1}}, + % const color of colormap={300} + % const color of colormap={300 of viridis} + /pgfplots/const color of colormap/.code={% + \pgfplots@color@of@colormap{const color of colormap={#1}}% },% /tikz/color of colormap/.style={/pgfplots/color of colormap={#1}}, % index of colormap={4} % index of colormap={4 of viridis} /pgfplots/index of colormap/.code={% - % colormap access=direct - \def\pgfplots@color@of@colormap@access{d}% - \pgfplots@color@of@colormap{#1}% + \pgfplots@color@of@colormap{index of colormap={#1}}% },% /tikz/index of colormap/.style={/pgfplots/index of colormap={#1}}, % + % #1: the target color name + % #2: the color space (like 'rgb') + % #3: the color components + /tikz/color/.define/.code args={#1#2#3}{% + \pgfutil@definecolor{#1}{#2}{#3}% + }, + % %% /pgfplots/scatter/.is choice, /pgfplots/scatter/false/.code={% @@ -4159,7 +4305,7 @@ /pgfplots/compat/anchors/1.11/.style= {/pgfplots/compat/anchors/1.3},% /pgfplots/compat/anchors/1.12/.style= {/pgfplots/compat/anchors/1.3},% /pgfplots/compat/anchors/1.13/.style= {/pgfplots/compat/anchors/1.3,/pgfplots/correct polar positioning=true},% - /pgfplots/compat/anchors/newest/.style= {/pgfplots/compat/anchors/1.3},% + /pgfplots/compat/anchors/1.14/.style= {/pgfplots/compat/anchors/1.13},% /pgfplots/compat/anchors/default/.style={/pgfplots/compat/anchors/1.3},% % /pgfplots/compat/empty line/.is choice, @@ -4176,7 +4322,7 @@ /pgfplots/compat/empty line/1.11/.style= {/pgfplots/compat/empty line/1.4},% /pgfplots/compat/empty line/1.12/.style= {/pgfplots/compat/empty line/1.4},% /pgfplots/compat/empty line/1.13/.style= {/pgfplots/compat/empty line/1.4},% - /pgfplots/compat/empty line/newest/.style= {/pgfplots/compat/empty line/1.4},% + /pgfplots/compat/empty line/1.14/.style= {/pgfplots/compat/empty line/1.4},% /pgfplots/compat/empty line/default/.style= {/pgfplots/compat/empty line/1.4},% % /pgfplots/compat/path replacement/.is choice, @@ -4193,7 +4339,7 @@ /pgfplots/compat/path replacement/1.11/.style= {/pgfplots/compat/path replacement/1.5.1}, /pgfplots/compat/path replacement/1.12/.style= {/pgfplots/compat/path replacement/1.5.1}, /pgfplots/compat/path replacement/1.13/.style= {/pgfplots/compat/path replacement/1.5.1}, - /pgfplots/compat/path replacement/newest/.style= {/pgfplots/compat/path replacement/1.5.1},% + /pgfplots/compat/path replacement/1.14/.style= {/pgfplots/compat/path replacement/1.5.1}, /pgfplots/compat/path replacement/default/.style= {/pgfplots/compat/path replacement/pre 1.3},% % /pgfplots/compat/pgfpoint substitution/.is choice, @@ -4210,7 +4356,7 @@ /pgfplots/compat/pgfpoint substitution/1.11/.code= {\pgfplots@substitute@pgfpointtrue}, /pgfplots/compat/pgfpoint substitution/1.12/.style= {/pgfplots/compat/pgfpoint substitution/1.11}, /pgfplots/compat/pgfpoint substitution/1.13/.style= {/pgfplots/compat/pgfpoint substitution/1.11}, - /pgfplots/compat/pgfpoint substitution/newest/.style= {/pgfplots/compat/pgfpoint substitution/1.11},% + /pgfplots/compat/pgfpoint substitution/1.14/.style= {/pgfplots/compat/pgfpoint substitution/1.11}, /pgfplots/compat/pgfpoint substitution/default/.style= {/pgfplots/compat/pgfpoint substitution/pre 1.3},% %ellipse/.is if=pgfplots@path@replace@ellipse, % @@ -4237,7 +4383,7 @@ /pgfplots/compat/labels/1.11/.style= {/pgfplots/compat/labels/1.8},% /pgfplots/compat/labels/1.12/.style= {/pgfplots/compat/labels/1.8},% /pgfplots/compat/labels/1.13/.style= {/pgfplots/compat/labels/1.8},% - /pgfplots/compat/labels/newest/.style= {/pgfplots/compat/labels/1.8},% + /pgfplots/compat/labels/1.14/.style= {/pgfplots/compat/labels/1.8},% /pgfplots/compat/labels/default/.style= {/pgfplots/compat/labels/pre 1.3},% maintain backwards compatibility % /pgfplots/compat/bar nodes/.is choice, @@ -4270,6 +4416,9 @@ /pgfplots/stacked since 1.9/.style={ /pgfplots/stacked ignores zero=true,% }, + /pgfplots/stacked since 1.13/.style={ + /pgfplots/stack negative=on previous,% backwards compatible. + },% /pgfplots/activate nodes near coords xbar stacked/.style={ /pgfplots/nodes near coords xbar stacked configuration, }, @@ -4286,7 +4435,7 @@ /pgfplots/stack negative=separate, },% },% - /pgfplots/compat/bar nodes/newest/.style= {/pgfplots/compat/bar nodes/1.9},% + /pgfplots/compat/bar nodes/1.14/.style= {/pgfplots/compat/bar nodes/1.13},% /pgfplots/compat/bar nodes/default/.style= {/pgfplots/compat/bar nodes/pre 1.3},% maintain backwards compatibility /pgfplots/compat/bar nodes/default, % @@ -4318,7 +4467,7 @@ /pgfplots/compat/scaling/1.11/.style={/pgfplots/compat/scaling/1.6}, /pgfplots/compat/scaling/1.12/.style={/pgfplots/compat/scaling/1.6}, /pgfplots/compat/scaling/1.13/.style={/pgfplots/compat/scaling/1.6}, - /pgfplots/compat/scaling/newest/.style={/pgfplots/compat/scaling/1.6}, + /pgfplots/compat/scaling/1.14/.style={/pgfplots/compat/scaling/1.6}, /pgfplots/compat/scaling/default/.style={/pgfplots/compat/scaling/1.4}, % /pgfplots/compat/scale mode/.is choice, @@ -4335,7 +4484,7 @@ /pgfplots/compat/scale mode/1.11/.style={/pgfplots/compat/scale mode/1.6}, /pgfplots/compat/scale mode/1.12/.style={/pgfplots/compat/scale mode/1.6}, /pgfplots/compat/scale mode/1.13/.style={/pgfplots/compat/scale mode/1.6}, - /pgfplots/compat/scale mode/newest/.style={/pgfplots/compat/scale mode/1.6}, + /pgfplots/compat/scale mode/1.14/.style={/pgfplots/compat/scale mode/1.6}, /pgfplots/compat/scale mode/default/.style={/pgfplots/compat/scale mode/1.5}, % % @@ -4353,7 +4502,7 @@ /pgfplots/compat/plot3graphics/1.11/.style= {/pgfplots/compat/plot3graphics/1.6},% /pgfplots/compat/plot3graphics/1.12/.style= {/pgfplots/compat/plot3graphics/1.6},% /pgfplots/compat/plot3graphics/1.13/.style= {/pgfplots/compat/plot3graphics/1.6},% - /pgfplots/compat/plot3graphics/newest/.style= {/pgfplots/compat/plot3graphics/1.6},% + /pgfplots/compat/plot3graphics/1.14/.style= {/pgfplots/compat/plot3graphics/1.6},% /pgfplots/compat/plot3graphics/default/.style= {/pgfplots/compat/plot3graphics/1.5},% % % ATTENTION: there is a compatibility issue which slipped through @@ -4397,7 +4546,7 @@ /pgfplots/compat/bar width by units/1.11/.style= {/pgfplots/compat/bar width by units/1.7}, /pgfplots/compat/bar width by units/1.12/.style= {/pgfplots/compat/bar width by units/1.7}, /pgfplots/compat/bar width by units/1.13/.style= {/pgfplots/compat/bar width by units/1.7}, - /pgfplots/compat/bar width by units/newest/.style= {/pgfplots/compat/bar width by units/1.7}, + /pgfplots/compat/bar width by units/1.14/.style= {/pgfplots/compat/bar width by units/1.7}, /pgfplots/compat/bar width by units/default/.style={/pgfplots/compat/bar width by units/pre 1.3}, % /pgfplots/compat/BB/.is choice, @@ -4414,7 +4563,7 @@ /pgfplots/compat/BB/1.11/.style= {/pgfplots/compat/BB/1.8},% /pgfplots/compat/BB/1.12/.style= {/pgfplots/compat/BB/1.8},% /pgfplots/compat/BB/1.13/.style= {/pgfplots/compat/BB/1.8},% - /pgfplots/compat/BB/newest/.style= {/pgfplots/compat/BB/1.8}, + /pgfplots/compat/BB/1.14/.style= {/pgfplots/compat/BB/1.8},% /pgfplots/compat/BB/default/.style={/pgfplots/compat/BB/pre 1.3}, % /pgfplots/compat/general/.is choice, @@ -4424,7 +4573,10 @@ /pgfplots/correct shader flat=false, /pgfplots/correct sampling=false, /pgfplots/lua backend=false, + /pgfplots/colormap uniform=always, /pgfplots/compat/library hook={statistics}{/pgfplots/boxplot/estimator=legacy,/pgfplots/boxplot/ensure mark=false}, + /pgfplots/colorbar pgfshading, + /pgfplots/colorbar=false, },% /pgfplots/compat/general/1.3/.style= {/pgfplots/compat/general/pre 1.3}, /pgfplots/compat/general/1.4/.style= {/pgfplots/compat/general/pre 1.3},% @@ -4452,8 +4604,17 @@ /pgfplots/compat/general/1.12, /pgfplots/correct shader flat=true, /pgfplots/correct sampling=true, + /pgfplots/colormap uniform=always, + },% + /pgfplots/compat/general/1.14/.style= {% + /pgfplots/compat/general/1.13, + /pgfplots/colormap uniform=if requested, + % no -- do _not_ activate that here: it is correct and + % simplifies the code, but many viewers (pdf.js, evince, + % sumatrapdf) are better off with pgfshadings: + %/pgfplots/colorbar sampled={surf,shader=interp,samples=2}, + %/pgfplots/colorbar=false, },% - /pgfplots/compat/general/newest/.style= {/pgfplots/compat/general/1.12}, /pgfplots/compat/general/default/.style={/pgfplots/compat/general/1.11}, % /pgfplots/enable tick line clipping/.is if=pgfplots@enable@tick@line@clipping, @@ -4471,23 +4632,65 @@ /pgfplots/compat/show suggested version/.is if=pgfplots@show@suggested@version, /pgfplots/compat/show suggested version=true, /pgfplots/compat/current/.initial=, - /pgfplots/compat/mostrecent/.initial=1.13, - /pgfplots/compat/.style={% - % ATTENTION: *every* /pgfplots/compat/ setting needs to accept - % the same choices due to this construction: - /pgfplots/compat/current=#1,% remember the value - /pgfplots/compat/anchors=#1,% - /pgfplots/compat/labels=#1,% - /pgfplots/compat/empty line=#1,% - /pgfplots/compat/scaling=#1,% - /pgfplots/compat/scale mode=#1,% - /pgfplots/compat/general=#1,% - /pgfplots/compat/BB=#1,% - /pgfplots/compat/path replacement=#1,% - /pgfplots/compat/plot3graphics=#1,% - /pgfplots/compat/bar width by units=#1,% - /pgfplots/compat/bar nodes=#1,% - /pgfplots/compat/pgfpoint substitution=#1,% + /pgfplots/compat/mostrecent/.initial=1.14, + /utils/exec={% + \pgfplotsutilforeachcommasep{% + /pgfplots/compat/current,% + /pgfplots/compat/anchors,% + /pgfplots/compat/labels,% + /pgfplots/compat/empty line,% + /pgfplots/compat/scaling,% + /pgfplots/compat/scale mode,% + /pgfplots/compat/general,% + /pgfplots/compat/BB,% + /pgfplots/compat/path replacement,% + /pgfplots/compat/plot3graphics,% + /pgfplots/compat/bar width by units,% + /pgfplots/compat/bar nodes,% + /pgfplots/compat/pgfpoint substitution,% + }\as\pgfplots@glob@TMPa{% + \ifx\pgfplots@glob@TMPa\pgfutil@empty + \else + \edef\pgfplots@glob@TMPb{% + \noexpand\pgfkeysdef{\pgfplots@glob@TMPa/newest}{% + \noexpand\pgfkeysalso{% + \pgfplots@glob@TMPa/\pgfkeysvalueof{/pgfplots/compat/mostrecent}% + }% + }% + }% + \pgfplots@glob@TMPb + \fi + }% + }, + /pgfplots/compat/.code={% + \def\pgfplots@glob@TMPa{newest}% + \edef\pgfplots@glob@TMPb{#1}% + \ifx\pgfplots@glob@TMPb\pgfplots@glob@TMPa + \edef\pgfplots@glob@TMPa{\noexpand\pgfkeysalso{/pgfplots/compat=\pgfkeysvalueof{/pgfplots/compat/mostrecent}}}% + \pgfplots@glob@TMPa + \else + \pgfkeysifdefined{/pgfplots/compat/general/#1/.@cmd}{% + \pgfkeysalso{% + % ATTENTION: *every* /pgfplots/compat/ setting needs to accept + % the same choices due to this construction: + /pgfplots/compat/current=#1,% remember the value + /pgfplots/compat/anchors=#1,% + /pgfplots/compat/labels=#1,% + /pgfplots/compat/empty line=#1,% + /pgfplots/compat/scaling=#1,% + /pgfplots/compat/scale mode=#1,% + /pgfplots/compat/general=#1,% + /pgfplots/compat/BB=#1,% + /pgfplots/compat/path replacement=#1,% + /pgfplots/compat/plot3graphics=#1,% + /pgfplots/compat/bar width by units=#1,% + /pgfplots/compat/bar nodes=#1,% + /pgfplots/compat/pgfpoint substitution=#1,% + }% + }{% + \pgfplots@error{Sorry, 'compat=#1' is unknown in this context. Please use at most 'compat=\pgfkeysvalueof{/pgfplots/compat/mostrecent}'}% + }% + \fi },% /pgfplots/compat/.default=pre 1.3,% this is used if you type '\pgfplotsset{compat}' without value /pgfplots/compat=default,% this is the initial config. @@ -4564,7 +4767,11 @@ \def\pgfplots@tickwidth{\pgfkeysvalueof{/pgfplots/major tick length}}% \def\pgfplots@subtickwidth{\pgfkeysvalueof{/pgfplots/minor tick length}}% -\pgfkeysgetvalue{/pgfplots/colorbar/draw/.@cmd}\pgfplots@colorbar@draw@defaultimpl +\begingroup +\pgfkeys{/pgfplots/colorbar pgfshading} +\pgfkeysgetvalue{/pgfplots/colorbar/draw/.@cmd}\pgfplots@loc@TMPa +\global\let\pgfplots@colorbar@draw@legacyimpl=\pgfplots@loc@TMPa +\endgroup % call % \pgfkeyslet{.../.@cmd}\pgfplots@cant@set@in@this@context @@ -4660,8 +4867,17 @@ }% \fi \pgfplots@gettikzinternal@keyval{samples at}{tikz@plot@samplesat}{-5,-4.6,...,5}% - \pgfkeyslet{/pgfplots/samples at}{\tikz@plot@samplesat}% - \let\pgfplots@plot@samples@at=\tikz@plot@samplesat + % + % check if it was a domain. This simplifies LUA code: + \pgfplotsforeachtodomain{\tikz@plot@samplesat}% + \ifx\pgfplotsretval\pgfutil@empty + \pgfkeyslet{/pgfplots/samples at}{\tikz@plot@samplesat}% + \let\pgfplots@plot@samples@at=\tikz@plot@samplesat + \else + \let\pgfplots@plot@domain=\pgfplotsretval + \let\pgfplots@plot@samples=\pgfplotsretvalb + \pgfkeyslet{/pgfplots/samples}{\pgfplots@plot@samples}% + \fi \else % routines should use \pgfplots@plot@samples@at. \fi @@ -4750,6 +4966,11 @@ % #2: the 'b' axis on the orentied surface (the same as \pgfplotspointonorientedsurfaceB) \def\pgfplots@drawaxis@innerlines@onorientedsurf#1#2#3{% \if2\csname pgfplots@#1axislinesnum\endcsname + \pgfplotsgetlayerforstyle{% + every inner #1 axis line, + }% + \pgfplotsonlayer{\pgfplotsretval}{inner #1 axis line}% + % \draw[/pgfplots/every inner #1 axis line,% decorate,% #1discont,% @@ -4767,6 +4988,8 @@ \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}% \endpgfextra ; + % + \endpgfplotsonlayer \fi }% @@ -4787,6 +5010,11 @@ /pgfplots/every outer #1 axis line, #1discont,decoration={pre length/.expand twice=\csname #1disstart\endcsname, post length/.expand twice=\csname #1disend\endcsname}% }% + \pgfplotsgetlayerforstyle{% + every outer #1 axis line, + }% + \pgfplotsonlayer{\pgfplotsretval}{outer #1 axis line}% + % \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% \expandafter\draw\expandafter[\pgfplots@drawaxis@outerlines@separate@onorientedsurf@opts] decorate { \pgfextra @@ -4807,6 +5035,8 @@ \endpgfextra }; }{}% + % + \endpgfplotsonlayer \fi }% @@ -4828,6 +5058,12 @@ \fi \fi \ifpgfplots@loc@tmp + \pgfplotsgetlayerforstyle{% + every outer x axis line, + every outer y axis line, + }% + \pgfplotsonlayer{\pgfplotsretval}{boxed axis line}% + % \draw[ /pgfplots/every outer x axis line, % using these outer styles is only useful in conjunction with 'separate axis lines=true' /pgfplots/every outer y axis line] @@ -4871,6 +5107,8 @@ \fi \fi ;% + % + \endpgfplotsonlayer \fi }% @@ -9915,11 +10153,7 @@ \ifx\pgfplots@colorbar@toname\pgfutil@empty \else \toks1={% - \pgfkeysgetvalue{/pgfplots/at/.@cmd}\pgfplots@at@orig - \pgfkeyslet{/pgfplots/at/orig/.@cmd}\pgfplots@at@orig - % - \pgfkeysgetvalue{/pgfplots/colorbar to name/at/.@cmd}\pgfplots@colorbar@toname@at - \pgfkeyslet{/pgfplots/at/.@cmd}\pgfplots@colorbar@toname@at + \pgfplots@colorbar@get@rid@of@at@parent@axis }% \pgfplots@colorbar@foreach@saved@key{% \pgfplots@command@with@args@to@string##2\pgfplots@loc@TMPa @@ -10023,47 +10257,154 @@ \newif\ifpgfplotscolorbarCMYKworkaround \pgfplotscolorbarCMYKworkaroundtrue -\def\pgfplots@colorbar@draw@{% +\def\pgfplots@colorbar@draw@reconfigure@if@needed@legacy{% \pgfkeysgetvalue{/pgfplots/colorbar/draw/.@cmd}\pgfplots@loc@TMPa - \ifx\pgfplots@loc@TMPa\pgfplots@colorbar@draw@defaultimpl - % Ah-- the default colorbar implementation is active! We may need to substitute it by a better one. - % Check that: - \def\b@pgfplots@colorbar@fallback@to@sampled{0}% - \ifpgfplotscolorbarCMYKworkaround - % the default implementation for colorbars is based on - % \pgfplotscolormaptoshadingspec. - % This, in turn, does NOT work for CMYK. + \ifx\pgfplots@loc@TMPa\pgfplots@colorbar@draw@legacyimpl + \begingroup + \pgfkeysalso{/pgfplots/.search also=/tikz}% + % we need to activate this style because the decision + % below may depend on it (and will, for example for + % contour filled) + \pgfplotsset{every colorbar}% + \pgfplots@init@collect@firstplotastick% % - % This here detects that case and switches to the (visually) - % equivalent 'colorbar sampled={surf,shader=interp}' style. - \if1\pgfplotscolormaptoshadingspectorgb - \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPb - \pgfplotscolormapgetcolorspace{\pgfplots@loc@TMPb}% - \def\pgfplots@loc@TMPa{cmyk}% - \ifx\pgfplots@loc@TMPa\pgfplotsretval - \pgfutil@ifundefined{pgfplots@colorbar@CMYK@\pgfplots@loc@TMPb}{% - \pgfplotswarning{colorbar CMYK unsupported}{\pgfplots@loc@TMPb}\pgfeov% - \expandafter\gdef\csname pgfplots@colorbar@CMYK@\pgfplots@loc@TMPb\endcsname{1}% - }{}% - \def\b@pgfplots@colorbar@fallback@to@sampled{1}% + % Ah-- the default colorbar implementation is active! We may need to substitute it by a better one. + % Check that: + \def\b@pgfplots@colorbar@fallback@to@sampled{0}% + % + \ifpgfplots@collect@firstplot@astick + % xtick={data} requires samples: + % see also call hierarchy of \pgfplots@colorbar@positions@to@samplesat + \def\b@pgfplots@colorbar@fallback@to@sampled{1}% + \fi + % + \ifpgfplotscolorbarCMYKworkaround + % the default implementation for colorbars is based on + % \pgfplotscolormaptoshadingspec. + % This, in turn, does NOT work for CMYK. + % + % This here detects that case and switches to the (visually) + % equivalent 'colorbar sampled={surf,shader=interp}' style. + \if1\pgfplotscolormaptoshadingspectorgb + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPb + \pgfplotscolormapgetcolorspace{\pgfplots@loc@TMPb}% + \def\pgfplots@loc@TMPa{cmyk}% + \ifx\pgfplots@loc@TMPa\pgfplotsretval + \pgfutil@ifundefined{pgfplots@colorbar@CMYK@\pgfplots@loc@TMPb}{% + \pgfplotswarning{colorbar CMYK unsupported}{\pgfplots@loc@TMPb}\pgfeov% + \expandafter\gdef\csname pgfplots@colorbar@CMYK@\pgfplots@loc@TMPb\endcsname{1}% + }{}% + \def\b@pgfplots@colorbar@fallback@to@sampled{1}% + \fi \fi \fi - \fi - % - \def\pgfplots@colorbar@extra@options{}% - \if c\pgfplots@colormap@access - % colormap access=piecewise constant - % In this case, we want a sampled colorbar. 2x2 samples are enough since "shader=interp" - % automatically handles the correct interpolation scheme: - \def\b@pgfplots@colorbar@fallback@to@sampled{1}% - \def\pgfplots@colorbar@extra@options{samples=2} - \fi + % + \if c\pgfplots@colormap@access + % colormap access=piecewise constant + % In this case, we want a sampled colorbar. + \def\b@pgfplots@colorbar@fallback@to@sampled{1}% + % + \fi + \pgfmath@smuggleone\b@pgfplots@colorbar@fallback@to@sampled + \endgroup % \if 1\b@pgfplots@colorbar@fallback@to@sampled - \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsset{colorbar sampled={surf,shader=interp,\pgfplots@colorbar@extra@options}}}% + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplotsset{% + colorbar sampled={% + surf,% + shader=interp,% + % 2x2 samples are enough since "shader=interp" + % automatically handles the correct interpolation scheme: + samples=2,% + }% + }% + }% \pgfplots@loc@TMPa \fi \fi +}% + +\def\pgfplots@colorbar@draw@reconfigure@if@needed{% + \pgfplots@colorbar@draw@reconfigure@if@needed@legacy + \pgfplotsset{% + /pgfplots/every axis plot post/.append code={% + \ifpgfplots@collect@firstplot@astick + % Oh! Someone wrote 'ytick=data. We want the precise positions. + % + % Note that this check needs to be done late: it must + % be after \begin{axis} -- and since many colorbar + % styles overwrite 'samples', we even have to run it + % after cycle list options! + % + % That's why it is in 'every axis plot post': + \pgfplots@colorbar@positions@to@samplesat + \fi + }% + }% +}% + +% Defines and sets 'samples at' such that it resembles the colormap +% positions. +\def\pgfplots@colorbar@positions@to@samplesat{% + \pgfplots@colorbar@positions@to@samplesat@ + \edef\pgfplots@loc@TMPa{samples at={\pgfplotsretval}}% + \expandafter\pgfplotsset\expandafter{\pgfplots@loc@TMPa}% +} +% Sets \pgfplotsretval such that it contains an argument for 'samples at' +\def\pgfplots@colorbar@positions@to@samplesat@{% + \pgfkeysgetvalue{/pgfplots/point meta min}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfplots@error{Please define 'point meta min' and 'point meta max' before using 'samples at colormap pos'}% + \fi + \pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfplots@error{Please define 'point meta min' and 'point meta max' before using 'samples at colormap pos'}% + \fi + % + \edef\pgfplots@loc@TMPb{% + \noexpand\pgfplotscolormapgetpositions + [{\pgfkeysvalueof{/pgfplots/point meta min}}:{\pgfkeysvalueof{/pgfplots/point meta max}}]% + {\pgfkeysvalueof{/pgfplots/colormap name}}% + }% + \pgfplots@loc@TMPb +}% + +% A utility method which draws a standalone colorbar for visualization +% purposes. +% +% Example: +% \pgfplotscolorbardrawstandalone[colorbar horizontal,colormap access=const] +% +% \pgfplotscolorbardrawstandalone[colorbar horizontal,point meta max=1000] +% +\def\pgfplotscolorbardrawstandalone{% + \pgfutil@ifnextchar[{\pgfplotscolorbardrawstandalone@opt}{\pgfplotscolorbardrawstandalone@opt[]}% +}% +\def\pgfplotscolorbardrawstandalone@opt[#1]{% + \pgfplots@ifintikzpicture{% + \pgfplotscolorbardrawstandalone@opt@[#1]% + }{% + \begin{tikzpicture}% + \pgfplotscolorbardrawstandalone@opt@[#1]% + \end{tikzpicture}% + }% +} +\def\pgfplotscolorbardrawstandalone@opt@[#1]{% + \coordinate (parent axis) at (0,0); + \pgfplotsset{% + point meta min=0,% + point meta max=1000,% + parent axis width/.initial=6cm,% + parent axis height/.initial=6cm,% + #1,% + colorbar/standalone draw,% + }% +}% + + +\def\pgfplots@colorbar@draw@{% + \pgfplots@colorbar@draw@reconfigure@if@needed % % FIXME : the semicolon after ';' has a fixed catcode, namely % the one assigned while pgfplots.code.tex has been read. @@ -10081,6 +10422,20 @@ % \pgfkeysvalueof{/pgfplots/colorbar/draw/.@cmd}\pgfeov } + +\def\pgfplotsifnodeexists#1#2#3{% + \pgfutil@IfUndefined{pgf@sh@ns@#1}{#3}{#2}% +}% + +\def\pgfplots@colorbar@get@rid@of@at@parent@axis{% + \pgfkeysgetvalue{/pgfplots/at/.@cmd}\pgfplots@at@orig + \pgfkeyslet{/pgfplots/at/orig/.@cmd}\pgfplots@at@orig + % + \pgfkeysgetvalue{/pgfplots/colorbar to name/at/.@cmd}\pgfplots@colorbar@toname@at + \pgfkeyslet{/pgfplots/at/.@cmd}\pgfplots@colorbar@toname@at + % + \let\pgfplots@colorbar@get@rid@of@at@parent@axis=\relax% already applied in this scope. +}% \pgfkeysdef{/pgfplots/colorbar to name/at}{% % automatically search-and-replace 'parent axis' which % is not defined for a detached colorbar: @@ -10510,6 +10865,29 @@ \pgfkeysgetvalue{/pgfplots/ztickmin}{\pgfplots@ztickmin}% \pgfkeysgetvalue{/pgfplots/ztickmax}{\pgfplots@ztickmax}% % + \pgfplots@init@collect@firstplotastick + \global\let\pgfplots@firstplot@coords@x=\pgfutil@empty + \global\let\pgfplots@firstplot@coords@y=\pgfutil@empty + \global\let\pgfplots@firstplot@coords@z=\pgfutil@empty + \pgfkeysalso{/pgfplots/.search also=/tikz}% + % + \pgfkeysifdefined{/tikz/on layer}{}{% + % make sure assignments 'on layer' in the /tikz/ prefix + % doesn't hurt. + % this may happen, for example with + % 'x grid style={on layer=...}' + % because 'x grid style' is not processed by the key filtering + % above (it is extracted later). + \pgfkeyslet{/tikz/on layer}\pgfutil@empty% + }% + % + \pgfplots@set@patched@options + % + \pgfplots@set@options@sanitize + \pgfplots@notify@options@are@set +} + +\def\pgfplots@init@collect@firstplotastick{% \def\pgfplots@loc@TMPa{data}% \pgfplots@collect@firstplot@astickfalse \ifx\pgfplots@xtick\pgfplots@loc@TMPa @@ -10533,26 +10911,7 @@ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa \pgfplots@collect@firstplot@asticktrue \fi - \global\let\pgfplots@firstplot@coords@x=\pgfutil@empty - \global\let\pgfplots@firstplot@coords@y=\pgfutil@empty - \global\let\pgfplots@firstplot@coords@z=\pgfutil@empty - \pgfkeysalso{/pgfplots/.search also=/tikz}% - % - \pgfkeysifdefined{/tikz/on layer}{}{% - % make sure assignments 'on layer' in the /tikz/ prefix - % doesn't hurt. - % this may happen, for example with - % 'x grid style={on layer=...}' - % because 'x grid style' is not processed by the key filtering - % above (it is extracted later). - \pgfkeyslet{/tikz/on layer}\pgfutil@empty% - }% - % - \pgfplots@set@patched@options - % - \pgfplots@set@options@sanitize - \pgfplots@notify@options@are@set -} +}% \def\pgfplots@set@options@of@layered@graphics{% \ifpgfplots@axis@on@top @@ -11388,6 +11747,18 @@ \pgfkeyslet{/pgfplots/on layer}\pgfutil@empty } +\def\pgfplots@set@options@after@survey{% + \pgfkeyssetvalue{/pgfplots/xmin}{\pgfplots@xmin}% + \pgfkeyssetvalue{/pgfplots/ymin}{\pgfplots@ymin}% + \pgfkeyssetvalue{/pgfplots/zmin}{\pgfplots@zmin}% + \pgfkeyssetvalue{/pgfplots/point meta min}{\pgfplots@axiswide@metamin}% + % + \pgfkeyssetvalue{/pgfplots/xmax}{\pgfplots@xmax}% + \pgfkeyssetvalue{/pgfplots/ymax}{\pgfplots@ymax}% + \pgfkeyssetvalue{/pgfplots/zmax}{\pgfplots@zmax}% + \pgfkeyssetvalue{/pgfplots/point meta max}{\pgfplots@axiswide@metamax}% +}% + % \end{axis} : % % This command actually takes all collected (global) variables, @@ -11407,6 +11778,7 @@ % \pgfplotssurveyphase@setactiveplothandlers % + \pgfplots@set@options@after@survey \expandafter\pgfplotsset\expandafter{\pgfplots@late@options}% % \pgfplots@prepare@layered@graphics diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex index 9c6141e6680..3108885c8e2 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex @@ -5,10 +5,10 @@ \catcode`\:=12 \catcode`\+=12 \catcode`\-=12 -\gdef\pgfplotsrevision{1.13} -\gdef\pgfplotsversion{1.13} -\gdef\pgfplotsversiondatetime{2016-01-06 21:00:24 +0100} -\gdef\pgfplotsrevisiondatetime{2016-01-06 21:00:24 +0100} +\gdef\pgfplotsrevision{1.14} +\gdef\pgfplotsversion{1.14} +\gdef\pgfplotsversiondatetime{2016-08-10 20:41:40 +0200} +\gdef\pgfplotsrevisiondatetime{2016-08-10 20:41:40 +0200} \gdef\pgfplots@glob@TMPa#1-#2-#3 #4\relax{#1/#2/#3} \xdef\pgfplotsversiondate{\expandafter\pgfplots@glob@TMPa\pgfplotsversiondatetime\relax} \xdef\pgfplotsrevisiondate{\expandafter\pgfplots@glob@TMPa\pgfplotsrevisiondatetime\relax} diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex index 5ec05fd41a0..6518b542006 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex @@ -1341,9 +1341,13 @@ % #4: the argument supplied as coordinate on that axis. % #5: the shift along the outer unit normal. \def\pgfplotspointoutsideofaxis@#1#2#3\relax#4#5{% + % + \def\pgfplotspointoutsideofaxis@lineshift{}% + % \if v#1% \pgfplotspointoutsideofaxis@plug@getlimit{y}{#2}\let\pgfplots@loc@TMPa=\pgfmathresult \pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@loc@TMPa}{#2}% + \def\pgfplotspointoutsideofaxis@lineshift{x}% % \pgfplotspointonorientedsurfaceabsetupfor xzy% \pgfplotspointoutsideofaxis@plug@trafo{x}{#4}\let\pgfplots@loc@A=\pgfmathresult @@ -1364,6 +1368,7 @@ \pgfplotspointonorientedsurfaceabsetupfor yxz% \pgfplotspointoutsideofaxis@plug@trafo{y}{#4}\let\pgfplots@loc@A=\pgfmathresult \pgfplotspointoutsideofaxis@plug@getlimit{x}{#1}\let\pgfplots@loc@B=\pgfmathresult + \def\pgfplotspointoutsideofaxis@lineshift{y}% \else \pgfplotspointoutsideofaxis@plug@getlimit{x}{#1}\let\pgfplots@loc@TMPa=\pgfmathresult \pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@loc@TMPa}{#1}% @@ -1375,12 +1380,20 @@ \def\pgfplots@loc@A{0}% \fi \pgfplotspointoutsideofaxis@plug@getlimit{y}{#2}\let\pgfplots@loc@B=\pgfmathresult + \def\pgfplotspointoutsideofaxis@lineshift{z}% \fi \fi % % read dimen argument #5: \afterassignment\pgfplots@gobble@until@relax \pgf@xa=#5pt\relax + % + \pgfkeysgetvalue{/pgfplots/axis \pgfplotspointoutsideofaxis@lineshift\space line shift}\pgfmathresult + \ifx\pgfmathresult\pgfutil@empty + \else + \advance\pgf@xa by \pgfmathresult pt % + \fi + % \edef\pgfplots@loc@distalong@normal{\pgf@sys@tonumber\pgf@xa}% % %\message{pgfplotspointoutsideofaxis{#1#2#3}{#4}{#5}: A = \pgfplots@loc@A, B = \pgfplots@loc@B.^^J}% @@ -2987,7 +3000,9 @@ % empty line=scanline % class: \def\pgfplotsscanlinelength@scanline@initzero{% - \c@pgfplots@scanlineindex=0 + \c@pgfplots@scanlineindex=0 % the index _inside_ of the current scanline + \def\pgfplotsscanlinecurrentlength{\the\c@pgfplots@scanlineindex}% + \def\pgfplotsscanlineindex{0}% 0 is the first scanline, 1 the second, and so on \def\pgfplots@scanlinelength{-1}% } \def\pgfplotsscanlinelength@scanline@increase{% @@ -3022,6 +3037,7 @@ \fi \fi \c@pgfplots@scanlineindex=0 + \pgfplotsutil@advancestringcounter\pgfplotsscanlineindex% } \def\pgfplotsscanlinelength@scanline@cleanup{% \ifnum\c@pgfplots@scanlineindex=0 @@ -3741,6 +3757,12 @@ \fi \pgfplots@LUA@backend@supportedfalse \fi + \pgfplotscolormapifisuniform{\pgfkeysvalueof{/pgfplots/colormap name}}{% + }{% + % FIXME : implement LUA for non-uniform colormaps + \pgfplots@LUA@survey@log@deactivation{non-uniform color maps unsupported currently}% + \pgfplots@LUA@backend@supportedfalse + }% % \ifpgfplots@LUA@backend@supported \edef\pgfplots@LUA@backend@plotnum{\pgfutil@directlua{tex.sprint(\pgfplotsHASH pgfplots.gca.plothandlers)}}% @@ -5337,7 +5359,11 @@ % FIXME : verify this case \else \pgfkeyssetvalue{/pgfplots/mesh/rows}{\pgfkeysvalueof{/pgfplots/samples y}}% - \pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/samples}}% + \ifx\pgfplots@plot@samples@at\pgfutil@empty + \pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/samples}}% + \else + % FIXME : count number of samples in 'samples at'! + \fi \fi \if1\b@pgfplots@should@sample@LINE \pgfkeyssetvalue{/pgfplots/sample dim}{1}% @@ -5434,9 +5460,14 @@ }% \pgfplots@addplotimpl@expression@split@yz#2\pgfplots@EOI% % - % we don't have 'samples at' for 3D plots -> use domain! - \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@domain\relax{\pgfplots@plot@samples}% - \let\pgfplots@expression@xdomain=\pgfplotsretval + \ifx\pgfplots@plot@samples@at\pgfutil@empty + % we don't have 'samples at' -> use domain! + \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@domain\relax{\pgfplots@plot@samples}% + \let\pgfplots@expression@xdomain=\pgfplotsretval + \else + % use 'samples at': + \let\pgfplots@expression@xdomain=\pgfplots@plot@samples@at + \fi % % do we have '\y' as y coordinate? \expandafter\def\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@plot@var@y}% @@ -5655,6 +5686,12 @@ }% \fi % + \ifx\pgfplots@plot@samples@at\pgfutil@empty + \else + \def\pgfplotsretval{0}% + \pgfplots@LUA@plotexpression@log@deactivation{samples at unsupported (yet)}% + \fi + % \if1\pgfplots@addplotimpl@expression@hasuniform@y \else \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplots@addplotimpl@expression@yEXPR}{% @@ -6030,7 +6067,7 @@ }% \def\pgfplots@identify@gnuplot@logbehavior@checkversion{% \begingroup - \immediate\write18{gnuplot -V >\pgfplots@plot@filename.vrs}% + \pgfplots@shellescape{gnuplot -V >\pgfplots@plot@filename.vrs}% \openin\r@pgfplots@reada=\pgfplots@plot@filename.vrs\relax \ifeof\r@pgfplots@reada \pgfplotswarning{gnuplot -V impossible}\pgfeov @@ -9340,6 +9377,6 @@ \immediate\openout\pgf@shellwrite=#1.sh \immediate\write\pgf@shellwrite{#2}% \immediate\closeout\pgf@shellwrite% - \immediate\write18{sh #1.sh > #1.out} + \pgfplots@shellescape{sh #1.sh > #1.out} \fi% } diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex index 54e02d4496f..bc37418c689 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex @@ -109,6 +109,7 @@ \let\pgfplotsglobalretval=\pgfplots@luabackend@table }% }% + \ifpgfplots@LUA@supported \let\pgfplotsutil@directlua=\directlua \let\pgfplotsutil@directlua@std=\pgfplotsutil@directlua @@ -273,6 +274,14 @@ \fi \let#1=\relax }, + /pgfplots/exception/too few colormap positions/.code args={#1#2}{% + \ifx\pgfplotsexceptionmsg\relax + \pgfplots@error{#2}% + \else + \pgfplots@error{\pgfplotsexceptionmsg}% + \fi + \let#1=\relax + }, /pgfplots/exception/dimension too small in ticks/.code args={#1}{% \ifx\pgfplotsexceptionmsg\relax \pgfplots@error{The argument(s) for #1tick resulted in a tick distance which is too small. Please reconfigure the xtick argument(s)}% @@ -290,6 +299,9 @@ /pgfplots/warning/illegal user argument in log axis/.code args={#1#2}{% \pgfplotsthrow@warning{Ignoring illegal input argument #1=#2: cannot apply log.}% }, + /pgfplots/warning/too many colormap positions/.code={% + \pgfplotsthrow@warning{the colormap has too many positions; ignoring position #1}% + }, /pgfplots/warning/plot without coordinates/.code={% \pgfplotsthrow@warning{the current plot has no coordinates (or all have been filtered away)}% }, diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex index 46fddb9dd11..f3b28374d07 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex @@ -1600,7 +1600,8 @@ \pgfkeysvalueof{/pgfplots/quiver/before arrow/.@cmd}\pgfeov \pgfplotsplothandlerquiver@vis@hook \ifpgfplots@quiver@usetikz - \draw[/pgfplots/quiver/every arrow] \pgfextra{\pgfplotsplothandlerquiver@vis@path{#1}}; + \edef\pgfplotsplothandler@quiver@point{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% + \draw[/pgfplots/quiver/every arrow] \pgfextra{\pgfplotsplothandlerquiver@vis@path{\pgfplotsplothandler@quiver@point}}; \else \pgfplotsplothandlerquiver@vis@path{#1}% \pgfusepath{stroke}% @@ -1962,6 +1963,16 @@ contour prepared filled/.style={% /pgfplots/contour prepared={draw color=mapped color!80!black,labels=false,filled=true}, }, + contour filled/.code={% + \pgfqkeys{/pgfplots/contour}{% + every filled contour plot,% + /pgfplots/surf,% + /pgfplots/shader=interp,% + /pgfplots/colormap access=const,% + #1,% + }% + \let\tikz@plot@handler=\pgfplotsplothandlercontourfilled + }, % FIXME : should use \tikz@plot@handler instead of just the % visualization thing! contour/handler/.style={/tikz/sharp plot}, @@ -1977,12 +1988,18 @@ },% contour/labels/.is if=pgfplotsplothandlercontour@labels, contour/labels=true, + % + % XXX : this here is dead code... it has been superseded by + % \pgfplotsplothandlercontourfilled: contour/filled/.is if=pgfplotsplothandlercontour@filled, contour/filled/.default=true, % EXPERIMENTAL: WILL CHANGE EVENTUALLY! % this is (only) used for contour filled: % data limits={(xmin,ymin,zmin,cmin) (xmax,ymax,ymax,cmax} contour/data limits/.initial=,% FIXME EXPERIMENTAL + contour/every filled contour plot/.style={ + /pgfplots/area legend, + }, contour/every contour plot/.style={ /pgfplots/legend image post style={sharp plot}, }, @@ -2015,6 +2032,7 @@ % Shared parameters: contour/number/.initial=5, contour/levels/.initial=, + contour/levels from colormap/.initial=, % % contour/contour dir/.is choice, @@ -2762,7 +2780,7 @@ \immediate\write\w@pgf@writea{\pgfkeysvalueof{/pgfplots/contour external/script}}% \immediate\closeout\w@pgf@writea % - \immediate\write18{\pgfkeysvalueof{/pgfplots/contour external/cmd}}% + \pgfplots@shellescape{\pgfkeysvalueof{/pgfplots/contour external/cmd}}% \endgroup % % @@ -2937,3 +2955,127 @@ \input pgfplotsmeshplothandler.code.tex +% +%-------------------------------------------- + + +% Implementation of 'contour filled': it is actually just a small +% wrapper around 'surf,shader=interp,colormap access=const' -- with +% dedicated color map definitions. +\def\pgfplotsplothandlercontourfilled{% + \pgfplotsplothandlermesh + \let\pgfplotsplothandlersurveyend@contourfilled@orig=\pgfplotsplothandlersurveyend + \def\pgfplotsplothandlersurveyend{% + \pgfplotsplothandlersurveyend@contourfilled@orig + \pgfplotsplothandlersurveyend@contourfilled + }% +}% + +\def\pgfplotscontourfilledcolormap{internal:contourfilled} +\pgfplotscreatecolormap{\pgfplotscontourfilledcolormap}{color=(black) color=(black)} + +\def\pgfplotsplothandlersurveyend@contourfilled{% + \pgfplotsplothandlersurveyaddoptions{ + % ensure that the point meta of the contour makes its way into + % the colorbar and the associated color mapping. + % + % FIXME: that fails if there are more than one contours in the + % same axis (or someone else uses 'colorbar source') + colorbar source,% + % + % ensure that other plots to not "corrupt" our mapping: + point meta rel=per plot,% + }% + \def\pgfplots@contour@cm@options{% + colorbar style={% + /pgfplots/colormap access=const, + },% + }% + % + \pgfkeysgetvalue{/pgfplots/contour/levels}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % no levels. + % Ok, check the other keys in the order of precedence: + \pgfkeysgetvalue{/pgfplots/contour/levels from colormap}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % no 'levels from colormap'. + % Ok, check the other keys in the order of precedence: + \pgfkeysgetvalue{/pgfplots/contour/number}\pgfplots@loc@TMPa + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % not sure if this is a use-case... + \pgfplots@log3{contour plot: skipping definition of suitable colormap (none of 'number', levels', 'levels from colormap' is set)}% + \t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}% + \edef\pgfplots@contour@cm@options{% + \the\t@pgfplots@toka% + % just copy the current colormap to ensure that it + % has the correct name: + colormap={\pgfplotscontourfilledcolormap}{of colormap={}},% + }% + \else + % Ah -- we have a number of samples! + \t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}% + \edef\pgfplots@contour@cm@options{% + \the\t@pgfplots@toka% + colormap={\pgfplotscontourfilledcolormap}{samples of colormap={\pgfplots@loc@TMPa}},% + }% + \fi + \else + % Ah - we want to take levels from a colormap definition! + % We only need to ensure that the colormap definition fits + % into the range [metamin:metamax]. Do that here: + \t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}% + \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}% + \edef\pgfplots@contour@cm@options{% + \the\t@pgfplots@toka% + /utils/exec={% + \noexpand\edef\noexpand\pgfplots@targetpos@restore{% + of colormap/target pos min=\pgfkeysvalueof{/pgfplots/of colormap/target pos min},% + of colormap/target pos max=\pgfkeysvalueof{/pgfplots/of colormap/target pos max},% + of colormap/target pos min/insert=\ifpgfplots@createcolormap@target@pos@includes@limits@min true\else false\fi,% + of colormap/target pos max/insert=\ifpgfplots@createcolormap@target@pos@includes@limits@max true\else false\fi,% + \if c\pgfplots@ofcolorbar@sample@for@choice + of colormap/sample for=const,% + \else + of colormap/sample for=default,% + \fi + }% + },% + of colormap/target pos min*=\pgfplots@metamin,% + of colormap/target pos max*=\pgfplots@metamax,% + of colormap/sample for=const,% + colormap={\pgfplotscontourfilledcolormap}{% + \the\t@pgfplots@tokb + },% + /utils/exec={% + \noexpand\expandafter + \noexpand\pgfkeysalso + \noexpand\expandafter{\noexpand\pgfplots@targetpos@restore}% + },% + }% + \fi + \else + % Ah - we have a list of positions for the contours! + \t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}% + \edef\pgfplots@contour@cm@options{% + \the\t@pgfplots@toka% + colormap={\pgfplotscontourfilledcolormap}{% + of colormap={% + target pos min*=\pgfplots@metamin, + target pos max*=\pgfplots@metamax, + sample for=const,% + target pos={\pgfplots@loc@TMPa}, + }% + },% + }% + \fi + % + \ifx\pgfplots@contour@cm@options\pgfutil@empty + \else + % move to "late options" such that we carry them outside of + % any \begingroup...\endgroup constructions: + \expandafter\pgfplotssetlateoptions\expandafter{\pgfplots@contour@cm@options}% +%\message{contour filled: assembled options \meaning\pgfplots@contour@cm@options^^J}% + \fi +}% + + diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex index b063bf72a55..7f45bfb5bef 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex @@ -268,6 +268,7 @@ \pgfplotsaxisdeserializedatapointfrom@private@backup@{#2}% }% +% #1: the result of \pgfplotsaxisserializedatapointtostring \def\pgfplots@stacked@parsezerolevelpoint#1{% \begingroup \pgfplotsaxisdeserializedatapointfrom#1% no braces here! @@ -366,6 +367,12 @@ \def\pgfplotspointgetnormalizedzerolevelcoordinates{% \begingroup \ifpgfplots@stackedmode + % STATE: + % * \pgfplots@stacked@diff is the diff of the CURRENT point. + % * \pgfplots@stacked@zerolevel is the ENTIRE point of the + % zerolevel (consisting of its recursive zerolevel, its own diff, and its x,y coords) + % -> we need both + \let\pgfplots@stacked@diff@cur=\pgfplots@stacked@diff \ifx\pgfplots@stacked@zerolevel\pgfutil@empty \pgfplotspointgetnormalizedcoordinates% \pgfplotsutilforeachcommasep{x,y,z}\as\pgfplots@loc@TMPa{% @@ -386,7 +393,7 @@ \pgfplotscoordmath{x}{zero}\let\pgfplots@stacked@diff@x=\pgfmathresult% \pgfplotscoordmath{y}{zero}\let\pgfplots@stacked@diff@y=\pgfmathresult% \pgfplotscoordmath{z}{zero}\let\pgfplots@stacked@diff@z=\pgfmathresult% - \pgfutil@namelet{pgfplots@stacked@diff@\pgfplots@stacked@dir}{pgfplots@stacked@diff}% + \pgfutil@namelet{pgfplots@stacked@diff@\pgfplots@stacked@dir}{pgfplots@stacked@diff@cur}% \else % Ah - no stacked plot!? Well, than do "something useful": % ... note that we have to use 'pgfbasic' here as that is the diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex index 76abf78a92d..6b8c58a9e30 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex @@ -1917,6 +1917,7 @@ % INPUT: % \MIN : the lower axis limit of #1 (a TeX register, in transformed range) % \MAX : same with upper axis limit of #1 +% \desirednumticks: the number of ticks to use % OUTPUT: % \H : will contain the (transformed) distance between adjacent ticks % \aftergroup\pgfplots@isuniformticktrue set if it applies diff --git a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def index 516d8e02a98..0a874efa6b5 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def +++ b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def @@ -10,13 +10,6 @@ % % Copyright 2007/2008 by Christian Feuersänger. % -% pgflibrarypgfplots.surfshading.pgfsys-luatex.def -% converted from ...-pdftex.def by replacing disappeared primitives/vars -% with their respective replacements, as laid out in the luatex manual. -% Conversion by Norbert Preining -% -% Included into the TeX Live pgfplots package with agreement of Till Tantau. -% % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or diff --git a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def new file mode 100644 index 00000000000..6c78ddf9661 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def @@ -0,0 +1,30 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007-2012 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +\input pgflibrarypgfplots.surfshading.pgfsys-luatex.def + +\endinput +% vi: ft=tex diff --git a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def index b73f495cd83..a56f50ec72d 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def +++ b/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def @@ -99,6 +99,7 @@ \else /Filter /\pgfplotslibrarysurf@filter@decode\space \fi + %/AntiAlias \space true }% % % \pgfplots@loc@TMPb := final boolean luaBinaryEncoding; diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex index fe79bad2665..992687268c3 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex @@ -29,6 +29,10 @@ \pgfkeyssetvalue{/pgfplots/colormap default colorspace}{auto} +% preset for '/pgfplots/colormap uniform=always +% This is only used for the colormap predefined in this very file. +\def\pgfplots@colormap@uniform@choice{0}% + % This package relies on pgfplots temporary registers and its array % data structure. @@ -53,17 +57,45 @@ % \pgfplotscreatecolormap{my map}{color=(green); color=(red); color=(blue); color=(yellow)} \def\pgfplotscreatecolormap#{\pgfplots@createcolormap}% \def\pgfplots@createcolormap#1#2{% + \pgfkeysinterruptkeyfilter \edef\pgfplots@createcolormap@name{pgfpl@cm@#1}% \expandafter\pgfplotsarraynewempty\expandafter{\pgfplots@createcolormap@name}% - \def\pgfplots@createcolormap@MIN{0}% NORMALIZATION: assume that lower-end is 0pt. - \def\pgfplots@createcolormap@MAX{0}% To be computed. + \pgfplotsapplistXnewempty\pgfplots@createcolormap@X + % + % '0' = is not uniform + % '1' = is uniform + % '2' = is FORCED to be uniform, i.e. will be reinterpolated + \ifcase\pgfplots@colormap@uniform@choice\relax + % colormap uniform=always (due to compatibility requirements) + \def\b@pgfplotscreatecolormap@isuniform{2}% + \or + % colormap uniform=if requested + \def\b@pgfplotscreatecolormap@isuniform{1}% + \fi + \def\pgfplots@createcolormap@MIN{}% To be computed. + \def\pgfplots@createcolormap@MAX{}% To be computed. + \def\b@pgfplots@createcolormap@pos@mode{a}% [a]uto or [m]anual \pgfplots@createcolormap@initcolorspace \let\pgfplots@createcolormap@LAST=\pgfplots@createcolormap@MIN % PARSE IT: - \edef\pgfplots@loc@TMPa{#2}% \let\pgfplots@createcolormap@context=\pgfutil@empty + %%%%%%%%%%%%%%%%%% % this does also init @H: + \pgflibraryfpuifactive{% + \def\pgfplots@createcolormap@restore@fpu{}% + }{% + \def\pgfplots@createcolormap@restore@fpu{\pgfkeys{/pgf/fpu=false}}% + \pgfkeys{/pgf/fpu=true}% + }% + %\edef\pgfplots@loc@TMPa{#2}% XXX this fails for active chars and + %if key/value options are too special + \def\pgfplots@loc@TMPa{#2}% \expandafter\pgfplots@createcolormap@startloop\pgfplots@loc@TMPa\pgfplots@EOI + % + \pgfplots@createcolormap@restore@fpu + % + %%%%%%%%%%%%%%%%%% + % \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}% % sanity checking: \expandafter\pgfplotsarraysizetomacro\expandafter{\pgfplots@createcolormap@name}\to\pgfplots@loc@TMPa @@ -72,15 +104,52 @@ \or \pgfplots@error{Sorry, you need to provide at least two points of a colormap.}% \fi - % Map the input range [0pt,MAX] linearly to [0,1000] - \pgfmathdivide@{\pgfplotscolormaprange}{\pgfplots@createcolormap@MAX}% + % Map the input range [MIN,MAX] linearly to [0,1000] + \pgfmathfloatsubtract@{\pgfplots@createcolormap@MAX}{\pgfplots@createcolormap@MIN}% \let\pgfplots@loc@TMPb=\pgfmathresult - \pgfmathmultiply@{\pgfplots@loc@TMPb}{\pgfplots@createcolormap@H}% - \let\pgfplots@createcolormap@H=\pgfmathresult - \expandafter\let\csname\pgfplots@createcolormap@name @h\endcsname=\pgfplots@createcolormap@H - \pgfmathreciprocal@{\pgfplots@createcolormap@H}% + \pgfmathfloatdivide@{\pgfplotscolormaprange@float}{\pgfplots@loc@TMPb}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfmathfloatmultiply@{\pgfplots@loc@TMPb}{\pgfplots@createcolormap@H}% + \let\pgfplots@loc@TMPd=\pgfmathresult + \pgfplots@createcolormap@normalize{\pgfmathresult}% + \expandafter\let\csname\pgfplots@createcolormap@name @h\endcsname=\pgfmathresult + % + \pgfmathfloatreciprocal@{\pgfplots@loc@TMPd}% + \pgfplots@createcolormap@normalize{\pgfmathresult}% \expandafter\let\csname\pgfplots@createcolormap@name @invh\endcsname=\pgfmathresult % + % ... and set up the X coordinates if the grid is not uniform: + \expandafter\pgfplotsarraynewempty\expandafter{\pgfplots@createcolormap@name @X}% + \if0\b@pgfplotscreatecolormap@isuniform + % Uncomment the '\iftrue' for testing purposes (to see if a uniform map changes if + % processed as non-uniform): +% \iftrue + \pgfplotsapplistXlet\pgfplots@loc@TMPc=\pgfplots@createcolormap@X + \expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots@loc@TMPc}\as\pgfplots@loc@TMPc{% + \ifx\pgfplots@loc@TMPc\pgfutil@empty + \else + % apply the trafo [MIN,MAX] -> [0,1000] here as well: + \pgfmathfloatsubtract@{\pgfplots@loc@TMPc}{\pgfplots@createcolormap@MIN}% + \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPb}% + \pgfplots@createcolormap@normalize{\pgfmathresult}% + \expandafter\pgfplotsarraypushback\expandafter{\pgfmathresult}\to{pgfpl@cm@#1@X}% + \fi + }% + % + \pgfplotscolormapsetadditionalintervalwidth@{#1}% + \else + \expandafter\let\csname\pgfplots@createcolormap@name @X@scale@order@z\endcsname=\pgfutil@empty + \fi + % clear temporary list: + \pgfplotsapplistXnewempty\pgfplots@createcolormap@X + % + \if m\b@pgfplots@createcolormap@pos@mode + % Ah - we have manually provided positions! + % DISABLE the extra interval. You have to enable it explicitly + % by means of 'colormap access/extra interval width=0.1' + \expandafter\def\csname\pgfplots@createcolormap@name @X@scale@order@z\endcsname{0}% + \fi + % \endpgfplotscolornormalizesequence% \expandafter\let\csname\pgfplots@createcolormap@name @colspace\endcsname=\pgfplotsretval \expandafter\let\csname\pgfplots@createcolormap@name @col@comps\endcsname=\pgfplotsretvalb @@ -89,19 +158,89 @@ \expandafter\edef\csname\pgfplots@createcolormap@name @lastindex\endcsname{\the\c@pgf@counta}% %\pgfplots@colormap@showdebuginfofor{#1}% \pgfplots@colormap@LUA@new{#1}% + \endpgfkeysinterruptkeyfilter } +\def\pgfplots@createcolormap@normalize#1{% + \pgfmathfloattofixed{#1}% + \pgf@xa=\pgfmathresult pt % + \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}% normalize number. +}% + +% Allows to customize the width of the additional interval used for +% 'colormap access=piecewise constant'. +% +% #1 colormap name +% #2 the additional interval width for this colormap. Use '0' to disable the additional +% interval. The value is relative to the total width and must be in +% the range 0<=#2<=0.9 +\def\pgfplotscolormapsetadditionalintervalwidth#1#2{% + \edef\pgfplots@loc@TMPd{#2}% + \def\pgfplots@loc@TMPc{h}% + \ifx\pgfplots@loc@TMPd\pgfplots@loc@TMPc + % 'h' means: mesh width: + \pgfplotscolormapifisuniform{#1}{% + \expandafter\let\csname pgfpl@cm@#1@X@scale@order@z\endcsname\pgfutil@empty% + }{% + \pgfplotscolormapsetadditionalintervalwidth@{#1}% + }% + \else + \pgfmathparse{#2}% + \pgfplotscolormapifisuniform{#1}{% + \ifdim\pgfmathresult pt>0pt + \pgfplots@error{Uniform colormaps support no configuration of the additional interval width for a colormap (although you can use 0 to turn it off). Please use a non-uniform colormap.}% + \else + % DISABLE the extra interval! + \expandafter\def\csname pgfpl@cm@#1@X@scale@order@z\endcsname{0}% + \fi + }{% + \ifdim\pgfmathresult pt>0pt + \ifdim\pgfmathresult pt>0.9pt + \pgfplots@error{Expected a number 0< X <= 0.9, not \pgfmathresult}% + \else + % compute the 'h'. + % + % Note that 's:=#2' is a fraction 0<x<1 of the RESULTING + % range, i.e. s * 1000 = H where 0<=H<=1000. + % but H = 1000/(1000+h) * 1000, and we need the 'h'. + % + % -> h = 1000/s - 1000. + % regarding the '1-#2': I did some mistake in my + % computation and that fixed it :-/ + \pgfmathparse{1000/(1-#2)-1000}% + \expandafter\let\csname pgfpl@cm@#1@h\endcsname=\pgfmathresult + \expandafter\let\csname pgfpl@cm@#1@invh\endcsname=\pgfutil@empty% unused! + \pgfplotscolormapsetadditionalintervalwidth@{#1}% + \fi + \else + % DISABLE the extra interval! + \expandafter\def\csname pgfpl@cm@#1@X@scale@order@z\endcsname{0}% + \fi + }% + \fi +}% + +% see \pgfplotscolormapsetadditionalintervalwidth +\def\pgfplotscolormapsetadditionalintervalwidth@#1{% + % 'colormap access=piecewise constant' (order 0) requires a + % special scaling factor. See its consumers for details + + % documentation + \pgfmathparse{1000/(1000+\csname pgfpl@cm@#1@h\endcsname)}% + \expandafter\let\csname pgfpl@cm@#1@X@scale@order@z\endcsname=\pgfmathresult +}% \def\pgfplots@createcolormap@initcolorspace{% \pgfplotscolornormalizesequence[ colorspace=\pgfkeysvalueof{/pgfplots/colormap default colorspace}, - context message=\pgfplots@createcolormap@context, + context message=\pgfplots@createcolormap@context\pgfplots@createcolormap@trace, ]% }% \def\pgfplots@createcolormap@seth[#1]{% \def\pgfplots@createcolormap@context{[#1]}% \pgfmathparse{#1}% \let\pgfplots@createcolormap@H=\pgfmathresult + % request for a uniform colormap: + \def\b@pgfplotscreatecolormap@isuniform{3}% \pgfplots@createcolormap@ }% @@ -118,175 +257,770 @@ {% \pgfutil@ifnextchar;{\pgfplots@createcolormap@grabsemicolon}% {% - \expandafter\pgfutil@ifnextchar\pgfplots@activesemicolon{\pgfplots@createcolormap@grabsemicolon@active}% - {% - \pgfplots@createcolormap@grabnext + \pgfutil@ifnextchar,{\pgfplots@createcolormap@grabcomma}% + { + \expandafter\pgfutil@ifnextchar\pgfplots@activesemicolon{\pgfplots@createcolormap@grabsemicolon@active}% + {% + \pgfplots@createcolormap@grabnext + }% }% }% }% } + +% Executes '#1' if there are more tokens and '#2' if not. +\def\pgfplots@createcolormap@ifhasmorecolors#1#2{% + \pgfutil@ifnextchar\pgfplots@EOI{% + #2% no more tokens. + }{% + \pgfutil@ifnextchar;{\pgfplots@createcolormap@grabsemicolon@hasnext{#1}{#2}}% + {% + \pgfutil@ifnextchar,{\pgfplots@createcolormap@grabcomma@hasnext{#1}{#2}}% + { + \expandafter\pgfutil@ifnextchar\pgfplots@activesemicolon{\pgfplots@createcolormap@grabsemicolon@active@hasnext{#1}{#2}}% + {% + #1% has more. + }% + }% + }% + }% +}% + \def\pgfplots@createcolormap@error#1#2\pgfplots@EOI{% {% \t@pgfplots@toka={#1#2}% \t@pgfplots@tokb={#1}% - \pgfplots@error{Illformed colormap specification: I could not read the substring `\the\t@pgfplots@toka' starting at `\the\t@pgfplots@tokb'}% + \pgfplots@error{Illformed colormap specification: I could not read the substring `\the\t@pgfplots@toka' starting at `\the\t@pgfplots@tokb'\pgfplots@createcolormap@trace}% }% }% -\def\pgfplots@createcolormap@grabnext#1({% - \pgfplots@createcolormap@grabnext@{#1}% +\def\pgfplots@createcolormap@trace{% + \space(color no \expandafter\pgfplotsarraysizeof\expandafter{\pgfplots@createcolormap@name}) +} + +\def\pgfplots@createcolormap@grabnext#1={% + \pgfutil@ifnextchar({\pgfplots@createcolormap@grabnext@round{#1}=}{% + \pgfutil@ifnextchar\bgroup{\pgfplots@createcolormap@grabnext@curly{#1}=}{% + \pgfplots@createcolormap@error#1=% + }% + }% } -\def\pgfplots@createcolormap@grabnext@#1#2){% - \pgfutil@in@={#1}% +\def\pgfplots@createcolormap@grabnext@round#1=(#2){% + \pgfplots@createcolormap@grabnext@@{#1}={#2}% +}% +\def\pgfplots@createcolormap@grabnext@curly#1=#2{% + \pgfplots@createcolormap@grabnext@@{#1}={#2}% +}% +\def\pgfplots@createcolormap@grabnext@@#1=#2{% + \pgfutil@in@({#1}% \ifpgfutil@in@ + % Ah. We have something like 'color(1cm)' before the equal sign. + \pgfplots@createcolormap@grabnext@read@pos#1\pgfplots@EOI% + % now: + %\pgfplots@loc@TMPa = colorspace + %\pgfplots@loc@TMPb = position + % + \else % Ah. we do not have a position, i.e. we have % color=(green) % or something like this. % % this here defines \pgfplots@loc@TMPa to contain the % colorspace: - \pgfplots@createcolormap@grabnext@remove@equal@sign#1\pgfplots@EOI + \pgfkeys@spdef\pgfplots@loc@TMPa{#1}% % \pgfplots@createcolormap@grabnext@computenextposition - \let\pgfplots@loc@TMPb=\pgfmathresult% posisiton - \def\pgfplots@loc@TMPc{#2}% color data - \let\pgfplots@loc@TMPd=\pgfplots@createcolormap@grabnext@complete - \else - % Ah. We have something like 'color(1cm)' and we did not see - % the equal sign so far. - \def\pgfplots@loc@TMPa{#1}% colorspace - \def\pgfplots@loc@TMPb{#2}% position - % - % and collect the color data: - \def\pgfplots@loc@TMPd{% - \pgfutil@ifnextchar={% - \pgfplots@createcolormap@grabnext@@ - }{% - \pgfplots@createcolormap@error#1(#2)% - }% - }% + \let\pgfplots@loc@TMPb=\pgfmathresult% position \fi - \pgfplots@loc@TMPd + \def\pgfplots@loc@TMPc{#2}% + \pgfplots@createcolormap@grabnext@complete }% -\def\pgfplots@createcolormap@grabnext@remove@equal@sign#1=#2\pgfplots@EOI{% - \def\pgfplots@loc@TMPa{#1}% - % - % FIXME : what if #2 is not empty!? +\def\pgfplots@createcolormap@grabnext@read@pos#1({% + \pgfkeys@spdef\pgfplots@loc@TMPa{#1}% colorspace + \pgfplots@createcolormap@grabnext@read@pos@ }% - -\def\pgfplots@createcolormap@grabnext@@={% - \pgfutil@ifnextchar({% - \pgfplots@createcolormap@grabnext@@@ +\def\pgfplots@createcolormap@grabnext@read@pos@#1){% + \def\pgfplots@loc@TMPb{#1}% position + \def\b@pgfplots@createcolormap@pos@mode{m}% [m]anual + \pgfutil@ifnextchar\pgfplots@EOI{% + % OK + \pgfplots@gobble@until@EOI }{% - \pgfplots@createcolormap@error=% + \pgfplots@createcolormap@error#1)% }% }% -\def\pgfplots@createcolormap@grabnext@@@(#1){% - \def\pgfplots@loc@TMPc{#1}% - \pgfplots@createcolormap@grabnext@complete -}% %%%%%%%%%% -% defines \pgfplotsretval to contain the argument and \pgfplotsretvalb -% to contain the colormap name. -\def\pgfplots@createcolormap@special@split#1{% +% Splits '<argument> of <source name>*' into (\pgfplotsretval, +% \pgfplotsretvalb). +% +% The 'of' part is optional. If it is missing, '\pgfplotsretval' +% contains the entire argument and '\pgfplotsretvalb' is the current +% colormap. +% +% Note that '<source name>*' is typically just a colormap name (i.e. without +% '*'), but it _may_ contain key-value lists! They will be returned as-is. +% #1: the string to split +% #2: '1' if '#1' may contain ',' and '0' otherwise +\def\pgfplots@createcolormap@special@split#1#2{% \pgfutil@in@{of }{#1}% \ifpgfutil@in@ \pgfplots@createcolormap@special@split@#1\pgfplots@EOI \else - \pgfkeys@spdef\pgfplotsretval{#1}% - \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretvalb + \if1#2\relax + % do not check it -- commas are allowed here! + \pgfutil@in@false + \else + \pgfutil@in@{,}{#1}% + \fi + \ifpgfutil@in@ + % ah - might be something like '5, target pos={1,2,3}'. + % -> define \pgfplotsretval='5' and + % \pgfplotsretvalb='<colormap name>, target pos={1,2,3}': + % + \pgfplots@createcolormap@special@split@command#1\pgfplots@EOI + \t@pgfplots@tokb=\expandafter{\pgfplotsretvalb}% + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretvalb + \edef\pgfplotsretvalb{\pgfplotsretvalb,\the\t@pgfplots@tokb}% + \else + \pgfkeys@spdef\pgfplotsretval{#1}% + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretvalb + \fi \fi - \pgfplots@createcolormap@special@ensure@source@cm{\pgfplotsretvalb}% +%\message{Split (#1) --> '\pgfplotsretval', '\pgfplotsretvalb'^^J}% }% \def\pgfplots@createcolormap@special@split@#1of #2\pgfplots@EOI{% \pgfkeys@spdef\pgfplotsretval{#1}% \pgfkeys@spdef\pgfplotsretvalb{#2}% } +\def\pgfplots@createcolormap@special@split@command#1,#2\pgfplots@EOI{% + \pgfkeys@spdef\pgfplotsretval{#1}% + \pgfkeys@spdef\pgfplotsretvalb{#2}% +} + +% Output: \pgfplotsretval will be populated with the resulting +% colormap name. \def\pgfplots@createcolormap@special@ensure@source@cm#1{% - \pgfplotscolormapifdefined{#1}{% - }{% - \pgfplots@error{The argument '#1' is no valid colormap.}% + \edef\pgfplotsretval{#1}% + \pgfplotscolormapifdefined{#1}{}{% + % hm... the colormap does not exist? Perhaps someone used + % style 'colormap/cool'. Try to define it! + \pgfkeysifdefined{/pgfplots/#1/.@cmd}{% + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@color@of@colormap@name@old + \pgfplotsset{#1}% + \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretval + \pgfkeyslet{/pgfplots/colormap name}\pgfplots@color@of@colormap@name@old + }{% + \pgfplots@error{The argument '#1' is no valid colormap.}% + }% }% }% -% defines \pgfplotsretval to contain an expanded color definition -% series -% #1: position -% #2: argument(s) -\expandafter\def\csname pgfplots@createcolormap@grabnextspecial@colors of colormap\endcsname#1#2{% - \pgfplots@createcolormap@special@split{#2}% - \pgfplots@createcolormap@special@process{#1}{color of colormap}% -%\message{colors of colormap(#1)=(#2): resulted in \meaning\pgfplotsretval^^J}% +\newif\ifpgfplots@createcolormap@target@pos@includes@limits@min +\newif\ifpgfplots@createcolormap@target@pos@includes@limits@max + +% these keys are only evaluated inside of +% \pgfplots@of@colormap@getresult : +\pgfqkeys{/pgfplots/of colormap}{% + source name/.initial=, + target pos/.initial=, + target pos min/.initial=, + target pos min/insert/.is if=pgfplots@createcolormap@target@pos@includes@limits@min, + target pos min*/.style={% + /pgfplots/of colormap/target pos min={#1}, + /pgfplots/of colormap/target pos min/insert=true, + },% + target pos max/.initial=, + target pos max*/.style={% + /pgfplots/of colormap/target pos max={#1}, + /pgfplots/of colormap/target pos max/insert=true, + },% + target pos max/insert/.is if=pgfplots@createcolormap@target@pos@includes@limits@max, + source pos/.initial=, + source pos/.set if not empty/.code={% + \edef\pgfplots@loc@TMPa{#1}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfkeyslet{/pgfplots/of colormap/source pos}\pgfplots@loc@TMPa + \fi + }, + % + @define/.code={% + \pgfplots@error{Please write 'single color' or 'color list' such that pgfplots knows how to interprete values} + \let\pgfplotsretval=\pgfutil@empty + }, + single color/.style={% + /pgfplots/of colormap/@define/.code={% + \pgfplots@createcolormap@special@process@single + }, + }, + color list/.style={% + /pgfplots/of colormap/@define/.code={% + \pgfplots@createcolormap@special@process@list% + }, + }, + color list, + % + of colormap/.style={#1}, + % + % 'color of colormap={#1}' is a style which boils down to + % '@delegate to@ of colormap={color}{#1}'. + % The same is true for + % colors of colormap + % index of colormap + % indices of colormap + % samples of colormap + % + % All use this implementation: + % #1: how to interprete results. /pgfplots/of colormap/#1 must be + % a valid key (like 'color'). + % #2: the argument which can be '<source pos> of <source name>' or '<source pos>'. + % #3: '1' if the source pos may contain ',' and '0' otherwise + @delegate to@ of colormap/.code args={#1#2#3}{% + % Convert 'color of colormap={...}' and its variants into + % 'of colormap={<list of keys>}': + \pgfplots@createcolormap@special@split{#2}{#3}% + \edef\pgfplots@loc@TMPa{% + #1,% + source pos={\pgfplotsretval},% + % \pgfplotsretvalb will contain the colormap name + % --- but it _can_ also contain further key-value pairs! + % Do not add braces here such that further key-value pairs + % can be found: + source name=\pgfplotsretvalb,% + }% + \expandafter\pgfkeysalso\expandafter{\pgfplots@loc@TMPa}% + }, + % + color/.style={% + /pgfplots/of colormap/colormap access=map, + /pgfplots/of colormap/single color, + /pgfplots/of colormap/source pos/.set if not empty={#1}, + }, + const color/.style={% + /pgfplots/of colormap/colormap access=piecewise constant, + /pgfplots/of colormap/single color, + /pgfplots/of colormap/source pos/.set if not empty={#1}, + }, + index/.style={% + /pgfplots/of colormap/colormap access=direct, + /pgfplots/of colormap/single color, + /pgfplots/of colormap/source pos/.set if not empty={#1}, + }, + colors/.style={% + /pgfplots/of colormap/colormap access=map, + /pgfplots/of colormap/color list, + /pgfplots/of colormap/source pos/.set if not empty={#1}, + }, + samples/.style={% + /pgfplots/of colormap/colormap access=map,% can be overridden if needed. + /pgfplots/of colormap/@define/.code={% + \pgfplots@createcolormap@special@process@list@sampled% + }, + /pgfplots/of colormap/source pos/.set if not empty={#1}, + },% + % + const colors/.style={% + /pgfplots/of colormap/colormap access=piecewise constant, + /pgfplots/of colormap/color list, + /pgfplots/of colormap/source pos/.set if not empty={#1}, + }, + indices/.style={% + /pgfplots/of colormap/colormap access=direct, + /pgfplots/of colormap/color list, + /pgfplots/of colormap/source pos/.set if not empty={#1}, + }, + colormap access/.style={/pgfplots/colormap access={#1}}, + source range/.initial=0:1000, + % + sample for/.is choice, + sample for/default/.code={\def\pgfplots@ofcolorbar@sample@for@choice{m}}, + sample for/const/.code={\def\pgfplots@ofcolorbar@sample@for@choice{c}}, + sample for=default, + % + /pgfplots/of colormap/.unknown/.code={% + \pgfplotsutilifstringequal{#1}{\pgfkeysnovalue}{% + % This here allows to write 'of colormap={initial}' + \pgfplotscolormapifdefined{\pgfkeyscurrentname}{% + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfkeysalso{% + /pgfplots/of colormap/source name={\pgfkeyscurrentname}, + }% + }% + \pgfplots@loc@TMPa + }{% + \pgfplots@error{Unknown key '\pgfkeyscurrentname'. Is this a colormap name? Maybe you need to write \string\pgfplotsset{\pgfkeyscurrentname} first?}% + }% + }{% + \pgfkeysgetvalue{/handlers/.unknown/.@cmd}{\pgfkeys@code}% + \expandafter\pgfkeys@code\pgfkeyscurrentvalue\pgfeov% + }% + }, + % + % allow something like 'of colormap={colormap/PuBuGn}': + /pgfplots/of colormap/colormap/.unknown/.code={% + \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsset{colormap/\pgfkeyscurrentname}}% + \pgfplots@loc@TMPa + },% } -\expandafter\def\csname pgfplots@createcolormap@grabnextspecial@samples of colormap\endcsname#1#2{% - \pgfplots@createcolormap@special@split{#2}% +\pgfplotsinvokeforeach{% + color,% defines 'color of colormap' + index,% defines 'index of colormap' + const color,% defines 'const color of colormap' + samples,% defines 'samples of colormap' +}{% + \def\pgfplots@glob@TMPa{#1}% + \ifx\pgfplots@glob@TMPa\pgfutil@empty + \else + \pgfkeysdef{/pgfplots/of colormap/#1 of colormap}{% + \pgfkeysalso{/pgfplots/of colormap/@delegate to@ of colormap={#1}{##1}{0}}% + }% + \fi +}% +\pgfplotsinvokeforeach{% + indices,% defines 'indices of colormap' + colors,% defines 'colors of colormap' + const colors,% defines 'const colors of colormap' +}{% + \def\pgfplots@glob@TMPa{#1}% + \ifx\pgfplots@glob@TMPa\pgfutil@empty + \else + \pgfkeysdef{/pgfplots/of colormap/#1 of colormap}{% + \pgfkeysalso{/pgfplots/of colormap/@delegate to@ of colormap={#1}{##1}{1}}% + }% + \fi +}% + +% This is the main implementation of 'of colormap'. It is shared by +% both cycle lists and colormaps. +% +\def\pgfplots@of@colormap@getresult#1{% + \pgfkeysinterruptkeyfilter + \pgfqkeys{/pgfplots/of colormap}{% + % ensure that this here is not inherited from the axis' + % configuration -- reset it: + colormap access=map,% + #1}% + \pgfkeysgetvalue{/pgfplots/of colormap/source name}\pgfplots@loc@TMPa + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfkeyslet{/pgfplots/colormap name}\pgfplots@loc@TMPa + \fi + \pgfplots@createcolormap@special@ensure@source@cm{\pgfkeysvalueof{/pgfplots/colormap name}}% + \pgfkeyslet{/pgfplots/colormap name}\pgfplotsretval + % + \pgfqkeys{/pgfplots/of colormap}{@define}% + \endpgfkeysinterruptkeyfilter +}% + + +\def\pgfplots@createcolormap@special@process@single@error{% + \pgfplots@error{Did not find a suitable input source pos in a 'of colormap' specification. Did you forget the 'source pos'? It can be given as 'colors of colormap=(source pos of name)' or 'of colormap=(source pos=...,..)'}% + \pgfkeyssetvalue{/pgfplots/of colormap/source pos}{0}% +}% +\def\pgfplots@createcolormap@special@process@single@error@comma{% + \pgfplots@error{Found an unexpected comma in 'source pos=\pgfkeysvalueof{/pgfplots/of colormap/source pos}'. Please use one of the styles 'colors', 'indices', or 'const colors' in order to process more than one position}% + \pgfkeyssetvalue{/pgfplots/of colormap/source pos}{0}% +}% +\def\pgfplots@createcolormap@special@process@single{% \begingroup - \let\pgfplots@source=\pgfplotsretval - \let\pgfplots@sourcecm=\pgfplotsretvalb - \pgfplots@domain@to@foreach 0:1000\relax{\pgfplots@source}% - \t@pgfplots@toka=\expandafter{\pgfplotsretval}% - \edef\pgfplotsretval{colors of colormap(#1)=({\the\t@pgfplots@toka} of \pgfplots@sourcecm)}% + \let\pgfplots@color@of@colormap@access=\pgfplots@colormap@access + \pgfkeysgetvalue{/pgfplots/of colormap/source range}\pgfplotspointmetatransformedrange + \ifx\pgfplotspointmetatransformedrange\pgfutil@empty + % evaluated by \pgfplots@color@of@colormap@define... + \let\pgfplotspointmetatransformedrange=\pgfplotscolormaprange + \fi + % + \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots@loc@TMPa + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfplots@createcolormap@special@process@single@error + \else + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfutil@in@{,}{\pgfplots@loc@TMPa}% + }% + \pgfplots@loc@TMPa + \ifpgfutil@in@ + \pgfplots@createcolormap@special@process@single@error@comma + \else + \pgfmathparse{\pgfkeysvalueof{/pgfplots/of colormap/source pos}}% + \pgfkeyslet{/pgfplots/of colormap/source pos}\pgfmathresult + \fi + \fi + % + \pgflibraryfpuifactive{\pgfkeys{/pgf/fpu=false}}{}% + % + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplots@color@of@colormap@define{\pgfkeysvalueof{/pgfplots/of colormap/source pos}}% + }% + \pgfplots@loc@TMPa + % + \pgfplots@createcolormap@special@process@single@define \pgfmath@smuggleone\pgfplotsretval \endgroup -%\message{samples of colormap(#1)=(#2): resulted in \meaning\pgfplotsretval^^J}% -} -\expandafter\def\csname pgfplots@createcolormap@grabnextspecial@indices of colormap\endcsname#1#2{% - \pgfplots@createcolormap@special@split{#2}% - \pgfplots@createcolormap@special@process{#1}{index of colormap}% -%\message{indices of colormap(#1)=(#2): resulted in \meaning\pgfplotsretval^^J}% -} -\expandafter\def\csname pgfplots@createcolormap@grabnextspecial@color of colormap\endcsname#1#2{% - \begingroup - % colormap access=map - \def\pgfplots@color@of@colormap@access{m}% - \pgfplots@color@of@colormap@define{#2}% +}% + +\def\pgfplots@createcolormap@special@process@single@define{% + \pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots@temp@pos + \ifx\pgfplots@temp@pos\pgfutil@empty + \else + \edef\pgfplots@temp@pos{(\pgfplots@temp@pos)}% + \fi + % \edef\pgfplotsretval{% - \csname pgfpl@cm@\pgfplots@color@of@colormap@name @colspace\endcsname(#1)=(\pgfmathresult)% + \csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname\pgfplots@temp@pos=(\pgfmathresult)% }% - \pgfmath@smuggleone\pgfplotsretval - \endgroup +}% +\let\pgfplots@createcolormap@special@process@single@define@CM=\pgfplots@createcolormap@special@process@single@define% + +\def\pgfplots@createcolormap@special@process@list@sanitize@selection{% + \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots@loc@TMPa + \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + % default to a suitable source pos. + \ifnum\pgfplots@pos@size<2 + % We have either 0 positions or 1 position. + % This is clearly insufficient and we assume that this + % position argument merely gives the start point for the + % list. + % + % Select all of the input colormap: + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfkeysalso{% + /pgfplots/of colormap/source pos={0,...,\pgfplotscolormaplastindexof{\pgfkeysvalueof{/pgfplots/colormap name}}},% + /pgfplots/of colormap/indices, + }% + }% + \pgfplots@loc@TMPa + \else + % hm... we have no source pos, but we have positions! In + % this case, we _sample_ source pos uniformly with one + % sample for each position! + \pgfkeyslet{/pgfplots/of colormap/source pos}\pgfplots@pos@size + \pgfplots@createcolormap@special@process@list@sampled@define{P}% + \fi + \fi } -\expandafter\def\csname pgfplots@createcolormap@grabnextspecial@index of colormap\endcsname#1#2{% +\def\pgfplots@createcolormap@special@process@list@limits{% \begingroup - % colormap access=direct - \def\pgfplots@color@of@colormap@access{d}% - \pgfplots@color@of@colormap@define{#2}% - \edef\pgfplotsretval{% - \csname pgfpl@cm@\pgfplots@color@of@colormap@name @colspace\endcsname(#1)=(\pgfmathresult)% - }% - \pgfmath@smuggleone\pgfplotsretval + % + \pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots@target + \ifx\pgfplots@target\pgfutil@empty + \else + \pgfkeys{/pgf/fpu=true}% + \pgfkeysgetvalue{/pgfplots/of colormap/target pos min}\pgfplots@target@min + \pgfkeysgetvalue{/pgfplots/of colormap/target pos max}\pgfplots@target@max + \pgfplots@loc@tmpfalse + \ifx\pgfplots@target@min\pgfutil@empty + \else + \pgfmathparse\pgfplots@target@min + \let\pgfplots@target@min=\pgfmathresult + \pgfplots@loc@tmptrue + \fi + \ifx\pgfplots@target@max\pgfutil@empty + \else + \pgfmathparse\pgfplots@target@max + \let\pgfplots@target@max=\pgfmathresult + \pgfplots@loc@tmptrue + \fi + \ifpgfplots@loc@tmp + % Ah - we _have_ limit constraints! Enforce them: + \def\b@pgfplots@isfirst{1}% + \pgfmathfloatcreate{1}{1.0}{324}% + \let\pgfplots@firstpos\pgfmathresult% + \let\pgfplots@lastpos\pgfmathresult% + \pgfplotsapplistXnewempty\pgfplots@createcolormap@trg@accum + \def\pgfplots@loc@TMPa{\pgfplotsforeachungrouped \x in}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@target}{% + \ifx\x\pgfutil@empty + \else + \pgfmathparse{\x}% + \let\x=\pgfmathresult + \ifx\pgfplots@target@min\pgfutil@empty + \else + \pgfmathfloatlessthan{\x}{\pgfplots@target@min}% + \ifpgfmathfloatcomparison + \let\x=\pgfutil@empty + \fi + \fi + \ifx\pgfplots@target@max\pgfutil@empty + \else + \ifx\x\pgfutil@empty + \else + \pgfmathfloatlessthan{\pgfplots@target@max}{\x}% + \ifpgfmathfloatcomparison + \let\x=\pgfutil@empty + \fi + \fi + \fi + % + \ifx\x\pgfutil@empty + \else + \let\pgfplots@lastpos=\x + \if1\b@pgfplots@isfirst + \let\pgfplots@firstpos=\x + \def\b@pgfplots@isfirst{0}% + \else + \edef\x{,\x}% + \fi + \expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots@createcolormap@trg@accum + \fi + \fi + }% + % + \ifpgfplots@createcolormap@target@pos@includes@limits@max + \ifx\pgfplots@target@max\pgfutil@empty + \else + \pgfmathfloatifapproxequalrel{\pgfplots@lastpos}{\pgfplots@target@max}{% + }{% + \let\x=\pgfplots@target@max + \if1\b@pgfplots@isfirst + \def\b@pgfplots@isfirst{0}% + \else + \edef\x{,\x}% + \fi + \expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots@createcolormap@trg@accum + }% + \fi + \fi + % + \pgfplotsapplistXlet\pgfplots@target=\pgfplots@createcolormap@trg@accum + % + \ifpgfplots@createcolormap@target@pos@includes@limits@min + \ifx\pgfplots@target@min\pgfutil@empty + \else + \pgfmathfloatifapproxequalrel{\pgfplots@firstpos}{\pgfplots@target@min}{% + }{% + \let\x=\pgfplots@target@min + \if1\b@pgfplots@isfirst + \let\pgfplots@target=\x + \else + \edef\pgfplots@target{\x,\pgfplots@target}% + \fi + }% + \fi + \fi + \fi + \fi + % + \global\let\pgfplots@glob@TMPb=\pgfplots@target \endgroup -} -\def\pgfplots@createcolormap@special@process#1#2{% +%\message{limit application: \pgfkeysvalueof{/pgfplots/of colormap/target pos} ^^J -->\pgfplots@glob@TMPb^^J}% + \pgfkeyslet{/pgfplots/of colormap/target pos}\pgfplots@glob@TMPb +}% + +\def\pgfplots@createcolormap@special@process@list@define@target@array{% + \pgfplots@createcolormap@special@process@list@limits% + % + \pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots@loc@TMP + \expandafter\pgfplotsarraynew\expandafter\pgfplots@pos@array\expandafter{\pgfplots@loc@TMP}% + % + \pgfplotsarraysizetomacro\pgfplots@pos@array\to\pgfplots@pos@size +}% + +% PRECONDITION: Must be invoked within \pgfplots@of@colormap@getresult +\def\pgfplots@createcolormap@special@process@list{% \begingroup - \let\pgfplots@source=\pgfplotsretval - \let\pgfplots@sourcecm=\pgfplotsretvalb - \def\pgfplots@temp@pos{(#1)}% + \pgfkeys{/pgf/fpu=true}% + \pgfplots@createcolormap@special@process@list@define@target@array % \pgfplotsapplistXnewempty\pgfplots@createcolormap@special@process@result + % + \gdef\c@pgfplots@elem{0}% + % + \def\pgfplots@createcolormap@special@process@list@append{% + \pgfplots@createcolormap@special@process@single + % + % append separator + \t@pgfplots@toka=\expandafter{\pgfplotsretval}% + \t@pgfplots@tokb=\expandafter{\pgfplots@createcolormap@special@process@list@separator}% + \edef\pgfplotsretval{\the\t@pgfplots@toka\the\t@pgfplots@tokb}% + % + \expandafter\pgfplotsapplistXpushback\pgfplotsretval\to\pgfplots@createcolormap@special@process@result + }% + % + \pgfplots@createcolormap@special@process@list@sanitize@selection + % + \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots@source + % \def\pgfplots@loc@TMPa{\pgfplotsforeachungrouped \x in }% \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@source}{% - \t@pgfplots@tokb=\expandafter{\pgfplots@sourcecm}% % - \edef\currentValue{#2\pgfplots@temp@pos=(\x\space of \the\t@pgfplots@tokb) }% + \pgfkeyslet{/pgfplots/of colormap/source pos}\x % - \expandafter\pgfplotsapplistXpushback\currentValue\to\pgfplots@createcolormap@special@process@result + \ifnum\c@pgfplots@elem<\pgfplots@pos@size\relax + \pgfplotsarrayselect\c@pgfplots@elem\of\pgfplots@pos@array\to\pgfplots@loc@TMPa + \pgfkeyslet{/pgfplots/of colormap/target pos}\pgfplots@loc@TMPa + \else + % auto-position: + \pgfkeyslet{/pgfplots/of colormap/target pos}\pgfutil@empty + \fi + % + \pgfplots@createcolormap@special@process@list@append % - % all following ones receive auto-positions: - \let\pgfplots@temp@pos=\pgfutil@empty + \pgfplotsutil@advancestringcounter@global\c@pgfplots@elem }% + % + \pgfutil@loop + \ifnum\c@pgfplots@elem<\pgfplots@pos@size\relax + \pgfplotsarrayselect\c@pgfplots@elem\of\pgfplots@pos@array\to\pgfplots@loc@TMPa + \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\x + \pgfplotswarning{too many colormap positions}{index \c@pgfplots@elem\space (value \pgfplots@loc@TMPa)}\pgfeov% + \pgfplotsutil@advancestringcounter@global\c@pgfplots@elem + % + \pgfutil@repeat + % \pgfplotsapplistXlet\pgfplotsretval=\pgfplots@createcolormap@special@process@result \global\let\pgfplots@glob@TMPa=\pgfplotsretval \endgroup \let\pgfplotsretval=\pgfplots@glob@TMPa +%\message{of colormap with list functionality results in \meaning\pgfplotsretval^^J}% }% +\def\pgfplots@createcolormap@special@process@list@sampled{% + \begingroup + \pgfkeys{/pgf/fpu=true}% + \pgfplots@createcolormap@special@process@list@define@target@array + % + % no need to reapply it in \pgfplots@createcolormap@special@process@list: + \let\pgfplots@createcolormap@special@process@list@define@target@array=\relax + % + \pgfplots@createcolormap@special@process@list@sampled@define{S}% + \pgfplots@createcolormap@special@process@list + \global\let\pgfplots@glob@TMPa=\pgfplotsretval + \endgroup + \let\pgfplotsretval=\pgfplots@glob@TMPa +} + +% Defines +% * 'source range', +% * 'source pos', +% in a way such that it implements 'samples of colormap' +% #1: 'S' if it _must_ satisfy the number of samples and 'P' if it +% _must_ satisfy the positions +\def\pgfplots@createcolormap@special@process@list@sampled@define#1{% + \begingroup + \pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots@source + % + \def\b@pgfplots@special@interval{0}% + \def\b@pgfplots@special@interval@additional{0}% + \if c\pgfplots@ofcolorbar@sample@for@choice% + % or colormap/sample for=const: + % sample one less and replicate the last color. This + % is to compensate for 'colormap access/extra interval width=0' + % (which is the default for colormaps with positions) + \ifnum\pgfplots@pos@size>1 + % ah - we have at least 2 positions and 'extra interval width=0' applies! + \if S#1% + \c@pgf@counta=\pgfplots@source\relax + \advance\c@pgf@counta by1 % + \ifnum\pgfplots@pos@size=\c@pgf@counta + \else + \pgfplotsthrow{too few colormap positions}{\pgfplots@pos@size}{There is an unexpected number of arguments to 'target pos' for 'samples of colormap=(\pgfplots@source)'. Please provide \the\c@pgf@counta\space positions, not \pgfplots@pos@size}\pgfeov% + \fi + \fi + \if S#1% + % this is the case + % samples of colormap={5, target pos={<6 positions>}} + % -> we need to replicate the last color such that we see the rightmost color of the input map + \def\b@pgfplots@special@interval{1}% + % -> we also need one more sample point (one for each position): + \def\b@pgfplots@special@interval@additional{1}% + \else + % we have pgfplots@pos@size=pgfplots@source. + \if1\b@pgfplots@createcolormap@found@more@colors + % there are more positions/colors!? Ok, no need to + % apply it here: + \def\b@pgfplots@special@interval{0}% + \else + \def\b@pgfplots@special@interval{1}% + \fi + \fi + \else + \def\b@pgfplots@special@interval{0}% + \fi + \else + \def\b@pgfplots@special@interval{0}% + \ifnum\pgfplots@pos@size>1 + % ah - we have at least 2 positions + \if S#1% + \ifnum\pgfplots@pos@size=\pgfplots@source + \else + \pgfplotsthrow{too few colormap positions}{\pgfplots@pos@size}{There is an unexpected number of arguments to 'target pos' for 'samples of colormap=(\pgfplots@source)'. Please provide \pgfplots@source\space positions, not \pgfplots@pos@size}\pgfeov% + \fi + \fi + \fi + \fi + % + \if1\b@pgfplots@special@interval@additional + \c@pgf@counta=\pgfplots@source\relax + \advance\c@pgf@counta by+1 + \edef\pgfplots@source{\the\c@pgf@counta}% + \fi + \if1\b@pgfplots@special@interval + \begingroup + \c@pgf@counta=\pgfplots@source\relax + \advance\c@pgf@counta by-1 + % + \pgfplotsapplistXnewempty\pgfplots@createcolormap@trg@accum + \ifnum\c@pgf@counta<2 + \pgfmathfloatcreate{0}{0.0}{0}% + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult,}\to\pgfplots@createcolormap@trg@accum + \else + \edef\pgfplots@source{\the\c@pgf@counta}% + \pgfplots@domain@to@foreach 0:1000\relax{\pgfplots@source}% + % + \def\pgfplots@loc@TMPa{\pgfplotsforeachungrouped \x in}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplotsretval}{% + \expandafter\pgfplotsapplistXpushback\expandafter{\x,}\to\pgfplots@createcolormap@trg@accum + }% + \fi + % + \pgfmathfloatcreate{1}{1.0}{3}% + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots@createcolormap@trg@accum + % + \pgfplotsapplistXlet\pgfplots@target=\pgfplots@createcolormap@trg@accum + \global\let\pgfplots@glob@TMPa=\pgfplots@target + \endgroup + % + \let\pgfplotsretval=\pgfplots@glob@TMPa + \else + \pgfplots@domain@to@foreach 0:1000\relax{\pgfplots@source}% + \fi + \pgfmath@smuggleone\pgfplotsretval + \endgroup + \pgfkeyslet{/pgfplots/of colormap/source pos}\pgfplotsretval + \pgfqkeys{/pgfplots/of colormap}{% + source range=0:1000,% + }% +%\message{define sample positions(#1) = \pgfplotsretval^^J}% +}% + + +\def\pgfplots@createcolormap@special@process@list@separator@CM{ }% +\let\pgfplots@createcolormap@special@process@list@separator=\pgfplots@createcolormap@special@process@list@separator@CM %%%%%%%%%% +\def\b@pgfplots@createcolormap@found@more@colors{0}% + \def\pgfplots@createcolormap@grabnext@complete{% - \pgfutil@IfUndefined{pgfplots@createcolormap@grabnextspecial@\pgfplots@loc@TMPa}{% + \edef\pgfplots@loc@TMPd{% + \noexpand\pgfutil@in@{of color}{\pgfplots@loc@TMPa}% + }% + \pgfplots@loc@TMPd + \ifpgfutil@in@ + \def\pgfplots@loc@TMPd{% + \pgfplots@createcolormap@ifhasmorecolors{% + \def\b@pgfplots@createcolormap@found@more@colors{1}% + \pgfplots@createcolormap@grabnext@complete@of@colormap + }{% + \def\b@pgfplots@createcolormap@found@more@colors{0}% + \pgfplots@createcolormap@grabnext@complete@of@colormap + }% + }% + \else % ok, this is a 'normal' color specification with position, % colorspace, and color data. % @@ -301,53 +1035,89 @@ % % continue loop: \def\pgfplots@loc@TMPd{\pgfplots@createcolormap@}% - }{% - % ah - a special one based on another colormap! - % convert it into the standard format: - % - \t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPc}% - \edef\pgfplots@loc@TMPd{% - \expandafter\noexpand\csname pgfplots@createcolormap@grabnextspecial@\pgfplots@loc@TMPa\endcsname - % position: - {\pgfplots@loc@TMPb} - % argument: - {\the\t@pgfplots@tokb}% - }% - \pgfplots@loc@TMPd - % - \def\pgfplots@loc@TMPd{% - \expandafter\pgfplots@createcolormap@\pgfplotsretval - }% - }% + \fi % % % continue loop: \pgfplots@loc@TMPd }% +\def\pgfplots@createcolormap@grabnext@complete@of@colormap{% + % ah - a special one based on another colormap! + % convert it into the standard format: + \begingroup + \let\pgfplotscolormap@at=\pgfplots@loc@TMPb + \let\pgfplotscolormap@argument=\pgfplots@loc@TMPc + \let\pgfplotscolormap@key=\pgfplots@loc@TMPa + % + \pgfplots@createcolormap@grabnext@complete@ofcolormap + \pgfmath@smuggleone\pgfplotsretval + \endgroup + % + \expandafter\pgfplots@createcolormap@\pgfplotsretval +}% + +% INPUT: +% \pgfplotscolormap@at +% \pgfplotscolormap@argument +% \pgfplotscolormap@key +% OUTPUT: +% The result of /pgfplots/of colormap/@define. +% For the normal colormap definition, it populates +% \pgfplotsretval with the color specifications as they should +% be processed by the colormap definition code. +\def\pgfplots@createcolormap@grabnext@complete@ofcolormap{% + \t@pgfplots@tokb=\expandafter{\pgfplotscolormap@argument}% + \edef\pgfplotscolormap@keyvalue{% + \if m\b@pgfplots@createcolormap@pos@mode + % ah - we have had manually provided positions before. + % Well, keep them. Otherwise, we will stay at the default + % placement. + target pos={\pgfplotscolormap@at},% + \fi + % ... but can be overriden here: + \pgfplotscolormap@key={\the\t@pgfplots@tokb},% + }% + % + \let\pgfplots@createcolormap@special@process@single@define=\pgfplots@createcolormap@special@process@single@define@CM + \let\pgfplots@createcolormap@special@process@list@separator=\pgfplots@createcolormap@special@process@list@separator@CM + % + % finally, process the keys: + \expandafter\pgfplots@of@colormap@getresult\expandafter{% + \pgfplotscolormap@keyvalue, + }% +%\message{\pgfplotscolormap@key={\pgfplotscolormap@argument} -> '\pgfplotscolormap@keyvalue' -> \pgfplotsretval^^J}% +}% + \def\pgfplots@createcolormap@grabnext@computenextposition{% % determine next step size automatically: \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}% \ifpgfplotsarrayempty - % first: must be at 0. - \def\pgfmathresult{0sp}% + % first: just use 0. + \pgfmathfloatcreate{0}{0.0}{0}% \else % not first: \ifx\pgfplots@createcolormap@H\pgfutil@empty % ah; we really have to deduce something. We are at the % second node: - \def\pgfmathresult{1cm}% + %\def\pgfmathresult{1cm}% + \pgfmathfloatcreate{1}{2.845274}{1}% 1cm=28.45274pt . Backw compat \else - \pgfmathadd@\pgfplots@createcolormap@LAST\pgfplots@createcolormap@H + \pgfmathfloatadd@\pgfplots@createcolormap@LAST\pgfplots@createcolormap@H \fi \fi }% \def\pgfplots@createcolormap@grabsemicolon;{\pgfplots@createcolormap@}% +\def\pgfplots@createcolormap@grabcomma,{\pgfplots@createcolormap@}% + +\def\pgfplots@createcolormap@grabsemicolon@hasnext#1#2;{\pgfplots@createcolormap@ifhasmorecolors{#1}{#2}}% +\def\pgfplots@createcolormap@grabcomma@hasnext#1#2,{\pgfplots@createcolormap@ifhasmorecolors{#1}{#2}}% { \catcode`\;=13 \gdef\pgfplots@createcolormap@grabsemicolon@active;{\pgfplots@createcolormap@}% + \gdef\pgfplots@createcolormap@grabsemicolon@active@hasnext#1#2;{\pgfplots@createcolormap@ifhasmorecolors{#1}{#2}}% } \def\pgfplots@createcolormap@nextcolor@tostring#1=#2\pgfplots@EOI#3{% @@ -362,7 +1132,7 @@ % % see \pgfplotscolornormalizesequencenext for details \def\pgfplots@createcolormap@nextcolor#1#2{% - \def\pgfplots@createcolormap@context{\pgfplots@createcolormap@nextcolor@tostring#2\pgfplots@EOI{#1}}% + \def\pgfplots@createcolormap@context{\pgfplots@createcolormap@nextcolor@tostring#2\pgfplots@EOI{#1}\pgfplots@createcolormap@trace}% % \pgfplotscolornormalizesequencenext{#2}% \let\pgfplots@createcolormap@col@comps=\pgfplotsretvalb @@ -375,79 +1145,134 @@ % compute 'h': \pgfmathparse{#1}% \let\pgfplots@createcolormap@MAX=\pgfmathresult - \expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@createcolormap@LAST}% + % + \ifx\pgfplots@createcolormap@MIN\pgfutil@empty + % it is the first. + \let\pgfplots@createcolormap@MIN=\pgfmathresult + \let\pgfplots@createcolormap@LAST=\pgfmathresult + \fi + % + \expandafter\pgfmathfloatsubtract@\expandafter{\pgfmathresult}{\pgfplots@createcolormap@LAST}% \let\pgfplots@createcolormap@H@cur=\pgfmathresult -%\message{found current diff = \pgfplots@createcolormap@H@cur\ ( from \pgfplots@createcolormap@MAX pt - \pgfplots@createcolormap@LAST pt)^^J}% + \pgfplots@createcolormap@check@increasing@mesh@width \let\pgfplots@createcolormap@LAST=\pgfplots@createcolormap@MAX \ifx\pgfplots@createcolormap@H\pgfutil@empty \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}% \ifpgfplotsarrayempty - \ifdim\pgfplots@createcolormap@MAX pt=0pt - \else - \pgfplots@error{Sorry, the left end of a colormap (at 0pt) must be provided explicitly. You cannot start with \pgfplots@createcolormap@MAX pt. The error occured near `\pgfplots@createcolormap@context'}% - \def\pgfplots@createcolormap@MAX{0}% - \fi \else \let\pgfplots@createcolormap@H=\pgfplots@createcolormap@H@cur -%\message{H := \pgfplots@createcolormap@H( from #1).}% \fi \else - \pgfmathapproxequalto@{\pgfplots@createcolormap@H}{\pgfplots@createcolormap@H@cur}% - \ifpgfmathcomparison + \pgfplots@createcolormap@compute@equalto{\pgfplots@createcolormap@H}{\pgfplots@createcolormap@H@cur}% + \ifpgfmathfloatcomparison \else - \pgfmathdivide@{\pgfplots@createcolormap@H@cur}{\pgfplots@createcolormap@H}% - % after this group, \pgfmathresult is - % - empty if no reinterpolation is possible, - % - non-empty if reinterpolation IS possible. In this - % case, it contains the integer multiple of H. - \begingroup - \afterassignment\pgfplots@createcolormap@nextRGB@consider@reinterpolation - \c@pgf@counta=\pgfmathresult\relax - \pgfmath@smuggleone\pgfmathresult - \endgroup - \ifx\pgfmathresult\pgfutil@empty - % I can't do that yet. + \ifnum\b@pgfplotscreatecolormap@isuniform>1 + % force reinterpolation: + \pgfplotscreatecolormap@reinterpolate{#2}% \else - \let\pgfplots@createcolormap@loop@end=\pgfmathresult - % interpolate missing values using the already fixed H. - % This interpolation procedure is stupid because it works - % only in forward direction - but it works at least. - % For the backwards direction, you can provide the - % meshwidth explicitly at - % \pgfplotscreatecolormap{}{[1pt]} - \pgfplotsforeachungrouped \c@pgfplots@createcolormap in {1,2,...,\pgfplots@createcolormap@loop@end} {% - \ifdim\c@pgfplots@createcolormap pt=\pgfplots@createcolormap@loop@end pt % - % omit the last. - \else - \pgfmathparse{\c@pgfplots@createcolormap/\pgfplots@createcolormap@loop@end}% - \let\pgfplots@createcolormap@scale@current=\pgfmathresult - \pgfmathparse{1-\pgfplots@createcolormap@scale@current}% - \let\pgfplots@createcolormap@scale@last=\pgfmathresult - % - \pgfplotscolornormalizesequencezero - \pgfplotscolornormalizesequenceaddweighted - {\pgfplotsretval} - {\pgfplots@createcolormap@scale@current} - {#2}% - \pgfplotscolornormalizesequenceaddweighted - {\pgfplotsretval} - {\pgfplots@createcolormap@scale@last} - {\pgfplots@createcolormap@last}% - % -%\message{interpolation step \c@pgfplots@createcolormap = \pgfplotsretval^^J}% - \edef\pgfplots@loc@TMPa{% - \noexpand\pgfplotsarraypushback{\pgfplotsretval}% - \noexpand\to}% - \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}% - \fi - }% + % it is NOT uniform! + \def\b@pgfplotscreatecolormap@isuniform{0}% + % + \pgfmathfloatmintwo{\pgfplots@createcolormap@H@cur}{\pgfplots@createcolormap@H}% + \let\pgfplots@createcolormap@H=\pgfmathresult \fi \fi \fi + %\message{found current H@cur = \pgfplots@createcolormap@H@cur\space (\pgfplots@createcolormap@LAST) -> H=\pgfplots@createcolormap@H^^J}% + % + % remember positions: + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@createcolormap@MAX,}\to\pgfplots@createcolormap@X + % \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsarraypushback{#2}\noexpand\to}% \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}% \edef\pgfplots@createcolormap@last{#2}% }% + +\def\pgfplots@createcolormap@check@increasing@mesh@width{% + \expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots@createcolormap@name}% + \ifpgfplotsarrayempty + \else + \pgfmathfloatifflags{\pgfplots@createcolormap@H@cur}{1}{% + % ok, H>0 + }{% + \pgfmathfloattofixed{\pgfplots@createcolormap@H@cur}% + \pgfplots@error{Colormaps must have increasing positions. The provided colormap has mesh width '\pgfmathresult' at \pgfplots@createcolormap@context. Please assign increasing positions}% + }% + \fi +}% +\def\pgfplots@createcolormap@compute@equalto#1#2{% + %\begingroup + %\pgfmathfloatcreate{1}{1.0}{-4}% + %\let\pgfmathfloat@relthresh=\pgfmathresult + \pgfmathfloatequalto@{#1}{#2}% + %\xdef\pgfplots@glob@TMPa{% + % \noexpand\def\noexpand\pgfmathresult{\pgfmathresult}% + % \ifpgfmathfloatcomparison + % \noexpand\pgfmathfloatcomparisontrue + % \else + % \noexpand\pgfmathfloatcomparisonfalse + % \fi + %}% + %\endgroup + %\pgfplots@glob@TMPa + %\message{equalto (#1,#2) = \pgfmathresult^^J}% +}% +\def\pgfplotscreatecolormap@reinterpolate#1{% + \pgfmathfloatdivide@{\pgfplots@createcolormap@H@cur}{\pgfplots@createcolormap@H}% + % after this group, \pgfmathresult is + % - empty if no reinterpolation is possible, + % - non-empty if reinterpolation IS possible. In this + % case, it contains the integer multiple of H. + \begingroup + \pgfmathfloattofixed{\pgfmathresult}% + \afterassignment\pgfplots@createcolormap@nextRGB@consider@reinterpolation + \c@pgf@counta=\pgfmathresult\relax + \pgfmath@smuggleone\pgfmathresult + \endgroup + \ifx\pgfmathresult\pgfutil@empty + % I can't do that yet. + \else + \let\pgfplots@createcolormap@loop@end=\pgfmathresult + % interpolate missing values using the already fixed H. + % This interpolation procedure is stupid because it works + % only in forward direction - but it works at least. + % For the backwards direction, you can provide the + % meshwidth explicitly at + % \pgfplotscreatecolormap{}{[1pt]} + \pgfplotsforeachungrouped \c@pgfplots@createcolormap in {1,2,...,\pgfplots@createcolormap@loop@end} {% + \pgfmathfloatequalto@{\c@pgfplots@createcolormap}{\pgfplots@createcolormap@loop@end}% + \ifpgfmathfloatcomparison + % omit the last. + \else + \pgfmathparse{\c@pgfplots@createcolormap/\pgfplots@createcolormap@loop@end}% + \let\pgfplots@createcolormap@scale@current=\pgfmathresult + \pgfmathparse{1-\pgfplots@createcolormap@scale@current}% + \let\pgfplots@createcolormap@scale@last=\pgfmathresult + % + \pgfmathfloattofixed\pgfplots@createcolormap@scale@current + \let\pgfplots@createcolormap@scale@current=\pgfmathresult + \pgfmathfloattofixed\pgfplots@createcolormap@scale@last + \let\pgfplots@createcolormap@scale@last=\pgfmathresult + % + \pgfplotscolornormalizesequencezero + \pgfplotscolornormalizesequenceaddweighted + {\pgfplotsretval} + {\pgfplots@createcolormap@scale@current} + {#1}% + \pgfplotscolornormalizesequenceaddweighted + {\pgfplotsretval} + {\pgfplots@createcolormap@scale@last} + {\pgfplots@createcolormap@last}% + % +%\message{interpolation step \c@pgfplots@createcolormap = \pgfplotsretval^^J}% + \edef\pgfplots@loc@TMPa{% + \noexpand\pgfplotsarraypushback{\pgfplotsretval}% + \noexpand\to}% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}% + \fi + }% + \fi +}% \def\pgfplots@createcolormap@nextRGB@consider@reinterpolation#1\relax{% \pgf@xa=#1pt \ifdim\pgf@xa>0.5pt % we have something like 99.995 or so. @@ -462,7 +1287,17 @@ %\message{Checking H/h = \pgfplots@createcolormap@H@cur pt/\pgfplots@createcolormap@H pt = \the\c@pgf@counta+-\pgf@sys@tonumber\pgf@xa\space: \the\pgf@xa > \the\pgf@xb\space (relative to \the\c@pgf@counta)?}% % \ifdim\pgf@xa>\pgf@xb - \pgfplots@error{Sorry, non-uniform colormaps are only partially implemented, yet: the provided points must be multiples of the mesh width h=\pgfplots@createcolormap@H pt (but I found one with H/h = \pgfplots@createcolormap@H@cur pt/\pgfplots@createcolormap@H pt = \the\c@pgf@counta+-\pgf@sys@tonumber\pgf@xa\space which is no integer). Perhaps it helps to provide the mesh widths as argument as in {<name>}{[1cm] <color arguments>}? The error occured near `\pgfplots@createcolormap@context'}% + \begingroup + \if2\b@pgfplotscreatecolormap@isuniform + \pgfplots@error{Non-uniform colormaps are only supported if you write 'compat=1.14' (or higher). Please adopt the compatibility level and retry. The error occured near '\pgfplots@createcolormap@context'}% + \else + \pgfmathfloattofixed{\pgfplots@createcolormap@H}% + \let\pgfplots@createcolormap@H=\pgfmathresult + \pgfmathfloattofixed{\pgfplots@createcolormap@H@cur}% + \let\pgfplots@createcolormap@H@cur=\pgfmathresult + \pgfplots@error{The provided colormap positions are not multiples of the prescribed mesh width h=\pgfplots@createcolormap@H\space (found one with H/h = \pgfplots@createcolormap@H@cur/\pgfplots@createcolormap@H = \the\c@pgf@counta+-\pgf@sys@tonumber\pgf@xa\space which is no integer). The error occured near `\pgfplots@createcolormap@context'}% + \fi + \endgroup \let\pgfmathresult=\pgfutil@empty \else \ifnum\c@pgf@counta=0 @@ -475,7 +1310,9 @@ \def\pgfplots@colormap@LUA@new#1{% \ifpgfplots@LUA@supported - \pgfplotscolormapserializecomponentstomacro{#1}\pgfplots@loc@TMPa + \begingroup + \pgfplotscolormapserializecomponentstomacro{#1}\pgfplots@values + \pgfplotscolormapserializeXtomacro{#1}\pgfplots@pos \pgfplotsutil@directlua{% local colorspace =^^J% pgfplots.\csname pgfpl@cm@#1@colspace\endcsname;^^J% @@ -483,13 +1320,27 @@ pgfplots.ColorMaps["#1"] = pgfplots.ColorMap.new(^^J% \csname pgfpl@cm@#1@h\endcsname,^^J% colorspace,^^J% - { \pgfplots@loc@TMPa });^^J% + { \pgfplots@values },^^J + { \pgfplots@pos }^^J + );^^J% else^^J% io.write("There is no LUA colorspace for '\csname pgfpl@cm@#1@colspace\endcsname' - skipping LUA color map definition of #1\string\n");^^J% end^^J% }% + \endgroup + \fi +}% + +% Executes '#2' if the colormap named '#1' has a uniform grid and '#3' +% if not. +\def\pgfplotscolormapifisuniform#1#2#3{% + \ifnum0=\pgfplotsarraysizeof{pgfpl@cm@#1@X}\relax + #2\relax + \else + #3\relax \fi }% + % Shows debug info about colormap #1 into the console. \def\pgfplots@colormap@showdebuginfofor#1{% \message{Debug info for color map '#1':^^J}% @@ -501,10 +1352,18 @@ \message{Colorspace: \csname pgfpl@cm@#1@colspace\endcsname^^JValues (\csname pgfpl@cm@#1@col@comps\endcsname\space components each): ^^J}% \begingroup \c@pgf@counta=0 - \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\elem{% - \pgfmath@basic@multiply@{\the\c@pgf@counta}{\csname pgfpl@cm@#1@h\endcsname}% - \message{\#\the\c@pgf@counta=(\pgfmathresult)=(\elem);^^J}% - \advance\c@pgf@counta by1 % + \pgfplotscolormapifisuniform{#1}{% + \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\elem{% + \pgfmath@basic@multiply@{\the\c@pgf@counta}{\csname pgfpl@cm@#1@h\endcsname}% + \message{\#\the\c@pgf@counta=(\pgfmathresult)=(\elem);^^J}% + \advance\c@pgf@counta by1 % + }% + }{% + \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\elem{% + \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#1@X}\to\pgfmathresult + \message{\#\the\c@pgf@counta=(\pgfmathresult)=(\elem);^^J}% + \advance\c@pgf@counta by1 % + }% }% \message{^^J}% \endgroup @@ -587,7 +1446,11 @@ \pgfplotsarrayforeach{pgfpl@cm@#2}\as\elem{% \ifnum\pgfplots@eachnth@cur=0\relax \gdef\pgfplots@eachnth@cur{0}% - \pgfmath@basic@multiply@{\pgfplotsarrayforeachindex}{\csname pgfpl@cm@#2@h\endcsname}% + \pgfplotscolormapifisuniform{#2}{% + \pgfmath@basic@multiply@{\pgfplotsarrayforeachindex}{\csname pgfpl@cm@#2@h\endcsname}% + }{% + \pgfplotsarrayselect\pgfplotsarrayforeachindex\of{pgfpl@cm@#1@X}\to\pgfmathresult + }% \edef\pgfplots@loc@TMPa{{\elem}{#2}{\pgfplotsarrayforeachindex}{\pgfmathresult}}% \expandafter\pgfplotscolormaptodatafile@elem\pgfplots@loc@TMPa \ifx\pgfplotsretval\pgfutil@empty @@ -613,7 +1476,9 @@ \endgroup } -% Defines \pgfplotsretval to contain the mesh width of colormap #1 +% Defines \pgfplotsretval to contain the mesh width of colormap #1. +% If the color map has a non-uniform grid, it returns the SMALLEST +% encountered mesh width. \def\pgfplotscolormapgetmeshwidth#1{% \expandafter\let\expandafter\pgfplotsretval\csname pgfpl@cm@#1@h\endcsname% }% @@ -621,13 +1486,39 @@ % defines macro #2 to contain a serialized variant of the color % components (only the color components!) \def\pgfplotscolormapserializecomponentstomacro#1#2{% + \pgfplotscolormapserialize@to@macro{pgfpl@cm@#1}{#2}% +} +\def\pgfplotscolormapserialize@to@macro#1#2{% \pgfplotsapplistXnewempty\pgfplots@serialize@list@ - \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\elem{% - \expandafter\pgfplotsapplistXpushback\expandafter{\elem},\to\pgfplots@serialize@list@ + \pgfplots@loc@tmptrue + \expandafter\pgfplotsarrayforeachungrouped\expandafter{#1}\as\elem{% + \ifpgfplots@loc@tmp + \expandafter\pgfplotsapplistXpushback\expandafter{\expandafter{\elem}}\to\pgfplots@serialize@list@ + \pgfplots@loc@tmpfalse + \else + \expandafter\pgfplotsapplistXpushback\expandafter,\expandafter{\elem}\to\pgfplots@serialize@list@ + \fi }% \pgfplotsapplistXlet#2=\pgfplots@serialize@list@ }% +\def\pgfplotscolormapserialize@to@macro@nobraces#1#2{% + \pgfplotsapplistXnewempty\pgfplots@serialize@list@ + \pgfplots@loc@tmptrue + \expandafter\pgfplotsarrayforeachungrouped\expandafter{#1}\as\elem{% + \ifpgfplots@loc@tmp + \expandafter\pgfplotsapplistXpushback\elem\to\pgfplots@serialize@list@ + \pgfplots@loc@tmpfalse + \else + \expandafter\pgfplotsapplistXpushback\expandafter,\elem\to\pgfplots@serialize@list@ + \fi + }% + \pgfplotsapplistXlet#2=\pgfplots@serialize@list@ +}% +\def\pgfplotscolormapserializeXtomacro#1#2{% + \pgfplotscolormapserialize@to@macro@nobraces{pgfpl@cm@#1@X}{#2}% +}% + % Copies the contents of the colormap named '#1' into a macro '#2'. % Invocation of the macro will then re-create the colormap. % @@ -636,6 +1527,7 @@ \def\pgfplotscolormapserializetomacro#1#2{% \begingroup \pgfplotscolormapserializecomponentstomacro{#1}\pgfplots@serialize@list + \pgfplotscolormapserializeXtomacro{#1}\pgfplots@serialize@list@X \toks0={\expandafter\def\csname pgfpl@cm@#1@h\endcsname}% \toks1={\expandafter\def\csname pgfpl@cm@#1@invh\endcsname}% \toks2={% @@ -651,6 +1543,16 @@ \toks4=\expandafter{\expandafter\def\csname pgfpl@cm@#1@colspace\endcsname}% \toks5=\expandafter{\expandafter\def\csname pgfpl@cm@#1@col@comps\endcsname}% \toks6=\expandafter{\expandafter\def\csname pgfpl@cm@#1@lastindex\endcsname}% + \toks7={% + \pgfplotsarraynewempty{pgfpl@cm@#1@X}% + \expandafter\pgfplotsutilforeachcommasep\pgfplots@loc@TMPa\as\pgfplots@loc@TMPb{% + \ifx\pgfplots@loc@TMPb\pgfutil@empty + \else + \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPb\to{pgfpl@cm@#1@X}% + \fi + }% + }% + \toks8=\expandafter{\pgfplots@serialize@list@X}% \xdef\pgfplots@glob@TMPa{% \the\toks0 {\csname pgfpl@cm@#1@h\endcsname}% \the\toks1 {\csname pgfpl@cm@#1@invh\endcsname}% @@ -659,15 +1561,97 @@ \the\toks4 {\csname pgfpl@cm@#1@colspace\endcsname}% \the\toks5 {\csname pgfpl@cm@#1@col@comps\endcsname}% \the\toks6 {\csname pgfpl@cm@#1@lastindex\endcsname}% + \noexpand\def\noexpand\pgfplots@loc@TMPa{\the\toks8 }% + \the\toks7 + \def\expandafter\noexpand\csname pgfpl@cm@#1@X@scale@order@z\endcsname{\csname pgfpl@cm@#1@X@scale@order@z\endcsname}% }% \endgroup \let#2=\pgfplots@glob@TMPa }% +% Defines \pgfplotsretval to contain an argument for use in \foreachlist +% which results in all the positions. +% +% [#1:#2] : the desired output domain. The smallest position will be +% mapped to #1, the largest to #2, and all in-between will be mapped +% accordingly. +% #3: the colormap name. +% +% Note that this switch depends on the current value of 'colormap +% access': piecewise constant may use different positions. +% +% On output, \pgfplotsretval will contain the result. +\def\pgfplotscolormapgetpositions[#1:#2]#3{% + \begingroup + \if d\pgfplots@colormap@access + \edef\pgfplotsretval{0,1,...,\pgfplotscolormaplastindexof{#3}}% + \else + \if m\pgfplots@colormap@access + \def\b@pgfplots@extra@interval{0}% + \edef\pgfplots@H{\csname pgfpl@cm@#3@h\endcsname}% + \else + \if c\pgfplots@colormap@access + \pgfplotscolormap@piecewiseconst@prepare@scale{#3}% + \edef\pgfplots@H{\pgf@sys@tonumber\pgf@x}% + \fi + \fi + % + \pgfkeys{/pgf/fpu}% + \pgfplotsapplistXnewempty\pgfplots@resultaccum + \pgfplotscolormapifisuniform{#3}{% + \pgfmathparse{#1 + (#2-#1) * \pgfplots@H/1000}% + \let\next=\pgfmathresult + \pgfmathparse{#2}% + (#2-#1)/1000}% + % + \def\b@pgfplots@isfirst{1}% + \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungrouped\noexpand \x in {#1,\next,...,\pgfmathresult}}% + \pgfplots@loc@TMPa{% + \if0\b@pgfplots@isfirst + \pgfplotsapplistXpushback,\to\pgfplots@resultaccum + \fi + \expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots@resultaccum + \def\b@pgfplots@isfirst{0}% + }% + }{% + \pgfmathparse{(#2-#1)/1000}% + \let\pgfplots@scale=\pgfmathresult + \pgfplotsarrayforeachungrouped{pgfpl@cm@#3@X}\as\pgfplots@loc@TMPc{% + \if m\pgfplots@colormap@access + % colormap access=map + \pgfmathparse{#1 + \pgfplots@loc@TMPc * \pgfplots@scale}% + \else + \if1\b@pgfplots@extra@interval + \pgfmathparse{#1 + \pgfplots@loc@TMPc * \pgfplots@H* \pgfplots@scale}% + \else + % DISABLE additional interval! + % Means: use the input position as usual: + \pgfmathparse{#1 + \pgfplots@loc@TMPc * \pgfplots@scale}% + \fi + \fi + \ifnum\pgfplotsarrayforeachindex>0 + \pgfplotsapplistXpushback,\to\pgfplots@resultaccum + \fi + \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots@resultaccum + }% + \if1\b@pgfplots@extra@interval + \pgfmathparse{#2}% + \pgfplotsapplistXpushback,\to\pgfplots@resultaccum + \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots@resultaccum + \fi + }% + \pgfplotsapplistXlet\pgfplotsretval=\pgfplots@resultaccum + \fi + \pgfmath@smuggleone\pgfplotsretval + \endgroup +}% + % this is a CONSTANT! Do NOT change it! % Just read it -- just in case \pgfplotscolormaptopdffunction will use % a different upper bound in the future. -\def\pgfplotscolormappdfmax{1}% FIXME : why? 1000 would be more precise...? +\def\pgfplotscolormappdfmax{1000}% +\def\pgfplotscolormappdfmax@inv{1}% % Expands to the size of colormap #1 . \def\pgfplotscolormapsizeof#1{% @@ -678,6 +1662,12 @@ }% }% +% Defines \pgfplotsretval to contain the color of color map '#1' at +% index '#2' +\def\pgfplotscolormapgetcolor#1#2{% + \pgfplotsarrayselect{#2}\of{pgfpl@cm@#1}\to\pgfplotsretval +}% + % Expands to the last index of colormap #1 (or -1) \def\pgfplotscolormaplastindexof#1{% \pgfplotscolormapifdefined{#1}{% @@ -687,6 +1677,100 @@ }% }% +% POSTCONDITION: +% 1. for uniform #1: +% \pgf@x contains the MODIFIED mesh width +% \b@pgfplots@extra@interval is 1 if and only if an extra interval +% should be added +% 2. for non-uniform #1: +% \pgf@x is a scaling factor to map input positions to MODIFIED +% positions +% \b@pgfplots@extra@interval is 1 if and only if an extra interval +\def\pgfplotscolormap@piecewiseconst@prepare@scale#1{% + % advance the number of intervals by 1. + \pgfplotscolormapifisuniform{#1}{% + % To this end, we have to compute + % N = n+1 + % and + % H = 1000 / (N-1) = 1000/n. + % Store H in \pgf@x: + \expandafter\ifx\csname pgfpl@cm@#1@X@scale@order@z\endcsname\pgfutil@empty% + \c@pgf@countd=\pgfplotscolormapsizeof{#1}\relax + % + \global\pgf@x=1000pt % + \global\divide\pgf@x by\c@pgf@countd + \def\b@pgfplots@extra@interval{1}% + \else + % DISABLE the extra interval! + \global\pgf@x=\csname pgfpl@cm@#1@h\endcsname pt % + \def\b@pgfplots@extra@interval{0}% + \fi + }{% + % the very same idea as for uniform colormaps applies + % for non-uniform maps as well: we create an + % artificial interval at the rightmost end. + % The idea is to think of a temporary map in the range + % [0,1000+ h] where h is the current colormap's + % mesh width. + % Since the domain is [0,1000], we map [0,1000+h] + % linearly into [0,1000]. + % + % This here is the scaling factor: + \global\pgf@x=\csname pgfpl@cm@#1@X@scale@order@z\endcsname pt % + % see also + % \pgfplotscolormapfindpiecewiseconst@precomputed for + % comments + \ifdim\pgf@x>0sp % + \def\b@pgfplots@extra@interval{1}% + \else + % disable it + \def\b@pgfplots@extra@interval{0}% + \fi + }% +}% + +% #1: colormap name +% #2: yes code +% #3: no code +\def\pgfplotscolormapifrequiresextrainterval#1#2#3{% + \if c\pgfplots@colormap@access + \pgfplotscolormapifisuniform{#1}{% + \expandafter\ifx\csname pgfpl@cm@#1@X@scale@order@z\endcsname\pgfutil@empty% + % no... + #3\relax% + \else + % yes: + #2\relax% + \fi + }{% + \ifdim\csname pgfpl@cm@#1@X@scale@order@z\endcsname pt>0pt + % yes: + #2\relax% + \else + % no: + #3\relax% + \fi + }% + \else + % no: + #3\relax% + \fi +}% +% #1: colormap name +% #2: yes code +% #3: no code +\def\pgfplotscolormapifdrawslastcolor#1#2#3{% + \pgfplotscolormapifrequiresextrainterval{#1}{% + #2\relax% + }{% + \if c\pgfplots@colormap@access + #3\relax% + \else + #2\relax% + \fi + }% +}% + % Writes a PDF function of /FunctionType 3 to \pgfplotsretval % % The /Domain argument will be set to [ 0 \pgfplotscolormappdfmax ] and bounds will be @@ -715,6 +1799,7 @@ \pgfplots@error{Sorry, processing more than 4 color components (as required for color map #1) is unsupported in this context}% \fi % + \def\b@pgfplots@extra@interval{0}% \if m\pgfplots@colormap@access % colormap access=map \def\pgfplots@order{1}% @@ -729,16 +1814,7 @@ % See comments in pgfplotscolormapfindpiecewiseconst@precomputed@ \def\pgfplots@order{0}% % - % advance the number of intervals by 1. - % To this end, we have to compute - % N = n+1 - % and - % H = 1000 / (N-1) = 1000/n. - % Store H in \pgf@x: - \c@pgf@countd=\pgfplotscolormapsizeof{#1}\relax - % - \global\pgf@x=1000pt % - \global\divide\pgf@x by\c@pgf@countd + \pgfplotscolormap@piecewiseconst@prepare@scale{#1}% % % interchange the sequence in the PDF function as it is % defined as @@ -775,9 +1851,25 @@ }% \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPd}\to\pgfplots@resultaccum \ifnum\c@pgf@counta<\c@pgf@countb\relax - \pgf@xa=\pgf@x - \multiply\pgf@xa by\c@pgf@counta\relax - \divide\pgf@xa by1000 % we want [ 0 1 ] not [0 1000] as domain XXX : why!? + \pgfplotscolormapifisuniform{#1}{% + \pgf@xa=\pgf@x + \multiply\pgf@xa by\c@pgf@counta\relax + }{% + \pgfplotsarrayselect{\c@pgf@counta}\of{pgfpl@cm@#1@X}\to\pgfplots@loc@TMPc + \if m\pgfplots@colormap@access + % colormap access=map + \pgf@xa=\pgfplots@loc@TMPc pt % + \else + \if1\b@pgfplots@extra@interval + \pgf@xa=\pgfplots@loc@TMPc\pgf@x% + \else + % DISABLE additional interval! + % Means: use the input position as usual: + \pgf@xa=\pgfplots@loc@TMPc pt % + \fi + \fi + }% + \divide\pgf@xa by\pgfplotscolormappdfmax@inv\relax% we want [ 0 1 ] not [0 1000] as domain XXX : why!? \edef\pgfplots@loc@TMPc{ \pgf@sys@tonumber\pgf@xa}% \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPc}\to\pgfplots@bounds@accum% \fi @@ -786,7 +1878,7 @@ \let\pgfplots@loc@TMPa=\cdata \advance\c@pgf@counta by1 }% - \if 0\pgfplots@order + \if1\b@pgfplots@extra@interval % add an artificial interval. \edef\pgfplots@loc@TMPd{% << @@ -797,10 +1889,15 @@ >> }% \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPd}\to\pgfplots@resultaccum - \pgf@xa=\pgf@x \advance\c@pgf@counta by-1 % - \multiply\pgf@xa by\c@pgf@counta\relax - \divide\pgf@xa by1000 % we want [ 0 1 ] not [0 1000] as domain XXX : why!? + \pgfplotscolormapifisuniform{#1}{% + \pgf@xa=\pgf@x + \multiply\pgf@xa by\c@pgf@counta\relax + }{% + \pgfplotsarrayselect{\c@pgf@counta}\of{pgfpl@cm@#1@X}\to\pgfplots@loc@TMPc + \pgf@xa=\pgfplots@loc@TMPc\pgf@x% + }% + \divide\pgf@xa by\pgfplotscolormappdfmax@inv\relax% we want [ 0 1 ] not [0 1000] as domain XXX : why!? \edef\pgfplots@loc@TMPc{ \pgf@sys@tonumber\pgf@xa}% \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPc}\to\pgfplots@bounds@accum% \pgfplotsapplistXpushback{ 0 1}\to\pgfplots@encode@accum% @@ -865,7 +1962,13 @@ \c@pgf@counta=0 \let#3=\pgfutil@empty \pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\pgfplotscolormaptoshadingspec@TMP{% - \pgf@yb=\c@pgf@counta\pgf@ya + \pgfplotscolormapifisuniform{#1}{% + \pgf@yb=\c@pgf@counta\pgf@ya + }{% + \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#1@X}\to\pgfplots@loc@TMPd + \pgfmathmultiply@{\pgfplots@loc@TMPd}{\pgfplots@loc@TMPb}% + \pgf@yb=\pgfmathresult pt % + }% \edef\pgfplots@colspace{\csname pgfpl@cm@#1@colspace\endcsname}% % FIXME : PGF shadings accept only RGB! \if1\pgfplotscolormaptoshadingspectorgb @@ -910,6 +2013,8 @@ % Expands to the transformed range's right end of every colormap. The left % end is fixed to '0'. \def\pgfplotscolormaprange{1000} +\pgfmathfloatcreate{1}{1.0}{3}% +\let\pgfplotscolormaprange@float=\pgfmathresult \def\pgfplotscolormapgetcolorspace#1{% \edef\pgfplotsretval{\csname pgfpl@cm@#1@colspace\endcsname}% @@ -952,17 +2057,22 @@ }% \def\pgfplotscolormapfind@precomputed[#1:#2][#3]#4#5{% \ifpgfplots@LUA@supported - \edef\pgfmathresult{% - \pgfplotsutil@directlua{% - pgfplots.texColorMapPrecomputed("#5", #1,#2,#4) + \pgfplotscolormapifisuniform{#5}{% + \edef\pgfmathresult{% + \pgfplotsutil@directlua{% + pgfplots.texColorMapPrecomputed("#5", "#1","#2","#4") + }% }% - }% - \ifx\pgfmathresult\pgfutil@empty - \pgfplotscolormapfind@precomputed@warn@LUA{#5}% + \ifx\pgfmathresult\pgfutil@empty + \pgfplotscolormapfind@precomputed@warn@LUA{#5}% + \pgfplotscolormapfind@precomputed@[#1:#2][#3]{#4}{#5}% + \else + %\message{LUA colormapfind[#1:#2](#4)(#5) = \pgfmathresult^^J}% + \fi + }{% + % FIXME : implement LUA for non-uniform colormaps \pgfplotscolormapfind@precomputed@[#1:#2][#3]{#4}{#5}% - \else - %\message{LUA colormapfind[#1:#2](#4)(#5) = \pgfmathresult^^J}% - \fi + }% \else \pgfplotscolormapfind@precomputed@[#1:#2][#3]{#4}{#5}% \fi @@ -974,33 +2084,45 @@ \expandafter\gdef\csname pgfplotscolormapfind@precomputed@warn@LUA@#1\endcsname{1}% \fi }% -\def\pgfplotscolormapfind@@@[#1:#2][#3]#4#5{% - % Step 0: compute #3 if it is missing and write it into - % \pgfplots@loc@TMPa. - \def\pgfplots@loc@TMPa{#3}% - \ifx\pgfplots@loc@TMPa\pgfutil@empty - \pgfmathsubtract@{#2}{#1}% - \let\pgfplots@loc@TMPb=\pgfmathresult - \pgfmathdivide@{\pgfplotscolormaprange}{\pgfplots@loc@TMPb}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \fi -%\message{mapping '#4' into colormap '#5' ... ^^J}% - \def\pgfplots@loc@samerange{0:1000}% +\def\pgfplotscolormapfind@transform[#1:#2][#3]#4#5{% + \edef\pgfplots@loc@TMPa{#1:#2}% + \edef\pgfplots@loc@samerange{0:\pgfplotscolormaprange}% \ifx\pgfplots@loc@TMPa\pgfplots@loc@samerange % we have phi(#4) = #4 because #4 in [0:1000]. - \def\pgfmathresult{#4}% + \pgfmathfloatparsenumber{#4}% + \pgfmathfloattofixed\pgfmathresult \else + % Step 0: compute #3 if it is missing and write it into \pgfplots@loc@TMPa. +%\message{mapping '#4' into colormap '#5' with range [#1:#2] ... ^^J}% + \pgfmathfloatparsenumber{#1}% + \let\pgfplots@L=\pgfmathresult + % + \def\pgfplots@loc@TMPa{#3}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfmathfloatparsenumber{#2}% + \let\pgfplots@R=\pgfmathresult + \pgfmathfloatsubtract@{\pgfplots@R}{\pgfplots@L}% + \let\pgfplots@loc@TMPb=\pgfmathresult + \pgfmathfloatdivide@{\pgfplotscolormaprange@float}{\pgfplots@loc@TMPb}% + \else + \pgfmathfloatparsenumber{#3}% + \fi + \let\pgfplots@loc@TMPa=\pgfmathresult + % % Step 1: perform lookup. Map #4 into the colormap's range % using the linear trafo % phi(#4) = ( #4 - #1 ) / (#2-#1) * colormaprange(#5). % This, determine the INTERVAL number into which #4 falls. - \pgfmathsubtract@{#4}{#1}% - \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPa}% + \pgfmathfloatparsenumber{#4}% + \let\pgfplots@V=\pgfmathresult + \pgfmathfloatsubtract@{\pgfplots@V}{\pgfplots@L}% + \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots@loc@TMPa}% + \pgfmathfloattofixed\pgfmathresult \fi - \ifdim\pgfmathresult pt<0pt + \ifdim\pgfmathresult pt<0pt % \def\pgfmathresult{0}% \else - \ifdim\pgfmathresult pt>1000pt + \ifdim\pgfmathresult pt>1000pt % \def\pgfmathresult{1000}% \fi \fi @@ -1008,44 +2130,84 @@ \def\pgfplotscolormapfind@precomputed@[#1:#2][#3]#4#5{% \pgfplotscolormapassertexists{#5}% \begingroup - \pgfplotscolormapfind@@@[#1:#2][#3]{#4}{#5}% + \pgfplotscolormapfind@transform[#1:#2][#3]{#4}{#5}% + \let\pgfplotscolormapfind@transformedx=\pgfmathresult % % Now, we have it in [0,1000]. Find the correct interval: - \let\pgfplotscolormapfind@transformedx=\pgfmathresult - \pgfmathmultiply@{\pgfplotscolormapfind@transformedx}{\csname pgfpl@cm@#5@invh\endcsname}% - \let\pgfplotscolormapfind@transformedx@divh=\pgfmathresult - \expandafter\pgfmathfloor@\expandafter{\pgfmathresult}% - % assign \pgfplotscolormapfind@intervalno := \pgfmathresult - % without '.0' suffix: - \def\pgfplots@discardperiod##1.##2\relax{\def\pgfplotscolormapfind@intervalno{##1}}% - \expandafter\pgfplots@discardperiod\pgfmathresult\relax - % Step 2: interpolate the desired RGB value using vector valued - % interpolation on the identified interval. - \c@pgf@counta=\pgfplotscolormapfind@intervalno\relax + \pgfplotscolormapifisuniform{#5}{% + \pgfmathmultiply@{\pgfplotscolormapfind@transformedx}{\csname pgfpl@cm@#5@invh\endcsname}% + \let\pgfplotscolormapfind@transformedx@divh=\pgfmathresult + % assign \pgfplotscolormapfind@intervalno := \pgfmathresult + % without '.0' suffix: + \expandafter\pgfplotscolormap@floor@unforgiving\pgfmathresult\relax + % Step 2: interpolate the desired RGB value using vector valued + % interpolation on the identified interval. + \c@pgf@counta=\pgfplotscolormapfind@intervalno\relax + % color^m(x) = ( (x-x_i)/(x_{i+1} - x_i) ) * (c_{i+1}^m - c_i^m ) + c_i^m + % = ( x/h - i ) * ( c_{i+1}^m - c_{i}^m ) + c_i^m + % = s * c_{i+1}^m + S * c_i^m + % + % s= x_h / h -i + \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}% + \let\pgfplots@loc@factor=\pgfmathresult + }{% + \pgfplotsarraybinarysearch{pgfpl@cm@#5@X}{\pgfplotscolormapfind@transformedx}{0}{\pgfplotscolormapsizeof{#5}}% + \c@pgf@counta=\pgfplotsretval\relax + \ifnum\c@pgf@counta<0 + % as per definition of \pgfplotsarraybinarysearch, a + % negative result indicates the "insertion point" ... + \c@pgf@counta=-\c@pgf@counta + % ... plus one. + \advance\c@pgf@counta by-1 + % + % But we do not WANT the insertion point! We want the LEFT + % interval boundary! + \advance\c@pgf@counta by-1 + \fi + % + % color^m(x) = ( (x-x_i)/(x_{i+1} - x_i) ) * (c_{i+1}^m - c_i^m ) + c_i^m + % = s * c_{i+1}^m + S * c_i^m + % + % s = (x - x_i) / (x_{i+1} - x_i) + \begingroup + \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5@X}\to\pgfplotscolormapfind@rgb@X@left + \advance\c@pgf@counta by1 + \ifnum\c@pgf@counta<\pgfplotsarraysizeof{pgfpl@cm@#5} % + % ok, we really have an interval + \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5@X}\to\pgfplotscolormapfind@rgb@X@right + % + \pgfmathsubtract@{\pgfplotscolormapfind@rgb@X@right}{\pgfplotscolormapfind@rgb@X@left}% + \let\pgfplotscolormapfind@h=\pgfmathresult + \pgfmathsubtract@{\pgfplotscolormapfind@transformedx}{\pgfplotscolormapfind@rgb@X@left}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfmathdivide@{\pgfplots@loc@TMPa}{\pgfplotscolormapfind@h}% + \let\pgfplots@loc@factor=\pgfmathresult + \else + % irrelevant (not used) + \def\pgfplots@loc@factor{1}% + \fi + \pgfmath@smuggleone\pgfplots@loc@factor + \endgroup + }% + % POSTCONDITION: \c@pgf@counta is the index of the LEFT interval + % and \pgfplots@loc@factor is the factor for the linear interpolation. + % %\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange] yielded phi(#4) = \pgfplotscolormapfind@transformedx, situated in interval no \the\c@pgf@counta.^^J}% \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5}\to\pgfplotscolormapfind@rgb@LEFT % % do the stuff which is specific to linear interpolation: % - \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}% - \let\pgfplots@loc@factor=\pgfmathresult + % S = 1 - s \pgfmathsubtract@{1}{\pgfplots@loc@factor}% \let\pgfplots@loc@factor@two=\pgfmathresult % - \pgfplotsarraysize{pgfpl@cm@#5}\to\c@pgf@countb - \advance\c@pgf@countb-1 % - \ifnum\c@pgf@counta<\c@pgf@countb - % Ah: (selected index < length-1) . That means: we have an interval. - \advance\c@pgf@counta by1 + \advance\c@pgf@counta by1 % + \ifnum\c@pgf@counta<\pgfplotsarraysizeof{pgfpl@cm@#5} % + % Ah: (selected index < length) . That means: we have an interval. \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5}\to\pgfplotscolormapfind@rgb@RIGHT %\message{After lookup: the corresponding RGB interval boundaries are [\pgfplotscolormapfind@rgb@LEFT: \pgfplotscolormapfind@rgb@RIGHT].^^J}% % % - % color^m(x) = ( x/h - i ) * ( c_{i+1}^m - c_{i}^m ) + c_i^m - % = s * c_{i+1}^m + S * c_i^m - % - % s= x_h / h -i - % S = 1 - s \pgfplotscolorzero{\csname pgfpl@cm@#5@col@comps\endcsname}% \pgfplotscoloraddweighted {\csname pgfpl@cm@#5@col@comps\endcsname} @@ -1123,7 +2285,7 @@ \def\pgfplotscolormapfindpiecewiseconst@precomputed@[#1:#2][#3]#4#5{% \pgfplotscolormapassertexists{#5}% \begingroup - \pgfplotscolormapfind@@@[#1:#2][#3]{#4}{#5}% + \pgfplotscolormapfind@transform[#1:#2][#3]{#4}{#5}% \let\pgfplotscolormapfind@transformedx=\pgfmathresult % % Now, we have it in [0,1000]. Find the correct interval: @@ -1148,19 +2310,77 @@ % what I really need is: % 1/H = N/1000 = (1000 h^{-1} +1)/ 1000 = h^{-1} + 1/1000 % - % compute 1/H here: - \pgfmathadd@{\csname pgfpl@cm@#5@invh\endcsname}{0.001}% - \let\pgfplots@piecewiseconst@invh=\pgfmathresult% - \pgfmathmultiply@{\pgfplotscolormapfind@transformedx}{\pgfplots@piecewiseconst@invh}% - \let\pgfplotscolormapfind@transformedx@divh=\pgfmathresult - \expandafter\pgfmathfloor@\expandafter{\pgfmathresult}% - % assign \pgfplotscolormapfind@intervalno := \pgfmathresult - % without '.0' suffix: - \def\pgfplots@discardperiod##1.##2\relax{\def\pgfplotscolormapfind@intervalno{##1}}% - \expandafter\pgfplots@discardperiod\pgfmathresult\relax - % Step 2: interpolate the desired RGB value using vector valued - % interpolation on the identified interval. - \c@pgf@counta=\pgfplotscolormapfind@intervalno\relax + \pgfplotscolormapifisuniform{#5}{% + % + \expandafter\ifx\csname pgfpl@cm@#5@X@scale@order@z\endcsname\pgfutil@empty% + % compute 1/H here: + \pgfmathadd@{\csname pgfpl@cm@#5@invh\endcsname}{0.001}% + \let\pgfplots@piecewiseconst@invh=\pgfmathresult% + \else + % disable the extra interval + \expandafter\let\expandafter\pgfplots@piecewiseconst@invh\csname pgfpl@cm@#5@invh\endcsname + \fi + \pgfmathmultiply@{\pgfplotscolormapfind@transformedx}{\pgfplots@piecewiseconst@invh}% + \let\pgfplotscolormapfind@transformedx@divh=\pgfmathresult + % assign \pgfplotscolormapfind@intervalno := \pgfmathresult + % without '.0' suffix: + \expandafter\pgfplotscolormap@floor\pgfmathresult\relax + % Step 2: interpolate the desired RGB value using vector valued + % interpolation on the identified interval. + \c@pgf@counta=\pgfplotscolormapfind@intervalno\relax + }{% + % the same idea can also be applied to non-uniform grids. + % However, it is more involved here. + % + % My idea is that I add an extra interval of length 'h' at the right end of + % the domain, i.e. I enlarge the domain to [0,1000+h]. + % + % To this end, I map the input number linearly from + % [0,1000] -> [0,1000+h] + % using k(t) = (1000+h)/1000 * t + % + % Note that k(t) = 1/ pgfpl@cm@#5@X@scale@order@z + % + % and search in the existing X coordinates of the colormap. + % Note that these X coordinates actually do not contain the + % artifical rightmost boundary point at 1000+h. But that is + % ok, we plan to assign COLOR(1000+h) := COLOR(1000) anyway. + % + % Naturally, some values 'k(t)' will be BEYOND '1000'. In this + % case, we simply use the rightmost interval and are done with + % it. + % + % compute k(t): + \ifdim\csname pgfpl@cm@#5@X@scale@order@z\endcsname pt>0pt + \pgfmathadd@{1000}{\csname pgfpl@cm@#5@h\endcsname}% + \pgf@xa=\pgfmathresult pt % + \divide\pgf@xa by1000 % + \edef\pgfplotscolormapfind@map@to@extra@interval{\pgf@sys@tonumber\pgf@xa}% + % + \pgfmathmultiply@{\pgfplotscolormapfind@transformedx}{\pgfplotscolormapfind@map@to@extra@interval}% + \let\pgfplotscolormapfind@transformedx@=\pgfmathresult + \else + % disable the extra interval + \let\pgfplotscolormapfind@transformedx@=\pgfplotscolormapfind@transformedx + \fi + % + % search k(t) in the original X values. + \pgfplotsarraybinarysearch{pgfpl@cm@#5@X}{\pgfplotscolormapfind@transformedx@}{0}{\pgfplotscolormapsizeof{#5}}% + \c@pgf@counta=\pgfplotsretval\relax + \ifnum\c@pgf@counta<0 + % as per definition of \pgfplotsarraybinarysearch, a + % negative result indicates the "insertion point" ... + \c@pgf@counta=-\c@pgf@counta + % ... plus one. + \advance\c@pgf@counta by-1 + % + % But we do not WANT the insertion point! We want the LEFT + % interval boundary! + \advance\c@pgf@counta by-1 + \fi +%\pgfplotscolormapserializeXtomacro{#5}\XXX +%\message{k(\pgfplotscolormapfind@transformedx) = \pgfplotscolormapfind@transformedx@. Searching for value in X=(\XXX) resulted in \pgfplotsretval, and the index to use is \the\c@pgf@counta.^^J}% + }% % \ifnum\c@pgf@counta=\pgfplotscolormapsizeof{#5}\relax % we have artificially increased the "h" (see the comments @@ -1169,13 +2389,27 @@ \advance\c@pgf@counta by-1 \fi % -%\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange] yielded phi(#4) = \pgfplotscolormapfind@transformedx, situated in interval no \the\c@pgf@counta.^^J}% +%\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange] yielded phi = \pgfplotscolormapfind@transformedx, situated in interval no \the\c@pgf@counta/\pgfplotsarraysizeof{pgfpl@cm@#5}.^^J}% \pgfplotsarrayselect\c@pgf@counta\of{pgfpl@cm@#5}\to\pgfplotscolormapfind@rgb@LEFT \let\pgfmathresult=\pgfplotscolormapfind@rgb@LEFT \pgfmath@smuggleone\pgfmathresult \endgroup }% +\def\pgfplotscolormap@floor#1.#2\relax{% + \ifdim0.#2pt>0.999pt + % ok, it is ALMOST one more! Take this as rounding inaccuracy + \c@pgf@counta=#1\relax + \advance\c@pgf@counta by1 + \edef\pgfplotscolormapfind@intervalno{\the\c@pgf@counta}% + \else + \def\pgfplotscolormapfind@intervalno{#1}% + \fi +}% + +\def\pgfplotscolormap@floor@unforgiving#1.#2\relax{% + \def\pgfplotscolormapfind@intervalno{#1}% +}% % Performs a direct color access into color map '#2' using an index % '#1'. @@ -1189,8 +2423,10 @@ \def\pgfplotscolormapgetindex#1#2{% \pgfplotscolormapassertexists{#2}% \begingroup - \afterassignment\pgfplots@gobble@until@relax - \c@pgf@counta=#1\relax + \pgfmathfloatparsenumber{#1}% + \expandafter\pgfmathfloattoint\expandafter{\pgfmathresult}% + %\afterassignment\pgfplots@gobble@until@relax + \c@pgf@counta=\pgfmathresult\relax \ifnum\c@pgf@counta<0 \c@pgf@counta=0 \else @@ -1231,7 +2467,6 @@ \fi }% - \pgfutil@definecolor{mapped color}{rgb}{0,0,0}% make sure this color exists. It will be overwritten if needed. % ATTENTION: replicated in pgfplots.code.tex : \pgfplotscreatecolormap{hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)} diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex index ad8f8bd36a9..d08717c533a 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex @@ -65,6 +65,22 @@ \pgfplotslistnew#1{#2}% }% +\def\pgfplots@shellescape@lua@eightseven#1{% + \pgfplotsutil@directlua{os.execute("\pgfplotsutil@luaescapestring{#1}")}% +}% +\def\pgfplots@shellescape#1{% + \immediate\write18{#1}% +}% +\pgfutil@IfUndefined{directlua}{% +}{% + \pgfutil@IfUndefined{lastsavedimageresourcepages}{% + \pgfplots@log3{Found old luatex which supports write18 (shell-escape)}% + }{% + \pgfplots@log3{Found new luatex: initializing lua commands instead of write18 (shell-escape)}% + \let\pgfplots@shellescape=\pgfplots@shellescape@lua@eightseven + }% +}% + % Sets the boolean \ifpgfplots@is@old@list@format to true if and only % if the input is a list in the format '{first\\second\\}'. % @@ -633,6 +649,56 @@ \fi }% +% Defines \pgfplotsretval to contain a 'domain' argument if '#1' is +% actually a domain listing. In this case, '\pgfplotsretvalb' will be +% set to the number of samples. +% +% If #1 is no valid domain argument, \pgfplotsretval will be set to +% empty. +\def\pgfplotsforeachtodomain#1{% + \begingroup + \long\def\pgfplotsforeachungroupednonuniform@##1##2##3{% + \def\pgfplotsretval{}% + \def\pgfplotsretvalb{}% + }% + \long\def\pgfplotsforeachungroupedslashed@##1/##2##3##4{% + \def\pgfplotsretval{}% + \def\pgfplotsretvalb{}% + }% + \long\def\pgfplotsforeachungroupeduniform@##1##2,##3,...,##4\relax##5{% + \edef\pgfplotsretval{##2:##4}% + \pgfkeys{/pgf/fpu}% + \pgfmathparse{##3-##2}% + \let\pgfplots@h=\pgfmathresult + \pgfmathparse{(##4-##2)/\pgfplots@h + 1}% + \pgfmathfloattofixed\pgfmathresult + \afterassignment\pgfplotsforeachtodomain@@ + \c@pgf@counta=\pgfmathresult + }% + \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsforeachungrouped \noexpand\x\space in{#1}{}}% + \pgfplots@loc@TMPa + % + \xdef\pgfplots@glob@TMPa{% + \noexpand\def\noexpand\pgfplotsretval{\pgfplotsretval}% + \noexpand\def\noexpand\pgfplotsretvalb{\pgfplotsretvalb}% + }% + \endgroup + \pgfplots@glob@TMPa +}% + +\def\pgfplotsforeachtodomain@@.#1\relax{% + \pgf@xa=0.#1pt % + \ifnum\pgf@xa>0.01pt % FIXME : threshold is chosen in a bad way... should be relative to number range! + % this is not an integer! We cannot convert it to a domain. + \def\pgfplotsretval{}% + \def\pgfplotsretvalb{}% + \else + % ok, it is an integer. Return it as number samples! + % \pgfplotsretval already contains the domain. + \edef\pgfplotsretvalb{\the\c@pgf@counta}% + \fi +}% + \long\def\pgfplotsforeachungrouped@@#1#2#3#4{% \pgfplots@for@reset@break{% % diff --git a/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty b/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty index 4486315128a..6a0874f0bf9 100644 --- a/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty +++ b/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty @@ -33,6 +33,8 @@ } \ProvidesPackage{pgfplots}[\pgfplotsversiondate\space v\pgfplotsversion\space Data Visualization (\pgfplotsrevision)] +\RequirePackage{graphicx} + % ATTENTION: % you MAY need one of % \def\pgfsysdriver{pgfsys-dvipdfm.def} @@ -46,6 +48,29 @@ % 'pdftex' for 'pdflatex' % -> dvipdfm needs special attention. +\IfFileExists{pgfsys-luatex.def}{% + % OK, proceed as usual +}{% + % hm. check if we need it: + \def\pgfplots@glob@TMPa{luatex.def}% + \edef\pgfplots@glob@TMPb{\Gin@driver}% + \ifx\pgfplots@glob@TMPb\pgfplots@glob@TMPa + % hm. probably + \@ifundefined{pgfsysdriver}{% + % use a patch shipped with pgfplots: + \def\pgfsysdriver{pgfsys-luatexpatch.def}% + \immediate\write16{Package pgfplots external lib: activating patch for pgfsys-luatex.def driver (PGF is too old)} + }{% + \def\pgfplots@glob@TMPa{pgfsys-luatex.def}% + \ifx\pgfsysdriver\pgfplots@glob@TMPa + % use a patch shipped with pgfplots: + \def\pgfsysdriver{pgfsys-luatexpatch.def}% + \immediate\write16{Package pgfplots external lib: activating patch for pgfsys-luatex.def driver (PGF is too old)} + \fi + }% + \fi +} + \RequirePackage{tikz} % This is *identical* to \pgfutil@IfUndefined . I copied it here |