Defining custom colormap

The colormap/<colormap name> stuff are predefined styles, i.e. they (i) either define the colormap itself which activates them too, or (ii) they activate them by calling them their name

\pgfplotsset{
    % (i) define the colormap and activate it
    colormap={<colormap name>}{ ... },
    % (ii) call an already defined colormap to activate it
    colormap/<colormap name>/.style={
        colormap name=<colormap name>,
    },
}

which of course you didn't do for your custom colormap. So see the comments in the following code on how you just activate it to use it either globally or locally.

% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usepgfplotslibrary{colormaps}
\pgfplotsset{
    % this *defines* a custom colormap ...
    colormap={slategraywhite}{
        rgb255=(112,128,144)
        rgb255=(255,159,101)
    },
%    % ... but this command does not *activate* a custom colormap ...
%    colormap/slategraywhite,        % <-- activate colormap
%    % this could either be done here (globally), which makes it the default
%    % used colormap, by specifying ...
%    colormap name=slategraywhite,
}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        hide axis,
        mesh/interior colormap name=hot,
        % ... or you activate it here (locally)
        colormap name=slategraywhite,
    ]
        \addplot3 [domain=-1.5:1.5,surf, shader=faceted] {-exp(-x^2-y^2)};
    \end{axis}
\end{tikzpicture}
\end{document}

image showing the result of above code


Let us see how the package author does the job:

In pgfplots.code.tex line 36 it input pgfplotscolormap.code.tex. In the later file line 2372

\pgfplotscreatecolormap{hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)}

In pgfplots.code.tex line 4019-47

/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)}
},
/pgfplots/colormap/viridis/.style={%
  /pgfplots/colormap={viridis}{%
      rgb=(0.267,0.00487,0.32942)
      rgb=(0.28192,0.08966,0.41241)
      rgb=(0.28026,0.1657,0.4765)
      rgb=(0.26366,0.23763,0.51877)
      rgb=(0.23744,0.3052,0.54192)
      rgb=(0.20862,0.36775,0.55267)
      rgb=(0.18225,0.42618,0.55711)
      rgb=(0.1592,0.48224,0.55807)
      rgb=(0.13777,0.53749,0.5549)
      rgb=(0.12115,0.59274,0.54465)
      rgb=(0.12808,0.64775,0.5235)
      rgb=(0.18065,0.7014,0.48819)
      rgb=(0.27415,0.75198,0.4366)
      rgb=(0.39517,0.79747,0.36775)
      rgb=(0.53561,0.83578,0.2819)
      rgb=(0.68895,0.86545,0.18272)
      rgb=(0.84557,0.88733,0.0997)
      rgb=(0.99324,0.90616,0.14394)
  }%
},
% instantiate viridis such that it is in memory by default:
/pgfplots/colormap/viridis,
% ... but reuse hot since it is used to be the default since the
% beginning:
/pgfplots/colormap name=hot,
%
/pgfplots/colormap/hot2/.style={
  /pgfplots/colormap={hot2}{[1cm]rgb255(0cm)=(0,0,0) rgb255(3cm)=(255,0,0) rgb255(6cm)=(255,255,0)
  rgb255(8cm)=(255,255,255)}
},
/pgfplots/colormap/bluered/.style={
  /pgfplots/colormap={bluered}{rgb255(0cm)=(0,0,180); rgb255(1cm)=(0,255,255); rgb255(2cm)=(100,255,0);
  rgb255(3cm)=(255,255,0); rgb255(4cm)=(255,0,0); rgb255(5cm)=(128,0,0)}
},
/pgfplots/colormap/cool/.style={
  /pgfplots/colormap={cool}{rgb255(0cm)=(255,255,255); rgb255(1cm)=(0,128,255); rgb255(2cm)=(255,0,255)}
},
/pgfplots/colormap/greenyellow/.style={
  /pgfplots/colormap={greenyellow}{rgb255(0cm)=(0,128,0); rgb255(1cm)=(255,255,0)}
},
/pgfplots/colormap/redyellow/.style={
  /pgfplots/colormap={redyellow}{rgb255(0cm)=(255,0,0); rgb255(1cm)=(255,255,0)}
},
/pgfplots/colormap/blackwhite/.style={
  /pgfplots/colormap={blackwhite}{gray(0cm)=(0); gray(1cm)=(1)}
},
/pgfplots/colormap/violet/.style={
  /pgfplots/colormap={violet}{rgb255=(25,25,122) color=(white) rgb255=(238,140,238)}
},
/pgfplots/colormap/jet/.style={
  /pgfplots/colormap={jet}{rgb255(0cm)=(0,0,128) rgb255(1cm)=(0,0,255) rgb255(3cm)=(0,255,255) rgb255(5cm)=(255,255,0)
  rgb255(7cm)=(255,0,0) rgb255(8cm)=(128,0,0)}
},

In English, the package does the following

  • activate hot, use hot. (only this is in pgfplotscolormap.code.tex)
  • define hot
  • define viridis
  • activate viridis, use viridis instead of hot
  • use hot instead of viridis
  • define hot2
  • define bluered
  • define cool
  • define greenyellow
  • define redyellow
  • define blackwhite
  • define violet
  • define jet

Therefore the status is

  • hot is defined, activated, and using. (Green light )
  • viridis is defined and activated. (Yellow light )
  • hot2, ..., jet are defined. (Red light )

We conclude that there are five ways to use a colormap:

  • use hot by doing nothing ()
  • use viridis by either colormap name=viridis or colormap/viridis. ()
  • use hot2, ..., jet by colormap/jet. ()
    • from the second time on, one can use colormap name=jet.
  • define a custom colormap by colormap/foo/.style={colormap={foo}{...}}.
    • And then activate and use it by colormap/foo.
    • from the second time on, one can use colormap name=foo. (beware of grouping)
  • activate a custom colormap by colormap={bar}{...}.
    • from the second time on, one can use colormap name=bar. (beware of grouping)