10

I need to visualize 3D matrix in a way similar to this one: enter image description here

There are no arrows needed, I only want to have all 2D arrays fully visible, one "behind" each other and their corners connected by lines.

Is there any macro/simple way to do this?

1

2 Answers 2

5

Here is one implementation using loops. The work around required for putting matrix inside a loop is taken from ( Problem with defining shortcuts for TikZ matrices. ) and ( Why is my \matrix path failing when put inside another macro? )

Some changes required to make the numbering/indexing scheme one-to-one with the given picture.

\documentclass[tikz]{standalone}

\begin{document}

\begin{tikzpicture}
\def\xs{1} %shift in x direction
\def\ys{0.5} %shift in y direction
\def\nm{5} % number of 2d matrices in the 3d matrix
\foreach \x in {1,2,...,\nm}
{

\matrix [draw, % for the rectangle border
         fill=white, % so that it is not transparent
         ampersand replacement=\&] %see explanation
(mm\x)%give the matrix a name
at(-\x * \xs, -\x * \ys) %shift the matrix
{
    \node {(\x,1,1)}; \& \node {(\x,1,2)};\\
    \node {(\x,2,1)}; \& \node {(\x,2,2)};\\
};
}

\draw [dashed,gray](mm1.north west) -- (mm\nm.north west);
\draw [dashed,gray](mm1.north east) -- (mm\nm.north east);
\draw [dashed,gray](mm1.south east) -- (mm\nm.south east);
\end{tikzpicture}
\end{document}

matrices using loops

10

First attempt with tikz and matrix library

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

Output

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .