# Plot grid graph with latex

I have no idea to plot the following graph. I don't need the bold shade. Can anyone help me. Thank you in advance.

A simple foreach is enough. The grid without the numbers can also be done with \draw (0,0) grid (6,4); and this can be modified as any other path. You can also specify the step, which in this case is not needed because the drawing uses 1cm and Tikz uses the same value by default.

Since you want custom numbers and you're loading pgfmath through Tikz, you can use arrays. The number 404 is there because you gave me only 4 numbers for the second row, so it was... not found.

## Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\tikzset{
dot/.style 2 args={fill, circle, inner sep=1pt, label={#1:\scriptsize #2}}
}

\begin{document}
\begin{tikzpicture}

\def\numberlist{{3,0,1,0,2,3,0,2,1,404,2,1,0,6,7,1,1,3,4,5,1,3,2,1,0}}
\def\maxX{4}
\foreach \x [count=\n] in {0,...,\maxX}{
\foreach \y in {0,...,4}{
\pgfmathtruncatemacro\tmp{\n+(\maxX+1)*\y}
\pgfmathtruncatemacro\num{\numberlist[\tmp-1]}
\draw[line width=.5pt] (\x,0) -- (\x,4);
\draw[line width=.5pt] (0,\y) -- (\maxX,\y);
\node[dot={45}{\num}] at (\x,\y) {};
}
}

\end{tikzpicture}
\end{document}

• @Alenano Thank you so much for your answer. How can change the label of a node? Sep 3 '16 at 15:47
• @ThomasEdison It depends. In what way do you want to change them? Sep 3 '16 at 20:53
• I want to change 1,2,3,4,5 ... to 3,0,1,2,1,.... This sequence does not has any rule. Sep 4 '16 at 0:34
• @ThomasEdison None whatsoever? What's the full sequence of numbers you need? Sep 4 '16 at 0:37
• I only need to plot in 5x5 grid with label are row 1: 3,0,1,0,2. row 2: 3,0,2,1, row 3: 2,1,0,6,7, row 4: 1,1,3,4,5, row 5: 1,3,2,1,0 Sep 4 '16 at 0:41