Plot a matrix of real values with TikZ/PGF like imshow in matlab

How can I plot a matrix of real values with TikZ/PGF such that it looks like plotted with imshow in MATLAB?

\addplot3 does something similar, but I'd like to have that in a color-coded 2D plot.

There's a problem with @Christian's first answer: It does not work for data matrices. In that case, the values get mapped at the corners of each squares, and the colors are some interpolation between adjacent data values, not the values themselves. I found the following solution. It's not completely satisfactory since the size of the marks does not adapt to the size of the picture, but it's a start. You can also have empty values, as shown in the example.

\begin{tikzpicture}
\begin{axis}[
width=0.75\textwidth, height=0.75\textwidth,
tick align=inside, unbounded coords=jump,
xmin=-1, xmax=5, ymin=-1, ymax=5,
point meta min=0, point meta max=8, colorbar, colormap/bluered]
mark size=17]
coordinates {
(0,0) 
(0,1) 
(0,2) 
(0,3) 
(0,4) 

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

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

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

(4,0) 
(4,1) 
(4,2) 
(4,3) 
(4,4) 
};
\end{axis}
\end{tikzpicture} The following does the job very well:

\begin{tikzpicture}
\begin{axis}[view={0}{90},
xlabel=$x$,
ylabel=$y$,
title=View from top]
\end{axis}
\end{tikzpicture}

• The tick does not align to the middle of rectangle in this approach. – Dilawar Jun 14 '18 at 7:00

I hacked a solution by my own, using a scatter plot. The key here is to adjust x and y, and the mark size to the right values.

\begin{tikzpicture}[]
\begin{axis}[x=4mm,y=4mm,xtick=\empty,ytick=\empty]