# 2d Grid with Tikz and Nodes

I'd like to create the following graph:

But I can't figure it out. I'm pretty new to Tikz and nodes in general, so a simple solution is appreciated.

Here is another grid but I can't figure out how to make it fill with rectangles of color instead of circles and how to add my spaced single rows/columns above and to the left. Additionally i would prefer to have rectangles instead of squares.

Any help is appreciated! The more explanations the better, or any good ressources on how to do any of these more IT problematic graphs.

My problem is mostly that i don't know what the name of those graphs is, so i can't find any tutorials/examples.

Greetings

EDIT: Thanks for all the great suggestions! I tried all of them out but will stick with the accepted answer, because it was the easiest to understand and recreate.

• Welcome to TeX-SE! It is not at all difficult to draw this. The reason why you may be waiting for an answer longer than you want to is that (a) there is no code from your side which could be used as a basis for an answer and (b) it is not clear how it is determined whether a given field should be white or red, i.e. there is no prescription. – user121799 May 7 '19 at 22:46
• Hello and thanks! Yes basically I have nothing, but the code from the link i provided. – Rhynden May 8 '19 at 7:28

This solution is more rudimentary and not programable like marmot's one, but I think it's easier to understand it.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{matrix, positioning}

\begin{document}
\begin{tikzpicture}[font=\sffamily]
\matrix[matrix of nodes, nodes in empty cells, column sep=-\pgflinewidth, row sep=-\pgflinewidth,
nodes = {minimum height=7mm, minimum width=1cm, anchor=center, draw, fill=red},
column 1/.style={nodes={fill=orange}},
row 1/.style={nodes={fill=green}},
row 1 column 1/.style={nodes={draw=none, fill=none}},
w/.style={fill=white},
label=above:Backside Clusters,
label={[rotate=90, anchor=south]left:Frontside Cluster}] (Clusters) {
&[3mm]&1000&1100&&&&&&&&&&&&\\[3mm]
900 &|[w]|&|[w]|&&&&&&&&&&&&&\\
&|[w]|&|[w]|&|[w]|&&&&&&&&&&&&\\
&&|[w]|&|[w]|&|[w]|&&&&&&&&&&&\\
&&&|[w]|&|[w]|&|[w]|&|[w]|&&&&&&&&&\\
&&&&|[w]|&|[w]|&|[w]|&|[w]|&|[w]|&&&&&&&\\
&&&&&&&|[w]|&|[w]|&|[w]|&|[w]|&&&&&\\
&&&&&&&&|[w]|&|[w]|&|[w]|&|[w]|&|[w]|&&&\\
&&&&&&&&&|[w]|&|[w]|&|[w]|&|[w]|&|[w]|&&\\
&&&&&&&&&&&|[w]|&|[w]|&|[w]|&|[w]|&\\
&&&&&&&&&&&&|[w]|&|[w]|&|[w]|&|[w]|\\
&&&&&&&&&&&&&&|[w]|&|[w]|\\
};

\node[font=\Huge\sffamily, above right=0pt of Clusters-10-3.south west] {Skipped};
\node[font=\Huge\sffamily, below left=0pt of Clusters-3-14.north east] {Skipped};
\end{tikzpicture}
\end{document}


\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[Xmax/.estore in=\Xmax,Xmax=15,Ymax/.estore in=\Ymax,Ymax=10,
Xstep/.initial=8mm,Ystep/.initial=4mm]
\edef\LstX{,1000,1100,,,,,,,,,,,,} %make sure there are (at least) Xmax-1 commas
\edef\LstY{900,,,,,,,,,,}%make sure there are (at least) Ymax-1 commas
\foreach \X in {1,...,\Xmax}
{
\draw[fill=green!70!black]
(\X*\pgfkeysvalueof{/tikz/Xstep},{(\Ymax+1.8)*\pgfkeysvalueof{/tikz/Ystep}})
rectangle ++ (-\pgfkeysvalueof{/tikz/Xstep},-\pgfkeysvalueof{/tikz/Ystep})
node[midway]{\pgfmathparse{{\LstX}[\X-1]}\pgfmathresult};
\foreach \Y in  {1,...,\Ymax}
{\ifnum\X=1
\draw[fill=orange]
(-0.8*\pgfkeysvalueof{/tikz/Xstep},\Y*\pgfkeysvalueof{/tikz/Ystep})
rectangle ++ (-\pgfkeysvalueof{/tikz/Xstep},-\pgfkeysvalueof{/tikz/Ystep})
node[midway]{\pgfmathparse{{\LstY}[\Ymax-\Y]}\pgfmathresult};
\fi
\pgfmathtruncatemacro{\itest}{int(1.2*abs(\X+1.4*\Y-\Xmax))}
\ifnum\itest>2
\draw[fill=red]
(\X*\pgfkeysvalueof{/tikz/Xstep},\Y*\pgfkeysvalueof{/tikz/Ystep})
rectangle ++ (-\pgfkeysvalueof{/tikz/Xstep},-\pgfkeysvalueof{/tikz/Ystep});
\else
\draw (\X*\pgfkeysvalueof{/tikz/Xstep},\Y*\pgfkeysvalueof{/tikz/Ystep})
rectangle ++ (-\pgfkeysvalueof{/tikz/Xstep},-\pgfkeysvalueof{/tikz/Ystep});
\fi
}}
\path (0.5,0.5)  node[above right,font=\Huge\sffamily] {Skipped};
\path ({\Xmax*(\pgfkeysvalueof{/tikz/Xstep}-1)-0.5},
{\Ymax*(\pgfkeysvalueof{/tikz/Ystep}-1)-0.5})  node[below left,font=\Huge\sffamily] {Skipped};
\end{tikzpicture}
\end{document}


• Wow thank you very much, didn't expect that! Do you mind explaining the main grid? I kinda do understand how you made the green and the orange one. What is the pgfmathtruncatemacro for? Where would I add numbers to the field if I'd need that (mainly orange/green row)? – Rhynden May 8 '19 at 7:35
• @Rhynden I added lists that carry these labels. – user121799 May 8 '19 at 14:30
• Thanks! That answe was definitly great, I will try to understand it more, but it helped a lot. – Rhynden May 8 '19 at 15:48

With a default tabular:

\documentclass[border=2mm]{standalone}
\usepackage[table]{xcolor}
\usepackage{array}
\newcolumntype{P}{>{\columncolor{red!80}\centering}p{2em}}
\def\V{\multicolumn{1}{@{}|>{\cellcolor{white}}c@{}|}{}}
\def\W{\multicolumn{1}{>{\cellcolor{white}}c|}{}}
\def\G{\cellcolor{green!80}}
\def\Skipped{\makebox(0,0){\Huge\bfseries\put(0,39){Skipped}}}
\begin{document}

\sffamily\footnotesize\tabcolsep=2pt
\begin{tabular}{rr}
& \begin{tabular}{|*{15}{P|}}
\multicolumn{15}{c}{Backside Clusters}\\\hline
\G & \G1000 & \G1100 &\G&\G&\G&\G&\G&\G&\G&\G&\G&\G&\G & \G\tabularnewline\hline
\end{tabular}\\[8pt]
\begin{tabular}{|>{\columncolor{orange!60}}c|}\hline
900\\\hline\\\hline\\\hline~\\\hline~\\\hline~\\\hline~\\\hline~\\\hline~\\\hline~\\\hline~\\\hline
\end{tabular}
&
\begin{tabular}{|*{15}{P|}}\hline
\V &\W &&&&&&&&&&&&&\\\hline
\V&\W&\W&&&&&&&&&&&&\\\hline
&\W&\W&\W&&&&&&&&&&&\\\hline
&&\W&\W&\W&\W&&&&&&&&&\\\hline
&&&\W&\W&\W&\W&\W&\Skipped&&&&&&\\\hline
&&&&&&\W&\W&\W&\W&&&&&\\\hline
&&&&&&&\W&\W&\W&\W&\W&&&\\\hline
&&&&&&&&\W&\W&\W&\W&\W&&\\\hline
&&&&&&&&&&\W&\W&\W&\W&\\\hline
&&&&&&&&&&&\W&\W&\W&\W\\\hline
&\Skipped&&&&&&&&&&&&\W&\W\\\hline
\end{tabular}
\end{tabular}
\end{document}


• see edited answer – user187802 May 8 '19 at 16:37