\documentclass[a4paper]{article}

\usepackage{pgfplots}
\usepackage{pgfplots.assert}

\begin{document}

%\tracingcommands=2\tracingmacros=2


\begingroup
	\pgfplotscreatecolormap{my map}{color=(green); color=(red); color=(blue); color=(yellow)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual

	% yellow is in CMYK; we see the result of the transformation to RGB.
	\pgfplotsassertequalstok{{0.0,1.0,0.0},{1.0,0.0,0.0},{0.0,0.0,1.0},{1,1,0},}{\actual}{}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{333.33333}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}
\endgroup

\begingroup
	\pgfplotscreatecolormap{my map}{color(0cm)=(green); color(2cm)=(red); color=(blue); color=(yellow)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual

	\pgfplotsassertequalstok{{0.0,1.0,0.0},{1.0,0.0,0.0},{0.0,0.0,1.0},{1,1,0},}{\actual}{}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{333.33342}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}
\endgroup

\message{^^J^^J}

\begingroup
	\pgfplotscreatecolormap{my map}{[1cm] color=(green); color=(red); color=(blue); color=(yellow)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual


	\pgfplotsassertequalstok{{0.0,1.0,0.0},{1.0,0.0,0.0},{0.0,0.0,1.0},{1,1,0},}{\actual}{}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{333.33333}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}
\endgroup

\begingroup
	\pgfplotscreatecolormap{my map}{rgb=(0,1,0); rgb255=(0,255,0) cmyk=(0,0,0,1); cmyk255=(0,0,0,255) gray=(0)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual

	\pgfplotsassertequalstok{{0.0,1.0,0.0},{0.0,0.99998,0.0},{0,0,0},{0.00002,0.00002,0.00002},{0.0,0.0,0.0},}{\actual}{}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{250.0}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}
\endgroup

\begingroup
	\pgfplotscreatecolormap{my map}{color(0cm)=(white); color(1cm)=(orange!75!red)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual

	\pgfplotsassertequalstok{{1,1,1},{1.0,0.375,0.0},}{\actual}{}

	\csname pgfplots@colormap@showdebuginfofor\endcsname{my map}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{1000.0}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}
\endgroup

\begingroup
	\pgfplotscreatecolormap{my map}{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)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual

	\pgfplotsassertequalstok{%
		{0.0,0.0,0.50195},% 0cm
		{0.0,0.0,0.99998},% 1cm
		{0.0,0.49998,0.99997},% interpoalted 2cm
		{0.0,0.99998,0.99998},% 3cm
		{0.49998,0.99997,0.49998},% interpolated 4cm
		{0.99998,0.99998,0.0},% 5cm
		{0.99997,0.49998,0.0},% interpoalted 6cm
		{0.99998,0.0,0.0},% 7cm
		{0.50195,0.0,0.0},% 8cm
	}{\actual}{}

	\csname pgfplots@colormap@showdebuginfofor\endcsname{my map}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{125.0}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}
\endgroup

% NEW CHOICES since 1.8:
\begingroup
	\pgfkeys{/pgfplots/colormap default colorspace=rgb}
	\pgfplotscreatecolormap{my map}{HTML=(804040) hsb=(1,0.5,0.5) Hsb=(360,0.5,0.5) wave=(500)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual

	\pgfplotsassertequalstok{%
		{0.50195,0.25098,0.25098},%
		{0.5,0.25,0.25},%
		{0.5,0.25,0.25},%
		{0,1,0.49846},%
		}{\actual}{}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{333.33333}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}
\endgroup

\begingroup
	\pgfkeys{/pgfplots/colormap default colorspace=rgb}
	\pgfplotscreatecolormap{my map}{HTML(0pt)=(804040) hsb=(1,0.5,0.5) Hsb(2cm)=(360,0.5,0.5) wave=(500)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual

	\pgfplotsassertequalstok{%
		{0.50195,0.25098,0.25098},%
		{0.5,0.25,0.25},%
		{0.5,0.25,0.25},%
		{0,1,0.49846},%
		}{\actual}{}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{333.33333}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}
\endgroup
\end{document}

