3

This Question has to be seen as a follow up question of this one:

Is it possible to produce data cubes in Latex with reasonable effort?

Based on the code that @Qrrbrbirlbel posted I came up with some changes and this code:

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

I know, what I did to the code of @Qrrbrbirlbel was horrible. And I even run into a problem with it. It seems to compile fine and in TexStudio it looks good. It does however not show all the features when opened in Adobe Reader:

In TexStudio:

cube1

In Adobe Reader:

cube2

Can anyone tell me why this happens? I deleted the axillary files and tried to compile again. It didn't work.

  • The none dash pattern is, well, wrong. What is it supposed to do? It basically defines an infinite amount of infinitesimal short parts. TeXstudio (and Sumatra) seem to ignore this. Adobe trips. – Qrrbrbirlbel May 13 '15 at 17:58
  • That was my way to remove the densely dashed line running over the top of the cube. If you just remove "densely dashed" it will do a solid line... – Thomas May 13 '15 at 18:01
3

The dash pattern defined as

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

is faulty. It basically declares a pattern that should repeat line paths of zero length, mathematically you would need to put these infinite times down to draw a line. Even more so, any amount of length will just draw a solid line. (You will need an off part.)

If you want to disable the drawing of a path, use 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);

or just skip them entirely by adjusting the loop once again:

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

For a ... definition that skips you can use for example {2, 4, ..., 10}.

| improve this answer | |
  • As I read one should not use the comment section to say thank you. I hope however that you understand how much I appreciate your help. – Thomas May 13 '15 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.