texlive[41838] Master/texmf-dist: pgfplots (11aug16)

commits+karl at tug.org commits+karl at tug.org
Thu Aug 11 23:43:18 CEST 2016


Revision: 41838
          http://tug.org/svn/texlive?view=revision&revision=41838
Author:   karl
Date:     2016-08-11 23:43:18 +0200 (Thu, 11 Aug 2016)
Log Message:
-----------
pgfplots (11aug16)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/generic/pgfplots/README
    trunk/Master/texmf-dist/doc/latex/pgfplots/TeX-programming-notes.pdf
    trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplots.doc.src.tar.bz2
    trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplots.pdf
    trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplotsexample.pdf
    trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplotstable.pdf
    trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplotstodo.pdf
    trunk/Master/texmf-dist/doc/plain/pgfplots/pgfplotsexample-plain.pdf
    trunk/Master/texmf-dist/scripts/pgfplots/matlab2pgfplots.m
    trunk/Master/texmf-dist/source/context/third/pgfplots/pgfplotstests.context.tar.bz2
    trunk/Master/texmf-dist/source/latex/pgfplots/pgfplotstests.tar.bz2
    trunk/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarycolorbrewer.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua
    trunk/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua
    trunk/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def
    trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def
    trunk/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex
    trunk/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex
    trunk/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfsys-luatexpatch.def
    trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def

Modified: trunk/Master/texmf-dist/doc/generic/pgfplots/README
===================================================================
--- trunk/Master/texmf-dist/doc/generic/pgfplots/README	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/doc/generic/pgfplots/README	2016-08-11 21:43:18 UTC (rev 41838)
@@ -23,7 +23,7 @@
 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 @@
 
 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

Modified: trunk/Master/texmf-dist/doc/latex/pgfplots/TeX-programming-notes.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplots.doc.src.tar.bz2
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplots.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplotsexample.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplotstable.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/pgfplots/pgfplotstodo.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/plain/pgfplots/pgfplotsexample-plain.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/pgfplots/matlab2pgfplots.m
===================================================================
--- trunk/Master/texmf-dist/scripts/pgfplots/matlab2pgfplots.m	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/scripts/pgfplots/matlab2pgfplots.m	2016-08-11 21:43:18 UTC (rev 41838)
@@ -34,7 +34,7 @@
 %       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.
 %
 %

Modified: trunk/Master/texmf-dist/source/context/third/pgfplots/pgfplotstests.context.tar.bz2
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/pgfplots/pgfplotstests.tar.bz2
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/context/third/pgfplots/t-pgfplots.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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`\@}

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarycolorbrewer.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarycolorbrewer.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarycolorbrewer.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -349,21 +349,24 @@
 \pgfutil at definecolor{PRGn-N}{RGB}{27,120,55}
 \pgfutil at definecolor{PRGn-O}{RGB}{0,68,27}
 
-\pgfutil at definecolor{PuOr-A}{RGB}{127,59,8}
-\pgfutil at definecolor{PuOr-B}{RGB}{179,88,6}
-\pgfutil at definecolor{PuOr-C}{RGB}{230,97,1}
-\pgfutil at definecolor{PuOr-D}{RGB}{224,130,20}
-\pgfutil at definecolor{PuOr-E}{RGB}{241,163,64}
-\pgfutil at definecolor{PuOr-F}{RGB}{253,184,99}
-\pgfutil at 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 at definecolor{PuOr-A}{RGB}{45,0,75}
+\pgfutil at definecolor{PuOr-B}{RGB}{84,39,136}
+\pgfutil at definecolor{PuOr-C}{RGB}{94,60,153}
+\pgfutil at definecolor{PuOr-D}{RGB}{128,115,172}
+\pgfutil at definecolor{PuOr-E}{RGB}{153,142,195}
+\pgfutil at definecolor{PuOr-F}{RGB}{178,171,210}
+\pgfutil at definecolor{PuOr-G}{RGB}{216,218,235}
 \pgfutil at definecolor{PuOr-H}{RGB}{247,247,247}
-\pgfutil at definecolor{PuOr-I}{RGB}{216,218,235}
-\pgfutil at definecolor{PuOr-J}{RGB}{178,171,210}
-\pgfutil at definecolor{PuOr-K}{RGB}{153,142,195}
-\pgfutil at definecolor{PuOr-L}{RGB}{128,115,172}
-\pgfutil at definecolor{PuOr-M}{RGB}{94,60,153}
-\pgfutil at definecolor{PuOr-N}{RGB}{84,39,136}
-\pgfutil at definecolor{PuOr-O}{RGB}{45,0,75}
+\pgfutil at definecolor{PuOr-I}{RGB}{254,224,182}
+\pgfutil at definecolor{PuOr-J}{RGB}{253,184,99}
+\pgfutil at definecolor{PuOr-K}{RGB}{241,163,64}
+\pgfutil at definecolor{PuOr-L}{RGB}{224,130,20}
+\pgfutil at definecolor{PuOr-M}{RGB}{230,97,1}
+\pgfutil at definecolor{PuOr-N}{RGB}{179,88,6}
+\pgfutil at definecolor{PuOr-O}{RGB}{127,59,8}
 
 \pgfutil at definecolor{RdBu-A}{RGB}{103,0,31}
 \pgfutil at definecolor{RdBu-B}{RGB}{178,24,43}

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.dateplot.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -156,14 +156,15 @@
 	\endgroup
 }%
 
+\expandafter\def\expandafter\pgfplots at notify@options at are@set\expandafter{\pgfplots at notify@options at are@set
+	\global\let\pgfplots at global@dateplot at defaultshift=\pgfutil at empty
+}
+
 \pgfplotsset{
 	/pgfplots/date ZERO/.code={%
 		\pgfplots at dateplot@parse at ZEROSHIFT{#1}%
 		\let\pgfplots at calender@ZEROSHIFT=\pgfmathresult
 	},
-	/pgfplots/execute at begin axis@@/.add={}{%
-		\global\let\pgfplots at global@dateplot at defaultshift=\pgfutil at empty
-	},
 	/pgfplots/date coordinates in/.code={%
 		\pgfkeysdef{/pgfplots/#1 coord trafo}{%
 			\begingroup

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.external.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -109,4 +109,23 @@
 	\endgroup
 \fi
 
+
+
+\def\tikzexternal at externalizefig@systemcall at call@old#1{%
+	\iftikzexternal at verboseio
+		\immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}%
+	\fi
+	\immediate\write18{#1}%
+}%
+
+\def\tikzexternal at externalizefig@systemcall at call@new#1{%
+	\iftikzexternal at verboseio
+		\immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}%
+	\fi
+	\pgfutil at shellescape{#1}%
+}%
+\ifx\tikzexternal at externalizefig@systemcall at call\tikzexternal at externalizefig@systemcall at call@old
+	\let\tikzexternal at externalizefig@systemcall at call=\tikzexternal at externalizefig@systemcall at call@new
+\fi
+
 \endinput

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.fillbetween.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at loc@TMPa{%
@@ -71,41 +71,10 @@
 	},%
 	%
 	/pgfplots/execute at begin axis@@/.add={}{%
-		\gdef\pgfplotsfillbetween at list@of at layers@with at clippath{}%
 		\gdef\b at pgfplotsfillbetween@list at has@set at layers{0}%
 	},
 }
 
-% #1: the value of /tikz/fill between/on layer
-\def\pgfplotsfillbetween at ensure@clipping at on@layer{%
-	\ifpgfplots at clip
-		\pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots at loc@TMPa
-		\edef\pgfplots at loc@TMPa{\pgfplots at loc@TMPa}%
-		%
-		% check if 'pre main,' is inside of the already prepared layers:
-		\def\pgfplots at loc@TMPb{\expandafter\pgfutil at in@\expandafter{\pgfplots at loc@TMPa,}}%
-		\expandafter\pgfplots at loc@TMPb\expandafter{\pgfplotsfillbetween at list@of at layers@with at clippath}%
-		%
-		\ifpgfutil at in@
-			% ah - already prepared. Good, nothing left to do.
-		\else
-			\pgfplots at log3{fill between: found 'clip=true'. Preparing pgfplotsextra instruction with clip path for layer '\pgfplots at loc@TMPa'...}%
-			\xdef\pgfplotsfillbetween at list@of at layers@with at clippath{\pgfplots at loc@TMPa,\pgfplotsfillbetween at list@of at layers@with at clippath}%
-			%
-			\edef\pgfplots at loc@TMPb{%
-				\noexpand\pgfplotsextra{%
-					\noexpand\pgfplotsonlayer{\pgfplots at loc@TMPa}%
-					\noexpand\pgfplotspathaxisoutline
-					\noexpand\pgfusepath{clip}%
-					\noexpand\endpgfplotsonlayer
-				}%
-			}%
-			\pgfplots at loc@TMPb
-			%
-		\fi
-	\fi
-}%
-
 % The options are from 
 % \addplot[#1] fill between[#2] #3;
 %
@@ -114,6 +83,12 @@
 	%
 	\pgfplots at start@plot at 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 at loc@TMPa
+	\pgfkeyslet{/tikz/fill between/on layer}{\pgfplots at loc@TMPa}%
+	%
+	% FIXME:  is this here an accident!?
 	\pgfkeysvalueof{/pgfplots/execute at end survey}%
 	\pgfplots at remember@survey at option@list
 	%
@@ -125,6 +100,41 @@
 	}{%
 		% empty - this here is a TikZ instruction, not a "real" \addplot command
 	}{%
+		\def\b at pgfplots@fillbetween at clip@on at layer{0}%
+		\pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots at loc@TMPa
+		\edef\pgfplots at fillbetween@layer{\pgfplots at loc@TMPa}%
+		\ifx\pgfplots at fillbetween@layer\pgfutil at empty
+		\else
+			\ifpgfplots at clip
+				\def\b at pgfplots@fillbetween at clip@on at 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 at beginscope resulted in invalid PDF.
+				%
+				\pgfplotsonlayer{\pgfplots at 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 at pgfplots@fillbetween at clip@on at layer
+			\endscope
+			\endpgfplotsonlayer%
+		\fi
 	}{%	
 		% post command.
 	}%
@@ -148,7 +163,6 @@
 }%
 
 % SIDE-EFFECT: modifies \b at pgfplotsfillbetween@list at has@set at layers and
-% \pgfplotsfillbetween at list@of at layers@with at clippath
 \def\pgfplotslibraryfillbetweenpreparecurrentlayer{%
 	\pgfkeysgetvalue{/tikz/fill between/on layer}\pgfplots at loc@TMPa
 	\ifx\pgfplots at loc@TMPa\pgfutil at empty
@@ -158,7 +172,6 @@
 			\pgfplotssetlateoptions{fill between/@ensure layers}%
 			\gdef\b at pgfplotsfillbetween@list at has@set at layers{1}%
 		\fi
-		\pgfplotsfillbetween at ensure@clipping at on@layer%
 	\fi
 }
 

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.groupplots.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -220,13 +220,13 @@
 % Determine the labels of both x and y.
 %
 \def\pgfplots at group@determine at labels{%
-    \def\pgfplots at loc@TMPa{all}
-    \def\pgfplots at loc@TMPb{lower}
+    \def\pgfplots at loc@TMPa{all}%
+    \def\pgfplots at loc@TMPb{lower}%
     \ifx\pgfplots at loc@TMPa\pgfplots at group@xlabels%
       % xlabels at=all
       % Do nothing as all should have xlabels
     \fi
-    \gdef\pgfplots at glob@TMPa{}
+    \gdef\pgfplots at glob@TMPa{}%
     \ifx\pgfplots at loc@TMPb\pgfplots at group@xlabels%
 	  % xlabels at=lower
       \ifnum1<\pgfplots at group@rows\relax
@@ -235,7 +235,11 @@
                 \ifnum\pgfplots at row=\pgfplots at group@rows\relax%
                 \else
                 \expandafter\xdef\expandafter\pgfplots at glob@TMPa\expandafter{%
-                    \pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={/pgfplots/xlabel={}}}%
+                    \pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={%
+						/pgfplots/xlabel={},%
+						\ifpgfplots at units@use/pgfplots/x unit={}\fi
+					}%
+				}%
                 \fi
             }%
         }%
@@ -252,7 +256,11 @@
 							\pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={/pgfplots/xticklabel pos=upper}}%
 						\else
 						\expandafter\xdef\expandafter\pgfplots at glob@TMPa\expandafter{%
-							\pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={/pgfplots/xlabel={}}}%
+							\pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={%
+								/pgfplots/xlabel={},%
+								\ifpgfplots at units@use/pgfplots/x unit={}\fi%
+							}%
+						}%
 						\fi
 					}%
 				}%
@@ -273,7 +281,11 @@
 				\foreach \pgfplots at row in {1,...,\pgfplots at group@rows} {%
 					\foreach \pgfplots at column in {2,...,\pgfplots at group@columns} {%
 						\expandafter\xdef\expandafter\pgfplots at glob@TMPa\expandafter{%
-							\pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={/pgfplots/ylabel={}}}%
+							\pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={%
+								/pgfplots/ylabel={},%
+								\ifpgfplots at units@use/pgfplots/y unit={}\fi%
+							}%
+						}%
 					}%
 				}%
 			\fi%
@@ -289,7 +301,11 @@
 								\pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={/pgfplots/yticklabel pos=upper}}%
 							\else
 							\expandafter\xdef\expandafter\pgfplots at glob@TMPa\expandafter{%
-								\pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={/pgfplots/ylabel={}}}%
+								\pgfplots at glob@TMPa,/pgfplots/group/plot c\pgfplots at column r\pgfplots at row/.append style={%
+									/pgfplots/ylabel={},%
+									\ifpgfplots at units@use/pgfplots/y unit={}\fi%
+								}%
+							}%
 							\fi
 						}%
 					}%
@@ -297,7 +313,7 @@
 			\fi%
 		\fi
     \fi
-    \expandafter\pgfkeys\expandafter{\pgfplots at glob@TMPa}
+    \expandafter\pgfkeys\expandafter{\pgfplots at glob@TMPa}%
 }
 
 %

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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/. at cmd}\pgfplotsarray at iflt
+	\let\mid=\c at pgf@counta
+	\let\left=\c at pgf@countb
+	\let\right=\c at pgf@countc
+	\left=#3\relax
+	\right=#4\relax
+	\advance\right by-1 % make it inclusive
+	\let\pgfplotsretval\pgfutil at empty
+	%
+	\pgfutil at loop
+	\ifnum\left>\right
+		\pgfplots at loop@CONTINUEfalse
+	\else
+		\pgfplots at loop@CONTINUEtrue
+	\fi
+	\ifpgfplots at loop@CONTINUE
+		\mid=\right
+		\advance\mid by -\left
+		\divide\mid by2 %
+		\advance\mid by\left
+		%
+		\pgfplotsarrayselect\mid\of#1\to\midvalue
+		\pgfplotsarray at iflt{\targetvalue}{\midvalue}{%
+			\right=\mid
+			\advance\right by-1 %
+		}{%
+			\pgfplotsarray at iflt{\midvalue}{\targetvalue}{%
+				\left=\mid
+				\advance\left by1 %
+			}{%
+				% found it! abort loop!
+				\left=\right
+				\advance\left by1 %
+				\edef\pgfplotsretval{\the\mid}%
+			}%
+			\pgfeov%
+		}%
+		\pgfeov%
+	\pgfutil at repeat
+	%
+	\ifx\pgfplotsretval\pgfutil at empty
+		\advance\left by1 %
+		\left=-\left
+		\edef\pgfplotsretval{\the\left}%
+	\fi
+	\pgfmath at smuggleone\pgfplotsretval
+	\endgroup
+}%

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua	2016-08-11 21:43:18 UTC (rev 41838)
@@ -32,8 +32,9 @@
 -- 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
@@ -40,6 +41,7 @@
 	self.invh = 1/h
 	self.colorspace = colorspace
 	self.values = values
+	self.pos = positions
 
 	local numComponents = self.colorspace.numComponents
 	for i = 1,#self.values do

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua	2016-08-11 21:43:18 UTC (rev 41838)
@@ -15,7 +15,6 @@
 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 @@
     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 @@
 	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 @@
 
 -- @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 @@
 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 @@
 		end
 		local old = updatePseudoConstants(ptCoords)
 
-		result = pgfmathparse(filterExpressionByDir[dir])
+		result = pgfluamathparser.pgfmathparse(filterExpressionByDir[dir])
 
 		updatePseudoConstants(old)
 	end

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at append@every at 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 at colname@for at styles{\the\t at pgfplots@tokb}%
 			\fi
-			\edef\pgfplotstable at loc@TMPa{\the\t at pgfplots@toka,columns/\pgfplotstable at colname@for at styles/.try}%
+			\edef\pgfplotstable at loc@TMPa{every column,\the\t at pgfplots@toka,columns/\pgfplotstable at colname@for at styles/.try}%
 			\t at pgfplots@toka=\expandafter{\pgfplotstable at loc@TMPa}%
 			\t at pgfplots@tokb=\expandafter{\pgfplotstable at displaycolkey}%
 			\edef\pgfplotstable at loc@TMPa{\the\t at pgfplots@toka,\the\t at pgfplots@tokb}%

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_loader.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -210,11 +210,14 @@
 			  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 at directlua{%
 		      pgfplots.pgfluamathfunctions = pgfluamathfunctions;
-			  pgfplots.pgfluamathparser = pgfluamathparser}
+			  pgfplots.pgfluamathparser = pgfluamathparser}%
 			\let\pgfmathnotifynewdeclarefunction at orig=\PATCH at pgfmathnotifynewdeclarefunction@orig
 			\let\pgfmathsetseed at pgfbasic=\PATCH at pgfmathsetseed@pgfbasic
+			\pgfplots at log4{luamath library shipped with pgf \pgfversion\space is outdated; using a substitute shipped with pgfplots}%
 		\else
 			\pgfplots at log4{luamath library shipped with pgf \pgfversion\space is up-to-date}%
 		\fi
@@ -221,5 +224,50 @@
 	\fi
 \fi
 
+\def\pgf at plotgnuplot@luatex at eight@seven[#1]#2{%
+  \pgf at resample@plottrue%
+  \pgfutilpreparefilename{#1.gnuplot}%
+  \let\pgf at plotgnuplotfile=\pgfretval
+  \pgfutilpreparefilename{#1.table}%
+  \let\pgf at plottablefile=\pgfretval
+  \let\pgf at plottablefile@quoted=\pgfretvalquoted
+  % Check, whether it is up-to-date
+  \openin\pgfutil at inputcheck=\pgf at plotgnuplotfile\relax
+  \ifeof\pgfutil at inputcheck%
+  \else%
+    \pgfutil at read\pgfutil at inputcheck to\pgf at temp% ignored
+    \pgfutil at read\pgfutil at inputcheck to\pgf at plot@line%
+	\closein\pgfutil at inputcheck
+    \edef\pgf at plot@code{#2\space}%
+    \ifx\pgf at plot@code\pgf at plot@line%
+      \openin\pgfutil at inputcheck=\pgfretval\relax
+      \ifeof\pgfutil at inputcheck%
+      \else%
+	    \closein\pgfutil at inputcheck
+        \pgf at resample@plotfalse%
+      \fi%
+    \fi%
+  \fi
+  \ifpgf at resample@plot%  
+    \immediate\openout\pgf at plotwrite=\pgf at plotgnuplotfile\relax
+    \immediate\pgfutil at write\pgf at plotwrite{\pgf at gnuplot@head}%
+    \immediate\pgfutil at write\pgf at plotwrite{#2}%
+    \immediate\closeout\pgf at plotwrite%
+    \pgfutil at shellescape{%
+      \pgfkeysvalueof{/pgf/plot/gnuplot call} \pgf at plotgnuplotfile}%
+  \fi%
+%  \let\pgf at savedparsexyline=\pgf at parsexyline%
+%  \let\pgf at parsexyline=\pgf at parsegnuplotxyline%
+  \pgfplotxyfile{\pgf at plottablefile}%
+%  \let\pgf at parsexyline=\pgf at savedparsexyline%
+}
 
+\pgfutil at IfUndefined{pgfutil at shellescape}{%
+	\def\pgfutil at shellescape{\pgfplots at shellescape}%
+	\let\pgf at plotgnuplot=\pgf at plotgnuplot@luatex at eight@seven
+}{%
+	% ok, plot function is up-to-date
+}%
+
+
 \endinput

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternalshared.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at externalizefig@before at grab{%
+	\pgfutil at IfUndefined{TP at holdbox}{%
+	}{%
+		% \usepackage[absolute]{textpos}
+		% populates this box -- and would inject unwanted material into our images. Reset it:
+		\global\setbox\TP at holdbox\vbox{}%
+	}%
+}%
+
 \def\tikzexternal at externalizefig@GRAB{%
-	\iftikzexternal at optimize
-		\ifpgf at external@grabshipout
+	\ifpgf at external@grabshipout
+		\iftikzexternal at optimize
 			\tikzexternal at optimize@RESTORE
 		\fi
+		\tikzexternal at externalizefig@before at grab
 	\fi
 	\def\tikzpicture{%
 		\def\tikzpicture{% make sure that nested \tikzpicture are processed normally.
@@ -1473,7 +1483,7 @@
 	\iftikzexternal at verboseio
 		\immediate\write16{===== 'mode=convert with system call': Invoking '#1' ========}%
 	\fi
-	\immediate\write18{#1}%
+	\pgfutil at shellescape{#1}%
 }%
 
 % Sets \iftikzexternal at file@isuptodate to false if one of the "force

Added: trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfsys-luatexpatch.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfsys-luatexpatch.def	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfsys-luatexpatch.def	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at invoke#1{\pdfextension literal{#1}}
+
+% Synced hboxes
+\def\pgfsys at hboxsynced#1{%
+  {%
+    \pgfsys at beginscope%
+    \setbox\pgf at hbox=\hbox{%
+      \hskip\pgf at pt@x%
+      \raise\pgf at pt@y\hbox{%
+        \pgf at pt@x=0pt%
+        \pgf at pt@y=0pt%
+        \pgflowlevelsynccm% 
+        \pgfsys at hbox#1}%
+      \hss%
+    }%
+    \wd\pgf at hbox=0pt%
+    \ht\pgf at hbox=0pt%
+    \dp\pgf at hbox=0pt%
+    \box\pgf at hbox%
+    \pgfsys at endscope%
+  }%
+}
+
+
+
+\def\pgfsys at imagesuffixlist{.pdf:.jpg:.jpeg:.png:}
+\def\pgfsys at defineimage{% width, height, page number
+  \ifx\pgf at imagewidth\pgfutil at empty\else\edef\pgf at imagewidth{ width \pgf at imagewidth }\fi%
+  \ifx\pgf at imageheight\pgfutil at empty\else\edef\pgf at imageheight{ height \pgf at imageheight }\fi%
+  \ifx\pgf at imagepage\pgfutil at empty\else\edef\pgf at imagepage{ page \pgf at imagepage }\fi%
+  \ifx\saveimageresource\@undefined% old version of lualatex
+    \ifx\pgf at imagepage\pgfutil at empty\else%
+      \pgfwarning{Page selection not supported. Ignoring page selection}%
+    \fi%
+    \setbox\pgfutil at tempboxa=\hbox{%
+      \pdfimage \pgf at imageheight \pgf at imagewidth {\pgf at filename}}%
+    \pdfform\pgfutil at tempboxa%
+    \edef\pgf at image{\noexpand\pdfrefform\the\pdflastform}%
+  \else% new version
+    {\saveimageresource \pgf at imageheight \pgf at imagewidth attr
+      {/Interpolate \pgf at imageinterpolate\space\pgf at imagemask} \pgf at imagepage
+      {\pgf at filename}}%
+    \edef\pgf at image{\noexpand\useimageresource\the\lastsavedimageresourceindex}%
+  \fi
+}%
+\def\pgfsys at definemask#1{%
+  \ifx\pgf at maskmatte\pgfutil at empty%
+  \else%
+    \edef\pgf at maskmatte{/Matte [\pgf at maskmatte]}%
+  \fi%
+  \edef\pgf at attr{{\pgf at maskmatte\space /Decode [1 0]}}%
+  \immediate\saveimageresource attr \pgf at attr {\pgf at filename}%
+  \edef\pgf at mask{/SMask \the\lastsavedimageresourceindex\space 0 R}%
+}
+\def\pgfsys at horishading#1#2#3{%
+  {%
+    \pgf at parsefunc{#3}%
+    \pgfmathparse{#2}%
+    \setbox\pgfutil at tempboxa=\hbox to\pgf at max{\vbox to\pgfmathresult pt{\vfil\pgfsys at invoke{/Sh sh}}\hfil}%
+    \pgf at process{\pgfpoint{\pgf at max}{#2}}%
+    \immediate\saveboxresource resources {%
+      /Shading << /Sh << /ShadingType 2
+      /ColorSpace /DeviceRGB
+      /Domain [\pgf at pdfparseddomain]
+      /Coords [\pgf at doma\space0 \pgf at domb\space0]
+      /Function \pgf at pdfparsedfunction
+      /Extend [false false] >> >>}\pgfutil at tempboxa% <<
+    \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}% 
+  }%
+}
+\def\pgfsys at vertshading#1#2#3{%
+  {%
+    \pgf at parsefunc{#3}%
+    \pgfmathparse{#2}%
+    \setbox\pgfutil at tempboxa=\hbox to\pgfmathresult pt{\vbox to\pgf at max{\vfil\pgfsys at invoke{/Sh sh}}\hfil}%
+    \pgf at process{\pgfpoint{#2}{\pgf at max}}%
+    \immediate\saveboxresource resources {%
+      /Shading << /Sh << /ShadingType 2
+      /ColorSpace /DeviceRGB
+      /Domain [\pgf at pdfparseddomain]
+      /Coords [0 \pgf at doma\space0 \pgf at domb]
+      /Function \pgf at pdfparsedfunction
+      /Extend [false false] >> >>}\pgfutil at tempboxa% <<
+    \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}%
+  }%
+}
+\def\pgfsys at radialshading#1#2#3{%
+  {%
+    \pgf at parsefunc{#3}%
+    \setbox\pgfutil at tempboxa=\hbox to2\pgf at max{\vbox to2\pgf at max{\vfil\pgfsys at invoke{/Sh sh}}\hfil}%
+    \pgf at process{#2}%
+    \pgf at xa=\pgf at x%
+    \pgf at ya=\pgf at y%
+    \pgf at process{\pgfpoint{\pgf at max}{\pgf at max}}%
+    \advance\pgf at xa by \pgf at x%
+    \advance\pgf at ya by \pgf at y%
+    \pgf at sys@bp at correct{\pgf at x}%
+    \pgf at sys@bp at correct{\pgf at y}%
+    \pgf at sys@bp at correct{\pgf at xa}%
+    \pgf at sys@bp at correct{\pgf at ya}%
+    \immediate\saveboxresource resources {%
+      /Shading << /Sh << /ShadingType 3
+      /ColorSpace /DeviceRGB
+      /Domain [\pgf at pdfparseddomain]
+      /Coords [\pgf at sys@tonumber{\pgf at xa} \pgf at sys@tonumber{\pgf at ya} \pgf at doma\space \pgf at sys@tonumber{\pgf at x} \pgf at sys@tonumber{\pgf at y} \pgf at domb]
+      /Function \pgf at pdfparsedfunction
+      /Extend [true false] >> >>}\pgfutil at tempboxa% <<
+    \expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\useboxresource\the\lastsavedboxresourceindex}%
+  }%
+}%
+\def\pgfsys at functionalshading#1#2#3#4{%
+  {%
+    \pgf at process{#2}%
+    \pgf at xa=\pgf at x%
+    \pgf at ya=\pgf at y%
+    \pgf at process{#3}%
+    \pgf at xb=\pgf at x%
+    \pgf at yb=\pgf at y%
+    \advance\pgf at x by-\pgf at xa%
+    \advance\pgf at y by-\pgf at ya%
+    \setbox\pgfutil at tempboxa=\hbox to\pgf at x{\vbox to\pgf at y{\vfil\pgfsys at invoke{/Sh sh}}\hfil}%
+    \pgf at sys@bp at correct{\pgf at xa}%
+    \pgf at sys@bp at correct{\pgf at ya}%
+    \pgf at sys@bp at correct{\pgf at xb}%
+    \pgf at sys@bp at correct{\pgf at yb}%
+    \pgf at xc=-\pgf at xa%
+    \pgf at yc=-\pgf at ya%
+    % Now build the function
+    \pdfextension obj 
+    stream
+    attr
+    {
+      /FunctionType 4
+      /Domain [\pgf at sys@tonumber{\pgf at xa}\space\pgf at sys@tonumber{\pgf at xb}\space\pgf at sys@tonumber{\pgf at ya}\space\pgf at sys@tonumber{\pgf at yb}]
+      /Range [0 1 0 1 0 1]
+    }
+    {{#4}}%
+    \edef\pgf at temp@num{\the\numexpr\pdffeedback lastobj\relax}%
+    \saveboxresource resources {%
+      /Shading << /Sh << /ShadingType 1
+      /ColorSpace /DeviceRGB
+      /Matrix [1 0 0 1 \pgf at sys@tonumber{\pgf at xc}\space\pgf at sys@tonumber{\pgf at yc}]
+      /Domain [\pgf at sys@tonumber{\pgf at xa}\space\pgf at sys@tonumber{\pgf at xb}\space\pgf at sys@tonumber{\pgf at ya}\space\pgf at sys@tonumber{\pgf at yb}]
+      /Function \pgf at temp@num\space 0 R 
+      >> >>}\pgfutil at tempboxa% <<
+    \expandafter\xdef\csname @pgfshading#1!\endcsname{%
+      \leavevmode%
+      \noexpand\useboxresource\the\lastsavedboxresourceindex%
+      \noexpand\pdfextension refobj \pgf at temp@num%
+    }%
+  }%
+}
+
+
+
+% Patterns
+
+\def\pgfsys at declarepattern#1#2#3#4#5#6#7#8#9{%
+  % Start building the pattern dictionary:
+  \pgf at xa=#2\relax%
+  \pgf at ya=#3\relax% 
+  \pgf at xb=#4\relax%
+  \pgf at yb=#5\relax%
+  \pgf at xc=#6\relax%
+  \pgf at yc=#7\relax%
+  \pgf at sys@bp at correct\pgf at xa%
+  \pgf at sys@bp at correct\pgf at ya%
+  \pgf at sys@bp at correct\pgf at xb%
+  \pgf at sys@bp at correct\pgf at yb%
+  \pgf at sys@bp at correct\pgf at xc%
+  \pgf at sys@bp at correct\pgf at 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 at sys@tonumber\pgf at xa\space\pgf at sys@tonumber\pgf at ya\space\pgf at sys@tonumber\pgf at xb\space\pgf at sys@tonumber\pgf at yb]
+    /XStep \pgf at sys@tonumber\pgf at xc\space
+    /YStep \pgf at sys@tonumber\pgf at yc\space
+    /Resources << >> %<<
+  }
+  {#8}% 
+  \pgfutil at addpdfresource@patterns{/pgfpat#1\space \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
+}
+
+\def\pgfsys at setpatternuncolored#1#2#3#4{%
+  \pgfsysprotocol at literal{/pgfprgb cs #2 #3 #4 /pgfpat#1\space scn}%
+}
+
+\def\pgfsys at setpatterncolored#1{%
+  \pgfsysprotocol at 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 at declarepattern@meta#1#2#3#4#5#6#7{%
+  % Start building the pattern dictionary:
+  \pgf at xa=#2\relax%
+  \pgf at ya=#3\relax% 
+  \pgf at xb=#4\relax%
+  \pgf at yb=#5\relax%
+  \pgf at xc=#6\relax%
+  \pgf at yc=#7\relax%
+  \pgf at sys@bp at correct\pgf at xa%
+  \pgf at sys@bp at correct\pgf at ya%
+  \pgf at sys@bp at correct\pgf at xb%
+  \pgf at sys@bp at correct\pgf at yb%
+  \pgf at sys@bp at correct\pgf at xc%
+  \pgf at sys@bp at correct\pgf at yc%
+  \pgfsys@@declarepattern at meta{#1}}
+
+\def\pgfsys@@declarepattern at meta#1#2#3#4#5#6#7#8#9{%
+   \pgfutil at tempdima=#6\relax%
+   \pgfutil at tempdimb=#7\relax%
+   \pgf at sys@bp at correct\pgf at xa%
+   \pgf at sys@bp at correct\pgf at 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 at sys@tonumber\pgf at xa\space\pgf at sys@tonumber\pgf at ya\space\pgf at sys@tonumber\pgf at xb\space\pgf at sys@tonumber\pgf at yb]
+     /XStep \pgf at sys@tonumber\pgf at xc\space
+     /YStep \pgf at sys@tonumber\pgf at yc\space
+     /Matrix [#2\space#3\space#4\space#5\space\pgf at sys@tonumber\pgfutil at tempdima\space\pgf at sys@tonumber\pgfutil at tempdimb]
+     /Resources << >> %<<
+   }
+   {#8}% 
+   \pgfutil at addpdfresource@patterns{/pgfpat#1\space \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
+ }
+
+
+
+\def\pgfsys at papersize#1#2{\pageheight#2\relax\pagewidth#1\relax}
+
+\def\pgfsys at global@papersize#1#2{\global\pageheight#2\relax\global\pagewidth#1\relax}
+
+\ifx\paperheight\@undefined
+  \def\pgfsys at thepageheight{\pageheight}
+  \def\pgfsys at thepagewidth{\pagewidth}
+\fi
+
+
+%
+% Position tracking
+%
+\def\pgfsys at markposition#1{%
+  \savepos%
+  \edef\pgf at temp{#1}%
+  \expandafter\pgfutil at writetoaux\expandafter{%
+    \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf at temp}{\the\lastxpos}{\the\lastypos}}%
+}
+
+\def\pgfsyspdfmark#1#2#3{%
+  \expandafter\gdef\csname pgf at sys@pdf at mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}%
+  \pgfutil at check@rerun{#1}{{#2}{#3}}%
+}
+
+\def\pgfsys at getposition#1#2{%
+  \edef\pgf at marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf at sys@pdf at mark@pos@#1\endcsname}%
+  \pgf at marshal%
+}
+
+\def\pgf at sys@pdf at mark@pos at pgfpageorigin{\pgfqpoint{\hoffset}{\voffset}}
+
+
+%
+% Opacity masks
+%
+\def\pgfsys at fadingfrombox#1#2{%
+  {%
+    \pgf at sys@pdf at check@resources%
+    \pgf at x=-.5\wd#2%
+    \pgf at y=-.5\ht#2%
+    \advance\pgf at y by.5\dp#2%
+    \expandafter\xdef\csname pgfsmasktrans@#1\endcsname{%
+      \noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf at x}{\the\pgf at y}}}%
+    \saveboxresource resources { \pgf at sys@pdf at possible@resources } #2%
+    \expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\lastsavedboxresourceindex}%
+  }%
+}
+\def\pgfsys at 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 at sys@pdf at install@mask{#1}%
+      \fi%
+      \pgftransformreset%
+      \pgftransformcm{#2}{#3}{#4}{#5}{\pgfpoint{#6}{#7}}%
+      \csname pgfsmasktrans@#1\endcsname%
+      {%
+        \pgflowlevelsynccm%
+        \pgfsys at invoke{/pgfsmask\csname pgfsmask@#1\endcsname\space gs}%
+      }%
+      \pgftransforminvert%
+      \pgflowlevelsynccm%
+    }%
+  \fi
+}
+
+\def\pgf at sys@pdf at install@mask#1{%
+  \setbox\pgfutil at tempboxa=\hbox{\useboxresource\csname pgfsmaskxform@#1\endcsname}
+  \immediate\saveboxresource%
+    attr {
+    /Group
+    <<
+      /S /Transparency
+      /CS /DeviceGray
+    >>
+  }% <<
+  \pgfutil at tempboxa% 
+  \pgfutil at 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 at transparencygroupfrombox#1{%
+  \pgf at sys@pdf at check@resources%
+  \saveboxresource
+  attr { /Group << /S /Transparency
+    /I \ifpgfsys at transparency@group at isolated true \else false \fi
+    /K \ifpgfsys at transparency@group at knockout true \else false \fi >> } %<<
+  resources { \pgf at sys@pdf at possible@resources }
+  #1%
+  \setbox#1=\hbox{\useboxresource\lastsavedboxresourceindex}%
+}
+
+
+
+
+%
+% Resource management
+%
+
+\def\pgf at sys@setuppdfresources at 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 at sys@pdf at extgs@objnum{\the\numexpr\pdffeedback lastobj\relax}
+  \pdfextension obj  reserveobjnum \edef\pgf at sys@pdf at pattern@objnum{\the\numexpr\pdffeedback lastobj\relax}
+  \pdfextension obj  reserveobjnum \edef\pgf at sys@pdf at colrospaces@objnum{\the\numexpr\pdffeedback lastobj\relax}
+  \def\pgf at sys@pdf at possible@resources{%
+    /ColorSpace \pgf at sys@pdf at colrospaces@objnum\space 0 R
+    /Pattern    \pgf at sys@pdf at pattern@objnum\space 0 R
+    /ExtGState  \pgf at sys@pdf at extgs@objnum\space 0 R
+  }
+  \let\pgf at sys@pdf at check@resources=\relax%
+  \def\pgf at sys@pdf at install@pageresources{
+    {
+      \edef\temp{
+        \pgf at sys@pdf at possible@resources
+      }
+      \expandafter\global\expandafter\pdfvariable pageresources\expandafter{\temp}
+    }
+  }
+  \pgf at sys@pdf at install@pageresources
+  \expandafter\pgfutil at everybye\expandafter{%
+    \the\pgfutil at everybye%
+    \immediate \pdfextension obj  useobjnum \pgf at sys@pdf at extgs@objnum {<<\pgf at sys@pgf at resource@list at extgs>>}%<<
+    \immediate \pdfextension obj  useobjnum \pgf at sys@pdf at pattern@objnum {<<\pgf at sys@pgf at resource@list at patterns>>}%<<
+    \immediate \pdfextension obj  useobjnum \pgf at sys@pdf at colrospaces@objnum {<<\pgf at sys@pgf at resource@list at colorspaces>>}%<<
+  }
+  \let\pgf at sys@pgf at resource@list at extgs=\pgfutil at empty%
+  \let\pgf at sys@pgf at resource@list at patterns=\pgfutil at empty%
+  \let\pgf at sys@pgf at resource@list at colorspaces=\pgfutil at empty%
+  \def\pgf at sys@addpdfresource at extgs@plain##1{\xdef\pgf at sys@pgf at resource@list at extgs{\pgf at sys@pgf at resource@list at extgs\space##1}}
+  \def\pgf at sys@addpdfresource at patterns@plain##1{\xdef\pgf at sys@pgf at resource@list at patterns{\pgf at sys@pgf at resource@list at patterns\space##1}}
+  \def\pgf at sys@addpdfresource at colorspaces@plain##1{\xdef\pgf at sys@pgf at resource@list at colorspaces{\pgf at sys@pgf at resource@list at colorspaces\space##1}}
+}
+\pgfutil at setuppdfresources % possibly call the above
+
+\pgfutil at addpdfresource@colorspaces{ /pgfprgb [/Pattern /DeviceRGB] }
+
+\def\pgfsys at color@unstacked#1{%
+	\pdfextension literal{\csname\string\color@#1\endcsname}%
+}
+
+\endinput
+
+
+%%% Local Variables: 
+%%% mode: latex
+%%% End: 


Property changes on: trunk/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfsys-luatexpatch.def
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at check@specials{#1}{#2}#2\pgfplots at EOI%
-	\endpgfkeysinterruptkeyfilter
 }%
 
 \def\pgfplotscreateplotcyclelist at check@specials#1#2{%
@@ -194,7 +193,32 @@
 	}%
 }%
 \def\pgfplotscreateplotcyclelist at 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 at createcolormap@special at process@single at define=\pgfplots at createcolormap@special at process@single at define@CYCLE
+	\let\pgfplots at createcolormap@special at process@list at separator=\pgfplots at createcolormap@special at process@list at separator@CYCLE
+	\pgfplots at of@colormap at getresult{#2}%
+	\global\let\pgfplots at glob@TMPa=\pgfplotsretval
+	\endgroup
+	%
+	\t at pgfplots@tokb={#1}%
+	\t at pgfplots@toka=\expandafter{\pgfplots at glob@TMPa}%
+	\edef\pgfplots at loc@TMPa{\noexpand\pgfplotscreateplotcyclelist{\the\t at pgfplots@tokb}{\the\t at pgfplots@toka}}%
+%\message{#2->^^J \meaning\pgfplots at loc@TMPa^^J}%
+	\pgfplots at loc@TMPa
+		%
+		% FIXME implement:
+		%--------------------------------------------------
+		% \ifnum\pgfplots at 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 at ifnextchar\pgfplots at EOI{%
 		\pgfplots at gobble@until at EOI
 	}{%
@@ -201,6 +225,7 @@
 		\pgfplotscreateplotcyclelist at check@specials at gobble@error{#2}%
 	}%
 }%
+
 \def\pgfplotscreateplotcyclelist at check@specials at gobble@error#1#2\pgfplots at EOI{%
 	\t at pgfplots@tokb={[#1]}%
 	\t at pgfplots@toka={#2}%
@@ -210,61 +235,8 @@
 	\expandafter\pgfplots at assign@list\csname pgfp at cyclist@\string#1@\endcsname{#2}%
 }
 
-\def\pgfplotscreateplotcyclelist at check@specials at process@colormap at conversion#1#2{%
-	\pgfplots at color@of at colormap@parse{#1}%
-	\begingroup
-	\gdef\pgfplots at glob@TMPa{}%
-	\gdef\pgfplots at glob@TMPb{0}%
-	\def\pgfplots at loc@TMPa{\foreach \x in }%
-	\expandafter\pgfplots at loc@TMPa\expandafter{\pgfplots at color@of at colormap@value}{%
-		\t at pgfplots@tokb=\expandafter{\pgfplots at color@of at colormap@name}%
-		\edef\currentValue{#2=\x\space of \the\t at pgfplots@tokb}%
-		%
-		\t at pgfplots@toka=\expandafter{\pgfplots at glob@TMPa}%
-		\t at pgfplots@tokb=\expandafter{\currentValue\\}%
-		\xdef\pgfplots at glob@TMPa{\the\t at pgfplots@toka\the\t at pgfplots@tokb}%
-		%
-		\pgfplotsutil at advancestringcounter@global\pgfplots at glob@TMPb
-		\ifnum\pgfplots at 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 at color@of at colormap@name
-	\t at pgfplots@tokb=\expandafter{\pgfplots at color@of at colormap@name}%
-	\t at pgfplots@toka=\expandafter{\pgfplots at glob@TMPa}%
-	\edef\pgfplots at loc@TMPa{\noexpand\pgfplotscreateplotcyclelist{\the\t at pgfplots@tokb}{\the\t at pgfplots@toka}}%
-%\message{got \meaning\pgfplots at loc@TMPa^^J}%
-	\pgfplots at loc@TMPa
-}%
-
 \pgfqkeys{/pgfplots/@cycle}{%
-	result name/.initial=,
 	max size/.initial=80,
-	of colormap/.code={%
-		\pgfplotsutilifstringequal{#1}{\pgfkeysnovalue}{%
-			\pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots at loc@TMPa
-			\t at pgfplots@toka=\expandafter{\pgfplots at loc@TMPa}%
-			\edef\pgfplots at loc@TMPa{%
-				\noexpand\pgfkeysalso{indices of colormap={0,...,\pgfplotscolormaplastindexof{\pgfplots at loc@TMPa}} of {\the\t at pgfplots@toka}}%
-			}%
-			\pgfplots at loc@TMPa
-		}{%
-			\pgfplotscolormapifdefined{#1}{%
-				\pgfkeysalso{indices of colormap={0,...,\pgfplotscolormaplastindexof{#1}} of {#1}}%
-			}{%
-				\pgfplots at error{There is no such colormap '#1'. Maybe you need to write \string\pgfplotsset{#1} first?}%
-			}%
-		}%
-	},%
-	colors of colormap/.code={%
-		\pgfplotscreateplotcyclelist at check@specials at process@colormap at conversion{#1}{color of colormap}%
-	},
-	indices of colormap/.code={%
-		\pgfplotscreateplotcyclelist at check@specials at process@colormap at conversion{#1}{index of colormap}%
-	},
 }
 
 \pgfplotscreateplotcyclelist{black white}{%
@@ -696,19 +668,50 @@
 	}%
 	%
 	\if m\pgfplots at color@of at colormap@access
-		\expandafter\pgfplotscolormapfind\expandafter[\pgfplotspointmetatransformedrange]
-			[1.0]
-			{\pgfplots at color@of at colormap@value}
-			{\pgfplots at color@of at colormap@name}
+		% colormap access=map
+		\expandafter\pgfplotscolormapfind\expandafter[\pgfplotspointmetatransformedrange]%
+			{\pgfplots at color@of at colormap@value}%
+			{\pgfplots at color@of at colormap@name}%
 	\else
-		\pgfplotscolormapgetindex{\pgfplots at color@of at colormap@value}{\pgfplots at color@of at colormap@name}%
+		\if c\pgfplots at color@of at colormap@access
+			% colormap access=piecewise constant
+			\expandafter\pgfplotscolormapfindpiecewiseconst\expandafter[\pgfplotspointmetatransformedrange]%
+				{\pgfplots at color@of at colormap@value}%
+				{\pgfplots at color@of at colormap@name}%
+		\else
+			% colormap access=direct
+			\pgfplotscolormapgetindex{\pgfplots at color@of at colormap@value}{\pgfplots at color@of at colormap@name}%
+		\fi
 	\fi
 }%
+
+\def\pgfplots at createcolormap@special at process@list at separator@CYCLE{\\}%
+\def\pgfplots at createcolormap@special at process@single at define@CYCLE{%
+	\edef\pgfplotsretval{%
+		/tikz/color/.define=%
+				{.}%
+				{\csname pgfpl at cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}%
+				{\pgfmathresult},%
+		/tikz/color=.,%
+	}%
+}%
 \def\pgfplots at color@of at colormap#1{%
-	\pgfplots at color@of at colormap@define{#1}%
-	\def\pgfplots at loc@TMPb{\pgfutil at definecolor{.}{\csname pgfpl at cm@\pgfplots at color@of at colormap@name @colspace\endcsname}}%
-	\expandafter\pgfplots at loc@TMPb\expandafter{\pgfmathresult}%
+	\begingroup
+	\def\pgfplots at createcolormap@special at process@single at define{%
+		\edef\pgfplotsretval{%
+			\noexpand\pgfutil at definecolor{.}{\csname pgfpl at cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}{\pgfmathresult}%
+		}%
+		\let\pgfplots at createcolormap@special at process@single at define=\relax
+	}%
+	\pgfplots at of@colormap at getresult{#1}%
+	\global\let\pgfplots at glob@TMPa=\pgfplotsretval
+	\endgroup
+	\pgfplots at glob@TMPa
 	\tikzset{color=.}%
+	%\pgfplots at color@of at colormap@define{#1}%
+	%\def\pgfplots at loc@TMPb{\pgfutil at definecolor{.}{\csname pgfpl at cm@\pgfplots at color@of at colormap@name @colspace\endcsname}}%
+	%\expandafter\pgfplots at loc@TMPb\expandafter{\pgfmathresult}%
+	%\tikzset{color=.}%
 }
 
 \newif\ifpgfplots at 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 at loc@TMPa
-			\else
-				\pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##2}\pgfplots at loc@TMPa
-			\fi
-			\def\pgfplots at loc@TMPb{\pgfdeclareverticalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}%
-			\expandafter\pgfplots at loc@TMPb\expandafter{\pgfplots at 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
 		},%
+		% 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 at loc@TMPa
+				\else
+					\pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{####2}\pgfplots at loc@TMPa
+				\fi
+				\def\pgfplots at loc@TMPb{\pgfdeclareverticalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}%
+				\expandafter\pgfplots at loc@TMPb\expandafter{\pgfplots at 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 at loc@TMPa
+				\else
+					\pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{####1}\pgfplots at loc@TMPa
+				\fi
+				\def\pgfplots at loc@TMPb{\pgfdeclarehorizontalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}%
+				\expandafter\pgfplots at loc@TMPb\expandafter{\pgfplots at loc@TMPa}%
+				\pgfuseshading{tempshading}%
+			},%
+		},%
 	},
-	/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 at loc@TMPa
-			\else
-				\pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##1}\pgfplots at loc@TMPa
-			\fi
-			\def\pgfplots at loc@TMPb{\pgfdeclarehorizontalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}%
-			\expandafter\pgfplots at loc@TMPb\expandafter{\pgfplots at loc@TMPa}%
-			\pgfuseshading{tempshading}%
-		},%
-	},%
+	/pgfplots/colorbar addplot/.initial=\pgfplots at error{COLORBAR SYSTEM UNDEFINED},
+	/pgfplots/colorbar/draw/.code={\pgfplots at 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 at colorbar@get at rid@of at at@parent at axis
+		\pgfplots at 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 at colorbar@as at legend@orientation{x}%
+		},
+		/pgfplots/colorbar vertical/lowlevel/.append code={%
+			\def\pgfplots at colorbar@as at legend@orientation{y}%
+		},
+		%
+		% ensure that our values
+		% \pgfplots at colorbar@as at 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 at CM
+			\begingroup
+				\pgfplotsset{every colorbar}%
+				\pgfmath at smuggleone\pgfplots at colorbar@as at legend@orientation
+			\endgroup
+			\pgfplotscolormapgetpositions[{\pgfkeysvalueof{/pgfplots/point meta min}}:{\pgfkeysvalueof{/pgfplots/point meta max}}]{\pgfplots at CM}%
+			\edef\pgfplots at loc@TMPa{%
+				\noexpand\pgfplotsarraynew\noexpand\positions{\pgfplotsretval}%
+			}%
+			\pgfplots at loc@TMPa
+			%
+			\c at pgf@countd=\pgfplotscolormaplastindexof{\pgfplots at CM}\relax
+			\edef\pgfplots at colorcount{\the\c at pgf@countd}%
+			\advance\c at 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 at colorcount@minus at one{\the\c at pgf@countd}%
+			%
+			% accumulate a list of formatted positions into this
+			% variable:
+			\def\pgfplots at loc@TMPc{}%
+			\pgfplotsforeachungrouped \x in {0,...,\pgfplots at colorcount} {%
+				\pgfplotsarrayselect{\x}\of\positions\to\pgfplotsretval
+				\edef\pgfplots at loc@TMPa{\noexpand\pgfmathprintnumber{\pgfplotsretval}}
+				\t at pgfplots@toka=\expandafter{\pgfplots at loc@TMPc}%
+				\t at pgfplots@tokb=\expandafter{\pgfplots at loc@TMPa}%
+				\edef\pgfplots at loc@TMPc{\the\t at pgfplots@toka \the\t at pgfplots@tokb,}%
+			}%
+			\t at pgfplots@tokb=\expandafter{\pgfplots at loc@TMPc}%
+			\xdef\pgfplots at glob@TMPa{%
+				\noexpand\pgfplotsset{%
+					% this FORGETS the colormap positions intentionally...
+					colormap={@temp at CM}{indices of colormap={0,...,\pgfplots at colorcount@minus at one of \pgfplots at CM}},
+					% ... and normalizes the number range.
+					point meta min=0,point meta max=1000,
+					colorbar style={
+						surf,shader=interp,
+						colormap access=const,
+						\pgfplots at colorbar@as at legend@orientation tick=data,
+						% here we add the positions back into the
+						% tick label:
+						\pgfplots at colorbar@as at legend@orientation ticklabels={\the\t at pgfplots@tokb},
+					},
+				}%
+			}%
+			\endgroup
+			\pgfplots at 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 at colorbar@positions at 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 at colormap@access{d}},%
 	/pgfplots/colormap access/map/.code={\def\pgfplots at colormap@access{m}},%
 	/pgfplots/colormap access/piecewise constant/.code={\def\pgfplots at colormap@access{c}},%
+	/pgfplots/colormap access/piecewise const/.code=   {\def\pgfplots at colormap@access{c}},%
+	/pgfplots/colormap access/const/.code=             {\def\pgfplots at 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 at ensure@old at cm
 	},
+	% a backwards compatibility switch:
+	/pgfplots/colormap uniform/.is choice,
+	/pgfplots/colormap uniform/always/.code={\def\pgfplots at colormap@uniform at choice{0}},
+	/pgfplots/colormap uniform/if requested/.code={\def\pgfplots at colormap@uniform at 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 at color@of at colormap@access{m}%
-		\pgfplots at color@of at colormap{#1}%
+		\pgfplots at color@of at 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 at color@of at 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 at color@of at colormap@access{d}%
-		\pgfplots at color@of at colormap{#1}%
+		\pgfplots at color@of at 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 at 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 at 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 at path@replace at 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/newest/.style=	{/pgfplots/compat/general/1.12},
+	/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/default/.style={/pgfplots/compat/general/1.11},
 	%
 	/pgfplots/enable tick line clipping/.is if=pgfplots at enable@tick at line@clipping,
@@ -4471,23 +4632,65 @@
 	/pgfplots/compat/show suggested version/.is if=pgfplots at show@suggested at 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 at glob@TMPa{%
+			\ifx\pgfplots at glob@TMPa\pgfutil at empty
+			\else
+				\edef\pgfplots at glob@TMPb{%
+					\noexpand\pgfkeysdef{\pgfplots at glob@TMPa/newest}{%
+						\noexpand\pgfkeysalso{%
+							\pgfplots at glob@TMPa/\pgfkeysvalueof{/pgfplots/compat/mostrecent}%
+						}%
+					}%
+				}%
+				\pgfplots at glob@TMPb
+			\fi
+		}%
+	},
+	/pgfplots/compat/.code={%
+		\def\pgfplots at glob@TMPa{newest}%
+		\edef\pgfplots at glob@TMPb{#1}%
+		\ifx\pgfplots at glob@TMPb\pgfplots at glob@TMPa
+			\edef\pgfplots at glob@TMPa{\noexpand\pgfkeysalso{/pgfplots/compat=\pgfkeysvalueof{/pgfplots/compat/mostrecent}}}%
+			\pgfplots at glob@TMPa
+		\else
+			\pgfkeysifdefined{/pgfplots/compat/general/#1/. at 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 at 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 at tickwidth{\pgfkeysvalueof{/pgfplots/major tick length}}%
 \def\pgfplots at subtickwidth{\pgfkeysvalueof{/pgfplots/minor tick length}}%
 
-\pgfkeysgetvalue{/pgfplots/colorbar/draw/. at cmd}\pgfplots at colorbar@draw at defaultimpl
+\begingroup
+\pgfkeys{/pgfplots/colorbar pgfshading}
+\pgfkeysgetvalue{/pgfplots/colorbar/draw/. at cmd}\pgfplots at loc@TMPa
+\global\let\pgfplots at colorbar@draw at legacyimpl=\pgfplots at loc@TMPa
+\endgroup
 
 % call 
 %   \pgfkeyslet{.../. at cmd}\pgfplots at cant@set at in@this at context
@@ -4660,8 +4867,17 @@
 				}%
 			\fi
 			\pgfplots at gettikzinternal@keyval{samples at}{tikz at plot@samplesat}{-5,-4.6,...,5}%
-			\pgfkeyslet{/pgfplots/samples at}{\tikz at plot@samplesat}%
-			\let\pgfplots at plot@samples at at=\tikz at plot@samplesat
+			%
+			% check if it was a domain. This simplifies LUA code:
+			\pgfplotsforeachtodomain{\tikz at plot@samplesat}%
+			\ifx\pgfplotsretval\pgfutil at empty
+				\pgfkeyslet{/pgfplots/samples at}{\tikz at plot@samplesat}%
+				\let\pgfplots at plot@samples at at=\tikz at plot@samplesat
+			\else
+				\let\pgfplots at plot@domain=\pgfplotsretval
+				\let\pgfplots at plot@samples=\pgfplotsretvalb
+				\pgfkeyslet{/pgfplots/samples}{\pgfplots at plot@samples}%
+			\fi
 		\else
 			% routines should use \pgfplots at plot@samples at at.
 		\fi
@@ -4750,6 +4966,11 @@
 % #2: the 'b' axis on the orentied surface (the same as \pgfplotspointonorientedsurfaceB)
 \def\pgfplots at drawaxis@innerlines at 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 at 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 at ifaxisline@B at onorientedsurf@should at be@drawn{0}{%
 			\expandafter\draw\expandafter[\pgfplots at drawaxis@outerlines at separate@onorientedsurf at opts] decorate {
 				\pgfextra
@@ -4807,6 +5035,8 @@
 				\endpgfextra 
 				};
 		}{}%
+		%
+		\endpgfplotsonlayer
 	\fi
 }%
 
@@ -4828,6 +5058,12 @@
 		\fi
 	\fi
 \ifpgfplots at 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 at colorbar@toname\pgfutil at empty
 	\else
 		\toks1={%
-			\pgfkeysgetvalue{/pgfplots/at/. at cmd}\pgfplots at at@orig
-			\pgfkeyslet{/pgfplots/at/orig/. at cmd}\pgfplots at at@orig
-			%
-			\pgfkeysgetvalue{/pgfplots/colorbar to name/at/. at cmd}\pgfplots at colorbar@toname at at
-			\pgfkeyslet{/pgfplots/at/. at cmd}\pgfplots at colorbar@toname at at
+			\pgfplots at colorbar@get at rid@of at at@parent at axis
 		}%
 		\pgfplots at colorbar@foreach at saved@key{%
 			\pgfplots at command@with at args@to at string##2\pgfplots at loc@TMPa
@@ -10023,48 +10257,155 @@
 \newif\ifpgfplotscolorbarCMYKworkaround
 \pgfplotscolorbarCMYKworkaroundtrue
 
-\def\pgfplots at colorbar@draw@{%
+\def\pgfplots at colorbar@draw at reconfigure@if at needed@legacy{%
 	\pgfkeysgetvalue{/pgfplots/colorbar/draw/. at cmd}\pgfplots at loc@TMPa
-	\ifx\pgfplots at loc@TMPa\pgfplots at colorbar@draw at defaultimpl
-		% Ah-- the default colorbar implementation is active! We may need to substitute it by a better one.
-		% Check that:
-		\def\b at pgfplots@colorbar at fallback@to at sampled{0}%
-		\ifpgfplotscolorbarCMYKworkaround
-			% the default implementation for colorbars is based on
-			% \pgfplotscolormaptoshadingspec.
-			% This, in turn, does NOT work for CMYK.
+	\ifx\pgfplots at loc@TMPa\pgfplots at colorbar@draw at 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 at init@collect at 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 at loc@TMPb
-				\pgfplotscolormapgetcolorspace{\pgfplots at loc@TMPb}%
-				\def\pgfplots at loc@TMPa{cmyk}%
-				\ifx\pgfplots at loc@TMPa\pgfplotsretval
-					\pgfutil at ifundefined{pgfplots at colorbar@CMYK@\pgfplots at loc@TMPb}{%
-						\pgfplotswarning{colorbar CMYK unsupported}{\pgfplots at loc@TMPb}\pgfeov% 
-						\expandafter\gdef\csname pgfplots at colorbar@CMYK@\pgfplots at loc@TMPb\endcsname{1}%
-					}{}%
-					\def\b at pgfplots@colorbar at fallback@to at sampled{1}%
+			% Ah-- the default colorbar implementation is active! We may need to substitute it by a better one.
+			% Check that:
+			\def\b at pgfplots@colorbar at fallback@to at sampled{0}%
+			%
+			\ifpgfplots at collect@firstplot at astick
+				% xtick={data} requires samples:
+				% see also call hierarchy of \pgfplots at colorbar@positions at to@samplesat
+				\def\b at pgfplots@colorbar at fallback@to at 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 at loc@TMPb
+					\pgfplotscolormapgetcolorspace{\pgfplots at loc@TMPb}%
+					\def\pgfplots at loc@TMPa{cmyk}%
+					\ifx\pgfplots at loc@TMPa\pgfplotsretval
+						\pgfutil at ifundefined{pgfplots at colorbar@CMYK@\pgfplots at loc@TMPb}{%
+							\pgfplotswarning{colorbar CMYK unsupported}{\pgfplots at loc@TMPb}\pgfeov% 
+							\expandafter\gdef\csname pgfplots at colorbar@CMYK@\pgfplots at loc@TMPb\endcsname{1}%
+						}{}%
+						\def\b at pgfplots@colorbar at fallback@to at sampled{1}%
+					\fi
 				\fi
 			\fi
-		\fi
+			%
+			\if c\pgfplots at colormap@access
+				% colormap access=piecewise constant
+				% In this case, we want a sampled colorbar.
+				\def\b at pgfplots@colorbar at fallback@to at sampled{1}%
+				%
+			\fi
+			\pgfmath at smuggleone\b at pgfplots@colorbar at fallback@to at sampled
+		\endgroup
 		%
-		\def\pgfplots at colorbar@extra at options{}%
-		\if c\pgfplots at 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 at pgfplots@colorbar at fallback@to at sampled{1}%
-			\def\pgfplots at colorbar@extra at options{samples=2}
-		\fi
-		%
 		\if 1\b at pgfplots@colorbar at fallback@to at sampled
-			\edef\pgfplots at loc@TMPa{\noexpand\pgfplotsset{colorbar sampled={surf,shader=interp,\pgfplots at colorbar@extra at options}}}%
+			\edef\pgfplots at 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 at loc@TMPa
 		\fi
 	\fi
+}%
+
+\def\pgfplots at colorbar@draw at reconfigure@if at needed{%
+	\pgfplots at colorbar@draw at reconfigure@if at needed@legacy
+	\pgfplotsset{%
+		/pgfplots/every axis plot post/.append code={%
+			\ifpgfplots at collect@firstplot at 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 at colorbar@positions at to@samplesat
+			\fi
+		}%
+	}%
+}%
+
+% Defines and sets 'samples at' such that it resembles the colormap
+% positions.
+\def\pgfplots at colorbar@positions at to@samplesat{%
+	\pgfplots at colorbar@positions at to@samplesat@
+	\edef\pgfplots at loc@TMPa{samples at={\pgfplotsretval}}%
+	\expandafter\pgfplotsset\expandafter{\pgfplots at loc@TMPa}%
+}
+% Sets \pgfplotsretval such that it contains an argument for 'samples at'
+\def\pgfplots at colorbar@positions at to@samplesat@{%
+	\pgfkeysgetvalue{/pgfplots/point meta min}\pgfplots at loc@TMPa
+	\ifx\pgfplots at loc@TMPa\pgfutil at empty
+		\pgfplots at error{Please define 'point meta min' and 'point meta max' before using 'samples at colormap pos'}%
+	\fi
+	\pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots at loc@TMPa
+	\ifx\pgfplots at loc@TMPa\pgfutil at empty
+		\pgfplots at error{Please define 'point meta min' and 'point meta max' before using 'samples at colormap pos'}%
+	\fi
 	%
+	\edef\pgfplots at loc@TMPb{%
+		\noexpand\pgfplotscolormapgetpositions
+			[{\pgfkeysvalueof{/pgfplots/point meta min}}:{\pgfkeysvalueof{/pgfplots/point meta max}}]%
+			{\pgfkeysvalueof{/pgfplots/colormap name}}%
+	}%
+	\pgfplots at 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 at ifnextchar[{\pgfplotscolorbardrawstandalone at opt}{\pgfplotscolorbardrawstandalone at opt[]}%
+}%
+\def\pgfplotscolorbardrawstandalone at opt[#1]{%
+	\pgfplots at ifintikzpicture{%
+		\pgfplotscolorbardrawstandalone at opt@[#1]%
+	}{%
+		\begin{tikzpicture}%
+		\pgfplotscolorbardrawstandalone at opt@[#1]%
+		\end{tikzpicture}%
+	}%
+}
+\def\pgfplotscolorbardrawstandalone at 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 at colorbar@draw@{%
+	\pgfplots at colorbar@draw at reconfigure@if at 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/. at cmd}\pgfeov
 }
+
+\def\pgfplotsifnodeexists#1#2#3{%
+	\pgfutil at IfUndefined{pgf at sh@ns@#1}{#3}{#2}%
+}%
+
+\def\pgfplots at colorbar@get at rid@of at at@parent at axis{%
+	\pgfkeysgetvalue{/pgfplots/at/. at cmd}\pgfplots at at@orig
+	\pgfkeyslet{/pgfplots/at/orig/. at cmd}\pgfplots at at@orig
+	%
+	\pgfkeysgetvalue{/pgfplots/colorbar to name/at/. at cmd}\pgfplots at colorbar@toname at at
+	\pgfkeyslet{/pgfplots/at/. at cmd}\pgfplots at colorbar@toname at at
+	%
+	\let\pgfplots at colorbar@get at rid@of at at@parent at 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 at ztickmin}%
 	\pgfkeysgetvalue{/pgfplots/ztickmax}{\pgfplots at ztickmax}%
 	%
+	\pgfplots at init@collect at firstplotastick
+	\global\let\pgfplots at firstplot@coords at x=\pgfutil at empty
+	\global\let\pgfplots at firstplot@coords at y=\pgfutil at empty
+	\global\let\pgfplots at firstplot@coords at z=\pgfutil at 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 at empty%
+	}%
+	%
+	\pgfplots at set@patched at options
+	%
+	\pgfplots at set@options at sanitize
+	\pgfplots at notify@options at are@set
+}
+
+\def\pgfplots at init@collect at firstplotastick{%
 	\def\pgfplots at loc@TMPa{data}%
 	\pgfplots at collect@firstplot at astickfalse
 	\ifx\pgfplots at xtick\pgfplots at loc@TMPa
@@ -10533,26 +10911,7 @@
 	\ifx\pgfplots at loc@TMPb\pgfplots at loc@TMPa
 		\pgfplots at collect@firstplot at asticktrue
 	\fi
-	\global\let\pgfplots at firstplot@coords at x=\pgfutil at empty
-	\global\let\pgfplots at firstplot@coords at y=\pgfutil at empty
-	\global\let\pgfplots at firstplot@coords at z=\pgfutil at 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 at empty%
-	}%
-	%
-	\pgfplots at set@patched at options
-	%
-	\pgfplots at set@options at sanitize
-	\pgfplots at notify@options at are@set
-}
+}%
 
 \def\pgfplots at set@options at of@layered at graphics{%
 	\ifpgfplots at axis@on at top
@@ -11388,6 +11747,18 @@
 	\pgfkeyslet{/pgfplots/on layer}\pgfutil at empty
 }
 
+\def\pgfplots at set@options at after@survey{%
+	\pgfkeyssetvalue{/pgfplots/xmin}{\pgfplots at xmin}%
+	\pgfkeyssetvalue{/pgfplots/ymin}{\pgfplots at ymin}%
+	\pgfkeyssetvalue{/pgfplots/zmin}{\pgfplots at zmin}%
+	\pgfkeyssetvalue{/pgfplots/point meta min}{\pgfplots at axiswide@metamin}%
+	%
+	\pgfkeyssetvalue{/pgfplots/xmax}{\pgfplots at xmax}%
+	\pgfkeyssetvalue{/pgfplots/ymax}{\pgfplots at ymax}%
+	\pgfkeyssetvalue{/pgfplots/zmax}{\pgfplots at zmax}%
+	\pgfkeyssetvalue{/pgfplots/point meta max}{\pgfplots at axiswide@metamax}%
+}%
+
 % \end{axis} :
 %
 % This command actually takes all collected (global) variables,
@@ -11407,6 +11778,7 @@
 	%
 	\pgfplotssurveyphase at setactiveplothandlers
 	%
+	\pgfplots at set@options at after@survey
 	\expandafter\pgfplotsset\expandafter{\pgfplots at late@options}%
 	%
 	\pgfplots at prepare@layered at graphics

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at glob@TMPa#1-#2-#3 #4\relax{#1/#2/#3}
 \xdef\pgfplotsversiondate{\expandafter\pgfplots at glob@TMPa\pgfplotsversiondatetime\relax}
 \xdef\pgfplotsrevisiondate{\expandafter\pgfplots at glob@TMPa\pgfplotsrevisiondatetime\relax}

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at lineshift{}%
+	%
 	\if v#1%
 		\pgfplotspointoutsideofaxis at plug@getlimit{y}{#2}\let\pgfplots at loc@TMPa=\pgfmathresult
 		\pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots at loc@TMPa}{#2}%
+		\def\pgfplotspointoutsideofaxis at lineshift{x}%
 		%
 		\pgfplotspointonorientedsurfaceabsetupfor xzy%
 		\pgfplotspointoutsideofaxis at plug@trafo{x}{#4}\let\pgfplots at loc@A=\pgfmathresult
@@ -1364,6 +1368,7 @@
 			\pgfplotspointonorientedsurfaceabsetupfor yxz%
 			\pgfplotspointoutsideofaxis at plug@trafo{y}{#4}\let\pgfplots at loc@A=\pgfmathresult
 			\pgfplotspointoutsideofaxis at plug@getlimit{x}{#1}\let\pgfplots at loc@B=\pgfmathresult
+			\def\pgfplotspointoutsideofaxis at lineshift{y}%
 		\else
 			\pgfplotspointoutsideofaxis at plug@getlimit{x}{#1}\let\pgfplots at loc@TMPa=\pgfmathresult
 			\pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots at loc@TMPa}{#1}%
@@ -1375,6 +1380,7 @@
 				\def\pgfplots at loc@A{0}%
 			\fi
 			\pgfplotspointoutsideofaxis at plug@getlimit{y}{#2}\let\pgfplots at loc@B=\pgfmathresult
+			\def\pgfplotspointoutsideofaxis at lineshift{z}%
 		\fi
 	\fi
 	%
@@ -1381,6 +1387,13 @@
 	% read dimen argument #5:
 	\afterassignment\pgfplots at gobble@until at relax
 	\pgf at xa=#5pt\relax
+	%
+	\pgfkeysgetvalue{/pgfplots/axis \pgfplotspointoutsideofaxis at lineshift\space line shift}\pgfmathresult
+	\ifx\pgfmathresult\pgfutil at empty
+	\else
+		\advance\pgf at xa by \pgfmathresult pt %
+	\fi
+	%
 	\edef\pgfplots at loc@distalong at normal{\pgf at sys@tonumber\pgf at xa}%
 	%
 %\message{pgfplotspointoutsideofaxis{#1#2#3}{#4}{#5}: A = \pgfplots at loc@A, B = \pgfplots at loc@B.^^J}%
@@ -2987,7 +3000,9 @@
 % empty line=scanline
 % class:
 \def\pgfplotsscanlinelength at scanline@initzero{%
-	\c at pgfplots@scanlineindex=0
+	\c at pgfplots@scanlineindex=0 % the index _inside_ of the current scanline
+	\def\pgfplotsscanlinecurrentlength{\the\c at pgfplots@scanlineindex}%
+	\def\pgfplotsscanlineindex{0}% 0 is the first scanline, 1 the second, and so on
 	\def\pgfplots at scanlinelength{-1}%
 }
 \def\pgfplotsscanlinelength at scanline@increase{%
@@ -3022,6 +3037,7 @@
 		\fi
 	\fi
 	\c at pgfplots@scanlineindex=0
+	\pgfplotsutil at advancestringcounter\pgfplotsscanlineindex%
 }
 \def\pgfplotsscanlinelength at scanline@cleanup{%
 	\ifnum\c at pgfplots@scanlineindex=0
@@ -3741,6 +3757,12 @@
 			\fi
 			\pgfplots at LUA@backend at supportedfalse
 		\fi
+		\pgfplotscolormapifisuniform{\pgfkeysvalueof{/pgfplots/colormap name}}{%
+		}{%
+			% FIXME : implement LUA for non-uniform colormaps
+			\pgfplots at LUA@survey at log@deactivation{non-uniform color maps unsupported currently}%
+			\pgfplots at LUA@backend at supportedfalse
+		}%
 		%
 		\ifpgfplots at LUA@backend at supported
 			\edef\pgfplots at LUA@backend at plotnum{\pgfutil at 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 at plot@samples at at\pgfutil at empty
+			\pgfkeyssetvalue{/pgfplots/mesh/cols}{\pgfkeysvalueof{/pgfplots/samples}}%
+		\else
+			% FIXME : count number of samples in 'samples at'!
+		\fi
 	\fi
 	\if1\b at pgfplots@should at sample@LINE
 		\pgfkeyssetvalue{/pgfplots/sample dim}{1}%
@@ -5434,9 +5460,14 @@
 		}%
 		\pgfplots at addplotimpl@expression at split@yz#2\pgfplots at EOI%
 		%
-		% we don't have 'samples at' for 3D plots -> use domain!
-		\expandafter\pgfplots at domain@to at foreach\pgfplots at plot@domain\relax{\pgfplots at plot@samples}%
-		\let\pgfplots at expression@xdomain=\pgfplotsretval
+		\ifx\pgfplots at plot@samples at at\pgfutil at empty
+			% we don't have 'samples at' -> use domain!
+			\expandafter\pgfplots at domain@to at foreach\pgfplots at plot@domain\relax{\pgfplots at plot@samples}%
+			\let\pgfplots at expression@xdomain=\pgfplotsretval
+		\else
+			% use 'samples at':
+			\let\pgfplots at expression@xdomain=\pgfplots at plot@samples at at
+		\fi
 		%
 		% do we have '\y' as y coordinate?
 		\expandafter\def\expandafter\pgfplots at loc@TMPb\expandafter{\pgfplots at plot@var at y}%
@@ -5655,6 +5686,12 @@
 			}%
 		\fi
 		%
+		\ifx\pgfplots at plot@samples at at\pgfutil at empty
+		\else
+			\def\pgfplotsretval{0}%
+			\pgfplots at LUA@plotexpression at log@deactivation{samples at unsupported (yet)}%
+		\fi
+		%
 		\if1\pgfplots at addplotimpl@expression at hasuniform@y
 		\else
 			\expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplots at addplotimpl@expression at yEXPR}{%
@@ -6030,7 +6067,7 @@
 }%
 \def\pgfplots at identify@gnuplot at logbehavior@checkversion{%
 	\begingroup
-	\immediate\write18{gnuplot -V >\pgfplots at plot@filename.vrs}%
+	\pgfplots at shellescape{gnuplot -V >\pgfplots at plot@filename.vrs}%
 	\openin\r at pgfplots@reada=\pgfplots at plot@filename.vrs\relax
 	\ifeof\r at pgfplots@reada
 		\pgfplotswarning{gnuplot -V impossible}\pgfeov
@@ -9340,6 +9377,6 @@
     \immediate\openout\pgf at shellwrite=#1.sh
     \immediate\write\pgf at shellwrite{#2}%
     \immediate\closeout\pgf at shellwrite%
-    \immediate\write18{sh #1.sh > #1.out}
+    \pgfplots at shellescape{sh #1.sh > #1.out}
   \fi%
 }

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -109,6 +109,7 @@
 		\let\pgfplotsglobalretval=\pgfplots at luabackend@table
 	}%
 }%
+
 \ifpgfplots at LUA@supported
 	\let\pgfplotsutil at directlua=\directlua
 	\let\pgfplotsutil at directlua@std=\pgfplotsutil at directlua
@@ -273,6 +274,14 @@
 		\fi
 		\let#1=\relax
 	},
+	/pgfplots/exception/too few colormap positions/.code args={#1#2}{%
+		\ifx\pgfplotsexceptionmsg\relax
+			\pgfplots at error{#2}%
+		\else
+			\pgfplots at error{\pgfplotsexceptionmsg}%
+		\fi
+		\let#1=\relax
+	},
 	/pgfplots/exception/dimension too small in ticks/.code args={#1}{%
 		\ifx\pgfplotsexceptionmsg\relax
 			\pgfplots at 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 at warning{Ignoring illegal input argument #1=#2: cannot apply log.}%
 	},
+	/pgfplots/warning/too many colormap positions/.code={%
+		\pgfplotsthrow at warning{the colormap has too many positions; ignoring position #1}%
+	},
 	/pgfplots/warning/plot without coordinates/.code={%
 		\pgfplotsthrow at warning{the current plot has no coordinates (or all have been filtered away)}%
 	},

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -1600,7 +1600,8 @@
 	\pgfkeysvalueof{/pgfplots/quiver/before arrow/. at cmd}\pgfeov
 	\pgfplotsplothandlerquiver at vis@hook
 	\ifpgfplots at quiver@usetikz
-		\draw[/pgfplots/quiver/every arrow] \pgfextra{\pgfplotsplothandlerquiver at vis@path{#1}};
+		\edef\pgfplotsplothandler at quiver@point{\global\pgf at x=\the\pgf at x\space\global\pgf at y=\the\pgf at y\space}%
+		\draw[/pgfplots/quiver/every arrow] \pgfextra{\pgfplotsplothandlerquiver at vis@path{\pgfplotsplothandler at quiver@point}};
 	\else
 		\pgfplotsplothandlerquiver at 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 at plot@handler=\pgfplotsplothandlercontourfilled
+	},
 	% FIXME : should use \tikz at plot@handler instead of just the
 	% visualization thing!
 	contour/handler/.style={/tikz/sharp plot},
@@ -1977,6 +1988,9 @@
 	},%
 	contour/labels/.is if=pgfplotsplothandlercontour at labels,
 	contour/labels=true,
+	% 
+	% XXX : this here is dead code... it has been superseded by
+	% \pgfplotsplothandlercontourfilled:
 	contour/filled/.is if=pgfplotsplothandlercontour at filled,
 	contour/filled/.default=true,
 	% EXPERIMENTAL: WILL CHANGE EVENTUALLY!
@@ -1983,6 +1997,9 @@
 	% 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 at pgf@writea{\pgfkeysvalueof{/pgfplots/contour external/script}}%
 	\immediate\closeout\w at pgf@writea
 	%
-	\immediate\write18{\pgfkeysvalueof{/pgfplots/contour external/cmd}}%
+	\pgfplots at 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 at contourfilled@orig=\pgfplotsplothandlersurveyend
+	\def\pgfplotsplothandlersurveyend{%
+		\pgfplotsplothandlersurveyend at contourfilled@orig
+		\pgfplotsplothandlersurveyend at contourfilled
+	}%
+}%
+
+\def\pgfplotscontourfilledcolormap{internal:contourfilled}
+\pgfplotscreatecolormap{\pgfplotscontourfilledcolormap}{color=(black) color=(black)}
+
+\def\pgfplotsplothandlersurveyend at 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 at contour@cm at options{%
+		colorbar style={%
+			/pgfplots/colormap access=const,
+		},%
+	}%
+	%
+	\pgfkeysgetvalue{/pgfplots/contour/levels}\pgfplots at loc@TMPa
+	\ifx\pgfplots at loc@TMPa\pgfutil at empty
+		% no levels. 
+		% Ok, check the other keys in the order of precedence:
+		\pgfkeysgetvalue{/pgfplots/contour/levels from colormap}\pgfplots at loc@TMPa
+		\ifx\pgfplots at loc@TMPa\pgfutil at empty
+			% no 'levels from colormap'. 
+			% Ok, check the other keys in the order of precedence:
+			\pgfkeysgetvalue{/pgfplots/contour/number}\pgfplots at loc@TMPa
+			\ifx\pgfplots at loc@TMPa\pgfutil at empty
+				% not sure if this is a use-case...
+				\pgfplots at log3{contour plot: skipping definition of suitable colormap (none of 'number', levels', 'levels from colormap' is set)}%
+				\t at pgfplots@toka=\expandafter{\pgfplots at contour@cm at options}%
+				\edef\pgfplots at contour@cm at options{%
+					\the\t at 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 at pgfplots@toka=\expandafter{\pgfplots at contour@cm at options}%
+				\edef\pgfplots at contour@cm at options{%
+					\the\t at pgfplots@toka%
+					colormap={\pgfplotscontourfilledcolormap}{samples of colormap={\pgfplots at 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 at pgfplots@toka=\expandafter{\pgfplots at contour@cm at options}%
+			\t at pgfplots@tokb=\expandafter{\pgfplots at loc@TMPa}%
+			\edef\pgfplots at contour@cm at options{%
+				\the\t at pgfplots@toka%
+				/utils/exec={%
+					\noexpand\edef\noexpand\pgfplots at 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 at createcolormap@target at pos@includes at limits@min true\else false\fi,%
+						of colormap/target pos max/insert=\ifpgfplots at createcolormap@target at pos@includes at limits@max true\else false\fi,%
+						\if c\pgfplots at ofcolorbar@sample at for@choice
+							of colormap/sample for=const,%
+						\else
+							of colormap/sample for=default,%
+						\fi
+					}%
+				},%
+				of colormap/target pos min*=\pgfplots at metamin,%
+				of colormap/target pos max*=\pgfplots at metamax,%
+				of colormap/sample for=const,%
+				colormap={\pgfplotscontourfilledcolormap}{%
+					\the\t at pgfplots@tokb
+				},%
+				/utils/exec={%
+					\noexpand\expandafter
+					\noexpand\pgfkeysalso
+					\noexpand\expandafter{\noexpand\pgfplots at targetpos@restore}%
+				},%
+			}%
+		\fi
+	\else
+		% Ah - we have a list of positions for the contours!
+		\t at pgfplots@toka=\expandafter{\pgfplots at contour@cm at options}%
+		\edef\pgfplots at contour@cm at options{%
+			\the\t at pgfplots@toka%
+			colormap={\pgfplotscontourfilledcolormap}{%
+				of colormap={%
+					target pos min*=\pgfplots at metamin,
+					target pos max*=\pgfplots at metamax,
+					sample for=const,%
+					target pos={\pgfplots at loc@TMPa},
+				}%
+			},%
+		}%
+	\fi
+	%
+	\ifx\pgfplots at contour@cm at options\pgfutil at empty
+	\else
+		% move to "late options" such that we carry them outside of
+		% any \begingroup...\endgroup constructions:
+		\expandafter\pgfplotssetlateoptions\expandafter{\pgfplots at contour@cm at options}%
+%\message{contour filled: assembled options \meaning\pgfplots at contour@cm at options^^J}%
+	\fi
+}%
+
+

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -268,6 +268,7 @@
 	\pgfplotsaxisdeserializedatapointfrom at private@backup@{#2}%
 }%
 
+% #1: the result of \pgfplotsaxisserializedatapointtostring
 \def\pgfplots at stacked@parsezerolevelpoint#1{%
 	\begingroup
 	\pgfplotsaxisdeserializedatapointfrom#1% no braces here!
@@ -366,6 +367,12 @@
 \def\pgfplotspointgetnormalizedzerolevelcoordinates{%
 	\begingroup
 	\ifpgfplots at stackedmode
+		% STATE: 
+		%  * \pgfplots at stacked@diff is the diff of the CURRENT point.
+		%  * \pgfplots at 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 at stacked@diff at cur=\pgfplots at stacked@diff
 		\ifx\pgfplots at stacked@zerolevel\pgfutil at empty
 			\pgfplotspointgetnormalizedcoordinates%
 			\pgfplotsutilforeachcommasep{x,y,z}\as\pgfplots at loc@TMPa{%
@@ -386,7 +393,7 @@
 		\pgfplotscoordmath{x}{zero}\let\pgfplots at stacked@diff at x=\pgfmathresult%
 		\pgfplotscoordmath{y}{zero}\let\pgfplots at stacked@diff at y=\pgfmathresult%
 		\pgfplotscoordmath{z}{zero}\let\pgfplots at stacked@diff at z=\pgfmathresult%
-		\pgfutil at namelet{pgfplots at stacked@diff@\pgfplots at stacked@dir}{pgfplots at stacked@diff}%
+		\pgfutil at namelet{pgfplots at stacked@diff@\pgfplots at stacked@dir}{pgfplots at stacked@diff at cur}%
 	\else
 		% Ah - no stacked plot!? Well, than do "something useful":
 		% ... note that we have to use 'pgfbasic' here as that is the

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at isuniformticktrue set if it applies

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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

Added: trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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


Property changes on: trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatexpatch.def
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def	2016-08-11 21:43:18 UTC (rev 41838)
@@ -99,6 +99,7 @@
 		\else
 			/Filter /\pgfplotslibrarysurf at filter@decode\space
 		\fi
+		%/AntiAlias \space true
 	}%
 	%
 	% \pgfplots at loc@TMPb := final boolean luaBinaryEncoding;

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at colormap@uniform at 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 at createcolormap}%
 \def\pgfplots at createcolormap#1#2{%
+	\pgfkeysinterruptkeyfilter
 	\edef\pgfplots at createcolormap@name{pgfpl at cm@#1}%
 	\expandafter\pgfplotsarraynewempty\expandafter{\pgfplots at createcolormap@name}%
-	\def\pgfplots at createcolormap@MIN{0}% NORMALIZATION: assume that lower-end is 0pt.
-	\def\pgfplots at createcolormap@MAX{0}% To be computed.
+	\pgfplotsapplistXnewempty\pgfplots at createcolormap@X
+	%
+	% '0' = is not uniform
+	% '1' = is uniform
+	% '2' = is FORCED to be uniform, i.e. will be reinterpolated
+	\ifcase\pgfplots at colormap@uniform at choice\relax
+		% colormap uniform=always (due to compatibility requirements)
+		\def\b at pgfplotscreatecolormap@isuniform{2}%
+	\or
+		% colormap uniform=if requested
+		\def\b at pgfplotscreatecolormap@isuniform{1}%
+	\fi
+	\def\pgfplots at createcolormap@MIN{}% To be computed.
+	\def\pgfplots at createcolormap@MAX{}% To be computed.
+	\def\b at pgfplots@createcolormap at pos@mode{a}% [a]uto or [m]anual
 	\pgfplots at createcolormap@initcolorspace
 	\let\pgfplots at createcolormap@LAST=\pgfplots at createcolormap@MIN
 	% PARSE IT:
-	\edef\pgfplots at loc@TMPa{#2}%
 	\let\pgfplots at createcolormap@context=\pgfutil at empty
+	%%%%%%%%%%%%%%%%%%
 	% this does also init @H:
+	\pgflibraryfpuifactive{%
+		\def\pgfplots at createcolormap@restore at fpu{}%
+	}{%
+		\def\pgfplots at createcolormap@restore at fpu{\pgfkeys{/pgf/fpu=false}}%
+		\pgfkeys{/pgf/fpu=true}%
+	}%
+	%\edef\pgfplots at loc@TMPa{#2}% XXX this fails for active chars and
+	%if key/value options are too special
+	\def\pgfplots at loc@TMPa{#2}%
 	\expandafter\pgfplots at createcolormap@startloop\pgfplots at loc@TMPa\pgfplots at EOI
+	%
+	\pgfplots at createcolormap@restore at fpu
+	%
+	%%%%%%%%%%%%%%%%%%
+	%
 	\expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots at createcolormap@name}%
 	% sanity checking:
 	\expandafter\pgfplotsarraysizetomacro\expandafter{\pgfplots at createcolormap@name}\to\pgfplots at loc@TMPa
@@ -72,15 +104,52 @@
 	\or
 		\pgfplots at 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 at createcolormap@MAX}%
+	% Map the input range [MIN,MAX] linearly to [0,1000]
+	\pgfmathfloatsubtract@{\pgfplots at createcolormap@MAX}{\pgfplots at createcolormap@MIN}%
 	\let\pgfplots at loc@TMPb=\pgfmathresult
-	\pgfmathmultiply@{\pgfplots at loc@TMPb}{\pgfplots at createcolormap@H}%
-	\let\pgfplots at createcolormap@H=\pgfmathresult
-	\expandafter\let\csname\pgfplots at createcolormap@name @h\endcsname=\pgfplots at createcolormap@H
-	\pgfmathreciprocal@{\pgfplots at createcolormap@H}%
+	\pgfmathfloatdivide@{\pgfplotscolormaprange at float}{\pgfplots at loc@TMPb}%
+	\let\pgfplots at loc@TMPb=\pgfmathresult
+	\pgfmathfloatmultiply@{\pgfplots at loc@TMPb}{\pgfplots at createcolormap@H}%
+	\let\pgfplots at loc@TMPd=\pgfmathresult
+	\pgfplots at createcolormap@normalize{\pgfmathresult}%
+	\expandafter\let\csname\pgfplots at createcolormap@name @h\endcsname=\pgfmathresult
+	%
+	\pgfmathfloatreciprocal@{\pgfplots at loc@TMPd}%
+	\pgfplots at createcolormap@normalize{\pgfmathresult}%
 	\expandafter\let\csname\pgfplots at createcolormap@name @invh\endcsname=\pgfmathresult
 	%
+	% ... and set up the X coordinates if the grid is not uniform:
+	\expandafter\pgfplotsarraynewempty\expandafter{\pgfplots at createcolormap@name @X}%
+	\if0\b at pgfplotscreatecolormap@isuniform
+		% Uncomment the '\iftrue' for testing purposes (to see if a uniform map changes if
+		% processed as non-uniform):
+%	\iftrue
+		\pgfplotsapplistXlet\pgfplots at loc@TMPc=\pgfplots at createcolormap@X
+		\expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplots at loc@TMPc}\as\pgfplots at loc@TMPc{%
+			\ifx\pgfplots at loc@TMPc\pgfutil at empty
+			\else
+				% apply the trafo [MIN,MAX] -> [0,1000] here as well:
+				\pgfmathfloatsubtract@{\pgfplots at loc@TMPc}{\pgfplots at createcolormap@MIN}%
+				\expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots at loc@TMPb}%
+				\pgfplots at createcolormap@normalize{\pgfmathresult}%
+				\expandafter\pgfplotsarraypushback\expandafter{\pgfmathresult}\to{pgfpl at cm@#1 at X}%
+			\fi
+		}%
+		%
+		\pgfplotscolormapsetadditionalintervalwidth@{#1}%
+	\else
+		\expandafter\let\csname\pgfplots at createcolormap@name @X at scale@order at z\endcsname=\pgfutil at empty
+	\fi
+	% clear temporary list:
+	\pgfplotsapplistXnewempty\pgfplots at createcolormap@X
+	%
+	\if m\b at pgfplots@createcolormap at 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 at createcolormap@name @X at scale@order at z\endcsname{0}%
+	\fi
+	%
 	\endpgfplotscolornormalizesequence%
 	\expandafter\let\csname\pgfplots at createcolormap@name @colspace\endcsname=\pgfplotsretval
 	\expandafter\let\csname\pgfplots at createcolormap@name @col at comps\endcsname=\pgfplotsretvalb
@@ -89,13 +158,81 @@
 	\expandafter\edef\csname\pgfplots at createcolormap@name @lastindex\endcsname{\the\c at pgf@counta}%
 %\pgfplots at colormap@showdebuginfofor{#1}%
 	\pgfplots at colormap@LUA at new{#1}%
+	\endpgfkeysinterruptkeyfilter
 }
 
+\def\pgfplots at createcolormap@normalize#1{%
+	\pgfmathfloattofixed{#1}%
+	\pgf at xa=\pgfmathresult pt %
+	\edef\pgfmathresult{\pgf at sys@tonumber\pgf at 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 at loc@TMPd{#2}%
+	\def\pgfplots at loc@TMPc{h}%
+	\ifx\pgfplots at loc@TMPd\pgfplots at loc@TMPc
+		% 'h' means: mesh width:
+		\pgfplotscolormapifisuniform{#1}{%
+			\expandafter\let\csname pgfpl at cm@#1 at X@scale at order@z\endcsname\pgfutil at empty%
+		}{%
+			\pgfplotscolormapsetadditionalintervalwidth@{#1}%
+		}%
+	\else
+		\pgfmathparse{#2}%
+		\pgfplotscolormapifisuniform{#1}{%
+			\ifdim\pgfmathresult pt>0pt
+				\pgfplots at 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 at cm@#1 at X@scale at order@z\endcsname{0}%
+			\fi
+		}{%
+			\ifdim\pgfmathresult pt>0pt
+				\ifdim\pgfmathresult pt>0.9pt
+					\pgfplots at 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 at cm@#1 at h\endcsname=\pgfmathresult
+					\expandafter\let\csname pgfpl at cm@#1 at invh\endcsname=\pgfutil at empty% unused!
+					\pgfplotscolormapsetadditionalintervalwidth@{#1}%
+				\fi
+			\else
+				% DISABLE the extra interval!
+				\expandafter\def\csname pgfpl at cm@#1 at X@scale at 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 at cm@#1 at h\endcsname)}%
+	\expandafter\let\csname pgfpl at cm@#1 at X@scale at order@z\endcsname=\pgfmathresult
+}%
+
 \def\pgfplots at createcolormap@initcolorspace{%
 	\pgfplotscolornormalizesequence[
 		colorspace=\pgfkeysvalueof{/pgfplots/colormap default colorspace},
-		context message=\pgfplots at createcolormap@context,
+		context message=\pgfplots at createcolormap@context\pgfplots at createcolormap@trace,
 	]%
 }%
 \def\pgfplots at createcolormap@seth[#1]{%
@@ -102,6 +239,8 @@
 	\def\pgfplots at createcolormap@context{[#1]}%
 	\pgfmathparse{#1}%
 	\let\pgfplots at createcolormap@H=\pgfmathresult
+	% request for a uniform colormap:
+	\def\b at pgfplotscreatecolormap@isuniform{3}%
 	\pgfplots at createcolormap@
 }%
 
@@ -118,27 +257,70 @@
 	{%
 		\pgfutil at ifnextchar;{\pgfplots at createcolormap@grabsemicolon}%
 		{%
-			\expandafter\pgfutil at ifnextchar\pgfplots at activesemicolon{\pgfplots at createcolormap@grabsemicolon at active}%
-			{%
-				\pgfplots at createcolormap@grabnext
+			\pgfutil at ifnextchar,{\pgfplots at createcolormap@grabcomma}%
+			{
+				\expandafter\pgfutil at ifnextchar\pgfplots at activesemicolon{\pgfplots at createcolormap@grabsemicolon at active}%
+				{%
+					\pgfplots at createcolormap@grabnext
+				}%
 			}%
 		}%
 	}%
 }
+
+% Executes '#1' if there are more tokens and '#2' if not.
+\def\pgfplots at createcolormap@ifhasmorecolors#1#2{%
+	\pgfutil at ifnextchar\pgfplots at EOI{%
+		#2% no more tokens.
+	}{%
+		\pgfutil at ifnextchar;{\pgfplots at createcolormap@grabsemicolon at hasnext{#1}{#2}}%
+		{%
+			\pgfutil at ifnextchar,{\pgfplots at createcolormap@grabcomma at hasnext{#1}{#2}}%
+			{
+				\expandafter\pgfutil at ifnextchar\pgfplots at activesemicolon{\pgfplots at createcolormap@grabsemicolon at active@hasnext{#1}{#2}}%
+				{%
+					#1% has more.
+				}%
+			}%
+		}%
+	}%
+}%
+
 \def\pgfplots at createcolormap@error#1#2\pgfplots at EOI{%
 	{%
 		\t at pgfplots@toka={#1#2}%
 		\t at pgfplots@tokb={#1}%
-		\pgfplots at error{Illformed colormap specification: I could not read the substring `\the\t at pgfplots@toka' starting at `\the\t at pgfplots@tokb'}%
+		\pgfplots at error{Illformed colormap specification: I could not read the substring `\the\t at pgfplots@toka' starting at `\the\t at pgfplots@tokb'\pgfplots at createcolormap@trace}%
 	}%
 }%
 
-\def\pgfplots at createcolormap@grabnext#1({%
-	\pgfplots at createcolormap@grabnext@{#1}%
+\def\pgfplots at createcolormap@trace{%
+	\space(color no \expandafter\pgfplotsarraysizeof\expandafter{\pgfplots at createcolormap@name})
 }
-\def\pgfplots at createcolormap@grabnext@#1#2){%
-	\pgfutil at in@={#1}%
+
+\def\pgfplots at createcolormap@grabnext#1={%
+	\pgfutil at ifnextchar({\pgfplots at createcolormap@grabnext at round{#1}=}{%
+		\pgfutil at ifnextchar\bgroup{\pgfplots at createcolormap@grabnext at curly{#1}=}{%
+			\pgfplots at createcolormap@error#1=%
+		}%
+	}%
+}
+\def\pgfplots at createcolormap@grabnext at round#1=(#2){%
+	\pgfplots at createcolormap@grabnext@@{#1}={#2}%
+}%
+\def\pgfplots at createcolormap@grabnext at curly#1=#2{%
+	\pgfplots at createcolormap@grabnext@@{#1}={#2}%
+}%
+\def\pgfplots at createcolormap@grabnext@@#1=#2{%
+	\pgfutil at in@({#1}%
 	\ifpgfutil at in@
+		% Ah. We have something like 'color(1cm)' before the equal sign.
+		\pgfplots at createcolormap@grabnext at read@pos#1\pgfplots at EOI%
+		% now:
+		%\pgfplots at loc@TMPa = colorspace
+		%\pgfplots at loc@TMPb = position
+		%
+	\else
 		% Ah. we do not have a position, i.e. we have
 		%   color=(green)
 		% or something like this.
@@ -145,148 +327,700 @@
 		%
 		% this here defines \pgfplots at loc@TMPa to contain the
 		% colorspace:
-		\pgfplots at createcolormap@grabnext at remove@equal at sign#1\pgfplots at EOI
+		\pgfkeys at spdef\pgfplots at loc@TMPa{#1}%
 		%
 		\pgfplots at createcolormap@grabnext at computenextposition
-		\let\pgfplots at loc@TMPb=\pgfmathresult% posisiton
-		\def\pgfplots at loc@TMPc{#2}% color data
-		\let\pgfplots at loc@TMPd=\pgfplots at createcolormap@grabnext at complete
-	\else
-		% Ah. We have something like 'color(1cm)' and we did not see
-		% the equal sign so far.
-		\def\pgfplots at loc@TMPa{#1}% colorspace
-		\def\pgfplots at loc@TMPb{#2}% position
-		%
-		% and collect the color data:
-		\def\pgfplots at loc@TMPd{%
-			\pgfutil at ifnextchar={%
-				\pgfplots at createcolormap@grabnext@@
-			}{%
-				\pgfplots at createcolormap@error#1(#2)%
-			}%
-		}%
+		\let\pgfplots at loc@TMPb=\pgfmathresult% position
 	\fi
-	\pgfplots at loc@TMPd
+	\def\pgfplots at loc@TMPc{#2}%
+	\pgfplots at createcolormap@grabnext at complete
 }%
 
-\def\pgfplots at createcolormap@grabnext at remove@equal at sign#1=#2\pgfplots at EOI{%
-	\def\pgfplots at loc@TMPa{#1}%
-	%
-	% FIXME : what if #2 is not empty!?
+\def\pgfplots at createcolormap@grabnext at read@pos#1({%
+	\pgfkeys at spdef\pgfplots at loc@TMPa{#1}% colorspace
+	\pgfplots at createcolormap@grabnext at read@pos@
 }%
-
-\def\pgfplots at createcolormap@grabnext@@={%
-	\pgfutil at ifnextchar({%
-		\pgfplots at createcolormap@grabnext@@@
+\def\pgfplots at createcolormap@grabnext at read@pos@#1){%
+	\def\pgfplots at loc@TMPb{#1}% position
+	\def\b at pgfplots@createcolormap at pos@mode{m}% [m]anual
+	\pgfutil at ifnextchar\pgfplots at EOI{%
+		% OK
+		\pgfplots at gobble@until at EOI
 	}{%
-		\pgfplots at createcolormap@error=%
+		\pgfplots at createcolormap@error#1)%
 	}%
 }%
-\def\pgfplots at createcolormap@grabnext@@@(#1){%
-	\def\pgfplots at loc@TMPc{#1}%
-	\pgfplots at createcolormap@grabnext at complete
-}%
 
 %%%%%%%%%%
 
-% defines \pgfplotsretval to contain the argument and \pgfplotsretvalb
-% to contain the colormap name.
-\def\pgfplots at createcolormap@special at 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 at createcolormap@special at split#1#2{%
 	\pgfutil at in@{of }{#1}%
 	\ifpgfutil at in@
 		\pgfplots at createcolormap@special at split@#1\pgfplots at EOI
 	\else
-		\pgfkeys at spdef\pgfplotsretval{#1}%
-		\pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretvalb
+		\if1#2\relax
+			% do not check it -- commas are allowed here!
+			\pgfutil at in@false
+		\else
+			\pgfutil at in@{,}{#1}%
+		\fi
+		\ifpgfutil at 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 at createcolormap@special at split@command#1\pgfplots at EOI
+			\t at pgfplots@tokb=\expandafter{\pgfplotsretvalb}%
+			\pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretvalb
+			\edef\pgfplotsretvalb{\pgfplotsretvalb,\the\t at pgfplots@tokb}%
+		\else
+			\pgfkeys at spdef\pgfplotsretval{#1}%
+			\pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretvalb
+		\fi
 	\fi
-	\pgfplots at createcolormap@special at ensure@source at cm{\pgfplotsretvalb}%
+%\message{Split (#1) --> '\pgfplotsretval', '\pgfplotsretvalb'^^J}%
 }%
 \def\pgfplots at createcolormap@special at split@#1of #2\pgfplots at EOI{%
 	\pgfkeys at spdef\pgfplotsretval{#1}%
 	\pgfkeys at spdef\pgfplotsretvalb{#2}%
 }
+\def\pgfplots at createcolormap@special at split@command#1,#2\pgfplots at EOI{%
+	\pgfkeys at spdef\pgfplotsretval{#1}%
+	\pgfkeys at spdef\pgfplotsretvalb{#2}%
+}
+
+% Output: \pgfplotsretval will be populated with the resulting
+% colormap name.
 \def\pgfplots at createcolormap@special at ensure@source at cm#1{%
-	\pgfplotscolormapifdefined{#1}{%
-	}{%
-		\pgfplots at 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/. at cmd}{%
+			\pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots at color@of at colormap@name at old
+			\pgfplotsset{#1}%
+			\pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsretval
+			\pgfkeyslet{/pgfplots/colormap name}\pgfplots at color@of at colormap@name at old
+		}{%
+			\pgfplots at 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 at createcolormap@grabnextspecial at colors of colormap\endcsname#1#2{%
-	\pgfplots at createcolormap@special at split{#2}%
-	\pgfplots at createcolormap@special at process{#1}{color of colormap}%
-%\message{colors of colormap(#1)=(#2): resulted in \meaning\pgfplotsretval^^J}%
+\newif\ifpgfplots at createcolormap@target at pos@includes at limits@min
+\newif\ifpgfplots at createcolormap@target at pos@includes at limits@max
+
+% these keys are only evaluated inside of
+% \pgfplots at of@colormap at getresult :
+\pgfqkeys{/pgfplots/of colormap}{%
+	source name/.initial=,
+	target pos/.initial=,
+	target pos min/.initial=,
+	target pos min/insert/.is if=pgfplots at createcolormap@target at pos@includes at 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 at createcolormap@target at pos@includes at limits@max,
+	source pos/.initial=,
+	source pos/.set if not empty/.code={%
+		\edef\pgfplots at loc@TMPa{#1}%
+		\ifx\pgfplots at loc@TMPa\pgfutil at empty
+		\else
+			\pgfkeyslet{/pgfplots/of colormap/source pos}\pgfplots at loc@TMPa
+		\fi
+	},
+	%
+	@define/.code={%
+		\pgfplots at error{Please write 'single color' or 'color list' such that pgfplots knows how to interprete values}
+		\let\pgfplotsretval=\pgfutil at empty
+	},
+	single color/.style={%
+		/pgfplots/of colormap/@define/.code={%
+			\pgfplots at createcolormap@special at process@single
+		},
+	},
+	color list/.style={%
+		/pgfplots/of colormap/@define/.code={%
+			\pgfplots at createcolormap@special at 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 at createcolormap@special at split{#2}{#3}%
+		\edef\pgfplots at 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 at 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 at createcolormap@special at process@list at 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 at ofcolorbar@sample at for@choice{m}},
+	sample for/const/.code={\def\pgfplots at ofcolorbar@sample at 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 at loc@TMPa{%
+					\noexpand\pgfkeysalso{%
+						/pgfplots/of colormap/source name={\pgfkeyscurrentname},
+					}%
+				}%
+				\pgfplots at loc@TMPa
+			}{%
+				\pgfplots at error{Unknown key '\pgfkeyscurrentname'. Is this a colormap name? Maybe you need to write \string\pgfplotsset{\pgfkeyscurrentname} first?}%
+			}%
+		}{%
+			\pgfkeysgetvalue{/handlers/.unknown/. at cmd}{\pgfkeys at code}%
+			\expandafter\pgfkeys at code\pgfkeyscurrentvalue\pgfeov%
+		}%
+	},
+	%
+	% allow something like 'of colormap={colormap/PuBuGn}':
+	/pgfplots/of colormap/colormap/.unknown/.code={%
+		\edef\pgfplots at loc@TMPa{\noexpand\pgfplotsset{colormap/\pgfkeyscurrentname}}%
+		\pgfplots at loc@TMPa
+	},%
 }
-\expandafter\def\csname pgfplots at createcolormap@grabnextspecial at samples of colormap\endcsname#1#2{%
-	\pgfplots at createcolormap@special at 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 at glob@TMPa{#1}%
+	\ifx\pgfplots at glob@TMPa\pgfutil at 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 at glob@TMPa{#1}%
+	\ifx\pgfplots at glob@TMPa\pgfutil at 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 at of@colormap at 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 at loc@TMPa
+	\edef\pgfplots at loc@TMPa{\pgfplots at loc@TMPa}%
+	\ifx\pgfplots at loc@TMPa\pgfutil at empty
+	\else
+		\pgfkeyslet{/pgfplots/colormap name}\pgfplots at loc@TMPa
+	\fi
+	\pgfplots at createcolormap@special at ensure@source at cm{\pgfkeysvalueof{/pgfplots/colormap name}}%
+	\pgfkeyslet{/pgfplots/colormap name}\pgfplotsretval
+	%
+	\pgfqkeys{/pgfplots/of colormap}{@define}%
+	\endpgfkeysinterruptkeyfilter
+}%
+
+
+\def\pgfplots at createcolormap@special at process@single at error{%
+	\pgfplots at 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 at createcolormap@special at process@single at error@comma{%
+	\pgfplots at 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 at createcolormap@special at process@single{%
 	\begingroup
-	\let\pgfplots at source=\pgfplotsretval
-	\let\pgfplots at sourcecm=\pgfplotsretvalb
-	\pgfplots at domain@to at foreach 0:1000\relax{\pgfplots at source}%
-	\t at pgfplots@toka=\expandafter{\pgfplotsretval}%
-	\edef\pgfplotsretval{colors of colormap(#1)=({\the\t at pgfplots@toka} of \pgfplots at sourcecm)}%
+	\let\pgfplots at color@of at colormap@access=\pgfplots at colormap@access
+	\pgfkeysgetvalue{/pgfplots/of colormap/source range}\pgfplotspointmetatransformedrange
+	\ifx\pgfplotspointmetatransformedrange\pgfutil at empty
+		% evaluated by \pgfplots at color@of at colormap@define...
+		\let\pgfplotspointmetatransformedrange=\pgfplotscolormaprange
+	\fi
+	%
+	\pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots at loc@TMPa
+	\edef\pgfplots at loc@TMPa{\pgfplots at loc@TMPa}%
+	\ifx\pgfplots at loc@TMPa\pgfutil at empty
+		\pgfplots at createcolormap@special at process@single at error
+	\else
+		\edef\pgfplots at loc@TMPa{%
+			\noexpand\pgfutil at in@{,}{\pgfplots at loc@TMPa}%
+		}%
+		\pgfplots at loc@TMPa
+		\ifpgfutil at in@
+			\pgfplots at createcolormap@special at process@single at 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 at loc@TMPa{%
+		\noexpand\pgfplots at color@of at colormap@define{\pgfkeysvalueof{/pgfplots/of colormap/source pos}}%
+	}%
+	\pgfplots at loc@TMPa
+	%
+	\pgfplots at createcolormap@special at process@single at define
 	\pgfmath at smuggleone\pgfplotsretval
 	\endgroup
-%\message{samples of colormap(#1)=(#2): resulted in \meaning\pgfplotsretval^^J}%
-}
-\expandafter\def\csname pgfplots at createcolormap@grabnextspecial at indices of colormap\endcsname#1#2{%
-	\pgfplots at createcolormap@special at split{#2}%
-	\pgfplots at createcolormap@special at process{#1}{index of colormap}%
-%\message{indices of colormap(#1)=(#2): resulted in \meaning\pgfplotsretval^^J}%
-}
-\expandafter\def\csname pgfplots at createcolormap@grabnextspecial at color of colormap\endcsname#1#2{%
-	\begingroup
-	% colormap access=map
-	\def\pgfplots at color@of at colormap@access{m}%
-	\pgfplots at color@of at colormap@define{#2}%
+}%
+
+\def\pgfplots at createcolormap@special at process@single at define{%
+	\pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots at temp@pos
+	\ifx\pgfplots at temp@pos\pgfutil at empty
+	\else
+		\edef\pgfplots at temp@pos{(\pgfplots at temp@pos)}%
+	\fi
+	%
 	\edef\pgfplotsretval{%
-		\csname pgfpl at cm@\pgfplots at color@of at colormap@name @colspace\endcsname(#1)=(\pgfmathresult)%
+		\csname pgfpl at cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname\pgfplots at temp@pos=(\pgfmathresult)%
 	}%
-	\pgfmath at smuggleone\pgfplotsretval
-	\endgroup
+}%
+\let\pgfplots at createcolormap@special at process@single at define@CM=\pgfplots at createcolormap@special at process@single at define%
+
+\def\pgfplots at createcolormap@special at process@list at sanitize@selection{%
+	\pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots at loc@TMPa
+	\edef\pgfplots at loc@TMPa{\pgfplots at loc@TMPa}%
+	\ifx\pgfplots at loc@TMPa\pgfutil at empty
+		% default to a suitable source pos.
+		\ifnum\pgfplots at 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 at loc@TMPa{%
+				\noexpand\pgfkeysalso{%
+					/pgfplots/of colormap/source pos={0,...,\pgfplotscolormaplastindexof{\pgfkeysvalueof{/pgfplots/colormap name}}},%
+					/pgfplots/of colormap/indices,
+				}%
+			}%
+			\pgfplots at 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 at pos@size
+			\pgfplots at createcolormap@special at process@list at sampled@define{P}%
+		\fi
+	\fi
 }
-\expandafter\def\csname pgfplots at createcolormap@grabnextspecial at index of colormap\endcsname#1#2{%
+\def\pgfplots at createcolormap@special at process@list at limits{%
 	\begingroup
-	% colormap access=direct
-	\def\pgfplots at color@of at colormap@access{d}%
-	\pgfplots at color@of at colormap@define{#2}%
-	\edef\pgfplotsretval{%
-		\csname pgfpl at cm@\pgfplots at color@of at colormap@name @colspace\endcsname(#1)=(\pgfmathresult)%
-	}%
-	\pgfmath at smuggleone\pgfplotsretval
+	%
+	\pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots at target
+	\ifx\pgfplots at target\pgfutil at empty
+	\else
+		\pgfkeys{/pgf/fpu=true}%
+		\pgfkeysgetvalue{/pgfplots/of colormap/target pos min}\pgfplots at target@min
+		\pgfkeysgetvalue{/pgfplots/of colormap/target pos max}\pgfplots at target@max
+		\pgfplots at loc@tmpfalse
+		\ifx\pgfplots at target@min\pgfutil at empty
+		\else
+			\pgfmathparse\pgfplots at target@min
+			\let\pgfplots at target@min=\pgfmathresult
+			\pgfplots at loc@tmptrue
+		\fi
+		\ifx\pgfplots at target@max\pgfutil at empty
+		\else
+			\pgfmathparse\pgfplots at target@max
+			\let\pgfplots at target@max=\pgfmathresult
+			\pgfplots at loc@tmptrue
+		\fi
+		\ifpgfplots at loc@tmp
+			% Ah - we _have_ limit constraints! Enforce them:
+			\def\b at pgfplots@isfirst{1}%
+			\pgfmathfloatcreate{1}{1.0}{324}%
+			\let\pgfplots at firstpos\pgfmathresult%
+			\let\pgfplots at lastpos\pgfmathresult%
+			\pgfplotsapplistXnewempty\pgfplots at createcolormap@trg at accum
+			\def\pgfplots at loc@TMPa{\pgfplotsforeachungrouped \x in}%
+			\expandafter\pgfplots at loc@TMPa\expandafter{\pgfplots at target}{%
+				\ifx\x\pgfutil at empty
+				\else
+					\pgfmathparse{\x}%
+					\let\x=\pgfmathresult
+					\ifx\pgfplots at target@min\pgfutil at empty
+					\else
+						\pgfmathfloatlessthan{\x}{\pgfplots at target@min}%
+						\ifpgfmathfloatcomparison
+							\let\x=\pgfutil at empty
+						\fi
+					\fi
+					\ifx\pgfplots at target@max\pgfutil at empty
+					\else
+						\ifx\x\pgfutil at empty
+						\else
+							\pgfmathfloatlessthan{\pgfplots at target@max}{\x}%
+							\ifpgfmathfloatcomparison
+								\let\x=\pgfutil at empty
+							\fi
+						\fi
+					\fi
+					%
+					\ifx\x\pgfutil at empty
+					\else
+						\let\pgfplots at lastpos=\x
+						\if1\b at pgfplots@isfirst
+							\let\pgfplots at firstpos=\x
+							\def\b at pgfplots@isfirst{0}%
+						\else
+							\edef\x{,\x}%
+						\fi
+						\expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots at createcolormap@trg at accum
+					\fi
+				\fi
+			}%
+			%
+			\ifpgfplots at createcolormap@target at pos@includes at limits@max
+				\ifx\pgfplots at target@max\pgfutil at empty
+				\else
+					\pgfmathfloatifapproxequalrel{\pgfplots at lastpos}{\pgfplots at target@max}{%
+					}{%
+						\let\x=\pgfplots at target@max
+						\if1\b at pgfplots@isfirst
+							\def\b at pgfplots@isfirst{0}%
+						\else
+							\edef\x{,\x}%
+						\fi
+						\expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots at createcolormap@trg at accum
+					}%
+				\fi
+			\fi
+			%
+			\pgfplotsapplistXlet\pgfplots at target=\pgfplots at createcolormap@trg at accum
+			%
+			\ifpgfplots at createcolormap@target at pos@includes at limits@min
+				\ifx\pgfplots at target@min\pgfutil at empty
+				\else
+					\pgfmathfloatifapproxequalrel{\pgfplots at firstpos}{\pgfplots at target@min}{%
+					}{%
+						\let\x=\pgfplots at target@min
+						\if1\b at pgfplots@isfirst
+							\let\pgfplots at target=\x
+						\else
+							\edef\pgfplots at target{\x,\pgfplots at target}%
+						\fi
+					}%
+				\fi
+			\fi
+		\fi
+	\fi
+	%
+	\global\let\pgfplots at glob@TMPb=\pgfplots at target
 	\endgroup
-}
-\def\pgfplots at createcolormap@special at process#1#2{%
+%\message{limit application: \pgfkeysvalueof{/pgfplots/of colormap/target pos} ^^J -->\pgfplots at glob@TMPb^^J}%
+	\pgfkeyslet{/pgfplots/of colormap/target pos}\pgfplots at glob@TMPb
+}%
+
+\def\pgfplots at createcolormap@special at process@list at define@target at array{%
+	\pgfplots at createcolormap@special at process@list at limits%
+	%
+	\pgfkeysgetvalue{/pgfplots/of colormap/target pos}\pgfplots at loc@TMP
+	\expandafter\pgfplotsarraynew\expandafter\pgfplots at pos@array\expandafter{\pgfplots at loc@TMP}%
+	%
+	\pgfplotsarraysizetomacro\pgfplots at pos@array\to\pgfplots at pos@size
+}%
+
+% PRECONDITION: Must be invoked within \pgfplots at of@colormap at getresult
+\def\pgfplots at createcolormap@special at process@list{%
 	\begingroup
-	\let\pgfplots at source=\pgfplotsretval
-	\let\pgfplots at sourcecm=\pgfplotsretvalb
-	\def\pgfplots at temp@pos{(#1)}%
+	\pgfkeys{/pgf/fpu=true}%
+	\pgfplots at createcolormap@special at process@list at define@target at array
 	%
 	\pgfplotsapplistXnewempty\pgfplots at createcolormap@special at process@result
+	%
+	\gdef\c at pgfplots@elem{0}%
+	%
+	\def\pgfplots at createcolormap@special at process@list at append{%
+		\pgfplots at createcolormap@special at process@single
+		%
+		% append separator
+		\t at pgfplots@toka=\expandafter{\pgfplotsretval}%
+		\t at pgfplots@tokb=\expandafter{\pgfplots at createcolormap@special at process@list at separator}%
+		\edef\pgfplotsretval{\the\t at pgfplots@toka\the\t at pgfplots@tokb}%
+		%
+		\expandafter\pgfplotsapplistXpushback\pgfplotsretval\to\pgfplots at createcolormap@special at process@result
+	}%
+	%
+	\pgfplots at createcolormap@special at process@list at sanitize@selection
+	%
+	\pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots at source
+	%
 	\def\pgfplots at loc@TMPa{\pgfplotsforeachungrouped \x in }%
 	\expandafter\pgfplots at loc@TMPa\expandafter{\pgfplots at source}{%
-		\t at pgfplots@tokb=\expandafter{\pgfplots at sourcecm}%
 		%
-		\edef\currentValue{#2\pgfplots at temp@pos=(\x\space of \the\t at pgfplots@tokb) }%
+		\pgfkeyslet{/pgfplots/of colormap/source pos}\x
 		%
-		\expandafter\pgfplotsapplistXpushback\currentValue\to\pgfplots at createcolormap@special at process@result
+		\ifnum\c at pgfplots@elem<\pgfplots at pos@size\relax
+			\pgfplotsarrayselect\c at pgfplots@elem\of\pgfplots at pos@array\to\pgfplots at loc@TMPa
+			\pgfkeyslet{/pgfplots/of colormap/target pos}\pgfplots at loc@TMPa
+		\else
+			% auto-position:
+			\pgfkeyslet{/pgfplots/of colormap/target pos}\pgfutil at empty
+		\fi
 		%
-		% all following ones receive auto-positions:
-		\let\pgfplots at temp@pos=\pgfutil at empty
+		\pgfplots at createcolormap@special at process@list at append
+		%
+		\pgfplotsutil at advancestringcounter@global\c at pgfplots@elem
 	}%
+	%
+	\pgfutil at loop
+	\ifnum\c at pgfplots@elem<\pgfplots at pos@size\relax
+		\pgfplotsarrayselect\c at pgfplots@elem\of\pgfplots at pos@array\to\pgfplots at loc@TMPa
+		\pgfkeysgetvalue{/pgfplots/of colormap/source pos}\x
+		\pgfplotswarning{too many colormap positions}{index \c at pgfplots@elem\space (value \pgfplots at loc@TMPa)}\pgfeov%
+		\pgfplotsutil at advancestringcounter@global\c at pgfplots@elem
+		%
+	\pgfutil at repeat
+	%
 	\pgfplotsapplistXlet\pgfplotsretval=\pgfplots at createcolormap@special at process@result
 	\global\let\pgfplots at glob@TMPa=\pgfplotsretval
 	\endgroup
 	\let\pgfplotsretval=\pgfplots at glob@TMPa
+%\message{of colormap with list functionality results in \meaning\pgfplotsretval^^J}%
 }%
+\def\pgfplots at createcolormap@special at process@list at sampled{%
+	\begingroup
+	\pgfkeys{/pgf/fpu=true}%
+	\pgfplots at createcolormap@special at process@list at define@target at array
+	%
+	% no need to reapply it in \pgfplots at createcolormap@special at process@list:
+	\let\pgfplots at createcolormap@special at process@list at define@target at array=\relax
+	%
+	\pgfplots at createcolormap@special at process@list at sampled@define{S}%
+	\pgfplots at createcolormap@special at process@list
+	\global\let\pgfplots at glob@TMPa=\pgfplotsretval
+	\endgroup
+	\let\pgfplotsretval=\pgfplots at 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 at createcolormap@special at process@list at sampled@define#1{%
+	\begingroup
+	\pgfkeysgetvalue{/pgfplots/of colormap/source pos}\pgfplots at source
+	%
+	\def\b at pgfplots@special at interval{0}%
+	\def\b at pgfplots@special at interval@additional{0}%
+	\if c\pgfplots at ofcolorbar@sample at 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 at pos@size>1
+			% ah - we have at least 2 positions and 'extra interval width=0' applies!
+			\if S#1%
+				\c at pgf@counta=\pgfplots at source\relax
+				\advance\c at pgf@counta by1 %
+				\ifnum\pgfplots at pos@size=\c at pgf@counta
+				\else
+					\pgfplotsthrow{too few colormap positions}{\pgfplots at pos@size}{There is an unexpected number of arguments to 'target pos' for 'samples of colormap=(\pgfplots at source)'. Please provide \the\c at pgf@counta\space positions, not \pgfplots at 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 at pgfplots@special at interval{1}%
+				% -> we also need one more sample point (one for each position):
+				\def\b at pgfplots@special at interval@additional{1}%
+			\else
+				% we have pgfplots at pos@size=pgfplots at source.
+				\if1\b at pgfplots@createcolormap at found@more at colors
+					% there are more positions/colors!? Ok, no need to
+					% apply it here:
+					\def\b at pgfplots@special at interval{0}%
+				\else
+					\def\b at pgfplots@special at interval{1}%
+				\fi
+			\fi
+		\else
+			\def\b at pgfplots@special at interval{0}%
+		\fi
+	\else
+		\def\b at pgfplots@special at interval{0}%
+		\ifnum\pgfplots at pos@size>1
+			% ah - we have at least 2 positions
+			\if S#1%
+				\ifnum\pgfplots at pos@size=\pgfplots at source
+				\else
+					\pgfplotsthrow{too few colormap positions}{\pgfplots at pos@size}{There is an unexpected number of arguments to 'target pos' for 'samples of colormap=(\pgfplots at source)'. Please provide \pgfplots at source\space positions, not \pgfplots at pos@size}\pgfeov%
+				\fi
+			\fi
+		\fi
+	\fi
+	%
+	\if1\b at pgfplots@special at interval@additional
+		\c at pgf@counta=\pgfplots at source\relax
+		\advance\c at pgf@counta by+1
+		\edef\pgfplots at source{\the\c at pgf@counta}%
+	\fi
+	\if1\b at pgfplots@special at interval
+		\begingroup
+		\c at pgf@counta=\pgfplots at source\relax
+		\advance\c at pgf@counta by-1
+		%
+		\pgfplotsapplistXnewempty\pgfplots at createcolormap@trg at accum
+		\ifnum\c at pgf@counta<2
+			\pgfmathfloatcreate{0}{0.0}{0}%
+			\expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult,}\to\pgfplots at createcolormap@trg at accum
+		\else
+			\edef\pgfplots at source{\the\c at pgf@counta}%
+			\pgfplots at domain@to at foreach 0:1000\relax{\pgfplots at source}%
+			%
+			\def\pgfplots at loc@TMPa{\pgfplotsforeachungrouped \x in}%
+			\expandafter\pgfplots at loc@TMPa\expandafter{\pgfplotsretval}{%
+				\expandafter\pgfplotsapplistXpushback\expandafter{\x,}\to\pgfplots at createcolormap@trg at accum
+			}%
+		\fi
+		%
+		\pgfmathfloatcreate{1}{1.0}{3}%
+		\expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots at createcolormap@trg at accum
+		%
+		\pgfplotsapplistXlet\pgfplots at target=\pgfplots at createcolormap@trg at accum
+		\global\let\pgfplots at glob@TMPa=\pgfplots at target
+		\endgroup
+		%
+		\let\pgfplotsretval=\pgfplots at glob@TMPa
+	\else
+		\pgfplots at domain@to at foreach 0:1000\relax{\pgfplots at source}%
+	\fi
+	\pgfmath at 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 at createcolormap@special at process@list at separator@CM{ }%
+\let\pgfplots at createcolormap@special at process@list at separator=\pgfplots at createcolormap@special at process@list at separator@CM
 %%%%%%%%%%
 
+\def\b at pgfplots@createcolormap at found@more at colors{0}%
+
 \def\pgfplots at createcolormap@grabnext at complete{%
-	\pgfutil at IfUndefined{pgfplots at createcolormap@grabnextspecial@\pgfplots at loc@TMPa}{%
+	\edef\pgfplots at loc@TMPd{%
+		\noexpand\pgfutil at in@{of color}{\pgfplots at loc@TMPa}%
+	}%
+	\pgfplots at loc@TMPd
+	\ifpgfutil at in@
+		\def\pgfplots at loc@TMPd{%
+			\pgfplots at createcolormap@ifhasmorecolors{%
+				\def\b at pgfplots@createcolormap at found@more at colors{1}%
+				\pgfplots at createcolormap@grabnext at complete@of at colormap
+			}{%
+				\def\b at pgfplots@createcolormap at found@more at colors{0}%
+				\pgfplots at createcolormap@grabnext at complete@of at colormap
+			}%
+		}%
+	\else
 		% ok, this is a 'normal' color specification with position,
 		% colorspace, and color data.
 		%
@@ -301,24 +1035,7 @@
 		%
 		% continue loop:
 		\def\pgfplots at loc@TMPd{\pgfplots at createcolormap@}%
-	}{%
-		% ah - a special one based on another colormap!
-		% convert it into the standard format:
-		%
-		\t at pgfplots@tokb=\expandafter{\pgfplots at loc@TMPc}%
-		\edef\pgfplots at loc@TMPd{%
-			\expandafter\noexpand\csname pgfplots at createcolormap@grabnextspecial@\pgfplots at loc@TMPa\endcsname
-				% position:
-				{\pgfplots at loc@TMPb}
-				% argument:
-				{\the\t at pgfplots@tokb}%
-		}%
-		\pgfplots at loc@TMPd
-		%
-		\def\pgfplots at loc@TMPd{%
-			\expandafter\pgfplots at createcolormap@\pgfplotsretval
-		}%
-	}%
+	\fi
 	%
 	%
 	% continue loop:
@@ -325,29 +1042,82 @@
 	\pgfplots at loc@TMPd
 }%
 
+\def\pgfplots at createcolormap@grabnext at complete@of at colormap{%
+	% ah - a special one based on another colormap!
+	% convert it into the standard format:
+	\begingroup
+	\let\pgfplotscolormap at at=\pgfplots at loc@TMPb
+	\let\pgfplotscolormap at argument=\pgfplots at loc@TMPc
+	\let\pgfplotscolormap at key=\pgfplots at loc@TMPa
+	%
+	\pgfplots at createcolormap@grabnext at complete@ofcolormap
+	\pgfmath at smuggleone\pgfplotsretval
+	\endgroup
+	%
+	\expandafter\pgfplots at createcolormap@\pgfplotsretval
+}%
+
+% INPUT: 
+%		\pgfplotscolormap at at
+%		\pgfplotscolormap at argument
+%		\pgfplotscolormap at 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 at createcolormap@grabnext at complete@ofcolormap{%
+	\t at pgfplots@tokb=\expandafter{\pgfplotscolormap at argument}%
+	\edef\pgfplotscolormap at keyvalue{%
+		\if m\b at pgfplots@createcolormap at 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 at},%
+		\fi
+		% ... but can be overriden here:
+		\pgfplotscolormap at key={\the\t at pgfplots@tokb},%
+	}%
+	%
+	\let\pgfplots at createcolormap@special at process@single at define=\pgfplots at createcolormap@special at process@single at define@CM
+	\let\pgfplots at createcolormap@special at process@list at separator=\pgfplots at createcolormap@special at process@list at separator@CM
+	%
+	% finally, process the keys:
+	\expandafter\pgfplots at of@colormap at getresult\expandafter{%
+		\pgfplotscolormap at keyvalue,
+	}%
+%\message{\pgfplotscolormap at key={\pgfplotscolormap at argument} -> '\pgfplotscolormap at keyvalue' -> \pgfplotsretval^^J}%
+}%
+
 \def\pgfplots at createcolormap@grabnext at computenextposition{%
 	% determine next step size automatically:
 	\expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots at 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 at createcolormap@H\pgfutil at 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 at createcolormap@LAST\pgfplots at createcolormap@H
+			\pgfmathfloatadd@\pgfplots at createcolormap@LAST\pgfplots at createcolormap@H
 		\fi
 	\fi
 }%
 
 \def\pgfplots at createcolormap@grabsemicolon;{\pgfplots at createcolormap@}%
+\def\pgfplots at createcolormap@grabcomma,{\pgfplots at createcolormap@}%
 
+\def\pgfplots at createcolormap@grabsemicolon at hasnext#1#2;{\pgfplots at createcolormap@ifhasmorecolors{#1}{#2}}%
+\def\pgfplots at createcolormap@grabcomma at hasnext#1#2,{\pgfplots at createcolormap@ifhasmorecolors{#1}{#2}}%
+
 {
 	\catcode`\;=13
 	\gdef\pgfplots at createcolormap@grabsemicolon at active;{\pgfplots at createcolormap@}%
+	\gdef\pgfplots at createcolormap@grabsemicolon at active@hasnext#1#2;{\pgfplots at createcolormap@ifhasmorecolors{#1}{#2}}%
 }
 
 \def\pgfplots at createcolormap@nextcolor at tostring#1=#2\pgfplots at EOI#3{%
@@ -362,7 +1132,7 @@
 %
 % see  \pgfplotscolornormalizesequencenext for details
 \def\pgfplots at createcolormap@nextcolor#1#2{%
-	\def\pgfplots at createcolormap@context{\pgfplots at createcolormap@nextcolor at tostring#2\pgfplots at EOI{#1}}%
+	\def\pgfplots at createcolormap@context{\pgfplots at createcolormap@nextcolor at tostring#2\pgfplots at EOI{#1}\pgfplots at createcolormap@trace}%
 	%
 	\pgfplotscolornormalizesequencenext{#2}%
 	\let\pgfplots at createcolormap@col at comps=\pgfplotsretvalb
@@ -375,79 +1145,134 @@
 	% compute 'h':
 	\pgfmathparse{#1}%
 	\let\pgfplots at createcolormap@MAX=\pgfmathresult
-	\expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots at createcolormap@LAST}%
+	%
+	\ifx\pgfplots at createcolormap@MIN\pgfutil at empty
+		% it is the first.
+		\let\pgfplots at createcolormap@MIN=\pgfmathresult
+		\let\pgfplots at createcolormap@LAST=\pgfmathresult
+	\fi
+	%
+	\expandafter\pgfmathfloatsubtract@\expandafter{\pgfmathresult}{\pgfplots at createcolormap@LAST}%
 	\let\pgfplots at createcolormap@H at cur=\pgfmathresult
-%\message{found current diff  = \pgfplots at createcolormap@H at cur\ ( from \pgfplots at createcolormap@MAX pt - \pgfplots at createcolormap@LAST pt)^^J}%
+	\pgfplots at createcolormap@check at increasing@mesh at width
 	\let\pgfplots at createcolormap@LAST=\pgfplots at createcolormap@MAX
 	\ifx\pgfplots at createcolormap@H\pgfutil at empty
 		\expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots at createcolormap@name}%
 		\ifpgfplotsarrayempty
-			\ifdim\pgfplots at createcolormap@MAX pt=0pt
-			\else
-				\pgfplots at error{Sorry, the left end of a colormap (at 0pt) must be provided explicitly. You cannot start with \pgfplots at createcolormap@MAX pt. The error occured near `\pgfplots at createcolormap@context'}%
-				\def\pgfplots at createcolormap@MAX{0}%
-			\fi
 		\else
 			\let\pgfplots at createcolormap@H=\pgfplots at createcolormap@H at cur
-%\message{H := \pgfplots at createcolormap@H( from #1).}%
 		\fi
 	\else
-		\pgfmathapproxequalto@{\pgfplots at createcolormap@H}{\pgfplots at createcolormap@H at cur}%
-		\ifpgfmathcomparison
+		\pgfplots at createcolormap@compute at equalto{\pgfplots at createcolormap@H}{\pgfplots at createcolormap@H at cur}%
+		\ifpgfmathfloatcomparison
 		\else
-			\pgfmathdivide@{\pgfplots at createcolormap@H at cur}{\pgfplots at 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 at createcolormap@nextRGB at consider@reinterpolation
-				\c at pgf@counta=\pgfmathresult\relax
-				\pgfmath at smuggleone\pgfmathresult
-			\endgroup
-			\ifx\pgfmathresult\pgfutil at empty
-				% I can't do that yet.
+			\ifnum\b at pgfplotscreatecolormap@isuniform>1
+				% force reinterpolation:
+				\pgfplotscreatecolormap at reinterpolate{#2}%
 			\else
-				\let\pgfplots at createcolormap@loop at 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 at pgfplots@createcolormap in {1,2,...,\pgfplots at createcolormap@loop at end} {%
-					\ifdim\c at pgfplots@createcolormap pt=\pgfplots at createcolormap@loop at end pt %
-						% omit the last.
-					\else
-						\pgfmathparse{\c at pgfplots@createcolormap/\pgfplots at createcolormap@loop at end}%
-						\let\pgfplots at createcolormap@scale at current=\pgfmathresult
-						\pgfmathparse{1-\pgfplots at createcolormap@scale at current}%
-						\let\pgfplots at createcolormap@scale at last=\pgfmathresult
-						%
-						\pgfplotscolornormalizesequencezero
-						\pgfplotscolornormalizesequenceaddweighted
-							{\pgfplotsretval}
-							{\pgfplots at createcolormap@scale at current}
-							{#2}%
-						\pgfplotscolornormalizesequenceaddweighted
-							{\pgfplotsretval}
-							{\pgfplots at createcolormap@scale at last}
-							{\pgfplots at createcolormap@last}%
-						%
-%\message{interpolation step \c at pgfplots@createcolormap = \pgfplotsretval^^J}%
-						\edef\pgfplots at loc@TMPa{%
-							\noexpand\pgfplotsarraypushback{\pgfplotsretval}%
-							\noexpand\to}%
-						\expandafter\pgfplots at loc@TMPa\expandafter{\pgfplots at createcolormap@name}%
-					\fi
-				}%
+				% it is NOT uniform!
+				\def\b at pgfplotscreatecolormap@isuniform{0}%
+				%
+				\pgfmathfloatmintwo{\pgfplots at createcolormap@H at cur}{\pgfplots at createcolormap@H}%
+				\let\pgfplots at createcolormap@H=\pgfmathresult
 			\fi
 		\fi
 	\fi
+	%\message{found current H at cur  = \pgfplots at createcolormap@H at cur\space (\pgfplots at createcolormap@LAST) -> H=\pgfplots at createcolormap@H^^J}%
+	% 
+	% remember positions:
+	\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots at createcolormap@MAX,}\to\pgfplots at createcolormap@X
+	%
 	\edef\pgfplots at loc@TMPa{\noexpand\pgfplotsarraypushback{#2}\noexpand\to}%
 	\expandafter\pgfplots at loc@TMPa\expandafter{\pgfplots at createcolormap@name}%
 	\edef\pgfplots at createcolormap@last{#2}%
 }%
+
+\def\pgfplots at createcolormap@check at increasing@mesh at width{%
+	\expandafter\pgfplotsarraycheckempty\expandafter{\pgfplots at createcolormap@name}%
+	\ifpgfplotsarrayempty
+	\else
+		\pgfmathfloatifflags{\pgfplots at createcolormap@H at cur}{1}{%
+			% ok, H>0
+		}{%
+			\pgfmathfloattofixed{\pgfplots at createcolormap@H at cur}%
+			\pgfplots at error{Colormaps must have increasing positions. The provided colormap has mesh width '\pgfmathresult' at \pgfplots at createcolormap@context. Please assign increasing positions}%
+		}%
+	\fi
+}%
+\def\pgfplots at createcolormap@compute at equalto#1#2{%
+	%\begingroup
+	%\pgfmathfloatcreate{1}{1.0}{-4}%
+	%\let\pgfmathfloat at relthresh=\pgfmathresult
+	\pgfmathfloatequalto@{#1}{#2}%
+	%\xdef\pgfplots at glob@TMPa{%
+	%	\noexpand\def\noexpand\pgfmathresult{\pgfmathresult}%
+	%	\ifpgfmathfloatcomparison
+	%		\noexpand\pgfmathfloatcomparisontrue
+	%	\else
+	%		\noexpand\pgfmathfloatcomparisonfalse
+	%	\fi
+	%}%
+	%\endgroup
+	%\pgfplots at glob@TMPa
+	%\message{equalto (#1,#2) = \pgfmathresult^^J}%
+}%
+\def\pgfplotscreatecolormap at reinterpolate#1{%
+	\pgfmathfloatdivide@{\pgfplots at createcolormap@H at cur}{\pgfplots at 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 at createcolormap@nextRGB at consider@reinterpolation
+		\c at pgf@counta=\pgfmathresult\relax
+		\pgfmath at smuggleone\pgfmathresult
+	\endgroup
+	\ifx\pgfmathresult\pgfutil at empty
+		% I can't do that yet.
+	\else
+		\let\pgfplots at createcolormap@loop at 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 at pgfplots@createcolormap in {1,2,...,\pgfplots at createcolormap@loop at end} {%
+			\pgfmathfloatequalto@{\c at pgfplots@createcolormap}{\pgfplots at createcolormap@loop at end}%
+			\ifpgfmathfloatcomparison
+				% omit the last.
+			\else
+				\pgfmathparse{\c at pgfplots@createcolormap/\pgfplots at createcolormap@loop at end}%
+				\let\pgfplots at createcolormap@scale at current=\pgfmathresult
+				\pgfmathparse{1-\pgfplots at createcolormap@scale at current}%
+				\let\pgfplots at createcolormap@scale at last=\pgfmathresult
+				%
+				\pgfmathfloattofixed\pgfplots at createcolormap@scale at current
+				\let\pgfplots at createcolormap@scale at current=\pgfmathresult
+				\pgfmathfloattofixed\pgfplots at createcolormap@scale at last
+				\let\pgfplots at createcolormap@scale at last=\pgfmathresult
+				%
+				\pgfplotscolornormalizesequencezero
+				\pgfplotscolornormalizesequenceaddweighted
+					{\pgfplotsretval}
+					{\pgfplots at createcolormap@scale at current}
+					{#1}%
+				\pgfplotscolornormalizesequenceaddweighted
+					{\pgfplotsretval}
+					{\pgfplots at createcolormap@scale at last}
+					{\pgfplots at createcolormap@last}%
+				%
+%\message{interpolation step \c at pgfplots@createcolormap = \pgfplotsretval^^J}%
+				\edef\pgfplots at loc@TMPa{%
+					\noexpand\pgfplotsarraypushback{\pgfplotsretval}%
+					\noexpand\to}%
+				\expandafter\pgfplots at loc@TMPa\expandafter{\pgfplots at createcolormap@name}%
+			\fi
+		}%
+	\fi
+}%
 \def\pgfplots at createcolormap@nextRGB at consider@reinterpolation#1\relax{%
 	\pgf at xa=#1pt
 	\ifdim\pgf at xa>0.5pt % we have something like 99.995 or so.
@@ -462,7 +1287,17 @@
 %\message{Checking  H/h = \pgfplots at createcolormap@H at cur pt/\pgfplots at createcolormap@H pt = \the\c at pgf@counta+-\pgf at sys@tonumber\pgf at xa\space:  \the\pgf at xa > \the\pgf at xb\space (relative to \the\c at pgf@counta)?}%
 	%
 	\ifdim\pgf at xa>\pgf at xb
-		\pgfplots at error{Sorry, non-uniform colormaps are only partially implemented, yet: the provided points must be multiples of the mesh width h=\pgfplots at createcolormap@H pt (but I found one with H/h = \pgfplots at createcolormap@H at cur pt/\pgfplots at createcolormap@H pt = \the\c at pgf@counta+-\pgf at sys@tonumber\pgf at 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 at createcolormap@context'}%
+		\begingroup
+		\if2\b at pgfplotscreatecolormap@isuniform
+			\pgfplots at 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 at createcolormap@context'}%
+		\else
+			\pgfmathfloattofixed{\pgfplots at createcolormap@H}%
+			\let\pgfplots at createcolormap@H=\pgfmathresult
+			\pgfmathfloattofixed{\pgfplots at createcolormap@H at cur}%
+			\let\pgfplots at createcolormap@H at cur=\pgfmathresult
+			\pgfplots at error{The provided colormap positions are not multiples of the prescribed mesh width h=\pgfplots at createcolormap@H\space (found one with H/h = \pgfplots at createcolormap@H at cur/\pgfplots at createcolormap@H = \the\c at pgf@counta+-\pgf at sys@tonumber\pgf at xa\space which is no integer). The error occured near `\pgfplots at createcolormap@context'}%
+		\fi
+		\endgroup
 		\let\pgfmathresult=\pgfutil at empty
 	\else
 		\ifnum\c at pgf@counta=0
@@ -475,7 +1310,9 @@
 
 \def\pgfplots at colormap@LUA at new#1{%
 	\ifpgfplots at LUA@supported
-		\pgfplotscolormapserializecomponentstomacro{#1}\pgfplots at loc@TMPa
+		\begingroup
+		\pgfplotscolormapserializecomponentstomacro{#1}\pgfplots at values
+		\pgfplotscolormapserializeXtomacro{#1}\pgfplots at pos
 		\pgfplotsutil at directlua{%
 			local colorspace =^^J%
 				pgfplots.\csname pgfpl at cm@#1 at colspace\endcsname;^^J%
@@ -483,13 +1320,27 @@
 				pgfplots.ColorMaps["#1"] = pgfplots.ColorMap.new(^^J%
 					\csname pgfpl at cm@#1 at h\endcsname,^^J%
 					colorspace,^^J%
-					{ \pgfplots at loc@TMPa });^^J%
+					{ \pgfplots at values },^^J
+					{ \pgfplots at pos }^^J
+				);^^J%
 			else^^J%
 				io.write("There is no LUA colorspace for '\csname pgfpl at cm@#1 at 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 at cm@#1 at X}\relax
+		#2\relax
+	\else
+		#3\relax
+	\fi
+}%
+
 % Shows debug info about colormap #1 into the console.
 \def\pgfplots at colormap@showdebuginfofor#1{%
 	\message{Debug info for color map '#1':^^J}%
@@ -501,10 +1352,18 @@
 	\message{Colorspace: \csname pgfpl at cm@#1 at colspace\endcsname^^JValues (\csname pgfpl at cm@#1 at col@comps\endcsname\space components each): ^^J}%
 	\begingroup
 	\c at pgf@counta=0
-	\pgfplotsarrayforeachungrouped{pgfpl at cm@#1}\as\elem{%
-		\pgfmath at basic@multiply@{\the\c at pgf@counta}{\csname pgfpl at cm@#1 at h\endcsname}%
-		\message{\#\the\c at pgf@counta=(\pgfmathresult)=(\elem);^^J}%
-		\advance\c at pgf@counta by1 %
+	\pgfplotscolormapifisuniform{#1}{%
+		\pgfplotsarrayforeachungrouped{pgfpl at cm@#1}\as\elem{%
+			\pgfmath at basic@multiply@{\the\c at pgf@counta}{\csname pgfpl at cm@#1 at h\endcsname}%
+			\message{\#\the\c at pgf@counta=(\pgfmathresult)=(\elem);^^J}%
+			\advance\c at pgf@counta by1 %
+		}%
+	}{%
+		\pgfplotsarrayforeachungrouped{pgfpl at cm@#1}\as\elem{%
+			\pgfplotsarrayselect\c at pgf@counta\of{pgfpl at cm@#1 at X}\to\pgfmathresult
+			\message{\#\the\c at pgf@counta=(\pgfmathresult)=(\elem);^^J}%
+			\advance\c at pgf@counta by1 %
+		}%
 	}%
 	\message{^^J}%
 	\endgroup
@@ -587,7 +1446,11 @@
 	\pgfplotsarrayforeach{pgfpl at cm@#2}\as\elem{%
 		\ifnum\pgfplots at eachnth@cur=0\relax
 			\gdef\pgfplots at eachnth@cur{0}%
-			\pgfmath at basic@multiply@{\pgfplotsarrayforeachindex}{\csname pgfpl at cm@#2 at h\endcsname}%
+			\pgfplotscolormapifisuniform{#2}{%
+				\pgfmath at basic@multiply@{\pgfplotsarrayforeachindex}{\csname pgfpl at cm@#2 at h\endcsname}%
+			}{%
+				\pgfplotsarrayselect\pgfplotsarrayforeachindex\of{pgfpl at cm@#1 at X}\to\pgfmathresult
+			}%
 			\edef\pgfplots at loc@TMPa{{\elem}{#2}{\pgfplotsarrayforeachindex}{\pgfmathresult}}%
 			\expandafter\pgfplotscolormaptodatafile at elem\pgfplots at loc@TMPa
 			\ifx\pgfplotsretval\pgfutil at 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 at cm@#1 at 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 at to@macro{pgfpl at cm@#1}{#2}%
+}
+\def\pgfplotscolormapserialize at to@macro#1#2{%
 	\pgfplotsapplistXnewempty\pgfplots at serialize@list@
-	\pgfplotsarrayforeachungrouped{pgfpl at cm@#1}\as\elem{%
-		\expandafter\pgfplotsapplistXpushback\expandafter{\elem},\to\pgfplots at serialize@list@
+	\pgfplots at loc@tmptrue
+	\expandafter\pgfplotsarrayforeachungrouped\expandafter{#1}\as\elem{%
+		\ifpgfplots at loc@tmp
+			\expandafter\pgfplotsapplistXpushback\expandafter{\expandafter{\elem}}\to\pgfplots at serialize@list@
+			\pgfplots at loc@tmpfalse
+		\else
+			\expandafter\pgfplotsapplistXpushback\expandafter,\expandafter{\elem}\to\pgfplots at serialize@list@
+		\fi
 	}%
 	\pgfplotsapplistXlet#2=\pgfplots at serialize@list@
 }%
 
+\def\pgfplotscolormapserialize at to@macro at nobraces#1#2{%
+	\pgfplotsapplistXnewempty\pgfplots at serialize@list@
+	\pgfplots at loc@tmptrue
+	\expandafter\pgfplotsarrayforeachungrouped\expandafter{#1}\as\elem{%
+		\ifpgfplots at loc@tmp
+			\expandafter\pgfplotsapplistXpushback\elem\to\pgfplots at serialize@list@
+			\pgfplots at loc@tmpfalse
+		\else
+			\expandafter\pgfplotsapplistXpushback\expandafter,\elem\to\pgfplots at serialize@list@
+		\fi
+	}%
+	\pgfplotsapplistXlet#2=\pgfplots at serialize@list@
+}%
+\def\pgfplotscolormapserializeXtomacro#1#2{%
+	\pgfplotscolormapserialize at to@macro at nobraces{pgfpl at cm@#1 at 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 at serialize@list
+		\pgfplotscolormapserializeXtomacro{#1}\pgfplots at serialize@list at X
 		\toks0={\expandafter\def\csname pgfpl at cm@#1 at h\endcsname}%
 		\toks1={\expandafter\def\csname pgfpl at cm@#1 at invh\endcsname}%
 		\toks2={%
@@ -651,6 +1543,16 @@
 		\toks4=\expandafter{\expandafter\def\csname pgfpl at cm@#1 at colspace\endcsname}%
 		\toks5=\expandafter{\expandafter\def\csname pgfpl at cm@#1 at col@comps\endcsname}%
 		\toks6=\expandafter{\expandafter\def\csname pgfpl at cm@#1 at lastindex\endcsname}%
+		\toks7={%
+			\pgfplotsarraynewempty{pgfpl at cm@#1 at X}%
+			\expandafter\pgfplotsutilforeachcommasep\pgfplots at loc@TMPa\as\pgfplots at loc@TMPb{%
+				\ifx\pgfplots at loc@TMPb\pgfutil at empty
+				\else
+					\expandafter\pgfplotsarraypushback\pgfplots at loc@TMPb\to{pgfpl at cm@#1 at X}%
+				\fi
+			}%
+		}%
+		\toks8=\expandafter{\pgfplots at serialize@list at X}%
 		\xdef\pgfplots at glob@TMPa{%
 			\the\toks0 {\csname pgfpl at cm@#1 at h\endcsname}%
 			\the\toks1 {\csname pgfpl at cm@#1 at invh\endcsname}%
@@ -659,15 +1561,97 @@
 			\the\toks4 {\csname pgfpl at cm@#1 at colspace\endcsname}%
 			\the\toks5 {\csname pgfpl at cm@#1 at col@comps\endcsname}%
 			\the\toks6 {\csname pgfpl at cm@#1 at lastindex\endcsname}%
+			\noexpand\def\noexpand\pgfplots at loc@TMPa{\the\toks8 }%
+			\the\toks7
+			\def\expandafter\noexpand\csname pgfpl at cm@#1 at X@scale at order@z\endcsname{\csname pgfpl at cm@#1 at X@scale at order@z\endcsname}%
 		}%
 	\endgroup
 	\let#2=\pgfplots at 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 at colormap@access
+		\edef\pgfplotsretval{0,1,...,\pgfplotscolormaplastindexof{#3}}%
+	\else
+		\if m\pgfplots at colormap@access
+			\def\b at pgfplots@extra at interval{0}%
+			\edef\pgfplots at H{\csname pgfpl at cm@#3 at h\endcsname}%
+		\else
+			\if c\pgfplots at colormap@access
+				\pgfplotscolormap at piecewiseconst@prepare at scale{#3}%
+				\edef\pgfplots at H{\pgf at sys@tonumber\pgf at x}%
+			\fi
+		\fi
+		%
+		\pgfkeys{/pgf/fpu}%
+		\pgfplotsapplistXnewempty\pgfplots at resultaccum
+		\pgfplotscolormapifisuniform{#3}{%
+			\pgfmathparse{#1 + (#2-#1) * \pgfplots at H/1000}%
+			\let\next=\pgfmathresult
+			\pgfmathparse{#2}% + (#2-#1)/1000}%
+			%
+			\def\b at pgfplots@isfirst{1}%
+			\edef\pgfplots at loc@TMPa{\noexpand\pgfplotsforeachungrouped\noexpand \x in {#1,\next,...,\pgfmathresult}}%
+			\pgfplots at loc@TMPa{%
+				\if0\b at pgfplots@isfirst
+					\pgfplotsapplistXpushback,\to\pgfplots at resultaccum
+				\fi
+				\expandafter\pgfplotsapplistXpushback\expandafter{\x}\to\pgfplots at resultaccum
+				\def\b at pgfplots@isfirst{0}%
+			}%
+		}{%
+			\pgfmathparse{(#2-#1)/1000}%
+			\let\pgfplots at scale=\pgfmathresult
+			\pgfplotsarrayforeachungrouped{pgfpl at cm@#3 at X}\as\pgfplots at loc@TMPc{%
+				\if m\pgfplots at colormap@access
+					% colormap access=map
+					\pgfmathparse{#1 + \pgfplots at loc@TMPc * \pgfplots at scale}%
+				\else
+					\if1\b at pgfplots@extra at interval
+						\pgfmathparse{#1 + \pgfplots at loc@TMPc * \pgfplots at H* \pgfplots at scale}%
+					\else
+						% DISABLE additional interval!
+						% Means: use the input position as usual:
+						\pgfmathparse{#1 + \pgfplots at loc@TMPc * \pgfplots at scale}%
+					\fi
+				\fi
+				\ifnum\pgfplotsarrayforeachindex>0
+					\pgfplotsapplistXpushback,\to\pgfplots at resultaccum
+				\fi
+				\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
+				\expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots at resultaccum
+			}%
+			\if1\b at pgfplots@extra at interval
+				\pgfmathparse{#2}%
+				\pgfplotsapplistXpushback,\to\pgfplots at resultaccum
+				\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
+				\expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfplots at resultaccum
+			\fi
+		}%
+		\pgfplotsapplistXlet\pgfplotsretval=\pgfplots at resultaccum
+	\fi
+	\pgfmath at 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 at 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 at 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 at x contains the MODIFIED mesh width
+%  \b at pgfplots@extra at interval is 1 if and only if an extra interval
+%  should be added
+% 2. for non-uniform #1:
+% 	\pgf at x is a scaling factor to map input positions to MODIFIED
+% 	positions
+%  \b at pgfplots@extra at interval is 1 if and only if an extra interval
+\def\pgfplotscolormap at piecewiseconst@prepare at 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 at x:
+		\expandafter\ifx\csname pgfpl at cm@#1 at X@scale at order@z\endcsname\pgfutil at empty%
+			\c at pgf@countd=\pgfplotscolormapsizeof{#1}\relax
+			%
+			\global\pgf at x=1000pt %
+			\global\divide\pgf at x by\c at pgf@countd
+			\def\b at pgfplots@extra at interval{1}%
+		\else
+			% DISABLE the extra interval!
+			\global\pgf at x=\csname pgfpl at cm@#1 at h\endcsname pt %
+			\def\b at pgfplots@extra at 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 at x=\csname pgfpl at cm@#1 at X@scale at order@z\endcsname pt %
+		% see also
+		% \pgfplotscolormapfindpiecewiseconst at precomputed for
+		% comments
+		\ifdim\pgf at x>0sp %
+			\def\b at pgfplots@extra at interval{1}%
+		\else
+			% disable it
+			\def\b at pgfplots@extra at interval{0}%
+		\fi
+	}%
+}%
+
+% #1: colormap name
+% #2: yes code
+% #3: no code
+\def\pgfplotscolormapifrequiresextrainterval#1#2#3{%
+	\if c\pgfplots at colormap@access
+		\pgfplotscolormapifisuniform{#1}{%
+			\expandafter\ifx\csname pgfpl at cm@#1 at X@scale at order@z\endcsname\pgfutil at empty%
+				% no...
+				#3\relax%
+			\else
+				% yes:
+				#2\relax%
+			\fi
+		}{%
+			\ifdim\csname pgfpl at cm@#1 at X@scale at 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 at 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 at error{Sorry, processing more than 4 color components (as required for color map #1) is unsupported in this context}%
 	\fi
 	%
+	\def\b at pgfplots@extra at interval{0}%
 	\if m\pgfplots at colormap@access
 		% colormap access=map
 		\def\pgfplots at order{1}%
@@ -729,17 +1814,8 @@
 			% See comments in pgfplotscolormapfindpiecewiseconst at precomputed@
 			\def\pgfplots at 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 at x:
-			\c at pgf@countd=\pgfplotscolormapsizeof{#1}\relax
+			\pgfplotscolormap at piecewiseconst@prepare at scale{#1}%
 			%
-			\global\pgf at x=1000pt %
-			\global\divide\pgf at x by\c at pgf@countd
-			%
 			% interchange the sequence in the PDF function as it is
 			% defined as 
 			% y = C0 + x^0 * (C1 - C0) = C1
@@ -775,9 +1851,25 @@
 			}%
 			\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots at loc@TMPd}\to\pgfplots at resultaccum
 			\ifnum\c at pgf@counta<\c at pgf@countb\relax
-				\pgf at xa=\pgf at x
-				\multiply\pgf at xa by\c at pgf@counta\relax
-				\divide\pgf at xa by1000 % we want [ 0 1 ] not [0 1000] as domain XXX : why!?
+				\pgfplotscolormapifisuniform{#1}{%
+					\pgf at xa=\pgf at x
+					\multiply\pgf at xa by\c at pgf@counta\relax
+				}{%
+					\pgfplotsarrayselect{\c at pgf@counta}\of{pgfpl at cm@#1 at X}\to\pgfplots at loc@TMPc
+					\if m\pgfplots at colormap@access
+						% colormap access=map
+						\pgf at xa=\pgfplots at loc@TMPc pt %
+					\else
+						\if1\b at pgfplots@extra at interval
+							\pgf at xa=\pgfplots at loc@TMPc\pgf at x%
+						\else
+							% DISABLE additional interval!
+							% Means: use the input position as usual:
+							\pgf at xa=\pgfplots at loc@TMPc pt %
+						\fi
+					\fi
+				}%
+				\divide\pgf at xa by\pgfplotscolormappdfmax at inv\relax% we want [ 0 1 ] not [0 1000] as domain XXX : why!?
 				\edef\pgfplots at loc@TMPc{ \pgf at sys@tonumber\pgf at xa}%
 				\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots at loc@TMPc}\to\pgfplots at bounds@accum%
 			\fi
@@ -786,7 +1878,7 @@
 		\let\pgfplots at loc@TMPa=\cdata
 		\advance\c at pgf@counta by1
 	}%
-	\if 0\pgfplots at order
+	\if1\b at pgfplots@extra at interval
 		% add an artificial interval.
 		\edef\pgfplots at loc@TMPd{%
 			<<
@@ -797,10 +1889,15 @@
 			>>
 		}%
 		\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots at loc@TMPd}\to\pgfplots at resultaccum
-		\pgf at xa=\pgf at x
 		\advance\c at pgf@counta by-1 %
-		\multiply\pgf at xa by\c at pgf@counta\relax
-		\divide\pgf at xa by1000 % we want [ 0 1 ] not [0 1000] as domain XXX : why!?
+		\pgfplotscolormapifisuniform{#1}{%
+			\pgf at xa=\pgf at x
+			\multiply\pgf at xa by\c at pgf@counta\relax
+		}{%
+			\pgfplotsarrayselect{\c at pgf@counta}\of{pgfpl at cm@#1 at X}\to\pgfplots at loc@TMPc
+			\pgf at xa=\pgfplots at loc@TMPc\pgf at x%
+		}%
+		\divide\pgf at xa by\pgfplotscolormappdfmax at inv\relax% we want [ 0 1 ] not [0 1000] as domain XXX : why!?
 		\edef\pgfplots at loc@TMPc{ \pgf at sys@tonumber\pgf at xa}%
 		\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots at loc@TMPc}\to\pgfplots at bounds@accum%
 		\pgfplotsapplistXpushback{ 0 1}\to\pgfplots at encode@accum%
@@ -865,7 +1962,13 @@
 	\c at pgf@counta=0
 	\let#3=\pgfutil at empty
 	\pgfplotsarrayforeachungrouped{pgfpl at cm@#1}\as\pgfplotscolormaptoshadingspec at TMP{%
-		\pgf at yb=\c at pgf@counta\pgf at ya
+		\pgfplotscolormapifisuniform{#1}{%
+			\pgf at yb=\c at pgf@counta\pgf at ya
+		}{%
+			\pgfplotsarrayselect\c at pgf@counta\of{pgfpl at cm@#1 at X}\to\pgfplots at loc@TMPd
+			\pgfmathmultiply@{\pgfplots at loc@TMPd}{\pgfplots at loc@TMPb}%
+			\pgf at yb=\pgfmathresult pt %
+		}%
 		\edef\pgfplots at colspace{\csname pgfpl at cm@#1 at 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 at float=\pgfmathresult
 
 \def\pgfplotscolormapgetcolorspace#1{%
 	\edef\pgfplotsretval{\csname pgfpl at cm@#1 at colspace\endcsname}%
@@ -952,17 +2057,22 @@
 }%
 \def\pgfplotscolormapfind at precomputed[#1:#2][#3]#4#5{%
 	\ifpgfplots at LUA@supported
-		\edef\pgfmathresult{%
-			\pgfplotsutil at directlua{%
-				pgfplots.texColorMapPrecomputed("#5", #1,#2,#4)
+		\pgfplotscolormapifisuniform{#5}{%
+			\edef\pgfmathresult{%
+				\pgfplotsutil at directlua{%
+					pgfplots.texColorMapPrecomputed("#5", "#1","#2","#4")
+				}%
 			}%
+			\ifx\pgfmathresult\pgfutil at empty
+				\pgfplotscolormapfind at precomputed@warn at LUA{#5}%
+				\pgfplotscolormapfind at 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 at precomputed@[#1:#2][#3]{#4}{#5}%
 		}%
-		\ifx\pgfmathresult\pgfutil at empty
-			\pgfplotscolormapfind at precomputed@warn at LUA{#5}%
-			\pgfplotscolormapfind at precomputed@[#1:#2][#3]{#4}{#5}%
-		\else
-			%\message{LUA colormapfind[#1:#2](#4)(#5) = \pgfmathresult^^J}%
-		\fi
 	\else
 		\pgfplotscolormapfind at precomputed@[#1:#2][#3]{#4}{#5}%
 	\fi
@@ -974,33 +2084,45 @@
 		\expandafter\gdef\csname pgfplotscolormapfind at precomputed@warn at 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 at loc@TMPa.
-	\def\pgfplots at loc@TMPa{#3}%
-	\ifx\pgfplots at loc@TMPa\pgfutil at empty
-		\pgfmathsubtract@{#2}{#1}%
-		\let\pgfplots at loc@TMPb=\pgfmathresult
-		\pgfmathdivide@{\pgfplotscolormaprange}{\pgfplots at loc@TMPb}%
-		\let\pgfplots at loc@TMPa=\pgfmathresult
-	\fi
-%\message{mapping '#4' into colormap '#5' ... ^^J}%
-	\def\pgfplots at loc@samerange{0:1000}%
+\def\pgfplotscolormapfind at transform[#1:#2][#3]#4#5{%
+	\edef\pgfplots at loc@TMPa{#1:#2}%
+	\edef\pgfplots at loc@samerange{0:\pgfplotscolormaprange}%
 	\ifx\pgfplots at loc@TMPa\pgfplots at 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 at loc@TMPa.
+%\message{mapping '#4' into colormap '#5' with range [#1:#2] ... ^^J}%
+		\pgfmathfloatparsenumber{#1}%
+		\let\pgfplots at L=\pgfmathresult
+		%
+		\def\pgfplots at loc@TMPa{#3}%
+		\ifx\pgfplots at loc@TMPa\pgfutil at empty
+			\pgfmathfloatparsenumber{#2}%
+			\let\pgfplots at R=\pgfmathresult
+			\pgfmathfloatsubtract@{\pgfplots at R}{\pgfplots at L}%
+			\let\pgfplots at loc@TMPb=\pgfmathresult
+			\pgfmathfloatdivide@{\pgfplotscolormaprange at float}{\pgfplots at loc@TMPb}%
+		\else
+			\pgfmathfloatparsenumber{#3}%
+		\fi
+		\let\pgfplots at 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 at loc@TMPa}%
+		\pgfmathfloatparsenumber{#4}%
+		\let\pgfplots at V=\pgfmathresult
+		\pgfmathfloatsubtract@{\pgfplots at V}{\pgfplots at L}%
+		\expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplots at 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 at precomputed@[#1:#2][#3]#4#5{%
 	\pgfplotscolormapassertexists{#5}%
 	\begingroup
-	\pgfplotscolormapfind@@@[#1:#2][#3]{#4}{#5}%
+	\pgfplotscolormapfind at transform[#1:#2][#3]{#4}{#5}%
+	\let\pgfplotscolormapfind at transformedx=\pgfmathresult
 	%
 	% Now, we have it in [0,1000]. Find the correct interval:
-	\let\pgfplotscolormapfind at transformedx=\pgfmathresult
-	\pgfmathmultiply@{\pgfplotscolormapfind at transformedx}{\csname pgfpl at cm@#5 at invh\endcsname}%
-	\let\pgfplotscolormapfind at transformedx@divh=\pgfmathresult
-	\expandafter\pgfmathfloor@\expandafter{\pgfmathresult}%
-	% assign \pgfplotscolormapfind at intervalno := \pgfmathresult
-	% without '.0' suffix:
-	\def\pgfplots at discardperiod##1.##2\relax{\def\pgfplotscolormapfind at intervalno{##1}}%
-	\expandafter\pgfplots at discardperiod\pgfmathresult\relax
-	% Step 2: interpolate the desired RGB value using vector valued
-	% interpolation on the identified interval.
-	\c at pgf@counta=\pgfplotscolormapfind at intervalno\relax
+	\pgfplotscolormapifisuniform{#5}{%
+		\pgfmathmultiply@{\pgfplotscolormapfind at transformedx}{\csname pgfpl at cm@#5 at invh\endcsname}%
+		\let\pgfplotscolormapfind at transformedx@divh=\pgfmathresult
+		% assign \pgfplotscolormapfind at intervalno := \pgfmathresult
+		% without '.0' suffix:
+		\expandafter\pgfplotscolormap at floor@unforgiving\pgfmathresult\relax
+		% Step 2: interpolate the desired RGB value using vector valued
+		% interpolation on the identified interval.
+		\c at pgf@counta=\pgfplotscolormapfind at 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 at transformedx@divh}{\pgfplotscolormapfind at intervalno}%
+		\let\pgfplots at loc@factor=\pgfmathresult
+	}{%
+		\pgfplotsarraybinarysearch{pgfpl at cm@#5 at X}{\pgfplotscolormapfind at transformedx}{0}{\pgfplotscolormapsizeof{#5}}%
+		\c at pgf@counta=\pgfplotsretval\relax
+		\ifnum\c at pgf@counta<0
+			% as per definition of \pgfplotsarraybinarysearch, a
+			% negative result indicates the "insertion point" ...
+			\c at pgf@counta=-\c at pgf@counta
+			% ... plus one.
+			\advance\c at pgf@counta by-1
+			%
+			% But we do not WANT the insertion point! We want the LEFT
+			% interval boundary!
+			\advance\c at 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 at pgf@counta\of{pgfpl at cm@#5 at X}\to\pgfplotscolormapfind at rgb@X at left
+		\advance\c at pgf@counta by1
+		\ifnum\c at pgf@counta<\pgfplotsarraysizeof{pgfpl at cm@#5} %
+			% ok, we really have an interval
+			\pgfplotsarrayselect\c at pgf@counta\of{pgfpl at cm@#5 at X}\to\pgfplotscolormapfind at rgb@X at right
+			%
+			\pgfmathsubtract@{\pgfplotscolormapfind at rgb@X at right}{\pgfplotscolormapfind at rgb@X at left}%
+			\let\pgfplotscolormapfind at h=\pgfmathresult
+			\pgfmathsubtract@{\pgfplotscolormapfind at transformedx}{\pgfplotscolormapfind at rgb@X at left}%
+			\let\pgfplots at loc@TMPa=\pgfmathresult
+			\pgfmathdivide@{\pgfplots at loc@TMPa}{\pgfplotscolormapfind at h}%
+			\let\pgfplots at loc@factor=\pgfmathresult
+		\else
+			% irrelevant (not used)
+			\def\pgfplots at loc@factor{1}%
+		\fi
+		\pgfmath at smuggleone\pgfplots at loc@factor
+		\endgroup
+	}%
+	% POSTCONDITION: \c at pgf@counta is the index of the LEFT interval
+	%                and \pgfplots at loc@factor is the factor for the linear interpolation.
+	%
 %\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange]  yielded phi(#4) = \pgfplotscolormapfind at transformedx, situated in interval no \the\c at pgf@counta.^^J}%
 	\pgfplotsarrayselect\c at pgf@counta\of{pgfpl at cm@#5}\to\pgfplotscolormapfind at rgb@LEFT
 	%
 	% do the stuff which is specific to linear interpolation:
 	%
-	\pgfmathsubtract@{\pgfplotscolormapfind at transformedx@divh}{\pgfplotscolormapfind at intervalno}%
-	\let\pgfplots at loc@factor=\pgfmathresult
+	%  S = 1 - s
 	\pgfmathsubtract@{1}{\pgfplots at loc@factor}%
 	\let\pgfplots at loc@factor at two=\pgfmathresult
 	%
-	\pgfplotsarraysize{pgfpl at cm@#5}\to\c at pgf@countb
-	\advance\c at pgf@countb-1 %
-	\ifnum\c at pgf@counta<\c at pgf@countb
-		% Ah: (selected index < length-1)  . That means: we have an interval.
-		\advance\c at pgf@counta by1
+	\advance\c at pgf@counta by1 %
+	\ifnum\c at pgf@counta<\pgfplotsarraysizeof{pgfpl at cm@#5} %
+		% Ah: (selected index < length)  . That means: we have an interval.
 		\pgfplotsarrayselect\c at pgf@counta\of{pgfpl at cm@#5}\to\pgfplotscolormapfind at rgb@RIGHT
 %\message{After lookup: the corresponding RGB interval boundaries are [\pgfplotscolormapfind at rgb@LEFT: \pgfplotscolormapfind at 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 at cm@#5 at col@comps\endcsname}%
 		\pgfplotscoloraddweighted
 			{\csname pgfpl at cm@#5 at col@comps\endcsname}
@@ -1123,7 +2285,7 @@
 \def\pgfplotscolormapfindpiecewiseconst at precomputed@[#1:#2][#3]#4#5{%
 	\pgfplotscolormapassertexists{#5}%
 	\begingroup
-	\pgfplotscolormapfind@@@[#1:#2][#3]{#4}{#5}%
+	\pgfplotscolormapfind at transform[#1:#2][#3]{#4}{#5}%
 	\let\pgfplotscolormapfind at 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 at cm@#5 at invh\endcsname}{0.001}%
-	\let\pgfplots at piecewiseconst@invh=\pgfmathresult%
-	\pgfmathmultiply@{\pgfplotscolormapfind at transformedx}{\pgfplots at piecewiseconst@invh}%
-	\let\pgfplotscolormapfind at transformedx@divh=\pgfmathresult
-	\expandafter\pgfmathfloor@\expandafter{\pgfmathresult}%
-	% assign \pgfplotscolormapfind at intervalno := \pgfmathresult
-	% without '.0' suffix:
-	\def\pgfplots at discardperiod##1.##2\relax{\def\pgfplotscolormapfind at intervalno{##1}}%
-	\expandafter\pgfplots at discardperiod\pgfmathresult\relax
-	% Step 2: interpolate the desired RGB value using vector valued
-	% interpolation on the identified interval.
-	\c at pgf@counta=\pgfplotscolormapfind at intervalno\relax
+	\pgfplotscolormapifisuniform{#5}{%
+		%
+		\expandafter\ifx\csname pgfpl at cm@#5 at X@scale at order@z\endcsname\pgfutil at empty%
+			% compute 1/H here:
+			\pgfmathadd@{\csname pgfpl at cm@#5 at invh\endcsname}{0.001}%
+			\let\pgfplots at piecewiseconst@invh=\pgfmathresult%
+		\else
+			% disable the extra interval
+			\expandafter\let\expandafter\pgfplots at piecewiseconst@invh\csname pgfpl at cm@#5 at invh\endcsname
+		\fi
+		\pgfmathmultiply@{\pgfplotscolormapfind at transformedx}{\pgfplots at piecewiseconst@invh}%
+		\let\pgfplotscolormapfind at transformedx@divh=\pgfmathresult
+		% assign \pgfplotscolormapfind at intervalno := \pgfmathresult
+		% without '.0' suffix:
+		\expandafter\pgfplotscolormap at floor\pgfmathresult\relax
+		% Step 2: interpolate the desired RGB value using vector valued
+		% interpolation on the identified interval.
+		\c at pgf@counta=\pgfplotscolormapfind at 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 at cm@#5 at X@scale at 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 at cm@#5 at X@scale at order@z\endcsname pt>0pt
+			\pgfmathadd@{1000}{\csname pgfpl at cm@#5 at h\endcsname}%
+			\pgf at xa=\pgfmathresult pt %
+			\divide\pgf at xa by1000 %
+			\edef\pgfplotscolormapfind at map@to at extra@interval{\pgf at sys@tonumber\pgf at xa}%
+			%
+			\pgfmathmultiply@{\pgfplotscolormapfind at transformedx}{\pgfplotscolormapfind at map@to at extra@interval}%
+			\let\pgfplotscolormapfind at transformedx@=\pgfmathresult
+		\else
+			% disable the extra interval
+			\let\pgfplotscolormapfind at transformedx@=\pgfplotscolormapfind at transformedx
+		\fi
+		%
+		% search k(t) in the original X values.
+		\pgfplotsarraybinarysearch{pgfpl at cm@#5 at X}{\pgfplotscolormapfind at transformedx@}{0}{\pgfplotscolormapsizeof{#5}}%
+		\c at pgf@counta=\pgfplotsretval\relax
+		\ifnum\c at pgf@counta<0
+			% as per definition of \pgfplotsarraybinarysearch, a
+			% negative result indicates the "insertion point" ...
+			\c at pgf@counta=-\c at pgf@counta
+			% ... plus one.
+			\advance\c at pgf@counta by-1
+			%
+			% But we do not WANT the insertion point! We want the LEFT
+			% interval boundary!
+			\advance\c at pgf@counta by-1
+		\fi
+%\pgfplotscolormapserializeXtomacro{#5}\XXX
+%\message{k(\pgfplotscolormapfind at transformedx) = \pgfplotscolormapfind at transformedx@. Searching for value in X=(\XXX) resulted in \pgfplotsretval, and the index to use is \the\c at pgf@counta.^^J}%
+	}%
 	%
 	\ifnum\c at pgf@counta=\pgfplotscolormapsizeof{#5}\relax
 		% we have artificially increased the "h" (see the comments
@@ -1169,7 +2389,7 @@
 		\advance\c at pgf@counta by-1
 	\fi
 	%
-%\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange]  yielded phi(#4) = \pgfplotscolormapfind at transformedx, situated in interval no \the\c at pgf@counta.^^J}%
+%\message{mapping [#1,#2] -> [0,\pgfplotscolormaprange]  yielded phi = \pgfplotscolormapfind at transformedx, situated in interval no \the\c at pgf@counta/\pgfplotsarraysizeof{pgfpl at cm@#5}.^^J}%
 	\pgfplotsarrayselect\c at pgf@counta\of{pgfpl at cm@#5}\to\pgfplotscolormapfind at rgb@LEFT
 	\let\pgfmathresult=\pgfplotscolormapfind at rgb@LEFT
 	\pgfmath at smuggleone\pgfmathresult
@@ -1176,7 +2396,21 @@
 	\endgroup
 }%
 
+\def\pgfplotscolormap at floor#1.#2\relax{%
+	\ifdim0.#2pt>0.999pt
+		% ok, it is ALMOST one more! Take this as rounding inaccuracy
+		\c at pgf@counta=#1\relax
+		\advance\c at pgf@counta by1
+		\edef\pgfplotscolormapfind at intervalno{\the\c at pgf@counta}%
+	\else
+		\def\pgfplotscolormapfind at intervalno{#1}%
+	\fi
+}%
 
+\def\pgfplotscolormap at floor@unforgiving#1.#2\relax{%
+	\def\pgfplotscolormapfind at 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 at gobble@until at relax
-	\c at pgf@counta=#1\relax
+	\pgfmathfloatparsenumber{#1}%
+	\expandafter\pgfmathfloattoint\expandafter{\pgfmathresult}%
+	%\afterassignment\pgfplots at gobble@until at relax
+	\c at pgf@counta=\pgfmathresult\relax
 	\ifnum\c at pgf@counta<0
 		\c at pgf@counta=0
 	\else
@@ -1231,7 +2467,6 @@
 	\fi
 }%
 
-
 \pgfutil at 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)}

Modified: trunk/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex	2016-08-11 21:43:18 UTC (rev 41838)
@@ -65,6 +65,22 @@
 	\pgfplotslistnew#1{#2}%
 }%
 
+\def\pgfplots at shellescape@lua at eightseven#1{%
+	\pgfplotsutil at directlua{os.execute("\pgfplotsutil at luaescapestring{#1}")}%
+}%
+\def\pgfplots at shellescape#1{%
+	\immediate\write18{#1}%
+}%
+\pgfutil at IfUndefined{directlua}{%
+}{%
+	\pgfutil at IfUndefined{lastsavedimageresourcepages}{%
+		\pgfplots at log3{Found old luatex which supports write18 (shell-escape)}%
+	}{%
+		\pgfplots at log3{Found new luatex: initializing lua commands instead of write18 (shell-escape)}%
+		\let\pgfplots at shellescape=\pgfplots at shellescape@lua at eightseven
+	}%
+}%
+
 % Sets the boolean \ifpgfplots at is@old at 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 at h=\pgfmathresult
+			\pgfmathparse{(##4-##2)/\pgfplots at h + 1}%
+			\pgfmathfloattofixed\pgfmathresult
+			\afterassignment\pgfplotsforeachtodomain@@
+			\c at pgf@counta=\pgfmathresult
+		}%
+		\edef\pgfplots at loc@TMPa{\noexpand\pgfplotsforeachungrouped \noexpand\x\space in{#1}{}}%
+		\pgfplots at loc@TMPa
+		%
+		\xdef\pgfplots at glob@TMPa{%
+			\noexpand\def\noexpand\pgfplotsretval{\pgfplotsretval}%
+			\noexpand\def\noexpand\pgfplotsretvalb{\pgfplotsretvalb}%
+		}%
+	\endgroup
+	\pgfplots at glob@TMPa
+}%
+
+\def\pgfplotsforeachtodomain@@.#1\relax{%
+	\pgf at xa=0.#1pt %
+	\ifnum\pgf at 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 at pgf@counta}%
+	\fi
+}%
+
 \long\def\pgfplotsforeachungrouped@@#1#2#3#4{%
 	\pgfplots at for@reset at break{%
 		%

Modified: trunk/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty	2016-08-11 21:42:45 UTC (rev 41837)
+++ trunk/Master/texmf-dist/tex/latex/pgfplots/pgfplots.sty	2016-08-11 21:43:18 UTC (rev 41838)
@@ -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 at glob@TMPa{luatex.def}%
+	\edef\pgfplots at glob@TMPb{\Gin at driver}%
+	\ifx\pgfplots at glob@TMPb\pgfplots at 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 at glob@TMPa{pgfsys-luatex.def}%
+			\ifx\pgfsysdriver\pgfplots at 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 at IfUndefined . I copied it here



More information about the tex-live-commits mailing list