使用 matlab2tikz 创建冲浪图时出错

使用 matlab2tikz 创建冲浪图时出错

我正在使用 matlab2tikz 为我的图形生成 tikz 代码。当使用下面的图形代码编译文档时,我收到错误:

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

现在真正让我感到困惑的是,当我用另一个数据集生成相同的图形时,它工作得很好!据我所知,除了包含的数据点外,实际的 tikz 代码是相同的。第二个数据集图形中的什么原因导致它在编译时失败?

我更新了 Mixtex 中的所有软件包,但似乎没什么用。如果您能告诉我我做错了什么,我将不胜感激,因为我越来越急切地想找到问题所在。

图1,工作

\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]

\addplot3[%
surf,
colormap={mymap}{[1pt] rgb(0pt)=(0,1,1); rgb(63pt)=(1,0,1)},
shader=faceted,
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}%

图 2,不起作用

\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]

\addplot3[%
surf,
colormap={mymap}{[1pt] rgb(0pt)=(0,1,1); rgb(63pt)=(1,0,1)},
shader=faceted,
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}%

答案1

这只是颜色图定义中的一个错误。

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

尝试用以下方法修复它:

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

相关内容