Latex 中数据立方体的后续问题

Latex 中数据立方体的后续问题

这个问题必须被视为这个问题的后续问题:

是否可以通过合理的努力在 Latex 中生成数据立方体?

根据@Qrrbrbirlbel 发布的代码,我做了一些更改,代码如下:

    \documentclass{article}
\usepackage{tikz}


\usetikzlibrary{matrix,paths.ortho,calc,paths.rectangle,positioning-plus}

\tikzset{if/.code n args=3{\pgfmathparse{#1}\ifnum\pgfmathresult=0 
        \pgfkeysalso{#3}\else\pgfkeysalso{#2}\fi}}
\tikzset{local cs/.style n args=4{shift={(#1)}, x=($(#2)-(#1)$),
        xslant={#3}, yscale={#4}}}

\tikzstyle{none}= [dash pattern=on 0\pgflinewidth]

\begin{document}\sffamily
    \begin{tikzpicture}[
    tight matrix/.style={
        matrix of nodes, inner sep=+0pt, outer sep=+0pt,
        every cell/.append style={
            every node/.append style={
                outer sep=+0pt,
                inner xsep=+.1em,
                inner ysep=+.3333em, % default (overwritten by matrix inner sep)
                align=center,
                text depth=+0pt, % depth("y"),
                text height=height("M"),
                text width=width("MMM-00-00"), % possibly other approaches
            }}},
            desc/.style={/utils/exec=\scriptsize}, % font key is not perfect
            continent/.style={
                desc, align=center, anchor=east, font=\bfseries},
            hemi/.style={desc, align=center, text width=width("Property C"), font=\bfseries},
            route/.style={desc, font=\bfseries},
            Route/.style={font=\bfseries},
            ]

            % The matrix
            \matrix[tight matrix, draw] (m) {
                Property A  & Property A   & Property A  \\
                Property B  & Property B   & Property B \\
                Property A  & Property A   & Property A  \\
                Property B  & Property B   & Property B \\
                Property A  & Property A   & Property A  \\
                Property B  & Property B   & Property B \\
            };

% The 3D
\tikzset{my cs/.style={local cs={m.north west}{m.north east}{1}{2}}}
\begin{scope}[my cs]
\draw (0,0) rectangle (1,1)
\foreach \i in {1,...,9}{
    coordinate[pos=1+\i/8/3] (tl-\i)}
(m.south east) -- ++ (up:1) -- (1,1);
\end{scope}

% The lines
\foreach \c in {1,2,3} 
\draw[my cs] (m-6-\c.south east) -- (m-1-\c.north east) -- ++ (up:1);


\foreach \c in {1,...,5} 
\draw[if={isodd(\c)}{densely dashed}{}, my cs] 
(m-\c-1.south west) -- (m-\c-3.south east) -- ++(up:1);


\foreach \c in {1,...,4} 
\draw[if={isodd(\c)}{none}{}, my cs]
(tl-\c) -- ++ (right:1) -- ([shift=(up:\c/6)]m.south east);


            % The Descriptions
            \foreach \st/\lt[count=\c from 0, evaluate={\d=int(2*\c+1)}] in
            {af/Property A, as/Property B, au/Property C}
            \node[continent] (\st) at (m-\d-1.south west) {\lt};

\node[route] at (-2,-1.7) {Property A};
\node[route] at (-0,-1.7) {Property B};
\node[route] at (2,-1.7) {Property C};


\begin{scope}[node distance=.25cm]
\foreach \st[count=\c from 0, evaluate={\d=int(2*\c+1)}] in {Property A, Property B, Property C}
\node[continent, left=of (tl-\d)](\st){\st};

\node[route, left=of |(Property B)(Property C)] (g) {Category}
(g) \foreach \co in {Property B, Property C}{ edge[my cs, -|-, hvvh/distance=.2cm] (\co)};

\end{scope}
            \end{tikzpicture}
        \end{document}

我知道,我对@Qrrbrbirlbel 的代码所做的很糟糕。我甚至遇到了问题。它似乎编译得很好,在 TexStudio 中看起来也不错。然而,在 Adob​​e Reader 中打开时,它并没有显示所有功能:

在 TexStudio 中:

立方体1

在 Adob​​e Reader 中:

立方体2

谁能告诉我为什么会发生这种情况?我删除了腋窝文件并尝试再次编译。但没有成功。

答案1

虚线图案定义为

\tikzset{none/.style={dash pattern=on 0\pgflinewidth}}

是错误的。它基本上声明了一个应该重复长度为零的线路径的模式,从数学上讲,你需要将这些无限次放下才能画出一条线。更重要的是,任何长度都只会画出一条实线。(你需要一个off部分。)

如果要禁用路径的绘制,请使用draw=none

\foreach \c in {1,...,4} 
  \draw[if={isodd(\c)}{draw=none}{}, my cs]
    (tl-\c) -- ++ (right:1) -- ([shift=(up:\c/6)]m.south east);

或者通过再次调整循环来完全跳过它们:

\foreach \c in {2, 4} 
  \draw[my cs] (tl-\c) -- ++ (right:1) -- ([shift=(up:\c/6)]m.south east);

对于...跳过的定义,您可以使用例如{2, 4, ..., 10}

相关内容