[Tex/LaTex] Drawing lattice (say over the integer numbers Z)

diagramslatticetikz-pgf

In which environment can I draw a 2d lattice (say over Z) and maybe colour various parts (e.g. excluding all points for which (x,y) > (2,2)?

Maybe tikz is a solution but I am not sure where to start from (e.g. how to define a lattice with an origin etc). There is a similar question but does not help a lot.

I upload a picture so that I make clearer what I want to do. The blue axes are the usual (x,y) axes but I also want to draw lines or exes beginning at other points and I want to exclude regions by coloring them. The arrows are not important. Also I do not mind if the lattice points appear too, actually that would be useful.

enter image description here

Best Answer

Here is a starting point using \foreach loops to iterate over all lattice points. I added also an example condition (i,j) > (2,2):

\documentclass[tikz,border=7pt]{standalone}
\begin{document}
  \begin{tikzpicture}
    % labels
    \foreach \i in {0,...,5}
      \path[blue] (\i,-1) node{\i} (-1,\i) node{\i};
    % loop over the lattice points
    \foreach \i in {0,...,5}
      \foreach \j in {0,...,5}{
        \draw (\i,\j) circle(3pt);
        % check if (\i,\j) > (2,2)
        \ifnum \i > 2
          \ifnum \j > 2
            \fill[red] (\i,\j) circle(2pt);
          \fi
        \fi
      };
  \end{tikzpicture}
\end{document}

enter image description here

Related Question