3

I'm very new to Latex in general used a suggestion I found on Stackexchange to build the cubes in the file. Now I need to write in them. I have tried adding nodes as per usual (like I did to write "time" and "knowledge near the lines), but can't make it work.

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{positioning}

\begin{document}

\newcommand{\drawbox}[4]{ \pgfmathsetmacro \angle {30} \pgfmathsetmacro \xd {{2/3cos(\angle)}} \pgfmathsetmacro \yd {{2/3sin(\angle)}} \pgfmathsetmacro \x {{#1-1+(#2-1)(\xd)}} \pgfmathsetmacro \y {{#3-1+(#2-1)(\yd)}}

\draw[fill=#4] (\x,\y) -- (\x+1,\y) -- (\x+1,\y+1) -- (\x,\y+1) -- cycle;
\draw[fill=#4] (\x,\y+1) -- (\x+\xd,\y+1+\yd) -- (\x+1+\xd,\y+1+\yd) -- (\x+1,\y+1) -- cycle;
\draw[fill=#4] (\x+1,\y+1) -- (\x+1+\xd,\y+1+\yd) -- (\x+1+\xd,\y+\yd) -- (\x+1,\y) -- cycle;

}

\newcommand{\Depth}{2}
\newcommand{\Height}{2}
\newcommand{\Width}{2}

\begin{tikzpicture}

\draw[->] (-1,-0.5) -- node[below, xshift=4cm] {time}(8,-0.5); %x-achse
\draw[->] (-1,-0.5) -- node[above, rotate=90, xshift=2.8cm] {knowledge}(-1, 7); %y-achse
\draw[->, red, thick] (0,2) -- (58:6.5cm); %diagonal line

\drawbox{1}{1}{1}{yellow!50!brown!40!} %bottom box 1
\drawbox{2}{1}{1}{yellow!50!brown!40!} %bottom box 2 
\drawbox{3}{1}{1}{yellow!50!brown!40!} %bottom box 3
\drawbox{4}{1}{1}{yellow!50!brown!40!} %bottom box 4
\drawbox{1.5}{1}{2}{yellow!50!brown!40!} %top box 1
\drawbox{2.5}{1}{2}{yellow!50!brown!40!} %top box 2
\drawbox{3.5}{1}{2}{yellow!50!brown!40!} %top box 3
\drawbox{4.5}{1}{2}{yellow!50!brown!40!} %top box 4
\drawbox{4.5}{1}{3}{yellow!50!brown!40!} %top box 5
\drawbox{4.5}{1}{4}{yellow!50!brown!40!} %top box 6
\drawbox{4.5}{1}{5}{yellow!50!brown!40!} %top box 7

\end{tikzpicture}

\end{document}

I'd be very grateful if someone could help me here. Thanks!

brinde
  • 71
  • 1
    Might these help? https://tex.stackexchange.com/questions/302539/putting-labels-on-a-cube-with-perspective, https://tex.stackexchange.com/questions/254010/placing-text-on-face-of-3d-cube – Steven B. Segletes Aug 23 '22 at 13:31
  • 1
    They did, thank you! – brinde Aug 23 '22 at 13:54
  • @brinde, it would be nice if you'd answer your question yourself to share the solution, which worked for you. Thank you. – MS-SPO Sep 27 '23 at 10:19

0 Answers0