\documentclass{article}
% translate with >> pdflatex -shell-escape <file>

% This file is used as unit test for pgfplots, copyright by Christian Feuersaenger.
% 
% See
%   http://pgfplots.sourceforge.net/pgfplots.pdf
% for pgfplots.
%
% Any required input files (for <plot table> or <plot file> or the table package) can be downloaded
% at
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/
% and
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/plotdata/

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\pagestyle{empty}

\begin{document}
Experiment:
\begin{itemize}
	\item Define a color map,
	\item convert it back to a shading; draw that shading,
	\item for a set of sample points, map them linearly into the color map and draw small ``tick'' lines over the shading.
\end{itemize}

The test PASSES IF AND ONLY IF: the shading and the ``tick'' lines have the same color.

Color spec: {rgb(0cm)=(1,0,0); rgb(2cm)=(0,0.5,0);  gray(4cm)=(0.2);  color(6cm)=(green); }

\pgfplotscreatecolormap{my map}{rgb(0cm)=(1,0,0); rgb(2cm)=(0,0.5,0);  gray(4cm)=(0.2);  color(6cm)=(green); }

\def\LENGTH{300}

\pgfplotscolormaptoshadingspec{my map}{\LENGTH pt}\temp
\def\tempb{\pgfdeclarehorizontalshading{myshadingA}{1cm}}
\expandafter\tempb\expandafter{\temp}
\begin{tikzpicture}
	\draw (0pt,0pt) rectangle (\LENGTH pt,3cm);
	\pgftext[left,bottom,at=\pgfpoint{0pt}{0pt}]{\pgfuseshading{myshadingA}}%
	\foreach \i in {0,10,...,\LENGTH .001} {
		\pgfplotscolormapfind[0:\LENGTH]{\i}{my map}%
		\def\tempb{\definecolor{tempcolor}{rgb}}
		\expandafter\tempb\expandafter{\pgfmathresult}
		\fill[tempcolor] (\i pt,1cm) rectangle (\i pt + 2pt,2cm);
	}
\end{tikzpicture}
\end{document}
