I want to state from the beginning that this is not supposed to be a “please draw for me” post. I just would like to know if it is possible to produce a data cube similar to this

with reasonable effort in Latex. I would preferable start off with a template if any is available. Reasonable effort shall be defined as two hours work max. My starting point is no knowledge of drawing in Latex. I basically only know that tikz can be used for drawing.

If anyone has done something similar I would appreciate it very much if he or she could post the code here and preferable state what he or she read in order to do it. If anyone knows where a template can be found, I would very much appreciate a link to the template. If it is not possible to produce a data cube with what was defined as reasonable effort but anyone knows some freeware program to produce this kind of data cube, I would like to invite the person to post the link to the program.

I would say: No. But it's hard to say because, of course, it depends how quickly you read and learn. If you're unfamiliar with TikZ but familiar with some similar syntax (perhaps from programming), it might be easier for you than it was for me ;). Or I may just be an unusually slow learner :(. That is, it is perfectly possible to do this in TikZ (or, I assume, pstricks etc.) but not if you know nothing about the system and have a 2 hour limit. If this is a one-off, use a graphical programme. If you need to draw other cubes or things, it might be worth more than 2 hours to learn a system.
– cfrMay 11 '15 at 15:41

I will only need one of these data cubes and will most likely use another graphic program if nothing else will come up here. @Alenanno As "reasonable effort" is a rather wide term I have chosen to define it in terms of hours.
– ThomasMay 11 '15 at 17:23

1

@Thomas Please post the edit here as a follow-up question (you can link this question in the new one). It's better that way. This way you're changing this question which has been already been answered.
– AlenannoMay 13 '15 at 15:24

2 Answers
2

the matrix library for the main part, including some auxiliary macros \rd and \rn for some random content in the matrix,

the calc library for some easy vector calculation,

my paths.ortho library (code: [1] and [2]) for the connections outside of the matrix,

my positioning-plus library for the use of left=of |(n1)(n2) which positions a node to the left of the vertical center of (n1) and (n2).

The local cs key (packaged later in the my cs style) is used to create a custom coordinate system that slants the vertical axis for the three-dimension part of the cube. (There are a lot of different ways to achieve this.)

There are also various different ways to achieve specific things in this code:

We could have drawn the lines inside the matrix as part of the inner nodes that lie inside it. We could have used the workarounds in the linked answer to replace my library.

that sets up a tight matrix where the matrix’ nodes are set border to border. The text … keys are used so that all nodes have same height, depth and width.

The matrix is then filled just as you would.

A custom coordinate system simulating the third dimension

With my cs/.style={local cs={m.north west}{m.north east}{1}{2}} I'm setting up a coordinate system which origins lie at (m.north west), the x vector points to (m.north east) and the y coordinate is “x-slanted” by the factor of 1 (For every y you go an additionally 1 to the right.) Also, the y is doubled.

I have used the xslanting as a way to use orthogonal parts (like |-, -| or my own -|-) without the need to worry about the third dimension.

However, there is actually a third dimension in TikZ. Its vector can be set with the z key and its default is (-3.85mm, -3.85mm). (So it actually points “out” of the paper.) We cannot use this third dimension in path operators. (It’s just a coordinate specification which maps three values to 2d-vectors.) However the direction of the y vector can be calculated from the xslanting: <direction> = atan(1/<xslant>).

The “third” dimension

With the coordinate system set up, we can draw the cube’s borderuse a usual rectangle path operator and it will draw a slanted rectangle.

The coordinate system also allows us to use the relative coordinate + (up:1) if we want to get into the third dimension anyway.

Lines

With the custom coordinate system set up we can draw the box’s border:

Here, I also define seven coordinates we later use to place the nodes at the top left of the cube.

Even though, in all three paths, the custom coordinate system is active, named nodes/coordinates are not affected as they are referenced absolutely. The ++(up:1) is used to get into the third dimension. The same applies to the shift coordinate at the end.

Nodes

For the placing of the descriptive nodes we either use the matrix’ cells’ nodes’ anchors as in

The positioning-plus library allows us to do left=of |(<n1>)(<n2>) which place the new node to the left of a coordinate that lies in the middle of the most left vertical line that spans the nodes (<n1>) and (<n1>). We could also write left=of ($(<n1>.north west)$!.5!(<n2>.south west)$) with just basic positioning.

The lines are drawn with the -|- to path and active my cs (see the options of \begin{scope}). The xslanting also slants the orthogonal connections:

Output

And to answer the question "Is it reasonable?" Yes, if you know how to approach the problems wit TikZ. Even more so, if you have multiple of these cubes.
– QrrbrbirlbelMay 11 '15 at 20:20

Yes, but the question explicitly stated the conditions and, given those conditions, the answer is surely 'No. It is not reasonable.' If you change the conditions, of course the answer will change... ;).
– cfrMay 11 '15 at 20:22

Wow this is very helpful and much more then i expected. The picture was basically just an example of what I was thinking about. If I had known that you are going to do it I would have drawn it on paper and uploaded it. Now I just have to find out how to get it to compile.
– ThomasMay 11 '15 at 20:37

@Thomas Start with the basic stuff (e.g. the matrix) and build upon that. (And if you get stuck, ask.) — I realize now that the 3d stuff is probably better drawn differently to understand it better as I use calculations and transformations at places you may not expect it. But I wanted to use the xslant factor for the "orthogonal" connections between the "Route" nodes. The cube is probably the most complicated part of the drawing.
– QrrbrbirlbelMay 11 '15 at 20:44

Yes but that's way over my head. I'm googling right now how to add libraries to a package. I think you start to get the idea where I am at.
– ThomasMay 11 '15 at 20:48

Qrrbrbirlbel already gave a very nice answer, but since I've been working on this for hours (I'm less expert), I thought it'd be a waste not to post it. It certainly can be improved, but it's late here so I'll try to do it tomorrow.

There are some differences with Qrrbrbirlbel's answer, the main one being the fact that the cube's depth has been done using perspective and then clipping the excess lines.

Here is the cube without clipping (the red line is the clipping path):

With something like \tikzset{partway to vanishing point/.style={to path={-- ($(\tikztostart)!#1!(\tikztotarget)$)\tikztonodes}}, partway from vanishing point/.style={to path={($(\tikztostart)!1-#1!(\tikztotarget)$) -- (\tikztotarget)\tikztonodes}}} you can do \path[thick, partway from vanishing point=.6] (4,6,-8) edge (4,\y,0) edge (\x,6,0) edge (4,6,0); and you wouldn't need to use clip. If you do not want to guess the parameter .6 you can also use any horizontal/vertical line in the xy plane and find where it intersects with lines to the vanishing point.
– QrrbrbirlbelMay 12 '15 at 21:19

1

@Qrrbrbirlbel That's brilliant, where do you learn these things?! :D
– AlenannoMay 12 '15 at 21:25