summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex143
1 files changed, 76 insertions, 67 deletions
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 992687268c3..464f05359fb 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex
@@ -5,7 +5,7 @@
%
% 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-2013 by Christian Feuersänger.
@@ -14,12 +14,12 @@
% 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/>.
%
@@ -52,7 +52,7 @@
% the last length+h for all others).
% - the semicolons can be omitted.
%
-% Example:
+% Example:
% \pgfplotscreatecolormap{my map}{rgb(0cm)=(1,0,0); rgb(1cm)=(0,1,0); rgb255(1.5cm)=(128,5,255); rgb(2cm)=(0,0,1); gray(3cm)=(3); color(4cm)=(green); }
% \pgfplotscreatecolormap{my map}{color=(green); color=(red); color=(blue); color=(yellow)}
\def\pgfplotscreatecolormap#{\pgfplots@createcolormap}%
@@ -201,9 +201,9 @@
% 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.
+ % 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 :-/
@@ -218,6 +218,12 @@
\fi
}%
\fi
+ %
+ \ifpgfplots@LUA@supported
+ \pgfplotsutil@directlua{%
+ pgfplots.texColorMapSetScaleOrderZ("#1", "\csname pgfpl@cm@#1@X@scale@order@z\endcsname")
+ }%
+ \fi
}%
% see \pgfplotscolormapsetadditionalintervalwidth
@@ -258,7 +264,7 @@
\pgfutil@ifnextchar;{\pgfplots@createcolormap@grabsemicolon}%
{%
\pgfutil@ifnextchar,{\pgfplots@createcolormap@grabcomma}%
- {
+ {%
\expandafter\pgfutil@ifnextchar\pgfplots@activesemicolon{\pgfplots@createcolormap@grabsemicolon@active}%
{%
\pgfplots@createcolormap@grabnext
@@ -276,7 +282,7 @@
\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.
@@ -355,7 +361,7 @@
% 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.
@@ -448,7 +454,7 @@
},
%
@define/.code={%
- \pgfplots@error{Please write 'single color' or 'color list' such that pgfplots knows how to interprete values}
+ \pgfplots@error{Please write 'single color' or 'color list' such that pgfplots knows how to interprete values}%
\let\pgfplotsretval=\pgfutil@empty
},
single color/.style={%
@@ -542,7 +548,7 @@
%
/pgfplots/of colormap/.unknown/.code={%
\pgfplotsutilifstringequal{#1}{\pgfkeysnovalue}{%
- % This here allows to write 'of colormap={initial}'
+ % This here allows to write 'of colormap={initial}'
\pgfplotscolormapifdefined{\pgfkeyscurrentname}{%
\edef\pgfplots@loc@TMPa{%
\noexpand\pgfkeysalso{%
@@ -894,8 +900,8 @@
\let\pgfplotsretval=\pgfplots@glob@TMPa
}
-% Defines
-% * 'source range',
+% 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
@@ -909,7 +915,7 @@
\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'
+ % 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!
@@ -1057,7 +1063,7 @@
\expandafter\pgfplots@createcolormap@\pgfplotsretval
}%
-% INPUT:
+% INPUT:
% \pgfplotscolormap@at
% \pgfplotscolormap@argument
% \pgfplotscolormap@key
@@ -1179,7 +1185,7 @@
\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
%
@@ -1256,12 +1262,12 @@
%
\pgfplotscolornormalizesequencezero
\pgfplotscolornormalizesequenceaddweighted
- {\pgfplotsretval}
- {\pgfplots@createcolormap@scale@current}
+ {\pgfplotsretval}%
+ {\pgfplots@createcolormap@scale@current}%
{#1}%
\pgfplotscolornormalizesequenceaddweighted
- {\pgfplotsretval}
- {\pgfplots@createcolormap@scale@last}
+ {\pgfplotsretval}%
+ {\pgfplots@createcolormap@scale@last}%
{\pgfplots@createcolormap@last}%
%
%\message{interpolation step \c@pgfplots@createcolormap = \pgfplotsretval^^J}%
@@ -1321,7 +1327,8 @@
\csname pgfpl@cm@#1@h\endcsname,^^J%
colorspace,^^J%
{ \pgfplots@values },^^J
- { \pgfplots@pos }^^J
+ { \pgfplots@pos },^^J
+ "\csname pgfpl@cm@#1@X@scale@order@z\endcsname"^^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%
@@ -1382,7 +1389,7 @@
% output format=csv,
% ]{viridis}
% {viridis.dat}
-\def\pgfplotscolormaptodatafile@elem#1#2#3#4{
+\def\pgfplotscolormaptodatafile@elem#1#2#3#4{%
\let\pgfplotsretval=\pgfutil@empty
}%
@@ -1689,9 +1696,9 @@
\def\pgfplotscolormap@piecewiseconst@prepare@scale#1{%
% advance the number of intervals by 1.
\pgfplotscolormapifisuniform{#1}{%
- % To this end, we have to compute
+ % To this end, we have to compute
% N = n+1
- % and
+ % 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%
@@ -1711,7 +1718,7 @@
% 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.
+ % mesh width.
% Since the domain is [0,1000], we map [0,1000+h]
% linearly into [0,1000].
%
@@ -1784,10 +1791,10 @@
\pgfplotscolormapassertexists{#1}%
\pgfplotsapplistXnewempty\pgfplots@resultaccum
\pgfplotsapplistXpushback{
- <<
- /FunctionType 3
- /Domain [0 \pgfplotscolormappdfmax]
- /Functions [
+ <<
+ /FunctionType 3
+ /Domain [0 \pgfplotscolormappdfmax]
+ /Functions [
}\to\pgfplots@resultaccum%
\c@pgf@counta=0
\c@pgf@countb=\pgfplotsarraysizeof{pgfpl@cm@#1} %
@@ -1810,14 +1817,14 @@
\if c\pgfplots@colormap@access
% colormap access=piecewise constant
% This has a dedicated special interval at the rightmost
- % end.
+ % end.
% See comments in pgfplotscolormapfindpiecewiseconst@precomputed@
\def\pgfplots@order{0}%
%
\pgfplotscolormap@piecewiseconst@prepare@scale{#1}%
%
% interchange the sequence in the PDF function as it is
- % defined as
+ % defined as
% y = C0 + x^0 * (C1 - C0) = C1
% -> we want the left interval boundary.
\def\pgfplots@C@left{C1}%
@@ -1844,8 +1851,8 @@
\edef\pgfplots@loc@TMPd{%
<<
/FunctionType 2
- /Domain [0 \pgfplotscolormappdfmax]
- /\pgfplots@C@left\space [\pgfplots@loc@TMPa] /\pgfplots@C@right\space [\cdata]
+ /Domain [0 \pgfplotscolormappdfmax]
+ /\pgfplots@C@left\space [\pgfplots@loc@TMPa] /\pgfplots@C@right\space [\cdata]
/N \pgfplots@order
>>
}%
@@ -1883,8 +1890,8 @@
\edef\pgfplots@loc@TMPd{%
<<
/FunctionType 2
- /Domain [0 \pgfplotscolormappdfmax]
- /\pgfplots@C@left\space [\cdata] /\pgfplots@C@right\space [\cdata]
+ /Domain [0 \pgfplotscolormappdfmax]
+ /\pgfplots@C@left\space [\cdata] /\pgfplots@C@right\space [\cdata]
/N \pgfplots@order
>>
}%
@@ -1947,7 +1954,7 @@
% Example:
% \pgfplotscolormaptoshadingspec{my colormap}{4cm}{\output}
% \def\tempb{\pgfdeclarehorizontalshading{myshadingA}{1cm}}
-% \expandafter\tempb\expandafter{\temp}
+% \expandafter\tempb\expandafter{\temp}
%
% \pgfuseshading{myshadingA}
\def\pgfplotscolormaptoshadingspec#1#2#3{%
@@ -2034,10 +2041,10 @@
% interpolated colors into \pgfmathresult. The result will be a triple
% for an RGB colormap and it will contain four numbers for CMYK. The
% components of the result will be in the range [0:1].
-%
+%
% [#1:#2] the number range of the data source (i.e. of #4). This is required to
% map into the colormap.
-% [#3] (optional) the quantity
+% [#3] (optional) the quantity
% s := \pgfplotscolormaprange / (#2-#1).
% Precomputing this quantity may save a lot of time because
% divisions are expensive in TeX. You can omit [#3] or
@@ -2144,10 +2151,10 @@
% 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
+ % = ( 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= x_h / h -i
\pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}%
\let\pgfplots@loc@factor=\pgfmathresult
}{%
@@ -2210,12 +2217,12 @@
%
\pgfplotscolorzero{\csname pgfpl@cm@#5@col@comps\endcsname}%
\pgfplotscoloraddweighted
- {\csname pgfpl@cm@#5@col@comps\endcsname}
+ {\csname pgfpl@cm@#5@col@comps\endcsname}%
{\pgfplotsretval}%
{\pgfplots@loc@factor@two}%
{\pgfplotscolormapfind@rgb@LEFT}%
\pgfplotscoloraddweighted
- {\csname pgfpl@cm@#5@col@comps\endcsname}
+ {\csname pgfpl@cm@#5@col@comps\endcsname}%
{\pgfplotsretval}%
{\pgfplots@loc@factor}%
{\pgfplotscolormapfind@rgb@RIGHT}%
@@ -2234,10 +2241,10 @@
% interpolation. It returns the interpolated colors into \pgfmathresult. The result will be a triple
% for an RGB colormap and it will contain four numbers for CMYK. The
% components of the result will be in the range [0:1].
-%
+%
% [#1:#2] the number range of the data source (i.e. of #4). This is required to
% map into the colormap.
-% [#3] (optional) the quantity
+% [#3] (optional) the quantity
% s := \pgfplotscolormaprange / (#2-#1).
% Precomputing this quantity may save a lot of time because
% divisions are expensive in TeX. You can omit [#3] or
@@ -2256,20 +2263,23 @@
}%
}%
\def\pgfplotscolormapfindpiecewiseconst@precomputed[#1:#2][#3]#4#5{%
- %\ifpgfplots@LUA@supported
- \iffalse
- % FIXME : implement
- \edef\pgfmathresult{%
- \pgfplotsutil@directlua{%
- pgfplots.texColorMapPrecomputed("#5", #1,#2,#4)
+ \ifpgfplots@LUA@supported
+ \pgfplotscolormapifisuniform{#5}{%
+ \edef\pgfmathresult{%
+ \pgfplotsutil@directlua{%
+ pgfplots.texColorMapFindPiecewiseConst("#5", #1,#2,#4)
+ }%
}%
- }%
- \ifx\pgfmathresult\pgfutil@empty
- \pgfplotscolormapfindpiecewiseconst@precomputed@warn@LUA{#5}%
+ \ifx\pgfmathresult\pgfutil@empty
+ \pgfplotscolormapfindpiecewiseconst@precomputed@warn@LUA{#5}%
+ \pgfplotscolormapfindpiecewiseconst@precomputed@[#1:#2][#3]{#4}{#5}%
+ \else
+ %\message{LUA colormapfindpiecewiseconst[#1:#2](#4)(#5) = \pgfmathresult^^J}%
+ \fi
+ }{%
+ % FIXME : implement LUA for non-uniform colormaps
\pgfplotscolormapfindpiecewiseconst@precomputed@[#1:#2][#3]{#4}{#5}%
- \else
- %\message{LUA colormapfindpiecewiseconst[#1:#2](#4)(#5) = \pgfmathresult^^J}%
- \fi
+ }%
\else
\pgfplotscolormapfindpiecewiseconst@precomputed@[#1:#2][#3]{#4}{#5}%
\fi
@@ -2296,9 +2306,9 @@
%
% I decided to enlarge the colormap artificially such that the
% rightmost color receives its own interval.
- %
+ %
% To this end, I recompute the coordinates at which colors "live".
- % The operations sounds more involved than it is: I simply need a NEW mesh width locally
+ % The operations sounds more involved than it is: I simply need a NEW mesh width locally
% inside of this function. The new mesh width H can be computed as
% follows, assuming that the OLD colormap has mesh width h.
%
@@ -2334,8 +2344,8 @@
%
% 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
+ %
+ % To this end, I map the input number linearly from
% [0,1000] -> [0,1000+h]
% using k(t) = (1000+h)/1000 * t
%
@@ -2384,7 +2394,7 @@
%
\ifnum\c@pgf@counta=\pgfplotscolormapsizeof{#5}\relax
% we have artificially increased the "h" (see the comments
- % above) -- meaning that this 'if' can happen.
+ % above) -- meaning that this 'if' can happen.
% ->Map the rightmost point to the rightmost interval:
\advance\c@pgf@counta by-1
\fi
@@ -2394,7 +2404,7 @@
\let\pgfmathresult=\pgfplotscolormapfind@rgb@LEFT
\pgfmath@smuggleone\pgfmathresult
\endgroup
-}%
+}
\def\pgfplotscolormap@floor#1.#2\relax{%
\ifdim0.#2pt>0.999pt
@@ -2480,12 +2490,11 @@
% #1: is the value which should be mapped into the color map; it
% is expected in the range [0,1000] (like point meta).
\def\pgfplotscolormapdefinemappedcolor#1{%
- \expandafter\pgfplotscolormapaccess\expandafter[\pgfplotspointmetatransformedrange]
- [1.0]
- {#1}
- {\pgfkeysvalueof{/pgfplots/colormap name}}
+ \expandafter\pgfplotscolormapaccess\expandafter[\pgfplotspointmetatransformedrange]%
+ [1.0]%
+ {#1}%
+ {\pgfkeysvalueof{/pgfplots/colormap name}}%
%\message{Color for current point is RGB '\pgfmathresult' (determined using meta 'phi(\pgfplotspointmeta) = \pgfplotspointmetatransformed')^^J}%
\def\pgfplots@loc@TMPb{\pgfutil@definecolor{mapped color}{\csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}}%
\expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}%
}%
-