标记此堆叠立方体并缩小第二个主要范围的比例

标记此堆叠立方体并缩小第二个主要范围的比例
  1. 我希望scale第二行tikzpicture比第一行小。

  2. 我想将其标记Tikzpicture为问题堆叠有间距的 3D 立方体

...

\documentclass[10pt, xcolor = {dvipsnames}]{beamer}

\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}
        \begin{scope}[local bounding box=first row]
        
            \begin{scope}[local bounding box =vector]
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            \end{scope}
        
        
            \begin{scope}[xshift=4cm, local bounding box = matrix]
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;        
            \end{scope}
        
        
            \begin{scope}[xshift=8cm, local bounding box = matrix]
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            \end{scope}
        
        \end{scope}
    
        \begin{scope}[yshift=-5.5cm,local bounding box=data frame]
        
            \begin{scope}[local bounding box =vector]
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
            \end{scope}
        
            \begin{scope}[xshift=3cm, local bounding box =vector]
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            \end{scope}
        
        
            \begin{scope}[xshift=5cm, local bounding box = matrix]
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;        
            \end{scope}
        
        
            \begin{scope}[xshift=9cm, local bounding box = matrix]
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,1.1,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (0,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (1.1,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
                \draw[white, fill = Cyan] (2.2,2.2,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            \end{scope}
        
        \end{scope}
    \end{tikzpicture}
\end{document}

我拥有的 这里是我拥有的

我想要的是

这是类似的事情我想

编辑

对我的代码进行任何您想要的更改。请不要编写不同的代码。

答案1

1. 问题

你把你tikzpicture分成了几个scope环境。要使第二行比第一行小,你只需插入scale=<factor>相应的范围。如果你想缩小这一行,因子应该是 0 到 1 之间的浮点数。所以改变这一行:

\begin{scope}[yshift=-5.5cm,local bounding box=data frame]

例如以下

\begin{scope}[yshift=-5.5cm,local bounding box=data frame, scale=.5]

2. 问题

要添加标签,您可以将节点放置在图像中的适当位置。以下是第一行向量的示例。更改此内容:

\begin{scope}[local bounding box =vector]
  \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
  \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
  \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
  \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
  \draw[white, fill = Cyan] (1.1,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
  \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
  \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
  \draw[white, fill = Cyan] (2.2,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
  \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
\end{scope}

在此

\begin{scope}[local bounding box =vector]
  \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
  \draw[white, fill = Cyan] (0,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
  \draw[white, fill = Cyan] (0,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
  \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
  \draw[white, fill = Cyan] (1.1,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
  \draw[white, fill = Cyan] (1.1,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
            
  \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
  \draw[white, fill = Cyan] (2.2,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
  \draw[white, fill = Cyan] (2.2,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;

  \node at (1,.75) {vector};% <-- added
\end{scope}

对其他标签执行相同操作。


改进代码的其他技巧

您的图片由许多以不同方式排列的立方体组成。如果想多次重复相同的操作,可以使用循环。TikZ提供foreach循环。以下是在第一行绘制矢量的简短示例。

\begin{scope}[local bounding box =vector]
  \foreach \x in {0, 1.1, 2.2} {
    \draw[white, fill = Cyan] (\x,0,0) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
    \draw[white, fill = Cyan] (\x,0,0) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
    \draw[white, fill = Cyan] (\x,0,0) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
  }
\end{scope}

如果你想阅读/了解有关foreach循环的更多信息,请查看PGF/TikZ 手册(第 88 节重复的事情:Foreach 语句)。我还建议学习如何对所有立方体使用相同的样式(请参阅cubeStyle我的优化版本)。


优化版本

\documentclass[10pt, dvipsnames]{standalone}

\usepackage{tikz}
\usepackage{xifthen}

\newcommand\drawCube[3]{%
    \draw[cubeStyle] (#1,#2,#3) -- ++(-1,0,0) -- ++(0,-1,0) -- ++(1,0,0) -- cycle;
    \draw[cubeStyle] (#1,#2,#3) -- ++(0,0,-1) -- ++(0,-1,0) -- ++(0,0,1) -- cycle;
    \draw[cubeStyle] (#1,#2,#3) -- ++(-1,0,0) -- ++(0,0,-1) -- ++(1,0,0) -- cycle;
}

\begin{document}
    \begin{tikzpicture}[
        cubeStyle/.style={
            white,
            fill=Cyan
        },
        arrowStyle/.style={
            ->,
            thick
        }
    ]
        \begin{scope}[local bounding box=first row]
            \foreach \xshift/\name [count=\c] in {0/Vector, 5/Matrix,11/Array} {%
                \begin{scope}[xshift=\xshift cm, local bounding box = \name]
                    % labels above and pins of the matrix
                    \ifthenelse{\c = 1} {
                        \node at (1,.75) {\name};
                    }{
                        \ifthenelse{\c = 2} {
                            \node at (1,3) {\name};
                            \node at (.6,-2.3) (columnsPin) {columns};
                            \draw (columnsPin)
                                edge[arrowStyle] (-0.5, -1.15)
                                edge[arrowStyle] ( 0.6, -1.15)
                                edge[arrowStyle] ( 1.7, -1.15);
                            \node at (4.3,1.1,.55) (rowsPin) {rows};
                            \draw (rowsPin)
                                edge[arrowStyle] (3,2.2,.55)
                                edge[arrowStyle] (3,1.1,.55)
                                edge[arrowStyle] (3,0,.55);
                        }{
                            \node at (4.25,6.25,6.25) {\name};
                        }
                    }

                    % draw vector, matrix or array
                    \foreach \x in {0,1.1,2.2} {%
                        \ifthenelse{\c = 1} {
                            \drawCube{\x}{0}{0}
                        }{
                            \foreach \y in {0,1.1,2.2} {%
                                \ifthenelse{\c = 2} {
                                    \drawCube{\x}{\y}{0}
                                }{
                                    \foreach \z in {2.2,1.1,0} {%
                                        \drawCube{\x}{\y}{-\z}
                                    }
                                }
                            }
                        }
                    }
                \end{scope}
            }
        \end{scope}
    
        \begin{scope}[yshift=-5cm, xshift=7cm, local bounding box=second row, scale=.55]% added scale=.5 to make the second row smaller than the first row
            \begin{scope}[local bounding box =vector]
                \foreach \x in {0,1.1} {%
                    \drawCube{\x}{0}{0}
                }
            \end{scope}
        
            \begin{scope}[xshift=3cm, local bounding box =vector]
                \foreach \y in {0,1.1,2.2} {%
                    \drawCube{0}{\y}{0}
                }
            \end{scope}

            \foreach \xshift/\name [count=\c] in {5/matrix,9/array} {%
                \begin{scope}[xshift=\xshift cm, local bounding box = \name]
                    \foreach \x in {0,1.1,2.2} {%
                        \foreach \y in {0,1.1,2.2} {%
                            \ifthenelse{\c = 1}{
                                \drawCube{\x}{\y}{0}
                            }{
                                \foreach \z in {2.2,1.1,0} {%
                                    \drawCube{\x}{\y}{-\z}
                                }
                            }
                        }
                    }
                \end{scope}
            }
        \end{scope}
    \end{tikzpicture}
\end{document}

结果

相关内容