如何使用 TiKz 在 3D 数组的轴上写入显示的名称

如何使用 TiKz 在 3D 数组的轴上写入显示的名称

我正在绘制一个像附图这样的 3D 数组,它实际上描述了一个多维数组。但是,我无法像附图那样放置轴的名称并从矩阵中获取值。 在此处输入图片描述 这是我的代码:

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}

\begin{document}
\begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=1.4cm,minimum height=7mm}]
\matrix (mA) [draw,matrix of math nodes]
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};

\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(1.5,0.7)$)
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};

\matrix (mC) [draw,matrix of math nodes] at ($(mB.south west)+(1.5,0.7)$)
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};

\draw[dashed](mA.north east)--(mC.north east);
\draw[dashed](mA.north west)--(mC.north west);
\draw[dashed](mA.south east)--(mC.south east);
\end{tikzpicture}


\end{document}

答案1

每个矩阵都是一个节点,并且具有通常的锚点,因此只需将节点相对于这些锚点放置即可。

要突出显示矩阵中的特定节点,请将选项添加到该单元格|[<options>]|的开头。

代码输出

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}

\begin{document}
\begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=1.4cm,minimum height=7mm}]
\matrix (mA) [draw,matrix of math nodes]
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};

\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(1.5,0.7)$)
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};

\matrix (mC) [draw,matrix of math nodes] at ($(mB.south west)+(1.5,0.7)$)
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & |[draw=red]|(1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};

\draw[dashed](mA.north east)--(mC.north east);
\draw[dashed](mA.north west)-- node[sloped,above] {Number} (mC.north west);
\draw[dashed](mA.south east)--(mC.south east);

\node [above left] at (mC.north) {Column};
\node [left] at (mC.west) {Row};

\draw (mC-2-3) to[out=260,in=200] ++(5cm,-1cm) node[right] {$(1,1,3)$};
\end{tikzpicture}
\end{document}

相关内容