3

I drew this graph in Gimp. However, I wanted to draw this in the latex. Can you help me?

enter image description here

  • 1
    of course it is possible .... you need (i) select package for drawing (tikz, pstrick ...) (ii) make you familiar with them, (iii) start drawing and (i) if you stuck in this, ask for help here. welcome to tex.se! – Zarko Jan 13 '18 at 13:56
  • I suggest you look at this example and possibly other examples on the same site, then consult the TikZ manual (texdoc tikz) for more information. – Harald Hanche-Olsen Jan 13 '18 at 13:57

4 Answers4

3
\documentclass[crop,tikz]{standalone}

\usepackage{bm}
\usetikzlibrary{calc}
\usetikzlibrary{angles}
\usetikzlibrary{quotes}
\newcommand{\vect}[1]{\bm{#1}}

\begin{document}
\begin{tikzpicture}[outer sep = 3pt]
  % coordinates
  \coordinate (O) at (0, 0);
  \coordinate (X) at ($ (O) + (225:3) $);
  \coordinate (Y) at ($ (O) + (0:4) $);
  \coordinate (Z) at ($ (O) + (90:3) $);

  \coordinate (x) at ($ (O) + (70:3) $);
  \coordinate (x') at ($ (O) + (20:3.5) $);
  \coordinate (xnew) at ($ (x) - (x') $);

  % axis
  \draw[black, ->] (O) -- (X) node[below]{$x$};
  \draw[black, ->] (O) -- (Y) node[right]{$y$};
  \draw[black, ->] (O) -- (Z) node[left]{$z$};

  % particles
  \fill[gray] (x) circle (0.1) (x') circle (0.1);


  % vectors
  \draw[blue, thick, ->] (O) -- (x) node[left, midway]{$\vect{x}$};
  \draw[blue, thick, ->] (O) -- (x') node[right, midway]{$\vect{x}'$};
  \draw[red, thick, ->] (x') -- (x) node[right, midway]{$\vect{x} -
    \vect{x}'$};

  \draw[red, thick, ->] (O) -- (xnew) node[left, midway]{$\vect{x} -
    \vect{x}'$};

  \pic [draw = black, ->, angle eccentricity=1.5, "$\theta$"] {angle = Z--O--xnew};

\end{tikzpicture}
\end{document}

enter image description here

caverac
  • 7,931
  • 2
  • 15
  • 31
3

Most of the lines start at (0,0) and end with an arrow, edges are more suitable in this case. edges give you more control over color, line ending, etc. without repeating commands. They also allow labels with the aid of the quotes library. Labels syntax is quite different, though. They take the following syntax [<edge options> <"label"> <label options>].

\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{calc,angles,quotes,bending}
\usepackage{bm}
\begin{document}

\begin{tikzpicture}[>= latex, line width=.7pt]      
    \path (70:2.5) node (x) [circle,fill=gray,inner sep=1pt] {}
          (30:3.5) node (x')[circle,fill=gray,inner sep=1pt] {}
          (0,0) coordinate (o) (0,3) coordinate (z) (-2.5,.5) coordinate (xnew);

    \path[->] (o)  edge ["$y$" below, pos=1] (3,0) 
                   edge ["$z$" left, pos=1]  (z) 
                   edge ["$x$" left, pos=1]  (225:2)
                   edge [blue, "$\color{black}\bm{x}$" right] (x)
                   edge [blue, "$\color{black}\bm{x'}$" right] (x')
                   edge [red, "$\bm{x-x'}$" black,pos=.3,sloped] (xnew)
              (x') edge [blue] ++(0,10pt)
                   edge [red, "$\bm{x-x'}$" above,sloped] (x)
              (x)  edge [blue] ++(0,10pt);

    \pic [draw, ->, "$\theta$"] {angle = z--o--xnew};    
\end{tikzpicture}

\end{document}

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
1

A very easy way to do that is to draw it in GeoGebra (free software downloadable here: https://www.geogebra.org), then export it as TikZ and finally incorporate the TikZ figure into LaTeX (examples showing TikZ figures in LaTeX can be found here: https://en.wikibooks.org/wiki/LaTeX/PGF/TikZ). Probably do it by yourself directly into TikZ would give better outputs, but if you're not used to TikZ this will take you much more time then the GeoGebra option :)

bas
  • 133
1

as starting point, in case that you select tikz as drawing tool:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{angles, arrows.meta, quotes}
\usepackage{siunitx}
    \begin{document}
%%%% se-phasor
\begin{tikzpicture}[
            > = Straight Barb,
phasor/.style = {very thick,-{Stealth}},
angles/.style = {draw, <->, angle eccentricity=1,
                 right, angle radius=7mm}
                        ]
% coordinates
    \draw[->] (-0.5,0) -- (4,0) coordinate (x) node[below left] {$Re$};
    \draw[->] (0,-1.5) -- (0,2) node[below left] (y) {$Im$};
% phasors
    \draw[phasor] (0,0) -- (300:1.5) coordinate (i)  node[right] {I};
    \draw[phasor] (0,0) -- ( 30:2.5) coordinate (v)  node[right] {V};
% angles drawn by pic
\coordinate (X)   at (0,0);
\draw
    pic["$\theta=\phi-\SI{90}{\degree}$",angles] {angle=i--X--x}
    pic["$\phi$",angles] {angle=x--X--v}
    ;
\end{tikzpicture}
    \end{document}

(this is from one of my very old answer, now i'm not able to find it on site). of course it is not equal to your image (from which is bad copy, almost not visible).

enter image description here

Zarko
  • 296,517