# Using pgfplots, how do I arrange my data matrix for a surface plot so that each cell in the matrix is plotted as a square?

I have a matrix of size MxN and I want to make a surface plot directly from above so that each cell in the matrix is drawn as a square. None of the pgfplots shaders really do what I want, since they draw squares between the cells of the matrix (i.e. a 3x3 matrix ends up as 2x2 cells when plotted). The example hopefully makes it clearer:

\documentclass{article}

\usepackage{fullpage}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

0 0 0
0 1 1
0 2 2

1 0 3
1 1 4
1 2 5

2 0 6
2 1 7
2 2 8
}\data

\begin{document}
\foreach \shader in {interp, flat, flat corner} {
\begin{tikzpicture}
\begin{axis}[
title style={
at={(0.5, 1.5)},
anchor=north,
},
width=.3\linewidth,
view={0}{90},
colormap/hot2,
colorbar horizontal,
colorbar style={
at={(0.5, 1.02)},
anchor=south,
xticklabel pos=upper,
},
]
\end{axis}
\end{tikzpicture}
}
\end{document}


How do I arrange my data so that each cell in the matrix is drawn as a separate cell in the output?

EDIT: I realised after entering the question that the answer is very simple, so I'll just answer this myself.

-

Looking at the flat corner plot in the question, it becomes obvious that one solution is to use flat corner and simply add an extra dummy row and an extra dummy column to the table. Their actual values will not influence the plot since flat corner uses only the value from the point which is inside the original matrix.