# How to manipulate grid

I have a grid I would like to make some changes to it but have no idea.

My minimal example:

\documentclass[border=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[step=2cm,color=gray,rotate=45] (-1,-1) grid (9,9);
\node at (-0.5,+0.5) {A};
\end{tikzpicture}
\end{document}


But this won't give me the answer.
What I actually want is
(i) each adjacent line to have different color(two in total, may be one red and another blue).
(ii) then where ever they cross blue and red lines a circle(hiding the cross with circle), inside the circle a text like A(misplaced by me), everywhere they cross.

(partially near to this)
Don't consider the background color. But something like the this directed(with arrows) network. With dashed and complete circles, labelled differently.

I am new to TikZ or making figures in LaTeX. My apologies.

The question is not very clear. I was preparing this solution, when I saw that marsupilam already aswered something very similar. The main difference in my solution is the inclusion of a \path[clip] to remove the unwanted parts:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\path[clip] (-3,-3) rectangle +(6,6);
\begin{scope}[rotate=45]
\foreach \x in {-4,...,4} {
\draw[red] (\x, -4) -- +(0,8);
}
\foreach \y in {-4,...,4} {
\draw[blue] (-4,\y) -- +(8,0);
}
\foreach \x in {-4,...,4}
\foreach \y in {-4,...,4}
\node[draw,circle,fill=white, inner sep=2pt] at (\x,\y) {A};
\end{scope}
\end{tikzpicture}


\end{document}

Result:

# Update

The OP asked for arrows between nodes. At first I thought of decorating the edges, but in the end the following approach, which draws arrows slightly offset is much simpler:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}[>=stealth]
\path[clip] (-3,-3) rectangle +(6,6);
\begin{scope}[rotate=45]
\foreach \x in {-4,...,4}
\foreach \y in {-4,...,4} {
\draw[blue,->] (\x-0.4, \y) -- (\x+0.6, \y);
\draw[red, ->] (\x, \y-0.5) -- (\x, \y+0.6);
\node[draw,circle,fill=white, inner sep=2pt] at (\x,\y) {A};
}
\end{scope}
\end{tikzpicture}

\end{document}


# Update 2

The OP asked later for different style/content for alternate nodes. The easiest way to do this is to compute the function mod(abs(x+y), 2)+1 which has only two possible outcomes (1 and 2), and use this result to set the appropiate subindex in the node content, and to select a different tikz style.

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\tikzset{
mynode/.style = {circle, draw, thick, fill=white, inner sep=0pt},
type1/.style = {mynode},
type2/.style = {mynode, dashed}
}

\begin{document}
\begin{tikzpicture}[>=stealth]
\path[clip] (-3,-3) rectangle +(6,6);
\begin{scope}[rotate=45]
\foreach \x in {-4,...,4}
\foreach \y in {-4,...,4} {
\pgfmathsetmacro{\type}{int(mod(abs(\x+\y),2)+1)};
\draw[blue,->] (\x-0.4, \y) -- (\x+0.6, \y);
\draw[red, ->] (\x, \y-0.5) -- (\x, \y+0.6);
\node[type\type]
at (\x,\y) {$A_\type$};
}
\end{scope}
\end{tikzpicture}

\end{document}


## Update

With clip, and no coordinate label

\documentclass[border=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\path[clip] (-10,-4) rectangle +(8,8);
\begin{scope}[rotate=45]
\draw[step=4cm,color=blue, thick] (-15,-15) grid (9,9);
\draw[step=4cm,color=red,thick, shift={(-2cm,-2cm)}] (-13,-13) grid (11,11);
\foreach \i in {-14,-12,...,8}{%
\foreach \j in {-14,-12,...,8}
}
\end{scope}
\end{tikzpicture}
\end{document}


Like the others have mentioned, the question is not clear. My interpretation is as such:

• Parallel grid lines (on both axes) should have alternate colours.
• Circle with text inside

Obviously the circles need not be on every intersection point, you can add nodes yourself on relevant coordinates. I've left the coordinates above the nodes, for your reference. You can omit those in your own code, if they are not required.

Also, your image in the question had labels outside the node, so I was confused on what you wanted for a moment.

\documentclass[border=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[rotate=45]
\draw[step=4cm,color=blue, thick] (-3,-3) grid (9,9);
\draw[step=4cm,color=red,thick, shift={(-2cm,-2cm)}] (-1,-1) grid (11,11);
\foreach \i in {-2,0,...,8}{%
\foreach \j in {-2,0,...,8}
}
\end{tikzpicture}
\end{document}


Crux of my code:

Basically I doubled the grid size from 2cm to 4cm, and set up two grids superimposed on each other, with a shift. This way I was able to set up two colours for the grid.

Welcome to TeX.SX !

## Edited version

### The output

Closer to your pic. Is this better ?

### The code

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\begin{scope}[rotate=45]
\coordinate (SE) at (-1,-1) ;
\coordinate (NW) at (9,9) ;
\foreach \x in {0,2,...,8}
{
\coordinate (X) at (\x,\x);
\draw [red] (X-|SE) -- (X-|NW) ;
\draw [blue] (X|-SE) -- (X|-NW) ;
}
\foreach \x in {0,2,...,8}
{
\foreach \y in {0,2,...,8}
{
\node [circle, draw, fill=green, fill opacity=.8, text opacity=1] at (\x,\y) {A};
}
}
\end{scope}
\end{tikzpicture}
\end{document}


## Original version

Is this what you need ?

### The code

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\begin{scope}[rotate=45]
\coordinate (SE) at (-1,-1) ;
\coordinate (NW) at (9,9) ;
\draw [step=2cm,color=gray] (SE) grid (NW);
\coordinate (A) at (2,4) ;
\draw [blue, thick,] (SE|-A) -- (NW|-A) ;
\draw [red, thick,] (SE-|A) -- (NW-|A) ;
\node [circle, draw, fill=green, fill opacity=.8, text opacity=1] at (A) {A};
\end{scope}
\end{tikzpicture}
\end{document}