I'd like to create the following graph: 2d grid

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.


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.

\usetikzlibrary{matrix, positioning}

\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}},
    label=above:Backside Clusters,
    label={[rotate=90, anchor=south]left:Frontside Cluster}] (Clusters) {
    900 &|[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};

enter image description here

\begin{tikzpicture}[Xmax/.estore in=\Xmax,Xmax=15,Ymax/.estore in=\Ymax,Ymax=10,
 \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}
 rectangle ++ (-\pgfkeysvalueof{/tikz/Xstep},-\pgfkeysvalueof{/tikz/Ystep})
 \foreach \Y in  {1,...,\Ymax}
 rectangle ++ (-\pgfkeysvalueof{/tikz/Xstep},-\pgfkeysvalueof{/tikz/Ystep})
  rectangle ++ (-\pgfkeysvalueof{/tikz/Xstep},-\pgfkeysvalueof{/tikz/Ystep});
  \draw (\X*\pgfkeysvalueof{/tikz/Xstep},\Y*\pgfkeysvalueof{/tikz/Ystep})
  rectangle ++ (-\pgfkeysvalueof{/tikz/Xstep},-\pgfkeysvalueof{/tikz/Ystep});
 \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};

enter image description here

  • 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:


        & \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
    \V &\W &&&&&&&&&&&&&\\\hline

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.