# Error when creating a surf plot with matlab2tikz

I'm using matlab2tikz to generate the tikz code for my figures. When compiling the document with the figure code as below, i get an error:

Package pgfplots Error: No such element: \pgfplotsarrayselect64\of{pgfpl@cm@mymap}


Now what really bugles my mind is that when i am generating the same figure with another dataset, it works perfectly fine! And as fare as i can see, the actual tikz code is identical except for the data points included. What on earth in the second data-set figure makes it fail when compiling?

I updated all packages in Mixtex, but that didn't seem to do much. Any idea's as to what i am doing wrong would be greatly appreciated as i am becoming increasingly desperate to find the issue.

Fig1, Working

\begin{tikzpicture}
\begin{axis}[%
view={45}{35},
width=\figurewidth,
height=\figureheight,
scale only axis,
xmin=0.1, xmax=1,
xtick={0.1,1},
xlabel={kh},
xmajorgrids,
ymin=10, ymax=80,
ytick={10,80},
ylabel={HLmax},
ymajorgrids,
zmin=1, zmax=4,
ztick={1,2,3,4},
zlabel={Iteratons},
zmajorgrids,
axis lines*=left]

surf,
colormap={mymap}{[1pt] rgb(0pt)=(0,1,1); rgb(63pt)=(1,0,1)},
draw=black]
coordinates{
(0.1,10,1)(0.1,20,1)(0.1,30,1)(0.1,40,1)(0.1,50,1)(0.1,60,1)(0.1,70,1)(0.1,80,1)

(0.2,10,1)(0.2,20,1)(0.2,30,1)(0.2,40,1)(0.2,50,1)(0.2,60,1)(0.2,70,1)(0.2,80,1)

(0.3,10,1)(0.3,20,1)(0.3,30,1)(0.3,40,1)(0.3,50,1)(0.3,60,1)(0.3,70,1)(0.3,80,1)

(0.4,10,1)(0.4,20,1)(0.4,30,1)(0.4,40,1)(0.4,50,1)(0.4,60,1)(0.4,70,1)(0.4,80,1)

(0.5,10,1)(0.5,20,1)(0.5,30,1)(0.5,40,1)(0.5,50,1)(0.5,60,1)(0.5,70,1)(0.5,80,1)

(0.6,10,1)(0.6,20,1)(0.6,30,1)(0.6,40,1)(0.6,50,1)(0.6,60,1)(0.6,70,1)(0.6,80,1)

(0.7,10,1)(0.7,20,1)(0.7,30,1)(0.7,40,1)(0.7,50,1)(0.7,60,1)(0.7,70,1)(0.7,80,1)

(0.8,10,1)(0.8,20,1)(0.8,30,1)(0.8,40,1)(0.8,50,1)(0.8,60,1)(0.8,70,1)(0.8,80,1)

(0.9,10,1)(0.9,20,1)(0.9,30,1)(0.9,40,1)(0.9,50,1)(0.9,60,1)(0.9,70,1)(0.9,80,1)

(1,10,1)(1,20,1)(1,30,1)(1,40,1)(1,50,1)(1,60,1)(1,70,1)(1,80,1)

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


Fig 2, not working

\begin{tikzpicture}

\begin{axis}[%
view={45}{35},
width=\figurewidth,
height=\figureheight,
scale only axis,
xmin=0.1, xmax=1,
xtick={0.1,1},
xlabel={kh},
xmajorgrids,
ymin=10, ymax=80,
ytick={10,80},
ylabel={HLmax},
ymajorgrids,
zmin=1, zmax=4,
ztick={1,2,3,4},
zlabel={Iteratons},
zmajorgrids,
axis lines*=left]

surf,
colormap={mymap}{[1pt] rgb(0pt)=(0,1,1); rgb(63pt)=(1,0,1)},
draw=black]
coordinates{
(0.1,10,2)(0.1,20,2)(0.1,30,2)(0.1,40,3)(0.1,50,3)(0.1,60,3)(0.1,70,3)(0.1,80,3)

(0.2,10,2)(0.2,20,2)(0.2,30,2)(0.2,40,2)(0.2,50,2)(0.2,60,3)(0.2,70,3)(0.2,80,3)

(0.3,10,2)(0.3,20,2)(0.3,30,2)(0.3,40,2)(0.3,50,2)(0.3,60,2)(0.3,70,3)(0.3,80,3)

(0.4,10,2)(0.4,20,2)(0.4,30,2)(0.4,40,2)(0.4,50,2)(0.4,60,2)(0.4,70,3)(0.4,80,3)

(0.5,10,2)(0.5,20,2)(0.5,30,2)(0.5,40,2)(0.5,50,2)(0.5,60,2)(0.5,70,3)(0.5,80,3)

(0.6,10,1)(0.6,20,1)(0.6,30,2)(0.6,40,2)(0.6,50,2)(0.6,60,2)(0.6,70,3)(0.6,80,3)

(0.7,10,1)(0.7,20,1)(0.7,30,1)(0.7,40,2)(0.7,50,2)(0.7,60,2)(0.7,70,3)(0.7,80,3)

(0.8,10,1)(0.8,20,1)(0.8,30,1)(0.8,40,2)(0.8,50,2)(0.8,60,2)(0.8,70,3)(0.8,80,3)

(0.9,10,1)(0.9,20,1)(0.9,30,1)(0.9,40,1)(0.9,50,2)(0.9,60,2)(0.9,70,3)(0.9,80,3)

(1,10,1)(1,20,1)(1,30,1)(1,40,1)(1,50,2)(1,60,2)(1,70,3)(1,80,3)

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

-

It's just an error in the colormap definition.

colormap={mymap}{[1pt] rgb(0pt)=(0,1,1); rgb(63pt)=(1,0,1)},


Try to fix it with:

colormap ={mymap}{rgb(0pt)=(0,1,1); rgb(63pt)=(1,0,1)},

-
You are my hero –  Allan Aug 3 '12 at 15:24
@bersanri Good analysis: your fix is slightly faster, uses less memory, and avoids the problem of the [1pt] variant. In addition, you identified a bug in pgfplots: it should have worked with both variants. –  Christian Feuersänger May 25 '13 at 11:33