[Tex/LaTex] Drawing Lattice/Trellis Graphs using PGF/TikZ

graphicspackagestikz-pgf

I am trying to draw a graph containing lattice points and vectors. I wish it to look something like this:

Lattice in $\mathbb{R}^{2}$

I am not sure how to go about it, however, I would ideally like to be able to use PGF/TikZ. Is this possible, or would I need to download and install a package like GeoGebra to create the graph, and export it into PGF/TikZ format? Again, I am not sure whether or not this is possible using GeoGebra.

Any suggestions would be appreciated.


Follow-up Question: Aligning x- and y-axis with lattice points on a graph using PGF/TikZ

Best Answer

Here is a little bit advanced but not so difficult to understand grid construction:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\begin{scope}
\clip (0,0) rectangle (10cm,10cm); % Clips the picture...
\pgftransformcm{1}{0.6}{0.7}{1}{\pgfpoint{3cm}{3cm}} % This is actually the transformation
                                                     %  matrix entries that gives the slanted
                                                     % unit vectors. You might check it on
                                                     % MATLAB etc. . I got it by guessing.

\draw[style=help lines,dashed] (-14,-14) grid[step=2cm] (14,14); % Draws a grid in the new coordinates.
\filldraw[fill=gray, draw=black] (0,0) rectangle (2,2); % Puts the shaded rectangle
\foreach \x in {-7,-6,...,7}{                           % Two indices running over each
    \foreach \y in {-7,-6,...,7}{                       % node on the grid we have drawn 
    \node[draw,circle,inner sep=2pt,fill] at (2*\x,2*\y) {}; % Places a dot at those points
    }
}
\end{scope}
\end{tikzpicture}
\end{document}

Here is the output:

enter image description here

If you combine it with Peter's code it would be almost ready. Note that there is a scope environment around my code that keeps the transformation local to that scope. Cehck the manual for some intuition about the command \pgftransformcm