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.tex286
1 files changed, 243 insertions, 43 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 b1496a8fc1b..838e0393e2e 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex
@@ -25,6 +25,8 @@
%
%--------------------------------------------
+\pgfkeyssetvalue{/pgfplots/colormap default colorspace}{auto}
+
% This package relies on pgfplots temporary registers and its array
% data structure.
@@ -53,6 +55,7 @@
\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.
+ \pgfplots@createcolormap@initcolorspace
\let\pgfplots@createcolormap@LAST=\pgfplots@createcolormap@MIN
% PARSE IT:
\edef\pgfplots@loc@TMPa{#2}%
@@ -75,8 +78,40 @@
\expandafter\let\csname\pgfplots@createcolormap@name @h\endcsname=\pgfplots@createcolormap@H
\pgfmathreciprocal@{\pgfplots@createcolormap@H}%
\expandafter\let\csname\pgfplots@createcolormap@name @invh\endcsname=\pgfmathresult
+ \expandafter\let\csname\pgfplots@createcolormap@name @col@comps\endcsname=\pgfplots@createcolormap@col@comps
+ \expandafter\let\csname\pgfplots@createcolormap@name @colspace\endcsname=\pgfplots@createcolormap@colspace
%\pgfplots@colormap@showdebuginfofor{#1}%
}
+\def\pgfplots@createcolormap@initcolorspace{%
+ \pgfkeysgetvalue{/pgfplots/colormap default colorspace}\pgfplots@loc@TMPa
+ \edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
+ \def\pgfplots@loc@TMPb{auto}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % colormap default colorspace=auto: same as empty.
+ \let\pgfplots@loc@TMPa=\pgfutil@empty
+ \fi
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ % colormap default colorspace=auto:
+ \def\pgfplots@createcolormap@col@comps{}% to be filled from first point
+ \def\pgfplots@createcolormap@colspace{}%
+ \else
+ \def\pgfplots@loc@TMPb{rgb}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % colormap default colorspace=rgb:
+ \def\pgfplots@createcolormap@colspace{rgb}%
+ \def\pgfplots@createcolormap@col@comps{3}%
+ \else
+ \def\pgfplots@loc@TMPb{cmyk}%
+ \ifx\pgfplots@loc@TMPb\pgfplots@loc@TMPa
+ % colormap default colorspace=cmyk:
+ \def\pgfplots@createcolormap@colspace{cmyk}%
+ \def\pgfplots@createcolormap@col@comps{4}%
+ \else
+ \pgfplots@error{Sorry, the choice 'colormap default colorspace=\pgfplots@loc@TMPa' is unknown to pgfplots, please use one of 'auto,rgb,cmyk'}%
+ \fi
+ \fi
+ \fi
+}%
\def\pgfplots@createcolormap@seth[#1]{%
\def\pgfplots@createcolormap@context{[#1]}%
\pgfmathparse{#1}%
@@ -101,7 +136,7 @@
{%
\pgfutil@ifnextchar g{\pgfplots@createcolormap@grabgray}%
{%
- \pgfutil@ifnextchar c{\pgfplots@createcolormap@grabcolor}%
+ \pgfutil@ifnextchar c{\pgfplots@createcolormap@grabc}%
{
\expandafter\pgfutil@ifnextchar\pgfplots@activesemicolon{\pgfplots@createcolormap@grabsemicolon@active}%
{\pgfplots@createcolormap@error}%
@@ -177,6 +212,41 @@
\edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfmathresult}}%
\expandafter\pgfplots@loc@TMPc\pgfplots@loc@TMPa
\pgfplots@createcolormap@}
+
+
+\def\pgfplots@createcolormap@grabcmyk myk{
+ \def\pgfplots@createcolormap@colspace@actual{cmyk}%
+ \def\pgfplots@createcolormap@col@comps@actual{4}%
+ \pgfutil@ifnextchar2{%
+ \pgfplots@createcolormap@grabcmyk@two@five@five
+ }{%
+ \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabcmyk@
+ \pgfplots@createcolormap@next
+ }%
+}
+\def\pgfplots@createcolormap@grabcmyk@(#1)=(#2,#3,#4,#5){%
+ \def\pgfplots@createcolormap@context{cmyk(#1)=(#2,#3,#4,#5)}%
+ \pgfplots@createcolormap@nextcolor{#1}{#2}{#3}{#4}{#5}%
+ \pgfplots@createcolormap@}
+\def\pgfplots@createcolormap@grabcmyk@two@five@five255{%
+ \let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabcmyk@two@five@five@
+ \pgfplots@createcolormap@next
+}
+\def\pgfplots@createcolormap@grabcmyk@two@five@five@(#1)=(#2,#3,#4,#5){%
+ \def\pgfplots@createcolormap@context{cmyk255(#1)=(#2,#3,#4,#5)}%
+ \pgfplots@createcolormap@grabcmyk@two@five@five@rescale{#2}%
+ \let\pgfplots@loc@TMPa=\pgfmathresult
+ \pgfplots@createcolormap@grabcmyk@two@five@five@rescale{#3}%
+ \let\pgfplots@loc@TMPb=\pgfmathresult
+ \pgfplots@createcolormap@grabcmyk@two@five@five@rescale{#4}%
+ \let\pgfplots@loc@TMPc=\pgfmathresult
+ \pgfplots@createcolormap@grabcmyk@two@five@five@rescale{#5}%
+ \def\pgfplots@loc@TMPd{\pgfplots@createcolormap@nextcolor{#1}}%
+ \edef\pgfplots@loc@TMPa{{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}{\pgfmathresult}}%
+ \expandafter\pgfplots@loc@TMPd\pgfplots@loc@TMPa
+ \pgfplots@createcolormap@}
+
+
\def\pgfplots@createcolormap@grabgray gray{%
\let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabgray@
\pgfplots@createcolormap@next
@@ -185,7 +255,15 @@
\def\pgfplots@createcolormap@context{gray(#1)=(#2)}%
\pgfplots@createcolormap@nextRGB{#1}{#2}{#2}{#2}%
\pgfplots@createcolormap@}
-\def\pgfplots@createcolormap@grabcolor color{%
+
+\def\pgfplots@createcolormap@grabc c{%
+ \pgfutil@ifnextchar m{%
+ \pgfplots@createcolormap@grabcmyk
+ }{%
+ \pgfplots@createcolormap@grabcolor
+ }%
+}%
+\def\pgfplots@createcolormap@grabcolor olor{%
\let\pgfplots@createcolormap@next@\pgfplots@createcolormap@grabcolor@
\pgfplots@createcolormap@next
}%
@@ -193,36 +271,105 @@
\def\pgfplots@createcolormap@context{color(#1)=(#2)}%
\pgfutil@colorlet{pgf@tempcol}{#2}%
\pgfutil@extractcolorspec{pgf@tempcol}{\pgf@tempcolor}%
- \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgf@rgbcolor}%
- \expandafter\pgfplots@createcolormap@grabcolor@@\pgf@rgbcolor\relax{#1}}%
+ \ifx\pgfplots@createcolormap@colspace\pgfutil@empty
+ % This here is mainly for backwards compatibility... in older
+ % versions, rgb was the only choice. This should still work
+ % unless overruled explicitly.
+ \def\pgfplots@createcolormap@colspace{rgb}%
+ \def\pgfplots@createcolormap@col@comps{3}%
+ \fi
+ % convert the colorspace (if needed):
+ \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{\pgfplots@createcolormap@colspace}{\pgf@rgbcolor}%
+ %
+ \let\pgfplots@createcolormap@colspace@actual=\pgfplots@createcolormap@colspace
+ \let\pgfplots@createcolormap@col@comps@actual=\pgfplots@createcolormap@col@comps
+ %
+ \if4\pgfplots@createcolormap@col@comps
+ \let\pgfplots@loc@TMPa=\pgfplots@createcolormap@grabcolor@@@
+ \else
+ \let\pgfplots@loc@TMPa=\pgfplots@createcolormap@grabcolor@@
+ \fi
+ \expandafter\pgfplots@loc@TMPa\pgf@rgbcolor\relax{#1}%
+}%
\def\pgfplots@createcolormap@grabcolor@@#1,#2,#3\relax#4{%
\pgfplots@createcolormap@nextRGB{#4}{#1}{#2}{#3}%
\pgfplots@createcolormap@}
+\def\pgfplots@createcolormap@grabcolor@@@#1,#2,#3,#4\relax#5{%
+ \pgfplots@createcolormap@nextcolor{#5}{#1}{#2}{#3}{#4}%
+ \pgfplots@createcolormap@}
+
\def\pgfplots@createcolormap@rgbrangeexception#1#2#3{%
\pgfplots@error{Sorry, RGB[#1,#2,#3] is not supported. The allowed range is 0 <= r,g,b <= 1. The error occured near `\pgfplots@createcolormap@context'}%
}%
+\def\pgfplots@createcolormap@rangeexception#1#2{%
+ \pgfplots@error{Sorry, the color component at index #1 (value #2) is out of range. The allowed range is 0 <= value <= 1. The error occured near `\pgfplots@createcolormap@context'}%
+}
+
% Ok, we parsed the next single spec.
% #1: the width
% #2,#3,#4 RGB values.
\def\pgfplots@createcolormap@nextRGB#1#2#3#4{%
+ \def\pgfplots@createcolormap@colspace@actual{rgb}%
+ \def\pgfplots@createcolormap@col@comps@actual{3}%
+ \pgfplots@createcolormap@nextcolor{#1}{#2}{#3}{#4}{}%
+}%
+
+% #1: h
+% #2...#5: the color components (at least 3 non-empty, can be 4).
+\def\pgfplots@createcolormap@nextcolor#1#2#3#4#5{%
\ifdim#2pt<0pt
- \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}%
+ \pgfplots@createcolormap@rangeexception0{#2}%
\fi
\ifdim#3pt<0pt
- \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}%
+ \pgfplots@createcolormap@rangeexception1{#3}%
\fi
\ifdim#4pt<0pt
- \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}%
+ \pgfplots@createcolormap@rangeexception2{#4}%
\fi
\ifdim#2pt>1pt
- \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}%
+ \pgfplots@createcolormap@rangeexception0{#2}%
\fi
\ifdim#3pt>1pt
- \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}%
+ \pgfplots@createcolormap@rangeexception1{#3}%
\fi
\ifdim#4pt>1pt
- \pgfplots@createcolormap@rgbrangeexception{#2}{#3}{#4}%
+ \pgfplots@createcolormap@rangeexception2{#4}%
+ \fi
+ \if4\pgfplots@createcolormap@col@comps@actual
+ \ifdim#5pt<0pt
+ \pgfplots@createcolormap@rangeexception3{#5}%
+ \fi
+ \ifdim#5pt>1pt
+ \pgfplots@createcolormap@rangeexception3{#5}%
+ \fi
+ \fi
+ \def\pgfplots@loc@TMPb{\pgfplots@createcolormap@nextcolor@{#1}{#2}{#3}{#4}{#5}}%
+ \ifx\pgfplots@createcolormap@colspace@actual\pgfplots@createcolormap@colspace
+ \else
+ \ifx\pgfplots@createcolormap@colspace\pgfutil@empty
+ \let\pgfplots@createcolormap@colspace=\pgfplots@createcolormap@colspace@actual
+ \let\pgfplots@createcolormap@col@comps=\pgfplots@createcolormap@col@comps@actual
+ \else
+ % Oh. We need to convert the color space!
+ \edef\pgfplots@loc@TMPa{{\pgfplots@createcolormap@colspace@actual}{#2,#3,#4\if4\pgfplots@createcolormap@col@comps@actual,#5\fi}}%
+ \expandafter\pgfutil@convertcolorspec\pgfplots@loc@TMPa{\pgfplots@createcolormap@colspace}{\pgfplots@loc@TMPa}%
+ % invoke
+ % \pgfplots@createcolormap@nextcolor@{#1}{C1}{C2}{C3}{C4}.
+ % We need to compute C1 ... C4 :
+ \def\pgf@colmarshal{{#1}}%
+ \expandafter\pgf@uncomma\pgfplots@loc@TMPa,,%
+ \if4\pgfplots@createcolormap@col@comps
+ \else
+ % ok, we have C4={}. Append it:
+ \edef\pgf@colmarshal{\pgf@colmarshal{}}%
+ \fi
+ \def\pgfplots@loc@TMPb{\expandafter\pgfplots@createcolormap@nextcolor@\pgf@colmarshal}%
+ \fi
\fi
+ \pgfplots@loc@TMPb
+}%
+\def\pgfplots@createcolormap@nextcolor@#1#2#3#4#5{%
+%\message{processing color #1=(#2,#3,#4,#5) with \pgfplots@createcolormap@col@comps@actual\space components^^J}%
% compute 'h':
\pgfmathparse{#1}%
\let\pgfplots@createcolormap@MAX=\pgfmathresult
@@ -270,14 +417,19 @@
\ifdim\c@pgfplots@createcolormap pt=\pgfplots@loc@TMPb pt
% omit the last.
\else
- \pgfmathparse{\pgfplots@createcolormap@lastR + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #2 - \pgfplots@createcolormap@lastR )}%
- \let\pgfplots@createcolormap@nextR=\pgfmathresult
- \pgfmathparse{\pgfplots@createcolormap@lastG + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #3 - \pgfplots@createcolormap@lastG )}%
- \let\pgfplots@createcolormap@nextG=\pgfmathresult
- \pgfmathparse{\pgfplots@createcolormap@lastB + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #4 - \pgfplots@createcolormap@lastB )}%
+ \pgfmathparse{\pgfplots@createcolormap@lastA + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #2 - \pgfplots@createcolormap@lastA )}%
+ \let\pgfplots@createcolormap@nextA=\pgfmathresult
+ \pgfmathparse{\pgfplots@createcolormap@lastB + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #3 - \pgfplots@createcolormap@lastB )}%
+ \let\pgfplots@createcolormap@nextB=\pgfmathresult
+ \pgfmathparse{\pgfplots@createcolormap@lastC + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #4 - \pgfplots@createcolormap@lastC )}%
+ \let\pgfplots@createcolormap@nextC=\pgfmathresult
+ \if4\pgfplots@createcolormap@col@comps
+ \pgfmathparse{\pgfplots@createcolormap@lastD + \c@pgfplots@createcolormap/\pgfplots@loc@TMPb * ( #4 - \pgfplots@createcolormap@lastD )}%
+ \let\pgfplots@createcolormap@nextD=\pgfmathresult
+ \fi
%
\edef\pgfplots@loc@TMPa{%
- \noexpand\pgfplotsarraypushback{\pgfplots@createcolormap@nextR,\pgfplots@createcolormap@nextG,\pgfmathresult}%
+ \noexpand\pgfplotsarraypushback{\pgfplots@createcolormap@nextA,\pgfplots@createcolormap@nextB,\pgfplots@createcolormap@nextC\if4\pgfplots@createcolormap@col@comps,\pgfplots@createcolormap@nextD\fi}%
\noexpand\to}%
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}%
\fi
@@ -285,11 +437,12 @@
\fi
\fi
\fi
- \def\pgfplots@loc@TMPa{\pgfplotsarraypushback{#2,#3,#4}\to}%
+ \edef\pgfplots@loc@TMPa{\noexpand\pgfplotsarraypushback{#2,#3,#4\if4\pgfplots@createcolormap@col@comps,#5\fi}\noexpand\to}%
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@createcolormap@name}%
- \edef\pgfplots@createcolormap@lastR{#2}%
- \edef\pgfplots@createcolormap@lastG{#3}%
- \edef\pgfplots@createcolormap@lastB{#4}%
+ \edef\pgfplots@createcolormap@lastA{#2}%
+ \edef\pgfplots@createcolormap@lastB{#3}%
+ \edef\pgfplots@createcolormap@lastC{#4}%
+ \edef\pgfplots@createcolormap@lastD{#5}%
}%
\def\pgfplots@createcolormap@nextRGB@consider@reinterpolation#1\relax{%
\pgf@xa=#1pt
@@ -318,19 +471,20 @@
% Shows debug info about colormap #1 into the console.
\def\pgfplots@colormap@showdebuginfofor#1{%
- \message{Debug info for color map '#1':}%
- \message{(Transformed) Range: [0:\pgfplotscolormaprange]; }%
- \message{H: \csname pgfpl@cm@#1@h\endcsname; }%
- \message{H:^{-1}: \csname pgfpl@cm@#1@invh\endcsname; }%
+ \message{Debug info for color map '#1':^^J}%
+ \message{(Transformed) Range: [0:\pgfplotscolormaprange]; ^^J}%
+ \message{H: \csname pgfpl@cm@#1@h\endcsname; ^^J}%
+ \message{H:^{-1}: \csname pgfpl@cm@#1@invh\endcsname; ^^J}%
\pgfplotsarraysizetomacro{pgfpl@cm@#1}\to\pgfplots@loc@TMPa
- \message{Size: \pgfplots@loc@TMPa; }%
- \message{RGB Values: }%
+ \message{Size: \pgfplots@loc@TMPa; ^^J}%
+ \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{%
\message{\#\the\c@pgf@counta: \elem; }%
\advance\c@pgf@counta by1
}%
+ \message{^^J}%
\endgroup
}
@@ -358,11 +512,15 @@
}%
}%
\toks3=\expandafter{\pgfplots@serialize@list}%
+ \toks4=\expandafter{\expandafter\def\csname pgfpl@cm@#1@colspace\endcsname}%
+ \toks5=\expandafter{\expandafter\def\csname pgfpl@cm@#1@col@comps\endcsname}%
\xdef\pgfplots@glob@TMPa{%
\the\toks0 {\csname pgfpl@cm@#1@h\endcsname}%
\the\toks1 {\csname pgfpl@cm@#1@invh\endcsname}%
\noexpand\def\noexpand\pgfplots@loc@TMPa{\the\toks3 }%
\the\toks2
+ \the\toks4 {\csname pgfpl@cm@#1@colspace\endcsname}%
+ \the\toks5 {\csname pgfpl@cm@#1@col@comps\endcsname}%
}%
\endgroup
\let#2=\pgfplots@glob@TMPa
@@ -395,7 +553,11 @@
\def\pgfplots@loc@TMPb{}%
\def\pgfplots@loc@TMPc{}%
\pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\cdata{%
- \edef\cdata{\expandafter\pgfplotscolormaptopdffunction@convertcdata\cdata\relax}%
+ \if4\csname pgfpl@cm@#1@col@comps\endcsname
+ \edef\cdata{\expandafter\pgfplotscolormaptopdffunction@convertcdata@four\cdata\relax}%
+ \else
+ \edef\cdata{\expandafter\pgfplotscolormaptopdffunction@convertcdata\cdata\relax}%
+ \fi
\ifnum\c@pgf@counta>0
\t@pgfplots@toka=\expandafter{\pgfplotsretval}%
\xdef\pgfplotsretval{%
@@ -428,6 +590,7 @@
\endgroup
}%
\def\pgfplotscolormaptopdffunction@convertcdata#1,#2,#3\relax{#1 #2 #3}%
+\def\pgfplotscolormaptopdffunction@convertcdata@four#1,#2,#3,#4\relax{#1 #2 #3 #4}%
% Invokes '#2' if a color map named '#1' exists and '#3' if no such color map exists.
\def\pgfplotscolormapifdefined#1#2#3{\pgfplotsarrayifdefined{pgfpl@cm@#1}{#2}{#3}}%
@@ -459,6 +622,7 @@
\def\pgfplotscolormaptoshadingspec#1#2#3{%
\pgfplotscolormapassertexists{#1}%
\begingroup
+ \def\pgfplots@rgb{rgb}%
\pgfmathparse{#2}%
\expandafter\pgfmathdivide@\expandafter{\pgfmathresult}{\pgfplotscolormaprange}%
\let\pgfplots@loc@TMPb=\pgfmathresult
@@ -467,12 +631,23 @@
\c@pgf@counta=0
\let#3=\pgfutil@empty
\pgfplotsarrayforeachungrouped{pgfpl@cm@#1}\as\pgfplotscolormaptoshadingspec@TMP{%
- \ifnum\c@pgf@counta=0
- \edef\pgfplots@loc@TMPc{rgb(0pt)=(\pgfplotscolormaptoshadingspec@TMP)}%
- \else
- \pgf@yb=\c@pgf@counta\pgf@ya
- \edef\pgfplots@loc@TMPc{rgb(\the\pgf@yb)=(\pgfplotscolormaptoshadingspec@TMP)}%
+ \pgf@yb=\c@pgf@counta\pgf@ya
+ \edef\pgfplots@colspace{\csname pgfpl@cm@#1@colspace\endcsname}%
+ % FIXME : PGF shadings accept only RGB!
+ \if1\pgfplotscolormaptoshadingspectorgb
+ \ifx\pgfplots@colspace\pgfplots@rgb
+ \else
+ \pgfutil@ifundefined{pgfpl@cm@#1@warned}{%
+ \expandafter\gdef\csname pgfpl@cm@#1@warned\endcsname{1}%
+ \pgfplots@warning{I am about to convert colormap '#1' from \pgfplots@colspace\space to rgb (which might be lossy). Perhaps the choice 'colorbar sampled={surf,shader=interp}' yields better results since it supports \pgfplots@colspace.}%
+ }{%
+ }%
+ \edef\pgf@tempcolor{{\pgfplots@colspace}{\pgfplotscolormaptoshadingspec@TMP}}%
+ \expandafter\pgfutil@convertcolorspec\pgf@tempcolor{rgb}{\pgfplotscolormaptoshadingspec@TMP}%
+ \def\pgfplots@colspace{rgb}%
+ \fi
\fi
+ \edef\pgfplots@loc@TMPc{\pgfplots@colspace(\the\pgf@yb)=(\pgfplotscolormaptoshadingspec@TMP)}%
\ifx#3\pgfutil@empty
\t@pgfplots@toka={}%
\else
@@ -485,6 +660,7 @@
\pgfmath@smuggleone#3%
\endgroup
}%
+\def\pgfplotscolormaptoshadingspectorgb{1}%
% The same as \pgfplotscolormaptoshadingspec, but this here yields the
% *reversed* sequence.
@@ -501,10 +677,20 @@
% end is fixed to '0'.
\def\pgfplotscolormaprange{1000}
-% Linearly maps the number #4 into the colormap #5 and returns the interpolated RGB triple
-% into \pgfmathresult.
+\def\pgfplotscolormapgetcolorspace#1{%
+ \edef\pgfplotsretval{\csname pgfpl@cm@#1@colspace\endcsname}%
+}%
+\def\pgfplotscolormapgetcolorcomps#1{%
+ \edef\pgfplotsretval{\csname pgfpl@cm@#1@col@comps\endcsname}%
+}%
+
+
+% Linearly maps the number #4 into the colormap #5 and 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. This is required to
+% [#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
% s := \pgfplotscolormaprange / (#2-#1).
@@ -564,6 +750,8 @@
% without '.0' suffix:
\def\pgfplots@discardperiod##1.##2\relax{\def\pgfplotscolormapfind@intervalno{##1}}%
\expandafter\pgfplots@discardperiod\pgfmathresult\relax
+ \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}%
+ \let\pgfplots@loc@factor=\pgfmathresult
%\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange] yielded phi(#4) = \pgfplotscolormapfind@transformedx, situated in interval no \pgfplotscolormapfind@intervalno.}%
% Step 2: interpolate the desired RGB value using vector valued
% interpolation on the identified interval.
@@ -573,7 +761,11 @@
\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].}%
\edef\pgfplots@loc@TMPa{\pgfplotscolormapfind@rgb@LEFT:\pgfplotscolormapfind@rgb@RIGHT}%
- \expandafter\pgfplotscolormapfind@interpolate\pgfplots@loc@TMPa\relax
+ \if4\csname pgfpl@cm@#5@col@comps\endcsname
+ \expandafter\pgfplotscolormapfind@interpolate@four\pgfplots@loc@TMPa\relax
+ \else
+ \expandafter\pgfplotscolormapfind@interpolate\pgfplots@loc@TMPa\relax
+ \fi
\pgfmath@smuggleone\pgfmathresult
\endgroup
%\message{-> got finally mapping(#4, #5) = RGB'\pgfmathresult'.}%
@@ -588,26 +780,33 @@
% R:
\pgfmathsubtract@{#4}{#1}%
\let\pgfplotscolormapfind@Cdiff=\pgfmathresult
- \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}%
- \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplotscolormapfind@Cdiff}%
+ \pgfmathmultiply@{\pgfplots@loc@factor}{\pgfplotscolormapfind@Cdiff}%
\expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#1}%
\let\RED=\pgfmathresult
% G:
\pgfmathsubtract@{#5}{#2}%
\let\pgfplotscolormapfind@Cdiff=\pgfmathresult
- \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}%
- \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplotscolormapfind@Cdiff}%
+ \pgfmathmultiply@{\pgfplots@loc@factor}{\pgfplotscolormapfind@Cdiff}%
\expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#2}%
\let\GREEN=\pgfmathresult
% B:
\pgfmathsubtract@{#6}{#3}%
\let\pgfplotscolormapfind@Cdiff=\pgfmathresult
- \pgfmathsubtract@{\pgfplotscolormapfind@transformedx@divh}{\pgfplotscolormapfind@intervalno}%
- \expandafter\pgfmathmultiply@\expandafter{\pgfmathresult}{\pgfplotscolormapfind@Cdiff}%
+ \pgfmathmultiply@{\pgfplots@loc@factor}{\pgfplotscolormapfind@Cdiff}%
\expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#3}%
\let\BLUE=\pgfmathresult
\edef\pgfmathresult{\RED,\GREEN,\BLUE}%
}%
+\def\pgfplotscolormapfind@interpolate@four#1,#2,#3,#4:#5,#6,#7,#8\relax{%
+ \pgfplotscolormapfind@interpolate#1,#2,#3:#5,#6,#7\relax
+ \let\CMY=\pgfmathresult
+ \pgfmathsubtract@{#8}{#4}%
+ \let\pgfplotscolormapfind@Cdiff=\pgfmathresult
+ \pgfmathmultiply@{\pgfplots@loc@factor}{\pgfplotscolormapfind@Cdiff}%
+ \expandafter\pgfmathadd@\expandafter{\pgfmathresult}{#4}%
+ \let\K=\pgfmathresult
+ \edef\pgfmathresult{\CMY,\K}%
+}
% Performs a direct color access into color map '#2' using an index
% '#1'.
@@ -655,6 +854,7 @@
\fi
}%
+
\pgfutil@definecolor{mapped color}{rgb}{0,0,0}% make sure this color exists. It will be overwritten if needed.
\pgfplotscreatecolormap{hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)}
@@ -670,7 +870,7 @@
{#1}
{\pgfkeysvalueof{/pgfplots/colormap name}}
%\message{Color for current point is RGB '\pgfmathresult' (determined using meta 'phi(\pgfplotspointmeta) = \pgfplotspointmetatransformed')}%
- \def\pgfplots@loc@TMPb{\pgfutil@definecolor{mapped color}{rgb}}%
+ \def\pgfplots@loc@TMPb{\pgfutil@definecolor{mapped color}{\csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}}%
\expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}%
}%