\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=1.4}
\usepgfplotslibrary{patchplots}

\pagestyle{empty}

\begin{document}
\pgfplotsset{show nodes/.style={nodes near coords=\coordindex,nodes near coords align={center}}}
	\newcommand\BILINEARSHAPE[5]{%
		\begin{tikzpicture}
			\begin{axis}[title={PGFPlots bilinear (#5)},shader=#5]
			\addplot3[patch,patch type=bilinear] coordinates {
				(0,0,#1)	
				(1,0,#2)
				(1,1,#3)
				(0,1,#4) 
			};
			\end{axis}
		\end{tikzpicture}
%
	}
	\newcommand\BILINEARSHAPES[1]{%
		\noindent
		\BILINEARSHAPE1000{#1}%
		\BILINEARSHAPE0100{#1}%

		\noindent
		\BILINEARSHAPE0010{#1}%
		\BILINEARSHAPE0001{#1}%
	}%
	\subsection{Shape Functions}
	{
		\subsubsection{interpolated}
		{
			\BILINEARSHAPES{interp}
		}%

		\subsubsection{refined}
		{
			\BILINEARSHAPES{faceted interp,patch refines=1}
		}

		\subsubsection{triangulated}
		{
			\BILINEARSHAPES{faceted interp,patch to triangles}
		}
	}
\end{document}
