5

How do we draw a figure like this in tikz?

enter image description here

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.

Thank you in advance!

6

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}

enter image description here

  • 1
    @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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.