# Draw an array of lines and vectors in tikz

How do we draw a figure like this in tikz?

I am able to draw the x-y frame via:

\begin{tikzpicture}
\draw[->] (0,0,0)--(1,0,0) node[right]{$x$};
\draw[->] (0,0,0)--(0,1,0) node[above]{$y$};
\end{tikzpicture}


other than that, it is a bit challenging to me.

I think this should work

\documentclass[12pt, border = 5pt]{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\foreach \x in {0, ..., 4} {
\draw[thick, red] (\x, 0) -- (\x, 2);
\fill[black] (\x, 0) circle (0.1);
\fill[black] (\x, 2) circle (0.1);
\draw[blue, thick, ->] (\x, 0) ++(135 : 0.3) -- ++(-45 : 0.6);
\draw[blue, thick, ->] (\x, 2) ++(-45 : 0.3) -- ++(135 : 0.6);
}
\begin{scope}[yshift = 2.5cm]
\draw[brown, ->] (0, 0) -- (1, 0) node[right]{$x$};
\draw[brown, ->] (0, 0) -- (0, 1) node[above]{$y$};
\end{scope}

\end{tikzpicture}

\end{document}


• @Sebastiano You're right, looks much nicer. Thanks for the suggestion :) – caverac Dec 17 '18 at 16:47
• could you remind me what has been changed? – annie heart Dec 17 '18 at 19:20
• @annieheart just changed the ordering of dots vs red lines – caverac Dec 17 '18 at 19:21