0

I want to draw the below diagram using Latex enter image description here

I am not sure what is the best way to do it, any pointers would be really helpful.

1 Answer 1

5

Here is something that produces a diagram of that type.

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending,chains}

\begin{document}
\begin{tikzpicture}[node distance = 2mm and 5mm,
     box/.style = {draw, align=center,rounded corners,
        text width={width("Target variable $y$")+4pt},minimum height=3em,
        node font=\sffamily,fill=#1},
      arw/.style = {-stealth,semithick}]
 \begin{scope}[start chain=A going right,nodes={on chain,join=by arw,alias=last}]
  \node[box=gray!20] {Unobserved factors};
  \node[box=yellow!20] {Unknown mixing};
  \node[box=blue!20] {Operation $x$};
  \node[box=purple!20] {Representation $r(x)$};
  \node[box=orange!20] {Prediction $\widehat{y}$};
 \end{scope}
 \node[box=green!20,above=of A-1] (T) {Target variable $y$};
 \node[box=red!20,below=of A-1] (B) {Sensitivity variable $s$};
 \draw[arw] (T) -- (A-2);
 \draw[arw] (B) -- (A-2);
 \draw[line width=3pt,green!60!black,-{Latex[bend]},shorten <=0.5pt] (last) 
  to[bend right] node[below=2em,black,font=\Large\bfseries]{Accurate} (T);
 \draw[line width=3pt,red,-{Latex[bend]},shorten <=1.5pt,
    dash pattern=on 9pt off 6pt] (B) to[bend right] 
 node[above=2em,black,font=\Large\bfseries]{While being fair}(last);
\end{tikzpicture}
\end{document}

enter image description here

Or

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending,chains}
\begin{document}
\begin{tikzpicture}[node distance = 2mm and 5mm,
     box/.style = {draw, align=center,rounded corners,
        text width={width("Target variable $y$")+4pt},minimum height=3em,
        node font=\sffamily,fill=#1},
      arw/.style = {-stealth,thick}]
 \begin{scope}[start chain=A going right,nodes={on chain,join=by arw,alias=last}]
  \node[box=gray!20] {Unobserved factors};
  \node[box=yellow!20] {Unknown mixing};
  \node[box=blue!20] {Operation $x$};
  \node[box=purple!20] {Representation $r(x)$};
  \node[box=orange!20] {Prediction $\widehat{y}$};
 \end{scope}
 \node[box=green!20,above=of A-1] (T) {Target variable $y$};
 \node[box=red!20,below=of A-1] (B) {Sensitivity variable $s$};
 \draw[arw] (T) -- (A-2);
 \draw[arw] (B) -- (A-2);
 \draw[line width=3pt,green!60!black,-{Latex[bend]},shorten <=0.5pt] (last.north) 
  to[out=120,in=40] node[below=2em,black,font=\Large\bfseries]{Accurate}
  (T.north);
 \draw[line width=3pt,red,-{Latex[bend]},shorten <=1.5pt,
    dash pattern=on 9pt off 6pt] (B.south) to[out=-40,in=-120] 
 node[above=2em,black,font=\Large\bfseries]{While being fair}(last.south);
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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