# Visualising a matrix as an image, or specifying directly values for segments rather than for vertices [duplicate]

I'm trying to use pgfplots to visualise a matrix using \addplot3[surf] and view={0}{90}. However, pgfplots colours each segment based on the value at the vertices, so that input coordinates in a 3x3-matrix result in only 2*2=4 coloured segments:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5.1}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={0}{90},
width=4cm,
height=4cm,
colorbar right]
\addplot3[surf] coordinates {
(0,0,0) (0,1,1) (0,2,2)

(1,0,1) (1,1,2) (1,2,4)

(2,0,2) (2,1,4) (2,2,8)
};
\end{axis}
\end{tikzpicture}
\end{document}


This results in:

Is there a way to specify the colours of the segments directly for an image-view of a matrix?

• I already wrote the question, then discovered it's a duplicate, however, having a duplicate question may make it easier for others to find it. – gerrit Oct 22 '12 at 13:52