\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}

\pagestyle{empty}

\long\def\matlabtestimg#1{%
	\IfFileExists{patchplots/#1}{%
		\includegraphics[width=10cm]{patchplots/#1}%
	}{%
		Matlab Test file `#1' does not exist, sorry. Run Matlab  on \texttt{patch\_plot\_example.m}.
	}%

	\nobreak
}
\begin{document}

\input patchplots/patchplottestcolormap.tex

\subsection{Solid color}
Matlab:

\message{IF THIS HERE CAUSES AN ERROR, CALL patch_plot_example.m in MATLAB }

\matlabtestimg{plot1.png}

PGFPlots:

\begin{tikzpicture}
	\begin{axis}
		\addplot[surf,point meta=\thisrow{c},mesh input=patches] table {patchplots/plot1.dat};
	\end{axis}
\end{tikzpicture}

\subsection{Interpolated colors, separate for each patch}
Matlab:

\matlabtestimg{plot2.png}

PGFPlots:

\begin{tikzpicture}
	\begin{axis}
		\addplot[surf,point meta=\thisrow{c},mesh input=patches,shader=interp] table {patchplots/plot2.dat};
	\end{axis}
\end{tikzpicture}

\subsection{Interpolated colors, continous over edges}
Matlab:

\matlabtestimg{plot3.png}

PGFPlots:


\begin{tikzpicture}
	\begin{axis}
		\addplot[surf,point meta=\thisrow{c},mesh input=patches,shader=interp] table {patchplots/plot3.dat};
		\addplot[mesh,ultra thin,draw=black,point meta=\thisrow{c},mesh input=patches] table {patchplots/plot3.dat};
	\end{axis}
\end{tikzpicture}

\subsection{3D}
Matlab:

\matlabtestimg{plot4.png}

PGFPlots:

\begin{tikzpicture}
	\begin{axis}[view={-37.5}{30}]
		\addplot3[surf,point meta=\thisrow{c},mesh input=patches] table {patchplots/plot4.dat};
	\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
	\begin{axis}[view={-37.5}{30}]
		\addplot3[surf,point meta=\thisrow{c},mesh input=patches,shader=interp] table {patchplots/plot4.dat};
	\end{axis}
\end{tikzpicture}

\subsection{3D smooth}
Matlab:

\matlabtestimg{plot5.png}

PGFPlots:

\begin{tikzpicture}
	\begin{axis}[view={-37.5}{30}]
		\addplot3[surf,point meta=\thisrow{c},mesh input=patches] table {patchplots/plot5.dat};
	\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
	\begin{axis}[view={-37.5}{30}]
		\addplot3[surf,point meta=\thisrow{c},mesh input=patches,shader=faceted interp,faceted color=black] table {patchplots/plot5.dat};
	\end{axis}
\end{tikzpicture}
\end{document}

