[Tex/LaTex] Colormap with Tikz

pgfplotstikz-pgf

What I have tried so far

\documentclass[a4paper]{article}
\usepackage{pgfplots}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}
 \begin{axis}[view={0}{90},
             colormap={custom}{color(0)=(red) color(1)=(white) color(2)=(green) color(4)=(blue)},
             colorbar,
    ]
  \addplot3[surf,shader=interp] table [row sep=newline] {

0.0000 150.0000 4.578e-10
10.0000 150.0000 4.466e-10
20.0000 150.0000 4.838e-10
30.0000 150.0000 5.657e-10
40.0000 150.0000 6.999e-10
50.0000 150.0000 7.954e-10
60.0000 150.0000 9.443e-10
70.0000 150.0000 1.116e-9
80.0000 150.0000 1.174e-9
90.0000 150.0000 1.162e-9
100.0000 150.0000 1.192e-9
110.0000 150.0000 1.207e-9
120.0000 150.0000 1.259e-9
130.0000 150.0000 1.351e-9
140.0000 150.0000 1.406e-9
150.0000 150.0000 1.432e-9
160.0000 150.0000 1.449e-9
170.0000 150.0000 1.459e-9
180.0000 150.0000 1.465e-9
190.0000 150.0000 1.462e-9
200.0000 150.0000 1.463e-9
210.0000 150.0000 1.462e-9
220.0000 150.0000 1.462e-9
230.0000 150.0000 1.461e-9
240.0000 150.0000 1.457e-9
250.0000 150.0000 1.454e-9
260.0000 150.0000 1.454e-9
270.0000 150.0000 1.456e-9
280.0000 150.0000 1.455e-9
290.0000 150.0000 1.453e-9
0.0000 160.0000 4.617e-10

};
\end{axis}
\end{tikzpicture}
\end{document}

My result is this here:

Colormap

But that is not how I would have it. It should look like this

Example 1 Colormap

Or at least like this

Example 2 Colormap

I don't know what I am doing wrong. I have a lot of points! Nine hundred columns and three rows. The rows start with 0 0 9e-10 and end with 290 290 1.3e-9.

Hopefully you can help.

Best Answer

Quoting from pgfplots.pdf:

\addplot3 has a way to decide whether a line visualization or a mesh visualization has to be done.

One has to search a little bit to find out how pgfplots does it in the case of a table input. To specify a surface, you have to tell \addplot3 which points are next to each other. The points are assumed to be in a matrix structure, i.e. \addplot3 will assume that you have m times n data points, and you have to specify m and n. Apparently, there are two possibilities:

  1. Either you need to specify m or n directly with mesh/rows or mesh/cols;
  2. or you leave empty lines in your table, to indicate where the rows end.

Example (using 2. and copy-paste data):

\begin{tikzpicture}
 \begin{axis}[view={0}{90},
             colormap={custom}{color(0)=(red) color(1)=(white) color(2)=(green) color(4)=(blue)},
             colorbar,
    ]
  \addplot3[surf,shader=interp] table [row sep=newline] {
0.0000 150.0000 4.578e-10
10.0000 150.0000 4.466e-10
20.0000 150.0000 4.838e-10
30.0000 150.0000 5.657e-10
40.0000 150.0000 6.999e-10
50.0000 150.0000 7.954e-10
60.0000 150.0000 9.443e-10
70.0000 150.0000 1.116e-9
80.0000 150.0000 1.174e-9
90.0000 150.0000 1.162e-9
100.0000 150.0000 1.192e-9
110.0000 150.0000 1.207e-9
120.0000 150.0000 1.259e-9
130.0000 150.0000 1.351e-9
140.0000 150.0000 1.406e-9
150.0000 150.0000 1.432e-9
160.0000 150.0000 1.449e-9
170.0000 150.0000 1.459e-9
180.0000 150.0000 1.465e-9
190.0000 150.0000 1.462e-9
200.0000 150.0000 1.463e-9
210.0000 150.0000 1.462e-9
220.0000 150.0000 1.462e-9
230.0000 150.0000 1.461e-9
240.0000 150.0000 1.457e-9
250.0000 150.0000 1.454e-9
260.0000 150.0000 1.454e-9
270.0000 150.0000 1.456e-9
280.0000 150.0000 1.455e-9
290.0000 150.0000 1.453e-9

0.0000 160.0000 4.617e-10
10.0000 160.0000 4.466e-10
20.0000 160.0000 4.838e-10
30.0000 160.0000 5.657e-10
40.0000 160.0000 6.999e-10
50.0000 160.0000 7.954e-10
60.0000 160.0000 9.443e-10
70.0000 160.0000 1.116e-9
80.0000 160.0000 1.174e-9
90.0000 160.0000 1.162e-9
100.0000 160.0000 1.192e-9
110.0000 160.0000 1.207e-9
120.0000 160.0000 1.259e-9
130.0000 160.0000 1.351e-9
140.0000 160.0000 1.406e-9
150.0000 160.0000 1.432e-9
160.0000 160.0000 1.449e-9
170.0000 160.0000 1.459e-9
180.0000 160.0000 1.465e-9
190.0000 160.0000 1.462e-9
200.0000 160.0000 1.463e-9
210.0000 160.0000 1.462e-9
220.0000 160.0000 1.462e-9
230.0000 160.0000 1.461e-9
240.0000 160.0000 1.457e-9
250.0000 160.0000 1.454e-9
260.0000 160.0000 1.454e-9
270.0000 160.0000 1.456e-9
280.0000 160.0000 1.455e-9
290.0000 160.0000 1.453e-9

};
\end{axis}
\end{tikzpicture}

final heatmap