5

I'm looking to create something like this in TikZ environment. Im kind of stuck with the relations to each other: it seems weird, positioning one below the other, when unsure if all the block will be used. Also, I have got no clue how to get these 'columns'.

enter image description here


Edit

This is the code with what I have tried so far.

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,calc}

\colorlet{mygreen}{green!80!black}
\colorlet{myblue}{blue!80!black}
\colorlet{myred}{red!80!black}

\begin{document}

\begin{tikzpicture}[
std/.style={
  draw,text width=2.5cm,align=center, font=\strut\sffamily
  },
rnd/.style={ draw=#1,rounded corners=8pt,line width=1pt,
  align=center, text width=3cm,minimum height=2cm,
  font=\strut\sffamily
  },
vac/.style={
  text width=2.5cm,align=center, font=\strut\sffamily
  },
ar/.style={
 ->,>=latex
  },
node distance=0.5cm and 3cm    
]
%The nodes for the left
\node[vac](urs) {\textbf{Ursache}};
\node[std,below=1cm of urs] (va) {Zeit};
\node[std,below=of va] (fs) {Formierung};
\node[std,below=of fs] (vs) {Vehicle Speed};
\node[std,below=of vs] (cv){Cabin Volume};
\node[std,below= 1cm of cv] (fr) {Fraction of Recirculation};
\node[std,below=of fr] (ac) {Ambient $CO_{2}$ Concentration};
\node[std,below=of ac] (op) {Occupant Parameters};

%The nodes for the center
\node[vac, right= of urs](dm) {degradation mech};
\node[std,right=of va,yshift=-12.5pt,fill=pink] (aer) {SEI- Wachstum};
\node[std,below=of aer,fill={rgb:red,4;green,2;yellow,1}] (cdm){Carbon Dioxide Built-in Module};
\node[std,below=of cdm] (vcm){Vehicle Cabin Module};
\node[std,below=of vcm] (hvac){HVAC Module};

%The nodes for the right

\node[std,right= of cdm,fill=green] (occ) {Verlust Lithium};
\node[std,right= of vcm,fill=yellow] (the) {Thermal Environment};
\node[vac,right= of hvac,fill=orange] (col){Compressor Load};

\draw[blue] (va)  to (aer);
\draw[red] (aer.east) to (occ.west);
\draw (fs) to (aer.west);\draw (fs) to (cdm.west);
\draw (cv.east) to (aer.west);
\draw (vs.east) to (cdm.west);
;

%The dashed fitting node
\node[draw,dashed,inner sep=8pt,fit={(urs) (op)}]
  (fit) {};
\node[draw,dashed,inner sep=8pt,fit={(dm) (hvac)}]
  (fit) {};
  \node[draw,dashed,inner sep=8pt,fit={(occ) (col)}]
  (fit) {};

\end{tikzpicture}

\end{document}

My code creates the following diagram, which is still far from the result I'd like to achieve.

enter image description here

2
  • 2
    You don‘t need to use relative positioning. If you can draw it on paper, read the coordinates, you can do it in tikz as well. // Start simple, grow step by step. Both pgf manuals are your friend on this journey.
    – MS-SPO
    Aug 14, 2022 at 17:47
  • Welcome to TeX.SE. I edited the question, adding the diagram produced by your quote. It makes clear what you have and what you want. Your code will benefit a lot of defining set of instructions with scope and a paradigmatic method to name your nodes.
    – FHZ
    Aug 14, 2022 at 18:40

1 Answer 1

7

This solution creates a tikzset named myBlock to compactly define all instructions to draw rectangles around nodes with the style you want.

The syntax [below=<value> of <node>] is responsible to ensure each node will be exactly below another given node.

I used foreach loops to compact how each node are connected. I separated arrows in four set accordingly to its colors: red, red!50, blue and blue!50. You may as well define new colors or insert the colors as a parameter of each arrow. I just find it simple to define the color of the whole set, mainly because I can redefine the property of the set as a whole instead of doing it individually.

Please, revise colors and the connections.

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{myBlock/.style n args={2}{
    every node/.style={rectangle,fill, text=black, minimum width=#1, minimum height=#2,}
    },
    myBlock/.default={5cm}{1cm}
 }
\begin{document}
\begin{tikzpicture}
  
  \fill[gray,opacity=0.2] (0,0)
  node[below right,black,text opacity=1]{Cause} rectangle ++(5,-18);
  \fill[gray,opacity=0.2] (7,0)
  node[below right,black,text opacity=1]{Degradation Mechanism} rectangle ++(5,-18);
  \fill[gray,opacity=0.2] (14,0)
  node[below right,black,text opacity=1]{Degradation Mode} rectangle ++(5,-18);
  \fill[gray,opacity=0.2] (21,0)
  node[below right,black,text opacity=1]{Effect} rectangle ++(5,-18);
  
  \begin{scope}[myBlock]
    \node[fill=red,text=white] at (2.5,-2) (A1) {Time};
    \node[fill=red!90,text=white] [below=1 of A1] (A2) {High temperature};
    \node[fill=red!80,text=white] [below=1 of A2] (A3) {A3};
    \node[fill=red!70] [below=1 of A3] (A4) {A4};
    \node[fill=blue!70] [below=1 of A4] (A5) {A5};
    \node[fill=blue!80,text=white] [below=1 of A5] (A6) {A6};
    \node[fill=blue!90,text=white] [below=1 of A6] (A7) {A7};
    \node[fill=blue,text=white] [below=1 of A7] (A8) {A8};
  \end{scope}
  
  \begin{scope}[shift={(7,0)},myBlock]
    \node[fill=red,text=white] at (2.5,-2) (B1) {SEI growt};
    \node[fill=red!90,text=white] [below=0.5 of B1] (B2) {SEI decomposition};
    \node[fill=red!80,text=white] [below=0.5 of B2] (B3) {B3};
    \node[fill=red!70] [below=0.5 of B3] (B4) {B4};
    \node[fill=red!60] [below=0.5 of B4] (B5) {B5};
    \node[fill=blue!50,text=white] [below=0.5 of B5] (B6) {B6};
    \node[fill=blue!60,text=white] [below=0.5 of B6] (B7) {B7};
    \node[fill=blue!70,text=white] [below=0.5 of B7] (B8) {B8};
    \node[fill=blue!80,text=white] [below=0.5 of B8] (B9) {B9};
    \node[fill=blue!90,text=white] [below=0.5 of B9] (B10) {B10};
    \node[fill=blue,text=white] [below=0.5 of B10] (B11) {B11};
  \end{scope}
  
  \begin{scope}[shift={(14,0)},myBlock]
    \node[fill=red,text=white] at (2.5,-4) (C1) {Loss of lithium inventory};
    \node[fill=blue!50] [below=3 of C1] (C2) {C2};
    \node[fill=blue,text=white] [below=3 of C2] (C3) {C3};
  \end{scope}
  
  \begin{scope}[shift={(21,0)},myBlock]
    \node[fill=red,text=white] at (2.5,-5) (D1) {Capacity fade};
    \node[fill=blue!50,text=white] [below=4 of D1] (D2) {D2};
  \end{scope}
  
  \begin{scope}[very thick, red]
    \draw (A1.east) -- (B1.west);
    \foreach \n in {1,2,3,4}{
      \draw (A2.east) -- (B\n.west);
    }
    \foreach \n in {1,2,...,5}{
      \draw (A3.east) -- (B\n.west);
    }
    
    \foreach \n in {1,2,3,7}{
      \draw (B\n.east) -- (C1.west);
    }
  \end{scope}
  
  \begin{scope}[very thick, red!50]
    \foreach \n in {1,2,5,6,8,9}{
      \draw (A4.east) -- (B\n.west);
    }
    \foreach \n in {1,2,3}{
      \draw (C\n.east) -- (D1.west);
    }
  \end{scope}
  
  \begin{scope}[very thick, blue]
    \foreach \n in {8,9}{
      \draw (A7.east) -- (B\n.west);
    }
    \foreach \n in {7,8,10,11}{
      \draw (A8.east) -- (B\n.west);
    }
    \foreach \n in {4,6,8,9,10,11}{
      \draw (B\n.east) -- (C3.west);
    }
  \end{scope}
  
  \begin{scope}[very thick, blue!50]
    \draw (A5.east) -- (B7.west);
    \foreach \n in {7,10}{
      \draw (A6.east) -- (B\n.west);
    }
    \foreach \n in {4,5,7,8,9,11}{
      \draw (B\n.east) -- (C2.west);
    }
    \foreach \n in {8,9}{
      \draw (B\n.east) -- (C3.west);
    }
    \foreach \n in {2,3}{
      \draw (C\n.east) -- (D2.west);
    }
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

1
  • Please, also revise the colors I used. I notice my reds are not the same red as your proposed diagram. Besides, there are some space for improvement with colors inside foreach loops and displacement of nodes.
    – FHZ
    Aug 14, 2022 at 18:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .