2

How can I draw vectors on a plane like the ones in the following image in LaTeX?

enter image description here

2 Answers 2

10

There are many ways to draw this, here is one.

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[>=stealth,scale=0.5,line cap=round,
    bullet/.style={circle,inner sep=1.5pt,fill}]
 \draw[->] (-9,0) -- (9,0) node[right]{$x$};
 \draw[->] (0,-7) -- (0,7) node[above]{$y$};
 \draw foreach \X in {3,6}
  {(\X,0.1) -- ++ (0,-0.2) node[below]{$\X$}};
 \draw foreach \Y in {2,4}
  {(0.1,\Y) -- ++ (-0.2,0) node[left]{$\Y$}};
 \foreach \X [count=\Y] in {(6,2),(3,4)} 
 {\path  \X node(n\Y)[bullet,label=right:{$\X$}]{};
 \draw[thick,->]  (0,0) -- (n\Y);}
\end{tikzpicture}
\end{document}

enter image description here

Or

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[>=stealth,scale=0.5,line cap=round,
    bullet/.style={circle,inner sep=1.5pt,fill}]
 \draw[->] (-9,0) -- (9,0) node[right]{$x$};
 \draw[->] (0,-7) -- (0,7) node[above]{$y$};
 \draw foreach \X in {3,6}
  {(\X,0.1) -- ++ (0,-0.2) node[below]{$\X$}};
 \draw foreach \Y in {2,4}
  {(0.1,\Y) -- ++ (-0.2,0) node[left]{$\Y$}};
 \path (0,0) coordinate (O) 
    (6,2) node[bullet,label=right:{$(6,2)$}](A){} 
    (3,4) node[bullet,label=right:{$(3,4)$}](B){} 
    (O) edge[thick,->] (A) edge[thick,->] (B);
\end{tikzpicture}
\end{document}
2
  • Thank you for your help. This is indeed a very clean vector diagram. I see that there are two nodes (3, 4) and (6, 2). Is there a way to label these nodes as A and B? I labeled the origin node as "O" but I'm stuck on naming the tips of the vectors.
    – Sam
    Feb 15, 2020 at 7:11
  • @Sam I added an example in which the nodes carry the names A and B. It is also a slightly different approach as the first one.
    – user194703
    Feb 15, 2020 at 7:16
6

With the new version 3.02c of tkz-euclide (which I'm discovering for the occasion), you get this:

screenshot

Some explanations are given as comments in the code.

\documentclass{article}

\usepackage{tkz-euclide}
\usetikzlibrary{arrows.meta}
\begin{document}

\begin{tikzpicture}[vect/.style={->,>={Straight Barb[angle=60:2pt 3]}}]
\tkzInit[xmin=-3,xmax=6,ymin=-1,ymax=6]% dimensions of the bounding box
\tkzDrawXY[noticks,>=latex]% draw the 2 axis
\tkzDefPoint(0,0){O}
\tkzDefPoint(3,4){A}
\tkzDefPoint(6,2){B}
\tkzPointShowCoord[-,xlabel=$3$,ylabel=$4$,thin,gray,xstyle={below=4pt}](A)% show the coordonates
\tkzPointShowCoord[-,xlabel=$6$,ylabel=$2$,thin,gray,xstyle={below=4pt}](B)
\tkzDrawSegments[vect](O,A O,B)
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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