I am having troble making a grid with tikzpicture. The vertical and horizontal lines are somewhat displaced. This is similar to TikZ not drawing some lines in grid. I have been fiddling with adding small amounts ("epsilons") to the corner points but to no avail. This is my code:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
%% Rulers -------------------------
\draw [black!80, dotted] (0, 0) -- (9, 0);
\draw [black!80, dotted] (0, 4) -- (9, 4);
\draw (-0.25, 0) -- (.25, 0);
\draw (-0.25, 4) -- (.25, 4);
\draw [black!50, thick, dashed] (0, .5) -- (1.5, .5);
\draw [black!50, thick, dashed] (0, .25) -- (3.25, .25);
\node (A) at (0,2) {$\Delta r$};
\draw[->] (A) -- (0,4);
\draw[->] (A) -- (0,0);
% First and second grids
\draw[step=1,black,thin] (1,0) grid (2,4);
\draw[step=0.5, black,thin] (2.99,0) grid (3.5,4);
% cell centers
\foreach \r in {.5, 1.5,..., 3.5}
\fill [] (1.5, \r) circle [radius=1pt];
\foreach \r in {.25, .75,..., 3.75}
\fill [] (3.25, \r) circle [radius=1pt];
% -----------------------------------------------
% Third anf fourth grids
\draw[step=4/3,black,thin] (5-2/3,-2/3) grid (5+2/3,4+2/3);
\draw[step=2/3,black,thin] (6+2/3,-1/3) grid (7+1/3,4+1/3);
% cell centers
\foreach \r in {0, 4/3, 8/3, 4}
\fill [] (5, \r) circle [radius=1pt];
\foreach \r in {0, 0.6666, ..., 4}
\fill [] (7, \r) circle [radius=1pt];
\node (notea) at (1.5,-1) {$(a)$};
\node (noteb) at (3.25,-1) {$(b)$};
\node (notec) at (5,0-1) {$(c)$};
\node (noted) at (7,-1) {$(d)$};
\end{tikzpicture}
\end{document}
The output I get looks like this:

But I want it to look like this (differences in red):

I suspect that this has to do with the length units I've chosen, because I have multiples of 1/3 that in the end don't sum up to round numbers. \draw[step=4/3,black,thin] (5-2/3,-2/3) grid (5+2/3,4+2/3);


tikz.sty 2010/10/13 v2.10 (rcs-revision 1.76). I've been trying, but I always get the wrong results in the grids (c) and (d). – Bubastis Jul 14 '15 at 10:45(0,0)of the 3rd and 4th and you'll see they agree at the origin. Instead you can draw a grid and shift it to a position with a scope – percusse Jul 14 '15 at 11:02