1

I would like to draw the attached diagram, but since it contains colors and texts I couldn't get a good picture. If one can help me with code that would be great. Note, the boxes are of the same size! Thanks.enter image description here

A. Rahman
  • 127

1 Answers1

7

Both a matrix of nodes or tikz-cd allow you to draw this.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{matrix,quotes}
\begin{document}
\begin{tikzpicture}[M/.style={draw=blue,fill=yellow},font=\sffamily,>=stealth]
 \matrix[matrix of nodes,column sep=3em,row sep=3em,nodes={minimum size=1cm},row 3/.style={nodes=M}] (mat)
 { A & & \\
  \phantom{C} & C & \phantom{F}& F \\
  B & D & |[draw=none,fill=none,minimum size=0em]| \phantom{F}& G\\
 };
 \draw[->] (mat-1-1) edge (mat-3-1)
  (mat-2-1) edge (mat-2-2) 
  (mat-2-2) edge["E"] (mat-3-2)
  (mat-2-4) edge["F"] (mat-3-4)
  (mat-2-2) edge[dashed] (mat-2-4)
  (mat-3-2) edge[dashed] (mat-3-4)
  (mat-2-3) edge[dashed] (mat-3-3);
\end{tikzpicture}
\end{document}

enter image description here

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-cd}
\tikzset{M/.style={draw=blue,fill=yellow,minimum size=2em}}
\begin{document}
\begin{tikzcd}[column sep=3em,row sep=3em]
  A\arrow[dd] & & \\
  \phantom{C} \arrow[r] & C \arrow[d,"E"] \arrow[rr,dashed] & \phantom{F} \arrow[d,dashed]& F \arrow[d,"H"]\\
  |[M]|B  & |[M]|D \arrow[rr,dashed] & \phantom{F}& |[M]|G\\
\end{tikzcd}
\end{document}

enter image description here